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
Report a failed district read as unknown density, not an empty Commons (#7458)
[._.]/ Adam Eivy181476f4be3f
diff --git a/docs/features/persistent-mind-continuous-play.md b/docs/features/persistent-mind-continuous-play.mdindex d4df742b97..f7eeb1fb66 100644--- a/docs/features/persistent-mind-continuous-play.md+++ b/docs/features/persistent-mind-continuous-play.md@@ -26,6 +26,8 @@ Priority order when signals conflict: a still-sparse Commons always explores firA failure rate only exists when work actually ran. `getTodayActivity()` reports `successRate: 0` for a day with zero completed agents, so the derivation requires a non-empty sample before trusting it: an idle day yields *no* failure signal (falling back to coarse health, then to `null`), never a fabricated 100%. Without that guard every wake before the day's first completed task would claim a 100% failure rate and force `maintain`, starving `construct` and `coordinate` entirely.+The same absent-vs-empty rule governs density. A failed source read reaches the picker as `null`, not `[]`, so a projection whose district reads all failed derives `districtCount: null` ("world signals unavailable") rather than a confidently empty `0` — an outage and a genuinely empty Commons both explore, but only the latter claims to have measured anything.+Each phase template ends by naming itself (e.g. `Phase: Construct`) so the mind states its current phase in the wake's user-visible working note — how Helm and other minds can see which phase produced a given wake. `GET /api/cos/mind/context` also resolves the phase for preview (best-effort; a signal-read failure there falls back to the general loop rather than failing the request).## Mind-adjustable `numCtx`diff --git a/server/lib/persistentMindPlaybookPhase.js b/server/lib/persistentMindPlaybookPhase.jsindex 232eaa9967..c58d4b8d16 100644--- a/server/lib/persistentMindPlaybookPhase.js+++ b/server/lib/persistentMindPlaybookPhase.js@@ -43,8 +43,6 @@ const clampFractionOrNull = (value) => {return Math.max(0, Math.min(1, value));};-const arrayLength = (value) => (Array.isArray(value) ? value.length : 0);-/*** A failure rate only exists when work actually ran. `getTodayActivity()`* reports `successRate: 0` for a day with zero completed agents, so trusting@@ -87,11 +85,18 @@ export function derivePersistentMindPlaybookPhaseSignals(worldSignals) {return { districtCount: null, failureRate: null, peersWithActivity: null };}- const districtCount = [+ // A failed source read arrives as `null`, not `[]`. Counting those as zero+ // would report a confidently empty Commons when the truth is that nothing+ // could be read, so an all-null projection degrades to `null` ("unknown")+ // and only genuinely-present districts contribute to the count.+ const districtEntries = [worldSignals.apps, worldSignals.agents, worldSignals.tasks, worldSignals.features,worldSignals.peers, worldSignals.activity, worldSignals.goals, worldSignals.memory,worldSignals.storage, worldSignals.jira, worldSignals.operations,- ].reduce((total, entries) => total + arrayLength(entries), 0);+ ].filter((entries) => Array.isArray(entries));+ const districtCount = districtEntries.length > 0+ ? districtEntries.reduce((total, entries) => total + entries.length, 0)+ : null;const productivity = Array.isArray(worldSignals.productivity) ? worldSignals.productivity[0] : null;// `??` (not `||`) so a measured zero-failure day stays 0 rather thandiff --git a/server/lib/persistentMindPlaybookPhase.test.js b/server/lib/persistentMindPlaybookPhase.test.jsindex f5ad7f6d63..177cf35b7c 100644--- a/server/lib/persistentMindPlaybookPhase.test.js+++ b/server/lib/persistentMindPlaybookPhase.test.js@@ -131,6 +131,24 @@ describe('derivePersistentMindPlaybookPhaseSignals', () => {expect(signals.failureRate).toBe(0);});+ it('distinguishes every district read failing (null) from a genuinely empty Commons (0)', () => {+ // buildEidoverseWorldSignals() returns null per district when that source+ // read failed. Summing those as 0 would report a confidently empty world+ // and hide the outage behind "sparse Commons (0 live signal(s))".+ const allSourcesFailed = {+ apps: null, agents: null, tasks: null, features: null, peers: null,+ activity: null, goals: null, memory: null, storage: null, jira: null, operations: null,+ };+ expect(derivePersistentMindPlaybookPhaseSignals(allSourcesFailed).districtCount).toBeNull();+ expect(selectPersistentMindPlaybookPhase(derivePersistentMindPlaybookPhaseSignals(allSourcesFailed)).reason)+ .toContain('unavailable');++ // A district that really is empty still reports a measured zero.+ const measuredEmpty = derivePersistentMindPlaybookPhaseSignals({ ...allSourcesFailed, apps: [] });+ expect(measuredEmpty.districtCount).toBe(0);+ expect(selectPersistentMindPlaybookPhase(measuredEmpty).reason).toContain('sparse');+ });+it('counts only travelable peers reporting non-steady status as active', () => {const signals = derivePersistentMindPlaybookPhaseSignals({peers: [