|
| 1 | +# P-037-X Stage 1 — canonical first-party call transport (EXPLORATORY) |
| 2 | + |
| 3 | +> Status: **EXPLORATORY research record, research branch `research/p037-max-v1` only.** |
| 4 | +> Track: P-037-X / P037-MAX, the capability-ceiling study of guarded ownership/effect |
| 5 | +> summaries. Protocol frozen BEFORE this code in Own.NET-paperwork |
| 6 | +> `paper-eval/prereg/p037-max-v1.json` (commit `69adf01`, sha256 `bbb08e3f…`). |
| 7 | +> This is **not** a production migration, **not** a reopen of #304 (the 2026-09-28 freeze |
| 8 | +> ruling stands unchanged), and **not** a P-037 implementation: no engine reads a guard value |
| 9 | +> at this stage. Never merged to `main`. |
| 10 | +> |
| 11 | +> Base: `main` at `fb06adc` (the #381 merge). Stage commits: `702d25b` (the carrier), |
| 12 | +> `2d2ba15` (the bridge tolerance), `4ed5eda` (the re-recorded census, controls and #380 pins), |
| 13 | +> and the commit that carries this note and the population evidence. |
| 14 | +> |
| 15 | +> Evidence tags as elsewhere: `REPOSITORY FACT`, `MEASURED OBSERVATION`, `INFERENCE`. |
| 16 | +
|
| 17 | +## 1. Question |
| 18 | + |
| 19 | +RQ-X1: how much capability returns if first-party calls are represented canonically instead |
| 20 | +of being pre-collapsed by the frontend? Stage-1 success is **not** "B1 green". It is: the |
| 21 | +core can SEE the call relationship without the frontend lying with unconditional |
| 22 | +`release`/`use` semantics. |
| 23 | + |
| 24 | +## 2. What was built (REPOSITORY FACT) |
| 25 | + |
| 26 | +One extractor change (`frontend/roslyn/OwnSharp.Extractor/Program.cs`, +219/−1 handwritten |
| 27 | +lines by the ledger rule) and one bridge tolerance (both engines, Python +14/−6, Rust +37/−16). No OwnIR |
| 28 | +schema field, no new op kind, no lattice, no guard read. |
| 29 | + |
| 30 | +**The rule, stated generically.** A statement-form invocation (`Foo(s);`, `await Foo(s);`, |
| 31 | +`await Foo(s).ConfigureAwait(false);`, `return Foo(s);`) of a resolved, non-reduced, |
| 32 | +ordinary first-party method that *will carry a `functions[]` record* is lowered as ONE |
| 33 | +existing OwnIR `call` op (spec/OwnIR.md §5 — the D5.2 op the bridge already reads as a |
| 34 | +forward edge) for every tracked handle that binds — by name, else by position, after the |
| 35 | +value-preserving unwrap of parentheses, `!` and identity/reference casts (A2.2 G-C, mined |
| 36 | +from #371 at `0ae8213`) — to one of the callee's owned-disposable parameters. `args` are |
| 37 | +positional over the callee's `params[]` list. Those handles get neither the legacy handoff |
| 38 | +`release` nor a `use` for the call, and a canonically forwarded local is not an escape. The |
| 39 | +extractor decides nothing about `must`/`may`/`no`: the MOS reads the callee's summary |
| 40 | +(INF-S3) and applies it (INF-A1, INF-A5). |
| 41 | + |
| 42 | +**Record prediction.** Whether the callee will carry a record is re-derived on the callee's |
| 43 | +own declaration with canonical emission off (a block body, a direct class member, an |
| 44 | +owned-disposable parameter, a body that lowers to at least one op). A callee without a |
| 45 | +record would read as extern → `unknown` and silence the caller, so such a call keeps the |
| 46 | +legacy lowering. Record absence is never read as a value, in either direction. |
| 47 | + |
| 48 | +**Degradation is counted, never hidden.** Every invocation into which a handle flows but |
| 49 | +that the rule cannot carry keeps the legacy lowering and is counted on stderr |
| 50 | +(`p037x: canonical=N degraded={reason=count,…}`): `unresolved_callee`, `reduced_extension`, |
| 51 | +`not_ordinary_method` (delegate invoke, local function), `not_first_party`, |
| 52 | +`callee_no_block_body` (expression-bodied, interface/abstract), `callee_not_class_member`, |
| 53 | +`callee_no_owned_param`, `callee_unmodelled` (unmodelled construct or empty body: the R |
| 54 | +boundary), `named_unresolved`, `ref_out`, `params_slot`, `non_owned_slot`, |
| 55 | +`gap_in_owned_slots` (a handle past an owned slot with no handle: positional `args` cannot |
| 56 | +express it without a filler the doors do not accept). |
| 57 | + |
| 58 | +**The bridge tolerance (both engines).** The carrier exposed a latent hazard: a `call` op |
| 59 | +whose argument names a handle the core never minted (a non-fresh first-party factory |
| 60 | +result, a branch-scoped acquire) reached the core as a raw name and hard-errored with |
| 61 | +OWN030, while a `use`/`release` of the same name has always been dropped silently. Measured |
| 62 | +on the pinned dotnet/runtime `HttpClient.cs` (case 2). Both engines now treat an unmapped |
| 63 | +call argument exactly like an unmapped `use`; a direct `Call` (which the core checks against |
| 64 | +the callee's signature) with an unmapped argument applies the callee's contract per mapped |
| 65 | +argument through the existing `$consume`/`$borrow` channel instead. Only documents that |
| 66 | +previously hard-errored can observe the change; every existing golden and parity fixture is |
| 67 | +unchanged (`tests/test_ownir.py` 282/282, `test_summaries_fixtures` 35/35, |
| 68 | +`test_lowered_fixtures` 27/27, `cargo test -p own-bridge` green). |
| 69 | + |
| 70 | +## 3. Challenge-set results (MEASURED OBSERVATION; the frozen expectations held on every row) |
| 71 | + |
| 72 | +45 documents, Rust and Python **byte-identical on every one**, 0 OWN030. |
| 73 | + |
| 74 | +| group | rows | baseline `fb06adc` | Stage 1 | frozen expectation | |
| 75 | +|---|---|---|---|---| |
| 76 | +| A: F3 pairs (4 × before/after) | 8 | silent on both sides | OWN051 advisory only, both sides | met: the guard is not read yet, so bug/safe stay undistinguished | |
| 77 | +| A: shapes on main | 14 | 9 caller records absent since #380 | the 9 caller records **return** with OWN051; `guard-forward-bare/negated` `Outer.s` `no → may`; 5 shapes unchanged | met | |
| 78 | +| A: B1 8 UNEXPLAINED coordinates | 8 | `no` (post-#380 legacy) | **`may` on 8/8** = A18-0's `L_canonical` (6 via the canonical call, 2 via the unwrap of `(Stream)p` / `p!`) | met | |
| 79 | +| B: #380 family | 10 | OWN002 ×2 | OWN002 ×2 kept; OWN051 ×4 at the partial callers; `BorrowingWrapper.borrowed` `no → may`; `ForwardDynamic.forwarded` `no → may` (the pin's own "canonical call facts arrived" branch) | met (XB-1…XB-10) | |
| 80 | +| B: gallery 07 anchor | 2 | OWN002 / silent | OWN002 / silent | met | |
| 81 | +| C: six real cases | 6 | see §4 | see §4 | met | |
| 82 | +| D: four conformance controls | 4 | no findings | OWN051 only; **no fabricated release, no OWN003, never consume**; `Outer.p` `no → may` | met (XD-1…XD-4) | |
| 83 | +| D: shape controls / mined A2.2 controls / B0 probes | 11 | — | `unresolved-callee` → `unresolved_callee=1`; `record-absence-boundary` → no canonical call (expression-bodied / empty-body callees never carry a record); `ref`/`params`/unstable-owned unchanged; B0 probes: 8 canonical, 2 `callee_unmodelled` (`Probe2.Log`, whose only use of its parameter sits in a local initializer: an R-boundary callee B1 also listed) | met (XD-5…XD-9) | |
| 84 | + |
| 85 | +The eight-row carrier result, in the words the protocol requires: **P-037-X Stage 1 moved |
| 86 | +the eight historically UNEXPLAINED B1 coordinates from the folded legacy value to the |
| 87 | +canonical value `may` merely by carrying the call.** It is an integration/carrier result. It |
| 88 | +is not evidence that the historical #373 FAIL was wrong: #373 measured the production carrier |
| 89 | +of its day, and that carrier folded these calls. |
| 90 | + |
| 91 | +## 4. The six real cases at Stage 1 (MEASURED OBSERVATION) |
| 92 | + |
| 93 | +| case | canonical / degraded | findings | what the carrier changed | |
| 94 | +|---|---|---|---| |
| 95 | +| 1 ImageHelpers.Outline | 3 / `unresolved_callee` 6, `callee_unmodelled` 1 | none | nothing at the frozen site: `Bitmap` is not a tracked disposable here (ANALYZER_SCOPE_LIMIT stands) | |
| 96 | +| 2 HttpClient.FinishSend | 10 / `unresolved_callee` 2, `not_first_party` 1, `not_ordinary_method` 1 | none (after the bridge tolerance; OWN030 before it) | ten first-party calls now reach the MOS; none is a frozen site — the CTS is tuple-deconstructed, not a tracked handle | |
| 97 | +| 3 EcmaAssembly.CreateModule | 1 / — | none | unchanged | |
| 98 | +| 4 SymmetricCngTestHelpers.VerifyPersistedKey | 2 / — | OWN001 ×2 (pre-existing: `CngKey.Delete` is not modelled as a release), **OWN051 ×2 at C12/C13** | the two caller records that #380 dropped **return**; the in-branch call to a `may` callee untracks `cngKey` (INF-A5b) with the honest advisory; no OWN009 | |
| 99 | +| 5 ArgumentSource.GetArguments | 14 / `callee_unmodelled` 1, `not_first_party` 2 | none | the public wrapper's call to the private iterator overload is `callee_unmodelled` (the iterator body carries no record: the R boundary), so the wrapper keeps the legacy `no` | |
| 100 | +| 6 AuthHandshakeMessageHandlerTests.SendResponseAsync | 0 / — | none | unchanged (using-declared listeners, local functions) | |
| 101 | + |
| 102 | +## 5. Population (MEASURED OBSERVATION) |
| 103 | + |
| 104 | +The complete before/after comparison, the sealed instruments' own outputs and the hand classification |
| 105 | +are the `population` object of the Stage 1 evidence file in Own.NET-paperwork |
| 106 | +(`paper-eval/p037-max/stage1-canonical-calls-v1.json`); this section is its digest. |
| 107 | + |
| 108 | +Four sealed snapshots per side (`scripts/p037_verdict_snapshot.py` rust/python, `scripts/p037_mos_snapshot.py` |
| 109 | +corpus/repo), population commit `fb06adc` on every side, `is_evidence: true`, `dirty: false`, before at |
| 110 | +`fb06adc`, after at `4ed5eda` (this stage's records commit). The sealed `compare` REFUSES `fb06adc → 4ed5eda` |
| 111 | +("the measurement instrument differs between before and after"): the bridge tolerance touched `ownlang/` and |
| 112 | +`rust/`, which the A2.0 instruments count as instrument, not treatment. That refusal is the instrument doing its |
| 113 | +job and is recorded as such. The comparison below is an unsealed diff of the two sealed snapshots; the sealed |
| 114 | +compare is taken instead across `fb06adc → 702d25b` (the carrier alone, a `Program.cs`-only change; sealed |
| 115 | +snapshots taken in a detached worktree at `702d25b`, `is_evidence: true`), and the tolerance is isolated as |
| 116 | +`702d25b → 4ed5eda` — both in the evidence file (`population.decomposition`). The sealed result for the |
| 117 | +carrier: `--level verdict` **UNCHANGED** on both engines (137 files, no verdict moved); `--level all` 12 of 137 |
| 118 | +files MOVED on both engines, every one an OWN051 note arrival on a challenge document, declared class |
| 119 | +EXPECTED_CARRIER_EFFECT; MOS corpus MOVED (facts 18, python 11, rust 11, after-parity 0); MOS repo MOVED |
| 120 | +(1 document, both engines). Every number equals the unsealed `fb06adc → 4ed5eda` comparison below: the whole |
| 121 | +population movement is the carrier's. The tolerance alone (`702d25b → 4ed5eda`): verdicts UNCHANGED on |
| 122 | +137/137 files on both engines, 0 transfer moves, 0 record changes on either population (the repo-tree facts digest differs by exactly 183 bytes: three `DiCaptiveSample.cs` records carry an absolute `file` path, so the digest depends on where the tree sits — the mid snapshot was taken in a worktree under the scratchpad; reproduced byte-for-byte with the instrument's own launcher invocation in both trees; a pre-existing extractor quirk on `main`, recorded for the owner, not fixed here). |
| 123 | + |
| 124 | +| population | moved | what moved | class | |
| 125 | +|---|---|---|---| |
| 126 | +| verdicts, 137 files, rust | 12 | OWN051 arrivals at note level, one per file; 0 error/warning-level movement; 0 exit changes | EXPECTED_CARRIER_EFFECT (INF-A5a advisory at a top-level canonical forward to a `may` callee) | |
| 127 | +| verdicts, 137 files, python | 12 | identical to rust; rust == python on all 137 files after | same | |
| 128 | +| which 12 | — | exactly the 8 F3 pair files and the 4 conformance controls — the challenge documents; no other corpus file moved | — | |
| 129 | +| MOS corpus, 137 documents | 18 facts digests | 12 challenge documents + 6 real-world `ownership-handoff-{consume,use,use-transitive}/{before,after}.cs` | the 6 real-world ones are representation-only: verdicts and summaries unchanged (op-level diff, base vs head extractor: the only change is each extractor-side `release` at a first-party definite-consumer call — `Archiver.Run/RunOk → Archive`, `HandoffUse.Run → Consume`, `HandoffUseTransitive.Run → Consume → Inner`, a two-level chain — replaced by one canonical `call`; the core derives the same `must` transitively and lowers it to `$consume`: the definite handoff is derived instead of fabricated, on real corpus documents) | |
| 130 | +| MOS corpus transfers | 6 coordinates × 2 engines | `no → may`: `GuardedNegation.Outer.s` ×2, `GuardedWrapper.Outer.s` ×2, `Guarded.Outer.p` ×2 (the mutated-guard and ref-alias controls) | L_canonical (A18-0): INF-S3 on a carried forward to a `may` callee; four are B1 UNEXPLAINED rows, two are the hostile-guard wrappers G-V4 requires to stay `may` | |
| 131 | +| MOS corpus records | +11 per engine, 0 lost | `Fine`/`Leak` on the 8 F3 files, `Guarded.Use` on 3 controls | the records #380 dropped return (a canonical forward is not an escape) | |
| 132 | +| MOS repo tree, 82 files | 1 document | `BorrowingWrapper.borrowed` and `ForwardDynamic.forwarded` `no → may` (rows XB-7, XB-8); +4 `GuardedConsumeSample` caller records; the other 104 records unchanged | as above | |
| 133 | +| cross-engine | 0 | 0 disagreements on any snapshot; 0 failures; 0 status changes | — | |
| 134 | + |
| 135 | +**Degradation over the populations (extractor counter, MEASURED).** Corpus: 28 canonical calls over 18 |
| 136 | +documents; 13 degraded — `callee_no_owned_param` ×10 on the arraypool documents (a rented array flows into a |
| 137 | +first-party helper whose parameter is not an owned-disposable type; the rule binds owned-disposable parameters |
| 138 | +only, so those calls keep the legacy lowering and their verdicts did not move) and `callee_no_block_body` ×3. |
| 139 | +Repo tree: 9 canonical, 1 `callee_no_block_body`. No `unresolved_callee`, `ref_out`, `params_slot` or |
| 140 | +`gap_in_owned_slots` degradation occurs on either population. |
| 141 | + |
| 142 | +**Runtime and size (MEASURED, quiet machine, medians of 3).** Extractor wall-clock over the 137 corpus |
| 143 | +documents (sequential `dotnet` launches, Release builds): base `fb06adc` 145.95 s, Stage 1 146.01 s (+0.0%); |
| 144 | +`own-cli ownir` over the 137 facts documents: 0.30 s vs 0.31 s (noise at the timer's granularity). Facts |
| 145 | +size: +10.46% bytes over the corpus (a canonical `call` op names its callee and signature where a `release` |
| 146 | +or `use` named only a variable). No MOS schema change; per-record shape unchanged. |
| 147 | + |
| 148 | + |
| 149 | +## 6. Records re-taken on the research branch (REPOSITORY FACT) |
| 150 | + |
| 151 | +Each re-recorded file keeps its superseded record verbatim in an append-only entry that |
| 152 | +names the Stage-1 commit and classifies the move as an EXPLORATORY P-037-X record, never as |
| 153 | +a production baseline: |
| 154 | + |
| 155 | +- `corpus/p037-shapes/*/expected.json` — 9 shapes (`baseline_transitions[]` id |
| 156 | + `p037x-stage1`; the `record: absent` assertions of #380 become `record: present` with the |
| 157 | + superseded absence kept); 5 shapes unchanged; |
| 158 | +- `corpus/p036-bakeoff/*/expected.json` — the 4 controls (`remeasured[]`, findings |
| 159 | + `['OWN051']`, no fabricated release). The `post_a1` layer is untouched: it is the A1 acceptance |
| 160 | + record, `p037_controls.py --post-a1` is documented and CI-configured as expected to fail until A1 |
| 161 | + lands, and Stage 1 is not A1. It now mismatches on all four controls (measured `['OWN051']`, |
| 162 | + recorded `[]`); the recorded `[]` rests on OWN051 sitting at note level (the legacy-honesty |
| 163 | + control's note says so) while both engines report OWN051 as a warning today — a pre-existing |
| 164 | + tension on `main` that belongs to A1, recorded here, not resolved here; |
| 165 | +- `tests/test_guarded_consume.py` — the definite consumers (`Close`, `CloseInFinally`) are pinned as |
| 166 | + canonical `call` ops with OWN002 derived by the core (INF-S2 on the callee + A1), no longer as |
| 167 | + extractor-side `release` ops; the four kept streams pin exactly the OWN051 advisory (silence would |
| 168 | + now mean the carrier is gone; any OWN001/OWN002/OWN003/OWN009 would be a fabrication); `ForwardDynamic` |
| 169 | + pinned `may` (the pin's own "canonical call facts arrived" branch), `BorrowingWrapper` pinned `may` |
| 170 | + (frozen expectation XB-7). |
| 171 | + |
| 172 | +## 7. Result |
| 173 | + |
| 174 | +**Stage 1: KEEP.** The core sees the call relationship; the frontend no longer decides a |
| 175 | +first-party call's ownership effect. Complexity: one generic extractor rule (+219/−1 lines), one |
| 176 | +generic bridge tolerance (+51/−22 lines over two engines), no vocabulary change. What the |
| 177 | +carrier alone buys and what it does not: every guarded caller is now honestly `may` + |
| 178 | +OWN051 — the bug/safe twins remain undistinguished until a guard is read (Stage 2). |
| 179 | + |
| 180 | +Findings for the owner, outside this track's authority: |
| 181 | + |
| 182 | +1. `#304` reopen condition 1 names exactly this representation ("the legacy `body` stops |
| 183 | + folding first-party forwards"); whether an exploratory carrier meets it is the owner's |
| 184 | + call and is **not claimed** here. |
| 185 | +2. The OWN030 hazard is latent on `main` today for a chain of two first-party factory |
| 186 | + calls whose first is not `fresh`; the tolerance is a candidate for a separate, |
| 187 | + ordinary correctness PR, independent of P-037. |
| 188 | +3. `callee_unmodelled` on the iterator overload (case 5) and on `Probe2.Log` are the R |
| 189 | + boundary (§10.6) seen from the carrier side; Stage 1 does not widen the record set. |
| 190 | +4. Three records of `frontend/roslyn/samples/DiCaptiveSample.cs` emit an absolute `file` path |
| 191 | + while every other record emits the path as given, so the repo-tree facts digest is |
| 192 | + machine-dependent by exactly those three fields (pre-existing on `main`; surfaced by the |
| 193 | + worktree decomposition above; not fixed here). |
0 commit comments