Repository navigation
fix(hooks): remove the payload file a background hook hands over - #1813
Conversation
|
No findings in the specified PR diff. The description satisfies the testing requirement: it records a representative real-CLI reproduction on Review was read-only; I did not run, build, or install PR code. |
Reviewed at
One point before I approve:
Also, CI is still running at this head. |
A Windows hook writes its payload to a temp file for the child it starts through WMI, and only the read path removed it. A child that returned early, and a parent killed before it started one, left the full payload — tool input and output — in %TEMP% for good. The dispatch now removes it on every exit, and a background pass sweeps payload files an earlier one left behind. Refs Tencent#1812
20ccd00 to
95152bb
Compare
|
Both points are addressed in
Windows CI still does not run |
|
No findings in the specified PR diff. The description satisfies the testing requirement: it records a representative real-CLI reproduction on The earlier review raised no findings, so none require resolution. Review was read-only; I did not run, build, or install PR code. |
SaulMoro
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Re-checked at 95152bb8. The payload point is fixed: readStdinFile removes the file again as soon as it reads it, and the finally in hookDispatchCli now only covers the exits that never reach the read, through the same removeStdinFile. The new case checks that the file is already gone while the handlers run, which is the behaviour main had and the earlier head lost. The sweep, its Windows-only guard and the CHANGELOG entry are unchanged from my previous run.
Not run here: the Windows spawn path and the sweep on real Windows. This test file is also outside the Windows CI subset.
Approving. I'll merge once CI is green at this head.
Summary
hook-dispatchthat runs with--stdin-fileremoves that file as soon as it reads it, and on the exits that never read it: a session teamai launched for itself (judge, scorer, recall-promote, codebase), and a host where Cursor or Copilot CLI has its own hooks. A background pass therefore holds the payload no longer thanmaindid.--bg-onlypass sweepsteamai-hook-*.jsonfiles older than ten minutes in its temp directory. That covers the other leak: the parent writes the payload, is killed by the host's hard-exit timer or job object, and never starts the child that would have removed it.Refs #1812. Fixes #1812.
Validation
npm run build— passesnpm run typecheck— passesnpm run lint— passes, including the documentation checksnpx vitest run src/__tests__/hook-dispatch-cli.test.ts src/__tests__/hook-dispatch.test.ts src/__tests__/hook-fast-path.test.ts src/__tests__/dashboard-report-scope.test.ts src/__tests__/git-hook.test.ts— 246/246 passProof first: the early-return case fails on
mainfor the reason the issue gives.Of those three, two are the sweep cases, which fail on
mainonly because the function does not exist there. The read-time case went the other way:mainremoved the file at the read, the first head of this branch moved that removal to the outermostfinally, and the new caseremoves the payload file as soon as it has read itfailed on that head (expected true to be false) until the removal went back beside the read, with the outerfinallykept for the exits that never read.Real-CLI run
A pair of worlds, same command in each, on this macOS host. The issue's failing path is reproduced against
mainand gone against the branch.World from
main(b8c811db0cfe+dirty, teamai 0.22.0, sha2563ee52079161f) — the+dirtyis this worktree's untrackednode_modulessymlink; the tree is otherwiseorigin/main:FAILED: the payload file is still there, as the issue describes.
World from the branch (
95152bb8a0c4+dirty, teamai 0.22.0, sha256307d54b65078) — samenode_modulescaveat:VERIFIED: the file is gone, exit 0, and the dispatch still returns early for a launcher session.
npm run -s verify -- ledger 20261110T081458-c2ede5ends withLedger: CLEAN.Limitations
platform: 'win32'and by the macOS check that it leaves the directory alone; Windows CI runs a subset of the tests, andsrc/hook-dispatch-cli.tsis not in it.--stdin-fileis internal to the Windows spawn path, and every host reaches the same dispatch.