Skip to content

fix(storage): preserve consumed acceptance quarantine (#90) - #91

Merged
OBenner merged 1 commit into
mainfrom
fix/90-quarantine-fifo
Nov 16, 2026
Merged

OBenner merged 1 commit into
mainfrom
fix/90-quarantine-fifo

Conversation

@OBenner

@OBenner OBenner commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Releasing quarantine could remove the marker of a submitted message whose one-message acceptance allowance was already consumed. The message stayed submitted, became a permanent FIFO blocker, and could not be reset by lease reaping.

Preserve quarantine for those consumed submissions. Ordinary quarantined deliveries still return to stored with cleared claims, while delivered/acked quarantine entries can be cleaned up. The shared cleanup runs in the existing transaction in both releaseQuarantinedDeliveries and SessionStore.register. The latter duplicated the defect and is the actual production reconciliation path; the explicit helper currently has no production callers. Later FIFO mail can progress without retrying the consumed message or fabricating delivery/read receipts. No schema, session/wire contract or v1 envelope changes.

The secondary audit confirms that claim-free inbox acknowledgement is intentional under v1 section 3, with project/recipient checks in storage and writer proof in RelayService. setDeliveryState and resetSubmittedForRetry already require project scope and have only test call sites; their internal setup purpose is documented. Details: docs/storage-delivery.md.

Validation: five new regression cases (three failed against the original code, including both release paths and database reopen); all 64 targeted storage tests pass. Full pnpm verify: 105 test files / 907 tests, format/import/typecheck/build all pass. Coverage includes actual subsequent delivery claims, durable consumption/quarantine across restart/reaping, repeated release, acknowledgement cleanup and project/recipient isolation.

Limitation: this preserves existing quarantine markers; it does not infer or repair already-unquarantined submissions on a live stand. Those require explicit reconciliation using real delivery/read evidence. No live database or runtime changes were made.

Fixes #90. Review: dev → CTO.

@OBenner

OBenner commented Nov 16, 2026

Copy link
Copy Markdown
Owner Author

Review (dev) — ACCEPT

Reviewed the full diff locally before the push (preliminary ACCEPT) and re-verified the published PR — identical after the rebase onto 254c48d (docs-only upstream change).

Correctness. The shared clearReleasedQuarantine guard is exactly right: after the preceding submitted → stored reset for non-consumed rows, the only remaining submitted rows are consumed-acceptance ones, and the NOT EXISTS keeps their quarantine marker; delivered/acked rows lose theirs. Both production-relevant paths (explicit release helper and SessionStore.register) now share the policy, inside their existing transactions, project/recipient-scoped. No state-machine, schema, session/wire or v1 changes.

Semantics. Consumed one-message allowance is never restored — no silent retry, no fabricated delivery/ack; ordinary quarantine returns to stored with claims cleared. Fail-safe direction throughout, matching the issue's required behavior.

Tests. 5 new regression tests reproduced the failure pre-fix (3 RED) and pass post-fix; independently re-ran the suite here (5/5). Coverage matches the claims: both paths, FIFO progression with real claimNextDelivery, repeated release, lease reaping, DB reopen, allowance non-reuse, project/recipient isolation.

Docs. docs/storage-delivery.md is precise about the invariant, the intentional claim-free ack (v1 §3), the internal-only mutators, and — importantly — the honest limitation: already-orphaned submitted rows on live stands are not guessed back; they need evidence-based reconciliation.

Verification. Author's full pnpm verify: 105 files / 907 tests; CI 3/3 on 3e65f08.

Passing to CTO for final.

@OBenner
OBenner merged commit 1d93b22 into main Nov 16, 2026
3 checks passed
@OBenner
OBenner deleted the fix/90-quarantine-fifo branch November 16, 2026 15:16
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.

releaseQuarantinedDeliveries can leave a submitted message without quarantine → permanent FIFO block of the recipient queue

1 participant