PR B: VALIDATING phase + unified ExceptionManager (arch steps 3, 7) #6
Reference in New Issue
Block a user
Delete Branch "devin/1776875351-validating-exception-manager"
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 3 and 7 from the architecture gap-analysis. Stacks on PR A.
What lands
services/exceptionManager.ts(new)One file, one taxonomy. Architecture note §12 collapsed into
ExceptionClass = 'timing' | 'data' | 'control' | 'business' | 'system'+ the 18 fine-grainedExceptionCodes. Factory helpers (Timing.dispatch,Data.valueMismatch,Control.unauthorized,Business.manualStop, …) keep call sites short and self-documenting.classify(err)normalises anything into aSettlementException, androute()is a deterministic table:errorRecovery)handle()is the single entry point callers should use — it does classify → route → retry-or-DLQ and returns the decision so the coordinator can still decide to abort.services/execution.ts(refactored, 68% rewrite)ExecutionCoordinator.executePlannow drives the full 12-state machine throughstateMachine.transition():New
validatePhase()(arch §9.2) reconciles before COMMIT:0x+ 64 hex)issueInstrumentstep amount > 0Mismatches raise
Data.valueMismatch(mismatches)and the machine transitions toABORTED. SoD-gated edges use distinct default actors (system-approver,system-releaser,system-validator) so the matrix in PR A stays satisfied; production callers pass real identities via the newactorsparam.api/plans.ts+index.tsNew
GET /api/plans/:planId/statereturns{ transaction_state, legacy_status, transitions: [...] }— the full audit chain from thetransaction_state_transitionstable (arch §14).Tests
tests/unit/exceptionManager.test.ts— 14 cases covering the four-class taxonomy,classify()idempotence, and every routing-matrix edge.Verification
Not in this PR
NotaryRegistry.finalizePlan()still calls the mock — PR C wires the real contract.errorHandler.ts,errorRecovery.ts,deadLetterQueue.ts,gracefulDegradation.tsleft in place; ExceptionManager consumes them rather than replacing them, so HTTP error middleware is unchanged.Series order
A → B → C → D → E → F → G → H.