Skip to content

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

fix([conflict-journal-issues]): exclude renumber-managed `number` from the issue conflict hash

[._.]/ Adam Eivy5febc9728bda
diff --git a/server/lib/conflictJournal.test.js b/server/lib/conflictJournal.test.js
index 58998b2ae0..c4de6cc717 100644
--- a/server/lib/conflictJournal.test.js
+++ b/server/lib/conflictJournal.test.js
@@ -18,8 +18,9 @@ afterAll(() => rmSync(TEST_DATA_ROOT, { recursive: true, force: true }));
const uni = (over = {}) => ({ id: 'u-1', name: 'X', starterPrompt: 'base', updatedAt: '2026-05-01T00:00:00Z', ...over });
// Minimal issue-shaped record — sanitizeRecordForWire('issue', …) passes the
-// content through verbatim (it does NOT run sanitizeIssue), so `stages` and
-// `number` round-trip as-is for the content hash.
+// content through verbatim (it does NOT run sanitizeIssue), so `stages`
+// round-trips into the content hash. `number` is deliberately EXCLUDED from
+// the issue conflict hash (renumber-managed; see HASH_EXCLUDED_FIELDS).
const iss = (over = {}) => ({ id: 'iss-1', seriesId: 'ser-1', title: 'T', number: 1, status: 'draft', stages: {}, updatedAt: '2026-05-01T00:00:00Z', ...over });
const pendingEntries = async () => cj.conflictJournalStore().loadAll();
@@ -100,6 +101,27 @@ describe('conflictJournal', () => {
expect(fields).not.toContain('id');
});
+ it('issue content hash ignores the renumber-managed `number` (no false divergence on a sibling renumber)', () => {
+ // A local sibling-delete shifts this issue's `number` in place WITHOUT
+ // bumping updatedAt — that must NOT register as a content divergence.
+ expect(cj.contentHashForRecord('issue', iss({ number: 1 })))
+ .toBe(cj.contentHashForRecord('issue', iss({ number: 9 })));
+ // A real content edit (title) still changes the hash.
+ expect(cj.contentHashForRecord('issue', iss({ title: 'A' })))
+ .not.toBe(cj.contentHashForRecord('issue', iss({ title: 'B' })));
+ });
+
+ it('a pure-renumber local drift does NOT journal a conflict when a real remote edit arrives', async () => {
+ const base = iss({ number: 1 });
+ await cj.setSyncBaseHash('issue', 'iss-1', cj.contentHashForRecord('issue', base));
+ // Local ONLY renumbered (number 1→2, no restorable edit, updatedAt unchanged).
+ const local = iss({ number: 2 });
+ // Remote made a real edit and is newer.
+ const remote = iss({ title: 'REMOTE edit', updatedAt: '2026-05-03T00:00:00Z' });
+ await cj.maybeJournalBeforeOverwrite({ kind: 'issue', id: 'iss-1', local, remote, source: { via: 'sync' } });
+ expect(await pendingEntries()).toHaveLength(0); // local == base (number excluded) → clean fast-forward
+ });
+
it('journals an issue 3-way divergence; diffSummary covers title + stages, never number/seriesId', async () => {
const base = iss();
await cj.setSyncBaseHash('issue', 'iss-1', cj.contentHashForRecord('issue', base));