Commit Graph
5 Commits
Author SHA1 Message Date
Lauri Ojansivu acb2c0786a Resolve a rule's later move, sort, move-all and archive on the board its card went to.
As decided on 2026-10-03, after a rule moved its card to another board, a
later action that names the rule's own board works where the card is now,
in the ordinary engine and in durable Sync alike:

- RulesHelper.ruleBoards gives the board the card is on and the board an
  action works on. A move to the top or bottom, a sort and a move-all
  resolve their list and swimlane names there; the write-access check
  covers that board. Before this, a move to "*" after a move to another
  board took the card's new list and swimlane but the old board, leaving
  the card split across two boards.
- The durable move, sort, move-all and archive commands find the card
  through ruleCardNow and save the board it is on as `onBoard`, written
  only when it is not the plan's, so every command saved before still
  validates; the archive's cascade takes the children on that board.
- These actions may now follow a move to another board, so such a plan
  stays durable. An email still may not, nor a second move to yet another
  board.

The archive reservation and follower guards follow the decision; the
cross-board move test now expects sorting and archiving to follow and
refuses an email instead, and a new server test runs the whole chain
durably and with the ordinary engine on a twin card, with the same result.

Thanks to xet7 !
2026-10-03 09:44:45 +03:00
Lauri Ojansivu f06ecdee09 Share guard results within one check, and make rule archive a durable Sync action.
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 !
2026-09-30 11:50:04 +03:00
Lauri Ojansivu 76f6eba249 Link Sync History rows to the chain when they are written, not planned.
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 !
2026-09-30 10:35:57 +03:00
Lauri Ojansivu 96b9bb6890 Bind archive activity plans to real collection hooks and verify replay 2026-09-28 16:21:11 +03:00
Lauri Ojansivu 85edeb0ec1 Persist archive History and activity plans before conditional replay 2026-09-28 16:18:48 +03:00