Serialize response-policy grant closure and receipt commits
Adds the proposed HTTP contract and an unmounted PostgreSQL adapter for grant closure versus receipt commit. Both use a shared grant lock and check current service delegation and typed-subject binding. Only disposable test DDL is included.
On a private local PostgreSQL 15 cluster, two race cases passed with zero skips. Both observed a real lock wait. Closure-first produced zero receipts/outbox entries; receipt-first preserved one of each. Closure replay after ownership loss refused. Targeted strict TypeScript check passed. Transport authentication, authoritative binding lifecycle, physical expiry and HTTP release remain open.
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Adds the proposed HTTP contract for response-policy grant closure and an unmounted PostgreSQL adapter that serializes closure and receipt commits under a shared grant lock.
- Both paths verify the caller's current service delegation and typed-subject binding under the same
FOR UPDATE/FOR SHAREgrant lock, now narrowed to the typed subject, so an unrelated grant row can't block work. - Closure first leaves zero receipts and outbox entries; receipt first preserves one of each.
- Repeated closure of the current generation succeeds idempotently; the same scoped
operationIdwith different input returnsoperation_conflict, a different current generation returnsstale_generation, and closure after binding loss is refused. - Credential authentication, binding retirement, physical expiry, and the HTTP release boundary are not mounted; the code accepts an already verified publication key and digest, and the included DDL is disposable test schema only.