Skip to content

Commit ba1d4cf

Browse files
authored
Merge pull request #349 from PhysShell/claude/checkpoint-0-execution-ggdagx
feat(launcher): opt-in Rust engine behind the existing launcher (#262 Stage 1) Merged under owner authority bound to the exact reviewed head 157b689. Stage 1 only (opt-in Rust behind the launcher; Python stays default and reference); grants no Stage-2 authority.
2 parents 46a0d8a + 157b689 commit ba1d4cf

27 files changed

Lines changed: 4674 additions & 79 deletions

‎.gitattributes‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Shell scripts must arrive with LF endings on every platform.
2+
#
3+
# `scripts/own-check.sh` is executed by git-bash on Windows (#262 Stage 1's
4+
# engine controls run it there). A checkout with the Windows default
5+
# `core.autocrlf=true` would rewrite it to CRLF, and bash cannot run a script
6+
# whose every line ends in a stray carriage return — it fails immediately, with
7+
# an exit code that looks like the script's own. No job had ever run this
8+
# script on a Windows runner before, so the defect was latent rather than new.
9+
#
10+
# Deliberately NARROW. This repository has byte-sensitive evidence (fixtures,
11+
# goldens, recorded campaign results) whose exact bytes are the contract, and a
12+
# blanket `* text=auto` would put those bytes at the mercy of a checkout
13+
# setting. #260 carries "a researched .gitattributes for byte-sensitive
14+
# evidence" as its own hygiene tail; this rule covers executable shell scripts
15+
# only and takes no position on that wider question.
16+
*.sh text eol=lf
17+
18+
# Campaign evidence is hashed BY BYTE, so it must not depend on a checkout
19+
# setting. `mutate_campaign.py` records the sha256 of the definition it ran,
20+
# and the gate refuses a result whose definition hash does not match. The
21+
# #262 Stage-1 Windows campaign runs on a windows-latest runner, where
22+
# `core.autocrlf=true` rewrote these files on checkout: the same definition
23+
# hashed 79ad1476f219 on Linux and 3dda13ce16d6 on Windows, and a run that
24+
# measured exactly the right tree was rejected as evidence for another tree.
25+
docs/evidence/*.json text eol=lf

‎.github/workflows/ci.yml‎

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎action.yml‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ inputs:
3232
description: "How findings are shown: error (default) or warning (advisory)."
3333
required: false
3434
default: "error"
35+
engine:
36+
description: >-
37+
Which analysis engine runs (#262 Stage 1): python (the DEFAULT and the
38+
reference), rust (the Rust core `own-cli ownir`), or compare (both over
39+
one captured input, exposing the reference's result only when they agree
40+
byte for byte). rust and compare require the candidate binary's absolute
41+
path in the OWEN_RUST_CORE environment variable — the Action does no
42+
discovery, so an unset or unusable OWEN_RUST_CORE is a configuration
43+
error (exit 2) and never a silent fall back to Python. compare is a
44+
development/CI seam for the migration, not yet a promised feature.
45+
required: false
46+
default: "python"
3547
fail-on-finding:
3648
description: >-
3749
Whether a FINDING fails the step. Default false: findings are published
@@ -89,10 +101,15 @@ runs:
89101
OWN_PATH: ${{ inputs.path }}
90102
OWN_FORMAT: ${{ inputs.format }}
91103
OWN_SEVERITY: ${{ inputs.severity }}
104+
OWN_ENGINE: ${{ inputs.engine }}
92105
OWN_FAIL_ON_FINDING: ${{ inputs.fail-on-finding }}
93106
OWN_SARIF_FILE: ${{ inputs.sarif-file }}
94107
OWN_CONFIG: ${{ inputs.config }}
95108
run: |
109+
# D2: the Action is one of the four launcher surfaces, but its
110+
# engine-selection SEMANTICS are own-check.sh's — it delegates rather
111+
# than re-implementing them, so the real fan-out is smaller than four
112+
# and there is exactly one contract to keep true.
96113
check="${{ github.action_path }}/scripts/own-check.sh"
97114
# P-035: forward an explicit own.toml to own-check when the caller set one.
98115
# Passed as data via OWN_CONFIG (never interpolated into the script body).
@@ -112,7 +129,8 @@ runs:
112129
sarif="${OWN_SARIF_FILE:-$RUNNER_TEMP/owen.sarif}"
113130
set +e
114131
"$check" --root "${{ github.action_path }}" --format sarif \
115-
--severity "$OWN_SEVERITY" "${config_args[@]}" --fail-on-finding -- "$OWN_PATH" > "$sarif"
132+
--severity "$OWN_SEVERITY" --engine "$OWN_ENGINE" "${config_args[@]}" \
133+
--fail-on-finding -- "$OWN_PATH" > "$sarif"
116134
rc=$?
117135
set -e
118136
echo "sarif-file=$sarif" >> "$GITHUB_OUTPUT"
@@ -143,7 +161,8 @@ runs:
143161
# action is allowed to negotiate about.
144162
set +e
145163
"$check" --root "${{ github.action_path }}" --format "$OWN_FORMAT" \
146-
--severity "$OWN_SEVERITY" "${config_args[@]}" --fail-on-finding -- "$OWN_PATH"
164+
--severity "$OWN_SEVERITY" --engine "$OWN_ENGINE" "${config_args[@]}" \
165+
--fail-on-finding -- "$OWN_PATH"
147166
rc=$?
148167
set -e
149168
if [ "$rc" -ge 2 ]; then

0 commit comments

Comments
 (0)