Deadline-rule primitives: working_days unit, combine=max, multi-anchor, outer-cap, before-mode backward snap (Wave 2) #103
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why this issue exists
m's 2026-05-25 15:29 steer: "we prefer the good and solid approach over a quick fix. We want the full solution". This overrides the (R) defer on §9 Q2/Q3/Q4 of curie's audit (docs/research-deadlines-completeness-2026-05-25.md) — we BUILD the primitives instead of documenting workarounds.
Without these primitives, at least 8 RoP/EPC rules cannot be modelled accurately (R.198, R.213, R.245.2, R.320, EPC Art.112a, R.109.1, R.109.4, R.131.2).
Scope — Tier 3 primitives (curie's §10 Tier 3)
Primitive 1 —
duration_unit = 'working_days'Adds a business-day arithmetic path to the deadline calculator. Counts only Mon–Fri minus court holidays from
paliad.gerichte/ public holiday tables.paliad.deadline_rules.duration_unitalready accepts string; verify enum / check constraint. Add'working_days'to allowed set if not present.internal/services/deadline_calculator.go(or similar) — whenduration_unit='working_days', walk forward N business days from the anchor.Primitive 2 —
combine_op = 'max'When a rule has two anchors (
primary_anchor+secondary_anchor),combine_opdecides how to combine:min— earliest of the two end dates (current behavior for some rules)max— latest of the two end dates (NEW)Schema: column
combine_op textmay exist per pauli's 2026-05-13 audit observation — verify. If not, add as nullable with defaultNULL(= single-anchor, no combine).Service: extend the projection to handle two anchors + the combine_op.
UI: render combined dates correctly in the timeline.
Primitive 3 — Multi-anchor "whichever later" trigger
Some rules anchor on the later of two user-supplied dates (e.g. R.245.2.a/b: 2 months from final decision OR defect discovery, whichever later).
paliad.deadline_rulesgainssecondary_trigger_event_id, plus the newcombine_opfrom Primitive 2.paliad.deadline_anchorsmay need to support multiple rows per (project, rule) — verify.Primitive 4 — Outer-cap modelling
Some deadlines have a fixed outer cap regardless of trigger (e.g. R.245.2 + R.320 + EPC Art.112a — all 12 months from a different anchor than the per-case 2-month period).
outer_cap_value int,outer_cap_unit text,outer_cap_anchor_event_idcolumns onpaliad.deadline_rules.Primitive 5 — Backward
timing='before'mode + snap-to-working-dayRules that anchor BACKWARDS from a future event (e.g. R.109.1 = 1 month BEFORE oral hearing, R.109.4 = 2 weeks BEFORE oral hearing). Schema supports
timing='before'but no rule populates it AND the calculator doesn't have a backward path.timing='before', subtract the period from the anchor. Snap result to the nearest preceding working day if it falls on weekend/holiday.Primitive 6 — Wiedereinsetzung backward-from-missed-deadline arithmetic (Q4 BUILD)
m's call: build the calendar arithmetic for PatG §123 / R.320 Wiedereinsetzung. The 2-month period anchors on the missed deadline AND a 1-year outer cap from the missed deadline.
Wiedereinsetzung-Fristchip on overdue deadlines (only when the rule allows it — UPC R.320, PatG §123, ZPO §233).Cross-proceeding spawn execution (Q9 / Q13 — full wire)
m's Q9 (wire
is_spawnfromupc.inf.cfi.decision→upc.dmgs.cfi.app) + Q13 (cross-proc spawn end-to-end) require:is_spawn=truerule fires (its anchor lands), AUTO-CREATE a sibling project of the target proceeding_type, link it viaspawn_from = source_project.id, and seed its deadlines.Slice plan
upc.pi.cfi.merits_startwhich is blocked on working_days). Pure data, runs after the primitives compile.Hard rules
-- per docs/research-deadlines-completeness-2026-05-25.md Tier 3 Primitive N.go build ./... && go test ./internal/... && cd frontend && bun run buildclean.mai/<worker>/wave2-tier3-primitives-slice-<a/b/c/d>.Out of scope
Reporting
mai report completedper slice with branch + SHAs + migration slot + which primitives shipped + which Tier-1 rule additions are now unblocked.