Skip to content

feat(receipts): chain every signed verdict as a receipt.v1 per tenant - #12

Open
PermutationResearch wants to merge 1 commit into
mainfrom
feat/sentinel-receipts
Open

PermutationResearch wants to merge 1 commit into
mainfrom
feat/sentinel-receipts

Conversation

@PermutationResearch

Copy link
Copy Markdown
Owner

Each signed verdict now also writes a receipt.v1 receipt into rep_receipt_chain, in the same transaction, chained per tenant. receipt.v1 is the shared decision-receipt format used by Company OS, Hearth and MailOps (HSM-II docs/company-os/RECEIPT_V1.md).

  • A verdict maps to gateway.verdict by service:sentinel, external: false, no approval. evidence is the verdict's payload_sha256.
  • The receipt hash is RFC 8785, with keys in code-point order, so it no longer depends on the machine's locale. The Ed25519 envelope is unchanged, so receipts already issued still verify.
  • A per-tenant advisory lock keeps seq/prev a single sequence. The table is append-only.
  • npm run receipts:export -- <tenant> prints the chain for HSM-II's scripts/receipt-verify.mjs.

Checks

  • test/receipt-v1.test.ts: the hash matches the HSM-II reference vector on French and non-BMP text. It fails when key sorting is removed.
  • A generated chain passes HSM-II's verifier: ok: 3 receipts, 1 chains, 0 problems.
  • npm run check passes.
  • npm test: 689–690 of 691 pass. auth lockout: repeated bad verify tokens trigger 429 also fails on main without this change. proxy: strips caller cookies fails intermittently.
  • Not run: npm run verify:receipts-postgres. It is extended here to check the chain, its order and the append-only refusal, but no isolated test database was available locally.

🤖 Generated with Claude Code

issueSignedReceipt now writes a receipt.v1 into rep_receipt_chain in the
same transaction as the signed verdict, under a per-tenant advisory lock.
The receipt hash is RFC 8785 (code-point key order), so it no longer
depends on the machine's locale; the existing Ed25519 envelope is
unchanged. A verdict maps to gateway.verdict by service:sentinel,
external false, no approval. `npm run receipts:export -- <tenant>` prints
the chain for HSM-II's scripts/receipt-verify.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants