Skip to content

Exercise a fenced Forms feedback outbox sender - #43

Merged
xgame92 merged 2 commits into
mainfrom
feat/frm19-frozen-outbox-dispatch
Dec 4, 2026
Merged

xgame92 merged 2 commits into
mainfrom
feat/frm19-frozen-outbox-dispatch

Conversation

@xgame92

@xgame92 xgame92 commented Dec 4, 2026

Copy link
Copy Markdown
Member

What and why

Add a bounded dispatcher for the feedback copy created by FRM-18. It preserves the approved grant generation, reference and HTTPS origin from the server-held preview. The preview write and completion each verify the same authority inside their D1 batch. The dispatcher sends the stored bytes under a fenced lease and validates the protected Track receipt before treating a delivery as accepted.

The fixture suite covers uncertain delivery followed by replay, withdrawal on each side of a claim, same-version authority rotation, rejected redirects, retry limits and legacy previews. A preview from before migration 0018 must be prepared again before sharing. People can still complete without sharing a copy.

Verification

  • Windows pnpm verify passed, including 587 web tests.
  • Windows Chromium pnpm test:e2e passed 174 tests with eight existing skips.
  • Drizzle Kit independently regenerated the same SQL and schema snapshot from current main migration 0017. Migrated local D1 runs the outbox fixtures against a synthetic receiver.
  • The staged changes passed gitleaks 8.30.1.

Deployment scope

The dispatcher has an injectable fixture transport. A production caller, cron, grant and delivery remain separate work. Migration 0018 is scoped to this PR. The embed draft #28 will regenerate its independent migration after the first schema merge.

FRM-19 · Track receipt contract

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Exact-head independent review of 3ad7bfc8b8d6979a4a9e09f9997ecd4bd51dfa5f (FRM-19; independent model family; read-only review — head and draft unchanged, nothing merged or deployed).

Decision: approve-equivalent. Scoped findings:

Preview authority read/commit. prepareFeedbackPreview reads answers inside a before/after revision fence with bounded retries and refuses on any drift or completion; the stored preview binds every authority input — connector version, generation, grant reference, approved origin, definition hash, answer revision — so completion can only ever use the exact copy the page showed.

Completion fencing. completionCopy re-verifies all of those bindings against the live connector and response, strict-parses the frozen projection (closed key set, per-field type/length/well-formedness, exactly one of choice/rating), and — the important invariant — appends server-owned envelope fields last, so even a damaged stored projection cannot overwrite kind, generation, deliveryId or sentAt. Unicode well-formedness and null-byte rejection mean user text only travels when SQLite can return it unchanged.

Transport byte preservation and same-origin use. The frozen payloadJson is handed to the transport verbatim, never re-serialized. The destination is pinned to the approved origin three ways (config origin, connector origin, row origin), https-only with no userinfo; redirects are never followed (redirect: "manual" plus explicit 3xx/redirected detection as permanent failure), so the bearer cannot leak cross-origin.

Receipt validation. Strict shape — state: "open", filed: true, issue either a strict key/url object or null — and anything else is receipt-invalid (transient): correct, because an unparseable acceptance is genuinely ambiguous, and replay safety rests on the delivery id rather than response inspection.

Lease and Retry-After. Claims are lease-bound (30s) with the transport bounded by remaining lease via AbortController; Retry-After is honored in both numeric and HTTP-date forms, floored at now, applied only to 429/408/5xx; exponential backoff is capped by the seven-day window and three-attempt ceiling.

Withdrawal / concurrent claim / replay. The claim is a conditional write; a withdrawal or deletion committing after the claim is caught by the pre-send re-read (the comment is honest that an in-flight send cannot be recalled); authority is re-verified immediately before send, including that the response is still completed; all finishing writes are claim-id-conditioned, so a stale worker cannot overwrite a newer lease or terminal state.

Privacy of diagnostics. Terminal codes are a fixed enum; transport errors are deliberately never inspected because they can carry the bearer or payload; receipt bodies are never persisted. Nothing user-controlled reaches a log or a stored diagnostic.

Non-blocking observation: the window-expired path's counts.skipped += changed ? 0 : 1 double-entry bookkeeping is correct but subtle enough to deserve a one-line comment. Nothing material found.

@xgame92
xgame92 marked this pull request as ready for review December 4, 2026 02:01
@xgame92
xgame92 merged commit 97e1927 into main Dec 4, 2026
6 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant