A Sync step's rules run after its card write, and since rules may move a
card to another list or archive it, the card can afterwards match
neither the step's before-state nor its after-state. Two things then
failed:
- An interrupted run never recovered. The replay retried the step's
write, which could not be confirmed, so the run failed on every replay.
The journal now treats a stored planned activity as proof that the
write happened (activities are stored only after it is confirmed) and
finishes the effects, which are idempotent.
- Even an uninterrupted run failed whenever a durable rule moved the card
out of the list. The activity's notification and webhook stages ran
after the rule and refused a card that was no longer in the activity's
list. They now also accept the card where a saved move of that
activity's own rules put it, and nowhere else.
A failed replay now logs why. The durable Sync server test runs a rule
that moves each new card out of the synced list, crashes after the move,
and checks that the replay completes the run with one move.
Thanks to xet7 !
Stored Sync stages nest - a rule archive's delivery inside the rule stage,
inside activity delivery, inside the Sync journal - and every layer's guard
checks before and after by calling the guard below it twice. One innermost
check therefore re-ran every outer guard 2^depth times, and one Sync-created
card archived by a rule took 36 s, which is why archive was held back from
durable Sync (1e40e7e06).
reuseWithinEvaluation (server/lib/syncGuardWindow.js) runs each guard at most
once per evaluation: calls made while another guard's check is running share
the results of guards already checked in it. A call from ordinary work -
between stages, after an adapter or a write - starts a new evaluation and
checks everything afresh, so a policy change or a lost lease between stages
still stops the next one. A first attempt with a 100 ms reuse window missed
exactly that and was dropped. Failures never carry over, a guard reached
again through its own check runs fresh instead of waiting on itself, and the
journal's ownership read is left as it was.
With that, archive and unarchive are registered as durable rule adapters
through the stored archive runner, and boards whose rules archive or
unarchive now take durable Sync. The full-app durable Sync test runs an
"archive every created card" rule end to end: 1.1 s for the whole test. The
rule selection test's example of an action without an adapter is now
moveCardToTop. 565 server tests pass.
Thanks to xet7 !
Sync and the stored rule archive runner fixed each History row's
previousHash and integrityHash when they PLANNED a batch, so the board's
History chain had to stay unchanged from planning until the last row was
written - which needed a multi-row History reservation that would block
or queue ordinary edits, and made a coordinated board refuse Sync.
Maintainer decision of 2026-09-30: plans are content only, and each row
is linked when it is appended, like an ordinary edit.
On a board still on the legacy path, the batch holds one writer token
(so a chain migration drains it) and each row is linked after the
chain's tip - the newest hashed row, then its successors, since the rows
of one batch share a planned createdAt and "newest" alone is a tie that
forks the chain. On a coordinated board each row goes through the chain
head. Appends are idempotent by row _id, and a replay accepts only the
planned content. The archive runner needs no reservation any more; it
captures the actor's redo candidates when it plans. Plans in the old
chained format are refused. An index on (boardId, previousHash) serves
the tip walk.
Unit and MongoDB tests: plans carry no link; rows chain correctly in
both modes and replay once; ordinary History written between planning
and writing is neither blocked nor forked; a coordinated board appends
through the head; old-format plans and adapters without admission or
linking are refused. The full-app archive case now runs without a
reservation and verifies the resulting chain. 561 server tests pass;
the one other failure in that run, the activity notification recovery
scan, is intermittent and passes on its own.
Thanks to xet7 !