iterate.com / kernel

git clone https://git.iterate.com/repos/kernel

MCP run guide: the wait for a commit's outcome reads payload.trigger.commitOid (#31)

Text only: two strings of `core/mind-worker/src/mcp.ts`, the default description of the `run` tool. The example waited with `payload: { commitOid }, afterOffset: 0`. The outcome events name their commit in `payload.trigger`, and `waitForEvent` compares top-level payload fields alone, so that wait timed out on a commit that did publish. The example now reads where the root's log ends before the commit and takes each outcome after that offset until one names the commit. The same words as /repos/config commit e04760eb6224609c2c5d16b0539bd7f79f9ac538, where the loop was proven on iterate.com.

Jonas, on the card, 28 Nov 2026 21:34 UTC: "Yes, text only".

Checked on this head: `pnpm -r typecheck` passes; `pnpm -r test` passes (lib 1134, auth-worker 572, secrets-worker 420, itx 611, boundary-worker 247, mind-worker 376).

Card: tasks/fix-the-run-tool-guide-s-waitforevent-example-for-worker-updated.md

Via: /agents/claude/run-guide-wait-example-mx0wxfcb-5a973d
Session: claude 7ba4426c-d452-4c93-804a-9c3c1791d4c7 on beelink

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Wq8CaYLKDR5JeKxYYoJYJp

Iterate-Run: /@1908336

jonas, 2026-11-28 21:37 UTC · 949894f1f04ced007702b88c8c43e13584e10cb1 · parent 0a212f0

1 file changed

M core/mind-worker/src/mcp.ts
@@ -146,8 +146,8 @@
   '`itx.cd("/path")` addresses another context of this mind.',
   'A result is JSON, and JSON is text to you. To SEE image files of the mind (`itx.files`), return their paths under the key `"itx/images"`: `return { note: "the page", "itx/images": ["/shots/page.png"] }`. Each arrives as an image beside the result: PNG, JPEG, GIF or WebP, at most 8 files and 5 MiB in all. `"itx/images-left-out"` in the result says which files did not come, and why.',
   'The mind\'s code is the config repo, `itx.repos.get("/repos/config")`: `listFiles()` and `readFile(path)` read it. Its `AGENTS.md` is the guide to this mind\'s code: read it before you change a file. `package.json` names the main module in `"main"` (`worker.ts`); its default export is a class that extends `IterateConfigEntrypoint` from `iterate/sdk`, and publication refuses any other. Files may be TypeScript (types are stripped, not checked) or JavaScript and import each other by relative path. `iterate/*` and `zod` come from the platform; any other package is listed in `package.json` `dependencies` and fetched from npm through esm.sh (a package that needs Node.js builtins is refused).',
-  "A commit to the config repo publishes the mind a few seconds after it lands. `commitFiles({ message, changes, parent })` takes the whole new content of each changed file (`{ path, content }`, or `{ path, delete: true }`). There is no patch operation: change the text inside your script, and the file never has to pass through your context. Pass the tip you read as `parent`, so the commit is refused if main moved meanwhile. The commit is authored by you unless it names an `author`; end its message with `Via: <your name>` so it says which agent did the work. Every commit gets one outcome event on `/`, `worker-updated` or `worker-update-failed`, and a failure's `payload.error` says why the commit is not live.",
-  "Change a file and wait for its outcome (this writes to the repo; replace the path and the text with your edit):\n```json\n{\"script\": \"async (itx) => { const repo = itx.repos.get('/repos/config'); const tip = await repo.tip(); const source = await repo.readFile('worker.ts', { commitOid: tip }); const next = source.replace('Homepage of mind ', 'Welcome to '); if (next === source) throw new Error('the homepage text is not in worker.ts'); const { commitOid } = await repo.commitFiles({ message: 'Change the homepage greeting\\\\n\\\\nVia: Claude Code', parent: tip, changes: [{ path: 'worker.ts', content: next }] }); const outcome = await itx.waitForEvent({ type: ['events.iterate.com/mind/worker-updated', 'events.iterate.com/mind/worker-update-failed'], payload: { commitOid }, afterOffset: 0, timeoutMs: 120000 }); if (outcome.payload.error) throw new Error(outcome.payload.error); return { commitOid, outcome: outcome.type }; }\"}\n```",
+  "A commit to the config repo publishes the mind a few seconds after it lands. `commitFiles({ message, changes, parent })` takes the whole new content of each changed file (`{ path, content }`, or `{ path, delete: true }`). There is no patch operation: change the text inside your script, and the file never has to pass through your context. Pass the tip you read as `parent`, so the commit is refused if main moved meanwhile. The commit is authored by you unless it names an `author`; end its message with `Via: <your name>` so it says which agent did the work. Every commit gets one outcome event on `/`, `worker-updated` or `worker-update-failed`, and a failure's `payload.error` says why the commit is not live. The outcome names its commit in `payload.trigger.commitOid`. The `payload` filter of `waitForEvent` compares top-level fields alone, so it cannot name that commit: read where the log of `/` ends before the commit, then take each outcome after that offset until one names your commit.",
+  "Change a file and wait for its outcome (this writes to the repo; replace the path and the text with your edit):\n```json\n{\"script\": \"async (itx) => { const repo = itx.repos.get('/repos/config'); const tip = await repo.tip(); const source = await repo.readFile('worker.ts', { commitOid: tip }); const next = source.replace('Homepage of mind ', 'Welcome to '); if (next === source) throw new Error('the homepage text is not in worker.ts'); const head = (await itx.readEvents(Number.MAX_SAFE_INTEGER, 1)).scannedThroughOffset; const { commitOid } = await repo.commitFiles({ message: 'Change the homepage greeting\\\\n\\\\nVia: Claude Code', parent: tip, changes: [{ path: 'worker.ts', content: next }] }); let outcome, after = head; do { outcome = await itx.waitForEvent({ type: ['events.iterate.com/mind/worker-updated', 'events.iterate.com/mind/worker-update-failed'], afterOffset: after, timeoutMs: 120000 }); after = outcome.offset; } while (outcome.payload.trigger?.commitOid !== commitOid); if (outcome.payload.error) throw new Error(outcome.payload.error); return { commitOid, outcome: outcome.type }; }\"}\n```",
   'After `worker-updated` the site serves the commit within 5 seconds: fetch `await itx.url()`, the mind\'s apex, with `itx.fetch` and check the page before you report success. To try a change with no commit, run the candidate as a worker: `(await itx.workers.get({ source: { ...(await itx.repos.get("/repos/config").files()), "worker.ts": candidateSource } }).fetch(new Request(await itx.url()))).text()`, the repo\'s files under their repo paths with your edits over them.',
   "The source code for all of this is public at https://github.com/iterate/core: read it before you guess how anything here works. List the files first: https://data.jsdelivr.com/v1/packages/gh/iterate/core@main?structure=flat (`files[].name`, each a path with a leading `/`; the list can be hours behind). GitHub's own list, https://api.github.com/repos/iterate/core/git/trees/main?recursive=1 (`tree[].path`), is exact, but GitHub allows 60 listings an hour to everyone behind one address, so through this tool it often answers 403. Then read `core/AGENTS.md`, then the file you need at `https://raw.githubusercontent.com/iterate/core/main/<path>`. To find where something is implemented, fetch the likely files in one script, search their text there, and return only the lines that match. `main` can differ from the code this mind runs: where they disagree, what a call answers is right. Through this tool: `async (itx) => (await itx.fetch(new Request(url))).text()`.",
 ].join("\n\n");