Skip to content

Commit 791ca4c

Browse files
committed
test(analysis): find the OWN007 rows by code, and correct what None means here
RED 16B.1a.1, test-only. Hardens the guard 4783e8c added and fixes a factual claim in the same file, both before the GREEN that has to satisfy them — changing the instrument in the commit that first tries to please it is the accounting this whole RED sequence exists to avoid. THE GUARD looked at `identity[0]` in each half of the OWN007 pair. That is today equivalent to looking at the OWN007 row, because each half emits exactly one diagnostic — and only today. A reference change that emitted anything before it would move the guard onto a different code while it kept passing. It now selects rows BY CODE, asserts one OWN007 per half, and checks the split. It also stops re-asserting the exact identity string. `a#9` is already frozen in the JSON and re-checked by the fresh-render comparison; a second copy in the guard is a second thing to drift. What no other case pins is the STRUCTURE — one half null, the other not — so that is what the guard holds. Verified by mutating the frozen halves: making the anonymous half named and making the named half anonymous are both CAUGHT. Prepending an unrelated row is NOT caught by this guard and should not be — it is caught by the staleness check, and the guard staying quiet is precisely the hardening working: it is no longer reading position 0. THE CLAIM. The handoff after 4783e8c said `_consume_like` was "the only known subjectless ownership site". Measured against the tree: of the reference's 28 `err` sites, TEN pass no subject — the borrow-permission errors (OWN006, OWN011, OWN012), the use-outside-region check (OWN004), the owned-use-under- mutable-loan case (OWN013), the effect-kind mismatches (OWN034, OWN041), and the `_consume_like` half of OWN007 among them. So the rule the GREEN ports is not "ownership diagnostics carry identity, one site excepted". `None` is as normative as a string, and it is a property of the emission path. The docstring now says so, because the next reader will be building the audit table from it. Oracle unchanged at 87 cases / 84 rows / 81 named / 3 anonymous. Refs #250, #259. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017umyRWQed6WaoRbVagGYVw
1 parent 4783e8c commit 791ca4c

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

‎tests/test_identity_fixtures.py‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
Python uses exactly that: ownership diagnostics take `sym.origin`, and lifetime
4747
`OWN014` takes `source#line`.
4848
49+
`None` is not an oversight anywhere it appears: of the reference's 28 `err`
50+
sites, **10 pass no subject at all** — the borrow-permission errors, the
51+
use-outside-region check, the effect-kind mismatches, and the `_consume_like`
52+
half of OWN007. So the port's rule cannot be "ownership diagnostics carry
53+
identity"; it is per emission path, and `None` is as normative as a string.
54+
4955
A port that instead builds `format!("{current_name}#{diagnostic_line}")` looks
5056
extremely plausible and is NOT equivalent: after a move or an alias join the
5157
current name is not the origin name, and the diagnostic line is not the origin
@@ -283,18 +289,38 @@ def run(write: bool = False) -> int:
283289
# `_consume_like` stamps nothing; the return-escape path stamps `subj`. A
284290
# port that decided by code — `if code in {...}` — satisfies one half and
285291
# fails the other, so the pair must stay split.
292+
#
293+
# Located by CODE within each case, never by row index: today each half has
294+
# exactly one row, but a reference change that emitted something before the
295+
# OWN007 would silently move this guard onto a different diagnostic and it
296+
# would keep passing while measuring nothing.
297+
#
298+
# Structural only. That the anonymous half is null and the named half is
299+
# not is what no other case pins; the exact identity string is already
300+
# frozen in the JSON and re-checked by the fresh-render comparison below,
301+
# so repeating it here would be a second copy to drift.
286302
by_case = {c["name"]: c["identity"] for c in frozen.get("cases", [])}
287-
anon = by_case.get("curated/own007-move-while-borrowed-anonymous.own")
288-
named_own7 = by_case.get("curated/own007-return-while-borrowed-named.own")
303+
304+
def _rows(case_name: str, code: str) -> list[list[object]] | None:
305+
rows = by_case.get(case_name)
306+
return None if rows is None else [r for r in rows if r[1] == code]
307+
308+
anon = _rows("curated/own007-move-while-borrowed-anonymous.own", "OWN007")
309+
named_own7 = _rows("curated/own007-return-while-borrowed-named.own", "OWN007")
289310
if anon is None or named_own7 is None:
290311
failures += _fail(
291312
"the OWN007 pair is incomplete — one half alone would let a port "
292313
"stamp the code uniformly and still pass")
293-
elif not (anon and anon[0][2] is None and named_own7 and named_own7[0][2]):
314+
elif len(anon) != 1 or len(named_own7) != 1:
315+
failures += _fail(
316+
f"the OWN007 pair no longer has exactly one OWN007 row per half "
317+
f"({len(anon)} / {len(named_own7)}) — the halves must stay minimal "
318+
f"or the split they demonstrate stops being isolated")
319+
elif anon[0][2] is not None or named_own7[0][2] is None:
294320
failures += _fail(
295-
f"the OWN007 pair no longer splits on identity ({anon!r} / "
296-
f"{named_own7!r}) — it was the only witness that identity follows "
297-
f"the emission path rather than the code")
321+
f"the OWN007 pair no longer splits on identity ({anon[0][2]!r} / "
322+
f"{named_own7[0][2]!r}) — it is the only witness that identity "
323+
f"follows the emission path rather than the code")
298324

299325
if "OWN014" not in codes:
300326
failures += _fail(

0 commit comments

Comments
 (0)