Skip to content

fix(mcp): keep the policy for a long-path, relative or missing handler on another drive - #20746

Merged
KiroCrewCaptain merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/20682-managed-tool-scope-windows
Oct 17, 2026
Merged

KiroCrewCaptain merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/20682-managed-tool-scope-windows

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A handler on another Windows drive skips the managed tool policy only when that drive is proven: an existing file named by an absolute path with a drive. Both sides are compared without the \\?\ long-path prefix, which only spells a path.

This is a follow-up to #20802, which fixed the cross-drive ValueError behind #20800 / #20682. #20802's _path_is_under answers False ("not managed", so the policy read is skipped) for any drive mismatch. That is the right answer for the case it fixed: a real app file on C: with Kiro Crew on D:. But a drive mismatch also shows up for inputs that do not prove the handler is on another drive:

  • a \\?\ long-path spelling on one side only: \\?\D:\...\kiro_crew\mcp_core.py splits to drive \\?\D:, which differs from D:, so Kiro Crew's own file reads as foreign (Windows realpath keeps that prefix on deep paths);
  • a relative co_filename: it resolves against whatever the cwd is at call time, so its drive says nothing about where the code lives;
  • a rooted name with no drive (\app\mcp_server.py): it resolves against the drive of the cwd at call time, and on Python 3.12 ntpath.isabs still calls it absolute;
  • a file that does not exist: the name proves nothing.

The long-path case is fixed by folding the prefix. The other three cannot be located, so they keep the policy. Before #20802 all of these kept the policy (the ValueError arm returned True). On current main they skip it.

Why it matters

serves_managed_tools is the fail-closed side of a governance control: every answer it cannot establish is True. These are not established, so they keep the policy. No normal pip, wheel or desktop install produces them: hardening, not a live bypass.

Not a goal

What changed (motivation → approach → change)

A drive mismatch means "not managed" only when the check finds the handler's file on disk under an absolute name with a drive; every other mismatch keeps the policy.

src/kiro_crew/mcp_shared.py, two small hunks:

  1. serves_managed_tools works out located inside the existing try (OSError still answers True): the original name, with any \\?\ prefix folded, has a drive and is absolute, and its realpath is an existing file. It passes located and its own os.path to _path_is_under, so both checks use one set of path rules and the tests can run Windows rules on every OS.
  2. _path_is_under folds both sides with the existing platform_compat.strip_extended_length_prefix (\\?\UNC\server\share\... becomes \\server\share\..., \\?\X:\... becomes X:\...), then on a drive mismatch returns not located. located defaults to True, as fix(mcp): treat an app on another Windows drive as outside the package #20802's direct tests call it; the one production caller passes it.

src/kiro_crew/platform_compat.py: strip_extended_length_prefix is typed with a TypeVar, so str in gives str out. Its body is unchanged.

Why not locate archives or sourceless pycs too: no supported install produces them (see the sweep below), so that would be machinery for an input nothing ships.

Backwards compatibility

Breaking: on Windows, a handler on another drive whose co_filename cannot be located (relative, drive-relative, rooted with no drive, a zip-imported or sourceless .pyc module, a missing file) keeps the managed tool policy again, as it did before #20802. An app served that way has its calls refused where no identity can be attested. An existing file under an absolute name on another drive stays not managed (#20802), and a \\?\ spelling compares as its plain path.

Writer sweep on origin/main @ 12835a8: no supported writer produces that shape. install_app copies a local directory as loose files, registry apps arrive by git clone, app dependencies install with pip --target, builtin apps live under the package, and the desktop builds keep each source beside its pyc (packaging/precompile_windows.py, packaging/build-desktop.sh), so the source loader sets co_filename to the real file. Only an app whose own manifest command runs an archive or a sourceless .pyc gets the refusal.

Reader: src/kiro_crew/mcp_shared.py:_run_stdio_dispatch_loop -- app -- test_app_mcp_tool_policy_scope.py::TestAppServerSkipsThePolicyRead

Tests

test/test_app_mcp_tool_policy_scope.py. TestAnotherDriveNeedsProof swaps mcp_shared.os for one whose path is ntpath (lexical realpath, isfile from the files a test lists, relative names against C:\work), with the package on the CI checkout's D: path, and asks serves_managed_tools:

Handler Answer Current main
\\?\D:\...\kiro_crew\mcp_core.py; a plain package file with the package spelled \\?\D:\... True red
package on \\server\share\...: handler \\?\UNC\..., or the package spelled \\?\UNC\... True red
\\?\unc\... (Windows realpath never writes it): folds to a name with no drive, not located True red
relative app\..., drive-relative C:app\..., rooted \app\..., missing file True red
realpath raising OSError True green
an existing app on C: (#20802's case) or at \\?\C:\..., an app at \\?\UNC\server\share\..., or an app on C: with the package spelled \\?\D:\... False green
relative name with the cwd on D: False green

TestServesManagedTools::test_a_link_into_the_package_is_managed: a handler under a make_dir_link link to the package is managed.

Mutation check, each red: drop any of the four located conditions (drive, isabs, isfile, folding the original name), read the drive or isabs from the resolved path, stop folding either side in _path_is_under, answer False or True on every mismatch, default located to False.

Determinism: the file passes 20 runs at -n0, 10 at -n 4 --dist loadgroup beside test_managed_tool_policy_include.py and test_app_mcp_session_identity.py, and a shuffled order (seed 20746). Linux, Python 3.12: the file and the serves_managed_tools / strip_extended_length_prefix neighbours at -n 4, 553 passed, 1 skipped; the ratchets and facade guards, 543 passed. Black gate, isort, flake8, mypy src/kiro_crew (no issues), comment-history, subprocess-encoding, the flake-pattern ratchet and Semgrep with the repo rules on the diff (0 findings) pass.

Manual verification

A native test ran once and passed on a Windows runner (Backend Tests (Windows) (7)): a real handler past 260 characters on another drive resolved through realpath to an existing file and answered False. It was removed because its skip guards broke a-ratchet-may-only-tighten. The fake resolves lexically, so no case reaches a native realpath on a UNC host.

Related Issues

Related: #20800, #20682. Follow-up to #20802.

Pattern harvest

Not generalizable: the rule is specific to this fail-closed check. A drive mismatch proves "elsewhere" only for an existing file under an absolute name with a drive, once any \\?\ prefix is folded; other commonpath users ask other questions.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|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): docs/architecture/mcp.md describes the check at the level this does not change
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners October 15, 2026 08:19
@jeeshofone
jeeshofone requested a review from bolichen97 October 15, 2026 08:19
@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 Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision ff7a8bcf07821a82ff841d1bb7ac995ff27d9e63 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of ff7a8bcf07821a82ff841d1bb7ac995ff27d9e63 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

The fix was checked once on a real Windows runner, and that test was then removed. A human should confirm that a real file on another drive still answers False.

What this change ships

Inventory (6 items) — 6 justified

Intent: stop a Windows tool handler from skipping Kiro Crew's managed tool policy just because its location shows a different drive, when that location doesn't prove the file is on another drive. This is a FIX.

  1. A package file spelled with the \\?\ long-path prefix is treated as Kiro Crew's own code again, and keeps the policy — justified
  2. A relative, rooted or drive-relative handler name on another drive keeps the policy again — justified
  3. A handler on another drive whose file doesn't exist keeps the policy again — justified
  4. An app on another drive served from a zip archive or a sourceless .pyc is refused again, as it was before fix(mcp): treat an app on another Windows drive as outside the package #20802; the description declares this as breaking — justified
  5. _path_is_under gains a located keyword, defaulting to True; its one production caller passes it, and the caller now also passes os.path explicitly — justified
  6. strip_extended_length_prefix is typed to accept and return str as well as Path; its body is unchanged — justified

[FIRST-PRINCIPLES-REVIEWED] ff7a8bc

Description read

[DESCRIPTION-READ] e4606b80d2f0fff81c9d4007955871cdab2a60a4ed02c8bc93b7c266790dcde0

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of ff7a8bcf07821a82ff841d1bb7ac995ff27d9e63 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 before merge: the only native-Windows proof (the realpath → isfile path for a real app on another drive) comes from one deleted test run, and the remaining tests resolve paths lexically.

[DESIGN-REVIEWED] ff7a8bc

Description read

[DESCRIPTION-READ] 5fd7319c48aa551841c1ca048a39f26600c65ee882d2d0b8f9093b761dbbf8ca

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ff7a8bc

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

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

Review details

No findings.
[GPT-REVIEWED] ff7a8bc

@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head 2ec385fe9486b99b422e3461252a76c2aa8b5065 (one commit, base 213339f unchanged). All lanes on 7760e91 had no findings; this head acts on an independent security review of that head.

Fixed: fail-closed on an unestablished different drive (src/kiro_crew/mcp_shared.py, serves_managed_tools). A drive mismatch now answers False (outside the package) only when co_filename is absolute, the resolved file exists and neither side carries a \\?\ prefix. A relative name, a missing file and a one-sided \\?\ spelling keep the policy (True). On 7760e91 those three returned False; the three new tests below fail there and pass here.

Input (Windows rules, package on D:) Answer
Existing absolute file on C: (the CI case) False
Missing file on C: True
Relative co_filename, resolving to another drive True
\\?\D:\...\kiro_crew\x.py against an unprefixed package True
realpath raising OSError True
Package code, any case or slash spelling True
Same drive, outside the package, or kiro_crew_extra False
Synthetic <...>, empty, or no code object True

Fixed: comment now names the UNC and \\?\ cases the drive check decides.

Fixed: symlink pin. test_a_symlink_into_the_package_is_managed (POSIX tmp_path symlink to a package file).

Mutations, each failing a named test: except returning False (test_an_unresolvable_location_keeps_the_policy), dropping realpath (symlink test), dropping isabs (relative), dropping isfile (missing file), dropping the prefix check (long path), True on any mismatch (other-drive test).

Gates on this head: test_app_mcp_tool_policy_scope.py 15 passed; with the policy suites at -n 8, 446 passed. Black gate, isort, flake8, file line cap, comment-history (base origin/main), mypy src/kiro_crew (0 errors). Semgrep 1.78.0 (p/python, p/security-audit, p/secrets, p/owasp-top-ten, semgrep/) on both files: 0 findings. The body was updated before the push.

@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 Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/20682-managed-tool-scope-windows branch from 2ec385f to 4e566e5 Compare October 15, 2026 09:46
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@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 Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/20682-managed-tool-scope-windows branch from 4e566e5 to e7430a3 Compare October 15, 2026 11:07
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Backend Tests (Windows) (7) on 4e566e5: TestWindowsPathSpellings::test_a_relative_location_on_another_drive_keeps_the_policy failed (assert False is True). Its relative name resolved against the runner's real cwd, D:\a\KiroCrew\KiroCrew, which is the package's own drive, so it was not "another drive" there and False (outside the package) is the correct answer. It passed on Linux only because ntpath resolved it against a POSIX cwd.

Fixed in the test, src/ unchanged, new head e7430a3 (rebased on current main): the _WindowsPath fake resolves relative names against a fixed cwd on C:, and a new sibling test_a_relative_location_on_the_package_drive_is_not_managed pins the real-runner case (cwd on D:, relative name outside the package: False). On Linux, with the fake's cwd on D: the old test fails with the same assert False is True; with the fix the file's 16 tests pass. 447 passed across the policy-scope and mcp_shared suites at -n 8; black gate, isort, flake8, comment-history and Semgrep 1.78.0 clean.

First-pass check: R1-R8 OK

@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 Oct 15, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 15, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Status on 4a91dc374: every lane passed on its first attempt, Windows (7) included. The CANCELLED entries in the rollup are the attempt-2 re-runs started at 21:05 (Sensitive Change Review, Issue Gate, PR Hygiene, SAST, Screenshot Evidence, Inclusive Language, Automated Rule Check), which were cancelled before they finished. Their attempt-1 runs are green. macOS (3) failed only at artifact upload (Failed to CreateArtifact: Unable to make request: ENOTFOUND); its tests passed. A fork cannot re-run these, so a maintainer re-run of those jobs is all that is left.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy-sensitive) at 4a91dc3.

This changes the fail-closed managed tool policy check in src/kiro_crew/mcp_shared.py (serves_managed_tools and _path_is_under), which decides whether an MCP handler's calls are governed by the policy. Changes to that control are reserved for a human reviewer, so this review does not approve it even though I found no defect.

Why it looks sound: a drive mismatch now proves 'not managed' only for an existing file under an absolute name with a drive, after folding the long-path prefix on both sides (mcp_shared.py#L1508-L1547). Relative, rooted-without-drive, missing and unresolvable inputs return True, matching the function's fail-closed contract, and #20802's real cross-drive answer is unchanged. The new ntpath-based tests cover each branch and are reported to fail on main.

To clear before a human approves:

  1. Answer the current-head Design Review punchline: a handler loaded from a zip or frozen bundle on another drive fails isfile(real), so its calls are refused. Say whether any supported app ships that way.
  2. Answer the First Principles punchline: native realpath on a deep cross-drive path was not checked on a Windows host.
  3. A maintainer re-run of macOS Tests / Backend Tests (macOS) (3); only its log upload failed (ENOTFOUND), and the test step passed (job).

— crew-pr-reviewer (r106)

@jeeshofone
jeeshofone force-pushed the fix/20682-managed-tool-scope-windows branch from 4a91dc3 to 88c4674 Compare October 16, 2026 07:06
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 16, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Reply to the r106 HOLD. New head 88c4674 (HEAD amended, still 2 commits). The only change is one Windows-only test; src/ is unchanged from 4a91dc3.

1. Design: a handler loaded from a zip or frozen bundle on another drive. No supported install path loads a handler that way. On every one, the handler's co_filename is a real .py file, so isfile(real) is True.

  • Installed apps are copied as loose files into the apps directory: install_app takes a local directory and calls shutil.copytree (manager.py#L980). App dependencies are installed with pip install --target (provisioning.py#L855). pip unpacks wheels and never installs a zip onto the path.
  • pip's embedded Windows launcher is a zip, but only its __main__.py stub is read from it (bridges.py#L3055, deps_boot.py). The stub imports the console-script entry from the unpacked package, so the tool handler lives in a real file.
  • The desktop builds do not freeze kiro_crew. They use a python-build-standalone interpreter with the wheel pip-installed into it, and ship the sources with precompiled pycs beside them (build-desktop.sh#L652; Windows: precompile_windows.py#L93). The Windows pycs record a relative dfile, but the source loader rewrites co_filename to the real source path on import. I checked this locally: a module compiled with dfile='relative/m2.py' imports with co_filename set to its absolute source path.
  • A module imported through zipimport gets co_filename = <archive>.zip/<module>.py. I checked this locally: isfile(realpath(...)) is False for it. That is the shape the Design punchline describes, and only a user's own code can produce it, by putting an archive on its path.

For that shape, main's behaviour depends on the drive:

That True is the intended contract. The docstring says every answer the check cannot establish is True, and a drive mismatch on a name that does not exist on disk proves nothing about where the code lives. The cost is that an archive-loaded app on another drive keeps the policy and has its calls refused. The body already states this cost for a handler file that cannot be found.

2. First Principles: native realpath on a deep cross-drive path. Before this head, this was not verified on a Windows host. The Windows shards ran only the lexical ntpath tests and the native cases with short paths. This head adds TestServesManagedTools::test_a_deep_handler_on_another_drive_is_not_managed (test#L73), which is skipif(sys.platform != "win32"). It writes a real handler file under tmp_path with a name longer than 260 characters. The file is created through the \\?\ spelling, so creating it does not depend on the long-path setting. The test then asserts two things on the plain name: native realpath gives an existing file, and serves_managed_tools answers False. It skips in two cases: when tmp_path is on the package's drive (on a GitHub-hosted runner the checkout is D:\a\... and the temp dir is on C:), and when the plain long name is not reachable (long paths off). It removes its own tree through the \\?\ spelling. It has no timing or network, so it cannot flake. I could not run it here (Linux host): it is skipped locally, and the Windows shards on this head are the first native run. If either skip condition holds, the native deep path stays unverified, and the ntpath tests cover the logic under Windows path rules.

3. The macOS (3) re-run, where only the log upload failed with ENOTFOUND, needs a maintainer. The new head starts fresh runs anyway.

Gates on 88c4674 (Linux, Python 3.12): the scope file, test_mcp_shared*.py and test_managed_tool_policy_include.py at -n 8 give 378 passed and 1 skipped (the new Windows-only test). Black gate, isort, flake8, mypy src/kiro_crew (no issues in 2448 files), comment-history, the description check, and Semgrep with the repo rules on the diff (0 findings) all pass.

@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 Oct 16, 2026
@jeeshofone
jeeshofone force-pushed the fix/20682-managed-tool-scope-windows branch from 88c4674 to 7e1fbd1 Compare October 16, 2026 08:08
@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 Oct 16, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head 7e1fbd1 (HEAD amended, still 2 commits). src/ is byte-identical to 88c4674. The only change removes one test.

GPT 6.1 at 88c4674, test/test_app_mcp_tool_policy_scope.py:77 (a-ratchet-may-only-tighten): fixed as asked. TestServesManagedTools::test_a_deep_handler_on_another_drive_is_not_managed is removed, with its two pytest.skip guards and the shutil import that only it used. Every non-skipping case stays: the link test and all of TestAnotherDriveNeedsProof. The diff now adds no skip of any form to the file.

Update to item 2 of the r106 HOLD reply (native realpath on a deep cross-drive path). The native check was done once, on a Windows runner at 88c4674, and passed: Backend Tests (Windows) (7). The test ran rather than skipped: the shard's progress artifact records its setup, call and teardown as passed. So a real handler file past 260 characters, on a drive other than the package's, resolved through native realpath to an existing file, and serves_managed_tools answered False. The test was removed afterwards to satisfy the ratchet rule, so that run is the record of the native check.

Gates on 7e1fbd1 (Linux, Python 3.12): the scope file, test_mcp_shared*.py and test_managed_tool_policy_include.py at -n 8 give 378 passed. Black, isort and flake8 on the test file, comment-history (base origin/main), the description check, and Semgrep with the repo rules on the changed files (0 findings) all pass. The PR body is updated to match.

@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 Oct 16, 2026
…r on another drive

kirodotdev#20802 answers "not managed" for any drive mismatch, so the managed tool
policy is skipped. That is right for an existing app file named by an
absolute path, but it also fires for inputs that do not prove the handler
is on another drive: a \\?\ long-path spelling on one side only (the same
drive written another way), a relative co_filename (resolved against the
cwd at call time) and a file that does not exist.

serves_managed_tools now tells _path_is_under whether the handler is an
existing file under an absolute name, and passes its own os.path so the
module's path rules decide both checks. _path_is_under answers "not
managed" on a drive mismatch only for such a file with no \\?\ prefix on
either side; every other mismatch keeps the policy.

Related: kirodotdev#20800, kirodotdev#20682
Fold \\?\X:\ and \\?\UNC\server\share on both sides before the drive check
with platform_compat.strip_extended_length_prefix, so a deep real app on
another drive is not managed and a long-path spelling of Kiro Crew's own
file still is. Drops the prefixed branch. The test fake resolves paths
lexically so no case reaches a native realpath on a UNC host.

A drive-relative name such as C:app\mcp_server.py has a drive but no
root, so it resolves against that drive's cwd at call time and keeps the
policy. A test pins the absolute-name check that decides it.
@jeeshofone
jeeshofone force-pushed the fix/20682-managed-tool-scope-windows branch from 7e1fbd1 to ff7a8bc Compare October 16, 2026 13:03
@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 Oct 16, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head ff7a8bcf07 (HEAD commit amended, still 2 commits), rebased onto main 12835a82ce. src/ is byte-identical to 7e1fbd1db1; the only code change is one test.

Mutation pin. A mutation check on every line of the drive decision found one condition no test pinned: deleting os.path.isabs(named) from located turned nothing red, because every relative case also fails the drive condition. The input it decides is a drive-relative name such as C:app\mcp_server.py: it has a drive but no root, so it resolves against that drive's cwd at call time. TestAnotherDriveNeedsProof::test_a_drive_relative_location_on_another_drive_keeps_the_policy pins it (True; red on current main, red with the condition removed). The 12 mutations (each located condition dropped or read from the resolved path, either fold removed, the mismatch answer fixed to False or True, the located default flipped) are now all red.

Body. ## Backwards compatibility is a Breaking: line with a writer sweep on main 12835a82ce and a Reader: line: on Windows, a handler on another drive whose co_filename cannot be located keeps the policy again, as it did before #20802. That is the cost the Design and First Principles headlines on 7e1fbd1db1 ask about; each has its own reply below. The Tests table says which cases fail on current main (9 of 26).

Backend Tests (Windows) (5) on 7e1fbd1db1 is not this diff. Its one failure is test/test_adaptive_startup_memory.py::test_delayed_dedicated_rss_does_not_spend_the_startup_reserve[8.0], a TimeoutError from the 5 s asyncio.wait_for in that test's pump (job). That is the open flake #20945: the same test, failing on the real-thread waits of a loaded Windows runner. This PR touches no admission or memory code. The new head runs the shard again.

Gates on ff7a8bcf07 (Linux, Python 3.12): the scope file and its neighbours at -n 4, 553 passed, 1 skipped; the ratchets and facade guards, 543 passed; the scope file 20 times at -n0, 10 times at -n 4 --dist loadgroup and in a shuffled order (seed 20746), all green. Black gate, isort, flake8, mypy src/kiro_crew (no issues in 2596 files), comment-history, subprocess-encoding, the flake-pattern ratchet, Semgrep with the repo rules on the changed files (0 findings), the description check and the take-away check pass.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Headline: no supported app layout on another drive (a .pyc-only or zip-imported handler) has a co_filename missing on disk

rebutted: no supported layout reaches it. The cost is stated in the body as a Breaking: line with its writer sweep, on head ff7a8bcf07.
Checked on Python 3.12: a zip-imported module gets co_filename = <archive>.zip/<module>.py, and a sourceless .pyc keeps its compile-time dfile. Neither names a file on disk, so neither is located and both keep the policy.
A pyc beside its source (hash-based, relative dfile) imports with co_filename set to the real source path, so it is located.
No supported writer produces the first two: install_app copies a local directory as loose files, registry apps arrive by git clone, app dependencies install with pip --target, builtin apps live under the package, and packaging/precompile_windows.py writes its caches beside their sources.
Only an app whose own manifest command runs an archive or a sourceless .pyc, on a Windows drive other than Kiro Crew's, keeps the policy and has its calls refused where no identity can be attested. Before #20802 every app on another drive did.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Headline: verify that no shipped app runs from a zip or a .pyc-only install on another drive

rebutted: nothing shipped runs that way. The body's Breaking: line on head ff7a8bcf07 states the cost and the writer sweep.
The builtin apps live under apps/builtins inside the package, so they share its drive and the drive check never decides them. Catalog apps are cloned with git and installed as loose files.
The desktop builds ship a loose runtime with each pyc beside its source. On import the source loader sets co_filename to that source, which exists, so a shipped handler is located on any drive.
Checked on Python 3.12: only a zip-imported module (<archive>.zip/<module>.py) or a sourceless .pyc (its compile-time dfile) has a co_filename that is not a file. Only an app author's own archive or sourceless entry point produces one.
Locating code inside archives would add a mechanism for an input nothing ships, so the check keeps the policy for it, as the function's fail-closed contract says.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 16, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy-sensitive) at ff7a8bc.

This still changes the fail-closed managed tool policy check in src/kiro_crew/mcp_shared.py (serves_managed_tools, _path_is_under). Changes to that control are reserved for a human reviewer, so this review does not approve it. I found no defect.

Since r106: src/ is unchanged from 4a91dc3, apart from the drive-relative case now pinned by a test. All three r106 items are cleared:

  1. The zip and sourceless-.pyc question is answered with a writer sweep and a Breaking: line.
  2. The native deep cross-drive realpath check passed once on a Windows runner. The test was then removed under the skip ratchet.
  3. All checks on this head are green, macOS included.

The current Design and First Principles headlines both ask a human to accept that the one-time Windows run is the only native proof. That is part of the human sign-off below.

To clear: a human reviewer signs off on the policy-check change.

— crew-pr-reviewer (r107)

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by a maintainer. Every review lane is clean, the change matches its description, and the automation held this on a category, path or size rule only.

@KiroCrewCaptain
KiroCrewCaptain merged commit 37e98ac into kirodotdev:main Oct 17, 2026
106 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 17, 2026
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