Repository navigation
fix(control): keep a taken message open past expires_at so its final ack lands - #280
connorburgess wants to merge 3 commits into
Conversation
…ack lands
Symptom: a message the machine acked `taken` and was still delivering
was marked `expired` ("expired before the machine took it") once its
expires_at passed. The machine's final ack (e.g. `delivered` with its
reply) was then answered 202 but dropped, so the reply was lost.
Cause: expireQueue skipped only rows whose outcome was final. `taken` is
not final (CONTROL.md §10: the machine is delivering it and a final ack
follows), so the receiver overwrote it, and ack() ignores acks for rows
that are already final.
Fix: expireQueue leaves a taken row open for the taken pause
(TAKEN_PAUSE_MS, 35 minutes from takenAt, the window that already pauses
redelivery), and never longer than that past expires_at, since takenAt
is the machine's clock. A taken row with no final word by then is closed
`unconfirmed`, as remote.ts closes a job taken and never heard of again,
not `expired`, which says the machine never took it. The pool send note
counts a taken row as on its way past expires_at, and the orchestrate
comment that relied on the old expiry says when it now happens.
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>
|
The taken-message expiry and final acknowledgement fix still applies to SessionPipe GUI v0.8.18. Merged current Added the previously deferred Unreleased changelog entry. Validation on this head, macOS / Node 22.23.2:
GitHub CI run 47453783115 for head Also checked the combined source/test changes from all 19 refreshed PRs on the same main: no source conflicts; typecheck, lint and build passed; all 252 unit-test files passed (3,439 tests, two skipped). This was a local integration check, separate from the individual PR run above. Release-note entries may still need combining as PRs land. |
Updated against v0.8.18 / main
d16a2c01on 2026-12-05. Current validation and refresh details.What
A message the machine has acked
takenis no longer markedexpiredby the receiver when itsexpires_atpasses while the machine is still delivering it. The machine's final ack (for exampledeliveredwith its reply) is now applied instead of being dropped. If the machine ackstakenand then never sends a final ack, the row is closedunconfirmedonce the 35-minute taken pause is over. It is no longer closedexpiredwith the detail "expired before the machine took it".Why
expireQueue(server/control/state.ts) skipped only rows whose outcome was already final.takenis not final. CONTROL.md §10 says: "Not final. The machine verified the message and is delivering it; a final ack follows", and "Every message is acked exactly once with a final outcome, optionally preceded by taken". So a row ackedtakenthat ran pastexpires_at(default 1 h) was overwritten asexpired, with a detail meant for rows the machine never took. When the machine's final ack came in,ack()skipped it because the row was already final, while the response still said202 {applied: 1}. The reply was lost and the activity showed the message as never taken.The fix is limited to
expireQueue:takenAtstays open while it is inside the taken pause (TAKEN_PAUSE_MS, 35 minutes fromtakenAt). This is the window that already pauses redelivery indeliverable().expires_at.takenAtis the machine's own clock, so a clock running far ahead cannot keep a row open indefinitely.unconfirmedwith no code. This is the outcomeremote.tsalready uses for a job that was taken and never heard of again, and the page already words it ("No word from X since it took this").expiredwould claim the machine never took it.Two small follow-ons, because a taken row can now be open past
expires_at:web/src/control/usePoolSend.ts:onItsWaycounts atakenrow as on its way. Without this, the pool note would go blank betweenexpires_atand the final ack.server/orchestrate/index.ts: a comment that described the old expiry of taken rows now says when that expiry happens.Left as they are, on purpose:
expiredaftertakenstayexpired. A late final ack for one of them is still dropped, as before. Reopening receiver-expired rows would need a way to tell them apart from a machine's ownexpiredack, and the case only covers messages that were in flight during the upgrade.progressacks do not extend the pause. The 35-minute bound comes from §10.deliverable()readstakenAtthe same way today.expires_at(files.keepUntilinenqueue). This was already the case before this change.key.addrows still settle throughkeyAddSettledwhen they close. A taken key.add that never gets a final ack now settles the device request as failed with outcomeunconfirmed, notexpired.Shared file: #276 (
fix/config-utf16-bom) also changesserver/control/state.ts, in itswriteAtomicand machines-loading code near the top of the file. This change only touchesexpireQueue.git merge-tree --write-treeof this branch against #276's head (42e7a90) and againstorigin/main(6165bed) both finish without conflicts.Original proof (before the v0.8.18 refresh)
New test in
server/control/control.test.ts, "a message the machine has taken is not expired at expires_at; its final ack is kept". It sends a prompt withexpires_in_s: 60, the machine polls it and ackstaken, the clock moves 2 minutes forward, and the machine acksdeliveredwith a reply. The test also covers a taken row whose machine goes silent (closedunconfirmedafter the pause) and atakenack stamped 24 h in the future (closedunconfirmedonce the pause pastexpires_atis over).On
origin/main'sserver/control/state.ts(with the new test), it fails:On this branch:
npx vitest run server/control server/orchestrate web/src/control:npm run typecheck: passes, with no output from eithertscrun.npm run lint:The warnings and the info (biome.json's schema 2.6.8 against CLI 2.6.9) are in files this change does not touch.
npm test:An earlier full run on the first version of this commit had
server/control/remote.parity.test.tstime out at its 15 s limit. That file passed in every targeted run, and it passes in this full run.An entry is now included under Unreleased in
CHANGELOG.md. Other open PRs also add release notes; those entries may need combining as the PRs land.Checklist
git commit -s): the DCO is the only paperwork.npm run typecheck && npm run lint && npm testpass;npm run test:e2efor a UI change.npm run test:e2ewas not run: the only UI change is one condition inusePoolSend.ts.// SPDX-License-Identifier: Apache-2.0. (No new files.)--demo).shared/*names the wire-contract change in the description. (Noshared/*change.)CHANGELOG.md.