Skip to content

sync: keep an unpublished export instead of sealing it again every pass - #2544

Merged
santoshkumarradha merged 2 commits into
app/v3from
fix/sync-repack
Nov 9, 2026
Merged

santoshkumarradha merged 2 commits into
app/v3from
fix/sync-repack

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

What was wrong

On the owner's Mac (engine fb3ddf1) codeaf app sat at ~400% CPU and furrow at ~88%. The relay answers every frame put with 403 "storage_off" (WorkAF engine.log). The background share pass (syncsetup.PublishLocalChats) retries each unshared chat on a backoff capped at one minute. Each attempt calls SyncEngine.Export, and furrow's export seals every object the ledger lacks and rewrites every frame. It does this even when the same frames are already sitting in the outbox. A frame leaves the outbox only when it is published, so every refused retry re-encrypted, hashed and rewrote the whole chat. For the chats whose engine-tree is factory/repos/Agent-Field/CodeAF, that was 60 frames / 470 MB per chat per attempt.

The fix

SyncEngine.Export writes kept-export.json beside the frames. It reuses that note, without asking the engine, while all of these are unchanged:

  • the head
  • the ledger name and its size (the ledger is append-only)
  • the frame size
  • a digest of the keys
  • every frame file, still present at its recorded size

Anything that could make the note wrong breaks it: a publish, a ledger record, a new turn or a key rotation. When the head moves, the next export seals again and deletes the frames that only the older export named. Before this, those frames stayed in the outbox forever.

Proof

  • TestARefusedUploadIsNotSealedAgainOnTheNextPass uses the real cellstore.SyncEngine and Publisher.Upload against a stub furrow and a relay that refuses every put. Over 5 passes on one head:
    • base: 5 exports, 320 objects sealed, 40 frames written
    • fix: 1 export, 64 objects sealed, 8 frames written
  • TestANewTurnReplacesTheWaitingFrames: the outbox held 5 frames on base and holds 3 with the fix (only the newest export's frames).
  • TestAPublishOrARecordEndsTheReuse: a publish forces a fresh export, and an unchanged pass reuses the note.
  • TestARepeatedExportKeepsTheWaitingFramesRealEngine (-tags engine, real furrow 0.3.6): on base a repeated export rewrote 13 of 13 frame files; with the fix it rewrites 0.
  • PERF.md has a new section, "Sync export retries".

Not addressed here

  • The client does not know storage_off. It is not in blobstore's wire table, so it is retried every ≤1 min indefinitely. Each retry still reads the waiting frames to ask the relay what it holds (skipHeld), and puts one 8 MB frame. That is I/O, not sealing. The fix is to add it as a halting refusal, once the relay's meaning of it is known.
  • Chats that share a store and tree still have separate outboxes, so identical frames are exported once per chat. After the first successful publish the shared ledger dedups them.

🤖 Generated with Claude Code

A relay that refuses every put (hosted 403 "storage_off") left a chat's frames
in its outbox, and the background share pass retried the chat each minute.
furrow's export seals every object the ledger lacks and rewrites the frames
afresh, whatever the outbox already holds, so each retry re-encrypted, hashed
and rewrote the whole chat: 470 MB per chat per minute for every chat whose
folder was the factory's repository, and a laptop at 400% CPU.

SyncEngine.Export now leaves kept-export.json beside the frames and answers it
while the head, keys, ledger size, frame size and every frame file are
unchanged. A moved head exports again and deletes the frames only the older
export named, so an outbox no longer grows by a whole chat per turn.
@santoshkumarradha
santoshkumarradha merged commit 5d02f0d into app/v3 Nov 9, 2026
6 checks passed
@santoshkumarradha
santoshkumarradha deleted the fix/sync-repack branch November 9, 2026 20:04
AbirAbbas added a commit that referenced this pull request Nov 9, 2026
Brings in #2544 (an unpublished sync export is kept rather than sealed
again every pass) and #2545 (idle job chats and an unchanged vault cost
nothing per look).

#2545 and this branch's engine rounds each fixed the person-Stop watch's
per-look cost, in two different ways. The branch's kept implementation
remembers the answer against the job document it came from and never keys
a conversation that manages no job on the floor folder, whose time moves
with every heartbeat file renamed into it; #2545's manager index was
rebuilt on exactly that folder time, so a churning floor rebuilt it every
few seconds. The branch's version passes #2545's own tests
(TestAnIdleManagerWatchReadsNoJobs, TestTheManagerWatchSeesEveryChange)
as well as its own, so factory_manager_index.go, which nothing calls any
more, is not carried. Store.readDocument becomes a method so #2545's read
counter reaches it, PERF.md describes the one mechanism, and the #2545
change entry no longer claims the index. The vault change is kept as is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
AbirAbbas pushed a commit that referenced this pull request Nov 9, 2026
…an AgentField node (#2478)

General intake (inbox, Jira, the routing table with an AI filter and priority order), the factory as an AgentField node whose triggers are its intake, AgentField runs as factory steps, named pipelines and a pipeline library, the engine idle-cost rounds, codeaf --events/--steer for watched harness runs, and app/v3 (#2524 go-aheads, #2505 Claude Code, #2544, #2545) merged in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant