From 8643e03248cfd6a01dedfdcc29067ebe6da82812 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:06:42 +0000 Subject: [PATCH 1/3] chore: sync from the current RSR template (35233e2) Three-way merge, base 48671ce (the :template-commit in the deed), target 35233e2. 12 conflicts resolved by hand as below; the rest replaced, added or merged cleanly. Taken from the template: pages.yml (ddraig-ssg build, freshness gate, badge deployed with Pages), governance-badge.js and governance_badge_test.js (a superset of the local #35 change: the template also migrates the "K9 L0-L2" label), extract.sh, aspect_tests.sh. hypatia-rule-order.json merged structurally. actions.lock repaired with scripts/lock-sync-fix.sh plus the template's own record for the pinned upload-pages-artifact. Kept apodeixis's own: persist-credentials: false on the pages.yml checkout, the repository-wide Hypatia pin 6693f9a in dogfood-gate.yml (same as hypatia-scan.yml, fork-governance.yml and verdict-grid-publish.yml), README.adoc, launcher.sh, the deed ((ply) already matches), TEST-NEEDS wording. REPOSITORY-MAP keeps both its deed row and the template's .uuid-v8-exempt row. Licences untouched. Verified locally: check-lock-sync, check-workflow-edges, check-ijson-jcs, check-no-a2ml, check-identity, check-hypatia-rule-order all rc 0; 21 new or changed test files pass; governance_badge_test.js 251 passed, 0 failed. NOT passing, neither wired into CI: readme_badge_prose_test, test_needs_minted_test. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zk1VxiWdKq68AQx2Ev --- .clinerules | 8 +- .github/copilot-instructions.md | 8 +- .github/hooks/scan-secrets.sh | 49 ++- .github/pull_request_template.md | 4 +- .github/workflows/README.adoc | 137 +++----- .github/workflows/actions.lock | 52 +-- .github/workflows/codeql.yml | 4 +- .github/workflows/dogfood-gate.yml | 56 +-- .github/workflows/estate-rules.yml | 35 ++ .github/workflows/fork-governance.yml | 2 +- .github/workflows/governance.yml | 322 +++++++++++++++++- .github/workflows/hypatia-scan.yml | 2 +- .github/workflows/main-estate-audit.yml | 15 +- .github/workflows/pages.yml | 192 ++++++++--- .github/workflows/scorecard.yml | 2 +- .github/workflows/secret-scanner.yml | 59 ++++ .machine_readable/arrival-pack/extract.sh | 66 +++- .machine_readable/mint-verbatim.txt | 5 + .machine_readable/root-allow.txt | 1 + .uuid-v8-exempt | 6 + CHANGELOG.adoc | 14 + CLAUDE.md | 28 +- build/container/README.adoc | 8 +- build/just/proofs.just | 13 +- build/just/provision-lib.sh | 15 +- build/just/repo-init.just | 9 + build/just/validate.just | 35 +- docs/architecture/REPOSITORY-MAP.adoc | 4 + docs/practice/AI-CONVENTIONS.adoc | 10 +- docs/status/PROOF-STATUS.adoc | 11 +- scripts/check-identity.sh | 49 +++ scripts/check-mise-language.sh | 1 + scripts/check-no-a2ml.sh | 12 +- scripts/deed-field.sh | 9 +- scripts/deed-template-sync.sh | 62 ++++ scripts/governance-badge.js | 45 ++- scripts/proof-claims-rows.sh | 29 ++ scripts/render-mise.sh | 7 +- tests/aspect_tests.sh | 4 +- tests/scan_secrets_hook_test.sh | 105 ++++++ tests/shape/rust_cli_root_shape_test.sh | 11 + tests/workflows/aspect_banner_test.sh | 43 +++ tests/workflows/check_identity_test.sh | 80 +++++ tests/workflows/check_no_a2ml_test.sh | 31 +- tests/workflows/check_no_md_in_docs_test.sh | 86 +++++ tests/workflows/check_proofs_test.sh | 123 +++++++ tests/workflows/container_guidance_test.sh | 111 ++++++ tests/workflows/deed_template_sync_test.sh | 49 +++ .../fork_governance_verdict_cancel_test.sh | 42 +++ tests/workflows/governance_badge_test.js | 34 ++ tests/workflows/governance_badge_test.sh | 139 ++++++-- tests/workflows/governance_policy_test.sh | 11 + tests/workflows/julia_library_test.sh | 211 ++++++++++++ tests/workflows/mint_gates_test.sh | 45 +++ tests/workflows/proof_claims_rows_test.sh | 84 +++++ .../workflows/proof_status_vocabulary_test.sh | 79 +++++ tests/workflows/readme_badge_prose_test.sh | 47 +++ .../scrub_deletes_whole_constructs_test.sh | 124 +++++++ .../secret_scanner_history_scope_test.sh | 190 +++++++++++ tests/workflows/test_needs_minted_test.sh | 68 ++++ tests/workflows/uuid_v8_test.sh | 14 +- .../verbatim_tests_child_safe_test.sh | 69 ++++ tests/workflows/verdict_grid_test.sh | 2 +- 63 files changed, 2864 insertions(+), 324 deletions(-) create mode 100644 .uuid-v8-exempt create mode 100755 scripts/check-identity.sh create mode 100755 scripts/deed-template-sync.sh create mode 100644 scripts/proof-claims-rows.sh create mode 100755 tests/scan_secrets_hook_test.sh create mode 100755 tests/workflows/aspect_banner_test.sh create mode 100755 tests/workflows/check_identity_test.sh create mode 100644 tests/workflows/check_no_md_in_docs_test.sh create mode 100644 tests/workflows/check_proofs_test.sh create mode 100755 tests/workflows/container_guidance_test.sh create mode 100755 tests/workflows/deed_template_sync_test.sh create mode 100755 tests/workflows/fork_governance_verdict_cancel_test.sh create mode 100644 tests/workflows/julia_library_test.sh create mode 100644 tests/workflows/proof_claims_rows_test.sh create mode 100755 tests/workflows/proof_status_vocabulary_test.sh create mode 100755 tests/workflows/readme_badge_prose_test.sh create mode 100755 tests/workflows/scrub_deletes_whole_constructs_test.sh create mode 100755 tests/workflows/secret_scanner_history_scope_test.sh create mode 100755 tests/workflows/test_needs_minted_test.sh create mode 100755 tests/workflows/verbatim_tests_child_safe_test.sh diff --git a/.clinerules b/.clinerules index 41ee124b..ffa46ecb 100644 --- a/.clinerules +++ b/.clinerules @@ -38,13 +38,13 @@ # Go -> Rust # Python -> Julia or Rust -# CONTAINERS +# CONTAINERS (only if this repo builds a container; otherwise skip) # Runtime: Podman first. # File: Containerfile (never Dockerfile). -# Base: cgr.dev/chainguard/wolfi-base:latest or cgr.dev/chainguard/static:latest. +# Base: cgr.dev/chainguard/wolfi-base or cgr.dev/chainguard/static, pinned by digest (@sha256:); a tag such as :latest is not a pin. -# ABI/FFI -# ABI: Idris2 with dependent types (src/interface/abi/). +# ABI/FFI (only if this repo has a src/interface/ seam; otherwise skip) +# ABI: Idris2 with dependent types (src/interface/Abi/). # FFI: Zig with C ABI (src/interface/ffi/). # Headers: src/interface/generated/. diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index a6d5be10..fda575d2 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -72,13 +72,17 @@ migration destination is AffineScript. ## Containers +Only if this repo builds a container; otherwise skip. + - Use Podman, never Docker. - Name the file `Containerfile`, never `Dockerfile`. -- Base image: `cgr.dev/chainguard/wolfi-base:latest`. +- Base image: `cgr.dev/chainguard/wolfi-base`, pinned by digest (`@sha256:`; `scripts/pin-container-digests.sh`). A tag alone, `:latest` included, is not a pin: `scripts/check-container-pins.sh` fails a `FROM` that has a tag and no digest (a tag followed by a digest passes). ## ABI/FFI -- ABI definitions in Idris2 (`src/interface/abi/`). +Only if this repo has a `src/interface/` seam; otherwise skip. + +- ABI definitions in Idris2 (`src/interface/Abi/`). - FFI implementations in Zig (`src/interface/ffi/`). - Generated C headers in `src/interface/generated/`. diff --git a/.github/hooks/scan-secrets.sh b/.github/hooks/scan-secrets.sh index c3b0ebb1..a5b467c1 100755 --- a/.github/hooks/scan-secrets.sh +++ b/.github/hooks/scan-secrets.sh @@ -79,8 +79,19 @@ DETECTOR_ARGS=(--exclude-detectors SonarCloud) # `command -v` is not enough: a mise shim with no pinned global version sits on # PATH, answers `command -v` happily, and fails every actual invocation with # "No version is set for shim". Installed is not invokable. Each candidate is -# therefore probed with `--version` and only accepted on exit 0. -probe() { [ -n "${1:-}" ] && [ -x "$1" ] && "$1" --version >/dev/null 2>&1; } +# therefore probed (see probe() below) and only accepted when it answers. +# A binary is also rejected when it lacks --fail-on-scan-errors (added after +# v3.90): the hook passes it on every scan, so an older binary would be +# "installed" yet fail every push on an unknown flag. Output is captured, not +# piped into grep -q, because under pipefail grep's early exit can SIGPIPE the +# producer and turn a match into a failure. +probe() { + local bin="${1:-}" help_text + [[ -n "$bin" && -x "$bin" ]] || return 1 + "$bin" --version >/dev/null 2>&1 || return 1 + help_text="$("$bin" --help 2>&1 || true)" + [[ "$help_text" == *"--fail-on-scan-errors"* ]] +} TH="" if probe "${TRUFFLEHOG:-}"; then @@ -99,7 +110,7 @@ fi if [ -z "$TH" ]; then cat >&2 <<'HINT' -[scan-secrets] BLOCKED: TruffleHog is not installed, or is a dead shim. +[scan-secrets] BLOCKED: TruffleHog is not installed, is a dead shim, or is too old (it must support --fail-on-scan-errors; use 3.96.0 or newer). This gate fails closed on purpose — a secret scanner that skips silently is indistinguishable from one that found nothing. @@ -128,7 +139,11 @@ fi # they must be REPORTED apart. Measured here: a stale remote ref pointing at # 0000…0 made every scan exit 1 with "upload-pack: not our ref", and a handler # that said "Secrets detected" for any non-zero told the developer to go hunting -# for a credential that did not exist. A gate that misnames its own failure +# for a credential that did not exist. NOTE the converse: TruffleHog checks for +# scan errors BEFORE it applies --fail, so a run that finds a secret AND hits a +# scan error exits non-zero but not 183. rc != 183 therefore never proves "no +# secret", and the error path below says the output may ALSO contain a finding. +# A gate that misnames its own failure # sends people looking in the wrong place, which is how gates get switched off. status=0 scanned=0 @@ -147,7 +162,7 @@ scan() { local rc=0 # NOT piped — see trap 2 in the header. "$TH" git "file://$REPO_ROOT" "$@" "${VERIFY_ARGS[@]}" "${DETECTOR_ARGS[@]}" \ - --fail --no-update >"$out" 2>&1 || rc=$? + --fail --fail-on-scan-errors --no-update >"$out" 2>&1 || rc=$? scanned=$((scanned + 1)) if [ "$rc" -eq 183 ]; then echo "[scan-secrets] FINDINGS while scanning $label:" >&2 @@ -156,7 +171,7 @@ scan() { status=1 elif [ "$rc" -ne 0 ]; then echo "[scan-secrets] SCANNER ERROR (exit $rc) while scanning $label —" >&2 - echo "[scan-secrets] this is a failure to scan, NOT a detected secret:" >&2 + echo "[scan-secrets] this is a failure to scan; the output below may ALSO contain a detected secret:" >&2 cat "$out" >&2 errored=1 status=1 @@ -168,7 +183,25 @@ if [ -n "${K9_PUSH_RANGES:-}" ]; then [ -z "${local_sha:-}" ] && continue [ "$local_sha" = "$ZERO" ] && continue # branch deletion if [ "${remote_sha:-$ZERO}" = "$ZERO" ]; then - scan "new branch ${local_ref:-HEAD} (last $MAX_DEPTH commits)" \ + # TruffleHog's --max-depth bounds the WHOLE history it walks from + # $local_sha, not just the commits no remote has yet, and at the limit it + # can stop partway through the oldest commit it reaches. So a count that + # excludes remote history (--not --remotes) undercounts what is walked, + # and a count equal to the limit is already too small. Count the same + # traversal and require it to be strictly below the limit; otherwise + # block rather than approve a partial scan. Set K9_SECRETS_MAX_DEPTH + # above the count to scan the whole history. + new_commits="$(git -C "$REPO_ROOT" rev-list --count "$local_sha" 2>/dev/null || echo "")" + if [[ -z "$new_commits" || "$new_commits" -ge "$MAX_DEPTH" ]]; then + echo "[scan-secrets] SCANNER ERROR while scanning new branch ${local_ref:-HEAD} —" >&2 + echo "[scan-secrets] its history is ${new_commits:-of unknown length} commits, not below K9_SECRETS_MAX_DEPTH=$MAX_DEPTH;" >&2 + echo "[scan-secrets] the depth limit would leave part of it unscanned. Set K9_SECRETS_MAX_DEPTH above that count." >&2 + scanned=$((scanned + 1)) + errored=1 + status=1 + continue + fi + scan "new branch ${local_ref:-HEAD} (full history, $new_commits commits)" \ --branch "$local_sha" --max-depth "$MAX_DEPTH" else scan "${local_ref:-HEAD} since ${remote_sha:0:12}" \ @@ -181,7 +214,7 @@ fi # HEAD rather than reporting a pass over nothing. A gate that reports success # having examined zero commits is the vacuity this estate keeps re-learning. if [ "$scanned" -eq 0 ]; then - scan "HEAD (no push ranges; last $MAX_DEPTH commits)" --max-depth "$MAX_DEPTH" + scan "HEAD (no push ranges; last $MAX_DEPTH commits)" --branch HEAD --max-depth "$MAX_DEPTH" fi if [ "$found" -ne 0 ]; then diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 751230fa..af129bf4 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -34,9 +34,9 @@ Copyright (c) Jonathan D.A. Jewell - [ ] Repo deed `(meta)` and/or `docs/decisions/` updated (if architectural decisions changed) - [ ] `docs/status/ROADMAP.adoc` updated (if milestones or next actions changed) - [ ] Documentation updated for user-facing changes -- [ ] `TOPOLOGY.md` updated (if architecture changed) +- [ ] `docs/architecture/TOPOLOGY.adoc` updated (if architecture changed) - [ ] `CHANGELOG` or release notes updated -- [ ] New dependencies reviewed for license compatibility (MPL-2.0 / MPL-2.0) +- [ ] New dependencies reviewed for license compatibility (compatible with MPL-2.0) - [ ] ABI/FFI changes validated (`src/interface/abi/` and `src/interface/ffi/` consistent) ## Testing diff --git a/.github/workflows/README.adoc b/.github/workflows/README.adoc index dfbc5110..b10c1d3a 100644 --- a/.github/workflows/README.adoc +++ b/.github/workflows/README.adoc @@ -93,10 +93,10 @@ what the canon says (standards `docs/CONTRACTILE-DESCRIPTILE-VALIDATION.adoc`). `k9-grid` artifact; it asks for `pull-requests: read` only. `k9-verdict` downloads that artifact and posts `report.md` to the pull request under ``, one comment per PR, - updated in place. `badges` publishes `badges/k9.json` to the - `governance-badges` branch on eligible pushes to `main`; the README badge reads it + updated in place. `badges` stages `badges/k9.json` on eligible pushes to + `main` and `pages.yml` deploys it to GitHub Pages; the README badge reads it through the shields endpoint; the section "The README badges are - generated output" below states the contract that branch operates under. + generated output" below states the contract. * `hypatia-scan.yml` -> `verdict` job posts the Hypatia grid the same way (artifact `verdict-grid`, marker ``). @@ -108,11 +108,10 @@ canonical tools, run from a standards checkout (`STANDARDS_DIR`), and skip with a notice when none is present. k9iser is retired estate-wide: contracts are authored to `1-formats/k9/spec/K9-CONTRACT-SPEC.adoc`, never generated. -== The README badges are generated output (`governance-badges`) +== The README badges are generated output (GitHub Pages) Every repository minted from this template publishes one Shields-endpoint JSON -file per validation lane, on a *separate orphan branch* named -`governance-badges`: +file per validation lane on its *GitHub Pages site*: [cols="1,1,3",options="header"] |=== @@ -120,7 +119,7 @@ file per validation lane, on a *separate orphan branch* named | K9 conformance | `badges/k9.json` -| `dogfood-gate.yml` -> `badges` job, on eligible pushes to `main` +| `dogfood-gate.yml` -> `badges` job stages it; `pages.yml` deploys it, on pushes to `main` |=== @@ -128,30 +127,49 @@ file per validation lane, on a *separate orphan branch* named not change: ---- -https://raw.githubusercontent.com///governance-badges/badges/k9.json +https://.github.io//badges/k9.json ---- -Both halves - rendering the badge and deciding whether to publish it - live in -`scripts/governance-badge.js`. The workflow only supplies the lane's result and -the lane's artifact. `tests/workflows/governance_badge_test.sh` exercises the -helper against a mock of the GitHub API and checks this directory's wiring. - -=== It is generated output, not source - -* `governance-badges` is an *orphan* branch. Its commits are created with - `parents: []`, so there is *no common ancestor with `main`* - not "a little - history", none. It is not a variant, a release branch or a staging area. -* *It must never be merged*, and there is nothing to merge: a pull request from - it would show unrelated histories. Do not open one, do not merge one, do not - rebase it onto `main`. Merging it would import a badges-only tree over the - repository's real content. -* *Recent pushes are normal.* Eligible pushes to `main` republish the badge. A run - whose badge is unchanged makes *no commit at all*, so the branch is quiet - when the lane result is stable and moves only when the state changes. -* It is safe to delete. The next eligible push to `main` recreates it, with no parent, - from scratch. -* It carries no workflows, no code and nothing that runs. Treat it like a - generated site deployment, not like a branch of the repository. +Both halves - rendering the badge and deciding what to stage - live in +`scripts/governance-badge.js` (`render` and `stage`). The workflow only supplies +the lane's result and the lane's artifact. `tests/workflows/governance_badge_test.sh` +exercises the helper and checks this directory's wiring. + +=== Why Pages and not a branch + +The badge used to be written straight to a generated orphan branch +(`governance-badges`) through the contents API. The estate's `Branch-Floor` +repository ruleset applies to *all* branches and its `code_coverage` rule +requires a pull request, so that write was refused (HTTP 409) on every push to +`main`. A Pages deployment is not a branch write, so it satisfies the ruleset +without any exemption. Nothing here weakens, bypasses or excuses the ruleset. + +=== How it flows + +* `badges` (in `dogfood-gate.yml`, `contents: read` only) runs `governance-badge.js stage` + and uploads the result as the `governance-badge-site` artifact, even when the + lane's evidence was unusable (the honest grey badge is staged, then the step + fails the run). +* `pages.yml` runs on `workflow_run` of "Dogfood Gate" for pushes to `main` + that were not cancelled, downloads that artifact, and adds `badges/k9.json` to + the site before deploying. A missing artifact fails the deploy loudly rather + than silently deleting the live badge. +* A freshness gate in `pages.yml` skips (does not fail) any run whose commit is no + longer the default branch's head, so re-running an old Dogfood Gate run, or a + late finisher in a burst of merges, cannot overwrite the current badge. The check runs twice: at the start (`gate` job) and again in the `deploy` job right before `actions/deploy-pages`, because the build can take up to 20 minutes and in-flight runs are not cancelled. A superseded run is skipped at either point. +* There is one Pages site per repository and a deployment replaces it wholesale, + which is why the badge travels *with* the site deployment. The consequence: + `pages.yml` has no `push` or `workflow_dispatch` trigger any more; to + redeploy, re-run Dogfood Gate on `main`. +* Each deployment writes the whole badge from scratch, so the old "compare bytes + with the branch, make no commit" step has no meaning here and is not used. +* It carries no workflows, no code and nothing that runs. +* *Repository setting (owner):* Pages must be enabled with source + "GitHub Actions". Pages host names are lower-case; a mixed-case owner name + needs the lower-case form in the README URL. A repository that is itself + named `.github.io` is a user/organisation Pages site served at the root, + so its badge URL has no `/` segment; the template's URL does not handle + that case and it must be edited by hand. === What each colour means @@ -197,67 +215,20 @@ helper against a mock of the GitHub API and checks this directory's wiring. *Grey means "this run did not produce a trustworthy success/failure result".* It does not mean "pending", "cached" or "about to go green", and it is never a stale green left behind by an earlier run: a workflow that runs with a skipped, -cancelled or unavailable lane *publishes grey*. +cancelled or unavailable lane *stages grey*. The badge reflects the *lane job's* result (`needs.k9-validate.result`), with the lane's artifact as a *witness*: a `success` result is only believed when the `k9-grid` artifact is present, well formed, byte-identical to the canonical render, and itself records `success`. An artifact can never turn a failed lane -green; it can only stop a green one being published. +green; it can only stop a green one being staged. [NOTE] ==== -*Known limit.* If the whole workflow run is cancelled, GitHub does not start -the publisher at all, so the badge keeps its previous value until the next eligible push -to `main`. No job can publish a state for a run it was not allowed to execute. -Because the run that cancels a superseded one is itself publishing, the badge -converges on the newest run's result rather than staying stuck. +*Known limit.* If the whole Dogfood Gate run is cancelled, no badge is staged +and `pages.yml` skips the deploy, so the live badge keeps its previous value +until the next eligible push to `main`. Deployments are serialised by the +`pages` concurrency group and are not cancelled mid-flight; the badge converges +on the newest completed run. ==== -=== Identical content produces no commit - -Before writing anything, the publisher fetches the file that is currently on the -branch and compares it *byte for byte* with the badge it has just rendered. - -* Identical -> it prints `unchanged`, writes no commit, and exits 0. -* Different -> it publishes with the blob sha it just read, so a concurrent - publication is detected (HTTP 409) and re-evaluated instead of silently - overwriting the other run's commit. Publications are also serialised by a - per-repository `concurrency` group. -* The JSON is never re-serialised or canonicalised to make a comparison - succeed. Key order and spacing are fixed by the renderer, and a file that - differs only in layout *is* a difference: it gets republished. - -=== Missing is not the same as broken - -The publisher distinguishes the two, because treating every API error as -"missing" is how a badge pipeline quietly creates branches it should not: - -[cols="1,2",options="header"] -|=== -| HTTP | What happens - -| `404` on the file, `404` on the ref -| The branch really is absent: create it as an orphan (`parents: []`). - -| `404` on the file, `200` on the ref -| The branch exists but the file does not: add the file, no new branch. - -| `404` on the file, anything else on the ref -| Unknown. Fail the run; do not create a branch. - -| `401` / `403` -| Authentication or permission failure. Fail; do not write. - -| `429` / `5xx`, or a network error -| Transient. Retried a bounded number of times, then fail; nothing is treated - as missing. - -| Any other status -| Fail; do not write. -|=== - -A malformed file that is already on the branch (not JSON, not an object, no -`schemaVersion`, no message) is *refused*, not overwritten: it did not come from -this tool, and silently replacing it would hide a hand edit. Repair or delete it -and re-run. diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index 99dfbde7..3137f53f 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -7,7 +7,7 @@ workflows: - 'actions/checkout@v7.0.1' '.github/workflows/codeql.yml': - 'actions/checkout@v7.0.1' - - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370' + - 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066' '.github/workflows/dependabot-automerge.yml': - 'dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98' '.github/workflows/docker-build.yml': @@ -37,6 +37,7 @@ workflows: - 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' '.github/workflows/governance.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' + - 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' '.github/workflows/groove-check.yml': - 'actions/checkout@v7.0.1' '.github/workflows/guix-policy.yml': @@ -46,7 +47,7 @@ workflows: - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' - 'actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9' - 'erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124' - - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370' + - 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066' '.github/workflows/julia.yml': - 'actions/checkout@v7.0.1' - 'julia-actions/setup-julia@da908477b5db94c10ffce8cfea9f2b3b9d5db687' @@ -55,17 +56,18 @@ workflows: '.github/workflows/lock-sync-gate.yml': [] '.github/workflows/main-estate-audit.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' + - 'hyperpolymath/deed-ecosystem@f9d999b60cb5f383679ea19912bcdc49c944973a' + - 'hyperpolymath/k9-ecosystem@2155aa26a21758f2ba119f61bc7e0e1981c106fb' '.github/workflows/mirror.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' '.github/workflows/ossf-best-practices.yml': - 'actions/checkout@v7.0.1' '.github/workflows/pages.yml': - - 'actions/cache@v6.1.0' - - 'actions/checkout@v7.0.1' - - 'actions/configure-pages@v6.0.0' - - 'actions/deploy-pages@v5.0.1' - - 'actions/upload-pages-artifact@v5.0.0' - - 'haskell-actions/setup@v2.12.1' + - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' + - 'actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d' + - 'actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346' + - 'actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333' + - 'actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9' '.github/workflows/proven-tests.yml': - 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' @@ -86,7 +88,7 @@ workflows: - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' '.github/workflows/scorecard.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' - - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370' + - 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066' - 'ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e' '.github/workflows/secret-scanner.yml': - 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' @@ -123,11 +125,6 @@ dependencies: commit: 'sha1-55cc8345863c7cc4c66a329aec7e433d2d1c52a9' owner_id: 44036562 repo_id: 215566462 - 'actions/cache@v6.1.0': - ref: 'v6.1.0' - commit: 'sha1-55cc8345863c7cc4c66a329aec7e433d2d1c52a9' - owner_id: 44036562 - repo_id: 215566462 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1': ref: 'v7.0.1' commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' @@ -138,12 +135,12 @@ dependencies: commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' owner_id: 44036562 repo_id: 197814629 - 'actions/configure-pages@v6.0.0': + 'actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d': ref: 'v6.0.0' commit: 'sha1-45bfe0192ca1faeb007ade9deae92b16b8254a0d' owner_id: 44036562 repo_id: 513659658 - 'actions/deploy-pages@v5.0.1': + 'actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346': ref: 'v5.0.1' commit: 'sha1-368f82528645a54fb793d4d04e342629a3f51346' owner_id: 44036562 @@ -168,7 +165,7 @@ dependencies: commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9' owner_id: 44036562 repo_id: 192625955 - 'actions/upload-pages-artifact@v5.0.0': + 'actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9': ref: 'v5.0.0' commit: 'sha1-fc324d3547104276b827a68afc52ff2a11cc49c9' owner_id: 44036562 @@ -190,16 +187,21 @@ dependencies: commit: 'sha1-54075bcc5e249e4758d363f27d099f55d843f124' owner_id: 47606891 repo_id: 331103973 - 'github/codeql-action@9b3254085494b55a0f7c4c2b3d2d52cc712ce370': - ref: 'v4.39.1' - commit: 'sha1-9b3254085494b55a0f7c4c2b3d2d52cc712ce370' + 'github/codeql-action@33d7b85da1a04171e211befe2c739303b9a4c066': + ref: 'v4.39.3' + commit: 'sha1-33d7b85da1a04171e211befe2c739303b9a4c066' owner_id: 9919 repo_id: 259445878 - 'haskell-actions/setup@v2.12.1': - ref: 'v2.12.1' - commit: 'sha1-0f8e8c99d88aeb3fbfd523f1ef2c6f762d10d64d' - owner_id: 75048950 - repo_id: 623796603 + 'hyperpolymath/deed-ecosystem@f9d999b60cb5f383679ea19912bcdc49c944973a': + ref: 'v0.1.0' + commit: 'sha1-f9d999b60cb5f383679ea19912bcdc49c944973a' + owner_id: 6759885 + repo_id: 1275649586 + 'hyperpolymath/k9-ecosystem@2155aa26a21758f2ba119f61bc7e0e1981c106fb': + ref: 'v0.1.0' + commit: 'sha1-2155aa26a21758f2ba119f61bc7e0e1981c106fb' + owner_id: 6759885 + repo_id: 1275650185 'hyperpolymath/smtp-notify-action@v0.5.1': ref: 'v0.5.1' commit: 'sha1-e384daf6167a7a7567642d6a62060106244d2413' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 14399403..cb083140 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -38,11 +38,11 @@ jobs: with: persist-credentials: false - name: Initialize CodeQL - uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.38.0 (4.38.1 blocked estate-wide; nexia-list#100) + uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.38.0 (4.38.1 blocked estate-wide; nexia-list#100) with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.38.0 (4.38.1 blocked estate-wide; nexia-list#100) + uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.38.0 (4.38.1 blocked estate-wide; nexia-list#100) with: category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/dogfood-gate.yml b/.github/workflows/dogfood-gate.yml index be56fb64..35161e95 100644 --- a/.github/workflows/dogfood-gate.yml +++ b/.github/workflows/dogfood-gate.yml @@ -144,19 +144,23 @@ jobs: path: ${{ runner.temp }}/k9-grid/badge.json if-no-files-found: error - # The live README badge: badges/k9.json (shields endpoint schema) published to - # the generated `governance-badges` ORPHAN branch on every push to main. + # The live README badge: badges/k9.json (shields endpoint schema), staged here + # and DEPLOYED by pages.yml to the repository's GitHub Pages site on every push + # to main. + # + # It is no longer written to a branch. The estate's Branch-Floor ruleset + # applies to every branch and requires a pull request, so a direct write to + # the old `governance-badges` orphan branch was refused (HTTP 409). A Pages + # deployment is not a branch write, so the ruleset is satisfied, not bypassed. # # Operational contract (the long form is in .github/workflows/README.adoc): - # * the branch is generated output - no common ancestor with main, no PR, - # never merged. That is why the branch is built with `parents: []` and - # never with main's head; - # * identical bytes produce NO commit; + # * this job only STAGES the badge and uploads it as the + # `governance-badge-site` artifact; pages.yml (workflow_run) deploys it; # * only a `success` lane result may render brightgreen; # * skipped, cancelled, unavailable and unrecognised states render - # lightgrey. Running with a skipped lane PUBLISHES grey; it must never - # leave a previous green badge in place, which is why this job no longer - # excludes `needs.k9-validate.result == 'skipped'`. + # lightgrey. Running with a skipped lane STAGES grey; it must never + # leave a previous green badge in place, which is why this job does not + # exclude `needs.k9-validate.result == 'skipped'`. # # scripts/governance-badge.js owns the whole decision, so it can be unit # tested without a repository, a token or a network. @@ -167,14 +171,7 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: - contents: write - # One publisher at a time per repository. The contents API is ALSO - # sha-checked, so a race that slips past the queue is detected (409) and - # re-evaluated against what the other run wrote instead of blindly - # overwriting it. - concurrency: - group: governance-badges-${{ github.repository }} - cancel-in-progress: false + contents: read steps: - name: Checkout repository uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -198,24 +195,31 @@ jobs: name: k9-grid path: ${{ runner.temp }}/k9-grid - - name: Publish badges/k9.json to the governance-badges branch + # Exit 3 (grey because the lane evidence was unusable) still writes the + # honest grey badge, and the upload below still runs, so the deployed + # badge stops claiming success; the step itself then fails the run. + - name: Publish badges/k9.json (stage it for the Pages deployment) env: - GITHUB_TOKEN: ${{ github.token }} LANE_RESULT: ${{ needs.k9-validate.result }} ARTIFACT: ${{ runner.temp }}/k9-grid/badge.json - BRANCH: governance-badges + OUT_DIR: ${{ runner.temp }}/governance-badge-site DEST: badges/k9.json - SOURCE_SHA: ${{ github.sha }} run: | set -euo pipefail - bun scripts/governance-badge.js publish \ + bun scripts/governance-badge.js stage \ --label K9 \ --lane-result "$LANE_RESULT" \ --artifact "$ARTIFACT" \ - --branch "$BRANCH" \ - --path "$DEST" \ - --repo "$GITHUB_REPOSITORY" \ - --source-sha "$SOURCE_SHA" + --out-dir "$OUT_DIR" \ + --path "$DEST" + + - name: Upload the badge for the Pages deployment + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: governance-badge-site + path: ${{ runner.temp }}/governance-badge-site + if-no-files-found: error # --------------------------------------------------------------------------- # Job 3: Empty-linter — invisible character detection diff --git a/.github/workflows/estate-rules.yml b/.github/workflows/estate-rules.yml index 24d3fbc6..886bdbcd 100644 --- a/.github/workflows/estate-rules.yml +++ b/.github/workflows/estate-rules.yml @@ -57,6 +57,10 @@ jobs: || { echo "::error::REPOSITORY-MAP.adoc is stale - run 'just repo-map'"; exit 1; } - name: AsciiDoc by default (no .md under docs/) run: bash scripts/check-no-md-in-docs.sh . + - name: AsciiDoc-by-default gate self-test (positive and negative controls) + run: bash tests/workflows/check_no_md_in_docs_test.sh + - name: proof-status claims reader (positive and negative controls) + run: bash tests/workflows/proof_claims_rows_test.sh # The rule above checks the file EXTENSION only, so a Markdown body # renamed to .adoc passes it. This one checks the file actually parses. # asciidoctor's --failure-level defaults to FATAL, so a document emitting @@ -64,6 +68,8 @@ jobs: # verdict rests on a stderr comparison. - name: Install asciidoctor run: sudo gem install asciidoctor -v 2.0.26 --no-document + - name: Proof gate self-test (stub prover; positive and negative controls) + run: bash tests/workflows/check_proofs_test.sh - name: AsciiDoc render gate self-test (must catch what bare asciidoctor misses) run: bash tests/workflows/check_adoc_renders_test.sh - name: Every tracked .adoc renders clean @@ -87,6 +93,8 @@ jobs: run: bash tests/workflows/internal_links_test.sh - name: Deed clause writer controls run: bash tests/workflows/deed_clause_test.sh + - name: Deed template sync controls + run: bash tests/workflows/deed_template_sync_test.sh - name: Canon lockstep decision controls (spine strict, instance lag passes) run: bash tests/workflows/canon_pin_check_test.sh - name: Canon lockstep adoption tool controls @@ -112,6 +120,10 @@ jobs: run: bash tests/workflows/mint_cleanup_test.sh - name: Self-name pass keeps issue references, provenance and detectors run: bash tests/workflows/self_name_pass_test.sh + - name: Mint scrub deletes only standalone constructs + run: bash tests/workflows/scrub_deletes_whole_constructs_test.sh + - name: Carried tests survive a child tree + run: bash tests/workflows/verbatim_tests_child_safe_test.sh # Stage-2 trial of standards A7 8.1: an edict selected by identity. Trial # only; it gates nothing but its own fixtures. - name: Edict trial (A7 stage 2) @@ -171,6 +183,12 @@ jobs: # equal to standards scripts/uuid-v8.js, and read without re-deriving. - name: Repo chora id is minted as UUIDv8 and read as written run: bash tests/workflows/uuid_v8_test.sh + # The deed's identity literals (standards A1 v0.4.5 T30, ruling Q2): a v5 + # id or a #u5 literal in :repo-uuid or :beholding-chora fails in every mode. + - name: Identity literals are version 8 (#uuid or #u8) + run: bash scripts/check-identity.sh "$(bash scripts/deed-field.sh --find .)" + - name: Identity-literal gate self-test (v5, #u5, v4 and upper-case must fail) + run: bash tests/workflows/check_identity_test.sh # A divergent legacy .well-known/ file is quarantined under the MINT date, # so a replay on a later day names it the same. - name: Legacy .well-known quarantine is named by the mint date @@ -227,6 +245,16 @@ jobs: # records. - name: Governance replaces the runtime gate for every pull request run: bash tests/workflows/governance_policy_test.sh + # A cancelled run must not leave a red verdict job behind. + - name: Fork governance verdict skips on cancel + run: bash tests/workflows/fork_governance_verdict_cancel_test.sh + # The proof-status vocabulary must give one answer for an open row. + - name: PROOF-STATUS vocabulary agrees with itself + run: bash tests/workflows/proof_status_vocabulary_test.sh + # aspect_tests.sh is carried verbatim, so a project token on an active + # line would print literally in every minted repository. + - name: Aspect-test banner carries no unsubstituted token + run: bash tests/workflows/aspect_banner_test.sh # The README badge is generated output on an orphan branch. This proves # the state -> colour table (grey, never a stale green), the byte-equal # no-op, the orphan commit, the API-error classification and the workflow @@ -284,6 +312,8 @@ jobs: fi - name: Converted container configs keep their data (template only) run: bash tests/workflows/container_kyaml_test.sh + - name: Base-image guidance agrees with the digest-pin gate + run: bash tests/workflows/container_guidance_test.sh - name: KYAML ratchet self-test (installs verify, gate propagates, narrowing) run: bash tests/workflows/kyaml_ratchet_test.sh - name: I-JSON (RFC 7493) + JCS (RFC 8785) canonical gate & self-test @@ -332,6 +362,11 @@ jobs: # a scanner that declares none. Every property is mutated in the test. - name: Secret scanner contract (three stable contexts) run: bash tests/workflows/secret_scanner_contract_test.sh + # The gitleaks history pass scans only a pull request's own commits and + # the full history elsewhere; real git repos and the pinned binary prove + # both bounds, the fallbacks, and that a planted secret still fails. + - name: Secret scanner history scope (PR diff vs full history) + run: bash tests/workflows/secret_scanner_history_scope_test.sh # Behaviour and negative controls for the inline fixes to governance, # hypatia-scan, main-estate-audit, rust-ci and secret-scanner. - name: Inline workflow gap fixes (behaviour + negative controls) diff --git a/.github/workflows/fork-governance.yml b/.github/workflows/fork-governance.yml index b05b55be..dab4261c 100644 --- a/.github/workflows/fork-governance.yml +++ b/.github/workflows/fork-governance.yml @@ -324,7 +324,7 @@ jobs: verdict: name: Fork governance verdict needs: [deed, k9, fleet] - if: always() + if: ${{ always() && !cancelled() }} runs-on: ubuntu-24.04 timeout-minutes: 15 permissions: diff --git a/.github/workflows/governance.yml b/.github/workflows/governance.yml index ce97d8d0..189f47cb 100644 --- a/.github/workflows/governance.yml +++ b/.github/workflows/governance.yml @@ -18,6 +18,11 @@ permissions: # Self-contained execution of the shared estate governance policies pinned to # metadatastician/standards@f0b3cd4c464d33e1584f8528c17bce104555e256 # (replacing the retired runtime-policy.yml workflow per PR #244). +# +# The DEED and K9 conformance lanes below are pinned separately, to +# metadatastician/standards@3f480e93c453271031da8890088f9cfc00d4de66: their lane scripts +# (conformance-deed.sh, conformance-k9.sh) first exist at 159fda2c, after the pin above. +# This commit is the last standards commit before #1574, which turned standards main red on 14 Nov; the lane scripts are identical to 159fda2c. The other sites stay on the older pin until each one is checked for compatibility. jobs: governance: name: Estate Governance Policy @@ -59,9 +64,14 @@ jobs: bash .standards-checkout/scripts/check-ts-allowlist.sh rm -rf .standards-checkout - bad_locks="$(git ls-files 'package-lock.json' '**/package-lock.json' 'yarn.lock' '**/yarn.lock' 'pnpm-lock.yaml' '**/pnpm-lock.yaml' || true)" + # pnpm-lock.yaml is expected, not banned: every package carries + # bun.lock, deno.lock and pnpm-lock.yaml together, written by + # tools/js-runtimes regen (standards LANGUAGE-POLICY §1.3-§1.4, + # owner ruling 2026-10-14). package-lock.json stays refused, and + # yarn is in no tier. + bad_locks="$(git ls-files 'package-lock.json' '**/package-lock.json' 'yarn.lock' '**/yarn.lock' || true)" if [ -n "$bad_locks" ]; then - echo "::error::Banned npm/yarn/pnpm lockfiles detected (use Deno or Bun per LANGUAGE-POLICY):" + echo "::error::Banned npm/yarn lockfiles detected (Bun first, from one package.json, per standards LANGUAGE-POLICY §1.3):" printf '%s\n' "$bad_locks" exit 1 fi @@ -71,3 +81,311 @@ jobs: exit 1 fi echo "Governance runtime and language anti-pattern checks passed." + + # A2ML is retired (standards A7, owner ruling S3 of 2026-11-14: the A2ML + # checks live in both governance-reusable.yml and this inline governance). + # The hard gate is estate-rules.yml "No .a2ml files": no A2ML outside the + # shrink-only legacy ledger, 9-archive/ included, so an added, copied, + # renamed or moved A2ML file fails (owner ruling 2026-11-14: A2ML moves + # fail), as standards' diff-based no-new-a2ml does. The advisory existing-A2ML lister is the + # existing-a2ml job below. It, and the DEED and K9 conformance lanes, need a + # standards pin that carries their scripts (159fda2c or later); pins move + # only through the applier (owner ruling, 2026-11-14). + + # Measured debt may fall, never rise silently (standards + # scripts/check-debt-ratchet.sh, the same gate as governance-reusable.yml's + # debt-ratchet job). A repo with no Debtfile passes. Pull requests only: + # the ratchet compares against the base commit. + debt-ratchet: + name: Debt ratchet + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + contents: read + if: ${{ github.event_name == 'pull_request' }} + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + # Full history: the ratchet reads the Debtfile at the base commit + # and scans commit messages between base and HEAD for a declared + # exception. + fetch-depth: 0 + persist-credentials: false + + - name: Checkout the pinned debt ratchet + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: metadatastician/standards + ref: f0b3cd4c464d33e1584f8528c17bce104555e256 + path: .standards-debt-ratchet + sparse-checkout: | + scripts/check-debt-ratchet.sh + scripts/check-debtfile-structure.sh + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Debt ratchet + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + set -euo pipefail + # Stage the scripts outside the scanned tree and delete the checkout, + # so the ratchet reads only this repository's Debtfile. A missing + # script is a failure, never a silent skip. + for s in check-debt-ratchet.sh check-debtfile-structure.sh; do + test -f ".standards-debt-ratchet/scripts/$s" || { + echo "::error::Pinned $s missing at f0b3cd4c464d33e1584f8528c17bce104555e256" + exit 1 + } + cp ".standards-debt-ratchet/scripts/$s" "$RUNNER_TEMP/" + done + rm -rf .standards-debt-ratchet + if [ -f .machine_readable/Debtfile.a2ml ]; then + bash "$RUNNER_TEMP/check-debtfile-structure.sh" + fi + bash "$RUNNER_TEMP/check-debt-ratchet.sh" "$BASE_SHA" + + # The advisory existing-A2ML lister (standards scripts/list-existing-a2ml.sh, + # the same listing as governance-reusable.yml's existing-a2ml-warning job). + # It never fails the run: the checkout and the staging are best effort too, so + # a pin without the script is one warning, not a red run. + existing-a2ml: + name: Existing A2ML (advisory) + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + contents: read + env: + ADVISORY: 'true' + steps: + - name: Checkout repository + id: checkout + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: List existing A2ML files (never fails) + if: ${{ steps.checkout.outcome == 'success' }} + env: + STANDARDS_PIN: f0b3cd4c464d33e1584f8528c17bce104555e256 + run: | + # Best effort end to end, and visibly so: a missing pin, network or script + # becomes one ::warning::, never a red run and never a silently masked step + # (no continue-on-error). The script is fetched outside the scanned tree. + d="$RUNNER_TEMP/standards-list-a2ml" + if git init -q "$d" \ + && git -C "$d" fetch -q --depth 1 https://github.com/metadatastician/standards.git "$STANDARDS_PIN" \ + && git -C "$d" checkout -q FETCH_HEAD -- scripts/list-existing-a2ml.sh; then + bash "$d/scripts/list-existing-a2ml.sh" . || echo "::warning::the existing-A2ML listing could not run (exit $?)" + else + echo "::warning::could not fetch scripts/list-existing-a2ml.sh at $STANDARDS_PIN (the pin may predate it); the existing-A2ML listing did not run." + fi + + - name: Say so when the checkout failed + if: ${{ steps.checkout.outcome == 'failure' }} + run: echo "::warning::the repository checkout failed, so the existing-A2ML listing did not run." + + # The DEED conformance lane (standards scripts/conformance-deed.sh, the same + # code governance-reusable.yml's nested deed-conformance.yml runs). ADVISORY + # is on, as in the reusable: every finding is a ::warning:: and the job passes, + # so a repository opts into enforcement by setting ADVISORY to 'false'. + deed-conformance: + name: Deed conformance + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + env: + ADVISORY: 'true' + LANE: .standards-checkout/scripts/conformance-deed.sh + T: .standards-checkout/1-formats/deed/tools + steps: + - name: Checkout repository + id: checkout + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Checkout the pinned DEED lane + id: canon + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: metadatastician/standards + ref: 3f480e93c453271031da8890088f9cfc00d4de66 + path: .standards-checkout + sparse-checkout: | + scripts/conformance-deed.sh + 1-formats/deed/tools + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Assert the pinned DEED lane script is present + # A checkout that succeeded but left no script means the standards pin + # predates it (159fda2c or later is needed): a configuration error, never an + # advisory finding, so it fails loudly and is not masked. + if: ${{ steps.canon.outcome == 'success' }} + run: | + test -f "$LANE" || { echo "::error::Pinned conformance-deed.sh missing: the standards pin predates it (159fda2c or later is needed)"; exit 1; } + + - name: Set up Bun + id: bun + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: "1.4.2" + + - name: Lint every committed deed + id: lint + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: bash "$LANE" lint + + - name: Advisory findings as warnings + # Also when a prerequisite step failed: a failed checkout leaves an empty + # workspace that lints as "nothing to lint" and would otherwise go green. + if: ${{ always() && env.ADVISORY == 'true' && (steps.lint.outcome == 'failure' || steps.checkout.outcome == 'failure' || steps.canon.outcome == 'failure' || steps.bun.outcome == 'failure') }} + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: | + # The script lives in the checkout this step may be reporting on, so the + # fallback for its absence is inline: a failed checkout must still warn. + if [ -f "$LANE" ]; then + bash "$LANE" warn + else + echo "::warning::deed conformance (advisory): the conformance script could not be staged (a checkout step failed), so conformance did not run; not enforced." + fi + + # The K9 conformance lane (standards scripts/conformance-k9.sh, the same code + # as the nested k9-conformance.yml). Advisory by the same switch as above. The + # grid is written to the job summary; the delta column reads the previous grid + # comment on a pull request. + k9-conformance: + name: K9 conformance + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + contents: read + pull-requests: read + env: + ADVISORY: 'true' + CANON: .standards-checkout + CANON_REF: 3f480e93c453271031da8890088f9cfc00d4de66 + LANE: .standards-checkout/scripts/conformance-k9.sh + NICKEL_VERSION: '1.18.0' + NICKEL_SHA256: '9cba4dd65ae9915ec61f73033aafcff307a377665a83fd8f530df086763318cb' + steps: + - name: Checkout repository + id: checkout + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + # Full history: the changed-file list is the merge-base diff and the + # ledger ratchet reads the commit messages. + fetch-depth: 0 + persist-credentials: false + + - name: Checkout the pinned K9 lane + id: canon + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: metadatastician/standards + ref: 3f480e93c453271031da8890088f9cfc00d4de66 + path: .standards-checkout + sparse-checkout: | + 1-formats/k9 + 2-protocols/k9-coordination/spec/abnf + 2-protocols/k9-coordination/tools/validate + scripts/k9-grid.sh + scripts/lib/k9-grid.jq + scripts/conformance-k9.sh + sparse-checkout-cone-mode: false + persist-credentials: false + + - name: Assert the pinned K9 lane script is present + # As for the DEED lane: a missing script at the pinned SHA is a configuration + # error and fails loudly. + if: ${{ steps.canon.outcome == 'success' }} + run: | + test -f "$LANE" || { echo "::error::Pinned conformance-k9.sh missing: the standards pin predates it (159fda2c or later is needed)"; exit 1; } + + - name: Install Nickel (pinned, sha256-verified) + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: | + set -euo pipefail + URL="https://github.com/tweag/nickel/releases/download/${NICKEL_VERSION}/nickel-x86_64-linux" + curl -sSfL --proto '=https' --proto-redir '=https' --tlsv1.2 --retry 3 -o "$RUNNER_TEMP/nickel" "$URL" + echo "${NICKEL_SHA256} ${RUNNER_TEMP}/nickel" | sha256sum -c - + chmod +x "$RUNNER_TEMP/nickel" + echo "$RUNNER_TEMP" >> "$GITHUB_PATH" + + - name: Set up Bun + continue-on-error: ${{ env.ADVISORY == 'true' }} + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 + with: + bun-version: "1.4.2" + + - name: Validator self-test + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: bash "$LANE" selftest + + - name: Contract typecheck + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: bash "$LANE" typecheck + + - name: Enumerate the committed K9 files, the changed files and ledger growth + continue-on-error: ${{ env.ADVISORY == 'true' }} + env: + BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }} + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + LEDGER: .machine_readable/k9-contract-debt.txt + run: bash "$LANE" enumerate + + - name: Validate every committed K9 file (L0-L2, strict) + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: bash "$LANE" validate + + - name: Validate coordination.k9 files against the v1.2 ABNF + continue-on-error: ${{ env.ADVISORY == 'true' }} + run: bash "$LANE" coord + + - name: Read the grid comment from the previous revision (delta column) + continue-on-error: ${{ env.ADVISORY == 'true' }} + if: github.event_name == 'pull_request' + env: + GH_TOKEN: ${{ github.token }} + COMMENTS_URL: ${{ github.event.pull_request.comments_url }} + MARKER: '' + GRID_AUTHOR: github-actions[bot] + run: bash "$LANE" previous + + - name: Render the verdict grid + id: grid + continue-on-error: ${{ env.ADVISORY == 'true' }} + env: + REQUIRE_FILES: 'false' + PR_NUMBER: ${{ github.event.pull_request.number || 'local' }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + run: bash "$LANE" render + + - name: Gate + continue-on-error: ${{ env.ADVISORY == 'true' }} + env: + STATE: ${{ steps.grid.outputs.state }} + FAIL_ON_INDETERMINATE: 'false' + CHECKOUT_OUTCOME: ${{ steps.checkout.outcome }} + CANON_OUTCOME: ${{ steps.canon.outcome }} + run: | + # The script lives in the checkout this step may be reporting on, so the + # fallback for its absence is inline: a failed checkout must still say so. + if [ -f "$LANE" ]; then + bash "$LANE" gate + elif [ "$ADVISORY" = "true" ]; then + echo "::warning::K9 conformance (advisory): the conformance script could not be staged (a checkout step failed), so conformance did not run; not enforced." + else + echo "::error::K9 conformance could not run: the conformance script could not be staged (a checkout step failed)"; exit 1 + fi diff --git a/.github/workflows/hypatia-scan.yml b/.github/workflows/hypatia-scan.yml index b47e02d4..fe86fded 100644 --- a/.github/workflows/hypatia-scan.yml +++ b/.github/workflows/hypatia-scan.yml @@ -158,7 +158,7 @@ jobs: - name: Upload Hypatia SARIF to GitHub Code Scanning if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository - uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: sarif_file: hypatia.sarif category: hypatia diff --git a/.github/workflows/main-estate-audit.yml b/.github/workflows/main-estate-audit.yml index 6de4fd71..c9825ba5 100644 --- a/.github/workflows/main-estate-audit.yml +++ b/.github/workflows/main-estate-audit.yml @@ -59,7 +59,7 @@ jobs: # suite (no check.sh), so run the `run:` block of the pinned # action.yml itself rather than a copy. They can fail a build. # manifest-check is NOT here: it delegates to the deed-ecosystem and - # k9-ecosystem validate-actions, which are `uses:` steps, not scripts. + # k9-ecosystem validate-actions, which are `uses:` steps below, not scripts. for gate in required-files-check idris2-abi-check; do echo "=== cicd-suite: $gate ===" script="$(yq -r '.runs.steps[0].run' "$SUITE/$gate/action.yml")" @@ -76,3 +76,16 @@ jobs: exit 1 fi echo "Central Estate CI/CD Audit passed." + + # manifest-check, inlined: the pinned cicd-suite action delegates to these + # two validators. Both are composite actions with no nested `uses:`, pinned + # at the commits the suite itself pins, now tagged v0.1.0 upstream. + - name: Validate DEED manifests + uses: hyperpolymath/deed-ecosystem/validate-action@f9d999b60cb5f383679ea19912bcdc49c944973a # v0.1.0 + with: + path: . + + - name: Validate K9 manifests + uses: hyperpolymath/k9-ecosystem/validate-action@2155aa26a21758f2ba119f61bc7e0e1981c106fb # v0.1.0 + with: + path: . diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index bb71ddb7..e02987ee 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,18 +1,25 @@ # This workflow is managed by gh actions-lock. # SPDX-License-Identifier: MPL-2.0 -# GitHub Pages via casket-ssg (hyperpolymath's pure-Haskell static site generator). +# GitHub Pages via ddraig-ssg (hyperpolymath's Idris2 static site generator, the +# proof-carrying one: the build fails if a page cannot be certified accessible). # Replaces the orphan one-off Pages deployment with a reproducible build. name: GitHub Pages +# Deployed AFTER Dogfood Gate completes on main, because the site now carries +# badges/k9.json (the README's live K9 badge). There is one Pages site per +# repository and a deployment replaces it wholesale, so the badge has to be part +# of THE deployment; a second, earlier deploy from a bare push would erase it. +# This also means a manual workflow_dispatch is gone: re-run Dogfood Gate on +# main to redeploy. Pages deployments are not branch writes, so this satisfies +# the Branch-Floor ruleset (which refused the old governance-badges branch). on: - push: + workflow_run: + workflows: ["Dogfood Gate"] + types: [completed] branches: [main] - workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write +# Least privilege: nothing at workflow level; each job asks for what it needs. +permissions: {} # Serialise Pages deploys; never cancel an in-flight deploy. concurrency: @@ -20,73 +27,137 @@ concurrency: cancel-in-progress: false jobs: - build: + # Freshness gate. Re-running an OLDER Dogfood Gate run (or a late-finishing one + # during a burst of merges) must not replace a newer run's badge: a green + # badge from an old commit would overwrite a red one from the current head. + # Only the run for the default branch's CURRENT head may deploy; a superseded + # run is skipped (not failed), because the newer run's own deployment follows. + gate: + # Only main pushes (never a PR or fork run), and not a cancelled gate run: + # a cancelled run staged nothing trustworthy to deploy. + if: >- + github.event.workflow_run.event == 'push' && + github.event.workflow_run.conclusion != 'cancelled' + permissions: + contents: read + timeout-minutes: 5 + runs-on: ubuntu-24.04 outputs: - pages-artifact-name: github-pages-${{ github.run_id }}-${{ github.run_attempt }} - # The cold Pandoc dependency build exceeded the previous 20-minute budget. - timeout-minutes: 60 + current: ${{ steps.fresh.outputs.current }} + steps: + - name: Is this the default branch's current head? + id: fresh + env: + GH_TOKEN: ${{ github.token }} + RUN_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + set -euo pipefail + head="$(gh api "repos/$GITHUB_REPOSITORY/commits/HEAD" --jq .sha)" + if [ "$head" = "$RUN_SHA" ]; then + echo "current=true" >> "$GITHUB_OUTPUT" + else + echo "current=false" >> "$GITHUB_OUTPUT" + echo "Superseded: run is for ${RUN_SHA:0:12}, default branch is at ${head:0:12}; not deploying its badge." + fi + + build: + needs: gate + if: needs.gate.outputs.current == 'true' + permissions: + contents: read + actions: read # download the badge artifact of the triggering run + pages: read # configure-pages reads the Pages config (private repos) + timeout-minutes: 20 runs-on: ubuntu-24.04 steps: + # Deliberately NO `ref:`: a workflow_run job runs with this repository's + # permissions, so it builds the default branch (this repo's own trusted + # code) and never checks out the triggering run's head. - name: Checkout - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - - name: Checkout casket-ssg - uses: actions/checkout@v7.0.1 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - repository: hyperpolymath/casket-ssg - ref: c190d2882d9ff27205dd5a5b6db6da12cc647a70 - path: .casket-ssg persist-credentials: false - - name: Setup GHCup - uses: haskell-actions/setup@v2.12.1 - with: - ghc-version: '9.8.2' - cabal-version: '3.10' - - - name: Cache Cabal - uses: actions/cache@v6.1.0 - with: - path: | - ~/.cabal/packages - ~/.cabal/store - .casket-ssg/dist-newstyle - key: ${{ runner.os }}-${{ runner.arch }}-ghc-9.8.2-cabal-3.10-casket-${{ hashFiles('.casket-ssg/casket-ssg.cabal', '.casket-ssg/cabal.project*') }} - - - name: Build casket-ssg - working-directory: .casket-ssg - run: cabal build + # Pinned to a commit: an SSG that runs in the deploy path must not float. + # Fetched by that exact SHA and verified, rather than through + # actions/checkout with a repository+ref: in a workflow_run workflow, + # SonarCloud S7631 flags any such checkout as possibly running fork code, + # and cannot tell a hard-coded SHA of a trusted repository from a + # variable ref. This step avoids that pattern; it does not make the + # finding wrong. The pin is the control, and the test below enforces it. + - name: Fetch ddraig-ssg at the pinned commit + env: + DDRAIG_SHA: c334dab63a25995ed5ce1256e4e633bad21adacd + run: | + set -euo pipefail + git init -q .ddraig-ssg + git -C .ddraig-ssg fetch -q --depth 1 https://github.com/hyperpolymath/ddraig-ssg "$DDRAIG_SHA" + git -C .ddraig-ssg checkout -q --detach FETCH_HEAD + test "$(git -C .ddraig-ssg rev-parse HEAD)" = "$DDRAIG_SHA" + # ddraig reads Markdown only and certifies every page (exactly one

, + # non-skipping headings); a page that fails certification FAILS the build + # (exit 1) rather than publishing. So the seed is a minimal page with one + #

pointing at the README (README.adoc is AsciiDoc and would fail the + # gate). A repository that wants a real site provides site/index.md. + # The toolchain is the same digest-pinned image ddraig's own CI uses, run + # on the runner's Docker: no marketplace action is needed for the build. - name: Build site + env: + IDRIS2_PACK_IMAGE: ghcr.io/stefan-hoeck/idris2-pack@sha256:f0758996a931fb35d9ecb1de273c4d59dabe2a09b433afc7e357f65a08b7e1ff + REPO: ${{ github.repository }} + OWNER: ${{ github.repository_owner }} run: | + set -euo pipefail mkdir -p site _site - # Seed site/index.md from README if the author hasn't provided one. + name="${REPO#*/}" if [ ! -f site/index.md ]; then { echo "---" - echo "title: $(basename "$PWD")" + echo "title: ${name}" echo "date: $(date +%Y-%m-%d)" echo "---" - if [ -f README.adoc ]; then cat README.adoc - elif [ -f README.md ]; then cat README.md - else printf '\n# %s\n\nDocumentation coming soon.\n' "$(basename "$PWD")" - fi + echo "# ${name}" + echo + echo "See the [repository README](https://github.com/${REPO}#readme)." } > site/index.md fi - cd .casket-ssg && cabal run casket-ssg -- build ../site ../_site + base_url="https://$(printf '%s' "$OWNER" | tr '[:upper:]' '[:lower:]').github.io/${name}" + docker run --rm -v "$PWD:/w" -w /w/.ddraig-ssg "$IDRIS2_PACK_IMAGE" \ + sh -c 'idris2 Ddraig.idr -o ddraig && ./build/exec/ddraig build ../site ../_site "$1"' _ "$base_url" + + # The badge was staged by the gate's `badges` job from the lane result and + # evidence. A missing artifact fails this job loudly: deploying the site + # without it would silently delete the live badge. + - name: Fetch the staged badge + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: governance-badge-site + path: ${{ runner.temp }}/governance-badge-site + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ github.token }} + + - name: Add the badge to the site + run: | + set -euo pipefail + test -f "$RUNNER_TEMP/governance-badge-site/badges/k9.json" + mkdir -p _site/badges + cp "$RUNNER_TEMP/governance-badge-site/badges/k9.json" _site/badges/k9.json + cat _site/badges/k9.json - name: Setup Pages - uses: actions/configure-pages@v6.0.0 + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 - name: Upload artifact - uses: actions/upload-pages-artifact@v5.0.0 + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: - name: github-pages-${{ github.run_id }}-${{ github.run_attempt }} path: '_site' deploy: + permissions: + contents: read # read the default branch head for the freshness re-check + pages: write + id-token: write timeout-minutes: 20 environment: name: github-pages @@ -94,8 +165,27 @@ jobs: runs-on: ubuntu-24.04 needs: build steps: + # Second freshness check. The gate job only looked once, at the start; the + # build can take up to 20 minutes and the pages concurrency group does not + # cancel in-flight runs, so a newer push to the default branch may have landed + # since. Re-check immediately before deploying and skip (not fail) when this + # run has been superseded: the newer run's own deployment follows. + - name: Still the default branch's current head? (re-check before deploy) + id: fresh + env: + GH_TOKEN: ${{ github.token }} + RUN_SHA: ${{ github.event.workflow_run.head_sha }} + run: | + set -euo pipefail + head="$(gh api "repos/$GITHUB_REPOSITORY/commits/HEAD" --jq .sha)" + if [ "$head" = "$RUN_SHA" ]; then + echo "current=true" >> "$GITHUB_OUTPUT" + else + echo "current=false" >> "$GITHUB_OUTPUT" + echo "Superseded: run is for ${RUN_SHA:0:12}, default branch is at ${head:0:12}; not deploying its badge." + fi + - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v5.0.1 - with: - artifact_name: ${{ needs.build.outputs.pages-artifact-name }} + if: steps.fresh.outputs.current == 'true' + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 57c9881c..87a947df 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -39,7 +39,7 @@ jobs: publish_results: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Upload Scorecard SARIF to GitHub Code Scanning - uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 with: sarif_file: results.sarif category: scorecard diff --git a/.github/workflows/secret-scanner.yml b/.github/workflows/secret-scanner.yml index 76767c4d..896e2c2a 100644 --- a/.github/workflows/secret-scanner.yml +++ b/.github/workflows/secret-scanner.yml @@ -6,6 +6,10 @@ on: pull_request: push: branches: [main] + merge_group: + # Weekly full-history sweep: pull requests scan only their own commits. + schedule: + - cron: "17 3 * * 2" workflow_dispatch: concurrency: @@ -125,6 +129,53 @@ jobs: chmod +x "$RUNNER_TEMP/gitleaks" rm -f "$RUNNER_TEMP/$TARBALL" + # HISTORY SCOPE (metadatastician/standards#1587). Without --log-opts, + # gitleaks' git mode walks every commit on every branch + # (`git log -p -U0 --full-history --all`), so a pull-request scan cost + # grew with the repository's age and timed out on large repos. A pull + # request now scans only the commits it adds; push, schedule and + # workflow_dispatch keep the full scan of every fetched ref (--all), so a + # secret committed and deleted on an unmerged branch is still found. A + # range that cannot be resolved, or that holds no commits, falls back to + # that full scan, never to nothing. + - name: History scope + id: scope + env: + EVENT_NAME: ${{ github.event_name }} + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + MG_BASE_SHA: ${{ github.event.merge_group.base_sha }} + run: | + set -euo pipefail + range="" + case "$EVENT_NAME" in + pull_request|pull_request_target) + if git rev-parse -q --verify 'HEAD^2' >/dev/null; then + range='HEAD^1..HEAD' + elif [ -n "${PR_BASE_SHA:-}" ] && git cat-file -e "${PR_BASE_SHA}^{commit}" 2>/dev/null; then + range="${PR_BASE_SHA}..HEAD" + fi + ;; + merge_group) + if [ -n "${MG_BASE_SHA:-}" ] && git cat-file -e "${MG_BASE_SHA}^{commit}" 2>/dev/null; then + range="${MG_BASE_SHA}..HEAD" + fi + ;; + *) + # push, schedule, workflow_dispatch and anything new: full history of every ref. + ;; + esac + if [ -n "$range" ] && [ "$(git rev-list --count "$range")" -eq 0 ]; then + echo "::notice::$range holds no commits for $EVENT_NAME; scanning full history instead of nothing." + range="" + fi + if [ -n "$range" ]; then + echo "History scope: DIFF ($range, $(git rev-list --count "$range") commit(s)) for $EVENT_NAME." + else + range="--all" + echo "History scope: FULL (all $(git rev-list --count --all) commit(s) on every fetched ref) for $EVENT_NAME." + fi + echo "range=$range" >> "$GITHUB_OUTPUT" + - name: Gitleaks working-tree pass run: | set -euo pipefail @@ -138,6 +189,7 @@ jobs: "$RUNNER_TEMP/gitleaks" detect \ --source . \ --no-git \ + --max-target-megabytes 5 \ --redact \ --no-banner \ --verbose \ @@ -146,12 +198,16 @@ jobs: done - name: Gitleaks full-history pass + env: + SCAN_RANGE: ${{ steps.scope.outputs.range }} run: | set -euo pipefail + test -n "${SCAN_RANGE:-}" if [ "$(git rev-parse --is-shallow-repository)" != "false" ]; then echo "::error::checkout is shallow; refusing vacuous history scan" exit 1 fi + echo "history in this clone: $(git rev-list --count HEAD) commits; this scan: $(git rev-list --count "$SCAN_RANGE") ($SCAN_RANGE)" # The estate baseline always runs; a repository .gitleaks.toml adds a # second pass and can never stand in for the baseline. CONFIGS=(".gitleaks-estate.toml") @@ -161,6 +217,8 @@ jobs: for CONFIG in "${CONFIGS[@]}"; do "$RUNNER_TEMP/gitleaks" detect \ --source . \ + --log-opts="$SCAN_RANGE" \ + --max-target-megabytes 5 \ --redact \ --no-banner \ --verbose \ @@ -196,6 +254,7 @@ jobs: "$RUNNER_TEMP/gitleaks" detect \ --source "$MIRROR" \ --no-git \ + --max-target-megabytes 5 \ --redact \ --no-banner \ --config "$CONFIG" \ diff --git a/.machine_readable/arrival-pack/extract.sh b/.machine_readable/arrival-pack/extract.sh index 8c2e3c0b..c9e0aa41 100755 --- a/.machine_readable/arrival-pack/extract.sh +++ b/.machine_readable/arrival-pack/extract.sh @@ -46,21 +46,43 @@ items() { printf '%s' "$out" } +# lines PATH KEY -> the deed list :KEY ( … ), one item per line, "" when absent +lines() { + local out rc=0 + out="$(bash "$READ" --list "$DEED" "$1" "$2")" || rc=$? + [[ "$rc" -le 1 ]] || return "$rc" + printf '%s' "$out" +} + # hash12 -> short content hash of stdin (drift provenance) hash12() { sha256sum | cut -c1-12; } -# The identity is the deed's own TYPED literal (#u5"", later #u8""), -# never a computed hex uuid. The uuid is derived from that name and never -# stored (deed.abnf); printing its hex form put a version-5 literal in -# CLAUDE.md, which ADR-008's strict gate (owner ruling D320, standards -# governance job uuid-v7-conformance) rejects in every minted repo. The -# typed literal says what the identifier is, as ADR-008 asks of legacy ids, -# and follows the deed when it moves to version 8. +# The identity is the deed's own TYPED literal, printed as written: +# #uuid"" (minted once, A7 J11), or the computed #u8"". +# The pack never prints a derived hex form of a name literal: that once put a +# version 5 id in CLAUDE.md, which ADR-008's strict gate (owner ruling D320) +# rejects in every minted repo. The typed literal says what the identifier is, +# as ADR-008 asks. uuid_name="$(field '' repo-uuid)" uuid="" -[ -z "$uuid_name" ] || uuid="$(sed -n -E 's/^[[:space:]]*:repo-uuid[[:space:]]+(#u[0-9]+"[^"]*").*/\1/p' "$DEED" | head -1)" +if [[ -n "$uuid_name" ]]; then + # --typed keeps the tag and quotes, and reads the literal wherever the layout puts it + rc=0 + uuid="$(bash "$READ" --typed "$DEED" '' repo-uuid)" || rc=$? + [[ "$rc" -le 1 ]] || exit "$rc" + [[ "$uuid" =~ ^#u(uid|[0-9]+)\"[^\"]*\"$ ]] || uuid="" +fi [ -z "$uuid_name" ] || [ -n "$uuid" ] \ - || { echo "extract.sh: $(basename "$DEED") :repo-uuid is not a typed #u\"...\" literal" >&2; exit 2; } + || { echo "extract.sh: $(basename "$DEED") :repo-uuid is not a typed #uuid\"...\" or #u\"...\" literal" >&2; exit 2; } +# A version 5 identity is reported, not refused, here: this is the arrival-pack +# reader, not the gate. Standards A1 v0.4.5 C10 and T30 (ruling Q2) make +# v5-identity and u5-identity errors in every mode, and `just validate-rsr` +# and estate-rules (scripts/check-identity.sh) refuse them. The chora id is the +# v8 id of the birth path. +case "$uuid" in + '#u5"'*|'#uuid"'????????-????-5*) + echo "extract.sh: v5-identity: $(basename "$DEED") :repo-uuid $uuid is a version 5 id; the chora id is #uuid\"\" (standards A1 V8)" >&2 ;; +esac # read_clauses -> the clauses this pack reads, one token per line. Hashing only # these keeps an unrelated deed edit (say a canon-pin bump) from reading as drift. @@ -81,9 +103,18 @@ isnot="$(items ecosystem not ' · ')" canonical_name="$(field '' canonical-name)" [ -n "$canonical_name" ] \ || { echo "extract.sh: $(basename "$DEED") has no :canonical-name" >&2; exit 2; } -prefixed_name="$(field identity prefixed-name)" +# Clade placements are identity facts about where the repo sits, never its id +# and never an edict; chora-registry is authoritative for them (standards A1 +# §11, ruling W10). The clause is optional. clade_primary="$(field clade primary)" clade_secondary="$(items clade secondary ', ')" +if [[ -z "$clade_primary" ]]; then + clade_aid="none declared (optional placement)" +elif [[ -n "$clade_secondary" ]]; then + clade_aid="$clade_primary (secondary $clade_secondary; placement)" +else + clade_aid="$clade_primary (placement)" +fi born="$(field lineage born)" forge_gh="$(field forges github)" purpose="$(field ecosystem purpose)" @@ -94,16 +125,17 @@ phase="$(field status phase)" maturity="$(field maturity level)" golden_smoke="$(items anchor/golden-path smoke-test-command ' && ')" golden_crit="$(items anchor/golden-path success-criteria '; ')" +# The anchor may override the estate language policy for this repo only. +anchor_forbidden="$(lines anchor/implementation-policy forbidden)" +anchor_allowed="$(lines anchor/implementation-policy allowed)" anchor_clause="$(bash "$READ" --clause "$DEED" anchor)" h_deed="$(read_clauses | hash12)" h_anchor="$(printf '%s\n' "$anchor_clause" | hash12)" -jq -n \ +jq -cnS \ --arg canonical_name "$canonical_name" \ - --arg prefixed_name "$prefixed_name" \ + --arg clade_aid "$clade_aid" \ --arg uuid "$uuid" \ - --arg clade_primary "$clade_primary" \ - --arg clade_secondary "$clade_secondary" \ --arg born "$born" \ --arg forge_gh "$forge_gh" \ --arg purpose "$purpose" \ @@ -118,4 +150,8 @@ jq -n \ --arg golden_crit "$golden_crit" \ --arg h_deed "$h_deed" \ --arg h_anchor "$h_anchor" \ - '$ARGS.named' + --arg anchor_forbidden "$anchor_forbidden" \ + --arg anchor_allowed "$anchor_allowed" \ + '$ARGS.named + | .anchor_forbidden |= (split("\n") | map(select(. != ""))) + | .anchor_allowed |= (split("\n") | map(select(. != "")))' diff --git a/.machine_readable/mint-verbatim.txt b/.machine_readable/mint-verbatim.txt index 8e0438a9..e89dd58b 100644 --- a/.machine_readable/mint-verbatim.txt +++ b/.machine_readable/mint-verbatim.txt @@ -36,3 +36,8 @@ tests/e2e/language_profiles_mint_test.sh # minted-tree fixtures; keeps archety tests/workflows/resolve_template_pin_test.sh # template-slug fixtures tests/ffi_strings_test.sh # FFI token fixture, filled in a scratch copy tests/workflows/container_kyaml_test.sh # container token fixtures (template only) +CHANGELOG.adoc # prose quotes the project-name brace token when it describes a mint failure +docs/reports/compliance/RSR-TEMPLATE-DAMAGE-2026-10-30.adoc # the report is about the unfilled project-name brace token +scripts/survey-template-damage.sh # searches children for an unfilled project-name brace token +scripts/check-mint-tokens.sh # the gate's own comments name the tokens it checks +tests/aspect_tests.sh # a comment names the lowercase brace token that symbol names may carry diff --git a/.machine_readable/root-allow.txt b/.machine_readable/root-allow.txt index 865ea870..a3da6c12 100644 --- a/.machine_readable/root-allow.txt +++ b/.machine_readable/root-allow.txt @@ -98,3 +98,4 @@ tests/ ?priv/ # elixir/OTP: an application's priv dir is fixed at the project root (Application.app_dir/2) ?Cargo.toml # rust-cli archetype: Cargo reads the package manifest from the package root only; the overlay mints it from Cargo.toml.in ?Cargo.lock # rust-cli archetype: `just repo-init` generates it (cargo generate-lockfile) because the minted CI builds with --locked +?.uuid-v8-exempt # scripts/check-uuid-v8.sh reads this exact root path: the negative-control tests that hold #u5 on purpose (owner-approved 2026-11-14) diff --git a/.uuid-v8-exempt b/.uuid-v8-exempt new file mode 100644 index 00000000..a1e22495 --- /dev/null +++ b/.uuid-v8-exempt @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MPL-2.0 +# Files scripts/check-uuid-v8.sh does not scan. Exact paths only, one per line. +# Ratchet-exception: negative-control fixture, owner approved 2026-11-14 (SysArch thread) +tests/workflows/coaptation_families_test.sh +tests/workflows/self_name_pass_test.sh +tests/workflows/uuid5_url_test.sh diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index a552e623..278e34e2 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -8,6 +8,20 @@ https://semver.org/spec/v2.0.0.html[Semantic Versioning]. === [Unreleased] +==== Fixed + +* The K9 badge publisher failed on every push to `main` in minted repos: it + wrote straight to the `governance-badges` branch, and the estate's + `Branch-Floor` ruleset (all branches, `code_coverage` requires a pull + request) refused it with HTTP 409. The badge is now staged by the `badges` + job (`governance-badge.js stage`, `contents: read` only) and deployed with + the GitHub Pages site by `pages.yml` (now triggered by Dogfood Gate + completing on `main`), at `https://.github.io//badges/k9.json`. + The ruleset is satisfied, not bypassed. Minted repos need Pages enabled with + source "GitHub Actions"; `pages.yml` lost its `push` and `workflow_dispatch` + triggers. The helper's old `publish` route is no longer used by any workflow + and is left in place for a follow-up removal. + ==== Added * **Chain minting: a minted repo can be minted again.** "Use this template" diff --git a/CLAUDE.md b/CLAUDE.md index a93417a7..0312c5e6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -145,13 +145,21 @@ present an unexecuted check as a pass. Using both does not make two independent witnesses (policy §1.2). Third-party code (crates such as Bevy, libraries, forks) is **not** converted -or re-proved. State what a proof relies on as an `ASSUMED` boundary -specification, and when choosing between dependencies that fit equally well, -prefer one that carries its own verification. A preference, not a gate. - -Proof grades are policy §8, *Proof Witness Grades*: `PWG-3` < `PWG-2i` < -`PWG-2ii` < `PWG-1`, where `PWG-1` is strongest. A grade is derived from -receipts, never asserted. A "verified" or "machine-checked" claim needs -current receipts. Report a census with its denominator, never a -percentage. Always write the `PWG-` prefix: CRG, TRG, ARG and FRG letters, -and ECHIDNA's `TrustLevel`, are different schemes. +or re-proved. Where a proof relies on a dependency the prover does not check, +state the reliance as an `ASSUMED` boundary specification. Where the +dependency's whole import cone compiles under the prover's safe mode with zero +postulates, it is *checked, not assumed*: record the cone (root module, flags, +postulate count of zero, library name, version and pin) instead of an +`ASSUMED` row (policy §1.1). A cone with a postulate, or compiled outside safe +mode, is not checked. When choosing between dependencies that fit equally +well, prefer one that carries its own verification. A preference, not a gate. + +Proof Witness Grades are policy §8. They apply to *theory* theorems only: Agda +source, rechecked in Rocq and Lean (§8.1). Engineering proofs (Creusot, Verus, +SPARK, Idris2) are not graded on this ladder; they use the §5 tokens only. For +a theory theorem, `PWG-3` < `PWG-2i` < `PWG-2ii` < `PWG-1`, where `PWG-1` is +strongest. A theorem that does not reach `PWG-3` is `ungraded`, with no +qualifier. A grade is derived from receipts, never asserted. A "verified" or +"machine-checked" claim needs current receipts. Report a census with its +denominator, never a percentage. Always write the `PWG-` prefix: CRG, TRG, ARG +and FRG letters, and ECHIDNA's `TrustLevel`, are different schemes. diff --git a/build/container/README.adoc b/build/container/README.adoc index c081eafe..4039e173 100644 --- a/build/container/README.adoc +++ b/build/container/README.adoc @@ -266,9 +266,11 @@ image build/publish jobs you no longer need. == Base images -* Builder: `cgr.dev/chainguard/wolfi-base:latest` -* Runtime: `cgr.dev/chainguard/wolfi-base:latest` (or - `cgr.dev/chainguard/static:latest` for static binaries) +* Builder: `cgr.dev/chainguard/wolfi-base@sha256:` +* Runtime: `cgr.dev/chainguard/wolfi-base@sha256:` (or + `cgr.dev/chainguard/static@sha256:` for static binaries) + +Pin every `FROM` by digest with `scripts/pin-container-digests.sh`. A tag is not a pin: `scripts/check-container-pins.sh` rejects a `FROM` with a tag and no digest (`:latest` or a version tag). It accepts a tag followed by a digest, but then the tag does nothing, so write the digest alone. Chainguard images are minimal, low-CVE, and rebuilt daily (`apk` package manager, Alpine-compatible). diff --git a/build/just/proofs.just b/build/just/proofs.just index dfd63346..29cde9f1 100644 --- a/build/just/proofs.just +++ b/build/just/proofs.just @@ -54,8 +54,17 @@ proof-status: # PROOF-STATUS may live at root, docs/status/ (post-#20), .md or .adoc (post-#23) for candidate in docs/status/PROOF-STATUS.adoc docs/status/PROOF-STATUS.md PROOF-STATUS.adoc PROOF-STATUS.md; do if [ -f "$candidate" ]; then - grep -E "^\| \*\*Total\*\*|^\| \*Total\*" "$candidate" 2>/dev/null || echo "(No summary row in $candidate)" - exit 0 + case "$candidate" in + *.adoc) + echo "Claims in $candidate (no overall total: a census is reported with its denominator):" + bash scripts/proof-claims-rows.sh "$candidate" || echo "(no claims rows found in $candidate)" + exit 0 ;; + *) + # The claims reader reads AsciiDoc only. Say so, and fail: + # a Markdown status file must not look like an empty census. + echo "$candidate is Markdown: the claims reader reads PROOF-STATUS.adoc. Migrate the file." >&2 + exit 1 ;; + esac fi done echo "(No PROOF-STATUS file found at root or docs/status/)" diff --git a/build/just/provision-lib.sh b/build/just/provision-lib.sh index 83e0cf67..6d7ea6a1 100755 --- a/build/just/provision-lib.sh +++ b/build/just/provision-lib.sh @@ -115,6 +115,7 @@ detect_langs() { [ -n "$(first gleam.toml)" ] && out+=(gleam) [ -n "$(first dune-project)" ] && out+=(ocaml) { [ -n "$(first '*.cabal')" ] || [ -n "$(first stack.yaml 1)" ]; } && out+=(haskell) + [ -n "$(first '*.affine' 3)" ] && out+=(affinescript) [ -n "$(first package.json)" ] && out+=(bun) [ ${#out[@]} -eq 0 ] && out+=(docs) printf '%s\n' "${out[@]}" @@ -136,6 +137,8 @@ lang_tools() { gleam) echo "gleam erl" ;; ocaml) echo "opam dune ocaml" ;; haskell) echo "ghc cabal" ;; + # Not a mise tool: the compiler is a release binary from hyperpolymath/affinescript. + affinescript) echo "affinescript" ;; # One package.json, every runtime (LANGUAGE-POLICY §1.4): bun runs it, and # `js-runtimes regen` needs deno and pnpm to write their locks too. bun) echo "bun deno pnpm" ;; @@ -158,13 +161,13 @@ lang_guix() { ocaml) echo "ocaml dune opam ocaml-findlib" ;; haskell) echo "ghc cabal-install" ;; docs) echo "ruby-asciidoctor" ;; - julia|bun) echo "" ;; + julia|bun|affinescript) echo "" ;; esac } # Tools a Guix shell cannot supply, so mise (inside that shell) does. lang_guix_gap() { case "$1" in - idris2) echo "idris2 (via pack)" ;; julia) echo julia ;; gleam) echo gleam ;; bun) echo "bun deno pnpm" ;; docs) echo lychee ;; + idris2) echo "idris2 (via pack)" ;; affinescript) echo "affinescript (release binary)" ;; julia) echo julia ;; gleam) echo gleam ;; bun) echo "bun deno pnpm" ;; docs) echo lychee ;; esac } # Print deduplicated base and detected-language Guix package specifications. @@ -221,6 +224,7 @@ lang_remedy() { gleam) echo "mise use gleam@latest erlang@latest" ;; ocaml) echo "mise use opam@latest && opam init -y && opam switch create . --deps-only -y" ;; haskell) echo "ghcup: https://www.haskell.org/ghcup/ (or: just dev-shell, which uses Guix)" ;; + affinescript) echo "install the compiler from https://github.com/hyperpolymath/affinescript (release binary named affinescript, on PATH)" ;; bun) echo "mise use bun@latest deno@latest pnpm@latest" ;; esac } @@ -299,6 +303,11 @@ lang_cmd() { # $1 lang, $2 verb -> prints a shell command, or nothing (= N/A) haskell:bench) grep -qs '^benchmark' ./*.cabal && echo "cabal bench all" ;; haskell:run) echo "cabal run" ;; + # AffineScript: no dependency-fetch, test or fmt verb exists here, and build needs an + # entry file and output only the repo knows, so those stay empty (lang_run says N/A). + # A repo sets build in its deed: affinescript compile FILE -o OUT.bun.js --bun-esm + affinescript:lint) git ls-files '*.affine' 2>/dev/null | grep -q . && echo "for f in \$(git ls-files '*.affine'); do affinescript check \"\$f\" || exit 1; done" ;; + bun:deps) [ -f bun.lock ] || [ -f bun.lockb ] && echo "bun install --frozen-lockfile" || echo "bun install" ;; bun:build) grep -qs '"build"[[:space:]]*:' package.json && echo "bun run build" ;; # `bun test` exits 0 when it finds no test files, so it runs only when some exist. @@ -463,7 +472,7 @@ guix_stub_reason() { # beside lang_tools and lang_remedy, so no second per-language table exists. lang_title() { case "$1" in rust) echo Rust ;; idris2) echo Idris2 ;; julia) echo Julia ;; zig) echo Zig ;; elixir) echo Elixir ;; - gleam) echo Gleam ;; ocaml) echo OCaml ;; haskell) echo Haskell ;; bun) echo Bun ;; docs) echo Docs ;; esac; } + gleam) echo Gleam ;; ocaml) echo OCaml ;; haskell) echo Haskell ;; affinescript) echo AffineScript ;; bun) echo Bun ;; docs) echo Docs ;; esac; } # What a language's route needs from the OS: "fedora|debian|macos command|why", or nothing. lang_sysdeps() { case "$1" in rust) echo "gcc pkgconf-pkg-config|build-essential pkg-config|xcode-select --install|Rust links through the system C toolchain, and pkg-config finds C libraries" ;; diff --git a/build/just/repo-init.just b/build/just/repo-init.just index b22beb8a..2c41ad99 100644 --- a/build/just/repo-init.just +++ b/build/just/repo-init.just @@ -860,6 +860,15 @@ repo-init archetype="": done < <(bash scripts/prune-archetype-modules.sh "archetypes/${ARCHETYPE}" .) echo " pruned: archetypes/${ARCHETYPE}/prune.txt applied" fi + # The README ships the Idris2-ABI and Zig-FFI badges because the spine carries + # src/interface/. When the archetype's prune.txt removed that scaffolding the + # badges would claim what the child does not have, so drop their lines (the + # same whole-line rule as the OpenSSF badge below). A child that keeps the + # interface keeps the badges. + if [ ! -d src/interface ]; then + sed -i -e '/img\.shields\.io\/badge\/Idris-Inside-/d' \ + -e '/img\.shields\.io\/badge\/Zig-Zero--overhead-/d' README.adoc 2>/dev/null || true + fi # Seed docs/ from the documentation seed, BEFORE substitution so the seed's # own placeholder tokens are rendered along with everything else. diff --git a/build/just/validate.just b/build/just/validate.just index 9a78e1d5..bbbd6d29 100644 --- a/build/just/validate.just +++ b/build/just/validate.just @@ -54,30 +54,17 @@ validate-rsr: want() { [ "$(field "$1" "$2")" = "$3" ] || MISSING="$MISSING $DEED:$1:$2" } - # Identity is the chora (standards A1, rulings R4, U1 to U4, V1): one - # :repo-uuid on the deed header, minted once from the repo's birth - # path and carried as the opaque literal #uuid"", - # version 5 or 8. The legacy name literals #u5"…" and #u8"…" are still - # read and are reported, not failed: their cutover date is the owner's. - RAW_UUID="$(sed -n -E 's/^[[:space:]]*:repo-uuid[[:space:]]+(#(uuid|u5|u8)"[^"]*").*/\1/p' "$DEED" | head -1)" - case "$RAW_UUID" in - '#uuid"'*) - printf '%s' "$RAW_UUID" | grep -Eq '^#uuid"[0-9a-f]{8}-[0-9a-f]{4}-[58][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"$' \ - || MISSING="$MISSING $DEED:repo-uuid(#uuid literal is not a lowercase v5/v8 RFC 9562 id)" - # A version 5 id is v5-identity (standards A1 C10, T30): a warning - # here, an error with RSR_STRICT=1. The chora id is version 8 (V8). - case "$RAW_UUID" in - '#uuid"'????????-????-5*) - if [ "${RSR_STRICT:-0}" = 1 ]; then - MISSING="$MISSING $DEED:repo-uuid(v5-identity)" - else - echo "WARNING: v5-identity: $DEED :repo-uuid $RAW_UUID is a version 5 id; the chora id is #uuid\"\" (standards A1 V8). RSR_STRICT=1 makes this an error." - fi ;; - esac ;; - '#u5"'?*|'#u8"'?*) - echo "NOTE: $DEED :repo-uuid is the legacy literal $RAW_UUID; the chora id is #uuid\"\" (standards A1, V1)." ;; - *) MISSING="$MISSING $DEED:repo-uuid" ;; - esac + # Identity is the chora (standards A1, rulings R4, U1 to U4, V1, Q2): one + # :repo-uuid on the deed header, minted once from the repo's birth path + # and carried as #uuid"" (or the computed #u8 form). + # A v5 id (v5-identity) or a #u5 literal (u5-identity) in :repo-uuid or + # :beholding-chora is an error in every mode (A1 v0.4.5 T30). The rule + # lives in scripts/check-identity.sh, tested by + # tests/workflows/check_identity_test.sh and run in estate-rules.yml. + IDENT_OUT="$(bash scripts/check-identity.sh "$DEED" 2>&1)" || { + printf "%s\n" "$IDENT_OUT" + MISSING="$MISSING $DEED:identity-literals(see above)" + } bash scripts/deed-field.sh --has "$DEED" identity || MISSING="$MISSING $DEED:(identity)" [ -n "$(field identity primary-forge)" ] || MISSING="$MISSING $DEED:identity:primary-forge" # Clade placements are identity facts, never the id and never an edict diff --git a/docs/architecture/REPOSITORY-MAP.adoc b/docs/architecture/REPOSITORY-MAP.adoc index f8bab496..05ba343f 100644 --- a/docs/architecture/REPOSITORY-MAP.adoc +++ b/docs/architecture/REPOSITORY-MAP.adoc @@ -85,6 +85,10 @@ predecessors did. | yes | the repo deed: universal AI entry point; family-7 allocation manifest + ply tree folded in (standards#837 pilot). Filename carries the repo slug (deed dispatch _chora.deed), so repo-init renames it at mint +| `.uuid-v8-exempt` +| optional +| scripts/check-uuid-v8.sh reads this exact root path: the negative-control tests that hold #u5 on purpose (owner-approved 2026-11-14) + | `CHANGELOG.adoc` | yes | AsciiDoc is the estate-standard documentation format diff --git a/docs/practice/AI-CONVENTIONS.adoc b/docs/practice/AI-CONVENTIONS.adoc index d087446f..907ce7a8 100644 --- a/docs/practice/AI-CONVENTIONS.adoc +++ b/docs/practice/AI-CONVENTIONS.adoc @@ -78,15 +78,19 @@ State, metadata, anchor and policy facts are clauses of the repo deed === Container Standard +Applies only if this repo builds a container (it has a `build/container/` module or a Containerfile). A repo without one has nothing to follow here. + - Runtime: **Podman** (never Docker). - File: **Containerfile** (never Dockerfile). -- Base images: `cgr.dev/chainguard/wolfi-base:latest` or `cgr.dev/chainguard/static:latest`. +- Base images: `cgr.dev/chainguard/wolfi-base` or `cgr.dev/chainguard/static`, pinned by digest (`@sha256:`); a tag is not a pin. === ABI/FFI Standard +Applies only if this repo carries an ABI/FFI seam (a `src/interface/` directory). Archetype minting may prune it; a repo without it has nothing to follow here. + - ABI definitions: **Idris2** with dependent types (`src/interface/Abi/`). -- FFI implementation: **Zig** with C ABI compatibility (`ffi/zig/`). -- Generated C headers: `generated/abi/`. +- FFI implementation: **Zig** with C ABI compatibility (`src/interface/ffi/`). +- Generated C headers: `src/interface/generated/`. === Build System diff --git a/docs/status/PROOF-STATUS.adoc b/docs/status/PROOF-STATUS.adoc index f40e67bd..56a280c6 100644 --- a/docs/status/PROOF-STATUS.adoc +++ b/docs/status/PROOF-STATUS.adoc @@ -26,10 +26,13 @@ row here claims a proof. Do not replace the table with a percentage or an ** `PWG-2i`: one recheck leg also counts (Rocq or Lean); ** `PWG-2ii`: both legs count; ** `PWG-1`: every counted witness has a current receipt for the exact commit; -** `ungraded`: a theory theorem below `PWG-3`; -** `n/a`: not a theory theorem (a test, a refusal fixture, an assumption, or an - engineering proof in Idris2, SPARK, Creusot or Verus). §8.1 puts these off the - ladder. +** `ungraded`: a theory row below `PWG-3`, or any row with no receipt yet, an + `open` row included, whether it is a theory theorem or an engineering + obligation; +** `n/a`: not on the ladder once it has a result: a test, a refusal fixture, an + assumption, or a discharged engineering proof in Idris2, SPARK, Creusot or + Verus. §8.1 puts these off the ladder. An `open` engineering obligation is not `n/a`: an `open` engineering + obligation stays `ungraded` until it has a receipt. * *Recheck legs* (§2): `transported`, `re-proved`, `waived` or `unavailable`, each with its §2.2 correspondence state, for example `BRIDGE-PENDING` or `RECONCILED`. A leg counts towards a grade only when it is `RECONCILED`. diff --git a/scripts/check-identity.sh b/scripts/check-identity.sh new file mode 100755 index 00000000..6e34d154 --- /dev/null +++ b/scripts/check-identity.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# +# check-identity.sh DEED — the identity literals of a repo deed (standards A1 +# v0.4.5 7.1 and T30, owner ruling Q2 of 2026-11-14; A7 S2, rollout 1c, YP04). +# +# :repo-uuid required. #uuid"" of version 8, or +# the computed form #u8"domain:name". +# :beholding-chora optional. The same forms. +# +# A version 5 id inside #uuid is v5-identity, and a #u5"…" literal is +# u5-identity. Both are errors in every mode, lax included: there is no +# warning tier. Prints one line per finding on stderr and exits 1 if there is any, +# 2 on a usage error or an unreadable deed, 0 otherwise. +set -uo pipefail + +[[ $# -eq 1 && -n "$1" ]] || { echo "usage: check-identity.sh DEED" >&2; exit 2; } +DEED="$1" +[[ -f "$DEED" ]] || { echo "check-identity.sh: no such deed: $DEED" >&2; exit 2; } +READ="$(dirname "${BASH_SOURCE[0]}")/deed-field.sh" + +bad=0 +# check FIELD REQUIRED +check() { + local field="$1" required="$2" lit rc=0 + lit="$(bash "$READ" --typed "$DEED" '' "$field")" || rc=$? + [[ "$rc" -le 1 ]] || { echo "check-identity.sh: cannot read :$field from $DEED" >&2; exit 2; } + if [[ -z "$lit" ]]; then + [[ "$required" = 1 ]] && { echo "$DEED: :$field is missing" >&2; bad=1; } + return + fi + case "$lit" in + '#uuid"'*'"') + if ! printf '%s' "$lit" | grep -Eq '^#uuid"[0-9a-f]{8}-[0-9a-f]{4}-[58][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"$'; then + echo "$DEED: :$field $lit is not a lowercase version 5 or 8 RFC 9562 id" >&2; bad=1 + elif printf '%s' "$lit" | grep -Eq '^#uuid"[0-9a-f]{8}-[0-9a-f]{4}-5'; then + echo "$DEED: :$field $lit is v5-identity: a version 5 id is an error in every mode; the chora id is #uuid\"\" (A1 T30, Q2)" >&2; bad=1 + fi ;; + '#u8"'?*:?*'"') ;; + '#u5"'*) + echo "$DEED: :$field $lit is u5-identity: a #u5 literal is an error in every mode; write #uuid\"\" or #u8\"domain:name\" (A1 T30, Q2)" >&2; bad=1 ;; + *) + echo "$DEED: :$field $lit is not a #uuid or #u8 literal" >&2; bad=1 ;; + esac +} + +check repo-uuid 1 +check beholding-chora 0 +exit "$bad" diff --git a/scripts/check-mise-language.sh b/scripts/check-mise-language.sh index 90e3a8f5..22a8a223 100644 --- a/scripts/check-mise-language.sh +++ b/scripts/check-mise-language.sh @@ -108,6 +108,7 @@ if [ -z "$LANGS" ] && [ "$DETECT" -eq 1 ]; then [ -n "$(_find gleam.toml)" ] && _l+=(gleam) [ -n "$(_find dune-project)" ] && _l+=(ocaml) { [ -n "$(_find '*.cabal')" ] || [ -n "$(_find stack.yaml 1)" ]; } && _l+=(haskell) + [ -n "$(_find '*.affine' 3)" ] && _l+=(affinescript) [ -n "$(_find package.json)" ] && _l+=(bun) [ "${#_l[@]}" -eq 0 ] && _l+=(docs) LANGS="${_l[*]}" diff --git a/scripts/check-no-a2ml.sh b/scripts/check-no-a2ml.sh index 0d09a774..5db10b6c 100755 --- a/scripts/check-no-a2ml.sh +++ b/scripts/check-no-a2ml.sh @@ -8,8 +8,11 @@ # # A repository that still carries legacy A2ML lists each file, by exact path, # in the shrink-only ledger .machine_readable/a2ml-legacy-allow.txt (owner -# decision 2026-11-04); listed files and anything under 9-archive/ are not -# reported here. The ledger's own integrity (a listed file that is gone, a +# decision 2026-11-04); listed files are not reported here. 9-archive/ has +# no exemption: archived copies are departures too (owner, 2026-11-13), and a +# file moved into 9-archive/, or renamed anywhere, stands at a path the +# ledger does not list, so it fails (owner ruling 2026-11-14: A2ML moves +# fail; only in-place edits and deletions pass). The ledger's own integrity (a listed file that is gone, a # glob entry, an entry the base ledger did not list) is the canonical gate's # job, standards scripts/check-a2ml-archived.sh, run by the deed lane # (.github/hooks/validate-deed.sh). @@ -35,16 +38,13 @@ else fi LEDGER="$REPO_ROOT/.machine_readable/a2ml-legacy-allow.txt" -if [ -n "$FOUND" ]; then - FOUND=$(printf '%s\n' "$FOUND" | grep -v '^9-archive/' || true) -fi if [ -n "$FOUND" ] && [ -f "$LEDGER" ]; then LISTED=$(sed -e 's/#.*//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' "$LEDGER" | grep -v '^$' || true) FOUND=$(printf '%s\n' "$FOUND" | grep -vxF -f <(printf '%s\n' "$LISTED") || true) fi if [ -z "$FOUND" ]; then - echo "PASS: no .a2ml files outside the legacy ledger and 9-archive/" + echo "PASS: no .a2ml files outside the legacy ledger" exit 0 fi echo "FAIL: .a2ml is a retired format; move these facts into the repo deed or a .k9 contract (or, for a file that predates the ledger, list it in .machine_readable/a2ml-legacy-allow.txt):" diff --git a/scripts/deed-field.sh b/scripts/deed-field.sh index 5356e569..914b5603 100755 --- a/scripts/deed-field.sh +++ b/scripts/deed-field.sh @@ -17,7 +17,8 @@ # deed-field.sh --has DEED PATH exit 0 iff the clause exists # deed-field.sh --find [DIR] print the one *_chora.deed in DIR (default .) # deed-field.sh --uuid DEED the repo uuid: the body of :repo-uuid #uuid"…" as -# written (legacy #u5 / #u8 forms are derived) +# written (#u8 is derived; a #u5 is derived only to +# read an old deed, and check-identity.sh refuses it) # deed-field.sh --typed DEED PATH KEY like the first form, but a tagged literal keeps its # tag and quotes: #u5"github.com/o/r" (a plain value # prints as it does without --typed) @@ -202,11 +203,13 @@ if [ "$mode" = uuid ]; then id="${lit#\#uuid\"}"; id="${id%\"}" ;; '#u5"'*'"') name="${lit#\#u5\"}"; name="${name%\"}" - echo "deed-field.sh: :repo-uuid is the legacy #u5 literal; the chora id is #uuid\"\" (standards A1 V8)" >&2 + # Read only so an old deed can still be looked up: a #u5 in an identity + # field is u5-identity, an error in every mode (A1 v0.4.5 T30, Q2), and + # scripts/check-identity.sh refuses it. + echo "deed-field.sh: :repo-uuid is a #u5 literal, an error under A1 T30 (Q2); derived here only to read an old deed. Write #uuid\"\"." >&2 id="$(uuid5_url "$name")" || exit 2 ;; '#u8"'*:*'"') body="${lit#\#u8\"}"; body="${body%\"}" - echo "deed-field.sh: :repo-uuid is the legacy #u8 literal; the chora id is #uuid\"\" (standards A1 V8)" >&2 id="$(bash "$(dirname "${BASH_SOURCE[0]}")/uuid-v8.sh" "${body%%:*}" "${body#*:}")" || exit 2 ;; *) echo "deed-field.sh: :repo-uuid is not a #uuid, #u5 or #u8 literal: '$lit'" >&2; exit 2 ;; esac diff --git a/scripts/deed-template-sync.sh b/scripts/deed-template-sync.sh new file mode 100755 index 00000000..a2fa9726 --- /dev/null +++ b/scripts/deed-template-sync.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: MPL-2.0 +# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) +# +# deed-template-sync.sh, carry the template's edits to template-owned clauses +# into a minted repo's deed at a template upgrade. +# +# A template upgrade keeps the child's deed, because the deed is the child's +# identity. But some clauses are the template's text, copied in at mint: the +# (ply) directory tree. When the template fixes such a clause (#356 wrapped a +# (ply) line over the 998-octet deed line limit), the fix must reach the +# child too, or the child's DEED syntax check stays red after the upgrade. +# +# Usage: +# deed-template-sync.sh DEED BASE NEW +# +# DEED is the child's deed. BASE and NEW are the template's own deed at the +# commit the child was cut from (or last upgraded to) and at the upgrade +# target, e.g. `git -C