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

stop a failed collection from flapping the Eidoverse visit marker (#7457)

[._.]/ Adam Eivye623bc60756e
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.md
index b3c3f7e2c2..d6eb4f9a46 100644
--- a/docs/features/eidoverse.md
+++ b/docs/features/eidoverse.md
@@ -978,6 +978,12 @@ and no conversation with its author required.
- **Never-observed is not nothing-new.** A first observation reports
`firstObservation: true` with no new items rather than handing a mind waking
into a months-old install its entire world as "new".
+- **A section that failed to collect is not an empty section.** It arrives as
+ `null`, contributes no changes, and **carries the previous marker's ids
+ forward**. Collapsing it to `[]` would report every peer as departed on a
+ transient read failure, rewrite the marker without them, and then report them
+ all as new on the next observation — a flap that repeats for as long as the
+ source keeps failing intermittently.
### The visit marker
diff --git a/server/lib/eidoverseObservation.js b/server/lib/eidoverseObservation.js
index 64553f3d65..b8d781eeee 100644
--- a/server/lib/eidoverseObservation.js
+++ b/server/lib/eidoverseObservation.js
@@ -16,6 +16,13 @@
* arguments, so the whole diff contract is testable without a world runtime,
* a socket, or a file.
*
+ * **Absent is never empty, here or in the trail.** A section that failed to
+ * collect arrives as `null` rather than `[]`, and an unavailable section
+ * contributes no changes and carries the previous marker's ids forward. A
+ * transient peer-read failure that presented as "no peers" would otherwise
+ * report every peer departed, rewrite the marker without them, and then report
+ * them all as new on the next observation.
+ *
* **Three things it must not do.** It must not require a running world — a
* mind that cannot start the runtime still needs to know what is in its
* Commons, so occupancy is derived from the live PortOS signals a projection
@@ -201,7 +208,8 @@ function observePeers(source, byPeer) {
* alarm.
*/
function observeControllers(installs) {
- return asArray(installs)
+ if (!Array.isArray(installs)) return null;
+ return installs
.filter((install) => install?.disarmedReason
|| (install?.consecutiveFailures ?? 0) > 0
|| install?.lastTickOk === false)
@@ -239,29 +247,52 @@ const NO_CHANGES = Object.freeze({
* diffing them would make `changes` noise instead of signal. The live count
* stays in `places` for a mind that wants it.
*/
-function diffAgainstMarker({ marker, foundationIds, peerIds, placeStatus, attentionControllerIds }) {
+function diffAgainstMarker({ marker, foundations, peers, controllers, placeStatus }) {
if (!marker) return { firstObservation: true, since: null, ...NO_CHANGES };
const seenFoundations = new Set(asArray(marker.foundationIds));
const seenPeers = new Set(asArray(marker.peerIds));
const seenAttention = new Set(asArray(marker.attentionControllerIds));
const previousPlaceStatus = marker.placeStatus && typeof marker.placeStatus === 'object' ? marker.placeStatus : {};
- const currentPeers = new Set(peerIds);
+ const currentPeers = new Set(peers.ids);
return {
firstObservation: false,
since: marker.observedAt ?? null,
- newFoundations: foundationIds.filter((id) => !seenFoundations.has(id)).slice(0, MAX_CHANGE_ENTRIES),
- newPeers: peerIds.filter((id) => !seenPeers.has(id)).slice(0, MAX_CHANGE_ENTRIES),
- departedPeers: [...seenPeers].filter((id) => !currentPeers.has(id)).sort().slice(0, MAX_CHANGE_ENTRIES),
+ newFoundations: foundations.available
+ ? foundations.ids.filter((id) => !seenFoundations.has(id)).slice(0, MAX_CHANGE_ENTRIES)
+ : [],
+ newPeers: peers.available
+ ? peers.ids.filter((id) => !seenPeers.has(id)).slice(0, MAX_CHANGE_ENTRIES)
+ : [],
+ departedPeers: peers.available
+ ? [...seenPeers].filter((id) => !currentPeers.has(id)).sort().slice(0, MAX_CHANGE_ENTRIES)
+ : [],
placesChanged: Object.entries(placeStatus)
.filter(([id, status]) => previousPlaceStatus[id] !== undefined && previousPlaceStatus[id] !== status)
.map(([id, status]) => ({ id, was: previousPlaceStatus[id], now: status }))
.slice(0, MAX_CHANGE_ENTRIES),
// Only controllers that were NOT already wanting attention last time, so a
// long-broken controller stops re-alarming every single wake.
- controllersNeedingAttention: attentionControllerIds.filter((id) => !seenAttention.has(id)).slice(0, MAX_CHANGE_ENTRIES),
+ controllersNeedingAttention: controllers.available
+ ? controllers.ids.filter((id) => !seenAttention.has(id)).slice(0, MAX_CHANGE_ENTRIES)
+ : [],
};
}
+/**
+ * An id list for one section, plus whether the section could be read at all.
+ *
+ * A section that FAILED to collect must not present as empty. Treating it as
+ * empty would report every peer as departed and every foundation as gone on a
+ * transient read failure, and — because the marker is rewritten from the same
+ * lists — would then report all of them as NEW again on the next observation.
+ * So an unavailable section contributes no changes and CARRIES FORWARD what
+ * the previous marker held, which is the absent-versus-empty rule applied to
+ * the trail itself.
+ */
+function section(ids, available, carriedForward) {
+ return available ? { ids, available: true } : { ids: asArray(carriedForward), available: false };
+}
+
const GUIDANCE = 'Observation before conversation: what you see here is this install\'s own world. '
+ 'Read `places` and `changes` first, act on what is already standing (eidoverse.foundations, '
+ 'eidoverse.controllers, eidoverse.augment), and only then reach for chat or a peer visit. '
@@ -281,9 +312,9 @@ export function buildEidoverseObservation({
source = {},
districts = EIDOVERSE_WORLD_DESIGN_V3.districts,
includes = EIDOVERSE_WORLD_DESIGN_V3.includes,
- foundations = [],
+ foundations = null,
foundationCounts = null,
- controllerInstalls = [],
+ controllerInstalls = null,
controllerCounts = null,
marker = null,
observedAt,
@@ -294,10 +325,25 @@ export function buildEidoverseObservation({
const peers = observePeers(source, byPeer);
const attentionControllers = observeControllers(controllerInstalls);
- const foundationIds = sortedUnique(asArray(foundations).map((entry) => entry?.id));
- const peerIds = sortedUnique(asArray(peers).map((entry) => entry.peerId));
+ // `null` means the section could not be read; `[]` means it read as empty.
+ // Collapsing the two here is what would make a transient failure flap — see
+ // `section()`.
+ const foundationSection = section(
+ sortedUnique(asArray(foundations).map((entry) => entry?.id)),
+ Array.isArray(foundations),
+ marker?.foundationIds,
+ );
+ const peerSection = section(
+ sortedUnique(asArray(peers).map((entry) => entry.peerId)),
+ peers !== null,
+ marker?.peerIds,
+ );
+ const controllerSection = section(
+ sortedUnique(asArray(attentionControllers).map((entry) => entry.id)),
+ attentionControllers !== null,
+ marker?.attentionControllerIds,
+ );
const placeStatus = Object.fromEntries(places.map(({ id, status }) => [id, status]));
- const attentionControllerIds = sortedUnique(attentionControllers.map((entry) => entry.id));
return {
report: {
@@ -314,16 +360,22 @@ export function buildEidoverseObservation({
counts: controllerCounts,
needsAttention: attentionControllers,
},
- changes: diffAgainstMarker({ marker, foundationIds, peerIds, placeStatus, attentionControllerIds }),
+ changes: diffAgainstMarker({
+ marker,
+ foundations: foundationSection,
+ peers: peerSection,
+ controllers: controllerSection,
+ placeStatus,
+ }),
guidance: GUIDANCE,
},
marker: {
schemaVersion: EIDOVERSE_OBSERVATION_SCHEMA_VERSION,
observedAt,
- foundationIds: foundationIds.slice(0, MAX_MARKER_FOUNDATION_IDS),
- peerIds,
+ foundationIds: foundationSection.ids.slice(0, MAX_MARKER_FOUNDATION_IDS),
+ peerIds: peerSection.ids,
placeStatus,
- attentionControllerIds,
+ attentionControllerIds: controllerSection.ids,
},
};
}
diff --git a/server/lib/eidoverseObservation.test.js b/server/lib/eidoverseObservation.test.js
index 407bd091e7..3192a93781 100644
--- a/server/lib/eidoverseObservation.test.js
+++ b/server/lib/eidoverseObservation.test.js
@@ -256,3 +256,59 @@ describe('the places a mind is told it is standing in', () => {
expect(apps.status).toBe('unknown');
});
});
+
+describe('a section that could not be read', () => {
+ const withPeer = () => observe({
+ source: { peers: [peerSignal(PEER_ALPHA)] },
+ foundations: [inheritedFoundation('peer:alpha:one', PEER_ALPHA)],
+ controllerInstalls: [{ id: 'broken', controllerId: 'lanternKeeper', armed: false, lastTickOk: false, consecutiveFailures: 2, disarmedReason: 'repeated failures' }],
+ });
+
+ it('does not report every peer as departed when the peer source failed', () => {
+ const first = withPeer();
+ const { report } = observe({ source: { peers: null }, marker: first.marker });
+
+ // A transient collection failure is not the whole federation leaving.
+ expect(report.peers).toBeNull();
+ expect(report.changes.departedPeers).toEqual([]);
+ expect(report.changes.newPeers).toEqual([]);
+ });
+
+ it('carries the previous marker forward so the next observation does not re-report everything as new', () => {
+ const first = withPeer();
+ const blind = observe({ source: { peers: null }, foundations: null, controllerInstalls: null, marker: first.marker });
+
+ // The failure must not erase the trail...
+ expect(blind.marker.peerIds).toEqual(first.marker.peerIds);
+ expect(blind.marker.foundationIds).toEqual(first.marker.foundationIds);
+ expect(blind.marker.attentionControllerIds).toEqual(first.marker.attentionControllerIds);
+
+ // ...so when collection recovers, nothing flaps back to "new".
+ const recovered = observe({
+ source: { peers: [peerSignal(PEER_ALPHA)] },
+ foundations: [inheritedFoundation('peer:alpha:one', PEER_ALPHA)],
+ controllerInstalls: [{ id: 'broken', controllerId: 'lanternKeeper', armed: false, lastTickOk: false, consecutiveFailures: 2, disarmedReason: 'repeated failures' }],
+ marker: blind.marker,
+ });
+ expect(recovered.report.changes.newPeers).toEqual([]);
+ expect(recovered.report.changes.newFoundations).toEqual([]);
+ expect(recovered.report.changes.controllersNeedingAttention).toEqual([]);
+ });
+
+ it('separates an unavailable controller list from one that is genuinely empty', () => {
+ expect(observe({ controllerInstalls: null }).report.controllers.needsAttention).toBeNull();
+ expect(observe({ controllerInstalls: [] }).report.controllers.needsAttention).toEqual([]);
+ });
+
+ it('still counts a district whose other sources read cleanly', () => {
+ const { report } = observe({
+ districts: [{ id: 'mix', label: 'Mix', direction: 'North', landmark: 'x', sources: ['apps', 'health'] }],
+ includes: { apps: true, health: true },
+ source: { apps: null, health: { status: 'healthy' } },
+ });
+
+ // One unreadable source must not discard a sibling's real signal; the
+ // district says which source it could not read instead.
+ expect(report.places[0]).toMatchObject({ signalCount: 1, status: 'active', unreadableSources: ['apps'] });
+ });
+});
diff --git a/server/services/eidoverseObservationLedger.js b/server/services/eidoverseObservationLedger.js
index 38b4516c21..a1383ed7d1 100644
--- a/server/services/eidoverseObservationLedger.js
+++ b/server/services/eidoverseObservationLedger.js
@@ -125,13 +125,19 @@ export async function observeEidoverseWorld({ signal, commit = true, now = () =>
source,
districts: design.districts,
includes: design.includes,
- foundations: ledger?.foundations || [],
+ // `null`, NOT `[]`, when the collection failed: an empty list would report
+ // every foundation as gone and then as new again next time, because the
+ // marker is rewritten from the same list. The builder carries an
+ // unavailable section forward instead.
+ foundations: Array.isArray(ledger?.foundations) ? ledger.foundations : null,
foundationCounts: ledger?.counts ?? null,
// Summarized, never raw: the pure lib reads `lastTickOk`/`lastTickReason`,
// which only exist on this projection — a raw record carries them inside
// `lastOutcome`, so handing one over would silently report every
// controller as never-ticked.
- controllerInstalls: (controllers?.installs || []).map((install) => summarizeControllerInstall(install)),
+ controllerInstalls: Array.isArray(controllers?.installs)
+ ? controllers.installs.map((install) => summarizeControllerInstall(install))
+ : null,
controllerCounts: controllers?.counts ?? null,
marker,
observedAt: now(),