Repository navigation
feat(feedback): freeze optional completion copies - #41
Conversation
Keep ordinary completion unchanged while letting a server-held feedback preview commit with completion as one D1 batch. The frozen copy is compared against the response answer revision, pinned definition, connector version and exact projection, so a save, connector change or withdrawal that wins first cannot produce a stale copy.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Keep bodyless authenticated completion as the explicit no-copy path while strictly validating supplied JSON. Compare the exact frozen projection, connector and generation again inside the completion batch, and reject damaged stored preview data before it can shape the payload.
xgame92
left a comment
There was a problem hiding this comment.
The authenticated bodyless no-copy path and the D1 outbox guards passed independent local checks on Node 24.11.0. All 64 existing feedback-copy, persisted completion, withdrawal, and SQL tests passed.
One completion retry case still fails. An authenticated request reads the open response. An identical request then commits and removes the preview. If the first request resumes and calls completionCopy after that commit, it returns 409 with feedback: stale before completeResponse rechecks the response's completion state. The outbox still contains exactly one row. The same completion request can therefore report failure even though the submission and copy committed.
I reproduced the ordering against the migrated local D1 database using the test Worker. Capture the open response row and pinned definition, complete through the API with the prepared preview, verify one outbox row and no remaining preview, then call completeResponse with the original open row and same preview ID. It rejects where the existing completion contract requires an idempotent success. The current parallel test does not force the preview lookup to lose this ordering.
Please route the preview refusal through a fresh check for the same authenticated response before returning stale, preserving refusal for a still-open response and preserving the withdrawal behavior. Add a deterministic test for that order and assert both the completion result and the single frozen outbox row.
Recheck the authenticated response when a feedback preview has just been cleared so a delayed identical completion can replay the stored success instead of reporting a false stale failure. Keep the stale refusal for a response that is still open and cover the losing order against migrated local D1.
|
Addressed at exact head
The new migrated-D1 regression forces the exact losing order: capture the open row and preview, complete the identical request through the Worker, verify the preview is gone, then resume the delayed request with the original open row and same preview ID. It succeeds and the single Validation at the pushed head:
Current |
xgame92
left a comment
There was a problem hiding this comment.
Re-reviewed exact head 99e193141de7456474ace692575faaba4a0a01c3 on current main. The earlier stale-preview race is resolved. The delayed identical completion now succeeds after the winning request commits, with exactly one unchanged outbox row. A superseded preview with a different projection still returns 409 while the response stays open. When withdrawal wins the same ordering, the delayed completion returns 404 and the outbox stays empty.
The local Windows run on Node 24.11.0 passed all five selected test files. Three targeted losing-order checks also passed independently on migrated local D1. Hosted workerd checks, Playwright, CLA, and the secret scan passed on this head.
|
Exact-head independent re-review of Decision: approve-equivalent. The race is closed in exactly the shape the review required, and I independently reproduced the suite: Delayed same-request replay — correct in Exactly one unchanged outbox row — the deterministic test is the reviewer's reproduction step for step: capture the open row and pinned definition, complete through the API with the prepared preview, assert one outbox row and zero remaining previews, then drive Genuine stale-open refusal intact — when the response is still open and the preview genuinely does not match (including the corrupted-generation case), the refusal survives: 409 with Withdrawal intact — the withdrawal-wins race still yields One observation, non-blocking: the replay path returns success to the loser without re-verifying that the committed copy matches the preview id the loser carried. That is correct under the completion contract — the winner was the same authenticated request carrying the same preview, and the outbox row is frozen at commit — but it is worth naming: idempotent replay here means "the completion you asked for happened", not "your exact copy attempt did". No change needed. |
|
Thanks for the exact-head re-review. No further changes are needed from my side; |
What and why
Part of the optional feedback-copy work in FRM-18. This adds the smallest server-held Forms foundation: a reviewed connector record, a response-scoped preview, and an immutable outbox row that commits with completion in one D1 batch.
Ordinary completion remains available as an authenticated bodyless POST when no copy is chosen; supplied JSON is strictly validated. When a preview is supplied, completion compares the server-derived
answer_revision, pinned definition hash, exact frozen projection, connector identity/version/generation, and form inside the batch. A save, connector change, stored-data change, or withdrawal that wins first cannot produce a stale copy. Exact completion retries remain idempotent through the response id key.The projected copy is limited to the declared choice or rating, the explicitly selected note, and declared static context. Detached answers, response credentials, browser credentials, network addresses and user agents are not projected. New previews supersede earlier previews under the same atomic guard so the response secret cannot accumulate preview rows without bound. Stored preview data is parsed back strictly, and server-owned payload envelope fields cannot be replaced by it.
This slice intentionally does not send anything to Track, provision or activate real grants, rotate keys, or include a sender claim/retry worker. The plaintext connector
generationis server-held fixture authority only so the exact frozen payload can be tested; production provisioning and sealing remain later slices.How it was tested
pnpm verifypasses on exact head6df5ad646c2dd4f8835d9a8bafca79060bf1c0cf.pnpm test:e2epasses on the same tree: 174 passed, 8 skipped.390 px:
320 px:
pnpm verifypassespnpm test:e2epassesDeploy notes