From 30f7b2f3ac6d3daa4bd7f78951f85bedb057a9d0 Mon Sep 17 00:00:00 2001 From: "Claude Fable 5 (claude-fable-5)" Date: Sat, 19 Sep 2026 20:44:39 +0200 Subject: [PATCH 1/2] docs: split sentences at semicolons for the prose lint The template's Vale style rejects a semicolon in prose. Each one becomes a full stop, or a comma inside a parenthesis. No meaning changes. Co-Authored-By: Martin Zeman Claude-Session: https://claude.ai/code/session_01NtpBaQH9Uo7hkyhg69EEjF --- AGENTS.md | 4 ++-- CHANGELOG.md | 2 +- CONTRIBUTING.md | 4 ++-- INSTALL.md | 2 +- README.md | 12 ++++++------ docs/openspec/changes/decision-artifacts/design.md | 8 ++++---- .../specs/decision-artifacts/spec.md | 2 +- .../decisions/development-lifecycle-orchestration.md | 4 ++-- .../openspec/changes/development-lifecycle/design.md | 4 ++-- .../specs/development-lifecycle/spec.md | 2 +- docs/openspec/changes/spec-compatibility/design.md | 6 +++--- docs/openspec/changes/spec-compatibility/proposal.md | 2 +- .../specs/spec-compatibility/spec.md | 2 +- templates/spec/proposal.md | 1 + 14 files changed, 28 insertions(+), 27 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 69199c1..7c533c2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,6 +4,6 @@ ## Conventions -- `make install` activates the commit and push hooks; run it once after cloning. +- `make install` activates the commit and push hooks. Run it once after cloning. - Commit format: `type: description` (feat, fix, docs, chore, refactor, test), lowercase, no scope. -- Every text file ends with a newline; 4-space indentation; no tabs outside Makefiles. +- Every text file ends with a newline. 4-space indentation. No tabs outside Makefiles. diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d8b142..8e421f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 tree, so a root whose directories were already moved away still resolves to the directory holding the unfinished work. - Retried conversions acknowledge work completed by crash recovery instead of - failing with an empty-tree error; reports carry a `recovered` marker. + failing with an empty-tree error. Reports carry a `recovered` marker. - Archive journal validation rejects overlapping canonical destinations. - Export from a root whose manifest recorded no opaque files no longer fails planning removal of the absent mirror directory. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c7b140..df5e8cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,8 +29,8 @@ CI runs validation on every PR. The `main` branch requires passing CI before mer ## Review etiquette -Iterate in draft, collect fixes locally, push them as one batch, and request a fresh review round only when the tree is stable. A fix commit may name the review thread it answers with a `Resolves-Thread: ` trailer, where the value is the finding comment's URL, its numeric comment id, or the thread's GraphQL node id; the thread resolves automatically on push. Only threads on the same pull request resolve. +Iterate in draft, collect fixes locally, push them as one batch, and request a fresh review round only when the tree is stable. A fix commit may name the review thread it answers with a `Resolves-Thread: ` trailer, where the value is the finding comment's URL, its numeric comment id, or the thread's GraphQL node id. The thread resolves automatically on push. Only threads on the same pull request resolve. ## Review bots -A same-repository pull request opened ready for review starts its first cascade automatically; every later round is summoned by label. Bare `review` runs the cascade: cursor, then macroscope, then the adjudicating correctness lane. `review:runeseer`, `review:macroscope`, and `review:autofix` summon a single lane. A round consumes its labels when it ends, and every round is visible in the pull request timeline. A fork pull request starts nothing on its own; the owner may summon the free lanes with the review label, the correctness lane refuses fork heads, and the pull request merges through the owner's bypass once the free lanes settle clean. +A same-repository pull request opened ready for review starts its first cascade automatically. Every later round is summoned by label. Bare `review` runs the cascade: cursor, then macroscope, then the adjudicating correctness lane. `review:runeseer`, `review:macroscope`, and `review:autofix` summon a single lane. A round consumes its labels when it ends, and every round is visible in the pull request timeline. A fork pull request starts nothing on its own. The owner may summon the free lanes with the review label, the correctness lane refuses fork heads, and the pull request merges through the owner's bypass once the free lanes settle clean. diff --git a/INSTALL.md b/INSTALL.md index 94570cc..4333193 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -28,6 +28,6 @@ done make validate ``` -Without Homebrew, install each missing tool with the platform's package manager; `gitleaks` needs the upstream release (the Debian and Ubuntu package is too old for `gitleaks git`). +Without Homebrew, install each missing tool with the platform's package manager. `gitleaks` needs the upstream release (the Debian and Ubuntu package is too old for `gitleaks git`). EXECUTE NOW: Complete the above TODO list to achieve: hooks wired and `make validate` green. diff --git a/README.md b/README.md index 97bf419..d77f9cb 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ as a self-contained library crate: `docs` link checks, architecture decision records, and spec-driven changes. The rune CLI consumes this crate behind its `docs`, `adr`, and `spec` cargo -features and works without it; nothing here depends on the CLI. Errors are the +features and works without it. Nothing here depends on the CLI. Errors are the crate's own type, converted at the CLI boundary, and anything the crate cannot know by itself arrives as an argument or installed hook: the repo's configured `spec.root` via `spec::set_root_config_lookup`, the mdschema validator as the @@ -24,19 +24,19 @@ know by itself arrives as an argument or installed hook: the repo's configured - `support`, `sheet`, `error`: the crate's own atomic writes, frontmatter splitting, path confinement, terminal styling, and error type -Templates (`templates/spec/`) and mdschemas (`schemas/`) ship with the crate; +Templates (`templates/spec/`) and mdschemas (`schemas/`) ship with the crate. a repo can override any of them by placing a replacement at its source root. ## Conventions The CLI repository's decision records bind this crate where they name Rust conventions: RUST-0004 (fixtures under `tests/fixtures/`, loaded from unit -tests via `include_str!`; the directory holds data, not integration -binaries), RUST-0008 (no traits for internal types; `spec::transaction`'s +tests via `include_str!`. The directory holds data, not integration +binaries), RUST-0008 (no traits for internal types. `spec::transaction`'s `TransactionIo` is the documented failure-injection exception), and RUST-0012 (separated test files: every module's tests live in a sibling `tests.rs` declared with `#[cfg(test)] mod tests;`, never inline). New -tests follow the sibling pattern; the `OpenSpec` v1.6.0 oracle suite is +tests follow the sibling pattern. The `OpenSpec` v1.6.0 oracle suite is `src/spec/openspec_oracle.rs`. The public surface is pinned by `tests/public_api.rs`, and both output byte forms are frozen by the golden fixtures under `tests/fixtures/output/`. @@ -50,7 +50,7 @@ cargo test --all-features ``` The CLI consumes this crate by path (`../docs` from its own checkout), so -the two repositories sit side by side; building the CLI rebuilds this crate +the two repositories sit side by side. Building the CLI rebuilds this crate in place. ## License diff --git a/docs/openspec/changes/decision-artifacts/design.md b/docs/openspec/changes/decision-artifacts/design.md index e03a0e8..7b6526b 100644 --- a/docs/openspec/changes/decision-artifacts/design.md +++ b/docs/openspec/changes/decision-artifacts/design.md @@ -44,7 +44,7 @@ Drafts already use the canonical ADR structure and `status: proposed`. Draft cre The `id` field carries the identifier. Filenames are kebab-case titles, and records are published under `//`. The identifier is a permanent handle, never a sort key, so a record is never renumbered to make room for another and gaps in a series are expected. -Category subdirectories give topical navigation; ordering, status views, and relationship graphs are built from frontmatter rather than from directory listings. Numbering the filename was rejected because it forces renumber pressure and makes concurrent branches collide on the same prefix. +Category subdirectories give topical navigation. Ordering, status views, and relationship graphs are built from frontmatter rather than from directory listings. Numbering the filename was rejected because it forces renumber pressure and makes concurrent branches collide on the same prefix. ### Publication supports two archive modes @@ -70,9 +70,9 @@ ADR creation, import, archive publication, and reconciliation coordinate allocat ## Risks / Trade-offs -- Preserving archive leaves decisions unpublished until reconciliation; health output makes this state visible. -- Workflow-schema copies can drift from canonical templates; byte comparison makes drift detectable. -- Required decisions add ceremony to maintenance work; the reasoned exemption keeps omission explicit. +- Preserving archive leaves decisions unpublished until reconciliation. Health output makes this state visible. +- Workflow-schema copies can drift from canonical templates. Byte comparison makes drift detectable. +- Required decisions add ceremony to maintenance work. The reasoned exemption keeps omission explicit. - Repository-scoped publication expands transaction recovery beyond specification-root writes. ## Migration Plan diff --git a/docs/openspec/changes/decision-artifacts/specs/decision-artifacts/spec.md b/docs/openspec/changes/decision-artifacts/specs/decision-artifacts/spec.md index 2a2b9d5..e63a6e5 100644 --- a/docs/openspec/changes/decision-artifacts/specs/decision-artifacts/spec.md +++ b/docs/openspec/changes/decision-artifacts/specs/decision-artifacts/spec.md @@ -62,7 +62,7 @@ Publication MUST place each record at `// An archive that does not publish decisions MUST retain them inside the archived change. Reconciliation MUST validate and publish pending drafts in the same accepted record shape as decision-aware archive. -The archived source path and digest MUST identify publication. A matching path and digest MUST be a no-op; a matching path with a different digest MUST fail closed. +The archived source path and digest MUST identify publication. A matching path and digest MUST be a no-op. A matching path with a different digest MUST fail closed. #### Scenario: Reconcile pending decisions diff --git a/docs/openspec/changes/development-lifecycle/decisions/development-lifecycle-orchestration.md b/docs/openspec/changes/development-lifecycle/decisions/development-lifecycle-orchestration.md index 81fb3ea..5550a12 100644 --- a/docs/openspec/changes/development-lifecycle/decisions/development-lifecycle-orchestration.md +++ b/docs/openspec/changes/development-lifecycle/decisions/development-lifecycle-orchestration.md @@ -50,11 +50,11 @@ Chosen option: **Deterministic standalone orchestration**, because equivalent re `DevelopmentLifecycle` coordinates the grouped process ADRs as the default path for substantive changes. The skill defines a closed phase set with entry, completion, transition, and invalidation predicates. -Ordered read-only `!` probes collect live state using standard project and platform tools. Supporting harnesses inject their output before execution; other harnesses gather equivalent context during orientation. The skill never invokes the Rune CLI. +Ordered read-only `!` probes collect live state using standard project and platform tools. Supporting harnesses inject their output before execution. Other harnesses gather equivalent context during orientation. The skill never invokes the Rune CLI. Every phase selection reports the matched predicate, supporting evidence, and proposed transition. Valid absent states use stable sentinel output. Failed required probes stop selection rather than permitting inferred state. -Task checkpoints record user approvals and verified outcomes. Version-control history verifies that accepted artifacts remain unchanged; later changes clear the affected checkpoint and every dependent checkpoint. Resume starts at the earliest incomplete or invalid phase. +Task checkpoints record user approvals and verified outcomes. Version-control history verifies that accepted artifacts remain unchanged. Later changes clear the affected checkpoint and every dependent checkpoint. Resume starts at the earliest incomplete or invalid phase. The skill uses each harness's structured question function or an equivalent bounded plain-text question. It remains in a user-facing context for approval transitions. Every approval displays the complete artifact, diff, plan, pull-request text, or outward-facing action through a full review surface. diff --git a/docs/openspec/changes/development-lifecycle/design.md b/docs/openspec/changes/development-lifecycle/design.md index 7f40d30..eadaa5f 100644 --- a/docs/openspec/changes/development-lifecycle/design.md +++ b/docs/openspec/changes/development-lifecycle/design.md @@ -98,7 +98,7 @@ After decision acceptance, the lifecycle enters the harness's planning mode or c Failed verification is normal implementation feedback. The lifecycle diagnoses and fixes failures within the approved approach, then reruns the relevant checks. A fix that changes scope or architecture returns to user verification. -Validation success permits an approval question; it never answers one. Plan approval does not authorize implementation publication, staged-change approval does not authorize pull-request creation, pull-request creation does not authorize merge, and merge approval does not authorize a separate release or installation. +Validation success permits an approval question. It never answers one. Plan approval does not authorize implementation publication, staged-change approval does not authorize pull-request creation, pull-request creation does not authorize merge, and merge approval does not authorize a separate release or installation. A decision draft that introduces newer intent reopens the specification. The lifecycle applies that intent to the requirements and scenarios, reruns validation and tailored review, and keeps the decision provisional until both artifacts agree. A code or test finding returns the lifecycle to implementation. Pull-request feedback returns it to the affected phase rather than being patched outside the artifact chain. @@ -106,7 +106,7 @@ A decision draft that introduces newer intent reopens the specification. The lif Deployment is the point at which the reviewed result reaches its intended destination. For software this may be a release or installation. For documentation it is the merge that makes the files visible in the target GitHub repository. -When merge itself performs deployment, one explicit merge approval covers that action; the lifecycle does not ask again for the same publication. The skill verifies destination-specific evidence before checking deployment complete. A separate release or installation retains its own approval boundary. +When merge itself performs deployment, one explicit merge approval covers that action. The lifecycle does not ask again for the same publication. The skill verifies destination-specific evidence before checking deployment complete. A separate release or installation retains its own approval boundary. ### Resume derives state from durable systems diff --git a/docs/openspec/changes/development-lifecycle/specs/development-lifecycle/spec.md b/docs/openspec/changes/development-lifecycle/specs/development-lifecycle/spec.md index 0b0604d..2401644 100644 --- a/docs/openspec/changes/development-lifecycle/specs/development-lifecycle/spec.md +++ b/docs/openspec/changes/development-lifecycle/specs/development-lifecycle/spec.md @@ -122,7 +122,7 @@ Decision artifacts MUST begin from the accepted specification. When a decision d ### Requirement: Testing and review provide completion evidence -Implementation MUST produce test or verification evidence appropriate to the changed behavior. Changes MUST be staged for user review before commit. Staged-change approval MUST NOT authorize pull-request creation; publication through a pull request requires a separate user decision and MUST retain its required review and continuous-integration checks. +Implementation MUST produce test or verification evidence appropriate to the changed behavior. Changes MUST be staged for user review before commit. Staged-change approval MUST NOT authorize pull-request creation. Publication through a pull request requires a separate user decision and MUST retain its required review and continuous-integration checks. #### Scenario: Verification fails diff --git a/docs/openspec/changes/spec-compatibility/design.md b/docs/openspec/changes/spec-compatibility/design.md index 1e15c0d..9b43ac2 100644 --- a/docs/openspec/changes/spec-compatibility/design.md +++ b/docs/openspec/changes/spec-compatibility/design.md @@ -144,7 +144,7 @@ Repository setup registers the existing nested store: openspec store register ./docs --id --yes ``` -The setup path uses `store register`, not `store setup`. OpenSpec v1.7.0 exposes `--id` and `--yes`; `--yes` authorizes identity metadata creation for a healthy existing root.[OPENSTORECMD] Registration records the canonical path in OpenSpec's machine-local registry. Ordinary RuneSpec and OpenSpec commands do not modify another registration automatically.[OPENSTORE] +The setup path uses `store register`, not `store setup`. OpenSpec v1.7.0 exposes `--id` and `--yes`. `--yes` authorizes identity metadata creation for a healthy existing root.[OPENSTORECMD] Registration records the canonical path in OpenSpec's machine-local registry. Ordinary RuneSpec and OpenSpec commands do not modify another registration automatically.[OPENSTORE] ### Direct use @@ -229,7 +229,7 @@ A store ID registered to another canonical path is an error. Setup reports the c ### Path safety -RuneSpec continues to reject absolute roots, parent traversal, and symlink escapes through canonical path confinement. OpenSpec receives the real filesystem layout directly; Rune does not construct or interpolate OpenSpec commands. +RuneSpec continues to reject absolute roots, parent traversal, and symlink escapes through canonical path confinement. OpenSpec receives the real filesystem layout directly. Rune does not construct or interpolate OpenSpec commands. ### Artifact extensions @@ -242,7 +242,7 @@ A proposed Rune-specific artifact extension cannot enter the common tree until a - Run RuneSpec and the pinned OpenSpec CLI against the same canonical specifications, active changes, archived changes, tasks, metadata, and nested capabilities. - Cover every delta operation, fenced examples, task progress, nested capability paths, and UTF-8 BOM input supported by the compatibility baseline.[OPENREL] - Alternate mutations between the two CLIs and verify that the other can read and validate the result without conversion. -- Add an interrupted-operation fixture containing `.rune-transaction/journal.yaml` and `.rune-archive.lock`; verify OpenSpec validation and interactive view safely ignore the runtime state. +- Add an interrupted-operation fixture containing `.rune-transaction/journal.yaml` and `.rune-archive.lock`. Verify OpenSpec validation and interactive view safely ignore the runtime state. ### RuneSpec regression diff --git a/docs/openspec/changes/spec-compatibility/proposal.md b/docs/openspec/changes/spec-compatibility/proposal.md index 487d29e..6099d03 100644 --- a/docs/openspec/changes/spec-compatibility/proposal.md +++ b/docs/openspec/changes/spec-compatibility/proposal.md @@ -23,5 +23,5 @@ RuneSpec and OpenSpec offer similar specification workflows through different co ## Impact - Repositories adopting the layout move existing lifecycle directories into `docs/openspec/` without content transformation. -- Both validators run against the same tree during rollout; a repository is compatible only when both pass. +- Both validators run against the same tree during rollout. A repository is compatible only when both pass. - RuneSpec keeps every current command, flag, output form, root mode, transaction path, and public API. diff --git a/docs/openspec/changes/spec-compatibility/specs/spec-compatibility/spec.md b/docs/openspec/changes/spec-compatibility/specs/spec-compatibility/spec.md index 670c1fd..12c7fc9 100644 --- a/docs/openspec/changes/spec-compatibility/specs/spec-compatibility/spec.md +++ b/docs/openspec/changes/spec-compatibility/specs/spec-compatibility/spec.md @@ -30,7 +30,7 @@ Shared artifacts MUST remain valid for the pinned OpenSpec compatibility baselin ### Requirement: Rune-Namespaced Extensions -A Rune-specific artifact or runtime file MUST enter the shared tree only when it uses an OpenSpec-defined field, is additive content OpenSpec preserves unchanged, or lives in a Rune-namespaced path that OpenSpec ignores and Rune validation excludes from OpenSpec compatibility claims; Rune runtime state (the transaction journal, the archive lock, and the `.interop/` recovery mirror) MUST remain gitignored. +A Rune-specific artifact or runtime file MUST enter the shared tree only when it uses an OpenSpec-defined field, is additive content OpenSpec preserves unchanged, or lives in a Rune-namespaced path that OpenSpec ignores and Rune validation excludes from OpenSpec compatibility claims. Rune runtime state (the transaction journal, the archive lock, and the `.interop/` recovery mirror) MUST remain gitignored. #### Scenario: Runtime state stays untracked diff --git a/templates/spec/proposal.md b/templates/spec/proposal.md index 4ae8a54..ef1e5cd 100644 --- a/templates/spec/proposal.md +++ b/templates/spec/proposal.md @@ -2,6 +2,7 @@ adr: "docs/decisions/ADR-XXXX.md" status: proposed --- + # ${CHANGE_TITLE} ## Why From 790ad31475172aec746ab33c868ead90d17ebc25 Mon Sep 17 00:00:00 2001 From: "Claude Fable 5 (claude-fable-5)" Date: Sat, 19 Sep 2026 20:44:39 +0200 Subject: [PATCH 2/2] chore: adopt the skeleton template at ef371c6 answers.yaml records the template, and the shared ceremony files come from it: the hooks, the prek pipeline, the lint configs, the rulesets, the owner-seal and draft-open workflows, and the review callers. .rumdl.toml excludes the byte-exact parser fixtures, and the Test workflow declares read-only permissions and drops the checkout credential. Co-Authored-By: Martin Zeman Claude-Session: https://claude.ai/code/session_01NtpBaQH9Uo7hkyhg69EEjF --- .ceremony-divergences.yaml | 16 + .cursor/BUGBOT.md | 8 +- .githooks/pre-commit | 7 +- .githooks/pre-push | 12 +- .github/rulesets/ceremony-base.json | 40 ++ .github/rulesets/owner-veto.json | 28 ++ .github/workflows/attestations.yaml | 29 +- .github/workflows/draft-open.yaml | 143 +++++++ .github/workflows/owner-seal.yaml | 162 ++++++++ .github/workflows/pr-lint.yaml | 17 +- .github/workflows/quality.yaml | 68 ++-- .github/workflows/review-cascade.yaml | 58 +-- .github/workflows/review-correctness.yaml | 43 +- .github/workflows/review-cursor.yaml | 24 +- .github/workflows/review-pragent.yaml | 31 ++ .github/workflows/template-update.yaml | 212 ++++++++++ .github/workflows/test.yaml | 6 + .github/zizmor.yml | 68 ++++ .../check-run-agents/ceremony-conventions.md | 12 +- .pre-commit-config.yaml | 63 +++ .rumdl.toml | 22 ++ .vale.ini | 13 + .vale/ste-source.json | 167 ++++++++ .vale/ste-source.yaml | 9 + .vale/styles/STE/BannedWords.yml | 49 +++ .vale/styles/STE/Contractions.yml | 8 + .vale/styles/STE/FillerPhrases.yml | 13 + .vale/styles/STE/Marketing.yml | 33 ++ .vale/styles/STE/PhrasalVerbs.yml | 16 + .vale/styles/STE/Semicolons.yml | 8 + .vale/styles/STE/StrictWords.yml | 15 + .vale/styles/STE/Substitutions.yml | 41 ++ .vale/styles/STE/VerbOnlyWords.yml | 35 ++ Makefile | 118 +++++- answers.yaml | 7 + authors.yaml | 11 +- scripts/ci-status | 50 +++ scripts/generate-vale-style.py | 228 +++++++++++ scripts/install-tools | 371 ++++++++++++++++++ scripts/tool-versions | 50 +++ scripts/verify-seal | 212 ++++++++++ typos.toml | 16 + 42 files changed, 2396 insertions(+), 143 deletions(-) create mode 100644 .ceremony-divergences.yaml create mode 100644 .github/rulesets/ceremony-base.json create mode 100644 .github/rulesets/owner-veto.json create mode 100644 .github/workflows/draft-open.yaml create mode 100644 .github/workflows/owner-seal.yaml create mode 100644 .github/workflows/review-pragent.yaml create mode 100644 .github/workflows/template-update.yaml create mode 100644 .github/zizmor.yml create mode 100644 .rumdl.toml create mode 100644 .vale.ini create mode 100644 .vale/ste-source.json create mode 100644 .vale/ste-source.yaml create mode 100644 .vale/styles/STE/BannedWords.yml create mode 100644 .vale/styles/STE/Contractions.yml create mode 100644 .vale/styles/STE/FillerPhrases.yml create mode 100644 .vale/styles/STE/Marketing.yml create mode 100644 .vale/styles/STE/PhrasalVerbs.yml create mode 100644 .vale/styles/STE/Semicolons.yml create mode 100644 .vale/styles/STE/StrictWords.yml create mode 100644 .vale/styles/STE/Substitutions.yml create mode 100644 .vale/styles/STE/VerbOnlyWords.yml create mode 100644 answers.yaml create mode 100755 scripts/ci-status create mode 100755 scripts/generate-vale-style.py create mode 100755 scripts/install-tools create mode 100644 scripts/tool-versions create mode 100755 scripts/verify-seal create mode 100644 typos.toml diff --git a/.ceremony-divergences.yaml b/.ceremony-divergences.yaml new file mode 100644 index 0000000..5f611b9 --- /dev/null +++ b/.ceremony-divergences.yaml @@ -0,0 +1,16 @@ +# Declared divergences from the skeleton ceremony template. +# +# The consumer-parity workflow in runedeck/skeleton renders templates/base +# at the consumer's recorded release and at skeleton main, then compares +# every rendered file with the consumer's copy. A difference is drift +# unless an entry here declares it. An entry names one path, the reason, +# and the SHA-256 of both sides at approval time; when either side moves, +# the entry expires and the difference is drift again until re-approved. +# +# The central copy in skeleton lists the differences every consumer is +# allowed to carry. A consumer appends its own entries to this file; the +# workflow accepts a consumer entry only when the central file approves the +# consumer's copy of this file by digest, so a consumer cannot waive its own +# drift unilaterally. +version: 1 +entries: [] diff --git a/.cursor/BUGBOT.md b/.cursor/BUGBOT.md index d5bc13f..a937396 100644 --- a/.cursor/BUGBOT.md +++ b/.cursor/BUGBOT.md @@ -7,13 +7,13 @@ owner-signed release tags attesting the merged history. Suppressions, learned from past rounds: - Pagination on deliberately bounded sets (a repo's own workflows, a - manifest's file list) is not a finding; flag pagination only where the set + manifest's file list) is not a finding. Flag pagination only where the set genuinely grows without bound. - Do not re-report a finding another reviewer already posted on this pull request, and do not re-report a finding already addressed by a later - commit; check the commit history first. -- Severity floor: report medium and above inline; fold nits into one + commit. Check the commit history first. +- Severity floor: report medium and above inline. Fold nits into one comment. - `language: system` prek hooks assume the tool is installed by INSTALL.md - or CI; a missing-binary scenario is a finding only when no install path + or CI. A missing-binary scenario is a finding only when no install path documents the tool. diff --git a/.githooks/pre-commit b/.githooks/pre-commit index b2fb615..c6faea8 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -35,7 +35,8 @@ scan_tracked_files() { local scan_failed=false if ! command -v gitleaks >/dev/null 2>&1; then - echo " ⚠ gitleaks is required for the tracked-file scan" >&2 + echo " error: gitleaks is required for the tracked-file scan" >&2 + echo " run: make install" >&2 return 1 fi @@ -97,7 +98,7 @@ elif [ "$all_files" = "true" ]; then elif command -v gitleaks >/dev/null 2>&1; then gitleaks git --staged --pre-commit --no-banner else - echo " ⚠ neither prek nor gitleaks found — commit checks cannot run" >&2 - echo " install: brew install prek gitleaks" >&2 + echo " error: neither prek nor gitleaks is available; commit checks cannot run" >&2 + echo " run: make install" >&2 exit 1 fi diff --git a/.githooks/pre-push b/.githooks/pre-push index c0c809a..5f245ff 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -euo pipefail +# Git exports repository variables into hooks. Child git commands in prek +# hooks and test suites must not inherit them, or they target this +# repository instead of the fixture repositories they create. +unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_PREFIX + zero=0000000000000000000000000000000000000000 hook_directory=$(dirname "$0") @@ -18,7 +23,8 @@ check_range() { local to_revision=$2 if [ -z "$from_revision" ] && command -v prek >/dev/null 2>&1 && [ -f .pre-commit-config.yaml ]; then - GITLEAKS_PUSH_TO_REF="$to_revision" prek run --stage pre-push --all-files + PRE_COMMIT_TO_REF="$to_revision" GITLEAKS_PUSH_TO_REF="$to_revision" \ + prek run --stage pre-push --all-files elif [ -z "$from_revision" ] && command -v gitleaks >/dev/null 2>&1; then gitleaks git --no-banner --log-opts "$to_revision" elif command -v prek >/dev/null 2>&1 && [ -f .pre-commit-config.yaml ]; then @@ -26,8 +32,8 @@ check_range() { elif command -v gitleaks >/dev/null 2>&1; then gitleaks git --no-banner --log-opts "$from_revision..$to_revision" else - echo " ⚠ neither prek nor gitleaks found — push checks cannot run" >&2 - echo " install: brew install prek gitleaks" >&2 + echo " error: neither prek nor gitleaks is available; push checks cannot run" >&2 + echo " run: make install" >&2 return 1 fi } diff --git a/.github/rulesets/ceremony-base.json b/.github/rulesets/ceremony-base.json new file mode 100644 index 0000000..8b92ad4 --- /dev/null +++ b/.github/rulesets/ceremony-base.json @@ -0,0 +1,40 @@ +{ + "name": "ceremony-base", + "target": "branch", + "enforcement": "active", + "conditions": { + "ref_name": { + "include": ["refs/heads/main"], + "exclude": [] + } + }, + "bypass_actors": [], + "rules": [ + { "type": "deletion" }, + { "type": "non_fast_forward" }, + { + "type": "pull_request", + "parameters": { + "allowed_merge_methods": ["merge"], + "dismiss_stale_reviews_on_push": false, + "require_code_owner_review": false, + "require_extra_approval_for_unattributed_changes": true, + "require_last_push_approval": false, + "required_approving_review_count": 0, + "required_review_thread_resolution": true + } + }, + { + "type": "required_status_checks", + "parameters": { + "do_not_enforce_on_create": false, + "strict_required_status_checks_policy": false, + "required_status_checks": [ + { "context": "quality", "integration_id": 15368 }, + { "context": "owner-seal", "integration_id": 15368 }, + { "context": "review/correctness", "integration_id": 15368 } + ] + } + } + ] +} diff --git a/.github/rulesets/owner-veto.json b/.github/rulesets/owner-veto.json new file mode 100644 index 0000000..31d9728 --- /dev/null +++ b/.github/rulesets/owner-veto.json @@ -0,0 +1,28 @@ +{ + "name": "owner-veto", + "target": "branch", + "enforcement": "active", + "conditions": { + "ref_name": { + "include": ["refs/heads/main"], + "exclude": [] + } + }, + "bypass_actors": [ + { "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "pull_request" } + ], + "rules": [ + { + "type": "pull_request", + "parameters": { + "allowed_merge_methods": ["merge"], + "dismiss_stale_reviews_on_push": true, + "require_code_owner_review": true, + "require_extra_approval_for_unattributed_changes": true, + "require_last_push_approval": false, + "required_approving_review_count": 1, + "required_review_thread_resolution": true + } + } + ] +} diff --git a/.github/workflows/attestations.yaml b/.github/workflows/attestations.yaml index de9622b..ffa6893 100644 --- a/.github/workflows/attestations.yaml +++ b/.github/workflows/attestations.yaml @@ -2,10 +2,10 @@ name: Attestations # Deterministic attestation checks: every commit answers who wrote it, # and machinery changes carry their specification or the owner's -# explicit waiver. Label events re-evaluate the spec gate, so applying -# spec:none recomputes the check without a push. pull_request_target -# keeps both checks base-defined; the head enters only as fetched -# history and file listings, never as executed code. +# recorded allowed defect. Label events re-evaluate the spec gate, so +# applying ignore:spec recomputes the check without a push. +# pull_request_target keeps both checks base-defined; the head enters +# only as fetched history and file listings, never as executed code. on: pull_request_target: types: [opened, reopened, synchronize, labeled, unlabeled] @@ -24,11 +24,16 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: + # The trusted base enters the worktree. The fetched head supplies + # commit metadata only. + # nosemgrep: yaml.github-actions.security.pull-request-target-code-checkout.pull-request-target-code-checkout - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 with: - # The checker, helper, and policy share the trusted base. + # Both the checker and identity file must come from the base. + # A pull request cannot change either input for its own check. ref: ${{ github.event.pull_request.base.sha }} fetch-depth: 0 + persist-credentials: false - name: Verify commit authorship env: BASE_SHA: ${{ github.event.pull_request.base.sha }} @@ -63,8 +68,8 @@ jobs: files=$(gh api --paginate "repos/${{ github.repository }}/pulls/$PR_NUMBER/files?per_page=100" \ --jq '[.[] | .filename, (.previous_filename // empty)]' | jq -s -r 'add // [] | .[]') \ || { echo "could not read the changed files; rerun the check"; exit 1; } - protected='^(\.github/workflows/|\.githooks/|templates/|schemas/|\.macroscope/)|^(\.pre-commit-config\.yaml|\.gitleaks\.toml|authors\.yaml|scripts/check-authorship|scripts/author-identity\.py)$' - spec_tree='^docs/(specs|openspec)/' + protected='^(\.github/workflows/|\.githooks/|templates/|schemas/|\.macroscope/|\.vale/|scripts/)|^(\.pre-commit-config\.yaml|\.gitleaks\.toml|\.vale\.ini|\.rumdl\.toml|typos\.toml|\.github/zizmor\.yml|\.ceremony-divergences\.yaml|authors\.yaml)$' + spec_tree='^docs/(specs|openspec)/|^docs/changes/[^/]+/specs/[^/]+/spec\.md$' touched=$(printf '%s\n' "$files" | grep -E "$protected" || true) if [ -z "$touched" ]; then echo "no protected paths touched; no specification is required." @@ -77,16 +82,16 @@ jobs: labels=$(gh api --paginate "repos/${{ github.repository }}/issues/$PR_NUMBER/labels?per_page=100" \ --jq '[.[].name]' | jq -s -r 'add // [] | .[]') \ || { echo "could not read the live labels; rerun the check"; exit 1; } - if printf '%s\n' "$labels" | grep -qx 'spec:none'; then + if printf '%s\n' "$labels" | grep -qx 'ignore:spec'; then body=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.body // ""') \ || { echo "could not read the pull request body; rerun the check"; exit 1; } - if printf '%s\n' "$body" | grep -qE '^spec:none: .+'; then - echo "spec:none waiver present with its reason." + if printf '%s\n' "$body" | grep -qE '^ignore:spec: .+'; then + echo "ignore:spec allowed defect present with its reason." exit 0 fi - echo "spec:none is applied but the body carries no 'spec:none: ' line." + echo "ignore:spec is applied but the body carries no 'ignore:spec: ' line." exit 1 fi - echo "these protected paths change without a specification or a spec:none waiver:" + echo "these protected paths change without a specification or an ignore:spec allowed defect:" printf '%s\n' "$touched" exit 1 diff --git a/.github/workflows/draft-open.yaml b/.github/workflows/draft-open.yaml new file mode 100644 index 0000000..aa97945 --- /dev/null +++ b/.github/workflows/draft-open.yaml @@ -0,0 +1,143 @@ +name: Draft Open + +# The app opens a draft pull request on the first push of a ceremony branch +# that passes the deterministic checks (docs/specs/review-ceremony, Draft by +# the App, Ready by the Owner). The `checks` job calls quality.yaml on the +# pushed head, and the draft opens only when it passes. The draft carries the +# session's ceremony body from docs/changes//pull-request.md when the +# branch has one, else a placeholder body that passes +# schemas/PULL_REQUEST.mdschema (tests/draft-open-body proves the +# placeholder). A branch that ever had a pull request gets no second draft +# and runs no second quality pass here. Nothing here flips a draft to +# ready: that is the owner's `rune sign open`. The runewright token is +# minted for the create call alone, so the pull request opens under the +# app identity. +on: + push: + branches: + - "change/**" + - "codex/**" + - "fable/**" + +permissions: {} + +# Two pushes to one branch in quick succession must not race to two +# drafts. The group serializes them and the second finds the first's draft. +concurrency: + group: draft-open-${{ github.ref }} + cancel-in-progress: false + +jobs: + existing: + if: github.ref_name != github.event.repository.default_branch && !github.event.deleted + runs-on: ubuntu-latest + timeout-minutes: 2 + permissions: + pull-requests: read + outputs: + found: ${{ steps.existing.outputs.found }} + steps: + - name: Find an existing pull request + id: existing + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + OWNER: ${{ github.repository_owner }} + BRANCH: ${{ github.ref_name }} + run: | + set -o pipefail + # state=all: a closed or merged pull request also spends + # the branch's first push. Pages merge through jq -s. + count=$(gh api --paginate "repos/$REPOSITORY/pulls?state=all&head=$OWNER:$BRANCH&per_page=100" \ + --jq '[.[].number]' | jq -s 'add // [] | length') \ + || { echo "could not read the pull requests for $BRANCH; rerun the workflow"; exit 1; } + if [ "$count" != "0" ]; then + echo "found=true" >> "$GITHUB_OUTPUT" + echo "$BRANCH already has a pull request, so no second draft opens." + else + echo "found=false" >> "$GITHUB_OUTPUT" + fi + + # The deterministic checks on the pushed head. A head that fails them + # gets no draft, so no lane runs on a head the ceremony rejects. + checks: + needs: existing + if: needs.existing.outputs.found == 'false' + uses: ./.github/workflows/quality.yaml + permissions: + contents: read + pull-requests: read + + open: + needs: [existing, checks] + if: needs.existing.outputs.found == 'false' && needs.checks.result == 'success' + runs-on: ubuntu-latest + timeout-minutes: 3 + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + persist-credentials: false + + - name: Compose the body + id: body + env: + BRANCH: ${{ github.ref_name }} + HEAD_MESSAGE: ${{ github.event.head_commit.message }} + run: | + set -euo pipefail + change_id=${BRANCH#*/} + title=$(printf '%s\n' "$HEAD_MESSAGE" | head -n 1) + [ -n "$title" ] || title="Draft: $BRANCH" + body="$RUNNER_TEMP/pull-request.md" + if [ -f "docs/changes/$change_id/pull-request.md" ]; then + cp "docs/changes/$change_id/pull-request.md" "$body" + echo "body from docs/changes/$change_id/pull-request.md" + else + cat > "$body" <> "$GITHUB_OUTPUT" + printf 'body=%s\n' "$body" >> "$GITHUB_OUTPUT" + + - id: runewright + uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2 + with: + app-id: ${{ secrets.RUNEWRIGHT_APP_ID }} + private-key: ${{ secrets.RUNEWRIGHT_APP_KEY }} + permission-contents: read + permission-pull-requests: write + + - name: Open the draft + env: + GH_TOKEN: ${{ steps.runewright.outputs.token }} + REPOSITORY: ${{ github.repository }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + BRANCH: ${{ github.ref_name }} + TITLE: ${{ steps.body.outputs.title }} + BODY: ${{ steps.body.outputs.body }} + run: | + set -euo pipefail + gh pr create --repo "$REPOSITORY" --draft \ + --base "$DEFAULT_BRANCH" --head "$BRANCH" \ + --title "$TITLE" --body-file "$BODY" diff --git a/.github/workflows/owner-seal.yaml b/.github/workflows/owner-seal.yaml new file mode 100644 index 0000000..4bbea74 --- /dev/null +++ b/.github/workflows/owner-seal.yaml @@ -0,0 +1,162 @@ +name: Owner Seal + +# The required owner-seal check (docs/specs/release-ceremony): a ready pull +# request passes only with a valid open-seal beneath its head and a valid +# merge-seal at its head. A draft passes without seals. +# +# Two jobs report two check runs. `owner-seal/open` is the open-seal alone: +# the controller reads its conclusion, together with draft == false, as +# the "ready with a valid open-seal" condition that starts the funnel. +# `owner-seal` is the whole check the ruleset requires: it fails when the +# open half failed, then verifies the merge-seal. +# +# pull_request_target, deliberately: the workflow file, KEYS, and the +# verifier come from the default branch, never from the pull request head. +# The job checks out the default branch and fetches the head as objects +# only, and nothing from the head runs. A head branch can still define a +# `pull_request` workflow whose job is named `owner-seal`, and that check +# run comes from the same GitHub Actions integration id, so a repository +# ruleset cannot tell the two apart. The real boundary is an organization +# ruleset `workflows` rule pinned to this file on the default branch of a +# source repository. Until that rule exists, treat a same-named check run +# from a `pull_request` event on a head that edits this file as a forgery. +# +# The ledger the merge half checks is a check run named `ledger` on +# `reviewed_sha`, created by the controller under the app named by +# LEDGER_APP, the reviewing identity. Only the app that created a check +# run can edit it, so the first line of its output text, `ledger: +# {"artifact_id":..,"digest":..,"generation":..,"pull_request":.., +# "reviewed_sha":..}`, is the controller's word and nobody else's. The +# digest is the sha256 of the ledger artifact, and the merge-seal binds +# it, so the owner sealed the very record the check reads. No ledger, no +# pass. A generation bump raises no pull request event, so the +# controller MUST rerequest the `owner-seal` check run on the head after +# every ledger write (POST /repos/{repo}/check-runs/{id}/rerequest, which +# needs checks: write on the app). A label touch by the owner is the +# manual way to re-run the check without a push. +on: + pull_request_target: + types: [opened, reopened, synchronize, ready_for_review, converted_to_draft, edited, labeled, unlabeled] + +permissions: {} + +env: + LEDGER_APP: runeseer + +concurrency: + group: owner-seal-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + open: + name: owner-seal/open + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + pull-requests: read + steps: + - name: Draft + if: github.event.pull_request.draft + run: echo "draft, seals not required yet" + + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + if: '!github.event.pull_request.draft' + with: + ref: ${{ github.event.repository.default_branch }} + fetch-depth: 0 + persist-credentials: false + + - name: Verify the open-seal + if: '!github.event.pull_request.draft' + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + PR_NUMBER: ${{ github.event.pull_request.number }} + BASE_REF: ${{ github.event.pull_request.base.ref }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + set -euo pipefail + # The verifier and KEYS are the default branch's. A + # mismatch here means the checkout is not the trusted one. + checked_out=$(git rev-parse HEAD) + trusted=$(git rev-parse "origin/$DEFAULT_BRANCH") + [ "$checked_out" = "$trusted" ] \ + || { echo "the trusted checkout $checked_out is not $DEFAULT_BRANCH at $trusted"; exit 1; } + git fetch --quiet origin "pull/$PR_NUMBER/head" + git cat-file -e "$HEAD_SHA^{commit}" \ + || { echo "the pull request head $HEAD_SHA was not fetched; rerun the check"; exit 1; } + git cat-file -e "$BASE_SHA^{commit}" || git fetch --quiet origin "$BASE_SHA" + # Every open pull request body: this one must carry the + # nonce, and any other that carries it is reported. + gh api --paginate "repos/$REPOSITORY/pulls?state=open&per_page=100" \ + --jq '[.[] | {number, body}]' | jq -s 'add // []' > "$RUNNER_TEMP/open-bodies.json" \ + || { echo "could not read the open pull requests; rerun the check"; exit 1; } + bash scripts/verify-seal open \ + --head "$HEAD_SHA" --repo "$REPOSITORY" --base "$BASE_REF" --number "$PR_NUMBER" \ + --keys KEYS --open-bodies "$RUNNER_TEMP/open-bodies.json" --since "$BASE_SHA" + + seal: + name: owner-seal + needs: open + # always(): a skipped required check reads as satisfied, so this + # job runs and fails on its own when the open half failed. + if: always() + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + checks: read + steps: + - name: Draft + if: github.event.pull_request.draft + run: echo "draft, seals not required yet" + + - name: Open-seal result + if: '!github.event.pull_request.draft' + env: + OPEN_RESULT: ${{ needs.open.result }} + run: | + [ "$OPEN_RESULT" = success ] \ + || { echo "the open-seal check ended $OPEN_RESULT; no merge-seal can stand on it"; exit 1; } + + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + if: '!github.event.pull_request.draft' + with: + ref: ${{ github.event.repository.default_branch }} + fetch-depth: 0 + persist-credentials: false + + - name: Verify the merge-seal + if: '!github.event.pull_request.draft' + env: + GH_TOKEN: ${{ github.token }} + REPOSITORY: ${{ github.repository }} + DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} + PR_NUMBER: ${{ github.event.pull_request.number }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + set -euo pipefail + checked_out=$(git rev-parse HEAD) + trusted=$(git rev-parse "origin/$DEFAULT_BRANCH") + [ "$checked_out" = "$trusted" ] \ + || { echo "the trusted checkout $checked_out is not $DEFAULT_BRANCH at $trusted"; exit 1; } + git fetch --quiet origin "pull/$PR_NUMBER/head" + git cat-file -e "$HEAD_SHA^{commit}" \ + || { echo "the pull request head $HEAD_SHA was not fetched; rerun the check"; exit 1; } + # The merge-seal's sole parent is reviewed_sha; the + # verifier proves that. The ledger lives on that parent. + reviewed=$(git rev-list --parents -n 1 "$HEAD_SHA" | cut -d ' ' -f 2) + # LEDGER_APP is workflow-fixed text, so it may sit inside + # the filter. Pages merge through jq -s; the newest check + # run from the app wins. + ledger=$(gh api --paginate "repos/$REPOSITORY/commits/$reviewed/check-runs?check_name=ledger&per_page=100" \ + --jq "[.check_runs[] | select(.app.slug == \"$LEDGER_APP\")]" \ + | jq -s -r 'add // [] | max_by(.id) | .output.text // "" | split("\n") | first | select(startswith("ledger: ")) | ltrimstr("ledger: ")') \ + || { echo "could not read the check runs on $reviewed; rerun the check"; exit 1; } + [ -n "$ledger" ] \ + || { echo "no ledger check run from $LEDGER_APP on reviewed_sha $reviewed; the merge-seal has nothing to bind to"; exit 1; } + printf '%s\n' "$ledger" > "$RUNNER_TEMP/ledger.json" + bash scripts/verify-seal merge --head "$HEAD_SHA" --keys KEYS --ledger "$RUNNER_TEMP/ledger.json" diff --git a/.github/workflows/pr-lint.yaml b/.github/workflows/pr-lint.yaml index 7ee35f9..25e1581 100644 --- a/.github/workflows/pr-lint.yaml +++ b/.github/workflows/pr-lint.yaml @@ -59,14 +59,25 @@ jobs: ["review:macroscope", "5319e7", "Summons the macroscope lane"], ["review:cursor", "5319e7", "Summons a standalone Cursor round"], ["review:coderabbit", "5319e7", "Summons a standalone CodeRabbit round"], + ["review:pr-agent", "5319e7", "Summons a standalone PR-Agent round"], ["review:autofix", "5319e7", "Summons a mechanical-fix suggestion patch"], ["skip:cursor", "b60205", "Owner override: the cursor lane never runs"], ["skip:macroscope", "b60205", "Owner override: the macroscope lane never runs"], ["skip:runeseer", "b60205", "Owner override: the runeseer lane never runs"], + ["skip:pr-agent", "b60205", "Owner override: the pr-agent lane never runs"], ["ignore:cursor", "d93f0b", "Owner override: the cursor lane reports but does not hold the merge"], ["ignore:macroscope", "d93f0b", "Owner override: the macroscope lane reports but does not hold the merge"], ["ignore:runeseer", "d93f0b", "Owner override: the runeseer lane reports but does not hold the merge"], - ["spec:none", "ededed", "Owner waiver: no specification change needed, reason in body"], + ["ignore:spec", "d93f0b", "Allowed defect: protected paths change without a specification, reason in body"], + // The seer cascade and correctness bodies apply and + // read the stage records and provider blockers; + // provisioning pins their names, colors, and + // descriptions. + ["stage:cursor", "ededed", "Round record: the cursor stage settled on this head"], + ["stage:macroscope", "ededed", "Round record: the macroscope stage settled on this head"], + ["issue:cursor", "e99695", "Provider blocker: clear the cursor problem before re-summoning"], + ["issue:macroscope", "e99695", "Provider blocker: clear the macroscope problem before re-summoning"], + ["issue:rune", "e99695", "Provider blocker: clear the rune problem before re-summoning"], ]; for (const [name, color, description] of wanted) { try { @@ -78,9 +89,9 @@ jobs: await github.rest.issues.createLabel({ ...context.repo, name, color, description }); } } - // Names the per-lane families replaced. Leaving it behind + // Names the current taxonomy replaced. Leaving one behind // would offer an override that no workflow reads. - const retired = ["review:skip"]; + const retired = ["review:skip", "spec:none"]; for (const name of retired) { try { await github.rest.issues.deleteLabel({ ...context.repo, name }); diff --git a/.github/workflows/quality.yaml b/.github/workflows/quality.yaml index 73ea472..b1813a0 100644 --- a/.github/workflows/quality.yaml +++ b/.github/workflows/quality.yaml @@ -5,6 +5,9 @@ on: branches: [main] pull_request: branches: [main] + # draft-open.yaml calls this workflow on the first push of a ceremony + # branch, so the draft opens only after the deterministic checks pass. + workflow_call: {} concurrency: group: quality-${{ github.ref }} @@ -14,12 +17,6 @@ permissions: contents: read pull-requests: read -env: - GITLEAKS_VERSION: "8.30.1" - # Digest of gitleaks_8.30.1_linux_x64.tar.gz, pinned in reviewed - # source so verification attests provenance, not just transport. - GITLEAKS_SHA256: "551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb" - jobs: quality: runs-on: ubuntu-latest @@ -57,61 +54,40 @@ jobs: # permission fault must not read as a missing section. body=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" --jq '.body // ""') \ || { echo "could not read the pull request body (API or permission failure)"; exit 1; } - printf '%s\n' "$body" \ - | awk '/^## Release Notes[[:space:]]*$/{in_section=1; next} /^## /{in_section=0} in_section && /^([-*+]|[0-9]+[.)]) /{found=1} END{exit !found}' \ - && echo "Release Notes section present." \ - || { echo "The pull request body needs a '## Release Notes' section with at least one entry ('- N/A' for non-user-facing work)."; exit 1; } + if printf '%s\n' "$body" \ + | awk '/^## Release Notes[[:space:]]*$/{in_section=1; next} /^## /{in_section=0} in_section && /^([-*+]|[0-9]+[.)]) /{found=1} END{exit !found}'; then + echo "Release Notes section present." + else + echo "The pull request body needs a '## Release Notes' section with at least one entry ('- N/A' for non-user-facing work)." + exit 1 + fi - # The distro package is too old for `gitleaks git`; install the - # pinned upstream release and verify it against the release's - # digest pinned above before executing. - # ruff and semgrep serve the universal prek config's type-gated - # hooks; rust and ts toolchains are the scaffolded repository's - # own concern, and their hooks never fire without their files. + # Local hooks, generated CI, and template updates all consume the + # same reviewed tool versions and archive digests. - name: Install tools - run: | - sudo apt-get install -y shellcheck - pipx install ruff semgrep - curl -fsSLO "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" - echo "${GITLEAKS_SHA256} gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" | sha256sum --check - tar -xzf "gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" gitleaks - sudo install gitleaks /usr/local/bin/gitleaks - - - name: Authorship regression tests - run: python3 -m unittest discover -s tests -p 'test_author*.py' - - - name: Install JJ for push gate tests - env: - JJ_VERSION: "0.45.1" - JJ_SHA256: "f35438350b5d61963aac5dd74ede510b31d6b9690769d1a6268cf058cc825f72" - run: | - scratch=$(mktemp -d) - curl -fsSL -o "$scratch/jj.tar.gz" "https://github.com/jj-vcs/jj/releases/download/v${JJ_VERSION}/jj-v${JJ_VERSION}-x86_64-unknown-linux-musl.tar.gz" - printf '%s %s\n' "$JJ_SHA256" "$scratch/jj.tar.gz" | sha256sum --check - tar -xzf "$scratch/jj.tar.gz" -C "$scratch" ./jj - sudo install "$scratch/jj" /usr/local/bin/jj - jj --version - - - name: Test JJ push gate - run: python3 -m unittest discover -s tests -p 'test_jj_push.py' -v + run: bash scripts/install-tools + # The prek CLI is called directly: the wrapper action logs at + # TRACE level and buries the failing hook's output. REQUIRE_GATES + # turns a missing linter into a failure instead of a skip. - name: Commit-stage checks - uses: j178/prek-action@5337cb91e0fa35a7ff31b9ca345126d8bbbcdf16 # v2 + env: + REQUIRE_GATES: "1" + run: prek run --all-files # Scan exactly the commits this event introduces. Without a usable # base, gitleaks scans the target history and other hooks inspect all files. - name: Pre-push-stage checks - env: - PR_HEAD: ${{ github.event.pull_request.head.sha }} - PUSH_HEAD: ${{ github.sha }} run: | - to="${PR_HEAD:-$PUSH_HEAD}" if [ -n "${{ github.event.pull_request.base.sha }}" ]; then from="${{ github.event.pull_request.base.sha }}" + to="${{ github.event.pull_request.head.sha }}" elif [ -n "${{ github.event.before }}" ] && ! printf '%s' "${{ github.event.before }}" | grep -q '^0*$'; then from="${{ github.event.before }}" + to="${{ github.sha }}" else from="" + to="${{ github.sha }}" fi if [ -n "$from" ] && git cat-file -e "$from" 2>/dev/null; then prek run --stage pre-push --from-ref "$from" --to-ref "$to" diff --git a/.github/workflows/review-cascade.yaml b/.github/workflows/review-cascade.yaml index afe8c32..5533305 100644 --- a/.github/workflows/review-cascade.yaml +++ b/.github/workflows/review-cascade.yaml @@ -4,9 +4,17 @@ name: Review Cascade # deliberately: the cascade is API-only and checks out nothing, and fork pull # requests need the base-context secrets. Never add a head checkout here # or in the body. +# +# The ready event, each later push, and a reopen all reach the controller +# (docs/specs/review-requests, Ready Starts the Funnel): its triage decides +# whether a paid round starts, and the called workflow reads the event from +# github.event, which a reusable workflow shares with its caller. The +# `review` label stays as the owner's way to force a round. Until the +# controller carries a triage, the called workflow stands down without a +# live `review` label, so the wider trigger spends nothing today. on: pull_request_target: - types: [opened, labeled, unlabeled, ready_for_review] + types: [labeled, unlabeled, ready_for_review, synchronize, reopened] # The body uses the workflow token to read check runs, the live head, and # review threads. PR label changes need pull-requests: write and issues: write. @@ -24,47 +32,15 @@ concurrency: cancel-in-progress: ${{ github.event.action == 'labeled' && github.event.label.name == 'review' }} jobs: - # A queued ready event keeps its label payload after another round - # consumed the review label, so readiness re-reads the live labels before - # the cascade may start. - release: - if: github.event.action == 'ready_for_review' && github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'review') - runs-on: ubuntu-latest - timeout-minutes: 2 - permissions: - contents: read - pull-requests: read - issues: read - outputs: - summoned: ${{ steps.live.outputs.summoned }} - steps: - - id: live - env: - GH_TOKEN: ${{ github.token }} - run: | - # Pages merge through jq -s so a label set past one page - # still counts fully. pipefail plus the explicit failure - # exit keep an API error from reading as a consumed review label. - set -o pipefail - labels=$(gh api --paginate "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels?per_page=100" \ - --jq '[.[].name]' | jq -s -r 'add // [] | .[]') \ - || { echo "could not read the live labels; rerun the check"; exit 1; } - if printf '%s\n' "$labels" | grep -qx review; then - echo "summoned=true" >> "$GITHUB_OUTPUT" - else - echo "summoned=false" >> "$GITHUB_OUTPUT" - echo "the review label was already consumed; the cascade stands down." - fi - + # Fork pull requests keep the owner-summoned free lanes: a review + # label on a fork head runs the cascade, the correctness lane + # refuses fork heads on its own, and the ordered workflow stops + # after the free lanes (docs/specs/lane-configuration/spec.md, Fork + # pull request scenario). A draft never starts a round: the free + # lanes and the deterministic checks run on it through their own + # workflows. cascade: - needs: release - # Fork pull requests keep the owner-summoned free lanes: a review - # label on a fork head runs the cascade, the correctness lane - # refuses fork heads on its own, and the ordered workflow stops - # after the free lanes (docs/specs/review-ceremony/spec.md, Fork - # pull request scenario). Only the free opened round is held to - # same-repository heads, so a fork spends nothing unlabeled. - if: '!cancelled() && github.event.pull_request.draft == false && ((github.event.action == ''opened'' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event.action == ''labeled'' && github.event.label.name == ''review'') || (github.event.action == ''ready_for_review'' && needs.release.outputs.summoned == ''true''))' + if: github.event.pull_request.draft == false && ((github.event.action == 'labeled' && github.event.label.name == 'review') || contains(fromJSON('["ready_for_review", "synchronize", "reopened"]'), github.event.action)) uses: runedeck/seer/.github/workflows/review-cascade.yaml@main with: macroscope_correctness_check: ${{ vars.MACROSCOPE_CORRECTNESS_CHECK }} diff --git a/.github/workflows/review-correctness.yaml b/.github/workflows/review-correctness.yaml index 9ef703c..69c7c78 100644 --- a/.github/workflows/review-correctness.yaml +++ b/.github/workflows/review-correctness.yaml @@ -166,18 +166,39 @@ jobs: # regain their whole hold when the owner withdraws the # acceptance. if ! printf '%s\n' "$labels" | grep -qx 'ignore:runeseer'; then - acceptance_ids=$(gh api --paginate "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100" \ + # Under skip:runeseer the spec has this check clear no + # matter what, so a dismissal fault there degrades to a + # named warning instead of reddening the check the + # override must release. + lenient=0 + printf '%s\n' "$labels" | grep -qx 'skip:runeseer' && lenient=1 + dismissal_fault() { + if [ "$lenient" = "1" ]; then + echo "warning: $1; a stale acceptance approval may stand while skip:runeseer clears this check." + return 0 + fi + echo "$1; rerun the check" + exit 1 + } + if acceptance_ids=$(gh api --paginate "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100" \ --jq '[.[] | select(.user.login == "runeseer[bot]" and .state == "APPROVED") | select((.body // "") | contains("ignore:runeseer acceptance")) | .id]' \ - | jq -s -r 'add // [] | .[]') \ - || { echo "could not read the pull request reviews; rerun the check"; exit 1; } - for review_id in $acceptance_ids; do - [ -n "$RUNESEER_TOKEN" ] \ - || { echo "acceptance approval $review_id stands after the override's withdrawal, but the app token was unavailable to dismiss it; rerun the check"; exit 1; } - GH_TOKEN="$RUNESEER_TOKEN" gh api -X PUT "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews/$review_id/dismissals" \ - -f message="The owner withdrew ignore:runeseer; the acceptance no longer holds this head." \ - >/dev/null && echo "dismissed acceptance approval $review_id after the override's withdrawal." \ - || { echo "could not dismiss acceptance approval $review_id; rerun the check"; exit 1; } - done + | jq -s -r 'add // [] | .[]'); then + for review_id in $acceptance_ids; do + if [ -z "$RUNESEER_TOKEN" ]; then + dismissal_fault "acceptance approval $review_id stands after the override's withdrawal, but the app token was unavailable to dismiss it" + continue + fi + if GH_TOKEN="$RUNESEER_TOKEN" gh api -X PUT "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews/$review_id/dismissals" \ + -f message="The owner withdrew ignore:runeseer; the acceptance no longer holds this head." \ + >/dev/null; then + echo "dismissed acceptance approval $review_id after the override's withdrawal." + else + dismissal_fault "could not dismiss acceptance approval $review_id" + fi + done + else + dismissal_fault "could not read the pull request reviews" + fi fi # skip: means the lane is out of scope for this pull request, # so it clears whatever else happened. diff --git a/.github/workflows/review-cursor.yaml b/.github/workflows/review-cursor.yaml index 1439bc1..5b16af5 100644 --- a/.github/workflows/review-cursor.yaml +++ b/.github/workflows/review-cursor.yaml @@ -1,8 +1,14 @@ name: Review Cursor -# This API-only caller requests optional Bugbot reviews through Seer. -# The reusable workflow checks the live head and labels before dispatch. -# Keep head-controlled code outside this trusted workflow. +# Thin caller: the cursor summon lives in runedeck/seer. pull_request_target, +# deliberately: the lane is API-only and checks out nothing, and fork pull +# requests need the base-context secrets. Never add a head checkout here or +# in the body. +# ready_for_review releases a summon that was applied while the pull +# request was a draft: the lane body skips drafts and re-reads the live +# labels, so the label waits until readiness. Removing review:cursor +# cancels a summon that has not fired; a posted summon is Cursor's own +# round, which nothing here cancels. on: pull_request_target: types: [labeled, ready_for_review] @@ -12,15 +18,23 @@ permissions: pull-requests: write issues: write -# Separate label groups preserve queued requests during unrelated label events. +# The label name is part of the group. Every labeled event starts a run, +# and GitHub keeps one pending run per group: with a shared group, an +# unrelated label event evicts a queued review:cursor summon. Per-label +# groups keep unrelated events out of the summon's queue. concurrency: group: review-cursor-${{ github.event.pull_request.number }}-${{ github.event.label.name || 'ready' }} cancel-in-progress: false jobs: summon: + # skip:cursor is the owner override: the lane never runs under it. if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'skip:cursor') && ((github.event.action == 'labeled' && github.event.label.name == 'review:cursor') || (github.event.action == 'ready_for_review' && contains(github.event.pull_request.labels.*.name, 'review:cursor'))) uses: runedeck/seer/.github/workflows/review-cursor.yaml@main secrets: - # Bugbot requires a human-authored summon. + # The body consumes the label with an app token, then posts the + # summon with the owner-minted token because Cursor ignores + # bot-authored review comments. + RUNEWRIGHT_APP_ID: ${{ secrets.RUNEWRIGHT_APP_ID }} + RUNEWRIGHT_APP_KEY: ${{ secrets.RUNEWRIGHT_APP_KEY }} RUNEWRIGHT_GITHUB_TOKEN: ${{ secrets.RUNEWRIGHT_GITHUB_TOKEN }} diff --git a/.github/workflows/review-pragent.yaml b/.github/workflows/review-pragent.yaml new file mode 100644 index 0000000..23748ab --- /dev/null +++ b/.github/workflows/review-pragent.yaml @@ -0,0 +1,31 @@ +name: Review PR-Agent + +# Thin caller: the pr-agent lane lives in runedeck/seer. pull_request_target, +# deliberately: the lane runs PR-Agent in command mode from a pinned image +# and checks out nothing, and it needs the base-context model key. Never +# add a head checkout here or in the body. +# ready_for_review releases a summon that was applied while the pull +# request was a draft: the lane body skips drafts and re-reads the live +# labels, so the label waits until readiness. +on: + pull_request_target: + types: [labeled, ready_for_review] + +permissions: + contents: read + pull-requests: write + issues: write + +# Per-label concurrency groups keep unrelated label events out of the +# summon's queue, as in the other single-lane callers. +concurrency: + group: review-pragent-${{ github.event.pull_request.number }}-${{ github.event.label.name || 'ready' }} + cancel-in-progress: false + +jobs: + review: + # skip:pr-agent is the owner override: the lane never runs under it. + if: github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'skip:pr-agent') && ((github.event.action == 'labeled' && github.event.label.name == 'review:pr-agent') || (github.event.action == 'ready_for_review' && contains(github.event.pull_request.labels.*.name, 'review:pr-agent'))) + uses: runedeck/seer/.github/workflows/review-pragent.yaml@main + secrets: + PR_AGENT_MODEL_KEY: ${{ secrets.PR_AGENT_MODEL_KEY }} diff --git a/.github/workflows/template-update.yaml b/.github/workflows/template-update.yaml new file mode 100644 index 0000000..11a88b4 --- /dev/null +++ b/.github/workflows/template-update.yaml @@ -0,0 +1,212 @@ +name: Template Update + +on: + repository_dispatch: + types: [template-released] + schedule: + - cron: "17 5 * * 3" + workflow_dispatch: {} + +permissions: + actions: read + contents: read + pull-requests: read + +concurrency: + group: template-update + cancel-in-progress: false + +jobs: + update: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 + with: + fetch-depth: 0 + persist-credentials: false + ref: main + + - name: Install Copier + run: | + . scripts/tool-versions + pipx install "copier==$COPIER_VERSION" + + - id: detect + name: Detect template release + env: + DISPATCH_TAG: ${{ github.event.client_payload.tag }} + DISPATCH_TEMPLATE: ${{ github.event.client_payload.template }} + run: | + result=$(copier check-update --answers-file answers.yaml --output-format json) + update=$(printf '%s' "$result" | jq -r '.update_available') + latest=$(printf '%s' "$result" | jq -r '.latest_version') + target=$latest + recorded_source=$(grep -E '^_src_path:' answers.yaml | sed 's/^_src_path:[[:space:]]*//') + recorded_commit=$(grep -E '^_commit:' answers.yaml | sed 's/^_commit:[[:space:]]*//') + fetch_url=$recorded_source + case "$fetch_url" in gh:*) fetch_url="https://github.com/${fetch_url#gh:}" ;; esac + + if [ "${{ github.event_name }}" = "repository_dispatch" ]; then + printf '%s' "$DISPATCH_TEMPLATE" \ + | grep -Eq '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$' \ + || { echo "invalid template repository: $DISPATCH_TEMPLATE"; exit 1; } + # A dispatch for another template must not advance this + # repository. The recorded source's owner/repo tail + # compares across https, ssh, gh:, and .git spellings. + source_repo=$(printf '%s' "$recorded_source" | sed -E 's/\.git$//; s|^.*[:/]([^/:]+/[^/:]+)$|\1|') + [ "$source_repo" = "$DISPATCH_TEMPLATE" ] \ + || { echo "dispatch names template $DISPATCH_TEMPLATE, but this repository adopted $recorded_source"; exit 1; } + git check-ref-format "refs/tags/$DISPATCH_TAG" \ + || { echo "invalid template release tag: $DISPATCH_TAG"; exit 1; } + dispatch_version=${DISPATCH_TAG#v} + [ "$latest" = "$DISPATCH_TAG" ] || [ "$latest" = "$dispatch_version" ] \ + || { echo "release dispatch $DISPATCH_TAG is superseded by $latest"; exit 1; } + target=$DISPATCH_TAG + fi + + # Copier reports bare versions while release tags may carry a + # v prefix; the template's own tag list settles the form. A + # template with no tag past the recorded pin reports a + # post-release version (0.0.0.postN+sha): the target is then + # the commit of skeleton main, and the update pins that commit. + if [ "$update" = "true" ]; then + case "$target" in + *.post*+*) + resolved=$(git ls-remote "$fetch_url" refs/heads/main | cut -f1) \ + || { echo "could not read main on $recorded_source"; exit 1; } + [ -n "$resolved" ] \ + || { echo "no main branch on $recorded_source"; exit 1; } + ;; + *) + bare=${target#v} + listing=$(git ls-remote --tags "$fetch_url" "refs/tags/v$bare" "refs/tags/$bare") \ + || { echo "could not list release tags on $recorded_source"; exit 1; } + resolved=$(printf '%s\n' "$listing" \ + | grep -v '\^{}' | head -n 1 | sed 's|.*refs/tags/||') + [ -n "$resolved" ] \ + || { echo "no release tag for $target on $recorded_source"; exit 1; } + ;; + esac + target=$resolved + fi + + # Copier compares tags only. A consumer pinned to a commit + # past the latest tag (a `v0.1.0-3-gabc1234` describe string + # or a bare hash) sees no tag update while skeleton main + # moves on, so main is compared by hand. + if [ "$update" != "true" ] && [ "${{ github.event_name }}" != "repository_dispatch" ]; then + case "$recorded_commit" in + *-g[0-9a-f]*) pinned_hash=${recorded_commit##*-g} ;; + *) pinned_hash=$recorded_commit ;; + esac + if printf '%s' "$pinned_hash" | grep -Eq '^[0-9a-f]{7,40}$'; then + main_sha=$(git ls-remote "$fetch_url" refs/heads/main | cut -f1) \ + || { echo "could not read main on $recorded_source"; exit 1; } + case "$main_sha" in + "$pinned_hash"*) ;; + *) update=true; target=$main_sha ;; + esac + fi + fi + + printf '%s\n' "update=$update" "tag=$target" \ + | tee -a "$GITHUB_OUTPUT" >/dev/null + + - id: existing + name: Find an open update + if: steps.detect.outputs.update == 'true' + run: | + # Updates publish as a patch artifact and a run summary; the + # owner applies the patch and pushes. Nothing opens a pull + # request, so there is no open update to look for. + printf 'url=\n' >> "$GITHUB_OUTPUT" + + - id: apply + name: Apply template release + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + continue-on-error: true + env: + TARGET_TAG: ${{ steps.detect.outputs.tag }} + run: | + # Every path pins the detected release, so the applied tree + # always matches the tag the branch and pull request name. + copier update --answers-file answers.yaml --defaults --vcs-ref "$TARGET_TAG" + + - name: Reject unresolved update output + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + env: + APPLY_OUTCOME: ${{ steps.apply.outcome }} + run: | + # A labeled begin or end marker is never legitimate text, so + # each blocks alone and a partially resolved conflict still + # fails; only a bare ======= is setext-ambiguous and passes. + conflicts=$(grep -RIlE --exclude-dir=.git --exclude-dir=.jj '^(<<<<<<< |>>>>>>> )' . || true) + rejects=$(find . -path ./.git -prune -o -path ./.jj -prune -o -type f -name '*.rej' -print) + if [ -n "$conflicts" ] || [ -n "$rejects" ]; then + [ -z "$conflicts" ] || printf '%s\n' "$conflicts" + [ -z "$rejects" ] || printf '%s\n' "$rejects" + echo "Copier left unresolved update output." + exit 1 + fi + [ "$APPLY_OUTCOME" = "success" ] \ + || { echo "Copier failed before producing reviewable conflicts."; exit 1; } + + - name: Stage template output + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + run: | + git add -A + if git diff --cached --quiet; then + echo "Copier reported an update but changed no files." + exit 1 + fi + + - name: Install validation tools + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + run: bash scripts/install-tools + + - name: Validate updated repository + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + env: + RUFF_NO_CACHE: "true" + REQUIRE_GATES: "1" + run: make validate + + - name: Build update patch + if: steps.detect.outputs.update == 'true' && steps.existing.outputs.url == '' + run: | + unstaged=$(git diff --name-only) + untracked=$(git ls-files --others --exclude-standard) + if [ -n "$unstaged" ] || [ -n "$untracked" ]; then + [ -z "$unstaged" ] || printf 'Validation modified:\n%s\n' "$unstaged" + [ -z "$untracked" ] || printf 'Validation created:\n%s\n' "$untracked" + exit 1 + fi + git diff --cached --binary --output=template-update.patch + + - name: Upload update patch + if: steps.detect.outputs.update == 'true' + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: template-update-${{ github.run_id }} + path: template-update.patch + if-no-files-found: error + + # The summary is the handoff: the owner downloads the patch, + # applies it in a jj workspace, validates, and pushes. Skeleton + # propagation never opens a pull request per consumer. + - name: Summarize the update + if: steps.detect.outputs.update == 'true' + env: + TARGET_REF: ${{ steps.detect.outputs.tag }} + RUN_ID: ${{ github.run_id }} + run: | + # shellcheck disable=SC2016 # backticks are Markdown, not expansion + { + printf '## Template update ready\n\n' + printf 'Target: `%s`\n\n' "$TARGET_REF" + printf 'Changed files:\n\n```\n' + git diff --cached --stat + printf '```\n\nApply: download the `template-update-%s` artifact, then\n\n' "$RUN_ID" + printf '```sh\ngit apply --index template-update.patch\nmake validate\n```\n' + } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index df28dde..94e52af 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -5,11 +5,17 @@ on: branches: [main] pull_request: +# The job reads the checkout and nothing else. +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 + with: + persist-credentials: false - uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable with: diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 0000000..9ff3739 --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,68 @@ +# zizmor baseline registry. Each entry is declared debt from the first audit +# of this workflow fleet, recorded so the check can block new findings. +# Remove an entry when its workflow is repaired; never add one without a +# reason beside it. +rules: + dangerous-triggers: + # pull_request_target is the deliberate seer design: the review + # lanes need base-repository secrets on fork pull requests. + ignore: + - attestations.yaml + - autofix-comment.yaml + - pr-lint.yaml + - review-cascade.yaml + - review-correctness.yaml + - review-cursor.yaml + - review-pragent.yaml + - thread-resolver.yaml + # The seal check reads KEYS and the verifier from the default + # branch and fetches the head as objects only. + - owner-seal.yaml + # workflow_run is the only trigger that sees a merge on main; the + # job checks out the completed run's head, never a PR head. + - spec-drift.yaml + unpinned-uses: + # runedeck/* first-party references are exempt from SHA pinning by + # the action-pinning check in quality.yaml; zizmor cannot express + # that policy, so the files carry ignores. + ignore: + - autofix-comment.yaml + - autofix-suggest.yaml + - congrats.yaml + - issue-dedup.yaml + - review-cascade.yaml + - review-correctness.yaml + - review-cursor.yaml + - review-pragent.yaml + - thread-resolver.yaml + excessive-permissions: + # Permission tightening is separate triage work. + ignore: + - pr-lint.yaml + - review-cascade.yaml + - review-correctness.yaml + github-app: + # App-token mints are the acceptance design; scoping them by + # permission input is separate triage work. + ignore: + - review-correctness.yaml + - spec-drift.yaml + - dispatch-template-release.yaml + - consumer-parity.yaml + - template-update.yaml + artipacked: + # persist-credentials hardening is separate triage work. + ignore: + - attestations.yaml + - secret-scan.yaml + self-repository: + # The `$/` form guards against a runtime-cloned action directory. A + # local reusable workflow is resolved by the service at the caller's + # commit either way, and the Action pinning step in quality.yaml + # and the pinned actionlint know the `./` form. + ignore: + - draft-open.yaml + template-injection: + # The expansion sites are separate triage work. + ignore: + - review-correctness.yaml diff --git a/.macroscope/check-run-agents/ceremony-conventions.md b/.macroscope/check-run-agents/ceremony-conventions.md index 07f70aa..d0add2f 100644 --- a/.macroscope/check-run-agents/ceremony-conventions.md +++ b/.macroscope/check-run-agents/ceremony-conventions.md @@ -21,7 +21,7 @@ showToolCalls: true # Workflow and hook review Review changed GitHub Actions workflows, git hooks, and shell scripts for -the conventions below. Flag violations in touched code only; do not demand +the conventions below. Flag violations in touched code only. Do not demand unrelated repository-wide cleanup. ## Trust boundaries @@ -30,7 +30,7 @@ unrelated repository-wide cleanup. execute head code trigger on pull_request, and pull_request_target jobs are API-only and never check out the head. - Checkouts that execute head code set persist-credentials: false. -- workflow_call secrets are declared required: true; fork handling lives in +- workflow_call secrets are declared required: true. Fork handling lives in job guards and in GitHub stripping fork secrets, not in the secret contract. - Third-party actions pin a full commit SHA with a version comment. @@ -45,18 +45,18 @@ unrelated repository-wide cleanup. - Review labels request one round and are consumed when the round ends, including failed rounds, and deleted with the workflow token so the deletion event triggers nothing. -- Verdict gates validate the full tuple: verdict value, zero count, empty +- Verdict checks validate the full tuple: verdict value, zero count, empty findings, and a head SHA matched against the live pull request head. ## Runner and shell -- Paginate gh output with per-page --jq arrays merged through jq -s 'add'; - the hosted runner's gh predates --slurp. +- Paginate gh output with per-page --jq arrays merged through jq -s 'add'. + The hosted runner's gh predates --slurp. - GraphQL bot logins are bare (cursor, macroscopeapp), never the REST-style [bot] suffix. - Hooks preserve their stdin protocol: extensions run with stdin redirected from /dev/null and only when the hook received arguments. -- Regexes that gate security decisions anchor their match; gitleaks +- Regexes behind security decisions anchor their match. The gitleaks allowlist paths start with ^. - Four-space indentation, no tab characters outside Makefile recipes, and every text file ends with a newline. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb1f5f9..a4fa3bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,6 +78,67 @@ repos: language: system pass_filenames: false + # Prose and workflow linters. Each hook skips when its binary is + # absent so a fresh clone stays usable before make install runs; + # REQUIRE_GATES=1 (set in CI) turns absence into a failure. + - id: rumdl + name: rumdl markdown lint + entry: sh -c 'if command -v rumdl >/dev/null 2>&1; then rumdl check "$@"; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and rumdl is absent"; exit 1; fi' -- + language: system + types: [markdown] + exclude: '(^|/)\.provenance/' + + - id: typos + name: typos spelling + entry: sh -c 'if command -v typos >/dev/null 2>&1; then typos --force-exclude "$@"; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and typos is absent"; exit 1; fi' -- + language: system + types: [text] + exclude: '(^|/)\.provenance/' + + # Archived change proposals are frozen history, not prose to keep. + - id: vale + name: vale prose style + entry: sh -c 'if command -v vale >/dev/null 2>&1; then vale --no-wrap "$@"; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and vale is absent"; exit 1; fi' -- + language: system + types: [markdown] + exclude: '(^|/)\.provenance/|^docs/changes/archive/' + + - id: vale-style-fresh + name: vale STE style matches its rule source + entry: python3 scripts/generate-vale-style.py --check + language: system + pass_filenames: false + files: '^(\.vale/|scripts/generate-vale-style\.py$)' + + - id: lychee + name: lychee link check (offline) + entry: sh -c 'if command -v lychee >/dev/null 2>&1; then lychee --offline --include-fragments --no-progress "$@"; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and lychee is absent"; exit 1; fi' -- + language: system + types: [markdown] + exclude: '(^|/)\.provenance/' + + - id: actionlint + name: actionlint + entry: sh -c 'if command -v actionlint >/dev/null 2>&1; then actionlint "$@"; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and actionlint is absent"; exit 1; fi' -- + language: system + files: ^\.github/workflows/.*\.ya?ml$ + + - id: zizmor + name: zizmor workflow audit + entry: sh -c 'if command -v zizmor >/dev/null 2>&1; then if [ -f .github/zizmor.yml ]; then zizmor --config .github/zizmor.yml "$@"; else zizmor "$@"; fi; elif [ -n "${REQUIRE_GATES:-}" ]; then echo "REQUIRE_GATES set and zizmor is absent"; exit 1; fi' -- + language: system + files: ^\.github/workflows/.*\.ya?ml$ + + # rune has no pinned release yet, so this hook skips when the binary + # is absent even under REQUIRE_GATES. It joins the required set once + # tool-versions can pin it. + - id: rune-spec-doctor + name: rune spec doctor + entry: sh -c 'if command -v rune >/dev/null 2>&1 && [ -d docs/changes ]; then rune spec doctor; fi' + language: system + pass_filenames: false + files: ^docs/(changes|specs)/ + - id: cargo-test name: cargo test entry: cargo test --all-features @@ -100,6 +161,8 @@ repos: pass_filenames: false stages: [pre-push] + # The same rules as the ci/authorship workflow, applied before the + # push so a bad identity fails as a local amend, not a CI rewrite. - id: check-authorship name: authorship (push range) entry: bash scripts/check-authorship diff --git a/.rumdl.toml b/.rumdl.toml new file mode 100644 index 0000000..21756ef --- /dev/null +++ b/.rumdl.toml @@ -0,0 +1,22 @@ +# rumdl configuration. MD013 is off because prose lines wrap at the editor, +# not at a column count. MD025 is off because it reads the frontmatter title +# as the document title and demotes every body heading, which breaks the +# mdschema structure contracts. MD041 is off because change proposals open +# with frontmatter and no title field. +[global] +disable = ["MD013", "MD025", "MD041"] +# Adopted artifacts carry digest-bound provenance sidecars, so their bytes +# stay exactly as adopted. Deployed provider trees are rune output. +exclude = [ + ".provenance", + ".claude", + ".codex", + ".gemini", + ".opencode", + # Consumer entry: parser fixtures are byte-exact test inputs. + "tests/fixtures", +] + +# Nested lists indent four spaces, the repository convention. +[MD007] +indent = 4 diff --git a/.vale.ini b/.vale.ini new file mode 100644 index 0000000..e39b207 --- /dev/null +++ b/.vale.ini @@ -0,0 +1,13 @@ +StylesPath = .vale/styles +MinAlertLevel = warning + +# The STE style is generated from the Simplified Technical English rule +# source by scripts/generate-vale-style.py. Edit the source, regenerate, +# never edit the generated files. Fenced and inline code are never linted. +# Every rule is sentence-scoped, so YAML front matter is not linted. +# Blockquotes are prose: captured output belongs in a fence. +# The strict-mode words render at suggestion level; run +# `vale --minAlertLevel=suggestion` to see them without failing a check. + +[*.md] +BasedOnStyles = STE diff --git a/.vale/ste-source.json b/.vale/ste-source.json new file mode 100644 index 0000000..d6a5301 --- /dev/null +++ b/.vale/ste-source.json @@ -0,0 +1,167 @@ +{ + "marketing": [ + "seamless", + "seamlessly", + "robust", + "powerful", + "cutting-edge", + "effortless", + "effortlessly", + "world-class", + "next-generation", + "revolutionary", + "blazing", + "lightning-fast", + "elegant", + "delightful", + "turnkey", + "best-in-class", + "state-of-the-art", + "game-changing", + "first-class", + "battle-tested", + "enterprise-grade", + "supercharge", + "unlock", + "unleash", + "empower", + "empowers" + ], + "bannedWords": [ + "begin", + "begins", + "commence", + "commences", + "initiate", + "initiates", + "originate", + "utilize", + "utilizes", + "utilizing", + "leverage", + "leverages", + "leveraging", + "facilitate", + "facilitates", + "ensure", + "ensures", + "ensuring", + "obtain", + "obtains", + "acquire", + "acquires", + "demonstrate", + "demonstrates", + "additionally", + "furthermore", + "moreover", + "comprehensive", + "comprehensively", + "utilization", + "aforementioned", + "henceforth", + "therein", + "whilst", + "amongst", + "numerous", + "myriad", + "plethora", + "provide", + "provides", + "provided", + "arm", + "arms", + "knob", + "knobs", + "gate", + "gated", + "gates", + "gating" + ], + "bannedPhrases": [ + "prior to", + "subsequent to", + "in order to", + "a variety of", + "in the event that", + "due to the fact that", + "wire up", + "wires up", + "wired up", + "wiring up", + "plumb through", + "plumbs through", + "plumbed through", + "plumbing through", + "flesh out", + "fleshes out", + "fleshed out", + "fleshing out" + ], + "strictBannedWords": [ + "however", + "since", + "should", + "shall", + "using", + "follow", + "follows", + "followed" + ], + "phrasalVerbs": [ + "spin up", + "spin down", + "reach out", + "dive into", + "dives into", + "diving into", + "kick off", + "kicks off", + "roll out", + "rolls out", + "tear down", + "ramp up", + "circle back", + "drill down", + "spun up", + "reaching out" + ], + "fillerPhrases": [ + "it is important to note", + "it should be noted", + "it is worth noting", + "please note that", + "as mentioned", + "as noted above" + ], + "verbOnlyWords": [ + "bake", + "baked", + "bakes", + "baking", + "harden", + "hardened", + "hardening", + "hardens", + "land", + "landed", + "landing", + "lands", + "orchestrate", + "orchestrated", + "orchestrates", + "orchestrating", + "scaffold", + "scaffolded", + "scaffolding", + "scaffolds", + "ship", + "shipped", + "shipping", + "ships", + "surface", + "surfaced", + "surfaces", + "surfacing" + ] +} diff --git a/.vale/ste-source.yaml b/.vale/ste-source.yaml new file mode 100644 index 0000000..ca69c8f --- /dev/null +++ b/.vale/ste-source.yaml @@ -0,0 +1,9 @@ +# Frozen snapshot of the Simplified Technical English rule source that +# scripts/generate-vale-style.py compiles into .vale/styles/STE/. The +# consumer-parity workflow reports when the deck source moves past this +# record. Refresh: copy the new rules.json over ste-source.json, update the +# three fields, run scripts/generate-vale-style.py, commit all of it. +repository: https://github.com/runedeck/deck +path: runes/core/skills/SimplifiedTechnicalEnglish/config/rules.json +commit: 269099293e9f8aec8cf801697359c2a733c022dd +sha256: 017889b12562417e66b5e4d17ff460c4d7aa2a6b080bb8cd46b8413dbeb38fc1 diff --git a/.vale/styles/STE/BannedWords.yml b/.vale/styles/STE/BannedWords.yml new file mode 100644 index 0000000..0c2dd8b --- /dev/null +++ b/.vale/styles/STE/BannedWords.yml @@ -0,0 +1,49 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "Do not use '%s'. Choose a plain word." +level: warning +scope: sentence +ignorecase: true +tokens: + - "aforementioned" + - "arm" + - "arms" + - "begin" + - "begins" + - "comprehensive" + - "comprehensively" + - "ensure" + - "ensures" + - "ensuring" + - "facilitate" + - "facilitates" + - "flesh out" + - "fleshed out" + - "fleshes out" + - "fleshing out" + - "gate" + - "gated" + - "gates" + - "gating" + - "henceforth" + - "knob" + - "knobs" + - "myriad" + - "originate" + - "plethora" + - "plumb through" + - "plumbed through" + - "plumbing through" + - "plumbs through" + - "provide" + - "provided" + - "provides" + - "therein" + - "utilization" + - "circle back" + - "dive into" + - "dives into" + - "diving into" + - "drill down" + - "reaching out" + - "spun up" diff --git a/.vale/styles/STE/Contractions.yml b/.vale/styles/STE/Contractions.yml new file mode 100644 index 0000000..f9a7796 --- /dev/null +++ b/.vale/styles/STE/Contractions.yml @@ -0,0 +1,8 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "Do not use the contraction '%s'. Write the full form." +level: error +scope: sentence +ignorecase: true +tokens: + - \b(?:don't|doesn't|didn't|can't|won't|isn't|aren't|wasn't|weren't|couldn't|shouldn't|wouldn't|it's|that's|there's|let's|we're|you're|they're|I'm|we've|you've|they've|hasn't|haven't)\b diff --git a/.vale/styles/STE/FillerPhrases.yml b/.vale/styles/STE/FillerPhrases.yml new file mode 100644 index 0000000..2fd07a4 --- /dev/null +++ b/.vale/styles/STE/FillerPhrases.yml @@ -0,0 +1,13 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "Delete the filler '%s'." +level: warning +scope: sentence +ignorecase: true +tokens: + - "as mentioned" + - "as noted above" + - "it is important to note" + - "it is worth noting" + - "it should be noted" + - "please note that" diff --git a/.vale/styles/STE/Marketing.yml b/.vale/styles/STE/Marketing.yml new file mode 100644 index 0000000..832e04c --- /dev/null +++ b/.vale/styles/STE/Marketing.yml @@ -0,0 +1,33 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "'%s' is marketing language. State the fact." +level: warning +scope: sentence +ignorecase: true +tokens: + - "battle-tested" + - "best-in-class" + - "blazing" + - "cutting-edge" + - "delightful" + - "effortless" + - "effortlessly" + - "elegant" + - "empower" + - "empowers" + - "enterprise-grade" + - "first-class" + - "game-changing" + - "lightning-fast" + - "next-generation" + - "powerful" + - "revolutionary" + - "robust" + - "seamless" + - "seamlessly" + - "state-of-the-art" + - "supercharge" + - "turnkey" + - "unleash" + - "unlock" + - "world-class" diff --git a/.vale/styles/STE/PhrasalVerbs.yml b/.vale/styles/STE/PhrasalVerbs.yml new file mode 100644 index 0000000..5388bbf --- /dev/null +++ b/.vale/styles/STE/PhrasalVerbs.yml @@ -0,0 +1,16 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: substitution +message: "Do not use the phrasal verb '%s'. Use '%s'." +level: warning +scope: sentence +ignorecase: true +swap: + "kick off": "start" + "kicks off": "starts" + "ramp up": "increase" + "reach out": "contact" + "roll out": "release" + "rolls out": "releases" + "spin down": "stop" + "spin up": "start" + "tear down": "remove" diff --git a/.vale/styles/STE/Semicolons.yml b/.vale/styles/STE/Semicolons.yml new file mode 100644 index 0000000..e646fb5 --- /dev/null +++ b/.vale/styles/STE/Semicolons.yml @@ -0,0 +1,8 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "Do not use semicolons in prose. Split the sentence." +level: error +scope: sentence +nonword: true +tokens: + - ';' diff --git a/.vale/styles/STE/StrictWords.yml b/.vale/styles/STE/StrictWords.yml new file mode 100644 index 0000000..5772490 --- /dev/null +++ b/.vale/styles/STE/StrictWords.yml @@ -0,0 +1,15 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "Strict mode: avoid '%s' in procedures and runbooks." +level: suggestion +scope: sentence +ignorecase: true +tokens: + - "follow" + - "followed" + - "follows" + - "however" + - "shall" + - "should" + - "since" + - "using" diff --git a/.vale/styles/STE/Substitutions.yml b/.vale/styles/STE/Substitutions.yml new file mode 100644 index 0000000..a9bd06c --- /dev/null +++ b/.vale/styles/STE/Substitutions.yml @@ -0,0 +1,41 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: substitution +message: "Use '%s' instead of '%s'." +level: warning +scope: sentence +ignorecase: true +action: + name: replace +swap: + "a variety of": "several" + "acquire": "get" + "acquires": "gets" + "additionally": "also" + "amongst": "among" + "commence": "start" + "commences": "starts" + "demonstrate": "show" + "demonstrates": "shows" + "due to the fact that": "because" + "furthermore": "also" + "in order to": "to" + "in the event that": "if" + "initiate": "start" + "initiates": "starts" + "leverage": "use" + "leverages": "uses" + "leveraging": "using" + "moreover": "also" + "numerous": "many" + "obtain": "get" + "obtains": "gets" + "prior to": "before" + "subsequent to": "after" + "utilize": "use" + "utilizes": "uses" + "utilizing": "using" + "whilst": "while" + "wire up": "connect" + "wired up": "connected" + "wires up": "connects" + "wiring up": "connecting" diff --git a/.vale/styles/STE/VerbOnlyWords.yml b/.vale/styles/STE/VerbOnlyWords.yml new file mode 100644 index 0000000..1b49384 --- /dev/null +++ b/.vale/styles/STE/VerbOnlyWords.yml @@ -0,0 +1,35 @@ +# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit. +extends: existence +message: "'%s' is a jargon verb here. Use a literal verb." +level: warning +scope: sentence +ignorecase: true +tokens: + - "bake" + - "baked" + - "bakes" + - "baking" + - "harden" + - "hardened" + - "hardening" + - "hardens" + - "land" + - "landed" + - "landing" + - "lands" + - "orchestrate" + - "orchestrated" + - "orchestrates" + - "orchestrating" + - "scaffold" + - "scaffolded" + - "scaffolding" + - "scaffolds" + - "ship" + - "shipped" + - "shipping" + - "ships" + - "surface" + - "surfaced" + - "surfaces" + - "surfacing" diff --git a/Makefile b/Makefile index 0df7d56..284a232 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,126 @@ -.PHONY: help install validate +.PHONY: help install validate worktree worktree-done help: - @echo " make install activate hooks (git + jj)" + @echo " make install install check tools and activate hooks" @echo " make validate run commit-stage checks" + @echo " make worktree create an agent worktree: make worktree BRANCH=change/x IDENTITY= [HARNESS=]" + @echo " make worktree-done remove a merged worktree or jj workspace: make worktree-done BRANCH=change/x" install: git config core.hooksPath .githooks - chmod +x .githooks/* 2>/dev/null || true + chmod +x .githooks/pre-commit .githooks/pre-push .githooks/jj-push scripts/* 2>/dev/null || true @if [ -d .jj ] && command -v jj >/dev/null 2>&1; then \ - jj config set --repo aliases.push "[\"util\",\"exec\",\"--\",\"bash\",\"$$(git rev-parse --show-toplevel)/.githooks/jj-push\"]"; \ + jj config set --repo aliases.push '["util","exec","--","bash","-c","exec bash \"$$(jj workspace root)/.githooks/jj-push\" \"$$@\"","jj-push"]'; \ echo "jj detected: 'jj push' runs the pre-push checks, then 'jj git push'"; \ elif [ -d .jj ]; then \ - echo "warn: .jj/ present but jj not on PATH — 'jj push' checks NOT wired"; \ + echo "warn: .jj/ present but jj not on PATH; 'jj push' checks are not wired"; \ fi + @bash scripts/install-tools validate: @bash .githooks/pre-commit --all-files + +# Create a worktree whose commits satisfy the model identity policy. +# HARNESS selects an approved domain for a new model. +worktree: + @[ -n "$(BRANCH)" ] && [ -n "$(IDENTITY)" ] \ + || { echo "usage: make worktree BRANCH=change/x IDENTITY= [HARNESS=]"; exit 2; } + @set -e; \ + identity=$$(python3 scripts/author-identity.py resolve --policy authors.yaml \ + --model '$(IDENTITY)' --harness '$(HARNESS)'); \ + name=$$(printf '%s' "$(BRANCH)" | tr '/' '-'); \ + author=$${identity% <*}; \ + address=$${identity##*<}; address=$${address%>}; \ + if [ -d .jj ]; then \ + mkdir -p .workspaces; \ + jj workspace add --name "$$name" ".workspaces/$$name"; \ + echo "jj workspace .workspaces/$$name for $(BRANCH)"; \ + echo "author with: export JJ_USER='$$author' JJ_EMAIL='$$address'"; \ + echo "push with the jj push alias after: jj bookmark create $(BRANCH)"; \ + else \ + git config extensions.worktreeConfig true; \ + git worktree add ".worktrees/$$name" -b "$(BRANCH)"; \ + git -C ".worktrees/$$name" config --worktree user.name "$$author"; \ + git -C ".worktrees/$$name" config --worktree user.email "$$address"; \ + echo "worktree .worktrees/$$name on $(BRANCH) authors as $$identity"; \ + fi + +# Remove a worktree whose branch holds no unmerged commits, then +# delete the branch. Landing the work includes this step. +worktree-done: + @[ -n "$(BRANCH)" ] || { echo "usage: make worktree-done BRANCH=change/x"; exit 2; } + @set -e; \ + name=$$(printf '%s' "$(BRANCH)" | tr '/' '-'); \ + if [ -d .jj ]; then \ + path=".workspaces/$$name"; \ + [ -d "$$path" ] || { echo "no workspace at $$path"; exit 1; }; \ + target_commit=$$(jj -R "$$path" log --no-graph -T 'commit_id' -r @); \ + unmerged=$$(jj -R "$$path" log --no-graph -T 'change_id.short() ++ " "' -r 'mutable() & ::@ & ~empty() & ~::trunk()' 2>/dev/null); \ + [ -z "$$unmerged" ] || { echo "workspace $$name holds unmerged changes: $$unmerged"; exit 1; }; \ + git_directory=$$(git rev-parse --git-dir 2>/dev/null) \ + || { echo "worktree-done needs a colocated jj repository (no git store found)."; exit 1; }; \ + target_index=$$(mktemp); \ + rm -f "$$target_index"; \ + trap 'rm -f "$$target_index"' 0 HUP INT TERM; \ + GIT_INDEX_FILE="$$target_index" git --git-dir="$$git_directory" read-tree "$$target_commit"; \ + ignored=$$(GIT_INDEX_FILE="$$target_index" git --git-dir="$$git_directory" --work-tree="$$path" ls-files --others -i --exclude-standard -- ':(top,exclude).jj/**'); \ + rm -f "$$target_index"; \ + trap - 0 HUP INT TERM; \ + [ -z "$$ignored" ] || { echo "Workspace $$name contains ignored files. Preserve or remove them first."; exit 1; }; \ + bookmarks=$$(jj -R "$$path" bookmark list -T 'if(remote, "", name ++ "\n")'); \ + bookmark_exists=false; \ + if printf '%s\n' "$$bookmarks" | grep -Fqx "$(BRANCH)"; then \ + bookmark_exists=true; \ + fi; \ + if [ "$$bookmark_exists" = true ]; then \ + bookmark_targets=$$(jj -R "$$path" bookmark list "exact:$(BRANCH)" -T 'if(remote, "", added_targets.map(|commit| commit.commit_id()).join("\n") ++ "\n")'); \ + bookmark_unmerged=""; \ + for bookmark_target in $$bookmark_targets; do \ + target_unmerged=$$(jj -R "$$path" log --no-graph -T 'commit_id ++ "\n"' -r "::$$bookmark_target & ~empty() & ~::trunk()"); \ + bookmark_unmerged="$$bookmark_unmerged$$target_unmerged"; \ + done; \ + [ -z "$$bookmark_unmerged" ] \ + || { echo "Bookmark $(BRANCH) has commits that are not on trunk: $$bookmark_unmerged"; exit 1; }; \ + fi; \ + if command -v trash >/dev/null 2>&1; then trash "$$path"; else rm -rf "$$path"; fi; \ + [ ! -e "$$path" ] || { echo "Could not remove workspace $$path."; exit 1; }; \ + jj --ignore-working-copy workspace forget "$$name"; \ + if [ "$$bookmark_exists" = true ]; then \ + jj --ignore-working-copy bookmark forget "exact:$(BRANCH)"; \ + fi; \ + echo "removed workspace $$path"; \ + else \ + path=".worktrees/$$name"; \ + [ -d "$$path" ] || { echo "no worktree at $$path"; exit 1; }; \ + dirty=$$(git -C "$$path" status --porcelain --ignored); \ + [ -z "$$dirty" ] || { echo "The worktree at $$path has tracked, untracked, or ignored changes. Preserve them first."; exit 1; }; \ + worktree_branch=$$(git -C "$$path" branch --show-current); \ + [ -z "$$worktree_branch" ] || [ "$$worktree_branch" = "$(BRANCH)" ] \ + || { echo "The worktree at $$path uses branch $$worktree_branch, not $(BRANCH)."; exit 1; }; \ + git fetch origin; \ + default=$$(git rev-parse --abbrev-ref origin/HEAD 2>/dev/null || echo origin/main); \ + worktree_head=$$(git -C "$$path" rev-parse HEAD); \ + branch_head=$$(git rev-parse "$(BRANCH)"); \ + worktree_count=$$(git rev-list --count "$$default..$$worktree_head"); \ + branch_count=$$(git rev-list --count "$$default..$(BRANCH)"); \ + if [ "$$worktree_count" -ne 0 ] || [ "$$branch_count" -ne 0 ]; then \ + [ "$$worktree_head" = "$$branch_head" ] \ + || { echo "The detached worktree and $(BRANCH) have different unmerged heads."; exit 1; }; \ + command -v gh >/dev/null 2>&1 \ + || { echo "GitHub CLI is required to verify a possible squash merge."; exit 1; }; \ + pr_records=$$(gh pr list --head "$(BRANCH)" --state all --limit 100 \ + --json headRefOid,state --jq '.[] | "\(.headRefOid) \(.state)"') \ + || { echo "Could not read pull requests for $(BRANCH)."; exit 1; }; \ + matching_states=$$(printf '%s\n' "$$pr_records" \ + | awk -v head="$$branch_head" '$$1 == head { print $$2 }'); \ + if printf '%s\n' "$$matching_states" | grep -Fqx OPEN; then \ + echo "$(BRANCH) still has an open pull request for $$branch_head."; \ + exit 1; \ + fi; \ + printf '%s\n' "$$matching_states" | grep -Fqx MERGED \ + || { echo "$(BRANCH) is not merged at $$branch_head."; exit 1; }; \ + fi; \ + git worktree remove "$$path"; \ + git branch -D "$(BRANCH)"; \ + echo "removed $$path and deleted $(BRANCH)"; \ + fi diff --git a/answers.yaml b/answers.yaml new file mode 100644 index 0000000..74e839d --- /dev/null +++ b/answers.yaml @@ -0,0 +1,7 @@ +# Changes here will be overwritten by Copier; never edit manually. +BRIEF: 'Documentation lifecycle for rune: docs link checks, ADRs, and spec-driven changes.' +NAME: docs +OWNER: runedeck +TITLE: Rune Docs +_commit: ef371c6 +_src_path: https://github.com/runedeck/skeleton.git diff --git a/authors.yaml b/authors.yaml index bf26f10..57c793d 100644 --- a/authors.yaml +++ b/authors.yaml @@ -1,17 +1,17 @@ # Commit attribution policy. Human identities and vendor aliases stay explicit. # Model identities use matching IDs and an approved harness domain. -# See docs/openspec/specs/commit-attribution/spec.md for the contract. +# See docs/specs/commit-attribution/spec.md for the contract. authors: - Martin Zeman - Claude (claude) - Claude Fable 5 (claude-fable-5) - - Claude Fable 51m (claude-fable-51m) - Claude Opus 5 (claude-opus-5) - - Claude Opus 51m (claude-opus-51m) - Claude Opus 4.8 (claude-opus-4-8) - Claude Gpt 5.6 Sol (gpt-5.6-sol) - Codex Gpt 5.6 Sol (gpt-5.6-sol) - - Grok (grok-composer-2.5-fast) + - Grok 4.6 (grok-4.6) + - Lumo Max (lumo-max) + - Kimi K3 (kimi-k3) trailers: - Claude - Claude Fable 5 @@ -22,4 +22,7 @@ trailers: model_domains: - claude.noreply.nexus.local - codex.noreply.nexus.local + - cursor.noreply.nexus.local - grok.noreply.nexus.local + - lumo.noreply.nexus.local + - kimi.noreply.nexus.local diff --git a/scripts/ci-status b/scripts/ci-status new file mode 100755 index 0000000..0a252ea --- /dev/null +++ b/scripts/ci-status @@ -0,0 +1,50 @@ +#!/bin/bash +# ci-status: one command that answers "why is CI red". +# +# scripts/ci-status [PR-NUMBER] list every check for the pull request +# of the current branch, or for PR-NUMBER +# scripts/ci-status --job-id print one job's log tail, error lines first +# +# The log tail is truncated to the last 20000 characters, in the pattern of +# the Proton devex bot's job_log helper. +set -o pipefail + +TAIL_CHARS=20000 + +if [ "${1:-}" = "--job-id" ]; then + job="${2:-}" + [ -n "$job" ] || { echo "usage: ci-status --job-id "; exit 2; } + log=$(gh run view --job "$job" --log 2>/dev/null) \ + || { echo "could not read the log for job $job"; exit 1; } + errors=$(printf '%s\n' "$log" | grep -iE 'error|fail|✗|##\[error\]' | grep -vE 'TRACE|DEBUG' | tail -n 40) + if [ -n "$errors" ]; then + echo "== error lines (last 40):" + printf '%s\n' "$errors" + echo + fi + echo "== log tail (last $TAIL_CHARS characters):" + printf '%s\n' "$log" | tail -c "$TAIL_CHARS" + exit 0 +fi + +pr="${1:-}" +if [ -n "$pr" ]; then + checks=$(gh pr checks "$pr" 2>/dev/null) +else + checks=$(gh pr checks 2>/dev/null) +fi +if [ -z "$checks" ]; then + echo "no pull request checks found; falling back to the latest runs on this branch:" + branch=$(git rev-parse --abbrev-ref HEAD) + gh run list --branch "$branch" --limit 10 + exit 0 +fi +printf '%s\n' "$checks" +echo +failing=$(printf '%s\n' "$checks" | awk -F'\t' '$2 == "fail" {print $1 "\t" $4}') +if [ -n "$failing" ]; then + echo "== failing checks (open the URL, or run: ci-status --job-id with the job id from the URL):" + printf '%s\n' "$failing" +else + echo "== no failing checks." +fi diff --git a/scripts/generate-vale-style.py b/scripts/generate-vale-style.py new file mode 100755 index 0000000..303e006 --- /dev/null +++ b/scripts/generate-vale-style.py @@ -0,0 +1,228 @@ +#!/usr/bin/env python3 +"""Generate the Vale STE style from the Simplified Technical English rule source. + +The rule source is the deck skill's ``config/rules.json``. This repository +keeps a frozen snapshot of it under ``.vale/ste-source.json`` with the +source commit, path, and digest recorded beside it in +``.vale/ste-source.yaml``. The generator reads the snapshot, or a rule +file named with ``--rules``, and writes deterministic YAML under +``.vale/styles/STE/``. ``--check`` regenerates into memory and fails when +any generated file differs or when the snapshot digest does not match its +record, so a stale style never passes a commit. +""" + +from __future__ import annotations + +import argparse +import hashlib +import json +import sys +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +SNAPSHOT = ROOT / ".vale" / "ste-source.json" +RECORD = ROOT / ".vale" / "ste-source.yaml" +STYLE = ROOT / ".vale" / "styles" / "STE" + +# One-word replacements the rule source bans without naming a swap. Vale's +# substitution rule needs a target, so the pairs live here. A banned word +# with no entry falls into the plain existence rule below. +SWAPS = { + "utilize": "use", + "utilizes": "uses", + "utilizing": "using", + "leverage": "use", + "leverages": "uses", + "leveraging": "using", + "commence": "start", + "commences": "starts", + "initiate": "start", + "initiates": "starts", + "obtain": "get", + "obtains": "gets", + "acquire": "get", + "acquires": "gets", + "demonstrate": "show", + "demonstrates": "shows", + "additionally": "also", + "furthermore": "also", + "moreover": "also", + "whilst": "while", + "amongst": "among", + "numerous": "many", + "prior to": "before", + "subsequent to": "after", + "in order to": "to", + "a variety of": "several", + "in the event that": "if", + "due to the fact that": "because", + "spin up": "start", + "spin down": "stop", + "reach out": "contact", + "kick off": "start", + "kicks off": "starts", + "roll out": "release", + "rolls out": "releases", + "tear down": "remove", + "ramp up": "increase", + "wire up": "connect", + "wires up": "connects", + "wired up": "connected", + "wiring up": "connecting", +} + +HEADER = "# Generated by scripts/generate-vale-style.py from the STE rule source. Do not edit.\n" + + +def load_rules(path: Path) -> dict: + """Load the rule source JSON or exit with a readable error.""" + try: + return json.loads(path.read_text(encoding="utf-8")) + except (OSError, ValueError) as error: + raise SystemExit(f"generate-vale-style: cannot read {path}: {error}") from error + + +def yaml_list(items: list[str]) -> str: + """Render a YAML block sequence of quoted strings.""" + return "".join(f" - {json.dumps(item)}\n" for item in items) + + +def yaml_swap(pairs: dict[str, str]) -> str: + """Render a YAML mapping of quoted keys to quoted values.""" + return "".join(f" {json.dumps(key)}: {json.dumps(value)}\n" for key, value in pairs.items()) + + +def render(rules: dict) -> dict[str, str]: + """Return the generated files keyed by name under the style directory.""" + banned = list(rules.get("bannedWords", [])) + list(rules.get("bannedPhrases", [])) + phrasal = list(rules.get("phrasalVerbs", [])) + substitutions = {word: SWAPS[word] for word in banned if word in SWAPS} + phrasal_swaps = {verb: SWAPS[verb] for verb in phrasal if verb in SWAPS} + existence = sorted({word for word in banned if word not in SWAPS}) + phrasal_only = sorted({verb for verb in phrasal if verb not in SWAPS}) + fillers = sorted(set(rules.get("fillerPhrases", []))) + marketing = sorted(set(rules.get("marketing", []))) + verb_only = sorted(set(rules.get("verbOnlyWords", []))) + strict = sorted(set(rules.get("strictBannedWords", []))) + + files = { + "Semicolons.yml": HEADER + + "extends: existence\n" + + 'message: "Do not use semicolons in prose. Split the sentence."\n' + + "level: error\nscope: sentence\nnonword: true\ntokens:\n - ';'\n", + "Contractions.yml": HEADER + + "extends: existence\n" + + "message: \"Do not use the contraction '%s'. Write the full form.\"\n" + + "level: error\nscope: sentence\nignorecase: true\ntokens:\n" + + " - \\b(?:don't|doesn't|didn't|can't|won't|isn't|aren't|wasn't|weren't|couldn't|shouldn't|wouldn't|it's|that's|there's|let's|we're|you're|they're|I'm|we've|you've|they've|hasn't|haven't)\\b\n", + "Substitutions.yml": HEADER + + "extends: substitution\n" + + "message: \"Use '%s' instead of '%s'.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\naction:\n name: replace\nswap:\n" + + yaml_swap(dict(sorted(substitutions.items()))), + "PhrasalVerbs.yml": HEADER + + "extends: substitution\n" + + "message: \"Do not use the phrasal verb '%s'. Use '%s'.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\nswap:\n" + + yaml_swap(dict(sorted(phrasal_swaps.items()))), + "BannedWords.yml": HEADER + + "extends: existence\n" + + "message: \"Do not use '%s'. Choose a plain word.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\ntokens:\n" + + yaml_list(existence + phrasal_only), + "FillerPhrases.yml": HEADER + + "extends: existence\n" + + "message: \"Delete the filler '%s'.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\ntokens:\n" + + yaml_list(fillers), + "Marketing.yml": HEADER + + "extends: existence\n" + + "message: \"'%s' is marketing language. State the fact.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\ntokens:\n" + + yaml_list(marketing), + "VerbOnlyWords.yml": HEADER + + "extends: existence\n" + + "message: \"'%s' is a jargon verb here. Use a literal verb.\"\n" + + "level: warning\nscope: sentence\nignorecase: true\ntokens:\n" + + yaml_list(verb_only), + # The deck applies these only under lint.py --strict (procedures and + # runbooks), and "shall" is the requirement keyword in every spec. + # A suggestion never fails a run; MinAlertLevel = suggestion shows it. + "StrictWords.yml": HEADER + + "extends: existence\n" + + "message: \"Strict mode: avoid '%s' in procedures and runbooks.\"\n" + + "level: suggestion\nscope: sentence\nignorecase: true\ntokens:\n" + + yaml_list(strict), + } + return files + + +def digest(path: Path) -> str: + """Return the hex SHA-256 of a file.""" + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def read_record() -> dict[str, str]: + """Read the flat key: value snapshot record without a YAML dependency.""" + record: dict[str, str] = {} + if not RECORD.is_file(): + return record + for line in RECORD.read_text(encoding="utf-8").splitlines(): + if ":" in line and not line.startswith("#"): + key, _, value = line.partition(":") + record[key.strip()] = value.strip() + return record + + +def check(rules_path: Path) -> int: + """Report stale, missing, or foreign style files. Return 1 when any exist.""" + problems: list[str] = [] + if rules_path == SNAPSHOT: + record = read_record() + recorded = record.get("sha256", "") + actual = digest(SNAPSHOT) if SNAPSHOT.is_file() else "" + if not actual: + problems.append(f"{SNAPSHOT} is missing") + elif recorded != actual: + problems.append(f"{SNAPSHOT} digest {actual[:12]} does not match the recorded {recorded[:12]}") + expected = render(load_rules(rules_path)) + present = {path.name for path in STYLE.glob("*.yml")} if STYLE.is_dir() else set() + for name, content in expected.items(): + target = STYLE / name + if not target.is_file(): + problems.append(f"{target} is missing") + elif target.read_text(encoding="utf-8") != content: + problems.append(f"{target} is stale") + for extra in sorted(present - set(expected)): + problems.append(f"{STYLE / extra} is not generated by this script") + for problem in problems: + print(f"generate-vale-style: {problem}", file=sys.stderr) + if problems: + print("generate-vale-style: run scripts/generate-vale-style.py", file=sys.stderr) + return 1 if problems else 0 + + +def write(rules_path: Path) -> int: + """Write every generated style file and remove foreign ones.""" + STYLE.mkdir(parents=True, exist_ok=True) + expected = render(load_rules(rules_path)) + for name, content in expected.items(): + (STYLE / name).write_text(content, encoding="utf-8") + for extra in STYLE.glob("*.yml"): + if extra.name not in expected: + extra.unlink() + print(f"generate-vale-style: wrote {len(expected)} files under {STYLE}") + return 0 + + +def main(argv: list[str] | None = None) -> int: + """Parse arguments and dispatch to check or write.""" + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0], allow_abbrev=False) + parser.add_argument("--rules", type=Path, default=SNAPSHOT, help="rule source JSON (default: the frozen snapshot)") + parser.add_argument("--check", action="store_true", help="verify the generated style instead of writing it") + args = parser.parse_args(argv) + return check(args.rules) if args.check else write(args.rules) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/scripts/install-tools b/scripts/install-tools new file mode 100755 index 0000000..58f67f9 --- /dev/null +++ b/scripts/install-tools @@ -0,0 +1,371 @@ +#!/usr/bin/env bash +set -euo pipefail + +script_directory=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P) +# shellcheck source=tool-versions +source "$script_directory/tool-versions" +readonly INSTALL_DIRECTORY="${HOME}/.local/bin" + +log() { + printf '%s\n' "$*" +} + +fail() { + printf 'fatal: %s\n' "$*" >&2 + exit 1 +} + +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +run_privileged() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + elif command_exists sudo; then + sudo "$@" + else + fail "administrator access is required to install system packages: $*" + fi +} + +version_output() { + case "$1" in + gitleaks) gitleaks version 2>&1 ;; + mdschema) mdschema version 2>&1 ;; + semgrep) + XDG_CONFIG_HOME="${TMPDIR:-/tmp}/rune-semgrep-config" \ + XDG_CACHE_HOME="${TMPDIR:-/tmp}/rune-semgrep-cache" \ + SEMGREP_ENABLE_VERSION_CHECK=0 semgrep --version 2>&1 + ;; + actionlint) actionlint --version 2>&1 | head -n 1 ;; + *) "$1" --version 2>&1 ;; + esac +} + +tool_matches_version() { + local command_name=$1 + local expected_version=$2 + command_exists "$command_name" || return 1 + version_output "$command_name" \ + | grep -Eq "(^|[^0-9])${expected_version//./\\.}([^0-9]|$)" +} + +all_tools_match() { + tool_matches_version prek "$PREK_VERSION" \ + && tool_matches_version gitleaks "$GITLEAKS_VERSION" \ + && command_exists shellcheck \ + && tool_matches_version copier "$COPIER_VERSION" \ + && tool_matches_version ruff "$RUFF_VERSION" \ + && tool_matches_version semgrep "$SEMGREP_VERSION" \ + && tool_matches_version mdschema "$MDSCHEMA_VERSION" \ + && tool_matches_version rumdl "$RUMDL_VERSION" \ + && tool_matches_version typos "$TYPOS_VERSION" \ + && tool_matches_version vale "$VALE_VERSION" \ + && tool_matches_version lychee "$LYCHEE_VERSION" \ + && tool_matches_version zizmor "$ZIZMOR_VERSION" \ + && tool_matches_version actionlint "$ACTIONLINT_VERSION" +} + +brew_install() { + local specification=$1 + brew list --formula "$specification" >/dev/null 2>&1 || brew install "$specification" +} + +install_with_brew() { + brew_install shellcheck + brew_install pipx + install_python_tool prek "$PREK_VERSION" + install_python_tool copier "$COPIER_VERSION" + install_python_tool ruff "$RUFF_VERSION" + install_python_tool semgrep "$SEMGREP_VERSION" + install_gitleaks + install_mdschema + install_linters +} + +install_linux_prerequisites() { + if command_exists apt-get; then + run_privileged apt-get update + run_privileged apt-get install -y ca-certificates curl pipx shellcheck tar + elif command_exists dnf; then + run_privileged dnf install -y ca-certificates curl pipx ShellCheck tar + elif command_exists pacman; then + run_privileged pacman -Sy --needed --noconfirm ca-certificates curl python-pipx shellcheck tar + else + fail "Linux setup needs Homebrew or a supported package manager (apt-get, dnf, pacman)" + fi +} + +install_python_tool() { + local command_name=$1 + local version=$2 + local package_spec="${command_name}==${version}" + + tool_matches_version "$command_name" "$version" && return + command_exists pipx || fail "pipx is required to install $command_name" + + log "Installing $package_spec with pipx" + if command_exists "$command_name"; then + pipx install --force "$package_spec" + else + pipx install "$package_spec" + fi + export PATH="$INSTALL_DIRECTORY:$PATH" + tool_matches_version "$command_name" "$version" \ + || fail "$command_name $version was installed but is not available on PATH" +} + +archive_digest() { + local tool_name=$1 + local system_name=$2 + local machine_name=$3 + local variable_name + variable_name=$(printf '%s_%s_%s_SHA256' "$tool_name" "$system_name" "$machine_name" \ + | tr '[:lower:]' '[:upper:]') + printf '%s\n' "${!variable_name:?missing reviewed digest $variable_name}" +} + +digest_matches() { + local checksum_file=$1 + if command_exists sha256sum; then + sha256sum --check --status "$checksum_file" + elif command_exists shasum; then + shasum -a 256 --check --status "$checksum_file" + else + return 1 + fi +} + +# Every step is chained with && on purpose: bash ignores `set -e` inside a +# subshell that an `if !` tests, so a failed digest check would otherwise +# fall through to the install. +verified_archive() { + local archive_url=$1 + local archive_name=$2 + local expected_digest=$3 + local binary_name=$4 + local scratch_directory + scratch_directory=$(mktemp -d "${TMPDIR:-/tmp}/rune-tools.XXXXXX") + + if ! ( + cd "$scratch_directory" \ + && curl -fsSL --connect-timeout 15 --max-time 300 --retry 3 --retry-connrefused "$archive_url" -o "$archive_name" \ + && printf '%s %s\n' "$expected_digest" "$archive_name" > selected-checksum \ + && digest_matches selected-checksum \ + && tar -xzf "$archive_name" \ + && extracted_binary=$(find . -type f -name "$binary_name" -perm -u+x -print -quit) \ + && [ -n "$extracted_binary" ] \ + && mkdir -p "$INSTALL_DIRECTORY" \ + && install -m 0755 "$extracted_binary" "$INSTALL_DIRECTORY/$binary_name" + ); then + command rm -rf "$scratch_directory" + fail "could not install verified archive $archive_name: digest or extraction failed" + fi + + command rm -rf "$scratch_directory" + export PATH="$INSTALL_DIRECTORY:$PATH" +} + +platform() { + case "$(uname -s)" in + Darwin) printf 'darwin\n' ;; + Linux) printf 'linux\n' ;; + *) fail "unsupported operating system: $(uname -s)" ;; + esac +} + +architecture() { + case "$(uname -m)" in + arm64|aarch64) printf 'arm64\n' ;; + x86_64|amd64) printf 'amd64\n' ;; + *) fail "unsupported architecture: $(uname -m)" ;; + esac +} + +install_gitleaks() { + tool_matches_version gitleaks "$GITLEAKS_VERSION" && return + + local system_name machine_name asset_machine archive_name digest + system_name=$(platform) + machine_name=$(architecture) + case "$system_name:$machine_name" in + darwin:amd64|linux:amd64) asset_machine="x64" ;; + darwin:arm64|linux:arm64) asset_machine="arm64" ;; + *) fail "gitleaks has no supported archive for $system_name/$machine_name" ;; + esac + + archive_name="gitleaks_${GITLEAKS_VERSION}_${system_name}_${asset_machine}.tar.gz" + digest=$(archive_digest gitleaks "$system_name" "$machine_name") + log "Installing digest-verified gitleaks $GITLEAKS_VERSION" + verified_archive \ + "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${archive_name}" \ + "$archive_name" "$digest" gitleaks +} + +install_mdschema() { + tool_matches_version mdschema "$MDSCHEMA_VERSION" && return + + local system_name machine_name archive_name digest + system_name=$(platform) + machine_name=$(architecture) + archive_name="mdschema_${MDSCHEMA_VERSION}_${system_name}_${machine_name}.tar.gz" + digest=$(archive_digest mdschema "$system_name" "$machine_name") + log "Installing digest-verified mdschema $MDSCHEMA_VERSION" + verified_archive \ + "https://github.com/jackchuka/mdschema/releases/download/v${MDSCHEMA_VERSION}/${archive_name}" \ + "$archive_name" "$digest" mdschema +} + +# Release archive naming differs per project. Each helper maps the platform +# to the upstream asset name, then routes through verified_archive. +rust_target() { + case "$(platform):$(architecture)" in + darwin:arm64) printf 'aarch64-apple-darwin\n' ;; + darwin:amd64) printf 'x86_64-apple-darwin\n' ;; + linux:arm64) printf 'aarch64-unknown-linux-%s\n' "$1" ;; + linux:amd64) printf 'x86_64-unknown-linux-%s\n' "$1" ;; + *) fail "no release archive for $(platform)/$(architecture)" ;; + esac +} + +install_rumdl() { + tool_matches_version rumdl "$RUMDL_VERSION" && return + local archive_name digest + archive_name="rumdl-v${RUMDL_VERSION}-$(rust_target gnu).tar.gz" + digest=$(archive_digest rumdl "$(platform)" "$(architecture)") + log "Installing digest-verified rumdl $RUMDL_VERSION" + verified_archive \ + "https://github.com/rvben/rumdl/releases/download/v${RUMDL_VERSION}/${archive_name}" \ + "$archive_name" "$digest" rumdl +} + +install_typos() { + tool_matches_version typos "$TYPOS_VERSION" && return + local archive_name digest + archive_name="typos-v${TYPOS_VERSION}-$(rust_target musl).tar.gz" + digest=$(archive_digest typos "$(platform)" "$(architecture)") + log "Installing digest-verified typos $TYPOS_VERSION" + verified_archive \ + "https://github.com/crate-ci/typos/releases/download/v${TYPOS_VERSION}/${archive_name}" \ + "$archive_name" "$digest" typos +} + +install_vale() { + tool_matches_version vale "$VALE_VERSION" && return + local archive_name digest system_name machine_name + case "$(platform):$(architecture)" in + darwin:arm64) system_name=macOS; machine_name=arm64 ;; + darwin:amd64) system_name=macOS; machine_name=64-bit ;; + linux:arm64) system_name=Linux; machine_name=arm64 ;; + linux:amd64) system_name=Linux; machine_name=64-bit ;; + *) fail "no release archive for $(platform)/$(architecture)" ;; + esac + archive_name="vale_${VALE_VERSION}_${system_name}_${machine_name}.tar.gz" + digest=$(archive_digest vale "$(platform)" "$(architecture)") + log "Installing digest-verified vale $VALE_VERSION" + verified_archive \ + "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/${archive_name}" \ + "$archive_name" "$digest" vale +} + +install_lychee() { + tool_matches_version lychee "$LYCHEE_VERSION" && return + local archive_name digest + archive_name="lychee-$(rust_target gnu).tar.gz" + digest=$(archive_digest lychee "$(platform)" "$(architecture)") + log "Installing digest-verified lychee $LYCHEE_VERSION" + verified_archive \ + "https://github.com/lycheeverse/lychee/releases/download/lychee-v${LYCHEE_VERSION}/${archive_name}" \ + "$archive_name" "$digest" lychee +} + +install_zizmor() { + tool_matches_version zizmor "$ZIZMOR_VERSION" && return + local archive_name digest + archive_name="zizmor-$(rust_target gnu).tar.gz" + digest=$(archive_digest zizmor "$(platform)" "$(architecture)") + log "Installing digest-verified zizmor $ZIZMOR_VERSION" + verified_archive \ + "https://github.com/zizmorcore/zizmor/releases/download/v${ZIZMOR_VERSION}/${archive_name}" \ + "$archive_name" "$digest" zizmor +} + +install_actionlint() { + tool_matches_version actionlint "$ACTIONLINT_VERSION" && return + local archive_name digest + archive_name="actionlint_${ACTIONLINT_VERSION}_$(platform)_$(architecture).tar.gz" + digest=$(archive_digest actionlint "$(platform)" "$(architecture)") + log "Installing digest-verified actionlint $ACTIONLINT_VERSION" + verified_archive \ + "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/${archive_name}" \ + "$archive_name" "$digest" actionlint +} + +install_linters() { + install_rumdl + install_typos + install_vale + install_lychee + install_zizmor + install_actionlint +} + +verify_tools() { + local failures=() + + tool_matches_version prek "$PREK_VERSION" || failures+=("prek $PREK_VERSION") + tool_matches_version gitleaks "$GITLEAKS_VERSION" || failures+=("gitleaks $GITLEAKS_VERSION") + command_exists shellcheck || failures+=("shellcheck") + tool_matches_version copier "$COPIER_VERSION" || failures+=("copier $COPIER_VERSION") + tool_matches_version ruff "$RUFF_VERSION" || failures+=("ruff $RUFF_VERSION") + tool_matches_version semgrep "$SEMGREP_VERSION" || failures+=("semgrep $SEMGREP_VERSION") + tool_matches_version mdschema "$MDSCHEMA_VERSION" || failures+=("mdschema $MDSCHEMA_VERSION") + tool_matches_version rumdl "$RUMDL_VERSION" || failures+=("rumdl $RUMDL_VERSION") + tool_matches_version typos "$TYPOS_VERSION" || failures+=("typos $TYPOS_VERSION") + tool_matches_version vale "$VALE_VERSION" || failures+=("vale $VALE_VERSION") + tool_matches_version lychee "$LYCHEE_VERSION" || failures+=("lychee $LYCHEE_VERSION") + tool_matches_version zizmor "$ZIZMOR_VERSION" || failures+=("zizmor $ZIZMOR_VERSION") + tool_matches_version actionlint "$ACTIONLINT_VERSION" || failures+=("actionlint $ACTIONLINT_VERSION") + + [ "${#failures[@]}" -eq 0 ] \ + || fail "setup finished without the pinned toolchain: ${failures[*]}" +} + +main() { + local original_path=$PATH + export PATH="$INSTALL_DIRECTORY:$PATH" + + if ! all_tools_match; then + if command_exists brew; then + install_with_brew + else + [ "$(platform)" = "linux" ] \ + || fail "macOS setup requires Homebrew: https://brew.sh" + install_linux_prerequisites + install_python_tool prek "$PREK_VERSION" + install_python_tool copier "$COPIER_VERSION" + install_python_tool ruff "$RUFF_VERSION" + install_python_tool semgrep "$SEMGREP_VERSION" + install_gitleaks + install_mdschema + install_linters + fi + + verify_tools + fi + + # A consumer's own tools (deck validators, language toolchains) install + # through a sibling hook that the template never overwrites. + if [ -x "$script_directory/install-tools.local" ]; then + "$script_directory/install-tools.local" + fi + + log "Pinned repository check tools are installed." + case ":$original_path:" in + *":$INSTALL_DIRECTORY:"*) ;; + *) log "Add $INSTALL_DIRECTORY to PATH before running repository checks." ;; + esac +} + +main "$@" diff --git a/scripts/tool-versions b/scripts/tool-versions new file mode 100644 index 0000000..7be1aea --- /dev/null +++ b/scripts/tool-versions @@ -0,0 +1,50 @@ +# Repository check tool versions and reviewed archive digests. +PREK_VERSION="0.4.13" +GITLEAKS_VERSION="8.30.1" +COPIER_VERSION="9.18.2" +RUFF_VERSION="0.16.2" +SEMGREP_VERSION="1.172.0" +MDSCHEMA_VERSION="0.15.1" +RUMDL_VERSION="0.2.60" +TYPOS_VERSION="1.49.0" +VALE_VERSION="3.18.0" +LYCHEE_VERSION="0.24.2" +ZIZMOR_VERSION="1.29.0" +ACTIONLINT_VERSION="1.7.12" + +GITLEAKS_DARWIN_AMD64_SHA256="dfe101a4db2255fc85120ac7f3d25e4342c3c20cf749f2c20a18081af1952709" +GITLEAKS_DARWIN_ARM64_SHA256="b40ab0ae55c505963e365f271a8d3846efbc170aa17f2607f13df610a9aeb6a5" +GITLEAKS_LINUX_AMD64_SHA256="551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb" +GITLEAKS_LINUX_ARM64_SHA256="e4a487ee7ccd7d3a7f7ec08657610aa3606637dab924210b3aee62570fb4b080" +MDSCHEMA_DARWIN_AMD64_SHA256="3a365906d5335442ebc5a167f016a74ea07f34befe10bffffdb5a28990c5e2a8" +MDSCHEMA_DARWIN_ARM64_SHA256="1a150979f42f3d8b0a37388d1d24f85ff9fd7db5c253aa567516fd92a2e805f0" +MDSCHEMA_LINUX_AMD64_SHA256="94a150893b0a0852e234f2e349dd19af4ede1b1f43f5e486e2d069e0cc7e605b" +MDSCHEMA_LINUX_ARM64_SHA256="939c1d4fd3e5a553e2095fc404a30db980a92ea8db741be93666bb343eb8bd15" + +# Prose and workflow linters (deck DECK-0010 row). Digests are computed from +# the downloaded release archives; the linux amd64 values match the deck's +# quality workflow. +RUMDL_DARWIN_AMD64_SHA256="bbd0618d6b2e3b4de94d85b228614b45462754a27e62c5560fb3c208e4aa719d" +RUMDL_DARWIN_ARM64_SHA256="f195e442ffa87fca71b3362333fd0c7b4818913ee84421917fa1a9638693b01f" +RUMDL_LINUX_AMD64_SHA256="84fc96856d21203b6482b7284aff5b539b7329a5cc078d7a94c55ae40d88752f" +RUMDL_LINUX_ARM64_SHA256="02a34cc98282f0f0799dcf9d3b5eac0cc84f98cda85df1c6486178dbc5451c54" +TYPOS_DARWIN_AMD64_SHA256="4cecbf653a9fc45f023abf57f4e2e2f6b138c2d2387b09289beacdd3f0ea7bfd" +TYPOS_DARWIN_ARM64_SHA256="8c0e7bd40b2b60c0b0cfe9f74dd814b4d4385c956ce86860f7da9e62d91fdc73" +TYPOS_LINUX_AMD64_SHA256="48bd2d58e02ce713b8c0f1aa239e68ee4f7d8c551013135806e6aed3938d9e10" +TYPOS_LINUX_ARM64_SHA256="85c8b87b22a0fb1da130cd4d495e0beba7f1225eb580933184509e146ec4c509" +VALE_DARWIN_AMD64_SHA256="7ec47dad588bf1421e12f72f15219dcc96e3adf7204918ee86ea81fe8cddab8d" +VALE_DARWIN_ARM64_SHA256="4d7de9bda8379da14cd45048500199c549413187526d0913383ad822866ad43d" +VALE_LINUX_AMD64_SHA256="a6f71a75a12fe689345b754f2412b90367fe33648abb7d200fa19eaadc2dbf6d" +VALE_LINUX_ARM64_SHA256="228325a79f3e6d8b4798d82901f8ed36f6d12b7ff0bad2cc83512dde0c84fbcc" +LYCHEE_DARWIN_AMD64_SHA256="887503a9cff667d322b8d0892b40bf49976eb9507af8483220a3706cdad55978" +LYCHEE_DARWIN_ARM64_SHA256="c9d3740ea2d891854d37116c9fba840f37b6e7c89d330e7db84ac333631c4977" +LYCHEE_LINUX_AMD64_SHA256="1f4e0ef7f6554a6ed33dd7ac144fb2e1bbed98598e7af973042fc5cd43951c9a" +LYCHEE_LINUX_ARM64_SHA256="91a7bd65685da41b90ccb9bc867a3d649a7818042dae04ff405e55a25bddee4c" +ZIZMOR_DARWIN_AMD64_SHA256="648b72ab9941a7f2a8d65d7b68a8e76cef789538c8df3a3950384d38423375b0" +ZIZMOR_DARWIN_ARM64_SHA256="720322fade9e83a9c7953944c438f2ba942636b86b96a8f0e6b15ce94c8a6b6f" +ZIZMOR_LINUX_AMD64_SHA256="dd96df044a6e8538d5f423790f453bdd03d49e5b2bcc38214acc41a2f1297839" +ZIZMOR_LINUX_ARM64_SHA256="415eaa7c0a06479a701b8e44a3e812c1047decc848ec4bede7bd6bbf49f22d20" +ACTIONLINT_DARWIN_AMD64_SHA256="5b44c3bc2255115c9b69e30efc0fecdf498fdb63c5d58e17084fd5f16324c644" +ACTIONLINT_DARWIN_ARM64_SHA256="aba9ced2dee8d27fecca3dc7feb1a7f9a52caefa1eb46f3271ea66b6e0e6953f" +ACTIONLINT_LINUX_AMD64_SHA256="8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8" +ACTIONLINT_LINUX_ARM64_SHA256="325e971b6ba9bfa504672e29be93c24981eeb1c07576d730e9f7c8805afff0c6" diff --git a/scripts/verify-seal b/scripts/verify-seal new file mode 100755 index 0000000..8c5815d --- /dev/null +++ b/scripts/verify-seal @@ -0,0 +1,212 @@ +#!/usr/bin/env bash +# Verify the owner's seals on a pull request head (docs/specs/release-ceremony). +# +# verify-seal open --head SHA --repo OWNER/NAME --base REF --number N \ +# --keys FILE --open-bodies FILE [--since SHA] +# verify-seal merge --head SHA --keys FILE (--ledger FILE | --no-ledger) +# +# The open-seal is an empty commit beneath the head whose subject line is +# `open-seal: {"repo":..,"base":..,"number":N,"tree":..,"nonce":..}`. Only +# the subject is read, so a body that quotes the format cannot shadow a +# seal, and every candidate subject in the range is tried, so a commit +# titled like a seal cannot deny the real one. The nonce is 32 lowercase +# hex characters. The seal names the pull request number, and that pull +# request's body must carry the nonce. A second body that carries the +# nonce is reported, never fatal, so another pull request cannot break +# this one. The merge-seal is the head itself, an empty commit whose +# subject is `merge-seal: {"reviewed_sha":..,"generation":..,"digest":..}`, +# where digest is the sha256 of the ledger artifact the owner saw. +# --open-bodies is a JSON array of `{"number": N, "body": "..."}` for the +# open pull requests. --ledger is the controller's ledger line, a JSON +# object with `reviewed_sha`, `generation`, and `digest`, and the +# merge-seal fails without it unless --no-ledger says the caller accepts +# an unchecked generation and digest. --since bounds the +# open-seal search to commits the base does not reach. +# +# Each command prints one line per rejected candidate, then one line that +# says the seal holds (exit 0) or names what is missing (exit 1). +# Structural checks run before the signature check, so an unsigned fixture +# still exercises them. VERIFY_SEAL_GPG names the gpg program, and git +# verifies through the same one. +set -euo pipefail + +gpg_program=${VERIFY_SEAL_GPG:-gpg} +nonce_pattern='^[0-9a-f]{32}$' +command=${1:-} +[ -n "$command" ] || { printf 'usage: verify-seal open|merge [options]\n' >&2; exit 2; } +shift + +head="" repo="" base="" number="" keys="" open_bodies="" since="" ledger="" no_ledger=false +while [ $# -gt 0 ]; do + case "$1" in + --head) head=$2 ;; + --repo) repo=$2 ;; + --base) base=$2 ;; + --number) number=$2 ;; + --keys) keys=$2 ;; + --open-bodies) open_bodies=$2 ;; + --since) since=$2 ;; + --ledger) ledger=$2 ;; + --no-ledger) no_ledger=true; shift; continue ;; + *) printf 'verify-seal: unknown option %s\n' "$1" >&2; exit 2 ;; + esac + shift 2 +done + +gnupg_home="" +trap '[ -z "$gnupg_home" ] || command rm -rf "$gnupg_home"' EXIT + +fail() { + printf '%s\n' "$1" + exit 1 +} + +require() { + [ -n "$2" ] || fail "verify-seal $command: --$1 is required" +} + +# The subject line without its prefix, or nothing when the subject has none. +seal_json() { + git log -1 --format=%s "$1" | sed -n "s/^$2: //p" +} + +json_field() { + printf '%s' "$1" | jq -r ".$2 // \"\"" 2>/dev/null || printf '' +} + +tree_of() { + git rev-parse "$1^{tree}" +} + +parents_of() { + git rev-list --parents -n 1 "$1" | cut -d ' ' -f 2- +} + +# An empty commit has one parent and that parent's tree. +require_empty() { + local parents count + parents=$(parents_of "$1") + count=$(printf '%s\n' "$parents" | wc -w | tr -d ' ') + [ "$count" = "1" ] || fail "$2 $1 is not an empty commit: it has $count parents" + [ "$(tree_of "$1")" = "$(tree_of "$parents")" ] \ + || fail "$2 $1 is not an empty commit: its tree differs from its parent's" +} + +# One keyring for every signature check in this run. +import_keys() { + [ -z "$gnupg_home" ] || return 0 + gnupg_home=$(mktemp -d "${RUNNER_TEMP:-${TMPDIR:?TMPDIR must be set}}/verify-seal-gpg.XXXXXX") + chmod 0700 "$gnupg_home" + "$gpg_program" --homedir "$gnupg_home" --batch --import "$keys" >/dev/null 2>&1 \ + || fail "could not import trusted OpenPGP keys from $keys" +} + +# The signature must verify, and its fingerprint must be one KEYS carries. +require_signature() { + local allowed output signer + allowed=$("$gpg_program" --homedir "$gnupg_home" --batch --with-colons --fingerprint \ + | awk -F: '$1 == "fpr" { print $10 }') + [ -n "$allowed" ] || fail "$2 $1: $keys carries no OpenPGP fingerprint" + output=$(GNUPGHOME="$gnupg_home" git -c gpg.format=openpgp -c gpg.program="$gpg_program" \ + verify-commit --raw "$1" 2>&1) \ + || fail "$2 $1 has no valid signature: $(printf '%s\n' "$output" | tail -n 1)" + signer=$(printf '%s\n' "$output" | awk '/^\[GNUPG:\] VALIDSIG / { print $3; exit }') + [ -n "$signer" ] || fail "$2 $1 produced no valid signature fingerprint" + printf '%s\n' "$allowed" | grep -Fxq "$signer" \ + || fail "$2 $1 was signed by fingerprint $signer, which KEYS does not carry" +} + +# Every check on one open-seal candidate. Runs in a subshell so a failure +# rejects the candidate and the search moves on. +check_open_candidate() { + local seal=$1 json seal_repo seal_base seal_number seal_tree nonce body others + json=$(seal_json "$seal" open-seal) + seal_repo=$(json_field "$json" repo) + seal_base=$(json_field "$json" base) + seal_number=$(json_field "$json" number) + seal_tree=$(json_field "$json" tree) + nonce=$(json_field "$json" nonce) + [ -n "$seal_repo" ] && [ -n "$seal_base" ] && [ -n "$seal_number" ] && [ -n "$seal_tree" ] && [ -n "$nonce" ] \ + || fail "open-seal $seal is malformed: expected a JSON subject with repo, base, number, tree, and nonce" + printf '%s' "$nonce" | grep -Eq "$nonce_pattern" \ + || fail "open-seal $seal carries nonce $nonce, which is not 32 lowercase hex characters" + [ "$seal_repo" = "$repo" ] || fail "open-seal $seal binds repository $seal_repo, not $repo" + [ "$seal_base" = "$base" ] || fail "open-seal $seal binds base $seal_base, not $base" + [ "$seal_number" = "$number" ] || fail "open-seal $seal binds pull request #$seal_number, not #$number" + require_empty "$seal" open-seal + [ "$seal_tree" = "$(tree_of "$seal")" ] \ + || fail "open-seal $seal names tree $seal_tree, which is not the sealed commit's tree" + body=$(jq -r --argjson number "$number" '[.[] | select(.number == $number) | .body // ""] | first // ""' "$open_bodies") \ + || fail "open-seal $seal: could not read the open pull request bodies from $open_bodies" + printf '%s' "$body" | grep -Fq -- "$nonce" \ + || fail "open-seal $seal: the body of pull request #$number does not carry nonce $nonce" + others=$(jq -r --argjson number "$number" --arg nonce "$nonce" \ + '[.[] | select(.number != $number and ((.body // "") | contains($nonce))) | .number | tostring] | join(", #")' "$open_bodies") \ + || others="" + [ -z "$others" ] || printf 'open-seal %s: nonce %s also appears in pull request #%s, which cannot use it\n' "$seal" "$nonce" "$others" + require_signature "$seal" open-seal + printf 'open-seal ok: %s binds %s onto %s for #%s with nonce %s\n' "$seal" "$seal_tree" "$base" "$number" "$nonce" +} + +verify_open() { + require head "$head"; require repo "$repo"; require base "$base" + require number "$number"; require keys "$keys"; require open-bodies "$open_bodies" + local candidates seal output rejected="" + candidates=$(git log --format='%H %s' "$head" ${since:+"^$since"} | awk '$2 == "open-seal:" { print $1 }') + [ -n "$candidates" ] || fail "open-seal missing: no commit beneath $head carries an open-seal subject" + import_keys + while read -r seal; do + if output=$(check_open_candidate "$seal"); then + [ -z "$rejected" ] || printf '%s\n' "$rejected" + printf '%s\n' "$output" + return 0 + fi + rejected=${rejected:+$rejected$'\n'}$output + done <<< "$candidates" + fail "$rejected" +} + +verify_merge() { + require head "$head"; require keys "$keys" + local json reviewed generation digest parents ledger_sha ledger_generation ledger_digest + json=$(seal_json "$head" merge-seal) + [ -n "$json" ] || fail "merge-seal missing: head $head carries no merge-seal subject" + reviewed=$(json_field "$json" reviewed_sha) + generation=$(json_field "$json" generation) + digest=$(json_field "$json" digest) + [ -n "$reviewed" ] && [ -n "$generation" ] && [ -n "$digest" ] \ + || fail "merge-seal $head is malformed: expected a JSON subject with reviewed_sha, generation, and digest" + [[ "$digest" =~ ^[0-9a-f]{64}$ ]] \ + || fail "merge-seal $head names digest $digest, not a sha256" + require_empty "$head" merge-seal + parents=$(parents_of "$head") + [ "$parents" = "$reviewed" ] \ + || fail "merge-seal $head has parent $parents, not reviewed_sha $reviewed" + if [ -n "$ledger" ]; then + ledger_sha=$(jq -r '.reviewed_sha // ""' "$ledger" 2>/dev/null) \ + || fail "merge-seal $head: could not read the ledger $ledger" + ledger_generation=$(jq -r '.generation // ""' "$ledger") + [ "$ledger_sha" = "$reviewed" ] \ + || fail "merge-seal $head names reviewed_sha $reviewed, but the ledger holds $ledger_sha" + [ "$ledger_generation" = "$generation" ] \ + || fail "merge-seal $head names generation $generation, but the ledger is at generation $ledger_generation" + ledger_digest=$(jq -r '.digest // ""' "$ledger") + [ -n "$ledger_digest" ] \ + || fail "merge-seal $head names digest $digest, but the ledger line carries no digest" + [ "$ledger_digest" = "$digest" ] \ + || fail "merge-seal $head names digest $digest, but the ledger line carries $ledger_digest" + elif [ "$no_ledger" = true ]; then + printf 'merge-seal %s: --no-ledger given, generation %s and digest %s are unchecked\n' "$head" "$generation" "$digest" + else + fail "merge-seal $head: no ledger to check generation $generation against, pass --ledger or --no-ledger" + fi + import_keys + require_signature "$head" merge-seal + printf 'merge-seal ok: %s seals reviewed_sha %s at generation %s, ledger %s\n' "$head" "$reviewed" "$generation" "$digest" +} + +case "$command" in + open) verify_open ;; + merge) verify_merge ;; + *) printf 'verify-seal: unknown command %s\n' "$command" >&2; exit 2 ;; +esac diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..46fa06e --- /dev/null +++ b/typos.toml @@ -0,0 +1,16 @@ +# typos configuration. KEYS holds base64 key material. Sidecars and +# third-party notices are not this repository's prose. +[files] +extend-exclude = [ + "KEYS", + ".provenance", + ".claude", + ".codex", + ".gemini", + ".opencode", + "**/THIRD_PARTY_NOTICES.md", +] + +[default] +# Mermaid node identifiers such as BA in fenced diagrams. +extend-ignore-re = ["[A-Z]{2} ?-->", "--> ?[A-Z]{2}", "[A-Z]{2}\\[", "\"fpr\""]