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

fix: stop the Eidoverse Agent Foundry alarming on an ordinary queued task

Adam Eivy78472840f478
diff --git a/server/lib/eidoverseWorldSignals.js b/server/lib/eidoverseWorldSignals.js
index 6b98d9af48..5990e8c126 100644
--- a/server/lib/eidoverseWorldSignals.js
+++ b/server/lib/eidoverseWorldSignals.js
@@ -31,6 +31,39 @@ const coarseStatus = (value) => {
return 'steady';
};
+/**
+ * CoS task status -> world signal, mapped EXPLICITLY rather than through
+ * `coarseStatus`'s word matcher.
+ *
+ * The generic matcher reads a work queue backwards. `pending` contains the
+ * word "pending", so it lands on `attention`; `challenged` (#2441 — a
+ * sub-agent disputing a reviewer rejection, which is stuck until a human rules
+ * on it) matches nothing at all and lands on `steady`. Because `observePlace`
+ * ORs its sources' attention flags, ONE queued task — the resting state of any
+ * work queue — flipped the Agent Foundry to `attention`, while a genuinely
+ * stuck one stayed silent. The district then read `active` only in the narrow
+ * window where every open task happened to be in flight, so it flapped on
+ * ordinary queue churn and its alarm carried no information.
+ *
+ * Task status is a CLOSED vocabulary (`TASK_STATUS_VALUES` in `taskParser.js`),
+ * so it is decided by name rather than by word-matching. The line it draws:
+ * waiting on a WORKER is ordinary, waiting on a HUMAN is attention.
+ *
+ * Attention is the DEFAULT rather than a listed case, so a status added to the
+ * vocabulary later — or a hand-edited marker `parseTasksMarkdown` could not
+ * represent, which it returns as its raw token — surfaces instead of going
+ * quiet. That matches how the parser itself treats an unrepresentable status:
+ * `toRepresentableTask` parks it as `blocked` with an `unknown-status`
+ * category, i.e. as something a human has to look at.
+ */
+const taskSignalStatus = (task) => {
+ const status = String(task?.status || 'pending').toLowerCase();
+ if (status === 'blocked') return 'error';
+ if (status === 'in_progress') return 'active';
+ if (status === 'pending') return task?.approvalRequired === true ? 'attention' : 'steady';
+ return 'attention';
+};
+
const finiteOrNull = (value) => typeof value === 'number' && Number.isFinite(value) ? value : null;
const nonNegativeOrNull = (value) => {
const number = finiteOrNull(value);
@@ -361,7 +394,7 @@ export function buildEidoverseWorldSignals({
? taskState.tasks
.filter((task) => !['completed', 'done', 'archived'].includes(String(task?.status || '').toLowerCase()))
.map((task, index) => ({
- id: opaqueId('task', task.id, `task-${index}`), label: 'Active task', status: coarseStatus(task.status || 'pending'),
+ id: opaqueId('task', task.id, `task-${index}`), label: 'Active task', status: taskSignalStatus(task),
}))
: null;
const projectedFeatures = Array.isArray(featuresState?.features)
diff --git a/server/lib/eidoverseWorldSignals.test.js b/server/lib/eidoverseWorldSignals.test.js
index add3686d51..7ae40f5909 100644
--- a/server/lib/eidoverseWorldSignals.test.js
+++ b/server/lib/eidoverseWorldSignals.test.js
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
-import { eidoverseHostId, eidoversePeerId } from './eidoverseWorldSignals.js';
+import { buildEidoverseObservation } from './eidoverseObservation.js';
+import { buildEidoverseWorldSignals, eidoverseHostId, eidoversePeerId } from './eidoverseWorldSignals.js';
describe('Eidoverse public identity compatibility', () => {
// Fixed outputs from the pre-extraction collector: changing these identities
@@ -20,3 +21,66 @@ describe('Eidoverse public identity compatibility', () => {
expect(eidoversePeerId({})).toBe('peer-f486350022b1');
});
});
+
+describe('Agent Foundry task signals', () => {
+ // Regression: the Agent Foundry read `attention` whenever ONE task sat in
+ // the queue, because `pending` matched the generic status word-matcher,
+ // while a `challenged` task — stuck until a human rules on it — matched
+ // nothing and read `steady`. The district ORs its sources, so the alarm
+ // fired on the resting state of the queue and stayed silent on the one
+ // status that actually wanted someone. Asserted through the district that
+ // consumes the signal, because the flip a mind acts on is the district's,
+ // not the individual task's.
+ const agentFoundryStatus = (tasks, agents = [{ id: 'agent-1', status: 'running' }]) => {
+ const source = buildEidoverseWorldSignals({
+ agents,
+ taskState: { tasks },
+ destinations: new Set(),
+ });
+ const { report } = buildEidoverseObservation({ source });
+ return report.places.find((place) => place.id === 'agents').status;
+ };
+
+ it('treats a queued task as ordinary work and reserves attention for a human decision', () => {
+ expect(agentFoundryStatus([{ id: 'task-1', status: 'pending' }])).toBe('active');
+ expect(agentFoundryStatus([
+ { id: 'task-1', status: 'pending' },
+ { id: 'task-2', status: 'in_progress' },
+ ])).toBe('active');
+
+ expect(agentFoundryStatus([{ id: 'task-1', status: 'pending', approvalRequired: true }])).toBe('attention');
+ expect(agentFoundryStatus([{ id: 'task-1', status: 'challenged' }])).toBe('attention');
+ expect(agentFoundryStatus([{ id: 'task-1', status: 'blocked' }])).toBe('attention');
+ expect(agentFoundryStatus(
+ [{ id: 'task-1', status: 'pending' }],
+ [{ id: 'agent-1', status: 'paused' }],
+ )).toBe('attention');
+ });
+
+ it('maps each task status to its own signal and drops finished work', () => {
+ const source = buildEidoverseWorldSignals({
+ agents: [],
+ taskState: {
+ tasks: [
+ { id: 'task-pending', status: 'pending' },
+ { id: 'task-approval', status: 'pending', approvalRequired: true },
+ { id: 'task-progress', status: 'in_progress' },
+ { id: 'task-blocked', status: 'blocked' },
+ { id: 'task-challenged', status: 'challenged' },
+ { id: 'task-hand-edited', status: '[>]' },
+ { id: 'task-done', status: 'completed' },
+ ],
+ },
+ destinations: new Set(),
+ });
+ expect(source.tasks.map((task) => task.status)).toEqual([
+ 'steady', 'attention', 'active', 'error', 'attention', 'attention',
+ ]);
+ });
+
+ it('keeps an unreadable task list distinct from an empty one', () => {
+ expect(agentFoundryStatus([])).toBe('active');
+ expect(agentFoundryStatus([], [])).toBe('quiet');
+ expect(agentFoundryStatus(null, null)).toBe('unknown');
+ });
+});