Skip to content

Commit 56856c1

Browse files
hooks: Freeze Pi mutation lifecycle evidence
Record reproducible captures and probe plugins for the pinned Pi 0.80.6 runtime so lifecycle, blocking, failure, ordering, signal, session, and mutation behavior can be reviewed before implementation. Update the integration plan to mark T01 complete and preserve the two design corrections discovered during probing. Plan: pi-mutation-scope-integration.md (T01) Co-authored-by: SCE <sce@crocoder.dev>
1 parent 1a854e5 commit 56856c1

22 files changed

Lines changed: 2949 additions & 103 deletions

‎cli/src/services/hooks/pi_mutation_scope/fixtures/NOTES.md‎

Lines changed: 729 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{"mono_us":160131784092,"wall":"2026-09-11T19:28:06.495Z","pid":936631,"tag":"capture","seq":1,"hook":"session_start","payload":{"event":{"type":"session_start","reason":"startup"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
2+
{"mono_us":160131784620,"wall":"2026-09-11T19:28:06.495Z","pid":936631,"tag":"capture","seq":2,"hook":"before_agent_start","payload":{"event":{"type":"before_agent_start","prompt":"Run this exact bash command using the bash tool: nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched","systemPrompt":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- bash: Execute bash commands (ls, grep, find, etc.)\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n- Use bash for file operations like ls, rg, find\n- Be concise in your responses\n- Show file paths clearly when working with files\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\nCurrent date: 2026-09-11\nCurrent working directory: <PROBE_REPO_ROOT>/repo","systemPromptOptions":{"cwd":"<PROBE_REPO_ROOT>/repo","skills":[],"contextFiles":[],"selectedTools":["bash"],"toolSnippets":{"bash":"Execute bash commands (ls, grep, find, etc.)"},"promptGuidelines":[]}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
3+
{"mono_us":160131785114,"wall":"2026-09-11T19:28:06.496Z","pid":936631,"tag":"capture","seq":3,"hook":"agent_start","payload":{"event":{"type":"agent_start"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
4+
{"mono_us":160131785209,"wall":"2026-09-11T19:28:06.496Z","pid":936631,"tag":"capture","seq":4,"hook":"turn_start","payload":{"event":{"type":"turn_start","turnIndex":0,"timestamp":1789154886496},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
5+
{"mono_us":160134444841,"wall":"2026-09-11T19:28:09.155Z","pid":936631,"tag":"capture","seq":5,"hook":"tool_execution_start","payload":{"event":{"type":"tool_execution_start","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","toolName":"bash","args":{"command":"nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
6+
{"mono_us":160134446103,"wall":"2026-09-11T19:28:09.157Z","pid":936631,"tag":"capture","seq":6,"hook":"tool_call","payload":{"event":{"type":"tool_call","toolName":"bash","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","input":{"command":"nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
7+
{"mono_us":160134459329,"wall":"2026-09-11T19:28:09.170Z","pid":936631,"tag":"capture","seq":7,"hook":"tool_result","payload":{"event":{"type":"tool_result","toolName":"bash","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","input":{"command":"nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"},"content":[{"type":"text","text":"launched\n"}],"isError":false},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
8+
{"mono_us":160134459431,"wall":"2026-09-11T19:28:09.170Z","pid":936631,"tag":"capture","seq":8,"hook":"tool_execution_end","payload":{"event":{"type":"tool_execution_end","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","toolName":"bash","result":{"content":[{"type":"text","text":"launched\n"}]},"isError":false},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
9+
{"mono_us":160134459613,"wall":"2026-09-11T19:28:09.170Z","pid":936631,"tag":"capture","seq":9,"hook":"turn_end","payload":{"event":{"type":"turn_end","turnIndex":0,"message":{"role":"assistant","content":[{"type":"toolCall","id":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","name":"bash","arguments":{"command":"nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"}}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":614,"output":43,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":657,"cost":{"input":0.0030700000000000002,"output":0.0012900000000000001,"cacheRead":0,"cacheWrite":0,"total":0.00436}},"stopReason":"toolUse","timestamp":1789154886501,"responseId":"resp_057012c4309108bc016aa45647803c87d2a54b4d10c2c9d87c"},"toolResults":[{"role":"toolResult","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","toolName":"bash","content":[{"type":"text","text":"launched\n"}],"isError":false,"timestamp":1789154889170}]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
10+
{"mono_us":160134459773,"wall":"2026-09-11T19:28:09.170Z","pid":936631,"tag":"capture","seq":10,"hook":"turn_start","payload":{"event":{"type":"turn_start","turnIndex":1,"timestamp":1789154889170},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
11+
{"mono_us":160135550103,"wall":"2026-09-11T19:28:10.261Z","pid":936631,"tag":"capture","seq":11,"hook":"turn_end","payload":{"event":{"type":"turn_end","turnIndex":1,"message":{"role":"assistant","content":[{"type":"text","text":"launched","textSignature":"{\"v\":1,\"id\":\"msg_057012c4309108bc016aa4564a1c9087d2b8c7dce46935ca51\",\"phase\":\"final_answer\"}"}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":671,"output":6,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":677,"cost":{"input":0.0033550000000000003,"output":0.00018,"cacheRead":0,"cacheWrite":0,"total":0.0035350000000000004}},"stopReason":"stop","timestamp":1789154889171,"responseId":"resp_057012c4309108bc016aa456499d7487d2ac6e4882c2040e01"},"toolResults":[]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
12+
{"mono_us":160135550217,"wall":"2026-09-11T19:28:10.261Z","pid":936631,"tag":"capture","seq":12,"hook":"agent_end","payload":{"event":{"type":"agent_end","messages":[{"role":"user","content":[{"type":"text","text":"Run this exact bash command using the bash tool: nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"}],"timestamp":1789154886495},{"role":"assistant","content":[{"type":"toolCall","id":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","name":"bash","arguments":{"command":"nohup sh -c 'sleep 5; echo done > detached.txt' >/dev/null 2>&1 & echo launched"}}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":614,"output":43,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":657,"cost":{"input":0.0030700000000000002,"output":0.0012900000000000001,"cacheRead":0,"cacheWrite":0,"total":0.00436}},"stopReason":"toolUse","timestamp":1789154886501,"responseId":"resp_057012c4309108bc016aa45647803c87d2a54b4d10c2c9d87c"},{"role":"toolResult","toolCallId":"call_McdNMF4niXBldgIbxOXwkgNK|fc_057012c4309108bc016aa456487a1087d28231386983e581db","toolName":"bash","content":[{"type":"text","text":"launched\n"}],"isError":false,"timestamp":1789154889170},{"role":"assistant","content":[{"type":"text","text":"launched","textSignature":"{\"v\":1,\"id\":\"msg_057012c4309108bc016aa4564a1c9087d2b8c7dce46935ca51\",\"phase\":\"final_answer\"}"}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":671,"output":6,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":677,"cost":{"input":0.0033550000000000003,"output":0.00018,"cacheRead":0,"cacheWrite":0,"total":0.0035350000000000004}},"stopReason":"stop","timestamp":1789154889171,"responseId":"resp_057012c4309108bc016aa456499d7487d2ac6e4882c2040e01"}]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
13+
{"mono_us":160135550654,"wall":"2026-09-11T19:28:10.261Z","pid":936631,"tag":"capture","seq":13,"hook":"agent_settled","payload":{"event":{"type":"agent_settled"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
14+
{"mono_us":160135550838,"wall":"2026-09-11T19:28:10.261Z","pid":936631,"tag":"capture","seq":14,"hook":"session_shutdown","payload":{"event":{"type":"session_shutdown","reason":"quit"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{"mono_us":159591503369,"wall":"2026-09-11T19:19:06.214Z","pid":933597,"tag":"capture","seq":1,"hook":"session_start","payload":{"event":{"type":"session_start","reason":"startup"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
2+
{"mono_us":159591503942,"wall":"2026-09-11T19:19:06.214Z","pid":933597,"tag":"capture","seq":2,"hook":"before_agent_start","payload":{"event":{"type":"before_agent_start","prompt":"Run this exact single bash tool call and do not retry regardless of the result: sh -c \"printf partial > nz.txt; exit 7\"","systemPrompt":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- bash: Execute bash commands (ls, grep, find, etc.)\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n\nGuidelines:\n- Use bash for file operations like ls, rg, find\n- Be concise in your responses\n- Show file paths clearly when working with files\n\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /home/davidabram/repos/shared-context-engineering/config/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\nCurrent date: 2026-09-11\nCurrent working directory: <PROBE_REPO_ROOT>/repo","systemPromptOptions":{"cwd":"<PROBE_REPO_ROOT>/repo","skills":[],"contextFiles":[],"selectedTools":["bash"],"toolSnippets":{"bash":"Execute bash commands (ls, grep, find, etc.)"},"promptGuidelines":[]}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
3+
{"mono_us":159591504480,"wall":"2026-09-11T19:19:06.215Z","pid":933597,"tag":"capture","seq":3,"hook":"agent_start","payload":{"event":{"type":"agent_start"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
4+
{"mono_us":159591504574,"wall":"2026-09-11T19:19:06.215Z","pid":933597,"tag":"capture","seq":4,"hook":"turn_start","payload":{"event":{"type":"turn_start","turnIndex":0,"timestamp":1789154346215},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
5+
{"mono_us":159593788650,"wall":"2026-09-11T19:19:08.499Z","pid":933597,"tag":"capture","seq":5,"hook":"tool_execution_start","payload":{"event":{"type":"tool_execution_start","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","toolName":"bash","args":{"command":"sh -c \"printf partial > nz.txt; exit 7\""}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
6+
{"mono_us":159593789891,"wall":"2026-09-11T19:19:08.500Z","pid":933597,"tag":"capture","seq":6,"hook":"tool_call","payload":{"event":{"type":"tool_call","toolName":"bash","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","input":{"command":"sh -c \"printf partial > nz.txt; exit 7\""}},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
7+
{"mono_us":159593804161,"wall":"2026-09-11T19:19:08.515Z","pid":933597,"tag":"capture","seq":7,"hook":"tool_result","payload":{"event":{"type":"tool_result","toolName":"bash","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","input":{"command":"sh -c \"printf partial > nz.txt; exit 7\""},"content":[{"type":"text","text":"(no output)\n\nCommand exited with code 7"}],"details":{},"isError":true},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
8+
{"mono_us":159593804792,"wall":"2026-09-11T19:19:08.515Z","pid":933597,"tag":"capture","seq":8,"hook":"tool_execution_end","payload":{"event":{"type":"tool_execution_end","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","toolName":"bash","result":{"content":[{"type":"text","text":"(no output)\n\nCommand exited with code 7"}],"details":{}},"isError":true},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
9+
{"mono_us":159593805227,"wall":"2026-09-11T19:19:08.516Z","pid":933597,"tag":"capture","seq":9,"hook":"turn_end","payload":{"event":{"type":"turn_end","turnIndex":0,"message":{"role":"assistant","content":[{"type":"toolCall","id":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","name":"bash","arguments":{"command":"sh -c \"printf partial > nz.txt; exit 7\""}}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":608,"output":31,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":639,"cost":{"input":0.00304,"output":0.00093,"cacheRead":0,"cacheWrite":0,"total":0.0039700000000000004}},"stopReason":"toolUse","timestamp":1789154346220,"responseId":"resp_0db7f88e4bdd7142016aa4542b2d6087d295589e990d689a5a"},"toolResults":[{"role":"toolResult","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","toolName":"bash","content":[{"type":"text","text":"(no output)\n\nCommand exited with code 7"}],"details":{},"isError":true,"timestamp":1789154348516}]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
10+
{"mono_us":159593805398,"wall":"2026-09-11T19:19:08.516Z","pid":933597,"tag":"capture","seq":10,"hook":"turn_start","payload":{"event":{"type":"turn_start","turnIndex":1,"timestamp":1789154348516},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
11+
{"mono_us":159596108091,"wall":"2026-09-11T19:19:10.819Z","pid":933597,"tag":"capture","seq":11,"hook":"turn_end","payload":{"event":{"type":"turn_end","turnIndex":1,"message":{"role":"assistant","content":[{"type":"text","text":"Command ran once and exited with code 7.","textSignature":"{\"v\":1,\"id\":\"msg_0db7f88e4bdd7142016aa4542e04f887d2ac06bfb073dfbbed\",\"phase\":\"final_answer\"}"}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":659,"output":14,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":673,"cost":{"input":0.003295,"output":0.00042,"cacheRead":0,"cacheWrite":0,"total":0.0037150000000000004}},"stopReason":"stop","timestamp":1789154348516,"responseId":"resp_0db7f88e4bdd7142016aa4542cfcf087d2aa80b3740f5b5c92"},"toolResults":[]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
12+
{"mono_us":159596108214,"wall":"2026-09-11T19:19:10.819Z","pid":933597,"tag":"capture","seq":12,"hook":"agent_end","payload":{"event":{"type":"agent_end","messages":[{"role":"user","content":[{"type":"text","text":"Run this exact single bash tool call and do not retry regardless of the result: sh -c \"printf partial > nz.txt; exit 7\""}],"timestamp":1789154346214},{"role":"assistant","content":[{"type":"toolCall","id":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","name":"bash","arguments":{"command":"sh -c \"printf partial > nz.txt; exit 7\""}}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":608,"output":31,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":639,"cost":{"input":0.00304,"output":0.00093,"cacheRead":0,"cacheWrite":0,"total":0.0039700000000000004}},"stopReason":"toolUse","timestamp":1789154346220,"responseId":"resp_0db7f88e4bdd7142016aa4542b2d6087d295589e990d689a5a"},{"role":"toolResult","toolCallId":"call_6acha0TQzc2EoN8qeXkzqdWV|fc_0db7f88e4bdd7142016aa4542c11ec87d28ab05cc33f3fbf18","toolName":"bash","content":[{"type":"text","text":"(no output)\n\nCommand exited with code 7"}],"details":{},"isError":true,"timestamp":1789154348516},{"role":"assistant","content":[{"type":"text","text":"Command ran once and exited with code 7.","textSignature":"{\"v\":1,\"id\":\"msg_0db7f88e4bdd7142016aa4542e04f887d2ac06bfb073dfbbed\",\"phase\":\"final_answer\"}"}],"api":"openai-codex-responses","provider":"openai-codex","model":"gpt-5.5","usage":{"input":659,"output":14,"cacheRead":0,"cacheWrite":0,"reasoning":0,"totalTokens":673,"cost":{"input":0.003295,"output":0.00042,"cacheRead":0,"cacheWrite":0,"total":0.0037150000000000004}},"stopReason":"stop","timestamp":1789154348516,"responseId":"resp_0db7f88e4bdd7142016aa4542cfcf087d2aa80b3740f5b5c92"}]},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
13+
{"mono_us":159596108700,"wall":"2026-09-11T19:19:10.819Z","pid":933597,"tag":"capture","seq":13,"hook":"agent_settled","payload":{"event":{"type":"agent_settled"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}
14+
{"mono_us":159596108888,"wall":"2026-09-11T19:19:10.819Z","pid":933597,"tag":"capture","seq":14,"hook":"session_shutdown","payload":{"event":{"type":"session_shutdown","reason":"quit"},"model":{"provider":"openai-codex","id":"gpt-5.5"}}}

0 commit comments

Comments
 (0)