Repository navigation
fix(native-chat): settling earlier sends after a restart no longer blocks starting a chat - #26577
brennanb2025 wants to merge 6 commits into
Conversation
…ocks starting a chat After a restart, starting or resuming a chat first settled the status of sends from the previous run, and a failed settlement write failed the start. Settlement is now best effort: unconfirmed sends keep showing as unconfirmed and keep their replay protection, the failure is logged and retried later, and the user's start proceeds. Co-Authored-By: OpenAI Codex gpt-6.1-sol <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rovably starts before it A send whose verdict failed to save stays unconfirmed; a later turn can move the resume point the next restart reads from past it, and that history then reads the delivered send as never sent. The reconciler now rejects an absent send only when it was handed over at or after the fence of the owner that last moved that resume point (derived from the record's chain head and the journal fold); otherwise it stays unconfirmed. Presence still settles it. Also: settlement failures are injected at the SQLite transaction in tests and checked on disk; re-attaching to a running agent keeps it when a settlement fails; docs on what a failed settlement leaves now say what is true.
…last moved Round-1 dated the start from the chain head, but every later acquisition re-proves an unmoved resume point as a new link, so one undecided attach left a truly undelivered send unconfirmed forever. The start is now the first of the trailing links that carry the head's handle, leaf included. The same owner can also move the point past a send it handed over (a turn end after an unrecorded accept), so at an equal fence the reconciler now rejects only when the point moved strictly before the handover on that owner's clock; a tie stays unconfirmed. attachJournal no longer samples history itself (only tests did, from the post-acquisition record); callers pass the sampled window.
… and time together A send handed over twice (legacy rows) paired its first handover's fence with its last handover's time. Both now come from one derived firstHandover. Also drop a writer comment about a pending retry path that no longer exists.
|
Closing as superseded by merged #30580 (6059a5f). I compared the complete production diff and all eight test changes. This PR makes provider-history reconciliation best effort and adds first-handover/history-start proof to prevent false “not delivered” results. #30580 deliberately removes that reconciliation mechanism, its adapter history hooks and the attach-time history read. Current The first-handover and history-window additions only support that removed mechanism, and the added tests cover it. No independent remaining scope needs salvaging here. Verified against current main; this PR's head is unchanged at 1e62f0e. |
ELI5
If Orca restarted while one of your chat messages was on its way to the agent, Orca can't tell whether it arrived. When you next use that chat, Orca checks the agent's own history and records the answer: delivered, or not delivered. If saving that answer failed (the database was busy, full or locked), Orca refused to restart the agent at all, so you couldn't keep chatting. Now the chat restarts normally. The old message just stays unconfirmed.
While fixing that, review found a second problem in the same check. A message that did reach the agent could be marked "not delivered", and sending it again would give the agent the same message twice. That no longer happens.
The problem
Native chat saves every message you send before handing it to the agent. After a crash or restart, a message that was handed over but never confirmed is marked unconfirmed. The next time the chat starts its agent (on your next send), Orca reads the agent's history for that conversation:
On main:
User-facing change
settling earlier sends against provider history failedand leaves that earlier message unconfirmed.What changed (mechanism)
structured-agent-session-attach.ts: settling earlier messages against provider history is best effort. A failed write is caught and logged, and the start continues. The catch covers only that settlement. Ownership, the new agent's events, adopted history and the start's own result still fail the start as before. Writes are applied in memory only after SQLite commits (journal-row-writer.ts), so a failed write leaves the message unconfirmed both in memory and on disk. The list of unconfirmed messages returned to the client is now read straight from the journal.journal-submission-reconciler.ts: one new rule before "not delivered". The history window carries where its start was set: the fence and host-clock time of the first link in the trailing run of identical resume points (resumePointStart,structured-agent-session-history-sample.ts). Each message carries the fence and time of its first handover (firstHandover, derived by the journal fold, never stored). Absence rejects a message only if it was handed over at a later fence than the start, or at the same fence strictly after the start's time; ties stay unconfirmed. New reason:history_start_unproven.firstHandoverrides along in snapshots like the existing host-onlyacceptedSequence; the submission schema drops it and no client reads it.attachJournalnow requires the history window thatperformAttachsamples before starting the agent. The lazy read inside it had no production caller.Why this approach
Known limits / not verified
Linked Issue
Found by the reviews of #26554 and #26555. Sibling: #26576 (stale-turn cleanup at start).
Visual Proof
Screenshots held locally pending owner review (they come from a real signed-in Claude session).
Live QA on Windows high spec with a real signed-in Claude and hidden windows. Each build ran on a fresh isolated profile. BEFORE = main
e3639ef8d69; AFTER =b0c6c871627. Later commits change comments and pair the handover fence and time from the same first handover, which only matters for rows from September builds. Failure injected by adding an unconfirmed message to the test profile's journal plus a trigger that aborts only the save of that message's delivered/not-delivered answer.settling earlier sends against provider history failed … QA26577 injected failure; the earlier message stays unconfirmedhistory_start_unproven: the agent started in Q1 had moved the resume point) and shows as a plain sent message. It is never resent. This is the expected cautious outcome until the follow-up PRReal-home checks: Claude's settings, the Codex hooks and config, and
~/.orcahashes were unchanged before launch, after first use and after teardown.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Full-host restart tests on real SQLite:
Reconciler unit tests cover both directions: an earlier fence, the same fence before or after or at the same instant, and no start.
Mutation checks:
8 changed test files (106 tests) pass, and 67 neighbouring restart, journal and attach test files pass (one more needs
--expose-gc, an environment flag). Node typecheck andorca-ci-checkspass.AI Disclosure
Review
Review summary posted as a PR comment.
Agent skill upstream boundary
Notes
config/scripts/vitest-sqlite-runtime-files.mjshas adjacent additive lines with fix(native-chat): acting on one chat no longer waits on checks of every other chat #26555 and fix(native-chat): an unfinished tool call too big for one cleanup write no longer breaks a chat for good #26576.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)