fix(approval): isolate long command classification - #101965
Open
lemontree9223 wants to merge 1 commit into
Open
lemontree9223 wants to merge 1 commit into
lemontree9223 wants to merge 1 commit into
Conversation
lemontree9223
force-pushed
the
fix/command-guard-worker-timeout
branch
from
September 3, 2026 08:57
732f885 to
759e962
Compare
Contributor
Overall: Isolates long-command classification out of the gateway process: commands ≥4096 chars run the pure checks (hardline, sudo-stdin, user deny globs, dangerous verdict) in a Correctness:
Non-blocking nits:
Verdict: LGTM. Strong fail-closed design; nits are perf/hardening follow-ups. |
8 tasks
lemontree9223
force-pushed
the
fix/command-guard-worker-timeout
branch
from
September 9, 2026 04:29
759e962 to
6fee02d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Long shell commands can drive command normalization and dangerous-command detection through expensive Python parser/regex paths. In a single-process gateway, a pathological input can monopolize the interpreter and stall unrelated messaging work.
This change moves only the pure classification of long commands into a subprocess with a 10-second hard deadline. Approval prompts, session state, YOLO/mode decisions, and the final allow/block decision remain in the parent process. Worker timeout, process failure, malformed JSON, and invalid per-verdict schemas all fail closed.
The existing parent-side parser cap remains the first cheap rejection step. Commands shorter than 4,096 characters keep the existing in-process path.
This is adjacent to, but does not duplicate:
Related Issue
Related: #7485, #44473, #72500
Type of Change
Changes Made
tools/approval_guard_worker.pyfor the parent-side subprocess protocol andtools/command_guard_worker.pyfor classification over stdin.tools/approval.py,tools/approval_detection.py, andtools/approval_floors.py; approval decisions and mutable session state remain in the parent.Review follow-up
The earlier automated review referenced an older revision. The current parent error includes only the worker exit code, not captured stderr; the worker reports only the exception type. No persistent-worker or caching architecture has been added.
Validation for the current revision
Current head:
6fee02dce4cab50b801eafdd0325eb16a3f59350.The commands below have been updated to paths present at this head. They are commands to run, not new passing results. Tests, lint, and compilation were not rerun as part of this description-only update. Previously reported pass counts and root E2E results belong to earlier validation and must not be treated as evidence for this head.
At the latest status check, this head had no check runs or commit-status results. The repository requires
All required checks pass, which is not yet satisfied; absence of results is not a confirmed test failure. Full-suite success is not claimed. Earlier local full-suite collection was blocked by the optional ACP dependency.