0
Fork 0
mirror of https://github.com/zeronsh/comet.git synced 2026-11-16 18:57:19 +00:00
comet/edge/scripts/chat2-check.mjs
wing-anara 2c9e306edf sync: empty checkpoint frontier is NOT contained — fetch, never skip history
Root cause of the 'Add Tweets' invisible-transcript incident (2026-08-18),
diagnosed from room stats + phone log archives + the absent on-device doc:
the room's checkpoint (seq 5, rows 1-5 trimmed) carries an empty frontier
label, and both clients treated empty-frontier as 'already contained' — so
every FRESH reader skipped the checkpoint, imported rows 6..75 raw, and
Loro parked everything depending on the chat's founding ops: transcript
invisible past the reader's own-lineage rows, no import errors (parking
is not an error), and snapshot export fails with pending ops so the doc
never persists. Converged devices (synced from row 1 pre-trim) unaffected,
which is why the bug only shows on new devices/fresh installs.

- Both clients: drop the empty-frontier shortcut; empty fails the decode
  path → not contained → fetch. Fetching is always safe (full-state merge;
  an empty-doc seed applies as a no-op) — the shortcut contradicted the
  adjacent comment's own principle ('never silently skips history').
  Applying the poisoned room's real checkpoint bytes heals it client-side
  with no server repair.
- Edge: reject checkpoint POSTs with an empty frontier when seqCovered>0
  (empty stays legal for the M1 empty-doc seed) so no new rooms are
  poisoned; chat2-check codifies the guard (66 checks green).
- Regression tests: EngineChatSink::contains_frontier(&[]) must be false;
  plan-level decision-table entry for the fresh-reader fetch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 17:40:35 +03:00

334 lines
20 KiB