Skip to content

Commit 184dba5

Browse files
authored
Merge pull request #361 from PhysShell/claude/p037-a2-baseline-4a8e658
P-037 A2.0: evidence harness hardening + terminal-green baseline (T, R)
2 parents dd20493 + 5fd6bfa commit 184dba5

43 files changed

Lines changed: 21599 additions & 17 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,6 +2998,47 @@ jobs:
29982998
[ "$rc" -eq 1 ] || { echo "FAIL: expected exit 1 (findings), got $rc"; exit 1; }
29992999
case "$out" in *OWN001*) ;; *) echo "FAIL: the Rust core found no OWN001"; exit 1 ;; esac
30003000
echo "OK: Rust-default dogfood on ${{ matrix.os }} (own-check.sh)"
3001+
# P-037 A1.1 (#304). Both censuses run here because this is the one job that
3002+
# already has all three things they need — a .NET SDK for the extractor, a
3003+
# built Rust candidate, and a Python for the reference engine.
3004+
#
3005+
# Linux only, deliberately: both censuses are about the EXTRACTOR's output and
3006+
# the two engines' reading of it, neither of which is platform-shaped. The
3007+
# Windows leg of this job exists for own-check.ps1, which is a separate
3008+
# launcher implementation and is the thing Windows actually tests.
3009+
#
3010+
# NOT here: the full P-037 verdict/MOS snapshots. The verdict sweep is
3011+
# 137 files times two engines and the MOS gate additionally measures the
3012+
# independent repository C# tree. They are per-STEP evidence recorded under
3013+
# docs/evidence/, not per-push work. The cheap provenance and MOS-reader
3014+
# controls below ARE per-push so forgetting or hollowing the heavy gate is red.
3015+
- name: P-037 conformance controls + fact-shape census
3016+
if: matrix.os == 'ubuntu-latest'
3017+
run: |
3018+
export OWEN_RUST_CORE="$PWD/rust/target/release/own-cli"
3019+
# The four G-V4 / class-3 controls, on both engines against one record.
3020+
# Today's record must match; --post-a1 is expected to FAIL until the
3021+
# semantic cut lands and is therefore NOT run as a gate here.
3022+
python scripts/p037_controls.py --engine both
3023+
# The eleven fact shapes. This is the census that exists because the
3024+
# 137-file VERDICT corpus reported UNCHANGED for a version of a1 that
3025+
# turned six jobs in this very workflow red: verdict coverage is not
3026+
# syntax/fact-shape coverage, and one fixture per shape fails by NAME.
3027+
python scripts/p037_fact_shapes.py check --engine both
3028+
# A2.0: a recorded run remains evidence only while its measured
3029+
# implementation closure and exact input blob set stay unchanged.
3030+
python tests/test_p037_evidence.py
3031+
# Level 2 reads the whole MOS document through the existing common
3032+
# P-022 capture envelope. This cheap control pins that returns and
3033+
# unresolved fields cannot disappear behind a transfer-only projection.
3034+
python scripts/p037_mos_snapshot.py --selftest
3035+
# A2.0: the machinery a baseline run stands on, exercised where cargo,
3036+
# git and dotnet are real. Both Rust executables are built qualified
3037+
# (path from cargo's own compiler-artifact message, digest verified),
3038+
# the frozen repo population is derived, materialized from blobs,
3039+
# re-hashed and removed again. No baseline is taken here.
3040+
python scripts/p037_evidence.py artifacts
3041+
python scripts/p037_evidence.py population --source repo --materialize --cleanup
30013042
# The Windows launcher is a separate implementation, not a wrapper around
30023043
# the shell one, so the Windows leg has to go through it to mean anything.
30033044
- name: Own.NET's own tree, through own-check.ps1 on the Rust core

‎.gitignore‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ __pycache__/
22
*.py[cod]
33
*.egg-info/
44
.pytest_cache/
5+
.mypy_cache/
6+
# P-037 A2.0: frozen evidence populations, materialized from git blobs
7+
# (scripts/p037_evidence.py); never tracked, never dirty.
8+
.p037-population/
59
*.ownreport.json
610

711
# .NET build output (golden_arraypool demo)

‎corpus/p037-shapes/README.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# `corpus/p037-shapes` — the FACT-SHAPE census for P-037 A1.1
2+
3+
A small, deliberate census of the C# shapes whose **emitted facts** the A1.1
4+
steps must preserve or must change — not a second verdict corpus.
5+
6+
## Why this exists
7+
8+
A1.1-a1 taught the lesson the hard way. The 137-file verdict corpus reported
9+
`UNCHANGED` for a version of a1 that turned six CI jobs red, because it contains
10+
no method that returns its own disposable parameter and the repository's own
11+
tree does. The corpus is labelled for **verdicts**; the A1.1 steps change the
12+
**fact surface**.
13+
14+
> **verdict coverage ≠ syntax / fact-shape coverage**
15+
16+
Two hundred more random C# files would not have closed that gap. One fixture per
17+
shape does. Each case here pins what the extractor emits for a shape it is known
18+
to be sensitive to, so a step that changes a shape it did not mean to touch is
19+
caught by name rather than by a CI job failing somewhere downstream.
20+
21+
## Layout
22+
23+
<shape>/case.cs the minimal program
24+
<shape>/expected.json what the facts must look like, and the verdict
25+
26+
`expected.json` records `facts` (asserted structure of the emitted
27+
`functions[]` record) and `verdict` (the finding codes at warning severity).
28+
A case whose shape belongs to a step that has not landed carries
29+
`"status": "pending_a2"` with the contract it will be held to, and asserts
30+
today's facts meanwhile — so the diff a2 produces is visible per shape instead
31+
of aggregated into a number.
32+
33+
Checked by `scripts/p037_fact_shapes.py`, which names its engine explicitly
34+
(#262 Stage 3) and runs one extractor invocation per case.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// A statement-level call. The C# lowering emits a `call` op in exactly ONE
2+
// place and only for `var x = Foo(...)` — a call whose RESULT binds to a local.
3+
// `Inner(s, true);` as a statement produces no `call` node at all, so there is
4+
// nothing for a summary layer to specialise. Without this, F3 cannot be carried
5+
// through the existing summary layer at all.
6+
//
7+
// This is also where a2's zero-semantic-cut risk lives: a real `call` op is
8+
// already semantically active and MOS reads it, so emitting one here can move
9+
// an existing summary before the guarded kernel is anywhere near. The MOS
10+
// collapsed-view diff is what catches that.
11+
using System.IO;
12+
13+
static class ShapeStatementCall
14+
{
15+
static void Inner(Stream s, bool keep)
16+
{
17+
if (!keep)
18+
{
19+
s.Dispose();
20+
}
21+
}
22+
23+
static void Caller(string path)
24+
{
25+
var r = File.OpenRead(path);
26+
Inner(r, true);
27+
}
28+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"schema": "p037-fact-shape/1",
3+
"shape": "call-expression-statement",
4+
"status": "pending_a2",
5+
"why": "The heart of the a2 gap. The C# lowering emits a `call` op in exactly ONE place and only for `var x = Foo(...)` — a call whose RESULT binds to a local. `Inner(r, true);` as a STATEMENT produces no `call` node, which the recorded facts show: `Caller`'s body is `acquire:r`, `release:r` — the fabricated release — and no call at all. So F3 cannot be carried through the existing summary layer today: there is no node for a guarded summary to specialise.",
6+
"a2_contract": "a2 emits a real `call` op for relevant first-party statement-level calls. This is also where a2's zero-semantic-cut risk lives, and it must be measured rather than hoped: a real `call` op is ALREADY semantically active and MOS reads it, so emitting one here can move an existing summary long before the guarded kernel is anywhere near. A verdict that happens to stay the same is not a pass — an unintended MOS collapsed-view change means a2 began the semantic cut early, and the answer is to isolate it or restage, never to note that the tests are green.",
7+
"measured_at": "464308b",
8+
"facts": {
9+
"ShapeStatementCall.Inner": {
10+
"params": [
11+
{
12+
"name": "s",
13+
"line": 15
14+
}
15+
],
16+
"body": [
17+
"if:None@17",
18+
"then:release:s@19"
19+
]
20+
},
21+
"ShapeStatementCall.Caller": {
22+
"params": null,
23+
"body": [
24+
"acquire:r@25",
25+
"release:r@26"
26+
]
27+
}
28+
},
29+
"verdict": {
30+
"rust": [],
31+
"python": []
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// A reduced EXTENSION method. Roslyn's reduced symbol drops the `this`
2+
// parameter from `Parameters`, but the summary lives on the UNREDUCED
3+
// declaration where the receiver is parameter 0. a2 must synthesise
4+
// receiver -> declared parameter 0
5+
// timeout -> declared parameter 1
6+
// or `CallReleasesReceiver` can never be honestly retired: the guarded
7+
// summaries would be complete except for one old tunnel under the fence.
8+
using System.IO;
9+
10+
static class ShapeExtensionReceiver
11+
{
12+
static void WaitForDispose(this Stream self, int timeout)
13+
{
14+
if (timeout >= 0)
15+
{
16+
self.Dispose();
17+
}
18+
}
19+
20+
static void Caller(string path)
21+
{
22+
var s = File.OpenRead(path);
23+
s.WaitForDispose(5);
24+
}
25+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"schema": "p037-fact-shape/1",
3+
"shape": "extension-receiver",
4+
"status": "pending_a2",
5+
"why": "A reduced extension method. Roslyn's reduced symbol drops `this` from Parameters while the summary lives on the UNREDUCED declaration, where the receiver is parameter 0.\n\nTwo things measured here, and the second was a surprise. (1) `CallReleasesReceiver` — the `ConsumesParam` consumer that handles this shape — is reached ONLY from two sites gated on `ThisFieldName(...)`: it is part of the FIELD disposal detector and never runs on a local. (2) Consequently `var s = ...; s.WaitForDispose(5);` is charged OWN001 even when the extension disposes its receiver UNCONDITIONALLY — verified with an unguarded probe, so it is not the guard doing it. That is a pre-existing false positive of exactly the family P-037 addresses (a first-party callee that releases, unrecognised), arriving through the RECEIVER rather than the argument. It is not A1's to fix and is recorded here so it is not mistaken for something A1 caused.",
6+
"a2_contract": "a2 synthesises the receiver binding against the UNREDUCED declaration: receiver -> declared parameter 0, `timeout` -> declared parameter 1. Without it `CallReleasesReceiver` can never be honestly retired — the guarded summaries would be complete except for one old tunnel under the fence, on the field path where nobody is looking.",
7+
"measured_at": "464308b",
8+
"facts": {
9+
"ShapeExtensionReceiver.WaitForDispose": {
10+
"params": [
11+
{
12+
"name": "self",
13+
"line": 12
14+
}
15+
],
16+
"body": [
17+
"if:None@14",
18+
"then:release:self@16"
19+
]
20+
},
21+
"ShapeExtensionReceiver.Caller": {
22+
"params": null,
23+
"body": [
24+
"acquire:s@22",
25+
"use:s@23"
26+
]
27+
}
28+
},
29+
"verdict": {
30+
"rust": [
31+
"OWN001:warning@22"
32+
],
33+
"python": [
34+
"OWN001:warning@22"
35+
]
36+
}
37+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// The same call with `false`. The two constants must be distinguishable in the
2+
// facts: a single "is a constant" bit would collapse the exact distinction the
3+
// cell selection turns on.
4+
using System.IO;
5+
6+
static class ShapeConstFalse
7+
{
8+
static void Inner(Stream s, bool keep)
9+
{
10+
if (!keep)
11+
{
12+
s.Dispose();
13+
}
14+
}
15+
16+
static void Caller(string path)
17+
{
18+
var r = File.OpenRead(path);
19+
Inner(r, false);
20+
}
21+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"schema": "p037-fact-shape/1",
3+
"shape": "guard-bool-const-false",
4+
"status": "pending_a2",
5+
"why": "The same call with `false`. Present so the two constants are distinguishable in the facts: a single `is a constant` bit would collapse the exact distinction cell selection turns on, and would do it invisibly.",
6+
"a2_contract": "{\"param\":1,\"kind\":\"bool_const\",\"value\":false}; Rust derives `const-neg`.",
7+
"measured_at": "464308b",
8+
"facts": {
9+
"ShapeConstFalse.Inner": {
10+
"params": [
11+
{
12+
"name": "s",
13+
"line": 8
14+
}
15+
],
16+
"body": [
17+
"if:None@10",
18+
"then:release:s@12"
19+
]
20+
},
21+
"ShapeConstFalse.Caller": {
22+
"params": null,
23+
"body": [
24+
"acquire:r@18",
25+
"release:r@19"
26+
]
27+
}
28+
},
29+
"verdict": {
30+
"rust": [],
31+
"python": []
32+
}
33+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// `Inner(s, true)`: a BOOL CONSTANT argument. a2 must record it as
2+
// {"param":1,"kind":"bool_const","value":true}; Rust derives `const-pos`.
3+
// The frontend never names const-pos itself — that is an interpretation
4+
// relative to the callee's elected guard, and it belongs to Rust.
5+
using System.IO;
6+
7+
static class ShapeConstTrue
8+
{
9+
static void Inner(Stream s, bool keep)
10+
{
11+
if (!keep)
12+
{
13+
s.Dispose();
14+
}
15+
}
16+
17+
static void Caller(string path)
18+
{
19+
var r = File.OpenRead(path);
20+
Inner(r, true);
21+
}
22+
}

0 commit comments

Comments
 (0)