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

feat: explain local Eidoverse district attention (#10048)

Adam Eivy0fa35d86258f
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.md
index 080c691d01..8ab6bc4917 100644
--- a/docs/features/eidoverse.md
+++ b/docs/features/eidoverse.md
@@ -1243,6 +1243,37 @@ and no conversation with its author required.
all as new on the next observation — a flap that repeats for as long as the
source keeps failing intermittently.
+### Local attention reasons
+
+Each place includes `attentionSignals` and `attentionTruncated`. Contributors
+identify the enabled, successfully read `source`, its actual `severity`
+(`attention` or `error`), its contributing `signalCount` (rows), and `reasons`.
+The district's total `signalCount` includes healthy rows and is not a fault count.
+An app group is one signal row even when it represents many applications.
+Each reason contains an allowlisted `code` and `affectedCount`, an aggregate
+number of affected records when known, otherwise `null`.
+
+Use `app_not_started`, `app_stopped`, and `app_unknown` to distinguish registry
+conditions before choosing a process diagnostic; not-started is not proof of a
+crash. Nexus can report `runtime_data_disk_pressure` or
+`runtime_data_disk_critical` (capacity of the filesystem holding runtime data),
+`memory_pressure` or `memory_critical`, `backup_failure`, `review_alerts`, and
+`cos_paused`. These come from the same predicates that determine source status;
+health does not alarm on not-started apps, while App Arcade does. Other sources
+and older reason-less inputs use `source_attention` or `source_error`: these
+say only that a coarse source status requires attention, without inventing a
+cause. Error sources remain identifiable even though district status is attention.
+
+Reasons are ordered by source, severity (error first), then code and capped at
+24 entries per district. `attentionTruncated: true` means some entries were
+omitted. Healthy recovery removes reasons on the next collection; disabled and
+unreadable sources emit none, and unavailable inputs never reuse previous causes.
+Diagnostics contain no app names, record identities, paths or raw errors. They
+are collected only for local observation under the existing mind
+`manageEidoverse` grant, without new routes, grants, world logs, renderer
+payloads or peer exports. A subsequent observe still advances the visit marker;
+use the internal `commit: false` form to inspect without consuming its delta.
+
### The visit marker
"What is new since I last looked" has to cross a **wake boundary**: a mind
diff --git a/server/lib/README.md b/server/lib/README.md
index 4b418f7d0d..77f8962949 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -674,7 +674,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `eidoverseObservation.js` | Pure observation-first discovery report for the Eidoverse (#7457) — the read behind `eidoverse.observe`. `buildEidoverseObservation` turns already-collected snapshots (world signals, the install's RESOLVED design districts/includes, the foundation ledger, summarized controller installs) plus the previously persisted visit marker into `{ report, marker }`: districts as places a mind can describe, peers keyed to the foundations inherited through each, a peer contribution's origin/arrival instances, controllers filtered to the ones actually failing, and a `changes` diff against the last visit. Places come from the recipe rather than a constant, so a mind never names a district a later design version renamed; an unreadable source stays `null` and a recipe-disabled one reports `disabled`, neither collapsing to `0`; a first observation reports `firstObservation` rather than declaring a settled world new; and places diff on status flips only so routine signal churn never becomes noise. Scalar-vs-list source shape is shared with the projection via `EIDOVERSE_SCALAR_SOURCE_KEYS`. Pure: the caller passes `observedAt` and decides whether to commit the returned marker. |
| `eidoverseWorldDesign.js` | Immutable Eidoverse World Design V1/V2/V3 registry, override migration, semantic districts, 48-signal ceiling, and install-local asset locks for PortOS Commons. |
| `eidoverseWorldLabels.js` | The `comp.label` component PortOS attaches to every entity it projects into Eidoverse (eidoverse-worlds#5), so a rendered building says what it represents instead of only naming its decorative model. `buildEidoverseLabel(component, alias?)` reads one already-built `comp.portos` payload and returns `{name, description?, visibility, offset?}` — district and world-identity landmarks always visible, live indicators labelled `nearby`, path markers `inspect`-only so a walkway cannot bury the district it leads to — and `null` for anything not `managedBy: 'portos'`, so a caller cannot label somebody else's entity. Names and descriptions are built from PortOS's own vocabulary (district label, kind label, resource category, coarse status, freshness) plus an opaque hashed resource ref for disambiguation, never from record contents, machine identity, addresses, or filesystem paths — the append-only world log is the strictest privacy boundary PortOS writes to. Also owns bounded opaque-key alias normalization and V1 renderer capability parsing; aliases are explicit opt-in names and are never inferred from private records. Owns `safeWorldText`, the one control-character/length sanitizer shared with `services/eidoverseWorldProjection.js` so a component field and the label built from it cannot disagree about what is safe. Pure. |
-| `eidoverseWorldSignals.js` | Pure raw-source-to-signal shaping: `buildEidoverseWorldSignals`, stable opaque host/peer IDs, storage and Jira aggregates; no service reads. |
+| `eidoverseWorldSignals.js` | Pure raw-source-to-signal shaping: `buildEidoverseWorldSignals`, stable opaque host/peer IDs, storage and Jira aggregates; optional local-observation reason metadata and the closed `EIDOVERSE_ATTENTION_REASON_CODES` vocabulary; no service reads. |
| `errorHandler.js` | `ServerError` + `asyncHandler` middleware, plus `sendErrorResponse`/`buildErrorEnvelope` for the standard `{ error, code, timestamp }` body outside a handler's catch. |
| `extensionErrors.js` | `isExtensionError(payload)` — true when a client error report came from a browser extension's injected content script (extension URL scheme in `source`/`stack`/`message`, or a short list of vendor/runtime message signatures) rather than from PortOS. Consumed by `services/clientErrors.js` to keep un-actionable extension noise out of the Review Hub *and* out of the 1/sec throttle slot, where it would displace real errors. Re-exported by `client/src/lib/extensionErrors.js`, so both sides classify identically. |
| `fetchErrorChain.js` | `describeFetchError(err)` flattens a fetch rejection's whole `cause` chain (depth-bounded, cycle-guarded) into one searchable `code: message` string — undici reports every network failure as the same opaque `TypeError: fetch failed` with the real reason nested inside, so a classifier reading only `err.message` misjudges every one of them. `isReplayableConnectionError(err)` is the narrow predicate over that string for connection-REUSE artifacts (HTTP/2 GOAWAY, reset, hang-up) that are safe to replay once via `fetchWithTimeout`'s `shouldRetry`; it deliberately EXCLUDES timeouts, which broader classifiers like `ollamaManager`'s `isTransientPullError` include. |
diff --git a/server/lib/eidoverseObservation.js b/server/lib/eidoverseObservation.js
index 5c2ccc8b5a..d851cadf01 100644
--- a/server/lib/eidoverseObservation.js
+++ b/server/lib/eidoverseObservation.js
@@ -39,9 +39,10 @@
import { asArray } from './arrayUtils.js';
import {
EIDOVERSE_SCALAR_SOURCE_KEYS,
+ EIDOVERSE_SOURCE_KEYS,
EIDOVERSE_WORLD_DESIGN_V3,
} from './eidoverseWorldDesign.js';
-import { eidoversePeerId } from './eidoverseWorldSignals.js';
+import { EIDOVERSE_ATTENTION_REASON_CODES, eidoversePeerId } from './eidoverseWorldSignals.js';
/** Storage-layout version stamped on the persisted visit marker. */
export const EIDOVERSE_OBSERVATION_SCHEMA_VERSION = 1;
@@ -55,6 +56,8 @@ const MAX_PEERS = 32;
const MAX_INHERITED = 20;
const MAX_ATTENTION_CONTROLLERS = 10;
const MAX_CHANGE_ENTRIES = 20;
+const MAX_ATTENTION_REASONS = 24;
+const ATTENTION_REASON_CODES = new Set([...EIDOVERSE_ATTENTION_REASON_CODES, 'source_attention', 'source_error']);
// Only `foundationIds` needs this: the other two marker lists are derived from
// report sections that are already capped far below it. An install that
// somehow exceeds it simply stops distinguishing the oldest ids as "seen",
@@ -79,18 +82,40 @@ const sortedUnique = (values) => [...new Set(asArray(values).filter(Boolean))].s
* would show a mind density that does not exist in the world.
*/
function readSource(source, key, includes) {
- if (includes?.[key] !== true) return { count: null, disabled: true, attention: false };
+ if (includes?.[key] !== true) return { count: null, disabled: true, contributors: [] };
const value = source?.[key];
- if (EIDOVERSE_SCALAR_SOURCE_KEYS.includes(key)) {
- if (value === null || value === undefined) return { count: null, disabled: false, attention: false };
- return { count: 1, disabled: false, attention: value.status === 'error' || value.status === 'attention' };
+ const scalar = EIDOVERSE_SCALAR_SOURCE_KEYS.includes(key);
+ if (scalar ? value === null || value === undefined : !Array.isArray(value)) {
+ return { count: null, disabled: false, contributors: [] };
}
- if (!Array.isArray(value)) return { count: null, disabled: false, attention: false };
- return {
- count: value.length,
- disabled: false,
- attention: value.some((item) => item?.status === 'error' || item?.status === 'attention'),
- };
+ const rows = scalar ? [value] : value;
+ const contributors = [];
+ // Aggregate by source severity, never by record identity. Stable code ordering
+ // and a closed vocabulary prevent private error text or row bags escaping.
+ for (const severity of ['error', 'attention']) {
+ const affectedRows = rows.filter((row) => row?.status === severity);
+ if (!affectedRows.length || !EIDOVERSE_SOURCE_KEYS.includes(key)) continue;
+ const reasons = new Map();
+ for (const row of affectedRows) {
+ const valid = asArray(row.attentionReasons).filter((reason) =>
+ ATTENTION_REASON_CODES.has(reason?.code));
+ const entries = valid.length ? valid : [{ code: `source_${severity}` }];
+ for (const reason of entries) {
+ const known = Number.isSafeInteger(reason.affectedCount) && reason.affectedCount >= 0;
+ const previous = reasons.get(reason.code);
+ reasons.set(reason.code, {
+ code: reason.code,
+ // Unknown counts stay unknown; a row is not necessarily one record.
+ affectedCount: known && (!previous || previous.affectedCount !== null)
+ ? Math.min(Number.MAX_SAFE_INTEGER, (previous?.affectedCount || 0) + reason.affectedCount) : null,
+ });
+ }
+ }
+ contributors.push({ source: key, severity, signalCount: affectedRows.length,
+ reasons: [...reasons.values()].sort((left, right) => left.code.localeCompare(right.code)) });
+ }
+ return { count: rows.length, disabled: false, contributors,
+ attention: rows.some((row) => row?.status === 'error' || row?.status === 'attention') };
}
/**
@@ -109,12 +134,25 @@ function observePlace(district, source, includes) {
let attention = false;
const unreadableSources = [];
const disabledSources = [];
+ const contributorsBySource = [];
+ let attentionTruncated = false;
+ let reasonCount = 0;
for (const key of district.sources) {
- const { count, disabled, attention: wantsAttention } = readSource(source, key, includes);
+ const { count, disabled, attention: wantsAttention, contributors } = readSource(source, key, includes);
if (disabled) disabledSources.push(key);
else if (count === null) unreadableSources.push(key);
else signalCount = (signalCount ?? 0) + count;
if (wantsAttention) attention = true;
+ contributorsBySource.push(...contributors);
+ }
+ const attentionSignals = [];
+ contributorsBySource.sort((left, right) => left.source.localeCompare(right.source)
+ || (left.severity === right.severity ? 0 : left.severity === 'error' ? -1 : 1));
+ for (const contributor of contributorsBySource) {
+ const reasons = contributor.reasons.slice(0, MAX_ATTENTION_REASONS - reasonCount);
+ if (reasons.length < contributor.reasons.length) attentionTruncated = true;
+ reasonCount += reasons.length;
+ if (reasons.length) attentionSignals.push({ ...contributor, reasons });
}
// Priority order, and `quiet` only when every enabled source read cleanly:
// an unreadable source must never render as an empty district.
@@ -131,6 +169,8 @@ function observePlace(district, source, includes) {
disabledSources,
signalCount,
status,
+ attentionSignals,
+ attentionTruncated,
};
}
diff --git a/server/lib/eidoverseObservation.test.js b/server/lib/eidoverseObservation.test.js
index ff007a0b2c..92e005c99b 100644
--- a/server/lib/eidoverseObservation.test.js
+++ b/server/lib/eidoverseObservation.test.js
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { buildEidoverseObservation } from './eidoverseObservation.js';
-import { eidoversePeerId } from './eidoverseWorldSignals.js';
+import { EIDOVERSE_ATTENTION_REASON_CODES, eidoversePeerId } from './eidoverseWorldSignals.js';
const OBSERVED_AT = '2026-09-16T12:00:00.000Z';
@@ -379,3 +379,40 @@ describe('a section that could not be read', () => {
expect(report.places[0]).toMatchObject({ signalCount: 1, status: 'active', unreadableSources: ['apps'] });
});
});
+
+
+describe('bounded attention projection', () => {
+ it('sanitizes reason metadata, aggregates unknown counts conservatively and truncates deterministically', () => {
+ const rows = ['error', 'attention'].map((status) => ({ status,
+ name: 'Example Secret App', path: '/invented/private/path', error: 'invented-error-token',
+ attentionReasons: [
+ ...EIDOVERSE_ATTENTION_REASON_CODES.map((code) => ({ code, affectedCount: 2, secret: 'invented-token' })),
+ { code: 'invented-secret-reason', affectedCount: 42 },
+ ],
+ }));
+ const districts = [{ id: 'test', sources: ['tasks', 'apps'] }];
+ const args = { districts, includes: { tasks: true, apps: true }, source: { apps: rows, tasks: rows } };
+ const place = observe(args).report.places[0];
+ expect(place.attentionSignals.flatMap((entry) => entry.reasons)).toHaveLength(24);
+ expect(place.attentionTruncated).toBe(true);
+ expect(place.attentionSignals.map((entry) => entry.source)).toEqual(['apps', 'apps', 'tasks']);
+ expect(observe({ ...args, districts: [{ id: 'test', sources: ['apps', 'tasks'] }],
+ source: { apps: [...rows].reverse(), tasks: [...rows].reverse() } }).report.places[0].attentionSignals).toEqual(place.attentionSignals);
+ const serialized = JSON.stringify(place.attentionSignals);
+ for (const secret of ['Example Secret App', '/invented/private/path', 'invented-error-token', 'invented-token', 'invented-secret-reason']) expect(serialized).not.toContain(secret);
+ const unknown = observe({ source: { apps: [rows[0], { status: 'error', attentionReasons: [{ code: 'app_unknown', affectedCount: NaN }] }] } }).report.places.find((entry) => entry.id === 'apps');
+ expect(unknown.attentionSignals[0].reasons).toContainEqual({ code: 'app_unknown', affectedCount: null });
+ });
+
+ it('keeps healthy, unreadable, disabled and legacy reason-less sources distinct without stale causes', () => {
+ const first = observe({ source: { apps: [{ status: 'error', attentionReasons: [{ code: 'app_unknown', affectedCount: 3 }] }] } });
+ const place = (args) => observe({ marker: first.marker, ...args }).report.places.find((row) => row.id === 'apps');
+ expect(place({ source: { apps: [{ status: 'active', attentionReasons: [{ code: 'app_unknown', affectedCount: 3 }] }] } })).toMatchObject({ attentionSignals: [], status: 'active' });
+ expect(place({ source: { apps: null } })).toMatchObject({ attentionSignals: [], signalCount: null, unreadableSources: ['apps'], status: 'unknown' });
+ expect(place({ source: { apps: [{ status: 'error' }] }, includes: { apps: false } })).toMatchObject({ attentionSignals: [], disabledSources: ['apps'] });
+ expect(place({ source: { apps: [{ status: 'error', attentionReasons: [{ code: 'raw-private-error' }] }, { status: 'attention' }] } }).attentionSignals).toEqual([
+ { source: 'apps', severity: 'error', signalCount: 1, reasons: [{ code: 'source_error', affectedCount: null }] },
+ { source: 'apps', severity: 'attention', signalCount: 1, reasons: [{ code: 'source_attention', affectedCount: null }] },
+ ]);
+ });
+});
diff --git a/server/lib/eidoverseWorldSignals.js b/server/lib/eidoverseWorldSignals.js
index bd896be395..32263faefd 100644
--- a/server/lib/eidoverseWorldSignals.js
+++ b/server/lib/eidoverseWorldSignals.js
@@ -23,6 +23,15 @@ export const eidoversePeerId = (peer) => opaqueId('peer', peer.instanceId || pee
export const eidoverseHostId = (instanceId) => `hst_${opaqueDigest('hst', instanceId, 'unknown-instance')}`;
+// Closed diagnostic vocabulary. Reasons are requested only by local observation;
+// the normal projection/renderer/federation collection keeps its historical shape.
+export const EIDOVERSE_ATTENTION_REASON_CODES = Object.freeze([
+ 'app_not_started', 'app_stopped', 'app_unknown',
+ 'backup_failure', 'review_alerts', 'cos_paused',
+ 'runtime_data_disk_pressure', 'runtime_data_disk_critical',
+ 'memory_pressure', 'memory_critical',
+]);
+
const coarseStatus = (value) => {
const status = String(value || '').toLowerCase();
if (/error|failed|unhealthy|offline|crash|blocked/.test(status)) return 'error';
@@ -85,13 +94,19 @@ function appSummary(apps) {
};
}
-function projectedApps(apps) {
+function projectedApps(apps, includeAttentionReasons) {
if (!Array.isArray(apps)) return null;
const groups = new Map();
for (const app of apps) {
const status = coarseStatus(app?.overallStatus);
- const group = groups.get(status) || { count: 0, managed: 0 };
+ const group = groups.get(status) || { count: 0, managed: 0, reasons: new Map() };
group.count += 1;
+ if (includeAttentionReasons && ['attention', 'error'].includes(status)) {
+ const code = { not_started: 'app_not_started', stopped: 'app_stopped', unknown: 'app_unknown' }[app?.overallStatus];
+ // Unknown/future spellings retain a coarse reason, never an invented cause.
+ const reason = code || `source_${status}`;
+ group.reasons.set(reason, (group.reasons.get(reason) || 0) + 1);
+ }
if (app?.managed === true) group.managed += 1;
groups.set(status, group);
}
@@ -103,6 +118,9 @@ function projectedApps(apps) {
status,
count: group.count,
managed: group.managed,
+ ...(includeAttentionReasons ? { attentionReasons: [...group.reasons]
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([code, affectedCount]) => ({ code, affectedCount })) } : {}),
}));
}
@@ -250,16 +268,20 @@ export function projectedStorage(introspection) {
return items;
}
-function projectedOperations({ cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent, inboxCounts }) {
+function projectedOperations({ cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent, inboxCounts }, includeAttentionReasons) {
const values = [cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent, inboxCounts];
if (!values.some((value) => value !== null && value !== undefined)) return null;
- const status = /failed|error|unhealthy/i.test(String(backupState?.status || ''))
- ? 'error'
- : ((review?.alert || 0) > 0 || cosStatus?.paused === true ? 'attention' : (cosStatus?.running ? 'active' : 'steady'));
+ const reasons = [];
+ if (/failed|error|unhealthy/i.test(String(backupState?.status || ''))) reasons.push({ code: 'backup_failure', severity: 'error' });
+ if ((review?.alert || 0) > 0) reasons.push({ code: 'review_alerts', severity: 'attention', affectedCount: nonNegativeOrNull(review.alert) });
+ if (cosStatus?.paused === true) reasons.push({ code: 'cos_paused', severity: 'attention' });
+ const status = reasons.some((reason) => reason.severity === 'error') ? 'error'
+ : reasons.length > 0 ? 'attention' : (cosStatus?.running ? 'active' : 'steady');
return [{
id: 'overview',
label: 'PortOS operations',
status,
+ ...(includeAttentionReasons ? { attentionReasons: reasons } : {}),
cos: cosStatus ? {
running: cosStatus.running === true,
paused: cosStatus.paused === true,
@@ -319,7 +341,7 @@ export function projectedJiraTickets(tickets) {
}));
}
-function healthSnapshot({ apps, cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent }) {
+function healthSnapshot({ apps, cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent }, includeAttentionReasons) {
const health = {
id: 'overview',
label: 'PortOS health',
@@ -354,16 +376,18 @@ function healthSnapshot({ apps, cosStatus, review, backupState, notifications, c
const available = [apps, cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent]
.some((value) => value !== null && value !== undefined);
if (!available) return null;
- const hasError = /failed|error|unhealthy/i.test(String(health.backup?.status || ''))
- || (health.diskPercent ?? 0) >= 95
- || (health.memory?.usedPercent ?? 0) >= 95;
- const needsAttention = (health.apps?.stopped || 0) > 0
- || (health.apps?.unknown || 0) > 0
- || (health.review?.alerts || 0) > 0
- || cosStatus?.paused === true
- || (health.diskPercent ?? 0) >= 85
- || (health.memory?.usedPercent ?? 0) >= 85;
- health.status = hasError ? 'error' : (needsAttention ? 'attention' : 'healthy');
+ const reasons = [];
+ if (/failed|error|unhealthy/i.test(String(health.backup?.status || ''))) reasons.push({ code: 'backup_failure', severity: 'error' });
+ for (const [value, prefix] of [[health.diskPercent, 'runtime_data_disk'], [health.memory?.usedPercent, 'memory']]) {
+ if ((value ?? 0) >= 95) reasons.push({ code: `${prefix}_critical`, severity: 'error' });
+ else if ((value ?? 0) >= 85) reasons.push({ code: `${prefix}_pressure`, severity: 'attention' });
+ }
+ if ((health.apps?.stopped || 0) > 0) reasons.push({ code: 'app_stopped', severity: 'attention', affectedCount: health.apps.stopped });
+ if ((health.apps?.unknown || 0) > 0) reasons.push({ code: 'app_unknown', severity: 'attention', affectedCount: health.apps.unknown });
+ if ((health.review?.alerts || 0) > 0) reasons.push({ code: 'review_alerts', severity: 'attention', affectedCount: health.review.alerts });
+ if (cosStatus?.paused === true) reasons.push({ code: 'cos_paused', severity: 'attention' });
+ health.status = reasons.some((reason) => reason.severity === 'error') ? 'error' : (reasons.length ? 'attention' : 'healthy');
+ if (includeAttentionReasons) health.attentionReasons = reasons;
return health;
}
@@ -376,7 +400,7 @@ export function buildEidoverseWorldSignals({
backupState, notifications, character, voiceConfig, memory, diskPercent,
todayActivity, activityCalendar, goalsData, memoryGraph,
inboxCounts, introspection, jira, destinations,
-}) {
+}, { includeAttentionReasons = false } = {}) {
const projectedAgents = Array.isArray(agents)
? agents.filter((agent) => ['running', 'paused'].includes(agent?.status)).map((agent, index) => ({
id: opaqueId('agent', agent.id, `agent-${index}`), label: 'Active agent', status: coarseStatus(agent.status),
@@ -404,10 +428,10 @@ export function buildEidoverseWorldSignals({
status: coarseStatus(peer.status),
}))
: null;
- const health = healthSnapshot({ apps, cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent });
+ const health = healthSnapshot({ apps, cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent }, includeAttentionReasons);
return {
- apps: projectedApps(apps),
+ apps: projectedApps(apps, includeAttentionReasons),
agents: projectedAgents,
tasks: projectedTasks,
features: projectedFeatures,
@@ -419,6 +443,6 @@ export function buildEidoverseWorldSignals({
memory: projectedMemory(memoryGraph),
storage: projectedStorage(introspection),
jira,
- operations: projectedOperations({ cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent, inboxCounts }),
+ operations: projectedOperations({ cosStatus, review, backupState, notifications, character, voiceConfig, memory, diskPercent, inboxCounts }, includeAttentionReasons),
};
}
diff --git a/server/lib/eidoverseWorldSignals.test.js b/server/lib/eidoverseWorldSignals.test.js
index 7ae40f5909..cc74756e67 100644
--- a/server/lib/eidoverseWorldSignals.test.js
+++ b/server/lib/eidoverseWorldSignals.test.js
@@ -84,3 +84,78 @@ describe('Agent Foundry task signals', () => {
expect(agentFoundryStatus(null, null)).toBe('unknown');
});
});
+
+
+describe('local attention reasons through builder-to-observation', () => {
+ const snapshots = (overallStatus = 'not_started') => ({
+ apps: [
+ { overallStatus: 'online', managed: true, name: 'Example Secret App' },
+ { overallStatus, managed: true, path: '/invented/private/path' },
+ { overallStatus: 'n/a', managed: false },
+ ],
+ featuresState: { features: Array.from({ length: 19 }, (_, i) => ({ id: `feature-${i}` })) },
+ diskPercent: 99, review: { alert: 1 }, cosStatus: { running: true, paused: false },
+ backupState: { status: 'complete' }, agents: [], taskState: { tasks: [{ status: 'pending' }] },
+ destinations: new Set(),
+ });
+ const project = (input) => buildEidoverseWorldSignals(input, { includeAttentionReasons: true });
+ const place = (source, id) => buildEidoverseObservation({ source }).report.places.find((row) => row.id === id);
+
+ it.each(['not_started', 'stopped', 'unknown'])('explains %s while preserving district totals and status', (status) => {
+ const input = snapshots(status);
+ const source = project(input);
+ expect(place(source, 'nexus')).toMatchObject({ signalCount: 21, status: 'attention', unreadableSources: [],
+ attentionSignals: [
+ { source: 'health', severity: 'error', signalCount: 1, reasons: expect.arrayContaining([
+ { code: 'runtime_data_disk_critical', affectedCount: null }, { code: 'review_alerts', affectedCount: 1 },
+ ]) },
+ { source: 'operations', severity: 'attention', signalCount: 1, reasons: [{ code: 'review_alerts', affectedCount: 1 }] },
+ ], attentionTruncated: false,
+ });
+ expect(place(source, 'apps')).toMatchObject({ signalCount: 3, status: 'attention', unreadableSources: [],
+ attentionSignals: [{ source: 'apps', severity: 'attention', signalCount: 1,
+ reasons: [{ code: `app_${status}`, affectedCount: 1 }] }],
+ });
+ expect(place(source, 'agents').attentionSignals).toEqual([]);
+ // Ordinary collection still feeds the renderer with its exact old shape.
+ const normal = buildEidoverseWorldSignals(input);
+ expect(JSON.stringify(normal)).not.toContain('attentionReasons');
+ expect(normal.health.status).toBe(source.health.status);
+ expect(normal.apps.map((row) => row.status)).toEqual(source.apps.map((row) => row.status));
+ if (status === 'not_started') expect(source.health.attentionReasons.map((reason) => reason.code)).not.toContain('app_not_started');
+ });
+
+ it('keeps represented app counts distinct from signal rows and uses coarse future-status fallback', () => {
+ const source = project({ apps: [
+ ...Array.from({ length: 7 }, () => ({ overallStatus: 'not_started' })),
+ { overallStatus: 'stopped' }, { overallStatus: 'failed' },
+ ] });
+ expect(place(source, 'apps').attentionSignals).toEqual([
+ { source: 'apps', severity: 'error', signalCount: 1, reasons: [{ code: 'source_error', affectedCount: 1 }] },
+ { source: 'apps', severity: 'attention', signalCount: 1, reasons: [
+ { code: 'app_not_started', affectedCount: 7 }, { code: 'app_stopped', affectedCount: 1 },
+ ] },
+ ]);
+ });
+
+ it('ties pressure, backup and paused reasons to the existing health/operations thresholds and recovers', () => {
+ const input = { diskPercent: 85, memory: { used: 95, total: 100 },
+ backupState: { status: 'failed', error: 'invented-secret-error' }, cosStatus: { paused: true } };
+ const first = project(input);
+ expect(place(first, 'nexus').attentionSignals).toEqual([
+ { source: 'health', severity: 'error', signalCount: 1, reasons: [
+ { code: 'backup_failure', affectedCount: null }, { code: 'cos_paused', affectedCount: null },
+ { code: 'memory_critical', affectedCount: null }, { code: 'runtime_data_disk_pressure', affectedCount: null },
+ ] },
+ { source: 'operations', severity: 'error', signalCount: 1, reasons: [
+ { code: 'backup_failure', affectedCount: null }, { code: 'cos_paused', affectedCount: null },
+ ] },
+ ]);
+ expect(place(project({ diskPercent: 95, memory: { used: 85, total: 100 } }), 'nexus').attentionSignals[0].reasons).toEqual([
+ { code: 'memory_pressure', affectedCount: null }, { code: 'runtime_data_disk_critical', affectedCount: null },
+ ]);
+ const healthy = project({ diskPercent: 84, memory: { used: 84, total: 100 }, backupState: { status: 'complete' }, cosStatus: { paused: false } });
+ expect(place(healthy, 'nexus').attentionSignals).toEqual([]);
+ expect(place(healthy, 'nexus').status).toBe('active');
+ });
+});
diff --git a/server/services/cosToolRegistry.js b/server/services/cosToolRegistry.js
index 5460dbc8a9..13d5e6385a 100644
--- a/server/services/cosToolRegistry.js
+++ b/server/services/cosToolRegistry.js
@@ -492,7 +492,7 @@ const eidoverseObserveTool = Object.freeze({
version: COS_TOOL_SCHEMA_VERSION,
providerName: providerToolName('eidoverse.observe'),
aliases: [providerToolName('eidoverse.observe')],
- description: 'Tour this install\'s own Eidoverse and see what is already standing — start here, before eidoverse.say, eidoverse.chat, or a peer visit. Returns `places` (the eight districts: what feeds each, how many live PortOS signals it currently reports, and whether any want attention), `peers` (opaque travel ids usable with eidoverse.visit, each with how many foundations this install inherited through it), `foundations.inherited` (a peer\'s contributions, newest first, with the peer they arrived through and the instance that authored them), `controllers.needsAttention` (only installs that are disarmed or failing — a controller that has never ticked yet is not an alarm), and `changes` (what is new since you last observed). `signalCount` counts what a district\'s sources report, not placed entities: the world holds a capped sample of them. A null section means that source could not be read, which is NOT the same as empty. Observing STAMPS a visit marker, so it is not idempotent — the next call\'s `changes` is measured from this one, and your first ever observation reports `firstObservation: true` with no new items rather than calling a settled world new.',
+ description: 'Tour this install\'s own Eidoverse and see what is already standing — start here, before eidoverse.say, eidoverse.chat, or a peer visit. Returns `places` (the eight districts: what feeds each, how many live PortOS signals it currently reports, and whether any want attention), `peers` (opaque travel ids usable with eidoverse.visit, each with how many foundations this install inherited through it), `foundations.inherited` (a peer\'s contributions, newest first, with the peer they arrived through and the instance that authored them), `controllers.needsAttention` (only installs that are disarmed or failing — a controller that has never ticked yet is not an alarm), and `changes` (what is new since you last observed). `signalCount` counts what a district\'s sources report, not placed entities: the world holds a capped sample of them. Each place also returns local-only `attentionSignals`: contributing source, actual severity (`error` or `attention`), contributing signal-row count, and allowlisted reason codes with `affectedCount` (null when unknown). Use these to choose a diagnostic action: app_not_started is not proof of a crash; runtime_data_disk_pressure/critical concern the runtime-data filesystem; review_alerts concern pending review alerts. Other codes cover app_stopped, app_unknown, backup_failure, cos_paused and memory_pressure/critical; source_attention/error are explicitly coarse fallbacks. District totals are not fault counts. At most 24 reason entries per district are returned; `attentionTruncated` indicates omissions. A null section means that source could not be read, which is NOT the same as empty. Observing STAMPS a visit marker, so it is not idempotent — the next call\'s `changes` is measured from this one, and your first ever observation reports `firstObservation: true` with no new items rather than calling a settled world new.',
input_schema: zodToOpenApiSchema(z.object({}).strict()),
output_schema: objectOutputSchema,
policy: {
diff --git a/server/services/eidoverseObservationLedger.js b/server/services/eidoverseObservationLedger.js
index 7c2b422b7b..fce498cf8d 100644
--- a/server/services/eidoverseObservationLedger.js
+++ b/server/services/eidoverseObservationLedger.js
@@ -114,7 +114,7 @@ async function resolveDesign() {
export async function observeEidoverseWorld({ signal, commit = true, source: collectedSource = null, now = () => new Date().toISOString() } = {}) {
const [source, ledger, controllers, design] = await Promise.all([
collectedSource ?? import('./eidoverseWorldSources.js')
- .then((module) => module.collectEidoverseWorldSources({ signal }))
+ .then((module) => module.collectEidoverseWorldSources({ signal, includeAttentionReasons: true }))
.catch(() => ({})),
import('./eidoverseFoundationLedger.js')
.then((module) => module.listEidoverseFoundations())
diff --git a/server/services/eidoverseWorldSources.js b/server/services/eidoverseWorldSources.js
index c28969ba3a..6b24f6bc5e 100644
--- a/server/services/eidoverseWorldSources.js
+++ b/server/services/eidoverseWorldSources.js
@@ -85,7 +85,7 @@ async function projectedJira(appConfig, featuresState) {
return projectedJiraTickets(batches.flatMap((batch) => batch.tickets));
}
-export async function collectEidoverseWorldSources({ signal } = {}) {
+export async function collectEidoverseWorldSources({ signal, includeAttentionReasons = false } = {}) {
throwIfAborted(signal);
const reads = await waitWithSignal(Promise.all([
getAppStatuses().catch(() => null),
@@ -120,5 +120,5 @@ export async function collectEidoverseWorldSources({ signal } = {}) {
backupState, notifications, character, voiceConfig, memory, diskPercent,
todayActivity, activityCalendar, goalsData, memoryGraph,
inboxCounts, introspection, jira, destinations,
- });
+ }, { includeAttentionReasons });
}
diff --git a/server/services/eidoverseWorldSources.test.js b/server/services/eidoverseWorldSources.test.js
index 78759e7d18..cd8177fc0a 100644
--- a/server/services/eidoverseWorldSources.test.js
+++ b/server/services/eidoverseWorldSources.test.js
@@ -1,11 +1,26 @@
-import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import { statfs } from 'node:fs/promises';
import { PATHS } from '../lib/paths.js';
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy } from '../lib/mockPathsDataRoot.js';
+
+const dataRoot = () => lazyTempDataRoot('portos-observation-dispatch-');
+vi.mock('../lib/fileUtils.js', async (importOriginal) => makePathsProxy(await importOriginal(), { dataRoot }));
+vi.mock('./persistentMindTaskCapability.js', () => ({ executePersistentMindTaskRequests: vi.fn() }));
+vi.mock('./persistentMindMaintenance.js', () => ({ cleanupPersistentMind: vi.fn() }));
+vi.mock('./voice/tools.js', () => ({ getToolSpecs: () => [], getToolSpecsForIntent: () => ({ specs: [] }), dispatchTool: vi.fn() }));
+vi.mock('./eidoverseFoundationLedger.js', () => ({ listEidoverseFoundations: async () => ({ foundations: [], counts: {} }) }));
+vi.mock('./eidoverseControllerRuntime.js', () => ({ listEidoverseControllers: async () => ({ installs: [], counts: {} }) }));
+vi.mock('./eidoverseWorld.js', () => ({ readEidoverseWorldRecipe: async () => null }));
+vi.mock('./eidoverseTravel.js', () => ({ listEidoverseDestinations: async () => ({ destinations: [] }) }));
+afterAll(cleanupTempDataRoots);
const sources = vi.hoisted(() => ({}));
-vi.mock('node:fs/promises', () => ({
+vi.mock('node:fs/promises', async (importOriginal) => ({
+ ...await importOriginal(),
statfs: vi.fn(async () => ({
blocks: 100,
bsize: 1,
@@ -217,3 +232,53 @@ describe('Eidoverse world source aggregation', () => {
expect(JSON.stringify(result.productivity)).not.toContain('Example private task');
});
});
+
+
+describe('semantic observation authority and marker workflow', () => {
+ it('delivers fresh bounded collector reasons only to a granted mind and preserves the observation delta', async () => {
+ const { executeCosToolCall } = await import('./cosToolRegistry.js');
+ const { observeEidoverseWorld } = await import('./eidoverseObservationLedger.js');
+ sources.apps = [
+ { overallStatus: 'online', managed: true },
+ { overallStatus: 'not_started', managed: true, name: 'Example Secret App',
+ token: 'invented-token', path: '/invented/private/path', host: 'host-XXXX.example.com', error: 'invented-raw-error' },
+ { overallStatus: 'n/a', managed: false },
+ ];
+ sources.featuresState = { features: Array.from({ length: 19 }, (_, i) => ({ id: `feature-${i}` })) };
+ sources.diskPercent = 99;
+ sources.review = { alert: 1 };
+ sources.cosStatus = { running: true, paused: false };
+ const call = { requestId: 'observation-granted-first', name: 'eidoverse.observe', arguments: {} };
+ await expect(executeCosToolCall({ call, authority: { scope: 'mind', capabilities: {} } })).rejects.toMatchObject({ code: 'TOOL_CAPABILITY_DENIED' });
+ const authority = { scope: 'mind', capabilities: { manageEidoverse: true, toolExposureAllSchemas: true } };
+ const first = await executeCosToolCall({ call, authority });
+ expect(first.state).toBe('completed');
+ expect(first.result.changes.firstObservation).toBe(true);
+ expect(first.result.places.find((place) => place.id === 'nexus')).toMatchObject({ signalCount: 21,
+ attentionSignals: [
+ { source: 'health', severity: 'error', signalCount: 1, reasons: [
+ { code: 'review_alerts', affectedCount: 1 }, { code: 'runtime_data_disk_critical', affectedCount: null },
+ ] },
+ { source: 'operations', severity: 'attention', signalCount: 1, reasons: [{ code: 'review_alerts', affectedCount: 1 }] },
+ ],
+ });
+ expect(first.result.places.find((place) => place.id === 'apps').attentionSignals[0].reasons).toEqual([{ code: 'app_not_started', affectedCount: 1 }]);
+ const serialized = JSON.stringify(first.result);
+ for (const secret of ['Example Secret App', 'invented-token', '/invented/private/path', 'host-XXXX.example.com', 'invented-raw-error']) expect(serialized).not.toContain(secret);
+ const markerPath = join(dataRoot(), 'eidoverse', 'observation.json');
+ const beforePeek = readFileSync(markerPath, 'utf8');
+ expect(beforePeek).not.toContain('attentionReasons');
+ sources.apps = [{ overallStatus: 'online' }]; sources.diskPercent = 10; sources.review = { alert: 0 };
+ const peek = await observeEidoverseWorld({ commit: false });
+ expect(peek.places.find((place) => place.id === 'nexus').attentionSignals).toEqual([]);
+ expect(readFileSync(markerPath, 'utf8')).toBe(beforePeek);
+ const next = await executeCosToolCall({ call: { ...call, requestId: 'observation-granted-next' }, authority });
+ expect(next.result.changes).toMatchObject({ firstObservation: false, since: first.result.observedAt,
+ placesChanged: expect.arrayContaining([{ id: 'nexus', was: 'attention', now: 'active' }, { id: 'apps', was: 'attention', now: 'active' }]),
+ });
+ sources.apps = null; sources.diskPercent = undefined; sources.memory = null; sources.review = null;
+ const unavailable = await executeCosToolCall({ call: { ...call, requestId: 'observation-granted-unavailable' }, authority });
+ expect(unavailable.result.places.find((place) => place.id === 'apps')).toMatchObject({ attentionSignals: [], unreadableSources: ['apps'] });
+ expect(unavailable.result.places.find((place) => place.id === 'nexus').attentionSignals).toEqual([]);
+ });
+});