mirror of
https://github.com/block/buzz.git
synced 2026-10-30 05:51:46 +00:00
A denied core lifecycle receipt (outcome_code = 2) requires zero events
of the mapped success-transition kind. The previous blanket RETURN NULL
for outcome_code NOT IN (1, 3) let a denied receipt commit alongside its
mapped success-transition event, creating contradictory durable ledger
facts: denial plus enrolled/retired/revoked/rotated.
Replace the early return with a three-way branch in
authorization_operation_receipt_event_guard_v1():
outcome_code IN (1, 3) — exactly-one mapped event (unchanged)
outcome_code = 2 — zero events of the mapped transition kind;
raises authorization_denied_lifecycle_receipt_no_success_event
other — skip (not a core lifecycle outcome)
Both deferred trigger directions share the same function body; a single
transaction with both INSERT paths exercises both directions at COMMIT.
The new negative fixture inserts a denied enroll receipt plus its mapped
success-transition event (event_kind = 1) in one transaction and asserts
COMMIT rejection with the exact constraint name.
Mutation: stashing the ELSIF branch lets COMMIT succeed, so expect_err
panics — confirming the branch is load-bearing (verified red).
Also correct three stale doc comments:
- Remove the "COMMIT succeeds" claim in the attempt-side shape guard
mutation note; accurately state the pre-existing semantic-binding
constraint fires instead.
- Remove the false claim that denial-attempt/admission-result tests
protect applied/no-op lifecycle; replace with accurate coverage note.
- Update the semantic_fingerprint column comment to distinguish
unresolved pre-auth kind-9 (actor_kind = 4) from authenticated kind-9
(actor_kind 1-3).
All changes byte-mirrored between migration 0042 and schema/schema.sql.
All 9 NIP-FI ignored PostgreSQL regressions pass (--test-threads=1).
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Hayt <9e1c23a3fd83f61da34420e4e88ff1b16e45cafcc0cd9019eb07d4ecfa8ca9b0@buzz.block.builderlab.xyz>