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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(grid): a model stopped on another computer leaves this one's list in seconds
bitcoinbuilder06ddbc5bc1d7
diff --git a/cli/src/lib/gridPicture.ts b/cli/src/lib/gridPicture.tsindex 417924368..ba16bce8a 100644--- a/cli/src/lib/gridPicture.ts+++ b/cli/src/lib/gridPicture.ts@@ -30,6 +30,17 @@ export const GRID_MODEL_RETENTION_MS = 150_000*/const MIN_ABSENT_READS = 2+/**+ * A model missing from an awake answer when an awake answer listed it no longer ago than this left while+ * the grid kept answering: its machine stopped serving it (`grid leave`), or the master dropped it. That is+ * no wake's blank — a master answering 15s ago has heard from its providers — so it goes after+ * [MIN_ABSENT_READS] answers, not [GRID_MODEL_RETENTION_MS]. Without this, a model stopped on another+ * computer stayed in this one's Shared with you for over two minutes, offered and failing (only the+ * computer that stopped it knows at once: `provenStopped`). Three awake memos (15s each), so one slow look+ * between them still counts as the grid answering throughout.+ */+const AWAKE_CONTINUITY_MS = 45_000+/*** A sleep record older than this is ignored: the master forgets node rows after 30 days asleep, so an* older record lists models nobody serves any more. ⚠️ Cross-repo timing, found by this exact name.@@ -51,6 +62,8 @@ export interface PictureModel {absentSince: number | null/** How many awake reads in a row it has been missing from. */absentReads: number+ /** It went missing while the grid kept answering ([AWAKE_CONTINUITY_MS]): left, not a wake's blank. */+ leftAwake?: boolean}export interface PictureNode {@@ -147,7 +160,8 @@ function nodeFrom(read: { name: string; engine: string; models: string[] }, at:* An awake answer merged in, per model. A model the answer does not list stays until it has been missing* for [GRID_MODEL_RETENTION_MS] across at least two awake answers — so a cold wake that answers empty* blanks nothing — unless `provenStopped` says this computer itself stopped serving it, which is positive- * evidence and takes effect at once.+ * evidence and takes effect at once, or it went missing while the grid kept answering+ * ([AWAKE_CONTINUITY_MS]), when two answers without it are enough.** Previous entries are paired with live ones by name and engine, first fit, so two same-named machines* stay two entries.@@ -166,8 +180,12 @@ export function mergeAwake(if (provenStopped(entry.name, model.key)) return nullconst absentSince = model.absentSince ?? nowconst absentReads = model.absentReads + 1- const gone = now - absentSince >= GRID_MODEL_RETENTION_MS && absentReads >= MIN_ABSENT_READS- return gone ? null : { ...model, absentSince, absentReads }+ // Decided at the first answer that missed it, from the answer before.+ const leftAwake = model.absentSince === null+ ? previous.state === 'awake' && now - model.seenAt <= AWAKE_CONTINUITY_MS+ : model.leftAwake === true+ const gone = absentReads >= MIN_ABSENT_READS && (leftAwake || now - absentSince >= GRID_MODEL_RETENTION_MS)+ return gone ? null : { ...model, absentSince, absentReads, ...(leftAwake ? { leftAwake } : {}) }}for (const entry of previous.nodes) {const match = live.find((node) => !paired.has(node) && node.name === entry.name && node.engine === entry.engine)@@ -380,7 +398,7 @@ export function parsePicture(value: unknown): GridPicture | null {const key = str(model?.key)if (!model || !key || seenAt === null) return []const absentReads = typeof model.absentReads === 'number' && Number.isInteger(model.absentReads) && model.absentReads >= 0 ? model.absentReads : 0- return [{ key, seenAt, absentSince: time(model.absentSince), absentReads }]+ return [{ key, seenAt, absentSince: time(model.absentSince), absentReads, ...(model.leftAwake === true ? { leftAwake: true } : {}) }]})nodes.push({ name: str(node.name), engine: str(node.engine), isMine: node.isMine === true, models })}diff --git a/cli/src/lib/gridReads.spec.ts b/cli/src/lib/gridReads.spec.tsindex 9c71ff202..eb5f129b5 100644--- a/cli/src/lib/gridReads.spec.ts+++ b/cli/src/lib/gridReads.spec.ts@@ -311,6 +311,41 @@ describe('the picture', () => {expect(ids(section(await look(), TEAM))).toEqual([])})+ // Stopped on another computer while the grid kept answering: no wake's blank, so not 150s more on this one.+ it('a model that leaves while the grid keeps answering is gone by the second answer without it', async () => {+ answer(TEAM_ID, OVERVIEW, awake([node('rig', ['big-model', 'small-model'])]))+ await look()+ later(16)+ answer(TEAM_ID, OVERVIEW, awake([node('rig', ['small-model'])]))+ // One answer without it could be a blip: kept.+ expect(ids(section(await look(), TEAM))).toEqual(['small-model', 'big-model'])+ later(16)+ expect(ids(section(await look(), TEAM))).toEqual(['small-model'])+ })++ it('so does the only model of a grid whose only machine left, though the grid then answers empty', async () => {+ answer(TEAM_ID, OVERVIEW, awake([node('harness', ['qwen3.8-27b'])]))+ await look()+ later(16)+ answer(TEAM_ID, OVERVIEW, awake([]))+ expect(ids(section(await look(), TEAM))).toEqual(['qwen3.8-27b'])+ later(16)+ expect(ids(section(await look(), TEAM))).toEqual([])+ })++ it('a grid that was asleep and answers empty on waking keeps its models the full 150s', async () => {+ answer(TEAM_ID, OVERVIEW, awake([node('rig', ['big-model'])]))+ await look()+ later(16)+ answer(TEAM_ID, OVERVIEW, asleep())+ expect(ids(section(await look(), TEAM))).toEqual(['big-model'])+ later(125) // past the asleep memo: the next look reads it woken+ answer(TEAM_ID, OVERVIEW, awake([]))+ expect(ids(section(await look(), TEAM))).toEqual(['big-model'])+ later(16); expect(ids(section(await look(), TEAM))).toEqual(['big-model'])+ later(140); expect(ids(section(await look(), TEAM))).toEqual([])+ })+it('a sleep record older than the last awake read does not replace it; a newer one does', async () => {answer(TEAM_ID, OVERVIEW, awake([node('rig', ['big-model'])]))await look()