diff --git a/.github/workflows/casket-pages.yml b/.github/workflows/casket-pages.yml index 0938eacc..6ea04e73 100644 --- a/.github/workflows/casket-pages.yml +++ b/.github/workflows/casket-pages.yml @@ -5,19 +5,26 @@ env: on: push: branches: [main, master] + pull_request: + paths: + - '.github/workflows/casket-pages.yml' + - 'site/**' workflow_dispatch: + inputs: + deploy: + description: 'Deploy the built site (false validates the build only)' + type: boolean + default: false permissions: actions: read contents: read - pages: write - id-token: write concurrency: - group: "pages" - cancel-in-progress: false + group: "pages-${{ github.ref }}" + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: build: runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 45 steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 @@ -25,6 +32,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 with: repository: hyperpolymath/casket-ssg + ref: c190d2882d9ff27205dd5a5b6db6da12cc647a70 path: .casket-ssg - name: Setup GHCup uses: haskell-actions/setup@ec49483bfc012387b227434aba94f59a6ecd0900 # v2 @@ -38,7 +46,7 @@ jobs: ~/.cabal/packages ~/.cabal/store .casket-ssg/dist-newstyle - key: ${{ runner.os }}-casket-${{ hashFiles('.casket-ssg/casket-ssg.cabal') }} + key: ${{ runner.os }}-ghc982-casket-c190d2882d9ff27205dd5a5b6db6da12cc647a70-${{ hashFiles('.casket-ssg/casket-ssg.cabal') }} - name: Build casket-ssg working-directory: .casket-ssg run: cabal build @@ -89,13 +97,17 @@ jobs: mkdir -p _site cd .casket-ssg && cabal run casket-ssg -- build ../.site-src ../_site touch ../_site/.nojekyll - - name: Setup Pages - uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 - name: Upload artifact - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 + uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4; nested artifact action is SHA-pinned with: path: '_site' deploy: + if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.deploy) + permissions: + actions: read + contents: read + pages: write + id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -103,6 +115,9 @@ jobs: timeout-minutes: 15 needs: build steps: + - name: Setup Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 + diff --git a/.github/workflows/echidna-verify.yml b/.github/workflows/echidna-verify.yml index f10738c3..11fccad1 100644 --- a/.github/workflows/echidna-verify.yml +++ b/.github/workflows/echidna-verify.yml @@ -1,196 +1,33 @@ # SPDX-License-Identifier: MPL-2.0 -# ECHIDNA proof verification — formal verification of Agda and Idris2 proofs. -# -# Scope: -# - lol/proofs/theories/**/*.agda -# - a2ml/src/A2ML/Proofs.idr -# - avow-protocol/avow-lib/src/abi/*.idr -# -# Dogfooding: standards repo defines ECHIDNA trust pipeline; this workflow -# applies that pipeline to the repo's own proofs. - +# Verify this repository's real proofs and ABI, using the same gates as each PR. name: ECHIDNA Proof Verification -env: - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true on: - push: - branches: [main] - paths: - - 'lol/proofs/**' - - 'a2ml/src/**/*.idr' - - 'avow-protocol/avow-lib/src/abi/*.idr' - - '.github/workflows/echidna-verify.yml' - pull_request: - paths: - - 'lol/proofs/**' - - 'a2ml/src/**/*.idr' - - 'avow-protocol/avow-lib/src/abi/*.idr' schedule: - # Weekly re-verification to catch stale-proof drift - cron: '0 6 * * 1' workflow_dispatch: -# Estate guardrail: cancel superseded runs so re-pushes / rebased PR -# updates do not pile up queued runs against the shared account-wide -# Actions concurrency pool. Applied only to read-only check workflows -# (no publish/mutation), so cancelling a superseded run is always safe. +permissions: + contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - actions: read - contents: read jobs: - agda-lol: - name: Agda — lol/proofs - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - name: Checkout - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - with: - submodules: recursive - - name: Install Agda - run: | - sudo apt-get update - sudo apt-get install -y agda agda-stdlib - agda --version - - name: Type-check proofs - id: typecheck - run: | - set -euo pipefail - echo "=== Agda proofs under lol/proofs ===" - find lol/proofs/theories -name '*.agda' -print - cd lol/proofs - for f in $(find theories -name '*.agda'); do - echo "--- checking $f ---" - agda --safe --cubical-compatible --double-check "$f" 2>&1 | tee -a ../../agda-verify.log - done - - name: Postulate audit - run: | - echo "=== Postulate usage in lol/proofs ===" - grep -rn "postulate" lol/proofs/theories/ || echo "No postulates found" - - name: Upload log - if: always() - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 - with: - name: agda-verify-log - path: agda-verify.log - if-no-files-found: ignore - idris2-a2ml: - name: Idris2 — a2ml proofs - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - name: Checkout - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - with: - submodules: recursive - - name: Cache pack - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: | - ~/.pack - ~/.idris2 - key: ${{ runner.os }}-idris2-pack-${{ hashFiles('**/pack.toml', '**/*.ipkg') }} - restore-keys: | - ${{ runner.os }}-idris2-pack- - - name: Install Idris2 via pack - run: | - set -e - if command -v idris2 >/dev/null 2>&1; then - echo "idris2 already present: $(idris2 --version)" - exit 0 - fi - # Bootstrap: install pack, which installs idris2. - sudo apt-get update - sudo apt-get install -y build-essential libgmp-dev chezscheme - # Clone pack bootstrap - git clone --depth 1 https://github.com/stefan-hoeck/idris2-pack.git "$HOME/idris2-pack" - cd "$HOME/idris2-pack" - # Use the bootstrap script in non-interactive mode - bash install.bash > "$GITHUB_PATH" - export PATH="$HOME/.pack/bin:$PATH" - pack install-api idris2 - idris2 --version - - name: Type-check A2ML.Proofs - run: | - export PATH="$HOME/.pack/bin:$PATH" - cd a2ml - idris2 --check src/A2ML/Proofs.idr 2>&1 | tee ../idris2-a2ml.log - - name: Upload log - if: always() - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 - with: - name: idris2-a2ml-log - path: idris2-a2ml.log - if-no-files-found: ignore - idris2-avow: - name: Idris2 — AVOW consent proofs - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - name: Checkout - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 - with: - submodules: recursive - - name: Cache pack - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: | - ~/.pack - ~/.idris2 - key: ${{ runner.os }}-idris2-pack-${{ hashFiles('**/pack.toml', '**/*.ipkg') }} - restore-keys: | - ${{ runner.os }}-idris2-pack- - - name: Install Idris2 via pack - run: | - set -e - if command -v idris2 >/dev/null 2>&1; then - echo "idris2 already present: $(idris2 --version)" - exit 0 - fi - sudo apt-get update - sudo apt-get install -y build-essential libgmp-dev chezscheme - git clone --depth 1 https://github.com/stefan-hoeck/idris2-pack.git "$HOME/idris2-pack" - cd "$HOME/idris2-pack" - bash install.bash > "$GITHUB_PATH" - export PATH="$HOME/.pack/bin:$PATH" - pack install-api idris2 - idris2 --version - - name: Type-check AVOW proofs - run: | - export PATH="$HOME/.pack/bin:$PATH" - cd avow-protocol/avow-lib - for f in src/abi/Consent.idr src/abi/Unsubscribe.idr src/abi/Types.idr; do - if [ -f "$f" ]; then - echo "--- checking $f ---" - idris2 --check "$f" 2>&1 | tee -a ../../idris2-avow.log - fi - done - - name: Upload log - if: always() - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 - with: - name: idris2-avow-log - path: idris2-avow.log - if-no-files-found: ignore + theory: + uses: ./.github/workflows/header-theory.yml + abi: + uses: ./.github/workflows/header-refc.yml trust-summary: name: Trust pipeline summary - needs: [agda-lol, idris2-a2ml, idris2-avow] - runs-on: ubuntu-latest - timeout-minutes: 15 + needs: [theory, abi] if: always() + runs-on: ubuntu-24.04 + timeout-minutes: 5 steps: - - name: Summarise - run: | - echo "## ECHIDNA Trust Summary" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "| Target | Result |" >> "$GITHUB_STEP_SUMMARY" - echo "|---|---|" >> "$GITHUB_STEP_SUMMARY" - echo "| Agda lol/proofs | ${{ needs.agda-lol.result }} |" >> "$GITHUB_STEP_SUMMARY" - echo "| Idris2 a2ml | ${{ needs.idris2-a2ml.result }} |" >> "$GITHUB_STEP_SUMMARY" - echo "| Idris2 avow | ${{ needs.idris2-avow.result }} |" >> "$GITHUB_STEP_SUMMARY" - echo "" >> "$GITHUB_STEP_SUMMARY" - echo "See artefacts for verification logs." >> "$GITHUB_STEP_SUMMARY" + - name: Require both real verification gates + env: + THEORY: ${{ needs.theory.result }} + ABI: ${{ needs.abi.result }} + run: | + printf 'Proven theory replay: %s\nActual Idris2/Zig ABI: %s\n' "$THEORY" "$ABI" >> "$GITHUB_STEP_SUMMARY" + test "$THEORY" = success + test "$ABI" = success + diff --git a/.github/workflows/header-refc.yml b/.github/workflows/header-refc.yml index eba79673..e78d457d 100644 --- a/.github/workflows/header-refc.yml +++ b/.github/workflows/header-refc.yml @@ -2,6 +2,7 @@ # Copyright (c) 2026 Jonathan D.A. Jewell name: Header RefC soundness on: + workflow_call: pull_request: push: branches: [main] @@ -9,7 +10,7 @@ on: permissions: contents: read concurrency: - group: header-refc-${{ github.ref }} + group: header-refc-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: header-refc: @@ -48,9 +49,12 @@ jobs: version: '0.15.2' - name: Total Idris kernel, actual ABI, exhaustive pairs and rejecting mutant run: bash scripts/test-header-bridge.sh + - name: Fresh Idris2 decoder contract and pure Zig native witnesses + run: bash scripts/test-refc-decoder.sh - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 if: always() with: name: header-refc-evidence path: build/header-evidence/ if-no-files-found: error + diff --git a/.github/workflows/header-theory.yml b/.github/workflows/header-theory.yml index e3b54836..516bc86e 100644 --- a/.github/workflows/header-theory.yml +++ b/.github/workflows/header-theory.yml @@ -2,6 +2,7 @@ # Copyright (c) 2026 Jonathan D.A. Jewell name: Header theory replay on: + workflow_call: pull_request: push: branches: [main] @@ -9,7 +10,7 @@ on: permissions: contents: read concurrency: - group: header-theory-${{ github.ref }} + group: header-theory-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: theory: @@ -35,10 +36,20 @@ jobs: ~/.opam ~/.local/header-proof-tools key: header-theory-ubuntu2404-systemghc-agda2643-lean4150-rocq920-ocaml511-${{ hashFiles('.github/workflows/header-theory.yml') }} + # Cache contains tools only; the exact version checks run on every replay. + restore-keys: | + header-theory-ubuntu2404-systemghc-agda2643-lean4150-rocq920-ocaml511- - name: Build pinned proof tools if: steps.proof-cache.outputs.cache-hit != 'true' run: | set -euo pipefail + # A fallback cache may have the same pinned tools under an older + # workflow hash. Check the installed versions before reusing it. + if [[ $("$HOME/.local/header-proof-tools/bin/agda" --version 2>/dev/null) == 'Agda version 2.6.4.3' ]] && + [[ $("$HOME/.local/header-proof-tools/lean-4.15.0-linux/bin/lean" --version 2>/dev/null) == 'Lean (version 4.15.0,'* ]] && + [[ $(opam exec --switch=header-proof -- coqc --version 2>/dev/null) == 'The Rocq Prover, version 9.2'* ]]; then + exit 0 + fi mkdir -p "$HOME/.local/header-proof-tools/bin" cabal update # Hosted images also put a newer, incompatible GHC on PATH. @@ -68,3 +79,4 @@ jobs: name: header-theory-evidence path: build/header-proof-evidence/ if-no-files-found: error + diff --git a/.github/workflows/secret-scanner.yml b/.github/workflows/secret-scanner.yml index 21abba22..14538c73 100644 --- a/.github/workflows/secret-scanner.yml +++ b/.github/workflows/secret-scanner.yml @@ -6,6 +6,7 @@ on: pull_request: push: branches: [main] + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.gitleaksignore b/.gitleaksignore index 68101d44..8646e021 100644 --- a/.gitleaksignore +++ b/.gitleaksignore @@ -2,8 +2,8 @@ # Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) # # Gitleaks false positives: test fixtures, not credentials. -# Fingerprint format is file:rule:line (the CI scan runs with --no-git), so an -# entry stops matching if its line moves. Re-run the scan after editing these files. +# Current-tree fingerprints use file:rule:line; history fingerprints additionally +# bind the exact commit. Re-run both scan modes after editing these files. # Placeholder Stripe-prefixed strings (live and test prefix, "abc123def456" body) # used only to prove detectFormat classifies the prefix as StripeKey. @@ -12,3 +12,14 @@ src/Proven/SafeAPIKey/Proofs.idr:stripe-access-token:46 # The public jwt.io example token (sub 1234567890, "John Doe"), used to test decoding. tests/unit/SafeJWTUnit.idr:jwt:37 + +# History-only findings: immutable, exact commit/file/rule/line fingerprints. +# Terraform's password_hashing value is the algorithm name argon2id, not a password. +4058fd882b892c4b86916b4d63e6e802e3ca26cf:bindings/hcl/proven.tf:hashicorp-tf-password:404 +# JWT literals in format/parsing unit tests, not authentication credentials. +# These dispositions do not suppress new tokens, paths, commits or current files. +4058fd882b892c4b86916b4d63e6e802e3ca26cf:bindings/zig/src/safe_jwt.zig:jwt:423 +4058fd882b892c4b86916b4d63e6e802e3ca26cf:bindings/zig/src/safe_jwt.zig:jwt:447 +# Inspection/refusal fixture: HS256 header with a four-byte ASCII signature +# (HS256 requires 32 bytes); these tests require authentication to reject it. +e7a0aa8a46601df22f0853c28ec26424a3874321:tests/remediation/JWTSQLMain.idr:generic-api-key:52 diff --git a/ffi/zig/src/core.zig b/ffi/zig/src/core.zig index eb0013f9..d97edf9d 100644 --- a/ffi/zig/src/core.zig +++ b/ffi/zig/src/core.zig @@ -1,9 +1,9 @@ +// SPDX-License-Identifier: MPL-2.0 // PROVEN FFI Implementation // // This module implements the C-compatible FFI declared in src/abi/Foreign.idr // All types and layouts must match the Idris2 ABI definitions. // -// SPDX-License-Identifier: MPL-2.0 const std = @import("std"); diff --git a/ffi/zig/src/refc/bits8.zig b/ffi/zig/src/refc/bits8.zig index 2c7686ce..32fc6ec3 100644 --- a/ffi/zig/src/refc/bits8.zig +++ b/ffi/zig/src/refc/bits8.zig @@ -4,6 +4,7 @@ //! Values are tagged words, not pointers to allocated objects. const std = @import("std"); const word = @import("bits8_word.zig"); +const decoder = @import("bits8_decode_word.zig"); const c = @cImport({ @cInclude("_datatypes.h"); }); @@ -18,12 +19,7 @@ pub fn encode(value: u8) ?*anyopaque { } pub fn decode(value: ?*anyopaque) error{InvalidRefcResult}!u8 { - const raw = @intFromPtr(value); - const payload = raw >> shift; - if (payload > std.math.maxInt(u8)) return error.InvalidRefcResult; - const byte: u8 = @intCast(payload); - if (raw != @intFromPtr(encode(byte))) return error.InvalidRefcResult; - return byte; + return decoder.decodeWord(@intFromPtr(value)); } test "all canonical Bits8 words round trip through the actual SDK layout" { diff --git a/ffi/zig/src/refc/bits8_decode_word.zig b/ffi/zig/src/refc/bits8_decode_word.zig new file mode 100644 index 00000000..5f896f13 --- /dev/null +++ b/ffi/zig/src/refc/bits8_decode_word.zig @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MPL-2.0 +// Copyright (c) 2026 Jonathan D.A. Jewell +// Pure word marshaling; the pointer carrier and SDK profile stay in bits8.zig. +const word = @import("bits8_word.zig"); + +pub fn decodeWord(raw: u64) error{InvalidRefcResult}!u8 { + const payload = raw / 4294967296; + if (payload > 255) return error.InvalidRefcResult; + const byte: u8 = @intCast(payload); + if (raw != word.encodeWord(byte)) return error.InvalidRefcResult; + return byte; +} diff --git a/scripts/test-refc-decoder.sh b/scripts/test-refc-decoder.sh new file mode 100644 index 00000000..60921a5b --- /dev/null +++ b/scripts/test-refc-decoder.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Fresh Idris2 contract and actual pure Zig decoder/import, in every native mode. +set -euo pipefail +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +out=${EVIDENCE_DIR:-"$root/build/header-evidence/decoder"} +mkdir -p "$out" +out=$(cd "$out" && pwd) +echo INCOMPLETE > "$out/result.txt" +work=$(mktemp -d) +trap 'status=$?; if ((status)); then echo FAIL > "$out/result.txt"; tail -n 35 "$out"/*.txt >&2; fi; rm -rf "$work"' EXIT +[[ $(zig version) == 0.15.2 ]] +mkdir -p "$work/Proven/FFI" +cp "$root/src/Proven/FFI/RefCBits8.idr" "$work/Proven/FFI/" +cp "$root/verification/header/DecoderOracle.idr" "$work/Main.idr" +cp "$root/verification/header/decoder_runner.zig" "$work/runner.zig" +cp "$root/ffi/zig/src/refc/"{bits8_decode_word,bits8_word}.zig "$work/" +(cd "$work"; sha256sum Main.idr Proven/FFI/RefCBits8.idr *.zig) > "$out/inputs.sha256" +(cd "$work"; idris2 --total -Werror --codegen refc -o oracle Main.idr) > "$out/idris-build.txt" 2>&1 +if grep -q '^Error:' "$out/idris-build.txt"; then exit 1; fi +(cd "$work"; printf ':m\n:q\n' | idris2 --no-banner Main.idr) > "$out/idris-holes.txt" 2>&1 +grep -q 'No holes' "$out/idris-holes.txt" +if grep -q '^Error:' "$out/idris-holes.txt"; then exit 1; fi +"$work/build/exec/oracle" > "$out/contract.tsv" +[[ $(wc -l < "$out/contract.tsv") == 1026 ]] +for mode in Debug ReleaseSafe ReleaseFast ReleaseSmall; do + zig build-exe "$work/runner.zig" -O "$mode" -femit-bin="$work/native" > "$out/build-$mode.txt" 2>&1 + "$work/native" > "$out/native-$mode.tsv" + cmp "$out/contract.tsv" "$out/native-$mode.tsv" +done +# Compile a wrong decoder, then require differential rejection at execution. +cp "$work/bits8_decode_word.zig" "$work/original" +sed '/if (raw != word.encodeWord(byte))/d' "$work/original" > "$work/bits8_decode_word.zig" +zig build-exe "$work/runner.zig" -O ReleaseSafe -femit-bin="$work/mutant" > "$out/mutant-build.txt" 2>&1 +"$work/mutant" > "$out/mutant.tsv" +if cmp -s "$out/contract.tsv" "$out/mutant.tsv"; then echo 'FAIL equality mutant escaped'; exit 1; fi +cp "$work/original" "$work/bits8_decode_word.zig" +(cd "$work"; sha256sum -c "$out/inputs.sha256") > "$out/recheck.txt" +cp "$work/"*.zig "$out/" +cp "$work/Proven/FFI/RefCBits8.idr" "$out/" +idris2 --version > "$out/idris-version.txt" +zig version > "$out/zig-version.txt" +echo PASS > "$out/result.txt" +echo 'DECODER PASS: fresh total Idris2 oracle, 1026 witnesses, four modes, rejected compiled mutant' + diff --git a/src/Proven/FFI/RefCBits8.idr b/src/Proven/FFI/RefCBits8.idr index bd65106e..9ee34977 100644 --- a/src/Proven/FFI/RefCBits8.idr +++ b/src/Proven/FFI/RefCBits8.idr @@ -9,3 +9,13 @@ module Proven.FFI.RefCBits8 public export encodeWord : Bits8 -> Bits64 encodeWord value = cast value * 4294967296 + 1 + +||| A byte is returned only after checking the entire canonical word. +||| This is a word contract, not validity of an allocated pointer. +public export +decodeWord : Bits64 -> Maybe Bits8 +decodeWord word = + let payload = word `div` 4294967296 in + if payload > 255 then Nothing else + let byte = the Bits8 (cast payload) in + if word == encodeWord byte then Just byte else Nothing diff --git a/verification/header/DECODER-SOURCE.adoc b/verification/header/DECODER-SOURCE.adoc new file mode 100644 index 00000000..ce3787d2 --- /dev/null +++ b/verification/header/DECODER-SOURCE.adoc @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: CC-BY-SA-4.0 +// Copyright (c) 2026 Jonathan D.A. Jewell += Decoder source binding + +`Proven.FFI.RefCBits8.decodeWord` owns the Idris2 ABI word contract. The pure +Zig `bits8_decode_word.zig` helper checks the payload bound before narrowing, +then requires exact re-encoding through its imported encoder. The actual +pointer-carrier wrapper calls this helper and retains its SDK/64-bit checks. +Unsigned division by 4294967296 makes the payload operation explicit in the +closed arithmetic source profile; it selects the same payload as shift32. + +Atoma must bind both complete source files, the exported encoder name, the +Idris2 contract/oracle, the target and compiler profile. A filename or digest +alone is not a semantic proof. The source interpreter must evaluate the bound +encoder and guarded decoder, then prove canonical acceptance for every word. +The fresh decoder oracle emits canonical and rejection cases for native +comparison; this finite corpus complements the universal theorem. + +The fresh decoder oracle and four native modes passed in hosted run +https://github.com/hyperpolymath/proven/actions/runs/45527057899[45527057899] +at Proven commit a38d22ba10d0e22a1bc83a69d7ed7eb547c1c239. +Atoma's universal original-source capsule and rejection controls passed in +https://github.com/hyperpolymath/atoma/actions/runs/45527831101[45527831101] +at Atoma head 1cc383c1ff2e747cb96d13a49638326ee75823f7, using that Proven pin. +These reports do not substitute for final-head qualification after later edits. +Pointer/integer-carrier correspondence, allocation validity and compiler +refinement remain separate obligations. No complete foreign-boundary or +production-readiness claim follows from this extraction. diff --git a/verification/header/DecoderOracle.idr b/verification/header/DecoderOracle.idr new file mode 100644 index 00000000..d3a0a34e --- /dev/null +++ b/verification/header/DecoderOracle.idr @@ -0,0 +1,26 @@ +-- SPDX-License-Identifier: MPL-2.0 +-- Copyright (c) 2026 Jonathan D.A. Jewell +module Main +import Proven.FFI.RefCBits8 +%default total + +emit : Bits64 -> IO () +emit w = putStrLn (show w ++ " " ++ case decodeWord w of + Nothing => "invalid" + Just b => show b) + +rows : Nat -> Nat -> IO () +rows Z index = pure () +rows (S fuel) index = do + let w = encodeWord (cast index) + emit w + emit (w - 1) + emit (w + 2) + emit (w + 1099511627776) + rows fuel (S index) + +main : IO () +main = do + rows 256 0 + emit 0 + emit 18446744073709551615 diff --git a/verification/header/decoder_runner.zig b/verification/header/decoder_runner.zig new file mode 100644 index 00000000..ea828462 --- /dev/null +++ b/verification/header/decoder_runner.zig @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: MPL-2.0 +const std = @import("std"); +const source = @import("bits8_decode_word.zig"); +const word = @import("bits8_word.zig"); +fn emit(raw: u64) !void { + var buf: [96]u8 = undefined; + const byte = source.decodeWord(raw) catch { + const line = try std.fmt.bufPrint(&buf, "{d} invalid\n", .{raw}); + try std.fs.File.stdout().writeAll(line); + return; + }; + const line = try std.fmt.bufPrint(&buf, "{d} {d}\n", .{ raw, byte }); + try std.fs.File.stdout().writeAll(line); +} +pub fn main() !void { + for (0..256) |index| { + const raw = word.encodeWord(@intCast(index)); + try emit(raw); + try emit(raw - 1); + try emit(raw + 2); + try emit(raw + 1099511627776); + } + try emit(0); + try emit(std.math.maxInt(u64)); +} +