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

address review (codex): exclude track renders from the sync content hash

[._.]/ Adam Eivy7b413a84327f
diff --git a/server/lib/conflictJournal.js b/server/lib/conflictJournal.js
index 6c55725c8b..8cf5e02b4f 100644
--- a/server/lib/conflictJournal.js
+++ b/server/lib/conflictJournal.js
@@ -81,7 +81,15 @@ const MEDIA_COLLECTION_SCALAR_FIELDS = Object.freeze(['name', 'description', 'co
// set the UI actually shows. (mediaCollection narrows via its own scalar
// projection below; universe/series exclude nothing, so their already-seeded
// base hashes stay valid across upgrade.)
-const HASH_EXCLUDED_FIELDS = Object.freeze({ issue: ['number'] });
+// Fields dropped from the CONTENT HASH (not the wire payload — they still
+// replicate). `issue.number` is renumber-managed. `track.renders` is an additive
+// field synthesized (backfilled) onto every existing track on first read: hashing
+// it would invalidate every pre-upgrade `sync_base_hash` and journal a one-time
+// FALSE 3-way conflict on the first cross-peer edit after both peers upgrade
+// (local and remote both differ from a base computed without renders). Excluding
+// it from the hash keeps base-hash compatibility; render-only divergences are
+// LWW-ordered by `updatedAt` regardless, and renders stays restorable (below).
+const HASH_EXCLUDED_FIELDS = Object.freeze({ issue: ['number'], track: ['renders'] });
/**
* sha256 of the canonical content projection. Reuses sanitizeRecordForWire +
@@ -306,6 +314,9 @@ export const RESTORABLE_FIELDS = Object.freeze({
author: ['name', 'writingStyle', 'bio', 'physicalDescription', 'headshotStyle', 'headshotImageUrl'],
artist: ['name', 'genre', 'bio', 'musicalStyle', 'physicalDescription', 'portraitStyle', 'portraitImageUrl'],
album: ['title', 'artistId', 'artist', 'description', 'genre', 'releaseYear', 'coverImageUrl', 'trackIds'],
+ // `renders` IS restorable (a conflict restore must bring back the local render
+ // history) but is EXCLUDED FROM THE CONTENT HASH — see HASH_EXCLUDED_FIELDS for
+ // why (base-hash compatibility for this additive backfilled field).
track: ['title', 'albumId', 'artistId', 'artist', 'lyrics', 'prompt', 'engine', 'modelId', 'durationSec', 'audioFilename', 'renders'],
// Issue: the user-authored content the merge can restore. `stages` carries
// the bulk of the work (prose, comic pages, render metadata). Server-owned /
diff --git a/server/services/tracks/file.test.js b/server/services/tracks/file.test.js
index 836f9b3324..c587a1a891 100644
--- a/server/services/tracks/file.test.js
+++ b/server/services/tracks/file.test.js
@@ -30,12 +30,9 @@ function reset() {
const journalEntries = () => cj.conflictJournalStore().loadAll();
-// `renders: []` matches the sanitized shape (no audio → empty history), so the
-// raw fixture hashes identically to the stored sanitized record in the
-// base-hash assertions below — `contentHashForRecord` now includes `renders`.
const track = (id, extra = {}) => ({
id, title: id, albumId: '', artistId: '', artist: '', lyrics: '', prompt: '',
- engine: '', modelId: '', durationSec: null, audioFilename: '', renders: [],
+ engine: '', modelId: '', durationSec: null, audioFilename: '',
createdAt: '2026-01-01T00:00:00.000Z', updatedAt: '2026-01-01T00:00:00.000Z',
deleted: false, deletedAt: null, ...extra,
});
@@ -58,6 +55,20 @@ describe('tracks file backend — CRUD', () => {
});
});
+describe('tracks content hash', () => {
+ it('excludes the render history (additive backfilled field stays base-hash compatible)', () => {
+ // A pre-renders track and the same track carrying a render history must hash
+ // identically, so backfilling renders onto existing synced tracks can't
+ // invalidate stored base hashes and journal a false conflict on first edit.
+ const base = track('track-h', { audioFilename: 'a.wav', engine: 'musicgen', durationSec: 12 });
+ const withRenders = { ...base, renders: [
+ { id: 'r1', audioFilename: 'a.wav', engine: 'musicgen', durationSec: 12, prompt: 'x', lyrics: '', createdAt: '2026-01-01T00:00:00.000Z' },
+ { id: 'r2', audioFilename: 'b.wav', engine: 'audioldm2', durationSec: 20, prompt: 'y', lyrics: '', createdAt: '2026-01-02T00:00:00.000Z' },
+ ] };
+ expect(cj.contentHashForRecord('track', withRenders)).toBe(cj.contentHashForRecord('track', base));
+ });
+});
+
describe('tracks file backend — mergeTracksFromSync (LWW outcomes)', () => {
it('inserts, then newer wins / older no-ops', async () => {
expect(await file.mergeTracksFromSync([track('track-1', { prompt: 'v1', updatedAt: '2026-02-01T00:00:00.000Z' })]))