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
fix: stop a controller-store write from downgrading a newer schemaVersion stamp
[._.]/ Adam Eivya07b8837f830
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.mdindex e3201b25ac..0db25869e8 100644--- a/docs/features/eidoverse.md+++ b/docs/features/eidoverse.md@@ -1098,7 +1098,9 @@ just produced; a violation fails that step and counts towardcontroller to the same contract the promote gate does. The store's own`schemaVersion` stamp is read back (not assumed to be this build's constant):a store written by a newer build disarms rather than stepping under rules it-does not fully understand.+does not fully understand — and the writes that disarm never re-stamp the file+with this build’s older constant, so the signal survives the pass that reads it+rather than being erased by it.**Storage** is `data/eidoverse/controllers.json` — `file-primary` and machinelocal, never federated (`docs/STORAGE.md`). A controller crosses to a peer onlydiff --git a/server/services/eidoverseControllerRuntime.js b/server/services/eidoverseControllerRuntime.jsindex c485647ca3..9206991041 100644--- a/server/services/eidoverseControllerRuntime.js+++ b/server/services/eidoverseControllerRuntime.js@@ -109,8 +109,18 @@ async function readInstalls() {return { schemaVersion, installs };}-async function writeInstalls(installs) {- await atomicWrite(storeFile(), { schemaVersion: STORE_SCHEMA_VERSION, installs });+/**+ * Writes never DOWNGRADE the file's stamp (#7629). A store a newer build wrote+ * carries a higher `schemaVersion`, and this build still has to persist to it —+ * a disarm, a delivery outcome. Re-stamping it with this build's own older+ * constant would erase the very signal `stepInstall` refuses to step on, so the+ * newer-store guard would fire exactly once and then never again, and the+ * newer build would read its own file back as one this version wrote. Callers+ * pass the stamp they read under the same lock.+ */+async function writeInstalls(installs, storeSchemaVersion = STORE_SCHEMA_VERSION) {+ const schemaVersion = Math.max(STORE_SCHEMA_VERSION, storeSchemaVersion);+ await atomicWrite(storeFile(), { schemaVersion, installs });}/** Every controller this install has, most recently installed first. */@@ -178,7 +188,7 @@ export async function installEidoverseController(input, {const nowMs = Date.parse(now);return withStoreLock(async () => {- const { installs } = await readInstalls();+ const { schemaVersion: storeSchemaVersion, installs } = await readInstalls();const existing = installs[authored.id] || null;if (!existing && Object.keys(installs).length >= EIDOVERSE_CONTROLLER_LIMITS.installs) {return refused([`this install already holds ${EIDOVERSE_CONTROLLER_LIMITS.installs} controllers — retire one before installing another`]);@@ -205,7 +215,7 @@ export async function installEidoverseController(input, {disarmedReason: armed ? null : (existing?.disarmedReason ?? null),};installs[authored.id] = record;- await writeInstalls(installs);+ await writeInstalls(installs, storeSchemaVersion);console.log(`${LOG_PREFIX}: installed "${record.id}" (${record.controllerId}, every ${Math.round(record.tickIntervalMs / 1000)}s, ${record.armed ? 'armed' : 'disarmed'})`);return { outcome: 'installed', install: record, reasons: [] };}).then(afterGateMove('install'));@@ -221,11 +231,11 @@ export async function installEidoverseController(input, {*/export async function retireEidoverseController(id) {return withStoreLock(async () => {- const { installs } = await readInstalls();+ const { schemaVersion: storeSchemaVersion, installs } = await readInstalls();const existing = installs[id];if (!existing) return { outcome: 'unknown-install', install: null, reasons: [`no controller is installed under "${id}"`] };delete installs[id];- await writeInstalls(installs);+ await writeInstalls(installs, storeSchemaVersion);console.log(`${LOG_PREFIX}: retired "${id}" (${existing.controllerId}) after ${existing.tick} tick${existing.tick === 1 ? '' : 's'}`);return { outcome: 'retired', install: existing, reasons: [] };}).then(afterGateMove('retire'));@@ -241,7 +251,7 @@ export async function retireEidoverseController(id) {export async function setEidoverseControllerArmed(id, armed, { now = new Date().toISOString() } = {}) {const nowMs = Date.parse(now);return withStoreLock(async () => {- const { installs } = await readInstalls();+ const { schemaVersion: storeSchemaVersion, installs } = await readInstalls();const existing = installs[id];if (!existing) return { outcome: 'unknown-install', install: null, reasons: [`no controller is installed under "${id}"`] };const record = {@@ -253,7 +263,7 @@ export async function setEidoverseControllerArmed(id, armed, { now = new Date()....(armed === true ? { nextTickAt: nextControllerTickAt(existing, nowMs), consecutiveFailures: 0, disarmedReason: null } : {}),};installs[id] = record;- await writeInstalls(installs);+ await writeInstalls(installs, storeSchemaVersion);return { outcome: 'updated', install: record, reasons: [] };}).then(afterGateMove('arm-toggle'));}@@ -275,7 +285,7 @@ export async function updateEidoverseControllerConfig(id, config, {resolveDefinition = findControllerDefinitionById,} = {}) {return withStoreLock(async () => {- const { installs } = await readInstalls();+ const { schemaVersion: storeSchemaVersion, installs } = await readInstalls();const existing = installs[id];if (!existing) return { outcome: 'unknown-install', install: null, reasons: [`no controller is installed under "${id}"`] };@@ -287,7 +297,7 @@ export async function updateEidoverseControllerConfig(id, config, {const record = { ...existing, config: parsed.data, updatedAt: now };installs[id] = record;- await writeInstalls(installs);+ await writeInstalls(installs, storeSchemaVersion);console.log(`${LOG_PREFIX}: updated config for "${id}" (${existing.controllerId}), state preserved`);return { outcome: 'updated', install: record, reasons: [] };});@@ -481,7 +491,7 @@ async function deliverPassEffects(stepped, { deliver, signal }) {async function recordDeliveries(deliveries) {if (deliveries.length === 0) return;await withStoreLock(async () => {- const { installs } = await readInstalls();+ const { schemaVersion: storeSchemaVersion, installs } = await readInstalls();let changed = false;for (const { id, tick, delivered, error } of deliveries) {const current = installs[id];@@ -489,7 +499,7 @@ async function recordDeliveries(deliveries) {installs[id] = { ...current, lastOutcome: { ...current.lastOutcome, delivered, deliveryError: error } };changed = true;}- if (changed) await writeInstalls(installs);+ if (changed) await writeInstalls(installs, storeSchemaVersion);});}@@ -537,7 +547,7 @@ async function tickOnce({gateMoved = gateMoved || next.record.armed !== record.armed;stepped.push(next);}- await writeInstalls(installs);+ await writeInstalls(installs, storeSchemaVersion);return {ticked: stepped.length,due: due.length,diff --git a/server/services/eidoverseControllerRuntime.test.js b/server/services/eidoverseControllerRuntime.test.jsindex cfe8dffc3a..8afef0012f 100644--- a/server/services/eidoverseControllerRuntime.test.js+++ b/server/services/eidoverseControllerRuntime.test.js@@ -395,6 +395,30 @@ describe('revalidating a stored install against its definition (#7629)', () => {expect(record.tick).toBe(0);expect(record.disarmedReason).toMatch(/newer than this build/);});++ it("never downgrades a newer stamp when it writes, so the guard survives the disarm that fires it", async () => {+ await install({ tickIntervalMs: MINUTE });+ const raw = await readJSONFile(storeFile(), null, { allowArray: false, strict: true });+ const newer = raw.schemaVersion + 1;+ await atomicWrite(storeFile(), { ...raw, schemaVersion: newer });++ // The disarming pass persists the record, and that write must not re-stamp+ // the file with THIS build’s older constant — doing so would erase the only+ // signal the guard reads, leaving it a one-shot.+ await runSupervisorPasses(1);+ expect((await readJSONFile(storeFile(), null, { allowArray: false, strict: true })).schemaVersion).toBe(newer);++ // So a re-arm (another write path) still lands on a newer-stamped store,+ // and the next pass refuses again instead of stepping under this build’s rules.+ await setEidoverseControllerArmed("plaza-beacon", true, { now: at(MINUTE) });+ expect((await readJSONFile(storeFile(), null, { allowArray: false, strict: true })).schemaVersion).toBe(newer);++ await runSupervisorPasses(1, { fromMs: 2 * MINUTE });+ const record = await getEidoverseControllerInstall("plaza-beacon");+ expect(record.armed).toBe(false);+ expect(record.tick).toBe(0);+ expect(record.disarmedReason).toMatch(/newer than this build/);+ });});describe('updateEidoverseControllerConfig (#7629)', () => {