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
25 changes: 24 additions & 1 deletion .github/workflows/atoma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ jobs:
build/scalar-proof-evidence/registry-source/
if-no-files-found: error

wrapper_source:
name: Wrapper source interpretation
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Provision independent Coq checker
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends coq=8.18.0+dfsg-1build2
- name: Actual wrapper source and conditional effects
run: bash scripts/atoma-wrapper-source-proof-gate.sh
- uses: actions/upload-artifact@v7.0.2
if: always()
with:
name: wrapper-source-proof-evidence-${{ github.sha }}
path: build/scalar-proof-evidence/wrapper-source/
if-no-files-found: error

scalar:
name: Scalar source proof gate
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -69,6 +90,8 @@ jobs:
run: bash scripts/atoma-word-proof-gate.sh
- name: Generic registry theory (compatible Agda, Lean and full Cubical)
run: bash scripts/atoma-registry-proof-gate.sh
- name: Borrowed wrapper theory and cleanup control
run: bash scripts/atoma-wrapper-proof-gate.sh
- name: Preserve canonical repository map for review
run: |
bash scripts/gen-repo-map.sh .
Expand All @@ -82,7 +105,7 @@ jobs:

soundness:
name: Atoma soundness gate
needs: [scalar, word_source]
needs: [scalar, word_source, wrapper_source]
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
Expand Down
4 changes: 2 additions & 2 deletions docs/decisions/ATOMA-TOOLCHAIN.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: CC-BY-SA-4.0
// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
= Atoma CI toolchain and bounded provisioning deviation
:revdate: 2026-11-07
:revdate: 2026-11-25

The preferred estate route is a pinned Guix/container closure. Atoma's inherited
provisioning does not currently provide its proof stack. To make this repair
Expand All @@ -14,7 +14,7 @@ the entire transitive system environment.
| Tool | CI input | Integrity / local comparison
| Zig | 0.15.2 official x86_64 Linux archive | SHA-256 pinned in installer; same version locally
| Z3 | 4.13.3 official x86_64 glibc 2.35 archive | SHA-256 pinned in installer; local Debian 4.13.3-1 also exercised
| Idris2 | v0.8.0 commit `15a3e4e70843f7a34100f6470c04b791330788df`, Chez bootstrap | Exact fetched commit checked; local 0.8.0-b6cbc25d5 is a separate recorded profile
| Idris2 | commit `b6cbc25d5cd2ef2a250556266fd7b68dfc360f8b`, Chez bootstrap | Exact fetched commit and `0.8.0-b6cbc25d5` version checked; same compiler/runtime profile required by both native consumer gates
| Agda | Ubuntu package `agda-bin=2.6.3-1build1` | apt authentication and exact package version; local Debian 2.6.4.3-1+b2 is a separate recorded profile
| Coq replay | Ubuntu Noble `coq=8.18.0+dfsg-1build2` | coqc and coqchk from the authenticated package; local Rocq 9.2 is a separate recorded profile
| ECHIDNA | `2ab7574ae1e574b0e881422fde6252bf79dea178`, locked release build, Rust 1.99.0 | No default optional prover features; local build uses Rust 1.99.1. This consumes the existing Rust verifier; it adds no Rust implementation proof claim
Expand Down
79 changes: 79 additions & 0 deletions docs/decisions/ATOMA-WRAPPER-OWNERSHIP.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// SPDX-License-Identifier: CC-BY-SA-4.0
= Conditional ownership and actual Zig wrappers
:revdate: 2026-11-25

== Admitted source and result

This experimental slice parses the original complete `registry.zig` and
`header_refc.zig` modules. It admits closed signatures, imports, surrounding
declarations, and an ordered call/loop grammar. Numeric guards become operands
of the operational interpretation. Changed callback arguments, missing cleanup,
reordered state updates, changed span guards and changed loop bounds must refuse.
It is not a general Zig parser or a compiler-refinement theorem.

UAA's theorem covers `uaa_registry_call`: initial idle state, all normal exits,
busy refusal, invalid-span callback refusal and preservation of endpoint
identities under a callback-frame premise. The actual imported state kernel is
checked independently; the protocol-tag source must export `known` and parse as
the 1..9 range. A renamed-export mutation must be rejected.
The surrounding create/destroy/register/unregister declarations are closed by
the grammar and exercised natively, but do not acquire ownership theorems merely
because their tokens match. Allocator correctness remains assumed.

Proven's theorem covers the actual `header_refc.detect` loop: under the explicit
foreign-step contract, its checked execution equals the authoritative Boolean
fold. Every iteration consumes one element of the borrowed list; the read count
is bounded by its length. The whole public `core.headerHasCrlf` entry, conversion
from machine pointer to slice, private RefC runtime and compiler remain outside
this refinement. The retained `bits8.zig` bytes identify that assumed carrier;
they are not promoted to a pointer-validity proof by appearing in a capsule.

== Ownership premises

* One live registry allocation, serialized owner access, no stale-pointer use.
* Callback and context are valid when invoked; registration retains their
identities. The owner must keep them valid while registration can be called,
or unregister before their storage/code lifetime ends.
* The callback may change its own disjoint context. It must preserve registry
storage, keep borrowed input readable and immutable, and return normally.
* No concurrent writes, asynchronous retention, non-local exit, process abort,
arbitrary raw-alias mutation or compiler correctness is established here.
* Proven receives a readable immutable span for its synchronous call. The
foreign RefC step returns a canonical state implementing the Idris contract
and does not write the borrowed span. Immediate tagged values are not heap
objects and must not be dereferenced as pointers.

These are quantified or stated premises, not facts inferred from non-nullness.
The UAA native raw-alias fixture deliberately deletes an endpoint during a
callback and demonstrates that `finish` does not restore the original frame.
That counterexample must remain visible; it prevents unconditional safety claims.

== Evidence and status

Idris2 owns both engineering contracts. UAA's linear Lease checks use of an
already-acquired logical owner: acquisition, unforgeability and machine aliases
are not proved by its constructors. Constructors are hidden, the resource
payload is linear, and release requires a consuming finalizer. Neither direct
duplication nor destruct-and-reconstruct duplication may type check. Wrapping
an already-copyable value does not establish exclusive machine ownership.
Proven proves checked scanning against its actual ByteKernel fold. Native tests
exercise real Zig wrappers and exported ABI; no FFI/API is implemented in C.

Compatible Agda is checked with safe, without-K, cubical-compatible and
double-check flags, followed by an audited Lean re-proof and full Cubical paths.
The independent Coq source interpretation adds kernel checking and ECHIDNA
replay. Hand re-proofs remain BRIDGE-PENDING; full Cubical is not an independent
kernel. No PWG promotion, universal native-memory safety or COMPLETE receipt.

The required source/theory jobs and combined consumer replay must pass on the
exact PR head before this slice is accepted. Qualification evidence is recorded
in https://github.com/hyperpolymath/atoma/pull/33[the implementation PR]; the
presence of these files alone is not a successful check or a promotion.

== Next obligations

Connect acquisition/release and callback registration lifetimes to an actual
heap model; prove the public pointer-to-slice entry; extend beyond normal return;
discharge or precisely retain foreign-call assumptions; reconcile statement
identity across kernels. Checked generation handles may support a future
versioned ABI, but this slice changes no ABI and silently repairs no stale handle.
5 changes: 3 additions & 2 deletions scripts/atoma-ci-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ unzip -q z3.zip
echo "$task/z3-4.13.3-x64-glibc-2.35/bin" >> "$GITHUB_PATH"
git init Idris2
git -C Idris2 remote add origin https://github.com/idris-lang/Idris2.git
git -C Idris2 fetch --depth 1 origin 15a3e4e70843f7a34100f6470c04b791330788df
git -C Idris2 fetch --depth 1 origin b6cbc25d5cd2ef2a250556266fd7b68dfc360f8b
git -C Idris2 checkout --detach FETCH_HEAD
[[ $(git -C Idris2 rev-parse HEAD) == 15a3e4e70843f7a34100f6470c04b791330788df ]]
[[ $(git -C Idris2 rev-parse HEAD) == b6cbc25d5cd2ef2a250556266fd7b68dfc360f8b ]]
make -C Idris2 bootstrap SCHEME=scheme PREFIX="$task/idris2" -j2
make -C Idris2 install PREFIX="$task/idris2"
[[ $("$task/idris2/bin/idris2" --version) == 'Idris 2, version 0.8.0-b6cbc25d5' ]]
echo "$task/idris2/bin" >> "$GITHUB_PATH"
dpkg-query -W agda-bin chezscheme libgmp-dev
43 changes: 43 additions & 0 deletions scripts/atoma-consumer-wrapper-gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
mkdir -p "$root/build/atoma-evidence/wrapper-consumers"
out=$(mktemp -d "$root/build/atoma-evidence/wrapper-consumers/run.XXXXXXXX")
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
for profile in header registry; do
if [[ $profile == header ]]; then
repo=proven; pin=ownership-proven.pin
source=ffi/zig/src/header_refc.zig; dependency=ffi/zig/src/refc/bits8.zig
else
repo=unified-api-adapter; pin=ownership-uaa.pin
source=src/interface/ffi/src/registry.zig; dependency=src/interface/ffi/src/registry_state.zig
fi
revision=$(cat "$root/tests/consumer-word/$pin")
[[ $revision =~ ^[0-9a-f]{40}$ ]]
checkout="$work/$repo"
git init -q "$checkout"
git -C "$checkout" remote add origin "https://github.com/hyperpolymath/$repo.git"
git -C "$checkout" fetch -q --depth 1 origin "$revision"
git -C "$checkout" checkout -q --detach FETCH_HEAD
[[ $(git -C "$checkout" rev-parse HEAD) == "$revision" ]]
git -C "$checkout" diff --exit-code "$revision" --
mkdir "$out/$profile"
echo "$revision" > "$out/$profile/revision.txt"
if [[ $profile == header ]]; then
EVIDENCE_DIR="$out/$profile/native" bash "$checkout/scripts/test-header-bridge.sh"
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
[[ $(cat "$out/$profile/native/result.txt") == PASS ]]
[[ $(cat "$out/$profile/native/ownership/result.txt") == PASS ]]
[[ $(cat "$out/$profile/native/ownership-controls/result.txt") == PASS ]]
else
EVIDENCE_DIR="$out/$profile/native" bash "$checkout/scripts/check-registry-ownership.sh"
[[ $(cat "$out/$profile/native/result.txt") == PASS ]]
EVIDENCE_DIR="$out/$profile/native-controls" bash "$checkout/scripts/check-registry-ownership-controls.sh"
[[ $(cat "$out/$profile/native-controls/result.txt") == PASS ]]
fi
git -C "$checkout" diff --exit-code "$revision" -- > "$out/$profile/consumer-recheck.txt"
bash "$root/scripts/atoma-source-profile-replay.sh" "$profile-wrapper" "$checkout/$source" "$checkout/$dependency" "$out/$profile/replay"
git -C "$checkout" diff --exit-code "$revision" -- > "$out/$profile/post-replay-recheck.txt"
done
echo 'WRAPPER CONSUMERS PASS: fresh native qualification and conditional original-source replay; ownership premises remain'
4 changes: 2 additions & 2 deletions scripts/atoma-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ case $("$AGDA" --version) in
'Agda version 2.6.3'|'Agda version 2.6.4.3') ;;
*) echo 'FAIL unsupported Agda version'; exit 1 ;;
esac
[[ $("$IDRIS2" --version) == 'Idris 2, version 0.8.0'* ]] || { echo 'FAIL expected Idris2 0.8.0'; exit 1; }
[[ $("$IDRIS2" --version) == 'Idris 2, version 0.8.0-b6cbc25d5' ]] || { echo 'FAIL expected Idris2 0.8.0-b6cbc25d5'; exit 1; }
evidence="$root/build/atoma-evidence"
mkdir -p "$evidence"
{
Expand Down Expand Up @@ -76,6 +76,7 @@ bash scripts/atoma-gate-falsifiers.sh | tee "$evidence/falsifiers.txt"
bash scripts/atoma-replay-gate.sh | tee "$evidence/replay.txt"
bash scripts/atoma-consumer-scalar-gate.sh | tee "$evidence/scalar-consumers.txt"
bash scripts/atoma-consumer-source-gate.sh | tee "$evidence/source-consumers.txt"
bash scripts/atoma-consumer-wrapper-gate.sh | tee "$evidence/wrapper-consumers.txt"
# Bind the source, contracts, proof sources and gate definitions to this run.
# Exclude generated caches/witnesses to avoid self-referential digests.
find tools/atoma/src examples/atoma/frame-v1/src examples/atoma/frame-v1/abi \
Expand All @@ -86,4 +87,3 @@ sha256sum tools/atoma/build.zig scripts/atoma-*.sh examples/atoma/frame-v1/verif
verification/proofs/{agda,idris2}/MANIFEST .github/workflows/atoma.yml >> "$evidence/inputs.sha256"
cp examples/atoma/frame-v1/witness/phase0.receipt.json "$evidence/"
echo 'ATOMA GATE PASS — INCOMPLETE (Warrant); closed source profiles replayed; compiler and foreign-boundary refinement unproved'

21 changes: 18 additions & 3 deletions scripts/atoma-source-profile-replay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ case "$profile" in
libraries=(ScalarSource RegistrySource)
reports=1
;;
registry-wrapper|header-wrapper)
import_path=$(realpath "$3")
cp "$import_path" "$out/dependency.zig"
libraries=(ScalarSource RegistrySource WrapperSource)
reports=1
if [[ $profile == registry-wrapper ]]; then
protocol_path=$(dirname "$source_path")/protocol_tag.zig
cp "$protocol_path" "$out/protocol_tag.zig"
reports=3
fi
;;
*) fail 'unsupported source profile' ;;
esac
for library in "${libraries[@]}"; do
Expand All @@ -31,6 +42,8 @@ capsule() {
case "$profile" in
decoder) bash "$root/scripts/atoma-word-capsule.sh" "$out/source.zig" "$out/encoder.zig" ;;
registry) bash "$root/scripts/atoma-registry-capsule.sh" "$out/source.zig" ;;
registry-wrapper) bash "$root/scripts/atoma-wrapper-capsule.sh" registry "$out/source.zig" "$out/dependency.zig" "$out/protocol_tag.zig" ;;
header-wrapper) bash "$root/scripts/atoma-wrapper-capsule.sh" header "$out/source.zig" "$out/dependency.zig" - ;;
esac
}
capsule > "$out/AtomaProof.v"
Expand All @@ -53,9 +66,11 @@ capsule > Audit.v
cmp -s AtomaProof.v Audit.v || fail 'capsule differs from independent regeneration'
timeout -k 5 180 coqc -q Audit.v > assumptions.txt 2>&1
[[ $(grep -c '^Closed under the global context$' assumptions.txt) == "$reports" ]] || fail 'unexpected assumptions'
! grep -q '^Axioms:' assumptions.txt
if grep -q '^Axioms:' assumptions.txt; then fail 'audit reported axioms'; fi
cmp -s source.zig "$source_path" || fail 'source changed during replay'
if [[ $profile == decoder ]]; then cmp -s encoder.zig "$import_path" || fail 'import changed'; fi
if [[ $profile == *-wrapper ]]; then cmp -s dependency.zig "$import_path" || fail 'wrapper dependency changed'; fi
if [[ $profile == registry-wrapper ]]; then cmp -s protocol_tag.zig "$protocol_path" || fail 'protocol dependency changed'; fi
for library in "${libraries[@]}"; do
cmp -s "$library.v" "$root/verification/atoma/consumer/coq/$library.v" || fail 'checker changed'
done
Expand All @@ -65,6 +80,6 @@ jq -cnS --arg profile "$profile" \
'{schema:"atoma.source.profile/1",status:"INCOMPLETE",profile:$profile,
checked:"original source interpretation; independent kernel replay",assumptions:[],
open:["Zig parser/compiler refinement","Idris primitive/compiler correspondence",
"cross-kernel witness transport","pointer validity and exclusive ownership","whole-wrapper effects"]}' > receipt.json
"cross-kernel witness transport","pointer validity and exclusive ownership",
"foreign callback and RefC contracts","whole-wrapper effects outside admitted profile"]}' > receipt.json
echo "SOURCE-CHECKED $profile: interpreted source; compiler and foreign boundary remain explicit"

60 changes: 60 additions & 0 deletions scripts/atoma-wrapper-capsule.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail
[[ $# == 4 && -f $2 && -f $3 ]]
profile=$1
[[ $profile == registry || $profile == header ]]
for source in "$2" "$3"; do [[ $(wc -c < "$source") -le 65536 ]]; done
cat <<'COQ'
From Coq Require Import List Bool ZArith String.
Require Import WrapperSource RegistrySource.
Import ListNotations.
Open Scope string_scope.
Open Scope nat_scope.
COQ
bytes() {
printf 'Definition %s : list nat := ' "$1"
od -An -v -tu1 "$2" | awk 'BEGIN {printf "["} {for(i=1;i<=NF;i++) {if(n++) printf ";"; printf "%s",$i}} END {print "]."}'

Check warning on line 17 in scripts/atoma-wrapper-capsule.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Assign this positional parameter to a local variable.

See more on https://sonarcloud.io/project/issues?id=hyperpolymath_zigprove&issues=AaIRu_V6CPd5tZl6y96x&open=AaIRu_V6CPd5tZl6y96x&pullRequest=33
}
bytes wrapper_bytes "$2"
bytes dependency_bytes "$3"
if [[ $profile == registry ]]; then
[[ -f $4 && $(wc -c < "$4") -le 65536 ]]
bytes protocol_bytes "$4"
cat <<'COQ'
Lemma source_accepted : WrapperSource.check_registry wrapper_bytes = true.
Proof. vm_compute. reflexivity. Qed.
Lemma dependency_accepted : RegistrySource.check dependency_bytes = true.
Proof. vm_compute. reflexivity. Qed.
Definition protocol_exports_known : bool :=
match ScalarSource.lex (List.length protocol_bytes) protocol_bytes with
| Some ("pub" :: "fn" :: "known" :: _) => true
| _ => false
end.
Lemma protocol_accepted : protocol_exports_known = true /\
ScalarSource.parse protocol_bytes = Some (ScalarSource.inclusive_range 1 9).
Proof. vm_compute. split; reflexivity. Qed.
Theorem source_checked : forall A present (s : RegistrySource.state A) tag valid callback,
RegistrySource.active s = false -> WrapperSource.callback_frames callback ->
exists p, WrapperSource.parse_registry wrapper_bytes = Some p /\
WrapperSource.final_registry (WrapperSource.registry_run p present s tag valid callback) = s.
Proof. intros. eapply WrapperSource.registry_normal_frame; eauto using source_accepted. Qed.
Print Assumptions source_checked.
Print Assumptions dependency_accepted.
Print Assumptions protocol_accepted.
COQ
else
# The pointer carrier / RefC runtime remain an explicit call contract. Preserve
# their actual bytes in the capsule rather than pretending this is a proof of them.
cat <<'COQ'
Lemma source_accepted : WrapperSource.check_header wrapper_bytes = true.
Proof. vm_compute. reflexivity. Qed.
Theorem source_checked : forall step foreign bs,
Forall (fun b => b < 256) bs ->
(forall s b, b < 256 -> foreign (WrapperSource.encode s) b = Some (WrapperSource.encode (step s b))) ->
exists p, WrapperSource.parse_header wrapper_bytes = Some p /\
WrapperSource.header_run p foreign bs = Some (WrapperSource.fold step false bs).
Proof. intros. eapply WrapperSource.header_source_fold; eauto using source_accepted. Qed.
Print Assumptions source_checked.
COQ
fi
31 changes: 31 additions & 0 deletions scripts/atoma-wrapper-proof-gate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
set -euo pipefail
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
out="$root/build/scalar-proof-evidence/wrapper-theory"
mkdir -p "$out"
work=$(mktemp -d)
trap 'status=$?; if ((status)); then tail -n 50 "$out"/*.txt >&2; fi; rm -rf "$work"' EXIT
cp "$root/verification/atoma/consumer/agda/WrapperEffects"*.agda "$work/"
cp "$root/verification/atoma/consumer/lean4/WrapperEffects.lean" "$work/"
cd "$work"
agda --safe --without-K --cubical-compatible --double-check --warning=error WrapperEffects.agda > "$out/agda.txt" 2>&1
lean WrapperEffects.lean > "$out/lean.txt" 2>&1
awk '
BEGIN {names["normalReturnFrame"]=1; names["invalidSpanCleanup"]=1; names["aliasCounterexample"]=1; names["aliasBreaksFrame"]=1; names["scanRefinesFold"]=1}
{
found=0
for (n in names) {
expected="\047WrapperEffects." n "\047 does not depend on any axioms"
if ($0 == expected && names[n] == 1) {names[n]=2; found=1; count++}
}
if (!found) exit 1
}
END {if (count != 5) exit 1}' "$out/lean.txt"
agda --safe --cubical --double-check --warning=error WrapperEffectsCubical.agda > "$out/cubical.txt" 2>&1
sed -e 's/module WrapperEffects where/module WrapperEffectsMutant where/' \
-e 's/finish s = registry (rest s) (mcp s) false/finish s = registry (rest s) (mcp s) true/' WrapperEffects.agda > WrapperEffectsMutant.agda
if agda --safe --cubical-compatible --double-check --warning=error WrapperEffectsMutant.agda > "$out/reject-cleanup.txt" 2>&1; then exit 1; fi
grep -q '!=' "$out/reject-cleanup.txt"
sha256sum ./*.agda ./*.lean > "$out/inputs.sha256"
echo 'WRAPPER THEORY PASS: compatible Agda, audited Lean, Cubical and rejecting cleanup control'
Loading
Loading