fix(mcp): bound and cancel Windows code search - #1608
Conversation
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Maintainer decision: the cancellation fix is wanted, but it needs a bound in the same change. Real cancellation is a genuine improvement — today a cancelled Windows search keeps running, which is a bug. Moving onto the supervised subprocess path so cancel kills the tree and removes the temp file is the right shape. The problem is what it gives up. So a bound has to land with it. A byte ceiling on the temp file is the one to use, not a result cap: it bounds the resource without touching result semantics at all, so it cannot silently drop matches the way a producer-side row cap can (see my note on #1607 — we are not taking that, and Concretely: cap the temp file, and when the cap is hit, fail loudly rather than parsing a truncated file as if it were complete. A partial scan reported as a complete one is the failure mode we care most about avoiding. Two other things for when you revise: this will need a rebase, since it rewrites the same Also worth saying: you used |
Signed-off-by: Ertan <ertan.kucukoglu@gmail.com>
fb7169c to
9b8d456
Compare
|
Updated per review: the supervised Windows scan now has a 64 MiB byte ceiling, cancels the contained process tree when exceeded, validates final size before parsing, fails explicitly, and removes the temporary output. The unrelated POSIX regex cleanup is now #1637. Focused MCP suite: 192 passed, 7 platform skips. |
|
This is the right shape, and I checked the part that mattered rather than taking the summary on trust: A byte ceiling is also the right kind of bound. It caps the resource without touching result semantics, so unlike a row cap it cannot silently drop matches the caller has no way to know about. 64 MiB is a sensible number — comfortably above any real search, comfortably below filling someone's disk. The test seam for overriding the limit is a nice touch; it makes the exceeded path actually testable rather than theoretical. Cancelling the contained process tree, validating final size before parsing, and removing the temp file on the way out means the failure path is ownership-complete, which is what the original Three pieces of feedback, three clean turnarounds — the debug flag on #1605, the leak split out as #1637, and the bound here. Thank you; that is unusually easy to review. Merging once CI clears. #1604 wants to land first since it renames the same function this touches. |
What does this PR do?
Propagates MCP request cancellation to the Windows PowerShell process used by
search_codeand bounds its temporary output.The scan now runs through the supervised subprocess path. Cancelling a request terminates the process tree and removes temporary command output files.
A 64 MiB byte ceiling now monitors the command output while the process is running and checks the final size before parsing. Hitting the ceiling cancels the contained process tree and returns an explicit error; truncated output is never parsed or reported as complete.
Regression coverage verifies both cancellation and output-limit failures, including cleanup of
.mcp-command-*files. The unrelated POSIXcbm_regfreecleanup was split into #1637 as requested.Rebased onto current
main; the shared command-builder call site will receive the final rename-only rebase after #1604 lands.Test results: focused MCP suite: 192 passed, 0 failed, 7 skipped.
Part of #1565
Checklist
git commit -s)make -f Makefile.cbm test-focused TEST_SUITES=mcp CC=clang CXX=clang++)