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
address review (claude): don't bake 'unknown' originInstanceId onto live records in migration 081
Adam Eivyd61c988200ad
diff --git a/scripts/migrations/081-brain-daily-log-inbox-sync.js b/scripts/migrations/081-brain-daily-log-inbox-sync.jsindex 2b2313ac7e..7e9245fd89 100644--- a/scripts/migrations/081-brain-daily-log-inbox-sync.js+++ b/scripts/migrations/081-brain-daily-log-inbox-sync.js@@ -71,12 +71,23 @@ async function readInstanceId(rootDir) {function normalizeRecord(record, { instanceId, seedTime, nowIso }) {// eslint-disable-next-line no-unused-varsconst { id: _innerId, ...rest } = record;- return {+ const normalized = {...rest,- originInstanceId: rest.originInstanceId || instanceId,createdAt: rest.createdAt || seedTime || nowIso,updatedAt: rest.updatedAt || seedTime || rest.createdAt || nowIso,};+ // Only stamp originInstanceId when we have a REAL id (or the record already+ // carries one). Migrations run before ensureSelf() creates instances.json, so+ // on a data dir copied in without it `instanceId` is the 'unknown' sentinel.+ // Baking 'unknown' onto a LIVE record is permanent — backfillOriginInstanceId+ // only repairs falsy values, so it would never fix it and the bogus provenance+ // would federate. Leaving the field absent instead lets that boot-time backfill+ // (which runs AFTER ensureSelf) fill the real id. (A tombstone legitimately+ // carries 'unknown', but tombstones never flow through this path.)+ if (rest.originInstanceId || instanceId !== UNKNOWN_INSTANCE) {+ normalized.originInstanceId = rest.originInstanceId || instanceId;+ }+ return normalized;}/**diff --git a/scripts/migrations/081-brain-daily-log-inbox-sync.test.js b/scripts/migrations/081-brain-daily-log-inbox-sync.test.jsindex 1e7457ef39..48d02efcc2 100644--- a/scripts/migrations/081-brain-daily-log-inbox-sync.test.js+++ b/scripts/migrations/081-brain-daily-log-inbox-sync.test.js@@ -179,11 +179,14 @@ describe('migration 081 up()', () => {expect(bridge['people:p1']).toBe('mem-2');});- it('falls back to the unknown sentinel when instances.json is absent', async () => {+ it('leaves originInstanceId absent (not "unknown") when instances.json is missing, so boot-time backfill can repair it', async () => {writeJsonl('inbox_log.jsonl', [{ id: 'a', capturedText: 'x', status: 'done', capturedAt: '2026-03-01T00:00:00.000Z' },]);await migration.up({ rootDir });- expect(readJson('inbox.json').records.a.originInstanceId).toBe('unknown');+ // Baking the 'unknown' sentinel onto a live record would be permanent+ // (backfillOriginInstanceId only fills falsy values). Leaving it absent lets+ // the post-ensureSelf backfill stamp the real instance id.+ expect(readJson('inbox.json').records.a).not.toHaveProperty('originInstanceId');});});