Repository navigation
Conversation
86e3fd7 to
1a97966
Compare
Thanks for this. #1813 fixes the same issue (#1812) in the same file. It was opened earlier and is already in review, so only one of the two should land. I compared them so the choice is quick:
This PR's read-time removal is the part I asked #1813 to add. Its sweep should be limited to Windows, as #1813's is, and it needs a CHANGELOG entry. I'm leaving this PR open while the author of #1813 answers. @jeff-r2026 your call on this one: which of the two to keep, since they are the same fix for #1812. |
|
No findings in the specified PR diff. The PR description includes representative real-CLI verification of both cleanup paths, satisfying the review rules’ testing-record requirement. Windows WMI execution is explicitly untested; that spawn path is unchanged. I did not run, build, or install anything from the PR. |
#1813 is merged ( |
The Windows/WMI spawn path hands each hook payload to the detached child as teamai-hook-<pid>-<ms>.json because WMI has no stdin pipe. Only readStdinFile() removed it, so early returns before that read (launcher and another-host gates, errors) left the full payload in %TEMP% indefinitely; a parent killed before any child started did the same. Wrap the dispatch in a finally that always removes --stdin-file, and on Windows have every --bg-only child sweep teamai-hook-*.json files older than ten minutes so files orphaned by a dead parent are collected too. The sweep is Windows-only because the plain spawn paths pipe the payload and create no temp file. Fresh files are untouched, so a live sibling's payload survives. Cleanup errors are swallowed: a completed dispatch must not fail on cleanup. Fixes Tencent#1812 Co-Authored-By: Claude Code <noreply@anthropic.com>
1a97966 to
aec745b
Compare
|
Applied both points at aec745b:
On payload lifetime: the read-time removal in Tests at this head: #1813 is the earlier PR for the same issue and now has the read-time removal too. I am happy to close this one in favour of #1813 if you prefer the first-opened branch; there is no need to land both. |
|
Superseded by #1813, which merged to main as 531eb15 while this was under review. The merged fix has the same read-time removal, outer |
|
No findings in the specified PR diff. The earlier review also reported none, so there are no prior findings to mark resolved. The PR description documents representative real-CLI verification, satisfying the testing-record requirement. Windows integration is explicitly deferred; the WMI spawn path is unchanged. I did not run, build, or install anything from the PR. |
Summary
hook-dispatch's Windows/WMI spawn path writes each hook payload to%TEMP%\teamai-hook-<pid>-<ms>.json, because WMI has no stdin pipe. OnlyreadStdinFile()removed that file, so every early return before the read (the launcher gate, the another-host gate, or any error) left the full payload — prompts, tool input and output — on disk indefinitely. A parent killed before its detached child started leaked it the same way.This makes cleanup independent of the read:
hookDispatchClinow removes--stdin-filein afinally, and on Windows every--bg-onlychild sweepsteamai-hook-*.jsonfiles in the temp directory that are older than ten minutes, collecting files orphaned by a parent that died first. Fresh files are untouched, so a live sibling's payload is never swept. The sweep is Windows-only because the plain spawn paths pipe the payload and create no temp file. A CHANGELOG entry is included.Fixes #1812.
Type of Change
Test Plan
npx tsc --noEmitpasses (npm run typecheck).npm run lintpasses, including documentation checks.npx vitest run src/__tests__/hook-dispatch-cli.test.ts— 41 passed. New tests cover the early-return cleanup, that a cleanup failure cannot fail the dispatch, thatsweepStaleHookPayloadsremoves only oldteamai-hook-*.jsonfiles while keeping fresh and unrelated files, and that the sweep is skipped off Windows.hook-dispatch-cli,hook-dispatch-scope,recall-attribution,dashboard-report-scope,score-drain-stop,votes-scope— 6 files, 311 tests.npm run build(macOS,node dist/index.js):TEAMAI_LAUNCHED_BY=judge node dist/index.js hook-dispatch stop --tool claude --stdin-file <file>→ exit 0, file removed. This is the early-return path that previously left the file behind.teamai-hook-*.json(mtime 11 minutes old) inos.tmpdir()and ran the same background pass with--bg-only --stdin-file <fresh>→ exit 0, the fresh stdin file was removed, and the stale file remained, confirming the Windows-only gate on macOS.I could not exercise the Windows WMI spawn itself on this macOS host. That spawn path is unchanged. The sweep's removal behavior is covered by the unit test that supplies a temp directory directly; the Windows-only integration is left to Windows CI. Windows CI does not currently run
hook-dispatch-cli.test.ts.Related Issues
Fixes #1812.
Notes for Reviewers
teamai-hook-and ends with.json, and ignores every cleanup error, so it can never affect dispatch.finallyalso covers the normal path, wherereadStdinFile()already removed the file.fs.rmSync(..., { force: true })makes the second removal a no-op.🤖 Generated with Claude Code