Skip to content

fix(security): resolve sensitive paths in the subprocess pool's child, from the calling thread - #12879

Merged
chenmingwei23 merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/pathres-wire-subprocess-pool
Sep 27, 2026
Merged

chenmingwei23 merged 1 commit into
kirodotdev:mainfrom
Pearcekieser:feat/pathres-wire-subprocess-pool

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Base commit: e46967b5d502e323728f272933c910bb81767983

This is the wiring PR that #12709's scope note (section 5) asks for: the sensitive-path resolver now runs its realpath work in kiro_crew.subprocess_pool's child interpreter, reached from the calling thread. It answers the classifier question that note raises rather than guessing at it (see "What changed"). Credit: the pool and its child are @chenmingwei23's (#12709); the child-pid syscall sampling, batched anchor request and fail-closed transport posture come from #10256 (@bolichen97) and #12739, whose own helper/client this supersedes. Refs #10255 -- closed by triage, but the executor swap it describes is what lands here, so please reopen it or read this as the follow-up.

Problem / Motivation

executors.path_resolve_executor() on main is still a ThreadPoolExecutor, so the gate still refuses legitimate paths when the interpreter is busy: os.path.realpath reacquires the GIL twice per path component, and beside CPU-bound sibling threads that wait, not the disk, spends the budget. Measured here on a 128-core host (medians of 9 uncached anchor rebuilds, scripts/measure_path_gate_ttl.py rebuild):

GIL hogs main: rebuild median / max ms this PR: rebuild median / max ms
0 3.2 / 3.2 3.9 / 4.1
1 2468.5 / 2549.3 11.5 / 16.8
2 5661.6 / 12120.0 21.5 / 1034.3
4 29996.6 / 37919.5 21.6 / 1044.7
8 36767.7 / 41525.4 31.8 / 619.6

The rebuild budget is 8 s; main is over it from four hogs, and its first refusal there pins both pool workers so every later path under every prefix is refused without probing ("2 of 2 resolver worker(s) pinned").

Why it matters

The user's own file reads, edits and shell calls are refused with the unverifiable-path message on ordinary project paths, more often the busier the gateway is, and the stall cooldown widens one spike into a prefix-wide refusal. #12709 landed the mechanism and deliberately left security/paths.py untouched because wiring it needed a decision; until that decision is made the fix is not in effect.

What changed (motivation → approach → change)

The decision the scope note asked for. _run_resolution_bounded classified a missed budget with thread-pool signals (future.cancel(), a started/abandoned handshake, a worker ceiling) that do not exist once the work is a process. It now reads child signals: a plain TimeoutError from call_op means no child ever took the request (the old never-started arm); SubprocessPoolTimeout, new in executor.py, means a child took it and missed the deadline, carrying child_syscall (/proc/<pid>/syscall sampled just before the kill). _child_blocked_in_filesystem reads it against the existing per-architecture stat/readlink table; on-CPU or futex is the load arm; unsampleable (Windows, macOS, unmapped arch) fails toward charging. The worker ceiling and _path_resolve_wedged are deleted: a timed-out child is destroyed and respawned.

On the calling thread, one request per unit of work. _resolve_on_calling_thread runs the worker on the thread that wants the answer, under a thread-local deadline its child requests share (#12709 item 3). The candidate is one OP_REALPATH_SPELLINGS request; the root anchors and the target rebuild are one request each through a new OP_REALPATH_MANY op (_realpaths_or_none). The grace folds into the child's single deadline; a child that misses it is destroyed.

Fail-closed on every fault (item 4). SubprocessPoolUnavailable raises PathResolutionStalled, uncharged: an empty set would read as "resolved". Three consecutive faults warn once and degrade to the in-process fallback until a child answers. Only the reaper thread spawns children and waits on killed ones; a caller leases a ready slot within its budget, so Popen never runs on the loop. A killed slot respawns at once until 2 * workers killed children are unexited (callers then refused at once); children run source captured at import, never re-read. A stall-history prefix is not re-probed while one serviceable child remains. A host that cannot spawn raises the OSError at once; the resolver falls back in-process. Where select cannot arm the pipe deadline (Windows), call_op reads on a dedicated thread under a timed future; at the deadline it kills the child and retires the slot without waiting on the reader. Relative inputs join the CWD without normpath; .. after a symlink resolves in the kernel. No deadline armed means in-process: is_sensitive_resolved_path (worker-thread walks) and sandbox_credential_targets (off-loop preflight, bounded by acp/client.py's 60 s wait_for) resolve in this interpreter, as before, neither holding a child to the ceiling nor queuing ahead of the loop; dashboard/handlers/files.py catches nothing in its exclusion build, so a stall there routes _grep_rg to the fail-closed python engine. _child_realpath.py moves to security/. path_resolve_executor() returns the SubprocessPoolExecutor; KIROCREW_PATH_RESOLVE_WORKERS sizes children (floor 2). security.md and scripts/measure_path_gate_ttl.py follow.

What the wiring does not buy. Each round trip still costs several parent-side GIL reacquisitions: a warm gate call measured a median of 51 / 413 / 599 / 862 ms at 1 / 2 / 4 / 8 hogs (maxima 3.1 s) against main's 323 ms at one hog and refusal from two. No prefix was charged; the only refusals came from the 12 s wait allowance after fifteen back-to-back calls at eight hogs. A socket pair with one recv is the pool follow-up.

Backwards compatibility

Compatible: no public API, config key or on-disk format changes. KIROCREW_PATH_RESOLVE_WORKERS keeps its name, default and range; it now counts children rather than threads. Two private names tests read are gone (_path_resolve_wedged, _wedged_workers) and one is renamed (_worker_blocked_in_filesystem → _child_blocked_in_filesystem, taking the sampled token); scripts/measure_path_gate_ttl.py is the one in-tree reader and is updated.

Tests

test/test_security_path_resolve_bounded.py (78 tests): the stubs now behave as a child does (wait out the shared deadline, raise SubprocessPoolTimeout), the cooldown/one-hop tests count child requests (OP_REALPATH_MANY once for the roots, once for the rebuild), the saturated arm leases both real children, and two pool-only tests are removed (leave-one-free re-probe guard, the never-run handshake). New pins: child answers identical to in-process for both ops; resolution runs on the calling thread; a SubprocessPoolUnavailable on either half refuses without a cooldown; a child that cannot start falls back in-process with one warning; an empty spelling never reaches the resolver; and the GIL-hog reproduction (sensitive_path_refusal on a healthy file beside one hog: not refused, no prefix charged, < 1.5 s). Added after review: the in-process fallback is bounded; parity on a ..-after-symlink candidate; and in test_subprocess_pool.py the caller's budget fires with select disabled (the Windows shape), so the three budget tests now run on every platform. test_file_grep.py pins that a stall routes the grep to the python engine; test_subprocess_pool.py pins the killed-child cap, the retired-slot arm and reaper-only spawning; the re-probe guard has its own pin. test_subprocess_pool.py, test_executors.py, test_pathres_loop_starvation.py, test_spawn_audit.py adjusted for the moved child, the executor type and the batch primitive; test_security_gate_liveness.py widens the security package's line budget by the relocated child script's size (a move, not growth).

Ran locally (-n0): the 17 files named in the gate set, 2032 passed, 2 skipped. flake8, isort, black clean on changed files; mypy src/kiro_crew/security/ src/kiro_crew/subprocess_pool/ src/kiro_crew/executors.py: no issues in 18 files; comment-history gate against origin/main passes; docs lint passes.

Manual verification

The two contention tables above (scripts/measure_path_gate_ttl.py rebuild --hogs 0,1,2,4,8 on this branch and on a detached origin/main worktree, plus a stdlib gate-call probe kept outside the repo). No wedged mount was available to observe the child's syscall on a real dead NFS/FUSE/CIFS mount; that caveat stands exactly as it did for the thread sample and is recorded in the spec.

Related Issues

Refs #10255, #12709, #10256, #12739.

Pattern harvest

Rule candidate: review-prompt
Pattern: "a classifier reads side effects of a submitted callable (thread id, handshake events, cancel() result) -- when the executor behind it changes shape, every one of those signals must be re-derived, not carried".

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 22, 2026
@dwu96

dwu96 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

2 similar comments
@dwu96

dwu96 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 24, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/pathres-wire-subprocess-pool branch from e2df7e0 to 0082a4c Compare September 24, 2026 05:06
@dwu96

dwu96 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 24, 2026
@dwu96

dwu96 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

3 similar comments
@dwu96

dwu96 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@dwu96

dwu96 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review.

When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically.

@Pearcekieser
Pearcekieser marked this pull request as ready for review September 24, 2026 18:01
@Pearcekieser
Pearcekieser requested review from a team and cixuuz September 24, 2026 18:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed b7fc1ed8fd9f9ac07dce38332d17ccc2cbb1b382 via the fork AI-review pipeline; updated in place on each push.

Review details

FINDING -- src/kiro_crew/subprocess_pool/executor.py:87 -- "always run it by path" contradicts _spawn() using captured source via -c -> Fix: describe the captured-source launch.
FINDING -- src/kiro_crew/executors.py:584 -- "mc-pathres" contradicts the actual mc-pathres-inline fallback prefix -> Fix: use the actual prefix.
[GPT-REVIEWED] b7fc1ed

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of b7fc1ed8fd9f9ac07dce38332d17ccc2cbb1b382 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the Windows arm on a real Windows host: every _CAN_SELECT_PIPES=False test runs on POSIX, and Windows now spawns resolver children for the first time.

Not justified as shipped

  • Item 10 — rides along: the files.py comment and test_file_grep.py pin change no runtime behaviour; they document that the new stall class already routes to the python engine.

What this change ships

Inventory (10 items) — 9 justified

Intent: FIX — stop the sensitive-path gate refusing ordinary paths on a busy gateway by moving its realpath into the subprocess pool's child, reached from the calling thread (the wiring #12709's scope note deferred; base security.md itself names the fix: "Closing that case needs the resolution to leave this interpreter (#10256)"). Base path_resolve_executor has exactly one consumer (security/paths.py — grepped path_resolve_executor in src/), so the executor-type swap breaks no one else.

  1. File reads, edits and shell calls stop being refused on a busy gateway — justified
  2. The anchor rebuild travels as one batched child request instead of ~130 hops — justified
  3. A missed budget is classified by the child's sampled syscall; worker-pin tracking deleted — justified
  4. Grace folds into one deadline; a timed-out child is killed and respawned — justified
  5. A child fault refuses fail-closed uncharged; three in a row degrade to bounded in-process resolution — justified
  6. A host that cannot spawn children resolves in-process, with one warning — justified
  7. Only the reaper spawns; killed-but-unexited children are bounded and exhaustion refuses at once — justified
  8. Windows callers get a real per-request deadline via a reader thread; the timed-out slot is retired — justified
  9. A stall-history prefix is never re-probed on the pool's last child; its cooldown is extended — justified
  10. Grep-exclusion stall routing pinned by a comment and a test — rides along: no runtime change

More than 10 items exist; the omitted ones (doc rewrite, measure-script rename, +200-line package budget for the moved child script, KIROCREW_PATH_RESOLVE_WORKERS now counting children at the same name/default/floor) are all declared riders of the same fix. The two deleted tests (leave-one-free guard, never-run handshake) pinned thread-pool signals that have no referent for a process; each is replaced by its process-shaped pin and the description declares the removals.

[FIRST-PRINCIPLES-REVIEWED] b7fc1ed

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of b7fc1ed8fd9f9ac07dce38332d17ccc2cbb1b382 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the reaper — now the pool's only spawn site — survives a poisoned tick; a dead reaper leaves every gated path refused until restart.

Suggestions

  • Wrap _reap's tick body in a broad except (plus a pin that a raising tick still respawns): the diff removes on-demand spawning in _Child.request ("Never spawns... raise SubprocessPoolUnavailable"), making that one unguarded daemon thread newly load-bearing for gate availability.

[DESIGN-REVIEWED] b7fc1ed

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 24, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/pathres-wire-subprocess-pool branch from 0082a4c to fdf0834 Compare September 24, 2026 18:59
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Review round on 0082a4ce4, addressed at head fdf083415 (same commit, amended).

Design Review — BLOCK (Windows loses the caller-side bound). Fixed in subprocess_pool/executor.py. Where select cannot arm the pipe deadline (_CAN_SELECT_PIPES is false), call_op now routes the request through _request_bounded_by_thread: the read runs on the executor's internal thread pool and the caller waits on that future with its own deadline; at the deadline it samples the child (None off Linux), kill_asynces it so the blocked read sees EOF, and raises SubprocessPoolTimeout. So on Windows a wedge is classified as a timeout within budget+grace, the resolver's unsampleable arm charges the prefix, and the caller is never held to the 20 s ceiling. Pinned by test_where_select_cannot_watch_the_pipe_the_caller_is_still_bounded (forces _CAN_SELECT_PIPES=False, hanging child, ceiling 600 s, asserts SubprocessPoolTimeout at the 1 s budget and the child destroyed); the three TestCallerBudget tests lost their POSIX-only skip and now run on every platform.

Both watch items are also taken:

  • .. after a symlink: _absolutized joins a relative input to the CWD without normpath; absolute inputs pass through untouched. Parity test gains into_store/../credentials (link into a store, then ..) for both ops and asserts the kernel-resolved form.
  • Unbounded can't-spawn fallback: _inline_bounded runs the in-process realpath on the pool's thread and waits with the shared deadline, raising PathResolutionStalled uncharged on a miss. Pinned by test_the_in_process_fallback_is_still_bounded.

The two-pass anchor invariant suggestion is left as is: pass 2 asks only for what _home_dir_targets/roots produced, and the existing resolution_differed marker already observes any derived-anchor drift.

First Principles — CONCERNS (proc_syscall exported with no consumer). Removed from subprocess_pool/__init__.py (import and __all__); the tests import it from kiro_crew.subprocess_pool.executor.

GPT — advisory after adjudication (IPC wait blocks the event loop). No change: as the adjudication records, the base already waits inline at the same ≤5 s ceiling, the new wait is bounded absolutely with the child killed at expiry, and offloading it re-introduces the two-handoff shape this PR measures at 2681 ms vs 81 ms.

Windows shards 1 and 6 on 0082a4ce4. Two were mine, fixed: the parity test wrote a filename containing a newline (EINVAL on NTFS; now POSIX-only for that one shape), and the fallback test expected None for a NUL path where Windows realpath returns a string (now compared against the in-process mirror, which is the property under test). test_history_index_worker::test_a_contended_write_waits_instead_of_failing and test_acp_tool_gate::test_env_root_override_is_read_verbatim do not touch this diff.

Local gates on fdf083415: 1,565 targeted tests (security, resolver, pool, executors, hooks, spawn audit), isort/flake8, check_black_formatting.py, mypy on the touched modules; body re-checked at 500/500 words.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review (fork) — 🟡 CONCERNS

Which legitimate operations does b7fc1ed8fd9f9ac07dce38332d17ccc2cbb1b382 newly refuse? Model proposes, scripts/deny_diff.py decides — updated in place on each push. A script-confirmed regression blocks PR readiness.

the reviewer's own judgement; no confirmed regression

Scope-Verdict: CONCERNS

TIGHTENING: the sensitive-path resolver behind the tool gate's path fence moved from the mc-pathres thread pool to killed-at-deadline child interpreters, and its fault arms got stricter -- where the thread-pool version answered a pool fault by returning None and keeping the lexical forms ("anything else here is a pool fault, and the gate's contract is to keep the lexical forms rather than fail the tool call"), a child transport fault now refuses outright: "A transport fault raises PathResolutionStalled rather than returning an empty set, because an empty set reads as 'resolved, no other spelling' and would leave a workspace symlink into a credential store matched on its lexical spelling alone" (_resolved_spellings, security/paths.py). The one threat refused is the CWE-59 link bypass riding an unavailable resolution -- a workspace symlink into a credential store passing on its lexical spelling -- plus, at the pool layer, the respawn-executes-an-edited-script variant: "respawning from disk would let an agent edit the script, kill a child it can see, and have the reaper execute the edit with credential-read access" (_read_child_source, subprocess_pool/executor.py).

ADJUDICATED: 14 candidates, 0 confirmed newly-refused
No leg verdicts were handed to this review; the deterministic fold reports each leg's result after capture. The candidates probe the three tiers the shell composite actually runs (sensitive-command, exfiltration, rule catalog), which this diff leaves textually untouched -- scripts/deny_diff.py's _TIERS carries an explicit "No path tier" for shell command text, and none of is_sensitive_bash_command, audit_bash_exfiltration, or is_denied is modified by the patch -- so zero flips is the expected outcome, and any flip the fold does report would indicate an import- or catalog-level side effect the diff does not advertise.

PLATFORM COVERAGE: 10 posix rows and 4 windows rows; no any rows, because every candidate carries a path, a separator, or an executable name. The diff's platform assumptions and the rows that cover them: the python -I -S -c child-spawn spelling (posix and windows rows, drive-letter path in the windows payload); backslash test paths and the .venv\Scripts\python.exe interpreter for the Windows test lane the diff un-skips (posix_read_deadline_only markers removed); /proc/<pid>/syscall sampling, which exists only on Linux (posix cat /proc/<pid>/syscall and ps -o wchan rows), with Get-Process as the Windows spelling of the same diagnosis, since the diff makes Windows fail toward charging the prefix (no sample). One assumed surface no candidate can probe on any platform: the Windows bounded-reader arm (_request_bounded_by_thread) and the _Unreaped respawn threshold are runtime behaviors of the resolver, and no shell command line reaches the resolver at all -- named below.

UNADJUDICATED: the tightening itself. The guard is the path fence's resolver: hooks.on_tool_call → is_sensitive_path/is_sensitive_write_path on every resolved path the file tools open → _candidate_forms → _run_resolution_bounded → SubprocessPoolExecutor.call_op into the _child_realpath.py child. A shell command line never takes this path (the bash gate matches no paths in command text, pinned by TestTheBashGateMatchesNoPaths, and the classifier's tier table excludes it), and the new refusal arms are functions of runtime pool state, not of any input string -- so no row can obtain a verdict for them. The candidate legitimate inputs I would have submitted:

  • An ordinary project-file read (fs_read of <workspace>/README.md) issued in the instant a resolver child dies to an external reaper (cgroup OOM, antivirus). Base: worker fault → None → lexical forms kept → the read is answered. Head: SubprocessPoolUnavailable → PathResolutionStalled → the read is refused, for the first _CHILD_FAULT_WARN_STREAK - 1 (two) consecutive faults before the in-process degrade engages, and again after every healthy answer resets the streak. On a host whose children die periodically this is a recurring refusal of healthy reads the thread-pool version never made. If this class is judged acceptable, the narrowest alternative is to route a sub-threshold fault through the same bounded in-process fallback the cannot-spawn arm already uses, rather than refusing -- the deadline still bounds it and the empty-answer hazard never arises.
  • A file read under a prefix with stall history, arriving while the pool is down to its last serviceable child: head refuses it and silently re-arms the prefix's cooldown (_extend_cooldown) without observing the mount, so a mount that has recovered stays refused for an extra earned-window per arrival; base re-probed once a worker was free.
  • The dashboard's file_grep over a home-rooted directory during an anchor stall: the (comment-only) _grep_sensitive_globs hunk codifies that the stall propagates and the search degrades to the fail-closed python engine -- slower, not refused; worth a manual exercise, not a row.
  • Windows only: a burst of deadline kills can fill _Unreaped (2 * workers), after which _lease refuses every path fail-closed and uncharged until a killed child exits -- unmeasurable on this repo's runners and inferred by the diff's own admission that the wedged-mount case is unverified.

The candidates in candidates.json cover the adjudicable shell perimeter of this change; the change's own behavior is testable only through the test-kind rows its PR already ships (test_security_path_resolve_bounded.py, test_subprocess_pool.py), which a human or the conductor's verify lane must run -- this review claims no pass on their behalf.

[SCOPE-REVIEWED] b7fc1ed

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • ubuntu-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • windows-latest (platform windows): 4 classified, 0 newly refused, 4 still allowed.

No candidate flipped from allowed to refused.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 24, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/pathres-wire-subprocess-pool branch from 406f3e4 to b5757b0 Compare September 26, 2026 21:10
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Cold resolver startup blocks the event loop — fixed at b5757b0175

A different claim under the same span as the rebutted pipe-wait finding, and this one is right: request spawned inline when a slot was empty, so the first on-loop call after start-up, and the first after any kill or fault, paid a Popen on the loop. Taken as the adjudicator framed it, a lease that skips an unspawned slot. _Child.ensure_spawned is now the only spawn site and runs only on the reaper thread; _free is a READY queue that the reaper fills after each spawn (_enqueue, guarded against double entries), call_op leases from it or waits inside its own budget (_lease), and a slot released without a live child goes back to the reaper (_release wakes it, so the wait is the fork/exec, not the 0.5 s tick). request never spawns; a child that died while idle is one refused resolution. A host that cannot start a child gets its OSError at once through a queued _SPAWN_FAILED marker, so the resolver's in-process fallback still triggers without draining the budget. Pinned by test_a_lease_never_spawns_on_the_calling_thread (every _spawn runs on the -reaper thread) and test_a_host_that_cannot_spawn_raises_the_oserror_inside_the_budget.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 26, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/pathres-wire-subprocess-pool branch from b5757b0 to dba9e9e Compare September 26, 2026 21:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Resolver pipe I/O blocks the gateway event loop — needs a decision (unchanged from 7bc137832)

The cold-start claim raised on 406f3e4ab3 is fixed on this head and did not recur. What remains is the original pipe-wait claim, same span, rebutted at this comment and asked for override at this one. This round's adjudicator confirms the facts of the rebuttal itself: "the base already blocked the calling thread on future.result(timeout=granted_budget)", so the on-loop wait is main's existing bound, not something this diff adds, and the offload it asks for is the thread-pool shape that produced #10255. Upheld on the anchor's blocking: true flag alone. Record for the new head; no new ping.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • One permanently wedged mount retires both resolver slots for good — fixed at 52325fa9bf

Right, and it was a consequence of the previous head's answer to GPT's orphan-accumulation finding (one process per slot, no respawn until the killed child exits): a SIGKILLed child in an uninterruptible syscall may never exit, so each wedge retired a slot permanently and the pool then refused everything uncharged after a full budget wait. Both of your fixes are taken. (1) The bound moved from per-slot to pool-wide: _Unreaped keeps at most 2 * workers killed-but-unexited children; below that a slot respawns at once (the reaper is woken, not waited for), at it a slot stays empty. GPT's finding stays answered because the process count is capped at 3 * workers. (2) The caller-side arm is back in _run_resolution_bounded: a re-probe of a prefix with stall history is refused, and that prefix's cooldown extended via _mark_stalled, while serviceable_children() (live children plus slots the reaper can still fill) is at most one, so a known-bad mount cannot take the last child. Also: when no child is live and the list is full, _lease raises SubprocessPoolUnavailable at once rather than spending the budget on an empty queue, so the fault-streak warning fires and the loop is not held for granted. Pinned by test_killed_but_unexited_children_are_bounded_and_a_slot_respawns_below_the_bound (respawn below the cap, no spawn at it, immediate refusal, refill once one exits) and test_a_stalled_prefix_is_not_reprobed_on_the_pools_last_child (refused before the resolver with one child, cooldown extended, other prefixes unaffected, proceeds with two). security.md updated.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Timed-out children can accumulate without bound — still fixed at 52325fa9bf, mechanism revised

The per-slot form of the fix (no respawn until the killed child exits) let one permanently wedged mount retire the pool for good (Opus, this head), so the bound is now pool-wide: _Unreaped holds at most 2 * workers killed-but-unexited children and the reaper does not spawn while it is full, so the pool never exceeds 3 * workers processes however many deadline kills a wedged mount causes. Pinned by test_killed_but_unexited_children_are_bounded_and_a_slot_respawns_below_the_bound.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Windows timeout cleanup blocks the gateway loop — fixed at 5f1276939d

Taken. _request_bounded_by_thread no longer waits future.result(timeout=2.0) for the reader after the kill; at the deadline it samples, kills the child and raises _ReaderLost at once, so the caller returns at its deadline. call_op retires the slot (_replace_slot): the killed process joins the bounded _Unreaped list for the reaper to collect, the fresh slot's child is spawned by the reaper, and the old reader's own cleanup runs on the reader thread when EOF arrives. test_a_bounded_read_that_misses_its_deadline_retires_the_slot_without_waiting pins the return within the budget and the slot replacement. The _Unreaped capacity accounting is the same list the deadline arm's _kill_locked(wait=False) uses, so the two paths share one bound.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Racing reaper can make sensitive-path resolution fail open — fixed at 147ce79d97

Real race, and the consequence was right: a slot retired mid-tick could be spawned and enqueued from the reaper's snapshot, and its next deadline would raise ValueError out of list.index, which the resolver treats as a pool fault and keeps the lexical forms. Fixed at both ends. _replace_slot swaps the roster under _qlock before it wakes the reaper, and a slot already retired is left alone (the call returns the stale object, swapping nothing). _enqueue checks roster membership under the same lock and, for a slot no longer current, kills the child it was just given instead of queuing it; an already-queued current slot is a no-op. Pinned by test_a_slot_retired_mid_tick_is_never_enqueued (leased, retired, late _enqueue: not queued, orphan killed, replacement leased, second retirement harmless).

  • Caller-thread test removes its lost-run bound — fixed at 147ce79d97

Taken as suggested: test_an_awaited_future_runs_the_transport_on_the_awaiting_thread awaits the future with no timeout on a helper thread (so the read stays on the awaiting thread on every platform, the point of the test), joins it with a 60 s bound, fails on a still-alive helper, and asserts the recorded transport thread is that helper.

  • _mark_stalled records a stall the re-probe guard never observed — fixed at 147ce79d97

Taken. The guard now calls _extend_cooldown(prefix), which re-arms the window the prefix's existing stall count already earned without incrementing the count or emitting the "did not complete" warning; _mark_stalled stays reserved for a resolution that ran and timed out in the filesystem. The pin asserts the count stays at 1 while the window moves.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Writable helper executes outside the sandbox — fixed at 3a80b8fbb0

The spawn-from-disk shape is inherited from main's subprocess_pool (this PR moves the file), but the remedy asked for is cheap, so it is taken rather than argued. _read_child_source reads the child's program text once, at import of subprocess_pool/executor.py for the default script (before any agent turn) or at executor construction for an adopter's script=, and every spawn passes that text as -c; the file is never re-read at respawn, so an edit to _child_realpath.py after start-up reaches no child of this process. -I -S are unchanged, so sys.path still carries nothing writable. Pinned by test_a_respawn_runs_the_source_captured_at_construction_not_the_file_on_disk (edit the script on disk, kill the child, the respawned child still answers with the captured program). The spawn-audit comment and security.md say so. Residual, stated: an edit made before the gateway starts is the whole package tree's writability, not this spawn's.

  • _Unreaped capacity can be exceeded by concurrent timeouts — fixed at 3a80b8fbb0

Wording corrected as suggested: capacity is described as a respawn threshold, add is documented as never refusing (the killed process exists whether counted or not), the overshoot is bounded at one per leased slot, and the process-count claim reads 4 * workers in the class docstring, the executor comment and security.md.

  • Resolver blocks the gateway event loop — downgraded by the adjudicator on 147ce79d97

Recorded for the ledger: this round's adjudication DOWNGRADED the finding (reason=disproportionate-remedy), confirming what the rebuttal at this comment said: the base blocks the same thread for the same budget, no Popen or wait runs on the caller, and the offload asked for reverses the measured fix. Nothing further is owed on this span unless a later head re-upholds it.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Head e67b6c6597: same tree as 3a80b8fbb0 (79552e918fc8), timestamp-only amend, no code change. On 3a80b8fbb0 GPT reported no blocking findings and 95 checks passed; the Opus and Security Scope lanes failed as "review incomplete" / "no leg reported" in the same 00:25 to 00:27Z window, with First Principles and Design neutral for the same reason, so this push re-runs them.

…, from the calling thread

Wire the sensitive-path resolver to kiro_crew.subprocess_pool: the candidate,
the root anchors and the target rebuild each travel as one request to the child
interpreter, made by the thread that wants the answer, so the budget is spent
waiting for the disk rather than for the GIL. The stall classifier is adapted to
child-shaped signals: a lease timeout means no child ran (not charged), and a
SubprocessPoolTimeout carries the child's syscall sampled before it was killed,
read against the existing stat/readlink table. Transport faults refuse
fail-closed with no cooldown; only a child that cannot start falls back
in-process. The child script moves beside the resolver it serves.

Refs kirodotdev#10255, kirodotdev#12709, kirodotdev#10256, kirodotdev#12739
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • A persistent die-loop refuses every gate, remedied only by a log line — fixed at b7fc1ed8fd

Taken this time. I had declined the fallback on c445352fb for the half-upgraded-interpreter case; your framing that in-process resolution is refusal-prone under load and not a bypass is the right one, and it also gives the pool-exhaustion case (every slot held by a killed child that will not exit) a way to keep serving healthy prefixes. _child_request now returns the in-process marker once the fault streak reaches _CHILD_FAULT_WARN_STREAK, so _inline_bounded takes over: same deadline, still fail-closed on a miss, never an empty answer. Below the threshold a fault stays a refusal (one fault is a killed-and-respawned child). The one warning names the degradation; a healthy child answer resets the streak. Pinned by test_a_run_of_child_faults_is_warned_about_once_and_degrades_in_process; security.md and the constant's comment say so.

  • Resolver pipe wait blocks the gateway event loop — needs a decision (record for the new head)

On e67b6c6597, the same tree as 3a80b8fbb0 where this lane reported no blocking findings and one head after the adjudicator downgraded the same claim on 147ce79d97, the finding was upheld again on the anchor flag. Facts unchanged from the rebuttal; this round's adjudicator again confirms them (bounded, self-limiting, main blocks the same thread). No new ping; the maintainer override asked at this comment still stands if the lane does not settle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants