Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
docs([conflict-restore-additive]): clarify why issue stages need no replace flag
[._.]/ Adam Eivy4ec30a7640e7
diff --git a/server/services/conflictJournalResolver.js b/server/services/conflictJournalResolver.jsindex e16cb927d7..c68f9d8f0b 100644--- a/server/services/conflictJournalResolver.js+++ b/server/services/conflictJournalResolver.js@@ -103,10 +103,15 @@ async function applyToRecord(kind, recordId, patch, { replace = false } = {}) {const effective = (cur?.universeId || cur?.seriesId) ? withoutName : patch;if (Object.keys(effective).length > 0) await updateCollection(recordId, effective).catch(translateGone);} else if (kind === 'issue') {- // updateIssue deep-merges `stages` per-stage (mergeIssuePatch), so a- // restore re-applies the archived stage content without clobbering a- // sibling stage the live record gained since detection — same additive- // overlay semantics as universe categories (see the NOTE above).+ // updateIssue merges `stages` per-key (mergeIssuePatch), but unlike universe+ // categories' OPEN custom-key set, `sanitizeStages` seeds a CLOSED, fixed+ // stage-id set with complete field shapes — so the archived snapshot always+ // carries every stage (and every content sub-field). The per-key overlay+ // therefore covers them all and the snapshot's value (even an empty one)+ // wins, making restore-all equivalent to a wholesale replace WITHOUT a+ // replace flag: a stage value the live record gained since the conflict is+ // overwritten. (`runHistory` is intentionally recomputed, not rolled back —+ // it tracks the live undo-history, which a faithful restore should preserve.)await updateIssue(recordId, patch).catch(translateGone);} else {throw makeErr(`Unsupported conflict kind: ${kind}`, ERR_VALIDATION);diff --git a/server/services/conflictJournalResolver.test.js b/server/services/conflictJournalResolver.test.jsindex 50814a0336..e3daaed5aa 100644--- a/server/services/conflictJournalResolver.test.js+++ b/server/services/conflictJournalResolver.test.js@@ -116,6 +116,24 @@ describe('conflictJournalResolver', () => {expect(fresh.stages.prose.output).toBe('MY prose');});+ it('issue restore-all overwrites a stage value the live record gained since the conflict (faithful without a replace flag)', async () => {+ const issue = await issueSvc.createIssue({ seriesId: 'ser-faithful', title: 'T' });+ // Post-conflict, the live record gained prose content the snapshot never had.+ await issueSvc.updateIssue(issue.id, { stages: { prose: { status: 'ready', output: 'live-added prose' } } });+ expect((await issueSvc.getIssue(issue.id)).stages.prose.output).toBe('live-added prose');+ // The archived snapshot's prose was empty (the user's version had no prose).+ const entryId = await seedEntry(+ issue.id,+ { id: issue.id, seriesId: 'ser-faithful', title: 'T', stages: { prose: { status: 'draft', output: '' } } },+ 'issue',+ );+ await resolver.resolveConflict(entryId, { action: 'restore-all' });+ // The snapshot's empty prose overwrote the live addition — the closed stage-id+ // set makes the per-key overlay equivalent to a wholesale replace, so issue+ // stages need no replaceStages flag (unlike universe categories' open key set).+ expect((await issueSvc.getIssue(issue.id)).stages.prose.output).toBe('');+ });+it('issue merge-fields overlays only the chosen field; unsupported kind is rejected', async () => {const issue = await issueSvc.createIssue({ seriesId: 'ser-merge', title: 'Keep Title' });await issueSvc.updateIssue(issue.id, { stages: { prose: { status: 'ready', output: 'REMOTE prose' } } });