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
feat: stamp producing instanceId on every spawned CoS agent (#1563)
[._.]/ Adam Eivy6705879cf5ff
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 548b5c226f..acd5e018a2 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -10,6 +10,8 @@- **The CoS → Schedule page is now a scannable card grid instead of a flat expandable list.** Each task type renders as a status card you can read at a glance — a colored status dot (active / on-demand / waiting-on-deps / disabled), a **next-run countdown** ("in 3h", "Mon 9:00") that was previously computed server-side but never shown, an app-coverage bar with the enabled/total count kept front-and-center, and last-run/run-count. Cards sort by status then soonest next run (so what's about to run rises to the top), the All/Enabled toggle is replaced by per-status filters (Active / On-Demand / Waiting / Disabled), and a name filter box jumps to a task quickly. A **Run** button sits on each card — for app-targeting tasks it opens an app picker so the on-demand run carries app context (just like the old per-task controls), and falls back to a plain global run for tasks with no managed apps; **Configure** opens a slide-over drawer with the full per-task settings (interval, provider/model, prompt, agent options, dependencies, pipeline stages, and per-app overrides) — the same controls as before, now in a focused panel that's deep-linkable via `?task=` and closes on Esc/backdrop. Mobile collapses the grid to a single column.+- **[issue-1563] Every Chief-of-Staff agent now records which machine produced it.** As a first step toward federating CoS agent history across peers, each spawned agent stamps the producing instance's federation identity (`instanceId`) into its metadata at registration. The stamp flows through to the agent's archived `metadata.json` automatically, so once agent history syncs between a node pair, each agent — and the worktree branch it created — can be attributed to the instance that ran it. This is the provenance prerequisite for the claim/lease ownership work that lets two federated peers share a backlog without ever duplicating each other's agent runs. (`server/services/agentLifecycle.js`)+## Local LLMs- **The Hugging Face model search now lets you pick a quantization, and defaults to the highest-fidelity build that fits your machine's memory.** Previously every GGUF repo installed a single auto-chosen Q4-ish quant, hiding larger variants (like a `…-BF16.gguf`) that a big-memory box can comfortably run. Each Hugging Face result now carries a **Quant** menu listing every GGUF variant in the repo (multi-part shards summed into one entry), with a per-quant fit hint — *fits comfortably* / *tight fit* / *exceeds RAM* — measured against your usable memory. The default selection is RAM-aware: PortOS reserves headroom for the OS and KV cache, then picks the largest variant that still fits (so a 128 GB unified-memory Mac defaults to BF16/Q8 where a 16 GB laptop stays on Q4), and you can override it per model. This is purely a file-picker improvement — these are all still GGUF files the existing Ollama/LM Studio runtimes already support; nothing about the GGUF-only requirement changed (raw safetensors/full-precision HF models need a different runtime and remain out of scope). Ollama installs via `hf.co/<repo>:<quant>`; LM Studio via `<repo>@<quant>`.diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.jsindex 034edf2b01..dc82b4a707 100644--- a/server/services/agentLifecycle.js+++ b/server/services/agentLifecycle.js@@ -27,6 +27,7 @@ import { extractCodexAssistantTail } from '../lib/codexAssistantExtract.js';import { buildTuiSpawnConfig, spawnTuiAgent } from './agentTuiSpawning.js';import { processAgentCompletion } from './agentCompletion.js';import { releaseAppReviewMarker } from './appActivity.js';+import { getInstanceId } from './instances.js';import { runnerAgents, pausedAgents, spawningTasks, useRunner, isTruthyMeta } from './agentState.js';import { v4 as uuidv4 } from '../lib/uuid.js';@@ -257,8 +258,18 @@ export async function spawnAgentForTask(task) {const { runId } = await createAgentRun(agentId, task, selectedModel, provider, workspacePath, resolvedAppName);const executionMode = isTui ? 'tui' : useRunner ? 'runner' : 'direct';- // Register the agent with model info+ // Register the agent with model info.+ //+ // `instanceId` stamps the producing machine's federation identity onto every+ // spawned agent (issue #1563, acceptance criterion 1). It flows through to+ // the completed-agent archive's `metadata.json` automatically (completeAgent+ // serializes `.metadata`), so once CoS agent history federates across peers a+ // node pair can attribute each agent + its worktree branch to the instance+ // that produced it. `getInstanceId()` never throws — it returns the+ // `UNKNOWN_INSTANCE_ID` sentinel before the local identity is initialized.+ const instanceId = await getInstanceId();await registerAgent(agentId, task.id, {+ instanceId,workspacePath,sourceWorkspace: worktreeInfo ? (task.metadata?.app ? await getAppWorkspace(task.metadata.app) : ROOT_DIR) : null,worktreeBranch: worktreeInfo?.branchName || null,diff --git a/server/services/agentLifecycle.test.js b/server/services/agentLifecycle.test.jsindex 8762b51cfc..e9e9674bbe 100644--- a/server/services/agentLifecycle.test.js+++ b/server/services/agentLifecycle.test.js@@ -647,6 +647,43 @@ describe('spawnAgentForTask — cleanupOnError error recovery', () => {});});+// ─── Instance provenance stamping (issue #1563, acceptance criterion 1) ──────+//+// Every spawned agent must record the producing machine's federation identity+// so that, once CoS agent history federates across peers (the rest of #1563),+// a node pair can attribute each agent + its worktree branch to the instance+// that produced it — the prerequisite for never duplicating agent work. The+// stamp rides in the `registerAgent` metadata and propagates into the+// completed-agent archive's `metadata.json` automatically, since `completeAgent`+// serializes `.metadata`. These source-level assertions break loudly if a+// future refactor drops the stamp.+describe('agentLifecycle — instance provenance stamping (#1563)', () => {+ it('source: imports getInstanceId from the instances service', () => {+ expect(AGENT_LIFECYCLE_SRC).toMatch(+ /import\s*\{\s*getInstanceId\s*\}\s*from\s*'\.\/instances\.js';/+ );+ });++ it('source: resolves instanceId via getInstanceId() before registering the agent', () => {+ const fnStart = AGENT_LIFECYCLE_SRC.indexOf('export async function spawnAgentForTask');+ const fnBody = AGENT_LIFECYCLE_SRC.slice(fnStart, fnStart + 60_000);+ const resolveIdx = fnBody.indexOf('await getInstanceId()');+ const registerIdx = fnBody.indexOf('registerAgent(agentId, task.id, {');+ expect(resolveIdx, '`await getInstanceId()` must exist inside spawnAgentForTask').toBeGreaterThan(-1);+ expect(registerIdx, '`registerAgent(...)` must exist inside spawnAgentForTask').toBeGreaterThan(-1);+ expect(resolveIdx, 'instanceId must be resolved BEFORE registerAgent is called').toBeLessThan(registerIdx);+ });++ it('source: stamps instanceId into the registerAgent metadata', () => {+ const registerIdx = AGENT_LIFECYCLE_SRC.indexOf('registerAgent(agentId, task.id, {');+ // The metadata object literal opens at registerIdx; assert `instanceId,`+ // appears within it (before the workspacePath field that follows).+ const metaSlice = AGENT_LIFECYCLE_SRC.slice(registerIdx, registerIdx + 400);+ expect(metaSlice).toMatch(/\binstanceId,/);+ expect(metaSlice.indexOf('instanceId,')).toBeLessThan(metaSlice.indexOf('workspacePath'));+ });+});+// ─── handleAgentCompletion error recovery ──────────────────────────────────//// `handleAgentCompletion` (agentLifecycle.js:841) does: