PR A: 12-state transaction machine + issueInstrument step + SoD matrix #5
Reference in New Issue
Block a user
Delete Branch "devin/1776874611-instrument-leg-state-machine"
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?
Implements steps 1, 2, 10 from the architecture gap-analysis (the data-model PR that unblocks B-G).
What lands
orchestrator/src/types/transactionState.ts— the 12 states from arch note §8.1 + the full transition table from §9.1 + segregation-of-duties matrix (§13). Both the coordinator and the DB CHECK constraint read from this file.orchestrator/src/types/plan.ts— adds'issueInstrument'toPlanStep.typeand a newInstrumentTermsinterface modeled on the Emirates Islamic SBLC / MT760 template (applicant, issuingBankBIC, beneficiaryBankBIC, beneficiaryName, beneficiaryAccount, amount, currency, tenor, expiryDate, placeOfPresentation, governingLaw, templateRef, templateHash).orchestrator/src/services/planValidation.ts— newissueInstrumentvalidator: required fields, ISO-4217 currency, BIC format (8 or 11 chars), YYYY-MM-DD expiry, sha256 templateHash, amount > 0.orchestrator/src/services/stateMachine.ts—transition()enforces legality + segregation-of-duties (checks the transition log for the prior gated actor) + appends to the append-only table, atomically.orchestrator/src/db/migrations/002_transaction_state.ts—plans.transaction_state(default'DRAFT', CHECK-constrained to the 12 values) +transaction_state_transitions(id, plan_id, from_state, to_state, reason, source_event_id, actor, actor_role, signature, created_at).tests/unit/transactionState.test.ts(13 tests — every legal edge, illegal edges, CLOSED-is-terminal, SoD matrix) +tests/unit/planValidation.instrument.test.ts(8 tests — happy path + 7 negative cases). 31 tests, all passing.What this PR does NOT change
ExecutionCoordinatorstill runs the legacy 4-phase path and writes the oldpending|complete|abortedstatus. PR B refactors the coordinator onto the new machine + adds theVALIDATINGphase.GET /plans/:id/statelands with PR D alongside the event bus).Verification
Next in the series
Part of the gap-analysis at
/home/ubuntu/review/CurrenciCombo-architecture-gap-analysis.md.