fix(litigationplanner): respect trigger_event_id + suppress optional from default (yoUPC#178 + #2568/#2570)
Some checks failed
Paliad CI gate / build (push) Has been cancelled
Paliad CI gate / test-go (push) Has been cancelled
Paliad CI gate / deploy (push) Has been cancelled

Two paired engine semantics fixes:

1. trigger_event_id is now the authoritative semantic anchor. When a
   rule carries trigger_event_id, the engine no longer falls back to
   the proceeding's trigger date — it resolves the anchor via
   CalcOptions.TriggerEventAnchors keyed by paliad.trigger_events.code.
   Missing anchor renders the rule as IsConditional (empty date) and
   propagates via courtSet so descendants also surface as conditional.
   Fixes the RoP.109.5 bug where the engine fabricated a date 2 weeks
   before the user's SoC instead of waiting for the oral_hearing date.

2. priority='optional' rules are suppressed from the default
   Calculate output. Callers (paliad /tools/procedures,
   youpc.org/deadlines) opt in via CalcOptions.IncludeOptional=true to
   restore the legacy "show optional applications" behaviour. The
   suppression cascades through skippedIDs so child rules drop too.

Wire shape additions:

  - CalcOptions.IncludeOptional bool
  - CalcOptions.TriggerEventAnchors map[string]string
  - Timeline.RulesAwaitingAnchor int (count of suppressed-by-missing-
    anchor rules, for caller telemetry / "N rules need an anchor" UX)

Existing before-court-set-anchor tests opt in to IncludeOptional=true
to preserve their non-optional-related test intent.

Refs: youpcorg/head delegations #2568 + #2570, m/paliad#153 (Litigation
Builder PRD path).
This commit is contained in:
mAi
2026-05-28 00:04:30 +02:00
parent 1844df3ae6
commit 3c840c0366
4 changed files with 505 additions and 16 deletions

View File

@@ -334,6 +334,25 @@ type CalcOptions struct {
// filter applied) so a stale frontend chip doesn't break the
// timeline render — see IsValidAppealTarget.
AppealTarget string
// IncludeOptional surfaces rules with priority='optional' in the
// default timeline (t-paliad-342 / youpcorg#2570). Default false:
// optional rules don't auto-fire alongside mandatory ones. The
// caller (paliad /tools/procedures, youpc.org/deadlines) wires this
// to a user-facing "show optional applications" toggle.
IncludeOptional bool
// TriggerEventAnchors supplies concrete dates for procedural events
// referenced by rules' trigger_event_id (t-paliad-342 / youpcorg#2568).
// Key = paliad.trigger_events.code (e.g. "oral_hearing"), value =
// YYYY-MM-DD. When a rule carries an explicit trigger_event_id, that
// catalog event is the authoritative semantic anchor: arithmetic
// resolves against TriggerEventAnchors[code] if set, otherwise the
// rule is suppressed as IsConditional (no fabricated date off the
// user's trigger date). Empty map = engine never anchors on a
// trigger event, so every rule with trigger_event_id surfaces as
// conditional.
TriggerEventAnchors map[string]string
}
// ProjectHint scopes a Catalog call to a specific project. Paliad's
@@ -375,6 +394,13 @@ type Timeline struct {
TriggerEventLabel string `json:"triggerEventLabel,omitempty"`
TriggerEventLabelEN string `json:"triggerEventLabelEN,omitempty"`
HiddenCount int `json:"hiddenCount"`
// RulesAwaitingAnchor counts rules suppressed because their
// trigger_event_id anchor date wasn't supplied via
// CalcOptions.TriggerEventAnchors (t-paliad-342). Such rules still
// render in the timeline as IsConditional (no date) — the field
// gives the caller a single integer for "N rules waiting on an
// anchor" UI affordances + telemetry.
RulesAwaitingAnchor int `json:"rulesAwaitingAnchor,omitempty"`
}
// TimelineEntry matches the frontend's CalculatedDeadline TypeScript