docs(hooks-claude): current-state comment wording caught in review
Two Codex nitpicks, comment-only (no behavior change): - the SubagentStop-cwd regression test comment narrated "The bug" / "Proven to regress" — rewrote to state the invariant it checks, not the history. - the subagent/end listener comment said "no session is passed"; with a child a session IS passed — corrected to "no `turn` is passed (so no hook/* records)", which is the actual reason runPoint has nothing that can reject.
This commit is contained in:
@@ -290,8 +290,9 @@ export function apply(ctx: Context, config: Config): void {
|
|||||||
// Look up the child (still recoverable: `subagent/end` fires from the
|
// Look up the child (still recoverable: `subagent/end` fires from the
|
||||||
// service's detached `.then` BEFORE the tool caller's `await run.result`
|
// service's detached `.then` BEFORE the tool caller's `await run.result`
|
||||||
// disposes it) so the hook runs in the child's cwd, not the server default.
|
// disposes it) so the hook runs in the child's cwd, not the server default.
|
||||||
// No `.then`/inject (SubagentStop only observes) and no session is passed, so
|
// No `.then`/inject follows (SubagentStop only observes), and no `turn` is
|
||||||
// runPoint cannot reject — no `.catch` is needed. Fire-and-forget.
|
// passed (so no `hook/*` log records), so runPoint has nothing that can
|
||||||
|
// reject — no `.catch` is needed. Fire-and-forget.
|
||||||
const child = ctx.get('agents')?.get(info.id)
|
const child = ctx.get('agents')?.get(info.id)
|
||||||
void runPoint('SubagentStop', SUBAGENT_TYPE, subagentPayload('SubagentStop', info, child), { ...child ? { agent: child } : {} })
|
void runPoint('SubagentStop', SUBAGENT_TYPE, subagentPayload('SubagentStop', info, child), { ...child ? { agent: child } : {} })
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -493,13 +493,11 @@ describe('hooks-claude coverage — hook runs in the session cwd, not the server
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('runs a SubagentStop hook in the CHILD session workspace, not the server cwd', async () => {
|
it('runs a SubagentStop hook in the CHILD session workspace, not the server cwd', async () => {
|
||||||
// The bug: SubagentStop ran runPoint(..., {}) with no agent, so the hook fell
|
// SubagentStop looks the child up (recoverable at subagent/end) and runs the
|
||||||
// back to the executor default (server cwd). SubagentStop must look the child
|
// hook in the CHILD's session cwd, not the executor default. Here the executor
|
||||||
// up (still recoverable at subagent/end) and run in the CHILD's session cwd.
|
// default and the child session cwd are DIFFERENT dirs; a SubagentStop hook
|
||||||
// Here the executor default and the child session cwd are DIFFERENT dirs; a
|
// writes `pwd` to a relative marker and we assert it landed in the CHILD dir —
|
||||||
// SubagentStop hook writes `pwd` to a marker and we assert it ran in the CHILD
|
// which only holds if the listener threaded the child agent into runPoint.
|
||||||
// dir. (Proven to regress: neuter the child lookup and the marker lands in the
|
|
||||||
// server dir instead.)
|
|
||||||
const serverDir = dir()
|
const serverDir = dir()
|
||||||
const childDir = dir()
|
const childDir = dir()
|
||||||
const marker = join(childDir, 'stopwhere')
|
const marker = join(childDir, 'stopwhere')
|
||||||
|
|||||||
Reference in New Issue
Block a user