Merge: Slice B.5 — Go type aliases (SequencingRule = DeadlineRule) + JSON envelope dual-emit + Deprecation headers (m/paliad#93)
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

This commit is contained in:
mAi
2026-05-26 20:08:43 +02:00
4 changed files with 183 additions and 10 deletions

View File

@@ -10,12 +10,24 @@ import (
"mgit.msbls.de/m/paliad/internal/models"
)
// DeadlineRuleService reads paliad.deadline_rules + paliad.proceeding_types.
// Rules are static reference data; no visibility check needed.
// DeadlineRuleService reads paliad.deadline_rules_unified (mig 139 view
// projecting paliad.sequencing_rules + procedural_events +
// legal_sources back to the legacy column shape after mig 140 dropped
// the underlying table) + paliad.proceeding_types. Rules are static
// reference data; no visibility check needed.
type DeadlineRuleService struct {
db *sqlx.DB
}
// SequencingRuleService is the Slice B.5 (t-paliad-305) canonical name
// for DeadlineRuleService. Alias preserves every existing call-site
// while new code can adopt the procedural-event vocabulary.
type SequencingRuleService = DeadlineRuleService
// NewSequencingRuleService is the canonical constructor name; alias to
// NewDeadlineRuleService for now. Both return the same underlying type.
var NewSequencingRuleService = NewDeadlineRuleService
// NewDeadlineRuleService wires the service to the pool.
func NewDeadlineRuleService(db *sqlx.DB) *DeadlineRuleService {
return &DeadlineRuleService{db: db}

View File

@@ -76,7 +76,13 @@ type RulePatch struct {
NameEN *string `json:"name_en,omitempty"`
Description *string `json:"description,omitempty"`
PrimaryParty *string `json:"primary_party,omitempty"`
// EventType is the legacy JSON key; EventKind is the Slice B.5
// canonical name. Decoder accepts either — coalescePatchKeys()
// resolves the canonical to the legacy field if only EventKind
// was sent. Same uuid wire shape; emit-side wraps via
// adminRuleResponse to expose both keys for one slice.
EventType *string `json:"event_type,omitempty"`
EventKind *string `json:"event_kind,omitempty"`
DurationValue *int `json:"duration_value,omitempty"`
DurationUnit *string `json:"duration_unit,omitempty"`
Timing *string `json:"timing,omitempty"`
@@ -101,6 +107,24 @@ type RulePatch struct {
ConceptID *uuid.UUID `json:"concept_id,omitempty"`
}
// CoalesceCanonicalKeys folds the Slice B.5 (t-paliad-305) canonical
// JSON aliases into the legacy field positions so the rest of the
// service can keep using the existing field names. Canonical wins
// when both are sent.
//
// json:"event_kind" → EventType (legacy)
//
// Called by the handler immediately after json.Decode. New code can
// adopt the canonical naming; legacy callers continue to work.
func (p *RulePatch) CoalesceCanonicalKeys() {
if p == nil {
return
}
if p.EventKind != nil {
p.EventType = p.EventKind
}
}
// CreateRuleInput is the create payload — a full rule row in draft
// state. Required fields enforce schema NOT-NULL on insert (name,
// name_en, duration_value, duration_unit).
@@ -111,9 +135,16 @@ type CreateRuleInput struct {
TriggerEventID *int64 `json:"trigger_event_id,omitempty"`
ParentID *uuid.UUID `json:"parent_id,omitempty"`
ConceptID *uuid.UUID `json:"concept_id,omitempty"`
// SubmissionCode is the legacy JSON key; Code is the Slice B.5
// canonical name. Decoder accepts either — CoalesceCanonicalKeys()
// folds Code → SubmissionCode if only the canonical was sent.
SubmissionCode *string `json:"submission_code,omitempty"`
Code *string `json:"code,omitempty"`
PrimaryParty *string `json:"primary_party,omitempty"`
// EventType is the legacy JSON key; EventKind is the Slice B.5
// canonical name. Same dual-accept pattern as SubmissionCode/Code.
EventType *string `json:"event_type,omitempty"`
EventKind *string `json:"event_kind,omitempty"`
DurationValue int `json:"duration_value"`
DurationUnit string `json:"duration_unit"`
Timing *string `json:"timing,omitempty"`
@@ -135,6 +166,24 @@ type CreateRuleInput struct {
SequenceOrder int `json:"sequence_order"`
}
// CoalesceCanonicalKeys folds the Slice B.5 (t-paliad-305) canonical
// JSON aliases into the legacy field positions. Canonical wins when
// both are sent. Called by the handler immediately after json.Decode.
//
// json:"code" → SubmissionCode (legacy)
// json:"event_kind" → EventType (legacy)
func (in *CreateRuleInput) CoalesceCanonicalKeys() {
if in == nil {
return
}
if in.Code != nil {
in.SubmissionCode = in.Code
}
if in.EventKind != nil {
in.EventType = in.EventKind
}
}
// Create inserts a new rule as lifecycle_state='draft' with
// published_at=NULL. The caller's reason is set on the session BEFORE
// the INSERT so the mig 079 trigger writes an audit row with the