Repository navigation
fix: escape % in the pi gate launcher's cmd paths on windows - #32142
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. This is a narrow fix at the root cause, with the same escaping rule as the existing Notes
[DESIGN-REVIEWED] 4f09a52 Description read[DESCRIPTION-READ] a3062cceb82675fccea661dfef605c76143015695b46f94068f2bf3570874cf8 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 Nothing blocks. The fix is aimed at the cause, a real Notes
What this change shipsInventory (4 items) — 3 justifiedIntent: on a Windows install whose pi or data-home path contains
[FIRST-PRINCIPLES-REVIEWED] 4f09a52 Description read[DESCRIPTION-READ] b916bfa58baba4c8a73f9d27d8cd9a4dfba8cb4d83309ffc26b2826cdc947f1e 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: |
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: |
|
Rebased: main moved in src/kiro_crew/acp/client.py, src/kiro_crew/acp/harness/codex.py, src/kiro_crew/acp/harness/kas.py, test/test_acp_bindings.py, test/test_acp_client_new_conversation.py, test/test_acp_provider_new_conversation.py, test/test_codex_sqlite_home.py, test/test_harness_parity.py since this head went green (8544127 -> b65af1a); CI re-running. |
e522729 to
3f6ebff
Compare
|
[operator: bolichen97] Backend Tests (3.12, 2) and Backend Tests (Windows) (2) fail only on test/test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget (package at 34855 lines vs a 34845 budget). This PR does not touch that package; the red comes from main and #32183 raises the budget. Waiting for it to merge, then rebasing. |
3f6ebff to
4f09a52
Compare
|
Rebased: main moved in. Old base |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 4f09a52, no conflict, no open change request.
(cherry picked from commit 1ab5673)
Problem / Motivation
Goal: On Windows, a
%in the pi path or the gate extension path reaches pi as written, so pi sessions on that install start.On Windows the pi harness writes a
.cmdlauncher that names the pi binary and the sealed gate extension. cmd.exe expands%NAME%in a batch file even inside double quotes, so a foldera%OS%breaches the harness asaWindows_NTb. A%in the pi path makes the launcher exit 1; a%in the extension path hands pi another file. Either way the gate read-back refuses every pi session, and the message does not point at the%.Why it matters
Windows allows
%in folder and account names. On such an install every pi session is refused before the first prompt, with a remedy (reinstall pi) that does not help.Not a goal
%inside the arguments the adapter forwards through%*. A batch file cannot escape those.%NAME%in the launcher's own path (the data home).cmd.exe /cexpands it before the batch runs; a lone%there works.What changed (motivation → approach → change)
cmd.exe re-expands
%in the launcher line, so the paths pi gets are not the paths Crew wrote. The Windows branch of_pi_gate_launcher_bodyinsrc/kiro_crew/acp/harness/pi.pynow passes both paths through a small local helper,_pi_cmd_literal, with the same rulepod/windows.py_cmd_literalalready uses:%doubles, and a", CR or LF is refused with anAcpErrornaming the path, because cmd.exe cannot express it. The helper is local so it raises the harness's own error, astesting/harness.pydoes.%*stays bare. The POSIX branch, the--extensionorder and the launcher cache key (raw values) do not change. A path without%gives byte-identical launcher text.Backwards compatibility
Compatible: a path without
%,"or a newline gives the same launcher bytes as before. A path with"or a newline already could not work (cmd.exe cannot quote it); it is now refused with a message naming it.Removes nothing: the change only escapes
%in two paths and refuses two shapes that could never run.Tests
test/test_acp_pi_backend.py::TestGateLauncher::test_the_windows_body_keeps_a_percent_in_either_path_literal: withIS_WINDOWSpatched,C:\a%OS%b\pi.cmdandC:\x%y\g.tscome out as%%,%*stays bare, and a path with"raisesAcpErrornaming it.test_acp_pi_backend.py,test_acp_pi_node_guard.py,test_acp_refactor_facade.py(506 passed, 36 skipped) andscripts/local-gate.py(5614 passed). Its 3 failures (test_pi_real_adapterpinned pi-acp version, twotest_pid_lifecyclereclaim tests) fail the same way on main on this host.TestGateLauncher(14 tests) run 10 times, each in a different shuffled order (seeds 0-9): 10 of 10 green. The new test is a pure function of its inputs.Proof: PROVEN test/test_acp_pi_backend.py::TestGateLauncher::test_the_windows_body_keeps_a_percent_in_either_path_literal (head e522729)
Manual verification
On native Windows 11, against the real module and real cmd.exe (
cmd.exe /d /c <launcher> --mode rpc, api.cmdstub that echoes its arguments):p%OS%i\pi.cmd,x%OS%y\gate.tsa%b\pi.cmd,c%d\gate.ts%The issue's portable script:
unescaped: FAIL rc=1,doubled: PASS rc=0.Real pi (pi.cmd from npm) gate read-back, data home
kc%27851: on main pi fails withExtension path does not exist: ...\kcrpc7851\...(cmd.exe read%2as the second argument), so the session would be refused; with this PR the gate extension loads from the sealed copy.Related Issues
Closes #27851
Refs #10439
Sibling sweep
Swept: git grep -n "@echo off" -- src
Sibling: src/kiro_crew/pod/windows.py:423 -- not affected -- already doubles % through _cmd_literal
Sibling: src/kiro_crew/testing/harness.py:429 -- not affected -- already doubles % in the exe path
Sibling: src/kiro_crew/apps/builtins/pptx_maker/backend/preview_tools.py:111 -- not affected -- already escapes through _cmd_escape
Pattern harvest
Rule candidate: review-prompt
Pattern: a path interpolated into a generated .cmd/.bat line without doubling % (cmd.exe expands it even inside quotes)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)