Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Core boundary, part 16: the teams behind the service host, and a discovery race (#745)

Deedf1981b12fb2
diff --git a/cli/e2e/core.e2e.ts b/cli/e2e/core.e2e.ts
index 1849c93dc..13e98cb0f 100644
--- a/cli/e2e/core.e2e.ts
+++ b/cli/e2e/core.e2e.ts
@@ -74,6 +74,30 @@ describe('the core under pressure', () => {
client.close()
})
+ it('agents created at once while discovery is slow: each binds under its own id, none retired or duplicated', async () => {
+ // Scans are held at random before they are applied, so some land while engines start and some
+ // straddle the moment the new-pane watcher identifies one. One that straddled used to count an
+ // engine's second miss and retire its agent 22ms after the engine was found; discovery then minted
+ // a second agent for the same pane, and the first never bound (e2e/soak.e2e.ts, 2026-10-04).
+ const d = await IsolatedDaemon.create({ env: { HARNESSD_TEST_SLOW_PROBE_MS: '500' } })
+ daemon = d
+ onTestFailed(() => { console.log(`---- daemon log\n${d.log().split('\n').slice(-150).join('\n')}`) })
+ await d.start()
+ const client = await LocalClient.connect(d)
+ const plan = [...engines, ...engines, ...engines, ...engines].map((engine, i) => ({ engine, name: `slow-scan-${engine}-${i}` }))
+ const ids = await Promise.all(plan.map(({ engine, name }) => create(d, client, engine, name)))
+ await Promise.all(ids.map((id) => bound(client, id, 90_000)))
+ // Let the scans that straddled the starts land, then look again.
+ await new Promise((resolve) => setTimeout(resolve, 3_000))
+ const all = await rows(client)
+ expect(all.map((agent) => agent.id).sort()).toEqual([...ids].sort())
+ for (const agent of all) expect(agent.status, agent.id).toBe('active')
+ expect(new Set(all.map((agent) => agent.tmuxPane)).size).toBe(ids.length)
+ expect(d.log()).not.toMatch(/retained · engine process absent/)
+ await Promise.all(ids.map((id, i) => turn(client, id, `after the slow scans ${i}`, 60_000)))
+ client.close()
+ })
+
it.each(engines)('%s: stopping in the middle of a turn, then resuming: the conversation goes on', async (engine) => {
const d = await fresh()
const client = await LocalClient.connect(d)
diff --git a/cli/e2e/services.e2e.ts b/cli/e2e/services.e2e.ts
index 7f13a5673..80769fa5c 100644
--- a/cli/e2e/services.e2e.ts
+++ b/cli/e2e/services.e2e.ts
@@ -90,6 +90,23 @@ describe('a failing service never takes the core down', () => {
client.close()
})
+ it('with the teams failing on every call, or not starting at all, messages are written and every turn reaches the client', async () => {
+ for (const faults of ['teams.prepare,teams.started,teams.raw,teams.forget', 'teams']) {
+ daemon = await IsolatedDaemon.create({ env: { HARNESSD_TEST_FAULTS: faults } })
+ const d = daemon
+ onTestFailed(() => { console.log(`---- daemon log (${faults})\n${d.log().split('\n').slice(-80).join('\n')}`) })
+ await d.start()
+ const client = await LocalClient.connect(d)
+ const agentId = await boundAgent(d, client, `teams-${faults.length}`)
+ for (let i = 1; i <= 3; i++) await turn(client, agentId, `with the teams failing ${i}`)
+ expect(d.log()).toContain(faults === 'teams' ? '[services] teams did not start' : '[services] teams.prepare failed')
+ expect(d.coresStarted()).toBe(1)
+ client.close()
+ await d.close()
+ daemon = undefined
+ }
+ })
+
it('a search request that fails before search is switched off answers that request, and the next one too', async () => {
daemon = await IsolatedDaemon.create({ env: { HARNESSD_TEST_FAULTS: 'search.search' } })
onTestFailed(() => { console.log(`---- daemon log\n${daemon?.log().split('\n').slice(-80).join('\n')}`) })
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index edce9a4b7..d0f01b7f2 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -120,6 +120,7 @@ import { ALL_TERMINAL_BACKENDS } from './config/terminalConfig.js'
import { TerminalBackendCoordinator } from './lib/terminalBackendCoordinator.js'
import { TerminalStreamManager } from './lib/terminalStreamManager.js'
import { terminalRouteKey, terminalRuntimeLabel } from './lib/terminalRuntime.js'
+import { probeTerminalAgents } from './lib/terminalAgentDiscovery.js'
import { TerminalAgentReconciler } from './lib/terminalAgentReconciler.js'
import { remoteCommand } from './remoteCommand.js'
import { tuiCommand } from './tui/index.js'
@@ -160,7 +161,7 @@ import { createAgentClosing } from './core/agents/close.js'
import { createEngineHooks, installEngineHooks } from './core/engines/hooks.js'
import { createCursorTaskHooks } from './core/engines/cursorTasks.js'
import { databaseHistory } from './core/transcripts/databaseHistory.js'
-import { createCoreApi, emptyPorts, MODELS_FALLBACKS, SEARCH_FALLBACKS, VIEWERS_FALLBACKS, WORKSPACES_FALLBACKS } from './core/api.js'
+import { createCoreApi, emptyPorts, MODELS_FALLBACKS, SEARCH_FALLBACKS, TEAMS_FALLBACKS, VIEWERS_FALLBACKS, WORKSPACES_FALLBACKS, type TeamsPort } from './core/api.js'
import { createServiceHost, testFaults } from './core/serviceHost.js'
import { startSearch } from './services/search.js'
import { startViewers } from './services/viewers.js'
@@ -1850,6 +1851,16 @@ async function runForeground(session: AuthSession | null): Promise<void> {
// Nothing is answered until start-up is done (see the end of this function).
backend.holdRequests()
daemonBoot.openRequests = () => backend.openRequests()
+ // The team prompt scopes are the socket's, and the core reaches them through the service host's guard
+ // (core/serviceHost.ts): a fault there can no longer cost a message its write, a hook its answer or
+ // an event its turn.
+ serviceHost.start('teams', (_core, started) => { started.teams = backend.swarmPromptScopes }, coreApi, TEAMS_FALLBACKS)
+ const teams: TeamsPort = {
+ prepare: (...args) => ports.teams?.prepare(...args) ?? (() => {}),
+ started: (...args) => ports.teams?.started(...args),
+ raw: (...args) => ports.teams?.raw(...args),
+ forget: (agentId) => ports.teams?.forget(agentId),
+ }
backend.viewerTargetProvider = (agentId) => ports.viewers?.forwardingUrl(agentId) ?? null
ensureBundledCoreHarnesses()
@@ -1920,7 +1931,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
return { kind: backend.e2ee.sessionRole(connId) === 'device' ? 'device' : 'web', name: label }
},
streamingAvailable: tmuxBackend != null,
- onScopedInput: (id, bytes, tabId, pasted) => backend.swarmPromptScopes.raw(id, bytes, tabId, pasted),
+ onScopedInput: (id, bytes, tabId, pasted) => teams.raw(id, bytes, tabId, pasted),
diagnostic: (event, fields) => console.log(`[terminal-stream] ${event}`, fields),
// The keystroke prewarm (grid-reads-without-waking issue 03): typing into a pane whose agent runs on
// a sleeping grid starts that grid while the person types. Here, in the daemon's own input path, so
@@ -2030,7 +2041,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
byAgent: (agentId) => registry.byAgent(agentId),
terminal: terminalControl,
teams: {
- prepare: (id, text, tabId, deliveryId) => backend.swarmPromptScopes.prepare(id, text, tabId, deliveryId),
+ prepare: (id, text, tabId, deliveryId) => teams.prepare(id, text, tabId, deliveryId),
delivery: (event) => {
backend.orchestratorDelivery(event)
backend.teamDelivery(event)
@@ -2204,7 +2215,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
search: sessionSearch,
turnStartedAt,
input,
- teams: backend.swarmPromptScopes,
+ teams,
deviceInput,
device: () => autonomousDeviceService,
startHeartbeat,
@@ -2232,7 +2243,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
runtimeProfiles,
watcher,
stopHeartbeat,
- teams: backend.swarmPromptScopes,
+ teams,
input,
deviceInput,
detachDsh,
@@ -2249,7 +2260,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
// A terminal is never the dial's business, and `syncSession` forces that for it anyway.
announceSession: session => announceSession(session, { device: false }),
invalidateTerminalControl,
- forgetInput: agentId => { backend.swarmPromptScopes.forget(agentId); input.forget(agentId); deviceInput.forget(agentId) },
+ forgetInput: agentId => { teams.forget(agentId); input.forget(agentId); deviceInput.forget(agentId) },
detachDsh,
syncRecapPool,
warn: (message, error) => console.warn(message, error),
@@ -2267,7 +2278,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
announceSession,
stoppedAgents,
syncRecapPool,
- teams: backend.swarmPromptScopes,
+ teams,
input,
deviceInput,
homes: { copilot: env.COPILOT_HOME, grok: env.GROK_HOME, agy: env.AGY_HOME },
@@ -2286,7 +2297,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
syncRecapPool,
attachSession,
invalidateTerminalControl,
- teams: backend.swarmPromptScopes,
+ teams,
input,
deviceInput,
questionWatcher,
@@ -2295,6 +2306,10 @@ async function runForeground(session: AuthSession | null): Promise<void> {
stoppedAgents,
restoreDegraded: () => restoreDegraded,
})
+ // HARNESSD_TEST_SLOW_PROBE_MS holds each discovery probe for up to that long, at random, before it is
+ // applied: some scans land at once and some straddle an agent's start, as on a loaded machine. The
+ // end-to-end suite uses it to put a scan across an engine's start on purpose (e2e/core.e2e.ts).
+ const slowProbeMs = Number(process.env.HARNESSD_TEST_SLOW_PROBE_MS) || 0
const agentReconciler = new TerminalAgentReconciler({
// The hook server starts before restore. Its early SessionStart hints must not run a full
// discovery scan over rows whose panes have not been recreated yet (and archive those rows).
@@ -2303,6 +2318,13 @@ async function runForeground(session: AuthSession | null): Promise<void> {
backends: terminalBackends,
backendOrder: terminalConfig.backends,
transaction: (apply) => registry.transaction(apply),
+ ...(slowProbeMs > 0 ? {
+ probe: async (hints: Parameters<typeof probeTerminalAgents>[3]) => {
+ const probe = await probeTerminalAgents(terminalBackends, terminalConfig.backends, process.pid, hints)
+ await new Promise((resolve) => setTimeout(resolve, Math.random() * slowProbeMs))
+ return probe
+ },
+ } : {}),
...discovery,
onProbeStatus: (status) => {
discoveryReady = status.ready
@@ -2509,7 +2531,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {
},
resolveHookAgent: engineHooks.resolveHookAgent,
onRegistered: handleRegistered,
- onPromptSubmitted: (id, text) => backend.swarmPromptScopes.started(id, text, 'hook', registry.byAgent(id)?.engine),
+ onPromptSubmitted: (id, text) => teams.started(id, text, 'hook', registry.byAgent(id)?.engine),
onSessionEnd: engineHooks.onSessionEnd,
// What the engines' own hooks say about a turn (core/turns/turnHooks.ts).
onTurnStart: turnHooks.onTurnStart,
diff --git a/cli/src/core/api.spec.ts b/cli/src/core/api.spec.ts
index cfa005a16..970bb718f 100644
--- a/cli/src/core/api.spec.ts
+++ b/cli/src/core/api.spec.ts
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest'
import { projectDisplayName, type RegisteredSession } from '../lib/registry.js'
-import { createCoreApi, emptyPorts, type CoreApiDeps } from './api.js'
+import { createCoreApi, emptyPorts, TEAMS_FALLBACKS, type CoreApiDeps } from './api.js'
const row = (agentId: string) => ({ agentId, sessionId: `s-${agentId}`, engine: 'claude', cwd: '/work/app' }) as RegisteredSession
@@ -43,8 +43,13 @@ describe('the core API services stand on', () => {
expect(core.account.accessToken).toBe(deps.accessToken)
})
+ it('falls back, when the teams fail, to an undo that has nothing to undo', () => {
+ const undo = TEAMS_FALLBACKS.prepare as () => void
+ expect(undo()).toBeUndefined()
+ })
+
it('starts with every port empty: a service fills its own when it starts', () => {
- expect(emptyPorts()).toEqual({ search: null, viewers: null, models: null, workspaces: null })
+ expect(emptyPorts()).toEqual({ search: null, viewers: null, models: null, workspaces: null, teams: null })
expect(emptyPorts()).not.toBe(emptyPorts())
})
})
diff --git a/cli/src/core/api.ts b/cli/src/core/api.ts
index 6e0bc1435..39302db78 100644
--- a/cli/src/core/api.ts
+++ b/cli/src/core/api.ts
@@ -15,6 +15,7 @@ import { projectDisplayName, type registry, type RegisteredSession } from '../li
import type { ExternalSessions, OpenSessions } from '../lib/sessionSearch/external.js'
import type { SessionSearchIndex } from '../lib/sessionSearch/indexer.js'
import type { StoppedAgentStore } from '../lib/stoppedAgents.js'
+import type { SwarmPromptScopes } from '../teams/promptScope.js'
import { FAIL, later, type PortFallbacks } from './serviceHost.js'
export interface CoreApi {
@@ -123,6 +124,14 @@ export interface WorkspacesPort {
/** What the core gets when workspaces fails: branches keep their names and nothing is swept. */
export const WORKSPACES_FALLBACKS: PortFallbacks<WorkspacesPort> = { nameBranches: undefined, sweepUnused: undefined }
+/** The core's calls into the teams: which team a prompt belongs to, recorded as a message is written,
+ * as a turn starts (from its hook or its transcript), as it is typed into a scoped terminal, and
+ * forgotten with its agent. */
+export type TeamsPort = Pick<SwarmPromptScopes, 'prepare' | 'started' | 'raw' | 'forget'>
+
+/** What the core gets when the teams fail: the prompt is written with no team recorded for it. */
+export const TEAMS_FALLBACKS: PortFallbacks<TeamsPort> = { prepare: () => {}, started: undefined, raw: undefined, forget: undefined }
+
/** Each port is filled by the service that owns it when that service starts, and is null while the
* service is off: the core never waits on one. */
export interface CorePorts {
@@ -130,10 +139,11 @@ export interface CorePorts {
viewers: ViewersPort | null
models: ModelsPort | null
workspaces: WorkspacesPort | null
+ teams: TeamsPort | null
}
export function emptyPorts(): CorePorts {
- return { search: null, viewers: null, models: null, workspaces: null }
+ return { search: null, viewers: null, models: null, workspaces: null, teams: null }
}
export interface CoreApiDeps {
diff --git a/cli/src/lib/terminalAgentReconciler.spec.ts b/cli/src/lib/terminalAgentReconciler.spec.ts
index ffbf2c4d4..523521c7a 100644
--- a/cli/src/lib/terminalAgentReconciler.spec.ts
+++ b/cli/src/lib/terminalAgentReconciler.spec.ts
@@ -180,6 +180,88 @@ describe('composite terminal reconciliation', () => {
expect(onRemoved).not.toHaveBeenCalled()
})
+ it('does not count a scan that began before the engine was identified against that engine', async () => {
+ // The race four agents created at once hit (e2e/soak.e2e.ts): the first scan finds the pane still
+ // running its launcher; the new-pane watcher identifies the engine while the second scan's probe
+ // runs, and that probe, taken before the engine existed, used to count its second miss.
+ const current: RegisteredSession = { ...session([tmux]), processIdentity: null, launch: { state: 'starting' } }
+ const pane = { runtime: tmux, rootPid: 1, cwd: '/work' }
+ let whileProbing: (() => void) | null = null
+ const onDormant = vi.fn()
+ const onObserved = vi.fn()
+ const reconciler = new TerminalAgentReconciler({
+ current: () => [current], backends: [], backendOrder: ['tmux'],
+ onDiscovered: vi.fn(), onObserved, onDormant, onRemoved: vi.fn(),
+ probe: async () => {
+ whileProbing?.()
+ whileProbing = null
+ return probe([{ instanceId: 'tmux:default', result: { state: 'available', roots: [pane] } }])
+ },
+ })
+ await reconciler.trigger()
+ whileProbing = () => { current.processIdentity = identity; current.launch = { state: 'ready' } }
+ await reconciler.trigger()
+ expect(onDormant).not.toHaveBeenCalled()
+ // A probe that began after the engine was identified does speak for it, from a count of one.
+ await reconciler.trigger()
+ expect(onDormant).not.toHaveBeenCalled()
+ await reconciler.trigger()
+ expect(onDormant).toHaveBeenCalledWith(current, 'engine process absent after 2 confirmed scans')
+ expect(onObserved).not.toHaveBeenCalled()
+ })
+
+ it('counts misses against one engine: an engine identified since starts again', async () => {
+ const current = session([tmux])
+ const pane = { runtime: tmux, rootPid: 1, cwd: '/work' }
+ const onDormant = vi.fn()
+ const reconciler = new TerminalAgentReconciler({
+ current: () => [current], backends: [], backendOrder: ['tmux'],
+ onDiscovered: vi.fn(), onObserved: vi.fn(), onDormant, onRemoved: vi.fn(),
+ probe: async () => probe([{ instanceId: 'tmux:default', result: { state: 'available', roots: [pane] } }]),
+ })
+ await reconciler.trigger()
+ current.processIdentity = { ...identity, pid: 43 }
+ await reconciler.trigger()
+ expect(onDormant).not.toHaveBeenCalled()
+ await reconciler.trigger()
+ expect(onDormant).toHaveBeenCalledTimes(1)
+ })
+
+ it('does not judge an agent created, or a pane given to one, while the probe ran', async () => {
+ const agents: RegisteredSession[] = []
+ const moved: TerminalRuntimeRef = { backend: 'tmux', paneId: '%2' }
+ let whileProbing: (() => void) | null = null
+ const onDormant = vi.fn()
+ const onRemoved = vi.fn()
+ const validate = vi.fn(async () => ({ state: 'gone' as const, reason: 'no such pane' }))
+ const backend = { instanceId: 'tmux:default', validate } as unknown as TerminalBackend
+ const reconciler = new TerminalAgentReconciler({
+ current: () => agents, backends: [backend], backendOrder: ['tmux'],
+ onDiscovered: vi.fn(), onObserved: vi.fn(), onDormant, onRemoved,
+ probe: async () => {
+ whileProbing?.()
+ whileProbing = null
+ return probe([{ instanceId: 'tmux:default', result: { state: 'available', roots: [] } }])
+ },
+ })
+ // Created mid-probe: the inventory was taken before its pane existed.
+ whileProbing = () => { agents.push(session([tmux])) }
+ await reconciler.trigger()
+ // Given a new pane mid-probe: the same.
+ whileProbing = () => {
+ agents[0].runtimes = [moved]
+ agents[0].primaryRuntimeKey = terminalRouteKey(moved)
+ }
+ await reconciler.trigger()
+ expect(onRemoved).not.toHaveBeenCalled()
+ expect(onDormant).not.toHaveBeenCalled()
+ // Probes that began after both judge the pane as they find it: gone, twice.
+ await reconciler.trigger()
+ expect(onRemoved).not.toHaveBeenCalled()
+ await reconciler.trigger()
+ expect(onRemoved).toHaveBeenCalledWith(agents[0], 'terminal runtime absent after 2 confirmed scans')
+ })
+
it('keeps an agent active when pane-specific validation is inconclusive', async () => {
const current = session([tmux])
const onDormant = vi.fn()
diff --git a/cli/src/lib/terminalAgentReconciler.ts b/cli/src/lib/terminalAgentReconciler.ts
index 986ea1e1c..c5440205d 100644
--- a/cli/src/lib/terminalAgentReconciler.ts
+++ b/cli/src/lib/terminalAgentReconciler.ts
@@ -100,7 +100,9 @@ function unboundRouteObservation(
/** Serialized, failure-isolated reconciliation across every enabled backend instance. */
export class TerminalAgentReconciler {
private readonly misses = new Map<string, number>()
- private readonly engineMisses = new Map<string, number>()
+ /** Consecutive scans that found no engine for an agent, counted against the process identity they
+ * missed: an engine identified since is a different engine, and its count starts again. */
+ private readonly engineMisses = new Map<string, { processKey: string | null; count: number }>()
private readonly suppressed = new Set<string>()
private readonly hints = new Map<string, AgentEngine>()
/** Terminal routes currently mid an in-place process swap (restart). Held by ROUTE, not by process
@@ -225,6 +227,16 @@ export class TerminalAgentReconciler {
private async reconcileOnce(): Promise<void> {
const hints = new Map(this.hints)
+ // What every agent was when the probe began. A probe is evidence only about what it could have
+ // seen: an agent created, a pane given to it, or an engine identified while the probe ran (the
+ // new-pane watcher binds one between two scans) is judged by the next probe, not this one. Four
+ // agents created at once proved it: a probe that began before one engine started counted that
+ // engine's second "miss", and the agent was retired 22ms after its engine was found
+ // (e2e/soak.e2e.ts, 2026-10-04).
+ const probedAs = new Map(this.deps.current().map((agent) => [agent.agentId, {
+ processKey: currentProcessKey(agent),
+ placements: new Set(agent.runtimes.map(terminalPlacementKey)),
+ }]))
const probe = await (this.deps.probe
? this.deps.probe(hints)
: probeTerminalAgents(
@@ -333,6 +345,7 @@ export class TerminalAgentReconciler {
// route and its active UI entry, just as a failed whole-process-table read does above.
if (validation.state === 'unknown') continue
}
+ if (!probedAs.get(current.agentId)?.placements.has(placement)) continue
const misses = (this.misses.get(missKey) ?? 0) + 1
if (misses < MISS_LIMIT) {
this.misses.set(missKey, misses)
@@ -343,21 +356,24 @@ export class TerminalAgentReconciler {
}
if (terminalVerified) await this.deps.onTerminalAvailability?.(current, true)
+ const probed = probedAs.get(current.agentId)
if (observed) {
this.engineMisses.delete(current.agentId)
- } else if (current.active && terminalVerified && !isTerminalEngine(current.engine) && !current.runtimes.some((runtime) =>
+ } else if (probed && probed.processKey === processKey
+ && current.active && terminalVerified && !isTerminalEngine(current.engine) && !current.runtimes.some((runtime) =>
probe.ambiguousPlacements.has(terminalPlacementKey(runtime)))) {
// A live pane with no engine process in it. For an agent that is a dormant engine; for a
// terminal (`engine === 'terminal'`) it is simply a shell at its prompt, which is why the
// branch is skipped for one. A terminal that ADOPTED an engine (`terminalHost`, engine no
// longer `terminal`) does come through here when that engine exits — the handler turns it
// back into a terminal rather than marking it dormant (cli.ts `onDormant`).
- const misses = (this.engineMisses.get(current.agentId) ?? 0) + 1
+ const prior = this.engineMisses.get(current.agentId)
+ const misses = (prior?.processKey === processKey ? prior.count : 0) + 1
if (misses >= MISS_LIMIT) {
this.engineMisses.delete(current.agentId)
await this.deps.onDormant(current, `engine process absent after ${MISS_LIMIT} confirmed scans`)
} else {
- this.engineMisses.set(current.agentId, misses)
+ this.engineMisses.set(current.agentId, { processKey, count: misses })
}
}
diff --git a/docs/design/2026-10-03-harnessd.md b/docs/design/2026-10-03-harnessd.md
index 81cdcdf40..f8c62691a 100644
--- a/docs/design/2026-10-03-harnessd.md
+++ b/docs/design/2026-10-03-harnessd.md
@@ -405,8 +405,10 @@ Done so far:
never waits on one. Session search, the DSH viewers, models (grid access, the model pictures on
agents' frames, the keystroke prewarm) and workspaces (branch names, the worktree sweep) stand on
it under `cli/src/services`, held to 100% beside the core. A service holds no credential: minting
- the grid name and the access token go through `CoreApi.account`. Relay, sharing, teams and
- devices, and step 14, remain.
+ the grid name and the access token go through `CoreApi.account`. The teams (part 16) are reached
+ the same way: the socket's prompt scopes are installed as `ports.teams` through the service host,
+ so a fault there cannot cost a message its write. The devices are guarded where the core calls
+ them (part 12); moving them, the relay and sharing into their own processes is the next phase.
- **A failing service cannot take the core down** (part 10, `cli/src/core/serviceHost.ts`). A
service whose start throws is left off and the core starts without it. Every call into a port is
guarded and answered with a fallback declared beside the port's contract, so the funnel, restore
@@ -487,8 +489,9 @@ start-up lint stay as they are; each is checked by `tsc`, the unit suites and th
10. Agent discovery and binding.
11. The agent lifecycle.
12. Engine hooks.
-13. Services in process, each behind `start(core, ports)`: search, viewers, models and workspaces
- first, then relay, sharing, teams and devices.
+13. Services in process, each behind `start(core, ports)`: search, viewers, models, workspaces and
+ the teams; the devices guarded where the core calls them. Relay, sharing and the devices move
+ with the next phase, into processes of their own.
14. Every slot `BackendSocket` calls into the core through is bound, and stays so:
`socketBindings.spec.ts` reads the class's slots and fails on any that `cli.ts` leaves unbound
(three are unbound on purpose, each with its reason). The bindings stay where start-up puts
@@ -559,6 +562,12 @@ Found while mapping, and fixed on their own rather than inside a move:
- Part 15: step 14 as described above, and coming back (`e2e/recovery.e2e.ts`): five restarts in a
row while agents work, the master killed outright, an engine missing from the machine (its launch
fails with `ENGINE_NOT_INSTALLED` and the reason), and a registry lock left by a crash.
+ - Part 16, found by the soak on a loaded machine: four agents created at once, and one was retired
+ 22ms after its engine was found. A discovery scan that began before that engine started counted
+ its second "missing" when it landed, and the agent was archived; the next scan then minted a
+ second agent for the same pane, and the first never bound. A scan now judges an agent only by
+ what it could have seen: an agent created, a pane given to one, or an engine identified while the
+ probe ran is left to the next scan, and misses count against one engine identity at a time.
## Testing