From 99a40d6ab758d084f352e0bd2d43ba643041ee06 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:27:05 +0000 Subject: [PATCH 1/3] fix(rsr): criterion 3.2.2 is the verdict of the capability reader Owner decision 2026-11-16 (the elegant option of the two-reader finding from #1033): 3.2.2 now passes exactly when declared_capabilities/1 finds a profile, the reader behind the scorecard's profile_present. Before, with no deed (rsr-profile ...) clause, 3.2.2 passed whenever /rsr-profile.a2ml existed, even if it did not parse or carried no capabilities list, while the scorecard reported no profile. The RsrProfile model proved that this was the only disagreement (disagreementIsExactly, residualDivergence). The model follows the code: criterion322 = verdictOf . declaredCapabilities. Agreement becomes a theorem for every source (verdictAgrees, profilePresentAgrees); deedDecidedAgrees is now an instance of it; the fail-closed and fallback criterion theorems are re-proved over the reader lemmas; the old divergence becomes emptyA2mlFails, with tests/reject/EmptyA2mlPassesProfileCriterion.idr as its regression guard. ExUnit: a new case runs 3.2.2 and profile_present over an a2ml with a list, without a list, with the wrong section and unparseable. PROOF-STATUS rows for the changed model are OPEN until this commit's Verify Proofs idris2 --check job runs; the earlier PROVEN receipt covered the previous model. Not run locally: no Idris2 here, and hex.pm is blocked, so mix could not fetch deps. check-proof-status.sh, proof-ledger.sh check/claims and check-trusted-base.sh pass. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E294yTkKk127qgKEXFFDBE --- .claude/CLAUDE.md | 2 +- CHANGELOG.adoc | 18 +++ lib/rules/rsr_conformance.ex | 26 ++-- src/Hypatia/ABI/RsrProfile.idr | 131 ++++++------------ test/rules/rsr_conformance_test.exs | 23 +++ tests/accept/RsrProfileResolution.idr | 26 ++-- .../EmptyA2mlPassesProfileCriterion.idr | 28 ++++ verification/PROOF-STATUS.adoc | 37 ++--- 8 files changed, 158 insertions(+), 133 deletions(-) create mode 100644 tests/reject/EmptyA2mlPassesProfileCriterion.idr diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 544f9285..ac548ba1 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -210,7 +210,7 @@ Training pipeline reads outcomes/*.jsonl for ESN (confidence time series) and pa | `Retraction.idr` | Quarantine as retraction (HYP-01): a token survives iff its support thins into what remains; a finding survives through one of its tokens. Transcribed from residual-evidence-types `Revision.agda` @ 97244f5 | | `Egress.idr` | RE001's decision on egress declarations (standards ADR-009): `Clean` is decidable (`decClean`); an audit hardener never passes a block claim; a declaration lists exactly the secrets read; a run-time key is never declared. Mirror: `test/egress_decision_mirror_test.exs` | | `SecretAlerts.idr` | The `hypatia secret-alerts` line contract read by the bash/jq secret-scanning sweep: exit 0 iff ok, 3 iff error; an error line is never "clean"; `total` = number of findings; no finding is "sound". Gate: `scripts/check-verdicts.sh` (`tests/accept/SecretAlertsLines.idr`, `tests/reject/SecretAlerts*.idr`) | -| `RsrProfile.idr` | RSR capability-profile resolution (engineering model of `lib/rules/rsr_conformance.ex`): deed precedence, fail-closed duplicate/list-less clauses, a2ml fallback, and when criterion 3.2.2 agrees with the scorecard's `profile_present` (and the one case it does not). Gate: `scripts/check-verdicts.sh` (+ `tests/reject/`, `tests/accept/`) | +| `RsrProfile.idr` | RSR capability-profile resolution (engineering model of `lib/rules/rsr_conformance.ex`): deed precedence, fail-closed duplicate/list-less clauses, a2ml fallback, and that criterion 3.2.2 agrees with the scorecard's `profile_present` for every source (3.2.2 is the verdict of the same capability reader). Gate: `scripts/check-verdicts.sh` (+ `tests/reject/`, `tests/accept/`) | **Build system:** `src/abi/hypatia-abi.ipkg` (compile), `verify/hypatia-verify.ipkg` (proofs), `pack.toml` (Pack package manager). The ipkg sets `sourcedir = ".."`, so **`src/Hypatia/ABI/` is what compiles** — that is the diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 3e87e50c..e648972b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -12,6 +12,24 @@ https://semver.org/[Semantic Versioning]. === Changed +==== RSR 3.2.2 is the verdict of the capability reader (2026-11-16) + +Criterion 3.2.2 (profile present) now passes exactly when +`declared_capabilities/1` finds a profile, the same reader behind the +scorecard's `profile_present`. Before, a repository with no deed +`(rsr-profile …)` clause passed 3.2.2 whenever +`/rsr-profile.a2ml` existed, even when that file did not parse +or carried no `capabilities` list. In that case the scorecard reported no +profile. The Idris2 model (`src/Hypatia/ABI/RsrProfile.idr`, from #1033) +proved that this was the only case where the two disagreed. With the fix it +proves they agree for every source (`profilePresentAgrees`), and +`tests/reject/EmptyA2mlPassesProfileCriterion.idr` guards against the old +behaviour returning. + +Effect on scores: a deedless repository whose `rsr-profile.a2ml` declares no +capabilities now fails 3.2.2. It was already scored as having no profile, so +gated criteria were already `:na` for it. + ==== WH014 reads the canonical workflow model (2026-11-16) The masked-report/SARIF-upload rule reads jobs, steps, inputs and working diff --git a/lib/rules/rsr_conformance.ex b/lib/rules/rsr_conformance.ex index c2644f02..f42e06d8 100644 --- a/lib/rules/rsr_conformance.ex +++ b/lib/rules/rsr_conformance.ex @@ -606,22 +606,18 @@ defmodule Hypatia.Rules.RsrConformance do end end - # 3.2.2: the repo declares a profile. Either carrier counts, with the same - # precedence and validation as the capability reader above: when the repo - # deed carries a top-level (rsr-profile …) clause it decides, and it passes - # only if the reader accepts it (exactly one clause, with a `:capabilities` - # list). A duplicated or list-less clause fails, as it declares nothing. - # With no such clause, the legacy /rsr-profile.a2ml counts. + # 3.2.2: the repo declares a profile. It passes exactly when the capability + # reader above finds one, so 3.2.2 and the scorecard's `profile_present` + # (`caps != :none`) agree by construction (src/Hypatia/ABI/RsrProfile.idr, + # `profilePresentAgrees`). The deed's top-level (rsr-profile …) clause + # decides when present: a duplicated or list-less clause fails, as it + # declares nothing. With no such clause, the legacy + # /rsr-profile.a2ml counts only if it yields a capabilities + # list; a file that exists but does not parse, or has none, no longer + # passes on its presence alone (that case once passed 3.2.2 while the + # scorecard reported no profile). defp profile_present do - a2ml = present_mr("rsr-profile.a2ml") - - fn repo -> - case deed_profile_capabilities(repo) do - :absent -> a2ml.(repo) - :none -> :fail - _caps -> :pass - end - end + fn repo -> if declared_capabilities(repo) == :none, do: :fail, else: :pass end end # 3.1.8: the anchor. The legacy ANCHOR.a2ml still counts; its successor is diff --git a/src/Hypatia/ABI/RsrProfile.idr b/src/Hypatia/ABI/RsrProfile.idr index 00b271cb..200579b4 100644 --- a/src/Hypatia/ABI/RsrProfile.idr +++ b/src/Hypatia/ABI/RsrProfile.idr @@ -17,8 +17,8 @@ -- `clause_capabilities/1` ~ `readClause` (with `capLists`, -- `keepCaps`) -- `a2ml_capabilities/1` ~ `a2mlCapabilities` --- `profile_present/0` (3.2.2) ~ `criterion322` --- `present_mr("rsr-profile.a2ml")` ~ `a2mlFileVerdict` +-- `profile_present/0` (3.2.2) ~ `criterion322` (= `verdictOf` of +-- `declaredCapabilities`) -- `deed_clause?/2` ~ not used by 3.2.2 since bffd76a; before -- it, 3.2.2 passed on any clause, which is -- the defect `deedDecidedAgrees` excludes @@ -42,13 +42,14 @@ -- `duplicateFailsCriterion`, `listlessFailsCriterion`); -- * fallback: with no clause the result is the a2ml reading -- (`fallbackNoDeed`, `fallbackNoClause`, `fallbackCriterionNoClause`); --- * consistency: 3.2.2 passes iff the scorecard says `profile_present` --- whenever the deed decides (`deedDecidedAgrees`, the bffd76a fix) and --- whenever the a2ml is not "present but declaring nothing" --- (`a2mlDecidedAgrees`); they disagree in exactly that one case --- (`disagreementIsExactly`), and it is inhabited (`residualDivergence`): --- with no deed clause, 3.2.2 checks only that rsr-profile.a2ml exists, --- while the scorecard needs it to yield a capabilities list. +-- * consistency: 3.2.2 passes iff the scorecard says `profile_present`, +-- for every source (`profilePresentAgrees`). It holds by construction: +-- 3.2.2 is the verdict of the same capability reader. The bffd76a fix +-- is the deed-decided instance (`deedDecidedAgrees`). The case that +-- diverged before the 3.2.2 fix (no deed clause; an rsr-profile.a2ml +-- that exists but yields no capabilities list, which passed 3.2.2 on its +-- presence while the scorecard reported no profile) now fails +-- (`emptyA2mlFails`). -- -- What is NOT proved here: that the Elixir behaves as this model. The -- Elixir is not extracted from this module; the correspondence is by review @@ -202,24 +203,17 @@ passes : CriterionVerdict -> Bool passes Pass = True passes Fail = False -||| `present_mr("rsr-profile.a2ml")`: the file exists. +||| The verdict of `profile_present/0`: pass exactly when the capability +||| reader declares a profile (`declared_capabilities(repo) == :none` fails). public export -a2mlFileVerdict : A2mlState -> CriterionVerdict -a2mlFileVerdict A2mlMissing = Fail -a2mlFileVerdict A2mlDeclaresNothing = Pass -a2mlFileVerdict (A2mlDeclares _) = Pass - -||| The `case` of `profile_present/0`. -public export -check322 : Resolution -> A2mlState -> CriterionVerdict -check322 Absent a = a2mlFileVerdict a -check322 DeclaresNothing _ = Fail -check322 (Declared _) _ = Pass +verdictOf : Caps -> CriterionVerdict +verdictOf CapsNone = Fail +verdictOf (CapsList _) = Pass ||| Criterion 3.2.2, `profile_present/0`. public export criterion322 : ProfileSource -> CriterionVerdict -criterion322 src = check322 (resolve (deed src)) (a2ml src) +criterion322 src = verdictOf (declaredCapabilities src) ------------------------------------------------------------------------ -- Section 4: Lemmas on the reading steps @@ -240,16 +234,6 @@ fromAbsent : (a : A2mlState) -> (r : Resolution) -> r = Absent -> fromResolution r a = a2mlCapabilities a fromAbsent _ _ Refl = Refl -public export -checkNothing : (a : A2mlState) -> (r : Resolution) - -> r = DeclaresNothing -> check322 r a = Fail -checkNothing _ _ Refl = Refl - -public export -checkAbsent : (a : A2mlState) -> (r : Resolution) - -> r = Absent -> check322 r a = a2mlFileVerdict a -checkAbsent _ _ Refl = Refl - ||| One clause: the reading is that clause's. public export oneClause : (bs : List (List BodyItem)) -> (body : List BodyItem) @@ -350,9 +334,7 @@ duplicateFailsCriterion : (items : List TopItem) -> (a : A2mlState) -> {b1, b2 : List BodyItem} -> {rest : List (List BodyItem)} -> profileBodies items = b1 :: b2 :: rest -> criterion322 (MkProfileSource (Just items) a) = Fail -duplicateFailsCriterion items a dup = - checkNothing a (readBodies (profileBodies items)) - (twoClauses (profileBodies items) dup) +duplicateFailsCriterion items a dup = cong verdictOf (duplicateDeclaresNothing items a dup) ||| One clause without a capabilities list fails 3.2.2, for every a2ml ||| state. @@ -362,9 +344,7 @@ listlessFailsCriterion : (items : List TopItem) -> (a : A2mlState) -> capLists body = [] -> criterion322 (MkProfileSource (Just items) a) = Fail listlessFailsCriterion items a body one listless = - checkNothing a (readBodies (profileBodies items)) - (trans (oneClause (profileBodies items) body one) - (listlessClause body listless)) + cong verdictOf (listlessDeclaresNothing items a body one listless) ------------------------------------------------------------------------ -- Section 7: Fallback to the a2ml @@ -384,74 +364,45 @@ fallbackNoClause : (items : List TopItem) -> (a : A2mlState) fallbackNoClause items a none = fromAbsent a (readBodies (profileBodies items)) (noClause (profileBodies items) none) -||| A deed without a top-level clause: 3.2.2 is the a2ml file check. +||| A deed without a top-level clause: 3.2.2 is the verdict of the a2ml +||| reading, so an .a2ml that exists but yields no list fails. public export fallbackCriterionNoClause : (items : List TopItem) -> (a : A2mlState) -> profileBodies items = [] - -> criterion322 (MkProfileSource (Just items) a) = a2mlFileVerdict a -fallbackCriterionNoClause items a none = - checkAbsent a (readBodies (profileBodies items)) (noClause (profileBodies items) none) + -> criterion322 (MkProfileSource (Just items) a) = verdictOf (a2mlCapabilities a) +fallbackCriterionNoClause items a none = cong verdictOf (fallbackNoClause items a none) ------------------------------------------------------------------------ -- Section 8: 3.2.2 and the scorecard agree ------------------------------------------------------------------------ +||| The verdict passes exactly when the scorecard field is true. public export -agreeWhenDecided : (r : Resolution) -> (a : A2mlState) -> Not (r = Absent) - -> passes (check322 r a) = scorecardProfilePresent (fromResolution r a) -agreeWhenDecided Absent _ notAbsent = void (notAbsent Refl) -agreeWhenDecided (Declared _) _ _ = Refl -agreeWhenDecided DeclaresNothing _ _ = Refl - -public export -agreeUnlessEmptyA2ml : (r : Resolution) -> (a : A2mlState) - -> Not (a = A2mlDeclaresNothing) - -> passes (check322 r a) = scorecardProfilePresent (fromResolution r a) -agreeUnlessEmptyA2ml Absent A2mlMissing _ = Refl -agreeUnlessEmptyA2ml Absent A2mlDeclaresNothing notEmpty = void (notEmpty Refl) -agreeUnlessEmptyA2ml Absent (A2mlDeclares _) _ = Refl -agreeUnlessEmptyA2ml (Declared _) _ _ = Refl -agreeUnlessEmptyA2ml DeclaresNothing _ _ = Refl +verdictAgrees : (c : Caps) -> passes (verdictOf c) = scorecardProfilePresent c +verdictAgrees CapsNone = Refl +verdictAgrees (CapsList _) = Refl +||| 3.2.2 passes iff the scorecard says the profile is present, for every +||| source: both read the same capability set. public export -disagreeReading : (r : Resolution) -> (a : A2mlState) - -> Not (passes (check322 r a) = scorecardProfilePresent (fromResolution r a)) - -> (r = Absent, a = A2mlDeclaresNothing) -disagreeReading Absent A2mlMissing differ = void (differ Refl) -disagreeReading Absent A2mlDeclaresNothing _ = (Refl, Refl) -disagreeReading Absent (A2mlDeclares _) differ = void (differ Refl) -disagreeReading (Declared _) _ differ = void (differ Refl) -disagreeReading DeclaresNothing _ differ = void (differ Refl) +profilePresentAgrees : (src : ProfileSource) + -> passes (criterion322 src) = scorecardProfilePresent (declaredCapabilities src) +profilePresentAgrees src = verdictAgrees (declaredCapabilities src) ||| When the deed decides, 3.2.2 passes iff the scorecard says the profile ||| is present. This is the property bffd76a restored: a duplicated or -||| list-less clause neither passes 3.2.2 nor counts as a profile. +||| list-less clause neither passes 3.2.2 nor counts as a profile. It is +||| now an instance of `profilePresentAgrees`. public export deedDecidedAgrees : (src : ProfileSource) -> Not (resolve (deed src) = Absent) -> passes (criterion322 src) = scorecardProfilePresent (declaredCapabilities src) -deedDecidedAgrees src notAbsent = agreeWhenDecided (resolve (deed src)) (a2ml src) notAbsent - -||| Unless the a2ml is present but declares no capabilities list, 3.2.2 -||| passes iff the scorecard says the profile is present. -public export -a2mlDecidedAgrees : (src : ProfileSource) -> Not (a2ml src = A2mlDeclaresNothing) - -> passes (criterion322 src) = scorecardProfilePresent (declaredCapabilities src) -a2mlDecidedAgrees src notEmpty = agreeUnlessEmptyA2ml (resolve (deed src)) (a2ml src) notEmpty - -||| The two readers disagree only when there is no deed clause and the a2ml -||| is present but declares no capabilities list. -public export -disagreementIsExactly : (src : ProfileSource) - -> Not (passes (criterion322 src) = scorecardProfilePresent (declaredCapabilities src)) - -> (resolve (deed src) = Absent, a2ml src = A2mlDeclaresNothing) -disagreementIsExactly src differ = disagreeReading (resolve (deed src)) (a2ml src) differ +deedDecidedAgrees src _ = profilePresentAgrees src -||| And that case occurs: no deed, and an rsr-profile.a2ml that exists but -||| yields no capabilities list, passes 3.2.2 while the scorecard reports no -||| profile. +||| The case that diverged before the 3.2.2 fix: no deed, and an +||| rsr-profile.a2ml that exists but yields no capabilities list. It used +||| to pass 3.2.2 on the file's presence while the scorecard reported no +||| profile; it now fails 3.2.2 (tests/reject/EmptyA2mlPassesProfileCriterion +||| is the regression guard). public export -residualDivergence : ( criterion322 (MkProfileSource Nothing A2mlDeclaresNothing) = Pass - , scorecardProfilePresent - (declaredCapabilities (MkProfileSource Nothing A2mlDeclaresNothing)) - = False ) -residualDivergence = (Refl, Refl) +emptyA2mlFails : criterion322 (MkProfileSource Nothing A2mlDeclaresNothing) = Fail +emptyA2mlFails = Refl diff --git a/test/rules/rsr_conformance_test.exs b/test/rules/rsr_conformance_test.exs index 393bae41..e3638992 100644 --- a/test/rules/rsr_conformance_test.exs +++ b/test/rules/rsr_conformance_test.exs @@ -288,6 +288,29 @@ defmodule Hypatia.Rules.RsrConformanceTest do end end + # With no deed clause, the legacy .a2ml counts only if the reader gets a + # capabilities list from it. This case used to pass 3.2.2 on the file's + # presence while the scorecard reported no profile (RsrProfile.idr: the + # former `residualDivergence`; now `emptyA2mlFails`). + test "3.2.2 agrees with profile_present on an rsr-profile.a2ml with no list", %{ + tmp_dir: tmp + } do + {:ok, catalogue} = RsrCriteria.load(@ssot) + path = ".machine_readable/rsr-profile.a2ml" + + for {text, want} <- [ + {"[rsr-profile]\ncapabilities = [\"bash\"]\n", {:pass, true}}, + {"[rsr-profile]\nversion = \"1.0.0\"\n", {:fail, false}}, + {"[unrelated]\ncapabilities = [\"bash\"]\n", {:fail, false}}, + {"this is not a record [[[\n", {:fail, false}} + ] do + mk!(tmp, path, text) + {:ok, sc} = RsrConformance.score(catalogue, tmp) + verdict = Enum.find(sc.results, &(&1.id == "3.2.2")).verdict + assert {verdict, sc.profile_present} == want, "for #{inspect(text)}" + end + end + test "a malformed descriptile fails 3.2.1 (parse gate, not just presence)", %{ tmp_dir: tmp } do diff --git a/tests/accept/RsrProfileResolution.idr b/tests/accept/RsrProfileResolution.idr index 71641bb5..4e5332b7 100644 --- a/tests/accept/RsrProfileResolution.idr +++ b/tests/accept/RsrProfileResolution.idr @@ -112,12 +112,20 @@ dupAgrees : passes (criterion322 (MkProfileSource (Just RsrProfileResolution.dup (declaredCapabilities (MkProfileSource (Just RsrProfileResolution.dupDeed) (A2mlDeclares ["bash"]))) dupAgrees = deedDecidedAgrees (MkProfileSource (Just dupDeed) (A2mlDeclares ["bash"])) nothingIsNotAbsent --- The residual case: no deed clause and an .a2ml that exists but yields no --- capabilities list. 3.2.2 passes on the file's presence; the scorecard --- reports no profile. -residualPasses : criterion322 (MkProfileSource Nothing A2mlDeclaresNothing) = Pass -residualPasses = fst residualDivergence - -residualNotPresent : scorecardProfilePresent (declaredCapabilities (MkProfileSource Nothing A2mlDeclaresNothing)) - = False -residualNotPresent = snd residualDivergence +-- The case that diverged before the 3.2.2 fix: no deed clause and an .a2ml +-- that exists but yields no capabilities list. 3.2.2 now fails, and agrees +-- with the scorecard, which reports no profile. +emptyA2mlFailsHere : criterion322 (MkProfileSource Nothing A2mlDeclaresNothing) = Fail +emptyA2mlFailsHere = emptyA2mlFails + +emptyA2mlNotPresent : scorecardProfilePresent (declaredCapabilities (MkProfileSource Nothing A2mlDeclaresNothing)) + = False +emptyA2mlNotPresent = Refl + +emptyA2mlAgrees : passes (criterion322 (MkProfileSource Nothing A2mlDeclaresNothing)) + = scorecardProfilePresent (declaredCapabilities (MkProfileSource Nothing A2mlDeclaresNothing)) +emptyA2mlAgrees = profilePresentAgrees (MkProfileSource Nothing A2mlDeclaresNothing) + +-- A2ML with a list and no deed: 3.2.2 passes. +a2mlListPasses : criterion322 (MkProfileSource Nothing (A2mlDeclares ["bash"])) = Pass +a2mlListPasses = Refl diff --git a/tests/reject/EmptyA2mlPassesProfileCriterion.idr b/tests/reject/EmptyA2mlPassesProfileCriterion.idr new file mode 100644 index 00000000..6ac9ca6b --- /dev/null +++ b/tests/reject/EmptyA2mlPassesProfileCriterion.idr @@ -0,0 +1,28 @@ +-- SPDX-License-Identifier: MPL-2.0 +-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +-- +-- EXPECTED REJECTION (RSR capability-profile resolution). +-- scripts/check-verdicts.sh passes only if Idris2 refuses this module, and +-- only at the declaration `invalid`. Every other declaration must +-- typecheck, so that the refusal is for the stated reason and not for a +-- missing import or a typo. +-- +-- Must fail: criterion 3.2.2 with no deed and an rsr-profile.a2ml that +-- exists but yields no capabilities list. Before the 3.2.2 fix the +-- detector passed on the file's presence while the scorecard reported no +-- profile; 3.2.2 is now the verdict of the capability reader, so it fails. +-- +-- EXPECT: Mismatch between: Pass and Fail. + +module EmptyA2mlPassesProfileCriterion + +import Hypatia.ABI.RsrProfile + +%default total +%unbound_implicits off + +source : ProfileSource +source = MkProfileSource Nothing A2mlDeclaresNothing + +invalid : criterion322 EmptyA2mlPassesProfileCriterion.source = Pass +invalid = Refl diff --git a/verification/PROOF-STATUS.adoc b/verification/PROOF-STATUS.adoc index 0e8b5b6e..7070a4a6 100644 --- a/verification/PROOF-STATUS.adoc +++ b/verification/PROOF-STATUS.adoc @@ -410,18 +410,20 @@ and fail 3.2.2, for every a2ml state (`+duplicateDeclaresNothing+`, `+listlessDeclaresNothing+`, `+duplicateFailsCriterion+`, `+listlessFailsCriterion+`). Fallback: no clause, the a2ml reading (`+fallbackNoDeed+`, `+fallbackNoClause+`, -`+fallbackCriterionNoClause+`). Consistency: 3.2.2 passes iff -`+scorecardProfilePresent+` whenever the deed decides -(`+deedDecidedAgrees+`, the bffd76a fix) or the a2ml is not present-but- -declaring-nothing (`+a2mlDecidedAgrees+`); they disagree in exactly that -case (`+disagreementIsExactly+`) |PROVEN — Verify Proofs run 42634000625, idris2 --check job 129217248108, at commit 34c7bc7cff0cf54b1b5707a497d9f8abf826e844 (Idris2 v0.7.0, ABI package build) +`+fallbackCriterionNoClause+`). Consistency: 3.2.2 is the verdict of the +capability reader (`+verdictOf+`), so it passes iff +`+scorecardProfilePresent+` for every source (`+verdictAgrees+`, +`+profilePresentAgrees+`; the bffd76a fix is the instance +`+deedDecidedAgrees+`); the case that diverged before the 3.2.2 fix now +fails (`+emptyA2mlFails+`) |OPEN — not yet kernel-checked at this commit. The model changed with the 3.2.2 fix; the last receipt (Verify Proofs run 42634000625, idris2 --check job 129217248108, at 34c7bc7cff0cf54b1b5707a497d9f8abf826e844) covered the previous model, which proved the divergence instead |`+tests/accept/RsrProfileResolution.idr+` |Idris2 |Positive control: the profile-reader cases of test/rules/rsr_conformance_test.exs stated against the model and accepted by evaluation (`+deedEraDeclares+`, `+deedWins+`, `+dupDeclaresNothing+`, `+dupFails+`, `+listlessNothing+`, `+listlessFails+`, `+nestedFallsBack+`, -`+a2mlOnly+`, `+dupAgrees+`) |TESTED — accepted in the same job +`+a2mlOnly+`, `+dupAgrees+`, `+emptyA2mlFailsHere+`, `+emptyA2mlNotPresent+`, +`+emptyA2mlAgrees+`, `+a2mlListPasses+`) |OPEN — not yet accepted at this commit (see the row above) |`+tests/reject/DuplicatedClauseIsAProfile.idr+` |Idris2 |Expected rejection: a duplicated clause counted as a present profile is refused at @@ -439,6 +441,11 @@ rejection: a list-less clause falling back to the a2ml is refused at a2ml overriding a well-formed deed clause is refused at `+invalid+` |TESTED — refused at `invalid` in the same job +|`+tests/reject/EmptyA2mlPassesProfileCriterion.idr+` |Idris2 |Expected +rejection: 3.2.2 passing with no deed and an a2ml that yields no +capabilities list (the pre-fix behaviour) is refused at `+invalid+` |OPEN +— not yet run at this commit + |Correspondence, lib/rules/rsr_conformance.ex |Elixir |The model's functions behave as the Elixir functions their header names. Argued by review; no kernel checked it, and the Elixir is not extracted from the @@ -446,15 +453,9 @@ model |ASSUMED |Runtime behaviour, lib/rules/rsr_conformance.ex |Elixir |Deed era, deed beside a2ml, duplicated, list-less and nested clauses, and 3.2.2 on a -duplicated or list-less clause: test/rules/rsr_conformance_test.exs -(sampled cases) |TESTED - -|`+src/Hypatia/ABI/RsrProfile.idr+` |Idris2 |3.2.2 and the scorecard's -profile_present can never disagree. False of the code as it stands: with -no deed clause, 3.2.2 checks only that rsr-profile.a2ml exists, while the -scorecard needs it to yield a capabilities list, so an a2ml that does not -parse or carries no list passes 3.2.2 with no profile present -(`+residualDivergence+`) |OPEN +duplicated or list-less clause, and 3.2.2 on an a2ml with and without a +capabilities list: test/rules/rsr_conformance_test.exs (sampled cases) +|TESTED |=== ==== secret-alerts line contract (HYP-01, 2026-11-09) @@ -764,9 +765,9 @@ inventory row above. These are properties of the model, not of the Elixir. `+listlessFailsCriterion+` * *P9.3* Fallback: `+fallbackNoDeed+`, `+fallbackNoClause+`, `+fallbackCriterionNoClause+` -* *P9.4* Consistency of 3.2.2 with the scorecard: `+deedDecidedAgrees+`, - `+a2mlDecidedAgrees+`; the exact residual: `+disagreementIsExactly+`, - `+residualDivergence+` +* *P9.4* Consistency of 3.2.2 with the scorecard, for every source: + `+verdictAgrees+`, `+profilePresentAgrees+`, `+deedDecidedAgrees+`; the + formerly divergent case now fails: `+emptyA2mlFails+` === Dangerous Pattern Audit From c9e8ce4400b49180765e0f32726abb13e3bfe4d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:53:37 +0000 Subject: [PATCH 2/3] docs(proofs): receipt for the 3.2.2 model; rows from OPEN to PROVEN/TESTED Verify Proofs run 43939522672, idris2 --check job 133552988403, at 99a40d6 (Idris 2 v0.7.0, ABI package build) checked the changed RsrProfile model: PASS: no escape-hatch marker in src/Hypatia/ABI/RsrProfile.idr PASS: accepted positive control RsrProfileResolution PASS: rejected EmptyA2mlPassesProfileCriterion at invalid: Mismatch between: Pass and Fail. PASS: ABI package, 11 positive control(s), 22 expected rejection(s) The model row is PROVEN on that receipt; the accept and the new reject fixture are TESTED. The Elixir correspondence stays ASSUMED. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E294yTkKk127qgKEXFFDBE --- verification/PROOF-STATUS.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/verification/PROOF-STATUS.adoc b/verification/PROOF-STATUS.adoc index 4034866b..4f50fbba 100644 --- a/verification/PROOF-STATUS.adoc +++ b/verification/PROOF-STATUS.adoc @@ -415,7 +415,7 @@ capability reader (`+verdictOf+`), so it passes iff `+scorecardProfilePresent+` for every source (`+verdictAgrees+`, `+profilePresentAgrees+`; the bffd76a fix is the instance `+deedDecidedAgrees+`); the case that diverged before the 3.2.2 fix now -fails (`+emptyA2mlFails+`) |OPEN — not yet kernel-checked at this commit. The model changed with the 3.2.2 fix; the last receipt (Verify Proofs run 42634000625, idris2 --check job 129217248108, at 34c7bc7cff0cf54b1b5707a497d9f8abf826e844) covered the previous model, which proved the divergence instead +fails (`+emptyA2mlFails+`) |PROVEN — Verify Proofs run 43939522672, idris2 --check job 133552988403, at commit 99a40d6ab758d084f352e0bd2d43ba643041ee06 (Idris2 v0.7.0, ABI package build). The earlier receipt (run 42634000625 at 34c7bc7c) covered the pre-fix model |`+tests/accept/RsrProfileResolution.idr+` |Idris2 |Positive control: the profile-reader cases of test/rules/rsr_conformance_test.exs stated @@ -423,7 +423,7 @@ against the model and accepted by evaluation (`+deedEraDeclares+`, `+deedWins+`, `+dupDeclaresNothing+`, `+dupFails+`, `+listlessNothing+`, `+listlessFails+`, `+nestedFallsBack+`, `+a2mlOnly+`, `+dupAgrees+`, `+emptyA2mlFailsHere+`, `+emptyA2mlNotPresent+`, -`+emptyA2mlAgrees+`, `+a2mlListPasses+`) |OPEN — not yet accepted at this commit (see the row above) +`+emptyA2mlAgrees+`, `+a2mlListPasses+`) |TESTED — accepted in the same job |`+tests/reject/DuplicatedClauseIsAProfile.idr+` |Idris2 |Expected rejection: a duplicated clause counted as a present profile is refused at @@ -443,8 +443,8 @@ a2ml overriding a well-formed deed clause is refused at `+invalid+` |TESTED |`+tests/reject/EmptyA2mlPassesProfileCriterion.idr+` |Idris2 |Expected rejection: 3.2.2 passing with no deed and an a2ml that yields no -capabilities list (the pre-fix behaviour) is refused at `+invalid+` |OPEN -— not yet run at this commit +capabilities list (the pre-fix behaviour) is refused at `+invalid+` |TESTED +— refused at `invalid` in the same job ("Mismatch between: Pass and Fail.") |Correspondence, lib/rules/rsr_conformance.ex |Elixir |The model's functions behave as the Elixir functions their header names. Argued by From 96aeabac12bc942477329247356e356685fa9a12 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:57:53 +0000 Subject: [PATCH 3/3] fix(rsr): 3.2.2 judges the capability set score/2 read once Codex review on #1188: 3.2.2 called declared_capabilities/1 a second time instead of using the `caps` score/2 had already read. A profile rewritten mid-scan (the delegated scan runs between the two reads) could then leave profile_present and the gated applicability on the old reading while 3.2.2 judged the new one, breaking the agreement the RsrProfile model proves, which assumes a single read. evaluate/4 now passes `caps` to a detector of arity 2, and 3.2.2 is such a detector: it judges exactly the value the scorecard reports. The other detectors are unchanged (arity 1). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01E294yTkKk127qgKEXFFDBE --- lib/rules/rsr_conformance.ex | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/rules/rsr_conformance.ex b/lib/rules/rsr_conformance.ex index f42e06d8..be8f536d 100644 --- a/lib/rules/rsr_conformance.ex +++ b/lib/rules/rsr_conformance.ex @@ -394,7 +394,10 @@ defmodule Hypatia.Rules.RsrConformance do # then to :unverified. case delegated_verdict(c.id, delegated) do :skip -> + # A detector of arity 2 also takes the capability set `score/2` read + # once, so it judges the same profile the scorecard reports. case Map.fetch(detectors(), c.id) do + {:ok, fun} when is_function(fun, 2) -> fun.(repo, caps) {:ok, fun} -> fun.(repo) :error -> :unverified end @@ -607,9 +610,11 @@ defmodule Hypatia.Rules.RsrConformance do end # 3.2.2: the repo declares a profile. It passes exactly when the capability - # reader above finds one, so 3.2.2 and the scorecard's `profile_present` - # (`caps != :none`) agree by construction (src/Hypatia/ABI/RsrProfile.idr, - # `profilePresentAgrees`). The deed's top-level (rsr-profile …) clause + # set `score/2` read (once, via the reader above) is not `:none`, so 3.2.2 + # and the scorecard's `profile_present` (`caps != :none`) judge the same + # value and agree by construction, even if the profile changes mid-scan + # (src/Hypatia/ABI/RsrProfile.idr, `profilePresentAgrees`, which models + # that single read). The deed's top-level (rsr-profile …) clause # decides when present: a duplicated or list-less clause fails, as it # declares nothing. With no such clause, the legacy # /rsr-profile.a2ml counts only if it yields a capabilities @@ -617,7 +622,7 @@ defmodule Hypatia.Rules.RsrConformance do # passes on its presence alone (that case once passed 3.2.2 while the # scorecard reported no profile). defp profile_present do - fn repo -> if declared_capabilities(repo) == :none, do: :fail, else: :pass end + fn _repo, caps -> if caps == :none, do: :fail, else: :pass end end # 3.1.8: the anchor. The legacy ANCHOR.a2ml still counts; its successor is