Skip to content

fix(config): refuse a link or junction at the workspace dir name - #14962

Merged
bolichen97 merged 1 commit into
mainfrom
fix/workspace-guard-junction-12358
Sep 29, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/workspace-guard-junction-12358

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On Windows, a directory junction at a workspace's dir is refused instead of being adopted as the workspace.

materialize_workspace_dir has a by-name arm, the one Windows takes because it cannot pin a parent descriptor. That arm adopts any name that answers is_dir(), and its EEXIST race check accepts is_dir() and not is_symlink(). A directory junction answers is_dir() True and is_symlink() False, so Kiro Crew registers it as the workspace and every later workspace write lands in the junction's target.

Why it matters

The function's own comment says a link cannot serve as a workspace. A junction is the one link an unelevated Windows user can make (mklink /J), so on Windows the guard misses exactly the link it is meant to stop. Writes then land outside the intended tree, and anything that later assumes the workspace is a real directory is wrong about it.

Not a goal

What changed (motivation → approach → change)

Symptom: a junction at the workspace name is accepted on Windows. Cause: both callers (the dashboard handler in src/kiro_crew/dashboard/handlers/files.py and the CLI in src/kiro_crew/cli_commands.py) resolve the dir before materialize_workspace_dir in src/kiro_crew/config/loader.py sees it. Resolving follows a link at the final name, so the guard only ever saw the target, on every platform. The config entry, though, stores the unresolved spelling.

Change: materialize_workspace_dir now takes the unresolved leaf as well, normalizes it, and refuses it when platform_compat.is_link_or_junction is true for it. Both callers pass it; the CLI takes it from _ws_dir_composed, the one composition its containment check also resolves. The by-name arm (Windows) also uses is_link_or_junction for its adopt and EEXIST checks, which catch a junction planted after resolution. A link ABOVE the final name is still followed, as before.

Case Before After
Windows: junction at the name adopted refused
POSIX: symlink at the name adopted (resolved away) refused
Any OS: plain, missing or racer's dir adopted / created same
Any OS: link in a parent followed followed

test/link_screen_sites.py records the function as a link-screen site that refuses every link, so it needs no held descriptor chain (regenerated with test/gen_link_screen_sites.py).

Backwards compatibility

Breaking: a workspace dir whose final name is a symlink (any OS) or a directory junction (Windows) is now refused with WorkspaceDirUnusable("workspace_dir_not_a_directory") instead of being adopted. Writer sweep on origin/main @ c4225bc: materialize_workspace_dir has exactly two callers, the dashboard create handler and the CLI create path; both pass leaf in this diff and already map the code to their refusal (a 409 body / an exit-1 message). Existing workspaces are not re-checked: only a new create goes through this function.

Tests

test/test_workspace_dir_link_guard.py, every case run on both arms (pinned, and by-name forced with supports_pinned_walk() -> False) and every call made the way the callers make it (resolve first, pass the leaf):

  • A real link made with platform_compat.symlink_or_junction (a junction on Windows shards, a symlink elsewhere) is refused after resolution, and its target stays empty.
  • A simulated junction (OS junction oracle patched, the fix: make the remaining is_symlink() guards see Windows junctions #11136 pattern) is refused on every platform.
  • A link reached as nope/../linked with nope missing is refused.
  • A plain dir is adopted untouched; a missing one is created; a linked PARENT is still followed.
  • By-name arm: a junction that appears after the leaf check, or wins the EEXIST race, is refused; a racer's plain dir is still adopted.

test/test_workspace_crud_cli.py: kirocrew workspace create --dir <link> exits 1 with the link message and registers nothing.

Red before: with the leaf check removed, the three link cases fail; with the by-name adopt check reverted to is_dir(), the swapped-in junction case fails. test_workspace_crud_handlers.py, test_workspace_crud_cli.py and test_link_screen_hold_pin.py pass.

Manual verification

N/A — no Windows host here. symlink_or_junction makes a junction only where os.symlink is refused, and CI's Windows runners can make symlinks, so no CI leg is guaranteed to build a real junction. The junction branch is pinned on every shard by the simulated-junction tests (the OS junction oracle patched, the #11136 pattern); the issue's reporter ran the real mklink /J probe against the same predicate.

Related Issues

Closes #12358

Pattern harvest

Rule candidate: review-prompt
Pattern: a link guard that inspects a path the caller already resolved, so the link at the final name is gone before the guard looks

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)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested a review from a team as a code owner September 29, 2026 07:02
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 29, 2026
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 651c588a61615282bfb32846ab8a27ea45e2ab97 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

No run anywhere composes a real Windows junction with this guard — the PR's headline case is verified only by a patched oracle and a third party's predicate probe.

Watch

The description's "no CI leg is guaranteed to build a real junction" is true only of the product helper symlink_or_junction, which junctions only when os.symlink is refused. A test can build a real junction deterministically on Windows shards via _winapi.CreateJunction (no privilege needed — platform_compat.py:7035 already relies on exactly that). Until one exists, if the real oracle disagrees with the _fake_junction simulation at this call site (e.g. the os.path.normpath(leaf) spelling), the guard silently misses on Windows, the adopted-junction bug #12358 claims to close stays open, and every test stays green.
Clears when: a Windows-only test creates a real junction with _winapi.CreateJunction and asserts materialize_workspace_dir refuses it, or the author reports the end-to-end create refusing a real mklink /J junction on a Windows host.

[DESIGN-REVIEWED] 651c588

Description read

[DESCRIPTION-READ] d9eb519567a6734060585e3a9ec58b3a10162b42de1994f2fc96414cbc4ce4a4

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 651c588a61615282bfb32846ab8a27ea45e2ab97 — 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 junction refusal on a real Windows host: no CI shard builds a real junction, so that leg rests on the patched oracle and the reporter's probe.

What this change ships

Inventory (7 items) — 7 justified

Intent: FIX — a workspace create must refuse a link/junction at the dir name instead of adopting it (issue #12358); the base EEXIST comment already pinned "a symlink cannot serve as a workspace".

  1. Windows create: a junction at the workspace dir name is refused instead of adopted — justified
  2. POSIX create: a symlink at the final name is refused instead of adopted via its target — justified
  3. Windows by-name arm: a junction planted after validation, including one winning the EEXIST race, is refused — justified
  4. materialize_workspace_dir now requires the unresolved leaf path (grepped: exactly 2 callers, both pass it) — justified
  5. CLI dir composition factored into _ws_dir_composed (2 consumers: containment check, create call) — justified
  6. test/link_screen_sites.py registers the function as a link-screen site — justified
  7. New tests pin both arms, the race, and the CLI exit-1 path — justified

[FIRST-PRINCIPLES-REVIEWED] 651c588

Description read

[DESCRIPTION-READ] c6e67a03f3cb1e78b787b2cbc04f0d54f7435b5df198d1bb0f32cd11fc12bbe6

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 Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 651c588a61615282bfb32846ab8a27ea45e2ab97 and found no blocking issues.

This comment is updated in place on each push.

Review details

FINDING -- src/kiro_crew/config/loader.py:979 -- "os.path.normpath(leaf)" checks the wrong leaf when .. follows a linked parent, allowing the actual final-name link to be registered -> Fix: probe leaf.parent.resolve() / leaf.name.
[GPT-REVIEWED] 651c588

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 651c588a61615282bfb32846ab8a27ea45e2ab97: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 651c588a61615282bfb32846ab8a27ea45e2ab97 — this comment is updated in place on each push.

Review details

No blocking issues; two gaps in the new leaf link screen.

FINDING — src/kiro_crew/config/loader.py:979 — os.path.normpath(leaf) collapses .. lexically while the leaf.resolve() the callers pass as validated applies .. to the already-symlink-resolved prefix, so the two disagree whenever a component above the .. is a link: with <home>/w/a → <home>/w/x/y and <home>/w/x/b → <home>/w/real, --dir "w/a/../b" resolves to <home>/w/real (adopted by the pinned arm) while the probe tests <home>/w/b, which is absent and not a link → the create registers dir = "w/a/../b", a spelling whose final component is a link and which workspace_dir_from_entry re-follows unresolved on every read → Fix: probe the final name under a resolved parent — platform_compat.is_link_or_junction(Path(os.path.realpath(leaf.parent)) / leaf.name) — which still catches the nope/../linked missing-component case and agrees with what resolve() landed on.

FINDING — src/kiro_crew/cli_commands.py:646 — the screen lives only in materialize_workspace_dir, which the CLI reaches solely in the else (no-copy) branch, so workspace create --copy-from default --dir linked with <home>/linked a dangling symlink skips it: _cli_validated_workspace_dst resolves it to <home>/target, dst_path.exists() is False, publish_dir_noreplace(staging, <home>/target) creates the target, and line 651 registers dir = "linked" — the link entry the new screen exists to refuse → Fix: screen _ws_dir_composed(ws_dir) once in _mutate_ws_create before the if staged_path is not None: split so both branches share it (note this is untouched code, so it cannot gate this merge).

[OPUS-REVIEWED] 651c588

Verdict parsed from the review's SHA-scoped output markers for commit 651c588a61615282bfb32846ab8a27ea45e2ab97.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 651c588a61615282bfb32846ab8a27ea45e2ab97: <one-sentence reason>

@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 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/workspace-guard-junction-12358 branch from 3729e59 to 2155dcd Compare September 29, 2026 07:27
@iamwhatever iamwhatever changed the title fix(config): refuse a Windows junction at the workspace dir name fix(config): refuse a link or junction at the workspace dir name Sep 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: junction check received an already-resolved target span=9ec07ed2ded9

Fixed in 2155dcd. materialize_workspace_dir now takes the unresolved leaf and refuses it when platform_compat.is_link_or_junction(leaf) is true, on every platform.
Both callers pass it: dashboard/handlers/files.py keeps unresolved_dir next to validated_dir; cli_commands.py composes the same leaf it resolved.
test/test_workspace_dir_link_guard.py now calls the function the way the callers do (resolve first, pass the leaf) on both arms; removing the leaf check reds the three link cases.

@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 29, 2026
@iamwhatever
iamwhatever force-pushed the fix/workspace-guard-junction-12358 branch from 2155dcd to 3609ac9 Compare September 29, 2026 07:40
@iamwhatever

iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author
  • fixed: CLI re-composes the unresolved leaf beside the validator span=90b2d4fd6488

Fixed in 3609ac9 by the item's second clear condition: test/test_workspace_crud_cli.py::test_create_refuses_a_link_at_the_workspace_dir runs kirocrew workspace create --dir <link> and asserts exit 1, the link message, and no registered entry.
The composition stays at the call site: _ws_dir_resolves_inside_home returns Path | None and its eight test assertions read that shape, so widening the return is a larger change than the Watch item asks; the new test pins that both compositions agree for a link.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: by-name adopt check had no test of its own span=15137de977ab

Fixed in 3609ac9: test_a_junction_swapped_in_after_the_leaf_check_is_refused passes a leaf that is not a link and a validated path that is a junction on the by-name arm.
Verified: reverting the adopt check to plain is_dir() reds that test; the rest stay green.

@iamwhatever
iamwhatever force-pushed the fix/workspace-guard-junction-12358 branch from 3609ac9 to a1b8a51 Compare September 29, 2026 07:55
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: link target traversed before refusal span=9ec07ed2ded9

Fixed in a1b8a51: both by-name checks now read not platform_compat.is_link_or_junction(validated) and validated.is_dir(), so a link short-circuits before is_dir() can follow it.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: body overclaimed a real-junction CI leg span=4d1c677a71b6

The description's Manual verification section no longer claims a Windows shard builds a real junction. It now says CI runners can make symlinks, so the junction branch is pinned by the simulated-junction tests on every shard, and the reporter ran the real mklink /J probe against the same predicate. Body edit only, no code change.

@iamwhatever

iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author
  • fixed: CLI re-composes the leaf beside the validator span=121d630201ca

Fixed in 651c588: new _ws_dir_composed is the single composition; _ws_dir_resolves_inside_home resolves it and the create passes it as leaf.

@iamwhatever

iamwhatever commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author
  • fixed: duplicate leaf composition in the CLI span=750018641d64

Fixed in 651c588: the inline recomposition is gone; the leaf comes from _ws_dir_composed, the same composition the containment check resolves.

Both workspace-create callers (dashboard handler, CLI) resolve the dir before materialize_workspace_dir sees it, and resolving follows a link at the final name, so the guard only ever saw the target. The function now also takes the unresolved leaf and refuses a symlink or directory junction there on every platform. The by-name arm (Windows) also uses platform_compat.is_link_or_junction for its adopt and EEXIST checks, which catch a junction planted after resolution.

materialize_workspace_dir is recorded in the link-screen baseline as a site that refuses every link, so it needs no held descriptor chain: it never continues through a link it screened.

Closes #12358
@iamwhatever
iamwhatever force-pushed the fix/workspace-guard-junction-12358 branch from a1b8a51 to 651c588 Compare September 29, 2026 08:18
@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • fixed: leaf screened as an unnormalized spelling span=964a6ea5f43f

Fixed in 651c588: the leaf is normpath-ed before is_link_or_junction, so nope/../linked with nope missing is refused; a test pins it on both arms and reds without the normpath.

@iamwhatever

Copy link
Copy Markdown
Contributor Author
  • rebutted: by-name adoption retains a junction-swap window span=9ec07ed2ded9

Pre-existing: main's by-name check (is_dir() and not is_symlink()) had the same same-user swap window; this PR does not add it.
Documented limit: materialize_workspace_dir's docstring states that where nothing can be pinned (Windows) both checks are by name.
Out of scope for #12358, which is the leaf junction the old check missed. A pin_directory hold across both callers' locked config write is its own change.

@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 Sep 29, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) September 29, 2026 16:28

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed on behalf of the maintainers (sweep 2026-09-29): readiness passed, required checks green on 651c588, no blocking review threads. Closes a guard bypass (callers resolved the link before the existing link check saw it); new-create only. Approving and merging.

@bolichen97
bolichen97 merged commit 4bb50ef into main Sep 29, 2026
99 of 105 checks passed
@bolichen97
bolichen97 deleted the fix/workspace-guard-junction-12358 branch September 29, 2026 16:59
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 29, 2026
bolichen97 added a commit that referenced this pull request Oct 1, 2026
…8.0 (#15666)

Backport of #14327, #14962, #15310 to release/0.8.0, cherry-picked in main's merge order.

* fix(windows): anchor six directory-link fences to pinned descriptors (#14327)
  (cherry picked from commit 6b0a6d5)
* fix(config): refuse a link or junction at the workspace dir name (#14962)
  (cherry picked from commit 4bb50ef)
* fix(windows): make four is_symlink guards see a junction (#12379, #10492) (#15310)
  (cherry picked from commit 6d54165)
bolichen97 added a commit that referenced this pull request Oct 1, 2026
… release/0.8.0 (#15619)

* fix(windows): backport the directory-junction hardening to release/0.8.0 (#15666)

Backport of #14327, #14962, #15310 to release/0.8.0, cherry-picked in main's merge order.

* fix(windows): anchor six directory-link fences to pinned descriptors (#14327)
  (cherry picked from commit 6b0a6d5)
* fix(config): refuse a link or junction at the workspace dir name (#14962)
  (cherry picked from commit 4bb50ef)
* fix(windows): make four is_symlink guards see a junction (#12379, #10492) (#15310)
  (cherry picked from commit 6d54165)

* style(test): black-format the failed-start reap test and drop its history wording on release/0.8.0 (#15665)

test/test_acp_runtime_failed_start_reap.py arrived with #15625 not
black-formatted (fails scripts/check_black_formatting.py on the release
tip), and the _gone docstring said "no longer runs", which
scripts/check_comment_history.py flags as history narration. Black 26.3.1
(--target-version py310) reflow, and the docstring now reads "has stopped
running", the wording the #15664 forward-port uses. Test file only.

* fix(adaptive): keep a same-window gate step from eating idle recovery (#15595)

Idle recovery (#15541) took its exec step only when nothing else had
changed on the sample. A spawn-gate increase earned on the same sample
set that shared flag, so the idle exec step due on it was skipped, and
the gate step also restarted the one-increase-per-window clock: the
exec cap then waited a further window for a step it had already been
due.

Judge the idle step on the exec track alone. Both tracks keep sharing
one increase-per-window clock across samples, as the earn rules do.

An increase's reason now names each track it moved: the exec note only
when the exec cap moved, and every gate step as "spawn gate target
X -> Y" (the policy's target; the daemon confirms or clamps it). A
gate-only step used to read "clean window earned +1", and a gate step
beside an exec step was not mentioned at all.

(cherry picked from commit f23a39f)

* fix(acp): treat only JSON whitespace as an empty mcp.json (#15673)

#15627 read an empty or whitespace-only MCP settings file as absent, using
bytes.strip() with no argument. That also strips \x0b and \x0c, which JSON
does not allow, so a file holding only those bytes read as "no restrictions"
instead of failing closed like any other malformed document. The emptiness
check now strips only space, tab, CR and LF (RFC 8259); anything else goes
to the parser and fails closed as before #15627.

Refs #15616

(cherry picked from commit 157fd51)

* fix(sandbox): backport the scope probe PATH and bus-path fixes to release/0.8.0 (#15638)

* fix(sandbox): keep the scope probe refresh off PATH, decode bus paths

Two defects the post-logout probe fix (#15622) introduced, from its
review:

- The probe now refreshes on a TTL, and every refresh resolved
  systemd-run with shutil.which on the event loop. A PATH entry on a
  stalled mount would hang the gateway's loop. The probe now uses
  platform_compat.trusted_system_bin, the same fixed-directory lookup
  cgroup_scope_argv already pins its wrapper with.
- DBUS_SESSION_BUS_ADDRESS unix:path= values may percent-escape any
  byte. Probing the escaped spelling literally misses a live bus that
  lives outside XDG_RUNTIME_DIR and drops the cgroup ceiling. The value
  is now decoded before it is dialed.

(cherry picked from commit e5a68df)
(cherry picked from commit 623f2b4)

* fix(sandbox): resolve the probe's systemd-run without any PATH walk

Second-round review of this PR: trusted_system_bin's miss diagnostic
still calls shutil.which, so a host with no trusted systemd-run walked
PATH on the event loop at the first probe refresh. The probe now uses
platform_compat.trusted_system_bin_quiet, the same fixed-directory
lookup without the diagnostic, and reports the miss in its reason.

A D-Bus unix:path= value that decodes to an empty path or one holding
a NUL cannot name a socket and made os.stat raise ValueError on the
spawn path; such values are now skipped.

(cherry picked from commit 5843231)

* fix(chat): restore the interrupted turn when Resume lands on a natively loaded session (#15643) (#15644)

* fix(chat): restore the interrupted turn when Resume lands on a natively loaded session (#15643)

kiro-cli appends a prompt to <sid>.jsonl only once the model has answered
it. When the process serving a turn dies mid-answer (a gateway restart, a
crash, a recycled runtime) that request is never written, so session/load
brings the conversation back without it. A natively resumed session gets
no Kiro Crew replay, so the Resume press on that turn sent a bare "finish
the user's most recent request" with the request missing: the model
answered the turn before it, or said there was nothing to continue.

Reproduced against kiro-cli 2.26.1: after a completed turn and a second
turn killed mid-stream, session/load restores only the first. The path is
any native resume: a dashboard chat with agent.tool_search off, a
dashboard chat linked to a channel, and the automatic connection-lost
recovery on a respawned runtime.

When the Resume message or the connection-lost recovery runs on a session
that this turn natively resumed, _run_chat now prepends the interrupted
turn from the slot's own transcript (the opener the turn-in-flight marker
restores, plus the partial answer), bracketed [INTERRUPTED TURN] so the
context scanner attributes it. A cold start that replays already carries
the turn and is unchanged. A session whose only turn was interrupted was
already covered: SessionMap.get prunes a sid whose log holds no turn.

Backport of #15643 to release/0.8.0. Conflict: context.py still carries
compress_thread_history here (removed on main by #14952); the new helper
is placed after it.

* fix(chat): open the interrupted-turn restore at the right row, and mint it after the scrub (#15643)

A cron, app or synthesis delivery opens its turn as an inject row. The
interrupted-turn walk only stopped at user, nudge and sub-agent rows, so
for such a turn it reached the already-answered request before it and
restored that as the user's most recent request. Openers now include the
inject kinds dashboard.state.TURN_OPENING_INJECT_KINDS names (the
dispatching kinds minus recovery and user_replay, which continue a turn).

The session-busy recovery (_BUSY_RECOVER_MSG) also resets the session and
session/loads the same native conversation, so it gets the restore too.

The frame tells the model the request inside it is the one to carry on
with, so its markers join _STRUCTURAL_MARKER_RES and the runner prepends
it after the egress scrub, like the task checklist; the builder scrubs
the restored payload itself.

The turn-in-flight marker now copies a sub-agent completion opener too
(_LOCAL_TURN_OPENER_ROLES / _LOCAL_TURN_PROMPT_ROLES): without it a crash
before the flush loses that row, and the restore would walk past it to
the previous, already-answered request.

* fix(mcp): repair Windows command casing at every resolver, not only the rewriter

On Windows `shutil.which` spells the extension it appends exactly as
PATHEXT spells it, so a bare `demo-mcp` resolves to `demo-mcp.EXE` while
the file on disk is `demo-mcp.exe`. A launcher that dispatches on its own
argv[0] basename case-sensitively (a tool manager's multiplexer shim)
refuses to run under that spelling and the MCP server never starts.

The rewriter already restored the on-disk basename, but the agent-config
resolver (`agent._resolve_command`) and the dashboard probe
(`mcp_discovery`) consumed raw `which` output, and the resolver's result is
PERSISTED as the spec's absolute `command`. An absolute command is accepted
verbatim on every later pass, so the uppercase spelling written once looked
operator-authored to the rewriter from then on and its repair never ran.

Move the helper to `kiro_crew.env.resolved_command_casing`, beside the
`mcp_search_path` the three resolvers already share, and apply it on both
return paths of `_resolve_command` and in the probe. Repairing at the
resolver also keeps the provenance record's `emitted` value repaired, so
`command_is_ours` still recognises the entry and re-derivation stays on.

Fixes #11627

(cherry picked from commit aa7c0bd, #15071;
 applied as its pre-#14919 revision 457210d plus the round-2 test
 and docstring delta, since release/0.8.0 predates the agent.py split)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: workspace create-only guard accepts a Windows junction as a valid workspace directory

2 participants