@@ -108,6 +108,219 @@ jobs:
108108 - name: cargo test -p own-cli --features fault-injection (the failure-mode controls)
109109 run: cargo test -p own-cli --features fault-injection --test faults
110110
111+ # P-022 step 8 (#262) STAGE 1 — the launcher's engine-selection contract.
112+ #
113+ # Stage 1 makes the Rust core SELECTABLE while Python stays the default and
114+ # the reference. Every claim in that sentence is a behaviour, so this job
115+ # drives real launchers against a real candidate binary and asserts on the
116+ # observable result. It is deliberately BOTH platforms: the ratified evidence
117+ # is explicit Rust-selected runs on Windows and Linux, and the two differ in
118+ # exactly the mechanics (process launch, executable bits, path forms) that a
119+ # Linux-only job would leave unproven.
120+ #
121+ # OWEN_STAGE1_REQUIRE=1 is the zero-denominator guard: this job exists to
122+ # provide the toolchain, so a control that skips here is a control that did
123+ # not run, and a run of skips would otherwise be indistinguishable from a
124+ # green one.
125+ stage1-engine:
126+ name: owen --engine (#262 Stage 1 controls)
127+ strategy:
128+ fail-fast: false
129+ matrix:
130+ os: [ubuntu-latest, windows-latest]
131+ runs-on: ${{ matrix.os }}
132+ defaults:
133+ run:
134+ shell: bash
135+ steps:
136+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
137+ - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
138+ with:
139+ dotnet-version: "8.0.x"
140+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
141+ with:
142+ python-version: "3.13"
143+ - uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master, 2026-07-10
144+ with:
145+ toolchain: stable
146+ # The PRODUCTION candidate. The controls run the real `own-cli`, not a
147+ # stand-in: a control that proves a mock's behaviour proves nothing about
148+ # the binary the launcher will actually spawn.
149+ - name: Build the production own-cli candidate
150+ working-directory: rust
151+ run: cargo build -p own-cli --release
152+ # A second build with #261's off-by-default fault-injection feature, so
153+ # the failure-mode controls force failures through the real binary.
154+ - name: Build the fault-injection own-cli (forced failure modes)
155+ working-directory: rust
156+ run: cargo build -p own-cli --release --features fault-injection --target-dir target-fault
157+ # The controllable native candidate the compare controls need. Built
158+ # with plain `rustc`, deliberately NOT as a cargo workspace member, so it
159+ # cannot move the crate-edge DAG that #261's gate pins.
160+ - name: Build the Stage-1 stub candidate
161+ run: |
162+ ext=""
163+ if [ "${{ matrix.os }}" = "windows-latest" ]; then ext=".exe"; fi
164+ rustc -O tests/helpers/stage1_stub.rs -o "$RUNNER_TEMP/stage1-stub$ext"
165+ - name: Build the owen launcher
166+ run: dotnet build frontend/roslyn/OwnSharp.Cli/OwnSharp.Cli.csproj -c Release --nologo
167+ # The vendored Python core is a PACK-time payload, so a plain build does
168+ # not place it where the launcher looks. Staging it here is harness setup
169+ # for the Python-engine paths, not a production behaviour.
170+ - name: Stage the vendored core beside the built launcher
171+ run: |
172+ out=frontend/roslyn/OwnSharp.Cli/bin/Release/net8.0
173+ mkdir -p "$out/ownlang-core/ownlang"
174+ cp ownlang/*.py "$out/ownlang-core/ownlang/"
175+ - name: Stage-1 engine controls (no fail-fast)
176+ env:
177+ OWEN_STAGE1_REQUIRE: "1"
178+ run: |
179+ ext=""
180+ if [ "${{ matrix.os }}" = "windows-latest" ]; then ext=".exe"; fi
181+ export OWEN_RUST_CORE="$PWD/rust/target/release/own-cli$ext"
182+ export OWEN_STAGE1_RUST_FAULT="$PWD/rust/target-fault/release/own-cli$ext"
183+ export OWEN_STAGE1_STUB="$RUNNER_TEMP/stage1-stub$ext"
184+ export OWEN_STAGE1_LAUNCHER_DLL="$PWD/frontend/roslyn/OwnSharp.Cli/bin/Release/net8.0/ownsharp.dll"
185+ python tests/test_stage1_engine.py
186+ # The PowerShell surface's own controls. They run on BOTH legs — the
187+ # logic is platform-neutral and a Linux run catches regressions early —
188+ # but only the Windows leg is evidence for a PowerShell-targeted
189+ # mutation, which is what the stage1-windows-mutations job below settles.
190+ - name: Stage-1 PowerShell controls
191+ env:
192+ OWEN_STAGE1_REQUIRE: "1"
193+ run: |
194+ ext=""
195+ if [ "${{ matrix.os }}" = "windows-latest" ]; then ext=".exe"; fi
196+ export OWEN_RUST_CORE="$PWD/rust/target/release/own-cli$ext"
197+ export OWEN_STAGE1_STUB="$RUNNER_TEMP/stage1-stub$ext"
198+ python tests/test_stage1_ps1.py
199+ # The explicit Rust-selected run on this platform, through the shell
200+ # launcher, recorded as its own step so the evidence names the surface
201+ # and the platform rather than being inferred from a green job.
202+ - name: Explicit Rust-selected run through own-check.sh
203+ run: |
204+ ext=""
205+ if [ "${{ matrix.os }}" = "windows-latest" ]; then ext=".exe"; fi
206+ export OWEN_RUST_CORE="$PWD/rust/target/release/own-cli$ext"
207+ mkdir -p "$RUNNER_TEMP/stage1-sample"
208+ cat > "$RUNNER_TEMP/stage1-sample/Leak.cs" <<'CS'
209+ using System;
210+ using System.IO;
211+ public class Leaky
212+ {
213+ public void Run()
214+ {
215+ var s = new FileStream("x.txt", FileMode.OpenOrCreate);
216+ Console.WriteLine(s.Length);
217+ }
218+ }
219+ CS
220+ set +e
221+ out=$(bash scripts/own-check.sh --engine rust --format human --fail-on-finding -- "$RUNNER_TEMP/stage1-sample")
222+ rc=$?
223+ set -e
224+ echo "$out"
225+ [ "$rc" -eq 1 ] || { echo "FAIL: --engine rust expected exit 1 (findings), got $rc"; exit 1; }
226+ case "$out" in *OWN001*) ;; *) echo "FAIL: no OWN001 finding from the Rust engine"; exit 1 ;; esac
227+ echo "Rust-selected run OK on ${{ matrix.os }}"
228+ # The Windows twin of the shell surface. own-check.ps1 is never exercised
229+ # by the Linux legs, so its engine contract needs its own step here.
230+ - name: own-check.ps1 -Engine rust (Windows only)
231+ if: matrix.os == 'windows-latest'
232+ shell: pwsh
233+ run: |
234+ $env:OWEN_RUST_CORE = "$PWD/rust/target/release/own-cli.exe"
235+ $sample = Join-Path $env:RUNNER_TEMP "stage1-sample"
236+ & ./scripts/own-check.ps1 -Engine rust -Format human -FailOnFinding -- $sample
237+ if ($LASTEXITCODE -ne 1) { throw "own-check.ps1 -Engine rust expected exit 1, got $LASTEXITCODE" }
238+ # And the D3.1 seam on this surface: an unusable locator is exit 2.
239+ $env:OWEN_RUST_CORE = "C:\definitely\not\a\binary.exe"
240+ & ./scripts/own-check.ps1 -Engine rust -Format human -- $sample
241+ if ($LASTEXITCODE -ne 2) { throw "own-check.ps1 with a bad OWEN_RUST_CORE expected exit 2, got $LASTEXITCODE" }
242+ Write-Host "own-check.ps1 engine contract OK"
243+ # The assertions above ARE this step's verdict, so say so
244+ # explicitly. GitHub's pwsh wrapper appends `exit $LASTEXITCODE`,
245+ # and the last command here exits 2 ON PURPOSE — without this the
246+ # step would inherit the exit code of a case it was written to
247+ # require.
248+ exit 0
249+
250+ # P-022 step 8 (#262) Stage 1 — the WINDOWS-NATIVE mutation leg.
251+ #
252+ # A mutation whose target is scripts/own-check.ps1 is only `caught` when a
253+ # Windows PowerShell catcher observes the mutant and fails. Running those
254+ # mutants on Linux would execute the mutated PowerShell under a different
255+ # runtime, and the Windows-specific halves — the spawn seam above all —
256+ # cannot be settled there at all: a mutant that runs where its control is
257+ # weakest is decorative, and proves nothing about the surface it edits.
258+ #
259+ # The same is true of one arm of own-check.sh. A drive-rooted path is
260+ # absolute only where Windows resolves it, so a mutant of that arm changes
261+ # nothing a Linux runner can observe, and the Linux campaign would record it
262+ # as caught or survived on the strength of a question it never asked.
263+ #
264+ # So this campaign runs here, on Windows, and this job is the gate. It fails
265+ # unless every mutation is caught with its expected catcher and the
266+ # honesty control survives the unmutated tree.
267+ stage1-windows-mutations:
268+ name: Windows-native mutation campaign (own-check.ps1 + the drive-rooted locator arm)
269+ runs-on: windows-latest
270+ defaults:
271+ run:
272+ shell: bash
273+ steps:
274+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
275+ - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4
276+ with:
277+ dotnet-version: "8.0.x"
278+ - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
279+ with:
280+ python-version: "3.13"
281+ - uses: dtolnay/rust-toolchain@fa04a1451ff1842e2626ccb99004d0195b455a88 # master, 2026-07-10
282+ with:
283+ toolchain: stable
284+ - name: Build the production own-cli candidate
285+ working-directory: rust
286+ run: cargo build -p own-cli --release
287+ - name: Build the Stage-1 stub candidate
288+ run: rustc -O tests/helpers/stage1_stub.rs -o "$RUNNER_TEMP/stage1-stub.exe"
289+ - name: Run the Windows-native mutation campaign
290+ env:
291+ OWEN_STAGE1_REQUIRE: "1"
292+ run: |
293+ export OWEN_RUST_CORE="$PWD/rust/target/release/own-cli.exe"
294+ export OWEN_STAGE1_STUB="$RUNNER_TEMP/stage1-stub.exe"
295+ python scripts/mutate_campaign.py --campaign docs/evidence/p022-stage1-windows.json --run
296+ # The recorded run, printed in full so its provenance and per-mutation
297+ # catchers can be read off this job rather than taken on trust — and so
298+ # the committed record can be reproduced from a named CI run, the way
299+ # #260's sweep record is.
300+ - name: Print the recorded result
301+ if: always()
302+ run: cat docs/evidence/p022-stage1-windows.result.json
303+ - name: Assert every mutation was caught by a Windows catcher
304+ run: |
305+ python - <<'PY'
306+ import json, sys
307+ d = json.load(open("docs/evidence/p022-stage1-windows.result.json", encoding="utf-8"))
308+ defn = json.load(open("docs/evidence/p022-stage1-windows.json", encoding="utf-8"))
309+ exp = {m["id"]: set(m["expected_catchers"]) for m in defn["mutations"]}
310+ problems = []
311+ if d["control"]["outcome"] != "survived":
312+ problems.append("the honesty control did not survive the unmutated tree")
313+ for m in d["mutations"]:
314+ if m["outcome"] != "caught":
315+ problems.append(f"{m['id']}: {m['outcome']}")
316+ elif not exp[m["id"]] <= set(m["catchers"]):
317+ problems.append(f"{m['id']}: expected catchers missed ({m['catchers']})")
318+ print("\n".join(problems) if problems
319+ else f"all {len(d['mutations'])} mutations caught natively on Windows, "
320+ "each by the catcher its definition names")
321+ sys.exit(1 if problems else 0)
322+ PY
323+
111324 # P-022 step 7a (#260) — COMPARE MODE over the committed corpus: the FAST half
112325 # of #260's test matrix, and one leg of it. The five pinned OSS repositories,
113326 # the large-solution controls and the examples tree are the scheduled/manual
0 commit comments