Phase 19 (F5a): IMDG dangerous-goods declarations + shore-pass/crew-change lifecycle - #54
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 19 Wave B — F5a scenario-gap implementation (audit A5-scenario-matrix §B9/§C5, both rated feasible on existing schema).
A5-B9 — IMDG dangerous-goods declarations
server/_core/imdg.ts: local structural IMDG validation — UN number format/range (0004–3550), class/division membership (1.1–9, 20 codes), packing-group I–III applicability per class (allowed: 3, 4.x, 5.1, 6.1, 8, 9), class-3 flashpoint required/bounded, EmS fire/spillage schedule shapes. No substance database is shipped or fabricated.server/routers/dangerousGoods.ts:addItem/removeItem(owner-only, frozen once declaration cleared, audited vialogAuditEvent),listForDeclaration(owner or officer),officerBoard(officer view surfacing DG-flagged declarations with their items). DG flag is derived (existence of ≥1 DG item — never stored, never stale).lookupalways fails closed withIMDG_CODE_LOOKUP_NOT_CONFIGURED— honest state since licensed IMDG Code data is not configured.declaration_dg_items(FK declarations/users, CHECK constraints), hand-written minimal delta + journal entry (0069/0070 precedent).A5-C5 — Shore-pass / crew-change lifecycle
server/data/imoMapping/v1/fal5.json) and the port-interop seafarer/STCW registry (blueeconomy-port-interoperability internal/registry/seafarer.go), consumed via new config-gatedserver/_core/seafarerRegistryClient.ts(GET /v1/registry/certificates/verify, typed classified errors, call-time config).server/routers/shorePass.ts:submit→ officerverifyCertificate→decide(approve/reject) →revoke/ expiry (lazy at read +expireSweep). Approval is verification-gated fail-closed: cert-bearing applications requireVERIFIED;FAILED/NOT_CONFIGUREDcan never be approved. Honest states when upstream crew data is not configured:CREW_REGISTRY_NOT_CONFIGURED/CREW_REGISTRY_UNAVAILABLE, recorded durably on the application. Append-onlyshore_pass_eventsaudit trail on every transition.shore_pass_applications+shore_pass_eventswith CHECK constraints and indexes.Notes
drizzle/schemaDgShorePass.ts(NOT the centraldrizzle/schema.ts) to avoid conflicts with concurrent workstreams.dangerousGoods/shorePassin the PRA-109 permify coverage gate exempt list (owner-scoped writes, in-router officer enforcement — aeoFastLane/queuePolicy precedent).server/routers.ts.submit(notapply) —applyis a tRPC reserved router key.Tests
server/_core/imdg.test.ts(29),server/routers/dangerousGoods.test.ts(10),server/routers/shorePass.test.ts(18+5 table-driven) — 62 tests, all green; plusserver/testutils/mockDrizzleDb.ts(condition-evaluating drizzle chain mock).tsc --noEmitclean.