refactor(t-paliad-195): drop legacy fields from Go service surface

Phase 3 Slice 9 Go cleanup. With mig 091's column drops live, the
service layer stops reading + emitting the legacy shape:

  - models.DeadlineRule: drop IsMandatory, IsOptional, ConditionFlag,
    ConditionRuleID fields. Comment block flags Slice 9 as the
    closeout slice.
  - DeadlineRuleService.ruleColumns: SELECT no longer enumerates the
    dropped columns. The post-Slice-9 schema is the live shape.
  - FristenrechnerService.UIDeadline: drops IsMandatory + IsOptional
    fields. Frontend reads `priority` directly post-Slice-8; the
    legacy emit was kept "for one release" and that release is now.
  - evalConditionExpr signature: drops the conditionFlag fallback
    param. NULL / "null" expressions return true (unconditional);
    the legacy text[] fallback was the only reason for the second
    param. New helpers hasConditionExpr + extractFlagsFromExpr fill
    the gaps (alt-swap guard + RuleCalculation.FlagsRequired list).
  - FristenrechnerService.Calculate + calculateByTriggerEvent +
    EventTriggerService.Trigger: switched to the new (single-arg)
    evalConditionExpr; alt-swap guard now uses
    hasConditionExpr(r.ConditionExpr) instead of the dropped
    len(r.ConditionFlag) > 0 check.
  - FristenrechnerService.CalculateRule: RuleCalculationRule.IsMandatory
    derived from priority via wireFlagsFromPriority (kept for the
    result-card panel TS contract). FlagsRequired walks the jsonb
    gate tree to enumerate {"flag":"X"} leaves (replaces the
    dropped condition_flag enumeration).
  - RuleEditorService.Create + CloneAsDraft INSERT statements:
    dropped is_mandatory / is_optional / condition_flag from the
    column lists. Live shape only.

Test fixtures (projection_service_test.go, rule_editor_service_test.go,
fristenrechner_test.go) all updated to write the live shape on
seed; the evalConditionExpr table-driven test dropped its legacy
fallback cases (the fallback no longer exists) and now exercises
20 pure-jsonb scenarios across AND/OR/NOT compositions.

The deadline_rule_service_test backfill assertion lost its
(is_mandatory, is_optional) bucket cross-check (those columns are
gone); the priority-non-NULL invariant still holds via the CHECK
constraint. condition_flag cross-check now joins the pre-mig-091
snapshot table (when present) instead of the live row.
This commit is contained in:
mAi
2026-05-15 17:53:31 +02:00
parent f9305d6108
commit 99a72a744f
5 changed files with 110 additions and 93 deletions

View File

@@ -162,6 +162,10 @@ func (s *RuleEditorService) Create(ctx context.Context, input CreateRuleInput, r
}
id := uuid.New()
// Slice 9 (t-paliad-195) dropped is_mandatory / is_optional /
// condition_flag / condition_rule_id from the schema. The INSERT
// here writes the live shape only — priority + condition_expr
// + is_court_set are the new gates.
if _, err := tx.ExecContext(ctx,
`INSERT INTO paliad.deadline_rules
(id, proceeding_type_id, trigger_event_id, parent_id, concept_id, code,
@@ -171,7 +175,7 @@ func (s *RuleEditorService) Create(ctx context.Context, input CreateRuleInput, r
rule_code, legal_source, deadline_notes, deadline_notes_en,
priority, is_court_set, is_spawn, spawn_label, spawn_proceeding_type_id,
condition_expr, sequence_order,
is_mandatory, is_optional, is_active,
is_active,
lifecycle_state, draft_of, published_at,
created_at, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, NULL, $9, $10,
@@ -180,7 +184,7 @@ func (s *RuleEditorService) Create(ctx context.Context, input CreateRuleInput, r
$19, $20, $21, $22,
$23, $24, $25, $26, $27,
$28, $29,
true, false, true,
true,
'draft', NULL, NULL,
now(), now())`,
id, input.ProceedingTypeID, input.TriggerEventID, input.ParentID, input.ConceptID, input.Code,
@@ -288,8 +292,8 @@ func (s *RuleEditorService) CloneAsDraft(ctx context.Context, id uuid.UUID, reas
alt_duration_value, alt_duration_unit, alt_rule_code, anchor_alt, combine_op,
rule_code, legal_source, deadline_notes, deadline_notes_en,
priority, is_court_set, is_spawn, spawn_label, spawn_proceeding_type_id,
condition_expr, condition_flag, sequence_order,
is_mandatory, is_optional, is_active,
condition_expr, sequence_order,
is_active,
lifecycle_state, draft_of, published_at,
created_at, updated_at)
SELECT $1, proceeding_type_id, trigger_event_id, parent_id, concept_id, code,
@@ -298,8 +302,8 @@ func (s *RuleEditorService) CloneAsDraft(ctx context.Context, id uuid.UUID, reas
alt_duration_value, alt_duration_unit, alt_rule_code, anchor_alt, combine_op,
rule_code, legal_source, deadline_notes, deadline_notes_en,
priority, is_court_set, is_spawn, spawn_label, spawn_proceeding_type_id,
condition_expr, condition_flag, sequence_order,
is_mandatory, is_optional, is_active,
condition_expr, sequence_order,
is_active,
'draft', $2, NULL,
now(), now()
FROM paliad.deadline_rules