Commit Graph
19 Commits
Author SHA1 Message Date
Lauri Ojansivu c06bf8d0e9 Sync sprints and releases into Scrum planning.
List Sync from Jira or GitLab now carries an issue's sprint and fix
versions / milestones into the board's Scrum planning while Scrum is
enabled on the board. A missing sprint or release is created on this
board with the dates the source gives; an existing one is matched by its
source ID first, then by name. A local planning change stays until the
source changes that issue's planning, and a first Sync never removes
planning. The writes go through the durable Sync journal and steps, so
an interrupted Sync is finished or discarded like any other.

Thanks to xet7 !
2026-10-08 12:35:58 +03:00
Lauri Ojansivu f735eba194 Rules: assignee actions, an optional title, and remove-all members that removes them.
#4294 asked for four things. Several triggers and actions, rule variables,
renaming in place and rule import/export were built earlier; two parts were
still missing.

- "I want the assignee to be the creator of the card by default": rules had
  member actions only. Add and Remove assignee actions take a username, a
  {creator}/{assignees}/{members} token, the user who triggered the rule, or
  "*" for every assignee, and write card.assignees. They are durable through
  Sync like the member actions, with the joinAssignee/unjoinAssignee
  activities the assignees hook writes.
- "give a Rule a default name": Add Rule with an empty title showed an
  error, and rules.createRule stored the literal "Rule". The title is now
  optional; the rule is named after its trigger and action ("When ...,
  then ..."), and the rules list renames it in place.

Fixing this found that "Remove all members from the card" iterated the
card's assignees while removing from its members: an earlier fix believed
assignMember wrote assignees, but both definitions in models/cards.js write
members. It removed only members who were also assignees. Remove-all now
iterates card.members, in the ordinary and the durable path, and the guards
that pinned the wrong collection now read models/cards.js to decide.

New text is added in English, pending Transifex.

Thanks to xeruf and xet7 !

Fixes #4294.
2026-10-08 11:31:12 +03:00
Lauri Ojansivu e108bb83b0 Lay the groundwork for durable rule moves to another board.
The saved command for a rule move onto another board is written
(server/lib/syncRuleMoveBoardCommand.js). It plans what Card.move and
its hooks write there: labels by name, the card number, mapped custom
fields, filtered members and watchers, cleared dependencies, the
History rows, the moveCardBoard and custom-field activities, the
re-pointed label activities and the legacy undo row. It accepts only
the last action of its rule plan. The History planner gains those
fields, and the recording scope can defer the dependencies row and the
label-activity hook, which runs while the card is still on its old
board. Nothing uses the command yet: such a rule still keeps its board
on direct Sync until its runner, guard and eligibility are added.

Thanks to xet7 !
2026-10-02 18:27:47 +03:00
Lauri Ojansivu 22311feaf4 Run the copyCard rule action through durable Sync on the card's own board.
A copyCard rule that copies onto the card's own board now has a saved
command. What the copy contains is decided once, with the ordinary
copy's own helpers: the card as Card.copy builds it (the custom fields
the actor may read, its dependencies on the board, its Scrum metadata,
a new card number, the bottom of the list), its live attachments, its
checklists and items, its subtasks with their checklists, and its
comments. Every document gets an id derived from the rule invocation,
so a replay inserts each once. The copy's and its subtasks' creation
activities are saved and delivered durably; each attachment file is
copied once (copyFile can now be given the id) and its History row is
written from the stored attachment; checklists, items and comments are
direct inserts, as Card.copy makes them. The cover is remapped to the
copied attachment by its derived id. Like the ordinary copy chain
guard, a copy whose own creation triggers the same action is not copied
again. A copy to another board keeps the board on direct Sync.

The server test copies a card with all of those, replays it, checks the
chain guard, and compares the result with the ordinary Card.copy.

Thanks to xet7 !
2026-10-02 17:09:16 +03:00
Lauri Ojansivu d69cde2ecf Run the addChecklistWithItems rule action through durable Sync.
The checklist lifecycle command now also covers addChecklistWithItems:
the checklist and one item per comma-separated title, both with ids
derived from the rule invocation so a replay inserts them once. After
the inserts it records, from the stored documents and in the order the
hooks write them, the checklist's activity and History row and then each
item's addChecklistItem activity and 'added' row. The item hooks are
deferred only for items of the checklist the command names. The item
titles are resolved by the same RulesHelper call the ordinary action
uses.

Thanks to xet7 !
2026-10-02 16:52:15 +03:00
Lauri Ojansivu 21d7848d47 Run rule checklist creation and removal through durable Sync.
addChecklist and removeChecklist rule actions now have saved commands,
like the other durable rule actions. addChecklist inserts a checklist
whose id is derived from the rule invocation, so a replay inserts it
once, and records the hook's addChecklist activity and History lifecycle
row from the document as it was stored. removeChecklist saves every
checklist the ordinary selector matches, one unit each, and for each
writes the removeChecklist activity before the removal and the 'removed'
History row after it, refusing a checklist that changed since capture.
The checklist hooks are deferred only for the checklist a command names.

Thanks to xet7 !
2026-10-02 15:40:57 +03:00
Lauri Ojansivu b3b4962414 Run rule moves to the top or bottom of the card's own list through durable Sync.
A moveCardToTop or moveCardToBottom rule whose list and swimlane are '*'
on the card's own board only changes the card's sort. It now has a saved
command, like the card-field actions: the sort is computed once at
capture as the ordinary action computes it, the write is conditional on
the saved sort, the hook's position History row is planned and written
once, and the legacy UserPositionHistory row that Ctrl+Z reads is
written once with trackChange's redo-stack clearing. Replays apply the
saved command and change nothing more.

A move to another list, swimlane or board is reported to eligibility as
'<type>:elsewhere', so a board with such a rule keeps direct Sync.

Thanks to xet7 !
2026-10-02 15:34:18 +03:00
Lauri Ojansivu af1b1bee2d Make the checklist rule actions durable in Sync.
checkAll, uncheckAll, checkItem and uncheckItem join the durable rule
actions. The command is captured with performAction's own lookups - the
checklist by title on the card, the items in the order ReactiveCache returns
them, the bulk selection, and checkItem's item query as it is - so a replay
acts on the same items with the same outcome, including the ordinary
action's no-ops.

The ordinary action writes each item in turn, and the checklist item hooks
record on every write, changed or not: uncompleteChecklist before it when
the whole checklist was finished, checkedItem or uncheckedItem after it, and
completeChecklist when the whole checklist is finished - plus a History row
on the item when isFinished changed. The command simulates exactly that on
the captured items and saves one unit per item. The runner goes item by item:
the before-write activity, the conditional write with the item's three hooks
deferred, its History, its after-write activities - each delivered durably -
so a rule triggered by one item runs before the next, as ordinarily.

The History planner now accepts checklist-item rows (entity and card kept
apart), and the recording deferral can name one checklist item. Unit tests
cover the hook sequence for check-all, uncheck-all and hidden-all lists,
no-ops and tampering; a full-app test runs a "check every item" rule through
the stored rule stage - two checkedItem, one completeChecklist, two History
rows, and nothing more on replay. 566 server tests pass.

Thanks to xet7 !
2026-09-30 12:17:20 +03:00
Lauri Ojansivu 0395989d01 Make the member rule actions durable in Sync.
addMember and removeMember join the durable card-field actions. The people
are resolved at capture exactly as performAction resolves them - the acting
user for the #2522 option, username tokens through buildRuleVars (#4294),
and the card's assignees for "remove every member" (#2674) - by a new
RulesHelper.resolveMemberTargets beside it, and saved with their usernames,
so a replay acts on the same people. The ordinary action's one $addToSet or
$pull per person becomes one planned change of `members`, with a joinMember
or unjoinMember activity for each person who really joined or left, as the
members hook writes it, and one members History row.

The new helper phrases its conditions so the source guards that locate
performAction's member branch still find it, and the recording-isolation
test now uses assignees as its example of a field that is never deferred.
Unit tests cover resolution being saved, joins and leaves, nobody resolved
and tampered targets; the full-app durable Sync test adds a member to every
created card through a rule - one joinMember activity and one members
History row. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:09:24 +03:00
Lauri Ojansivu ad4ccd5c38 Make the date rule actions durable in Sync.
setDate, updateDate, setDateRelative and removeDate join the durable
card-field actions. Their semantics follow the ordinary actions exactly:
setDate only fills a date that is unset, updateDate always sets it,
setDateRelative offsets from "now", removeDate unsets - with "now" fixed at
the command's capture time, so a replay makes the same change.

A full-app probe of the ordinary writes showed what they record: a dates
History row (added, edited or removed) and the timing hook's a-<field>
activity with username, card title, time key and the old value ('' when
there was none) - and no timeValue when the date is removed. The command
plans exactly that. The timing hook in server/models/cards.js gains a
'timing' deferral kind so the saved activity is written instead of the
hook's own, never both; the runner can now unset a field as well as set it.

Unit tests cover all four actions, setDate on a filled date, the timing
activity's shape for set and unset, and a replay-stable relative date; the
full-app durable Sync test gives every created card a due date through a
rule - one a-dueAt activity and one dates History row. 565 server tests pass.

Thanks to xet7 !
2026-09-30 12:05:03 +03:00
Lauri Ojansivu ff86170f35 Make colour, label and completion rule actions durable in Sync.
Boards with any rule action other than email and archive stayed on direct
Sync. Six more now take the durable path: setColor, addLabel, removeLabel,
removeAllLabels, markCardComplete and markCardIncomplete.

Each rule invocation saves one command (server/lib/syncRuleCardCommand.js)
with its card field's value before and after the action - with the ordinary
action's semantics: $addToSet/$pull for single labels, a missing field stays
missing on removeLabel, 'white' is stored as null - and the effects the
ordinary hooks would write: one History row for the field and, for
addLabel/removeLabel, the addedLabel/removedLabel activity only when the
label really changed (removeAllLabels writes none, as ordinarily). The runner
applies the saved change conditionally with ordinary History deferred for
that one write, then writes the planned History rows and activities, each
activity delivered durably with its own rules and notifications, and returns
the invocation only when all of it is confirmed. Replays use the saved
command, never the rule's current configuration.

The History planner is parameterized by allowed fields (Sync's own, or these
three), and the recording deferral covers labelIds, color and dueComplete.
Unit tests cover every action, the effects, absent-versus-null selectors and
tampering; the full-app durable Sync test labels every created card through
a rule - one History row, one activity, nothing more on replay. 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 12:00:47 +03:00
Lauri Ojansivu e191baef7e Recover abandoned History writers online, fenced, without stopping servers.
A legacy History writer holds a token on its board's gate until its write is
confirmed, with no expiry, so an uncertain write can never become invisible to
a chain migration. A writer that died kept its token forever, and the only way
to remove it was the offline tool with every server stopped. Maintainer
decision of 2026-09-30: build online recovery - liveness heartbeats and fencing
on History inserts - and keep the offline tool as the fallback.

Each writer on an upgraded server now writes a lease beside its token
(historyWriterLeases) and renews it while it works. Before every legacy
History insert it claims the row id in the lease; only an active lease can
claim. Recovery takes a lease only after it has been expired for another full
lease period (HISTORY_WRITER_LEASE_MS, default 30 s). It sets the lease to
fenced, so the old writer can neither renew nor claim. A claimed row id is
then fenced by a tombstone under that id, so the unique _id makes a late
insert fail, and a row that had already landed stays. Only then is the token
removed. Safety rests on the fence; clocks only decide when a lease may be
taken, and a slow writer that is taken loses its write with an error.
Tombstones use the reserved board id #history-writer-fence and are invisible
to every board reader. A Sync append refuses a tombstone as its planned row.

A chain migration takes abandoned writers by itself while the board drains,
a full gate does the same once, and releases/recover-history-writer.cjs
--recover-expired does it on demand, online. Tokens without a lease (older
servers) are listed and still need the offline procedure.

MongoDB tests with two clients: a writer that died after claiming a row is
taken and its late insert fails; a fenced slow writer cannot claim; a row
that landed before the fence is kept; live writers and lease-less tokens are
not taken; a migration drains a dead writer and completes on the real chain
head. A full-app test covers the production binding. 563 server tests pass.

Thanks to xet7 !
2026-09-30 11:03:37 +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 281f294746 Admit Sync History through the board's History writer gate.
Sync writes History rows it hashed when it planned them, straight into
the collection. On a board whose History chain had been migrated to the
coordinated head, that would fork the chain, and a migration could start
while a Sync batch was still writing. persistSyncFieldHistory now writes
only as a writer the History gate admits: production ChangeHistory holds
a legacy writer token for the whole batch, so a migration drains it
first, and a coordinated board refuses Sync History with
sync-history-coordination-required instead of appending around the head.
There is no default: an adapter without admission is refused. The rule
archive path shares it through persistSyncEffects.

A MongoDB integration test uses the real gate: the batch holds a token
while it writes and releases it after; a migration waits for a batch in
flight, a new batch is refused while the board drains, the in-flight one
completes; a coordinated board refuses and writes nothing. Test adapters
gained the pass-through admission; 561 server tests pass.

Thanks to xet7 !
2026-09-30 02:44:52 +03:00
Lauri Ojansivu 0975d33d94 Persist Sync creation activities with separate delivery acknowledgement 2026-09-28 04:04:25 +03:00
Lauri Ojansivu 6cebd5ec58 Chain durable Sync History plans across card mutations 2026-09-28 04:00:32 +03:00
Lauri Ojansivu bb42397a26 Recover legacy History redo invalidation from exact Sync snapshots 2026-09-28 03:59:00 +03:00
Lauri Ojansivu 2c91935352 Persist and validate Sync effect plans with their card units 2026-09-28 02:39:56 +03:00
Lauri Ojansivu f5e2dd0f59 Persist retryable Sync field History batches and redo snapshots 2026-09-28 02:36:02 +03:00