Skip to content

fix(pi): invoke Bash helpers correctly on native Windows - #3843

Merged
kunchenguid merged 9 commits into
kunchenguid:mainfrom
cr101:fix/3838-windows-pi-shell-invocations
Sep 6, 2026
Merged

kunchenguid merged 9 commits into
kunchenguid:mainfrom
cr101:fix/3838-windows-pi-shell-invocations

Conversation

@cr101

@cr101 cr101 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Implement upstream issue #3838 by fixing every affected Pi extension Bash invocation seam on native Windows while preserving macOS/Linux behavior and existing failure contracts, with native-Windows regression coverage at the actual extension seams. Reconcile PR #3843 with current main: preserve upstream #3865's removal of commands.test and its intent-targeted validation policy, remove this branch's now-obsolete no-mistakes command/documentation workaround, retain the Pi implementation and relevant Windows regression selection/line-ending support, submit the updated PR through no-mistakes, and do not merge it.

What Changed

  • Route Pi session-start, pre-tool, turn-end, and operational-input Bash helpers through bash on native Windows while retaining direct invocation elsewhere.
  • Route OpenCode operational-input helpers through bash on native Windows.
  • Add native-Windows Pi seam coverage, select it for related changes, enforce LF shell-script checkouts, and accommodate MSYS permission emulation in parallel test workers.

Risk Assessment

✅ Low: Captain, the Windows-only Bash routing preserves non-Windows behavior and failure contracts, with focused behavioral coverage for every affected seam.

Testing

Under native Git Bash with Node reporting win32, the end-to-end Pi test exercised every affected extension seam, including async branch-outcome encoding through bash, and passed. The focused runner assertions confirmed changed-path coverage plus MINGW/MSYS-only mode accommodation; Git checkout evidence confirms the LF policy. The broader runner-contract script was stopped after these relevant assertions because unrelated portable-shard checks were exceptionally slow on this host.

Evidence: Native Windows Pi seam validation

Source: Native Windows Pi seam validation

Native Git Bash transcript: Pi session-start, pre-tool, turn-end, synchronous operational-input, and async branch-outcome seams passed; changed-selection and MINGW/MSYS worker-mode assertions also passed.
Evidence: Git LF checkout validation

Source: Git LF checkout validation

PASS: Git checkout materialized probe.sh with LF under repository .gitattributes policy
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (26m5s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ .no-mistakes.yaml - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • ⚠️ tests/fm-pi-windows-shell-invocation.test.sh:66 - Intent requires “native-Windows regression coverage at the actual extension seams.” This test only invokes synchronous classifyFirstmateOperationalText; it does not exercise the changed async encodeFirstmateOperationalInputWith path used by branch-outcome delivery. Cover that async branch-outcome seam and assert its encoded result.

🔧 Fix: Cover async Windows branch-outcome Bash invocation
2 warnings still open:

  • ⚠️ bin/fm-test-run.sh:2169 - The new Windows exemption also disables 0700 worker-root verification for CYGWIN*. A Cygwin worker whose mode reads as 755 now succeeds, contradicting the accepted requirement to retain strict POSIX enforcement while accommodating Git Bash's non-POSIX reporting. Restrict the exemption to MINGW*|MSYS*.
  • ⚠️ tests/fm-pi-windows-shell-invocation.test.sh:1 - The added test enters the derived portable-serial lane without a timing hint, leaving the serial hint/count and shard-balance documentation stale despite the documented requirement to refresh when that lane gains scripts. Add measured timing evidence and update the hint and derived shard documentation.

🔧 Fix: Preserve Cygwin checks and refresh Windows timing
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 .opencode/plugins/lib/fm-operational-input.js:16 - tests/fm-operational-input.test.sh fails on native Windows: the unchanged OpenCode adapter spawns bin/fm-operational-input.sh directly and Node reports spawn EFTYPE. This is outside the Pi extension changes but prevents that existing cross-language protocol regression from passing on this host.
  • C:\Program Files\Git\bin\bash.exe bin/fm-test-run.sh tests/fm-pi-windows-shell-invocation.test.sh with Git Bash first on PATH (passed).
  • git check-attr text eol -- bin/fm-test-run.sh tests/fm-pi-windows-shell-invocation.test.sh (both resolve to text and eol=lf).
  • C:\Program Files\Git\bin\bash.exe bin/fm-test-run.sh tests/fm-operational-input.test.sh (failed: unchanged OpenCode adapter direct-spawn behavior on native Windows).
  • Started tests/fm-test-run.test.sh and the runner’s changed-selection/coverage checks; stopped them after they spent the focused-test window enumerating the repository’s broad families rather than executing the new Pi seam test.

🔧 Fix: Invoke OpenCode operational-input owner through Bash on Windows
✅ Re-checked - no issues remain.

  • Baseline: bash --version and node -p "process.platform + ' ' + process.version" (host default was WSL Bash, so native Git Bash was used).
  • C:\Program Files\Git\bin\bash.exe: bin/fm-test-run.sh --jobs 1 tests/fm-pi-windows-shell-invocation.test.sh tests/fm-operational-input.test.sh tests/fm-test-run.test.sh in an LF-normalized temporary checkout; Pi seam and relevant runner assertions passed.
  • Manual Git checkout probe with core.autocrlf=true and the repository .gitattributes, verifying a checked-out .sh contains no CRLF.
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously missing changed-file mappings now select the native-Windows regression for both affected Pi extension paths.

Reviews (4): Last reviewed commit: "no-mistakes(ci): Fixed PR-caused changed..." | Re-trigger Greptile

@@ -0,0 +1,82 @@
#!/usr/bin/env bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Windows regression is not selected

The new test is absent from the changed-file mappings used by fm-test-run.sh --changed, while non-Windows CI hosts skip its assertions. As a result, the configured validation path can pass without exercising this native-Windows regression coverage; register the test for the Pi extension paths it covers.

Knowledge Base Used: Operational tooling and verification

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@cr101
cr101 force-pushed the fix/3838-windows-pi-shell-invocations branch from a80f3d2 to 9c5a019 Compare September 6, 2026 21:40
@cr101 cr101 changed the title fix(pi): invoke extension Bash helpers through Bash on Windows fix(pi): invoke Bash helpers correctly on native Windows Sep 6, 2026
…g the malformed tracked evidence artifact and allowing deleted, unconsumed source paths to retire cleanly while preserving fail-closed behavior for live unmapped paths. Added regression coverage. Verified native-Windows Pi shell-seam test passes and --changed selects the Windows regression
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Triage of HEAD 941e50b66b1e4168c9baeb4f63932e32de6ae0a1 (helps issue #3838 Windows Pi spawn EFTYPE).

Contract-class: restore — unconfigured Pi on native Windows already promised to run tracked Bash helpers; direct spawn(.sh) throws EFTYPE and disables pre-tool / turn-end. Diff routes session-start, pre-tool, turn-end, and operational-input through bash on win32 only; macOS/Linux stay direct. Supporting: .gitattributes *.sh text eol=lf, MINGW/MSYS worker-mode exemption, changed-selection for the new Windows seam test + retired unconsumed source paths (fail-closed retained for live unmapped).

Attestation: MATCH (941e50b6…).
workflow-zero: yes (no .github/workflows/*).
Fork CI: approved this pass — CI 34062587275, NM synchronize 34062587233 / edited 34062588518 (edited SUCCESS; synchronize was body-race). Waiting on CI to finish.

VISION (brief): aligns — fleet survives Windows Node EFTYPE; scripts stay owners of helpers; authority unchanged; no new default consent. Align paragraph: restores a broken promised path.

Will squash-merge when CI + NM are green on this HEAD.

@kunchenguid
kunchenguid merged commit d8e2bb3 into kunchenguid:main Sep 6, 2026
15 of 16 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @cr101 — really appreciate you taking the time on this.

HEAD 941e50b66b1e4168c9baeb4f63932e32de6ae0a1 · attestation MATCH · CI 34062587275 SUCCESS · NM edited 34062588518 SUCCESS · squash d8e2bb327407cbd28a7b42ef8ca3b541792fc3be. Helps #3838 (Windows Pi EFTYPE).

@cr101
cr101 deleted the fix/3838-windows-pi-shell-invocations branch September 6, 2026 22:53
eduardstan added a commit to eduardstan/firstmate that referenced this pull request Sep 7, 2026