Skip to content

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

Claude Code's and Codex's hooks: declared contracts that core applies with the kit (#1045)

Dee734b5e497e98
diff --git a/cli/scripts/resume-native-e2e.ts b/cli/scripts/resume-native-e2e.ts
index 26c5fa869..848dd0027 100644
--- a/cli/scripts/resume-native-e2e.ts
+++ b/cli/scripts/resume-native-e2e.ts
@@ -56,7 +56,7 @@ const { checkPidRuntime } = await import('../src/lib/deleteAgentFallback.js')
const { startHookServer } = await import('../src/hookServer.js')
const { BackendSocket } = await import('../src/backendSocket.js')
const { bindNativeResumeRequests } = await import('../src/testing/nativeResumeSocket.js')
-const { installCodexHooks } = await import('../src/lib/hooks.js')
+const { engineHooks } = await import('../src/engines/hooks.js')
const backend = new TmuxBackend()
const socketBackend = new BackendSocket('fixture-only')
const hooks: Array<{ engine: string; sessionId: string }> = []
@@ -121,7 +121,7 @@ try {
{ timestamp, type: 'event_msg', payload: { type: 'task_complete', turn_id: sessionId, last_agent_message: `Retained ${marker}` } },
].map(row => JSON.stringify(row)).join('\n') + '\n')
writeFileSync(join(profile, 'config.toml'), `model_provider = "fixture"\ncheck_for_update_on_startup = false\n[model_providers.fixture]\nname = "Local fixture"\nbase_url = "http://127.0.0.1:9/v1"\nwire_api = "responses"\nrequires_openai_auth = false\n[projects.${JSON.stringify(cwd)}]\ntrust_level = "trusted"\n[features]\nhooks = true\n`)
- installCodexHooks(server.port, profile)
+ engineHooks.codex.installIn(server.port, profile)
}
const old = registry.openPendingAgent({ engine, runtimes: [{ backend: 'tmux', paneId: '%99999' }], cwd, codexHome: engine === 'codex' ? profile : null, defaultName: `Native ${engine} fixture` })!
diff --git a/cli/src/architecture.spec.ts b/cli/src/architecture.spec.ts
index 086bc8697..bcae46d79 100644
--- a/cli/src/architecture.spec.ts
+++ b/cli/src/architecture.spec.ts
@@ -144,6 +144,9 @@ const SERVICE_MAY_IMPORT: Record<string, string> = {
/** What is not the core's, by path: each goes to a service or its own process, in the plan's order. */
const EDGE: RegExp[] = [
/^engines\/(claude|codex)\/(screen|composer|activity|stoppedGoal|modelControl|modelPicker|questionControl|submission|nativeControl)\.ts$/,
+ // Claude Code's and Codex's hooks are declared data (hookContract.ts) that the kit applies in core: no hook code
+ // of theirs is the core's, and none runs in a worker either (docs/design/2026-10-08-engine-hooks.md).
+ /^engines\/(claude|codex)\/(hooks|installHooks)\.ts$/,
/^lib\/(askQuestion|runtimeProfileController|composerScreen|teamWriteHold|messageHold|terminalActivity|codexTurnRecovery)\.ts$/,
/^engines\/(screens|modelControls|questionControls|submissions|nativeControls)\.ts$/,
// Claude Code's and Codex's reading of their composer: shared by the two, loaded only by their workers.
@@ -231,6 +234,15 @@ describe('the daemon\'s shape', () => {
}
})
+ it('hook installation, admission, transcript correction and turn closing load the engines\' declared hook contracts alone', () => {
+ const contracts = new Set(['engines/claude/hookContract.ts', 'engines/codex/hookContract.ts'])
+ for (const entry of ['engines/hooks.ts', 'engines/kit/hookSettings.ts', 'engines/kit/hookRules.ts', 'engines/kit/stopHook.ts',
+ 'core/turns/turnHooks.ts']) {
+ expect([...closureOf(entry).keys()].filter(file => /^engines\/(claude|codex)\//.test(file) && !contracts.has(file)), entry).toEqual([])
+ }
+ expect([...closureOf('engines/hooks.ts').keys()].filter(file => contracts.has(file)).sort()).toEqual([...contracts].sort())
+ })
+
it('the gateway reaches the core only through core/api.ts: never a core module, the registry, cli.ts or the socket', () => {
// It speaks to the core through GatewayPort and GatewayEvents alone, so that it can run in a process of
// its own (step 10, R2) without taking any of the core with it.
diff --git a/cli/src/core/AGENTS.md b/cli/src/core/AGENTS.md
index 9261542f1..1c3dabb14 100644
--- a/cli/src/core/AGENTS.md
+++ b/cli/src/core/AGENTS.md
@@ -37,7 +37,7 @@ questions. Everything else is a service ([../services/AGENTS.md](../services/AGE
validates bounded replies, retains acknowledged cursors and owns binding/turn state. The explicit
inline/older-master compatibility path is the only live parser or runtime profile implementation
composition in core. Screen reads are bounded and fenced to the worker connection and session binding
- ([screen boundary](../../../docs/design/2026-10-08-engine-screen.md)). Core keeps accepted profiles and control authority; native model drivers run in workers through [revocable control grants](../../../docs/design/2026-10-08-engine-model-control.md), and so does question navigation ([question control](../../../docs/design/2026-10-08-engine-question-control.md)). Whether a typed prompt was taken is read there too: core keeps the writer, every Enter and the verdict ([submission](../../../docs/design/2026-10-08-engine-submission.md)). Codex's shared app-server is spoken to from its worker under a stop grant; core keeps the process table, identity and the stop's decisions ([native control](../../../docs/design/2026-10-08-engine-native-control.md)). See [runtime profiles](../../../docs/design/2026-10-08-engine-runtime.md).
+ ([screen boundary](../../../docs/design/2026-10-08-engine-screen.md)). Core keeps accepted profiles and control authority; native model drivers run in workers through [revocable control grants](../../../docs/design/2026-10-08-engine-model-control.md), and so does question navigation ([question control](../../../docs/design/2026-10-08-engine-question-control.md)). Whether a typed prompt was taken is read there too: core keeps the writer, every Enter and the verdict ([submission](../../../docs/design/2026-10-08-engine-submission.md)). Codex's shared app-server is spoken to from its worker under a stop grant; core keeps the process table, identity and the stop's decisions ([native control](../../../docs/design/2026-10-08-engine-native-control.md)). Their hooks never go to a worker: each engine declares them as data, and core applies the declaration in line with `engines/kit` mechanics (installing settings, refusing a delegated session, correcting a transcript, closing a turn on Stop; [hooks](../../../docs/design/2026-10-08-engine-hooks.md)). See [runtime profiles](../../../docs/design/2026-10-08-engine-runtime.md).
- `input.ts`, `questions.ts`: messages into a pane; an agent's question and its answer. Core matches an answer to the
question on screen and holds the lease; Claude Code's and Codex's keys for each approved step come from their engine
worker through a revocable grant (`engines/questionControls.ts`).
diff --git a/cli/src/engines/README.md b/cli/src/engines/README.md
index f934638a4..644647a83 100644
--- a/cli/src/engines/README.md
+++ b/cli/src/engines/README.md
@@ -17,9 +17,12 @@ that stream.
**The engine interface is being migrated in small batches.** Claude Code and Codex now own their
launch contracts, history/last-turn readers and hook behavior behind `Engine` (`engine.ts`). `registry.ts`
selects those engines; `launches.ts` and `hooks.ts` expose their respective facets without loading history
-readers. Hook transport, process binding and event delivery stay with core. Claude Code and Codex history/last-turn reads,
+readers. Hook transport, process binding and event delivery stay with core. Their hooks are declared data
+(`claude/hookContract.ts`, `codex/hookContract.ts`) that core applies in line with `kit/` mechanics, never in a
+worker ([hooks](../../../docs/design/2026-10-08-engine-hooks.md)). Claude Code and Codex history/last-turn reads,
live transcript parsing, runtime profiles/catalogs, screen interpretation, submission readings, model-control drivers, question navigation and Codex's app-server connection run on demand in supervised workers;
the other facets still run in core. Explicit inline mode and older masters retain inline implementations. See
+[hooks](../../../docs/design/2026-10-08-engine-hooks.md),
[question control](../../../docs/design/2026-10-08-engine-question-control.md),
[submission](../../../docs/design/2026-10-08-engine-submission.md),
[native control](../../../docs/design/2026-10-08-engine-native-control.md),
diff --git a/cli/src/engines/__fixtures__/hook-installers.golden.json b/cli/src/engines/__fixtures__/hook-installers.golden.json
new file mode 100644
index 000000000..e09cecf96
--- /dev/null
+++ b/cli/src/engines/__fixtures__/hook-installers.golden.json
@@ -0,0 +1,2771 @@
+{
+ "claude installIn: no file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: no home folder": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: empty file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: whitespace only": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: malformed JSON": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: byte order mark": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: JSON null": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "null"
+ }
+ }
+ },
+ "claude installIn: JSON array": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "[]\n"
+ }
+ }
+ },
+ "claude installIn: JSON string": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "\"text\""
+ }
+ }
+ },
+ "claude installIn: JSON number": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "42"
+ }
+ }
+ },
+ "claude installIn: hooks is a string": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n },\n \"keep\": 1\n}\n"
+ }
+ }
+ },
+ "claude installIn: hooks is an array": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": []\n}\n"
+ }
+ }
+ },
+ "claude installIn: hooks is null": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: an event is not a list": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: odd blocks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n null,\n \"text\",\n {\n \"hooks\": \"no\"\n },\n {\n \"hooks\": [\n null,\n {}\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a command that is not text": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{\"SessionStart\":[{\"hooks\":[{\"type\":\"command\",\"command\":5}]}]}}"
+ }
+ }
+ },
+ "claude installIn: duplicate keys": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{},\"hooks\":{\"SessionStart\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"SessionEnd\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"UserPromptSubmit\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"Stop\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"StopFailure\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}]}}"
+ }
+ }
+ },
+ "claude installIn: foreign hooks only": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: our old hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: our old hook beside foreign hooks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours current on some events, old or missing on others": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours current, minified": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{\"SessionStart\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"SessionEnd\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"UserPromptSubmit\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"Stop\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}],\"StopFailure\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command claude 19473>\",\"timeout\":5}]}]}}"
+ }
+ }
+ },
+ "claude installIn: ours current before foreign hooks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours current with another timeout": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 30\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 30\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 30\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 30\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 30\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours twice on an event": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours twice, the first old": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: our block led by a foreign hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-first\"\n },\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-first\"\n },\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-first\"\n },\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-first\"\n },\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-first\"\n },\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: our block with another matcher": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ],\n \"matcher\": \"other\"\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ],\n \"matcher\": \"other\"\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ],\n \"matcher\": \"other\"\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ],\n \"matcher\": \"other\"\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ],\n \"matcher\": \"other\"\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: our block missing its matcher": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: ours current for another port": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a symlink to foreign settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/real.json"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a symlink to current settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/real.json"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a dangling symlink": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/missing.json"
+ },
+ "elsewhere/missing.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a symlink into a missing folder": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error ENOENT open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error ENOENT open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/gone/missing.json"
+ }
+ }
+ },
+ "claude installIn: a read-only file": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EACCES open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EACCES open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "444",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a read-only file, current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "444",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: an unreadable file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "200",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a read-only folder": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EACCES open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EACCES open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "555"
+ }
+ }
+ },
+ "claude installIn: a read-only folder holding a writable file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "555"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: a private file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "600",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude installIn: the file is a folder": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EISDIR open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write settings.json: Error EISDIR open <root>/moved/claude-work/settings.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "dir",
+ "mode": "755"
+ }
+ }
+ },
+ "claude installIn: a temporary file left by this process": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/moved/claude-work/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/claude-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/claude-work/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ },
+ "moved/claude-work/settings.json.<pid>.tmp": {
+ "type": "file",
+ "mode": "600",
+ "text": "junk"
+ }
+ }
+ },
+ "claude install: no file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: no home folder": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: malformed JSON": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: foreign hooks only": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: our old hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] updated (path/port changed) → <script> --port 19473 in <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: ours current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "claude install: a symlink to foreign settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Claude session + turn (Stop/StopFailure) hooks → <root>/home/.claude/settings.json",
+ "log [hooks] (takes effect on the next claude session start)"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Claude session + turn (Stop/StopFailure) hooks already installed"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.claude": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.claude/settings.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/real.json"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ],\n \"SessionEnd\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"Stop\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"StopFailure\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command claude 19473>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: no file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: no home folder": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: empty file": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": ""
+ }
+ }
+ },
+ "codex installIn: whitespace only": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": " \n"
+ }
+ }
+ },
+ "codex installIn: malformed JSON": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{not-json"
+ }
+ }
+ },
+ "codex installIn: byte order mark": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{}"
+ }
+ }
+ },
+ "codex installIn: JSON null": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "null"
+ }
+ }
+ },
+ "codex installIn: JSON array": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "[]\n"
+ }
+ }
+ },
+ "codex installIn: JSON string": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "\"text\""
+ }
+ }
+ },
+ "codex installIn: JSON number": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "42"
+ }
+ }
+ },
+ "codex installIn: hooks is a string": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n },\n \"keep\": 1\n}\n"
+ }
+ }
+ },
+ "codex installIn: hooks is an array": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": []\n}\n"
+ }
+ }
+ },
+ "codex installIn: hooks is null": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: an event is not a list": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: odd blocks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n null,\n \"text\",\n {\n \"hooks\": \"no\"\n },\n {\n \"hooks\": [\n null,\n {}\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a command that is not text": {
+ "runs": [
+ {
+ "logs": [],
+ "threw": "TypeError"
+ },
+ {
+ "logs": [],
+ "threw": "TypeError"
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{\"SessionStart\":[{\"hooks\":[{\"type\":\"command\",\"command\":5}]}]}}"
+ }
+ }
+ },
+ "codex installIn: duplicate keys": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{},\"hooks\":{\"SessionStart\":[{\"matcher\":\"startup|resume|clear|compact\",\"hooks\":[{\"type\":\"command\",\"command\":\"<command codex 19473 installIn>\",\"timeout\":5}]}],\"UserPromptSubmit\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command codex 19473 installIn>\",\"timeout\":5}]}]}}"
+ }
+ }
+ },
+ "codex installIn: foreign hooks only": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: our old hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: our old hook beside foreign hooks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours current on some events, old or missing on others": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours current, minified": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\"hooks\":{\"SessionStart\":[{\"matcher\":\"startup|resume|clear|compact\",\"hooks\":[{\"type\":\"command\",\"command\":\"<command codex 19473 installIn>\",\"timeout\":5}]}],\"UserPromptSubmit\":[{\"hooks\":[{\"type\":\"command\",\"command\":\"<command codex 19473 installIn>\",\"timeout\":5}]}]}}"
+ }
+ }
+ },
+ "codex installIn: ours current before foreign hooks": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-after\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours current with another timeout": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 30\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 30\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours twice on an event": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours twice, the first old": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: our block led by a foreign hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: our block with another matcher": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: our block missing its matcher": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: ours current for another port": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a symlink to foreign settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a symlink to current settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "link",
+ "target": "<root>/elsewhere/real.json"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a dangling symlink": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a symlink into a missing folder": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a read-only file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a read-only file, current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "444",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: an unreadable file": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "200",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a read-only folder": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write Codex hooks.json: Error EACCES open <root>/moved/codex-work/hooks.json.<pid>.tmp"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write Codex hooks.json: Error EACCES open <root>/moved/codex-work/hooks.json.<pid>.tmp"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "555"
+ }
+ }
+ },
+ "codex installIn: a read-only folder holding a writable file": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] failed to write Codex hooks.json: Error EACCES open <root>/moved/codex-work/hooks.json.<pid>.tmp"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] failed to write Codex hooks.json: Error EACCES open <root>/moved/codex-work/hooks.json.<pid>.tmp"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "555"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: a private file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex installIn: the file is a folder": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/moved/codex-work/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "dir",
+ "mode": "755"
+ }
+ }
+ },
+ "codex installIn: a temporary file left by this process": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/moved/codex-work/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/moved/codex-work/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "moved/codex-work": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "moved/codex-work/hooks.json": {
+ "type": "file",
+ "mode": "600",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 installIn>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: no file": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: no home folder": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: malformed JSON": {
+ "runs": [
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/home/.codex/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "error [hooks] Codex hooks file is invalid JSON; leaving it unchanged: <root>/home/.codex/hooks.json",
+ "error [hooks] fix the file, then restart harness login"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{not-json"
+ }
+ }
+ },
+ "codex install: foreign hooks only": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: our old hook": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: ours current": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ },
+ "codex install: a symlink to foreign settings": {
+ "runs": [
+ {
+ "logs": [
+ "log [hooks] installed Codex SessionStart/UserPromptSubmit hooks → <root>/home/.codex/hooks.json",
+ "log [hooks] Codex requires reviewing these user hooks with /hooks before normal use"
+ ],
+ "threw": null
+ },
+ {
+ "logs": [
+ "log [hooks] Codex SessionStart/UserPromptSubmit hooks already installed → <root>/home/.codex/hooks.json"
+ ],
+ "threw": null
+ }
+ ],
+ "files": {
+ "home/.codex": {
+ "type": "dir",
+ "mode": "755"
+ },
+ "home/.codex/hooks.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n },\n {\n \"matcher\": \"startup|resume|clear|compact\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n },\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"<command codex 19473 install>\",\n \"timeout\": 5\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ },
+ "elsewhere/real.json": {
+ "type": "file",
+ "mode": "644",
+ "text": "{\n \"model\": \"opus\",\n \"nested\": {\n \"list\": [\n 1,\n 2.5,\n \"x\"\n ],\n \"none\": null\n },\n \"note\": \"café ✓ 🎉\",\n \"hooks\": {\n \"SessionStart\": [\n {\n \"matcher\": \"resume\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-start\",\n \"timeout\": 9\n }\n ]\n }\n ],\n \"UserPromptSubmit\": [\n {\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-prompt\"\n }\n ]\n }\n ],\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"foreign-tool\"\n }\n ]\n }\n ]\n }\n}\n"
+ }
+ }
+ }
+}
diff --git a/cli/src/engines/claude/hookContract.ts b/cli/src/engines/claude/hookContract.ts
new file mode 100644
index 000000000..99dc9d0a1
--- /dev/null
+++ b/cli/src/engines/claude/hookContract.ts
@@ -0,0 +1,35 @@
+import type { HookContract } from '../facets/hooks.js'
+
+/**
+ * Claude Code's hooks, declared: data only, which core applies with the kit's installer and rules
+ * (engines/hooks.ts). Copied from the former installHooks.ts and hooks.ts of this folder.
+ */
+export const hooks: HookContract = {
+ settings: {
+ // The person's own. A home the person moved (CLAUDE_CONFIG_DIR, lib/engineHomes.ts) gets the same block
+ // in its own settings.json (core/engines/hooks.ts).
+ home: { inHome: '.claude' },
+ file: 'settings.json',
+ // SessionStart/UserPromptSubmit bind mutable engine-session metadata to the process agent. SessionEnd
+ // only asks discovery to reconcile: the process, not the hook, owns the tile lifetime. UserPromptSubmit
+ // is the CATCH hook, so a SessionStart missed because the adapter started late is repaired on first input.
+ // Stop/StopFailure are the authoritative turn-close signals (Stop = normal finish incl. max_tokens/
+ // refusal; StopFailure = turn ended on an API error, where Stop does NOT fire) — they close a turn even
+ // when the JSONL-derived turn_ended is missed. Neither supports a matcher (silently ignored).
+ events: [{ event: 'SessionStart' }, { event: 'SessionEnd' }, { event: 'UserPromptSubmit' }, { event: 'Stop' }, { event: 'StopFailure' }],
+ timeout: 5,
+ commandNamesHome: false,
+ unreadable: 'replace',
+ write: 'in-place',
+ upToDate: { command: 'first-ours', matcher: false },
+ messages: {
+ current: '[hooks] Claude session + turn (Stop/StopFailure) hooks already installed',
+ installed: '[hooks] installed Claude session + turn (Stop/StopFailure) hooks → {file}',
+ updated: '[hooks] updated (path/port changed) → {script} --port {port} in {file}',
+ after: '[hooks] (takes effect on the next claude session start)',
+ failed: '[hooks] failed to write settings.json:',
+ },
+ },
+ sessionFile: { suffix: '.jsonl' },
+ stopClosesTurns: true,
+}
diff --git a/cli/src/engines/claude/installHooks.ts b/cli/src/engines/claude/installHooks.ts
deleted file mode 100644
index 89ef51310..000000000
--- a/cli/src/engines/claude/installHooks.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
-import { dirname, join } from 'node:path'
-import { homedir } from 'node:os'
-import { command, HOOK_SCRIPT, isOurs, type Settings } from '../kit/notifyHooks.js'
-
-const SETTINGS_PATH = join(homedir(), '.claude', 'settings.json')
-
-// SessionStart/UserPromptSubmit bind mutable engine-session metadata to the process agent. SessionEnd
-// only asks discovery to reconcile: the process, not the hook, owns the tile lifetime. UserPromptSubmit
-// is the CATCH hook, so a SessionStart missed because the adapter started late is repaired on first input.
-// Stop/StopFailure are the authoritative turn-close signals (Stop = normal finish incl. max_tokens/
-// refusal; StopFailure = turn ended on an API error, where Stop does NOT fire) — they close a turn even
-// when the JSONL-derived turn_ended is missed. Neither supports a matcher (silently ignored).
-const EVENTS = ['SessionStart', 'SessionEnd', 'UserPromptSubmit', 'Stop', 'StopFailure'] as const
-
-/** `settingsPath`: another Claude Code home's settings, for a home the person moved (lib/engineHomes.ts). */
-export function installSessionHooks(port: number, settingsPath: string = SETTINGS_PATH): void {
- let settings: Settings = {}
- try {
- settings = JSON.parse(readFileSync(settingsPath, 'utf-8')) as Settings
- } catch {
- // missing / unreadable → start from empty settings
- }
-
- if (!settings.hooks || typeof settings.hooks !== 'object') settings.hooks = {}
- const cmd = command(port, 'claude')
- let changed = false
- let updated = false // true when an EXISTING block's command changed (path/port drift)
-
- for (const event of EVENTS) {
- const blocks = Array.isArray(settings.hooks[event]) ? settings.hooks[event] : []
- // Collapse any duplicate "ours" blocks (e.g. from an earlier path) down to a single one, and
- // keep every non-ours block untouched.
- const foreign = blocks.filter((b) => !isOurs(b))
- const oursBlocks = blocks.filter(isOurs)
- if (oursBlocks.length > 1) changed = true // dropping duplicates is a change
-
- // The one canonical block for this event with the CURRENT command (path + port). If a prior
- // block existed with a different command (moved checkout / dev↔dist / changed port), this
- // overwrites it in place.
- const existingCmd = oursBlocks[0]?.hooks?.find((h) => isOurs({ hooks: [h] }))?.command
- if (oursBlocks.length === 0) changed = true
- else if (existingCmd !== cmd) { changed = true; updated = true }
-
- settings.hooks[event] = [...foreign, { hooks: [{ type: 'command', command: cmd, timeout: 5 }] }]
- }
-
- if (!changed) {
- console.log('[hooks] Claude session + turn (Stop/StopFailure) hooks already installed')
- return
- }
-
- try {
- mkdirSync(dirname(settingsPath), { recursive: true })
- writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n')
- // Both name the file written: a daemon can write several (every moved home gets its own), and the
- // end-to-end harness checks each one it names is inside its throwaway root.
- console.log(
- updated
- ? `[hooks] updated (path/port changed) → ${HOOK_SCRIPT} --port ${port} in ${settingsPath}`
- : `[hooks] installed Claude session + turn (Stop/StopFailure) hooks → ${settingsPath}`,
- )
- console.log('[hooks] (takes effect on the next claude session start)')
- } catch (err) {
- console.error('[hooks] failed to write settings.json:', err)
- }
-}
diff --git a/cli/src/engines/codex/hookContract.ts b/cli/src/engines/codex/hookContract.ts
new file mode 100644
index 000000000..c542b6fbf
--- /dev/null
+++ b/cli/src/engines/codex/hookContract.ts
@@ -0,0 +1,35 @@
+import type { HookContract } from '../facets/hooks.js'
+
+/**
+ * Codex's hooks, declared: data only, which core applies with the kit's installer and rules
+ * (engines/hooks.ts). Copied from the former installHooks.ts and hooks.ts of this folder.
+ */
+export const hooks: HookContract = {
+ settings: {
+ // This machine's own default profile. A Codex agent launched against a different CODEX_HOME profile (see
+ // `Agent.codexHome`/`agent_create`) reads hooks.json from THAT folder, not this one, so `onCreateAgent`
+ // installs again into the chosen profile before spawning such an agent. Idempotent either way.
+ home: { setting: 'CODEX_HOME' },
+ file: 'hooks.json',
+ events: [{ event: 'SessionStart', matcher: 'startup|resume|clear|compact' }, { event: 'UserPromptSubmit' }],
+ timeout: 5,
+ commandNamesHome: true,
+ // A malformed existing file is left untouched: silently replacing it could disable user
+ // security/automation hooks.
+ unreadable: 'keep',
+ write: 'atomic',
+ upToDate: { command: 'first', matcher: true },
+ messages: {
+ current: '[hooks] Codex SessionStart/UserPromptSubmit hooks already installed → {file}',
+ installed: '[hooks] installed Codex SessionStart/UserPromptSubmit hooks → {file}',
+ after: '[hooks] Codex requires reviewing these user hooks with /hooks before normal use',
+ failed: '[hooks] failed to write Codex hooks.json:',
+ malformed: ['[hooks] Codex hooks file is invalid JSON; leaving it unchanged: {file}', '[hooks] fix the file, then restart harness login'],
+ },
+ },
+ // A delegated session (a Codex sub-agent) runs its hooks from its parent's pane, and its rollout's first
+ // record names it a child (`source.subagent`). Registered, it would take the parent's pane and transcript,
+ // and its prompt would be credited to the parent: refused before either (hookServer.ts, registry.register).
+ children: { type: 'session_meta', child: ['payload', 'source', 'subagent'], reason: 'codex_subagent' },
+ // Codex closes turns through its transcript, never a Stop hook.
+}
diff --git a/cli/src/engines/codex/hooks.ts b/cli/src/engines/codex/hooks.ts
deleted file mode 100644
index fde7c76b2..000000000
--- a/cli/src/engines/codex/hooks.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { EngineHooks } from '../facets/hooks.js'
-import { readCodexRolloutMeta } from './rollout.js'
-import { installCodexHooks } from './installHooks.js'
-
-export const hooks: EngineHooks = {
- install: installCodexHooks,
- installIn: installCodexHooks,
- admit: (body) => body.transcriptPath && readCodexRolloutMeta(body.transcriptPath)?.isSubagent
- ? { accepted: false, reason: 'codex_subagent' }
- : { accepted: true },
- // Codex closes turns through its transcript, never a Stop hook.
-}
diff --git a/cli/src/engines/codex/installHooks.ts b/cli/src/engines/codex/installHooks.ts
deleted file mode 100644
index 88d7f6f13..000000000
--- a/cli/src/engines/codex/installHooks.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { existsSync, readFileSync } from 'node:fs'
-import { join } from 'node:path'
-import { env } from '../../config/env.js'
-import { command, isOurs, writeJsonAtomic, type HookBlock, type Settings } from '../kit/notifyHooks.js'
-
-/**
- * Merge Machine's user-level Codex hooks without replacing unrelated hooks. A malformed existing
- * file is left untouched: silently replacing it could disable user security/automation hooks.
- *
- * `codexHome` defaults to this machine's own default profile, but a Codex agent launched against a
- * different CODEX_HOME profile (see `Agent.codexHome`/`agent_create`) reads hooks.json from THAT
- * folder, not this one — so `onCreateAgent` calls this again with the chosen profile before
- * spawning such an agent. Idempotent either way.
- */
-export function installCodexHooks(port: number, codexHome: string = env.CODEX_HOME): void {
- const hooksPath = join(codexHome, 'hooks.json')
- let settings: Settings = {}
- if (existsSync(hooksPath)) {
- try {
- settings = JSON.parse(readFileSync(hooksPath, 'utf-8')) as Settings
- } catch (err) {
- console.error(`[hooks] Codex hooks file is invalid JSON; leaving it unchanged: ${hooksPath}`)
- console.error('[hooks] fix the file, then restart harness login')
- return
- }
- }
- if (!settings.hooks || typeof settings.hooks !== 'object') settings.hooks = {}
-
- const cmd = command(port, 'codex', codexHome)
- const required: Array<{ event: 'SessionStart' | 'UserPromptSubmit'; matcher?: string }> = [
- { event: 'SessionStart', matcher: 'startup|resume|clear|compact' },
- { event: 'UserPromptSubmit' },
- ]
- let changed = false
- for (const { event, matcher } of required) {
- const blocks = Array.isArray(settings.hooks[event]) ? settings.hooks[event] : []
- const foreign = blocks.filter((b) => !isOurs(b))
- const ours = blocks.filter(isOurs)
- const canonical: HookBlock = {
- ...(matcher ? { matcher } : {}),
- hooks: [{ type: 'command', command: cmd, timeout: 5 }],
- }
- const current = ours[0]
- if (ours.length !== 1 || current?.matcher !== matcher || current?.hooks?.[0]?.command !== cmd) changed = true
- settings.hooks[event] = [...foreign, canonical]
- }
-
- if (!changed) {
- console.log(`[hooks] Codex SessionStart/UserPromptSubmit hooks already installed → ${hooksPath}`)
- return
- }
- try {
- writeJsonAtomic(hooksPath, settings)
- console.log(`[hooks] installed Codex SessionStart/UserPromptSubmit hooks → ${hooksPath}`)
- console.log('[hooks] Codex requires reviewing these user hooks with /hooks before normal use')
- } catch (err) {
- console.error('[hooks] failed to write Codex hooks.json:', err)
- }
-}
diff --git a/cli/src/engines/engine.ts b/cli/src/engines/engine.ts
index 9f6a995d7..938d9e07d 100644
--- a/cli/src/engines/engine.ts
+++ b/cli/src/engines/engine.ts
@@ -6,7 +6,7 @@ import type { EngineModelControl } from './facets/modelControl.js'
import type { ProcessEngine } from './types.js'
import type { EngineTranscript } from './facets/transcript.js'
import type { EngineLaunch } from './facets/launch.js'
-import type { EngineHooks } from './facets/hooks.js'
+import type { HookContract } from './facets/hooks.js'
import type { EngineLive } from './facets/live.js'
import type { EngineRuntime } from './facets/runtime.js'
@@ -15,7 +15,8 @@ export interface Engine {
readonly name: ProcessEngine
readonly transcript: EngineTranscript
readonly launch: EngineLaunch
- readonly hooks: EngineHooks
+ /** Declared data that core applies in line (engines/hooks.ts): never run in the engine's worker. */
+ readonly hooks: HookContract
readonly live: EngineLive
readonly runtime: EngineRuntime
readonly screen: EngineScreen
diff --git a/cli/src/engines/facets/hooks.ts b/cli/src/engines/facets/hooks.ts
index 0993338b1..3992dc940 100644
--- a/cli/src/engines/facets/hooks.ts
+++ b/cli/src/engines/facets/hooks.ts
@@ -1,3 +1,4 @@
+import type { Env } from '../../config/env.js'
import type { LiveEvent } from '../kit/events.js'
import type { LiveTurn } from './live.js'
@@ -9,7 +10,7 @@ export interface HookSession {
export interface HookStop { sessionId: string; status?: string; firedAt?: number }
-/** Core supplies immutable observations and owns the event funnel. The engine decides what its Stop means. */
+/** Core supplies immutable observations and owns the event funnel. The kit's Stop rule decides what a Stop means. */
export interface HookTurnContext {
turnState(sessionId: string): LiveTurn | undefined
/** Atomically close only this observed turn; a rejected stale proposal emits nothing. */
@@ -23,6 +24,84 @@ export interface HookTurnContext {
export type HookAdmission = { accepted: true } | { accepted: false; reason: string }
+/** A daemon setting that names a folder, such as `CODEX_HOME`. */
+type FolderSetting = { [K in keyof Env]: Env[K] extends string ? K : never }[keyof Env]
+
+/**
+ * Where an engine reads its hooks, and how Harness keeps its own block there. Declared data, applied by the
+ * one kit installer (kit/hookSettings.ts), synchronously, at daemon start and before a spawn. Core authors
+ * the command every block runs (kit/notifyHooks.ts). Copied from the former engines/{claude,codex}/
+ * installHooks.ts, whose every write, mode and log line the kit reproduces (engines/hookInstallers.golden.spec.ts):
+ * the two treated a malformed file, a symlink and a drifted block differently, and so do these fields.
+ */
+export interface HookSettings {
+ /** The engine's home when core names none: a folder in the person's home, or a daemon setting. */
+ home: { inHome: string } | { setting: FolderSetting }
+ /** The settings file, in that home. */
+ file: string
+ /** One block of ours per event, in this order, with a matcher only where the engine honours one. */
+ events: ReadonlyArray<{ event: string; matcher?: string }>
+ /** Seconds the engine gives the hook. */
+ timeout: number
+ /** The command names this home as the engine's (`--codex-home`): a profile's sessions are in its own store. */
+ commandNamesHome: boolean
+ /**
+ * A file that cannot be read or parsed. `replace`: start from empty settings, and the write replaces it.
+ * `keep`: leave it as it is and say so, since replacing it could switch off the person's own hooks.
+ */
+ unreadable: 'replace' | 'keep'
+ /**
+ * `in-place`: write the file where it is, through a symlink, keeping its mode. `atomic`: write a new file
+ * beside it and rename it over the old one, which replaces a symlink and takes the new file's mode.
+ */
+ write: 'in-place' | 'atomic'
+ /**
+ * When the block of ours already there needs no write. It is the only block of ours, and its command is
+ * the current one: the command of its first notify.mjs hook (`first-ours`) or of its first hook (`first`).
+ * Where `matcher` is set, its matcher is the declared one too.
+ */
+ upToDate: { command: 'first-ours' | 'first'; matcher: boolean }
+ /**
+ * The daemon's log lines, with {file}, {script} and {port} filled in. The end-to-end harness checks that
+ * every file a line names is inside its throwaway root (e2e/harness/daemon.ts `hookFilesNamed`).
+ */
+ messages: {
+ /** Nothing to write. */
+ current: string
+ /** After a write; `updated` instead when a block of ours ran another command. */
+ installed: string
+ updated?: string
+ /** After either. */
+ after: string
+ /** Logged with the error when the write fails. */
+ failed: string
+ /** The lines for an unreadable file that is kept. */
+ malformed?: readonly string[]
+ }
+}
+
+/** A session another session delegated to, told apart by its transcript's first record. */
+export interface HookChildRule {
+ /** The first record's `type`. */
+ type: string
+ /** The field, from that record, whose presence (anything but null) marks a child. Every step before it is an object. */
+ child: readonly string[]
+ /** Why its hooks are refused, in the hook server's answer and log. */
+ reason: string
+}
+
+/** An engine's hooks, declared. Core evaluates every part of it in line: hooks bind sessions and close turns. */
+export interface HookContract {
+ settings: HookSettings
+ /** Refuse a delegated session's hooks before any of them is credited to the pane it runs in. */
+ children?: HookChildRule
+ /** A session's transcript is named `<sessionId><suffix>` (kit/hookRules.ts `knownTranscript`). */
+ sessionFile?: { suffix: string }
+ /** The engine's Stop and StopFailure hooks close its turns (kit/stopHook.ts). */
+ stopClosesTurns?: boolean
+}
+
+/** What core calls, composed from an engine's contract and the kit's mechanics (engines/hooks.ts). */
export interface EngineHooks {
install(port: number): void
installIn(port: number, home: string): void
diff --git a/cli/src/engines/hookInstallers.golden.spec.ts b/cli/src/engines/hookInstallers.golden.spec.ts
new file mode 100644
index 000000000..42ac08bf7
--- /dev/null
+++ b/cli/src/engines/hookInstallers.golden.spec.ts
@@ -0,0 +1,336 @@
+/**
+ * What the Claude Code and Codex hook installers write, byte for byte, in every state their files are found
+ * in. Recorded from the former `engines/{claude,codex}/installHooks.ts` before they became declared settings
+ * applied by one kit installer (docs/design/2026-10-08-engine-hooks.md): the two detected drift and wrote
+ * differently (in place versus atomically, which hook counts as ours, what a malformed file means), and
+ * every one of those differences reaches a person's own settings. Each case runs the installer twice and
+ * keeps what each run logged and threw, and every file left behind: its bytes, its mode, a symlink kept or
+ * replaced, a temporary file left over.
+ *
+ * `RECORD_HOOK_GOLDEN=1` writes the fixture. Record it again only for a change meant to alter what lands
+ * in an engine's settings, and say so in that change.
+ */
+import { chmodSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { dirname, join, relative } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
+
+const GOLDEN = fileURLToPath(new URL('./__fixtures__/hook-installers.golden.json', import.meta.url))
+const RECORD = process.env.RECORD_HOOK_GOLDEN === '1'
+const PORT = 19473
+const OTHER_PORT = 19474
+/** A hook of ours from another install: another path, another port, and the bare `node` of old releases. */
+const OLD = "node '/opt/old/notify.mjs' --port 18473"
+/** Permission cases mean nothing to root, which may write anywhere. */
+const ROOT_USER = process.getuid?.() === 0
+
+type Engine = 'claude' | 'codex'
+type Via = 'install' | 'installIn'
+interface Target { engine: Engine; via: Via; home: string; file: string; cmd: string; otherCmd: string; elsewhere: string }
+interface Case { name: string; setup?: (target: Target) => void; noHome?: boolean; permissions?: boolean }
+
+/** The events each former installer wrote, with their matchers, to build the files a current install leaves. */
+const EVENTS: Record<Engine, Array<{ event: string; matcher?: string }>> = {
+ claude: ['SessionStart', 'SessionEnd', 'UserPromptSubmit', 'Stop', 'StopFailure'].map((event) => ({ event })),
+ codex: [{ event: 'SessionStart', matcher: 'startup|resume|clear|compact' }, { event: 'UserPromptSubmit' }],
+}
+const current = (engine: Engine, cmd: string, timeout = 5) => ({
+ hooks: Object.fromEntries(EVENTS[engine].map(({ event, matcher }) => [event, [{ ...(matcher ? { matcher } : {}), hooks: [{ type: 'command', command: cmd, timeout }] }]])),
+})
+const pretty = (value: unknown): string => JSON.stringify(value, null, 2) + '\n'
+const write = (file: string, text: string, mode?: number): void => {
+ mkdirSync(dirname(file), { recursive: true })
+ writeFileSync(file, text)
+ if (mode !== undefined) chmodSync(file, mode)
+}
+const foreign = (engine: Engine) => ({
+ model: 'opus', nested: { list: [1, 2.5, 'x'], none: null }, note: 'café ✓ 🎉',
+ hooks: {
+ [EVENTS[engine][0].event]: [{ matcher: 'resume', hooks: [{ type: 'command', command: 'foreign-start', timeout: 9 }] }],
+ UserPromptSubmit: [{ hooks: [{ type: 'command', command: 'foreign-prompt' }] }],
+ PreToolUse: [{ matcher: 'Bash', hooks: [{ type: 'command', command: 'foreign-tool' }] }],
+ },
+})
+
+const CASES: Case[] = [
+ { name: 'no file' },
+ { name: 'no home folder', noHome: true },
+ { name: 'empty file', setup: ({ file }) => write(file, '') },
+ { name: 'whitespace only', setup: ({ file }) => write(file, ' \n') },
+ { name: 'malformed JSON', setup: ({ file }) => write(file, '{not-json') },
+ { name: 'byte order mark', setup: ({ file }) => write(file, '{}') },
+ { name: 'JSON null', setup: ({ file }) => write(file, 'null') },
+ { name: 'JSON array', setup: ({ file }) => write(file, '[]') },
+ { name: 'JSON string', setup: ({ file }) => write(file, '"text"') },
+ { name: 'JSON number', setup: ({ file }) => write(file, '42') },
+ { name: 'hooks is a string', setup: ({ file }) => write(file, '{"hooks":"nope","keep":1}') },
+ { name: 'hooks is an array', setup: ({ file }) => write(file, '{"hooks":[]}') },
+ { name: 'hooks is null', setup: ({ file }) => write(file, '{"hooks":null}') },
+ { name: 'an event is not a list', setup: ({ file, engine }) => write(file, JSON.stringify({ hooks: { [EVENTS[engine][0].event]: { a: 1 } } })) },
+ { name: 'odd blocks', setup: ({ file, engine }) => write(file, JSON.stringify({ hooks: { [EVENTS[engine][0].event]: [null, 'text', { hooks: 'no' }, { hooks: [null, {}] }] } })) },
+ { name: 'a command that is not text', setup: ({ file, engine }) => write(file, JSON.stringify({ hooks: { [EVENTS[engine][0].event]: [{ hooks: [{ type: 'command', command: 5 }] }] } })) },
+ { name: 'duplicate keys', setup: ({ file, engine, cmd }) => write(file, `{"hooks":{},"hooks":${JSON.stringify(current(engine, cmd).hooks)}}`) },
+ { name: 'foreign hooks only', setup: ({ file, engine }) => write(file, pretty(foreign(engine))) },
+ { name: 'our old hook', setup: ({ file, engine }) => write(file, pretty(current(engine, OLD))) },
+ {
+ name: 'our old hook beside foreign hooks', setup: ({ file, engine }) => {
+ const settings = foreign(engine) as { hooks: Record<string, unknown[]> }
+ for (const { event } of EVENTS[engine]) settings.hooks[event] = [...(settings.hooks[event] ?? []), { hooks: [{ type: 'command', command: OLD, timeout: 5 }] }]
+ write(file, pretty(settings))
+ },
+ },
+ {
+ name: 'ours current on some events, old or missing on others', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd)
+ const [first, ...rest] = EVENTS[engine]
+ settings.hooks[first.event] = [{ ...(first.matcher ? { matcher: first.matcher } : {}), hooks: [{ type: 'command', command: OLD, timeout: 5 }] }]
+ if (rest.length > 1) delete settings.hooks[rest[0].event]
+ write(file, pretty(settings))
+ },
+ },
+ { name: 'ours current', setup: ({ file, engine, cmd }) => write(file, pretty(current(engine, cmd))) },
+ { name: 'ours current, minified', setup: ({ file, engine, cmd }) => write(file, JSON.stringify(current(engine, cmd))) },
+ {
+ name: 'ours current before foreign hooks', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, unknown[]> }
+ for (const { event } of EVENTS[engine]) settings.hooks[event].push({ hooks: [{ type: 'command', command: 'foreign-after' }] })
+ write(file, pretty(settings))
+ },
+ },
+ { name: 'ours current with another timeout', setup: ({ file, engine, cmd }) => write(file, pretty(current(engine, cmd, 30))) },
+ {
+ name: 'ours twice on an event', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, unknown[]> }
+ const { event } = EVENTS[engine][0]
+ settings.hooks[event].push(settings.hooks[event][0])
+ write(file, pretty(settings))
+ },
+ },
+ {
+ name: 'ours twice, the first old', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, unknown[]> }
+ const { event, matcher } = EVENTS[engine][0]
+ settings.hooks[event].unshift({ ...(matcher ? { matcher } : {}), hooks: [{ type: 'command', command: OLD, timeout: 5 }] })
+ write(file, pretty(settings))
+ },
+ },
+ {
+ name: 'our block led by a foreign hook', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, Array<{ hooks: unknown[] }>> }
+ for (const { event } of EVENTS[engine]) settings.hooks[event][0].hooks.unshift({ type: 'command', command: 'foreign-first' })
+ write(file, pretty(settings))
+ },
+ },
+ {
+ name: 'our block with another matcher', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, Array<{ matcher?: string }>> }
+ for (const { event } of EVENTS[engine]) settings.hooks[event][0].matcher = 'other'
+ write(file, pretty(settings))
+ },
+ },
+ {
+ name: 'our block missing its matcher', setup: ({ file, engine, cmd }) => {
+ const settings = current(engine, cmd) as { hooks: Record<string, Array<{ matcher?: string }>> }
+ for (const { event } of EVENTS[engine]) delete settings.hooks[event][0].matcher
+ write(file, pretty(settings))
+ },
+ },
+ { name: 'ours current for another port', setup: ({ file, engine, otherCmd }) => write(file, pretty(current(engine, otherCmd))) },
+ {
+ name: 'a symlink to foreign settings', setup: ({ file, engine, elsewhere }) => {
+ write(join(elsewhere, 'real.json'), pretty(foreign(engine)))
+ mkdirSync(dirname(file), { recursive: true })
+ symlinkSync(join(elsewhere, 'real.json'), file)
+ },
+ },
+ {
+ name: 'a symlink to current settings', setup: ({ file, engine, cmd, elsewhere }) => {
+ write(join(elsewhere, 'real.json'), pretty(current(engine, cmd)))
+ mkdirSync(dirname(file), { recursive: true })
+ symlinkSync(join(elsewhere, 'real.json'), file)
+ },
+ },
+ {
+ name: 'a dangling symlink', setup: ({ file, elsewhere }) => {
+ mkdirSync(elsewhere, { recursive: true })
+ mkdirSync(dirname(file), { recursive: true })
+ symlinkSync(join(elsewhere, 'missing.json'), file)
+ },
+ },
+ {
+ name: 'a symlink into a missing folder', setup: ({ file, elsewhere }) => {
+ mkdirSync(dirname(file), { recursive: true })
+ symlinkSync(join(elsewhere, 'gone', 'missing.json'), file)
+ },
+ },
+ { name: 'a read-only file', permissions: true, setup: ({ file, engine }) => write(file, pretty(foreign(engine)), 0o444) },
+ { name: 'a read-only file, current', permissions: true, setup: ({ file, engine, cmd }) => write(file, pretty(current(engine, cmd)), 0o444) },
+ { name: 'an unreadable file', permissions: true, setup: ({ file, engine }) => write(file, pretty(foreign(engine)), 0o200) },
+ { name: 'a read-only folder', permissions: true, setup: ({ home }) => chmodSync(home, 0o555) },
+ {
+ name: 'a read-only folder holding a writable file', permissions: true, setup: ({ file, engine, home }) => {
+ write(file, pretty(foreign(engine)))
+ chmodSync(home, 0o555)
+ },
+ },
+ { name: 'a private file', setup: ({ file, engine }) => write(file, pretty(foreign(engine)), 0o600) },
+ { name: 'the file is a folder', setup: ({ file }) => mkdirSync(file, { recursive: true }) },
+ {
+ name: 'a temporary file left by this process', setup: ({ file, engine }) => {
+ write(file, pretty(foreign(engine)))
+ write(`${file}.${process.pid}.tmp`, 'junk', 0o600)
+ },
+ },
+]
+/** The cases also run against each engine's default home, which the installer finds on its own. */
+const DEFAULT_HOME_CASES = new Set(['no file', 'no home folder', 'malformed JSON', 'foreign hooks only', 'our old hook', 'ours current', 'a symlink to foreign settings'])
+
+interface Run { logs: string[]; threw: string | null }
+interface Entry { type: 'dir' | 'file' | 'link'; mode?: string; text?: string; target?: string }
+interface Outcome { runs: Run[]; files: Record<string, Entry> }
+
+let root = ''
+const saved: Record<string, string | undefined> = {}
+let hooks: typeof import('./hooks.js')['engineHooks']
+let command: typeof import('./kit/notifyHooks.js')['command']
+let tokens: Array<[string, string]> = []
+const golden: Record<string, Outcome> = RECORD ? {} : JSON.parse(readFileSync(GOLDEN, 'utf8')) as Record<string, Outcome>
+const recorded: Record<string, Outcome> = {}
+
+const homes = (): Record<Engine, Record<Via, string>> => ({
+ claude: { install: join(root, 'home', '.claude'), installIn: join(root, 'moved', 'claude-work') },
+ codex: { install: join(root, 'home', '.codex'), installIn: join(root, 'moved', 'codex-work') },
+})
+const FILE: Record<Engine, string> = { claude: 'settings.json', codex: 'hooks.json' }
+
+const normalize = (text: string): string => tokens.reduce((out, [value, token]) => out.split(value).join(token), text)
+const describeError = (error: unknown): string => {
+ if (!(error instanceof Error)) return `thrown ${typeof error}`
+ const { code, syscall, path, dest } = error as NodeJS.ErrnoException & { dest?: string }
+ return [error.name, code, syscall, path && normalize(path), dest && normalize(dest)].filter(Boolean).join(' ')
+}
+
+/** Everything under the case's folders: what a person would find in their engine's home afterwards. */
+function snapshot(): Record<string, Entry> {
+ const files: Record<string, Entry> = {}
+ const walk = (dir: string): void => {
+ let names: string[]
+ try { names = readdirSync(dir).sort() } catch { return }
+ for (const name of names) {
+ const path = join(dir, name)
+ const stat = lstatSync(path)
+ const key = normalize(relative(root, path))
+ if (stat.isSymbolicLink()) files[key] = { type: 'link', target: normalize(readlinkSync(path)) }
+ else if (stat.isDirectory()) {
+ files[key] = { type: 'dir', mode: (stat.mode & 0o777).toString(8) }
+ walk(path)
+ } else {
+ const mode = stat.mode & 0o777
+ // A file the person cannot read is still compared: read it for the record, then put its mode back.
+ if (!(mode & 0o400)) chmodSync(path, mode | 0o400)
+ const text = normalize(readFileSync(path, 'utf8'))
+ if (!(mode & 0o400)) chmodSync(path, mode)
+ files[key] = { type: 'file', mode: mode.toString(8), text }
+ }
+ }
+ }
+ for (const top of ['home', 'moved', 'elsewhere']) walk(join(root, top))
+ return files
+}
+
+/** Give back write access everywhere, so that the next case starts from nothing. */
+function reset(): void {
+ const open = (path: string): void => {
+ let stat
+ try { stat = lstatSync(path) } catch { return }
+ if (stat.isSymbolicLink()) return
+ chmodSync(path, stat.isDirectory() ? 0o755 : 0o644)
+ if (stat.isDirectory()) for (const name of readdirSync(path)) open(join(path, name))
+ }
+ for (const top of ['home', 'moved', 'elsewhere']) {
+ open(join(root, top))
+ rmSync(join(root, top), { recursive: true, force: true })
+ }
+ mkdirSync(join(root, 'home'), { recursive: true })
+}
+
+function run(engine: Engine, via: Via, scenario: Case): Outcome {
+ reset()
+ const home = homes()[engine][via]
+ const commandFor = (port: number): string => engine === 'claude' ? command(port, 'claude') : command(port, 'codex', home)
+ const target: Target = { engine, via, home, file: join(home, FILE[engine]), cmd: commandFor(PORT), otherCmd: commandFor(OTHER_PORT), elsewhere: join(root, 'elsewhere') }
+ if (!scenario.noHome) mkdirSync(home, { recursive: true })
+ scenario.setup?.(target)
+ const runs: Run[] = []
+ for (let i = 0; i < 2; i++) {
+ const logs: string[] = []
+ const capture = (level: string) => (...args: unknown[]) => {
+ logs.push(`${level} ${args.map((arg) => typeof arg === 'string' ? normalize(arg) : describeError(arg)).join(' ')}`)
+ }
+ const spies = [vi.spyOn(console, 'log').mockImplementation(capture('log')), vi.spyOn(console, 'error').mockImplementation(capture('error')),
+ vi.spyOn(console, 'warn').mockImplementation(capture('warn'))]
+ let threw: string | null = null
+ try {
+ if (via === 'install') hooks[engine].install(PORT)
+ else hooks[engine].installIn(PORT, home)
+ } catch (error) { threw = describeError(error) } finally { for (const spy of spies) spy.mockRestore() }
+ runs.push({ logs, threw })
+ }
+ return { runs, files: snapshot() }
+}
+
+beforeAll(async () => {
+ root = mkdtempSync(join(tmpdir(), 'hook-golden-'))
+ for (const name of ['HOME', 'CODEX_HOME', 'ADAPTER_DATA_DIR', 'ADAPTER_RUNTIME_DIR', 'CLAUDE_PROJECTS_DIR']) saved[name] = process.env[name]
+ // Every folder the hook command names is inside the throwaway root, so the command reads the same on every machine.
+ process.env.HOME = join(root, 'home')
+ process.env.CODEX_HOME = join(root, 'home', '.codex')
+ process.env.ADAPTER_DATA_DIR = join(root, 'data')
+ process.env.ADAPTER_RUNTIME_DIR = join(root, 'runtime')
+ delete process.env.CLAUDE_PROJECTS_DIR
+ mkdirSync(join(root, 'data'), { recursive: true })
+ mkdirSync(join(root, 'runtime'), { recursive: true })
+ vi.resetModules()
+ ;({ engineHooks: hooks } = await import('./hooks.js'))
+ const notify = await import('./kit/notifyHooks.js')
+ command = notify.command
+ const all = homes()
+ const commands: Array<[string, string]> = []
+ for (const port of [PORT, OTHER_PORT]) {
+ commands.push([command(port, 'claude'), `<command claude ${port}>`])
+ for (const via of ['install', 'installIn'] as const) commands.push([command(port, 'codex', all.codex[via]), `<command codex ${port} ${via}>`])
+ }
+ // Longest first: Claude Code's command is the start of Codex's, and every command contains the folders below.
+ commands.sort(([a], [b]) => b.length - a.length)
+ tokens = [...commands, [notify.HOOK_SCRIPT, '<script>'], [process.execPath, '<node>'], [root, '<root>'], [`.${process.pid}.`, '.<pid>.']]
+})
+
+afterAll(() => {
+ for (const [name, value] of Object.entries(saved)) if (value === undefined) delete process.env[name]; else process.env[name] = value
+ if (root) { reset(); rmSync(root, { recursive: true, force: true }) }
+ if (RECORD) writeFileSync(GOLDEN, JSON.stringify(recorded, null, 1) + '\n')
+})
+
+describe.each(['claude', 'codex'] as const)('%s hook installer, byte for byte', (engine) => {
+ for (const via of ['installIn', 'install'] as const) {
+ for (const scenario of CASES.filter((one) => via === 'installIn' || DEFAULT_HOME_CASES.has(one.name))) {
+ const key = `${engine} ${via}: ${scenario.name}`
+ it.skipIf(scenario.permissions && ROOT_USER)(key, () => {
+ const previous = process.umask(0o022)
+ try {
+ const outcome = run(engine, via, scenario)
+ recorded[key] = outcome
+ if (!RECORD) expect(outcome).toEqual(golden[key])
+ } finally { process.umask(previous) }
+ })
+ }
+ }
+})
+
+it('has a recorded outcome for every case, and no other', () => {
+ if (RECORD) return
+ const expected = (['claude', 'codex'] as const).flatMap((engine) => (['installIn', 'install'] as const).flatMap((via) =>
+ CASES.filter((one) => via === 'installIn' || DEFAULT_HOME_CASES.has(one.name)).map((one) => `${engine} ${via}: ${one.name}`)))
+ expect(Object.keys(golden).sort()).toEqual(expected.sort())
+})
diff --git a/cli/src/engines/hooks.spec.ts b/cli/src/engines/hooks.spec.ts
index 843e2c25d..2c775b994 100644
--- a/cli/src/engines/hooks.spec.ts
+++ b/cli/src/engines/hooks.spec.ts
@@ -3,19 +3,34 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { afterEach, expect, it, vi } from 'vitest'
-import { admitHook, engineHooks, hooksFor } from './hooks.js'
+import { admitHook, engineHooks, hookContracts, hooksFor } from './hooks.js'
import { engineFor } from './registry.js'
import { liveFor } from './live.js'
afterEach(() => vi.restoreAllMocks())
-it('exposes the same hooks through the full and hook-only engine interfaces', () => {
- for (const name of ['claude', 'codex']) expect(engineFor(name)!.hooks).toBe(hooksFor(name))
+it('declares each engine\'s hooks once, for the full engine interface and the hook-only lookup', () => {
+ for (const name of ['claude', 'codex'] as const) {
+ expect(engineFor(name)!.hooks).toBe(hookContracts[name])
+ expect(hooksFor(name)).toBe(engineHooks[name])
+ }
for (const name of [null, undefined, '', 'future', 'constructor', '__proto__']) expect(hooksFor(name)).toBeUndefined()
expect(admitHook('future', {})).toEqual({ accepted: true })
expect(admitHook('claude', {})).toEqual({ accepted: true })
})
+it('composes only what a contract declares: Claude Code corrects transcripts and closes turns, Codex admits', () => {
+ expect(Object.keys(engineHooks.claude).sort()).toEqual(['install', 'installIn', 'onStop', 'transcriptFor'])
+ expect(Object.keys(engineHooks.codex).sort()).toEqual(['admit', 'install', 'installIn'])
+})
+
+it('keeps every contract plain data: nothing in it runs', () => {
+ const functions = (value: unknown): number => typeof value === 'function' ? 1
+ : value && typeof value === 'object' ? Object.values(value).reduce<number>((sum, inner) => sum + functions(inner), 0) : 0
+ expect(functions(hookContracts)).toBe(0)
+ expect(JSON.parse(JSON.stringify(hookContracts))).toEqual(hookContracts)
+})
+
it('installs Claude hooks into the requested home through its facet', () => {
const home = mkdtempSync(join(tmpdir(), 'claude-hook-facet-'))
try {
diff --git a/cli/src/engines/hooks.ts b/cli/src/engines/hooks.ts
index 5eae149ed..8924d1f01 100644
--- a/cli/src/engines/hooks.ts
+++ b/cli/src/engines/hooks.ts
@@ -1,15 +1,43 @@
-import type { EngineHooks, HookAdmission, HookSession } from './facets/hooks.js'
-import { hooks as claude } from './claude/hooks.js'
-import { hooks as codex } from './codex/hooks.js'
+import type { EngineHooks, HookAdmission, HookContract, HookSession } from './facets/hooks.js'
+import { hooks as claude } from './claude/hookContract.js'
+import { hooks as codex } from './codex/hookContract.js'
+import { installHookSettings, type HookEngine } from './kit/hookSettings.js'
+import { isChildSession, knownTranscript } from './kit/hookRules.js'
+import { closeTurnOnStop } from './kit/stopHook.js'
+
+/**
+ * The engines' hooks as they declare them: data only. Installation, the hook server and turn closing load
+ * no engine code and wait on no engine worker: hooks are how sessions bind and turns close, which are the
+ * core's (docs/design/2026-10-08-engine-hooks.md).
+ */
+export const hookContracts = { claude, codex } satisfies Record<string, HookContract>
+
+/** An engine's hooks as core calls them: the kit's mechanics, run on that engine's declaration. */
+function composed(engine: HookEngine, { settings, children, sessionFile, stopClosesTurns }: HookContract): EngineHooks {
+ return {
+ install: (port) => installHookSettings(engine, settings, port),
+ installIn: (port, home) => installHookSettings(engine, settings, port, home),
+ ...(sessionFile ? { transcriptFor: (body: HookSession, agent: HookSession | undefined) => knownTranscript(body, agent, sessionFile) } : {}),
+ ...(children ? {
+ admit: (body: HookSession): HookAdmission => body.transcriptPath && isChildSession(body.transcriptPath, children)
+ ? { accepted: false, reason: children.reason }
+ : { accepted: true },
+ } : {}),
+ ...(stopClosesTurns ? { onStop: closeTurnOnStop } : {}),
+ }
+}
/** Hook-only lookup: installation and the HTTP door do not need history readers or launch code. */
-export const engineHooks = { claude, codex }
+export const engineHooks = { claude: composed('claude', claude), codex: composed('codex', codex) }
export function hooksFor(name: string | null | undefined): EngineHooks | undefined {
return name && Object.hasOwn(engineHooks, name) ? engineHooks[name as keyof typeof engineHooks] : undefined
}
-/** A broken admission check must never let a delegated session claim its parent's pane. */
+/**
+ * A broken admission check must never let a delegated session claim its parent's pane. The hook server asks
+ * this before it credits a prompt or registers, and `registry.register` asks it again, so the two agree.
+ */
export function admitHook(engine: string, body: HookSession): HookAdmission {
try { return hooksFor(engine)?.admit?.(body) ?? { accepted: true } } catch (error) {
console.warn(`[hooks] ${engine} admission failed:`, error instanceof Error ? error.message : error)
diff --git a/cli/src/engines/kit/hookRules.spec.ts b/cli/src/engines/kit/hookRules.spec.ts
new file mode 100644
index 000000000..72ac75556
--- /dev/null
+++ b/cli/src/engines/kit/hookRules.spec.ts
@@ -0,0 +1,103 @@
+import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { afterAll, beforeAll, describe, expect, it } from 'vitest'
+import { readCodexRolloutMeta } from '../codex/rollout.js'
+import { hooks as codex } from '../codex/hookContract.js'
+import { isChildSession, knownTranscript } from './hookRules.js'
+
+let root = ''
+beforeAll(() => { root = mkdtempSync(join(tmpdir(), 'hook-rules-')) })
+afterAll(() => rmSync(root, { recursive: true, force: true }))
+
+const meta = (payload: unknown, type = 'session_meta'): string => JSON.stringify({ type, payload })
+/** First records as Codex writes them, and every way one can fail to be a child's. */
+const FIRST_RECORDS: Array<[string, string]> = [
+ ['a spawned child', meta({ id: 'c', source: { subagent: { thread_spawn: { parent_thread_id: 'p', depth: 1 } } } }) + '\n'],
+ ['a review child', meta({ id: 'c', source: { subagent: 'review' } }) + '\n'],
+ ['a child marked false', meta({ source: { subagent: false } }) + '\n'],
+ ['a child marked 0', meta({ source: { subagent: 0 } }) + '\n'],
+ ['a child marked by an empty list', meta({ source: { subagent: [] } }) + '\n'],
+ ['a null child field', meta({ source: { subagent: null } }) + '\n'],
+ ['a main session', meta({ id: 'p', source: 'cli' }) + '\n'],
+ ['a source that is a list', meta({ source: [{ subagent: 'x' }] }) + '\n'],
+ ['a payload that is a list', meta([{ source: { subagent: 'x' } }]) + '\n'],
+ ['a payload that is text', meta('subagent') + '\n'],
+ ['no payload', JSON.stringify({ type: 'session_meta' }) + '\n'],
+ ['another first record', meta({ source: { subagent: 'x' } }, 'response_item') + '\n'],
+ ['a record that is a list', '[{"type":"session_meta"}]\n'],
+ ['a record that is null', 'null\n'],
+ ['blank lines before the record', '\n \n\t\n' + meta({ source: { subagent: 'x' } }) + '\n'],
+ ['carriage returns', meta({ source: { subagent: 'x' } }) + '\r\n' + meta({}) + '\r\n'],
+ ['a child as the second record', meta({ source: 'cli' }) + '\n' + meta({ source: { subagent: 'x' } }) + '\n'],
+ ['no newline after the record', meta({ source: { subagent: 'x' } })],
+ ['malformed JSON', '{"type":"session_meta",\n'],
+ ['an empty file', ''],
+ ['only blank lines', '\n\n'],
+ ['a record past the bound', meta({ source: { subagent: 'x' }, pad: 'x'.repeat(130 * 1024) }) + '\n'],
+ ['a record just inside the bound', meta({ source: { subagent: 'x' }, pad: 'x'.repeat(127 * 1024) }) + '\n'],
+ ['a __proto__ step', '{"type":"session_meta","payload":{"__proto__":{"subagent":"x"},"source":{}}}\n'],
+ ['unicode before the field', meta({ note: 'é✓🎉', source: { subagent: 'x' } }) + '\n'],
+]
+
+describe('Codex\'s declared child rule', () => {
+ // `registry` still reads rollouts with readCodexRolloutMeta, at load, to repair a parent a child's hook
+ // overwrote: the rule evaluated on the hook path must say what that reader says about every first record.
+ it.each(FIRST_RECORDS)('agrees with the rollout reader on %s', (name, text) => {
+ const file = join(root, `${name.replace(/\W+/g, '-')}.jsonl`)
+ writeFileSync(file, text)
+ expect(isChildSession(file, codex.children!)).toBe(readCodexRolloutMeta(file)?.isSubagent === true)
+ })
+
+ it('finds the children it should', () => {
+ const verdict = (text: string): boolean => {
+ const file = join(root, 'verdict.jsonl')
+ writeFileSync(file, text)
+ return isChildSession(file, codex.children!)
+ }
+ expect(FIRST_RECORDS.filter(([, text]) => verdict(text)).map(([name]) => name)).toEqual([
+ 'a spawned child', 'a review child', 'a child marked false', 'a child marked 0', 'a child marked by an empty list',
+ 'blank lines before the record', 'carriage returns', 'no newline after the record', 'a record just inside the bound',
+ 'unicode before the field',
+ ])
+ })
+
+ it('admits what it cannot read: a missing file, a folder, a dangling link', () => {
+ mkdirSync(join(root, 'folder.jsonl'))
+ symlinkSync(join(root, 'nowhere.jsonl'), join(root, 'dangling.jsonl'))
+ for (const file of [join(root, 'missing.jsonl'), join(root, 'folder.jsonl'), join(root, 'dangling.jsonl')]) {
+ expect(isChildSession(file, codex.children!)).toBe(false)
+ expect(readCodexRolloutMeta(file)).toBeNull()
+ }
+ })
+
+ it('reads any declared path, needing an object at every step before the field', () => {
+ const file = join(root, 'other.jsonl')
+ writeFileSync(file, JSON.stringify({ type: 'start', a: { b: { c: 'yes' } } }) + '\n')
+ const rule = (child: string[], type = 'start') => isChildSession(file, { type, child, reason: 'test' })
+ expect(rule(['a', 'b', 'c'])).toBe(true)
+ expect(rule(['a', 'b', 'c'], 'session_meta')).toBe(false)
+ expect(rule(['a', 'b', 'c', 'd'])).toBe(false)
+ expect(rule(['a', 'x'])).toBe(false)
+ expect(rule([])).toBe(true)
+ })
+})
+
+describe('the declared session file naming', () => {
+ const suffix = { suffix: '.jsonl' }
+ it('takes the row\'s own file for an announcement that never appears, and only for this conversation', () => {
+ const sessionId = '73f090ca-0000-4000-8000-000000000000'
+ const known = join(root, 'project', `${sessionId}.jsonl`)
+ mkdirSync(join(root, 'project'), { recursive: true })
+ writeFileSync(known, '{}\n')
+ const announced = join(root, 'elsewhere', `${sessionId}.jsonl`)
+ const row = { sessionId, transcriptPath: known }
+ expect(knownTranscript({ sessionId, transcriptPath: announced }, row, suffix)).toBe(known)
+ expect(knownTranscript({ sessionId, transcriptPath: announced }, row, { suffix: '.json' })).toBe(announced)
+ expect(knownTranscript({ sessionId, transcriptPath: known }, { sessionId, transcriptPath: announced }, suffix)).toBe(known)
+ expect(knownTranscript({ sessionId: 'other', transcriptPath: announced }, row, suffix)).toBe(announced)
+ expect(knownTranscript({ sessionId, transcriptPath: announced }, undefined, suffix)).toBe(announced)
+ expect(knownTranscript({ sessionId, transcriptPath: null }, row, suffix)).toBeUndefined()
+ expect(knownTranscript({ transcriptPath: announced }, row, suffix)).toBe(announced)
+ })
+})
diff --git a/cli/src/engines/kit/hookRules.ts b/cli/src/engines/kit/hookRules.ts
new file mode 100644
index 000000000..a3fe11fe0
--- /dev/null
+++ b/cli/src/engines/kit/hookRules.ts
@@ -0,0 +1,63 @@
+/**
+ * The rules core applies to a hook as it arrives, from what an engine declares (facets/hooks.ts
+ * `HookContract`). Both run synchronously on the hook server's path, with no engine code and no worker: a
+ * hook is how a session binds, and session control never waits on an engine's process.
+ */
+import { closeSync, existsSync, openSync, readSync } from 'node:fs'
+import { basename } from 'node:path'
+import type { HookChildRule, HookSession } from '../facets/hooks.js'
+
+/** The most of a transcript read for its first record: the bound of Codex's own rollout reader (codex/rollout.ts). */
+const FIRST_RECORD_BYTES = 128 * 1024
+
+type JsonObject = Record<string, unknown>
+const object = (value: unknown): JsonObject | null =>
+ value !== null && typeof value === 'object' && !Array.isArray(value) ? value as JsonObject : null
+
+/**
+ * Whether `file` is a delegated session's transcript: its first record is of the rule's type and carries
+ * its child field. Anything unreadable, or a record not of that type, is not a child: the session is
+ * admitted as before, and the registry's own checks still apply. Reads one bounded block from the start.
+ */
+export function isChildSession(file: string, rule: HookChildRule): boolean {
+ let fd: number | null = null
+ try {
+ fd = openSync(file, 'r')
+ const buffer = Buffer.alloc(FIRST_RECORD_BYTES)
+ const bytes = readSync(fd, buffer, 0, buffer.length, 0)
+ const firstLine = buffer.subarray(0, bytes).toString('utf8').split('\n').find((line) => line.trim())
+ if (!firstLine) return false
+ const record = object(JSON.parse(firstLine))
+ if (record?.type !== rule.type) return false
+ let at: unknown = record
+ for (const step of rule.child) {
+ const container = object(at)
+ if (!container) return false
+ at = container[step]
+ }
+ return at !== undefined && at !== null
+ } catch {
+ return false
+ } finally {
+ if (fd !== null) {
+ try { closeSync(fd) } catch { /* best effort */ }
+ }
+ }
+}
+
+/**
+ * `claude --resume` from a folder other than the conversation's own: Claude Code announces a transcript
+ * under the CURRENT cwd's project dir, then keeps writing the original file (measured: a resume of
+ * 73f090ca from `cli/` announced `…-openharness-cli/73f090ca.jsonl`, and every later turn still landed
+ * in `…-openharness/73f090ca.jsonl`). The announced file never appears, the hook is dropped, and the
+ * resume is never confirmed — "Start failed" over a pane that is working. The row being resumed already
+ * knows the real file; take it when it names this very conversation, by the engine's declared naming.
+ */
+export function knownTranscript(body: HookSession, agent: HookSession | undefined, sessionFile: { suffix: string }): string | undefined {
+ const announced = body.transcriptPath ?? undefined
+ if (!announced || existsSync(announced)) return announced
+ const known = agent?.transcriptPath
+ if (!known || !body.sessionId || agent.sessionId !== body.sessionId) return announced
+ if (basename(known) !== `${body.sessionId}${sessionFile.suffix}` || !existsSync(known)) return announced
+ return known
+}
diff --git a/cli/src/engines/kit/hookSettings.spec.ts b/cli/src/engines/kit/hookSettings.spec.ts
new file mode 100644
index 000000000..7f7e58bec
--- /dev/null
+++ b/cli/src/engines/kit/hookSettings.spec.ts
@@ -0,0 +1,43 @@
+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
+import { homedir, tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { afterEach, beforeEach, expect, it, vi } from 'vitest'
+import { env } from '../../config/env.js'
+import { hooks as claude } from '../claude/hookContract.js'
+import { hooks as codex } from '../codex/hookContract.js'
+import { defaultHookHome, installHookSettings } from './hookSettings.js'
+import { HOOK_SCRIPT } from './notifyHooks.js'
+
+// What every case writes and logs is engines/hookInstallers.golden.spec.ts; these are the kit's own edges.
+let root = ''
+beforeEach(() => { root = mkdtempSync(join(tmpdir(), 'hook-settings-')) })
+afterEach(() => {
+ vi.restoreAllMocks()
+ rmSync(root, { recursive: true, force: true })
+})
+
+it('finds an engine\'s home in the person\'s home or in a daemon setting', () => {
+ expect(defaultHookHome(claude.settings)).toBe(join(homedir(), '.claude'))
+ expect(defaultHookHome(codex.settings)).toBe(env.CODEX_HOME)
+})
+
+it('names a home literally in its log lines, whatever characters the path holds', () => {
+ const log = vi.spyOn(console, 'log').mockImplementation(() => {})
+ // `$&` and `$1` mean something to String.replace with a string replacement, and {port} to the templates.
+ const home = join(root, 'a$&b$1{port}{file}')
+ const file = join(home, 'settings.json')
+ installHookSettings('claude', { ...claude.settings, messages: { ...claude.settings.messages, installed: '{file}|{script}|{port}' } }, 19473, home)
+ expect(log.mock.calls[0]).toEqual([`${file}|${HOOK_SCRIPT}|19473`])
+ expect(JSON.parse(readFileSync(file, 'utf8')).hooks.Stop[0].hooks[0].command).toContain('--port 19473')
+})
+
+it('keeps a malformed file quietly for an engine that declares no lines for it', () => {
+ const error = vi.spyOn(console, 'error').mockImplementation(() => {})
+ const home = join(root, 'codex')
+ mkdirSync(home)
+ writeFileSync(join(home, 'hooks.json'), '{not-json')
+ const { malformed: _, ...messages } = codex.settings.messages
+ installHookSettings('codex', { ...codex.settings, messages }, 19473, home)
+ expect(error).not.toHaveBeenCalled()
+ expect(readFileSync(join(home, 'hooks.json'), 'utf8')).toBe('{not-json')
+})
diff --git a/cli/src/engines/kit/hookSettings.ts b/cli/src/engines/kit/hookSettings.ts
new file mode 100644
index 000000000..88645b1a4
--- /dev/null
+++ b/cli/src/engines/kit/hookSettings.ts
@@ -0,0 +1,87 @@
+/**
+ * The one installer of the engines' declared hook settings (facets/hooks.ts `HookSettings`): Harness's block
+ * merged into the settings file an engine reads its hooks from, every other block left as it was.
+ *
+ * It replaces Claude Code's and Codex's own installers, statement for statement, and writes the same bytes,
+ * modes and log lines in every state their files were recorded in (engines/hookInstallers.golden.spec.ts).
+ * It runs in core, synchronously: at daemon start (core/engines/hooks.ts) and before a Codex agent starts in
+ * a profile of its own (core/agents/create.ts), where a hook installed late is a hook that never fires.
+ */
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { dirname, join } from 'node:path'
+import { env } from '../../config/env.js'
+import type { HookSettings } from '../facets/hooks.js'
+import { command, HOOK_SCRIPT, isOurs, writeJsonAtomic, type Settings } from './notifyHooks.js'
+
+/** The engines whose hooks run the notify.mjs command. */
+export type HookEngine = Parameters<typeof command>[1]
+
+/** The home an engine's settings are in when core names none. */
+export function defaultHookHome(settings: HookSettings): string {
+ return 'setting' in settings.home ? env[settings.home.setting] : join(homedir(), settings.home.inHome)
+}
+
+export function installHookSettings(engine: HookEngine, settings: HookSettings, port: number, home: string = defaultHookHome(settings)): void {
+ const file = join(home, settings.file)
+ const say = (line: string): string => line.replace(/\{(file|script|port)\}/g, (_, name: string) =>
+ name === 'file' ? file : name === 'script' ? HOOK_SCRIPT : String(port))
+ const { messages } = settings
+ let current: Settings = {}
+ if (settings.unreadable === 'replace') {
+ try {
+ current = JSON.parse(readFileSync(file, 'utf-8')) as Settings
+ } catch {
+ // missing / unreadable → start from empty settings
+ }
+ } else if (existsSync(file)) {
+ try {
+ current = JSON.parse(readFileSync(file, 'utf-8')) as Settings
+ } catch {
+ for (const line of messages.malformed ?? []) console.error(say(line))
+ return
+ }
+ }
+
+ if (!current.hooks || typeof current.hooks !== 'object') current.hooks = {}
+ const cmd = command(port, engine, settings.commandNamesHome ? home : undefined)
+ let changed = false
+ let updated = false // true when an EXISTING block's command changed (path/port drift)
+
+ for (const { event, matcher } of settings.events) {
+ const blocks = Array.isArray(current.hooks[event]) ? current.hooks[event] : []
+ // Collapse any duplicate "ours" blocks (e.g. from an earlier path) down to a single one, and keep every
+ // non-ours block untouched.
+ const foreign = blocks.filter((b) => !isOurs(b))
+ const ours = blocks.filter(isOurs)
+ if (ours.length !== 1) changed = true // none yet, or duplicates to drop
+ const existing = ours[0]
+ if (existing) {
+ // A prior block with a different command (moved checkout / dev↔dist / changed port / interpreter) is
+ // overwritten in place by the canonical one below.
+ const existingCmd = settings.upToDate.command === 'first-ours'
+ ? existing.hooks?.find((h) => isOurs({ hooks: [h] }))?.command
+ : existing.hooks?.[0]?.command
+ if (existingCmd !== cmd) { changed = true; updated = true }
+ if (settings.upToDate.matcher && existing.matcher !== matcher) changed = true
+ }
+ current.hooks[event] = [...foreign, { ...(matcher ? { matcher } : {}), hooks: [{ type: 'command', command: cmd, timeout: settings.timeout }] }]
+ }
+
+ if (!changed) {
+ console.log(say(messages.current))
+ return
+ }
+
+ try {
+ if (settings.write === 'atomic') writeJsonAtomic(file, current)
+ else {
+ mkdirSync(dirname(file), { recursive: true })
+ writeFileSync(file, JSON.stringify(current, null, 2) + '\n')
+ }
+ console.log(say(updated && messages.updated ? messages.updated : messages.installed))
+ console.log(say(messages.after))
+ } catch (err) {
+ console.error(say(messages.failed), err)
+ }
+}
diff --git a/cli/src/engines/claude/hooks.ts b/cli/src/engines/kit/stopHook.ts
similarity index 67%
rename from cli/src/engines/claude/hooks.ts
rename to cli/src/engines/kit/stopHook.ts
index 84bb7a334..8fd73afe2 100644
--- a/cli/src/engines/claude/hooks.ts
+++ b/cli/src/engines/kit/stopHook.ts
@@ -1,29 +1,15 @@
-import { existsSync } from 'node:fs'
-import { basename, join } from 'node:path'
-import { sid } from '../../lib/log.js'
-import type { LiveTurn } from '../facets/live.js'
-import type { EngineHooks, HookSession, HookStop, HookTurnContext } from '../facets/hooks.js'
-import { installSessionHooks } from './installHooks.js'
-
/**
- * `claude --resume` from a folder other than the conversation's own: Claude Code announces a transcript
- * under the CURRENT cwd's project dir, then keeps writing the original file (measured: a resume of
- * 73f090ca from `cli/` announced `…-openharness-cli/73f090ca.jsonl`, and every later turn still landed
- * in `…-openharness/73f090ca.jsonl`). The announced file never appears, the hook is dropped, and the
- * resume is never confirmed — "Start failed" over a pane that is working. The row being resumed already
- * knows the real file; take it when it names this very conversation.
+ * What a Stop or StopFailure hook means for an engine whose contract says its Stop closes turns
+ * (facets/hooks.ts `stopClosesTurns`): Claude Code's. Turn mechanics only, on core's immutable turn
+ * snapshots and its atomic close (core/turns/turnHooks.ts), so it runs in core with no engine code. Moved
+ * from engines/claude/hooks.ts.
*/
-export function transcriptFor(body: HookSession, agent: HookSession | undefined): string | undefined {
- const announced = body.transcriptPath ?? undefined
- if (!announced || existsSync(announced)) return announced
- const known = agent?.transcriptPath
- if (!known || !body.sessionId || agent.sessionId !== body.sessionId) return announced
- if (basename(known) !== `${body.sessionId}.jsonl` || !existsSync(known)) return announced
- return known
-}
+import { sid } from '../../lib/log.js'
+import type { HookStop, HookTurnContext } from '../facets/hooks.js'
+import type { LiveTurn } from '../facets/live.js'
/** Capture the arrival's turn before the first await: a drain can open the next turn. */
-async function onStop(
+export async function closeTurnOnStop(
{ turnState, closeTurn, latestPromptAt, drain, noteEngineStopped, emit, graceMs }: HookTurnContext,
{ sessionId, status, firedAt }: HookStop,
): Promise<void> {
@@ -61,10 +47,3 @@ async function onStop(
emit(sessionId, [{ type: 'turn_ended', payload: {} }])
}
}
-
-export const hooks: EngineHooks = {
- install: installSessionHooks,
- installIn: (port, home) => installSessionHooks(port, join(home, 'settings.json')),
- transcriptFor,
- onStop,
-}
diff --git a/cli/src/engines/registry.ts b/cli/src/engines/registry.ts
index e5baa7a07..fc5d0da65 100644
--- a/cli/src/engines/registry.ts
+++ b/cli/src/engines/registry.ts
@@ -9,7 +9,7 @@ import { modelControl as codexModelControl } from './codex/modelControl.js'
import { screen as codexScreen } from './codex/screen.js'
import type { Engine } from './engine.js'
import { engineLaunches } from './launches.js'
-import { engineHooks } from './hooks.js'
+import { hookContracts } from './hooks.js'
import { transcript as claudeTranscript } from './claude/transcript.js'
import { transcript as codexTranscript } from './codex/transcript.js'
import { live as claudeLive } from './claude/live.js'
@@ -19,8 +19,8 @@ import { runtime as codexRuntime } from './codex/runtimeProfile.js'
/** Only the migrated engines. Others keep their existing handlers until their own small batch. */
const engines = {
- claude: { name: 'claude', launch: engineLaunches.claude, transcript: claudeTranscript, hooks: engineHooks.claude, live: claudeLive, runtime: claudeRuntime, screen: claudeScreen, modelControl: claudeModelControl, questionControl: claudeQuestionControl, submission: claudeSubmission },
- codex: { name: 'codex', launch: engineLaunches.codex, transcript: codexTranscript, hooks: engineHooks.codex, live: codexLive, runtime: codexRuntime, screen: codexScreen, modelControl: codexModelControl, questionControl: codexQuestionControl, submission: codexSubmission, nativeControl: codexNativeControl },
+ claude: { name: 'claude', launch: engineLaunches.claude, transcript: claudeTranscript, hooks: hookContracts.claude, live: claudeLive, runtime: claudeRuntime, screen: claudeScreen, modelControl: claudeModelControl, questionControl: claudeQuestionControl, submission: claudeSubmission },
+ codex: { name: 'codex', launch: engineLaunches.codex, transcript: codexTranscript, hooks: hookContracts.codex, live: codexLive, runtime: codexRuntime, screen: codexScreen, modelControl: codexModelControl, questionControl: codexQuestionControl, submission: codexSubmission, nativeControl: codexNativeControl },
} satisfies Record<string, Engine>
type MigratedEngine = keyof typeof engines
export function engineFor(name: string | null | undefined): Engine | undefined {
diff --git a/cli/src/lib/hooks.spec.ts b/cli/src/lib/hooks.spec.ts
index 2e2288431..90a7991c4 100644
--- a/cli/src/lib/hooks.spec.ts
+++ b/cli/src/lib/hooks.spec.ts
@@ -18,7 +18,9 @@ async function loadHooks() {
process.env.HERMES_HOME = hermesHome
process.env.COMMANDCODE_HOME = commandcodeHome
process.env.DEVIN_CONFIG_PATH = devinConfigPath
- return import('./hooks.js')
+ // Claude Code's and Codex's installers are their declared hook settings, applied by the kit (engines/hooks.ts).
+ const [hooks, { engineHooks }] = await Promise.all([import('./hooks.js'), import('../engines/hooks.js')])
+ return { ...hooks, claude: engineHooks.claude, codex: engineHooks.codex }
}
describe('Codex hook installation', () => {
@@ -48,8 +50,8 @@ describe('Codex hook installation', () => {
const script = process.argv[1]
process.argv[1] = join(cliDir, 'cli.js')
try {
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(19473)
+ const { codex } = await loadHooks()
+ codex.install(19473)
expect(readFileSync(join(codexHome, 'hooks.json'), 'utf-8')).toContain(join(cliDir, 'notify.mjs'))
} finally {
process.argv[1] = script
@@ -67,8 +69,8 @@ describe('Codex hook installation', () => {
},
}))
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(19473)
+ const { codex } = await loadHooks()
+ codex.install(19473)
const first = readFileSync(file, 'utf-8')
const parsed = JSON.parse(first)
@@ -79,15 +81,15 @@ describe('Codex hook installation', () => {
expect(parsed.hooks.UserPromptSubmit[1]).not.toHaveProperty('matcher')
expect(parsed.hooks.UserPromptSubmit[1].hooks[0].command).toContain('--engine codex')
- installCodexHooks(19473)
+ codex.install(19473)
expect(readFileSync(file, 'utf-8')).toBe(first)
})
it('installs into a custom CODEX_HOME profile, with a matching --codex-home baked in', async () => {
const customProfile = mkdtempSync(join(tmpdir(), 'adapter-codex-profile-'))
try {
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(19473, customProfile)
+ const { codex } = await loadHooks()
+ codex.installIn(19473, customProfile)
const profileFile = join(customProfile, 'hooks.json')
const first = readFileSync(profileFile, 'utf-8')
@@ -99,7 +101,7 @@ describe('Codex hook installation', () => {
expect(existsSync(join(codexHome, 'hooks.json'))).toBe(false)
// Idempotent: a second install into the same profile is a no-op.
- installCodexHooks(19473, customProfile)
+ codex.installIn(19473, customProfile)
expect(readFileSync(profileFile, 'utf-8')).toBe(first)
} finally {
rmSync(customProfile, { recursive: true, force: true })
@@ -110,8 +112,8 @@ describe('Codex hook installation', () => {
const file = join(codexHome, 'hooks.json')
writeFileSync(file, '{not-json')
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(19473)
+ const { codex } = await loadHooks()
+ codex.install(19473)
expect(readFileSync(file, 'utf-8')).toBe('{not-json')
expect(existsSync(`${file}.${process.pid}.tmp`)).toBe(false)
@@ -502,8 +504,8 @@ describe('the Node interpreter baked into hook commands', () => {
it('names an absolute, runnable interpreter and never the bare word node', async () => {
const file = join(codexHome, 'hooks.json')
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(18473)
+ const { codex } = await loadHooks()
+ codex.install(18473)
const out = JSON.parse(readFileSync(file, 'utf8')) as { hooks: Record<string, Array<{ hooks: Array<{ command: string }> }>> }
const command = out.hooks.SessionStart[0].hooks[0].command
@@ -524,8 +526,8 @@ describe('the Node interpreter baked into hook commands', () => {
process.env.ADAPTER_RUNTIME_DIR = runtimeDir
const file = join(codexHome, 'hooks.json')
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(18473)
+ const { codex } = await loadHooks()
+ codex.install(18473)
const out = JSON.parse(readFileSync(file, 'utf8')) as { hooks: Record<string, Array<{ hooks: Array<{ command: string }> }>> }
expect(interpreterOf(out.hooks.SessionStart[0].hooks[0].command)).toBe(upgraded)
@@ -536,8 +538,8 @@ describe('the Node interpreter baked into hook commands', () => {
process.env.ADAPTER_RUNTIME_DIR = runtimeDir
const file = join(codexHome, 'hooks.json')
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(18473)
+ const { codex } = await loadHooks()
+ codex.install(18473)
const out = JSON.parse(readFileSync(file, 'utf8')) as { hooks: Record<string, Array<{ hooks: Array<{ command: string }> }>> }
// A hook naming an interpreter that cannot run is strictly worse than one naming the interpreter
@@ -550,8 +552,8 @@ describe('the Node interpreter baked into hook commands', () => {
process.env.ADAPTER_RUNTIME_DIR = runtimeDir
const file = join(codexHome, 'hooks.json')
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(18473)
+ const { codex } = await loadHooks()
+ codex.install(18473)
const out = JSON.parse(readFileSync(file, 'utf8')) as { hooks: Record<string, Array<{ hooks: Array<{ command: string }> }>> }
expect(interpreterOf(out.hooks.SessionStart[0].hooks[0].command)).toBe(process.execPath)
@@ -568,8 +570,8 @@ describe('the Node interpreter baked into hook commands', () => {
},
}))
- const { installCodexHooks } = await loadHooks()
- installCodexHooks(18473)
+ const { codex } = await loadHooks()
+ codex.install(18473)
const out = JSON.parse(readFileSync(file, 'utf8')) as { hooks: Record<string, Array<{ hooks: Array<{ command: string }> }>> }
const commands = out.hooks.SessionStart.flatMap((block) => block.hooks.map((h) => h.command))
@@ -631,14 +633,14 @@ describe('Claude Code hooks in a moved home', () => {
const file = join(home, 'work', 'settings.json')
mkdirSync(join(home, 'work'), { recursive: true })
writeFileSync(file, JSON.stringify({ model: 'opus', hooks: { Stop: [{ hooks: [{ type: 'command', command: 'say done' }] }] } }))
- const { installSessionHooks } = await loadHooks()
- installSessionHooks(19473, file)
+ const { claude } = await loadHooks()
+ claude.installIn(19473, join(home, 'work'))
const first = readFileSync(file, 'utf-8')
const settings = JSON.parse(first)
expect(settings.model).toBe('opus')
expect(settings.hooks.SessionStart[0].hooks[0].command).toContain('notify.mjs')
expect(settings.hooks.Stop.map((block: { hooks: Array<{ command: string }> }) => block.hooks[0].command)).toEqual(['say done', expect.stringContaining('notify.mjs')])
- installSessionHooks(19473, file)
+ claude.installIn(19473, join(home, 'work'))
expect(readFileSync(file, 'utf-8')).toBe(first)
})
})
diff --git a/cli/src/lib/hooks.ts b/cli/src/lib/hooks.ts
index 8fec3f352..7760e68dd 100644
--- a/cli/src/lib/hooks.ts
+++ b/cli/src/lib/hooks.ts
@@ -8,8 +8,6 @@ import { VERSION } from '../version.js'
import { hermesConfigHomes } from '../engines/hermes/home.js'
import { opencodeMajorVersion } from '../engines/opencode/version.js'
import { command, isOurs, writeJsonAtomic, type HookBlock, type Settings } from '../engines/kit/notifyHooks.js'
-export { installSessionHooks } from '../engines/claude/installHooks.js'
-export { installCodexHooks } from '../engines/codex/installHooks.js'
const GROK_HOOKS_PATH = join(env.GROK_HOME, 'hooks', 'harness.json')
const CURSOR_HOOKS_PATH = join(cursorConfigDir(), 'hooks.json')
@@ -353,9 +351,10 @@ const COMMANDCODE_EVENTS = ['SessionStart', 'PreToolUse', 'Stop'] as const
/**
* Command Code's hook file is `~/.commandcode/settings.json` with the SAME nested `matcher`/`hooks`
- * schema as `~/.claude/settings.json`, so this mirrors installSessionHooks — including its dedup
- * discipline: every "ours" block (any command mentioning notify.mjs, whatever its old path/port) is
- * collapsed into exactly one canonical entry, and foreign blocks are preserved untouched.
+ * schema as `~/.claude/settings.json`, so this mirrors Claude Code's hook settings
+ * (engines/claude/hookContract.ts) — including its dedup discipline: every "ours" block (any command
+ * mentioning notify.mjs, whatever its old path/port) is collapsed into exactly one canonical entry, and
+ * foreign blocks are preserved untouched.
*/
export function installCommandCodeHooks(port: number): void {
let settings: Settings = {}
@@ -393,11 +392,12 @@ export function installCommandCodeHooks(port: number): void {
}
// Devin reads Claude's hook schema verbatim (its binary parses `ClaudeHookConfig`/`ClaudeHookMatcherConfig`),
-// so the only differences from installSessionHooks are the file and that hooks nest under a "hooks" key of
-// the user's general config — which also holds `devin.org_id`, `theme_mode`, etc, so this MERGES and never
-// rewrites the file wholesale. Verified live: SessionStart/UserPromptSubmit/Stop all fire with
-// `$TMUX_PANE` intact; the payload carries {hook_event_name, session_id, prompt_id, prompt, source} but
-// NO transcript_path and NO cwd (notify.mjs derives cwd from its own process).
+// so the only differences from Claude Code's hook settings (engines/claude/hookContract.ts) are the file and
+// that hooks nest under a "hooks" key of the user's general config — which also holds `devin.org_id`,
+// `theme_mode`, etc, so this MERGES and never rewrites the file wholesale. Verified live:
+// SessionStart/UserPromptSubmit/Stop all fire with `$TMUX_PANE` intact; the payload carries
+// {hook_event_name, session_id, prompt_id, prompt, source} but NO transcript_path and NO cwd (notify.mjs
+// derives cwd from its own process).
const DEVIN_EVENTS = ['SessionStart', 'UserPromptSubmit', 'Stop', 'SessionEnd'] as const
export function installDevinHooks(port: number): void {
diff --git a/cli/src/lib/registry.spec.ts b/cli/src/lib/registry.spec.ts
index c207d54dc..d92274bd0 100644
--- a/cli/src/lib/registry.spec.ts
+++ b/cli/src/lib/registry.spec.ts
@@ -1433,6 +1433,33 @@ describe('agent identity: the process owns the agent, the session is bound to it
}
})
+ it('never registers a delegated Codex session, agreeing with the hook server\'s admission', async () => {
+ const { registry } = await loadRegistryModule()
+ const { admitHook } = await import('../engines/hooks.js')
+ registry.load()
+ const profile = mkdtempSync(join(tmpdir(), 'adapter-codex-profile-'))
+ try {
+ registry.openPendingAgent({ engine: 'codex', runtimes: [{ backend: 'tmux', paneId: '%10' }], cwd: '/tmp/demo', codexHome: profile })
+ const rollout = (id: string, source: unknown): string => {
+ const file = join(profile, 'sessions', `rollout-${id}.jsonl`)
+ mkdirSync(join(file, '..'), { recursive: true })
+ writeFileSync(file, JSON.stringify({ type: 'session_meta', payload: { id, source } }) + '\n')
+ return file
+ }
+ const register = (sessionId: string, transcriptPath: string) => registry.register({
+ engine: 'codex', sessionId, transcriptPath, tmuxPane: '%10', cwd: '/tmp/demo', processIdentity: processIdentity(910),
+ })
+ const child = rollout('child', { subagent: { thread_spawn: { parent_thread_id: 'parent', depth: 1 } } })
+ expect(admitHook('codex', { transcriptPath: child })).toEqual({ accepted: false, reason: 'codex_subagent' })
+ expect(register('child', child)).toBeNull()
+ const parent = rollout('parent', 'cli')
+ expect(admitHook('codex', { transcriptPath: parent })).toEqual({ accepted: true })
+ expect(register('parent', parent)?.entry.sessionId).toBe('parent')
+ } finally {
+ rmSync(profile, { recursive: true, force: true })
+ }
+ })
+
it('keeps a name given before the agent had a session', async () => {
// Names live under the ENGINE session id — that is what survives the launcher and comes back on a
// resume, since the agent id is minted fresh each launch. An agent renamed while still unbound has
diff --git a/cli/src/lib/registry.ts b/cli/src/lib/registry.ts
index 478710d68..3be2fd093 100644
--- a/cli/src/lib/registry.ts
+++ b/cli/src/lib/registry.ts
@@ -42,6 +42,7 @@ import { cursorDataDir } from '../engines/cursor/home.js'
import { env } from '../config/env.js'
import { claudeProjectsRoots, codexHomeRoots, sessionCodexHome } from './engineHomes.js'
import { readCodexRolloutMeta, resolveCodexRollout } from '../engines/codex/rollout.js'
+import { admitHook } from '../engines/hooks.js'
import { ENGINES, isTerminalEngine, type AgentEngine } from '../engines/types.js'
import type { GridAssignment } from './gridAssignment.js'
import { parseGridLaunchOverride, type GridLaunchOverride, type GridLaunchRecord, type GridWebSearchStatus } from './gridLaunch.js'
@@ -1514,7 +1515,9 @@ class Registry {
// CODEX_HOME profile, if it has one other than the default — see RegisteredSession.codexHome.
|| (transcriptPath && !validTranscriptPath(engine, transcriptPath, processAgent?.codexHome ?? undefined))
) return null
- if (engine === 'codex' && transcriptPath && readCodexRolloutMeta(transcriptPath)?.isSubagent) return null
+ // A delegated session is never registered, by any caller: the same admission the hook server asks before
+ // it credits a prompt (hookServer.ts), so that the two can never disagree.
+ if (transcriptPath && !admitHook(engine, { transcriptPath }).accepted) return null
const now = Date.now()
const existing = this.agents.get(agentId)
diff --git a/cli/src/startupOrder.spec.ts b/cli/src/startupOrder.spec.ts
index be734f9a9..f8d5e750a 100644
--- a/cli/src/startupOrder.spec.ts
+++ b/cli/src/startupOrder.spec.ts
@@ -113,7 +113,7 @@ describe('the core\'s start-up order (core/main.ts)', () => {
for (const risky of [
'requireTmuxAvailable(', // throws outright when tmux is missing
'await startHookServer(', // EADDRINUSE on a fixed port with no fallback
- 'installSessionHooks(', // 13 vendor settings files, any of which can be unreadable
+ 'installEngineHooks(', // 13 vendor settings files, any of which can be unreadable
'await restoreAgents({', // tmux, the registry, and the closures a bad edit puts in a dead zone
'await agentReconciler.start(',
'loadCursorPendingTasks(', // a file lock that can hang, not just throw
diff --git a/docs/design/2026-10-08-engine-hooks.md b/docs/design/2026-10-08-engine-hooks.md
new file mode 100644
index 000000000..1d4a7c147
--- /dev/null
+++ b/docs/design/2026-10-08-engine-hooks.md
@@ -0,0 +1,73 @@
+# Engine hooks
+
+Claude Code's and Codex's hook code has left the core. Each engine now declares its hooks as data
+(`Engine.hooks`, `engines/{claude,codex}/hookContract.ts`), and shared mechanics in `engines/kit` apply
+them. Core still evaluates all of it in line and synchronously, as before. Nothing moved into a worker.
+Hooks are how sessions bind and turns close, and the (d) review ruled that session control never
+depends on an engine worker.
+
+## What moved
+
+| Was | Now |
+| --- | --- |
+| `engines/claude/installHooks.ts`, `engines/codex/installHooks.ts` | `HookContract.settings`: the home and file, the events and matchers, the timeout, what an unreadable file means, the write mode, when a block of ours is up to date, and the log lines. One installer applies it: `engines/kit/hookSettings.ts`. |
+| `engines/codex/hooks.ts` `admit`, through `readCodexRolloutMeta` | `HookContract.children`: the first record's type (`session_meta`), the field that marks a child (`payload.source.subagent`) and the reason (`codex_subagent`). `kit/hookRules.ts` `isChildSession` reads at most 128 KiB, the rollout reader's bound. |
+| `engines/claude/hooks.ts` `transcriptFor` | `HookContract.sessionFile` (`<sessionId>.jsonl`) and `kit/hookRules.ts` `knownTranscript` |
+| `engines/claude/hooks.ts` `onStop` | `kit/stopHook.ts` `closeTurnOnStop`, for a contract with `stopClosesTurns`. The `/goal` flag stays `LiveTurn.continued`. |
+
+`engines/hooks.ts` composes what core calls (`EngineHooks`: `install`, `installIn`, `transcriptFor`,
+`admit`, `onStop`) from each contract. Its callers are unchanged. Core keeps authoring the command
+(`kit/notifyHooks.ts`).
+
+## When each part runs
+
+- **Installation:** at daemon start, for the default homes and every home the person moved
+ (`core/engines/hooks.ts`), and before a Codex agent starts in a profile of its own
+ (`core/agents/create.ts`, relaunch overrides). It is synchronous: a hook installed late never fires.
+- **Admission:** on the hook server, before `onPromptSubmitted` and before registering. So a delegated
+ session's prompt is never credited to its parent's pane. `registry.register` asks the same
+ `admitHook` again, so the two cannot disagree. A check that throws refuses the hook.
+- **Transcript correction:** synchronous on the hook path (`hookServer.ts` `knownTranscriptFor`).
+- **Stop:** `core/turns/turnHooks.ts`. Codex declares no Stop rule and closes turns through its transcript.
+
+## The same bytes
+
+The two installers differed in ways that reach a person's own settings. The contract carries each
+difference:
+
+| | Claude Code | Codex |
+| --- | --- | --- |
+| Default home | `~/.claude` | `CODEX_HOME` |
+| A file that cannot be read or parsed | starts from empty settings and replaces it | is left alone, with two log lines |
+| Write | in place: through a symlink, keeping the mode | atomic: renames a new file over it, which replaces a symlink and takes mode 0644 |
+| A block of ours is up to date when | its first notify.mjs hook runs the current command | it is the only one, its first hook runs the current command, and its matcher is the declared one |
+| The command names the home | no | yes (`--codex-home`) |
+
+**Proof.** `engines/hookInstallers.golden.spec.ts` was recorded from the former installers, in the commit
+before this change. It covers 43 states each file can be in: none, empty, malformed, foreign hooks
+only, our old hook, ours current, duplicates, mixed, symlinked, dangling, read-only, unreadable,
+private, a folder, and a leftover temporary file. Each installs twice through `installIn`, and 7 of them
+through the default home too. It keeps every file's bytes, mode and symlink, the log lines and what
+threw. It passes unchanged against the kit. So does a seeded run, not committed, of 500 generated files
+per engine through both entry points, recorded from the former installers the same way. Flipping any one
+of the differences in the table above fails it.
+
+**Kept as they were, not fixed here:**
+- Claude Code replaces a settings file it cannot read or parse, the person's other settings with it.
+- A settings file holding JSON `null` or a scalar throws. `installEngineHooks` catches it per engine.
+- Codex's atomic write replaces a read-only `hooks.json` and a symlink.
+
+## Core closure (esbuild, `core/main.ts`, dynamic imports external)
+
+| | Lines | Files |
+| --- | --- | --- |
+| Before (after #1043) | 72,963 | 387 |
+| After | 73,056 | 388 |
+
+**Left:** the four hook files of `engines/{claude,codex}`, 212 lines. **Came in:** the two contracts
+(72 lines of data) and three kit modules (202 lines). `engines/codex/rollout.ts` stays in the closure
+through the registry's load-time repair and session repair, both batch (c).
+
+`architecture.spec.ts` lists `engines/{claude,codex}/{hooks,installHooks}.ts` as edge files. It also
+checks the closures of the hook lookup, the three kit modules and `core/turns/turnHooks.ts`: they reach
+no Claude Code or Codex file but the two contracts.
diff --git a/docs/design/2026-10-08-engine-remaining-facets.md b/docs/design/2026-10-08-engine-remaining-facets.md
index 6eac101bd..b174971f1 100644
--- a/docs/design/2026-10-08-engine-remaining-facets.md
+++ b/docs/design/2026-10-08-engine-remaining-facets.md
@@ -26,7 +26,11 @@ Still in core and engine-specific, as data or copy: `engines/{claude,codex}/subm
`lib/goalCommand.ts` (`/goal` and `/loop` adaptation, synchronous on the input path). The tmux paste
settle in `lib/tmux.ts` is the writer's own and stays in core.
-## (b) Hook admission and installers
+## (b) Hook admission and installers: done in the batch after (d)
+
+See [engine hooks](2026-10-08-engine-hooks.md). Nothing moved into a worker: the engines' hook code left
+the core, replaced by declared contracts and `engines/kit` mechanics that core runs in line. The map below
+is as it stood before it.
| File | Engine-specific behavior | Stays in core | Can move | Risk |
| --- | --- | --- | --- | --- |
@@ -80,9 +84,30 @@ About 220 lines would leave, and with them core's only native child process and
2. **(d) Native control connections.** The smallest and fully async. It removes a native child process
and a long-lived socket from core, the kind of work that crashes, hangs or leaks. It reuses the
control-grant pattern of model and question control.
-3. **(b) Hook admission and installers.** The installers become worker operations that core awaits
- before it spawns or binds the hook port. Admission needs a bounded async path, or a declarative rule
- core can evaluate in line, so a worker that is down does not reject every hook.
+3. **(b) Hook admission and installers.** Done: see [engine hooks](2026-10-08-engine-hooks.md). Revised after the (d) review, which ruled that session control
+ must not depend on an engine worker. Hooks are how sessions bind and turns close, so every part of
+ this batch stays worker-free. The engines' code leaves the core; declared data and shared kit
+ mechanics replace it, the way the stop's ownership rules did in (d):
+ - **Installers.** `engines/{claude,codex}/installHooks.ts` become declared hook settings in each
+ engine's hooks contract: the file in the home, the events and matchers, the timeout, and what to do
+ with a malformed file (Claude starts empty; Codex leaves it untouched). One kit installer applies
+ them, synchronously, at daemon start and before a spawn, as today. Core keeps authoring the
+ command (`kit/notifyHooks.ts`). The risk is byte-identical output: the two installers detect drift
+ and write slightly differently today (plain versus atomic write, which hook counts as ours). The
+ contract must carry those differences, or fixtures must prove them equal.
+ - **Admission.** Codex's subagent rule (`engines/codex/hooks.ts` `admit`) must still run before
+ `onPromptSubmitted`, or a delegated session's prompt is credited to its parent's pane. It reads the
+ rollout's first record, and `registry.register` repeats the same read. It becomes a declared rule
+ that core evaluates in line: the first record's type, plus the field whose presence marks a child.
+ The read stays bounded at 128 KB. Alternatively it stays a (c) item with the registry's copy.
+ - **Claude's transcript correction** (`transcriptFor`, synchronous on the hook path) becomes declared
+ naming (`<sessionId>.jsonl`) plus a kit rule.
+ - **Claude's Stop rule** (`onStop`) is engine-neutral turn mechanics, apart from the `continued`
+ (`/goal`) flag, which is already a `LiveTurn` field. It moves to `engines/kit`, and Claude's contract
+ declares that its Stop hook closes turns.
+
+ With this approach nothing moves into a worker. About 230 lines of Claude/Codex code leave the core
+ closure, and a few dozen lines of declared data come in.
4. **(c) Launch, discovery and resume.** The largest. It has the most synchronous call sites (registry
load, discovery tables, argv). Split it into sub-batches:
- resume preparation and trust writes (async callers, before spawn)