Repository navigation
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
serves_managed_tools decides whether the managed tool policy applies by asking os.path.commonpath whether the handler's code file sits under the package directory. commonpath raises ValueError when the two paths sit on different drives, and the catch-all except answered True (managed). On a GitHub-hosted Windows runner the checkout lives on D: while pytest's tmp_path lives on C:, so every stand-in app module was judged managed and Backend Tests (Windows) went red on every fork PR. A file on another drive cannot be inside the package directory, so a ValueError from commonpath is a known False, not an unknown. OSError from realpath still fails closed to True.
0c13b59 to
3aa491f
Compare
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that [DESIGN-REVIEWED] 6f8201c Description read[DESCRIPTION-READ] b1ea18a262782f6802b277e23fb76b86ab695b1f2fcb9e9fc7ce89c61a4860b8 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Before merging, confirm that What this change shipsInventory (4 items) — 4 justifiedIntent: make the Windows backend tests pass again on fork PRs by treating an app handler on a different drive as outside the Kiro Crew package. FIX. Evidence: a linked red run, two named failing tests, and a new test that fails on base.
[FIRST-PRINCIPLES-REVIEWED] 6f8201c Description read[DESCRIPTION-READ] 7691ac9fee8d9aa4b6c0b5d0ca71171cff7f7a67fa776dd5d145489bccf78c18 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
A commonpath refusal between two spellings of one drive (\\?\C: beside C:) keeps the fail-closed True; only a real drive mismatch is False. A realpath ValueError (embedded NUL in co_filename) stays fail-closed. The cross-drive tests build their handler with a code object rather than exec().
3aa491f to
6f8201c
Compare
|
Superseded by #20802 (merged 2026-10-15 17:16Z), which lands the same drive-safe containment check in |
Problem / Motivation
Goal:
Backend Tests (Windows)goes green again on fork pull requests.Since #20530 (9c65772) landed on 2026-10-15 05:44Z,
Backend Tests (Windows) (7)is red on EVERY fork PR against main.mcp_shared.serves_managed_toolsdecides whether the managed tool policy applies by askingos.path.commonpath([handler_file, package_dir])whether the handler's code sits under the package. On a GitHub-hostedwindows-latestrunner (which fork PRs use) the checkout lives onD:\a\...while pytest'stmp_pathlives onC:\Users\..., socommonpathraisesValueError: Paths don't have the same driveand the surroundingexcept (OSError, ValueError)answersTrue(managed). A stand-in app module intmp_pathis therefore judged to be Kiro Crew's own code, and these two tests fail:test/test_app_mcp_tool_policy_scope.py::TestServesManagedTools::test_a_handler_outside_the_package_is_not_managedtest/test_app_mcp_tool_policy_scope.py::TestAppServerSkipsThePolicyRead::test_an_app_tool_runs_when_no_identity_can_be_attestedExample red: https://github.com/kirodotdev/KiroCrew/actions/runs/38691894797/job/116289405538 (PR #20638). In-repo PRs run on the fleet's CodeBuild Windows runners where checkout and temp both live on
C:, so nobody in-repo sees it.The same bug also hits a real user: an app installed on a different drive from the Kiro Crew package is wrongly held to the managed tool policy, which is the exact defect #20530 set out to fix.
Why it matters
Every fork contributor has a required check red through no fault of their own, and the maintainers cannot tell a real Windows regression from this one until it is fixed. A user whose app lives on another drive than the Kiro Crew install gets every app tool call refused on the shared ACP runtime.
Not a goal
serves_managed_toolsdoes for handlers with no code location or for anOSErrorfromrealpath(both still fail closed toTrue).os.path.commonpathwithpathlib; the one-exception fix is the smallest change that makes the containment check drive-safe.What changed (motivation → approach → change)
Symptom: cross-drive
ValueErrorfromcommonpath→ root cause: the catch-allexceptturns a known answer ("not under the package directory") into the fail-closedTrue→ change: the containment check moves into_inside_package_dir(real, package_dir). On acommonpathValueErrorit compares the two paths' drives (_nt_drive: case-folded,\\?\/\\?\UNC\prefix stripped): different drives is a knownFalse; the same drive spelled two ways, or no drives at all, stays the fail-closedTrue.realpathkeeps its ownexcept (OSError, ValueError): return True, so an unresolvableco_filename(embedded NUL) still fails closed.Backwards compatibility
Compatible: handlers inside the package, partials and bound methods of package code, and handlers with no code location answer exactly as before. Only a handler on a different drive changes, from
True(wrong) toFalse.Removes nothing: no key, record, path or public function is removed or renamed.
Tests
Added to
test/test_app_mcp_tool_policy_scope.py::TestServesManagedTools(handlers are built from a code object viatypes.FunctionType(code.replace(co_filename=...)), noexec):test_a_handler_on_another_drive_is_not_managed(every platform): withos.path.commonpathraising the two-driveValueError, aC:handler against aD:package dir isFalse, also when spelled\\?\C:. Red on origin/main (no_inside_package_dir;serves_managed_toolsanswersTruefor the other-drive handler), green here.test_a_refusal_between_spellings_of_one_drive_keeps_the_policy:\\?\D:andd:against aD:package dir stayTrue.test_a_refusal_with_no_drives_at_all_keeps_the_policy: two POSIX paths under a refusingcommonpathstayTrue.test_a_handler_whose_path_cannot_resolve_keeps_the_policy: withos.path.realpathraisingValueError(what an embedded NUL does on POSIX), the answer staysTrue.test_a_handler_on_another_drive_letter_is_not_managed_on_windows(Windows only, no stub): a handler whose code file sits on a drive letter the package does not use isFalse.Evidence (worktree venv, Python 3.12, Linux, head 6f8201c):
pytest -n0 test/test_app_mcp_tool_policy_scope.py: 10 passed, 1 skipped.test_app_mcp_tool_policy_scope.py+test_mcp_shared.py(220 ids): 20x-n0seeded shuffles, 0 red; 10x-n 4 --dist loadgroupseeded shuffles, 0 red.scripts/local-gate.pybackend (related): 4394 passed, 3 skipped, 5 xfailed. The frontend lane did not run (worktree has nowebsite/node_modules); the diff is backend-only.check_black_formatting.py,check_subprocess_encoding.py,isort --check-only,flake8,mypy src/kiro_crew(0 issues in 2431 files),check_comment_history.py,check_brand_name.py,check_file_line_cap.py,test_flake_pattern_ratchet.py(56 passed): all green.Manual verification
N/A — unit coverage sufficient: the failing CI job is itself the reproduction, and the Windows-only test exercises the real two-drive path on the hosted runner for this PR.
Related Issues
Follow-up to #20530.
Pattern harvest
Rule candidate: review-prompt
Pattern:
os.path.commonpath(or any path-containment check) wrapped in anexceptthat returns the permissive/fail-closed default; on Windows two absolute paths on different drives raiseValueError, so the except silently flips the answer only on hosted two-drive runners.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.