Skip to content

Commit 20b09c9

Browse files
committed
docs(p037): govern run-level call-site evidence
AR1/AR2 (a scratch, never-committed two-crate PoC replaying CH3-3's per-result SARIF boundary against the held R1 treatment) falsified that boundary's completeness before any T_B was retaken against it: AR2 (a static selection correctly removing a fabricated double-dispose) measures a correct, empty AFTER SARIF result set, so a per-result properties bag has no result to attach a witness to. CH3-3 was a correctly preregistered hypothesis given the evidence available at the time, not a mistake -- this amendment supersedes and narrows it, it does not extend it. Final boundary: run.properties.p037_call_site_witnesses[] (run-level, plural, populated even when results==[]), schema p037-verdict-snapshot/5. verdict.rs's struct Finding/fn transfer_note and render.rs's struct Properties/fn sarif_result -- CH3-3's own item set -- are RE-FROZEN, with hostile tests proving each rejected; impl Finding stays mutable as the additive evidence entry point; verdict.rs's fn check_facts and render.rs's struct Run/fn build_sarif join as the new item-level surface. lower.rs widens by exactly one item, struct Lowering -- not fn guarded_use_lowered/ fn apply_guarded_uses, which were found (mechanically, via git merge-base and rust_items()) not to exist anywhere on this branch's own lineage; that mechanism lives only on R1's separate lineage, built after the branches diverged. registered_new_items stays {} by design: nothing is preregistered ahead of the treatment commit that actually defines it. New scripts/p037_b_cli_diff_gate.py governs rust/crates/own-cli/src/ ownir.rs at item level (fn check/fn display only), the seam a real run-level producer needs on the own-cli side; scripts/p037_evidence_b.py's instrument closure is extended to a three-gate check (rust/extractor/cli) and its own selftest fixtures updated to the CH3-8 shape. classify_call_site() ports classify()'s own, already-tested APPLICATION_REFINEMENT branch to the call-site witness (a static pos/neg selection against an existing split summary, now carrying its own selection_license), pinned against the two real measured shapes: AR1 (before=nothing, after=a real OWN001 at the resource's acquire site, never naming the callee) and AR2 (before=a real OWN003 at the acquire site, after=nothing). CONDITIONALITY_HONESTY's own logic is unchanged. docs/evidence/p037-b-epoch.json: production_diff_gate.rust/cli record the final boundary; capture_transport and the CH3-3 instrument-consequence narrative gain a resolution field each, pointing at this commit, with the historical text kept verbatim rather than rewritten; a new, explicitly non-governed note cross-checks this work against PR #371's own record-absence ruling (PASS -- consistent, not depended upon, not merged). Zero production semantics: rust/, frontend/, and ownlang/ are byte- identical to this commit's own parent. Touches only scripts/p037_b_*.py, the new scripts/p037_b_cli_diff_gate.py, and docs/evidence/p037-b-epoch.json. instrument_identity moves again, as expected and already recorded -- measured after this commit, never predicted. ruff and strict mypy are clean; every affected selftest passes, including the new p037_b_cli_diff_gate.py's own 17 cases; test_p037_a2d_epoch.py and test_p037_cumulative_evidence.py are unaffected and green. No T_B named, no R_B taken, no R1 commit/push/replay. Held for independent review before any retake. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AN6xHbpovxrmZ4AMjS7WQA
1 parent f1acf95 commit 20b09c9

7 files changed

Lines changed: 1325 additions & 209 deletions

File tree

‎docs/evidence/p037-b-epoch.json‎

Lines changed: 26 additions & 8 deletions
Large diffs are not rendered by default.

‎scripts/p037_b_classifier.py‎

Lines changed: 108 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ def check_call_site_witness(w: dict[str, Any]) -> None:
585585
_require(acquire is None
586586
or (isinstance(acquire, dict) and isinstance(acquire.get("line"), int)),
587587
"call-site witness.resource_acquire_site must be null or {line: int}")
588+
_require(w.get("selection") in ("pos", "neg", "unselected"),
589+
"call-site witness.selection must be pos|neg|unselected")
588590
guarded = w.get("guarded")
589591
_require(isinstance(guarded, dict), "call-site witness.guarded must be an object")
590592
assert isinstance(guarded, dict) # narrows for mypy; _require already enforced it at runtime
@@ -594,40 +596,79 @@ def check_call_site_witness(w: dict[str, Any]) -> None:
594596
_require(isinstance(cells, dict) and cells.get("pos") in _TRANSFER_VALUES
595597
and cells.get("neg") in _TRANSFER_VALUES,
596598
"guarded.finalized_cells must be {pos,neg} Transfer values for a split shape")
599+
else:
600+
# CH3-8: an uncond shape has no split to select between -- the same
601+
# constraint check_witness() already enforces for the summary-level
602+
# witness's own guarded.selection, ported here now that a call-site
603+
# selection is a real, checked field rather than always "unselected".
604+
_require(w.get("selection") == "unselected",
605+
"an uncond call-site guarded shape has no call-site selection to make")
597606
_require(guarded.get("collapsed") in _TRANSFER_VALUES,
598607
"guarded.collapsed must be a Transfer value")
599-
_require(w.get("selection") in ("pos", "neg", "unselected"),
600-
"call-site witness.selection must be pos|neg|unselected")
608+
# CH3-8: selection_license, added for APPLICATION_REFINEMENT -- the SAME
609+
# requirement check_witness() already enforces for the summary-level
610+
# witness's own guarded.selection_license (a pos/neg selection needs a
611+
# license naming what licensed it), at this witness kind's own top level
612+
# rather than nested in `guarded`, matching where `selection`/`lowered`
613+
# themselves already live here. Only `kind` truthiness is checked, not a
614+
# closed set of kind values: the legal vocabulary (own_ir::GuardedArgKind
615+
# -- var/param/bool_const/null_literal/object_creation/call_result/
616+
# opaque) is the PRODUCER's, not re-validated bit-for-bit here, the same
617+
# looseness check_witness() already accepts for its own selection_license.
618+
if w.get("selection") in ("pos", "neg"):
619+
license_ = w.get("selection_license")
620+
_require(bool(isinstance(license_, dict) and license_.get("kind")),
621+
"a pos/neg call-site selection needs a selection_license naming what licensed it")
601622
_require(w.get("lowered") in ("consume", "borrow", "plain"),
602623
"call-site witness.lowered must be consume|borrow|plain (#175's own Lowered)")
603624

604625

605626
def classify_call_site(w: dict[str, Any]) -> dict[str, Any]:
606627
"""Classifies a CALL_SITE_WITNESS into the SAME closed class vocabulary
607-
classify() uses. Today CONDITIONALITY_HONESTY is the only positive class
608-
reachable here: APPLICATION_REFINEMENT and SUMMARY_REFINEMENT both name a
609-
(method,param) SUMMARY's own value (a summary either got a static
610-
selection applied to it, or the summary itself refined) -- a call-site
611-
witness, by construction, names no such summary, so neither class is
612-
authorized here without a SEPARATE amendment extending them to this
613-
witness kind, which this one does not do. LEGACY_HONESTY is a summary-
614-
level, verdict-equivalent shape (collapsed=unknown, legacy=may, both
615-
plain) that this witness kind cannot even express: it carries no
616-
`legacy` field at all (see check_call_site_witness's own docstring for
617-
why), so there is no scalar legacy Transfer value to compare against."""
628+
classify() uses. This is NOT a fifth class: CH3-8 ports classify()'s own,
629+
already-tested APPLICATION_REFINEMENT branch (a static pos/neg selection
630+
against an existing split summary) to this witness kind, now that it
631+
carries its own `selection_license` (check_call_site_witness's own
632+
validation). SUMMARY_REFINEMENT stays unreachable here, unchanged: it
633+
names a (method,param) SUMMARY's own collapsed value refining with NO
634+
call-site selection at all, and a call-site witness carries no such
635+
summary value to refine -- SUMMARY_REFINEMENT stays p037_mos_snapshot.py's
636+
document-level classification's job (see docs/evidence/p037-b-epoch.json's
637+
own supersession note: no new call-site machinery is built for it).
638+
LEGACY_HONESTY is a summary-level, verdict-equivalent shape (collapsed=
639+
unknown, legacy=may, both plain) that this witness kind cannot even
640+
express: it carries no `legacy` field at all (see
641+
check_call_site_witness's own docstring for why), so there is no scalar
642+
legacy Transfer value to compare against."""
618643
check_call_site_witness(w)
619644
guarded = w["guarded"]
620645
collapsed: Transfer = guarded["collapsed"]
621646
selection = w["selection"]
622647
lowered = w["lowered"]
623648

624649
if selection in ("pos", "neg"):
625-
return {"class": UNCLASSIFIED,
626-
"reason": "a call-site witness with a static pos/neg selection is outside this "
627-
"amendment's scope: APPLICATION_REFINEMENT is defined over a "
628-
"(method,param) summary's own selection_license, which this witness "
629-
"kind does not carry, and extending it to call sites is a separate, "
630-
"unauthorized amendment"}
650+
# check_call_site_witness() already required guarded.shape == "split"
651+
# for a pos/neg selection (the uncond branch there requires
652+
# selection == "unselected"), so this cannot be reached with an
653+
# uncond shape -- no invented priority needed for that combination.
654+
cells = guarded["finalized_cells"]
655+
selected_cell: Transfer = cells["pos"] if selection == "pos" else cells["neg"]
656+
expected_lowered = lower(selected_cell)
657+
if lowered != expected_lowered:
658+
return {"class": UNCLASSIFIED,
659+
"reason": f"selected the {selection} cell ({selected_cell}), which #175's "
660+
f"apply() lowers to {expected_lowered}, but this witness's own "
661+
f"lowered field says {lowered} -- the witness's selection/lowered "
662+
"fields disagree with each other, which is refused rather than "
663+
"explained away"}
664+
license_ = w["selection_license"]
665+
return {"class": APPLICATION_REFINEMENT,
666+
"reason": f"call site selected the {selection} cell ({selected_cell}) via "
667+
f"{license_['kind']}, lowering to {lowered} (#175's own apply()); the "
668+
"guarded summary already existed at this callee/param, only the "
669+
"call-site's own static selection is new (the same G-A1/G-A2 route "
670+
"classify()'s own summary-level APPLICATION_REFINEMENT branch already "
671+
"recognizes, ported to this witness kind)"}
631672
if guarded["shape"] != "split":
632673
return {"class": UNCLASSIFIED,
633674
"reason": "an uncond call-site guarded shape has no conditional structure to "
@@ -1048,10 +1089,54 @@ def _cs(**kwargs: Any) -> dict[str, Any]:
10481089
_check("call-site-u1-conditionality-honesty-positive",
10491090
r["class"] == CONDITIONALITY_HONESTY, r)
10501091

1051-
# hostile: a static selection at a call-site witness is out of THIS
1052-
# amendment's scope, not silently folded into class 4.
1053-
r = classify_call_site(_cs(selection="pos"))
1054-
_check("call-site-hostile-selected-is-unclassified", r["class"] == UNCLASSIFIED, r)
1092+
# positive (CH3-8): a static selection with a valid selection_license
1093+
# against the SAME {no,must} split classifies as APPLICATION_REFINEMENT
1094+
# -- the class-4 CONDITIONALITY_HONESTY shape above and this class-1
1095+
# shape are the same guarded coordinate, differing only in whether the
1096+
# call site made a static choice; not a fifth class, the same
1097+
# (method,param)-summary-level branch classify() already recognizes,
1098+
# ported here now that this witness kind carries its own license.
1099+
r = classify_call_site(_cs(selection="pos",
1100+
selection_license={"kind": "bool_const", "value": True},
1101+
lowered="borrow"))
1102+
_check("call-site-pos-no-selected-borrow-is-application-refinement",
1103+
r["class"] == APPLICATION_REFINEMENT, r)
1104+
r = classify_call_site(_cs(selection="neg",
1105+
selection_license={"kind": "bool_const", "value": False},
1106+
lowered="consume"))
1107+
_check("call-site-neg-must-selected-consume-is-application-refinement",
1108+
r["class"] == APPLICATION_REFINEMENT, r)
1109+
1110+
# hostile: the two possible selected-cell/lowered mismatches -- selected
1111+
# No (which #175 lowers to Borrow) claiming Consume, and selected Must
1112+
# (which lowers to Consume) claiming Borrow. Neither is silently
1113+
# accepted as APPLICATION_REFINEMENT or folded into any other class.
1114+
r = classify_call_site(_cs(selection="pos",
1115+
selection_license={"kind": "bool_const", "value": True},
1116+
lowered="consume"))
1117+
_check("call-site-hostile-selected-no-lowered-consume-is-unclassified",
1118+
r["class"] == UNCLASSIFIED, r)
1119+
r = classify_call_site(_cs(selection="neg",
1120+
selection_license={"kind": "bool_const", "value": False},
1121+
lowered="borrow"))
1122+
_check("call-site-hostile-selected-must-lowered-borrow-is-unclassified",
1123+
r["class"] == UNCLASSIFIED, r)
1124+
1125+
# hostile: a pos/neg selection with no selection_license at all, or a
1126+
# structurally invalid one (missing `kind`), is REFUSED (raises), never
1127+
# silently classified either way -- the schema-level check, not the
1128+
# classifier's own priority logic, catches this.
1129+
try:
1130+
classify_call_site(_cs(selection="pos", lowered="borrow"))
1131+
_check("call-site-hostile-selection-without-license-is-refused", False, "did not raise")
1132+
except WitnessError:
1133+
_check("call-site-hostile-selection-without-license-is-refused", True)
1134+
try:
1135+
classify_call_site(_cs(selection="pos", selection_license={"value": True},
1136+
lowered="borrow"))
1137+
_check("call-site-hostile-invalid-license-is-refused", False, "did not raise")
1138+
except WitnessError:
1139+
_check("call-site-hostile-invalid-license-is-refused", True)
10551140

10561141
# hostile: uncond guarded shape at the call site -- nothing conditional
10571142
# to recover.

0 commit comments

Comments
 (0)