Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AFFIRMATION.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ state and commitments. Companion detail:
model checking, which is `tested-only`, not a proof). What each artefact
proves, and how strongly, is the proof ledger
(`verification/proof-ledger.jsonl`, rendered in
`verification/PROOF-STATUS.adoc#proof-ledger`): 33 proven of 53;
0 proven-with-postulates, 11 tested-only, 2 argued, 7 open. Four of the
`verification/PROOF-STATUS.adoc#proof-ledger`): 34 proven of 55;
0 proven-with-postulates, 12 tested-only, 2 argued, 7 open. Four of the
Lean proofs rested on the Lean kernel axioms `propext` and `Quot.sound`,
which a source scan does not see and `Lean.collectAxioms` does; they moved
to Idris2 on 2026-11-09, which has no such axioms. *Zero escape hatches outside
Expand Down
6 changes: 3 additions & 3 deletions EXPLAINME.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ ____
safety-triangle routing, dispatch thresholds, quarantine, rollback, the Bayesian update and rate
limiting), one Agda model of the Logtalk-to-Elixir migration, and a TLA+
model of the Kin gate that is model-checked on a bounded instance. The proofs are about models of
the code, not the Elixir runtime itself. Proof ledger: 33 proven of 53; 0 proven-with-postulates,
11 tested-only, 2 argued, 7 open
the code, not the Elixir runtime itself. Proof ledger: 34 proven of 55; 0 proven-with-postulates,
12 tested-only, 2 argued, 7 open
____

How this is implemented::
Expand Down Expand Up @@ -292,7 +292,7 @@ Census, from `scripts/proof-ledger.sh check`:

[source,text]
----
33 proven of 53; 0 proven-with-postulates, 11 tested-only, 2 argued, 7 open.
34 proven of 55; 0 proven-with-postulates, 12 tested-only, 2 argued, 7 open.
----

Of the three theory rows, `logtalk-migration` is `PWG-3`;
Expand Down
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ It combines:
safety-triangle routing, dispatch thresholds, quarantine, rollback, the Bayesian update and rate
limiting), one Agda model of the Logtalk-to-Elixir migration, and a TLA+
model of the Kin gate that is model-checked on a bounded instance. The proofs are about models of
the code, not the Elixir runtime itself. Proof ledger: 33 proven of 53; 0 proven-with-postulates,
11 tested-only, 2 argued, 7 open (link:EXPLAINME.adoc#proof-ledger[details])
the code, not the Elixir runtime itself. Proof ledger: 34 proven of 55; 0 proven-with-postulates,
12 tested-only, 2 argued, 7 open (link:EXPLAINME.adoc#proof-ledger[details])

=== Core philosophy

Expand Down
86 changes: 67 additions & 19 deletions test/rules/actions_lock_closure_corpus_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,20 @@ defmodule Hypatia.Rules.ActionsLockClosureCorpusTest do
end

# `-- N owner/repo@ref`: the model's ref numbering, keyed after the fold.
# Two refs sharing a number, or one ref listed twice, would let the model
# merge distinct records while every equation still held, so both raise.
defp model_numbering(src) do
Regex.scan(~r/^--\s+(\d+)\s+(\S+@\S+)\s*$/m, src)
|> Map.new(fn [_, n, ref] -> {ActionsLock.normalise_ref(ref), String.to_integer(n)} end)
pairs =
Regex.scan(~r/^--\s+(\d+)\s+(\S+@\S+)\s*$/m, src)
|> Enum.map(fn [_, n, ref] -> {ActionsLock.normalise_ref(ref), String.to_integer(n)} end)

{refs, numbers} = Enum.unzip(pairs)
if refs != Enum.uniq(refs), do: raise("model numbering lists a ref twice: #{inspect(refs)}")

if numbers != Enum.uniq(numbers),
do: raise("model numbering reuses a number: #{inspect(numbers)}")

Map.new(pairs)
end

# `-- corpus: <fixture> <model row>`
Expand All @@ -104,14 +115,23 @@ defmodule Hypatia.Rules.ActionsLockClosureCorpusTest do
end

# `<row> = MkLock [w, ...] [(k, [u, ...]), ...]`
# A record the pattern does not match, or a key listed twice, would vanish
# from the map below while the row's equation still held, so both raise.
defp model_lock(src, row) do
[_, wf, recs] = Regex.run(~r/^#{row} = MkLock \[([\d, ]*)\] \[(.*)\]\s*$/m, src)
record = ~r/\((\d+), \[([\d, ]*)\]\)/

leftover = record |> Regex.replace(recs, "") |> String.replace(",", "") |> String.trim()
if leftover != "", do: raise("#{row}: unparsed text in its records: #{inspect(leftover)}")

records =
Regex.scan(~r/\((\d+), \[([\d, ]*)\]\)/, recs)
|> Map.new(fn [_, k, uses] -> {String.to_integer(k), uses |> nats() |> Enum.sort()} end)
pairs =
Regex.scan(record, recs)
|> Enum.map(fn [_, k, uses] -> {String.to_integer(k), uses |> nats() |> Enum.sort()} end)

{nats(wf), records}
keys = Enum.map(pairs, &elem(&1, 0))
if keys != Enum.uniq(keys), do: raise("#{row}: a record key appears twice: #{inspect(keys)}")

{nats(wf), Map.new(pairs)}
end

# `row<Name> : danglingOf ActionsLockClosure.<row> = [n, ...]`
Expand All @@ -125,34 +145,62 @@ defmodule Hypatia.Rules.ActionsLockClosureCorpusTest do

# The edges a fixture names: every quoted ref under workflows:, and each
# dependency record with its nested uses:, mapped through the numbering.
# The corpus has one layout, and every line must match one of its shapes;
# any other line raises, so a fixture written in another style cannot drop
# an edge from this comparison without failing it. A nested ref counts only
# under its record's `uses:` key.
defp lock_edges(content, numbering) do
id = &Map.fetch!(numbering, ActionsLock.normalise_ref(&1))
field = ~r/^ (ref|commit|hostname): '[^']*'$|^ (owner_id|repo_id): \d+$/

{_section, _key, refs, records} =
{_state, refs, records} =
content
|> String.split("\n")
|> Enum.reduce({nil, nil, [], %{}}, fn line, {section, key, refs, records} ->
|> Enum.reduce({:top, [], %{}}, fn line, {state, refs, records} ->
cond do
line == "" or String.starts_with?(line, "#") ->
{state, refs, records}

Regex.match?(~r/^version: '[^']+'$/, line) ->
{:top, refs, records}

line == "workflows:" ->
{:workflows, nil, refs, records}
{:workflows, refs, records}

line == "dependencies:" ->
{:dependencies, nil, refs, records}
{:dependencies, refs, records}

section == :workflows and Regex.match?(~r/^\s+- '/, line) ->
[_, ref] = Regex.run(~r/^\s+- '([^']+)'$/, line)
{section, key, [id.(ref) | refs], records}
state == :workflows and Regex.match?(~r/^ '[^']+':( \[\])?$/, line) ->
{state, refs, records}

section == :dependencies and Regex.match?(~r/^ '[^']+':$/, line) ->
state == :workflows and Regex.match?(~r/^ - '[^']+'$/, line) ->
[_, ref] = Regex.run(~r/^ - '([^']+)'$/, line)
{state, [id.(ref) | refs], records}

state != :workflows and state != :top and Regex.match?(~r/^ '[^']+':$/, line) ->
[_, ref] = Regex.run(~r/^ '([^']+)':$/, line)
{section, id.(ref), refs, Map.put(records, id.(ref), [])}

section == :dependencies and Regex.match?(~r/^\s{12}- '/, line) ->
[_, ref] = Regex.run(~r/^\s+- '([^']+)'$/, line)
{section, key, refs, Map.update!(records, key, &Enum.sort([id.(ref) | &1]))}
if Map.has_key?(records, id.(ref)),
do: raise("a closure fixture lists the record #{ref} twice")

{{:record, id.(ref)}, refs, Map.put(records, id.(ref), [])}

match?({:record, _}, state) and Regex.match?(field, line) ->
{state, refs, records}

match?({:record, _}, state) and line == " uses:" ->
{{:uses, elem(state, 1)}, refs, records}

match?({:uses, _}, state) and Regex.match?(~r/^ - '[^']+'$/, line) ->
{:uses, key} = state
[_, ref] = Regex.run(~r/^ - '([^']+)'$/, line)
{state, refs, Map.update!(records, key, &Enum.sort([id.(ref) | &1]))}

match?({:uses, _}, state) and Regex.match?(field, line) ->
{{:record, elem(state, 1)}, refs, records}

true ->
{section, key, refs, records}
raise "unrecognised line in a closure fixture (state #{inspect(state)}): #{inspect(line)}"
end
end)

Expand Down
19 changes: 17 additions & 2 deletions verification/PROOF-STATUS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ receipts (`+scripts/proof-ledger.sh derive+`) and fails on an overclaim or
a stale underclaim.
Checked against PROOF-POLICY as pinned by `+metadatastician/standards 3-practice/PROOF-POLICY.adoc b8f60511e76c9015d86990317162dce653c92fe1+`.

*Census:* 33 proven of 53; 0 proven-with-postulates, 11 tested-only, 2 argued, 7 open. Theory rows: 3 (PWG-1 0, PWG-2ii 0, PWG-2i 0, PWG-3 1, ungraded 2).
*Census:* 34 proven of 55; 0 proven-with-postulates, 12 tested-only, 2 argued, 7 open. Theory rows: 3 (PWG-1 0, PWG-2ii 0, PWG-2i 0, PWG-3 1, ungraded 2).

[cols="3,1,2,2,2",options="header"]
|===
Expand Down Expand Up @@ -132,6 +132,12 @@ Checked against PROOF-POLICY as pinned by `+metadatastician/standards 3-practice
|`+verification/proofs/idris2/VerisimdbConnector.idr+`: `+cleanFindingCompleteness+`, `+cleanFindingSoundness+`, `+factPreservesData+`, `+parseSeverityTotal+`
|Over the Idris2 records; lib/verisim_connector.ex is not shown to follow them

|An actions.lock is closed exactly when its dangling list is empty; that list is sound and complete, closure is decidable, and each of the four corpus rows transcribed into the model evaluates to the dangling list stated for it (standards#963). That those rows and lists match the fixtures and expected.tsv is the tested-only row actions-lock-closure-corpus
|proven
|Idris2 0.7.0, idris2 --check (--total)
|`+verification/proofs/idris2/ActionsLockClosure.idr+`: `+closedIffNoDangling+`, `+danglingSound+`, `+danglingComplete+`, `+decClosed+`, `+rowClosedV00x+`, `+rowClosedCaseVariant+`, `+rowDanglingNested+`, `+rowDanglingWorkflowRef+`
|Over the Idris2 model; lib/rules/actions_lock.ex and standards scripts/close-lock.sh agree with it on the corpus only (row actions-lock-closure-corpus), and the owner/repo fold happens before the model

|Quarantine triggers, release and routing blockage behave as specified (P5)
|proven
|Idris2 0.7.0, idris2 --check (--total)
Expand Down Expand Up @@ -294,6 +300,12 @@ Checked against PROOF-POLICY as pinned by `+metadatastician/standards 3-practice
|`+test/security_errors_test.exs+`: `+SecurityErrors+`
|Example-based; the transcription into the Agda table is not itself checked. Bounds: ExUnit cases over the migrated alert types

|ActionsLock.parse/1 reproduces every expected.tsv row of the shared closure corpus, and the Idris2 model transcribes every fixture and states every row
|tested-only
|ExUnit (mix test)
|`+test/rules/actions_lock_closure_corpus_test.exs+`: `+ActionsLockClosureCorpusTest+`
|The corpus only; standards close-lock-test.sh replays the same byte-identical corpus against close-lock.sh. Bounds: 5 corpus locks, 6 refs, lockfile versions v0.0.2 and v0.0.3

|Damped PageRank iteration converges to a unique stationary vector
|open, ungraded
|-
Expand Down Expand Up @@ -510,7 +522,10 @@ standards#963). `+scripts/close-lock.sh --check+` in hyperpolymath/standards
is a second implementation. The two share a five-row corpus,
`+test/fixtures/actions_lock/closure/+`, which is byte-identical to standards'
`+scripts/tests/fixtures/actions-lock-closure/+`. This is an engineering
proof, so it carries §5 tokens only and no PWG.
proof, so it carries §5 tokens only and no PWG. The canonical record is
two rows of <<proof-ledger>>: `actions-lock-closure` (the model, proven) and
`actions-lock-closure-corpus` (the corpus test, tested-only). This section
explains them; where it and the ledger differ, the ledger wins.

[width="100%",cols="28%,14%,42%,16%",options="header",]
|===
Expand Down
Loading
Loading