Repository navigation
fix(chat): confirm a Pi receipt only from text stamped after its send (#2234, #2055) - #2323
Conversation
…capture (#2234) Pi exposes no submission id, so a receipt matched any same-text user record appended after its anchor. A message typed into Pi's terminal and queued before Ovis pressed Enter could therefore confirm Ovis's receipt even when Ovis's own message was never recorded. Pi stamps a user message with Date.now() when it is submitted or queued, before it is appended. The anchor now records its capture time, taken before Enter, and a record stamped earlier never matches. The same text submitted elsewhere after Enter stays indistinguishable; DESIGN.md says so. Also from #2055: an anchor and its append state keep a sha256 digest of the bounded tail instead of the 64 KiB tail itself, and the large-history test uses a sparse file instead of writing 200 MiB.
The server took any 36 hex-or-dash characters as an attach's receipt_resume_id, while the browser only generates and keeps a lowercase UUIDv4. Both now share one pattern. Also folds the doubled doc comment above PendingInputs.resend() and drops `null as never` where null type-checks.
) Codex Sol review: a wall clock set back between the capture and Pi's stamp put Ovis's own record before the bound, so its receipt waited for good and, being first in FIFO order, held every later receipt of the pane. The anchor also keeps the monotonic capture time, and the bound is the capture time on the current wall clock when that is earlier. DESIGN.md also names the case the bound cannot cover: Pi stamps input it staged during compaction only when the stage drains.
…ed text matches (#2234) Codex Sol's second review: the monotonic correction from the previous commit let a pre-capture external record confirm after a clock set back, and a clock set back and restored before reconciliation still stranded Ovis's own record, which then held every later receipt of the pane. No wall-clock comparison can tell those apart from a submission order. So the bound is the capture time again, and a receipt whose text appears only in records stamped before it is now "ambiguous": it settles as transcript_unconfirmed, which the browser already shows as "confirmation unavailable" and lets the user dismiss, and its FIFO successors move on. A same-text record stamped after the capture is still preferred, and an earlier one used for an ambiguous settle cannot settle a later receipt.
…s over omo review (LOW): with a terminal-typed "same" before two Ovis sends of "same", a reconciliation that ran after Ovis's first record and before its second reported the second receipt ambiguous, because each reconciliation scans the branch from the anchor again and met the earlier copy. The copies a match passes over are now marked used along with it.
…dmits Codex Sol review (MEDIUM): with the wall clock set back between two captures, a record stamped before the first receipt's capture can still be no earlier than the second's, so it may be the second receipt's own. Retiring it with the first receipt's match left the second waiting for good. A passed-over record is now retired only when it was stamped before every remaining receipt's capture in the batch.
Codex Sol review (MEDIUM): the bound for keeping a passed-over record took every remaining receipt's capture, so an earlier capture of a receipt with other text kept an old same-text record alive, and the next reconciliation settled a later same-text receipt as unconfirmed. Only remaining receipts with the same text count now.
Review findings and resolutions (before the first push)Reviewers: omo-native-code-reviewer and Codex (gpt-6.1-sol, fast, xhigh), each on an adversarial, read-only brief in its own pinned worktree. Commits referenced are on this branch. Codex round 1 (5398656), BLOCK
omo round 1 (5398656), APPROVE: no CRITICAL/HIGH/MEDIUM. LOW clock step (same as Codex's first MEDIUM, fixed as above); LOW DESIGN.md wording (fixed in 19eefa8); LOW a Pi build stamping seconds (hypothetical: upstream and installed builds use milliseconds); LOW the sparse test file may not be sparse on NTFS (no worse than the 200 MiB the old test wrote; not checked on Windows). Codex round 2 (4541307), BLOCK
omo round 2 and Codex round 3 (5a1c83d): omo APPROVE with LOW-1, Codex MEDIUM, same defect: an earlier-stamped record a match had skipped made a later same-text receipt ambiguous on the next reconciliation. Fixed in 278020b (passed-over copies are retired with the match). omo's LOW-2 (pre-Enter same text now shows "unavailable") is the intended outcome. Codex round 4 (278020b), BLOCK
Codex round 5 (390fd18), BLOCK
Stopping here. Rounds 3 to 5 each found an edge introduced by the previous narrow fix, and each needs the wall clock set back between Ovis's captures plus a delayed reconciliation. Per the merge pass's rule for heuristic matchers (one last round after a fix; findings that need exotic inputs become documented limits), 3536b83 was not sent for a sixth Codex round; the merge pass reviews it. In the worst remaining case a delivered message shows the dismissible "confirmation unavailable" or keeps waiting until its pane's target changes; no false confirmation beyond main's was found. Every fix has a unit test that fails on the commit before it; |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Merging 3536b83 (closes #2234 and #2055). A Pi send's receipt now confirms only from a same-text transcript record stamped at or after the pre-Enter capture; an earlier-stamped match settles as a dismissible "confirmation unavailable", never a false confirmation or a receipt stuck for good, and nothing is resent. #2055's items are done or dispositioned in the PR body. Queued input and receipts, so the merge pass reviewed it strictly beyond the lane's rounds (omo APPROVE twice; Codex five rounds, every MEDIUM fixed with a fail-before test): same-text sends back to back, whole-second stamps, the unavailable state across reconnect, other agents' receipts and the receipt-resume contract all held; 231 tests, typecheck clean. Known limits (Dori's decision, no follow-up issue: not something a user can realistically meet): (1) a same-text message submitted by another writer before Ovis's capture but stamped in the same millisecond confirms the receipt ( |
Change
Fixes #2234: a Pi receipt could be confirmed by a same-text user record that Ovis did not send.
Pi exposes no submission id, so a receipt is matched by its text on the active branch after the
captured anchor. A message typed into Pi's own terminal and queued while Pi worked, before Ovis
pressed Enter, is appended after that anchor too, and it confirmed Ovis's receipt even when Ovis's
own message was never recorded.
Pi stamps every user message with
Date.now()when it is submitted or queued, before it isappended at
message_end(pi-monoagent-session.ts_queueSteer/_queueFollowUp,agent.tsnormalizePromptInput). The anchor now records its capture time, taken before Ovis presses Enter,and a record stamped no earlier than that capture confirms the receipt. When only an earlier-stamped
record has its text, the receipt is neither confirmed nor left waiting: it settles as
transcript_unconfirmed, which the browser already shows as Sent to Pi · transcriptconfirmation unavailable with Discard. That is the issue's own suggestion ("keeping
identical-text matches uncertain"). A wall clock set back between the capture and Pi's stamp ends
the same way, instead of stranding the receipt and every later one in the pane's FIFO; review
showed that no clock correction can tell those cases apart. A record without a numeric stamp keeps
the old behaviour.
Without a Pi submission id two cases stay indistinguishable, and DESIGN.md names both: the same
text submitted elsewhere after Ovis's Enter, and the same text typed while Pi compacts, which Pi
stages as
{ text, mode }and stamps only when the stage drains (interactive-mode.ts, Pi 1.3).Also from #2055 (follow-ups of #2041):
tail instead of the tail itself (two 64 KiB strings per receipt before).
pi-delivery.test.tsno longer writes ~200 MiB per run: the large-history test uses a sparsefile, and it still counts every byte read.
receipt_resume_idonly in the lowercase UUIDv4 form the browsergenerates and keeps (
shared/receipt-resume.ts, shared by both), not any 36 hex-or-dashcharacters.
PendingInputs.resend()is one comment, and the pending tests passnullwhere it type-checks instead ofnull as never.Closes #2234
Closes #2055
The rest of #2055
Reviewed against current main; none is a reproduced, user-visible MEDIUM, so none gets its own issue.
stale held copy stays resendable for offline recovery.
withdrawal_only: only a bridge update fixes that; new bridges have it.connection; LOW.
that; LOW.
nothing is delivered or lost; LOW.
first, and the oldest anchor has the largest append, so it is the one that exceeds the budget;
the rest could not be matched past it anyway (FIFO).
every browser message as JSON: bounded memory and CPU, LOW.
unit and contract tests.
Tests
server/pi-delivery.test.ts: "does not let a same-text record Pi stamped before the captureconfirm the receipt", "prefers the record stamped after the capture when an earlier one has the
same text" and "settles, rather than strands, Ovis's own record stamped while the wall clock was
set back" all fail with main's matcher.
server/pending-input.contract.test.ts(real server, isolated test session, port 0), bothfailing on main: "does not confirm a receipt from the same text Pi stamped before Ovis pressed
Enter" (two Ovis sends of the same text, then one write with an earlier-stamped terminal record
and Ovis's first record: on main both receipts are confirmed, now only the first, and the second
waits for Ovis's own second record), and "settles a receipt as unconfirmed when only an
earlier-stamped record has its text".
server/core/terminals.test.tsrefuses 36 dashes, a nil UUID, a v1-shaped UUID and upper case;it fails with main's check.
bun run check fast: passed on 3536b83 (workflow syntax, generated types/themes, typecheck, build, unit tests).Remote PCs get the server part with the next
REMOTE_BUNDLE_VERSIONraise at release.Review
omo-native-code-reviewer approved twice (5398656, 5a1c83d). Codex (gpt-6.1-sol, fast, xhigh) ran five rounds; each MEDIUM it found is fixed with a test that fails on the commit before it. The findings and their resolutions are in the PR comment below. The last fix (3536b83) did not get a sixth Codex round, under the merge pass's cap for heuristic matchers.
Known limit: a wall clock set back between two of Ovis's sends to one Pi pane, with a reconciliation delayed until all records are present, can still leave a delivered message showing "confirmation unavailable" (dismissible) or waiting until the pane's target changes. Without a Pi submission id, order across a clock step cannot be proven.
LOW, not changed: a Pi build stamping seconds instead of milliseconds would never confirm (upstream and the installed builds use milliseconds); the sparse test file may not be sparse on NTFS (no worse than the 200 MiB the old test wrote).