Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

Prevent stale shell handles from targeting new jobs

Rach Pradhan35f09c71ca51
diff --git a/docs/adr/0179-durable-shell-handles.md b/docs/adr/0179-durable-shell-handles.md
new file mode 100644
index 00000000..22564f90
--- /dev/null
+++ b/docs/adr/0179-durable-shell-handles.md
@@ -0,0 +1,21 @@
+# 0179: Reserve durable shell handles before spawning
+
+Status: accepted
+
+## Context
+
+A process-local counter reused shell handles after restart. A handle in saved history could then read or stop an unrelated new command, including after a crash before a session checkpoint.
+
+## Decision
+
+Shell handles are integer IDs from 2^32 through 2^53−1, disjoint from legacy u32 handles and exactly representable by JavaScript numbers. Subagent IDs are unchanged. Reserve each handle before spawning, using an exclusive advisory lock and an atomically replaced, synced high-water counter in HOME/.codegraff. Never reset initialized storage automatically. Keep the stable initialization marker separate from the replaced counter; malformed, missing initialized state, exhausted space or unavailable storage prevents spawning.
+
+A fresh initializer syncs the parent directory, marker and counter before dispatch. Concurrent openers briefly retry an empty initialization marker without holding its lock. A crash during first initialization may leave a marker without its counter; this deliberately refuses further commands until the state is repaired, rather than risk reusing an ID. Ordinary later reservations recover the old or new atomic counter, and no command starts until its reservation is durable.
+
+Unowned handles report an interrupted or unknown outcome and never target a different local process. They do not claim the old command never ran or recommend automatically repeating it.
+
+## Consequences
+
+Every shell spawn pays one durable counter replacement. State belongs to HOME, not an archivable worktree. Deleting all allocator state, restoring an older backup, or changing HOME loses the continuity guarantee; never recommend resetting the ledger as recovery. This change does not reattach surviving commands or provide durable terminal receipts or exactly-once side effects. Unix directory synchronization protects the initialization ordering; Windows retains the file-level guarantees available through the existing atomic writer.
+
+Offline tests cover concurrent first and later reservations, hard termination after reservation, malformed/missing/exhausted storage, integer boundaries, and two actual harness processes showing stale output/kill cannot affect a new command.
diff --git a/docs/adr/README.md b/docs/adr/README.md
index 55f87792..c66ea32b 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -203,6 +203,8 @@ record only when you need the evidence or the edge cases.
| [0177](0177-owned-async-tool-execution.md) | Direct read-only async jobs own their lifetime, preserve order, and join before the next request. |
| [0178](0178-batched-edits-preflight-before-commit.md) | Preflight every edit span in memory, then perform one verified replacement; an invalid later span leaves the file unchanged. |
+| [0179](0179-durable-shell-handles.md) | Reserve durable JS-exact shell handles before spawning; stale handles never target new jobs. |
+
## When to write one
Write an ADR when a decision is load-bearing and non-obvious: it was reached
diff --git a/docs/proposals/harness-operation-priorities.md b/docs/proposals/harness-operation-priorities.md
index 3750a6d9..0644e08a 100644
--- a/docs/proposals/harness-operation-priorities.md
+++ b/docs/proposals/harness-operation-priorities.md
@@ -24,6 +24,18 @@ Workspace binding belongs in the operation contract before cross-turn RLM jobs
are enabled. Do not promise exactly-once external side effects: a process can die
after an effect occurs but before its completion is durably recorded.
+## Implemented safeguards
+
+- [ADR 0179](../adr/0179-durable-shell-handles.md) closes shell-handle reuse
+ after restart: reserve durable identities before dispatch, and reject stale
+ output/kill requests. This does not yet provide terminal receipts or reattach
+ surviving operations. The offline crash and reservation regressions run in
+ `scripts/eval-tier1.sh --only shell`.
+- [ADR 0178](../adr/0178-batched-edits-preflight-before-commit.md) prevents an
+ invalid later edit span from leaving earlier spans written. Valid batches
+ use one staged replacement and exact verification. This is a correctness
+ safeguard; lower model latency or token usage remains unproven.
+
## Source comparison
Source review is pinned to Unreal Agent revision
diff --git a/evals/harness_behavior.jsonl b/evals/harness_behavior.jsonl
index dd5e47fe..0d8c396d 100644
--- a/evals/harness_behavior.jsonl
+++ b/evals/harness_behavior.jsonl
@@ -61,7 +61,7 @@
{"id": "plugin-off-keeps-personal-skills", "why": "GRAFF_NO_PLUGINS must drop plugin-tree skills while ~/.cursor/skills-cursor stays personal. The regression is treating skills-cursor as a plugin (it vanishes) or ignoring the opt-out (plugin-secret still loads).", "args": [], "env": {"GRAFF_NO_PLUGINS": "1"}, "workspace_seed": {".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/.cursor-plugin/plugin.json": "{\"name\":\"eval-gmail\"}\n", ".cursor/plugins/cache/cursor-public/evalfix/2a8044425c7bddf429c3bdedf3ab61e791d34d65/skills/plugin-secret/SKILL.md": "---\nname: plugin-secret\ndescription: load before using the plugin secret handshake\n---\n\n# Plugin Secret\n\nPLUGIN_SKILL_BODY_TOKEN_9f3a\n", ".cursor/skills-cursor/env-setup/SKILL.md": "---\nname: env-setup\ndescription: personal skills-cursor playbook that survives GRAFF_NO_PLUGINS\n---\n\n# Env Setup\n\nPERSONAL_SKILL_BODY_TOKEN_c2e1\n"}, "prompt": "load the handshake playbook if it exists", "script": [{"tool": "skill", "arguments": {"name": "plugin-secret"}}, {"text": "plugin skill is gone; personal env-setup remains"}], "assert": [{"request_contains": {"index": 0, "text": "env-setup (personal)"}}, {"request_lacks": {"index": 0, "text": "plugin-secret"}}, {"request_lacks": {"index": 0, "text": "plugin-secret (plugin)"}}, {"request_lacks": {"index": 0, "text": "PLUGIN_SKILL_BODY_TOKEN_9f3a"}}, {"event": {"type": "tool_call", "name": "skill"}}, {"request_contains": {"index": -1, "text": "no skill named 'plugin-secret'"}}, {"final_text_contains": "plugin skill is gone"}]}
{"id": "workspace-list-use", "why": "ADR 0006: workspace is a folded tool that must list real git worktrees and chdir the session. A skill cannot move file-tool cwd; bash-cd is not enough. Guards load_tool_schemas unfold + use by folder name.", "args": [], "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "create a feature worktree, list workspaces, switch into it", "script": [{"tool": "bash", "arguments": {"command": "git init && git config user.email eval@invalid && git config user.name Eval && echo x > README && git add README && git commit -m init && git worktree add wt-feature -b feature && echo seeded-worktree"}}, {"tool": "load_tool_schemas", "arguments": {"tools": ["workspace"]}}, {"tool": "workspace", "arguments": {"action": "list"}}, {"tool": "workspace", "arguments": {"action": "use", "path": "wt-feature"}}, {"tool": "bash", "arguments": {"command": "basename \"$(pwd)\""}}, {"text": "switched into wt-feature"}], "assert": [{"event": {"type": "tool_call", "name": "load_tool_schemas"}}, {"event": {"type": "tool_call", "name": "workspace"}}, {"request_contains": {"index": -1, "text": "wt-feature"}}, {"request_contains": {"index": -1, "text": "now at"}}, {"final_text_contains": "switched into wt-feature"}]}
{"id":"final-open-work-continues","why":"#745: plain final prose must not stop an unfinished checklist after tools have run.","args":[],"prompt":"finish the work","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"do the work","status":"in_progress"}]}},{"text":"I will continue working."},{"tool":"todo_write","arguments":{"todos":[{"content":"do the work","status":"completed"}]}},{"text":"Work completed."}],"assert":[{"request_contains":{"index":2,"text":"Open-work reconciliation"}},{"events_at_least":{"match":{"type":"tool_call","name":"todo_write"},"count":2}},{"final_text_contains":"Work completed."}]}
-{"id":"final-open-work-background","why":"#745: starting a background job must not turn a progress reply into a terminal response while independent root work remains.","args":[],"env":{"GRAFF_NO_CODEDB_GUARD":"1"},"prompt":"start a background check, do the independent root step, then collect the check and finish","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"root step and background check","status":"in_progress"}]}},{"tool":"bash","arguments":{"command":"sleep 0.1; echo worker-ready","run_in_background":true}},{"text":"The worker is running; I will continue the local work."},{"tool":"bash","arguments":{"command":"echo root-step-done"}},{"tool":"bash_output","arguments":{"id":1,"wait_ms":1000}},{"tool":"todo_write","arguments":{"todos":[{"content":"root step and background check","status":"completed"}]}},{"text":"Root step and background check completed."}],"assert":[{"request_contains":{"index":3,"text":"Open-work reconciliation"}},{"event":{"type":"tool_result","name":"bash","text":"root-step-done\n"}},{"event":{"type":"tool_call","name":"bash_output"}},{"events_at_most":{"match":{"type":"turn"},"count":1}},{"final_text_contains":"Root step and background check completed."}]}
+{"id":"final-open-work-background","why":"#745: starting a background job must not turn a progress reply into a terminal response while independent root work remains.","args":[],"env":{"GRAFF_NO_CODEDB_GUARD":"1"},"prompt":"start a background check, do the independent root step, then collect the check and finish","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"root step and background check","status":"in_progress"}]}},{"tool":"bash","arguments":{"command":"sleep 0.1; echo worker-ready","run_in_background":true}},{"text":"The worker is running; I will continue the local work."},{"tool":"bash","arguments":{"command":"echo root-step-done"}},{"tool":"bash_output","arguments":{"id":4294967296,"wait_ms":1000}},{"tool":"todo_write","arguments":{"todos":[{"content":"root step and background check","status":"completed"}]}},{"text":"Root step and background check completed."}],"assert":[{"request_contains":{"index":3,"text":"Open-work reconciliation"}},{"event":{"type":"tool_result","name":"bash","text":"root-step-done\n"}},{"event":{"type":"tool_call","name":"bash_output"}},{"events_at_most":{"match":{"type":"turn"},"count":1}},{"final_text_contains":"Root step and background check completed."}],"workspace_seed":{".codegraff/shell-id.lock":"shell-ids-v1\n",".codegraff/shell-id.counter":"4294967295\n"}}
{"id":"final-open-work-bounded","why":"#745: repeated status prose must not create an infinite retry loop or imply root execution continues after returning.","args":[],"prompt":"finish the two steps","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"first step","status":"in_progress"},{"content":"second step","status":"pending"}]}},{"text":"I will keep working."},{"text":"I will keep working."},{"tool":"bash","arguments":{"command":"echo must-not-run"}}],"assert":[{"request_contains":{"index":2,"text":"Open-work reconciliation"}},{"no_event":{"type":"tool_call","name":"bash"}},{"final_text_contains":"Root execution has stopped with 2 open checklist items"}]}
{"id":"final-open-work-status","why":"#745: an open checklist is not permission to resume work after a status-only user request; reconciliation is bounded and explicitly preserves that request.","args":[],"prompt":"create a pending checklist, then wait for my decision","second_prompt":"Only tell me the status; do not run tools or resume the task.","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"await decision","status":"pending"}]}},{"tool":"attempt_completion","arguments":{"result":"Waiting for your decision."}},{"text":"Waiting for your decision; no work has resumed."},{"text":"Waiting for your decision; root execution is stopping."},{"tool":"bash","arguments":{"command":"echo must-not-run"}}],"assert":[{"request_contains":{"index":3,"text":"status-only question"}},{"no_event":{"type":"tool_call","name":"bash"}},{"final_text_contains":"Waiting for your decision; root execution is stopping."}]}
{"id":"final-open-work-budget","why":"#745: reconciliation must not consume an unavailable model call when a plain final reaches the invocation budget.","args":["--max-model-calls","2"],"prompt":"start a checklist and report the limit","script":[{"tool":"todo_write","arguments":{"todos":[{"content":"unfinished","status":"pending"}]}},{"text":"The call budget is spent."},{"tool":"bash","arguments":{"command":"echo must-not-run"}}],"assert":[{"no_event":{"type":"tool_call","name":"bash"}},{"final_text_contains":"Root execution has stopped with 1 open checklist items"}]}
@@ -87,7 +87,7 @@
{"id": "mcp-wire-name-normalization", "why": "#930: loading a tool with spaces in its server name and punctuation in its tool name must emit an API-safe definition and retain original MCP dispatch.", "env": {"GRAFF_MCP_SCHEMA_BUDGET": "0", "GRAFF_MCP_PROBE": "0", "GRAFF_LEARN_AUTO": "off"}, "workspace_seed": {".mcp.json": "{\"mcpServers\": {\"docs server\": {\"command\": \"python3\", \"args\": [\"mock_mcp.py\"]}}}", "mock_mcp.py": "import json, sys\nfor line in sys.stdin:\n r = json.loads(line)\n if 'id' not in r: continue\n method = r.get('method')\n if method == 'initialize':\n result = {'protocolVersion':'2025-06-18','capabilities':{'tools':{}},'serverInfo':{'name':'fixture','version':'1'}}\n elif method == 'tools/list':\n result = {'tools':[{'name':'room.for_branch','description':'Find a room','inputSchema':{'type':'object','properties':{}}}]}\n elif method == 'tools/call':\n result = {'content':[{'type':'text','text':'original name routed' if r['params']['name'] == 'room.for_branch' else 'WRONG NAME'}]}\n else: result = {}\n print(json.dumps({'jsonrpc':'2.0','id':r['id'],'result':result}),flush=True)\n"}, "prompt": "Load the docs server tool, call it and report completion.", "script": [{"tool": "load_tool_schemas", "arguments": {"server": "docs server"}}, {"tool": "mcp__docs_x20server__room_x2efor_branch", "arguments": {}}, {"text": "routing complete"}], "assert": [{"request_contains": {"index": 1, "text": "mcp__docs_x20server__room_x2efor_branch"}}, {"request_lacks": {"index": 1, "text": "mcp__docs server__room.for_branch"}}, {"request_contains": {"index": -1, "text": "original name routed"}}, {"final_text_contains": "routing complete"}]}
{"id": "peer-inbox-preserves-live-body-865", "why": "#865: inject a device-room user message after the first drain; full body must survive deliverInbound and inbox tool dispatch without entering the wake.", "prompt": "Run the fixture injection, then read the peer inbox twice.", "script": [{"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'fixture-peer'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'prefix full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload BODY_END_865'\"'\"'})+'\"'\"'\\n'\"'\"'); f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"text": "fixture complete"}], "assert": [{"request_lacks": {"index": 1, "text": "[peer message from fixture-peer"}}, {"request_contains": {"index": 2, "text": "[peer message from fixture-peer"}}, {"request_contains": {"index": 2, "text": "[peer message from fixture-peer \\u00b7 device]: prefix full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload full body payload BODY_END_865"}}, {"request_contains": {"index": 3, "text": "inbox empty"}}, {"no_event": {"type": "tool_call_finished", "name": "peer_message", "is_error": true}}]}
{"id": "peer-inbox-live-multidrain-overflow-unicode-clear-865", "why": "#865: two live device-room drains overflow the eight-slot ring cumulatively (10 then 5: 2 then 7 lost); exact tool results prove retained 7..14 order and full 211-character Unicode bodies/device flags, read clears messages and loss, and later arrival has no stale loss. Assertions bind complete tool-result objects to call IDs to exclude scripted-command/history false positives. ADR0149/#1137: mid-tool-loop inbox arrivals stay parked rather than injecting a new authoritative user message; exact inbox result assertions below still prove cumulative loss and preserved bodies.", "prompt": "Inject the two fixture batches, read the inbox twice, inject the fresh fixture, and read twice again.", "script": [{"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(0,10)]; f.close()'"}}, {"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(10,15)]; f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "bash", "arguments": {"command": "python3 -c 'import json,os,pathlib; p=pathlib.Path(os.environ['\"'\"'HOME'\"'\"'])/'\"'\"'.graff/live/chan-all.jsonl'\"'\"'; p.parent.mkdir(parents=True,exist_ok=True); f=p.open('\"'\"'a'\"'\"'); [f.write(json.dumps({'\"'\"'from_pid'\"'\"':2147483000,'\"'\"'from_session'\"'\"':'\"'\"'overflow-fixture'\"'\"','\"'\"'from_user'\"'\"':True,'\"'\"'text'\"'\"':'\"'\"'item-%02d:'\"'\"'%i+chr(0x754c)*211+'\"'\"':tail-%02d'\"'\"'%i})+'\"'\"'\\n'\"'\"') for i in range(15,16)]; f.close()'"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"tool": "peer_message", "arguments": {"action": "inbox"}}, {"text": "fixture complete"}], "assert": [{"request_lacks": {"index": 1, "text": "[peer] 8 unread; 2 dropped"}}, {"request_lacks": {"index": 2, "text": "[peer] 8 unread; 7 dropped"}}, {"request_contains": {"index": 3, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_3\", \"content\": \"[peer inbox: 7 dropped message(s) could not be retained; the room log keeps the originals]\\n[peer message from overflow-fixture \\u00b7 device]: item-07:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-07\\n[peer message from overflow-fixture \\u00b7 device]: item-08:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-08\\n[peer message from overflow-fixture \\u00b7 device]: item-09:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-09\\n[peer message from overflow-fixture \\u00b7 device]: item-10:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-10\\n[peer message from overflow-fixture \\u00b7 device]: item-11:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-11\\n[peer message from overflow-fixture \\u00b7 device]: item-12:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-12\\n[peer message from overflow-fixture \\u00b7 device]: item-13:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-13\\n[peer message from overflow-fixture \\u00b7 device]: item-14:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-14\\n(inbox cleared \\u2014 reply with peer_message; omit session for the room, or name one peer to DM)\"}"}}, {"request_contains": {"index": 4, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_4\", \"content\": \"inbox empty\"}"}}, {"request_contains": {"index": 6, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_6\", \"content\": \"[peer message from overflow-fixture \\u00b7 device]: item-15:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-15\\n(inbox cleared \\u2014 reply with peer_message; omit session for the room, or name one peer to DM)\"}"}}, {"request_contains": {"index": 7, "text": "{\"role\": \"tool\", \"tool_call_id\": \"call_7\", \"content\": \"inbox empty\"}"}}, {"events_at_least": {"match": {"type": "tool_call_finished", "name": "peer_message", "is_error": false}, "count": 4}}, {"no_event": {"type": "tool_call_finished", "is_error": true}}, {"request_lacks": {"index": 1, "text": "[peer message from overflow-fixture"}}, {"request_lacks": {"index": 2, "text": "[peer message from overflow-fixture"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-00:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-00\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-01:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-01\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-02:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-02\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-03:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-03\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-04:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-04\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-05:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-05\\n"}}, {"request_lacks": {"index": 3, "text": "[peer message from overflow-fixture \\u00b7 device]: item-06:\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c\\u754c:tail-06\\n"}}]}
-{"id": "notification-wake-wire", "why": "Generated job wakes remain model-visible user context while saved provenance never reaches provider requests.", "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "Start a background check, do another step, then read the completed check.", "script": [{"tool": "bash", "arguments": {"command": "sleep 0.1; echo notification-ready", "run_in_background": true}}, {"tool": "bash", "arguments": {"command": "sleep 1; echo independent-step"}}, {"tool": "bash_output", "arguments": {"id": 1}}, {"text": "Check completed."}], "assert": [{"request_contains": {"index": 2, "text": "do not poll"}}, {"request_lacks": {"index": 2, "text": "_graff_origin"}}, {"final_text_contains": "Check completed."}]}
+{"id":"notification-wake-wire","why":"Generated job wakes remain model-visible user context while saved provenance never reaches provider requests.","env":{"GRAFF_NO_CODEDB_GUARD":"1"},"prompt":"Start a background check, do another step, then read the completed check.","script":[{"tool":"bash","arguments":{"command":"sleep 0.1; echo notification-ready","run_in_background":true}},{"tool":"bash","arguments":{"command":"sleep 1; echo independent-step"}},{"tool":"bash_output","arguments":{"id":4294967296}},{"text":"Check completed."}],"assert":[{"request_contains":{"index":2,"text":"do not poll"}},{"request_lacks":{"index":2,"text":"_graff_origin"}},{"final_text_contains":"Check completed."}],"workspace_seed":{".codegraff/shell-id.lock":"shell-ids-v1\n",".codegraff/shell-id.counter":"4294967295\n"}}
{"id": "readonly-heredoc-publication-text", "why": "#879: read-only heredoc data containing publication words must execute without triggering publication preflight.", "prompt": "Print the diagnostic text without publishing anything.", "script": [{"tool": "bash", "arguments": {"command": "python3 - <<'PYDATA'\ntext = 'gh pr create'\nprint('inert-data-ok:' + text)\nPYDATA"}}, {"text": "Diagnostic printed."}], "assert": [{"event": {"type": "tool_result", "name": "bash", "text": "inert-data-ok:gh pr create\n"}}, {"events_at_most": {"match": {"type": "tool_call_finished", "is_error": true}, "count": 0}}, {"final_text_contains": "Diagnostic printed."}]}
{"id": "informational-summary-bounded", "why": "#884: repository summaries retain bounded evidence gathering and receive one provenance-marked checkpoint without coding-work completion pressure.", "prompt": "go through the codebase and summarize what it does", "workspace_seed": {"README.md": "# Notebook\nA desktop note-taking app. App owns startup, Controller routes user actions, and Store persists notes. See src/App.swift and src/Controller.swift.\n", "src/App.swift": "struct App { let controller: Controller }\n", "src/Controller.swift": "struct Controller { let store: Store }\n", "src/Store.swift": "struct Store { func save(_ text: String) {} }\n", "src/Feature0.swift": "struct Feature0 {}\n", "src/Feature1.swift": "struct Feature1 {}\n", "src/Feature2.swift": "struct Feature2 {}\n", "src/Feature3.swift": "struct Feature3 {}\n", "src/Feature4.swift": "struct Feature4 {}\n", "src/Feature5.swift": "struct Feature5 {}\n", "src/Feature6.swift": "struct Feature6 {}\n", "src/Feature7.swift": "struct Feature7 {}\n", "src/Feature8.swift": "struct Feature8 {}\n", "src/Feature9.swift": "struct Feature9 {}\n", "src/Feature10.swift": "struct Feature10 {}\n", "src/Feature11.swift": "struct Feature11 {}\n", "tests/Feature0Tests.swift": "// Tests for feature 0\n", "tests/Feature1Tests.swift": "// Tests for feature 1\n", "tests/Feature2Tests.swift": "// Tests for feature 2\n", "tests/Feature3Tests.swift": "// Tests for feature 3\n", "tests/Feature4Tests.swift": "// Tests for feature 4\n", "tests/Feature5Tests.swift": "// Tests for feature 5\n", "tests/Feature6Tests.swift": "// Tests for feature 6\n", "tests/Feature7Tests.swift": "// Tests for feature 7\n", "tests/Feature8Tests.swift": "// Tests for feature 8\n", "tests/Feature9Tests.swift": "// Tests for feature 9\n"}, "script": [{"tool": "read_file", "arguments": {"path": "README.md"}}, {"tool": "read_file", "arguments": {"path": "src/App.swift"}}, {"tool": "read_file", "arguments": {"path": "src/Controller.swift"}}, {"tool": "read_file", "arguments": {"path": "src/Store.swift"}}, {"text": "Notebook is a desktop note-taking application. App owns startup, Controller routes user actions, and Store persists notes. The remaining feature modules and tests support that flow."}], "assert": [{"events_at_most": {"match": {"type": "tool_call"}, "count": 4}}, {"events_at_least": {"match": {"type": "tool_call", "name": "read_file"}, "count": 4}}, {"request_contains": {"index": -1, "text": "Summary scope checkpoint:"}}, {"request_lacks": {"index": 0, "text": "Summary scope checkpoint:"}}, {"request_lacks": {"index": -1, "text": "If the user requested a change, a description alone is not completion:"}}, {"final_text_contains": "Notebook is a desktop note-taking application. App owns startup, Controller routes user actions, and Store persists notes. The remaining feature modules and tests support that flow."}]}
{"id": "informational-summary-no-edit-bounce", "why": "#884: a completed summary of supplied evidence must not trigger the edit-oriented first-answer retry.", "args": ["--lean"], "prompt": "Summarize this architecture: App owns startup, Controller routes user actions, and Store persists notes.", "script": [{"text": "Notebook is a desktop note-taking application. App owns startup, Controller routes user actions, and Store persists notes. The remaining feature modules and tests support that flow."}], "assert": [{"events_at_most": {"match": {"type": "tool_call"}, "count": 0}}, {"request_lacks": {"index": -1, "text": "If the user requested a change, a description alone is not completion:"}}, {"request_contains": {"index": 0, "text": "Task scope: first distinguish"}}, {"final_text_contains": "Notebook is a desktop note-taking application. App owns startup, Controller routes user actions, and Store persists notes. The remaining feature modules and tests support that flow."}]}
@@ -121,8 +121,8 @@
{"id": "completion-result-keeps-evidence-and-limits", "why": "A result-only completion must deliver the full verified answer and remaining limitations without requiring duplicate assistant prose; this checks delivery, not model compliance with the wording.", "prompt": "Run the fixture verification command, then report the exact evidence and the remaining integration-test limitation.", "script": [{"tool": "shell", "arguments": {"command": "printf 'fixture verification: OK\\n'"}}, {"tool": "attempt_completion", "arguments": {"result": "Verified: fixture verification: OK.\nRemaining: integration tests were not run."}}], "assert": [{"event": {"type": "tool_result", "name": "shell", "is_error": false}}, {"final_text_contains": "Verified: fixture verification: OK."}, {"final_text_contains": "Remaining: integration tests were not run."}, {"events_at_most": {"match": {"type": "model_call_started"}, "count": 2}}]}
{"args": ["--old"], "prompt": "Run the scripted verification fixture and report only observed results.", "id": "completion-pending-automatic", "why": "An unfinished shell receipt cannot satisfy same-batch completion; pending is not command failure.", "script": [{"tools": [{"tool": "shell", "arguments": {"command": "sleep 1; exit 0", "timeout": 1}}, {"tool": "attempt_completion", "arguments": {"result": "PREMATURE_COMPLETION"}}]}, {"text": "Verification is still pending."}], "assert": [{"event": {"type": "tool_call_finished", "name": "shell", "is_error": false}}, {"event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": true}}, {"no_event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": false}}, {"final_text_contains": "Verification is still pending."}]}
{"args": ["--old"], "prompt": "Run the scripted verification fixture and report only observed results.", "id": "completion-pending-explicit", "why": "An unfinished shell receipt cannot satisfy same-batch completion; pending is not command failure.", "script": [{"tools": [{"tool": "shell", "arguments": {"command": "sleep 0.2; exit 0", "run_in_background": true}}, {"tool": "attempt_completion", "arguments": {"result": "PREMATURE_COMPLETION"}}]}, {"text": "Verification is still pending."}], "assert": [{"event": {"type": "tool_call_finished", "name": "shell", "is_error": false}}, {"event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": true}}, {"no_event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": false}}, {"final_text_contains": "Verification is still pending."}]}
-{"args": ["--old"], "prompt": "Run the scripted verification fixture and report only observed results.", "id": "completion-resumed-failure", "why": "A resumed verification result admits completion only after a successful terminal exit.", "script": [{"tool": "shell", "arguments": {"command": "printf 'RESUMED_EXIT_SEVEN\\n'; exit 7", "run_in_background": true}}, {"tool": "shell", "arguments": {"command": "sleep 0.3"}}, {"tools": [{"tool": "shell", "arguments": {"action": "output", "id": 1, "wait_ms": 1000}}, {"tool": "attempt_completion", "arguments": {"result": "FAILED_COMPLETION"}}]}, {"text": "Verification failed; completion withheld."}], "assert": [{"event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": true}}, {"no_event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": false}}, {"event": {"type": "tool_result", "name": "shell", "is_error": true, "text": "[job 1: exited with code 7]\nRESUMED_EXIT_SEVEN\n", "id": "call_3_0"}}, {"request_contains": {"text": "exited with code 7"}}]}
-{"args": ["--old"], "prompt": "Run the scripted verification fixture and report only observed results.", "id": "completion-resumed-success", "why": "A resumed verification result admits completion only after a successful terminal exit.", "script": [{"tool": "shell", "arguments": {"command": "printf 'RESUMED_EXIT_ZERO\\n'; exit 0", "run_in_background": true}}, {"tool": "shell", "arguments": {"command": "sleep 0.3"}}, {"tools": [{"tool": "shell", "arguments": {"action": "output", "id": 1, "wait_ms": 1000}}, {"tool": "attempt_completion", "arguments": {"result": "VERIFIED_COMPLETION"}}]}, {"text": "Verification failed; completion withheld."}], "assert": [{"event": {"type": "tool_call_finished", "name": "attempt_completion", "is_error": false}}, {"final_text_contains": "VERIFIED_COMPLETION"}, {"event": {"type": "tool_result", "name": "shell", "is_error": false, "text": "[job 1: exited with code 0]\nRESUMED_EXIT_ZERO\n", "id": "call_3_0"}}]}
+{"args":["--old"],"prompt":"Run the scripted verification fixture and report only observed results.","id":"completion-resumed-failure","why":"A resumed verification result admits completion only after a successful terminal exit.","script":[{"tool":"shell","arguments":{"command":"printf 'RESUMED_EXIT_SEVEN\\n'; exit 7","run_in_background":true}},{"tool":"shell","arguments":{"command":"sleep 0.3"}},{"tools":[{"tool":"shell","arguments":{"action":"output","id":4294967296,"wait_ms":1000}},{"tool":"attempt_completion","arguments":{"result":"FAILED_COMPLETION"}}]},{"text":"Verification failed; completion withheld."}],"assert":[{"event":{"type":"tool_call_finished","name":"attempt_completion","is_error":true}},{"no_event":{"type":"tool_call_finished","name":"attempt_completion","is_error":false}},{"event":{"type":"tool_result","name":"shell","is_error":true,"text":"[job 4294967296: exited with code 7]\nRESUMED_EXIT_SEVEN\n","id":"call_3_0"}},{"request_contains":{"text":"exited with code 7"}}],"workspace_seed":{".codegraff/shell-id.lock":"shell-ids-v1\n",".codegraff/shell-id.counter":"4294967295\n"}}
+{"args":["--old"],"prompt":"Run the scripted verification fixture and report only observed results.","id":"completion-resumed-success","why":"A resumed verification result admits completion only after a successful terminal exit.","script":[{"tool":"shell","arguments":{"command":"printf 'RESUMED_EXIT_ZERO\\n'; exit 0","run_in_background":true}},{"tool":"shell","arguments":{"command":"sleep 0.3"}},{"tools":[{"tool":"shell","arguments":{"action":"output","id":4294967296,"wait_ms":1000}},{"tool":"attempt_completion","arguments":{"result":"VERIFIED_COMPLETION"}}]},{"text":"Verification failed; completion withheld."}],"assert":[{"event":{"type":"tool_call_finished","name":"attempt_completion","is_error":false}},{"final_text_contains":"VERIFIED_COMPLETION"},{"event":{"type":"tool_result","name":"shell","is_error":false,"text":"[job 4294967296: exited with code 0]\nRESUMED_EXIT_ZERO\n","id":"call_3_0"}}],"workspace_seed":{".codegraff/shell-id.lock":"shell-ids-v1\n",".codegraff/shell-id.counter":"4294967295\n"}}
{"id": "malformed-edit-batch-recovers", "why": "A string-valued edits field used to panic on unchecked union access; return a tool error without writing so the next model turn can retry a valid array and finish.", "args": [], "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "Create version.txt with alpha and beta, then update both lines using a batched edit. Correct any malformed arguments and verify the final file.", "script": [{"tool": "write_file", "arguments": {"path": "version.txt", "content": "alpha\nbeta\n"}}, {"tool": "edit_file", "arguments": {"path": "version.txt", "edits": "[{\"old_string\":\"alpha\",\"new_string\":\"ALPHA\"}]"}}, {"tool": "edit_file", "arguments": {"path": "version.txt", "edits": [{"old_string": "alpha", "new_string": "ALPHA"}, {"old_string": "beta", "new_string": "BETA"}]}}, {"tool": "bash", "arguments": {"command": "test \"$(cat version.txt)\" = \"$(printf 'ALPHA\\nBETA')\" && echo EDIT_BATCH_RECOVERED"}}, {"text": "The corrected batch landed and was verified."}], "assert": [{"event": {"type": "tool_call_finished", "name": "edit_file", "is_error": true}}, {"events_at_most": {"match": {"type": "tool_call_finished", "is_error": true}, "count": 1}}, {"event": {"type": "tool_call_finished", "name": "edit_file", "is_error": false}}, {"request_contains": {"index": 2, "text": "edits must be an array"}}, {"event": {"type": "tool_result", "name": "bash", "text": "EDIT_BATCH_RECOVERED\n"}}, {"file_equals": {"path": "version.txt", "content": "ALPHA\nBETA\n"}}, {"final_text_contains": "The corrected batch landed and was verified."}]}
{"id": "exact-reply-one-call", "why": "An explicit literal reply needs no edit-oriented fake-done retry.", "args": ["--lean", "-p", "Reply with exactly: pong"], "prompt": "Reply with exactly: pong", "script": [{"text": "pong"}], "assert": [{"request_count": 1}, {"stdout_equals": "pong\n"}]}
{"id": "exact-reply-quoted-action-words", "why": "An explicit literal reply needs no edit-oriented fake-done retry.", "args": ["--lean", "-p", "Reply with exactly: \"run tests and deploy\""], "prompt": "Reply with exactly: \"run tests and deploy\"", "script": [{"text": "run tests and deploy"}], "assert": [{"request_count": 1}, {"stdout_equals": "run tests and deploy\n"}]}
diff --git a/scripts/eval-tier1.sh b/scripts/eval-tier1.sh
index d61a25ac..4d29c92e 100755
--- a/scripts/eval-tier1.sh
+++ b/scripts/eval-tier1.sh
@@ -27,7 +27,7 @@ cd "$repo_root"
# processes discover their repo from their cwd like they expect.
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_COMMON_DIR GIT_OBJECT_DIRECTORY GIT_PREFIX
-CHECKS=(fmt lines spec reach build tests tui tuiguard invariants sdk)
+CHECKS=(fmt lines spec reach build shell tests tui tuiguard invariants sdk)
usage() {
cat <<'EOF'
@@ -39,6 +39,7 @@ checks, in order:
spec spec/conformance.py (kernel properties + fixture staleness)
reach every file that declares tests is reachable from the test root
build zig build
+ shell durable shell IDs and stale-handle isolation after a crash
tests zig build test, and the suite count never shrinks
tui zig build tui-test (the TUI suite was ungated until the 2026-08 bug wave)
tuiguard real-binary pty probes: lifecycle invariants (tui-pty-guard.py)
@@ -169,6 +170,28 @@ skip_dependent() {
printf '\n \033[33mskipped\033[0m %s (zig build failed above)\n' "$1"
}
+# --- shell -------------------------------------------------------------
+if wanted shell; then
+ if ((!build_ok)); then
+ skip_dependent shell
+ else
+ announce shell "durable reservations and stale handles cannot target new jobs"
+ if (
+ probe_dir=$(mktemp -d) || exit 1
+ trap 'rm -rf "$probe_dir"' EXIT
+ if [[ $(uname -s) == Darwin && -z ${SDKROOT:-} ]]; then
+ SDKROOT=$(xcrun --sdk macosx --show-sdk-path) || exit 1
+ export SDKROOT
+ fi
+ python3 scripts/eval/process_guard.py --timeout 180 zig build-exe src/shell_identity_probe.zig -lc -femit-bin="$probe_dir/identity" &&
+ python3 scripts/eval/process_guard.py --timeout 60 python3 scripts/test-shell-identity.py "$probe_dir/identity" &&
+ python3 scripts/eval/process_guard.py --timeout 90 python3 scripts/test-shell-restart.py zig-out/bin/graff
+ ); then :; else
+ record_fail shell
+ fi
+ fi
+fi
+
# --- tests -------------------------------------------------------------
suite_count() {
# `--summary all` prints "P/T tests passed (S skipped)" when the run step
diff --git a/scripts/test-shell-identity.py b/scripts/test-shell-identity.py
new file mode 100644
index 00000000..fd0e9f58
--- /dev/null
+++ b/scripts/test-shell-identity.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+"""Offline durable reservation races and hard-crash recovery (no shell launch)."""
+import concurrent.futures
+import os
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+
+FIRST = 1 << 32
+LAST = (1 << 53) - 1
+
+
+def main():
+ probe = str(Path(sys.argv[1]).resolve())
+ with tempfile.TemporaryDirectory(prefix='graff-shell-identity-') as tmp:
+ home = Path(tmp)
+ env = dict(os.environ, HOME=str(home))
+ def reserve():
+ run = subprocess.run([probe], env=env, capture_output=True, text=True, timeout=15)
+ assert run.returncode == 0, run.stderr
+ return int(run.stderr.strip())
+ def race(count):
+ with concurrent.futures.ThreadPoolExecutor(max_workers=count) as pool:
+ return list(pool.map(lambda _: reserve(), range(count)))
+ initial = race(12)
+ assert sorted(initial) == list(range(FIRST, FIRST + 12)), initial
+ existing = race(12)
+ assert sorted(existing) == list(range(FIRST + 12, FIRST + 24)), existing
+ # The probe stops exactly after the production allocator has durably
+ # reserved its handle and before any process dispatch. SIGKILL gives it
+ # no opportunity to run a save, destructor, or recovery callback.
+ child = subprocess.Popen([probe], env=dict(env, GRAFF_TEST_RESERVATION_HOLD='1'),
+ stdout=subprocess.DEVNULL, stderr=subprocess.PIPE, text=True)
+ try:
+ reserved = int(child.stderr.readline().strip())
+ child.kill()
+ assert child.wait(timeout=5) != 0
+ finally:
+ if child.poll() is None:
+ child.kill()
+ child.wait(timeout=5)
+ child.stderr.close()
+ assert reserved == FIRST + 24
+ assert reserve() == reserved + 1
+ counter = home/'.codegraff/shell-id.counter'
+ for value in ('broken\n', f'{LAST}\n', None):
+ if value is None:
+ counter.unlink()
+ else:
+ counter.write_text(value)
+ result = subprocess.run([probe], env=env, capture_output=True, text=True, timeout=15)
+ assert result.returncode != 0, value
+ print('PASS shell identities: fresh/existing process races, SIGKILL after reservation, corruption/exhaustion/missing state')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/test-shell-restart.py b/scripts/test-shell-restart.py
new file mode 100644
index 00000000..d7f5ed2a
--- /dev/null
+++ b/scripts/test-shell-restart.py
@@ -0,0 +1,161 @@
+#!/usr/bin/env python3
+"""Offline harness crash/restart regression: stale shell IDs cannot reach new jobs."""
+import argparse, json, os, re, shlex, signal, subprocess, sys, tempfile, threading, time
+from pathlib import Path
+REPO = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(REPO / 'scripts/eval'))
+from mock_model import ScriptedModel
+
+
+def wait_until(fn, timeout=15):
+ end = time.monotonic() + timeout
+ while time.monotonic() < end:
+ if fn(): return
+ time.sleep(.025)
+ raise AssertionError('fixture deadline expired')
+
+
+def tool_text(body):
+ return [m.get('content', '') for m in body.get('messages', []) if m.get('role') == 'tool']
+
+
+def rejected(text):
+ # Historical records may say interrupted; unknown handles must fail closed.
+ return bool(re.search(r'no background job|unknown (?:background )?job|interrupted|stale (?:shell )?(?:job|handle)', text, re.I))
+
+
+def job_id(text):
+ found = re.search(r'\[job (\d+) started:', text)
+ if not found: raise AssertionError(f'no started handle in {text[:500]!r}')
+ return int(found.group(1))
+
+
+class Model(ScriptedModel):
+ def __init__(self, directory, name, old=None):
+ super().__init__([])
+ self.directory, self.name, self.old = directory, name, old
+ self.ready, self.release = threading.Event(), threading.Event()
+ self.handle, self.error, self.checked = None, None, {}
+
+ def next_reply(self, body):
+ with self._lock:
+ self.requests.append(body)
+ n = len(self.requests)
+ try:
+ if n == 1:
+ command = 'exec ' + shlex.join([sys.executable, str(self.directory / 'child.py'), str(self.directory), self.name])
+ return {'tool': 'shell', 'arguments': {'action': 'run', 'command': command, 'run_in_background': True}}
+ results = tool_text(body)
+ if n == 2:
+ self.handle = job_id(results[-1])
+ wait_until(lambda: (self.directory / (self.name + '.heartbeat')).exists())
+ time.sleep(.15)
+ self.ready.set()
+ if self.old is None:
+ self.release.wait(20)
+ return {'text': 'A finished'}
+ return {'tool': 'bash_output', 'arguments': {'id': self.old, 'wait_ms': 0}}
+ if n == 3:
+ self.checked['stale_output'] = results[-1]
+ return {'tool': 'bash_kill', 'arguments': {'id': self.old}}
+ if n == 4:
+ self.checked['stale_kill'] = results[-1]
+ heartbeat = self.directory / 'B.heartbeat'
+ first = heartbeat.stat().st_size
+ time.sleep(.35)
+ self.checked['b_alive_after_stale_kill'] = heartbeat.stat().st_size > first
+ self.checked['output_rejected'] = rejected(self.checked['stale_output'])
+ self.checked['kill_rejected'] = rejected(self.checked['stale_kill'])
+ self.checked['b_output_disclosed'] = 'ONLY-B-' in self.checked['stale_output']
+ return {'text': 'isolation checked'}
+ return {'text': 'done'}
+ except Exception as exc:
+ self.error = repr(exc)
+ self.ready.set()
+ return {'text': 'fixture error'}
+
+
+def cleanup_child(directory, name):
+ identity = directory / (name + '.identity')
+ if not identity.exists(): return
+ record = json.loads(identity.read_text())
+ pid = record['pid']
+ try:
+ cmd = subprocess.check_output(['ps', '-p', str(pid), '-o', 'command='], text=True).strip()
+ # Signal only a currently verified child launched from this private directory.
+ if str(directory / 'child.py') not in cmd: return
+ if os.getpgid(pid) != record['pgid'] or record['pgid'] != pid:
+ raise AssertionError('unexpected child process group; refusing cleanup signal')
+ os.killpg(pid, signal.SIGKILL)
+ except (ProcessLookupError, subprocess.CalledProcessError): pass
+
+
+def start(binary, directory, model):
+ port = model.start(0)
+ env = {k: v for k, v in os.environ.items() if not k.endswith('_API_KEY') and not k.startswith(('GRAFF_', 'HARNESS_'))}
+ env.update(HOME=str(directory / 'home'), AI_GATEWAY_API_KEY='local', GRAFF_FLEET='off',
+ GRAFF_VERCEL_URL=f'http://127.0.0.1:{port}/v1/chat/completions', GRAFF_NO_TELEMETRY='1',
+ GRAFF_NO_SMOLIFY='1', GRAFF_BEHAVIOR_UPLOAD='off', NO_COLOR='1')
+ out = open(directory / (model.name + '.stdout'), 'w')
+ err = open(directory / (model.name + '.stderr'), 'w')
+ proc = subprocess.Popen([str(binary), '--json', '--yolo', '--old', '--no-lean', '--max-model-calls', '6', '--model', 'vercel'],
+ cwd=directory, env=env, stdin=subprocess.PIPE, stdout=out, stderr=err, text=True, start_new_session=True)
+ proc.stdin.write(json.dumps({'type': 'user', 'text': 'Run the scripted shell job and handle checks.'}) + '\n')
+ proc.stdin.flush()
+ return proc, out, err
+
+
+def run(binary, expect):
+ directory = Path(tempfile.mkdtemp(prefix='graff-shell-restart-'))
+ os.chmod(directory, 0o700)
+ (directory / 'home').mkdir(mode=0o700)
+ (directory / 'child.py').write_text('''import json, os, sys, time
+from pathlib import Path
+root, name = Path(sys.argv[1]), sys.argv[2]
+(root / (name + '.identity')).write_text(json.dumps({'pid':os.getpid(),'pgid':os.getpgrp()}))
+print('ONLY-' + name + '-PRIVATE-JOB-OUTPUT', flush=True)
+for _ in range(1200):
+ with (root / (name + '.heartbeat')).open('a') as f: f.write('.')
+ time.sleep(.05)
+''')
+ running = []
+ models = []
+ try:
+ a = Model(directory, 'A'); models.append(a)
+ process_a, out_a, err_a = start(binary, directory, a); running.append((process_a, out_a, err_a))
+ assert a.ready.wait(20), 'A did not return a background handle'
+ assert not a.error, a.error
+ assert a.handle is not None
+ process_a.kill(); process_a.wait(timeout=5) # abrupt harness crash, no shutdown cleanup
+ a.release.set()
+ cleanup_child(directory, 'A')
+ b = Model(directory, 'B', a.handle); models.append(b)
+ process_b, out_b, err_b = start(binary, directory, b); running.append((process_b, out_b, err_b))
+ wait_until(lambda: bool(b.checked.get('stale_kill')) or b.error is not None, 25)
+ wait_until(lambda: 'b_alive_after_stale_kill' in b.checked or b.error is not None, 5)
+ assert not b.error, b.error
+ passed = bool(b.handle != a.handle and b.checked['output_rejected'] and b.checked['kill_rejected'] and
+ b.checked['b_alive_after_stale_kill'] and not b.checked['b_output_disclosed'])
+ report = dict(binary=str(binary), old_handle=a.handle, new_handle=b.handle, passed=passed, **b.checked)
+ (directory / 'receipt.json').write_text(json.dumps(report, indent=2))
+ print(json.dumps(dict(directory=str(directory), **report), indent=2))
+ assert passed == (expect == 'pass'), f'expected {expect}, observed {passed}'
+ finally:
+ for model in models: model.release.set()
+ for process, out, err in running:
+ if process.poll() is None: process.kill()
+ process.wait(timeout=5)
+ out.close(); err.close()
+ for name in ('A', 'B'): cleanup_child(directory, name)
+ for model in models: model.stop()
+
+
+if __name__ == '__main__':
+ if os.name != 'posix':
+ print('SKIP shell crash/restart: POSIX process-group fixture')
+ sys.exit(0)
+ parser = argparse.ArgumentParser()
+ parser.add_argument('binary', type=Path, nargs='?', default=REPO / 'zig-out/bin/graff')
+ parser.add_argument('--expect', choices=['pass', 'fail'], default='pass')
+ args = parser.parse_args()
+ run(args.binary.resolve(), args.expect)
diff --git a/src/commands_jobs.zig b/src/commands_jobs.zig
index 7c9a3b74..99cc10c9 100644
--- a/src/commands_jobs.zig
+++ b/src/commands_jobs.zig
@@ -31,7 +31,7 @@ pub fn tryHandle(root: *Agent, line: []const u8, out: *Io.Writer) !bool {
fn control(root: *Agent, rest: []const u8, out: *Io.Writer) !void {
var it = std.mem.tokenizeAny(u8, rest, " \t");
const verb = it.next() orelse return out.print("{s}\n", .{usage});
- const id = std.fmt.parseInt(u32, it.next() orelse "", 10) catch return out.print("{s}\n", .{usage});
+ const id = std.fmt.parseInt(u64, it.next() orelse "", 10) catch return out.print("{s}\n", .{usage});
if (std.mem.eql(u8, verb, "keep") or std.mem.eql(u8, verb, "unkeep")) {
const keep = verb[0] == 'k';
const ok = jobs.setPinned(root.io, id, keep) orelse return out.print("no background job {d} — /jobs lists them\n", .{id});
@@ -60,7 +60,7 @@ fn control(root: *Agent, rest: []const u8, out: *Io.Writer) !void {
}
const Row = struct {
- id: u32,
+ id: u64,
pid: i32,
running: bool,
status: []const u8,
diff --git a/src/doctor_live.zig b/src/doctor_live.zig
index 804bb722..963d340a 100644
--- a/src/doctor_live.zig
+++ b/src/doctor_live.zig
@@ -17,7 +17,7 @@ const jobs_mod = @import("jobs.zig");
const posix_groups = builtin.os.tag != .windows and builtin.os.tag != .wasi;
pub const JobView = struct {
- id: u32 = 0,
+ id: u64 = 0,
done: bool = false,
shares_root_pgid: bool = false,
};
@@ -98,7 +98,7 @@ fn jobStateLine(arena: Allocator, jobs: []const JobView) Allocator.Error!Check {
fn jobSharesRoot(arena: Allocator, jobs: []const JobView) Allocator.Error!?Check {
var n: usize = 0;
- var first: u32 = 0;
+ var first: u64 = 0;
for (jobs) |j| {
if (!j.shares_root_pgid) continue;
if (n == 0) first = j.id;
diff --git a/src/engine_events.zig b/src/engine_events.zig
index 86171230..cbb39266 100644
--- a/src/engine_events.zig
+++ b/src/engine_events.zig
@@ -297,7 +297,7 @@ pub const EngineEvent = union(enum) {
tool_output_delta: struct { name: []const u8, stderr: bool = false, text: []const u8 },
/// A background bash job finished (grok-build TaskCompleted). Pulse:
/// the model learns via the injected wake, not a durable wire id.
- job_completed: struct { id: u32, exit_code: ?u8 = null, killed: bool = false },
+ job_completed: struct { id: u64, exit_code: ?u8 = null, killed: bool = false },
/// A live transport attempt was cut; the payload says how and whether
/// the turn ends with it (slice 1b). Distinct from stream_aborted: no
/// partial answer is in flight, so sinks notice without flushing.
diff --git a/src/exec_bash.zig b/src/exec_bash.zig
index b922a133..404ce33f 100644
--- a/src/exec_bash.zig
+++ b/src/exec_bash.zig
@@ -65,6 +65,8 @@ fn spawnFailText(gpa: Allocator, err: anyerror) ![]u8 {
// #122: backgrounding costs MORE fds (pipes + pump task), so the generic
// "run it in the foreground" advice is right for every error except the
// fd-quota ones. #253: SYSTEM-wide exhaustion is not a ulimit problem.
+ if (err == error.ShellIdentityHomeRequired or err == error.ShellIdentityStoreInvalid or err == error.ShellIdentityExhausted or err == error.ShellIdentityUnavailable)
+ return std.fmt.allocPrint(gpa, "could not reserve a durable shell handle ({t}); no command was started. Check HOME and its .codegraff directory permissions. Preserve existing shell-id files when repairing storage.", .{err});
return if (err == error.ProcessFdQuotaExceeded)
try gpa.dupe(u8, "could not start background job (ProcessFdQuotaExceeded) — graff hit its open-file limit. Wait for running jobs/tools to finish, then retry with less parallel fan-out; if it recurs, raise the limit (`ulimit -n 4096`) before starting graff.")
else if (err == error.SystemFdQuotaExceeded)
@@ -73,7 +75,7 @@ fn spawnFailText(gpa: Allocator, err: anyerror) ![]u8 {
try std.fmt.allocPrint(gpa, "could not start background job ({t}) — run it in the foreground instead", .{err});
}
-fn startedText(gpa: Allocator, id: u32, cmd: []const u8, ssh: bool, auto_bg: bool, wait_s: u64, partial: []const u8) ![]u8 {
+fn startedText(gpa: Allocator, id: u64, cmd: []const u8, ssh: bool, auto_bg: bool, wait_s: u64, partial: []const u8) ![]u8 {
var aw: Io.Writer.Allocating = .init(gpa);
errdefer aw.deinit();
const w = &aw.writer;
diff --git a/src/job_idle.zig b/src/job_idle.zig
index 471bd5fa..22f73d91 100644
--- a/src/job_idle.zig
+++ b/src/job_idle.zig
@@ -55,7 +55,7 @@ fn parseMins(v: []const u8) ?u64 {
}
/// The one dim chrome line at the warn threshold.
-pub fn warnLine(buf: []u8, id: u32, idle_ms: u64, stop_ms: u64, cmd: []const u8) []const u8 {
+pub fn warnLine(buf: []u8, id: u64, idle_ms: u64, stop_ms: u64, cmd: []const u8) []const u8 {
var a: [16]u8 = undefined;
var b: [16]u8 = undefined;
return std.fmt.bufPrint(buf, "· job {d} idle {s} ({s}) · stops after {s} idle · /jobs keep {d} pins it", .{
@@ -64,14 +64,14 @@ pub fn warnLine(buf: []u8, id: u32, idle_ms: u64, stop_ms: u64, cmd: []const u8)
}
/// Pump thread: paint the warn line (hosted sink or line-REPL stdout).
-pub fn warn(io: Io, id: u32, idle_ms: u64, cmd: []const u8) void {
+pub fn warn(io: Io, id: u64, idle_ms: u64, cmd: []const u8) void {
var buf: [160]u8 = undefined;
const line = warnLine(&buf, id, idle_ms, policy.stop_ms, cmd);
if (line.len > 0) tool_pulse.emitNotice(io, "{s}", .{line});
}
/// The bash_output status line for a job the policy stopped.
-pub fn printStopped(w: *Io.Writer, id: u32, stop_ms: u64) !void {
+pub fn printStopped(w: *Io.Writer, id: u64, stop_ms: u64) !void {
var b: [16]u8 = undefined;
try w.print("[job {d}: stopped after {s} with no output and no reads — rerun it if it is still needed; the user pins a long-lived server with /jobs keep {d}]", .{ id, tool_pulse.formatElapsed(&b, stop_ms), id });
}
diff --git a/src/job_notify.zig b/src/job_notify.zig
index 424d1f9f..7178a96d 100644
--- a/src/job_notify.zig
+++ b/src/job_notify.zig
@@ -14,7 +14,7 @@ const Agent = agent_mod.Agent;
const output_cap: usize = 3072;
pub const Notice = struct {
- id: u32,
+ id: u64,
exit_code: ?u8 = null,
killed: bool = false,
idle: bool = false, // the idle policy stopped it (#199): no auto-turn wake
@@ -37,7 +37,7 @@ var count: usize = 0;
/// Legacy bounded dismiss-before-record credits (ADR 0061). The production
/// pump no longer relies on these: done + queue and consumption share the
/// jobs mutex, so eviction cannot resurrect a consumed completion (#728).
-var dismissed: [cap]u32 = undefined;
+var dismissed: [cap]u64 = undefined;
var dismissed_len: usize = 0;
/// Unit fixtures must join their job pumps before clearing notification state.
@@ -95,7 +95,7 @@ fn wakeLine(buf: []u8, n: Notice) []const u8 {
/// Standalone notification convenience (tests). The job pump MUST split
/// queue (under jobs mutex) from publish (outside it); calling this after
/// exposing done reintroduces #728. Publication is UI, not a model wake.
-pub fn record(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8, idle: bool) void {
+pub fn record(io: Io, id: u64, exit_code: ?u8, killed: bool, cmd: []const u8, idle: bool) void {
queue(io, id, exit_code, killed, cmd, idle, "");
publish(io, id, exit_code, killed);
}
@@ -103,7 +103,7 @@ pub fn record(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8, id
/// Queue while holding the jobs mutex, in the same critical section as done.
/// Consumers hold jobs -> notification mutex in that same order. Never call
/// a frontend here: it may re-enter jobOutput.
-pub fn queue(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8, idle: bool, output: []const u8) void {
+pub fn queue(io: Io, id: u64, exit_code: ?u8, killed: bool, cmd: []const u8, idle: bool, output: []const u8) void {
const clipped = clipCmd(cmd);
const tail = clipOutput(output);
const n = Notice{
@@ -120,7 +120,7 @@ pub fn queue(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8, idl
mu.lockUncancelable(io);
var queued = false;
if (dismissedIndex(id)) |i| {
- std.mem.copyForwards(u32, dismissed[i .. dismissed_len - 1], dismissed[i + 1 .. dismissed_len]);
+ std.mem.copyForwards(u64, dismissed[i .. dismissed_len - 1], dismissed[i + 1 .. dismissed_len]);
dismissed_len -= 1;
} else {
if (count == cap) {
@@ -136,14 +136,14 @@ pub fn queue(io: Io, id: u32, exit_code: ?u8, killed: bool, cmd: []const u8, idl
}
/// Frontend-only publication AFTER releasing the jobs mutex. No wake is queued.
-pub fn publish(io: Io, id: u32, exit_code: ?u8, killed: bool) void {
+pub fn publish(io: Io, id: u64, exit_code: ?u8, killed: bool) void {
if (engine_sink.hostedSink()) |sink| {
sink.emit(io, .{ .job_completed = .{ .id = id, .exit_code = exit_code, .killed = killed } });
}
}
/// Caller holds `mu`.
-fn dismissedIndex(id: u32) ?usize {
+fn dismissedIndex(id: u64) ?usize {
for (dismissed[0..dismissed_len], 0..) |d, i| if (d == id) return i;
return null;
}
@@ -154,7 +154,7 @@ fn dismissedIndex(id: u32) ?usize {
/// turn, which the model then spends on a `bash_output` snapshot that says
/// "(no new output)". Drop the queued notice; if the pump has not queued it
/// yet, remember the id so `record` skips it. ADR 0061.
-pub fn dismiss(io: Io, id: u32) void {
+pub fn dismiss(io: Io, id: u64) void {
mu.lockUncancelable(io);
defer mu.unlock(io);
var i: usize = 0;
@@ -170,7 +170,7 @@ pub fn dismiss(io: Io, id: u32) void {
}
if (found or dismissedIndex(id) != null) return;
if (dismissed_len == cap) {
- std.mem.copyForwards(u32, dismissed[0 .. cap - 1], dismissed[1..cap]);
+ std.mem.copyForwards(u64, dismissed[0 .. cap - 1], dismissed[1..cap]);
dismissed_len = cap - 1;
}
dismissed[dismissed_len] = id;
@@ -180,7 +180,7 @@ pub fn dismiss(io: Io, id: u32) void {
/// The tool result for a bash_output wait that ended before the job did.
/// An Esc used to be rendered by setting the elapsed counter to the 10-hour
/// deadline, so the model read "36000s elapsed" for a 36-second wait.
-pub fn printRunning(w: *Io.Writer, id: u32, waited_ms: u64, interrupted: bool, persistent: bool) !void {
+pub fn printRunning(w: *Io.Writer, id: u64, waited_ms: u64, interrupted: bool, persistent: bool) !void {
var ebuf: [16]u8 = undefined;
const el = tool_pulse.formatElapsed(&ebuf, waited_ms);
if (persistent) {
@@ -202,7 +202,7 @@ pub fn printRunning(w: *Io.Writer, id: u32, waited_ms: u64, interrupted: bool, p
/// wait runs long (#607). ADR 0010 keeps the wait single-hop; this only tells
/// the human it is alive. Presentation pulse: --json drops it, and a session
/// with no bound sink (subagents) stays quiet.
-pub fn stillRunning(io: Io, id: u32, waited_ms: u64, unread: usize) void {
+pub fn stillRunning(io: Io, id: u64, waited_ms: u64, unread: usize) void {
var ebuf: [16]u8 = undefined;
tool_pulse.emitNotice(io, "· bash_output · job {d} still running · {s} · {d} unread byte(s)", .{ id, tool_pulse.formatElapsed(&ebuf, waited_ms), unread });
}
diff --git a/src/jobs.zig b/src/jobs.zig
index ab78c3d6..4a10c90d 100644
--- a/src/jobs.zig
+++ b/src/jobs.zig
@@ -55,7 +55,7 @@ pub const KeepReason = agent_worktree.KeepReason;
pub const keepReasonText = agent_worktree.keepReasonText;
const Job = struct { // session-global; pump drains pipes; survives Esc
- id: u32,
+ id: u64,
cmd: []u8,
child: std.process.Child,
// #199 idle lifecycle + ownership record (job_idle.zig, job_registry.zig)
@@ -101,10 +101,9 @@ const posix_groups = builtin.os.tag != .windows and builtin.os.tag != .wasi;
const Jobs = struct {
mutex: Io.Mutex = .init,
list: std.ArrayList(*Job) = .empty,
- next_id: u32 = 1,
/// Caller holds the mutex.
- fn find(self: *Jobs, id: u32) ?*Job {
+ fn find(self: *Jobs, id: u64) ?*Job {
for (self.list.items) |j| if (j.id == id) return j;
return null;
}
@@ -112,14 +111,14 @@ const Jobs = struct {
pub var g_jobs: Jobs = .{};
-pub fn markPersistent(io: Io, id: u32) void {
+pub fn markPersistent(io: Io, id: u64) void {
g_jobs.mutex.lockUncancelable(io);
defer g_jobs.mutex.unlock(io);
if (g_jobs.find(id)) |job| job.persistent = true;
}
/// Deterministic test pause after done becomes observable, before UI publish.
-pub var completion_test_hook: ?*const fn (Io, u32) void = null;
+pub var completion_test_hook: ?*const fn (Io, u64) void = null;
/// Drain MultiReader bytes into the job buffer; drop oldest unread past the cap.
fn jobDrain(job: *Job, gpa: Allocator, readers: []const *Io.Reader, now_ms: i64) void {
@@ -247,7 +246,7 @@ fn recordOf(io: Io, job: *Job) job_registry.Record {
/// /jobs keep|unkeep (#199): exempt from the idle stop, retained at session
/// end. Null for an unknown id, false for one that already finished.
-pub fn setPinned(io: Io, id: u32, pinned: bool) ?bool {
+pub fn setPinned(io: Io, id: u64, pinned: bool) ?bool {
g_jobs.mutex.lockUncancelable(io);
defer g_jobs.mutex.unlock(io);
const job = g_jobs.find(id) orelse return null;
@@ -260,7 +259,7 @@ pub fn setPinned(io: Io, id: u32, pinned: bool) ?bool {
/// /jobs restart (#199): rerun a finished job's command in its cwd, as a new
/// job. The finished record stays listed until reaped.
-pub fn restartJob(gpa: Allocator, io: Io, id: u32) !*Job {
+pub fn restartJob(gpa: Allocator, io: Io, id: u64) !*Job {
var cmd: []const u8 = "";
var cwd: ?[]const u8 = null;
{
@@ -303,6 +302,7 @@ pub fn spawnJob(gpa: Allocator, io: Io, cmd: []const u8) !*Job {
}
pub fn spawnJobOpts(gpa: Allocator, io: Io, cmd: []const u8, opts: SpawnOpts) !*Job {
+ const id = try @import("shell_identity.zig").forJob(io);
const argv = shellArgv(cmd);
var child = try std.process.spawn(io, .{
.argv = &argv,
@@ -336,8 +336,7 @@ pub fn spawnJobOpts(gpa: Allocator, io: Io, cmd: []const u8, opts: SpawnOpts) !*
.last_active_ms = nowMs(io),
};
g_jobs.mutex.lockUncancelable(io);
- job.id = g_jobs.next_id;
- g_jobs.next_id += 1;
+ job.id = id;
const appended = blk: {
g_jobs.list.append(gpa, job) catch break :blk false;
break :blk true;
@@ -373,7 +372,7 @@ pub fn spawnJobOpts(gpa: Allocator, io: Io, cmd: []const u8, opts: SpawnOpts) !*
/// bash_output: unread output + status. wait_ms=0 is a snapshot. wait_ms>0
/// blocks until the job exits (or Esc) for finite jobs (ADR 0010). Persistent
/// servers snapshot immediately; wait_ms is ignored (ADR 0152).
-pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
+pub fn jobOutput(gpa: Allocator, io: Io, id: u64, wait_ms: u64) !ToolOutput {
var waited: u64 = 0;
var interrupted = false; // Esc: report what was waited, not the 10h cap (ADR 0061)
var still = tool_pulse.Pulse{ .interval_ms = 15_000 }; // #807: pulse often enough to tell hang from work
@@ -382,7 +381,7 @@ pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
g_jobs.mutex.lockUncancelable(io);
const job = g_jobs.find(id) orelse {
g_jobs.mutex.unlock(io);
- return .{ .text = try std.fmt.allocPrint(gpa, "no background job {d} — it may never have started; /jobs lists them", .{id}), .is_error = true };
+ return .{ .text = try std.fmt.allocPrint(gpa, "background job {d} has no live owner in this process — interrupted or unknown outcome; do not assume it never ran or rerun it automatically; /jobs lists current jobs", .{id}), .is_error = true };
};
browser_guard.touch(job, nowMs(io)); // a read or a blocking wait is activity (#199)
const deadline = job_wait.resolveDeadlineFor(wait_ms, job.persistent);
@@ -438,11 +437,11 @@ pub fn jobOutput(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !ToolOutput {
/// bash_kill: flag the job and wait (bounded) for the pump to kill + reap it.
/// The pump's future is never awaited here — jobsReap owns it — so two
/// racing kills are harmless.
-pub fn jobKill(gpa: Allocator, io: Io, id: u32) !ToolOutput {
+pub fn jobKill(gpa: Allocator, io: Io, id: u64) !ToolOutput {
{
g_jobs.mutex.lockUncancelable(io);
defer g_jobs.mutex.unlock(io);
- const job = g_jobs.find(id) orelse return .{ .text = try std.fmt.allocPrint(gpa, "no background job {d} — /jobs lists them", .{id}), .is_error = true };
+ const job = g_jobs.find(id) orelse return .{ .text = try std.fmt.allocPrint(gpa, "background job {d} has no live owner in this process — interrupted or unknown outcome; no process was stopped; /jobs lists current jobs", .{id}), .is_error = true };
if (job.done) {
job_notify.dismiss(io, id); // already-finished also reports the exit
const unread = job.buf.items.len - job.cursor;
@@ -471,7 +470,7 @@ pub fn jobKill(gpa: Allocator, io: Io, id: u32) !ToolOutput {
/// Outcome of a root foreground wait (#620 / grok-build auto-background).
pub const FgDone = struct { exit_code: ?u8, killed: bool, output: []u8, dropped: bool };
-pub const FgPartial = struct { id: u32, output: []u8, dropped: bool };
+pub const FgPartial = struct { id: u64, output: []u8, dropped: bool };
pub const FgWait = union(enum) { done: FgDone, running: FgPartial, cancelled: FgPartial };
fn takeUnread(gpa: Allocator, job: *Job) error{OutOfMemory}!struct { []u8, bool } {
@@ -492,7 +491,7 @@ fn freeJob(gpa: Allocator, io: Io, job: *Job) void {
gpa.destroy(job);
}
-pub fn reapFinished(gpa: Allocator, io: Io, id: u32) void {
+pub fn reapFinished(gpa: Allocator, io: Io, id: u64) void {
g_jobs.mutex.lockUncancelable(io);
var found: ?*Job = null;
for (g_jobs.list.items, 0..) |j, i| {
@@ -509,7 +508,7 @@ pub fn reapFinished(gpa: Allocator, io: Io, id: u32) void {
if (found) |job| freeJob(gpa, io, job);
}
-pub fn waitForeground(gpa: Allocator, io: Io, id: u32, wait_ms: u64) !FgWait {
+pub fn waitForeground(gpa: Allocator, io: Io, id: u64, wait_ms: u64) !FgWait {
const deadline = if (wait_ms == 0) job_wait.wait_cap_ms else @min(wait_ms, job_wait.wait_cap_ms);
var waited: u64 = 0;
var still = tool_pulse.Pulse{};
diff --git a/src/jobs_completion_tests.zig b/src/jobs_completion_tests.zig
index f0496e3b..aa10ec55 100644
--- a/src/jobs_completion_tests.zig
+++ b/src/jobs_completion_tests.zig
@@ -7,7 +7,7 @@ const cancel = @import("cancel_source.zig");
const Agent = @import("agent.zig").Agent;
var hook_failed: bool = false;
-fn consumeBeforePublish(io: std.Io, id: u32) void {
+fn consumeBeforePublish(io: std.Io, id: u64) void {
const result = jobs.jobOutput(std.testing.allocator, io, id, 0) catch {
hook_failed = true;
return;
diff --git a/src/jobs_tests.zig b/src/jobs_tests.zig
index c88bb75b..70eb8d80 100644
--- a/src/jobs_tests.zig
+++ b/src/jobs_tests.zig
@@ -264,7 +264,7 @@ test "#199: output keeps a job alive past the budget; a pinned job is never idle
try std.testing.expectEqual(@as(?bool, true), jobs.setPinned(io, pinned, true));
try std.testing.expectEqual(@as(?bool, null), jobs.setPinned(io, 9999, true));
io.sleep(.fromMilliseconds(1_000), .awake) catch {};
- for ([_]u32{ chatty, pinned }) |id| {
+ for ([_]u64{ chatty, pinned }) |id| {
const snap = try jobs.jobOutput(gpa, io, id, 0);
defer gpa.free(snap.text);
try std.testing.expect(std.mem.indexOf(u8, snap.text, "running") != null);
diff --git a/src/main.zig b/src/main.zig
index 096c02a5..88fa96d7 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -586,7 +586,7 @@ test { // ── Unit tests (`zig build test`): pull in tests from imported modu
_ = @import("goal_state.zig");
_ = @import("goal_persist_tests.zig");
_ = @import("agent_render_cleanup.zig");
- _ = @import("goal_flow.zig");
+ _ = .{ @import("goal_flow.zig"), @import("shell_identity.zig") };
_ = @import("goal_todo.zig");
_ = @import("goal_pacing.zig");
_ = .{ @import("presence_accord.zig"), @import("peer_idle.zig"), @import("acp_idle.zig"), @import("presence_chan.zig"), @import("presence_record.zig"), @import("daddy.zig"), @import("peer_inbox_content_test.zig"), @import("peer_inbox_failure_test.zig"), @import("peer_inbox_storage_test.zig"), @import("peer_inbox_sequence_test.zig"), @import("peer_inbox_snapshot_test.zig") };
diff --git a/src/shell_identity.zig b/src/shell_identity.zig
new file mode 100644
index 00000000..cccb5e6d
--- /dev/null
+++ b/src/shell_identity.zig
@@ -0,0 +1,148 @@
+//! Durable shell handles. The numeric wire stays exact in JavaScript; the new
+//! namespace cannot overlap any legacy u32 handle retained in saved history.
+const std = @import("std");
+const builtin = @import("builtin");
+const Io = std.Io;
+pub const Id = u64;
+pub const first: Id = 1 << 32;
+pub const last: Id = (1 << 53) - 1;
+const marker = "shell-ids-v1\n";
+const private_file = @import("credential_store.zig").private_file;
+var test_mutex: Io.Mutex = .init;
+var test_home: ?[]const u8 = null;
+
+/// Existing job tests still exercise this allocator, in a private test-only
+/// directory rather than the user's HOME. Dedicated tests call reserve directly.
+pub fn forJob(io: Io) !Id {
+ if (builtin.is_test) {
+ test_mutex.lockUncancelable(io);
+ defer test_mutex.unlock(io);
+ if (test_home == null) {
+ var tmp = std.testing.tmpDir(.{});
+ var buf: [std.fs.max_path_bytes]u8 = undefined;
+ const n = try tmp.dir.realPath(io, &buf);
+ test_home = try std.heap.page_allocator.dupe(u8, buf[0..n]);
+ tmp.dir.close(io);
+ tmp.parent_dir.close(io);
+ }
+ return reserve(io, test_home.?);
+ }
+ return reserve(io, @import("job_registry.zig").home) catch |err| switch (err) {
+ error.ShellIdentityHomeRequired, error.ShellIdentityStoreInvalid, error.ShellIdentityExhausted => return err,
+ else => return error.ShellIdentityUnavailable,
+ };
+}
+
+fn readCounter(io: Io, dir: Io.Dir, name: []const u8) !Id {
+ var buf: [64]u8 = undefined;
+ const data = dir.readFile(io, name, &buf) catch return error.ShellIdentityStoreInvalid;
+ if (data.len < 2 or data[data.len - 1] != '\n') return error.ShellIdentityStoreInvalid;
+ const n = std.fmt.parseInt(Id, data[0 .. data.len - 1], 10) catch return error.ShellIdentityStoreInvalid;
+ if (n < first - 1 or n > last) return error.ShellIdentityStoreInvalid;
+ return n;
+}
+
+fn writeCounter(io: Io, dir: Io.Dir, name: []const u8, n: Id) !void {
+ var buf: [32]u8 = undefined;
+ const data = try std.fmt.bufPrint(&buf, "{d}\n", .{n});
+ try @import("credential_store.zig").replaceFile(io, dir, name, data, private_file);
+}
+
+pub fn reserve(io: Io, home: []const u8) !Id {
+ for (0..50) |_| {
+ return reserveLocked(io, home) catch |err| {
+ if (err != error.ShellIdentityInitializing) return err;
+ // Release the advisory lock before the creator can initialize it.
+ try io.sleep(.fromMilliseconds(10), .awake);
+ continue;
+ };
+ }
+ return error.ShellIdentityStoreInvalid;
+}
+
+fn reserveLocked(io: Io, home: []const u8) !Id {
+ if (home.len == 0) return error.ShellIdentityHomeRequired;
+ var buf: [std.fs.max_path_bytes]u8 = undefined;
+ const path = try std.fmt.bufPrint(&buf, "{s}/.codegraff", .{home});
+ Io.Dir.cwd().createDir(io, path, @import("credential_store.zig").private_dir) catch |err| {
+ if (err != error.PathAlreadyExists) return err;
+ };
+ var dir = try Io.Dir.cwd().openDir(io, path, .{});
+ defer dir.close(io);
+ var fresh = true;
+ const lock = dir.createFile(io, "shell-id.lock", .{
+ .read = true,
+ .truncate = false,
+ .exclusive = true,
+ .lock = .exclusive,
+ .permissions = private_file,
+ }) catch |err| blk: {
+ if (err != error.PathAlreadyExists) return err;
+ fresh = false;
+ break :blk try dir.openFile(io, "shell-id.lock", .{ .mode = .read_write, .lock = .exclusive });
+ };
+ defer lock.close(io);
+ if (fresh) {
+ if (builtin.os.tag != .windows) {
+ // The first reserver may not be the process that created the
+ // directory. Sync its parent before initializing durable state.
+ const parent = try Io.Dir.cwd().openFile(io, home, .{ .allow_directory = true });
+ defer parent.close(io);
+ try parent.sync(io);
+ }
+ // Existing counters without their initialization marker are not a new
+ // store. Do not reset them after deletion/replacement of the lock file.
+ if (dir.statFile(io, "shell-id.counter", .{})) |_| return error.ShellIdentityStoreInvalid else |e| if (e != error.FileNotFound) return e;
+ try lock.writePositionalAll(io, marker, 0);
+ try lock.sync(io);
+ try writeCounter(io, dir, "shell-id.counter", first - 1);
+ } else {
+ var content: [32]u8 = undefined;
+ const n = try lock.readPositionalAll(io, &content, 0);
+ if (n == 0) return error.ShellIdentityInitializing;
+ if (!std.mem.eql(u8, content[0..n], marker)) return error.ShellIdentityStoreInvalid;
+ }
+ const current = try readCounter(io, dir, "shell-id.counter");
+ if (current == last) return error.ShellIdentityExhausted;
+ const next = current + 1;
+ // Atomic replacement yields the old or new valid counter after a crash.
+ // Spawn happens only after the new counter and directory entry are synced.
+ try writeCounter(io, dir, "shell-id.counter", next);
+ return next;
+}
+
+test "shell identity reservations survive a fresh allocator and remain JS exact" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [std.fs.max_path_bytes]u8 = undefined;
+ const n = try tmp.dir.realPath(std.testing.io, &buf);
+ try std.testing.expectEqual(first, try reserve(std.testing.io, buf[0..n]));
+ try std.testing.expectEqual(first + 1, try reserve(std.testing.io, buf[0..n]));
+ try std.testing.expect(last <= 9007199254740991);
+ try std.testing.expectError(error.ShellIdentityHomeRequired, reserve(std.testing.io, ""));
+}
+
+test "shell identity fails closed on missing corrupt or exhausted storage" {
+ const io = std.testing.io;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var buf: [std.fs.max_path_bytes]u8 = undefined;
+ const n = try tmp.dir.realPath(io, &buf);
+ const home = buf[0..n];
+ _ = try reserve(io, home);
+ var dir = try tmp.dir.openDir(io, ".codegraff", .{});
+ defer dir.close(io);
+ try dir.deleteFile(io, "shell-id.counter");
+ try std.testing.expectError(error.ShellIdentityStoreInvalid, reserve(io, home));
+ // An initializer killed after syncing its marker must never reset IDs.
+ try std.testing.expectError(error.ShellIdentityStoreInvalid, reserve(io, home));
+ try dir.writeFile(io, .{ .sub_path = "shell-id.lock", .data = "" });
+ try std.testing.expectError(error.ShellIdentityStoreInvalid, reserve(io, home));
+ try dir.writeFile(io, .{ .sub_path = "shell-id.lock", .data = marker });
+ try dir.writeFile(io, .{ .sub_path = "shell-id.counter", .data = "bad" });
+ try std.testing.expectError(error.ShellIdentityStoreInvalid, reserve(io, home));
+ try writeCounter(io, dir, "shell-id.counter", last);
+ try std.testing.expectError(error.ShellIdentityExhausted, reserve(io, home));
+ try dir.deleteFile(io, "shell-id.lock");
+ try std.testing.expectError(error.ShellIdentityStoreInvalid, reserve(io, home));
+}
diff --git a/src/shell_identity_probe.zig b/src/shell_identity_probe.zig
new file mode 100644
index 00000000..1c6e793e
--- /dev/null
+++ b/src/shell_identity_probe.zig
@@ -0,0 +1,8 @@
+//! Offline process-boundary probe used by test-shell-identity.py.
+const std = @import("std");
+pub fn main(init: std.process.Init) !void {
+ const id = try @import("shell_identity.zig").reserve(init.io, init.environ_map.get("HOME") orelse "");
+ std.debug.print("{d}\n", .{id});
+ if (init.environ_map.get("GRAFF_TEST_RESERVATION_HOLD") != null)
+ while (true) try init.io.sleep(.fromSeconds(60), .awake);
+}
diff --git a/src/shell_tool.zig b/src/shell_tool.zig
index 95af4a07..8bfc5386 100644
--- a/src/shell_tool.zig
+++ b/src/shell_tool.zig
@@ -107,12 +107,12 @@ pub fn exec(ctx: ToolCtx, call: ToolCall) !ToolOutput {
.output => {
const id = intField(call.input, "id") orelse return missingArg(gpa, "id");
const wait_ms = intField(call.input, "wait_ms") orelse 0;
- if (id < 0 or id > std.math.maxInt(u32)) return .{ .text = try gpa.dupe(u8, "invalid job id"), .is_error = true };
+ if (id < 0 or id > @import("shell_identity.zig").last) return .{ .text = try gpa.dupe(u8, "invalid job id"), .is_error = true };
return jobs.jobOutput(gpa, ctx.io, @intCast(id), @intCast(@max(wait_ms, 0)));
},
.kill => {
const id = intField(call.input, "id") orelse return missingArg(gpa, "id");
- if (id < 0 or id > std.math.maxInt(u32)) return .{ .text = try gpa.dupe(u8, "invalid job id"), .is_error = true };
+ if (id < 0 or id > @import("shell_identity.zig").last) return .{ .text = try gpa.dupe(u8, "invalid job id"), .is_error = true };
return jobs.jobKill(gpa, ctx.io, @intCast(id));
},
}
@@ -203,3 +203,27 @@ test "catalog advertises shell, not the three bash names" {
}
try std.testing.expect(saw_shell);
}
+
+test "shell controls preserve JS exact handles and reject out of range integers" {
+ const gpa = std.testing.allocator;
+ var client: std.http.Client = undefined;
+ const ctx: ToolCtx = .{ .gpa = gpa, .io = std.testing.io, .client = &client, .provider = undefined, .registry = null, .from_sub = false, .approvals = null, .tracer = null };
+ for ([_][]const u8{ "bash_output", "bash_kill" }) |name| {
+ for ([_]i64{ 4294967296, 9007199254740991, -1, 9007199254740992 }) |id| {
+ const input = try std.fmt.allocPrint(gpa, "{{\"id\":{d}}}", .{id});
+ defer gpa.free(input);
+ var c = try parseCall(gpa, name, input);
+ defer c.parsed.deinit();
+ const out = try exec(ctx, c.call);
+ defer gpa.free(out.text);
+ try std.testing.expect(out.is_error);
+ if (id < 0 or id > @import("shell_identity.zig").last) {
+ try std.testing.expectEqualStrings("invalid job id", out.text);
+ } else {
+ const expected = try std.fmt.allocPrint(gpa, "background job {d} has no live owner", .{id});
+ defer gpa.free(expected);
+ try std.testing.expect(std.mem.startsWith(u8, out.text, expected));
+ }
+ }
+ }
+}