diff --git a/AUDIT.md b/AUDIT.md index a26c1cb89..7cd6dc594 100644 --- a/AUDIT.md +++ b/AUDIT.md @@ -29,9 +29,9 @@ flowchart TD This audit is not occasional. Run it whenever you **create, adopt, or materially change** a fleet repo, and on demand for any known repo: -- **A full sweep opens with a fleet membership check, not a per-repo one.** `spec/audit.py`, run with no repo names, first lists every non-fork repository the registry `owner` actually owns on GitHub and diffs it against `registry/repos.json`. A repo that exists but carries no entry is invisible to every other check in this file. That is because all of them iterate the registry and never look past it. So this is the only place that gap is caught. The check also reconciles one field: a registry `status: "archived"` must agree with GitHub's own archived flag, in either direction. A name-filtered run or `--issue` skips it, since those are scoped to repos already known to the registry. Run this as `gh auth login` for the owner's own account. That is because a fine-grained PAT scoped to "selected repositories" returns an incomplete list with no error. So the sweep would read clean while some repos were never inspected. -- **Onboarding a repo is complete only when it either passes this audit or has a hub-committed `reports//audit.md` plus a tracking issue** enumerating every residual delta. Passing means operational on every applicable check. A repo that is partially set up but never audited is itself a **defect**, the exact state this process prevents. The create-to-conformance counterpart is [`STANDUP.md`][standup]. Because both read the same manifests, a repo stood up by that file passes this audit by construction. -- **Touching a repo** (any conformance-affecting change) ends by re-running the applicable checks and **reconciling the registry entry to reality**: `status`, `types`, `releaseTrigger`, `workflowModel`, `driftNotes`. The registry records reality, not intent. [`spec/validate.py`][validate] proves the catalog is self-consistent, not that it matches the live repo. Closing that gap is this audit's job. The deterministic subset is mechanized in [`spec/audit.py`][audit-runner]. It covers settings, rulesets, secret names, file presence, and file names. It also covers per-scope Markdown section presence, workflow interface conformance, verbatim content, hub-hosted files a repo carries, and branch facts. The runner is owner-initiated, run on demand when onboarding a repo, on suspected drift, or before fleet-wide changes. A required section missing from a carried Markdown file is a **drift finding**, not a letter. That is because a heading rename reads as missing and equivalence is judged by hand. A carried `interface` workflow (spec/fidelity-model.md) is checked by name and wiring (required jobs, the ruleset-bound check name, the artifact-name handoff, and the forbidden `artifact-ids:` fork). All of those checks are at **drift**, since the body is owned and a rename is a hint to verify. A carried `verbatim` unit is content-hashed against the hub's canonical after line-ending normalization. Such a unit is either a whole file (`.markdownlint-cli2.jsonc`) or a canonical workflow job region (the `github-release` job). A mismatch is classified **stale** (matches a past hub revision, re-vendor) or **modified** (matches none, the repo changed fixed content). Both are at **drift**, since equivalence is intent-governed and a byte diff is a hint to review. A carried `intent` unit gets one advisory beyond presence, a last-modified comparison. That advisory marks a copy as possibly trailing, at **drift**, and `spec/fidelity-model.md` states which changes raise it. That is a hint rather than proof, since a copy touched without reconciling reads current and content is never judged. A plain-JSON copy of a unit declaring `repoOwnedKeys` is the exception, judged by the leaves it does not own and reported whatever the dates read. A content scan also looks for a version literal. Such a literal is a three-part version, a full 40-character commit SHA, or an abbreviated one of 7 to 12 characters mixing digits and letters. One found in `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, or `WORKFLOW.md`, outside the verbatim sections downstream and across the whole file in the hub, is a **drift** finding. That is because a pin's value in prose goes stale at the next bump and every other literal reads like one. +- **A full sweep opens with a fleet membership check, not a per-repo one.** `spec/audit.py`, run with no repo names, first lists every non-fork repository the registry `owner` actually owns on GitHub and diffs it against `registry/repos.json`. A repo that exists but carries no entry is invisible to every other check in this file. That is because all of them iterate the registry and never look past it. So this is the only place that gap is caught. The check also reconciles one field: a registry `status: "archived"` must agree with GitHub's own archived flag, in either direction. A name-filtered run or `--issue` skips it, since those are scoped to repos already known to the registry. Authenticate `gh` with a token that reaches every repository the owner has, never a fine-grained PAT scoped to "selected repositories". Such a token returns an incomplete list with no error, so the sweep would read clean while some repos were never inspected. The runner refuses a login other than the registry owner, but it cannot see a token's scope. +- **Onboarding a repo is complete only when it either passes this audit or has a hub-committed `reports//audit.md` plus a tracking issue** enumerating every residual delta. Section 8 defines `` in that path. Passing means operational on every applicable check. A repo that is partially set up but never audited is itself a **defect**, the exact state this process prevents. The create-to-conformance counterpart is [`STANDUP.md`][standup]. Because both read the same manifests, a repo stood up by that file passes this audit by construction. +- **Touching a repo** (any conformance-affecting change) ends by re-running the applicable checks and **reconciling the registry entry to reality**: `status`, `types`, `releaseTrigger`, `workflowModel`, `driftNotes`. The registry records reality, not intent. [`spec/validate.py`][validate] proves the catalog is self-consistent, not that it matches the live repo. Closing that gap is this audit's job. The deterministic subset is mechanized in [`spec/audit.py`][audit-runner]. It covers settings, rulesets, secret names, file presence, and file names. It also covers per-scope Markdown section presence, workflow interface conformance, verbatim content, hub-hosted files a repo carries, and branch facts. The runner is owner-initiated, run on demand when onboarding a repo, on suspected drift, or before fleet-wide changes. A required section missing from a carried Markdown file is a **drift finding**, not a letter. That is because a heading rename reads as missing and equivalence is judged by hand. A carried `interface` workflow (`spec/fidelity-model.md`) is checked by name and wiring. That covers its required jobs, the ruleset-bound check name, and the tokens and event types its [`spec/files.json`][files] contract names. Where they apply, the checks also cover the workflow's `concurrency:` block and the `workflow-model` and `python-directories` inputs it passes its hub task. All of those checks are at **drift**, since the body is owned and a rename is a hint to verify. A carried `verbatim` unit is content-hashed against the hub's canonical after line-ending, action-pin, and job-`needs:` normalization. Such a unit is either a whole file (`.markdownlint-cli2.jsonc`) or a `## heading` section of a carried Markdown file (the verbatim sections of `AGENTS.md` and `GOVERNANCE.md`). A mismatch is classified **stale** (matches a past hub revision, re-vendor) or **modified** (matches none, the repo changed fixed content). Both are at **drift**, since equivalence is intent-governed and a byte diff is a hint to review. A carried `intent` unit gets one advisory beyond presence, a last-modified comparison. That advisory marks a copy as possibly trailing, at **drift**, and `spec/fidelity-model.md` states which changes raise it. That is a hint rather than proof, since a copy touched without reconciling reads current. Content only ever clears a copy, since one hashing equal to the hub's file for it is current however old its last commit. A plain-JSON copy of a unit declaring `repoOwnedKeys` is the exception, judged by the leaves it does not own and reported whatever the dates read. The advisory does not run against the hub itself. A content scan also looks for a version literal. Such a literal is a three-part version, a full 40-character commit SHA, or an abbreviated one of 7 to 12 characters mixing digits and letters. One found in `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, or `WORKFLOW.md`, outside the verbatim sections downstream and across the whole file in the hub, is a **drift** finding. That is because a pin's value in prose goes stale at the next bump and every other literal reads like one. **Verify the host before running any hub tool.** The tools carry version floors. A host below one answers `--version`, looks healthy, and produces a wrong answer. So a clean audit run from a broken host is a clean-looking result rather than a result. @@ -39,7 +39,7 @@ This audit is not occasional. Run it whenever you **create, adopt, or materially python3 scripts/host_gate.py --repo "" # run from a hub checkout, floors from spec/host-tools.json ``` -Pass `--repo`, since the gate reads the target's own `host-tools.json` relative to it and defaults to the working directory. Omitting it does not read the target's declaration at all, so every floor that repo adds goes unapplied. The run reports nothing about the omission. A finding is a **host** misconfiguration rather than a repo one, and [`docs/host-setup.md`][host-setup] is the contract it checks. +Pass `--repo`, since the gate reads the target's own `host-tools.json` relative to it and defaults to the working directory. Omitting it does not read the target's declaration at all, so every floor that repo adds goes unapplied. The run reports nothing about the omission. A `--repo` naming a path that is not the target's checkout is just as silent. So check that the run prints a `layered N local entry(s)` note naming the target's own `host-tools.json`, the only sign its declaration was read. A finding is a **host** misconfiguration rather than a repo one, and [`docs/host-setup.md`][host-setup] is the contract it checks. ## 1. Scope and Ground-Truth Branch diff --git a/spec/fidelity-model.md b/spec/fidelity-model.md index 15a5d77db..cee9207fa 100644 --- a/spec/fidelity-model.md +++ b/spec/fidelity-model.md @@ -11,7 +11,7 @@ Carried content is a class with virtual functions. The **fixed** part is the int Each [`spec/files.json`][files] entry declares one `fidelity`, defaulting to `presence`. - **presence** - the unit exists (a file, or a Markdown section heading). The audit's baseline check. -- **intent** - carried faithfully but judged by meaning, not bytes. A downstream copy legitimately differs (a governed divergence or a paraphrase), and equivalence is a human call via `intentRef`. The audit asserts presence, plus a last-modified staleness advisory at drift. A hub canonical changing after the copy's own last commit marks the copy as possibly trailing, a hint rather than proof. Content is never judged, except that a `repoOwnedKeys` unit's JSON is read for its fleet-owned values. That "changing" walks past a revision whose diff is normalized-only (the same line-ending, action-pin, and job-needs normalization as verbatim below). So a Dependabot pin bump on a workflow file does not by itself mark every carrier as trailing. An `intentRef` naming an `#anchor` is dated by the section that anchor names, so an edit elsewhere in its document marks nothing. An `intentRef` naming another file dates the copy by that file. A unit naming a `reference` is dated by that file instead. An anchor naming no heading dates the whole file. A unit naming `repoOwnedKeys` lists the dotted JSON keys of that reference whose value the repository chooses, such as the SDK line in `global.json`. A copy holding every other leaf its reference holds is current whatever those keys hold, and a leaf the copy adds is its own too. A copy missing or changing one of those other leaves is reported as trailing, whatever the dates read. So a repository on another line than the hub's baseline never reads as trailing it, unless its copy is not plain JSON. A key the reference drops goes unreported. A registry `driftNote` naming `(files.intent)` acknowledges a copy verified against the change the advisory cites, per `AUDIT.md` section 7, until that canonical changes again. +- **intent** - carried faithfully but judged by meaning, not bytes. A downstream copy legitimately differs (a governed divergence or a paraphrase), and equivalence is a human call via `intentRef`. The audit asserts presence, plus a last-modified staleness advisory at drift. A hub canonical changing after the copy's own last commit marks the copy as possibly trailing, a hint rather than proof. Content is never judged, except that a copy hashing equal to the hub's file is current. That file is its canonical, or the hub's own copy at its path where the unit names no `reference`. A `repoOwnedKeys` unit's JSON is also read for its fleet-owned values. That "changing" walks past a revision whose diff is normalized-only (the same line-ending, action-pin, and job-needs normalization as verbatim below). So a Dependabot pin bump on a workflow file does not by itself mark every carrier as trailing. An `intentRef` naming an `#anchor` is dated by the section that anchor names, so an edit elsewhere in its document marks nothing. An `intentRef` naming another file dates the copy by that file. A unit naming a `reference` is dated by that file instead. An anchor naming no heading dates the whole file. A unit naming `repoOwnedKeys` lists the dotted JSON keys of that reference whose value the repository chooses, such as the SDK line in `global.json`. A copy holding every other leaf its reference holds is current whatever those keys hold, and a leaf the copy adds is its own too. A copy missing or changing one of those other leaves is reported as trailing, whatever the dates read. So a repository on another line than the hub's baseline never reads as trailing it, unless its copy is not plain JSON. A key the reference drops goes unreported. A registry `driftNote` naming `(files.intent)` acknowledges a copy verified against the change the advisory cites, per `AUDIT.md` section 7, until that canonical changes again. - **verbatim** - byte-identical to the hub's canonical after line-ending, action-pin, and job-needs normalization. The audit content-hashes the downstream copy against canonical. It applies to a whole file, a workflow job region, or a Markdown section region. A job region is a job selected by key, and a section region is a `## heading` block selected by name. The section granularity lets one file be **intent overall while a few of its sections are verbatim**. A universal rule block stays byte-identical fleet-wide even though the rest of the document is a repo-adapted paraphrase. So a stale section or a missing rule is caught while its heading still passes the presence check. - **interface** - an overridable body that must honor a named contract. The audit checks the contract by name and wiring, never the body. @@ -21,14 +21,14 @@ Fidelity is a declared field defaulting to `presence`, never inferred from `whol ## Why Each Unit Sits Where It Does -- **verbatim** - `.markdownlint-cli2.jsonc`, the `github-release` job region of the release task, and the universal rule sections of `AGENTS.md`. The config is fleet-generic. A repository's own exclusions go in a nested config beside the content they exclude rather than in this file. So there is no governed divergence. The job region is the canonical orchestration a repo must not fork. The `AGENTS.md` sections are fleet-law with no repo-specific content (no SHAs, no `ptr727/` references). In them a paraphrase or a missing rule is a defect, not an adaptation. Which `AGENTS.md` sections are verbatim and which stay intent (the few that describe one repo) is defined in [section-model.md][section-model]. -- **interface** - the release, PR, and bot workflows. Their fixed contract is the job and check names plus the artifact handoff. For a caller stub the contract is the hub task it reaches and the secrets it maps. It also covers any activity type the hub task needs the stub to subscribe to. The leaf build jobs, by contrast, are owned. See [`WORKFLOW.md`][workflow] "Two Layers: Orchestration vs Build" and [`docs/reusable-workflows.md`][reusable-workflows]. +- **verbatim** - `.markdownlint-cli2.jsonc` and the universal rule sections of `AGENTS.md` and `GOVERNANCE.md`. The config is fleet-generic. A repository's own exclusions go in a nested config beside the content they exclude rather than in this file. So there is no governed divergence. Those sections are fleet-law with no repo-specific content (no SHAs, no `ptr727/` references). In them a paraphrase or a missing rule is a defect, not an adaptation. Which sections are verbatim and which stay intent (the few that describe one repo) is defined in [section-model.md][section-model]. +- **interface** - the release, PR, bot, and site-deploy workflows. Their fixed contract is the job and check names. For a caller stub the contract is the hub task it reaches, the secrets it maps, and any other token its contract requires or forbids. Where those checks apply, it also covers the caller's `concurrency:` block and its `workflow-model` and `python-directories` inputs. It also covers any activity type the hub task needs the stub to subscribe to. The leaf build jobs, by contrast, are owned. See [`WORKFLOW.md`][workflow] "Two Layers: Orchestration vs Build" and [`docs/reusable-workflows.md`][reusable-workflows]. - **intent** - `.editorconfig`, `.gitattributes`, `cspell.json`, and the carried docs `CODESTYLE.md` / `WORKFLOW.md` / `AUDIT.md` / `.github/copilot-instructions.md`. The `[*] end_of_line` default and path pins vary by platform in `.editorconfig` and `.gitattributes`. The words list and file scope vary in `cspell.json`. The carried docs are judged by meaning. - **presence** - `README.md`, `HISTORY.md`, `.gitignore`, and the per-repo config that only needs to exist. ## The Workflow Override Seam Contract -The fixed interface of a workflow is stated in [`WORKFLOW.md`][workflow] ("Two Layers: Orchestration vs Build" and "The Seam Contract") and [`GOVERNANCE.md`][governance] ("Workflow YAML Conventions"). The `interface` check enforces it by name and structure. It enforces the ruleset-bound required check `name: Check pull request workflow status job`, given only on a `pull_request` run where any other event also triggers the workflow. It also enforces the `github-release` and `get-version` job keys, and the `release-asset--` artifact-name handoff. It also enforces that `github-release` collects assets by `pattern:` / `merge-multiple:` and never by an `artifact-ids:` that names a build job's output. A repo owns the leaf `build--task` job list, its `needs` targets, and its paths-filter, and none of those are checked. +The fixed interface of a workflow is stated in [`WORKFLOW.md`][workflow] ("Two Layers: Orchestration vs Build" and "The Seam Contract") and [`GOVERNANCE.md`][governance] ("Workflow YAML Conventions"). The `interface` check enforces it by name and structure. It enforces the ruleset-bound required check `name: Check pull request workflow status job`, given only on a `pull_request` run where any other event also triggers the workflow. A repo owns the leaf `build--task` job list, its `needs` targets, and its paths-filter, and none of those are checked. Once a workflow's job graph moves into the hub, the carried unit is a caller stub rather than the job graph itself. The contract moves with it. In that case `publish-release.yml`'s `interface` check asserts the `plan`, `validate`, and `publish` job keys. It also asserts that `plan` and `publish` each name their hub task by token (`publish-plan-task.yml`, `build-release-task.yml`), never the build job list. A carried `build-release-task.yml` used to expose that list. @@ -48,7 +48,7 @@ So a local rule edit to `CODESTYLE.md` or `WORKFLOW.md`, both `intent` and whole ## Normalization -A verbatim check compares content by hash after **line-ending, action-pin, and job-needs normalization**. EOL variance is governed by the line-ending rules. A `uses: @` pin (with its trailing `# vN` comment) is Dependabot-owned and bumped per repo. A job's `needs:` list is pruned per repo to its vendored targets (an unvendored name fails the workflow to load). So all three are governed drift rather than a fidelity deviation. This keeps a verbatim workflow job region (the `github-release` job) from flagging on a routine action bump or a legitimate needs-prune. The normalization still catches a real structural fork. It does **not** mask placeholders: a verbatim unit carries none. A file that declares a `placeholders` list is fidelity `intent`, judged by hand and never hashed. Masking could not serve a hash anyway. A downstream copy holds the substituted value (`ptr727`), not the token (``), so masking the token in the canonical alone would guarantee a mismatch. A verbatim unit that ever needed a per-repo substitution would require template-matching, not this content hash. Template-matching means the canonical as a pattern and the copy as an instance. None does today. +A verbatim check compares content by hash after **line-ending, action-pin, and job-needs normalization**. EOL variance is governed by the line-ending rules. A `uses: @` pin (with its trailing `# vN` comment) is Dependabot-owned and bumped per repo. A job's `needs:` list is pruned per repo to its vendored targets (an unvendored name fails the workflow to load). So all three are governed drift rather than a fidelity deviation. This keeps a verbatim workflow job region from flagging on a routine action bump or a legitimate needs-prune. The normalization still catches a real structural fork. It does **not** mask placeholders: a verbatim unit carries none. A file that declares a `placeholders` list is fidelity `intent`, judged by hand and never hashed. Masking could not serve a hash anyway. A downstream copy holds the substituted value (`ptr727`), not the token (``), so masking the token in the canonical alone would guarantee a mismatch. A verbatim unit that ever needed a per-repo substitution would require template-matching, not this content hash. Template-matching means the canonical as a pattern and the copy as an instance. None does today. `verbatim-tree` applies no normalization. It compares file bytes because a fully owned tree has no per-repository substitutions or Dependabot-owned regions.