From c045c0a5d3e9e3ab6e4bf07ea8ce6b61491844d3 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 25 Nov 2026 19:22:41 -0800 Subject: [PATCH 1/5] Re-Vendor the Instruction Set from the Hub Carries the 16 stale verbatim sections of AGENTS.md and GOVERNANCE.md with carry.py apply-sections. Then three-way merges the hub's CODESTYLE.md changes since the last resync base, keeping the PlexCleaner .NET and Python sections. That brings in Toolchain Versions, the re-raise interrupt rule, the POSIX sh adaptation, exit status 64, and the PowerShell section, which the file carries whole. The AGENTS.md preamble takes the hub's language-section sentence. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 22 +++++++++-------- CODESTYLE.md | 65 +++++++++++++++++++++++++++++++++--------------- GOVERNANCE.md | 68 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 100 insertions(+), 55 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d20d1617..50ddc05c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ **PlexCleaner** is a .NET 10 CLI utility that optimizes media files for Direct Play in Plex, Emby, and Jellyfin, converting containers to MKV, re-encoding incompatible codecs, managing tracks and language tags, verifying and repairing media, and monitoring folders for changes. It orchestrates external media tools (FFmpeg, HandBrake, MkvToolNix, MediaInfo, and 7-Zip) through CLI wrappers. It ships two release targets, a multi-arch Docker image on Docker Hub (`ptr727/plexcleaner`) and standalone executables attached to GitHub Releases, and consumers pull from Docker Hub or the GitHub releases on their own cadence. The repo also holds an xUnit test project (`PlexCleanerTests/`), optional process plugins (`Plugins/`), and a Python regression-test tooling subtree (`RegressionTests/`). -This file is the entry point every coding agent reads first. It holds the bootstrap that says where the canonical rules live and which procedure to follow for the state this repository is actually in. It also holds the rules for managing context and delegation, which apply to every task, and a map of where every other rule lives. It holds nothing else. The rule text itself is in [`GOVERNANCE.md`](./GOVERNANCE.md), one section per topic. Code style lives in [`CODESTYLE.md`](./CODESTYLE.md), and the CI/CD workflow contract in [`WORKFLOW.md`](./WORKFLOW.md). `CODESTYLE.md` holds a General section plus per-language sections for .NET, Python, and Shell. The language sections are packaged as the `dotnet-codestyle`, `python-codestyle`, and `shell-codestyle` Skills. The architecture, processing pipeline, and design patterns live in [`ARCHITECTURE.md`](./ARCHITECTURE.md). The local verification, runbooks, and tool usage live in [`OPERATIONS.md`](./OPERATIONS.md). +This file is the entry point every coding agent reads first. It holds the bootstrap that says where the canonical rules live and which procedure to follow for the state this repository is actually in. It also holds the rules for managing context and delegation, which apply to every task, and a map of where every other rule lives. It holds nothing else. The rule text itself is in [`GOVERNANCE.md`](./GOVERNANCE.md), one section per topic. Code style lives in [`CODESTYLE.md`](./CODESTYLE.md), and the CI/CD workflow contract in [`WORKFLOW.md`](./WORKFLOW.md). `CODESTYLE.md` holds a General section plus per-language sections for .NET, Python, Shell, and PowerShell. The .NET, Python, and Shell sections are packaged as the `dotnet-codestyle`, `python-codestyle`, and `shell-codestyle` Skills. The architecture, processing pipeline, and design patterns live in [`ARCHITECTURE.md`](./ARCHITECTURE.md). The local verification, runbooks, and tool usage live in [`OPERATIONS.md`](./OPERATIONS.md). Treat this file and `GOVERNANCE.md` as authoritative for cross-cutting rules, and do not restate their rules elsewhere. Per the `skill-lifecycle` Skill, a Skill that needs a rule's full text to work in isolation carries it as a generated include, never a copy. The include comes from the rule's home, so the text cannot drift undetected. This project's own conventions and behavioral contracts live in the topical doc that owns them, [`ARCHITECTURE.md`](./ARCHITECTURE.md) for the processing pipeline and design patterns and [`CODESTYLE.md`](./CODESTYLE.md) for how the code is written, and **never** in [`.github/copilot-instructions.md`](./.github/copilot-instructions.md), because that file targets GitHub Copilot / VS Code specifically while the rest are agent-agnostic, so any rule a reviewer must honor has to live outside it to be provider-independent. A section of its own in this file is not the alternative. An undeclared section here is drift to reconcile rather than a local liberty. Copilot review *mechanics* are owned by `.github/copilot-instructions.md`, and `GOVERNANCE.md` "PR Review Etiquette" delegates them there explicitly. High-level summaries in other docs (for example the README's Contributing section) are allowed when they link back here, without duplicating the rules themselves. @@ -43,16 +43,16 @@ An agent session is billed on the context it carries, not the work it does. Ever ### Reading -- **Map a large file, then read one range.** For anything over about 200 lines, list the headings with `grep -n '^## '` first and read only the range the task needs. Read the section, not the file that contains it. +- **Map a large file, then read one range.** For anything over about 200 lines, list the headings with `grep -nE '^#+ '` first and read only the range the task needs. Read the section, not the file that contains it. - **Prefer an in-place edit to a whole-file rewrite.** Rewriting a file bills its full content again on top of what the read already cost. ### Commands -- **Bound output at the source.** Write every command so its output is the answer, not the haystack. A `--jq` projection on an API call does that. So do a count or files-only flag on a search, a summary flag on a diff, and an explicit cap on anything unbounded. A command whose output you then skim is a command that should have been narrower. +- **Bound output at the source.** Write every command so its output is the answer, not the haystack. A `--jq` projection on a `gh` API call does that. So do a count or files-only flag on a search, a summary flag on a diff, and an explicit cap on anything unbounded. A command whose output you then skim is a command that should have been narrower. - **Keep a long query in a file, not in the command.** A heredoc re-typed on every call costs its own length in context each time, often more than the answer it retrieves. - **Keep generated caches outside the checkout when the executor restricts writes.** Give each task a cache directory under a writable temporary root. Point tools such as uv and ruff there through their own cache variables. Never repurpose `HOME` or an agent's configuration directory to make a tool run. - **Report an execution boundary separately from a check finding.** A denied path, network request, or Docker socket says the check did not run. Preserve that failure, then use the executor's approval mechanism for the required rerun. Request the narrowest reusable command prefix the executor supports. Report the rerun's result as the verification evidence. -- **Bound every probe, and prove it ended.** A throwaway probe or test harness runs under `timeout`, and one that can recurse or fan out also runs under a task and memory cap. Start it in a process group of its own, as `setsid --wait timeout ` on Linux, and end it by that group with `kill -- -`. Without `--wait`, `setsid` returns at once when its caller leads a process group, and the probe runs on detached. A `pkill -f` pattern that matches nothing exits 1 and kills nothing. Then confirm with `pgrep` that nothing from any earlier run survives, since a later clean run proves nothing about an earlier one. Never suppress a cleanup command's output or exit status. A command the harness moved to the background, where no background job was intended, is stopped and confirmed gone before work continues. +- **Bound every probe, and prove it ended.** A throwaway probe or test harness runs under `timeout`, and one that can recurse or fan out also runs under a task and memory cap. Start it in a process group of its own, as `setsid --wait timeout "" ""` on Linux. `` stands for the probe's command and its own arguments, which replace its quotes so each stays a word of its own. End it by that group with `kill -- "-"`. Without `--wait`, `setsid` returns at once when its caller leads a process group, and the probe runs on detached. A `pkill -f` pattern that matches nothing exits 1 and kills nothing. Then confirm with `pgrep` that nothing from any earlier run survives, since a later clean run proves nothing about an earlier one. Never suppress a cleanup command's output or exit status. A command the harness moved to the background, where no background job was intended, is stopped and confirmed gone before work continues. ### Model Tiers @@ -61,7 +61,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i - **`frontier`** is the fleet's default reasoning tier, for orchestrating, rule text, design, spec logic, and adversarial review. It is not the most capable model available, which is `highest`. - **`standard`** is ordinary implementation and driving a pull request. Judging a review finding is never mechanical, however often it repeats, so it runs at `standard` or above. A `standard` driver's evidence-backed decline of a finding raised on its pull request stands, since that pull request's reviewers and its merge gate check it. - **`bulk`** is the cheapest model that does the work correctly. It is for high fan-out mechanical work, such as an extraction or a status check. -- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set, and otherwise at the session's own. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. A session never reaches for it because a task looks hard. +- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set. Otherwise it runs at the default the host's agent-safety kit sets, which is the `frontier` model. On a host without the kit it runs at the session's own. That default does not reach every agent type a tool builds in. On Claude Code the `Explore` and `Plan` types still take the session's model, so the kit refuses a dispatch of either that names no model. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. The kit's default is a backstop for a dispatch that forgot its tier, never a reason to leave one out. A session never reaches for it because a task looks hard. | Tool | `highest` | `frontier` | `standard` | `bulk` | | --- | --- | --- | --- | --- | @@ -70,26 +70,28 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i Each cell is the name that tool's subagent dispatch takes, which follows the latest model of its family. A dispatch on a tool with no row here, or on one that cannot name a model per subagent, names no model. - **A tier resolves only through this table.** A word such as "frontier", "strongest", or "most capable" never resolves to `highest`. The industry's "frontier model" is the opposite of what this tier means here. A session that cannot see this table names no model rather than guessing one. -- **An orchestrating seat runs at `frontier` and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. +- **An orchestrating seat runs at `frontier`, or at `highest` where the maintainer chose that for the session, and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. ### Delegation - **Delegate exploration, keep judgment.** A subagent starts from an empty context and returns only its conclusion. So a wide search, a multi-file audit, or a "which of these is affected" question costs a fraction of the same work inline. Delegate when the finding compresses to a short answer, and stay inline when the intermediate detail drives the next edit. - **Match the model tier to the judgment, not to the diff size.** Mechanical work (a known-shape edit repeated across files, an extraction, a status check, a lint fix) runs at `bulk`, at the lowest effort that holds. State the tier in the delegation itself rather than accepting the default. A change to a gate, a ruleset, a release condition, or a carried governance section is a design change however small it looks. - **Never tier down the seat holding the judgment.** Governance wording, spec logic, rulesets, and repository visibility are fleet-wide and durable when wrong. Tier the subagents, not the main thread. +- **A session above the tier its work calls for keeps the judgment and dispatches the execution.** A session the maintainer launched on `highest` is the ordinary case, and so is a `frontier` session handed implementation. Such a session spends its own turns on what its tier is for. It decides the design, the seams, and the rulings, and it solves what a cheaper seat could not. It writes those decisions into the brief, so the worker executes a decision rather than making one. Everything else it dispatches at the tier "Model Tiers" names for that work, a Skill's own procedure included. So a `highest` session asked to drive one pull request dispatches the drive at `standard`, and does not sit in the review loop itself. Asking the maintainer stays with the session, since a dispatched seat can prompt no one. The brief tells the worker to hand a problem back once its own attempts stop converging, with what it tried. Solving it one seat up costs less than another round of the worker looping. Work that costs less to do than to brief stays inline. None of this dispatches judgment downward, which the bullet above still forbids. - **Brief a subagent so it never needs a governance file.** A subagent inherits no context, so anything it must honor has to be in its prompt. Reading `GOVERNANCE.md` to find out costs it the same tokens the main thread would have paid. Brief on this shape: ```text Task: -Paths: +Paths: Rules that bind this task: Return: Bounds: +If your own attempts at a problem stop converging, stop and hand it back with what you tried. If a rule you were given does not cover what you find, stop and report it. Do not guess, and do not read a governance file to resolve it. ``` - **Wait in a background process, not in a poll loop.** A review or CI wait is a sequence of near-identical requests, each billed for whatever context it happens to carry. Run the wait as one backgrounded command rather than as a sequence of turns. -- **A wait separates its outcomes, and says which one it reached.** The condition was met, it has not been met yet, and the wait cannot reach it at all are different results. A backgrounded wait that emits nothing renders them identically. Run the command once in the foreground and read its output before backgrounding it. That is because a wait is only as good as the command inside it. It is also because an unsupported flag on the installed tool version exits non-zero with an empty stdout that every naive test reads as "nothing yet". Never let a fallback stand in for a failed command, since `|| echo '[]'`, `|| true`, and `2>/dev/null` convert an error into that same reading. That conversion is the suppression the write-safety rules already forbid on a mutation. Make the wait emit on failure as loudly as on success, so silence means "still running" and nothing else. Bound it too, so a condition that is never coming ends in a report rather than in another wait. +- **A wait separates its outcomes, and says which one it reached.** The condition was met, it has not been met yet, and the wait cannot reach it at all are different results. A backgrounded wait that emits nothing renders them identically. Run the command once in the foreground and read its output before backgrounding it. That is because a wait is only as good as the command inside it. It is also because an unsupported flag on the installed tool version exits non-zero with an empty stdout that every naive test reads as "nothing yet". Never let a fallback stand in for a failed command, since `|| echo '[]'` and `|| true` convert an error into that same reading. That conversion is the suppression `GOVERNANCE.md` "Repository Boundaries and Write Safety" already forbids on a mutation. Make the wait emit on failure as loudly as on success. Bound it too, so a condition that is never coming ends in a report rather than in another wait. - **Never write a wait as an unbounded shell loop.** This is a prohibition rather than a preference. A loop that waits for something, with no bound anywhere in the command that runs it, is forbidden. That holds in a tool call, in a script, and in a brief handed to a subagent. The bound goes inside that command. The wait then says which of these it found: the condition met, the bound reached, or the check itself failing. **Prefer the mechanism that already signals.** Where the dispatch mechanism reports a subagent's completion itself, polling that subagent's output file is a second channel. The answer is already on its way. **The agent that starts a wait owns the process it leaves.** A process a tool call leaves running survives the turn, the subagent, and the run that dispatched it. So a run that dispatched workers does not report itself done while it cannot say what it left running. ## Where the Rules Live @@ -100,7 +102,7 @@ Every rule below is a level-two section of [`GOVERNANCE.md`](./GOVERNANCE.md) un | --- | --- | | Why the rules are shaped this way | `Foundational Principles` | | Recording a durable lesson, updating governance, or work here waiting on a fix in another repository | `Durable Knowledge and Self-Improvement`, surfaced at its decision moments by the `agent-conduct` Skill, and the section keeps the full rules | -| Any push, API mutation, comment, label, or merge, or which checkout the work happens in | `Repository Boundaries and Write Safety`, its task-isolation rule surfaced at the task-start moment by the `repo-worktree` Skill, and the section keeps the full rules | +| Any push, API mutation, comment, label, or merge, or which checkout the work happens in | `Repository Boundaries and Write Safety`, its task-isolation rule surfaced at the task-start moment by the `repo-worktree` Skill, and the section keeps the full rules. Who takes a merge or another irreversible step is `Communicating with the User` | | Quoting data into a comment, commit, test, or doc | `Representative Data in Agent-Authored Text` | | Committing, signing, rebasing, force-pushing | `Git and Commit Rules`, packaged as the `git-commit-conventions` Skill | | Branch choice, promotion, keeping branches in sync | `Branching Model`, packaged as the `branching-and-release-model` Skill | @@ -131,7 +133,7 @@ A row above naming no Skill, or naming one only for part of its section, is doc- Some of the rules above are also packaged as Claude Code / opencode / Codex Skills, hand-authored at `.agents/skills/` in the hub. That path is not a repo-relative link here, since it is hub-local and not carried into every fleet repo. Packaging them means they surface automatically instead of needing to be re-read every session. `scripts/` is hub-hosted and reached rather than carried, per "Hub-Hosted Tooling", so run the installer from a hub checkout. `python3 scripts/skills_install.py` (or the `.sh`/`.ps1` wrapper), run once per machine from `github.com/ptr727/ProjectTemplate`, installs them for every repo touched from that machine. `python3 scripts/skills_install.py --report`, also from a hub checkout, says whether this machine is current. A rule that keeps needing to be restated is a sign the install is missing or stale, not that the rule does not exist. Keeping a repo's own carried `.github/copilot-instructions.md` in sync with the hub, without losing that repo's own "Disproved Claims" ledger entries in the process, is `copilot-instructions-keeper`. It is a skill about maintaining that file rather than a rule extracted from it. That is because the file itself is read directly by the Copilot bot and stays fully intact everywhere it is carried. Checking, from inside this repo's own session with no operator watching, whether this repo and this machine are actually current against the hub is `check-this-repo`. It is new content rather than a rule extracted from a section. It is the counterpart to `resync-a-repo` that needs no standing hub checkout or named target beyond the repo the session is already in. That holds even though its own check fetches a hub checkout to reach `scripts/skills_install.py`. Opening a pull request against a repository outside this fleet, one the maintainer does not control, follows a different workflow entirely. That workflow is new content rather than a rule extracted from a section, packaged as `upstream-contribution-workflow`. It is independent of the target repo's own type or workflow model. Isolating a task into its own worktree before its first file edit, with the base-branch choice, the layout convention, and the cleanup mechanics, is `repo-worktree`. It is the task-start surface of the `Repository Boundaries and Write Safety` law, which keeps the rule. Writing the handoff that "Session Scope" above requires, and resuming from one, is `session-handoff`, new content rather than a rule extracted from a section. It is new content because deciding what actually earns a place in each of the sections that rule names is judgment rather than a shape. It carries `GOVERNANCE.md` "Communicating with the User" whole as a generated include, that being the parked-decision account the rule owes. It also names the hub's `scripts/handoff.py` for the chain's mechanics. Its widest trigger is the one that earns it, about to re-attempt something a previous round may already have tried. That trigger earns it because a session that does not know a chain exists never goes looking for one. Creating, changing, or retiring one of these skills is itself packaged as `skill-lifecycle`. It is hub-context only, since `.agents/skills/` exists only in the hub and the generated plugin tree is never hand-edited. -Adding or changing a managed host tool is packaged as `add-host-tool`. It keeps the cross-platform contract, installer, documentation, test, and native-verification surfaces together. +Adding or changing a managed host tool is packaged as `add-host-tool`. It keeps the cross-platform contract, installer, documentation, test, and native-verification surfaces together. It is hub-context only, since the installers and `spec/host-tools.json` it edits exist only in the hub. Bringing a machine's coding agents fully current is packaged as `update-host`, new content rather than a rule extracted from a section. It runs the hub's bootstrap `--agent-setup` action from any session and reports each step with `--agent-status`. The steps are the agent tools, the fleet skills, the Claude Code safety kit, and the host-wide rules for Codex and opencode. It changes the machine, where `check-this-repo` reads one repository and `resync-a-repo` converges one. diff --git a/CODESTYLE.md b/CODESTYLE.md index 657b5602..666390b1 100644 --- a/CODESTYLE.md +++ b/CODESTYLE.md @@ -1,6 +1,6 @@ # Code Style and Formatting Rules -This is the single code-style guide for the fleet. The **General** section applies to every language. Each **language section** (.NET, Python, Shell) is self-contained: a repo follows only the section(s) for the languages it ships and ignores the rest. A repo keeps the whole file rather than trimming it. An unused-language section costs nothing, the same whole-file model as [`.editorconfig`][root], whose inert `[*.cs]` block a non-.NET repo keeps. +This is the single code-style guide for the fleet. The **General** section applies to every language. Each **language section** (.NET, Python, Shell, PowerShell) is self-contained: a repo follows only the section(s) for the languages it ships and ignores the rest. A repo keeps the whole file rather than trimming it. An unused-language section costs nothing, the same whole-file model as [`.editorconfig`][root], whose inert `[*.cs]` block a non-.NET repo keeps. Cross-cutting *process* rules live in [GOVERNANCE.md][governance] and are not repeated here. They cover PR titles, branching, US English, Markdown style, comments philosophy, workflow YAML, and PR review etiquette. They also cover the verification discipline that defines the pre-push lint gate. @@ -12,22 +12,32 @@ These rules apply to every language in the repo. Use each tool's official casing in task labels, docs, and prose, per the `comment-and-doc-style` Skill at `.agents/skills/comment-and-doc-style/SKILL.md` in the hub. That is not a repo-relative link, since the path is hub-local and not carried into every fleet repo. +### Toolchain Versions + +Where the hub carries a baseline file that selects a language's toolchain line, that file sets the fleet's default line once. Each repository selects its own line in its own copy of that file. That copy is the repository's source of truth, and the hub's workflows install the line it selects. They fall back to the hub's default only where a repository carries no selector. + +- **A repository may lead or lag the default.** One repository can move to a newer major while the fleet stays, or hold an older line while the fleet moves. +- **A move edits the selector and every setting that names the same line, together.** These include a target framework, a devcontainer image tag, and any fixed language version. +- **The language level follows the selected line.** It is left unset wherever the toolchain derives it from the line, and set by hand only where it does not. +- **A resync never changes the line a repository selects.** It carries the baseline file's fleet-owned settings and leaves the repository's own choice of line in place. +- **The audit checks that a repository agrees with itself.** Its settings must name one line between them, and that line need not be the hub's default. + ### Clean-Compile Verification -Each language defines a **clean-compile** verification: the combination of build, formatter, linter, and code-analysis tools that must report clean before a commit. It is exposed as one or more **named** VS Code tasks (or, where a language ships no tasks, documented commands). Those definitions are the same across the fleet. The concrete names live in each language section below. +Each language defines a **clean-compile** verification: the combination of build, formatter, linter, and code-analysis tools that must report clean before a commit. It is exposed as one or more **named** VS Code tasks (or, where a language ships no tasks, documented commands). Those definitions are the same across the fleet. Each language's definition is in its section below or in the Skill that section names. - **Run it after every code change, and it is not the whole gate.** The relevant language's clean-compile must pass before you commit. CI runs those same language checks as a backstop **plus everything else its validation workflow runs**. All of it reports into the one required status. A green clean-compile therefore does not predict a green CI. That remainder is at least the doc-lint set (markdownlint, cspell, actionlint, `editorconfig-checker`) and whatever spec, config, and script gates the repo carries. So read the workflow for the full list rather than assuming the previous sentence enumerates it. What has to pass before a push is the repo's **whole** lint gate, per [GOVERNANCE.md "Verification Discipline"][governance-verification-discipline]. Each linter's known-working invocation is in `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", a hub-only section read in a hub checkout rather than carried into every fleet repo. - **The named task definition is the canonical spec** - its exact command sequence, arguments, and strictness. You may run it through the VS Code task **or** by invoking the equivalent native commands directly. Either is fine **only if the sequence, arguments, and strictness match exactly**. No shortcuts and no more-lenient options (for example, never drop `--verify-no-changes` or loosen a `--severity`). -- **A working local commit/pre-commit gate is strongly suggested, not the repo's free choice to skip.** The *mechanism* is bounded by the toolchain the repo already keeps rather than by which languages its checks cover, and canonical shapes carry it. Husky.Net runs from a .NET tool manifest declaring it, so a repo that keeps no such manifest uses the `pre-commit` framework instead. Any repo may also wire an equivalent hook of its own at `.husky/pre-commit`, enabled with `core.hooksPath` and sourcing nothing. Canonical shapes for Husky.Net and the `pre-commit` framework live in `catalog/snippets/` in the hub. That is not a repo-relative path, since it is hub-local and not carried into every fleet repo. What that gate must cover, its per-clone enablement steps, and what its absence means for the audit are not restated here. They are in `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", the same hub-only section. Keeping a working gate is not drift. +- **A working local commit/pre-commit gate is strongly suggested fleet-wide, and its absence is a measured audit finding.** The *mechanism* is bounded by the toolchain the repo already keeps rather than by which languages its checks cover, and canonical shapes carry it. Husky.Net runs from a .NET tool manifest declaring it, so a repo that keeps no such manifest uses the `pre-commit` framework instead. Any repo may also wire an equivalent hook of its own at `.husky/pre-commit`, enabled with `core.hooksPath` and sourcing nothing. Canonical shapes for Husky.Net and the `pre-commit` framework live in `catalog/snippets/` in the hub. That is not a repo-relative path, since it is hub-local and not carried into every fleet repo. What that gate must cover and its per-clone enablement steps are not restated here. They are in `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", the same hub-only section. ### Analyzer Diagnostics and Suppressions -- **A new port is not a license to silence diagnostics.** Brownfield / just-ported status never justifies relaxing analyzer or linter severities or muting newly surfaced warnings. Fix them. (The only brownfield allowance is the one-time git-signing / line-ending migration described in [GOVERNANCE.md][governance] and [README.md][readme], which has nothing to do with code analysis.) +- **A new port is not a license to silence diagnostics.** Brownfield / just-ported status never justifies relaxing analyzer or linter severities or muting newly surfaced warnings. Fix them. - **Suppress only genuine false-positives or deliberate, documented exceptions**, always at the **narrowest scope that fits**, in this order of preference: 1. An **in-code annotation on the specific symbol**, with a justification, in the language's attribute/comment form, never a blanket pragma spanning a region. 2. The **owning project's local config** when the exception is project-wide for one project (e.g. a test project's own `.editorconfig` / `pyproject.toml`). 3. The **root / shared config** only when the suppression is genuinely applicable to **every** project in the repo. -- **Never blanket-relax a batch of rules project-wide** to get a port to build. The per-language mechanics (which attribute, which config key) are in each language section. +- **Never blanket-relax a batch of rules project-wide** to get a port to build. The per-language mechanics (which attribute, which config key) are in the Skill a language section names, where it names one. ### Operations and Failure Messages @@ -37,13 +47,14 @@ Each language defines a **clean-compile** verification: the combination of build ### Interrupts -This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. +This applies to every shell and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. -- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. +- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. A script started with SIGINT ignored keeps it ignored, so a stop meant to reach it sends SIGTERM. A non-interactive shell starts a background child that way. - **A write to persistent state goes to a temporary path beside the target, then is renamed over it.** An interrupt then leaves the old content or the new, never a mix of both. A store with transactions of its own, such as an SQLite database, is written through those instead. A rename over an open database can corrupt it. -- **An interrupted script prints one line naming the signal, with no traceback, and exits 130 for SIGINT or 143 for SIGTERM.** Each status is 128 plus the signal number, the status a shell reports for a process that signal ended. +- **An interrupted script prints one line naming the signal, with no traceback, and ends by re-raising the signal.** The signal then ends the process, so a shell reports 130 for SIGINT or 143 for SIGTERM, 128 plus the signal number. At Ctrl-C, a calling shell's loop then stops rather than starting its next iteration. A script calling `exit 130` has not died by the signal, so that loop reads an ordinary non-zero exit and runs on. A launcher between them, such as `uv run`, exits with the status rather than dying by the signal, so that loop runs on there too. - **A script takes this rule when it is created or next edited.** An existing script is not edited for this rule alone. -- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts the matching exit status and that nothing the script held remains. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts that the script died by that signal and that nothing it held remains. It starts the script with its interpreter directly, since a launcher such as `uv run` hides the signal death. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that ends by `exec`-ing its long-running process owes no interrupt handling for that process.** The `exec` replaces the script, so a signal reaches the process directly. A background child the script starts to outlive the `exec` is handed across it, and the script neither stops it nor waits for it. Such a child is handed across only where something else stops it, such as a container's teardown of its whole process tree. Anything else the script holds is released before the `exec`. A script that holds nothing else at any point before the `exec` owes no trap and no signal test. As PID 1, such as a container's entrypoint, it ignores a SIGTERM that arrives before the `exec`, so a stop waits for its timeout. ### Parsing Structured Formats @@ -54,7 +65,8 @@ This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Pyth A command-line script is one a person or an agent runs by name. A hook its host runs, taking its input from that host rather than from a command line, is not one. - **Every command-line script answers `--help` and `-h`** with the same text on stdout, then exits 0, changing nothing. That text opens on a usage line naming the script. An agent learns a script's interface by asking it, so a script that reads `--help` as an input acts in a way nobody predicted. A PowerShell script declaring its own parameters answers `-Help` and `-h` instead, from a `-Help` switch carrying an `h` alias. That form follows PowerShell's own parameter convention, so such a script owes no answer to a literal `--help`. A wrapper that forwards its arguments to another script answers whatever that script answers. -- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. Where no parameter takes the remaining arguments, the binder's refusal does that. A script with such a parameter refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. That refusal comes from the binder only in an advanced script, one carrying `[CmdletBinding()]` or a `[Parameter()]` attribute. Without either, a plain `param()` block binds an unknown parameter into `$args` and runs on. Such a script refuses a non-empty `$args` itself, before any work. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. A script with a parameter taking the remaining arguments refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **A shell script that gives a refused argument an exit status of its own uses 64, `EX_USAGE` from `sysexits.h`, and reserves it.** A caller can then tell a refusal, which changed nothing, from a run that started and failed, without reading the message. Every refusal exits through one function that exits 64. Under `set -e` a failed command's own status becomes the script's, so an `EXIT` trap turns any other exit carrying 64 into 1. A program the script `exec`s replaces that trap. So the script `exec`s only a program whose own 64, if it exits 64 at all, means a refused argument. An argument the script passes on, which that program refuses, keeps the program's status. The script's `--help` names the status, so a caller reads it as a contract. ### Script and Utility File Names @@ -89,7 +101,7 @@ These rules apply repo-wide, in every directory. Markdown lints clean via `markd *This section applies only to the .NET side. A repo with no .NET projects still carries it (the file is carried whole) and ignores it.* -The style guide for any .NET projects in this repo covers the zero-warnings build policy and its clean-compile task chain. It covers central `Directory.Build.props`/`Directory.Packages.props` configuration and the root `global.json` that selects the SDK line, with `LangVersion` left unset so the C# version follows the TFM. It covers C# language and naming conventions, XML documentation, and analyzer suppression scope. It covers the library-versus-application logging split, async and error-handling patterns, and xUnit v3 + AwesomeAssertions testing conventions. It covers the runner declaration, package references and version floor that an MTP-based test project needs under `WORKFLOW.md` D1.6. With them it covers the local diagnostic for a run that reports no tests. It also covers AOT-compatible project configuration. +The style guide for any .NET projects in this repo covers the zero-warnings build policy and its clean-compile task chain. It covers central `Directory.Build.props`/`Directory.Packages.props` configuration and the root `global.json` that selects the SDK line, with `LangVersion` left unset so the C# version follows the TFM. That `global.json` is the repository's selector under "Toolchain Versions" above. It covers C# language and naming conventions, XML documentation, and analyzer suppression scope. It covers the library-versus-application logging split, async and error-handling patterns, and xUnit v3 + AwesomeAssertions testing conventions. It covers the runner declaration, package references and version floor that an MTP-based test project needs under `WORKFLOW.md` D1.6. With them it covers the local diagnostic for a run that reports no tests. It also covers AOT-compatible project configuration. This is packaged as the `dotnet-codestyle` Skill at `.agents/skills/dotnet-codestyle/SKILL.md` in the hub. That is not a repo-relative link, since the path is hub-local and not carried into every fleet repo. The summary above sketches the scope. Read the skill for the full rules, code examples, and mechanics. @@ -117,13 +129,13 @@ This is packaged as the `python-codestyle` Skill at `.agents/skills/python-codes ### Tests and Script Dependencies - **A test lives in a `tests/` directory, never inside the production file it tests.** A deployed script may keep a `--selftest` that runs a small smoke check in seconds, and the case matrix lives in `tests/`. A self-test shipped inside the file it tests grows the file every reviewer reads, and its cases can come to outweigh the code they test. -- **A hub-hosted standalone script that needs a third-party library declares it in PEP 723 inline script metadata, and runs as `uv run --no-project --script `.** The block opens on `# /// script`, closes on `# ///`, and carries `dependencies` and `requires-python`. The fleet already installs uv on hosts and in CI. `--no-project` keeps uv from syncing the project around a script that has no block yet, where it would write a lockfile and a virtual environment. A script with no such block runs under `python3` and uv alike. A hook an agent harness runs on every tool call stays standard-library only, since it runs before any toolchain is guaranteed. +- **A hub-hosted standalone script that needs a third-party library declares it in PEP 723 inline script metadata, and runs as `uv run --no-project --script ""`.** The block opens on `# /// script`, closes on `# ///`, and carries `dependencies` and `requires-python`. The fleet already installs uv on hosts and in CI. `--no-project` keeps uv from syncing the project around a script that has no block yet, where it would write a lockfile and a virtual environment. A script with no such block runs under `python3` and uv alike. A hook an agent harness runs on every tool call stays standard-library only, since it runs before any toolchain is guaranteed. ### Interrupts in Python -- **SIGINT and SIGTERM take one path.** Python raises `KeyboardInterrupt` on SIGINT. The entry point installs a SIGTERM handler with `signal.signal` that records the signal and raises `KeyboardInterrupt`. -- **The entry point catches `KeyboardInterrupt` once, and any handler below it that catches the exception re-raises it.** It prints the line `CODESTYLE.md` "Interrupts" requires, then exits 143 where the SIGTERM handler recorded a signal and 130 otherwise. -- **What the script holds is released by `with` blocks and `finally` clauses as the exception unwinds.** A `subprocess.Popen` child is stopped in a `finally` clause with `terminate()`, then `wait()`, since leaving its `with` block does not stop it. That child runs without `shell=True`, so `terminate()` reaches the command rather than a shell around it. +- **SIGINT and SIGTERM take one path.** The entry point installs one handler with `signal.signal` for both signals. The handler records the first signal and raises `KeyboardInterrupt`, and returns at once on any later one. A later signal would cut the cleanup short, such as the SIGTERM that `uv run` forwards to a process group a Ctrl-C already reached. The handler takes SIGINT only where `signal.getsignal(signal.SIGINT)` is still `signal.default_int_handler`, so a SIGINT inherited as ignored stays ignored. +- **The entry point catches `KeyboardInterrupt` once, and any handler below it that catches the exception re-raises it.** It prints the line `CODESTYLE.md` "Interrupts" requires, then re-raises the signal the handler recorded. To re-raise, it flushes standard output and standard error inside `contextlib.suppress(OSError)`, restores the default handler with `signal.signal(signum, signal.SIG_DFL)`, then re-sends the signal with `os.kill(os.getpid(), signum)`. The suppression covers a pipe whose reader the same Ctrl-C ended. The default action ends the process without Python's own exit handling. So the flush comes first, and no cleanup on this path relies on an `atexit` handler or a finalizer. The re-raise runs outside every `with` block and `finally` clause, such as at the `__main__` call site, since none of them runs after it. A process the re-sent signal does not end, such as PID 1 in a container, then exits 128 plus the signal number. On Windows, `os.kill` ends the process with the signal number as its status, so there the entry point skips it and exits 130. +- **What the script holds is released by `with` blocks and `finally` clauses as the exception unwinds.** A `subprocess.Popen` child is stopped in a `finally` clause, since leaving its `with` block does not stop it. The clause calls `terminate()`, then `wait(timeout=...)`, such as 10 seconds. On `subprocess.TimeoutExpired`, it calls `kill()`, then `wait()`. The handler passes over a second Ctrl-C, so a child that ignores SIGTERM would otherwise hold the script. That child runs without `shell=True`, so `terminate()` reaches the command rather than a shell around it. - **The rename over persistent state uses `os.replace`.** `os.rename` and `Path.rename` fail on Windows when the target exists. ### PlexCleaner Python Conventions @@ -132,19 +144,32 @@ The only Python in this repo is the stdlib-only tooling under `RegressionTests/` ## Shell -Bash, and only where a program cannot be Python: a bootstrap that installs the interpreter cannot be written in it. Nor can a host tool that must run before a development toolchain exists depend on Python. Everything else is Python, with a test under its own scripts tree's `tests/` directory. The `shell-codestyle` Skill packages the mandatory `set -Eeuo pipefail` header, the pipefail-versus-early-reader pitfall, and self-recursive command shims. It also packages self-locating scripts, the `shellcheck`-plus-`shfmt` clean-compile, and the why-not-what comment rule. It is at `.agents/skills/shell-codestyle/SKILL.md` in the hub, not a repo-relative link since that path is hub-local and not carried into every fleet repo. Read the skill for the full rules. A script's own arguments follow "Command-Line Arguments" under General, which the Skill carries whole. Run the clean-compile check itself per `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", not by probing `command -v shellcheck`. That section is hub-only, read in a hub checkout rather than carried into every fleet repo. +*This section applies only to Bash and POSIX `sh` scripts. A repo with none still carries it (the file is carried whole) and ignores it.* + +A bootstrap, a program that must run before the interpreter or a development toolchain exists, is written in the platform's native shell. That is Bash on Linux and PowerShell on Windows. Logic that needs its failure cases tested is Python, with a test under its own scripts tree's `tests/` directory. The pattern is a platform-native entry point over shared Python logic. The `shell-codestyle` Skill packages the mandatory `set -Eeuo pipefail` header, the pipefail-versus-early-reader pitfall, and self-recursive command shims. It also packages self-locating scripts, the `shellcheck`-plus-`shfmt` clean-compile, and the why-not-what comment rule. It is at `.agents/skills/shell-codestyle/SKILL.md` in the hub, not a repo-relative link since that path is hub-local and not carried into every fleet repo. Read the skill for the full rules. A script's own arguments follow "Command-Line Arguments" under General, which the Skill carries whole. Run the clean-compile check itself per `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", not by probing `command -v shellcheck`. That section is hub-only, read in a hub checkout rather than carried into every fleet repo. ### Interrupts in Shell -- **Cleanup of temporary paths and locks runs in the script's `EXIT` trap.** Bash runs that trap when SIGINT or SIGTERM ends the script, as well as on a normal exit. -- **Every script sets an `INT` trap and a `TERM` trap, which stop its children and keep the status.** Each one sends SIGTERM with `kill` to the children the script started, then waits for them with `wait`. It then prints the line `CODESTYLE.md` "Interrupts" requires and exits 130 or 143. The children's process IDs are held in an array, such as `pids`, set to `()` before the traps are set. A trap skips the `kill` and the `wait` while `${#pids[@]}` is 0, a test `set -u` allows on an empty array in every Bash version. Under `set -u`, an unset one would end the trap before the line prints. The `kill` takes `2>/dev/null`, since a child that already exited makes it print an error. Both take `|| :`, since under `set -e` a non-zero status from either ends the trap before the line prints. SIGTERM is the signal sent because a background child ignores SIGINT. Other cleanup stays in the `EXIT` trap. -- **A long-running external command runs in the background, and the script waits for it with `wait "$pid"`, so its exit status reaches `set -e`.** Bash runs a trap only after a foreground command returns, while a trapped signal ends a `wait` at once. Only the script's own shell starts such a child. One that a subshell or a pipeline element starts never reaches the script's array or its `wait`. A background child that reads standard input takes `<&0`, since bash otherwise gives it `/dev/null`. The trap's `kill` reaches only the process `$!` names. So a function, a group, a subshell, a pipeline, or `sh -c` runs in the foreground instead. There the trap runs once the command it interrupted returns, so nothing the script started is orphaned. +- **Cleanup of temporary paths and locks runs in the script's `EXIT` trap, set before the `INT` and `TERM` traps.** Bash runs that trap when SIGINT or SIGTERM ends the script, as well as on a normal exit. Set after the `TERM` trap, it does not run when that trap's re-sent SIGTERM ends the script. +- **Every script sets an `INT` trap and a `TERM` trap, which stop its children and re-raise the signal.** Each one sends SIGTERM with `kill` to the children the script started, then waits for them with `wait`. It then prints the line `CODESTYLE.md` "Interrupts" requires. Last, it clears its own trap with `trap - INT` or `trap - TERM` and re-sends the signal to the script with `kill -s INT "$$"` or `kill -s TERM "$$"`. It ends with `exit 130` or `exit 143`, which runs only where the re-sent signal does not end the script, such as PID 1 in a container. The children's process IDs are held in an array, such as `pids`, set to `()` before the traps are set. A trap skips the children's `kill` and the `wait` while `${#pids[@]}` is 0, a test `set -u` allows on an empty array in every Bash version. Under `set -u`, an unset one would end the trap before the line prints. The children's `kill` takes `2>/dev/null`, since a child that already exited makes it print an error. Both take `|| :`, since under `set -e` a non-zero status from either ends the trap before the line prints. SIGTERM is the signal sent because a background child ignores SIGINT. Other cleanup stays in the `EXIT` trap. A script that the `exec` case in `CODESTYLE.md` "Interrupts" frees from owing a trap sets neither trap. +- **A long-running external command runs in the background, and the script waits for it with `wait "$pid"`, so its exit status reaches `set -e`.** Bash runs a trap only after a foreground command returns, while a trapped signal ends a `wait` at once. Only the script's own shell starts such a child. One that a subshell or a pipeline element starts never reaches the script's array or its `wait`. A background child that reads standard input takes `<&0`, since bash otherwise gives it `/dev/null`. The trap's `kill` reaches only the process `$!` names. So a function, a group, a subshell, a pipeline, or `sh -c` runs in the foreground instead. There the trap runs once the command it interrupted returns, so nothing the script started is orphaned. A launcher, such as `uvx`, `uv run`, `uv pip install`, `dotnet`, or `xargs`, may run in the foreground too. One that does not stop the tool it starts on SIGTERM must run in the foreground. `uv pip install` is one when it builds an editable install or an sdist through a build backend that outlives uv on SIGTERM. A background child starts with SIGINT ignored, and the tool a launcher starts inherits that. So at Ctrl-C the tool runs on until the trap's SIGTERM reaches it through the launcher. In the foreground, Ctrl-C reaches the whole process group, the tool included. A SIGTERM sent to the script alone runs its `TERM` trap only once that foreground command returns. So a stop that must be prompt signals the process group. That group holds only the script and its command where the script leads it, as `setsid` starts one. The `exec` case in `CODESTYLE.md` "Interrupts" is the exception. The process a script `exec`s into replaces it, and a child handed across that `exec` is not waited for. +- **A deliberately POSIX `#!/bin/sh` script, such as a git hook, adapts the bullets above to what dash lacks.** Dash runs no `EXIT` trap when the re-sent signal ends the script. So the `INT` and `TERM` traps release the temporary paths and locks themselves, and the `EXIT` trap still covers an ordinary exit. A `/bin/sh` that is bash runs the `EXIT` trap after the signal trap too. So a release that cannot run twice, such as a lock's, sets its variable back to `""`. POSIX sh has no arrays, so the script runs one background child at a time. It holds that child's process ID in a scalar, such as `child`, set to `""` again after its `wait`. Every variable a trap reads, `child` and each temporary path included, is set to `""` before the traps are set. Under `set -u`, an unset one would end the trap before the signal is re-sent. A trap skips the child's `kill` and `wait` while `[ -n "$child" ]` fails, and skips the removal of a path still empty. + +## PowerShell + +*This section applies only to PowerShell scripts. A repo with no `.ps1` files still carries it (the file is carried whole) and ignores it.* + +PowerShell is the native shell on Windows, so a Windows bootstrap and a Windows entry point over shared Python logic are written in it. Logic that needs its failure cases tested is Python on Windows too. PSScriptAnalyzer is the analyzer, and it runs every default rule through a `PSScriptAnalyzerSettings.psd1` at the repo root, which CI reads. A repo with `.ps1` files keeps its own copy. It excludes a rule below only where its own scripts meet that rule's reason, and states the reason there. + +- **`PSAvoidUsingWriteHost`.** A script whose purpose is a console report writes it with `Write-Host`. Its functions return exit codes through the pipeline, so text sent with `Write-Output` would reach the caller as a return value. +- **`PSUseShouldProcessForStateChangingFunctions`.** A script that already carries its own preview and consent step, such as a dry-run switch and a confirm prompt, keeps them. Supporting `ShouldProcess` would add `-WhatIf` and `-Confirm` beside them, a second spelling of each. + +The check is clean when `Invoke-ScriptAnalyzer -Path "" -Settings ./PSScriptAnalyzerSettings.psd1` reports no finding for any tracked `.ps1` file, as CI requires. Run the check per `GOVERNANCE.md` "Running the Linters Locally (Known-Working Invocations)", not by probing `command -v pwsh`. That section is hub-only, read in a hub checkout rather than carried into every fleet repo. Windows batch (`.cmd` and `.bat`) appears only as a shim that puts a command on `PATH`, by decision, so it has no section here. [governance]: ./GOVERNANCE.md [governance-verification-discipline]: ./GOVERNANCE.md#verification-discipline -[readme]: ./README.md [root]: ./.editorconfig [tasks]: ./.vscode/tasks.json diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 8ebbb378..340f247b 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -19,8 +19,8 @@ The specific rules in this file implement a few governing principles. Read these - **Keep the governance current as you work.** When work surfaces something durable, record it in the governance docs as part of that change. Something durable includes a rule worth enforcing, a recurring gotcha, a positive pattern to repeat, or a negative one to design out. Record it rather than leaving it in a local note or routing around it with a one-off workaround. Where the governing doc is carried from a template this repo cannot edit directly, propose the change upstream rather than patching the local copy. A local patch leaves every sibling repo with the same trap. Governance is not static: it improves by agents folding good patterns in and designing bad ones out. - **A blocker filed in another repository is recorded in the repository whose work it blocks.** The binding moment is when the upstream issue is filed or, where it already exists, found. That is because the session filing or finding it is the one that knows what stopped and why. It owes a second issue in the repository that is waiting rather than only the first. Where the upstream issue already exists, the local issue names that one and no second upstream issue is filed. The local issue states what this repository cannot do and why, in its own terms rather than as a pointer to read elsewhere. That is because a reader who has to open the upstream issue to learn whether it affects them opens every one of them. The local issue names the upstream one as its blocker, carries the `blocked` label, and carries whatever labels its own work would carry anyway. A comment on the upstream issue then names the local one in return. It is a comment rather than an edit to the body because a second repository may join the same blocker later. It is also because the body is often not this session's to rewrite. That order is the upstream issue, then the local issue, then the backlink comment. It leaves a partial failure as a record naming its blocker rather than as a blocker naming a record nobody wrote. **A handoff does not do this job.** It carries the blockers a round met, but it belongs to one track and closes when that track's work is done. The wait can outlive that track, so it belongs in the backlog the whole repository reads. - **The blocker record is written under the ordinary write rules, and the label on it is taken off deliberately.** Filing an issue and commenting on another are state-changing calls. So "Repository Boundaries and Write Safety" binds each of them exactly as it binds any other write. That keeps the upstream issue inside this owner. That binding also makes a blocker under a different owner a matter of explicit permission rather than of this rule. The `blocked` label is what every reader of this record selects on. So a repository not carrying it cannot host one until the fleet label set is applied there. That is a change to that repository's configuration rather than anything this rule writes. A session that finds it missing reports that. The label comes off when the blocker clears. The session closing the upstream issue is best placed to take it off. That is because the backlink comments naming every waiting repository are on the issue it is closing. Any later session that finds it cleared takes it off instead. A fix can land well before either of those, so the label lags the fix rather than tracking it. That is why a session meeting a `blocked` issue reads the state of the issue that issue's body names rather than the label. The local issue stays open when the label comes off. That is because the work it records still has to be done and is ordinary backlog from that moment on. -- **A handoff parked on a maintainer decision carries the `blocked` label too.** Its blocker is a `decision` issue in this same repository rather than an issue elsewhere, and the parking comment on the handoff names it. A reader reads the named issue rather than the label, and the blocker clears when that issue loses its `decision` label. Unlike a cross-repository blocker, a session finding it cleared does not take the label off. It comes off only once a session writes the next round and leaves no `decision` issue it filed on that work unanswered. So a running loop never takes a handoff a present maintainer is still working, or one it could only park again. -- **A durable rule earns a mechanical hook only where a hook can actually decide it, otherwise it stays prose.** The conditions below must hold together, not any one alone. The failure recurs even after the governing prose was demonstrably read and understood. So it is not a discovery or loading problem that a structural fix would already solve. A structural fix here means getting the rule into context at all. The triggering shape is decidable from the tool call's own text, arguments, and working directory alone, with no semantic or contextual judgment required. And the failure is destructive or hard to reverse rather than a quality miss. A worktree-isolation lapse met all of them, so it was promoted to a `gh-write-guard` hook rule. It recurred under prose the agent had already read. The question "is this command's target a primary checkout" is a plain directory comparison. And the harm is another task's swept or reverted work. A skill's own trigger going unread by the session at all, by contrast, is a loading problem. It is fixed by getting the rule into context (the `CLAUDE.md` importing `AGENTS.md`), not by a hook. And "was this review finding actually evidence-backed" fails the second condition outright. A hook sees only the command text, never the judgment call itself, so it can only ever nag, not decide. That class of rule stays prose and a chained Skill trigger. Those conditions gate promotion to a **host** hook. That is the involuntary layer that fires in every session under the maintainer's own credentials, and only the maintainer can grant an exemption from it. That is why the bar there is destructive harm. A **committed** hook in the repository's own tree is a third layer between prose and that one, and it is earned on weaker grounds. It is opt-in per clone, visible in the tree, and bypassable by design. It therefore fits a rule whose harm is a quality miss rather than a destruction. The second condition still binds it, since a hook that cannot decide its own trigger is a hook that nags. So what earns the layer is finding the decidable half of a rule whose other half is judgment. The local-review rule under `GOVERNANCE.md` "Verification Discipline" is the worked example. Whether a review's findings were rightly disposed of is judgment no hook can decide, and it stays prose. Whether a review pass ran over exactly the content being pushed is a receipt comparison, which the hub's own `.husky/pre-push` decides. +- **A handoff parked on a maintainer decision carries the `blocked` label too.** Its blocker is a `decision` issue in this same repository rather than an issue elsewhere, and the parking comment on the handoff names it. A reader reads the named issue rather than the label, and the blocker clears when that issue loses its `decision` label. Unlike a cross-repository blocker, a session finding it cleared does not take the label off. It comes off only once a session writes the next round and leaves no `decision` issue on that work unanswered, whichever session filed it. So a running loop never takes a handoff a present maintainer is still working, or one it could only park again. +- **A durable rule earns a mechanical hook only where a hook can actually decide it, otherwise it stays prose.** The conditions below must hold together, not any one alone. The failure recurs even after the governing prose was demonstrably read and understood. So it is not a discovery or loading problem that a structural fix would already solve. A structural fix here means getting the rule into context at all. The triggering shape is decidable from the tool call's own text, arguments, and working directory alone, with no semantic or contextual judgment required. And the failure is destructive or hard to reverse rather than a quality miss. A worktree-isolation lapse met all of them, so it was promoted to a `gh-write-guard` hook rule. It recurred under prose the agent had already read. The question "is this command's target a primary checkout" is a plain directory comparison. And the harm is another task's swept or reverted work. A skill's own trigger going unread by the session at all, by contrast, is a loading problem. It is fixed by getting the rule into context (the session loading `AGENTS.md` at start), not by a hook. And "was this review finding actually evidence-backed" fails the second condition outright. A hook sees only the command text, never the judgment call itself, so it can only ever nag, not decide. That class of rule stays prose and a chained Skill trigger. Those conditions gate promotion to a **host** hook. That is the involuntary layer that fires in every session under the maintainer's own credentials, and only the maintainer can grant an exemption from it. That is why the bar there is destructive harm. A **committed** hook in the repository's own tree is a third layer between prose and that one, and it is earned on weaker grounds. It is opt-in per clone, visible in the tree, and bypassable by design. It therefore fits a rule whose harm is a quality miss rather than a destruction. The second condition still binds it, since a hook that cannot decide its own trigger is a hook that nags. So what earns the layer is finding the decidable half of a rule whose other half is judgment. The local-review rule under `GOVERNANCE.md` "Verification Discipline" is the worked example. Whether a review's findings were rightly disposed of is judgment no hook can decide, and it stays prose. Whether a review pass ran over exactly the content being pushed is a receipt comparison, which the hub's own `.husky/pre-push` decides. `GOVERNANCE.md` "Durable Knowledge and Self-Improvement" keeps the full rules. The `agent-conduct` Skill at `.agents/skills/agent-conduct/SKILL.md` in the hub carries it whole as a generated include and surfaces it at its decision moments. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. @@ -31,7 +31,7 @@ A state-changing GitHub call is the highest-blast-radius thing an agent does her - **Write only within the owner of the current project's repository.** Every state-changing call targets this project's `origin` or another repository under the same owner, which is the fleet the maintainer already administers. A broad or logged-in identity is capability, not permission: a token that *can* reach another owner's repository does not authorize writing to it. Writing under a **different owner** needs explicit human permission naming that repository, granted deliberately rather than assumed from a token's reach. A "harmless test" write is still a write, so there is no probe exception. That boundary is where the harm sits. That is because the incident this rule exists for was a stray comment on a stranger's repository, not work across the maintainer's own projects. Reads from anywhere are fine. - **Provider connectors are read-only for fleet work.** Use a provider's GitHub connector for reads where it helps. Perform each GitHub mutation through the documented hub tool, or through authenticated `gh` where no tool owns the operation. This gives Codex, Claude, opencode, and a terminal session one write path with the same checks. It also avoids a connector mutation that predictably lacks repository authorization while the verified `gh` session already has it. A provider-specific instruction may explain how to reach the common path. It never replaces that path with its own mutation surface. - **Never fabricate, guess, or reuse an identifier passed to a write.** Capture every identifier a state-changing call consumes from a live query in the **same** session. This includes node, numeric, thread, and comment ids. Pass the captured value directly. Do not hand-type an id, recall it from another session, or copy it from documentation or an example. Ids commonly resolve **globally**, so a wrong-but-valid id does not fail. It writes to the wrong target, in someone else's repository. Apply the same rule to an identifier embedded in outward-facing text. Read the complete URL from the live object. Never construct a plausible link from an unverified id. If a query returns no id or URL, stop rather than invent one to proceed. -- **A write is never a probe, and a write's output is never suppressed.** Never fire a state-changing call to see whether it works: decide it should happen, make it happen, and read the result. Never append output-discarding redirection or a force-success tail to a mutation (for example `>/dev/null`, `2>/dev/null`, `&>/dev/null`, `|| true`, `|| :`, `|| echo`). The reason is that the write's output is exactly what must be read. A write that appears to fail is **verified, not assumed harmless**. That is because the operation may have succeeded on the server while the client reported an error. So confirm the actual state before retrying or moving on. The ban targets hiding a *failure*. An ad-hoc call's response is the only signal you get. So `>/dev/null 2>&1`, `|| true`, and `|| echo`, which swallow the error stream or force success, are never acceptable on one. A committed script under `set -e` is a narrow exception. It may send a write's *stdout* to `/dev/null` to drop the success-response noise, because stderr stays visible and a failed write still aborts loudly. The hub's own `repo-config/configure.sh` does exactly this, and a repository reaches it there rather than carrying a copy. The exception is stdout-only suppression inside a reviewed, fail-loud script, never `2>&1` or a force-success tail, and never an ad-hoc command. +- **A write is never a probe, and a write's output is never suppressed.** Never fire a state-changing call to see whether it works: decide it should happen, make it happen, and read the result. A test, probe, or verification run never makes a call that would change state outside its own disposable workspace if it succeeded, `sudo` included. It stubs or dry-runs that call instead. That workspace is a temporary directory, a tool cache, a container and the images it runs, and its checkout's working tree and local git state. Remotes, services, installed software, system or account configuration, and an operational repository's tracked live files stay outside it. A refusal this time never makes a live run acceptable, since the next run may hold the credential the refusal lacked. Never append output-discarding redirection or a force-success tail to a mutation (for example `>/dev/null`, `2>/dev/null`, `&>/dev/null`, `|| true`, `|| :`, `|| echo`). The reason is that the write's output is exactly what must be read. A write that appears to fail is **verified, not assumed harmless**. That is because the operation may have succeeded on the server while the client reported an error. So confirm the actual state before retrying or moving on. The ban targets hiding a *failure*. An ad-hoc call's response is the only signal you get. So `>/dev/null 2>&1`, `|| true`, and `|| echo`, which swallow the error stream or force success, are never acceptable on one. A committed script under `set -e` is a narrow exception. It may send a write's *stdout* to `/dev/null` to drop the success-response noise, because stderr stays visible and a failed write still aborts loudly. The hub's own `repo-config/configure.sh` does exactly this, and a repository reaches it there rather than carrying a copy. The exception is stdout-only suppression inside a reviewed, fail-loud script, never `2>&1` or a force-success tail, and never an ad-hoc command. - **A refused write is reported, never re-shaped, and the maintainer's say-so does not lift a refusal by the harness.** These are two different permissions and only one of them is the maintainer's to give. When the agent harness refuses a write, the maintainer authorizing it in conversation does not change the outcome. The identical call is refused again, so a second attempt is not worth making. Reading the second refusal as a flake is how an agent starts hunting for another shape of the same request. **That hunt is the failure this rule exists to stop.** Re-expressing a refused `gh` command as a raw `gh api -X POST` reaches the same endpoint with the same identity and the same blast radius. It has defeated the one control that stopped it. And it is the more dangerous version because the agent believes it has permission. So a refused write is never re-attempted through a different API surface, a different tool, or a rephrasing. It is also never routed around by the agent writing itself a permission rule, which is self-authorization whatever the maintainer said. The routes that remain are the maintainer's: they add the permission rule themselves, or they run the command themselves. Raise it as a blocked decision naming those routes (see "Communicating with the User"). Where the work needs the result rather than the call, say what the agent will verify once the maintainer has run it. A gate-checked subcommand that the maintainer's own installer allows, such as `pr_review.py merge`, is a shape of call the maintainer sanctions in advance. It sanctions how the write is made, never whether it is, so the write still needs the maintainer's go-ahead as before. A skill prescribes it as the first call for its write. It is not among the routes left after a refusal. So it is never reached for once a hand-typed form of the same write was refused. **A refusal is also a fact about the contract, not just about the session.** Where a required verification needs a write the agent is refused, the document requiring it says so and names who runs it. That is because a check that is mandatory and unperformable is quietly dropped and then reported as done. - **Each task runs in its own checkout, in its own directory, on its own feature branch.** The unit is the task rather than the agent. That is because one agent moving between two repositories meets the same hazard as two agents sharing one tree. It is also because a rule written per agent permits exactly the case that goes wrong. The commands that cross the boundary are the ordinary ones rather than the reckless ones, and each is correct in isolation. A blanket `git add -A` sweeps another task's uncommitted work into the commit, and a `git reset --hard` deletes it. A branch switch carries it into an unrelated change. And a `git stash pop` can pop another task's entry, since the stash is one list per repository shared by every worktree. The mechanical habit that holds the rule up: a mutating command takes an absolute path, or a `cd` to one in the same invocation. It does not take the working directory it inherited. That is because a read in the wrong directory is a wasted call and a write there is damage. No working directory scopes the shared stash list, so a task leaves the stash alone. - **A task isolates into its own worktree before its first file edit, and a continuation re-isolates.** All new work begins by creating a unique git worktree (or clone) on its own feature branch. Its base is the branch work starts on for the repository's model per "Branching Model", which is `develop` unless the task is explicitly about `main`-only content. The primary checkout is the maintainer's own surface, so a session launched there isolates before writing rather than after noticing contention. An operational repository's live checkout on `develop` is the one exception, since it takes a direct commit in place per "Operational Repositories". A session resuming a prior task creates a fresh worktree rather than resuming wherever its branch happens to be checked out. That is because a branch sitting checked out in a shared tree is exactly how two sessions end up in one checkout. The moment this rule binds is the first file edit. That is because the commit-time and review-time checks all run after another task's uncommitted work can already be swept. The worktree mechanics, the layout convention, and the cleanup are packaged as the `repo-worktree` Skill at `.agents/skills/repo-worktree/SKILL.md` in the hub. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. This section keeps the rule. For Claude Code sessions, the `gh-write-guard` hook now backstops a mechanical subset of this rule directly. It denies a mutating git operation run against a primary checkout rather than a worktree. That covers `reset`, `add`, `commit`, and most of the rest, a documented handful of exemptions such as a fast-forward-only pull kept aside. An operational repository's in-place commit is one of them. The hook allows it only where the repository's `.github/agent-policy.json` on `main` lists the checked-out branch. Every other agent, and everything about isolation a hook cannot see, still relies on this prose alone. What a hook cannot see includes which checkout a read happens in and whether another task is live in the tree. The parenthetical "(or clone)" above names `repo-worktree`'s own standalone-clone fallback, used when a linked worktree is unavailable. That fallback is itself structurally a primary checkout to the hook's own primary-vs-worktree test. So a session using it on Claude Code sets the hook's `GH_WRITE_GUARD_ALLOW_PRIMARY_CHECKOUT` grant for that session, per `repo-worktree`'s own instructions. That keeps it from being silently denied the commits the fallback exists to make. @@ -39,12 +39,13 @@ A state-changing GitHub call is the highest-blast-radius thing an agent does her ## Representative Data in Agent-Authored Text -Agent-authored text illustrates with data the agent constructed, never with data it observed in the maintainer's environment. This binds every surface an agent writes: pull request and issue comments, review replies, commit messages, code, tests, fixtures, and docs. Reading real data is unrestricted, and what is bounded is what an agent copies out of the environment into text that is committed or posted. The rule holds for a private repository as much as a public one. That is because a repository's audience changes with one settings toggle while the text stays exactly where it was written. It also holds where the data is the maintainer's own, since the exposure happens on their behalf before they can weigh it. +Agent-authored text illustrates with data the agent constructed, never with identifying data it observed in the maintainer's environment. The first bullet below defines identifying data, and everywhere else in this section observed data means identifying data observed there. This binds every surface an agent writes: pull request and issue comments, review replies, commit messages, code, tests, fixtures, and docs. Reading real data is unrestricted, and what is bounded is what an agent copies out of the environment into text that is committed or posted. The rule holds for a private repository as much as a public one. That is because a repository's audience changes with one settings toggle while the text stays exactly where it was written. It also holds where the data is the maintainer's own, since the exposure happens on their behalf before they can weigh it. +- **The rule bounds identifying data, and nothing else.** Identifying data is people's names and other personal details, account identifiers, secrets, and host names. A personal detail is anything that points at a person. Examples are an email address, a phone number, a street address, and a username, the one a home path carries included. An account identifier is an account number, a masked account suffix, or a reference or transfer id. A secret, such as a credential, a token, or a key, identifies the account it unlocks. A host name is the name of a machine on the maintainer's own network. A date, an amount, a balance, or a private-range IP address identifies nobody, so it is out of scope even where it was observed. A private-range address is reused on every private network, so it points at none of them. A review finding that raises one as observed data is answered by citing this bullet, and it owes no replacement and no record. - **Synthetic evidence is the better evidence, not a weaker substitute.** A case constructed to carry the defect demonstrates it exactly, and any reader can re-run it. Observed data proves the same thing and can never be reproduced by anyone else. A filename built to contain a newline is a complete proof of a newline-handling defect. The real directory it was found in adds nothing the proof needed. Reaching for observed data to make a finding more convincing inverts which of the two is the stronger evidence. Where observed data is what revealed the defect, name its shape, meaning the property that triggers the fault. Then construct a case that carries that property. - **The exposure is one-way.** A public comment is fetched, cached, and indexed the moment it posts, so editing it afterwards is mitigation rather than a fix. The edit leaves the original readable in the comment's edit history to anyone who can read the repository. Text that has already landed is reported to the maintainer rather than quietly rewritten. That is because the decision on what to do about it, deletion included, is theirs. Observed data a review finds in a repository's committed text takes the set route in the next bullet. Do not quote the exposed data again while reporting or investigating it. That is because a transcript, an issue, or a commit message written about the exposure reproduces it somewhere new. -- **Observed data a review finds in committed text is routed by where it sits and who can read it.** A sweep for the finding's siblings is owed, reaching as far as any real finding's class sweep does. For the finding and each sibling, the first case that fits decides. Data no pushed commit holds is removed from the unpushed commits before the push, and needs no record. Two kinds of data are escalated to the maintainer, and the work on them stops. One is data in a public repository's pushed history, the hub's included. The other is data in a carrying repository's copy of hub-authored text. It is already exposed, or it is the hub's to fix, and a history rewrite is the maintainer's call. The escalation names the repository and the kind of data. It and any issue, comment, or answer it writes never name the commit, the file, the line, or the value, or quote the reviewer's words. Data in a private repository's pushed history is replaced in the current text, even in a file the change does not otherwise touch. Where the current text no longer holds it, nothing is replaced, and the record below is still owed. The pull request body records it under an `Observed data recorded` heading, naming the location and kind, never the value. Where another pull request's review raised it, that line names the raising pull request too. Both carry the `history-data` label. That heading and label are the record a later decision reads, since no scanner finds a name. Where the repository lacks the label, the heading is the record, and the maintainer is told the label is missing. Read the visibility live, with `gh repo view --json visibility`, at the moment of the finding, since one toggle changes it. -- **A repository becoming public first answers for its history.** Before its visibility changes, list its pull requests carrying `history-data` or an `Observed data recorded` heading, and each pull request such a heading names. Replacing the current text is not enough, and neither is a history rewrite alone, since GitHub keeps every pull request's commits after a force push. The history is rewritten, and any review comment showing the data is deleted. The maintainer then asks GitHub Support to purge the cached pull request refs. That request also names any submitted review body showing it, since no one can delete one. Only after all of these does the toggle change. +- **Observed data a review finds in committed text is routed by where it sits and who can read it.** A sweep for the finding's siblings is owed, reaching as far as any real finding's class sweep does. For the finding and each sibling, the first case that fits decides. Data no pushed commit holds is removed from the unpushed commits before the push, and needs no record. Two kinds of data are escalated to the maintainer, and the work on them stops. One is data in a public repository's pushed history, the hub's included. The other is data in a carrying repository's copy of hub-authored text. It is already exposed, or it is the hub's to fix, and a history rewrite is the maintainer's call. The escalation names the repository and the kind of data. It and any issue, comment, or answer it writes never name the commit, the file, the line, or the value, or quote the reviewer's words. Data in a private repository's pushed history is replaced in the current text, even in a file the change does not otherwise touch. Where the current text no longer holds it, nothing is replaced, and the record below is still owed. The pull request body records it under an `Observed data recorded` heading, naming the location and kind, never the value. Where another pull request's review raised it, that line names the raising pull request too. Both carry the `history-data` label. That heading and label are the record a later decision reads, since no scanner finds a name. Where the repository lacks the label, the heading is the record, and the maintainer is told the label is missing. Read the visibility live, with `gh repo view --json visibility`, at the moment of the finding, since one toggle changes it. Every observed secret also goes to the maintainer for revocation, whatever else its case requires, naming only the repository and the kind of data. +- **A repository becoming public first answers for its history.** Before its visibility changes, list its pull requests carrying `history-data` or an `Observed data recorded` heading, and each pull request such a heading names. An empty listing owes none of the steps below. Replacing the current text is not enough, and neither is a history rewrite alone, since GitHub keeps every pull request's commits after a force push. The history is rewritten, and any review comment showing the data is deleted. The maintainer then asks GitHub Support to purge the cached pull request refs. That request also names any submitted review body showing it, since no one can delete one. The maintainer then waits for GitHub Support's reply confirming that everything the request named is purged. Only after all of these does the toggle change, though the maintainer may decide not to wait for the reply. A pending request leaves the cached refs and any named review body readable. A toggle made on the request alone publishes what the purge exists to remove. - **No checker closes this.** A pattern finds an absolute home path or a drive letter, and gating that subset is worth doing as a floor. The exposure this rule exists for was name-shaped, and a name is not pattern-detectable. So a search of the offending text for path-shaped strings returns nothing while the names sit in plain sight. A gate here catches the easy half, and mistaking it for the answer is what stops anyone looking at the other half. That is why this is a judgment an agent applies rather than a check it waits for. ## Git and Commit Rules @@ -63,6 +64,7 @@ Two workflow models, set per repo by the registry `workflowModel` field. Most re promotions, and forward-only with no back-merges. That model has promotion traps worth knowing before the first one (never delete `develop`, resolve an EOL-only conflict by taking `develop`'s side). **GitHub's own "default branch" repository setting reads `main`, but `develop` is where work starts and where in-flight content lives.** So a worktree or clone that defaults to "the default branch" lands on `main`. It can silently miss content already merged to `develop` but not yet promoted. Branch from `develop`, on either workflow model, unless the task is explicitly about `main`-only content. +Issue-closing keywords go only in a promotion pull request's body. A squash setting can copy a pull request's body into its commit. Then a keyword in a feature pull request's body closes its issue once the promotion reaches `main`. A direct-push commit message does the same. So neither carries a keyword. Where either names the issues it fixes, it uses the inert `Closes on promotion:` line. A keyword fires even inside a sentence that negates it. **Operational** repos differ substantially (direct-to-`develop`, advisory CI, dispatch-only release), covered as a delta rather than a separate model. @@ -94,11 +96,18 @@ already cut, and wrapper-repo upstream-version tracking. The registry `workflowModel` field is `release` (the default) or `operational`. **Operational** repos track a live service's running state rather than shipping versioned units of delivery. They hold live-service config such as Home Assistant, ESPHome, Vantage, and home automation. Commits go -directly to `develop`, and CI runs on the push as advisory feedback only. The maintainer and an agent alike commit in place, in the live checkout the running service reads. A worktree or a pull request into `develop` stays available to an agent and is never required. The host write guard allows that in-place commit only once the repository's `.github/agent-policy.json` on `main` lists `develop` in its `guard` section. The maintainer's merge to `main` is therefore what grants it, and until then the guard denies it. A direct push names -the issues it fixes in one `Closes on promotion:` line in its commit message, such as -`Closes on promotion: #N, #M`. The promotion pull request carrying that push takes a closing -keyword in its body for each issue the line names. Its body takes no closing keyword for a push -without that line. A PR still exists for a +directly to `develop`, and CI runs on the push as advisory feedback only. The maintainer and an agent alike commit in place, in the live checkout the running service reads. A worktree or a pull request into `develop` stays available to an agent and is never required. The host write guard allows that in-place commit only once the repository's `.github/agent-policy.json` on `main` lists `develop` in its `guard` section. The maintainer's merge to `main` is therefore what grants it, and until then the guard denies it. A change reaching +`develop` names the issues it fixes in one `Closes on promotion:` line, such as +`Closes on promotion: #N, #M`. A direct push writes the line in its commit message. A pull request +into `develop` writes it in its body. The promotion reads a merged pull request's line from its +body, never from its commits. The +promotion pull request carrying the change takes a closing keyword in its body for each issue the +line names. Its body takes no closing keyword for a change without that line. A change that undoes a +fix not yet on `main` names that fix's issues in one `Reopens on promotion:` line, written where a +`Closes on promotion:` line would go. A rollback committed as an ordinary change is one. The line is +required because a rollback often carries no revert marker for the range to show. The promotion body +takes no closing keyword for an issue that line names. Where the range names one issue on both +lines, the line of the latest change naming it decides. A PR still exists for a change worth reviewing, and the `main` promotion gate is unchanged. Release happens only by manual dispatch. @@ -115,11 +124,11 @@ Line-ending governance for an operational repo is in [Line Endings](#line-ending A repo whose own stacks or scripts read local runtime credentials from disk keeps them in a dotted `.secrets/` directory at the repo root. The most common case is an operational repo's Docker Compose stack. This is the repo-scoped counterpart to the host-scoped `~/.secrets/` convention a repo's own `OPERATIONS.md` may document. It is a different thing from `spec/secrets.json`, the CI/GitHub Actions secret-name registry `spec/audit.py` cross-checks. `spec/secrets.json` governs what a workflow reads from GitHub Actions. This convention governs what a repo's own process reads from its own checkout. - **The directory is named `.secrets/`, dotted, never a bare `secrets/`.** -- **A secret file's name is lowercase fields joined by `_`** (`homeassistant_db_password`, `mail_relay.env`), per [`CODESTYLE.md` "Script and Utility File Names"](./CODESTYLE.md#script-and-utility-file-names). +- **A secret file's name is lowercase fields joined by `_`** (`widget_db_password`, `widget_mail_relay.env`), per [`CODESTYLE.md` "Script and Utility File Names"](./CODESTYLE.md#script-and-utility-file-names). - **A host secret file a repository installs in `~/.secrets/` is named `_[_]`**, `` being its registry `shortName`, and the `github_` provisioning namespace is unchanged. -- **A single opaque credential file carries no extension** (`homeassistant_db_password`, not `homeassistant_db_password.txt`), the same reason `README` and `LICENSE` carry none. It is a security property, read but never sourced, not a formatting preference. +- **A single opaque credential file carries no extension** (`widget_db_password`, not `widget_db_password.txt`), the same reason `README` and `LICENSE` carry none. It is a security property, read but never sourced, not a formatting preference. - **A structured credential keeps its format's extension** (`.json` for structured config). -- **The shared env file is named for what it configures**, not a bare `.env` (`docker.env` for a repo whose stacks are Docker Compose). A second env-shaped file added later then stays unambiguous. +- **The shared env file is named for what it configures**, not a bare `.env` (`widget_docker.env` for a repo whose stacks are Docker Compose). A second env-shaped file added later then stays unambiguous. - **Every real secret file has a tracked `.example` beside it**, and only the `.example` files plus a `README.md` catalog are un-ignored: ```gitignore @@ -128,7 +137,7 @@ A repo whose own stacks or scripts read local runtime credentials from disk keep !**/.secrets/README.md ``` - A fresh checkout then documents its own required shape without ever exposing a real value. This negation keeps a real secret file out of a **new** commit. It does not remove one already tracked: `.gitignore` has no effect on a path git already follows. A real secret file found tracked is removed from the index (`git rm --cached `) and its credential is rotated, not just added to `.gitignore` going forward. + A fresh checkout then documents its own required shape without ever exposing a real value. This negation keeps a real secret file out of a **new** commit. It does not remove one already tracked: `.gitignore` has no effect on a path git already follows. A real secret file found tracked is removed from the index (`git rm --cached ""`) and its credential is rotated, not just added to `.gitignore` going forward. - **`.secrets/README.md` is a catalog**, one row per file naming what it holds and what consumes it. It adds a short note on how the directory relates to `~/.secrets/` where the repo also touches that. - **A repository whose shell scripts read a credential from disk declares the `host-secrets` type, and reads each one through the carried readers.** A credential is a secret file or an env file holding one, in `.secrets/` or in the host-scoped `~/.secrets/`, and this bullet reaches both. A single inline read counts, since it is the read a bare existence check and a sourced file get wrong. A script sources its carried `lib/fleet/sh/secrets.sh`, per "Hub-Hosted Tooling", and checks the file before reading it. A private file takes `require_secret` or `secret_set_verdict`, and one a container reads as a Docker secret takes `secret_verdict` with `shared`. It reads one value from an env file with `read_env_value` rather than sourcing the file into its own shell. @@ -140,7 +149,7 @@ The fleet's tooling lives in the hub once and a repository runs it from there ra **Code a repository's own runtime executes is the exception, and it is carried.** Such a library runs on a host the project owns, often unattended and sometimes as root. Fetched from the hub at run time, it would let a GitHub outage or a bad `main` commit stop a scheduled host job. It would also run code the repository never reviewed against its own secrets. So offline operation and review in the repository that runs it outweigh the staleness of a copy. A gate differs, since "the tool did not run" is an acceptable answer there and CI is the backstop. The hub hosts the library once. A repository whose declared types select it carries it byte-for-byte, as a tree the hub's `spec/files.json` declares. The hub owns the carried directory whole. The repository extends the library in a file of its own outside it that sources it, never by editing the copy. The staleness is made visible rather than accepted. The repository gate compares each carried tree with the hub tree its pinned action holds. It reports a difference as a warning that never fails the gate. A failure would break every downstream pull request on each hub fix. The audit reports a stale copy, and the resync refreshes it. -**Reaching it is a checkout of the hub rather than a copy of one file.** A tool reads the payloads, tables, and sibling modules beside it. So a single file lifted out of the tree runs against whatever the caller happens to have. That is the copy problem again in a shorter loop. Read `main`, the promoted and gated state, and fetch immediately before running. That is because a clone is whatever it last fetched rather than the branch it names, and a stale clone answers confidently instead of failing. For a repository whose registry entry has merged to `develop` but not yet reached `main`, run `repo-config/configure.sh` and `spec/audit.py` from `develop`. Name the tool by its path in that checkout and name the target explicitly. That is because a tool that defaults to the current directory or the current repository resolves somewhere either way. It is also because a result computed against the wrong repository is well-formed. Which directory the command runs in is the tool's own contract rather than a rule here. So a gate reading a working tree runs in the repository under test. Likewise, a tool taking its target as an argument runs anywhere and is given one. What the rule forbids is letting a default decide which repository the answer is about. +**Reaching it is a checkout of the hub rather than a copy of one file.** A tool reads the payloads, tables, and sibling modules beside it. So a single file lifted out of the tree runs against whatever the caller happens to have. That is the copy problem again in a shorter loop. Read `main`, the promoted and gated state, and fetch immediately before running. That is because a clone is whatever it last fetched rather than the branch it names, and a stale clone answers confidently instead of failing. For a repository whose registry entry has merged to `develop` but not yet reached `main`, run `repo-config/configure.sh`, `scripts/carry.py`, and `spec/audit.py` from `develop`. That run is an exception to the `AGENTS.md` "Fleet Bootstrap" rule that the hub's `main` is ground truth. It exists because these tools resolve a repository through its registry entry, which `main` does not hold yet. Name the tool by its path in the hub checkout holding it, and name the target explicitly. That is because a tool that defaults to the current directory or the current repository resolves somewhere either way. It is also because a result computed against the wrong repository is well-formed. Which directory the command runs in is the tool's own contract rather than a rule here. So a gate reading a working tree runs in the repository under test. Likewise, a tool taking its target as an argument runs anywhere and is given one. What the rule forbids is letting a default decide which repository the answer is about. **A loader is outside this section rather than exempt from it.** The rule above governs a tool that reads hub content, because a tool reads the payloads, tables, and sibling modules beside it. A loader reads none of them. It obtains a tree and hands control to a tool inside that tree, on a host that cannot yet obtain one. The bound is what it may contain rather than who runs it, and it is one line. A loader references no path inside the tree it fetches except the single entry point it hands control to. Everything else it touches is the machine or the network. A loader that grows a second path into that tree has become a tool and is governed above. @@ -152,13 +161,13 @@ The fleet's tooling lives in the hub once and a repository runs it from there ra ## Pull Request Title and Commit Message Conventions -A PR title and a commit message share one contract. The subject is imperative, 72 characters or fewer, and has no trailing period. Vague titles like `update stuff` or `wip` are out, while Dependabot's `Bump X from Y to Z` is fine as-is. Unsolicited `Co-Authored-By:` lines are out. So is any release-bump magnitude in the title, since Nerdbank.GitVersioning computes the next version from `version.json` and git history. +A PR title and a commit message share one contract. The subject is imperative, 72 characters or fewer, and has no trailing period. The 72 measures the authored title or subject, and the `(#N)` suffix a squash merge appends sits outside it. Title case lowercases only the bind words the skill lists, and that list is exhaustive. Vague titles like `update stuff` or `wip` are out, while Dependabot's `Bump X from Y to Z` is fine as-is. An agent may add a `Co-Authored-By:` line unless the user disallows it, and a repository's own rules may change that default. A link to the agent's session, such as a `Claude-Session:` trailer, is never allowed in a commit message or a pull request. Neither the user nor a repository's rules can allow one. Also out is any release-bump magnitude in the title, since Nerdbank.GitVersioning computes the next version from `version.json` and git history. This is packaged as the `comment-and-doc-style` Skill at `.agents/skills/comment-and-doc-style/SKILL.md` in the hub. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. The summary above sketches the contract. Read the skill for the full format, rules, and examples. ## Documentation Style Conventions -The fleet's prose and formatting contract, applied to docs and code/workflow comments alike. It governs what a carried file may reference, Markdown link, heading, and tense structure, and the comment philosophy. It also holds the ASCII character-set tiers, the line-ending policy, and the sentence-structure house style. It bans naming an issue, a pull request, or a commit in a comment, a docstring, or an instruction document. And it holds the rules keeping a quantitative claim honest and an incidental count out of the text. +The fleet's prose and formatting contract, applied to docs and code/workflow comments alike. It governs what a carried file may reference, Markdown link, heading, and tense structure, and the comment philosophy. It also holds the ASCII character-set tiers, the line-ending policy, and the sentence-structure house style. It bans naming an issue, a pull request, or a commit in a comment, a docstring, or an instruction document. And it holds the rules keeping a quantitative claim honest and an incidental count out of the text. It also keeps a command a reader copies and runs safe to paste. This is packaged as the `comment-and-doc-style` Skill at `.agents/skills/comment-and-doc-style/SKILL.md` in the hub. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. The summary above sketches the contract. Read the skill for the full rules. @@ -186,20 +195,25 @@ ASD-STE100's structural half is the adopted house style: short sentences, one in Text refers to an enumeration rather than stating its size, so it writes "the following checks", "each case", or "the rows below". This holds in every fleet repository, for docs, code and workflow comments, and docstrings alike. A stated count is a second copy of what the list or table already shows, and nothing keeps the two copies in sync. Every later edit to the enumeration then owes an edit to the sentence, and a missed one surfaces as a review finding. A word such as "both" or "all three" is a count too, where the list it counts can grow. A count is written only where the number is what the reader needs, such as a limit, a threshold, or a measured result. Such a count names its source, such as the constant or the measurement, so a reader can re-derive it. A wrong incidental count is fixed by removing it rather than by correcting it, since a corrected number goes stale the same way. +### Copy-and-Run Commands + +A command in Markdown is text a reader copies and runs, so it has to run as written once pasted. That covers a code span opening with a command and every line of a shell fence. Such a command holds no bare ``, since the shell reads `<` as a redirection and the paste dies before the command runs. It holds no bracketed `[Placeholder]` either, since the shell reads that as a glob. The glob expands silently to any one-character file it matches. And it holds no bare `a|b` alternation, since the shell reads that as a pipe. The left-hand side then still runs, a live write included, while its own output vanishes behind an error from the right-hand side. A real pipe is spaced, so it never reads as an alternation. A placeholder is quoted instead, as in `git branch -d ""`, so the shell reads it as one word rather than as syntax. The quotes wrap the placeholder alone where its value may need the shell to expand it, such as a path opening `~`. The reader fills the value in inside the quotes. A value that is several arguments, such as a command and its own arguments, or one the shell must expand, replaces the quotes too. A single argument holding spaces keeps them. Inside a string handed to a second shell, such as the one `sh -c` runs, the placeholder is quoted within that string. A choice between values is written as the common value, with the other named in a parenthetical after the command. So `repo-config/configure.sh check "/" release` is followed by "(substitute `operational` for an operational repo)". In a shell fence that parenthetical is a trailing comment instead. An optional flag is not written in brackets, since that is a glob too. It is left out of the command and named in the parenthetical. The rule holds for every such command, one naming a single argument in prose included. That is because whether a reader pastes a span whole is a judgment no check can make. The prose gate's `paste-safe` rule enforces it for the commands its data file names. It also reads a string handed to a second shell, as `su -c`, `sh -c`, `bash -c`, and `ssh` take one, as the command that shell runs. + ## Verification Discipline The checks that separate work actually done from work that merely reports success. A pattern that matches less still exits zero, and a gate that stops gating still reports success. - **Locate every check a change owes before running any of them, and CI's coverage is not that list.** The checks are read from what the repository declares, rather than inferred from whatever the pipeline happens to run. What it declares means its `OPERATIONS.md` "Local Verification" section alongside the workflows. Part of a repository's contract is routinely unreachable from a runner. Examples are a redirect no build serves, a deploy no pull request performs, and hardware no runner holds. So the check covering that part lives in a document rather than in a workflow. It is run by hand before the pull request opens. Green is then the precise signal that it was skipped. That is because the pipeline reports success over the half it reaches while saying nothing about the half it cannot. Reading a document's own description of itself is not how such a check is found. That is because a topical document is named for its most visible function, usually a post-merge one. It is also because an accurate description of that function routes a pre-merge task away from the file holding the gate. The destination is declared fleet-wide for that reason, rather than left to how well each repository worded a pointer to it. A repository whose `OPERATIONS.md` carries no such heading, or carries no such file, is missing content it owes. In that case, read that file whole where it exists, and the workflows beside it either way. Report what is absent rather than reading its absence as an answer that no local check applies. - **A test runner failing to spawn is not evidence that no test coverage applies here.** `uv run pytest` failing to spawn in a lint-only Python Scripts profile is that profile working as intended, not a missing dependency. The `python-codestyle` Skill's Two Profiles section states this. Read the actual invocation from the same `OPERATIONS.md` "Local Verification" section the bullet above names, rather than guessing a generic test-runner command. Report that document's own command result, not the guessed command's failure. -- **A test must assert the mechanism it names, and a gate has to be watched failing.** Label each case by the behavior it proves, then write the case that reintroduces the fault and confirm the gate objects to it. A case that passes for an incidental reason, the right answer reached by the wrong path, is worse than no case. That is because it is later cited as evidence. A proof that restates the gated data instead of reading it proves only that the function works. So drive the real table or the real config. And a gate that finds nothing is indistinguishable from a gate with nothing to find, so assert a floor on what a healthy run covers. +- **A test must assert the mechanism it names, and a gate has to be watched failing.** Label each case by the behavior it proves, then write the case that reintroduces the fault and confirm the gate objects to it. A case that passes for an incidental reason, the right answer reached by the wrong path, is worse than no case. That is because it is later cited as evidence. A proof that restates the gated data instead of reading it proves only that the function works. So drive the real table or the real config, read as data. A call that would change state as "Repository Boundaries and Write Safety" bounds it is still stubbed or dry-run. And a gate that finds nothing is indistinguishable from a gate with nothing to find, so assert a floor on what a healthy run covers. - **Gates, filters, and gate-like watchers fail loud, never narrow quietly.** A pattern that silently matches less, an allowlist that silently stops matching, or a gate that silently stops gating all report success while doing nothing. When a construct exists to notice something, make the not-noticing case produce an error or an annotation. An identity allowlist used as a gate, for one, must raise an error when its list stops matching, not silently pass everything through. - **Config with a uniqueness rule is validated on read, and its consumers assert what it promised.** A repeated key in a lookup table is not a precedence question to settle quietly. It is two answers to one question. Keeping whichever came last picks one of them where the reader sees no choice being made. Fail on the duplicate at the point the config is read, so the code downstream can rely on the invariant instead of re-deriving it. - **Validate and read on the same normalized key.** A guard that compares stripped names while the join looks up the raw one passes a padded key and then matches nothing. So the exact fault the guard exists to stop is sitting inside the guard. Normalize once at the boundary and use that one value for both the check and the lookup. -- **Every push toward a pull request is preceded by a local adversarial review of the branch's whole diff, and the pass is recorded.** The rule binds every push rather than the first one. So a fix push answering a reviewer's finding owes a pass exactly as the branch's first push did. That is the round it is actually skipped on. The fix looks small, the branch was reviewed once already, and what goes up is content no review has read. Skipping it does not save the round. It moves it into the fix-commit and review-comment cycle, which spends wall-clock, Actions runtime, and agent tokens finding what a local pass would have. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's. `scripts/local_review.py` records it keyed on the content the reviewer actually saw. So a capture point can ask whether a receipt still covers what is about to be pushed. It need not trust the rule to have been remembered. The pass is mandatory and its findings are advisory, which are opposite claims worth keeping apart. A pass is recorded whether it raised ten findings or none. Disposing of each one is judgment, per `GOVERNANCE.md` "PR Review Etiquette". -- **Canonical content one repo authors and others carry is read the way a carrier reads it, whole, in the repo that can fix it. That read is swept periodically rather than owed by a push.** Such content is written and merged against a diff of a few lines. It reaches a reviewer as a new file, in full, only when a repo carries it for the first time. So the first real read of a rule happens where nothing can be done about the result. That is because the tree is manifest-owned, and the copy is compared against the authoring repo's, byte for byte wherever the declared fidelity is verbatim. It is also because a local edit there is drift on the next fidelity check. Where the fidelity is intent the carrier may adapt its own copy. The defect still has to be fixed at the source, since every other carrier holds it too. Every carrier after that re-discovers the same defect. The finding arrives in a session holding no checkout of the authoring repo and no standing to test the claim. The unit is what a reviewer reads whole. The carry manifest, `spec/files.json` in the hub, rather than the document decides what is a unit, down to which files carry units at all. So the engine that reads that manifest is the authority on the set rather than any restatement of its rules. In the ordinary case a unit is one level-two section of a carried Markdown canonical, which is the fidelity unit `spec/section-model.md` declares. The read is of the unit's whole current text rather than of the diff that moved it. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's, exactly as they are for the pass above. **The read is swept because owing it at every push cost too much to keep owing it there.** Measured across this fleet's review rounds, the passes a push owed were a large share of what a pull request spent. What they returned was never measured against that. So the read moves to a schedule on the cost alone, rather than being owed by whichever change happens to touch a unit. A change that moves a unit is no longer refused over one. No capture point asks a change for a pass of this kind. The diff pass the bullet above requires is owed by every push exactly as before. What replaces the per-push read is a schedule in the authoring repo. It gathers the work into one piece and files it where an agent session can run the passes and fix what they find. That work is every unit whose text has moved past the pass that read it. That work also covers a bounded slice of the units nothing has read there at all, taken newest-committed first. The slice is what keeps a newly authored unit from waiting on a volunteer. That is because such a unit has no earlier pass to move past. It is also because such a unit would otherwise reach a carrier with nothing having asked to read it. That is the case this whole rule is about. A unit newly carried by widening the manifest alone is not reached that way. The order reads the unit's own file rather than the manifest. So such a unit joins the backlog at that file's age. There a section written and declared in one commit leads like any other newly authored one. Bounding it is what keeps a long backlog from arriving as one week's work. `scripts/canonical_review.py` records each pass keyed on the content the reviewer saw, and names both sets. So the sweep's list is read off that record rather than remembered. Its ledger is tracked content the change carrying it commits like any other. Like the pass above, a pass the sweep asks for is mandatory and its findings are advisory. +- **Every push toward a pull request is preceded by a local adversarial review of the branch's whole diff, and the pass is recorded.** The rule binds every push rather than the first one. So a fix push answering a reviewer's finding owes a pass exactly as the branch's first push did. That is the round it is actually skipped on. The fix looks small, the branch was reviewed once already, and what goes up is content no review has read. Skipping it does not save the round. It moves it into the fix-commit and review-comment cycle, which spends wall-clock, Actions runtime, and agent tokens finding what a local pass would have. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's. The hub-hosted `scripts/local_review.py` records it keyed on the content the reviewer actually saw. So a capture point can ask whether a receipt still covers what is about to be pushed. It need not trust the rule to have been remembered. The pass is mandatory and its findings are advisory, which are opposite claims worth keeping apart. A pass is recorded whether it raised ten findings or none. Disposing of each one is judgment, per `GOVERNANCE.md` "PR Review Etiquette". +- **Canonical content one repo authors and others carry is read the way a carrier reads it, whole, in the repo that can fix it. That read is swept periodically rather than owed by a push.** Such content is written and merged against a diff of a few lines. It reaches a reviewer as a new file, in full, only when a repo carries it for the first time. So the first real read of a rule happens where nothing can be done about the result. That is because the tree is manifest-owned, and the copy is compared against the authoring repo's, byte for byte wherever the declared fidelity is verbatim. It is also because a local edit there is drift on the next fidelity check. Where the fidelity is intent the carrier may adapt its own copy. The defect still has to be fixed at the source, since every other carrier holds it too. Every carrier after that re-discovers the same defect. The finding arrives in a session holding no checkout of the authoring repo and no standing to test the claim. The unit is what a reviewer reads whole. The carry manifest, `spec/files.json` in the hub, rather than the document decides what is a unit, down to which files carry units at all. So the engine that reads that manifest is the authority on the set rather than any restatement of its rules. In the ordinary case a unit is one level-two section of a carried Markdown canonical, which is the fidelity unit `spec/section-model.md` declares. The read is of the unit's whole current text rather than of the diff that moved it. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's, exactly as they are for the pass above. **The read is swept because owing it at every push cost too much to keep owing it there.** Measured across this fleet's review rounds, the passes a push owed were a large share of what a pull request spent. What they returned was never measured against that. So the read moves to a schedule on the cost alone, rather than being owed by whichever change happens to touch a unit. A change that moves a unit is no longer refused over one. No capture point asks a change for a pass of this kind. The diff pass the bullet above requires is owed by every push exactly as before. What replaces the per-push read is a schedule in the authoring repo. It gathers the work into one piece and files it where an agent session can run the passes and fix what they find. That work is every unit whose text has moved past the pass that read it. That work also covers a bounded slice of the units nothing has read there at all, taken newest-committed first. The slice is what keeps a newly authored unit from waiting on a volunteer. That is because such a unit has no earlier pass to move past. It is also because such a unit would otherwise reach a carrier with nothing having asked to read it. That is the case this whole rule is about. A unit newly carried by widening the manifest alone is not reached that way. The order reads the unit's own file rather than the manifest. So such a unit joins the backlog at that file's age. There a section written and declared in one commit leads like any other newly authored one. Bounding it is what keeps a long backlog from arriving as one week's work. The hub-hosted `scripts/canonical_review.py` records each pass keyed on the content the reviewer saw, and names both sets. So the sweep's list is read off that record rather than remembered. Its ledger is tracked content the change carrying it commits like any other. Like the pass above, a pass the sweep asks for is mandatory and its findings are advisory. - **Another round of edits after either pass is owed only while a defect this change introduced or fixes in place is open.** A finding count never owes one. Which findings count as introduced, what each class owes, and how many rounds a push may spend are the `local-strict-review` Skill's. - **Run the repo's whole lint gate before every push, not the parts that look relevant.** CI runs all of them, so a partial local run only defers the failure. The tool most likely to catch a given change is often the one it seems least about. An edit that manipulates line endings is exactly when `editorconfig-checker` matters. The repo documents each linter's known-working invocation, and this rule is that **all** of them run. +- **Run the repo's whole test suite before every push, not the modules a change touches.** Run it in the invocation `OPERATIONS.md` "Local Verification" declares, as the bullets above require. CI runs every case a runner can reach, so a partial local run only defers the failure, as it does for the lint gate. A suite can hold tests that judge every file in the tree, so a change can fail a module it never touched. - **Editing CRLF files programmatically: `.` matches `\r` in a regex**, so a captured line keeps its carriage return and rejoining with `\r\n` yields `CRCRLF`. Prefer literal replacement over regex reassembly. In Python the *default* path is a text-mode rewrite, which has the mirror failure. `Path.read_text()` decodes through universal newlines and `write_text()` translates each `\n` back to `os.linesep`. So a read-edit-write round trip rewrites every line ending in the file to the host's own while the edit itself looks correct. Work in bytes, or open the file explicitly with `newline=''` on both the read and the write. That is because a read that preserves the endings still hands them to a write that translates them. Use `open()` rather than `Path.read_text()`, which accepts that argument only on Python 3.13 and newer and raises `TypeError` below it. The corruption is worth naming because it is invisible in a rendered diff. - **Scope a check by what the project declares, not by the file that prompted it.** A check written while editing one file tends to cover that file's language and stop. It then reports success on every other surface the rule governs. Read the declared types, or the config that enumerates them, and cover each one. Then assert a floor per surface, so a table that narrows fails loudly instead of passing quietly. A rule about comments means every comment syntax the project ships. A format that carries comments in practice counts even where its specification says otherwise. - **Never write source text carrying backslash escapes through a shell construct that interprets them.** A `printf` format string, a `printf` argument consumed by `%b`, `echo -e`, POSIX `sh`'s builtin `echo`, and `$'...'` each consume the escape. Each writes an invisible control character in its place. So a `\b` inside a regex becomes a backspace, and the pattern silently matches nothing while every test still passes. A quoted heredoc, `<<"EOF"`, is not one of those constructs and writes every backslash literally. An unquoted `< main promotion whose head round states no coverage has further ways to be covered, which the `pr-review-conduct` Skill's Merge Gate states. Triage every finding, including low-confidence findings collapsed into the review body rather than threads. Reply to and resolve every addressed finding. Repeat after every fix until the checks are green, the current head is covered, and no finding is left open. Only an explicit maintainer instruction may stop, defer, or alter this default. Silence or a request that says only "open a PR" is not such an instruction. Never merge on a green or CLEAN merge state alone. That state does not prove the review covered the current head SHA and full diff. It also does not expose unanswered low-confidence findings that opened no thread. +The provider-agnostic review-loop contract every fleet repo follows starts when a pull request opens. Open every fleet-owned pull request ready for review. Draft state is reserved for the separately documented upstream contribution workflow while a third-party contribution is still being prepared. Creating the pull request is not a terminal handoff. Run the review status once in the foreground. Then start the bounded review wait in a background process. Which bots review which pull requests, when, and how often is the repository's review policy. That policy is the `review` section of `.github/agent-policy.json`, or the hub's `spec/agent-policy.default.json` where the repository states none. The review wait reads that policy from the pull request's base branch. It sends each request the policy asks it to send. A bot the policy marks automatic is left to start on its own, except a gated Copilot, whose missed start it fills. So the loop below runs the same whether a repository's reviews arrive automatically or on request, and nothing here names which. Under the hub default, a Copilot review is requested at one defined moment rather than on every push. That moment is the head of a pull request into the default branch, a promotion among them. The review wait also requests one on any other pull request where a partial round or a truncated review history is on record. On a pull request into any other branch, every head is covered instead by the recorded local pass the push already owes. That pass is published to the pull request so the review status can read it. The `pr-review-conduct` Skill's Merge Gate states when that published pass counts as coverage. Confirm that the current head SHA is covered by a review or, on such a pull request, by that published pass. Also confirm that a review covers the full diff rather than only part of it. Where no round covering the head states coverage, a round covering it whose own file table names exactly the changed files covers it. That is the reading a Copilot round at Balanced review effort gives. Where no round covering the head carries its own table, the newest round that does stands in where its table names exactly the changed files. The bound is that file set rather than file recency. The carry exists for a later head that changed those files and drew a round with no table of its own. Either table may leave out an added, modified, renamed, or deleted file with no changed line, such as a binary. That holds while some changed file has one. A table stands in only where no Copilot round on the pull request, on any commit, states partial coverage. So a pull request that ever had a partial round goes to the maintainer. A pull request into the default branch, a promotion among them, can have further ways to be covered where its head round states no coverage. The `pr-review-conduct` Skill's Merge Gate states them. Triage every finding, including low-confidence findings collapsed into the review body rather than threads. Reply to and resolve every addressed finding. Repeat after every fix until the checks are green, the current head is covered, and no finding is left open. Only an explicit maintainer instruction may stop, defer, or alter this default. Silence or a request that says only "open a PR" is not such an instruction. Never merge on a green or CLEAN merge state alone. That state does not prove the review covered the current head SHA and full diff. It also does not expose unanswered low-confidence findings that opened no thread. This is packaged as the `pr-review-conduct` Skill at `.agents/skills/pr-review-conduct/SKILL.md` in the hub. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. The summary above sketches the contract. Read the skill for the merge gate, the expected loop, and how a finding is closed. @@ -253,7 +268,9 @@ The hub's `scripts/pr_review.py` implements the provider-specific mechanics this - **Reference every pull request as a clickable link.** When you mention a PR on a surface that renders Markdown (chat, a summary, a report), render it as a Markdown link to the PR. Write it as `[#N](https://github.com/OWNER/REPO/pull/N)`, never a bare `#N`. The same applies to issues and commits. **The form follows the surface.** Some surfaces link neither a Markdown link nor a bare URL, an interactive prompt's question and option text among them. Pasting a full URL into one of those does not rescue it, since the reader gets a string to copy. That is the outcome this rule exists to prevent. There the reference is a bare `#N`. The clickable link goes in the message that comes **before** the prompt rather than merely alongside it. That is because the prompt blocks on an answer, and a message emitted after it is read once that answer is already given. That is the one moment the link is no longer any use. The test is whether the reader can click it where it is read, not whether it was written in the syntax that works elsewhere. - **Put a command the user must run where the user can run it.** This session's input line is where the user types to the agent. A command runs outside this session where this session's input line cannot run it or cannot hold its effect. One waiting on typed input, such as a password or a confirmation, is such a command. So is one meant for another host, or one setting a variable the session reads at launch. Every other one runs at this session's input line, where that line can run a command, and outside the session otherwise. **A command the user runs outside this session goes in the question's own text.** Where a question asks the user to run one, the question carries the exact command, complete and ready to paste. A message before the prompt may repeat the command, but the question never points at that message. A question pointing at it can leave the reader to find the command among a long run of earlier output. Such a command stays in the prompt, where the turn opens one, although the clickable-link bullet above moves a link out of one. The command needs no rendering, since the prompt shows it as plain text the reader can copy. **A command the user runs at this session's input line never goes in an interactive prompt.** On Claude Code such a command is a `!` line, typed at the session's input line so its output lands in the session. While an interactive prompt is open, the user cannot type at the session's input line. So a command placed in one sits in the one surface that blocks running it. It goes in a plain message instead, as a fenced block holding the `!` line itself, complete and ready to paste. Several commands join on that one line with `&&`, which runs them in order and stops at the first that fails. The block opens the message. Any question the same turn owes follows it as a numbered list, and any report comes after both. The message asks the user to reply once the command has run, and the turn ends with no interactive prompt open. The agent then checks the result on the user's next message. It reads back the state the command was meant to change, or the output it left in the session. An answer saying the command ran is not that check. -- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". +- **Ask when the user can cheaply confirm.** An assumption that saves one question and is wrong costs the rework plus the trust. So a genuine ambiguity in intent, scope, or authorization is raised, not resolved by picking the likelier reading. Rules that already answer the question (the committed instruction set) are not ambiguity, so read them first rather than asking what they state. +- **The irreversible step (merging, publishing, releasing, force-pushing, deleting, changing branch protection) stays the maintainer's.** **A grant given in a past session or for a different task authorizes nothing now.** Whether a credential's reach or a tool that happens to work authorizes anything is answered by `GOVERNANCE.md` "Repository Boundaries and Write Safety" rather than here. +- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. **Each question reads whole from its own text.** It states the problem, why it is being asked, and what each option does, in plain words. It may cite an issue or a pull request by number. The question and its options still read fully without opening it. A question leaning on an issue for its meaning is often answered without reading that issue, so the answer misses its point. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". - **Raise work blocked on the user as a direct interactive prompt.** When progress needs a decision, an authorization, or an answer only the user can give, ask for it at the point the work stops. Ask through the interface's own prompt mechanism. Never leave it as prose in a summary. A handoff buried in a paragraph is a handoff that did not happen. That is because a summary reads as a report of finished work. It is also because the one line still waiting on the user is the easiest in a summary to skim past. The blocked item is the message, not a closing remark on a message about something else. **The options offered are the actions themselves.** The one that unblocks the work names the action it authorizes ("squash and merge it"). Selecting it is then the go-ahead rather than a note to act on later. Offering only ways to wait is the same failure in interactive clothing. That is because a prompt whose every choice is inaction reports the block rather than clearing it. Where the agent may not perform the authorized action itself, the option says who does it. Where no interactive prompt is available, the numbered list the bullet above names is the fallback. In a turn asking for a command the user runs at this session's input line, the command bullet above replaces the interactive prompt. - **Lead every choice with a recommendation and its reason.** Wherever the user is asked to choose, in a prompt or in a numbered list, the option the agent recommends comes first. It is marked as the recommendation, and every option states the reason for it. A user who takes the recommendation then reads one line, and one who does not sees what the other options trade away. A question with no defensible recommendation says so rather than inventing one. Where an open question has no options and the agent does have an answer, that answer and its reason go in the question's text. They never go in as an invented option. - **A question filed as an issue is parked rather than asked, and it stays owed.** Where the work cannot continue without the answer, the interactive-prompt bullet governs and the question is asked at the point the work stops. Wherever the question is recorded rather than asked, recording it is the right thing to do, and recording it is still not asking it. That holds whether the work can continue without the answer or the question was asked once and deferred. So the issue carries the fleet's `decision` label. When the filing session knows the choices the question is between, the issue states them. The label and the stated choices are what let a later session, one that was not there when the issue was filed, find the question. That session can then put the question to the user without inventing its answers. **The parked queue is the failure, not the parking.** An issue holding a question the user has never seen reads to every later session as tracked work rather than as a block. So each session files correctly and moves on. Presenting the accumulation is the step nobody owns. @@ -268,11 +285,12 @@ These conventions bind every workflow. [`WORKFLOW.md`](./WORKFLOW.md) section 4 An overlap with `WORKFLOW.md` resolves **by subject**, never by blanket precedence. This section keeps the full style rules and wins on them, stating each in more detail than the guarantee that carries it. `WORKFLOW.md` wins on the architecture, the contract, and the test methodology. `WORKFLOW.md` section 2 points at this section rather than restating it. Throughout, a job is named by its id and a step by its `name:`. The `workflow-ci-contract` Skill at `.agents/skills/workflow-ci-contract/SKILL.md` in the hub surfaces it. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. - **Action pinning**: pin **every** action, first-party (`actions/*`) and third-party alike, to a commit SHA with a trailing comment naming the release tag at that SHA. Renovate / Dependabot can then still bump it, but a tag swap can't change the executed code. The comment spells the tag exactly as the referenced repository publishes it. That is `# vX.Y.Z` where its tags carry a `v`, and the bare tag, `# X.Y.Z`, where they do not. So the comment never names a tag that does not exist. This binds a `uses:` wherever it appears, in a workflow and in a composite action under `.github/actions/**` alike. The exception is a local (`./`) reference or a self-repository (`$/`) one, which names no ref to pin. In a workflow file, `$/` is GitHub's syntax for a path in the repository holding that file, resolved at that file's own commit. Use a major-only comment, `# vX` or the bare `# X` by the same spelling rule, only where a condition holds. That condition is that the upstream's floating major tag doesn't correspond to a specific patch/minor release SHA. That is because pinning to the floating-tag SHA still gives the SHA guarantee, and the version comment just records the major line. Documented exception (no SHA pin at all): `dotnet/nbgv` is consumed via `@master`. That is because the upstream tag stream lags `master` substantially and Dependabot's tag-tracking would propose a downgrade. **This applies to repo-owned build-layer leaves too**, since a leaf owning its build specifics is not a reason to use floating tags. It is also because Dependabot still bumps SHA pins (updating the SHA + version comment). +- **Checkout credentials**: every `actions/checkout` step sets `persist-credentials: false`. Left at its default, the action writes the token it checked out with into the checkout's git configuration. Every later step in that job, and anything such a step runs, can then read a credential it was never handed. The action still authenticates its own fetch through its `token` input either way. A job whose later step runs an authenticated git command against the remote, such as a push or a fetch, keeps the credential instead. Its checkout step then sets `persist-credentials: true`, with a comment above that line naming the step that needs it. An action that configures its own git credential from its own `token` input, such as `peter-evans/create-pull-request`, is not such a step. - **Filename**: a workflow declaring `on: workflow_call` ends in `-task.yml`, **whatever else it is also triggered by**, since that is the half the suffix is about. A workflow without `workflow_call` is an entry point (`push`, `pull_request`, `pull_request_target`, `schedule`, `workflow_dispatch`) and takes no `-task` suffix. It ends instead with what it does: `-pull-request.yml`, `-release.yml`. The suffix says the file is meant to be `uses:`-d, which stays true of a file that is also dispatchable. Composite actions are named by their path (`.github/actions//action.yml`), so these suffix rules do not reach them. - **Workflow `name:`** (the top-level `name:` field): a workflow declaring `workflow_call` takes a name ending in **"task"** (e.g. `Build project release task`). That matches the filename rule above and covers a file that is also dispatchable. Every other workflow takes one ending in **"action"** (e.g. `Publish project release action`, `Test pull request action`). The suffix tells an orchestrator from a callee while reading the source tree, and on the runs list for an entry point. It does not do that in the Actions UI for a callee. A called reusable workflow's jobs appear nested inside the caller's run as ` / `. And the runs list shows the caller's workflow name rather than the callee's own. - **Job and step `name:` suffixes**: every job's `name:` ends in **"job"** and every step's `name:` ends in **"step"**. That includes the PR-gate aggregator. The name its `pull_request` run posts is a required-status-check `context:` in a branch ruleset (`Check pull request workflow status job` in `test-pull-request.yml`). Where another event also triggers the workflow, the `name:` is the expression form `WORKFLOW.md` D1.5 requires. Each string that expression yields ends in "job" too. A trailing parenthetical qualifier after the suffix is allowed and is the only exception (`Upload coverage to Codecov step (Python)`), and nothing enforces the rule mechanically. A ruleset-bound job's `pull_request` name and its ruleset `context:` are the **same string**: rename them **together**, or required-status-check enforcement silently breaks. Every surface whose staleness breaks that enforcement moves in the same change, never one without the others. In a repository the surfaces are the live ruleset and its own workflow. A rename of the fleet-wide string additionally moves the hub's `repo-config/` payloads and its `spec/files.json` `requiredCheckName`. It also moves each adopter-facing stub in its `catalog/` and `docs/reusable-workflows.md`. Those surfaces exist only in the hub. Prose naming the old string goes stale rather than breaking, and follows behind. - **Concurrency**: top-level workflows declare `concurrency: { group: '${{ github.workflow }}-${{ github.ref }}', cancel-in-progress: true }` so a fresh push supersedes an in-flight run on the same ref. `cancel-in-progress: false` queues instead of cancelling, and queuing is not ordering. GitHub holds at most one pending run per group, and cancels the previously pending one when a newer run queues. So the guarantee it buys is that a **running** job finishes, rather than that every event runs in arrival order. **Documented exceptions** follow, each cited by number, never restated, in the comment above its implementing workflow's `concurrency:` key. (1) A merge-bot workflow keys the group on the **PR number** (`-${{ github.event.pull_request.number }}`) rather than on `-${{ github.ref }}`. Under `pull_request_target` the ref is the base branch, and keying on it would serialize every bot PR against it. The workflow takes `cancel-in-progress: false`, because cancelling mid-flight would leave auto-merge enabled or disabled inconsistently (`.github/workflows/merge-bot-pull-request.yml`). (2) A publisher keeps the ref-scoped group with `cancel-in-progress: false`. Cancelling a run can leave a partially pushed tag set or a half-created release. A newer run replaces the group's one pending run. So a push the publish plan does not publish appends `github.run_id` to the group, per `WORKFLOW.md` D7.1 (`catalog/snippets/workflows/publish-release.yml`). A `schedule` run on a publisher whose schedule never publishes does the same. The hub's own publisher is dispatch-only and omits the suffix. (3) A deploy workflow keys the group on the **environment** it deploys, with `cancel-in-progress: false`. That is because a cancelled deploy leaves a release uploaded and the pointer unflipped. (4) A workflow whose only write is one repository-scoped issue keys on the **workflow alone** with `cancel-in-progress: false`. That is because nothing it writes varies by ref. So a ref-scoped group would separate a scheduled run, which always runs on the default branch, from a dispatch made anywhere else. Each would then read no open issue and each would file one. A further reason is that a cancel between two writes can leave the first landed and the second unmade. (5) A workflow whose writes go to fixed branches regardless of the triggering ref keys on the **workflow alone** with `cancel-in-progress: true`. A ref-scoped group would let a dispatch from one ref and the scheduled run race on the same branches. Each run regenerates the whole branch and its pull request, so a newer run rewrites whatever a cancelled run left (`catalog/snippets/workflows/run-periodic-codegen-pull-request.yml`). -- **Shells**: every bash surface, a multi-line `run:` block and every committed bash script alike, starts with `set -Eeuo pipefail`. That means fail fast, fail on undefined vars, and fail on a failed pipe segment. It also lets an `ERR` trap inherit into functions, subshells, and command substitutions (`-E`). A shebang naming bash makes a script one whatever its extension. A single-line `run:` block is outside the rule. A one-liner that pipes or chains commands takes a multi-line block instead, since without `pipefail` a failed producer reads as success. The `-E` is defense in depth. The fleet ships no `ERR` trap today, so a script that later adds one inherits the behavior instead of silently losing it. A deliberately POSIX `#!/bin/sh` surface is not a bash surface. In practice that is a git hook that must run before any toolchain exists. It takes `set -eu`, dropping `-E` and `pipefail`, which `sh` does not carry. +- **Shells**: every bash surface, a multi-line `run:` block and every committed bash script alike, starts with `set -Eeuo pipefail`. That means fail fast, fail on undefined vars, and fail on a failed pipe segment. It also lets an `ERR` trap inherit into functions, subshells, and command substitutions (`-E`). A shebang naming bash makes a script one whatever its extension. A single-line `run:` block is outside the rule. A one-liner that pipes or chains commands takes a multi-line block instead, since without `pipefail` a failed producer reads as success. The `-E` is defense in depth. The fleet ships no `ERR` trap today, so a script that later adds one inherits the behavior instead of silently losing it. A deliberately POSIX `#!/bin/sh` surface is not a bash surface. In practice that is a git hook that must run before any toolchain exists. It takes `set -eu`. POSIX sh defines no `ERR` trap for `-E` to carry, and dash reads `-E` as its emacs editing option instead. A dash that predates its `pipefail` option rejects `set -o pipefail`, so the bash form aborts such a hook there. - **Conditionals**: multi-line `if:` uses the folded scalar `if: >-`, which joins the wrapped source lines back into one line. `WORKFLOW.md` D9.3 requires it. A literal block (`if: |`) evaluates the same, the expression lexer skipping newlines along with other whitespace. So this is a legibility rule rather than a correctness one, and it binds as a guarantee regardless. - **Boolean inputs**: a workflow triggered both via `workflow_call` and `workflow_dispatch` declares each boolean input in *both* trigger blocks. That is because one declaration does not propagate to the other. Which context reads it then decides the comparison, and the two are not the same. The `inputs` context **preserves the declared boolean** on both paths, so `if: ${{ inputs.foo }}` is read directly. The `github.event.inputs` context delivers **every** input as a string whatever its declared type, so a read through it is compared against `'true'`. Comparing a `github.event.inputs` read against the boolean `true` as well is dead rather than defensive. An operand-type mismatch casts each side to a number, and a non-numeric string casts to `NaN`. `NaN` compares equal to nothing, so `github.event.inputs.foo == true` is false even on the run where the input arrived as `true`. A both-forms comparison on an `inputs` read is merely redundant. `WORKFLOW.md` D7.3 is the contract this bullet's rationale serves, and wins on any disagreement. - **Validate input/state consistency at entry, fail fast**: this applies when a workflow's inputs must satisfy a cross-input or input-versus-derived-state invariant. Examples are the release branch having to match the computed version's prerelease status, or two inputs being mutually exclusive. Assert the invariant **once** at entry, before any expensive build or publish work, rather than as partial checks scattered deep in later jobs. One gate that fails fast with a clear `::error::` beats a late or one-directional check. Where later **jobs** depend on the assertion, it is a job of its own that they `needs:`. That is because `needs:` takes job ids and cannot name a step. Where the work it guards is in the same job, an entry step in that job is enough. Examples: `build-release-task.yml`'s `validate-release` job (branch-versus-prerelease, both directions), and the input-validating entry step in `publish-docker-readme-task.yml`'s own first job. That job also resolves the repository list, so a consumer of it depends on that job rather than on the validation alone. @@ -303,7 +321,7 @@ Contributors commit to this repo with signed commits. This repo ships no committ Every repo's GitHub repository details (the About panel) follow a fixed convention so the fleet stays consistent and self-describing. -- **Description** is one canonical sentence that carries to the README, the About panel, and (for a Docker repo) the Docker Hub short description alike. It is at most **100 characters**, Docker Hub's short-description cap and the tightest surface it feeds. Once a repo declares `registry/repos.json`'s optional `description` field, that field is the source, itself link-free plain text on one line for the same reason. `repo-config/configure.sh apply` writes it to the About panel directly. The README's **tagline** (its first non-empty line after the `#` H1 heading) follows it rather than the other way around. A repo that has not adopted the field yet keeps the pre-existing convention. There the README tagline is the source of truth, and the About panel is set from it by hand (`gh api -X PATCH repos// -f description=...`). `spec/audit_markdown.py`'s `description_findings()`, which the audit runs, reports drift either way, falling back to the tagline when no field is declared. It is that one line and not the paragraph it opens: a README may carry further paragraphs below the tagline, and no mirror reads them. When the current description is *more specific* than the declared source (a chip revision or variant it omits), surface the drift to the maintainer. Do not silently discard the detail. The fix there is to sharpen the declared source so the other mirrors follow it. Docker Hub receives it from the About panel, which the docker-readme task reads at publish time. So an About panel left diverged from the canonical value is carried onward rather than corrected there. +- **Description** is one canonical sentence that carries to the README, the About panel, and (for a Docker repo) the Docker Hub short description alike. It is at most **100 characters**, Docker Hub's short-description cap and the tightest surface it feeds. Once a repo declares `registry/repos.json`'s optional `description` field, that field is the source, itself link-free plain text on one line for the same reason. `repo-config/configure.sh apply` writes it to the About panel directly. The README's **tagline** (its first non-empty line after the `#` H1 heading) follows it rather than the other way around. A repo that has not adopted the field yet keeps the pre-existing convention. There the README tagline is the source of truth, and the About panel is set from it by hand (`gh api -X PATCH "repos//" -f description=...`). `spec/audit_markdown.py`'s `description_findings()`, which the audit runs, reports drift either way, falling back to the tagline when no field is declared. It is that one line and not the paragraph it opens: a README may carry further paragraphs below the tagline, and no mirror reads them. When the current description is *more specific* than the declared source (a chip revision or variant it omits), surface the drift to the maintainer. Do not silently discard the detail. The fix there is to sharpen the declared source so the other mirrors follow it. Docker Hub receives it from the About panel, which the docker-readme task reads at publish time. So an About panel left diverged from the canonical value is carried onward rather than corrected there. - **Topics** are optional, and any that are present match the repo's actual content. Do not invent topics to fill the field. - **Include in the home page**: Releases on, Deployments off, Packages off. These toggles are UI-only, since the REST and GraphQL APIs neither read nor write them. So they are set by hand and cannot be audited through `gh`. From d92b834b58eb10b1beb00e61c8bfd9ecb97be1de Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 25 Nov 2026 19:23:34 -0800 Subject: [PATCH 2/5] Re-Vendor the Carried Skills Tree from the Hub Carries .github/skills from the hub with carry.py apply. Every replaced file matched a past hub revision, and the tree gains and loses no path. Co-Authored-By: Claude Opus 5.5 --- .github/skills/add-host-tool/SKILL.md | 11 +- .github/skills/agent-conduct/SKILL.md | 22 +- .github/skills/audit-a-repo/SKILL.md | 14 +- .github/skills/backlog-burndown/SKILL.md | 238 ++++++++++++------ .../branching-and-release-model/SKILL.md | 54 +++- .../branch-protection-and-promotion.md | 36 ++- .../references/release-publish-mechanics.md | 4 +- .../carried-instruction-file-guard/SKILL.md | 2 +- .github/skills/check-this-repo/SKILL.md | 11 +- .github/skills/comment-and-doc-style/SKILL.md | 51 +++- .../references/carried-doc-references.md | 18 +- .github/skills/decision-triage/SKILL.md | 8 +- .github/skills/dotnet-codestyle/SKILL.md | 66 +++-- .../references/conventions.md | 37 ++- .../references/project-config.md | 8 +- .../dotnet-codestyle/references/testing.md | 4 +- .github/skills/drive-pr/SKILL.md | 120 ++++++--- .github/skills/fleet-code-review/SKILL.md | 1 + .../skills/git-commit-conventions/SKILL.md | 13 +- .../references/history-rewrite.md | 49 ++-- .github/skills/local-strict-review/SKILL.md | 29 ++- .github/skills/merge-and-release/SKILL.md | 82 +++--- .github/skills/pr-review-conduct/SKILL.md | 77 +++++- .github/skills/python-codestyle/SKILL.md | 61 +++-- .../python-codestyle/references/code-style.md | 6 +- .../python-codestyle/references/profiles.md | 26 +- .github/skills/repo-worktree/SKILL.md | 76 +++--- .github/skills/resync-a-repo/SKILL.md | 50 ++-- .github/skills/session-handoff/SKILL.md | 33 +-- .github/skills/shell-codestyle/SKILL.md | 47 ++-- .github/skills/standup-a-repo/SKILL.md | 46 ++-- .github/skills/update-host/SKILL.md | 4 +- .../upstream-contribution-workflow/SKILL.md | 64 +++-- .github/skills/workflow-ci-contract/SKILL.md | 2 +- .../references/architecture.md | 8 +- .../references/d-guarantees.md | 2 +- .../references/test-methodology.md | 2 +- 37 files changed, 920 insertions(+), 462 deletions(-) diff --git a/.github/skills/add-host-tool/SKILL.md b/.github/skills/add-host-tool/SKILL.md index 22b10df5..62f9eb03 100644 --- a/.github/skills/add-host-tool/SKILL.md +++ b/.github/skills/add-host-tool/SKILL.md @@ -25,12 +25,12 @@ description: >- - Prefer the distribution package when it meets the floor. - Use the platform's established package manager and official package identifier. - Keep install and upgrade idempotent. -- Before an apt-managed install, detect and remove an unowned downloaded copy that shadows it. -- Before a downloaded install, detect and remove a conflicting package-managed copy. +- Before an apt-managed install, detect an unowned downloaded copy that shadows it. Report it with the command that removes it by hand, per `GOVERNANCE.md` "Design Before Code". Skip that tool's install until the copy is gone, since the shadowing copy would keep answering on PATH. +- Before a downloaded install, detect a conflicting package-managed copy. Report it and skip the install the same way. - Preserve report, list, explicit selection, install, upgrade, reinstall, and dry-run behavior. -- Do not test a Windows mutation on Linux or a Linux mutation on Windows. +- Hand each native mutation to the operator on its own platform, never a Windows mutation on Linux or a Linux mutation on Windows. -When a platform is unavailable, verify its registry and tests without claiming a native install. Hand off the exact native commands and expected observations to the operator. +Verify each platform's registry and tests without claiming a native install, whether or not the platform is available. Hand off the exact native commands and expected observations to the operator. ## Update the Complete Surface @@ -42,5 +42,6 @@ Update the platform installers, `spec/host-tools.json`, `docs/host-setup.md`, an 2. Run the repository's formatting, lint, type, and test gates required by the changed files. 3. On the current native platform, exercise list and report first. 4. Exercise install and upgrade dry runs. -5. Apply the install, repeat it to prove idempotence, and run the host gate. +5. Hand the operator the exact native commands for the install, a repeat install proving + idempotence, and the host gate, with the expected observations. Verify what the operator reports. 6. Record untested platforms explicitly and leave cross-platform verification open. diff --git a/.github/skills/agent-conduct/SKILL.md b/.github/skills/agent-conduct/SKILL.md index cc82cf88..5db8e1a5 100644 --- a/.github/skills/agent-conduct/SKILL.md +++ b/.github/skills/agent-conduct/SKILL.md @@ -26,7 +26,7 @@ Read `GOVERNANCE.md` "Design Before Code" before the first edit of a change. ## Before Claiming Done -Read the section below before reporting success on anything non-trivial. It is `GOVERNANCE.md` "Verification Discipline", whole. +Read the section below before reporting success. It is `GOVERNANCE.md` "Verification Discipline", whole. @@ -34,14 +34,15 @@ The checks that separate work actually done from work that merely reports succes - **Locate every check a change owes before running any of them, and CI's coverage is not that list.** The checks are read from what the repository declares, rather than inferred from whatever the pipeline happens to run. What it declares means its `OPERATIONS.md` "Local Verification" section alongside the workflows. Part of a repository's contract is routinely unreachable from a runner. Examples are a redirect no build serves, a deploy no pull request performs, and hardware no runner holds. So the check covering that part lives in a document rather than in a workflow. It is run by hand before the pull request opens. Green is then the precise signal that it was skipped. That is because the pipeline reports success over the half it reaches while saying nothing about the half it cannot. Reading a document's own description of itself is not how such a check is found. That is because a topical document is named for its most visible function, usually a post-merge one. It is also because an accurate description of that function routes a pre-merge task away from the file holding the gate. The destination is declared fleet-wide for that reason, rather than left to how well each repository worded a pointer to it. A repository whose `OPERATIONS.md` carries no such heading, or carries no such file, is missing content it owes. In that case, read that file whole where it exists, and the workflows beside it either way. Report what is absent rather than reading its absence as an answer that no local check applies. - **A test runner failing to spawn is not evidence that no test coverage applies here.** `uv run pytest` failing to spawn in a lint-only Python Scripts profile is that profile working as intended, not a missing dependency. The `python-codestyle` Skill's Two Profiles section states this. Read the actual invocation from the same `OPERATIONS.md` "Local Verification" section the bullet above names, rather than guessing a generic test-runner command. Report that document's own command result, not the guessed command's failure. -- **A test must assert the mechanism it names, and a gate has to be watched failing.** Label each case by the behavior it proves, then write the case that reintroduces the fault and confirm the gate objects to it. A case that passes for an incidental reason, the right answer reached by the wrong path, is worse than no case. That is because it is later cited as evidence. A proof that restates the gated data instead of reading it proves only that the function works. So drive the real table or the real config. And a gate that finds nothing is indistinguishable from a gate with nothing to find, so assert a floor on what a healthy run covers. +- **A test must assert the mechanism it names, and a gate has to be watched failing.** Label each case by the behavior it proves, then write the case that reintroduces the fault and confirm the gate objects to it. A case that passes for an incidental reason, the right answer reached by the wrong path, is worse than no case. That is because it is later cited as evidence. A proof that restates the gated data instead of reading it proves only that the function works. So drive the real table or the real config, read as data. A call that would change state as "Repository Boundaries and Write Safety" bounds it is still stubbed or dry-run. And a gate that finds nothing is indistinguishable from a gate with nothing to find, so assert a floor on what a healthy run covers. - **Gates, filters, and gate-like watchers fail loud, never narrow quietly.** A pattern that silently matches less, an allowlist that silently stops matching, or a gate that silently stops gating all report success while doing nothing. When a construct exists to notice something, make the not-noticing case produce an error or an annotation. An identity allowlist used as a gate, for one, must raise an error when its list stops matching, not silently pass everything through. - **Config with a uniqueness rule is validated on read, and its consumers assert what it promised.** A repeated key in a lookup table is not a precedence question to settle quietly. It is two answers to one question. Keeping whichever came last picks one of them where the reader sees no choice being made. Fail on the duplicate at the point the config is read, so the code downstream can rely on the invariant instead of re-deriving it. - **Validate and read on the same normalized key.** A guard that compares stripped names while the join looks up the raw one passes a padded key and then matches nothing. So the exact fault the guard exists to stop is sitting inside the guard. Normalize once at the boundary and use that one value for both the check and the lookup. -- **Every push toward a pull request is preceded by a local adversarial review of the branch's whole diff, and the pass is recorded.** The rule binds every push rather than the first one. So a fix push answering a reviewer's finding owes a pass exactly as the branch's first push did. That is the round it is actually skipped on. The fix looks small, the branch was reviewed once already, and what goes up is content no review has read. Skipping it does not save the round. It moves it into the fix-commit and review-comment cycle, which spends wall-clock, Actions runtime, and agent tokens finding what a local pass would have. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's. `scripts/local_review.py` records it keyed on the content the reviewer actually saw. So a capture point can ask whether a receipt still covers what is about to be pushed. It need not trust the rule to have been remembered. The pass is mandatory and its findings are advisory, which are opposite claims worth keeping apart. A pass is recorded whether it raised ten findings or none. Disposing of each one is judgment, per `GOVERNANCE.md` "PR Review Etiquette". -- **Canonical content one repo authors and others carry is read the way a carrier reads it, whole, in the repo that can fix it. That read is swept periodically rather than owed by a push.** Such content is written and merged against a diff of a few lines. It reaches a reviewer as a new file, in full, only when a repo carries it for the first time. So the first real read of a rule happens where nothing can be done about the result. That is because the tree is manifest-owned, and the copy is compared against the authoring repo's, byte for byte wherever the declared fidelity is verbatim. It is also because a local edit there is drift on the next fidelity check. Where the fidelity is intent the carrier may adapt its own copy. The defect still has to be fixed at the source, since every other carrier holds it too. Every carrier after that re-discovers the same defect. The finding arrives in a session holding no checkout of the authoring repo and no standing to test the claim. The unit is what a reviewer reads whole. The carry manifest, `spec/files.json` in the hub, rather than the document decides what is a unit, down to which files carry units at all. So the engine that reads that manifest is the authority on the set rather than any restatement of its rules. In the ordinary case a unit is one level-two section of a carried Markdown canonical, which is the fidelity unit `spec/section-model.md` declares. The read is of the unit's whole current text rather than of the diff that moved it. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's, exactly as they are for the pass above. **The read is swept because owing it at every push cost too much to keep owing it there.** Measured across this fleet's review rounds, the passes a push owed were a large share of what a pull request spent. What they returned was never measured against that. So the read moves to a schedule on the cost alone, rather than being owed by whichever change happens to touch a unit. A change that moves a unit is no longer refused over one. No capture point asks a change for a pass of this kind. The diff pass the bullet above requires is owed by every push exactly as before. What replaces the per-push read is a schedule in the authoring repo. It gathers the work into one piece and files it where an agent session can run the passes and fix what they find. That work is every unit whose text has moved past the pass that read it. That work also covers a bounded slice of the units nothing has read there at all, taken newest-committed first. The slice is what keeps a newly authored unit from waiting on a volunteer. That is because such a unit has no earlier pass to move past. It is also because such a unit would otherwise reach a carrier with nothing having asked to read it. That is the case this whole rule is about. A unit newly carried by widening the manifest alone is not reached that way. The order reads the unit's own file rather than the manifest. So such a unit joins the backlog at that file's age. There a section written and declared in one commit leads like any other newly authored one. Bounding it is what keeps a long backlog from arriving as one week's work. `scripts/canonical_review.py` records each pass keyed on the content the reviewer saw, and names both sets. So the sweep's list is read off that record rather than remembered. Its ledger is tracked content the change carrying it commits like any other. Like the pass above, a pass the sweep asks for is mandatory and its findings are advisory. +- **Every push toward a pull request is preceded by a local adversarial review of the branch's whole diff, and the pass is recorded.** The rule binds every push rather than the first one. So a fix push answering a reviewer's finding owes a pass exactly as the branch's first push did. That is the round it is actually skipped on. The fix looks small, the branch was reviewed once already, and what goes up is content no review has read. Skipping it does not save the round. It moves it into the fix-commit and review-comment cycle, which spends wall-clock, Actions runtime, and agent tokens finding what a local pass would have. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's. The hub-hosted `scripts/local_review.py` records it keyed on the content the reviewer actually saw. So a capture point can ask whether a receipt still covers what is about to be pushed. It need not trust the rule to have been remembered. The pass is mandatory and its findings are advisory, which are opposite claims worth keeping apart. A pass is recorded whether it raised ten findings or none. Disposing of each one is judgment, per `GOVERNANCE.md` "PR Review Etiquette". +- **Canonical content one repo authors and others carry is read the way a carrier reads it, whole, in the repo that can fix it. That read is swept periodically rather than owed by a push.** Such content is written and merged against a diff of a few lines. It reaches a reviewer as a new file, in full, only when a repo carries it for the first time. So the first real read of a rule happens where nothing can be done about the result. That is because the tree is manifest-owned, and the copy is compared against the authoring repo's, byte for byte wherever the declared fidelity is verbatim. It is also because a local edit there is drift on the next fidelity check. Where the fidelity is intent the carrier may adapt its own copy. The defect still has to be fixed at the source, since every other carrier holds it too. Every carrier after that re-discovers the same defect. The finding arrives in a session holding no checkout of the authoring repo and no standing to test the claim. The unit is what a reviewer reads whole. The carry manifest, `spec/files.json` in the hub, rather than the document decides what is a unit, down to which files carry units at all. So the engine that reads that manifest is the authority on the set rather than any restatement of its rules. In the ordinary case a unit is one level-two section of a carried Markdown canonical, which is the fidelity unit `spec/section-model.md` declares. The read is of the unit's whole current text rather than of the diff that moved it. The pass itself, its delegation shape, and its model tier are the `local-strict-review` Skill's, exactly as they are for the pass above. **The read is swept because owing it at every push cost too much to keep owing it there.** Measured across this fleet's review rounds, the passes a push owed were a large share of what a pull request spent. What they returned was never measured against that. So the read moves to a schedule on the cost alone, rather than being owed by whichever change happens to touch a unit. A change that moves a unit is no longer refused over one. No capture point asks a change for a pass of this kind. The diff pass the bullet above requires is owed by every push exactly as before. What replaces the per-push read is a schedule in the authoring repo. It gathers the work into one piece and files it where an agent session can run the passes and fix what they find. That work is every unit whose text has moved past the pass that read it. That work also covers a bounded slice of the units nothing has read there at all, taken newest-committed first. The slice is what keeps a newly authored unit from waiting on a volunteer. That is because such a unit has no earlier pass to move past. It is also because such a unit would otherwise reach a carrier with nothing having asked to read it. That is the case this whole rule is about. A unit newly carried by widening the manifest alone is not reached that way. The order reads the unit's own file rather than the manifest. So such a unit joins the backlog at that file's age. There a section written and declared in one commit leads like any other newly authored one. Bounding it is what keeps a long backlog from arriving as one week's work. The hub-hosted `scripts/canonical_review.py` records each pass keyed on the content the reviewer saw, and names both sets. So the sweep's list is read off that record rather than remembered. Its ledger is tracked content the change carrying it commits like any other. Like the pass above, a pass the sweep asks for is mandatory and its findings are advisory. - **Another round of edits after either pass is owed only while a defect this change introduced or fixes in place is open.** A finding count never owes one. Which findings count as introduced, what each class owes, and how many rounds a push may spend are the `local-strict-review` Skill's. - **Run the repo's whole lint gate before every push, not the parts that look relevant.** CI runs all of them, so a partial local run only defers the failure. The tool most likely to catch a given change is often the one it seems least about. An edit that manipulates line endings is exactly when `editorconfig-checker` matters. The repo documents each linter's known-working invocation, and this rule is that **all** of them run. +- **Run the repo's whole test suite before every push, not the modules a change touches.** Run it in the invocation `OPERATIONS.md` "Local Verification" declares, as the bullets above require. CI runs every case a runner can reach, so a partial local run only defers the failure, as it does for the lint gate. A suite can hold tests that judge every file in the tree, so a change can fail a module it never touched. - **Editing CRLF files programmatically: `.` matches `\r` in a regex**, so a captured line keeps its carriage return and rejoining with `\r\n` yields `CRCRLF`. Prefer literal replacement over regex reassembly. In Python the *default* path is a text-mode rewrite, which has the mirror failure. `Path.read_text()` decodes through universal newlines and `write_text()` translates each `\n` back to `os.linesep`. So a read-edit-write round trip rewrites every line ending in the file to the host's own while the edit itself looks correct. Work in bytes, or open the file explicitly with `newline=''` on both the read and the write. That is because a read that preserves the endings still hands them to a write that translates them. Use `open()` rather than `Path.read_text()`, which accepts that argument only on Python 3.13 and newer and raises `TypeError` below it. The corruption is worth naming because it is invisible in a rendered diff. - **Scope a check by what the project declares, not by the file that prompted it.** A check written while editing one file tends to cover that file's language and stop. It then reports success on every other surface the rule governs. Read the declared types, or the config that enumerates them, and cover each one. Then assert a floor per surface, so a table that narrows fails loudly instead of passing quietly. A rule about comments means every comment syntax the project ships. A format that carries comments in practice counts even where its specification says otherwise. - **Never write source text carrying backslash escapes through a shell construct that interprets them.** A `printf` format string, a `printf` argument consumed by `%b`, `echo -e`, POSIX `sh`'s builtin `echo`, and `$'...'` each consume the escape. Each writes an invisible control character in its place. So a `\b` inside a regex becomes a backspace, and the pattern silently matches nothing while every test still passes. A quoted heredoc, `<<"EOF"`, is not one of those constructs and writes every backslash literally. An unquoted `< Communicating with the User --> - **Reference every pull request as a clickable link.** When you mention a PR on a surface that renders Markdown (chat, a summary, a report), render it as a Markdown link to the PR. Write it as `[#N](https://github.com/OWNER/REPO/pull/N)`, never a bare `#N`. The same applies to issues and commits. **The form follows the surface.** Some surfaces link neither a Markdown link nor a bare URL, an interactive prompt's question and option text among them. Pasting a full URL into one of those does not rescue it, since the reader gets a string to copy. That is the outcome this rule exists to prevent. There the reference is a bare `#N`. The clickable link goes in the message that comes **before** the prompt rather than merely alongside it. That is because the prompt blocks on an answer, and a message emitted after it is read once that answer is already given. That is the one moment the link is no longer any use. The test is whether the reader can click it where it is read, not whether it was written in the syntax that works elsewhere. - **Put a command the user must run where the user can run it.** This session's input line is where the user types to the agent. A command runs outside this session where this session's input line cannot run it or cannot hold its effect. One waiting on typed input, such as a password or a confirmation, is such a command. So is one meant for another host, or one setting a variable the session reads at launch. Every other one runs at this session's input line, where that line can run a command, and outside the session otherwise. **A command the user runs outside this session goes in the question's own text.** Where a question asks the user to run one, the question carries the exact command, complete and ready to paste. A message before the prompt may repeat the command, but the question never points at that message. A question pointing at it can leave the reader to find the command among a long run of earlier output. Such a command stays in the prompt, where the turn opens one, although the clickable-link bullet above moves a link out of one. The command needs no rendering, since the prompt shows it as plain text the reader can copy. **A command the user runs at this session's input line never goes in an interactive prompt.** On Claude Code such a command is a `!` line, typed at the session's input line so its output lands in the session. While an interactive prompt is open, the user cannot type at the session's input line. So a command placed in one sits in the one surface that blocks running it. It goes in a plain message instead, as a fenced block holding the `!` line itself, complete and ready to paste. Several commands join on that one line with `&&`, which runs them in order and stops at the first that fails. The block opens the message. Any question the same turn owes follows it as a numbered list, and any report comes after both. The message asks the user to reply once the command has run, and the turn ends with no interactive prompt open. The agent then checks the result on the user's next message. It reads back the state the command was meant to change, or the output it left in the session. An answer saying the command ran is not that check. -- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". +- **Ask when the user can cheaply confirm.** An assumption that saves one question and is wrong costs the rework plus the trust. So a genuine ambiguity in intent, scope, or authorization is raised, not resolved by picking the likelier reading. Rules that already answer the question (the committed instruction set) are not ambiguity, so read them first rather than asking what they state. +- **The irreversible step (merging, publishing, releasing, force-pushing, deleting, changing branch protection) stays the maintainer's.** **A grant given in a past session or for a different task authorizes nothing now.** Whether a credential's reach or a tool that happens to work authorizes anything is answered by `GOVERNANCE.md` "Repository Boundaries and Write Safety" rather than here. +- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. **Each question reads whole from its own text.** It states the problem, why it is being asked, and what each option does, in plain words. It may cite an issue or a pull request by number. The question and its options still read fully without opening it. A question leaning on an issue for its meaning is often answered without reading that issue, so the answer misses its point. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". - **Raise work blocked on the user as a direct interactive prompt.** When progress needs a decision, an authorization, or an answer only the user can give, ask for it at the point the work stops. Ask through the interface's own prompt mechanism. Never leave it as prose in a summary. A handoff buried in a paragraph is a handoff that did not happen. That is because a summary reads as a report of finished work. It is also because the one line still waiting on the user is the easiest in a summary to skim past. The blocked item is the message, not a closing remark on a message about something else. **The options offered are the actions themselves.** The one that unblocks the work names the action it authorizes ("squash and merge it"). Selecting it is then the go-ahead rather than a note to act on later. Offering only ways to wait is the same failure in interactive clothing. That is because a prompt whose every choice is inaction reports the block rather than clearing it. Where the agent may not perform the authorized action itself, the option says who does it. Where no interactive prompt is available, the numbered list the bullet above names is the fallback. In a turn asking for a command the user runs at this session's input line, the command bullet above replaces the interactive prompt. - **Lead every choice with a recommendation and its reason.** Wherever the user is asked to choose, in a prompt or in a numbered list, the option the agent recommends comes first. It is marked as the recommendation, and every option states the reason for it. A user who takes the recommendation then reads one line, and one who does not sees what the other options trade away. A question with no defensible recommendation says so rather than inventing one. Where an open question has no options and the agent does have an answer, that answer and its reason go in the question's text. They never go in as an invented option. - **A question filed as an issue is parked rather than asked, and it stays owed.** Where the work cannot continue without the answer, the interactive-prompt bullet governs and the question is asked at the point the work stops. Wherever the question is recorded rather than asked, recording it is the right thing to do, and recording it is still not asking it. That holds whether the work can continue without the answer or the question was asked once and deferred. So the issue carries the fleet's `decision` label. When the filing session knows the choices the question is between, the issue states them. The label and the stated choices are what let a later session, one that was not there when the issue was filed, find the question. That session can then put the question to the user without inventing its answers. **The parked queue is the failure, not the parking.** An issue holding a question the user has never seen reads to every later session as tracked work rather than as a block. So each session files correctly and moves on. Presenting the accumulation is the step nobody owns. @@ -97,8 +97,8 @@ Where a lesson lands, when it earns a mechanical hook, and where work blocked on - **Keep the governance current as you work.** When work surfaces something durable, record it in the governance docs as part of that change. Something durable includes a rule worth enforcing, a recurring gotcha, a positive pattern to repeat, or a negative one to design out. Record it rather than leaving it in a local note or routing around it with a one-off workaround. Where the governing doc is carried from a template this repo cannot edit directly, propose the change upstream rather than patching the local copy. A local patch leaves every sibling repo with the same trap. Governance is not static: it improves by agents folding good patterns in and designing bad ones out. - **A blocker filed in another repository is recorded in the repository whose work it blocks.** The binding moment is when the upstream issue is filed or, where it already exists, found. That is because the session filing or finding it is the one that knows what stopped and why. It owes a second issue in the repository that is waiting rather than only the first. Where the upstream issue already exists, the local issue names that one and no second upstream issue is filed. The local issue states what this repository cannot do and why, in its own terms rather than as a pointer to read elsewhere. That is because a reader who has to open the upstream issue to learn whether it affects them opens every one of them. The local issue names the upstream one as its blocker, carries the `blocked` label, and carries whatever labels its own work would carry anyway. A comment on the upstream issue then names the local one in return. It is a comment rather than an edit to the body because a second repository may join the same blocker later. It is also because the body is often not this session's to rewrite. That order is the upstream issue, then the local issue, then the backlink comment. It leaves a partial failure as a record naming its blocker rather than as a blocker naming a record nobody wrote. **A handoff does not do this job.** It carries the blockers a round met, but it belongs to one track and closes when that track's work is done. The wait can outlive that track, so it belongs in the backlog the whole repository reads. - **The blocker record is written under the ordinary write rules, and the label on it is taken off deliberately.** Filing an issue and commenting on another are state-changing calls. So "Repository Boundaries and Write Safety" binds each of them exactly as it binds any other write. That keeps the upstream issue inside this owner. That binding also makes a blocker under a different owner a matter of explicit permission rather than of this rule. The `blocked` label is what every reader of this record selects on. So a repository not carrying it cannot host one until the fleet label set is applied there. That is a change to that repository's configuration rather than anything this rule writes. A session that finds it missing reports that. The label comes off when the blocker clears. The session closing the upstream issue is best placed to take it off. That is because the backlink comments naming every waiting repository are on the issue it is closing. Any later session that finds it cleared takes it off instead. A fix can land well before either of those, so the label lags the fix rather than tracking it. That is why a session meeting a `blocked` issue reads the state of the issue that issue's body names rather than the label. The local issue stays open when the label comes off. That is because the work it records still has to be done and is ordinary backlog from that moment on. -- **A handoff parked on a maintainer decision carries the `blocked` label too.** Its blocker is a `decision` issue in this same repository rather than an issue elsewhere, and the parking comment on the handoff names it. A reader reads the named issue rather than the label, and the blocker clears when that issue loses its `decision` label. Unlike a cross-repository blocker, a session finding it cleared does not take the label off. It comes off only once a session writes the next round and leaves no `decision` issue it filed on that work unanswered. So a running loop never takes a handoff a present maintainer is still working, or one it could only park again. -- **A durable rule earns a mechanical hook only where a hook can actually decide it, otherwise it stays prose.** The conditions below must hold together, not any one alone. The failure recurs even after the governing prose was demonstrably read and understood. So it is not a discovery or loading problem that a structural fix would already solve. A structural fix here means getting the rule into context at all. The triggering shape is decidable from the tool call's own text, arguments, and working directory alone, with no semantic or contextual judgment required. And the failure is destructive or hard to reverse rather than a quality miss. A worktree-isolation lapse met all of them, so it was promoted to a `gh-write-guard` hook rule. It recurred under prose the agent had already read. The question "is this command's target a primary checkout" is a plain directory comparison. And the harm is another task's swept or reverted work. A skill's own trigger going unread by the session at all, by contrast, is a loading problem. It is fixed by getting the rule into context (the `CLAUDE.md` importing `AGENTS.md`), not by a hook. And "was this review finding actually evidence-backed" fails the second condition outright. A hook sees only the command text, never the judgment call itself, so it can only ever nag, not decide. That class of rule stays prose and a chained Skill trigger. Those conditions gate promotion to a **host** hook. That is the involuntary layer that fires in every session under the maintainer's own credentials, and only the maintainer can grant an exemption from it. That is why the bar there is destructive harm. A **committed** hook in the repository's own tree is a third layer between prose and that one, and it is earned on weaker grounds. It is opt-in per clone, visible in the tree, and bypassable by design. It therefore fits a rule whose harm is a quality miss rather than a destruction. The second condition still binds it, since a hook that cannot decide its own trigger is a hook that nags. So what earns the layer is finding the decidable half of a rule whose other half is judgment. The local-review rule under `GOVERNANCE.md` "Verification Discipline" is the worked example. Whether a review's findings were rightly disposed of is judgment no hook can decide, and it stays prose. Whether a review pass ran over exactly the content being pushed is a receipt comparison, which the hub's own `.husky/pre-push` decides. +- **A handoff parked on a maintainer decision carries the `blocked` label too.** Its blocker is a `decision` issue in this same repository rather than an issue elsewhere, and the parking comment on the handoff names it. A reader reads the named issue rather than the label, and the blocker clears when that issue loses its `decision` label. Unlike a cross-repository blocker, a session finding it cleared does not take the label off. It comes off only once a session writes the next round and leaves no `decision` issue on that work unanswered, whichever session filed it. So a running loop never takes a handoff a present maintainer is still working, or one it could only park again. +- **A durable rule earns a mechanical hook only where a hook can actually decide it, otherwise it stays prose.** The conditions below must hold together, not any one alone. The failure recurs even after the governing prose was demonstrably read and understood. So it is not a discovery or loading problem that a structural fix would already solve. A structural fix here means getting the rule into context at all. The triggering shape is decidable from the tool call's own text, arguments, and working directory alone, with no semantic or contextual judgment required. And the failure is destructive or hard to reverse rather than a quality miss. A worktree-isolation lapse met all of them, so it was promoted to a `gh-write-guard` hook rule. It recurred under prose the agent had already read. The question "is this command's target a primary checkout" is a plain directory comparison. And the harm is another task's swept or reverted work. A skill's own trigger going unread by the session at all, by contrast, is a loading problem. It is fixed by getting the rule into context (the session loading `AGENTS.md` at start), not by a hook. And "was this review finding actually evidence-backed" fails the second condition outright. A hook sees only the command text, never the judgment call itself, so it can only ever nag, not decide. That class of rule stays prose and a chained Skill trigger. Those conditions gate promotion to a **host** hook. That is the involuntary layer that fires in every session under the maintainer's own credentials, and only the maintainer can grant an exemption from it. That is why the bar there is destructive harm. A **committed** hook in the repository's own tree is a third layer between prose and that one, and it is earned on weaker grounds. It is opt-in per clone, visible in the tree, and bypassable by design. It therefore fits a rule whose harm is a quality miss rather than a destruction. The second condition still binds it, since a hook that cannot decide its own trigger is a hook that nags. So what earns the layer is finding the decidable half of a rule whose other half is judgment. The local-review rule under `GOVERNANCE.md` "Verification Discipline" is the worked example. Whether a review's findings were rightly disposed of is judgment no hook can decide, and it stays prose. Whether a review pass ran over exactly the content being pushed is a receipt comparison, which the hub's own `.husky/pre-push` decides. `GOVERNANCE.md` "Durable Knowledge and Self-Improvement" keeps the full rules. The `agent-conduct` Skill at `.agents/skills/agent-conduct/SKILL.md` in the hub carries it whole as a generated include and surfaces it at its decision moments. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. diff --git a/.github/skills/audit-a-repo/SKILL.md b/.github/skills/audit-a-repo/SKILL.md index 5e543ea1..cd104775 100644 --- a/.github/skills/audit-a-repo/SKILL.md +++ b/.github/skills/audit-a-repo/SKILL.md @@ -22,8 +22,8 @@ The audit is the fleet's measurement procedure. The failure shapes it guards aga ## Before Measuring Anything - **Route first.** A repo with no carried instruction set, or a partial one, has a baseline that never arrived rather than drift to report (`AUDIT.md` section 0). It therefore goes to `STANDUP.md` sections 1A and 2 first (`AUDIT.md` section 0). Auditing it anyway produces a report that is all absences and reads as catastrophe. -- **Verify the host.** Run `python3 scripts/host_gate.py --repo ` from the hub checkout before any hub tool, and pass `--repo`, since a bare run skips the target's own `host-tools.json` overlay. A stale tool answers `--version`, looks healthy, and produces a wrong answer. -- **Read `main` as ground truth**, for every workflow model, and read `develop` only to detect divergence (`AUDIT.md` section 1). An `operational` repo's `develop` is mid-flight by design. Conformance work sitting there is therefore un-promoted work, not a defect, and it counts when it reaches `main`. Use `uv run --no-project --script spec/audit.py --branch ` to preview in-flight work, which stamps the override so the finding cannot be mistaken for one against ground truth. +- **Verify the host.** Run `python3 scripts/host_gate.py --repo ""` from the hub checkout before any hub tool, and pass `--repo`, since a bare run skips the target's own `host-tools.json` overlay. A stale tool answers `--version`, looks healthy, and produces a wrong answer. +- **Read `main` as ground truth**, for every workflow model, and read `develop` only to detect divergence (`AUDIT.md` section 1). An `operational` repo's `develop` is mid-flight by design. Conformance work sitting there is therefore un-promoted work, not a defect, and it counts when it reaches `main`. Use `uv run --no-project --script spec/audit.py --branch "" ""` to preview in-flight work, which stamps the override so the finding cannot be mistaken for one against ground truth. ## Measuring @@ -31,18 +31,18 @@ The audit is the fleet's measurement procedure. The failure shapes it guards aga - **Know what the runner does and does not prove.** `spec/audit.py` mechanizes the deterministic subset only: settings, rulesets, secret names, file and section presence, verbatim hashing, interface wiring, Dependabot coverage, branch facts. It evaluates no check under a type in `spec/project-types.json` (`AUDIT.md` section 4). So every per-type check is judged by hand, and a clean run is no evidence for them (`AUDIT.md` section 4). Silence from a tool that was never looking reads exactly like a pass. - **Judge letter and intent per check** and keep the vocabulary. A letter miss with intent satisfied is a drift finding. Both missing is a defect. Operational is binary over the applicable set. That vocabulary is in `AUDIT.md` sections 4 and 7. Do not invent a parallel scheme. - **Assert the Actions implement `WORKFLOW.md`** by outcome, not by matching catalog snippets byte for byte (`AUDIT.md` section 5). The method is the 5A static audit, each applicable guarantee cited in the form 5A sets out, then the 5B trace scenarios (`AUDIT.md` section 5). Read a workflow the repo only calls at the SHA it pins, throughout. The `workflow-ci-contract` skill summarizes that contract. -- **Check live settings, rulesets, and secrets from a hub checkout at `main`** with `AUDIT.md` section 6. Use a hub checkout at `develop` instead while the target's registry entry has merged there but not yet reached `main`. Run `repo-config/configure.sh check` with the target repository and model for settings and rulesets, and `uv run --no-project --script spec/audit.py [RepoName]` for secrets, rather than constructing a local comparison. The hub payloads are the only repository-configuration source. +- **Check live settings, rulesets, and secrets from a hub checkout at `main`** with `AUDIT.md` section 6. Use a hub checkout at `develop` instead while the target's registry entry has merged there but not yet reached `main`. Run `repo-config/configure.sh check` with the target repository and model for settings and rulesets, and `uv run --no-project --script spec/audit.py ""` for secrets, rather than constructing a local comparison. The hub payloads are the only repository-configuration source. ## Reporting -- **Write `reports//audit.md` from `reports/_template.md`**, `` being the repository name in lowercase. Findings are ranked most severe first, each with the `file:line` it was judged against. Quote the run stamp. The stamp is quoted because findings are a point-in-time snapshot. All of this is in `AUDIT.md` section 8. +- **Write `reports//audit.md` from `reports/_template.md`**. Findings are ranked most severe first, each with the `file:line` it was judged against. Quote the run stamp. The stamp is quoted because findings are a point-in-time snapshot. All of this is in `AUDIT.md` section 8. - **The hub authors the report.** A downstream repo never opens a hub pull request to write its own, which would be self-certification. Downstream context goes into issues filed against the hub instead. -- **Generate a convergence issue, never compose one**: `uv run --no-project --script spec/audit.py --issue ` emits it from live findings. A finding judged by hand goes under the fixed `## Manual findings` heading that body ends with. That is the issue's one hand-written section, and regenerating replaces only the text above it (`AUDIT.md` section 8). An agent picking such an issue up re-runs the audit first and acts on the live result, not the pasted findings. +- **Generate a convergence issue, never compose one**: `uv run --no-project --script spec/audit.py --issue ""` emits it from live findings. A finding judged by hand goes under the fixed `## Manual findings` heading that body ends with. That is the issue's one hand-written section, and regenerating replaces only the text above it (`AUDIT.md` section 8). An agent picking such an issue up re-runs the audit first and acts on the live result, not the pasted findings. - **Reconcile registry `driftNotes` in the same pass**: a resolved deviation's note is deleted, not left describing finished work. A note naming a check id is retired by a person, not by a run. All of this is in `AUDIT.md` section 8. - **Stale-versus-modified classification and the intent staleness advisory need a full hub clone with git history.** In a shallow clone the audit reports one ERROR per repo and exits non-zero, so run `git fetch --unshallow origin` in the hub checkout first. To verify one finding without history, compare against the current hub canonical on `main`, which decides current-match only. ## After the Report -Measuring and fixing are separate phases. Converging is `AUDIT.md` section 10. In that section, fixes ship as pull requests on the target repo, one focused pull request per drift class. In that section too, the Copilot loop is driven to green per the `pr-review-conduct` skill, and the maintainer merges. For a repo already stood up, `RESYNC.md` sequences the findings, since order matters (a deletion lands before the re-vendor that would refresh it). Its section 6 states the one grouping. Systemic drift shared by many repos is fixed in the hub spec, not hand-patched per repo. Spec questions are escalated rather than resolved silently. Both are in `AUDIT.md` section 9. +Measuring and fixing are separate phases. Converging is `AUDIT.md` section 10. In that section, a file fix ships as a pull request on the target repo, one focused pull request per drift class. In that section too, the Copilot loop is driven to green per the `pr-review-conduct` skill, and the maintainer merges. For a repo already stood up, `RESYNC.md` sequences the findings, since order matters (a deletion lands before the re-vendor that would refresh it). Its section 6 states the one grouping. Systemic drift shared by many repos is fixed in the hub spec, not hand-patched per repo. Spec questions are escalated rather than resolved silently. Both are in `AUDIT.md` section 9. -An audit leaves no checkout behind it, since one left standing is what a later sweep has to tell apart from live work. Each is removed when the run ends, per `repo-worktree` "Listing and Cleanup". The report's pull request is cleaned up once it merges, with `uv run --no-project --script scripts/pr_review.py cleanup --repo ptr727/ProjectTemplate --checkout `. A detached checkout at `main` that only read the hub is removed by hand once it is clean. +An audit leaves no checkout behind it, since one left standing is what a later sweep has to tell apart from live work. Each is removed when the run ends, per `repo-worktree` "Listing and Cleanup". The report's pull request is cleaned up once it merges, with `uv run --no-project --script scripts/pr_review.py cleanup "" --repo ptr727/ProjectTemplate --checkout ~/repos/ProjectTemplate`, `~/repos/ProjectTemplate` being the hub's primary clone. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. Spell every `scripts/pr_review.py` call this skill prints as `pr-review-conduct` "Expected review loop" says. A detached checkout at `main` that only read the hub is removed by hand once it is clean. diff --git a/.github/skills/backlog-burndown/SKILL.md b/.github/skills/backlog-burndown/SKILL.md index 661a2e1e..b09fec3d 100644 --- a/.github/skills/backlog-burndown/SKILL.md +++ b/.github/skills/backlog-burndown/SKILL.md @@ -74,19 +74,30 @@ Working them is out of this skill's scope, and a fleet-wide backlog sweep is a d ## The Round -A round is the unit. Each one runs these steps in order. +A round is the unit. Each one runs these steps, step 6 repeating as each worker ends. 1. **Rank** every open issue, per "Ranking". -2. **Group** the top of that ranking, per "Grouping and File Claims". +2. **Group** the top of that ranking, per "Grouping and File Claims", until each free slot holds a + group that passes step 3. A slot is free only while both dispatch limits in "Grouping and File + Claims" leave room for the group taking it. 3. **Verify** each group's predicted file set against everything in flight before dispatching - anything. A group whose files are already claimed waits for the next round. -4. **Dispatch** at most four workers, one per group, per "Dispatching a Worker". + it. A group whose files are already claimed waits for a refill that finds them free, or for + the next round. +4. **Dispatch** one worker per group, within the dispatch limits in "Grouping and File Claims", per + "Dispatching a Worker". 5. **Collect** each worker's outcome: merged to develop, stopped on a maintainer-only question, parked behind another group's file claim, handed back for review, or abandoned. The adjudication in "Grouping and File Claims" and a confirmed-gone worker each produce that outcome. Bound this wait per "Bounding the Wait on a Worker". The orchestrator records a handed-back pass and continues the same worker. -6. **Clean up** the worktrees, local branches, and remote branches of every group that has - merged or been abandoned, per "Dispatching a Worker". +6. **Clean up and refill as each worker ends**, rather than once the round's last worker has. + Clean up the worktree, local branch, and remote branch of a group that merged or was abandoned, per + "Dispatching a Worker". Then run steps 1 to 3 afresh for the free slots and dispatch the + groups they form. Refilling stops once step 7 + starts. From then, and under the freeze, "The Promotion Boundary" step 6 says what may be + dispatched. In an attended run, a free slot goes first to a stopped group whose question is + answered. The + round moves to step 7 once no worker is in flight and no group can be dispatched. A round + prepared under the freeze first waits for that merge, per step 8. 7. **Promote**, per "The Promotion Boundary". 8. **Re-rank from scratch**. Whenever a promotion pull request is still waiting on the maintainer, the next round prepares under the freeze "The Promotion Boundary" describes. Under that freeze @@ -158,7 +169,7 @@ whether it waits on a split, as it names a `blocked` one. An issue that asks a question rather than states a defect is not ranked and is never guessed at. It has no group, no worker, and no claim, so nothing in "Raising a Blocked Question" applies to it -except how the question travels. It goes to the maintainer at the end of ranking, per +except how the question travels. It goes to the maintainer at the end of the first ranking that meets it, per `GOVERNANCE.md` "Communicating with the User". It does not wait for a stop that may not come. It is batched with any other question the run is sending at that moment, and goes in a prompt of its own otherwise. It stays unranked until answered. An issue carrying `decision` is such a question already @@ -210,13 +221,14 @@ Group so that **no file is claimed by two live groups at once.** This is the rul for, and it binds harder than any throughput target. - **Group by the files a fix will touch**, not by the issues' subject matter. Two issues that read - as unrelated but both edit a shared governance file are one group. Two issues that read as near + as unrelated but both edit a shared governance file share a group, up to the group cap below. Two issues that read as near duplicates but touch different files are two groups. - **Genuine duplicates are one group.** Never close an issue during triage on the orchestrator's own judgment. Comment to cross-link the pair, and let the fix close both. - **Closing keywords go on the promotion pull request**, not the feature pull request, per - `branching-and-release-model`. A feature pull request merging into develop fires no - auto-close, so a `Fixes #N` line there closes nothing. **The feature pull request body instead + `branching-and-release-model`. A repository's squash setting can copy the body into the commit, + as the hub's does. Then a `Fixes #N` line there closes #N when the promotion brings that commit + to main, a closure no promotion body stated. **The feature pull request body instead carries a line reading `Closes on promotion: #N`**. It lists every issue that pull request actually fixes and nothing it merely mentions. The promotion body is assembled from that line, per "The Promotion Boundary". GitHub reads a closing keyword only where the issue reference @@ -227,7 +239,7 @@ for, and it binds harder than any throughput target. that behavior. That is the doc, the manifest entry, or the rule sentence `GOVERNANCE.md` "Verification Discipline" makes the change's own to fix. Find them by searching the tree for the identifier, flag, check name, or rule phrase the fix changes, rather than by guessing which - docs apply. Two groups needing one such file are one group, per the first bullet. A predicted + docs apply. A predicted edit lands before the first push, where it costs no extra CI run or hosted review. - **Record every claim on the issue itself**, as a comment naming the predicted file set **and the branch that holds it**, before dispatching. The comment opens with `**Backlog burndown claim` @@ -254,10 +266,15 @@ for, and it binds harder than any throughput target. - **Verify the prediction before dispatching**, against everything in flight, which is wider than this round. In flight covers the files changed by every open **feature** pull request on this repository. It also covers the claim comments of every group still holding a branch, parked - groups from earlier rounds included. + groups from earlier rounds included. It covers too the claim of each group dispatched whose + worker has not yet ended. A worker creates its branch only once it runs. A worker handed back + for review has not ended, since the same worker is continued. The orchestrator reads + that set from the assignments and outcomes its working notes hold, per "Run State". A refill + planner's brief names the groups in it. A claim comment alone cannot say, since a merged group's cleanup + leaves its claim reading like one whose worker has yet to start. `gh pr list --state open --limit 1000 --json number,baseRefName,headRefName,isCrossRepository --jq '.[] | select(.headRefName != "develop" or .baseRefName != "main" or .isCrossRepository) | .number'` lists the open pull requests, its filter applying the promotion exclusion below. - `gh pr diff --name-only` then reads each one's files. `git worktree list` reports the + `gh pr diff "" --name-only` then reads each one's files. `git worktree list` reports the registered worktrees and the branch checked out in each. That is not the same as every branch that exists. So pair it with `git branch -r`, after `git fetch --prune origin`, for one that was pushed and whose worktree is already gone. Pair it also with `git branch` for one that was never @@ -269,8 +286,8 @@ for, and it binds harder than any throughput target. the web interface. A plain fetch leaves that ref in `git branch -r` to defer valid groups forever. Stop and report a failed fetch rather than reading `git branch -r` anyway, per `GOVERNANCE.md` "Verification Discipline" on what a local clone answers for. Here the scan would - miss a branch pushed since the last successful fetch and keep one deleted since it. The round - stops there and reports, rather than dispatching against a stale answer. Stopping rather than + miss a branch pushed since the last successful fetch and keep one deleted since it. Dispatch + stops there and the failure is reported, rather than dispatching against a stale answer. Stopping rather than deferring is what the cleanup and promotion steps need too, since both read the same remote. Those three enumerate the branches, with one gap. A branch in the standalone clone `repo-worktree` allows as a fallback is reached only once it is pushed. That is because @@ -281,14 +298,15 @@ for, and it binds harder than any throughput target. open promotion pull request from that enumeration.** Its diff is all of `origin/main..origin/develop`, so counting it claims nearly every file any earlier round touched. A round run during the freeze would then defer every group it formed. A predicted claim that - collides with a real one is a group deferred to the next round, never one dispatched hoping the - overlap stays small. + collides with a real one is a group deferred to a later refill or the next round. It is never + one dispatched hoping the overlap stays small. - **A branch no claim comment covers still has to yield a file set.** The maintainer's own worktree and a hand-driven task's branch are enumerated above and carry no claim comment. So reading only the comments records them as holding nothing. That is the collision this section exists to prevent rather than the absence of one. Read the branch itself instead: - `git diff --name-only origin/...` for what it has committed, and, for a - registered worktree, `git -C status --porcelain` for what it holds uncommitted. + `git diff --name-only "origin/..."` for what it has committed, and, for a + registered worktree, `git -C "" status --porcelain --untracked-files=all` for what it + holds uncommitted. `` is the `baseRefName` of the branch's pull request where it has one, and `develop` otherwise. That is because `repo-worktree` "The Base Branch" lets a task branch from `main`. Read against `develop`, a `main`-based branch can list files it never touched, which errs toward a collision @@ -299,11 +317,11 @@ for, and it binds harder than any throughput target. needing a file outside its claim stops and reports rather than editing it. A file may sit on a branch no claim comment covers, or on one whose set is unknown. Then the worker is stopped for the maintainer per "Raising a Blocked Question". Where no branch holds the file, the orchestrator - verifies that as it verifies a prediction. It then extends the claim comment at once. A grown + verifies that as it verifies a prediction. It then extends the claim comment. A grown set failing the tier test in "Choosing the Worker's Model Tier" under a worker below `frontier` stops the group there. One passing it lets the worker continue, unless the agent-safety hold below applies. That is the ordinary path for a doc describing the group's own change, and it is - answered at once rather than at a round boundary. Where another group holds the file, the need + answered without waiting for a round boundary. Where another group holds the file, the need is a conflict. The orchestrator decides which group keeps the file and tells the loser what to do rather than leaving it to choose. The loser narrows its change to drop that file, parks until the holder merges, or abandons its branch per "Cleanup Is the Orchestrator's". Some losers need @@ -323,13 +341,24 @@ for, and it binds harder than any throughput target. drifts from the real claim it exists to report. A group told to abandon its branch keeps its claim comment unchanged, since cleanup decides whether that claim is released, per "Cleanup Is the Orchestrator's". -- **Cap the round at four workers**, whatever the grouping allows. +- **Cap each group at three issues and four predicted files.** A wide group draws the most review + passes and sets the round's tail. A refill shortens the idle time around that tail but not the + tail itself. Where the ranking would form a wider group, its lower-ranked issues wait for a later + group, which a refill can dispatch once this one merges. Genuine duplicates count as one issue, + and an issue holding nothing but a question counts as none. A file a generator writes from + another in the set does not count. An issue predicting more than + four files on its own forms a group by itself. +- **Limit the round's dispatch to four workers at once and eight groups in all**, whatever the + grouping allows. A group counts once in a round, however many workers it takes. So a group + resuming in the round it stopped in takes no second place among the eight. One resuming in a + later round counts there. A promotion fix counts toward neither limit. ## Bounding a Prose Group A group whose files are prose-heavy Markdown bloats in a way a code group does not. It needs its own bound stated in the worker's brief. +- **The group's scope is capped** per "Grouping and File Claims", and the brief names that cap. - **The change reaches the units the issue names and the units it puts in disagreement.** A unit stating the rule or behavior the change altered is this change's to fix wherever it sits in this repository, per `GOVERNANCE.md` "Verification Discipline". Its edit is the smallest one that makes it true again. @@ -358,7 +387,8 @@ Brief on `AGENTS.md` "Context and Delegation Discipline"'s subagent shape. another's worktree. That is why "Bounding the Wait on a Worker" removes a dead worker's tree, with or without its branch, or leaves that tree untouched for the maintainer. It never passes the tree on, for the same reason. -- **The worker reports the path of the checkout it worked in**, with its outcome. A standalone +- **The worker reports the path of the checkout it worked in**, with its outcome. It also reports + a missing or wrong shared git hook it met, per `repo-worktree` "Preparing Git Hooks". A standalone clone, the fallback `repo-worktree` allows, appears in no `git worktree list`. So a worker choosing that fallback records the clone's directory name, `-`, on each of its group's claim comments before cloning. Each edit keeps the comment's `**Backlog burndown claim` @@ -373,6 +403,11 @@ Brief on `AGENTS.md` "Context and Delegation Discipline"'s subagent shape. the override moves is the two cleanup halves `drive-pr` runs after it, the worktree procedure and the verify-then-delete of the merged remote branch. It moves **both** rather than only the first. "Cleanup Is the Orchestrator's" below, in this same section, says why and what it covers. +- **The brief quotes the `merge` command in `drive-pr` step 4's exact spelling**, without + `--cleanup` or `--checkout`. It also quotes, whole, the paragraph in `pr-review-conduct` "Expected review loop" + on spelling a `scripts/pr_review.py` call. A worker that writes the call another way, adding a + cache variable for one, sends its merge to the auto-mode classifier. That classifier refuses a merge no + human has approved. - **A worker that cannot dispatch a subagent hands back its worktree path, target, and digest.** The brief says so per `local-strict-review` "Running It", and says the orchestrator can continue the same worker after recording. - **The brief names the branch the worker will use**, which is what lets the claim comment record @@ -380,7 +415,7 @@ Brief on `AGENTS.md` "Context and Delegation Discipline"'s subagent shape. one of its choosing. That is because a claim naming a branch nobody used points at nothing. A brief dispatching an issue returned to the ranking names a new branch. A branch a claim comment names for the first time is one no pull request on the repository has - used as its head. That is checked with `gh pr list --head --state all` before the + used as its head. That is checked with `gh pr list --head "" --state all` before the comment is written. - **The brief quotes `pr-review-conduct` outcome 4 whole and adds no instruction of its own to file a review finding.** A worker reads its brief as the more specific instruction. So a brief saying "file a @@ -395,6 +430,9 @@ Brief on `AGENTS.md` "Context and Delegation Discipline"'s subagent shape. - **The brief requires the `Closes on promotion:` line** in the pull request body, listing exactly the issues this group fixes. A worker never reads this skill, and `drive-pr` does not ask for the line. So a brief that omits it produces a pull request nothing can derive a closing set from. + On an operational-model repository the brief also requires a `Reopens on promotion:` line where + the group undoes a fix already in the range. Without it the promotion closes an issue whose fix + the range no longer holds. It also has the worker draft that body, and each rewrite of it, in a file named for its branch. Workers sharing a scratch directory and one file name each publish the other's draft. - **The brief names the files this group owns and the files it must not touch.** A subagent never @@ -409,7 +447,7 @@ Brief on `AGENTS.md` "Context and Delegation Discipline"'s subagent shape. installed skills need not match develop, since some installs snapshot promoted `main`. So a rule merged to develop during the run may not reach it. In the hub, the brief tells the worker to read each fleet skill from develop as it invokes it. That covers any reference file it links. - The read is `git fetch origin develop && git show origin/develop:.agents/skills//`, + The read is `git fetch origin develop && git show "origin/develop:.agents/skills//"`, in place of the installed copy. The orchestrator reads the skills it applies the same way at each round's start. Reading develop rather than the worker's own tree also covers a worker on an older branch, such as a resumed group. A downstream repository has no such gap, since its skills come from the hub. @@ -425,10 +463,13 @@ that concurrently mutate one shared checkout, which `GOVERNANCE.md` "Repository Write Safety" forbids. So the whole procedure moves to the orchestrator. -It runs the procedure against the base clone at the round's cleanup step, while no worker is live in a tree it touches. +It runs the procedure against the base clone as each group's worker ends, per "The Round" step 6. +It runs it while no worker is live in a tree it touches. It carries the remote half of `drive-pr`'s post-merge cleanup too. -For a merged group both halves are one command, `uv run --no-project --script scripts/pr_review.py cleanup --repo / --checkout `. -It is run from a hub checkout once for each merged group, `` being the repository's primary clone. +For a merged group both halves are one command, `uv run --no-project --script scripts/pr_review.py cleanup "" --repo "/" --checkout ~/repos/""`. +Spell every `scripts/pr_review.py` call this skill prints as `pr-review-conduct` "Expected review loop" says. +The command is run from a hub checkout once for each merged group, `~/repos/` being the repository's primary clone. +That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. It deletes the remote branch, then removes the group's worktree and local branch, per `repo-worktree` "Listing and Cleanup", which also says what its exit leaves to do. Taking that step from the worker without naming a new owner would leave a live remote branch behind every group. `cleanup` holds the delete's checks, among them the tip against the pull request's `headRefOid`. @@ -441,9 +482,10 @@ A group told to abandon its branch keeps a registered worktree until something r That worktree holds a live claim that would collide with the very group the next round re-forms for the same issue. For a merged group the procedure is deferred rather than changed: `repo-worktree`'s verify-before-removing and prove-the-cleanup steps run unchanged, just later and in one seat. A merged group that worked in a standalone clone is checked before anything is deleted, since `cleanup` sees only the base clone's registered worktrees. -The orchestrator confirms the clone the worker reported or recorded is clean and its branch tip is at the pull request's `headRefOid` or behind it. +The orchestrator confirms the clone the worker reported or recorded is clean by `repo-worktree` "Listing and Cleanup"'s hand-removal read. +It also confirms the clone's branch tip is at the pull request's `headRefOid` or behind it. `repo-worktree` "Listing and Cleanup" accepts both, since a GitHub "Update branch" merge leaves a tip behind it that holds nothing the merge lacks. -After `git -C fetch origin `, `git -C merge-base --is-ancestor refs/heads/ ` exits `0` in both cases. +After `git -C "" fetch origin ""`, `git -C "" merge-base --is-ancestor "refs/heads/" ""` exits `0` in both cases. Where either confirmation fails, nothing is deleted and the group is stopped for the maintainer per "Raising a Blocked Question". Where both hold, `cleanup` runs as for any merged group and deletes the remote branch. The orchestrator then removes the clone, per `repo-worktree` "Listing and Cleanup". @@ -451,8 +493,8 @@ The orchestrator then removes the clone, per `repo-worktree` "Listing and Cleanu **Retiring a worktree and deleting its branch are two dispositions with two tests.** Citing one for the other is how a removal that discards nothing gets routed to the maintainer. It is also how a removal that discards commits gets waved through. Retiring a worktree alone, the branch left -standing, risks only what is uncommitted in it. A clean tree is the whole test, and the branch's -own contents do not enter it. A tree that is not clean is left exactly as it stands while the +standing, risks only what is uncommitted in it. A tree clean by `repo-worktree` "Listing and +Cleanup"'s hand-removal read is the whole test, and the branch's own contents do not enter it. A tree that is not clean is left exactly as it stands while the group is stopped for the maintainer per "Raising a Blocked Question". Deleting the branch as well risks what is committed, so it carries whichever branch check the group's state calls for. That is `repo-worktree`'s verify-before-removing for a group whose pull request merged. It is the no-merge @@ -468,7 +510,7 @@ abandon its branch reports its worktree path and ends without discarding anythin orchestrator waits until the dispatch mechanism reports that the worker has ended, per "Bounding the Wait on a Worker". It then reads a live `git worktree list --porcelain` for a linked worktree, an entry other than the first, whose `branch` line names the claimed branch. Where one exists, it -runs `git -C reset --hard` and then `git -C clean -fd`, `` being that entry's +runs `git -C "" reset --hard` and then `git -C "" clean -fd`, `` being that entry's `worktree` line. It discards nothing in any other tree. Where none exists and the worker reported or recorded no standalone clone, nothing is discarded and the group is stopped for the maintainer per "Raising a Blocked Question". A standalone clone follows the clone paragraph below. The @@ -477,32 +519,32 @@ branch's commits stay for the branch check below. An abandoned group, and a dead worker's clean tree, have no merged pull request for `repo-worktree`'s verify-before-removing step to read. So that step gives way here to a check of what it exists to establish, that nothing unmerged is being thrown away. -The orchestrator records the local tip with `git rev-parse refs/heads/`. -After `git fetch origin develop`, `git merge-base --is-ancestor refs/remotes/origin/develop` must exit `0`, and the worktree must be clean. +The orchestrator records the local tip with `git rev-parse "refs/heads/"`. +After `git fetch origin develop`, `git merge-base --is-ancestor "" refs/remotes/origin/develop` must exit `0`, and the worktree must be clean by `repo-worktree` "Listing and Cleanup"'s hand-removal read. Where both hold, the worktree and local branch are removed by hand, since `cleanup` needs a merged pull request to read. -The removal is `git worktree remove `, then `git update-ref -d refs/heads/ `. +The removal is `git worktree remove ""`, then `git update-ref -d "refs/heads/" ""`. That delete refuses only where the branch has moved off the tip the is-ancestor check judged, so it discards nothing that check did not clear. `git branch -d` would not agree with that check, since it judges a branch with no upstream against `HEAD`, and the fetch does not advance local develop. -Where `git config --get-regexp '^branch\.\.'` prints anything, `git config --remove-section branch.` then removes the tracking `git branch -d` would have removed. +Where `git config --get-regexp '^branch\.\.'` prints anything, `git config --remove-section "branch."` then removes the tracking `git branch -d` would have removed. A refusal stops the group for the maintainer per "Raising a Blocked Question". Where the branch was never pushed, the orchestrator records the release once both succeed. -It edits the group's claim comment, and the issue returns to the next round's ranking. +It edits the group's claim comment, and the issue returns to the ranking. Where it was pushed, the orchestrator also deletes the remote branch, since `cleanup` needs a merged pull request to read. That is the one remote delete this skill types by hand. The delete runs only where two more checks hold. -The remote tip, read live with `git ls-remote --exit-code origin refs/heads/`, equals the recorded tip. +The remote tip, read live with `git ls-remote --exit-code origin "refs/heads/"`, equals the recorded tip. And no open pull request uses the branch as its head or its base. -`gh pr list --head --state open --json number --jq length` prints `0`, and so does the same command with `--base`. -The delete is `git push origin --delete `, an outward-facing write bound by `GOVERNANCE.md` "Repository Boundaries and Write Safety". +`gh pr list --head "" --state open --json number --jq length` prints `0`, and so does the same command with `--base`. +The delete is `git push origin --delete ""`, an outward-facing write bound by `GOVERNANCE.md` "Repository Boundaries and Write Safety". So it names the exact branch, takes every identifier from a live read, and keeps its output unsuppressed. -The orchestrator then reads the ref back with `git ls-remote --exit-code origin refs/heads/`, and only its exit `2`, no matching ref, confirms the delete. -Only after that confirmation is the release recorded on the claim comment, and the issue then returns to the next round's ranking. +The orchestrator then reads the ref back with `git ls-remote --exit-code origin "refs/heads/"`, and only its exit `2`, no matching ref, confirms the delete. +Only after that confirmation is the release recorded on the claim comment, and the issue then returns to the ranking. Where any check fails or the delete is not confirmed, the claim is kept and the group is stopped for the maintainer per "Raising a Blocked Question". Where a confirmation fails for an abandoned group, cleanup stops there and the group is stopped for the maintainer. That stop is per "Raising a Blocked Question", since past that point removal discards work. A dead worker's clean tree whose branch fails the check is retired alone instead, per "Bounding the Wait on a Worker". Where a pushed branch still heads or bases an open pull request, what goes to the maintainer names that pull request. -A worker still live, a promotion fix included, keeps its worktree until the next round's cleanup step. +A worker still live, a promotion fix included, keeps its worktree until it ends and its group's cleanup runs. **A standalone clone holds its branch alone**, since the base clone does not register it. So the base-clone commands above do not reach it, and deleting the clone deletes its local branch too. @@ -510,12 +552,12 @@ The orchestrator finds it under the temporary root the brief named, by the recor run that named another root cannot find it, so its group goes to the maintainer. The abandoned-worker discard above does not run there, so a dirty abandoned clone goes to the maintainer. -The clone must be clean, and its tip is read with `git -C rev-parse refs/heads/`. +The clone must be clean by `repo-worktree` "Listing and Cleanup"'s hand-removal read, and its tip is read with `git -C "" rev-parse "refs/heads/"`. A clone retired alone, its branch left standing, also needs that tip to equal the remote tip, read -live with `git -C ls-remote --exit-code origin refs/heads/`. The remote then holds the +live with `git -C "" ls-remote --exit-code origin "refs/heads/"`. The remote then holds the only copy of the branch. A clone removed with its branch and no merged pull request instead needs -`git -C merge-base --is-ancestor refs/remotes/origin/develop` to exit `0` after -`git -C fetch origin develop`. Its branch, where pushed, then takes the abandoned-group +`git -C "" merge-base --is-ancestor "" refs/remotes/origin/develop` to exit `0` after +`git -C "" fetch origin develop`. Its branch, where pushed, then takes the abandoned-group remote checks, delete, and confirmation above first. Where the checks hold, the orchestrator then deletes the clone's exact directory, per `repo-worktree` "Listing and Cleanup". It also removes the recorded name from the claim comments. A clone removed with its branch and no merged pull request @@ -557,9 +599,10 @@ is met here. A worker reports merged, parked, stopped, or handed back for review. A worker that reports nothing at all needs a bound. Its silence looks exactly like slowness, and dying mid-drive is ordinary here. -The bound is a state read rather than a clock. When the other workers in the round have reported, +The bound is a state read rather than a clock. Wait until every other worker dispatched no later than +the silent one has reported or is confirmed gone, as below. Then read the silent worker's branch and pull request directly, with `git log` on that branch and -`gh pr view `. Pass the branch as that command's positional argument, since a +`gh pr view ""`. Pass the branch as that command's positional argument, since a bare `gh pr view` resolves the pull request of whatever branch the caller is standing on. It never resolves the worker's. Let what they show decide. A pull request that is merged means the worker died after doing the work. The group is then finished. @@ -573,11 +616,12 @@ that is. Waiting costs a round's latency and guessing costs another task's uncom Once the worker is confirmed gone, its worktree decides what follows. A standalone clone recorded on the claim comment is that worktree, retired or removed per "Cleanup Is the Orchestrator's". Where that fails, the group stops there and no fresh worker is dispatched. +A worktree is judged clean or dirty by `repo-worktree` "Listing and Cleanup"'s hand-removal read. **A clean one** is cleaned up as an abandoned group's is, per "Cleanup Is the Orchestrator's". That procedure confirms the branch carries no commit that is not already on develop before anything is removed. A worker that committed its fix and then died leaves a clean tree standing over commits develop has never seen. So that check is what separates the two. It holds, and once that procedure releases the claim, -the issue returns to the next round's ranking to be dispatched on a new branch. It +the issue returns to the ranking to be dispatched on a new branch. It fails, and the branch holds the dead worker's work. So the worktree alone is retired, per "Cleanup Is the Orchestrator's". The branch, its claim, and any pull request it heads stay standing. A fresh worker is then dispatched on that same branch to finish the drive, in the dead @@ -610,17 +654,18 @@ rather than a decision. - **The question is also written on its issue, and so is the answer**, so both survive the session that asked it. - **A stopped group keeps its branch and its claim.** Its worktree is left exactly as it stands while the question is open, since the answer may be that the work in it continues. Say in the - prompt whether that worktree holds uncommitted work. For a standalone clone, say also whether its + prompt whether that worktree holds uncommitted work, by `repo-worktree` "Listing and Cleanup"'s + hand-removal read. For a standalone clone, say also whether its tip equals the remote tip, and that pushing the branch is the maintainer's. That is because what becomes of it is part of what is being asked, rather than something to settle while waiting. - **Resuming retires that worktree first, then dispatches a fresh worker.** Git refuses to attach a branch already checked out somewhere, per `repo-worktree`. So a fresh worker cannot take the branch while the stopped tree holds it. Once the answer is in, remove that worktree if it is - clean. Otherwise apply what the answer said about its uncommitted work, then remove it. A + clean by `repo-worktree` "Listing and Cleanup"'s hand-removal read. Otherwise apply what the answer said about its uncommitted work, then remove it. A standalone clone draws no such refusal and is retired all the same, so two checkouts never hold one branch. It is retired per "Cleanup Is the Orchestrator's", once its tip equals the remote - tip. Only then dispatch. This is the + tip. Only then dispatch, into a slot per "The Round" step 6. This is the same retire-then-dispatch shape "Bounding the Wait on a Worker" uses, and no worker ever inherits another's tree. @@ -675,11 +720,11 @@ the issues it fixes in a `Closes on promotion:` line in its own commit message, yields by handing the file over. A holder that already pushed and has an open pull request yields by having that pull request wait, its branch untouched. It also yields by the promotion fix taking the file, since the two must not be in flight on one file at once. Once the fix - lands, that pull request waits untouched until the freeze lifts. Reconciling its content is the + lands, that pull request waits untouched until the next round dispatches. Reconciling its content is the next round's worker's job rather than the orchestrator's, which opens no branch and edits nothing. The orchestrator retires that group's worktree, the branch and its pull request left standing. That is the worktree-only disposition "Cleanup Is the Orchestrator's" separates out, - and the retire-then-dispatch shape "Raising a Blocked Question" uses. The orchestrator then + and the retire-then-dispatch shape "Raising a Blocked Question" uses. That next round dispatches a fresh worker on that same branch. That worker is briefed either to merge develop in to pick the fix up, or to narrow the change to drop the file. Never rebase it, since its branch is already pushed and a rebase there needs what `GOVERNANCE.md` "Git and Commit Rules" forbids. @@ -704,13 +749,17 @@ two hops. First, for each commit in `origin/main..origin/develop`, freshly fetched, read the pull request that merged it into develop: ```sh -gh api repos///commits//pulls --jq '.[] | select(.merged_at != null and .base.ref == "develop") | .number' +gh api "repos///commits//pulls" --jq '.[] | select(.merged_at != null and .base.ref == "develop") | .number' ``` Then read each pull request it prints for its `Closes on promotion:` line. That is the line "Grouping and File Claims" requires every feature pull request to carry and every worker brief to ask for. A commit it prints nothing for is a direct push. Read that commit's own message for its -line instead. A read that exits non-zero stops the assembly and is reported. +line instead. On an operational-model repository, also read the same places for a +`Reopens on promotion:` line, which a change undoing a fix carries there per `GOVERNANCE.md` +"Operational Repositories". Leave out each issue such a line names, unless a later change in the +range names it on a `Closes on promotion:` line again. A read that exits non-zero stops the +assembly and is reported. **That line exists because the set has to be stated rather than inferred**, distinct from any issue a body merely mentions. A body routinely references an issue it does not fix, the deferral @@ -730,6 +779,14 @@ from a read of the body made immediately before the write, keeping every line th Then read the body again, and repeat the amendment where it lacks a `Fixes` line a freshly fetched range calls for. Checking the whole set rather than only this amendment's own lines is what restores a line another session's write dropped. +On an operational-model repository, a `Reopens on promotion:` line can land in the range during the +freeze. Where it names an issue the body holds a `Fixes` line for, put that line to the maintainer +rather than editing it. A seat cannot tell that line from one added by hand for a change that left +its own line out. + +Run the mechanical closing-set check that `branching-and-release-model` states in its +negated-keyword bullet, at each point that bullet names. A body naming a deferral issue +in a sentence that negates a keyword still closes that issue, and reading the body misses it. ## Away Mode @@ -765,6 +822,12 @@ merge to main with no release never exercises artifact creation. rule assumes no other run is live and no attended session works a parked group's issue. So the maintainer starts an away run only once any earlier run has ended and no such attended work is in flight. +- **An away run gains nothing from a session on `highest`.** The lean orchestrator below reads no + issue, diff, or thread. Its planner and workers run at the tiers this skill names, whatever the + session's own. So `highest` there buys only a dearer dispatcher, and an away run is launched at + `frontier`. An attended run is the one a stronger session improves, since there the orchestrator + ranks, groups, and chooses each tier itself. A session on `highest` asked for an away run says + this once, before its first dispatch, and then runs as asked. ### Needs the Maintainer @@ -843,23 +906,34 @@ subagents and holds only what they return. undetermined outcome, a settled decision, or an unrequested rule, the planner files it as `decision`. It comments the question there, unless the issue already carries the label. It returns the round plan: each group's issues, branch, claimed files, and tier, then each held-back - issue with its reason. It also names each `deferred` issue it lifted. A promotion fix comes first, and a group resuming parked work names the + issue with its reason. It also names each `deferred` issue it lifted. A planner stopping short of + a plan still returns each claim comment it wrote. A promotion fix comes first, and a group resuming parked work names the parked worktree. 2. **Retire each parked worktree a resuming group names**, before dispatching its worker. Git - refuses to attach a branch another worktree holds, per `repo-worktree`. Remove a clean tree with - `git worktree remove `, leaving its branch standing. That command errors on a + refuses to attach a branch another worktree holds, per `repo-worktree`. Remove a tree clean by + `repo-worktree` "Listing and Cleanup"'s hand-removal read with `git worktree remove ""`, leaving its branch standing. That command errors on a standalone clone, which takes the retire-alone checks of "Cleanup Is the Orchestrator's" instead. Leave a dirty tree, or a clone failing those checks, exactly as it stands. Keep its group parked, and name it in the report. Only the maintainer disposes of another task's uncommitted work. -3. **Dispatch the group workers** per "Dispatching a Worker", each brief built from the group's - line. Each brief also states the park duty below and the comment rule above. A group worker - drives to develop and ends there, whatever the scope. +3. **Dispatch the group workers** per "Dispatching a Worker", each brief built + from the group's line. Each brief also states the park duty below and the comment rule above. + A group worker drives to develop and ends there, whatever the scope. 4. **Collect each worker's one-line outcome**, bounding the wait per "Bounding the Wait on a Worker". A worker that hands back for review is continued per "The Round" step 5. Dispatch the reviewer, record the pass per `local-strict-review` "Running It", and continue the same worker. - The orchestrator reads only the reviewer's findings and the record's exit. -5. **Clean up** per "Cleanup Is the Orchestrator's". Each command there is one call whose exit and + The orchestrator reads only the reviewer's findings and the record's exit. **The slot a worker + frees is refilled** per "The Round" step 6, once step 5 below has run for its group. Dispatch a + planner that runs orchestrator step 1 for the free slots, without the net-flow count. Dispatch + one for each worker that ends. Once this round has dispatched eight groups, dispatch one only + while a group this round stopped or parked has not resumed. Such a group needs no place among + the eight, and no other group can take a slot. The planner's brief names each group this round dispatched. It marks each whose worker has not yet ended and each that stopped or parked and + has not resumed. It + names no file set. The planner reads each group's current set from its claim comment, which + holds any grown set granted since the plan. One refill planner runs at + a time, and none starts while a dispatch is pending. While one runs, a grown set a worker reports and a group's cleanup + each wait for it to return. So every claim is written from a current read. Then dispatch each group's worker per steps 2 and 3. +5. **Clean up** each group as its worker ends, per "Cleanup Is the Orchestrator's". Each command there is one call whose exit and status line are all the orchestrator reads. 6. **Promote** per "Promoting" below. 7. **Record the round's report** in working notes, per "Run State", and start the next round. @@ -887,6 +961,8 @@ a state of the session rather than of any issue, so the orchestrator handles it condition, and one leaving unclear whether a subagent started. It also covers a dispatch still failing after its third wait, and a timer that cannot start. The final message names the seat whose dispatch failed and the error its last attempt returned. +- **Once the run is ending, a failed dispatch takes neither path above.** "Ending an Away Run" + says what becomes of it. ### Parking Instead of Asking @@ -984,16 +1060,32 @@ group's pull request merges, the worker ends the track with `close`, per `sessio The run ends at the first of these, each an ending of its own: -- A re-rank finds nothing it can act on. +- A round's opening ranking finds nothing it can act on. - The round cap is reached. - A dispatch fails, per "A Dispatch That Fails". - A condition every later round would meet. Examples are a missing label, an exhausted reviewer allowance, a refused push or merge, and a read the planner cannot make. - The session ends. -The final message is the report "Ending the Run" describes, with every held-back issue under the +Every ending but the session's own first drops every waiting dispatch retry and stops its timer. +From then, a dispatch that fails is not retried and ends nothing. That holds for a reviewer and +for continuing a handed-back worker alike. The ending names that worker as uncollected, leaves its +branch and claim as they stand, and goes on. It names a worker whose dropped retry it needed the +same way. Where the error left unclear whether the dispatch started, it marks that seat as one +that may be live. Every ending but +the session's own and a dispatch failure then collects each worker still in flight. It cleans up each such +group per "The Lean Orchestrator" steps 4 and 5, and refills no slot. Such an ending also waits +for a refill planner still running. An ending releases no claim it did not clean up. "Grouping and File Claims" +counts no claim in flight that has neither a branch nor a live worker. Every ending but +the session's own names each claim the run recorded for a group with no outcome. It also names +each planner that ended returning nothing, since the claims it wrote are unknown. A run ended by a +dispatch failure names each worker and any refill planner still in flight, the claims such a +planner writes being unknown. Where its error left unclear whether the failed dispatch started, it +marks that seat as one that may have. Where that seat was a planner, its claims are unknown too. The final message is the report "Ending the Run" describes, with every held-back issue under the reason that holds it back. **Only what needs the maintainer is reported as needing the -maintainer.** That is an open `decision` issue, a group parked on one, and a parked dirty tree. It +maintainer.** That is an open `decision` issue, a group parked on one, and a parked dirty tree. +It is also a worker named as uncollected, since no later run resumes its group. It is also a +missing or wrong shared git hook a worker reported, per `repo-worktree` "Preparing Git Hooks". It also covers an issue held back for a setting, a credential, a host, or the agent-safety tree, reported as needing the maintainer present. An outsider's issue awaiting acceptance is reported as needing the maintainer to accept it. Each other reason is named as itself, never as a @@ -1004,7 +1096,7 @@ it. An ending that cannot dispatch a promotion worker the run owes is named too. ## Run State - **Working notes outside the repository hold the round**: the ranking, the working groups, the - tier choices, and the worker assignments. A scratch file the harness gives a session serves + tier choices, the worker assignments, and the outcomes. A scratch file the harness gives a session serves where there is one. Any note kept out of the tree serves where there is not. It is the in-flight session state `GOVERNANCE.md` "Durable Knowledge and Self-Improvement" describes, and nothing about it is committed. @@ -1019,7 +1111,7 @@ it. An ending that cannot dispatch a promotion worker the run owes is named too. The run ends at one of the points below, and they are different endings. -- **The backlog is worked out**, meaning a full re-rank finds no open issue this skill can act on. +- **The backlog is worked out**, meaning a round's opening ranking finds no open issue this skill can act on. That differs from zero open issues, since a backlog of nothing but maintainer questions and issues whose blockers still stand is a finished run. Report it as finished, with the questions put to the maintainer. @@ -1046,7 +1138,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i - **`frontier`** is the fleet's default reasoning tier, for orchestrating, rule text, design, spec logic, and adversarial review. It is not the most capable model available, which is `highest`. - **`standard`** is ordinary implementation and driving a pull request. Judging a review finding is never mechanical, however often it repeats, so it runs at `standard` or above. A `standard` driver's evidence-backed decline of a finding raised on its pull request stands, since that pull request's reviewers and its merge gate check it. - **`bulk`** is the cheapest model that does the work correctly. It is for high fan-out mechanical work, such as an extraction or a status check. -- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set, and otherwise at the session's own. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. A session never reaches for it because a task looks hard. +- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set. Otherwise it runs at the default the host's agent-safety kit sets, which is the `frontier` model. On a host without the kit it runs at the session's own. That default does not reach every agent type a tool builds in. On Claude Code the `Explore` and `Plan` types still take the session's model, so the kit refuses a dispatch of either that names no model. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. The kit's default is a backstop for a dispatch that forgot its tier, never a reason to leave one out. A session never reaches for it because a task looks hard. | Tool | `highest` | `frontier` | `standard` | `bulk` | | --- | --- | --- | --- | --- | @@ -1055,7 +1147,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i Each cell is the name that tool's subagent dispatch takes, which follows the latest model of its family. A dispatch on a tool with no row here, or on one that cannot name a model per subagent, names no model. - **A tier resolves only through this table.** A word such as "frontier", "strongest", or "most capable" never resolves to `highest`. The industry's "frontier model" is the opposite of what this tier means here. A session that cannot see this table names no model rather than guessing one. -- **An orchestrating seat runs at `frontier` and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. +- **An orchestrating seat runs at `frontier`, or at `highest` where the maintainer chose that for the session, and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. diff --git a/.github/skills/branching-and-release-model/SKILL.md b/.github/skills/branching-and-release-model/SKILL.md index 68b33c2d..3c67af58 100644 --- a/.github/skills/branching-and-release-model/SKILL.md +++ b/.github/skills/branching-and-release-model/SKILL.md @@ -55,13 +55,37 @@ rather than guessing from the repo's contents. workflow YAML file resolves on a throwaway branch off `main`, not on `develop`. Full recovery and conflict-resolution commands: `references/branch-protection-and-promotion.md`. - **A merge or release ends with worktree cleanup and the base clone on current `develop`.** Run the `repo-worktree` post-merge procedure after a feature squash merge. Run it again after a promotion or release completes, unless the user explicitly asks to retain a checkout or branch. Remove finished task, conflict-resolution, installer, and release helpers. Never delete `develop`, and never leave the base clone on `main` merely because `main` was promoted or released. -- **Issue-closing keywords (`Closes #N`, `Fixes #N`) go in the `develop -> main` promotion PR, not - the feature -> `develop` PR.** GitHub auto-closes an issue only when the closing keyword merges - into the **default branch** (`main`), so a feature -> `develop` PR merge never fires it. - Reference the issue in the `develop` PR body if useful, but the actual closing keyword belongs on - the promotion PR. Closing by hand is the ordinary route wherever the keyword cannot fire. Cases include a +- **Issue-closing keywords (`Closes #N`, `Fixes #N`) go in the `develop -> main` promotion PR's + body, and nowhere else.** The keywords are `close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, + `resolve`, `resolves`, and `resolved`. Each closes the issue it directly precedes once the text + holding it reaches the **default branch** (`main`). A feature -> `develop` PR targets another + branch, so it registers no closing reference itself. Its squash commit's message is still what + the repository's squash setting composes, read live with + `gh api "repos//" --jq .squash_merge_commit_message`. Where that reads `PR_BODY`, as + it does in the hub, the PR body becomes the commit message. So a `Fixes #N` in that body lands + on `develop` and closes #N when the promotion brings the commit to `main`. That holds whatever + the promotion body says. A direct-push commit message on `develop` behaves the same way. So a + feature PR body or a direct-push commit carries no closing keyword. It names the issues it fixes, + where it names them, in the inert `Closes on promotion: #N, #M` line. The promotion PR's body + carries one closing keyword per issue those lines name. In an operational repository that line + is required, as "Operational repositories (the complete delta)" below sets. That delta also lets + a rollback's `Reopens on promotion:` line take an issue out of the promotion body. Closing by hand is the ordinary route wherever the keyword cannot fire. Cases include a promotion that already merged without it, or completed work with no promotion imminent. Closing by hand is not a repair for a botched promotion. Cite the squash SHA and re-read that commit before closing. +- **A closing keyword fires inside a sentence that negates it.** GitHub matches the keyword and + the reference alone, with at most a colon between them, and reads no other word. So each of + `does not fix #N` and `narrowed rather than closed: #N` closes its issue. Where text names an + issue it leaves open, keep every keyword away from the reference, as in `#N stays open`. Reading the + text misses this. So check a promotion PR mechanically after opening it and after each body + amendment. Check it again when reporting it ready and before merging it, since a merge into + `develop` moves the range. + Compare the set + `gh pr view "" --repo "/" --json closingIssuesReferences --jq '[.closingIssuesReferences[].number]'` + prints with the intended set. Then scan the range's commit messages, since a keyword there closes + its issue at the promotion merge too: + `git log --format=%B origin/main..origin/develop | grep -n -i -E '\b(close[sd]?|fix(e[sd])?|resolve[sd]?):?[[:space:]]+[[:alnum:]_./:-]*(#|/issues/)[0-9]'`, + run after `git fetch origin`. Each line it prints is a closure the promotion merge makes + whatever its body says. Name any unintended one in the promotion PR's ready report. - **Neither ruleset requires branches to be up to date before merging.** The reasons differ on each branch (a graph-based check that would fail every release on `main`, a check that stalls bot auto-merge on `develop`). Detail: `references/branch-protection-and-promotion.md`. @@ -136,10 +160,18 @@ stays the same: The host write guard allows the in-place commit only once the repository's `.github/agent-policy.json` on `main` lists `develop` in its `guard` section. The maintainer's merge to `main` therefore grants the exemption, and until then the guard denies it. -- **A direct push names the issues it fixes in its commit message**, as one line such as - `Closes on promotion: #N, #M`. The words `on promotion:` keep GitHub from reading the line as a closing keyword. The promotion - PR carrying the push puts a closing keyword in its own body for each issue the line names, per the - closing-keyword bullet above. Its body takes no closing keyword for a push without the line. +- **A change reaching `develop` names the issues it fixes in one line**, such as + `Closes on promotion: #N, #M`. A direct push writes the line in its commit message. A pull + request into `develop` writes it in its body. The promotion reads a merged pull request's line + from its body, never from its commits. The words `on promotion:` keep GitHub from reading the line as a closing keyword. The promotion + PR carrying the change puts a closing keyword in its own body for each issue the line names, per the + closing-keyword bullet above. Its body takes no closing keyword for a change without the line. + A change that undoes a fix not yet on `main` names that fix's issues in one + `Reopens on promotion:` line, written where a `Closes on promotion:` line would go. A rollback + committed as an ordinary change is one. The line is required because a rollback often carries + no revert marker for the range to show. The promotion body takes no closing keyword for an issue + that line names. Where the range names one issue on both lines, the line of the latest change + naming it decides. - **A PR into `develop` stays available, and CI runs on it, reported but not required.** Dropping the requirement permits the direct push. It does not withdraw the pull request, so a change worth reviewing takes one and both paths into `develop` are legitimate. @@ -153,7 +185,9 @@ stays the same: That would withdraw the allowance the model exists to give. - **The `main` promotion gate is unchanged.** The shared `main` ruleset still **enforces** the required `Check pull request workflow status job` on the `develop -> main` PR. For an operational - repo that check is lint/validation only, never unit tests. It is editorconfig/EOL plus a domain linter + repo that check is lint/validation, with unit tests only for a .NET test project or a Python suite + the validator runs. A test in the repo's own `.github/actions/validate/action.yml` hook counts too. + The check is editorconfig/EOL plus a domain linter such as a Home Assistant or ESPHome config validation. So `develop` stays the live surface and a broken config can never reach `main`. - **Release only by manual dispatch.** Operational repos carry `releaseTrigger: dispatch-only` and diff --git a/.github/skills/branching-and-release-model/references/branch-protection-and-promotion.md b/.github/skills/branching-and-release-model/references/branch-protection-and-promotion.md index ad3c1117..2a0c05eb 100644 --- a/.github/skills/branching-and-release-model/references/branch-protection-and-promotion.md +++ b/.github/skills/branching-and-release-model/references/branch-protection-and-promotion.md @@ -2,8 +2,8 @@ Full detail for the "Branching" rules in `SKILL.md`. Load this when configuring or reconstructing branch protection on a fleet repo, or when executing a `develop -> main` promotion. Also load it -when recovering a lost `develop`, resolving an EOL-only promotion conflict, or working on the -dual-target bot wiring (Dependabot, codegen, the merge-bot). It is not for an ordinary +when recovering a lost `develop`, cutting a conflicted promotion, the EOL-only case included, or +recovering a squash into `main`. Load it too when working on the dual-target bot wiring (Dependabot, codegen, the merge-bot). It is not for an ordinary feature-branch PR, which the SKILL.md summary covers. ## Configuring branch protection: don't hand-build the rules @@ -11,7 +11,7 @@ feature-branch PR, which the SKILL.md summary covers. From a hub checkout at `main`, create **exactly two rulesets named `develop` and `main`** from the hub's `repo-config/*.json` payloads. Use a hub checkout at `develop` instead while the repository's registry entry has merged there but not yet reached `main`. Run -`repo-config/configure.sh apply / release|operational` from that checkout. The names +`repo-config/configure.sh apply "/" release` (substitute `operational` for an operational repo) from that checkout. The names are load-bearing because governance content and workflows reference them. The registry `workflowModel` selects the `develop` payload for a registered repository. `apply` refuses a repository outside the registry, writing nothing. Once `apply` has created both rulesets, delete @@ -27,17 +27,28 @@ These traps were learned the hard way: exactly this reason) deletes `develop` itself. Merge a promotion with a plain `gh pr merge --merge`, no `--delete-branch`. If `develop` is ever lost this way, restore it to the merged PR's head SHA. That SHA is still reachable as the merge commit's second parent: - `gh api -X POST "repos///git/refs" -f ref=refs/heads/develop -f sha="$(gh pr view --json headRefOid --jq .headRefOid)"`. + `gh api -X POST "repos///git/refs" -f ref=refs/heads/develop -f sha="$(gh pr view "" --json headRefOid --jq .headRefOid)"`. - **Spurious EOL-only conflicts resolve by taking `develop`.** When `develop`'s `.editorconfig` line-ending default has changed while `main` hasn't caught up yet, `develop -> main` conflicts *whole-file* on every renormalized path. An example of that default changing is the fleet-wide CRLF-to-LF flip. `develop`'s `required_linear_history` plus PR rulesets forbid resolving on `develop` (no merge commit, no force-push). So resolve on a throwaway branch off `main`: `git checkout -b promote/develop-to-main origin/main && git merge origin/develop`. Take - `develop`'s side for the EOL-conflicted files (`git checkout --theirs `) **after + `develop`'s side for the EOL-conflicted files (`git checkout --theirs ""`) **after confirming each is content-identical modulo EOL, or that `develop` is a strict superset** (`diff <(git show ":2:" | tr -d '\r') <(git show ":3:" | tr -d '\r')`). Then open that branch into `main`. Verify no genuine `main`-only content is dropped (build/test where the repo supports it). +- **A conflicted promotion lands from a branch cut from `main` that merges `develop`.** The EOL-only case above is one instance. A bot bump that landed on `main` and `develop` separately, beside a line `develop` changed, is another. This procedure covers a `develop` that is a strict superset of `main`'s content. The steps: + 1. Run `git fetch origin`, then cut the branch in a worktree of its own: `git worktree add -b promote/develop-to-main "" origin/main`. Run `git merge origin/develop` there. + 2. Take `develop`'s side on each conflict only after the strict-superset check above shows `main` holds nothing `develop` lacks there. Stage each resolved file and commit the merge, so `HEAD` holds it. + 3. Confirm the merged tree equals `develop`'s before the push: `git diff origin/develop HEAD --stat` prints nothing. + 4. A path it prints holds content `develop` lacks. Redo a resolution that kept `main`'s side. Land genuine `main`-only content on `develop` through a feature pull request first. Then run `git fetch origin develop` and merge `origin/develop` again. + 5. Open the branch as the promotion pull request in place of the one headed by `develop`. Carry the superseded pull request's whole body, its closing set included. + 6. Carry its labels too, `comments` among them. Without that label, a local strict pass on the new head reports every comment line the feature pull requests landed as `comment-added`. + 7. Close the superseded pull request with a comment naming the new one. + 8. Land each later `develop` fix on the branch in the same worktree. Run `git fetch origin develop`, then `git merge --no-ff origin/develop`. Re-run the tree check, then push the branch. + 9. Merge it like any promotion, with `--merge`. The merge commit restores the merge base, so the next promotion runs from `develop` again. +- **A squash into `main` is recovered with that same cut.** The `main` ruleset allows only merge commits, yet its admin bypass lets a squash through. A squashed promotion leaves `main` with `develop`'s content but not its history. The merge base stays at the previous merge commit. So the next promotion conflicts wherever a later `develop` change edits a line the squash already carried. Where it merges cleanly instead, it keeps any such line a later `develop` change removed. GitHub runs no pull request workflow while the promotion conflicts. So the hub's `validate-task.yml` `Check promotion history step` fails the next promotion that merges cleanly. It names each single-parent commit on `main`'s first-parent chain since its previous promotion merge. Recover with the conflicted-promotion cut above, resolving each conflict as its step 2 states. The cut merges from the same stale base, so it can keep a removed line too. Its tree check then prints that path. Restore `develop`'s version of each such path the squash carried with `git checkout origin/develop -- ""`. Remove one `develop` has since deleted with `git rm ""`. Then commit. The step passes a head that already holds each commit it named, and the merge then restores the merge base. Never rewrite or force-push `main` to undo the squash. ## Why both rulesets omit "Require branches to be up to date before merging" @@ -52,7 +63,7 @@ The flag is off on `main` and on `develop`, for related but distinct reasons. and the linearity invariant. - **Develop**: the check stalls bot auto-merge when two bot PRs against `develop` land within the same window. As soon as the first merges, the second flips to `mergeStateStatus: BEHIND` and - GitHub's auto-merge will not fire while strict is on. The merge-bot only *enables* auto-merge on + GitHub's auto-merge will not fire while strict is on. The merge-bot arms auto-merge on `opened`/`reopened` and never auto-updates bot branches, and Dependabot's rebase isn't real-time. So the second PR sits OPEN with all checks green indefinitely. Squash mechanics still rebase the diff onto `develop`'s tip on merge, and `required_linear_history` still enforces linearity. @@ -83,12 +94,19 @@ during long-running develop features. Codegen content can also be production-cri So both branches need fresh codegen on their own cadence. **Maintainer-pushed commits on a bot PR auto-disable auto-merge.** The merge-bot's -`merge-dependabot` and `merge-codegen` jobs only fire on `opened`/`reopened` events (auto-merge is -enabled exactly once per PR). A maintainer may push commits to a bot's branch. Such a push is a `synchronize` +`merge-dependabot` and `merge-app` jobs arm auto-merge only on `opened`/`reopened` events. Its +`rearm-auto-merge` job leaves the disable below in place, since the head is then not the bot's own push. A maintainer may push commits to a bot's branch. Such a push is a `synchronize` event with an actor that isn't the same bot. When it happens, the merge-bot's `disable-auto-merge-on-maintainer-push` job fires and calls `gh pr merge --disable-auto`. The maintainer's commits stay in the PR but won't auto-merge with the bot's content. Re-enable -auto-merge manually (`gh pr merge --auto ` or the GitHub UI) when ready. +auto-merge manually (`gh pr merge --auto ""` or the GitHub UI) when ready. + +**A disable GitHub makes is re-armed once, then fails visibly.** GitHub can disable an armed +auto-merge with every check green. It does so for a merge that would write workflow content the +App may not write. The caller stub triggers on `auto_merge_disabled`, so the merge-bot's +`rearm-auto-merge` job answers such a disable. It re-arms once the base branch has settled. Where +every check is green, `gh` merges at once instead, so a refused merge fails the job. That makes the +stall visible rather than recovering it. WORKFLOW.md D8.1 is the contract. ## Codegen determinism diff --git a/.github/skills/branching-and-release-model/references/release-publish-mechanics.md b/.github/skills/branching-and-release-model/references/release-publish-mechanics.md index 0c1d193d..b3af6488 100644 --- a/.github/skills/branching-and-release-model/references/release-publish-mechanics.md +++ b/.github/skills/branching-and-release-model/references/release-publish-mechanics.md @@ -116,9 +116,9 @@ A package publish job is gated like everything else, `needs:` the release-task c **Re-dispatch, available only while the tip has not moved.** A `workflow_dispatch` takes a ref rather than a commit, and D2.3 admits only `main` or `develop`. So what it builds is that branch's tip at dispatch time. While the tip is still the commit whose push failed, a re-dispatch rebuilds the same version and runs its push again. It refreshes the release the way any dispatch does. -This is a time-of-check-to-time-of-use race rather than a guarded operation, because nothing compares the tip against the failed run. So a push landing between the two mints a new version instead of erroring. The operator then sees a green publish that left the failed version unpublished. Confirm the failed run's own head commit still equals the branch tip immediately before dispatching. Make that comparison with `gh run view --json headSha` against `gh api repos/{owner}/{repo}/branches/` for the branch that run built rather than whichever branch is to hand. Where the two differ, or where the check is not worth making, prefer the re-run route, which is bound to that commit by construction. In those cases, fall back to re-dispatch only once the re-run window below has closed. +This is a time-of-check-to-time-of-use race rather than a guarded operation, because nothing compares the tip against the failed run. So a push landing between the two mints a new version instead of erroring. The operator then sees a green publish that left the failed version unpublished. Confirm the failed run's own head commit still equals the branch tip immediately before dispatching. Make that comparison with `gh run view "" --json headSha` against `gh api "repos/{owner}/{repo}/branches/"` for the branch that run built rather than whichever branch is to hand. Where the two differ, or where the check is not worth making, prefer the re-run route, which is bound to that commit by construction. In those cases, fall back to re-dispatch only once the re-run window below has closed. -**Re-run all jobs, available inside the window whatever the tip has done.** `gh run rerun ` replays the run under the original event's `GITHUB_SHA` and `GITHUB_REF` and re-executes every job rather than only the failed ones. The publisher pins the release task to that commit with `ref: ${{ github.sha }}`. So `get-version` recomputes the same version from the same commit and history, and each build leaf checks out the `GitCommitId` that job emits. So the package artifact D5.2 deleted is rebuilt and re-uploaded rather than missing when `publish-` downloads it. That job then retries the push it failed. The release itself needs nothing from the re-run, the failed run having already cut it. However, on a dispatch-triggered run the re-run re-enters `github-release`. That job refreshes the release per D4.4's dispatch leg and runs the `release-asset-*` delete with it per D5.2. A re-dispatch here would build the new tip instead. NBGV derives the version from git height, so that is a further version and the one whose push failed never reaches the registry. +**Re-run all jobs, available inside the window whatever the tip has done.** `gh run rerun ""` replays the run under the original event's `GITHUB_SHA` and `GITHUB_REF` and re-executes every job rather than only the failed ones. The publisher pins the release task to that commit with `ref: ${{ github.sha }}`. So `get-version` recomputes the same version from the same commit and history, and each build leaf checks out the `GitCommitId` that job emits. So the package artifact D5.2 deleted is rebuilt and re-uploaded rather than missing when `publish-` downloads it. That job then retries the push it failed. The release itself needs nothing from the re-run, the failed run having already cut it. However, on a dispatch-triggered run the re-run re-enters `github-release`. That job refreshes the release per D4.4's dispatch leg and runs the `release-asset-*` delete with it per D5.2. A re-dispatch here would build the new tip instead. NBGV derives the version from git height, so that is a further version and the one whose push failed never reaches the registry. The qualifications below come with the re-run route. diff --git a/.github/skills/carried-instruction-file-guard/SKILL.md b/.github/skills/carried-instruction-file-guard/SKILL.md index 3f41dc32..5c3b0e2c 100644 --- a/.github/skills/carried-instruction-file-guard/SKILL.md +++ b/.github/skills/carried-instruction-file-guard/SKILL.md @@ -29,7 +29,7 @@ The fix is not "be careful." Being careful is what failed the first time. The fi - Pick the phrase in it that is most peculiar to this repo, not generic governance vocabulary. A rule about "always sign commits" is generic. A rule about "this repo's Docker image pins Alpine 3.19 because 3.20 broke the s6 supervisor" is peculiar. - Grep the hub's canonical copy of the same file for that peculiar phrase. - **Absent from the hub canonical means it is a local addition.** It is never dropped because it looks similar to something else, and never dropped because a merge or overwrite would be simpler without it. -3. **A local addition found by the probe gets a destination, not a deletion.** It either names a rule that should apply fleet-wide, or it is genuinely specific to this repo. In the first case, flag it for the maintainer to promote into the hub. In the second case, it moves to the repo's own topical doc before the carried file is touched. Those docs are `CODESTYLE.md` for a language/formatting convention, `ARCHITECTURE.md` for a design decision, `OPERATIONS.md` for a runbook or operational note, `TODO.md` for backlog. Move it, confirm it is not lost, and only then proceed with the carry. +3. **A local addition found by the probe gets a destination, not a deletion.** It either names a rule that should apply fleet-wide, or it is genuinely specific to this repo. In the first case, flag it for the maintainer to promote into the hub. In the second case, it moves to the repo's own topical doc before the carried file is touched. Those docs are `CODESTYLE.md` for a language/formatting convention, `ARCHITECTURE.md` for a design decision, `OPERATIONS.md` for a runbook or operational note, `TODO.md` for backlog. Move it, confirm it is not lost, and only then proceed with the carry. `CODESTYLE.md` is the one guarded file that is itself such a destination, for a language convention. A local section there stays in place, and the carried text is merged around it. 4. **Do not trust a similarity or word-overlap check for step 2.** A repo-specific rule written in ordinary governance language reads as a reworded duplicate of an unrelated hub rule to that kind of check. That check will confidently tell you the local content is redundant when it is not. Exact phrase presence or absence is the only check that has held up. ## What is actually safe to overwrite without this procedure diff --git a/.github/skills/check-this-repo/SKILL.md b/.github/skills/check-this-repo/SKILL.md index d289019c..1365a8c1 100644 --- a/.github/skills/check-this-repo/SKILL.md +++ b/.github/skills/check-this-repo/SKILL.md @@ -45,8 +45,15 @@ reach this particular repo. default, pass the re-run `--dir` or `-Dir` naming the parent of `live.checkout`. That is because re-running the installer from any other directory leaves an existing registration where it is. - Where `live` carries no `vcs` and a non-null `commit`, it names a git checkout. One that - is detached, `branch: null`, or on an old branch is an answer too. Moving that checkout - is the fix rather than re-installing. + is detached, `branch: null`, or on an old branch is an answer too. So is a `live.commit` + behind the hub's own tip of `live.branch`. A checkout on `main` that has not pulled names + the right branch and still serves stale content. Fetch that branch into the same hub + checkout with full history. Name its destination, since a single-branch clone records + none: `git fetch origin "+refs/heads/:refs/remotes/origin/"`, + adding `--unshallow` in a shallow clone. A `live.commit` other than `origin/` for which + `git merge-base --is-ancestor "" "origin/"` exits 0 is behind. An exit + other than 0 or 1 means the test could not judge, which is an answer to report as well. + Moving or fast-forwarding that checkout is the fix rather than re-installing. - Any other shape names no registration, or one this report could not read, and the `reason` it carries, where it carries one, says which. 2. **Does this repo's own carried content still match the hub.** Compare `AGENTS.md`'s diff --git a/.github/skills/comment-and-doc-style/SKILL.md b/.github/skills/comment-and-doc-style/SKILL.md index 5650699f..1f0eaae1 100644 --- a/.github/skills/comment-and-doc-style/SKILL.md +++ b/.github/skills/comment-and-doc-style/SKILL.md @@ -7,7 +7,8 @@ description: >- characters to type in agent-authored text, whenever the file being edited is CRLF, whenever naming a tool in prose or docs, whenever authoring a new Markdown file, whenever editing a carried instruction file (AGENTS.md, GOVERNANCE.md, CODESTYLE.md, WORKFLOW.md, - .github/copilot-instructions.md), and whenever text states how many items a list or a table holds. + .github/copilot-instructions.md), whenever text states how many items a list or a table holds, + and whenever a doc gives a command for a reader to copy and run. Triggers even when the task looks purely mechanical, such as "just fix a typo" or "add a one-line comment", because an em dash slipped into a sentence, a comment that grew by one more clause, or a text-mode edit that silently flattens a CRLF file to LF are each easy to miss. @@ -86,8 +87,8 @@ Agent-specific authorization stays in provider-labeled bullets so one agent's co not read as a shared requirement: - **Codex:** execution rules match exact argument prefixes, so they cannot safely cover changing - worktree paths and digests. Smart Approvals can prompt per task. No-prompt operation is - supported only inside an external sandbox because it removes command-wide protection. + worktree paths and digests. Smart Approvals can prompt per task. No-prompt operation removes + command-wide protection, so it is supported only inside an external sandbox. ## Markdown formatting @@ -196,9 +197,9 @@ left exported reaches the commit and never the merge gate. The facts below about reaching those escapes read as a broken gate until they are known. On a public repository the lint job reads the label when it runs, and its log says "Read the pull request's labels live". A label added before then applies, and a rerun picks up one added since. In a private -repository, or where the log lacks that line, the event's snapshot decides. It misses a label -applied after the event, `gh pr create --label` included, so -there the label applies to the next push. The label reaches a repository only when the fleet label +repository, or where the log lacks that line, the event's snapshot decides. A label given to +`gh pr create` usually reaches the opened event, though it is sometimes missed. A label added +after the create applies from the next push, or from a close and reopen. The label reaches a repository only when the fleet label set is applied to it. So a repository that has not had that applied since the label was declared cannot carry it. In such a repository the finding names a remedy that is not yet available. And the local escape reaches a commit before any of that. A commit is where a repository meets this rule first, @@ -291,7 +292,7 @@ It is also because reading those would report a fixture rather than a claim abou Agent-authored text is ASCII by default: documentation, code, comments, commit messages, and PR descriptions. A non-ASCII character is read against the tiers below, because whether one is typography or meaning depends on where it sits. A character in no tier is a finding rather than a -silent pass, a letter of a recorded name excepted per the bullet below. +silent pass. A letter of a recorded name and quoted data are excepted, per the bullets below. - **Tier 1, never legitimate.** Typography carrying no meaning its ASCII form loses. Remove on sight: @@ -324,12 +325,17 @@ silent pass, a letter of a recorded name excepted per the bullet below. document records as data is written with its own letters and the marks they carry. The reason is that folding such a name to ASCII records a different name. Anywhere else a letter the agent writes that no tier covers takes its ASCII form. +- **A Markdown code span is quoted data, as a fenced block is.** A string quoted verbatim from + another source, such as a third party's output, keeps its bytes inside an inline code span. No + tier judges it there. Outside Markdown a backtick is structural, so a code line is read whole. - **An unrecognized non-ASCII character is reported, not allowed.** Classify it into a tier above - before using it. A letter of a recorded name is the one exception, per the bullet above. + before using it. A letter of a recorded name and quoted data are the exceptions, per the bullets + above. - **No semicolon in agent-authored prose.** Recast a mid-sentence semicolon as a comma or as two sentences. A semicolon separating items in a list that already contains commas, or a statement terminator in code, is unaffected. A single semicolon separates such a list only between two labeled items, as in `Inputs: a, b; outputs: c`, and a list item's bold opening label is not one. + A semicolon inside one token, such as `TL;DR`, joins no clause and is unaffected too. - **No spaced hyphen joining or interrupting a sentence** (` - `, or the paired aside ` - x - `). Recast as a comma, two sentences, or parentheses. A hyphen inside a compound word, a leading list marker, a range, and the `- **Label** - explanation` bullet separator are unaffected. @@ -358,20 +364,31 @@ the `spec/` files and the carried `AUDIT.md` never reference the template repo behavior a carried rule needs, not the coordination flow that produced it, the maintainer supplies the destination out of band. A contextually relevant link to a related project (the image this config feeds, a library this depends on) is not a coordination reference. It is expected. The full -exceptions are in `references/carried-doc-references.md`. They are a verbatim section that must -name the hub to do its job, and a pointer to a hub-hosted tool the reader runs. +exceptions are in `references/carried-doc-references.md`. One is a verbatim section that must +name the hub to do its job. The other is a pointer to a hub-hosted tool the reader runs, or to a +procedure the reader runs from a hub checkout. ## PR titles and commit messages - **Format**: an imperative subject, 72 characters or fewer, no trailing period ("Add 24-Hour - PM2.5 Average Sensor", not "Added X" or "Adds X"). An optional body, blank-line separated, + PM2.5 Average Sensor", not "Added X" or "Adds X"). The 72 measures the authored title or subject. + The `(#N)` suffix GitHub appends at a squash merge sits outside it, so a merged subject past 72 + breaks no rule. An optional body, blank-line separated, explains *why* the change is being made when that is non-obvious, the diff already shows *what*. +- **Closing keywords**: `branching-and-release-model` says where one may go. A form of `close`, + `fix`, or `resolve` directly before an issue reference closes that issue, even inside a sentence + that negates it. So `does not fix #N` closes #N. Write a reference to an issue left open with no + keyword beside it, as in `#N stays open`. - **Rules**: no vague titles (`update stuff`, `wip`). Dependabot's default `Bump X from Y to Z` - titles are fine as-is. No `Co-Authored-By:` lines unless the developer explicitly asks. No + titles are fine as-is. A `Co-Authored-By:` line is allowed unless the developer disallows it, + and a repository's own rules may change that default. A link to the agent's session, such as a + `Claude-Session:` trailer, is never allowed in a commit message or a pull request. Neither the + developer nor a repository's rules can allow one. No release-bump magnitude in the title ("minor", "patch", "release v0.2.0"), Nerdbank.GitVersioning computes the next version from `version.json` and git history. A dependency version in a dependency-bump title is fine and expected. US English spelling, and title case with lowercase - short bind words (a, an, the, and, but, or, of, in, on, at, to, by, for, from). A hyphenated + short bind words. The bind-word list is exhaustive: a, an, the, and, but, or, of, in, on, at, to, + by, for, from, with, as, via, into, over, per. A hyphenated compound capitalizes both parts unless the second is a short preposition (*Built-in*, *EPA-Corrected*, *24-Hour*). @@ -383,6 +400,14 @@ Bump xunit.v3 from 3.2.2 to 3.3.0 Clarify Devcontainer Setup Steps in README ``` +## Copy-and-run commands + + + +A command in Markdown is text a reader copies and runs, so it has to run as written once pasted. That covers a code span opening with a command and every line of a shell fence. Such a command holds no bare ``, since the shell reads `<` as a redirection and the paste dies before the command runs. It holds no bracketed `[Placeholder]` either, since the shell reads that as a glob. The glob expands silently to any one-character file it matches. And it holds no bare `a|b` alternation, since the shell reads that as a pipe. The left-hand side then still runs, a live write included, while its own output vanishes behind an error from the right-hand side. A real pipe is spaced, so it never reads as an alternation. A placeholder is quoted instead, as in `git branch -d ""`, so the shell reads it as one word rather than as syntax. The quotes wrap the placeholder alone where its value may need the shell to expand it, such as a path opening `~`. The reader fills the value in inside the quotes. A value that is several arguments, such as a command and its own arguments, or one the shell must expand, replaces the quotes too. A single argument holding spaces keeps them. Inside a string handed to a second shell, such as the one `sh -c` runs, the placeholder is quoted within that string. A choice between values is written as the common value, with the other named in a parenthetical after the command. So `repo-config/configure.sh check "/" release` is followed by "(substitute `operational` for an operational repo)". In a shell fence that parenthetical is a trailing comment instead. An optional flag is not written in brackets, since that is a glob too. It is left out of the command and named in the parenthetical. The rule holds for every such command, one naming a single argument in prose included. That is because whether a reader pastes a span whole is a judgment no check can make. The prose gate's `paste-safe` rule enforces it for the commands its data file names. It also reads a string handed to a second shell, as `su -c`, `sh -c`, `bash -c`, and `ssh` take one, as the command that shell runs. + + + ## Quantitative claims diff --git a/.github/skills/comment-and-doc-style/references/carried-doc-references.md b/.github/skills/comment-and-doc-style/references/carried-doc-references.md index 4aa33975..d9125c0a 100644 --- a/.github/skills/comment-and-doc-style/references/carried-doc-references.md +++ b/.github/skills/comment-and-doc-style/references/carried-doc-references.md @@ -53,13 +53,17 @@ same document's own prose, outside that region, is governed normally. A referenc verbatim section is a defect in the canonical. It is fixed once at the source rather than reported against every repository carrying it. -**The second exception is a hub-hosted tool the reader is told to run**, which is a different kind -of reference. A rule naming a gate, a script, or a reference snippet the reader executes or copies -states an instruction rather than a provenance. An instruction with no destination is -unfollowable, which is precisely how a pointer in carried text comes to read as decorative. The -test is whether the reference is something the reader *does* or something that *happened to this -file*. Where the content came from stays out, what the reader runs stays in. Such a pointer names -the hub's canonical rather than this repository's provenance. So it is the hub's to keep resolving +**The second exception is a hub-hosted tool the reader is told to run, or a procedure the reader +runs from a hub checkout.** It is a different kind of reference. A rule naming a gate, a +script, or a reference snippet the reader executes or copies states an instruction rather than a +provenance. So does a procedure whose steps the reader runs from a hub checkout, such as auditing +a repository and converging what the audit finds. Reporting a discrepancy upstream runs no such +step, so it stays under item 1. An instruction +with no destination is unfollowable, which is precisely how a pointer in carried text comes to read +as decorative. The test is whether the reference is something the reader *does* or something +that *happened to this file*. Where the content came from stays out, what the reader runs or +carries out stays in. Such a pointer names the hub's canonical rather than this repository's +provenance. So it is the hub's to keep resolving and never a repository's to edit out or re-point at a local path. What is reached rather than carried, and how, is `GOVERNANCE.md` "Hub-Hosted Tooling". In `AGENTS.md` and `GOVERNANCE.md` this belongs in verbatim rule text, the same region the first exception already covers. So the whole diff --git a/.github/skills/decision-triage/SKILL.md b/.github/skills/decision-triage/SKILL.md index fe537db0..7e56609f 100644 --- a/.github/skills/decision-triage/SKILL.md +++ b/.github/skills/decision-triage/SKILL.md @@ -217,7 +217,9 @@ an item leaves the queue, carried here whole as a generated include. - **Reference every pull request as a clickable link.** When you mention a PR on a surface that renders Markdown (chat, a summary, a report), render it as a Markdown link to the PR. Write it as `[#N](https://github.com/OWNER/REPO/pull/N)`, never a bare `#N`. The same applies to issues and commits. **The form follows the surface.** Some surfaces link neither a Markdown link nor a bare URL, an interactive prompt's question and option text among them. Pasting a full URL into one of those does not rescue it, since the reader gets a string to copy. That is the outcome this rule exists to prevent. There the reference is a bare `#N`. The clickable link goes in the message that comes **before** the prompt rather than merely alongside it. That is because the prompt blocks on an answer, and a message emitted after it is read once that answer is already given. That is the one moment the link is no longer any use. The test is whether the reader can click it where it is read, not whether it was written in the syntax that works elsewhere. - **Put a command the user must run where the user can run it.** This session's input line is where the user types to the agent. A command runs outside this session where this session's input line cannot run it or cannot hold its effect. One waiting on typed input, such as a password or a confirmation, is such a command. So is one meant for another host, or one setting a variable the session reads at launch. Every other one runs at this session's input line, where that line can run a command, and outside the session otherwise. **A command the user runs outside this session goes in the question's own text.** Where a question asks the user to run one, the question carries the exact command, complete and ready to paste. A message before the prompt may repeat the command, but the question never points at that message. A question pointing at it can leave the reader to find the command among a long run of earlier output. Such a command stays in the prompt, where the turn opens one, although the clickable-link bullet above moves a link out of one. The command needs no rendering, since the prompt shows it as plain text the reader can copy. **A command the user runs at this session's input line never goes in an interactive prompt.** On Claude Code such a command is a `!` line, typed at the session's input line so its output lands in the session. While an interactive prompt is open, the user cannot type at the session's input line. So a command placed in one sits in the one surface that blocks running it. It goes in a plain message instead, as a fenced block holding the `!` line itself, complete and ready to paste. Several commands join on that one line with `&&`, which runs them in order and stops at the first that fails. The block opens the message. Any question the same turn owes follows it as a numbered list, and any report comes after both. The message asks the user to reply once the command has run, and the turn ends with no interactive prompt open. The agent then checks the result on the user's next message. It reads back the state the command was meant to change, or the output it left in the session. An answer saying the command ran is not that check. -- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". +- **Ask when the user can cheaply confirm.** An assumption that saves one question and is wrong costs the rework plus the trust. So a genuine ambiguity in intent, scope, or authorization is raised, not resolved by picking the likelier reading. Rules that already answer the question (the committed instruction set) are not ambiguity, so read them first rather than asking what they state. +- **The irreversible step (merging, publishing, releasing, force-pushing, deleting, changing branch protection) stays the maintainer's.** **A grant given in a past session or for a different task authorizes nothing now.** Whether a credential's reach or a tool that happens to work authorizes anything is answered by `GOVERNANCE.md` "Repository Boundaries and Write Safety" rather than here. +- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. **Each question reads whole from its own text.** It states the problem, why it is being asked, and what each option does, in plain words. It may cite an issue or a pull request by number. The question and its options still read fully without opening it. A question leaning on an issue for its meaning is often answered without reading that issue, so the answer misses its point. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". - **Raise work blocked on the user as a direct interactive prompt.** When progress needs a decision, an authorization, or an answer only the user can give, ask for it at the point the work stops. Ask through the interface's own prompt mechanism. Never leave it as prose in a summary. A handoff buried in a paragraph is a handoff that did not happen. That is because a summary reads as a report of finished work. It is also because the one line still waiting on the user is the easiest in a summary to skim past. The blocked item is the message, not a closing remark on a message about something else. **The options offered are the actions themselves.** The one that unblocks the work names the action it authorizes ("squash and merge it"). Selecting it is then the go-ahead rather than a note to act on later. Offering only ways to wait is the same failure in interactive clothing. That is because a prompt whose every choice is inaction reports the block rather than clearing it. Where the agent may not perform the authorized action itself, the option says who does it. Where no interactive prompt is available, the numbered list the bullet above names is the fallback. In a turn asking for a command the user runs at this session's input line, the command bullet above replaces the interactive prompt. - **Lead every choice with a recommendation and its reason.** Wherever the user is asked to choose, in a prompt or in a numbered list, the option the agent recommends comes first. It is marked as the recommendation, and every option states the reason for it. A user who takes the recommendation then reads one line, and one who does not sees what the other options trade away. A question with no defensible recommendation says so rather than inventing one. Where an open question has no options and the agent does have an answer, that answer and its reason go in the question's text. They never go in as an invented option. - **A question filed as an issue is parked rather than asked, and it stays owed.** Where the work cannot continue without the answer, the interactive-prompt bullet governs and the question is asked at the point the work stops. Wherever the question is recorded rather than asked, recording it is the right thing to do, and recording it is still not asking it. That holds whether the work can continue without the answer or the question was asked once and deferred. So the issue carries the fleet's `decision` label. When the filing session knows the choices the question is between, the issue states them. The label and the stated choices are what let a later session, one that was not there when the issue was filed, find the question. That session can then put the question to the user without inventing its answers. **The parked queue is the failure, not the parking.** An issue holding a question the user has never seen reads to every later session as tracked work rather than as a block. So each session files correctly and moves on. Presenting the accumulation is the step nobody owns. @@ -239,7 +241,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i - **`frontier`** is the fleet's default reasoning tier, for orchestrating, rule text, design, spec logic, and adversarial review. It is not the most capable model available, which is `highest`. - **`standard`** is ordinary implementation and driving a pull request. Judging a review finding is never mechanical, however often it repeats, so it runs at `standard` or above. A `standard` driver's evidence-backed decline of a finding raised on its pull request stands, since that pull request's reviewers and its merge gate check it. - **`bulk`** is the cheapest model that does the work correctly. It is for high fan-out mechanical work, such as an extraction or a status check. -- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set, and otherwise at the session's own. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. A session never reaches for it because a task looks hard. +- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set. Otherwise it runs at the default the host's agent-safety kit sets, which is the `frontier` model. On a host without the kit it runs at the session's own. That default does not reach every agent type a tool builds in. On Claude Code the `Explore` and `Plan` types still take the session's model, so the kit refuses a dispatch of either that names no model. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. The kit's default is a backstop for a dispatch that forgot its tier, never a reason to leave one out. A session never reaches for it because a task looks hard. | Tool | `highest` | `frontier` | `standard` | `bulk` | | --- | --- | --- | --- | --- | @@ -248,7 +250,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i Each cell is the name that tool's subagent dispatch takes, which follows the latest model of its family. A dispatch on a tool with no row here, or on one that cannot name a model per subagent, names no model. - **A tier resolves only through this table.** A word such as "frontier", "strongest", or "most capable" never resolves to `highest`. The industry's "frontier model" is the opposite of what this tier means here. A session that cannot see this table names no model rather than guessing one. -- **An orchestrating seat runs at `frontier` and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. +- **An orchestrating seat runs at `frontier`, or at `highest` where the maintainer chose that for the session, and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. diff --git a/.github/skills/dotnet-codestyle/SKILL.md b/.github/skills/dotnet-codestyle/SKILL.md index 83ad9011..109d7525 100644 --- a/.github/skills/dotnet-codestyle/SKILL.md +++ b/.github/skills/dotnet-codestyle/SKILL.md @@ -43,8 +43,11 @@ All builds must complete without warnings, enforced as follows: - **Analyzer configuration.** `true` with `latest-all` and `All` (the full analyzer set), plus `true`. With that, any diagnostic - surfaced as a warning fails the build. Such a diagnostic must be fixed or deliberately suppressed at the - narrowest scope that fits (see Analyzer suppressions below), never left to accumulate. + the build surfaces as a warning fails it. `EnforceCodeStyleInBuild` is left unset, so the IDE code-style + rules do not run in the build, and the `dotnet format style` step fails on their warnings instead. Such a diagnostic must be fixed or deliberately suppressed at the + narrowest scope that fits (see Analyzer suppressions below), never left to accumulate. IDE0079 is + the exception, since neither that step nor the build reports it. Remove a suppression the IDE + flags under IDE0079 only once the format step and every configuration and target framework CI builds pass without it. - **CI lint backstop.** CI runs the clean-compile checks on every PR as the authoritative gate. Husky.Net is wired from the canonical `catalog/snippets/husky/` config in the hub, hub-local and not carried into every fleet repo. Its hook needs a .NET tool manifest declaring @@ -60,9 +63,7 @@ All builds must complete without warnings, enforced as follows: per-clone enablement steps. **A new port is not a license to silence diagnostics.** Brownfield or just-ported status never -justifies relaxing analyzer severities or muting newly surfaced warnings. Fix them. (The only -brownfield allowance in the fleet is the one-time git-signing / line-ending migration described in -GOVERNANCE.md and README.md. That migration has nothing to do with code analysis.) +justifies relaxing analyzer severities or muting newly surfaced warnings. Fix them. ### Central build and package configuration @@ -105,16 +106,28 @@ Shared MSBuild configuration is centralized at the repository root, never duplic The major tracks the repo's .NET TFM (`net10.0`), never a `netstandard` target an analyzer or source-generator project carries beside it. It moves only with that TFM (`11.0.100` alongside - `net11.0`), and such a project's fixed `LangVersion` moves with them. The hub's workflows and composite actions install the SDK line through - `setup-dotnet`'s `dotnet-version`, and the hub's devcontainer snippet through its image tag. A - repo calling them therefore cannot move to a new major alone, since CI would then find no - compatible SDK. Such a move starts in the hub, as a fleet-wide change. The hub's steps and image - provide both lines until every repo has moved. A repo still on - `10.0.100` would otherwise find no compatible SDK once the hub installs only the new line. - - A developer host now needs a release SDK on the line, 10.0.x today. A host holding only a newer - major, or only a 10.0 preview, fails with a clear "A compatible .NET SDK was not found" error - rather than silently drifting. Install the line's SDK beside the newer one. + `net11.0`), and such a project's fixed `LangVersion` moves with them. The line is the + repository's own choice, per `CODESTYLE.md` "Toolchain Versions", so a repository may lead or + lag the hub's baseline. Its move edits `global.json`, the TFM, its devcontainer image tag, and + any analyzer project's fixed `LangVersion` together, in that repository alone. A resync carries + the baseline's `rollForward` and `allowPrerelease` and never changes the repository's + `sdk.version`. The hub's workflows install the line the calling repo's own `global.json` + selects, through `setup-dotnet`'s `global-json-file`, so CI follows each repo's file. A repo + carrying no `sdk` block yet gets `10.x`, the baseline's major, which the hub's tests hold to the + baseline. The hub's host installers install the line the `catalog/snippets/configs/global.json` + baseline selects, named in each installer and held equal to the baseline by the hub's tests. + The Linux one adds the newest line the feed carries, and every other line under `--optional`. + The Windows one adds the two majors below it under `-Optional`. A fleet-wide move is a hub change to that + baseline, the installers, that fallback, and the devcontainer snippet's image tag. A repository + not yet moved keeps building on its own line. + + A developer host now needs a release SDK on the repository's line, 10.0.x for the fleet default + today. A host holding only another major, or only a 10.0 preview, fails with a clear error. It + reads "A compatible .NET SDK was not found" rather than silently drifting. The hub's host + installers install the fleet default line's SDK by default. A host building a repository on + another line adds that line's SDK. The Linux `--optional` set, the Windows `-Optional` set for + an older major, or a direct install provides it. On Linux, a package feed carrying no package for the default line is named in a + warning and in the report. **`LangVersion` is left unset** in every `.props` or `.targets` file the repo holds and every project targeting a .NET TFM. The SDK's own targets derive it, which is the point. The C# version then follows the TFM (`net10.0` gives C# 14 under any SDK). Never set it @@ -172,7 +185,8 @@ updates, dependency upgrades, benchmarks) on top: Key rules: no `var` (always explicit types), file-scoped namespaces, Allman braces, Nullable enabled, modern C# features (primary constructors, pattern matching, collection expressions). Every public surface has XML documentation. Private fields use `_camelCase`, static fields `s_camelCase`, -constants PascalCase. Member ordering follows StyleCop SA1201. +constants PascalCase. Member ordering follows StyleCop SA1201 by kind first, then SA1202 by access +within one kind. For language features, naming, code structure, and XML documentation examples, see `references/conventions.md`. @@ -203,6 +217,11 @@ The .NET mechanics, narrowest first: `dotnet_analyzer_diagnostic.severity`) to push a brownfield port through the build is exactly what this forbids. +A code-style option in the root `.editorconfig` takes a `dotnet_diagnostic..severity = warning` +entry for each rule it configures. An option alone leaves its rule at the default severity, often +hidden, which the format gate never reports. A formatting option is the exception, since CSharpier +owns formatting and IDE0055 stays `none`. + ## Error handling and logging 1. **Structured logging**: use structured message templates. Serilog is the application's concrete @@ -245,12 +264,21 @@ The .NET mechanics, narrowest first: ## Code patterns -1. **Guard clauses**: prefer early returns for validation and error handling. +1. **Guard clauses**: prefer early returns for validation and error handling. A guard that CA1510 + to CA1513 match calls the throw helper its rule names, such as `ArgumentNullException.ThrowIfNull`. + That holds even where IDE0046 offers a conditional `return` for it. A `netstandard` project + lacks those helpers, so a guard there that IDE0016, IDE0046, or IDE0270 matches takes the throw + expression instead. A local assigned and then + null-checked takes `?? throw` on the assignment, per IDE0270. IDE0046 makes any other such + shape a single conditional `return`, a throw expression included. That shape is an `if` and + the `return`, `throw`, or `else` right after it, each branch only returning a value or throwing. Both + branches throwing is not that shape. Write that shape as the conditional `return` from the start. 2. **Async all the way**: avoid blocking calls (`.Result`, `.Wait()`), use `async`/`await`. 3. **Cancellation tokens**: accept `CancellationToken` as the last parameter and pass it through. 4. **ConfigureAwait**: in library code, use `ConfigureAwait(false)` unless context is required. Do not call `ConfigureAwait(false)` in xUnit tests (see xUnit1030). -5. **Disposables**: use `await using` for async disposables, prefer `using` declarations. +5. **Disposables**: use `await using` for async disposables. A `using` declaration is required + wherever IDE0063 matches. 6. **LINQ vs loops**: use LINQ for clarity, loops for hot paths or allocations. 7. **HTTP**: reuse `HttpClient` via factory, never per-request instantiation. 8. **Collections**: prefer `IReadOnlyList`/`IReadOnlyCollection` for public APIs. @@ -269,7 +297,7 @@ parameterized tests. A test project on `xunit.v3` 4.0.0 or later is MTP-based, a ## Project configuration -.NET 10.0 target, AOT-compatible (`IsAotCompatible=true`, with `VerifyReferenceAotCompatibility=true` only under the `PublishAot` condition), +Target the repository's own .NET line, .NET 10.0 for the fleet default. AOT-compatible (`IsAotCompatible=true`, with `VerifyReferenceAotCompatibility=true` only under the `PublishAot` condition), SourceLink, embedded untracked sources, `InternalsVisibleTo` for test/benchmark access. See `references/project-config.md` for the full property list. diff --git a/.github/skills/dotnet-codestyle/references/conventions.md b/.github/skills/dotnet-codestyle/references/conventions.md index b0caf08e..7a3dd5c3 100644 --- a/.github/skills/dotnet-codestyle/references/conventions.md +++ b/.github/skills/dotnet-codestyle/references/conventions.md @@ -13,13 +13,21 @@ project. 2. **Nullable reference types**: enabled (`enable`), use nullable annotations appropriately, use `required` for mandatory properties. -3. **Modern C# features**: prefer modern language constructs. Prefer primary constructors when - appropriate, top-level statements for console apps, pattern matching over traditional checks. - Prefer collection expressions when types loosely match. Prefer extension methods (the classic - `this`-parameter form or an `extension() { ... }` block on C# 14+). Prefer implicit - object creation when the type is apparent. Prefer range and index operators. -4. **Expression-bodied members**: use for applicable methods, properties, accessors, operators, - lambdas, local functions. +3. **Modern C# features**: prefer modern language constructs. Each construct below is required + wherever its IDE rule matches, since the gate reports each rule at warning: + - a primary constructor (IDE0290), + - top-level statements in place of a `Program.Main` (IDE0210), + - pattern matching over traditional checks (IDE0019, IDE0020, IDE0038, IDE0078, IDE0083, + IDE0260), + - a collection expression when types loosely match (IDE0028, IDE0300 to IDE0306), + - implicit object creation when the type is apparent (IDE0090), + - range and index operators (IDE0056, IDE0057). + + Prefer extension methods (the classic `this`-parameter form or an `extension() { ... }` + block on C# 14+). +4. **Expression-bodied members**: each is required wherever its IDE rule matches (IDE0021 to + IDE0027, IDE0053, IDE0061). That covers constructors, methods, operators, properties, + indexers, accessors, lambdas, and local functions. 5. **`var` keyword**: do NOT use `var`, always use explicit types: ```csharp @@ -91,15 +99,18 @@ project. 5. **Line endings**: not specified here, governed per repo by `.editorconfig` / `.gitattributes` per GOVERNANCE.md's "Line Endings" section. 6. **`#region`**: do not use regions, prefer logical file/folder/namespace organization. -7. **Member ordering (StyleCop SA1201)**: const -> static readonly -> static fields -> instance - readonly fields -> instance fields -> constructors -> public. Public members are ordered events -> properties -> indexers - -> methods -> operators. Non-public follows in same order, then nested types. +7. **Member ordering (StyleCop SA1201, SA1202)**: order by kind first, across every access level + (SA1201). The kinds run fields, constructors, finalizers, delegates, events, enums, interfaces, + extension blocks, properties, indexers, conversion operators, operators, methods, nested + structs, and nested classes. Within one kind, order by access: public -> internal -> protected + internal -> protected -> private protected -> private (SA1202). Within one kind and access, + const precedes static, which precedes instance, and readonly precedes mutable (SA1203, SA1204, + SA1214). ## Comments and documentation -XML documentation is on: `true`, and -missing XML comments for public APIs are suppressed in `.editorconfig`. Every public surface must -still be documented: a single-line summary, additional details in remarks, documented input +XML documentation is on: `true`. Every +public surface must be documented: a single-line summary, additional details in remarks, documented input parameters, return values, exceptions, and crefs. ```csharp diff --git a/.github/skills/dotnet-codestyle/references/project-config.md b/.github/skills/dotnet-codestyle/references/project-config.md index 0171c991..177c93af 100644 --- a/.github/skills/dotnet-codestyle/references/project-config.md +++ b/.github/skills/dotnet-codestyle/references/project-config.md @@ -1,12 +1,14 @@ # .NET Project Configuration -1. **Target framework and SDK line**: .NET 10.0 (`net10.0`). +1. **Target framework and SDK line**: the repository's own line, .NET 10.0 for the fleet default (`net10.0`). The root `global.json` `sdk` block selects the same line (`"version": "10.0.100"`, `"rollForward": "latestFeature"`, `"allowPrerelease": false`). See `SKILL.md`'s "Central build and package configuration". `LangVersion` stays unset, so the C# version follows the TFM. A `netstandard` analyzer or source-generator project is the exception, and that section says what - it sets. The TFM, the `sdk` major, and that project's fixed `LangVersion` move together. They move only once the hub's - `setup-dotnet` steps and devcontainer image provide the new line beside the old one. + it sets. The TFM, the `sdk` major, the devcontainer image tag, and that project's fixed + `LangVersion` move together. The line is the repository's own, so it may lead or lag the hub's + `global.json` baseline, and a resync never changes the repository's `sdk.version`. The hub's + `setup-dotnet` steps install whatever line the repo's own `global.json` selects. 2. **AOT compatibility**: `true` unconditionally, and `true` only in a ``. That group is placed in the `.csproj` after diff --git a/.github/skills/dotnet-codestyle/references/testing.md b/.github/skills/dotnet-codestyle/references/testing.md index 265e0962..be92e6e9 100644 --- a/.github/skills/dotnet-codestyle/references/testing.md +++ b/.github/skills/dotnet-codestyle/references/testing.md @@ -16,10 +16,12 @@ int actual = GetValue(); // Assert - actual.Should().Be(expected); + _ = actual.Should().Be(expected); } ``` + The `_ =` discard is what IDE0058 requires of an assertion whose result goes unused. + 2. **Organization**: Arrange-Act-Assert pattern. 3. **Naming**: descriptive names with underscores. 4. **Theory tests**: use `[Theory]` with `[InlineData]`. diff --git a/.github/skills/drive-pr/SKILL.md b/.github/skills/drive-pr/SKILL.md index c68a088b..aecfbc3b 100644 --- a/.github/skills/drive-pr/SKILL.md +++ b/.github/skills/drive-pr/SKILL.md @@ -61,10 +61,13 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR - Naming this skill, and answering its how-far question, is the maintainer's explicit, current go-ahead. It covers every feature -> develop squash merge the drive performs to reach that target. + It also covers opening each pull request the drive needs. And it covers the whole post-merge + `cleanup` after each feature -> develop merge, a peer's merge included. - A dispatched drive answers no such question. So what stands in its place is the go-ahead the - dispatching seat holds, per "How Far to Drive" above. The drive performs the same merges on it. + dispatching seat holds, per "How Far to Drive" above. The drive performs the same writes on it. Reading this bullet list is not how such a drive establishes that. That is because a worker - cannot verify a grant made in a seat it has no access to. + cannot verify a grant made in a seat it has no access to. Its brief can also withhold one of + those writes. A `backlog-burndown` worker's brief withholds the post-merge `cleanup`, for one. - It is never authorization to merge the develop -> main promotion PR, or to dispatch a release. Those stay in merge-and-release, invoked on its own so the maintainer keeps a checkpoint before the harder-to-reverse step. @@ -75,7 +78,12 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR ## The Drive Loop 1. Isolate into a worktree per repo-worktree before the first edit. Base it on the branch that skill's base rule names, develop unless the task is explicitly about main-only content. -2. Commit the work, then run `local-strict-review` and record its pass in the order that skill +2. Before any commit that first writes a code or config comment line, check + `gh label list --search comments`. Where the label is missing, `comment-and-doc-style` says the + escape is not yet available there. So delete the comment line before committing. Where a rule + requires the comment, report the missing label to whoever dispatched the drive, or to the + maintainer, and do not push. + Commit the work, then run `local-strict-review` and record its pass in the order that skill gives, its diff receipt following the commit. Where the change also carries the canonical ledger, that skill's carried-content records instead precede the commit, because that ledger is tracked. A driver that cannot dispatch a subagent follows that skill's "Running It". @@ -88,10 +96,17 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR finding still open into the pull request's body with its class, per `local-strict-review` "Disposing of Findings". A later push adds its own to any list already there. Step 3 gives each one an outcome under the Merge Gate's item 3. Where the - change writes a code or config comment line, add the `comments` label after creating the PR, or - the prose gate refuses it. Where a public repository's lint log says "Read the pull - request's labels live", a rerun of the failed job picks the label up. Otherwise it applies to - the next push. + change writes a code or config comment line, create the PR with `gh pr create --label comments`, + or the prose gate refuses it. A repository lacking the label can refuse that create, which is + why the check above comes first. A label added after the create is missing from the + opened event's payload. Where the lint log lacks "Read the pull request's labels live", that + payload decides. A private repository's log always lacks it until the lint job holds + `pull-requests: read`. A label given at the create is still missed there now and then, so read + the first lint run. Where a later push first writes a comment line, add the label with + `gh pr edit` before that push, so the push's event carries it. Where the log reads the labels + live, a rerun of the failed job picks up a label added late. Otherwise a rerun replays the + payload. So the label then reaches the gate only through a fresh event, such as the next push + or a close and reopen. A push refused by a `.husky/pre-push` hook is that gate working rather than an obstacle to route around. The hub carries such a hook, and a repository has one only if it adds one. That skill's refusal table says what each refusal means and what clears it. @@ -103,16 +118,20 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR one per "Disposing of Every Finding" and wait again. Read `state=` in every digest `wait` or `status` prints. A peer can merge or close the pull request mid-drive. A digest carrying `state=MERGED` on a feature PR into develop means the merge has landed. Skip the merge in step 4 and go on to its post-merge path. + A finding still open there keeps its outcome owed. That covers an unresolved thread and every finding step 4 names, whether or not `merge` would refuse on it. + Give each one per "Disposing of Every Finding" before that path's cleanup, a fix landing as a fresh feature -> develop pass. On a promotion PR it means the drive's end state is passed, so stop and report it merged. A digest carrying `state=CLOSED` is a stop to report, with its `closed_at=`. On such a PR `state=` decides the next step over any exit code `wait` or `status` returns. A promotion re-reviews content its feature PRs already carried. So under the hub's default review policy, the hosted review runs once per change, at the promotion in step 6. `wait` sends each request the repository's review policy asks for, so the drive never asks whether a reviewer starts on its own. -4. Merge the feature PR into - develop with `uv run --no-project --script scripts/pr_review.py merge --repo / --cleanup --checkout `, - run from a hub checkout outside the task's worktree, `` being the repository's - primary clone. It reads the Merge Gate's mechanically readable items in code, through `wait`'s +4. Run this step's merge and post-merge `cleanup` only on the go-ahead "What Invoking This Skill + Authorizes" states. Merge the feature PR into + develop with `uv run --no-project --script scripts/pr_review.py merge "" --repo "/" --cleanup --checkout ~/repos/""`, + run from a hub checkout outside the task's worktree, `~/repos/` being the repository's + primary clone. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. Spell every `scripts/pr_review.py` call this skill prints as `pr-review-conduct` + "Expected review loop" says. `merge` reads the Merge Gate's mechanically readable items in code, through `wait`'s own decision and a fresh read after it. It merges nothing while one reads unmet. The items no code reads stay this seat's per pr-review-conduct's Merge Gate. A finding the pull request's body lists is one. A no-thread finding on an earlier round is one too, since `FINDINGS WITH NO @@ -130,18 +149,25 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR line's route here. The hub's `scripts/README.md` "`pr_merge.py`" gives each route in full. - `next=done` is merged and cleaned up. - - `next=cleanup` is a merge that landed with its cleanup still owed. Run the `cleanup` command - below. Report a pull request another hand merged as a merge this run cannot vouch for. The - head that merged may be one the gate never read. - - `next=readback` is a merge that may have landed. Read it back with `gh pr view --repo - / --json state`. `MERGED` means run `cleanup`, and `OPEN` means treat it as + - `next=cleanup` is a merge that landed with its cleanup still owed. Give its open findings the + outcome step 3 owes after a peer merge, then run the `cleanup` command below. Report a pull + request another hand merged as a merge this run cannot vouch for. The head that merged may be + one the gate never read. + - `next=readback` is a merge that may have landed. Read it back with `gh pr view "" --repo + "/" --json state`. `MERGED` means run `cleanup`, and `OPEN` means treat it as `redrive`. Only a read that still cannot answer is reported, saying the merge may have landed. - `next=redrive` is a refusal that merged nothing and that this seat can clear. Do what its `status=` lines name, per step 3 and pr-review-conduct, giving each finding they count an outcome per "Disposing of Every Finding". A check still running clears by waiting for it, - with `timeout 1800 gh pr checks --repo / --watch`. A hosted + with `timeout 1800 gh pr checks "" --repo "/" --watch`. A hosted reviewer's review still running on the head is such a check, refused as `CHECKS_PENDING`. - Then run `merge` once more. + An open registration grace is refused as `CHECKS_PENDING` too, on a line naming when it + ends. The watch above can return before then, so it does not clear the grace alone. On a + held head, `wait` holds until the grace ends. On any other head, run the watch above + first, since a check settling restarts the grace. Then wait in a background process until + the later of the named end and 90 seconds after the watch returned. Then run `merge` once + more. A rerun that still refuses on a grace is the blocked merge reported below, naming the + end it gives. - `next=retry` is a read that did not answer, or a merge `gh` refused on an unchanged head. Run `merge` once more as it is. - `next=maintainer` is a line no action of this seat can change, or a merge whose `cleanup` @@ -154,27 +180,28 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR around, and it hands the maintainer no command to run instead. A harness refusing the `merge` call itself is a refused write rather than a gate refusal. That happens on a machine with no allow rule for it, or under - another provider. Raise it as a blocked decision per `GOVERNANCE.md` "Repository Boundaries and - Write Safety". Name the maintainer's routes, adding the permission rule or running the command - themselves. Once the merge is + another provider. It also happens on Claude Code for a call the rule does not match, per + `pr-review-conduct` "Expected review loop". Raise it as a blocked decision per `GOVERNANCE.md` + "Repository Boundaries and Write Safety". Name the maintainer's routes. One is adding the + permission rule where it is missing. Another is the change that paragraph names, a hub checkout + inside the session's working directories or a writable uv cache. The last is running the + command themselves. Once the merge is confirmed, `--cleanup` runs repo-worktree's post-merge cleanup, - `uv run --no-project --script scripts/pr_review.py cleanup --repo / --checkout `, - and its exit is the command's. It deletes the remote branch, then removes the task's worktree and local branch. + `uv run --no-project --script scripts/pr_review.py cleanup "" --repo "/" --checkout ~/repos/""`, + and its exit is the command's. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. It deletes the remote branch, then removes the task's worktree and local branch. It decides its local refusals before the remote delete. `repo-worktree` "Listing and Cleanup" says what a refusal after the remote delete and a `base=kept` line each leave to do. It takes the pull request rather than a branch name and does the verify-then-delete in - code. It refuses unless the pull request merged into `develop` from a head in that same - repository. It also refuses a permanent branch or one any ruleset or branch protection covers. It + code. It refuses unless the pull request merged into `develop`, or is a conflicted promotion + merged into `main`, from a head in that same repository. It also refuses a permanent branch or one any ruleset or branch protection covers. It checks the tip is still at the pull request's `headRefOid` before deleting, and reads the ref back to confirm. These exits are `cleanup`'s, read once a `status=MERGED` line printed or a standalone `cleanup` ran. Exit `0` is done, the branch deleted or already gone. Any other exit stops and reports rather than deleting by hand. `1` is a refusal, a moved tip among them. `2` is a read that did not answer or a delete it could not confirm. `64` is a target under an owner other than the hub - checkout's own `origin`, or that `origin` unreadable. A registry refusal is a `1`. It runs - under the host-safety installer's `Bash(uv run --no-project --script scripts/pr_review.py:*)` allow rule, - which is what lets auto mode complete it. - It also refuses while another open pull request in the repository has the branch as its head or base. + checkout's own `origin`, or that `origin` unreadable. A registry refusal is a `1`. + `cleanup` also refuses while another open pull request in the repository has the branch as its head or base. It names each, since the delete would close or retarget it. Where this seat cannot run `cleanup`, report the delete to the maintainer instead of deleting by hand. Name the pull request number and `--repo` so the maintainer runs the same command. @@ -184,16 +211,29 @@ this skill exists to prevent. So is forgetting to loop back to the promotion PR repo's auto-delete-head-branches setting is kept off fleet-wide (to protect `develop` and `main` from it, GitHub has no per-branch exception). So nothing deletes an ordinary feature branch automatically. Stop here and report the merged PR when the target is develop only. -5. Open the develop -> main promotion PR if it does not exist yet, or find the existing one. +5. Open the develop -> main promotion PR if it does not exist yet, or find the existing one. Its + body carries the closing keywords, checked as `branching-and-release-model`'s closing-keyword + bullets state. A promotion reading `DIRTY`, or failed by the `Check promotion history step`, + lands from a conflicted-promotion cut instead. That skill's + `references/branch-protection-and-promotion.md` states the cut, its label and closing-set carry, + and its tree-equality check. 6. Drive its review loop the same way. A finding that needs a code change never gets pushed to the promotion PR directly, since its head is develop. So land the fix as a fresh pass through steps 1 to 4 in its own worktree and branch. Then return here. -7. The fix landing on develop updates the promotion PR's diff and head SHA on its own. Re-request + The promotion's head can read `coverage=none` where a Copilot round covers it and none + covering it carries a file table. Then run the local strict review at the `frontier` tier from + a clean checkout of that head, `main...develop`. Its target is `main` in every command that + skill runs, the `status` and `record` calls included. Then run `pr_review.py attest` from that + checkout on the promotion pull request. Merge Gate item 2 in + pr-review-conduct then reads `coverage=local`, on the further terms that item states. Each new + head owes its own pass and attestation. +7. The fix landing on develop updates the promotion PR's diff and head SHA on its own. A cut's + head does not move with develop, so merge each fix into the cut as that reference states. Re-request a review on the new head and continue the loop. 8. Repeat 6 and 7 until the promotion PR meets every pr-review-conduct Merge Gate item except the maintainer's explicit permission to merge. 9. Report the promotion PR number, its ready state, and its full head SHA, read as `gh pr view - --repo / --json headRefOid --jq .headRefOid`, the one `merge-and-release` + "" --repo "/" --json headRefOid --jq .headRefOid`, the one `merge-and-release` compares against before merging. Do not merge it. ## Disposing of Every Finding @@ -207,7 +247,10 @@ maintainer when". A finding that committed text holds observed data takes outcome 4's observed-data bullet, whatever its class, ahead of every other outcome. That applies once the data is confirmed as -observed. A value the repository constructed is disproved under outcome 2 instead. +observed. A value the repository constructed is disproved under outcome 2 instead. So is a +value outside the rule's scope, such as a date, an amount, a balance, or a private-range IP +address. `GOVERNANCE.md` "Representative Data in Agent-Authored Text" bounds only what its first +bullet calls identifying data. 1. **Real, so fix it, and fix the class rather than the instance.** A reviewer samples rather than enumerates, so sweep for the finding's siblings before replying. Fix each one sitting @@ -264,7 +307,11 @@ observed. A value the repository constructed is disproved under outcome 2 instea that one too. The pull request holding the record takes the `history-data` label, and so does the one whose review raised it. Where the repository lacks that label, the maintainer is told. A thread raising a recorded finding is answered with a pointer to its body line and - resolved. + resolved. Every observed secret also goes to the maintainer for revocation, whatever else its + case requires, naming only the repository and the kind of data. A seat that cannot reach the + maintainer hands that notice to whoever dispatched it. The notice is not an escalation, so it + stops nothing, and its case's own route continues. A seat with no dispatcher lists it in its + final report, never in a handoff issue. - A local pass before the push that opens the pull request can raise a `pre-existing` correctness defect in a file the diff already touches. That defect is fixed here under outcome 1. That covers wrong behavior and a false or unfollowable instruction, and not a @@ -339,8 +386,9 @@ instance's outcome is context for the new one, never a standing answer to reuse ## Mechanics Live Elsewhere - Review loop mechanics, the Merge Gate, and `scripts/pr_review.py`: pr-review-conduct. -- Branch rules, never delete develop, the EOL-only conflict, issue-closing keywords belonging on - the promotion PR: branching-and-release-model. +- Branch rules, never delete develop, the EOL-only conflict, the conflicted-promotion cut, the + squash recovery, issue-closing keywords belonging on the promotion PR: + branching-and-release-model. - Worktree isolation and post-merge cleanup: repo-worktree. ## Stop and Ask, Beyond the How-Far Question diff --git a/.github/skills/fleet-code-review/SKILL.md b/.github/skills/fleet-code-review/SKILL.md index e8523b66..167a727f 100644 --- a/.github/skills/fleet-code-review/SKILL.md +++ b/.github/skills/fleet-code-review/SKILL.md @@ -62,6 +62,7 @@ A change is cheapest to shape before it is written. Hardening nothing calls for, - **Reuse before building.** Search this repository and the hub for a primitive that already does the job. Start from the list of consolidated primitives this repository's `OPERATIONS.md` keeps under `Configuration Layout` once it has consolidated any. Extend one that exists rather than adding a sibling that does almost the same thing. A near-duplicate splits every later fix between two copies. - **A defect class seen a second time gets one primitive, and every site in a file the change touches moves onto it.** A check written at each site repeats its own platform and edge-case defects at every site. A read that can block on a named pipe, for one, meets a new platform difference at each site that guards it alone. One reader that opens without blocking and judges the open descriptor closes that class everywhere. Every other site takes the outcome the class-sweep bullet of "Verification Discipline" gives it. - **Complexity is a cost that needs a reason.** Code that answers no requirement and no realistic threat is removed rather than maintained, since each later review and each later change reads it again. +- **A one-off is detected and reported, never corrected by code.** A one-off is a defect that occurs once on a host or a repository, and that correcting it once removes. A tool installed by the wrong method is one, and so is a wrong path the user can fix by hand. The tooling detects it and tells the user how to correct it by hand. It writes no code that performs the correction. Such code runs once and then never again, yet it is reviewed, tested, and maintained for as long as it exists. The detection stays automated, because a check that runs every time is what keeps the one-off from going unnoticed. `GOVERNANCE.md` "Design Before Code" keeps the full rules. The `fleet-code-review` Skill at `.agents/skills/fleet-code-review/SKILL.md` in the hub carries it whole as a generated include and surfaces it wherever a change is reviewed. That path is not a repo-relative link, since it is hub-local and not carried into every fleet repo. diff --git a/.github/skills/git-commit-conventions/SKILL.md b/.github/skills/git-commit-conventions/SKILL.md index 8a705e52..c6802c72 100644 --- a/.github/skills/git-commit-conventions/SKILL.md +++ b/.github/skills/git-commit-conventions/SKILL.md @@ -157,19 +157,16 @@ Each line names a setting, whether the target matches the probe, and the scope a ## Never force push -Do not run `git push --force` or `git push --force-with-lease` under any circumstances. Force +In a fleet repository, do not run `git push --force` or `git push --force-with-lease` under any circumstances. Force pushing rewrites shared history and can cause data loss. This holds regardless of how confident the rewrite looks, a rejected push is recoverable, a force-pushed one is not. +The maintainer's fork of a third-party repository is not a fleet repository. There `upstream-contribution-workflow` names the branches that may take `--force-with-lease`, and each push still waits for his explicit, current go-ahead. + ## History rewrites re-identify only what changed -**Do not rewrite a commit that does not need to change.** A history rewrite (e.g. `git filter-repo` -to strip PII) re-signs every touched commit with the rewriter's key. If that commit is still -committed by a bot (`dependabot[bot]`, `github-actions[bot]`) or GitHub's own web-flow, the signature will not match the committer. The require-signed-commits rule then rejects it. Scope the -rewrite to only the commits that must change. Set `committer` (and `author`) to the rewriter's -identity on any non-own commit that must be modified. Verify with `git log --show-signature` after -any rewrite. See `references/history-rewrite.md` for the full rule. +**Do not rewrite history unless a commit must change, and re-sign every commit the rewrite reaches.** A rewrite cascades, since a commit's hash covers its parents' hashes, so it reaches every descendant of the earliest commit it changes. `git filter-repo` (for example, to strip PII) strips the signature from every commit it processes and signs nothing. So the rewritten history lands unsigned, which the require-signed-commits rule rejects. State each branch's reach before rewriting, and re-sign in a pass that signs each commit. GitHub verifies a signature against the commit's `committer`. So in that pass set `committer` to the rewriter's signing identity on every commit another identity committed, such as a bot's. Keep its `author`, since verification reads only the committer. Verify through GitHub's API (`commit.verification.verified` and `reason`), since `git log --show-signature` cannot see GitHub's committer match. See `references/history-rewrite.md` for the full rule. ## Never run destructive git commands without being asked -`git reset --hard`, `git checkout .`, `git restore .`, `git clean -f`, and other commands that discard work require explicit developer instruction. Never use them as a convenience inside a larger task. One narrow cleanup exception applies to `git branch -D ` after a squash merge. It requires live proof, per `repo-worktree`, that the pull request for that exact branch merged. The same proof must show that the worktree is clean and the branch is at the verified head SHA or behind it. The exception never applies to `develop`, an unmerged branch, an unresolved pull request, or a branch with uncommitted work. A `backlog-burndown` orchestrator has that instruction for the linked worktree of a worker it told to abandon, once that worker has ended. That skill's "Cleanup Is the Orchestrator's" states it. The orchestrator runs `git reset --hard` and then `git clean -fd` in that worktree, and nowhere else. +`git reset --hard`, `git checkout .`, `git restore .`, `git clean -f`, and other commands that discard work require explicit developer instruction. Never use them as a convenience inside a larger task. One narrow cleanup exception applies to `git branch -D ""` after a squash merge. It requires live proof, per `repo-worktree`, that the pull request for that exact branch merged. The same proof must show that the worktree is clean and the branch is at the verified head SHA or behind it. The exception never applies to `develop`, an unmerged branch, an unresolved pull request, or a branch with uncommitted work. A `backlog-burndown` orchestrator has that instruction for the linked worktree of a worker it told to abandon, once that worker has ended. That skill's "Cleanup Is the Orchestrator's" states it. The orchestrator runs `git reset --hard` and then `git clean -fd` in that worktree, and nowhere else. diff --git a/.github/skills/git-commit-conventions/references/history-rewrite.md b/.github/skills/git-commit-conventions/references/history-rewrite.md index 81d26c56..c2dff005 100644 --- a/.github/skills/git-commit-conventions/references/history-rewrite.md +++ b/.github/skills/git-commit-conventions/references/history-rewrite.md @@ -1,20 +1,39 @@ # History Rewrites: Re-identification Rules -**A history rewrite includes only the commits that must change, and re-identifies any commit it -rewrites that is not the agent's own.** Filtering history (`git filter-repo` or an equivalent, for -example to strip PII) re-signs every commit it touches with the rewriter's own key. Meanwhile, the tooling preserves each commit's original `author`/`committer` unless told otherwise. GitHub verifies a signature against the commit's `committer` identity. So a rewriter's signature over a commit still committed by a bot (`dependabot[bot]`, `github-actions[bot]`) or GitHub's own web-flow does not match its committer. That signature lands `unknown_key`/unverified, which a -require-signed-commits rule then rejects. +**Every commit a history rewrite reaches needs a valid signature again. The pass that re-signs it re-identifies the committer of each commit that another identity committed.** The facts below about the tooling drive every rule after them. + +- **A rewrite cascades to every descendant.** A commit's hash covers its parents' hashes. So changing one commit changes the hash of every commit below it, on every branch that holds it. Rewriting a commit near the root rewrites nearly the whole branch, however few commits the edit itself changes. +- **`git filter-repo` strips signatures and signs nothing.** Its documentation says a rewritten commit's signature "cannot continue to work" and is removed. A run strips the signature from every commit it processes, including one whose content it leaves alone. By default it processes every ref. So every commit it emits lands unsigned, which a require-signed-commits rule rejects. +- **GitHub verifies a signature against the commit's `committer`, not its `author`.** The REST API's `verification.reason` values `no_user`, `unverified_email`, and `bad_email` are each defined by the committer email. So a rewriter's valid signature over a commit still committed by a bot (`dependabot[bot]`, `github-actions[bot]`) or GitHub's own web-flow lands unverified. These gates keep committer and signature aligned: -1. **Scope the rewrite to only the commits that must be modified.** By default those are the - rewriter's own, whose committer already matches. So a commit that needs no change stays out of - the rewrite entirely and its identity and signature are never touched. -2. **If a commit that must change is not the rewriter's own, set its `committer` to the rewriter's - own signing identity before re-signing**. For such a commit, set its `author` the same way, since a rewrite that alters - content should not keep attributing it to the bot. The original bot attribution is deliberately - given up as the cost of having to rewrite it. - -Never leave a signature over a commit committed by another identity. Verify after any rewrite that -every rewritten commit is signed and committed under the correct identity -(`git log --show-signature`). +1. **State the reach before rewriting anything.** Rewrite only when a commit must change, since no scoping stops the cascade to every descendant of the earliest commit that changes. A default `git filter-repo` run reaches every commit on every ref. Also list what is anchored to the old hashes, from "Collateral" below. Record which tags are signed, since a rewrite can strip a tag's signature: + + ```sh + git for-each-ref --format='%(if)%(contents:signature)%(then)%(refname:short)%(end)' refs/tags + ``` + +2. **Re-sign every rewritten commit in a signing pass that also sets the committer.** A tool that creates each commit through `git commit-tree -S` signs it. The command below re-signs every commit on every local branch and moves each tag with it, which fits a default `git filter-repo` run. It keeps merge commits, authors, and both dates. Before running it, record each branch's `git rev-list --count ""` and `git log --format=%T ""` output. Replace the placeholders with the rewriter's own signing identity: + + ```sh + git filter-branch --tag-name-filter cat --commit-filter 'GIT_COMMITTER_NAME="" GIT_COMMITTER_EMAIL="" git commit-tree -S "$@"' -- --branches --tags + ``` + +3. **Re-identify the committer, and keep the author.** The command above sets the committer on every commit, the rewriter's own included. Leave `author` as the rewrite left it, an identity correction included, since verification reads only the committer. +4. **Verify against GitHub, not the local checkout.** `git log --show-signature` checks a signature against the local keyring or allowed-signers file. It knows nothing of the account GitHub matches the committer to, so a commit can read good locally and still land unverified. Before the push, confirm the signing pass changed metadata only. Each branch's commit count and its `git log --format=%T` tree hashes match the values recorded before the signing pass. Publishing the rewrite is a force push, so an agent stops here and hands the push to the maintainer. After the maintainer's push, read every commit on each rewritten branch through the REST API and require `verified: true` with `reason: valid` on all of them. A single output line ending `true valid` is a pass, and any other line names a failing reason: + + ```sh + out=$(gh api --paginate "repos///commits?sha=&per_page=100" --jq '.[].commit.verification | "\(.verified) \(.reason)"') && printf '%s\n' "$out" | sort | uniq -c + ``` + +Never leave a signature over a commit committed by another identity, and never leave a rewritten commit unsigned. + +## Collateral + +What is anchored to an old hash goes stale when the rewrite lands, including the following: + +- **Tags** move to the re-signed commits through `--tag-name-filter cat` above. A signed tag's signature no longer verifies after the rewrite, so re-create each tag gate 1 recorded as signed with `git tag -f -s "" '^{commit}'`. +- **Remote tags and pull request refs** keep the old commits readable on GitHub. Each moved tag is pushed again, and GitHub keeps every pull request's commits until GitHub Support purges them. +- **Other clones** diverge from the rewritten branch, so each one is re-cloned rather than pulled. +- **Published artifacts** that record a commit hash keep naming a hash the branch no longer holds, and no rewrite reaches them. diff --git a/.github/skills/local-strict-review/SKILL.md b/.github/skills/local-strict-review/SKILL.md index 786a5f9a..50d7ba34 100644 --- a/.github/skills/local-strict-review/SKILL.md +++ b/.github/skills/local-strict-review/SKILL.md @@ -22,7 +22,7 @@ A coding agent that finishes a unit of work, judges it ready, and opens the pull ## What It Does -Dispatches one subagent against this branch's full diff since it forked from its target branch. The subagent is read-only apart from the one report file it writes, so it needs an agent type that can write a file. Resolve `` once, `develop` unless `repo-worktree`'s base-branch rule put this branch on `main` instead. Then fetch it, `git fetch origin `, and diff against the merge-base, `git diff "$(git merge-base refs/remotes/origin/ HEAD)"`. The target is named by its full remote-tracking ref because git resolves the short `origin/` against local branches first. So a local branch of that name would define the diff the reviewer reads. In that case the engine, which resolves the full ref, would key its receipt on another diff. Stop and report a failed fetch rather than running the merge-base or diff commands anyway. That is because an existing `refs/remotes/origin/` ref can still resolve after a failed fetch. Reviewing against it silently trades the current target for a stale one. Use the same resolved `` in every command below, never a literal `develop` alongside it. Naming the target branch explicitly matters. The branch's own `@{u}` tracking ref points at the branch's own remote once it has been pushed, not at the branch it targets. So anchoring there silently narrows a later run to only the diff since the last push instead of the full accumulated diff. That merge-base diff covers every commit already on the branch plus whatever is currently staged or unstaged. So it never reviews only the latest increment, at any of the moments this skill is invoked from. An empty diff is not the same as nothing to review, and it is never the signal to stop. That is because it reports no untracked file at all. It also reports nothing for content a commit carries that the working tree has since put back. The untracked-file list below covers the first of those. The second is why the diff pass commits before reviewing. That is because a removal or a restore that is committed leaves no net content to miss. The sweep's own passes below run against uncommitted content instead, on the change that carries their ledger. The second is also why the engine reads HEAD rather than this diff. Its change set comes from the merge base against HEAD, the index and the working tree, so the two answer different questions. A fresh review of the full accumulated diff is what catches what per-push review misses, the exact evidence this skill exists to act on. +Dispatches one subagent against this branch's full diff since it forked from its target branch. The subagent is read-only apart from the one report file it writes, so it needs an agent type that can write a file. Resolve `` once, `develop` unless `repo-worktree`'s base-branch rule put this branch on `main` instead. Then fetch it, `git fetch origin ""`, and diff against the merge-base, `git diff "$(git merge-base "refs/remotes/origin/" HEAD)"`. The target is named by its full remote-tracking ref because git resolves the short `origin/` against local branches first. So a local branch of that name would define the diff the reviewer reads. In that case the engine, which resolves the full ref, would key its receipt on another diff. Stop and report a failed fetch rather than running the merge-base or diff commands anyway. That is because an existing `refs/remotes/origin/` ref can still resolve after a failed fetch. Reviewing against it silently trades the current target for a stale one. Use the same resolved `` in every command below, never a literal `develop` alongside it. Naming the target branch explicitly matters. The branch's own `@{u}` tracking ref points at the branch's own remote once it has been pushed, not at the branch it targets. So anchoring there silently narrows a later run to only the diff since the last push instead of the full accumulated diff. That merge-base diff covers every commit already on the branch plus whatever is currently staged or unstaged. So it never reviews only the latest increment, at any of the moments this skill is invoked from. An empty diff is not the same as nothing to review, and it is never the signal to stop. That is because it reports no untracked file at all. It also reports nothing for content a commit carries that the working tree has since put back. The untracked-file list below covers the first of those. The second is why the diff pass commits before reviewing. That is because a removal or a restore that is committed leaves no net content to miss. The sweep's own passes below run against uncommitted content instead, on the change that carries their ledger. The second is also why the engine reads HEAD rather than this diff. Its change set comes from the merge base against HEAD, the index and the working tree, so the two answer different questions. A fresh review of the full accumulated diff is what catches what per-push review misses, the exact evidence this skill exists to act on. `git diff` never reports a path `git add` has not touched, so a newly created file sitting untracked would otherwise go unread. List it explicitly, `git ls-files --others --exclude-standard`, and read each result in full alongside the diff, the same as any other file the diff touches. @@ -80,7 +80,7 @@ Before dispatching, grep the tree for other statements of each rule the diff add **Model tier:** `frontier`, the tier "Model Tiers" below names for adversarial review, which this pass is. Where `frontier` is not reachable, run the pass on the strongest tier below it that is, even the one that authored the change. A second, adversarially-prompted look still catches what the authoring pass's own "looks ready" judgment did not. -Reachable means the tier this session can name when it dispatches the reviewer, rather than the tier this session is itself running on. A worker dispatched by an orchestrator is the ordinary case of a session deliberately tiered down for execution work. Such a session names `frontier` for the reviewer where its harness lets it. That is because tiering down the author is the reason the reviewer must not follow it down. What a given harness and account actually permit varies, so treat this as the tier to ask for rather than one to assume. Where a dispatch exposes no way to name a tier, take what it gives and run the pass, for the reason the fallback above states. A seat that cannot dispatch a subagent hands the pass to whoever dispatched it. The seat commits and runs `python3 /scripts/local_review.py status --target ` in its worktree. It then hands back its worktree path, target, and `contentDigest`. The dispatcher runs that same `status` command in that worktree for its `reportPath`. It stops where the `contentDigest` printed there differs from the one handed back. The dispatcher fills the brief's ``, ``, and `` slots and runs the reviewer. Once the reviewer's completion notification arrives, it runs the record command from "Recording the Pass" in that worktree, with `--reviewer agent-skill --target --expect-digest --report `. It returns the findings. Each fix commit repeats this cycle, and the seat pushes only when a record matches its content. The brief dispatching the seat states whether the dispatcher can continue that seat. Where the dispatcher cannot, the seat stops, reports, and does not push. Where nobody dispatched the seat, it reports to the maintainer that it could not run the pass, and does not push. Either way the push waits rather than the pass being quietly skipped. The headless `run --backend` route under "Recording the Pass" is not the substitute. That is because it runs a vendor CLI against its own review, which never carries the brief above. So it satisfies the rule this section states only where that separate route is what a capture point asked for. +Reachable means the tier this session can name when it dispatches the reviewer, rather than the tier this session is itself running on. A worker dispatched by an orchestrator is the ordinary case of a session deliberately tiered down for execution work. Such a session names `frontier` for the reviewer where its harness lets it. That is because tiering down the author is the reason the reviewer must not follow it down. What a given harness and account actually permit varies, so treat this as the tier to ask for rather than one to assume. Where a dispatch exposes no way to name a tier, take what it gives and run the pass, for the reason the fallback above states. A seat that cannot dispatch a subagent hands the pass to whoever dispatched it. The seat commits and runs `python3 ""/scripts/local_review.py status --target ""` in its worktree. It then hands back its worktree path, target, and `contentDigest`. The dispatcher runs that same `status` command in that worktree for its `reportPath`. It stops where the `contentDigest` printed there differs from the one handed back. The dispatcher fills the brief's ``, ``, and `` slots and runs the reviewer. Once the reviewer's completion notification arrives, it runs the record command from "Recording the Pass" in that worktree, with `--reviewer agent-skill --target "" --expect-digest "" --report ""`. It returns the findings. Each fix commit repeats this cycle, and the seat pushes only when a record matches its content. The brief dispatching the seat states whether the dispatcher can continue that seat. Where the dispatcher cannot, the seat stops, reports, and does not push. Where nobody dispatched the seat, it reports to the maintainer that it could not run the pass, and does not push. Either way the push waits rather than the pass being quietly skipped. The headless `run --backend` route under "Recording the Pass" is not the substitute. That is because it runs a vendor CLI against its own review, which never carries the brief above. So it satisfies the rule this section states only where that separate route is what a capture point asked for. ## Recording the Pass @@ -115,29 +115,38 @@ A second pass under the same rule, run in the repository that authors canonical **The unit is what a reviewer reads whole.** `spec/files.json` rather than the document decides which, down to which files carry units at all. `canonical_review.py list` names the whole set and is the authority on it. So the rules are not paraphrased here, where a paraphrase can only drift from them. In the ordinary case a unit is one level-two section of a carried Markdown canonical. `sweep` names each unit it wants exactly as `record` takes it. The pass reads that unit's whole current text rather than the diff that moved it, because reproducing the carrier's read is the entire point. It also does so because a diff with surrounding context is a different read the pass above has already done. -Run it at the same model tier and in the same delegation shape as the pass above. The brief, the engine, and its flags each differ, and each is below. +Run it at the same model tier and in the same delegation shape as the pass above, one reviewer per unit. The brief, the engine, and its flags each differ, and each is below. The report contract is the same one, so the reviewer again needs an agent type that can write a file. ```text Task: adversarial review of one canonical unit, read as a repository carrying it for the first time reads it, whole, knowing nothing about what this branch changed in it. -Paths: , read in full out of the file that key names. +Worktree: , the checkout holding the sweep's branch and the below. + Start every command with `cd &&`, since a harness can reset the working directory between calls. +Paths: , read in full out of the file that key names, at its path under ``. Read the whole unit, never a diff of it. Rules that bind this task: , and judge the text as a reader who has only this unit: a claim it makes about a tool, a path, a command, or another rule is a defect wherever that claim is false, stale, or unverifiable from the unit itself, and an instruction it gives is a defect wherever following it literally fails. Return: one finding per line, the sentence quoted, and what is wrong with it. No severity theater. -Bounds: read-only. Report a rule that looks incomplete rather than guessing at what it meant. + Write the same finding lines to before returning, under a first line reading + `contentDigest: `. Nothing else goes in the file. A pass with no findings writes that + first line alone. +Bounds: read-only apart from that one report file. Report a rule that looks incomplete rather + than guessing at what it meant. ``` ```sh uv run --no-project --script scripts/canonical_review.py sweep # the units it asks for this round, with their digests # exit 1 where it named any, which is the sweep working rather than the command failing -# run the pass above over each unit it named, then, per unit: -uv run --no-project --script scripts/canonical_review.py record --reviewer agent-skill --target develop --findings '' --unit '=' +# per unit it named: take the unit's , run the pass above, wait for its completion notification, then record it +uv run --no-project --script scripts/canonical_review.py report-path --unit '=' # JSON, the unit's report path +uv run --no-project --script scripts/canonical_review.py record --reviewer agent-skill --target develop --unit '=' ``` +`` is the checkout these commands run in. `` is the one `sweep` printed beside the unit, and `` is what `report-path` names for it. That path sits in the git directory, keyed by the unit and its digest, so `record` finds each unit's report without being told where. `record` reads each report with the same reader the pass above uses. It refuses a unit whose report is absent or names another digest. While any unit it was given is refused, it records none of them. It derives each unit's count from its report's lines and stores the report's sha256. So the record-only-on-completion rule above binds here too, and a driver never writes a report for its reviewer. + These run in the authoring repository itself, the only repository this pass ever runs in. So the engine path is the plain one, and no downstream side needs the `/` form the pass above shows for its own reach. Each resolves the repository from the working directory rather than from where the script sits. So the directory a command runs in is what decides which tree it measures. The unit model and the manifest reader come from the checkout the script itself lives in. Running one checkout's copy against another's tree therefore measures the second tree by the first's rules. So run them in the tree being measured. `record` additionally stamps each pass with the merge-base against `--target`, which is provenance rather than coverage. The line above names it rather than leaning on the default, since a sweep's own branch is based on `develop`. A `main`-based branch passes `--target main` instead. The digest is bound to the read for the same reason `--expect-digest` is above. Recording a unit by name alone would stamp whatever the file holds at record time. So an edit between the review and the record would be attested to by a reviewer who never saw it. Record each unit whatever the pass found, including nothing. Fixing a finding is itself such an edit, so `record` then refuses the digest you were holding. That refusal is the content having moved rather than a fault in the record. The answer is a read of the unit's new text, which is what a carrier will actually receive, recorded at its new digest. @@ -164,7 +173,7 @@ Each bullet is a rule down to its `Why:` line, which is rationale rather than ru ## When to Run It - Before the first push toward a pull request, the push that opens it in `drive-pr` "The Drive Loop" and in `pr-review-conduct` "Expected review loop". -- Before pushing a fix for a reviewer finding, because the same self-review blind spot applies to a fix as to the original diff. Such a fix is the fix outcome of `pr-review-conduct` "Every finding ends in a listed outcome", which `drive-pr` "Disposing of Every Finding" carries. +- Before every push after that one, whatever finding it answers, per `pr-review-conduct` "Expected review loop", which also says when a recorded pass already covers one. A fix for a reviewer finding is the common case. The same self-review blind spot applies to a fix as to the original diff. Such a fix is the fix outcome of `pr-review-conduct` "Every finding ends in a listed outcome", which `drive-pr` "Disposing of Every Finding" carries. - Whenever `agent-conduct`'s "about to claim work is done, verified, green, or fixed" trigger fires for work that will become, or already is, a pull request. - When the canonical sweep's issue is worked, over each unit it names, per "The Carried-Content Sweep" above. Editing such content is not itself one of these moments, and nothing refuses a push over it. @@ -194,7 +203,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i - **`frontier`** is the fleet's default reasoning tier, for orchestrating, rule text, design, spec logic, and adversarial review. It is not the most capable model available, which is `highest`. - **`standard`** is ordinary implementation and driving a pull request. Judging a review finding is never mechanical, however often it repeats, so it runs at `standard` or above. A `standard` driver's evidence-backed decline of a finding raised on its pull request stands, since that pull request's reviewers and its merge gate check it. - **`bulk`** is the cheapest model that does the work correctly. It is for high fan-out mechanical work, such as an extraction or a status check. -- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set, and otherwise at the session's own. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. A session never reaches for it because a task looks hard. +- **`highest`** is the most capable model available, and only the maintainer selects it. The maintainer chooses it for the session itself, or allows it for the session's subagents at launch. The host's agent-safety kit reads that launch setting, `FLEET_ALLOW_HIGHEST=1` on Claude Code. Naming the tier in a prompt does not set it. A maintainer naming it partway through a session restarts the session with it allowed, and an agent never sets it. Without that setting, the kit refuses a dispatch that names it. A dispatch naming no model runs at its agent definition's model where one is set. Otherwise it runs at the default the host's agent-safety kit sets, which is the `frontier` model. On a host without the kit it runs at the session's own. That default does not reach every agent type a tool builds in. On Claude Code the `Explore` and `Plan` types still take the session's model, so the kit refuses a dispatch of either that names no model. A fork always runs at the session's model, whatever it names. So a session launched on `highest` names a tier on every dispatch meant to run below it, and uses no fork for such work. The kit's default is a backstop for a dispatch that forgot its tier, never a reason to leave one out. A session never reaches for it because a task looks hard. | Tool | `highest` | `frontier` | `standard` | `bulk` | | --- | --- | --- | --- | --- | @@ -203,7 +212,7 @@ A rule, a Skill, or a brief names a model tier, never a model. A model release i Each cell is the name that tool's subagent dispatch takes, which follows the latest model of its family. A dispatch on a tool with no row here, or on one that cannot name a model per subagent, names no model. - **A tier resolves only through this table.** A word such as "frontier", "strongest", or "most capable" never resolves to `highest`. The industry's "frontier model" is the opposite of what this tier means here. A session that cannot see this table names no model rather than guessing one. -- **An orchestrating seat runs at `frontier` and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. +- **An orchestrating seat runs at `frontier`, or at `highest` where the maintainer chose that for the session, and names a tier on every dispatch.** It defaults a subagent to `frontier`, and picks `standard` or `bulk` deliberately for execution or mechanical work. diff --git a/.github/skills/merge-and-release/SKILL.md b/.github/skills/merge-and-release/SKILL.md index e330225c..61cd909a 100644 --- a/.github/skills/merge-and-release/SKILL.md +++ b/.github/skills/merge-and-release/SKILL.md @@ -59,19 +59,21 @@ skill covers all of it, scoped down by what the maintainer actually asks for. ## The Procedure 1. Identify the open develop -> main promotion PR for this repo, stop and report if none is open. -2. Record the promotion's live head, `gh pr view [number] --repo owner/repo --json headRefOid +2. Record the promotion's live head, `gh pr view "" --repo owner/repo --json headRefOid --jq .headRefOid`. Then, from a hub checkout, `scripts/` is not carried into downstream repos, - run `uv run --no-project --script scripts/pr_review.py status [number] --repo owner/repo` on it and confirm the - pr-review-conduct Merge Gate. Stop and report exactly what is missing rather than merging on a - partial gate. A digest carrying `state=MERGED` is a promotion merged since step 1 found it + run `uv run --no-project --script scripts/pr_review.py status "" --repo owner/repo` on it and confirm the + pr-review-conduct Merge Gate. Spell every `scripts/pr_review.py` call this skill prints as + `pr-review-conduct` "Expected review loop" says. Where the gate is not met, stop and report exactly what is missing rather than + merging on a partial gate. A digest carrying `state=MERGED` is a promotion merged since step 1 found it open, whose `merge=UNKNOWN` never clears, so stop re-reading it. Confirm its `merge_commit=` per step 4, run the ready-report comparison below against its `head=`, and report both. Dispatch nothing on the chosen scope alone, since whoever merged it may have released it already. Where - a release scope was chosen, look, then ask. Read this repo's `releaseTrigger` as step 5 does, - and where it reads `none` report that no release is configured. Otherwise read the publisher's + a release scope was chosen, look, then ask. Confirm the publisher exists as step 5 does. Read it + at `` below rather than at a tip step 4 confirmed, since `main` may have moved past + the merge. Where it is absent report the missing publisher. Otherwise read the publisher's runs on the merge commit, `gh run list --repo owner/repo --workflow publish-release.yml --commit - --json databaseId,event,headBranch,status,conclusion,createdAt`. `` is - the full 40-character SHA, `gh pr view [number] --repo owner/repo --json mergeCommit --jq + "" --json databaseId,event,headBranch,status,conclusion,createdAt`. `` is + the full 40-character SHA, `gh pr view "" --repo owner/repo --json mergeCommit --jq .mergeCommit.oid`, since the digest's 8-character `merge_commit=` matches no run. Report whether a release started, naming each run with its event, status, and conclusion. A read that fails is reported with its output, never taken as no release started. A run found there, whether @@ -91,34 +93,34 @@ skill covers all of it, scoped down by what the maintainer actually asks for. Confirm the digest's `head=` is a prefix of the recorded SHA, re-running both where it is not. That way the SHA step 3 merges is the one the gate verified. Where drive-pr's ready report named a head and it is not a prefix of the recorded one, stop and re-ask with the commits added, - `gh api repos/owner/repo/compare/... --jq '.commits[] | .sha[:8] + " " + + `gh api "repos/owner/repo/compare/..." --jq '.commits[] | .sha[:8] + " " + (.commit.message | split("\n")[0])'`. The reason is that a feature PR squashed into `develop` after the report moves the promotion's head onto content the maintainer never saw. Under an away-mode standing grant this comparison is skipped, even where the worker holds a ready report. Content another session merged meanwhile rides along, as `backlog-burndown` "Away Mode" accepts. Where no report named a head, a promotion made ready by hand, the go-ahead covers the head this step recorded. -3. `gh pr merge [number] --merge --match-head-commit --repo owner/repo`, where `` is + Whichever case set it, run the closing-set check `branching-and-release-model` states in its + negated-keyword bullet on the head step 3 merges. This step runs from a hub checkout, so read + the range's commit messages from the target rather than with a local `git log`: + `gh api --paginate "repos/owner/repo/compare/main..." --jq '.commits[].commit.message' > ""`. + Run that read on its own and stop the merge on a non-zero exit, since a failed read is not a + range with no closure. Then run that bullet's `grep` over ``. Stop and report any closure + it prints that the promotion body does not state, rather than merging. +3. `gh pr merge "" --merge --match-head-commit "" --repo owner/repo`, where `` is the head the go-ahead covers. Attended, that is the head `drive-pr`'s ready report named, or the moved head the maintainer approved after step 2's re-ask. Under an away-mode grant, or where no report named a head, it is the head step 2 recorded. The server then refuses the merge if the head moved past that SHA. Never `--delete-branch`, the promotion PR's head is `develop`. 4. Confirm the merge landed, `mergedAt` set, `main`'s tip matching the merge commit. -5. When the chosen scope includes a release, first bring the hub checkout used for this procedure - current, `git fetch origin main`. Then read this repo's `releaseTrigger` from that fetched tip - rather than a possibly-stale working tree copy. That matters when the target repo is the hub itself - and this exact promotion changed its own registry entry. Select the one matching entry - explicitly, falling back to the registry's own default when that entry sets no - `releaseTrigger` of its own. Stop and report rather than guessing when selection is not - exactly one match. On a non-1 count exit non-zero rather than returning empty with success. An - ambiguous or missing match must fail loud, not read as an empty value still safe to act on: `git - show origin/main:registry/repos.json | jq -r --arg name '' '(.repos | map(select(.name - == $name))) as $m | if ($m | length) == 1 then ($m[0].releaseTrigger // .defaults.releaseTrigger) - else error("expected exactly one registry entry for \($name), got \($m | length)") end'`. Two - cases, `none` versus anything else. When it - reads `none`, report that no - release is configured, dispatch and run-correlation (step 6) do not apply. Otherwise, dispatch +5. When the chosen scope includes a release, confirm the publisher exists on `main`'s tip from + step 4. Every fleet repository releases, so its `releaseTrigger` selects no case here. Read + `gh api "repos/owner/repo/contents/.github/workflows/publish-release.yml?ref=" --jq + .path`, `` being the full SHA step 4 confirmed. An answer naming the path means the + publisher exists. An HTTP 404 means it is absent. That repository owes a publisher the audit + reports as drift, so report it, and dispatch and run-correlation (step 6) do not apply. Any + other failure is reported with its output, never read as either answer. Where it exists, dispatch explicitly, `gh workflow run publish-release.yml --ref main --repo owner/repo`, or `--ref develop` only when the maintainer explicitly asked for a prerelease dispatch instead. 6. Correlate the specific run this dispatch produced rather than assuming the newest one is it. @@ -138,21 +140,21 @@ skill covers all of it, scoped down by what the maintainer actually asks for. id to completion in one further bounded background wait with an explicit, finite timeout. The timeout is 2700 seconds (45 minutes, matching `scripts/pr_review.py`'s own default) unless the maintainer states a different bound for this specific release. Use `timeout 2700 gh run - watch --repo owner/repo --exit-status` on a host with GNU `timeout`, with the maintainer's bound in place of 2700 where they state + watch "" --repo owner/repo --exit-status` on a host with GNU `timeout`, with the maintainer's bound in place of 2700 where they state one. On a host without it (macOS without coreutils, native Windows), use the equivalent bounded-wait mechanism enforcing the same bound. Never pipe `gh run watch` into another command unless the shell running it sets `pipefail`. That is because without it a pipeline reports its last stage's exit status and `gh run watch ... | tail` reports whether `tail` succeeded rather than whether the run did. Read the watch's own exit status, or read the conclusion back with - `gh run view --repo owner/repo --json status,conclusion`. + `gh run view "" --repo owner/repo --json status,conclusion`. Report a timeout separately from a completed run's own conclusion, the tag or version it produced. A run that fails, times out, or never starts is reported, never silently retried. 7. In the hub, when the chosen scope includes a release, refresh this machine's Codex and opencode copy from the promoted `main`. Do it in a detached worktree of its own, never by switching an existing checkout to `main`. The reason is that the checkout Claude Code loads in place would move with it. Run `git fetch origin main`, then `git worktree add --detach - origin/main` at a new path in the fleet worktree layout. From that worktree run + "" origin/main` at a new path in the fleet worktree layout. From that worktree run `python3 scripts/skills_install.py --snapshot-only`, then `python3 scripts/skills_install.py --report`, and confirm its snapshot reads current. A fresh worktree holds nothing uncommitted or ignored under `.agents/skills/` or `.claude-plugin/`, the paths the installer reads, so @@ -169,7 +171,7 @@ skill covers all of it, scoped down by what the maintainer actually asks for. So where that report reads anything other than CURRENT, first rule out a rollback. The report judges payload digests alone, so a kit newer than `main` also reads stale. Read the commit its `This machine:` line names after `hub`. Install only where that commit carries no `-dirty` - suffix and `git merge-base --is-ancestor origin/main` exits 0, or where the report + suffix and `git merge-base --is-ancestor "" origin/main` exits 0, or where the report reads NOT INSTALLED. Any other result, a kit installed from `develop` or from a dirty tree among them, is reported to the maintainer rather than installed over. Where the install is owed, run `python3 host-setup/agent-safety/claude/install.py` with no arguments from the same @@ -189,7 +191,7 @@ skill covers all of it, scoped down by what the maintainer actually asks for. `--report` again. A SHADOWED Codex is reported to the maintainer and not fixed, since the override is theirs. An EDITED file is rewritten after its backup, and that is reported. A failure is reported with its output, never retried. Then remove the worktree with - `git worktree remove `, whatever any report said. Removing it leaves the skills + `git worktree remove ""`, whatever any report said. Removing it leaves the skills snapshot, the installed kit, and their stamps unchanged. A result that does not read current is reported to the maintainer. The skills `--report` exits on the snapshot alone. This step runs whether step 5 or 6 dispatched, skipped, or failed a release. That is because it is gated only on the chosen scope, @@ -200,7 +202,7 @@ skill covers all of it, scoped down by what the maintainer actually asks for. failure, an ambiguous run match, a timeout, a failed run, or a hub refresh all still reach this step. So does step 2 finding the promotion already merged. The merge already landed by then, in step 3 or before step 2 read it. Every part below is required: - - The promotion PR's own worktree, where one exists: fetch and prune, remove the worktree, then bring the base + - A `develop`-headed promotion PR's own worktree, where one exists: fetch and prune, remove the worktree, then bring the base clone to current `develop`. To do so, check `develop` out first only where it sits on another branch, and fast-forward it with `git merge --ff-only origin/develop`. Where that checkout is needed, removing first, not after, matters. The reason is that the base clone cannot check out `develop` @@ -208,6 +210,10 @@ skill covers all of it, scoped down by what the maintainer actually asks for. in two worktrees at once is refused outright. Never delete `develop`: it is the promotion PR's own head. The repo's auto-delete-head-branches setting is kept off fleet-wide for exactly this reason, so nothing does this automatically. + - A conflicted promotion's own branch, where one exists. That promotion's head is a branch cut + from `main` that merges `develop` rather than `develop` itself. Run the `cleanup ` + command the next bullet names on the promotion PR. It removes that branch's worktree, its local + branch, and its remote branch. - A defensive sweep for anything drive-pr's own cleanup should already have removed but might not have. The causes include an interrupted loop, a fix landed by hand outside that skill, or a maintainer merge in the GitHub UI. `git worktree list` for any worktree still registered under this @@ -217,9 +223,9 @@ skill covers all of it, scoped down by what the maintainer actually asks for. than reading an empty answer as safe: `gh pr list --head "" --base develop --state merged --repo owner/repo --json number --jq 'if length == 1 then .[0].number else error("expected exactly one merged PR for this head, got \(length)") end'`. Then run - `uv run --no-project --script scripts/pr_review.py cleanup --repo owner/repo --checkout ` - from a hub checkout outside the worktree it removes, `` being the repository's - primary clone, per `repo-worktree` "Listing and Cleanup". It re-reads that pull request and + `uv run --no-project --script scripts/pr_review.py cleanup "" --repo owner/repo --checkout ~/repos/""` + from a hub checkout outside the worktree it removes, `~/repos/` being the repository's + primary clone. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. See `repo-worktree` "Listing and Cleanup". The `cleanup` command re-reads that pull request and repeats the merged, base, head-repository, and tip checks in code. It refuses a permanent or protected branch, deletes the remote branch, and confirms it by reading the ref back. It treats a remote branch already gone as done, so a prior interrupted attempt finishes rather than @@ -228,17 +234,15 @@ skill covers all of it, scoped down by what the maintainer actually asks for. says what a refusal after it and a `base=kept` line each leave to do. Exit `0` is done, and any other exit stops and reports. `1` is a refusal, and `2` is an unanswered read or an unconfirmed delete. `64` is a target under an owner other than the hub checkout's own `origin`, or an - unreadable `origin`. A registry refusal is a `1`. It runs under the host-safety - installer's `Bash(uv run --no-project --script scripts/pr_review.py:*)` allow rule, which is what lets auto mode - complete it. - It also refuses while another open pull request in the repository has the branch as its head or base, naming each. + unreadable `origin`. A registry refusal is a `1`. + `cleanup` also refuses while another open pull request in the repository has the branch as its head or base, naming each. Where this seat cannot run `cleanup`, report the cleanup to the maintainer instead of running its steps by hand. That report names the pull request number and `--repo`. No direct `git push origin --delete`, ref API delete, `git worktree remove`, or `git branch -D` runs on a feature branch from this skill. That is because `cleanup` is the one place holding the checks. Never apply this sweep to `develop` or `main` themselves, only to feature branches a drive-pr loop created. - What no single pull request names: run - `uv run --no-project --script scripts/pr_review.py cleanup --sweep --repo owner/repo --checkout ` - and report what it lists. It writes nothing but a fetch, and `--apply` runs only on the + `uv run --no-project --script scripts/pr_review.py cleanup --sweep --repo owner/repo --checkout ~/repos/""` + and report what it lists. In that command `~/repos/` is the convention layout, and a machine not yet migrated passes its actual primary clone instead. The sweep writes nothing but a fetch, and `--apply` runs only on the maintainer's go-ahead, since the report reaches other sessions' finished work too. ## Mechanics Live Elsewhere diff --git a/.github/skills/pr-review-conduct/SKILL.md b/.github/skills/pr-review-conduct/SKILL.md index 5cd7d08e..57107263 100644 --- a/.github/skills/pr-review-conduct/SKILL.md +++ b/.github/skills/pr-review-conduct/SKILL.md @@ -54,6 +54,8 @@ visible comments, routinely still carries a finding nobody has answered. Treatin whose own file table names exactly the changed files covers it, `coverage=table`. That is the reading a Copilot round at Balanced review effort gives. Where no round covering the head carries a table of its own, the newest round that does stands in as `coverage=carried:table`. Its table has to name exactly the changed files. + The bound is that file set rather than file recency. The carry exists for a later head that + changed those files and drew a round with no table of its own. Either table may leave out an added, modified, renamed, or deleted file with no changed line, such as a binary. That holds while some changed file has one. On a develop -> main promotion, a file that only green Dependabot bumps changed is taken out of that comparison. The head reads @@ -61,6 +63,18 @@ visible comments, routinely still carries a finding nobody has answered. Treatin table names the rest. A table stands in only where no Copilot round on the pull request, on any commit, states partial coverage. So a pull request that ever had a partial round goes to the maintainer. + The review policy owes a Copilot round to some heads, by default those of a pull request into + the default branch, a promotion among them. On such a head a file table stays the first route to + this item. An attested local pass covers it instead, `coverage=local`, only where no Copilot + round covering it states coverage or carries a table of its own. No table above may already + stand in, since a carried table is read first. That pass + runs at the `frontier` tier over the whole diff against the pull request's base, + `main...develop` on a promotion. It holds only where no round on record states partial + coverage and the whole review history is in view. No refusal on the head may stand against it. + A spent cap waives none of these here, since a Copilot round already covers the head. A head + round whose own table names other than exactly the changed files keeps this route closed, + since that table says what Copilot read. So does a head no Copilot round covers yet, since + that round is still owed. `coverage=none` and `coverage=UNKNOWN` leave this item unsatisfied and decide no exit code, so read the field rather than the exit. The coverage this item requires is Copilot's, the attested local pass above, or that green @@ -71,7 +85,16 @@ visible comments, routinely still carries a finding nobody has answered. Treatin or Qodo check on the head has neither passed nor failed, `merge` refuses as `CHECKS_PENDING`, whatever the merge state reads. `wait` holds an attested head then too. A reviewer whose newest output is a rate limit posted since the check began posts no review, so its check holds - nothing. + nothing. The registration grace is not an absence either. A CodeRabbit or Qodo reviewer asked + by comment registers its check only after the ask. The grace runs 90 seconds from the latest + of the head's push, its last check settling, and its newest trusted review ask. A hosted + reviewer's own check, Copilot's included, never counts as that settling. A trusted ask + is one from an owner, member, or collaborator. The grace ends early once a CodeRabbit or Qodo + check that did not conclude `SKIPPED` begins at or after that ask. + Until then `merge` refuses as `CHECKS_PENDING`, on a line naming when the grace ends. `wait` + holds an attested head then too. + A CodeRabbit or Qodo check can read `success` over a rate limit, and a rate limit is not + coverage of the head. `pr_review.py`'s `review_on_head` names Copilot's own coverage specifically, not "no review of any kind covers this head". An advisory reviewer carrying the exact head under `other_reviewed`, with an empty review body and no new threads, is not a missing review. It is @@ -235,8 +258,8 @@ visible comments, routinely still carries a finding nobody has answered. Treatin - Read each part whole in the review body, since the excerpt only locates it. Give every item in it item 3's outcome: fixed with its SHA, declined with evidence, or listed as pre-existing in the pull request body. - - Post the outcomes with `pr_review.py comment --repo / --fingerprint - --body `. One from an owner, member, or collaborator clears the hold, + - Post the outcomes with + `uv run --no-project --script scripts/pr_review.py comment "" --repo "/" --fingerprint "" --body ""`. One from an owner, member, or collaborator clears the hold, `shapes=ACKNOWLEDGED`. New unplaced text on a new head owes a new acknowledgment. - The spelling is a data edit to the matching `scripts/reviewers/*.json` in the hub plus one fixture. Whoever acknowledged the part makes it in a pull request of its own, never an issue. @@ -278,9 +301,12 @@ must have done. since an advisory reviewer blocks nothing. - **Silence is not evidence, and is never read as one on its own.** A reviewer that has posted nothing may not have started yet, or may not cover this repository at all. Or it may have - reviewed and had nothing to say. That case posts no comment to read, and Merge Gate item 2 - describes it as its own ordinary shape. Read the reviews themselves rather than the comments alone, since the third - case appears only there. + reviewed and had nothing to say. That case opens no thread, and where it leaves its record + differs by reviewer. It can be a review with an empty body, the shape Merge Gate item 2 calls + ordinary. A CodeRabbit clean pass can leave no review object at all. It then shows only in + CodeRabbit's summary comment, as a line saying no actionable comments were generated. That line + counts only where the commit range the summary's review details print ends at the current head. + So read the reviews and the comments both, since either can hold the third case. - **Copilot's absence blocks where no local pass stands in, and is answered elsewhere.** Merge Gate item 2 requires Copilot's own coverage of the current head. Where the review policy hands the head to a local pass, by default off the default branch, an attested local pass stands @@ -313,15 +339,33 @@ that says only "open a PR" is not such an instruction. Run every `scripts/pr_review.py` command below from a hub checkout. The script is hosted there and is never carried into a downstream repository. +On Claude Code, the host-safety installer's allow rule runs a `scripts/pr_review.py` call without +the auto-mode classifier only where the call matches the rule's text. So run each such command as a +call of its own, spelled exactly as the skill prints it. That holds for every +`scripts/pr_review.py` call a fleet skill prints, in this skill or another. Where the hub checkout sits inside the session's working +directories, a `cd "" &&` prefix keeps the match. A `cd` elsewhere may not. A leading +variable assignment leaves the rule unmatched unless Claude Code counts that variable as known-safe. +So does a flag between `uv run` and the script, or a script named by an absolute path or a shell +variable. The classifier then judges the call, and its default rules refuse a merge no human has +approved. So the spelling is owed on the first call. A call refused anyway is a refused write +under `GOVERNANCE.md` "Repository Boundaries and Write Safety", reported rather than re-spelled. +On Claude Code, where the executor restricts uv's cache writes, the cache variable that restriction +needs is such an assignment. So every call there reaches the classifier. A call that merges or +deletes is then reported to the maintainer as a blocked write rather than run. Those calls are +`merge`, `cleanup `, and `cleanup --sweep --apply`. They are the writes the classifier is +known to refuse, a merge even with its gate met and a branch delete on some days. So running one there is a +write fired to see whether it passes, which `GOVERNANCE.md` "Repository Boundaries and Write Safety" forbids. Any other call there runs, and one the classifier refuses is the refused +write above. + Run `local-strict-review` against the branch's current diff before every push this loop makes. The pass is owed before the push that opens the pull request in step 1 and each one after it. It is owed whatever finding a push answers and whether or not the branch was reviewed once already. A push that delivers content no pass has read is the case the rule is about. So a re-push of a tree a recorded pass already covers needs no second pass. That is because the receipt is keyed on the branch's net content rather than on its commit series. A rebase that leaves the tree alone keeps the receipt only while the merge base holds. Rebasing onto a target that has moved retires the receipt although no file changed. That push owes a pass like any other. Follow that skill's own ordering and record each pass, which is what a capture point reads. The hub's own `pre-push` hook is one, and a repository has none until such a hook is carried to it. A push that hook refuses, where one is present, is the gate working rather than an obstacle to route around. That skill's refusal table says what each refusal means and what clears it. 1. Push changes to the PR branch and open the pull request when it does not exist. Once the push - lands, run `uv run --no-project --script scripts/pr_review.py attest --repo / --checkout `. + lands, run `uv run --no-project --script scripts/pr_review.py attest "" --repo "/" --checkout ""`. `attest` refuses unless the checkout is the pushed head and a recorded pass covers that head. Attest after every push a recorded pass covers, the opening push included. The comment `attest` posts is the record Merge Gate item 2's promotion case reads, since the receipt goes when its worktree does. -2. Run `uv run --no-project --script scripts/pr_review.py status --repo /` once in the foreground and read its output. +2. Run `uv run --no-project --script scripts/pr_review.py status "" --repo "/"` once in the foreground and read its output. 3. Send each request the repository's review policy asks for, which step 4's `wait` is what does. Under the hub's default that is one Copilot round, on the head of a pull request into the default branch. A promotion is one such pull request. Auto-trigger is unreliable, so `wait` fills a @@ -335,7 +379,7 @@ Run `local-strict-review` against the branch's current diff before every push th the request set. Something in the request set is the condition the recovery below clears. An error refusal whose run log reads transient is the exception, owed one re-request per Merge Gate item 2. Requesting in the pull request UI is the maintainer's route rather than this loop's. -4. Run a bounded `uv run --no-project --script scripts/pr_review.py wait --repo /` in a background process and read its terminal output. +4. Run a bounded `uv run --no-project --script scripts/pr_review.py wait "" --repo "/"` in a background process and read its terminal output. A completed review raising **no findings** is a valid terminal outcome, so do not re-trigger it or read silence as a missing review. A review whose body says it declined to review is the one exception, and it is terminal the other way. Nothing follows it, and re-requesting the same @@ -357,13 +401,16 @@ is not a stopping condition here, and neither is patience running out. Reporting PR was opened is an early exit unless the maintainer explicitly instructed the agent not to monitor or drive its review. -After an authorized merge, run the `repo-worktree` post-merge cleanup procedure unless the user explicitly asks to retain the checkout or branch. For a merge into `develop` that procedure is `uv run --no-project --script scripts/pr_review.py cleanup --repo / --checkout `, run from a hub checkout. The pull request loop is incomplete while its finished worktree or local task branch remains. A promotion branch merged into `main` is the exception, which `repo-worktree` leaves for its sweep. The loop is also incomplete until the base clone returns to fetched and fast-forwarded `develop`. +After an authorized merge, run the `repo-worktree` post-merge cleanup procedure unless the user explicitly asks to retain the checkout or branch. For a merge into `develop` that procedure is `uv run --no-project --script scripts/pr_review.py cleanup "" --repo "/" --checkout ~/repos/""`, run from a hub checkout. In that command `~/repos/` is the convention layout, and a machine not yet migrated passes its actual primary clone instead. The pull request loop is incomplete while its finished worktree or local task branch remains. A conflicted promotion's branch merged into `main` takes the same command, run on the promotion pull request. The loop is also incomplete until the base clone returns to fetched and fast-forwarded `develop`. ## Every finding ends in a listed outcome A finding that committed text holds observed data takes outcome 4's observed-data bullet, whatever its class, ahead of every other outcome. That applies once the data is confirmed as -observed. A value the repository constructed is disproved under outcome 2 instead. +observed. A value the repository constructed is disproved under outcome 2 instead. So is a +value outside the rule's scope, such as a date, an amount, a balance, or a private-range IP +address. `GOVERNANCE.md` "Representative Data in Agent-Authored Text" bounds only what its first +bullet calls identifying data. 1. **Real, so fix it, and fix the class rather than the instance.** A reviewer samples rather than enumerates, so sweep for the finding's siblings before replying. Fix each one sitting @@ -420,7 +467,11 @@ observed. A value the repository constructed is disproved under outcome 2 instea that one too. The pull request holding the record takes the `history-data` label, and so does the one whose review raised it. Where the repository lacks that label, the maintainer is told. A thread raising a recorded finding is answered with a pointer to its body line and - resolved. + resolved. Every observed secret also goes to the maintainer for revocation, whatever else its + case requires, naming only the repository and the kind of data. A seat that cannot reach the + maintainer hands that notice to whoever dispatched it. The notice is not an escalation, so it + stops nothing, and its case's own route continues. A seat with no dispatcher lists it in its + final report, never in a handoff issue. - A local pass before the push that opens the pull request can raise a `pre-existing` correctness defect in a file the diff already touches. That defect is fixed here under outcome 1. That covers wrong behavior and a false or unfollowable instruction, and not a @@ -536,7 +587,7 @@ item 4's lead bullet covers takes no `--ack` until the maintainer answers, per M collaborator. Code checks that each item carries an outcome, never that the outcome is right, which stays this section's. **Read every round, not only the head.** A suppressed finding does not retire when a later push -supersedes it, it just stops showing up in a head-scoped query while still unanswered. Post the answer with `uv run --no-project --script scripts/pr_review.py comment --repo / --ack = --body ` +supersedes it, it just stops showing up in a head-scoped query while still unanswered. Post the answer with `uv run --no-project --script scripts/pr_review.py comment "" --repo "/" --ack "=" --body ""` from a hub checkout. Do not use a provider connector or reconstruct the GitHub mutation. ## Escalate to the maintainer when diff --git a/.github/skills/python-codestyle/SKILL.md b/.github/skills/python-codestyle/SKILL.md index cd46358b..ce90d1b6 100644 --- a/.github/skills/python-codestyle/SKILL.md +++ b/.github/skills/python-codestyle/SKILL.md @@ -99,43 +99,49 @@ neither `uv sync` nor `uv run`, since either writes a `uv.lock` that, once commi directory the uv form. A pip-form directory builds its environment as the pip-form block below shows. A **lint-only** Scripts profile has no `uv.lock` to sync and no pytest to run. For it, substitute -`uvx` per tool and `unittest` per the Two Profiles section above: +`uvx` per tool and `unittest` per the Two profiles section above: ```sh uv sync # creates .venv, installs deps + dev group -uv run ruff format # auto-format -uv run ruff check --fix # auto-fix lint -uv run ruff check # verify lint clean -uv run ruff format --check # verify format clean +uv run ruff format --extend-exclude ./hub_fetch_run.py --force-exclude # auto-format +uv run ruff check --fix --extend-exclude ./hub_fetch_run.py --force-exclude # auto-fix lint +uv run ruff check --extend-exclude ./hub_fetch_run.py --force-exclude # verify lint clean +uv run ruff format --check --extend-exclude ./hub_fetch_run.py --force-exclude # verify format clean uv run pyright # verify types uv run pytest # run tests uv build # produce wheel + sdist in ./dist (published packages only) ``` +A downstream repo keeps the carried `hub_fetch_run.py` at its root. So each ruff command this skill and its references name carries +`--extend-exclude ./hub_fetch_run.py --force-exclude`, whatever form runs it. The repo's own ruff config may be stricter than the hub's. +The flags keep ruff from reporting or rewriting the helper, which stays byte-identical to the hub's copy. + The **build**-profile Python clean-compile, in its uv form, is `uv run ruff format` + `uv run ruff check` + the repo's type checker. That checker is `uv run pyright`, or `uv run mypy` -where mypy is the CI checker, or both where the repo runs both (see Type checking above). Where the +where mypy is the CI checker, or both where the repo runs both (see Toolchain above). Where the config sits in the project directory, CI passes the checker no path, so the config's own target settings decide what is checked. mypy left with no target that way exits with an error. A declared subdirectory with no config of its own uses the repository root's instead. CI then runs the checker -from the root with the directory as its path, `uv run --project `, so run it +from the root with the directory as its path, `uv run --project "" "" ""`, so run it the same way. Run the clean-compile, plus `uv run pytest`, before committing. A **build**-profile directory in its pip form builds its environment the way CI does, through uv's pip interface, which writes no `uv.lock`. It installs every `requirements*.txt` in one command, since separate installs let one file's pins downgrade what another resolved. Where its `pyproject.toml` carries a `[project]` table it then installs the directory itself as editable. Without that, a -`src`-layout package is not importable and pytest fails locally where CI passes: +`src`-layout package is not importable and pytest fails locally where CI passes. Both installs pass +`--python .venv/bin/python`, since `uv pip install` targets an active `VIRTUAL_ENV` ahead of +`./.venv`: ```sh uv venv --clear # creates .venv, replacing an existing one -uv pip install -r requirements.txt -r requirements-dev.txt # one -r per requirements*.txt -uv pip install -e . # only where pyproject.toml has a [project] table +uv pip install --python .venv/bin/python -r requirements.txt -r requirements-dev.txt # one -r per requirements*.txt +uv pip install --python .venv/bin/python -e . # only where pyproject.toml has a [project] table # in a declared directory whose .venv installs ruff, .venv/bin/python -m ruff replaces uvx ruff@latest -uvx ruff@latest format # auto-format -uvx ruff@latest check --fix # auto-fix lint -uvx ruff@latest check # verify lint clean -uvx ruff@latest format --check # verify format clean +uvx ruff@latest format --extend-exclude ./hub_fetch_run.py --force-exclude # auto-format +uvx ruff@latest check --fix --extend-exclude ./hub_fetch_run.py --force-exclude # auto-fix lint +uvx ruff@latest check --extend-exclude ./hub_fetch_run.py --force-exclude # verify lint clean +uvx ruff@latest format --check --extend-exclude ./hub_fetch_run.py --force-exclude # verify format clean .venv/bin/python -m pytest # run tests ``` @@ -155,7 +161,7 @@ way, as in `/.venv/bin/python -m mypy `. On Windows each interpreter p clean-compile, run with pytest before committing. A **lint-only** profile's clean-compile substitutes its `uvx` and `unittest` equivalents, per Two -Profiles above, and has no such command to run before committing beyond those. These are documented +profiles above, and it runs only those before committing. These are documented commands. The hub's `vscode-tasks-python.json` snippet carries the VS Code tasks mirror of the uv form that the fleet baseline expects. Its header names the pip-form and lint-only adaptations. Every command-executing task in it is `type: process`, and every aggregator is `dependsOn`-only. Neither chains with `&&`, so the mirror runs the same on any task shell. @@ -168,7 +174,7 @@ a root `pyproject.toml`, per `WORKFLOW.md` D1.2. That undeclared root is gated m reads its type-checker configuration only from the `[tool.mypy]` or `[tool.pyright]` section of its `pyproject.toml`. It skips the type check where neither is there, whatever the form. In its pip form CI installs nothing for that check and runs a bare -`uvx @latest`. So the local check against the environment is the stricter one. And CI runs +`uvx "@latest"`. So the local check against the environment is the stricter one. And CI runs its tests only where a pytest suite in `tests/` sits beside a `uv.lock` or `requirements*.txt`. A repo that keeps no .NET tool manifest declaring Husky.Net wires its local hook from the canonical @@ -244,7 +250,7 @@ build-profile conventions, and `references/profiles.md` for the lint-only `unitt - **A test lives in a `tests/` directory, never inside the production file it tests.** A deployed script may keep a `--selftest` that runs a small smoke check in seconds, and the case matrix lives in `tests/`. A self-test shipped inside the file it tests grows the file every reviewer reads, and its cases can come to outweigh the code they test. -- **A hub-hosted standalone script that needs a third-party library declares it in PEP 723 inline script metadata, and runs as `uv run --no-project --script `.** The block opens on `# /// script`, closes on `# ///`, and carries `dependencies` and `requires-python`. The fleet already installs uv on hosts and in CI. `--no-project` keeps uv from syncing the project around a script that has no block yet, where it would write a lockfile and a virtual environment. A script with no such block runs under `python3` and uv alike. A hook an agent harness runs on every tool call stays standard-library only, since it runs before any toolchain is guaranteed. +- **A hub-hosted standalone script that needs a third-party library declares it in PEP 723 inline script metadata, and runs as `uv run --no-project --script ""`.** The block opens on `# /// script`, closes on `# ///`, and carries `dependencies` and `requires-python`. The fleet already installs uv on hosts and in CI. `--no-project` keeps uv from syncing the project around a script that has no block yet, where it would write a lockfile and a virtual environment. A script with no such block runs under `python3` and uv alike. A hook an agent harness runs on every tool call stays standard-library only, since it runs before any toolchain is guaranteed. @@ -252,7 +258,8 @@ build-profile conventions, and `references/profiles.md` for the lint-only `unitt Published packages use `_version.py` with `__version__ = "0.0.0"` as a placeholder. Wire `hatch-vcs` or equivalent to increment, publish with `skip-existing: true`. Source-only repos use -a static `version` in `[project]` with no `_version.py`. See `references/profiles.md` for details. +a static `version` in `[project]` with no `_version.py`, and NBGV plus `version.json` own their +release tag. See `references/profiles.md` for details. ## Linter cleanliness @@ -286,7 +293,8 @@ Before pushing or opening a PR: A command-line script is one a person or an agent runs by name. A hook its host runs, taking its input from that host rather than from a command line, is not one. - **Every command-line script answers `--help` and `-h`** with the same text on stdout, then exits 0, changing nothing. That text opens on a usage line naming the script. An agent learns a script's interface by asking it, so a script that reads `--help` as an input acts in a way nobody predicted. A PowerShell script declaring its own parameters answers `-Help` and `-h` instead, from a `-Help` switch carrying an `h` alias. That form follows PowerShell's own parameter convention, so such a script owes no answer to a literal `--help`. A wrapper that forwards its arguments to another script answers whatever that script answers. -- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. Where no parameter takes the remaining arguments, the binder's refusal does that. A script with such a parameter refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. That refusal comes from the binder only in an advanced script, one carrying `[CmdletBinding()]` or a `[Parameter()]` attribute. Without either, a plain `param()` block binds an unknown parameter into `$args` and runs on. Such a script refuses a non-empty `$args` itself, before any work. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. A script with a parameter taking the remaining arguments refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **A shell script that gives a refused argument an exit status of its own uses 64, `EX_USAGE` from `sysexits.h`, and reserves it.** A caller can then tell a refusal, which changed nothing, from a run that started and failed, without reading the message. Every refusal exits through one function that exits 64. Under `set -e` a failed command's own status becomes the script's, so an `EXIT` trap turns any other exit carrying 64 into 1. A program the script `exec`s replaces that trap. So the script `exec`s only a program whose own 64, if it exits 64 at all, means a refused argument. An argument the script passes on, which that program refuses, keeps the program's status. The script's `--help` names the status, so a caller reads it as a contract. @@ -294,13 +302,14 @@ A command-line script is one a person or an agent runs by name. A hook its host -This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. +This applies to every shell and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. -- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. +- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. A script started with SIGINT ignored keeps it ignored, so a stop meant to reach it sends SIGTERM. A non-interactive shell starts a background child that way. - **A write to persistent state goes to a temporary path beside the target, then is renamed over it.** An interrupt then leaves the old content or the new, never a mix of both. A store with transactions of its own, such as an SQLite database, is written through those instead. A rename over an open database can corrupt it. -- **An interrupted script prints one line naming the signal, with no traceback, and exits 130 for SIGINT or 143 for SIGTERM.** Each status is 128 plus the signal number, the status a shell reports for a process that signal ended. +- **An interrupted script prints one line naming the signal, with no traceback, and ends by re-raising the signal.** The signal then ends the process, so a shell reports 130 for SIGINT or 143 for SIGTERM, 128 plus the signal number. At Ctrl-C, a calling shell's loop then stops rather than starting its next iteration. A script calling `exit 130` has not died by the signal, so that loop reads an ordinary non-zero exit and runs on. A launcher between them, such as `uv run`, exits with the status rather than dying by the signal, so that loop runs on there too. - **A script takes this rule when it is created or next edited.** An existing script is not edited for this rule alone. -- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts the matching exit status and that nothing the script held remains. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts that the script died by that signal and that nothing it held remains. It starts the script with its interpreter directly, since a launcher such as `uv run` hides the signal death. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that ends by `exec`-ing its long-running process owes no interrupt handling for that process.** The `exec` replaces the script, so a signal reaches the process directly. A background child the script starts to outlive the `exec` is handed across it, and the script neither stops it nor waits for it. Such a child is handed across only where something else stops it, such as a container's teardown of its whole process tree. Anything else the script holds is released before the `exec`. A script that holds nothing else at any point before the `exec` owes no trap and no signal test. As PID 1, such as a container's entrypoint, it ignores a SIGTERM that arrives before the `exec`, so a stop waits for its timeout. @@ -308,9 +317,9 @@ This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Pyth -- **SIGINT and SIGTERM take one path.** Python raises `KeyboardInterrupt` on SIGINT. The entry point installs a SIGTERM handler with `signal.signal` that records the signal and raises `KeyboardInterrupt`. -- **The entry point catches `KeyboardInterrupt` once, and any handler below it that catches the exception re-raises it.** It prints the line `CODESTYLE.md` "Interrupts" requires, then exits 143 where the SIGTERM handler recorded a signal and 130 otherwise. -- **What the script holds is released by `with` blocks and `finally` clauses as the exception unwinds.** A `subprocess.Popen` child is stopped in a `finally` clause with `terminate()`, then `wait()`, since leaving its `with` block does not stop it. That child runs without `shell=True`, so `terminate()` reaches the command rather than a shell around it. +- **SIGINT and SIGTERM take one path.** The entry point installs one handler with `signal.signal` for both signals. The handler records the first signal and raises `KeyboardInterrupt`, and returns at once on any later one. A later signal would cut the cleanup short, such as the SIGTERM that `uv run` forwards to a process group a Ctrl-C already reached. The handler takes SIGINT only where `signal.getsignal(signal.SIGINT)` is still `signal.default_int_handler`, so a SIGINT inherited as ignored stays ignored. +- **The entry point catches `KeyboardInterrupt` once, and any handler below it that catches the exception re-raises it.** It prints the line `CODESTYLE.md` "Interrupts" requires, then re-raises the signal the handler recorded. To re-raise, it flushes standard output and standard error inside `contextlib.suppress(OSError)`, restores the default handler with `signal.signal(signum, signal.SIG_DFL)`, then re-sends the signal with `os.kill(os.getpid(), signum)`. The suppression covers a pipe whose reader the same Ctrl-C ended. The default action ends the process without Python's own exit handling. So the flush comes first, and no cleanup on this path relies on an `atexit` handler or a finalizer. The re-raise runs outside every `with` block and `finally` clause, such as at the `__main__` call site, since none of them runs after it. A process the re-sent signal does not end, such as PID 1 in a container, then exits 128 plus the signal number. On Windows, `os.kill` ends the process with the signal number as its status, so there the entry point skips it and exits 130. +- **What the script holds is released by `with` blocks and `finally` clauses as the exception unwinds.** A `subprocess.Popen` child is stopped in a `finally` clause, since leaving its `with` block does not stop it. The clause calls `terminate()`, then `wait(timeout=...)`, such as 10 seconds. On `subprocess.TimeoutExpired`, it calls `kill()`, then `wait()`. The handler passes over a second Ctrl-C, so a child that ignores SIGTERM would otherwise hold the script. That child runs without `shell=True`, so `terminate()` reaches the command rather than a shell around it. - **The rename over persistent state uses `os.replace`.** `os.rename` and `Path.rename` fail on Windows when the target exists. diff --git a/.github/skills/python-codestyle/references/code-style.md b/.github/skills/python-codestyle/references/code-style.md index 54e438b3..da2aa3a9 100644 --- a/.github/skills/python-codestyle/references/code-style.md +++ b/.github/skills/python-codestyle/references/code-style.md @@ -100,7 +100,11 @@ rejects non-ASCII output from a child writing UTF-8. No static check in the ruff, pyright, or mypy toolchain looks for the omission in a subprocess call. Naming the encoding settles how the bytes are translated, not what a byte or character outside that encoding is worth. Each call - decides that with its own `errors` argument, and the strict default decides it by raising. + decides that with its own `errors` argument, and the strict default decides it by raising. A + call whose child is a Python interpreter also owes that child the matching encoder. Below + Python 3.15 the child's own streams take the locale encoding too. Pass `PYTHONIOENCODING=utf-8` + in the child's environment. A child run with `-I` or `-E` ignores that variable, so give it + `-X utf8` on its command line instead. diff --git a/.github/skills/python-codestyle/references/profiles.md b/.github/skills/python-codestyle/references/profiles.md index 6fe393d5..fe4add40 100644 --- a/.github/skills/python-codestyle/references/profiles.md +++ b/.github/skills/python-codestyle/references/profiles.md @@ -16,12 +16,13 @@ review. The axes that commonly vary: installs. CI's `uv sync --all-groups --frozen` installs that group too, since the command takes every group and no extra. PEP 621 - `[project.optional-dependencies]` (installed with `uv sync --extra `) suits only a tool CI + `[project.optional-dependencies]` (installed with `uv sync --extra ""`) suits only a tool CI does not run. The pip form declares its dependencies in `requirements*.txt` files, installed together in one resolve, per `SKILL.md` "Local development loop". - **Versioning / publishing**: a published package or a source-only repo (see Versioning below). A published package has `_version.py` plus a version source, `uv build`, and a PyPI publish step. - A source-only repo has a static `version` and no publish step. + A source-only repo has a static `version` and no PyPI publish step, and NBGV plus `version.json` + own its release tag. ## Two profiles: full specification @@ -39,7 +40,7 @@ Tool configuration alone marks the lint-only one: with `dependencies`, a `[build-system]`, and a committed `uv.lock`. Its dev tools sit in `[dependency-groups]`, per the dependency-declaration axis above. The `uv.lock` is pinned LF, per GOVERNANCE.md's "Line Endings" section. CI runs `uv sync --all-groups --frozen` + - `uv run `, so the lockfile pins tool versions. That sync installs every `[dependency-groups]` group and no + `uv run ""`, so the lockfile pins tool versions. That sync installs every `[dependency-groups]` group and no `[project.optional-dependencies]` extra. The pip form is a `pyproject.toml` beside a `requirements*.txt`, installed with pip, whether or not it carries a `[project]` table. A committed `uv.lock` makes a directory the uv form even where a `requirements*.txt` sits beside it. @@ -48,7 +49,7 @@ Tool configuration alone marks the lint-only one: `python-directories` input runs ruff and the type checker from that environment where it installs them. It otherwise runs them through `uvx`, with the checker pointed at that environment. The undeclared default root runs ruff through `uvx` at the pinned version the - lint-only profile below names, and a bare `uvx @latest`, with nothing installed. + lint-only profile below names, and a bare `uvx "@latest"`, with nothing installed. - **Scripts** (the `lint-only` profile): stdlib-only utility scripts (e.g. a Python tooling subtree of a `csharp` app). Run the tools with `uvx` (no project install, no lockfile). The `pyproject.toml` carries only tool config (`[tool.ruff]`, `[tool.mypy]`, and @@ -56,7 +57,7 @@ Tool configuration alone marks the lint-only one: `uv.lock` (that metadata would misrepresent it as a shippable package). mypy is the type-check gate (there is no first-party package for pyright strict to anchor on). A `[tool.pyright]` block in standard mode keeps Pylance quiet in the editor, the same mypy-gate/pyright-editor - split the build profile uses. There is no lockfile, and a `uvx @` literal in a `run:` + split the build profile uses. There is no lockfile, and a `uvx "@"` literal in a `run:` step is not something Dependabot tracks. The fleet rule is to pin only what Dependabot auto-updates (SHA-pinned actions, package deps) and otherwise run latest. A manual pin would silently go stale. So CI runs ruff at the version the hub validator's @@ -76,13 +77,20 @@ Tool configuration alone marks the lint-only one: owes the same gates whatever its profile: lint, format, a type check, a test suite, and a coverage report to Codecov. The hub validator runs them in each directory the caller declares in its `python-directories` input, which the registry's `pythonDirectories` mirrors. From inside - a lint-only directory it runs `uvx ruff@ check`, `uvx ruff@ format --check`, + a lint-only directory it runs `uvx "ruff@" check`, `uvx "ruff@" format --check`, `uvx mypy@latest`, and `uvx coverage@latest run -m unittest discover -s tests`. It adds `--with-requirements tests/requirements.txt` to that last where the directory carries one. It then writes `coverage.xml` and uploads it best-effort per `WORKFLOW.md` D1.6, with no threshold adopted. A declared directory with no `tests/` fails that job. +In either profile, the mypy configuration names its target with `files`, `packages`, or +`modules`. That holds for a `[tool.mypy]` section and for a `mypy.ini`, `.mypy.ini`, or `setup.cfg` +`[mypy]` section alike. A `[tool.mypy]` section in a project usually names `files = ["src"]`, and +one in a lint-only directory `files = ["."]`. An INI file writes the list bare, as `files = src`. +CI passes mypy no path where that config sits in the directory it checks. +Without a target, mypy then exits 2 with "Missing target module, package, files, or command". + A profile belongs to a declared directory, not to the repository. A repository declaring none has its root gated only where it tracks a root `pyproject.toml`, as `WORKFLOW.md` D1.2 states. Each deliverable takes one build-profile directory of @@ -105,7 +113,7 @@ you wire `_version.py` to something that increments (the usual options are `hatc version.json bridge, or manual bumps), no new PyPI versions land. Publishing with `skip-existing: true` keeps a stuck placeholder version from failing the run. -**Source-only repos** (no PyPI publish, with a source-release on dispatch or no release at all) do -not need `_version.py`. Keep a static `version` in `pyproject.toml` `[project]`, or let the -release pipeline's version source (e.g. NBGV plus `version.json`) own the tag. There is no publish +**Source-only repos** (no PyPI publish, with a source release on dispatch) do +not need `_version.py`. The release pipeline's version source, NBGV plus `version.json`, owns the +tag. A static `version` in `pyproject.toml` `[project]` does not replace it. There is no publish step to guard, so `skip-existing` does not apply. diff --git a/.github/skills/repo-worktree/SKILL.md b/.github/skills/repo-worktree/SKILL.md index 049edac2..67660f65 100644 --- a/.github/skills/repo-worktree/SKILL.md +++ b/.github/skills/repo-worktree/SKILL.md @@ -140,8 +140,10 @@ system may reap it as temporary data. State the absolute path as soon as the fal and again in the handoff. Do not present work there as ordinarily reviewable from the primary workspace. +The `~/repos/""` path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. + ```sh -TASK_ORIGIN="$(git -C "" remote get-url origin)" +TASK_ORIGIN="$(git -C ~/repos/"" remote get-url origin)" git clone --no-checkout "$TASK_ORIGIN" "/-" git -C "/-" fetch origin develop git -C "/-" switch -c "" origin/develop @@ -165,15 +167,15 @@ no separate branch setup. Git refuses to attach a branch that is already checked tree is the hazard the continuation rule exists for. `git worktree list` names the checkout holding it and prints the base clone first, and what to do there depends on which checkout that is. -The base clone holding it is the case "The Base Branch" excepts. Return it to its own working -branch when its tree is clean, `git -C ~/repos/ checkout develop`, and then create the -worktree. Stop when it is not clean, because a dirty shared checkout is the signal that another +The base clone holding it is the case "The Base Branch" excepts. Judge its tree by the +hand-removal read in "Listing and Cleanup". When it is clean, return it to its own working +branch, `git -C ~/repos/"" checkout develop`, and then create the worktree. Stop when it is not clean, because a dirty shared checkout is the signal that another task may be live there. A previous session's own worktree holding it is retired rather than switched. It normally sits at the very `~/repos/worktrees/-` path the command above wants, so `worktree add` -aborts on the existing directory whatever its branch is. Remove it when it is clean, and stop when -it is not, because a dirty tree there may be uncommitted work. `backlog-burndown` calls this +aborts on the existing directory whatever its branch is. Remove it when it is clean by the +hand-removal read in "Listing and Cleanup". Stop when it is not, because a dirty tree there may be uncommitted work. `backlog-burndown` calls this retire-then-dispatch and cites this skill for it. A machine not yet migrated to this layout still isolates exactly the same way, since the mandate is the isolation rather than the path. Create the worktree beside whatever layout the machine @@ -209,8 +211,10 @@ in the new tree. own, run the same commands there whatever the setting reads. - **Python pre-commit:** When `.pre-commit-config.yaml` exists, check for the hook the new tree will run before installing anything, from the worktree root, with - `test -x "$(git rev-parse --git-path hooks)/pre-commit"`. In a linked worktree with no - `core.hooksPath` set, that path is the base clone's shared hooks directory. So a hook already there is the one every checkout runs, and the step is done. Where none is present in a linked + `h="$(git rev-parse --git-path hooks)/pre-commit"; test -x "$h" && grep -q '^# File generated by pre-commit' "$h"`. + It passes only on an executable hook carrying the framework's own header. Any other executable + there is not the gate this bullet is about. In a linked worktree with no + `core.hooksPath` set, that path is the base clone's shared hooks directory. So such a hook already there is the one every checkout runs, and the step is done. Where none is present in a linked worktree, the bullet below applies. In a standalone clone the hooks directory is the clone's own, so run `uv tool install pre-commit` once per host if not already installed, then `pre-commit install` there. `pre-commit` is never a project dependency, so this is the same @@ -222,15 +226,22 @@ in the new tree. checkout of the repository, the maintainer's own included. Rewriting a setting to the value it already holds, as the Husky.Net step above does, changes nothing and is not this case. Switching installers is the same act, since `prek install` over a pre-commit framework hook moves the original aside and chains to it. That chaining has left every commit in every checkout failing on the - chained script. A missing or wrong shared hook is reported to the maintainer, not repaired from - the worktree. -- **Repository override:** Follow a repository's explicit hook-setup instructions when they differ from these standard cases. The exception is that none of them may change a shared hook or setting - from a linked worktree, per the bullet above. Do not infer a replacement command from + chained script. A missing or wrong shared hook is put to the maintainer per `GOVERNANCE.md` + "Communicating with the User", not repaired from the worktree. A dispatched worker hands it to + its dispatcher in its report. An away run lists it in its end-of-run report under what needs + the maintainer, per `backlog-burndown` "Ending an Away Run". The task does not wait for the + repair, and CI stays the gate meanwhile. A wrong hook that refuses every commit + stops the task at its first commit, reported the same way, since it is never bypassed. No agent repairs it by running an installer against + the shared hooks directory or its setting, from any checkout. The maintainer repairs it by hand. +- **Repository override:** Follow a repository's explicit hook-setup instructions when they differ from these standard cases. The exceptions are the bullet above's. None of them + may change a shared hook or setting from a linked worktree. None may repair a missing or wrong + one from any checkout. Do not infer a replacement command from the language alone. Treat hook preparation as worktree setup, not as recovery after a rejected commit. If setup -fails, report that boundary and fix the setup. Never bypass the hook to make the commit succeed. -A commit-time `core.hooksPath` override, `git -c core.hooksPath= commit`, is a bypass too, +fails, report that boundary and fix the setup this tree owns, routing a shared hook as the +bullet above says. Never bypass the hook to make the commit succeed. +A commit-time `core.hooksPath` override, `git -c core.hooksPath="" commit`, is a bypass too, since git then runs whatever that directory holds, and nothing where it holds nothing. ## Listing and Cleanup @@ -244,41 +255,42 @@ since git then runs whatever that directory holds, and nothing where it holds no helper worktree needs no pull request, but its commit must be contained in the branch whose completed operation created it. - **A pull request merged into `develop` is cleaned up by one command.** Run - `uv run --no-project --script scripts/pr_review.py cleanup --repo / --checkout ` - from a hub checkout outside the worktree it removes, `` being the repository's - primary clone. It reads the branch from the pull request and deletes the remote branch. It then + `uv run --no-project --script scripts/pr_review.py cleanup "" --repo "/" --checkout ~/repos/""` + from a hub checkout outside the worktree it removes, `~/repos/` being the repository's + primary clone. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. It reads the branch from the pull request and deletes the remote branch. It then removes every worktree holding the branch without force, deletes the local branch, and fast-forwards the base clone's `develop`. Its local refusals are decided before the remote delete. So a dirty worktree, an operation in progress, or a local tip the merge did not carry leaves everything in place. A re-check after the delete can still refuse where a concurrent session changed a tree in between. The refusal's output then names what was already deleted. Any exit other than `0` stops and is reported as it stands rather than finished by hand. The raw `git worktree remove`, `git branch -D`, and remote delete it replaces are not on the host-safety - permission allowlist, and the command is. It forwards to `scripts/pr_cleanup.py`, and - `scripts/README.md` "`pr_cleanup.py`" in the hub holds the full contract. -- **What no merged pull request into `develop` covers is removed by hand.** That is a promotion's - worktree, a detached helper worktree, and a temporary standalone clone. Confirm the tree is - clean, and read `git status --porcelain --ignored` for the ignored files the removal deletes. Then remove the exact path with `git worktree remove `, or delete the exact - `/-` directory. A named branch such a tree held, a promotion - branch merged into `main` by a merge commit for one, is left for the sweep below. The sweep reads it as finished once `origin/main` or `origin/develop` contains it. `git branch -d` is no substitute, since it judges a branch with no upstream against `HEAD`. So it refuses one merged only into + permission allowlist, and the command is. Spell every `scripts/pr_review.py` call this skill prints as `pr-review-conduct` "Expected review loop" says. `cleanup` forwards to `scripts/pr_cleanup.py`, and + `scripts/README.md` "`pr_cleanup.py`" in the hub holds the full contract. A conflicted + promotion's branch, cut from `main` and merging `develop`, takes the same command, run on its + pull request into `main`. +- **What no pull request `cleanup` takes covers is removed by hand.** That is a `develop`-headed + promotion's worktree, a detached helper worktree, and a temporary standalone clone. Read + `git -C "" status --porcelain --ignored --untracked-files=normal`. Any line not starting `!!` means the tree is not clean, so stop. Each `!!` line names an ignored file the removal deletes. Then remove the exact path with `git worktree remove ""`, or delete the exact + `/-` directory. A named branch such a tree held is left for the + sweep below. The sweep reads it as finished once `origin/main` or `origin/develop` contains it. `git branch -d` is no substitute, since it judges a branch with no upstream against `HEAD`. So it refuses one merged only into `main` while the base clone is on `develop`. Where that branch was pushed, its remote branch is - reported to the maintainer for deletion, since `cleanup` reads only a pull request merged into - `develop`. Never delete `develop` after a promotion, since it is the permanent integration + reported to the maintainer for deletion, since no pull request `cleanup` takes covers it. Never delete `develop` after a promotion, since it is the permanent integration branch. - **Return the base clone to current `develop`.** `cleanup` does this itself where the base clone is on `develop` or on the merged branch with no tracked changes. A base clone on the merged branch that it cannot switch is one of its refusals. One on another branch, or on `develop` with tracked changes or no fast-forward, exits `0` with `base=kept` on its `status=CLEANED` line. - That line, and every hand removal, leaves this step to run. The step is to fetch and prune `origin`, confirm the base clone is clean, switch it to `develop` when - needed, and fast-forward it with `git merge --ff-only origin/develop`. A completed promotion or + That line, and every hand removal, leaves this step to run. The step fetches and prunes `origin` and confirms the base clone is clean by the hand-removal read above. + It then switches the base clone to `develop` when needed, and fast-forwards it with `git merge --ff-only origin/develop`. A completed promotion or release does not leave the base clone on `main`. Stop and report a dirty base clone or a non-fast-forward instead of switching or reconciling it. - **What an interrupted or abandoned session left behind is swept.** Run - `uv run --no-project --script scripts/pr_review.py cleanup --sweep --repo / --checkout ` - from a hub checkout. It fetches and prunes `origin` and writes nothing else. It reports each worktree and branch that is clean, idle past `--min-age-hours` (default 24), and provably + `uv run --no-project --script scripts/pr_review.py cleanup --sweep --repo "/" --checkout ~/repos/""` + from a hub checkout. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. It fetches and prunes `origin` and writes nothing else. It reports each worktree and branch that is clean, idle past `--min-age-hours` (default 24), and provably finished. Adding `--apply` removes what the report lists through the same checks, the remote branch of a merged `develop` pull request included. The report reaches other sessions' finished work as well as this task's, so `--apply` runs on the maintainer's go-ahead. -- **Prove the cleanup.** Finish with `git status --short --branch` in the base clone and `git worktree list`. The expected result is a clean base clone at `origin/develop` and no worktree belonging only to the completed task. +- **Prove the cleanup.** Finish with `git status --short --branch --untracked-files=normal` in the base clone and `git worktree list`. The expected result is a clean base clone at `origin/develop` and no worktree belonging only to the completed task. - A worktree that refuses removal is dirty, and force is not the fix. Look at what is - uncommitted in it first, since discarding uncommitted work runs only on explicit instruction, + uncommitted in it first, by the hand-removal read above. Discarding uncommitted work runs only on explicit instruction, per the `git-commit-conventions` skill. diff --git a/.github/skills/resync-a-repo/SKILL.md b/.github/skills/resync-a-repo/SKILL.md index 28d64942..ccff7953 100644 --- a/.github/skills/resync-a-repo/SKILL.md +++ b/.github/skills/resync-a-repo/SKILL.md @@ -31,33 +31,40 @@ change from one resync to the next. Read RESYNC.md section 0. A repo with no instruction set at all, or a partial one, is not this skill's job. It is STANDUP.md sections 1A and 2 instead, since an absent carried file is a -baseline that never arrived rather than drift to converge. Run `uv run --no-project --script spec/audit.py `, +baseline that never arrived rather than drift to converge. First create the hub and target +worktrees and verify the host, as the next section says, since no hub tool runs before the host gate. +A stale tool answers `--version`, looks healthy, and produces a wrong answer. Then run +`uv run --no-project --script spec/audit.py ""`, the target's `registry/repos.json` `name` field rather than an `owner/repo` slug or a checkout -path. Then read whether the findings are letters (absent) or drift (present but stale). Do both before doing +path. Then read whether the findings are letters (absent) or drift (present but stale). Do all of this before doing anything else. The finding kind names the procedure the repo is owed. ## Reach the hub and measure before changing anything Fetch a hub checkout of your own immediately before reading it, since a stale clone -answers confidently instead of failing. This follows section 1 of the hub-only `RESYNC.md`. +answers confidently instead of failing. Check out `main`, or `develop` while the target's registry entry has +merged there but not yet reached `main`. This follows section 1 of the hub-only `RESYNC.md`. That file is fetched with the hub rather than present in a carrier. Never do the resync's own work in a checkout another task may be using, the maintainer's own primary checkout included, even one that looks current. For the hub and for the target repo alike, create a worktree of your own off that base clone and work there, per `repo-worktree`. Remove each one when the run ends, per that skill's "Listing and Cleanup". A merged pull request's worktree goes through -`uv run --no-project --script scripts/pr_review.py cleanup --repo / --checkout `. A +`uv run --no-project --script scripts/pr_review.py cleanup "" --repo "/" --checkout ~/repos/""`, +`~/repos/` being that repository's primary clone. That path is the convention layout, and a machine not yet migrated passes its actual primary clone instead. Spell every `scripts/pr_review.py` call this skill prints as +`pr-review-conduct` "Expected review loop" says. A hub worktree that only read the hub is removed by hand once it is clean, its branch with it. On a machine carrying the hub's agent-safety install, Claude Code also refuses a mutating git command run directly in a primary checkout. However, its rules classify git and gh commands only. So a plain file write is never denied, and the re-vendoring this skill exists to govern goes uncaught. A compound command is judged whole, so a copy chained to a denied git write does not run either. Prose is the enforcement here, and following it is not optional. Verify -the host with `python3 scripts/host_gate.py --repo `, run from your hub +the host with `python3 scripts/host_gate.py --repo ""`, run from your hub worktree, since `scripts/` is hub-hosted and no carrier holds it. Then run the audit end to end, -`RESYNC.md` section 2. `uv run --no-project --script spec/audit.py ` measures the target's ground-truth +`RESYNC.md` section 2. `uv run --no-project --script spec/audit.py ""` measures the target's ground-truth branch, which the registry's `groundTruthBranch` names and which is `main` for every cataloged -repo today, never `develop`. That is the invocation "Confirm the procedure before starting" -already ran, run again here. Convergence lands on a ref `main` does not hold yet, so a run that -previews in-flight work names that ref: `uv run --no-project --script spec/audit.py --branch `. Use it +repo today, never `develop`. "Confirm the procedure before starting" already ran that +invocation after this host gate, so read its findings here. A re-run is still owed before +acting on one, as below. Convergence lands on a ref `main` does not hold yet, so a run that +previews in-flight work names that ref: `uv run --no-project --script spec/audit.py --branch "" ""`. Use it to check whether a fix landed, since a run against `main` still reports what the in-flight ref already fixed. Section 2 carries two further commands that neither of these replaces. A finding is a snapshot. So quote the run stamp in anything derived from it, and re-run before acting on a @@ -79,20 +86,25 @@ conversion waits on a re-level of `develop` where an audit `branch:` finding nam covers a finding too large to classify and a path changed on both branches. Use the squash pull request `RESYNC.md` section 3 describes. -1. **The instruction set first.** `CLAUDE.md`, then `AGENTS.md` and `GOVERNANCE.md` verbatim sections, then `CODESTYLE.md` and `WORKFLOW.md`. Include the `AGENTS.md` skill-dependency pointer paragraph in this same step, as one more verbatim unit and not a separate pass. The paragraph names `scripts/skills_install.py` and where the fleet's Skills live. `CLAUDE.md` is the single `@AGENTS.md`-import file that gets `AGENTS.md` into a Claude Code session's context at all. It is a separate baseline entry from `AGENTS.md` itself, so carrying one without the other still leaves that provider unconfigured. **Before touching `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, or `WORKFLOW.md` in this step, run the `carried-instruction-file-guard` skill's distinctive-phrase probe against the target file, every time, without exception.** **This holds regardless of whether the update is a verbatim re-vendor or an intent-fidelity edit.** This is not advisory language to weigh against how routine the diff looks. A diff that looks routine is exactly the shape the AGENTS.md-overwrite incident took. Do not proceed to the re-vendor until the probe has run and any local addition it finds has a destination. That gate follows that skill's own procedure. `CLAUDE.md` is outside that guard's scope. It carries no mixed or repo-specific content by design, so its re-vendor is an ordinary verbatim-fidelity copy, no probe needed. +1. **The instruction set first.** `AGENTS.md` and `GOVERNANCE.md` verbatim sections, then `CODESTYLE.md` and `WORKFLOW.md`. Include the `AGENTS.md` skill-dependency pointer paragraph in this same step, as one more verbatim unit and not a separate pass. The paragraph names `scripts/skills_install.py` and where the fleet's Skills live. **Before touching `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, or `WORKFLOW.md` in this step, run the `carried-instruction-file-guard` skill's distinctive-phrase probe against the target file, every time, without exception.** **This holds regardless of whether the update is a verbatim re-vendor or an intent-fidelity edit.** This is not advisory language to weigh against how routine the diff looks. A diff that looks routine is exactly the shape the AGENTS.md-overwrite incident took. Do not proceed to the re-vendor until the probe has run and any local addition it finds has a destination. That gate follows that skill's own procedure. 2. **Deletions second, before any re-vendor**, other than step 3's re-vendor of the manifest-owned trees, which "Ship it" below moves into step 1's pull request. Only a `retire` disposition in - `spec/divergences.json` authorizes removing a file. The removal is swept tree-wide, per - RESYNC.md section 4, before the deletion counts as done. -3. **Verbatim re-vendors** for `CLAUDE.md` and everything else the probe in step 1 cleared. A - finding classified modified rather than stale gets its diff read before being overwritten. + `spec/divergences.json` authorizes removing a file. A retired `CLAUDE.md` is one, since Claude + Code reads `AGENTS.md` itself. The audit's finding says whether the copy matches one of the + hub's past versions. Delete it only where it does, and report any other copy to the maintainer + rather than deleting it. The removal is swept tree-wide, per RESYNC.md section 4, + before the deletion counts as done. +3. **Verbatim re-vendors** for every verbatim finding, the four instruction files only once step 1's + probe cleared them. A finding classified modified rather than stale gets its diff read before being overwritten. The reason is that it may be an improvement the hub should adopt instead of a mistake to erase. -4. **Interface workflows.** Honor the named contract, required jobs, the ruleset-bound check name, - the artifact-name handoff, rather than copying bytes. -5. **Settings, rulesets, and secrets.** Run +4. **Interface workflows.** Honor the named contract rather than copying bytes. `AUDIT.md` + section 0 lists the checks that contract covers. +5. **Settings, rulesets, and secrets.** Set the first public-interaction limit by hand on one `collaborators` pilot repository, since `apply` sets none until a committed record says a pilot verified one. Verify there that Copilot, CodeRabbit, Qodo, and Dependabot still work under it. Then commit that record, `repo-config/interaction-verification.json`, through a hub pull request carrying the evidence. + This is `RESYNC.md` step 5. Run `repo-config/configure.sh check "/" release` (substitute `operational` for an - operational repo) from the hub at `main`, then `apply` for what it reports, never from a - carried copy. Run `uv run --no-project --script spec/audit.py ` from the same checkout for secrets. + operational repo), then `apply` for what it reports, never from a carried copy. Both run from + the hub checkout this run fetched, at `main` or at `develop` for a registry entry not yet + promoted. Run `uv run --no-project --script spec/audit.py ""` from the same checkout for secrets. 6. **Intent files last, and by hand,** since nothing mechanical judges these. Reconcile the registry entry (`status`, `types`, `releaseTrigger`, `workflowModel`, diff --git a/.github/skills/session-handoff/SKILL.md b/.github/skills/session-handoff/SKILL.md index 563a7d5c..786c4897 100644 --- a/.github/skills/session-handoff/SKILL.md +++ b/.github/skills/session-handoff/SKILL.md @@ -159,7 +159,7 @@ per-section rule broke several sections earlier. Neither is the rule. Sections 7 and 8 are what the chain exists for, and they are also the most likely to be padded. A handoff issue outlives the session that wrote it, and is readable by everyone who can read the -repository. On a public one that is everyone. So it quotes no data observed in the maintainer's +repository. On a public one that is everyone. So it quotes no identifying data observed in the maintainer's environment, per `GOVERNANCE.md` "Representative Data in Agent-Authored Text". That rule binds on a private repository exactly as it does on a public one, and the visibility only changes who the audience is. The routine case here is an absolute home path, since a handoff naturally wants to @@ -212,16 +212,17 @@ A maintainer resuming work says little, often only "resume the handoff", and tha the whole procedure below. Run every step without being reminded of any of them. 0. **Clone a hub checkout of the session's own, as the first command.** Clone the hub's `main` - into a new directory under ``, the fleet worktree directory `repo-worktree` names, - before any `git` or `$handoff` command. `` is a name no directory under `` - already holds, so the clone never takes a path a task worktree wants: + into a new directory under `~/repos/worktrees`, the fleet worktree directory `repo-worktree` + names, before any `git` or `$handoff` command. `` is a name no directory under + `~/repos/worktrees` already holds, so the clone never takes a path a task worktree wants: ```sh - git clone --branch main https://github.com/ptr727/ProjectTemplate.git /ProjectTemplate-hub- + git clone --branch main https://github.com/ptr727/ProjectTemplate.git ~/repos/worktrees/ProjectTemplate-hub-"" ``` That clone is the hub checkout "Running the Chain" sets `$handoff` from, so every later step - runs the chain's script there. Bring it up to date with `git -C pull --ff-only` before + runs the chain's script there. Bring it up to date with + `git -C ~/repos/worktrees/ProjectTemplate-hub-"" pull --ff-only` before step 6 writes, since a clone is whatever it last fetched. Wherever this skill was loaded from is never this session's hub checkout, whatever checkout or snapshot holds it. So no step reads that location as the hub checkout or runs `$handoff` from it. A task worktree `repo-worktree` creates @@ -265,8 +266,8 @@ the whole procedure below. Run every step without being reminded of any of them. with `new`, presents the parked decision queue, and saves memories last. Where the issue carries the `blocked` label left on in step 3, take it off once the next round is written and the queue presented. Remove it with `gh issue edit "" --repo OWNER/NAME --remove-label blocked`, since - the round it marked is archived. Leave it on instead where a `decision` issue this session filed - on this link's work is still unanswered then. The lane waits on that decision now, and an + the round it marked is archived. Leave it on instead where a `decision` issue on this link's work + is still unanswered then, whichever session filed it. The lane waits on that decision now, and an away-mode run taking it could only park it again. Name that issue in a comment on the handoff, as a parking comment does, so a reader reads the question the lane now waits on. An `auto-*` lane differs in one way, since it holds one piece of work. Where that work is done, end the @@ -296,10 +297,12 @@ it. written, comment those answers onto its issue, with the queue's count and list after them. That is because the body keeps the count it was written with, and a resume reads the issue's comments. 4. **Remove the hub clone** "The Attended Session" step 0 made, where it made one, once no step - above still needs `$handoff`. No other step or sweep reaches that clone. From outside it, confirm - `git -C status --porcelain` prints nothing, then delete that exact directory. Ignored - files there are tool caches, so the removal takes them too. A clone - holding uncommitted work is left in place and named in the session's closing message. + above still needs `$handoff`. No other step or sweep reaches that clone. From outside it, read + `git -C ~/repos/worktrees/ProjectTemplate-hub-"" status --porcelain --ignored --untracked-files=normal`. + Any line not starting `!!` is uncommitted work, so the clone is left in place and named in the session's closing + message. Otherwise name each `!!` entry in that message, since the removal deletes them, and + delete that exact directory. `--porcelain` alone never lists ignored entries. The explicit + untracked mode keeps a `status.showUntrackedFiles=no` setting from hiding untracked ones too. 5. **Save memories last.** Where the host keeps a per-user memory, what goes there is the environment-specific nuance "Durable Knowledge and Self-Improvement" leaves to memory. A quirk of this machine or this account is one such nuance. What goes there is saved as the session's final @@ -329,7 +332,9 @@ The numbered list also serves a turn asking for a command run at the session's i - **Reference every pull request as a clickable link.** When you mention a PR on a surface that renders Markdown (chat, a summary, a report), render it as a Markdown link to the PR. Write it as `[#N](https://github.com/OWNER/REPO/pull/N)`, never a bare `#N`. The same applies to issues and commits. **The form follows the surface.** Some surfaces link neither a Markdown link nor a bare URL, an interactive prompt's question and option text among them. Pasting a full URL into one of those does not rescue it, since the reader gets a string to copy. That is the outcome this rule exists to prevent. There the reference is a bare `#N`. The clickable link goes in the message that comes **before** the prompt rather than merely alongside it. That is because the prompt blocks on an answer, and a message emitted after it is read once that answer is already given. That is the one moment the link is no longer any use. The test is whether the reader can click it where it is read, not whether it was written in the syntax that works elsewhere. - **Put a command the user must run where the user can run it.** This session's input line is where the user types to the agent. A command runs outside this session where this session's input line cannot run it or cannot hold its effect. One waiting on typed input, such as a password or a confirmation, is such a command. So is one meant for another host, or one setting a variable the session reads at launch. Every other one runs at this session's input line, where that line can run a command, and outside the session otherwise. **A command the user runs outside this session goes in the question's own text.** Where a question asks the user to run one, the question carries the exact command, complete and ready to paste. A message before the prompt may repeat the command, but the question never points at that message. A question pointing at it can leave the reader to find the command among a long run of earlier output. Such a command stays in the prompt, where the turn opens one, although the clickable-link bullet above moves a link out of one. The command needs no rendering, since the prompt shows it as plain text the reader can copy. **A command the user runs at this session's input line never goes in an interactive prompt.** On Claude Code such a command is a `!` line, typed at the session's input line so its output lands in the session. While an interactive prompt is open, the user cannot type at the session's input line. So a command placed in one sits in the one surface that blocks running it. It goes in a plain message instead, as a fenced block holding the `!` line itself, complete and ready to paste. Several commands join on that one line with `&&`, which runs them in order and stops at the first that fails. The block opens the message. Any question the same turn owes follows it as a numbered list, and any report comes after both. The message asks the user to reply once the command has run, and the turn ends with no interactive prompt open. The agent then checks the result on the user's next message. It reads back the state the command was meant to change, or the output it left in the session. An answer saying the command ran is not that check. -- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". +- **Ask when the user can cheaply confirm.** An assumption that saves one question and is wrong costs the rework plus the trust. So a genuine ambiguity in intent, scope, or authorization is raised, not resolved by picking the likelier reading. Rules that already answer the question (the committed instruction set) are not ambiguity, so read them first rather than asking what they state. +- **The irreversible step (merging, publishing, releasing, force-pushing, deleting, changing branch protection) stays the maintainer's.** **A grant given in a past session or for a different task authorizes nothing now.** Whether a credential's reach or a tool that happens to work authorizes anything is answered by `GOVERNANCE.md` "Repository Boundaries and Write Safety" rather than here. +- **Ask every question through the interface's prompt, never in prose.** When you need the user to decide, answer, or approve anything, put it to them through the interface's own prompt mechanism. Do so whether or not work is blocked on it. An offer to do more work ("want me to file that?") is a question like any other. A question written into a message is lost in the report around it, however short it is. One closing a long report sits where the reader is least likely to reach it. **Each question reads whole from its own text.** It states the problem, why it is being asked, and what each option does, in plain words. It may cite an issue or a pull request by number. The question and its options still read fully without opening it. A question leaning on an issue for its meaning is often answered without reading that issue, so the answer misses its point. Where no prompt mechanism is available, the questions go as a numbered list opening the message rather than closing it. The user can then reply per number. A turn asking for a command the user runs at this session's input line is an exception, per the command bullet above. It puts every question it owes in that message, since a prompt open beside the command would block the place it runs. This bullet settles how a question is put once it is asked. Whether a question is asked now or recorded for later is the parking bullet's to settle. That is the one opening "A question filed as an issue is parked rather than asked". - **Raise work blocked on the user as a direct interactive prompt.** When progress needs a decision, an authorization, or an answer only the user can give, ask for it at the point the work stops. Ask through the interface's own prompt mechanism. Never leave it as prose in a summary. A handoff buried in a paragraph is a handoff that did not happen. That is because a summary reads as a report of finished work. It is also because the one line still waiting on the user is the easiest in a summary to skim past. The blocked item is the message, not a closing remark on a message about something else. **The options offered are the actions themselves.** The one that unblocks the work names the action it authorizes ("squash and merge it"). Selecting it is then the go-ahead rather than a note to act on later. Offering only ways to wait is the same failure in interactive clothing. That is because a prompt whose every choice is inaction reports the block rather than clearing it. Where the agent may not perform the authorized action itself, the option says who does it. Where no interactive prompt is available, the numbered list the bullet above names is the fallback. In a turn asking for a command the user runs at this session's input line, the command bullet above replaces the interactive prompt. - **Lead every choice with a recommendation and its reason.** Wherever the user is asked to choose, in a prompt or in a numbered list, the option the agent recommends comes first. It is marked as the recommendation, and every option states the reason for it. A user who takes the recommendation then reads one line, and one who does not sees what the other options trade away. A question with no defensible recommendation says so rather than inventing one. Where an open question has no options and the agent does have an answer, that answer and its reason go in the question's text. They never go in as an invented option. - **A question filed as an issue is parked rather than asked, and it stays owed.** Where the work cannot continue without the answer, the interactive-prompt bullet governs and the question is asked at the point the work stops. Wherever the question is recorded rather than asked, recording it is the right thing to do, and recording it is still not asking it. That holds whether the work can continue without the answer or the question was asked once and deferred. So the issue carries the fleet's `decision` label. When the filing session knows the choices the question is between, the issue states them. The label and the stated choices are what let a later session, one that was not there when the issue was filed, find the question. That session can then put the question to the user without inventing its answers. **The parked queue is the failure, not the parking.** An issue holding a question the user has never seen reads to every later session as tracked work rather than as a block. So each session files correctly and moves on. Presenting the accumulation is the step nobody owns. @@ -383,7 +388,7 @@ python3 "$handoff" chain --repo OWNER/NAME --track "" --grep "an escaped python3 "$handoff" new --repo OWNER/NAME --track "" --title "" \ --body-file "" --dry-run python3 "$handoff" close --repo OWNER/NAME --track "" --body-file "" --dry-run -python3 "$handoff" tracks --repo OWNER/NAME [--json] +python3 "$handoff" tracks --repo OWNER/NAME # add --json for JSON output ``` Read `--dry-run` output before the first real `new` of a session, since the run replaces a body. It diff --git a/.github/skills/shell-codestyle/SKILL.md b/.github/skills/shell-codestyle/SKILL.md index b9fb0abe..4595fac9 100644 --- a/.github/skills/shell-codestyle/SKILL.md +++ b/.github/skills/shell-codestyle/SKILL.md @@ -2,7 +2,7 @@ name: shell-codestyle description: >- Governs Bash/shell script style for ptr727/ProjectTemplate fleet repos: when a bootstrap or - host-tool script may be shell instead of Python, the mandatory set -Eeuo pipefail header, the + host-tool script may be shell instead of Python, the mandatory set -Eeuo pipefail line, the pipefail-versus-early-reader pitfall, self-recursive command shims, self-locating scripts, the shellcheck-plus-shfmt clean-compile, the --help and unknown-argument rule, the SIGINT/SIGTERM rule, and the why-not-what comment rule. Use this whenever writing, reviewing, or editing a shell @@ -19,16 +19,15 @@ description: >- ## Why this exists This is the shell-specific half of the fleet's code style guide, kept in one place instead of -re-derived per repo or per session. Shell is the fleet's exception language, reached for only -where Python cannot run yet. So its rules exist to keep that narrow surface safe rather than to -cover general scripting style. +re-derived per repo or per session. Shell is the fleet's exception language, so its rules exist to +keep that narrow surface safe rather than to cover general scripting style. ## When shell, not Python -Bash, and only where a program cannot be Python: a bootstrap that installs the interpreter cannot -be written in it. Nor can a host tool that must run before a development toolchain exists depend on -Python. Everything else is Python, with a test under its own scripts tree's -`tests/` directory. +A bootstrap, a program that must run before the interpreter or a development toolchain exists, is +written in the platform's native shell. That is Bash on Linux and PowerShell on Windows. Logic that +needs its failure cases tested is Python, with a test under its own scripts tree's `tests/` +directory. The pattern is a platform-native entry point over shared Python logic. ## Rules @@ -38,14 +37,19 @@ Python. Everything else is Python, with a test under its own scripts tree's section, and the hub's `scripts/docker_lint.py` runs the same pair headless. Neither is scoped to the `*.sh` glob alone. A tracked, extension-less script whose shebang names bash or sh joins the target list too. That is the shape a script meant to run as a bare command takes. -- **`set -Eeuo pipefail`, before the first command the script runs.** A header comment sits above - it, as the hub's own `repo-config/configure.sh` and `host-setup/` scripts do. That works because - what matters is that nothing executes unguarded rather than which line number it lands on. +- **`set -Eeuo pipefail`, before the first command the script runs.** No header comment is + required, so the `set` line may follow the shebang directly. A comment above it is allowed + where it carries a specific non-obvious point. The no-summary rule in + `comment-and-doc-style` still forbids one restating what the script contains. What matters is + that nothing executes unguarded rather than which line number the `set` lands on. Without `-e` a failed command in the middle of a sequence lets the rest run against a state nobody checked. Without `pipefail` a pipeline reports the exit of its last stage. So a fetch that failed reads as an answer when a parser downstream succeeds on an empty input. `-E` carries an `ERR` trap into functions and command substitutions. So a script that later adds one is not - surprised by where it does not fire. + surprised by where it does not fire. A deliberately POSIX `#!/bin/sh` script, in practice a git + hook that must run before any toolchain exists, takes `set -eu` instead. The bash form + aborts such a hook wherever `/bin/sh` is a dash that predates its `pipefail` option, which + rejects `set -o pipefail`. Dash reads `-E` as its emacs editing option. - **A reader that stops early needs its producer read first.** Under `pipefail`, a producer writing to a closed pipe exits non-zero. So `curl ... | grep -q` reports a successful fetch as a failure whenever the match is found early enough. Capture the output, then search it. @@ -89,7 +93,8 @@ Python. Everything else is Python, with a test under its own scripts tree's A command-line script is one a person or an agent runs by name. A hook its host runs, taking its input from that host rather than from a command line, is not one. - **Every command-line script answers `--help` and `-h`** with the same text on stdout, then exits 0, changing nothing. That text opens on a usage line naming the script. An agent learns a script's interface by asking it, so a script that reads `--help` as an input acts in a way nobody predicted. A PowerShell script declaring its own parameters answers `-Help` and `-h` instead, from a `-Help` switch carrying an `h` alias. That form follows PowerShell's own parameter convention, so such a script owes no answer to a literal `--help`. A wrapper that forwards its arguments to another script answers whatever that script answers. -- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. Where no parameter takes the remaining arguments, the binder's refusal does that. A script with such a parameter refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **An argument the script does not recognize is refused**, with a non-zero exit before any read or write. The refusal names it as an unknown or unrecognized option, argument, flag, or parameter, and PowerShell's own refusal of a parameter it cannot bind counts. That refusal comes from the binder only in an advanced script, one carrying `[CmdletBinding()]` or a `[Parameter()]` attribute. Without either, a plain `param()` block binds an unknown parameter into `$args` and runs on. Such a script refuses a non-empty `$args` itself, before any work. So a PowerShell script declaring its own parameters refuses a literal `--help` like any other unrecognized argument. A script with a parameter taking the remaining arguments refuses a dash-prefixed leftover itself. An unrecognized first argument is never taken as a default mode or as a target. +- **A shell script that gives a refused argument an exit status of its own uses 64, `EX_USAGE` from `sysexits.h`, and reserves it.** A caller can then tell a refusal, which changed nothing, from a run that started and failed, without reading the message. Every refusal exits through one function that exits 64. Under `set -e` a failed command's own status becomes the script's, so an `EXIT` trap turns any other exit carrying 64 into 1. A program the script `exec`s replaces that trap. So the script `exec`s only a program whose own 64, if it exits 64 at all, means a refused argument. An argument the script passes on, which that program refuses, keeps the program's status. The script's `--help` names the status, so a caller reads it as a contract. @@ -97,13 +102,14 @@ A command-line script is one a person or an agent runs by name. A hook its host -This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. +This applies to every shell and Python script. `CODESTYLE.md` "Interrupts in Python" and "Interrupts in Shell" state each language's mechanics. -- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. +- **On SIGINT or SIGTERM, a script releases what it holds before it exits.** It removes the temporary paths it created, releases the locks it took, and stops the child processes it started. A path, lock, or child left behind can stop the next run from starting, or feed it a half-written input. A script started with SIGINT ignored keeps it ignored, so a stop meant to reach it sends SIGTERM. A non-interactive shell starts a background child that way. - **A write to persistent state goes to a temporary path beside the target, then is renamed over it.** An interrupt then leaves the old content or the new, never a mix of both. A store with transactions of its own, such as an SQLite database, is written through those instead. A rename over an open database can corrupt it. -- **An interrupted script prints one line naming the signal, with no traceback, and exits 130 for SIGINT or 143 for SIGTERM.** Each status is 128 plus the signal number, the status a shell reports for a process that signal ended. +- **An interrupted script prints one line naming the signal, with no traceback, and ends by re-raising the signal.** The signal then ends the process, so a shell reports 130 for SIGINT or 143 for SIGTERM, 128 plus the signal number. At Ctrl-C, a calling shell's loop then stops rather than starting its next iteration. A script calling `exit 130` has not died by the signal, so that loop reads an ordinary non-zero exit and runs on. A launcher between them, such as `uv run`, exits with the status rather than dying by the signal, so that loop runs on there too. - **A script takes this rule when it is created or next edited.** An existing script is not edited for this rule alone. -- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts the matching exit status and that nothing the script held remains. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that holds a lock, temporary state, or a child process owes a test that signals it mid-run.** The test sends SIGINT or SIGTERM, then asserts that the script died by that signal and that nothing it held remains. It starts the script with its interpreter directly, since a launcher such as `uv run` hides the signal death. It is skipped on Windows, which cannot deliver either signal for a script to handle. A script holding none of these owes no such test. +- **A script that ends by `exec`-ing its long-running process owes no interrupt handling for that process.** The `exec` replaces the script, so a signal reaches the process directly. A background child the script starts to outlive the `exec` is handed across it, and the script neither stops it nor waits for it. Such a child is handed across only where something else stops it, such as a container's teardown of its whole process tree. Anything else the script holds is released before the `exec`. A script that holds nothing else at any point before the `exec` owes no trap and no signal test. As PID 1, such as a container's entrypoint, it ignores a SIGTERM that arrives before the `exec`, so a stop waits for its timeout. @@ -111,8 +117,9 @@ This applies to every Bash and Python script. `CODESTYLE.md` "Interrupts in Pyth -- **Cleanup of temporary paths and locks runs in the script's `EXIT` trap.** Bash runs that trap when SIGINT or SIGTERM ends the script, as well as on a normal exit. -- **Every script sets an `INT` trap and a `TERM` trap, which stop its children and keep the status.** Each one sends SIGTERM with `kill` to the children the script started, then waits for them with `wait`. It then prints the line `CODESTYLE.md` "Interrupts" requires and exits 130 or 143. The children's process IDs are held in an array, such as `pids`, set to `()` before the traps are set. A trap skips the `kill` and the `wait` while `${#pids[@]}` is 0, a test `set -u` allows on an empty array in every Bash version. Under `set -u`, an unset one would end the trap before the line prints. The `kill` takes `2>/dev/null`, since a child that already exited makes it print an error. Both take `|| :`, since under `set -e` a non-zero status from either ends the trap before the line prints. SIGTERM is the signal sent because a background child ignores SIGINT. Other cleanup stays in the `EXIT` trap. -- **A long-running external command runs in the background, and the script waits for it with `wait "$pid"`, so its exit status reaches `set -e`.** Bash runs a trap only after a foreground command returns, while a trapped signal ends a `wait` at once. Only the script's own shell starts such a child. One that a subshell or a pipeline element starts never reaches the script's array or its `wait`. A background child that reads standard input takes `<&0`, since bash otherwise gives it `/dev/null`. The trap's `kill` reaches only the process `$!` names. So a function, a group, a subshell, a pipeline, or `sh -c` runs in the foreground instead. There the trap runs once the command it interrupted returns, so nothing the script started is orphaned. +- **Cleanup of temporary paths and locks runs in the script's `EXIT` trap, set before the `INT` and `TERM` traps.** Bash runs that trap when SIGINT or SIGTERM ends the script, as well as on a normal exit. Set after the `TERM` trap, it does not run when that trap's re-sent SIGTERM ends the script. +- **Every script sets an `INT` trap and a `TERM` trap, which stop its children and re-raise the signal.** Each one sends SIGTERM with `kill` to the children the script started, then waits for them with `wait`. It then prints the line `CODESTYLE.md` "Interrupts" requires. Last, it clears its own trap with `trap - INT` or `trap - TERM` and re-sends the signal to the script with `kill -s INT "$$"` or `kill -s TERM "$$"`. It ends with `exit 130` or `exit 143`, which runs only where the re-sent signal does not end the script, such as PID 1 in a container. The children's process IDs are held in an array, such as `pids`, set to `()` before the traps are set. A trap skips the children's `kill` and the `wait` while `${#pids[@]}` is 0, a test `set -u` allows on an empty array in every Bash version. Under `set -u`, an unset one would end the trap before the line prints. The children's `kill` takes `2>/dev/null`, since a child that already exited makes it print an error. Both take `|| :`, since under `set -e` a non-zero status from either ends the trap before the line prints. SIGTERM is the signal sent because a background child ignores SIGINT. Other cleanup stays in the `EXIT` trap. A script that the `exec` case in `CODESTYLE.md` "Interrupts" frees from owing a trap sets neither trap. +- **A long-running external command runs in the background, and the script waits for it with `wait "$pid"`, so its exit status reaches `set -e`.** Bash runs a trap only after a foreground command returns, while a trapped signal ends a `wait` at once. Only the script's own shell starts such a child. One that a subshell or a pipeline element starts never reaches the script's array or its `wait`. A background child that reads standard input takes `<&0`, since bash otherwise gives it `/dev/null`. The trap's `kill` reaches only the process `$!` names. So a function, a group, a subshell, a pipeline, or `sh -c` runs in the foreground instead. There the trap runs once the command it interrupted returns, so nothing the script started is orphaned. A launcher, such as `uvx`, `uv run`, `uv pip install`, `dotnet`, or `xargs`, may run in the foreground too. One that does not stop the tool it starts on SIGTERM must run in the foreground. `uv pip install` is one when it builds an editable install or an sdist through a build backend that outlives uv on SIGTERM. A background child starts with SIGINT ignored, and the tool a launcher starts inherits that. So at Ctrl-C the tool runs on until the trap's SIGTERM reaches it through the launcher. In the foreground, Ctrl-C reaches the whole process group, the tool included. A SIGTERM sent to the script alone runs its `TERM` trap only once that foreground command returns. So a stop that must be prompt signals the process group. That group holds only the script and its command where the script leads it, as `setsid` starts one. The `exec` case in `CODESTYLE.md` "Interrupts" is the exception. The process a script `exec`s into replaces it, and a child handed across that `exec` is not waited for. +- **A deliberately POSIX `#!/bin/sh` script, such as a git hook, adapts the bullets above to what dash lacks.** Dash runs no `EXIT` trap when the re-sent signal ends the script. So the `INT` and `TERM` traps release the temporary paths and locks themselves, and the `EXIT` trap still covers an ordinary exit. A `/bin/sh` that is bash runs the `EXIT` trap after the signal trap too. So a release that cannot run twice, such as a lock's, sets its variable back to `""`. POSIX sh has no arrays, so the script runs one background child at a time. It holds that child's process ID in a scalar, such as `child`, set to `""` again after its `wait`. Every variable a trap reads, `child` and each temporary path included, is set to `""` before the traps are set. Under `set -u`, an unset one would end the trap before the signal is re-sent. A trap skips the child's `kill` and `wait` while `[ -n "$child" ]` fails, and skips the removal of a path still empty. diff --git a/.github/skills/standup-a-repo/SKILL.md b/.github/skills/standup-a-repo/SKILL.md index 0bfa9e3e..323ec163 100644 --- a/.github/skills/standup-a-repo/SKILL.md +++ b/.github/skills/standup-a-repo/SKILL.md @@ -28,10 +28,11 @@ cold-start self-test. ## Before starting -Read STANDUP.md section 0A first. Nothing in this procedure creates the GitHub repository, its -App, or its secrets. Each is an outward-facing write that needs the maintainer's explicit permission -and inputs. So hand that checklist over before step 1 rather than discovering the gap partway -through. A repo with no remote is not partially stood up, it is not started, and only the +Read STANDUP.md section 0A first. Nothing in this procedure creates the GitHub repository or +installs its App. Each is an outward-facing write that needs the maintainer's explicit permission +and inputs. Only the maintainer can supply a repository-scoped secret's value file, which section +4 reads to set both secret stores. So hand that checklist over before step 1 rather than +discovering the gap partway through. A repo with no remote is not partially stood up, it is not started, and only the maintainer can supply what section 0A lists. ## Apply, in order @@ -42,14 +43,25 @@ maintainer can supply what section 0A lists. under the wrong identity or unsigned cannot be cleanly repaired afterward. 2. **Branches, before the first standup commit.** STANDUP.md section 0B: create `main` and - `develop` empty, off one signed empty root commit, then run every step below on a feature + `develop` empty, off one signed empty root commit. Then run each later target-repository step on a feature branch off `develop`. Never commit standup work directly onto `develop`. `non_fast_forward` on both branch payloads, or the missing blocking rule on an operational repo's `develop` ruleset, - makes that mistake either unrecoverable or silently unprotected. + makes that mistake either unrecoverable or silently unprotected. Point `origin` at the + repository once it exists. Push `main` and `develop` before step 6, since `scripts/carry.py` + needs `origin/develop`. The fleet's agent-safety kit refuses a commit, a push, and a + `git checkout -b` in the primary checkout a fresh `git init` makes. So in a session running + it, the branch block and the seed push are the maintainer's hand-over. Once the repository + exists, hand the maintainer section 0B's block through `git branch develop`. Read its + identity and signing output per step 1 before anything is pushed. Then hand over + `git remote add origin ""` and `git push -u origin main develop`. Wait for the push to + land. Then create the feature branch as a linked worktree with + `git worktree add -b "" "" develop`. Later work on the target repository runs there. Hub commands run from a clean hub checkout. 3. **Classify and catalog.** STANDUP.md section 1: resolve the repo's type(s) against `AUDIT.md` section 2, then write or repair its `registry/repos.json` entry and confirm it with - `spec/validate.py`. + `spec/validate.py`. The entry and its `SHORT_NAME_PINS` pin are hub edits, so they land + through a hub pull request into `develop`. Step 6 waits for it to merge, since `scripts/carry.py` + refuses a repository the fetched hub's registry does not hold. 4. **The instruction set, before authoring anything.** STANDUP.md section 1A. An existing repository that `docs/eol-lf-rollout.md` "Per-Repo Conversion" says needs a line-ending @@ -58,13 +70,13 @@ maintainer can supply what section 0A lists. audit finding naming paths `develop` is behind on calls for a re-level of `develop` before the conversion, per STANDUP.md section 1A. So does a hand comparison showing `main` content `develop` lacks, for a finding too large to classify or a path changed - on both branches. Then carry `CLAUDE.md`, + on both branches. Then carry `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, `WORKFLOW.md` and `AUDIT.md`, adapted rather than cloned for the ones that describe a repo, plus `.markdownlint-cli2.jsonc` and `cspell.json`. A downstream `AUDIT.md` is the short, repository-scoped form that says how the - repository reaches the hub for its audit and configuration check. `CLAUDE.md` is the fixed, verbatim `@AGENTS.md`-import file that gets - `AGENTS.md` into a Claude Code session's context at all. It is a separate baseline entry from - `AGENTS.md` itself, so carrying one without the other still leaves that provider unconfigured. + repository reaches the hub for its audit and configuration check. Write it from + `catalog/snippets/configs/AUDIT.md`, filling each placeholder `spec/files.json` declares for it. + No `CLAUDE.md` is carried, since Claude Code reads `AGENTS.md` itself. Read `CODESTYLE.md` and the `GOVERNANCE.md` documentation-style rules before writing any repo content of your own, the same window-closes shape as signing in step 1. @@ -87,16 +99,17 @@ maintainer can supply what section 0A lists. 8. **Settings, rulesets, and secrets.** STANDUP.md section 4: confirm the remote and the GitHub repository agree before running anything else here. Then run - `repo-config/configure.sh check owner/repo release` (substitute `operational` for an + `repo-config/configure.sh check "/" release` (substitute `operational` for an operational repo) from the hub at `main`. Use the hub at `develop` instead while the repo's registry entry has merged there but not yet reached `main`. A non-zero exit there means drift - was found, not a command failure. Review what it reports. Then run the same command's `apply` subcommand, never from a hand-built or carried copy. It + was found, not a command failure. Review what it reports. Where the repo is public, the first public-interaction limit follows `STANDUP.md` section 4's pilot-first rule. Then run the same command's `apply` subcommand, never from a hand-built or carried copy. It idempotently reconciles the repo to the full committed configuration regardless of what `check` reported. 9. **Verify with the audit.** STANDUP.md section 5: run `AUDIT.md` end to end. The repo is stood up only when it passes for its type, or a hub-committed `reports//audit.md` - plus an issue tracks its residual deltas. `` there is the repository name in lowercase. + plus an issue tracks its residual deltas. `AUDIT.md` section 8 defines `` there. + The report lands through a hub pull request of its own into `develop`. ## Onboarding a new repo type @@ -109,8 +122,9 @@ context-free agent, not just by the one that wrote it. ## Ship it -One pull request per standup, branched from `develop` per step 2 above, into `develop`, never a -direct push to a protected branch. While its instruction set is partial, a partly +One target-repository pull request per standup, beside the hub pull requests steps 3 and 9 name. +It is branched from `develop` per step 2 above, into `develop`, never a direct push to a +protected branch. While its instruction set is partial, a partly stood-up repository takes this same shape. That is any re-level and conversion pull requests, then one standup pull request. `RESYNC.md` section 6 applies once the set is whole. Close the review loop, per the `pr-review-conduct` skill, diff --git a/.github/skills/update-host/SKILL.md b/.github/skills/update-host/SKILL.md index a0ddfe9f..25b1055f 100644 --- a/.github/skills/update-host/SKILL.md +++ b/.github/skills/update-host/SKILL.md @@ -39,14 +39,14 @@ Each Windows command stops on a failed download, so a stale earlier copy of the ## What the Setup Does -1. Upgrades the coding-agent tools already installed, and adds none. +1. Upgrades the coding-agent tools already installed, and adds none. A failed upgrade does not stop the later steps. Once they finish, the setup names the tools as not current and exits non-zero. 2. Installs the fleet skills for Codex, opencode, and Claude Code, from a tree the bootstrap keeps. 3. Installs the Claude Code safety kit where Claude Code is present, and skips it with a line saying so where it is not. 4. Writes the host-wide rules to the global instruction file of each of Codex and opencode that is installed. A Codex `AGENTS.override.md` that is not blank takes precedence over that file, so the status reports it as SHADOWED and the setup warns. Neither touches the override. ## Report It -Report each step's status as the output states it, in the order above, and name every step the status run lists as not current. Then say plainly: +Report each step's status as the output states it, in the order above, and name every step the status run lists as not current. The status lists the agent tools without judging them, so also name each tool the setup run reported as failed or skipped, with its reason. Then say plainly: - Restart agent sessions to load the new hooks and rules. A running session keeps what it started with. - Codex and opencode get the rules but no hooks yet. No hook guards their sessions yet, so those sessions are not mechanically guarded. diff --git a/.github/skills/upstream-contribution-workflow/SKILL.md b/.github/skills/upstream-contribution-workflow/SKILL.md index 642a2bab..d222020d 100644 --- a/.github/skills/upstream-contribution-workflow/SKILL.md +++ b/.github/skills/upstream-contribution-workflow/SKILL.md @@ -2,16 +2,16 @@ name: upstream-contribution-workflow description: >- Governs how the maintainer contributes to a third-party repository he does not control, distinct - from the fleet's own branching model: a dirty work branch on his fork for the work and review - iteration, its fork-internal PR kept open and never merged, squashed once clean to a second branch - carrying only the intended history, that clean branch opened as the upstream PR, and reviewer - feedback applied to the dirty branch first, then re-squashed. Use this whenever about to open a + from the fleet's own branching model: a dirty work branch on his fork for the iteration, its + fork-internal PR kept open and never merged, squashed once clean to a second branch carrying only + the intended history, that clean branch opened as the upstream PR, and reviewer feedback applied + to the dirty branch first. Use this whenever about to open a pull request against a repository outside the ptr727 fleet, whenever forking a third-party project to contribute, whenever an upstream reviewer requests changes on a PR opened this way, whenever a fork-internal iteration PR looks ready to merge or close, whenever the upstream base branch moves - under a contribution in flight, and whenever choosing an issue or PR template for such a - repository. Triggers regardless of the target repo's own type or workflow model, whose conventions - this skill never assumes match the fleet's. + under a contribution, whenever an upstream's CI rejects merge commits or it forbids + rewriting a published PR, and whenever choosing such a repository's issue or PR template. + Triggers regardless of the target repo's type or workflow model, never assumed to match the fleet's. --- # Upstream Contribution Workflow @@ -56,10 +56,10 @@ fleet's internal model so the two are never conflated. required-check history a rewrite would orphan. That rule stays absolute there, with no exception. It has no jurisdiction here**. That is because this clean presentation branch lives on the maintainer's own fork, outside the fleet entirely, and carries nobody's work but this squash. Force-with-lease - is scoped just as tightly regardless. It applies only to this one branch, only on the maintainer's own fork, - and never to the dirty work branch. That branch is the append-only iteration log this whole workflow exists - to preserve. If force-with-lease is ever refused or unavailable, open a fresh PR from a newly - named clean branch rather than fighting the push. + is scoped just as tightly regardless. It applies only to this one branch, only on the maintainer's own fork. The dirty work branch takes it only in the one case "The iteration PR is never merged" below names. That branch is the append-only iteration log this whole workflow exists to preserve. **Each force-with-lease push still waits for the maintainer's explicit, current go-ahead.** Force-pushing is an irreversible step that stays his, per `GOVERNANCE.md` "Communicating with the User", and this skill decides only where one may happen. If the clean branch's force-with-lease push is refused or unavailable, open a fresh PR from a newly + named clean branch rather than fighting the push. A dirty-branch lease push that is refused or unavailable never takes this route. "The iteration PR is never merged" below says what it takes instead. + + **Where the upstream forbids rewriting a published pull request branch, keep the clean branch append-only instead.** Its contribution guidelines or its reviewers say so. Commit each round's change on top of the clean branch as a new commit, and push it without force. The squash then happens through the upstream's own squash merge, never as a rewrite of the published branch. Where the upstream does not squash on merge and wants one commit, stop and ask the maintainer for an approved route. On every other upstream, the re-squash above is unchanged. **The dirty branch is always the working copy. The clean branch is always the presentation copy.** Never reverse this: never iterate directly on the branch that's open against upstream, and never @@ -75,17 +75,49 @@ iteration PR is the place where upstream drift is absorbed and its fallout fixed upstream PR has to absorb that drift. So merging or closing the iteration PR removes that place. When the upstream base moves, sync the mirror branch from upstream and merge the mirror branch into -the dirty branch. In that case, also fix whatever breaks in the iteration PR. Bringing the mirror branch in is a merge rather than a rebase, -since the dirty branch is append-only and is never force-pushed. Then re-squash onto the new mirror -tip whenever the clean branch needs to follow, per step 5. +the dirty branch. In that case, also fix whatever breaks in the iteration PR. Bringing the mirror branch in is a merge rather than a rebase, since the dirty branch is append-only. A dirty branch stacked on another takes the lower branch's changes the same way. Then re-squash onto the new mirror tip whenever the clean branch needs to follow, per step 5. An append-only clean branch, per step 5, has no recorded way to follow a moved base. So stop and ask the maintainer before it follows one. Stop too before it takes a round from a dirty branch that has merged the moved mirror, since that round carries upstream's code. + +**Where the upstream's own CI rejects merge commits, rebase the dirty branch instead.** Such a check fails any pull request whose commits include a merge, and stops the rest of the upstream's checks from running. So a merge there costs the iteration PR the CI coverage it exists to provide. The rebase applies only in that case, and only to the dirty branch on the maintainer's own fork. Rebase it onto the mirror branch. On a stack, rebase the lower branch first. Then move the upper branch with `git rebase --onto "" "" ""`, its old head read from the lower branch's backup. Before each rebase, push the branch's old head to a named backup branch on the fork, and confirm the fork holds it. That backup keeps the replaced iteration log readable. A rebase also drops every merge commit, and with it any manual edit or conflict resolution the merge held. The chain below stops after the rebase where the old head carried one. Read each with `git show --remerge-diff ""` and reapply what it holds beyond the sync, or stop and ask the maintainer. Then run only the lease push. Otherwise push the rebased branch with `--force-with-lease`, pinned to that old head, under the go-ahead step 5 requires: + +```sh +old=$(git rev-parse --verify work/x) && bak=refs/heads/backup/work-x-1 && + git push origin "$old:$bak" && + { [ "$(git ls-remote origin "$bak" | cut -f1)" = "$old" ] || { echo "backup not confirmed: $bak" >&2; false; }; } && + git rebase "$mirror" work/x && + { merges=$(git rev-list --merges "$mirror..$old") && [ -z "$merges" ] || { echo "merge scan failed or the rebase dropped merge commits, read each with git show --remerge-diff" >&2; false; }; } && + git push --force-with-lease="work/x:$old" origin work/x +``` + +PowerShell equivalent: + +```powershell +if (-not $mirror) { throw 'set $mirror to the mirror branch first' } +$old = git rev-parse --verify work/x +if ($LASTEXITCODE -ne 0) { throw 'branch not found: work/x' } +$bak = 'refs/heads/backup/work-x-1' +git push origin "${old}:$bak" +if ($LASTEXITCODE -ne 0) { throw "backup push failed: $bak" } +if ("$(git ls-remote origin $bak)".Split("`t")[0] -ne $old) { throw "backup not confirmed: $bak" } +git rebase $mirror work/x +if ($LASTEXITCODE -ne 0) { throw 'rebase stopped, resolve it before pushing' } +$merges = git rev-list --merges "$mirror..$old" +if ($LASTEXITCODE -ne 0) { throw 'merge scan failed, so the check did not run' } +if ($merges) { throw 'the rebase dropped merge commits, read each with git show --remerge-diff' } +git push --force-with-lease="work/x:$old" origin work/x +if ($LASTEXITCODE -ne 0) { throw 'lease push refused: work/x' } +``` + +Set `mirror` to the mirror branch's name first. Number the backup branch per rebase, raising the suffix each time, so a later rebase never overwrites an earlier backup. Stop where the confirmation fails, since the force-push would then leave the old head on no remote branch. Where the rebase stops on a conflict, resolve it and run `git rebase --continue`. Then read the old head back from the backup branch with `git ls-remote origin ""`. The merge check did not run in that case, so run `git rev-list --merges "$mirror.."` with that value. A scan that exits non-zero checked nothing, so fix its cause and rerun it before anything else. Read any merge it names, as above. Where the merge check stops the chain instead, first fix a failed scan's cause and rerun it. Then read and reapply any merge it names. Run only the lease push, pinned to the old head. + +A lease push that fails, or that the fork does not allow, stops the chain. Re-fetch with `git fetch origin`. A fetch that fails leaves `origin/work/x` stale, so stop and report that rather than comparing against it. Then list the fork's branch against the old head with `git log --oneline --left-right "...origin/work/x"`. Read the old head back from the backup branch as above. A `>` entry is a commit the fork gained that the rebase never saw, so the fork moved under you. `<` entries alone are old-head commits the fork's branch lacks now, such as ones never pushed or ones a reset dropped. An empty list means the push failed for another reason, such as a fork refusing force pushes or a failed connection. Whatever the list shows, stop and ask the maintainer, showing it. Never push the branch again in the meantime. A repeat of the pinned push is refused again. An unpinned `--force-with-lease` after that fetch, or a bare `--force`, overwrites whatever the fork gained. Never open a fresh pull request from a new dirty branch either, since that drops the iteration log this workflow keeps. The rebased local branch and the backup branch both stay as they are until he answers. For example, the fork's mirror branch and upstream both sit at commit `A`, with the iteration PR from `work/x` into the mirror branch green. Upstream advances to `B`. The fork syncs its mirror branch to `B`, merges `B` into `work/x`, and fixes the breakage in the iteration PR. Had `work/x` been merged into the mirror branch at `A`, the mirror branch could not have fast-forwarded to `B`. -The contribution ends when upstream merges or declines the upstream PR. Only then close the -iteration PR, unmerged, and delete the dirty and clean branches. A merged change then reaches the +The contribution ends once the PR of every clean branch the dirty branch feeds is merged or +closed, with no slice left to cut. Only then close the iteration PR, unmerged, and delete the dirty and clean branches. Leave each backup branch for the maintainer to delete. A merged change then reaches the mirror branch through the next sync from upstream, the same way anyone else's change does. ## Use the upstream repo's own conventions, not the fleet's diff --git a/.github/skills/workflow-ci-contract/SKILL.md b/.github/skills/workflow-ci-contract/SKILL.md index 40a9d597..2875f29d 100644 --- a/.github/skills/workflow-ci-contract/SKILL.md +++ b/.github/skills/workflow-ci-contract/SKILL.md @@ -42,6 +42,6 @@ A workflow-only change is not smoke-built, and actionlint still runs on it in CI **actionlint discovers `.github/workflows/` recursively, both extensions, and opens no action file on its own.** It reaches a local action's `action.yml` only through a workflow's `uses: ./`, wherever in the tree that path leads. It reports everything it finds there against the calling workflow. That covers the caller's `with:` block against the action's declared inputs and the caller's `steps..outputs.` against its declared outputs. It covers the action's own `name`, top-level `description` and `runs.using` too. A missing per-input `description` and an unexpected top-level key are the metadata it does not reach that way. Pointing it at an action file directly makes it parse the file as a workflow and report several syntax-check errors. Widening its file list is therefore not available. **Where no workflow in the repository names the action, actionlint reaches it not at all**. That is the ordinary shape for a repository whose hooks are invoked from a hub reusable workflow rather than from a workflow of its own. -**A schema check covers the action file itself.** It is `check-jsonschema`'s `vendor.github-actions` builtin, run by the repo gate's `composite-actions` check as `uvx check-jsonschema@latest --builtin-schema vendor.github-actions -- `. It reads every tracked `action.yml` and `action.yaml` under `.github/actions/`, whether or not a workflow references it. It reaches the structure and the keys rather than the caller's contract. The schema and actionlint disagree on some keys. The schema accepts `runs.using: node16`, which actionlint rejects as an invalid runner. A green schema run therefore says nothing about what GitHub currently accepts. An action file outside `.github/actions/` keeps actionlint's caller check and gets no schema check at all. +**A schema check covers the action file itself.** It is `check-jsonschema`'s `vendor.github-actions` builtin, run by the repo gate's `composite-actions` check as `uvx check-jsonschema@latest --builtin-schema vendor.github-actions -- ""`, with every tracked action file passed as its own argument. It reads every tracked `action.yml` and `action.yaml` under `.github/actions/`, whether or not a workflow references it. It reaches the structure and the keys rather than the caller's contract. The schema and actionlint disagree on some keys. The schema accepts `runs.using: node16`, which actionlint rejects as an invalid runner. A green schema run therefore says nothing about what GitHub currently accepts. An action file outside `.github/actions/` keeps actionlint's caller check and gets no schema check at all. **Neither of those reads a composite action's `run:` bodies or its `if:` expressions.** Measured on a referenced action with a malformed `if:` and an unterminated shell `if` in a `run:` block, both pass it. The `composite-actions` check therefore also runs shellcheck over each bash or sh `run:` body. It replaces every `${{ }}` expression with a placeholder first. A broken `if:` expression still surfaces only when a run executes it. diff --git a/.github/skills/workflow-ci-contract/references/architecture.md b/.github/skills/workflow-ci-contract/references/architecture.md index d3575a60..07d73c83 100644 --- a/.github/skills/workflow-ci-contract/references/architecture.md +++ b/.github/skills/workflow-ci-contract/references/architecture.md @@ -22,13 +22,13 @@ flowchart LR ```mermaid flowchart LR edit[direct signed commit] -->|advisory CI| develop - pr[pull request] -->|lint CI, reported not required| develop - develop -->|merge commit, enforced lint CI| main + pr[pull request] -->|validation CI, reported not required| develop + develop -->|merge commit, enforced validation CI| main ``` The direct commit is an **allowance, not a substitute for review**. The ruleset drops the pull-request *requirement*, which permits a direct push without withdrawing the pull request. So a change worth reviewing still takes one, and both paths reach `develop` legally. Which changes those are is stated as a shape rather than a line count in `GOVERNANCE.md` "Operational Repositories". That section owns the test and is the one place it is written, since nothing in a ruleset can apply it. What differs is when validation lands. On the direct-commit path the commit is already on the branch, so CI can only be advisory after the fact. That is the accepted cost of the model. On the pull-request path the change has not landed, so validation is pre-merge and actionable, the moment it is worth the most. The lint workflow's `pull_request` trigger therefore filters no base branch (`WORKFLOW.md` section 6). That is what makes **D1.2** hold here, since its input is *any* PR and the operational model is no exception. The check is reported on a `develop` PR rather than required. That is because a required status check on `develop` binds the direct push too, and would dissolve the allowance the model is built on. -Their CI is lint/validation only: editorconfig/EOL plus domain linters such as Home Assistant or ESPHome config validation or a firmware build, but **no unit tests**. So the D-guarantees in `WORKFLOW.md` section 4 that assume a build/test pipeline are **N/A** exactly as for `source-only` (`WORKFLOW.md` section 6). What binds is the promotion gate and the source-only release on manual dispatch (`releaseTrigger: dispatch-only`, tag + source zip). At the promotion gate, the `develop -> main` PR must pass the required `Check pull request workflow status job`. Branch-model rulesets are specified in `GOVERNANCE.md` "Branching Model" rather than in `WORKFLOW.md`. +Their CI is lint/validation: editorconfig/EOL plus domain linters such as Home Assistant or ESPHome config validation or a firmware build. It runs **no unit tests** unless the repo carries a .NET test project or a Python suite the validator runs. Tests that its own validate hook or a replacement validator runs count too. A suite in a directory the validate call names in `python-directories` is one it runs. The declaration decides what the validator gates, per D1.2. With no tests for a type, the build/test D-guarantees in `WORKFLOW.md` section 4 are **N/A** for it, as for `source-only` (`WORKFLOW.md` section 6). Where it has tests, the `csharp` or `python` guarantees they bring apply as in any other repo, D1.6 included. That holds whether or not it declares `python-directories`. What binds either way is the promotion gate and the source-only release on manual dispatch (`releaseTrigger: dispatch-only`, tag + source zip). At the promotion gate, the `develop -> main` PR must pass the required `Check pull request workflow status job`. Branch-model rulesets are specified in `GOVERNANCE.md` "Branching Model" rather than in `WORKFLOW.md`. ### Two Layers: Orchestration vs Build @@ -86,7 +86,7 @@ flowchart TD ### Release Model -Each publish builds a **single branch**, the trigger ref (`main` a release, `develop` a prerelease). So there is no branch matrix, and `github.ref` always names the built branch. A **human merge never auto-publishes**. A `plan` job (`publish-plan-task.yml`) decides once, and a job downstream of it either gates on its outputs or inherits the skip through `needs:`. A run publishes on a **code-affecting bot push to `main`**. The App merges every Dependabot/codegen PR, so `github.actor` gates that push. The publisher's own `on.push.paths` list also drops a non-substantive change like an Actions bump. A run also publishes on a **manual dispatch** of `main`/`develop`, or on a **main-only weekly schedule** (Docker, to refresh the base image). The `push` is main-only, so a develop bot merge publishes nothing (its prerelease comes via dispatch). A **source-only** repo publishes on **dispatch only**. Every release is a tag on the built commit plus a source archive, README, and LICENSE. Targets amend it with `release-asset-*` files. A registry push contributes none, and is made by the Docker leaf for an image and by the separate `publish-` job for a package. An unchanged version cuts no second release on a schedule or push trigger, while a dispatch refreshes it (D4.4). Docker re-pushes by design. +Each publish builds a **single branch**, the trigger ref (`main` a release, `develop` a prerelease). So there is no branch matrix, and `github.ref` always names the built branch. A **human merge never auto-publishes**. A `plan` job (`publish-plan-task.yml`) decides once, and a job downstream of it either gates on its outputs or inherits the skip through `needs:`. A run publishes on a **code-affecting bot push to `main`**. The App merges every Dependabot/codegen PR, so `github.actor` gates that push. The publisher's own `on.push.paths` list also drops a non-substantive change like an Actions bump. A run also publishes on a **manual dispatch** of `main`/`develop`, or on a **main-only weekly schedule** (Docker, to refresh the base image). The `push` is main-only, so a develop bot merge publishes nothing (its prerelease comes via dispatch). A **source-only** repo publishes on **dispatch only**. **Every repository whose registry `status` is `cataloged` releases**, whatever its types. Every release is a tag on the built commit plus a source archive, README, and LICENSE. Targets amend it with `release-asset-*` files. A registry push contributes none, and is made by the Docker leaf for an image and by the separate `publish-` job for a package. An unchanged version cuts no second release on a schedule or push trigger, while a dispatch refreshes it (D4.4). Docker re-pushes by design. ```mermaid flowchart TD diff --git a/.github/skills/workflow-ci-contract/references/d-guarantees.md b/.github/skills/workflow-ci-contract/references/d-guarantees.md index ee54e96f..39c9ae60 100644 --- a/.github/skills/workflow-ci-contract/references/d-guarantees.md +++ b/.github/skills/workflow-ci-contract/references/d-guarantees.md @@ -68,7 +68,7 @@ The required behaviors, organized by domain. Each is a **MUST**, and its `Output ### D8 - Bots / Automation -- **D8.1 Merge-bot.** Output: the merge-bot enables auto-merge on `opened`/`reopened` for **every** Dependabot tier including semver-major. The required checks are the gate, not the bump magnitude. The merge-bot dispatches `--squash`/`--merge` by the PR's base ref, and disables on a maintainer-pushed `synchronize`. Its concurrency is keyed on the **PR number**, not `github.ref`. On `closed` it deletes a merged in-repo bot head when the caller opts in. The push leases the branch tip to the merged head, so a moved branch survives. *Prevents: two PRs colliding in auto-merge.* +- **D8.1 Merge-bot.** Output: the merge-bot enables auto-merge on `opened`/`reopened` for **every** Dependabot tier including semver-major. The required checks are the gate, not the bump magnitude. The merge-bot dispatches `--squash`/`--merge` by the PR's base ref, and disables on a maintainer-pushed `synchronize`. GitHub can disable an armed auto-merge with every check green, as for a merge that would write workflow content the App may not write. So the caller also triggers on `auto_merge_disabled`. A short job then answers a disable recorded under the App on a pull request the merge-bot arms. It waits for the base branch to settle, for at most five minutes, then re-arms once, pinned to the head it read. Where every check is already green, `gh` merges at once rather than arming, so a refused merge fails that job. That is visibility, not recovery. A second such disable on the same head fails the job too. A disable a person made stays in place. So does the maintainer-push disable, since the head is then not the bot's own push. So unless a person pushed to it or disabled its auto-merge, a pull request the merge-bot armed either merges or fails visibly. Its concurrency is keyed on the **PR number**, not `github.ref`. On `closed` it deletes a merged in-repo bot head when the caller opts in. The push leases the branch tip to the merged head, so a moved branch survives. *Prevents: two PRs colliding in auto-merge, and a bot pull request sitting open and green after GitHub disabled its auto-merge.* - **D8.2 CodeGen and Dependabot.** Output: codegen runs as a matrix over both branches and is deterministic from an external source. `.github/dependabot.yml` targets both branches, and security PRs go to the default branch. - **D8.3 Upstream-version tracker.** Output: a scheduled resolver prints a JSON `name -> version` object to a committed state file. It opens a rolling per-branch bump PR naming only the moved keys, and the merge-bot auto-merges it. The `main` pin push the merge-bot makes publishes via the release gate, while a `develop` pin does not auto-publish. It ships via a `develop` dispatch (prerelease) or the next promotion to `main`. The tracker's `bump-branch-prefix` + `branches` MUST match a merge-bot rule, or auto-merge silently never fires. That rule is one of the built-in `-` head/base pairs or a `rules` entry the caller passes. A tracker whose bump needs a human decision instead sets `auto-merge: false`, which prefixes the head so no merge-bot rule matches it, whatever `bump-branch-prefix` names. A `main` pin it carries then lands by a human merge, which never auto-publishes (D4.1), so it ships on the next publish. - **D8.4 An identity allowlist used as a gate fails loud.** Where a gate compares `github.actor` (or a PR author) against hard-coded bot identities, the non-matching branch **emits a `::warning::`** on an otherwise-legitimate trigger. There it does not fall through silently. Output: a run that declines to act on an unrecognized identity is visibly annotated. *Prevents: the App being renamed, replaced, or reinstalled under a new slug, after which the comparison quietly evaluates false and the gate stops firing. The result is a green and silent run that looks identical to a healthy one.* The masking matters most where a second path hides the loss. One such path is a weekly schedule that keeps publishing, so the only symptom is release *timeliness*, easily missed for months. Where the failure is self-announcing instead (the merge-bot simply stops merging, so bot PRs visibly pile up) an annotation is optional. The delete job compares the same `user.login` as the merge jobs, so a renamed App already shows as piled-up bot PRs. Resolving the identity at run time (mint an App token, read `GET /app`) removes the hard-coded string entirely. Run-time resolution is the escalation if an allowlist proves fragile in practice. diff --git a/.github/skills/workflow-ci-contract/references/test-methodology.md b/.github/skills/workflow-ci-contract/references/test-methodology.md index 804d8412..d5140ce9 100644 --- a/.github/skills/workflow-ci-contract/references/test-methodology.md +++ b/.github/skills/workflow-ci-contract/references/test-methodology.md @@ -18,7 +18,7 @@ Cite what each verdict rests on. That is `file:line` for a file in the audited r ### 5B. End-to-End Trace Scenarios (No Execution, Deterministic from the YAML) -For each *applicable* scenario, evaluate every job's `if:`/`needs:` against the inputs. Emit the predicted **run/skip + version + release + artifact-end-state** table, then compare to the expected. A scenario governing a construct the repo does not contain is N/A, per `WORKFLOW.md` section 1, and an absent trigger is such a construct. Each scenario's trigger belongs to one workflow, so read that workflow's own `on:` block rather than the repo's type. For S1 to S4 the block is the pull request workflow's, and for S5 to S10 and S14 the publisher's. For S11 the block is the upstream tracker's, and for S12 and S13 the deploy workflow's. A publisher carrying only `workflow_dispatch` therefore records S5, S6 and S9 N/A, their push and schedule paths never firing there. A repo with no publisher at all records S5 to S10 and S14 N/A together. A publisher whose schedule never publishes, per D4.1, records the schedule paths of S7 and S9 N/A as well. Where a scenario's path runs through a workflow or composite action the repo only **calls**, trace that callee as the repo reaches it. Read it at the SHA the caller pins rather than at the callee's current default branch, which is the same evidence rule 5A states. Predicting from the callee's `main` predicts a table for YAML the audited repo never runs. A self-repository (`$/`) call or a job-level local (`./`) reusable-workflow call carries no pin of its own. It resolves at the calling workflow file's commit, so it is traced at that file's own commit. That commit is the SHA fixed by the pin that reached that file. Where that file is one of the audited repository's own workflows, it is the audited commit instead. A local (`./`) action reference carries no pin either, but it resolves against whatever the job checked out. So it is traced at that checkout's commit. That is the caller's commit where a reusable workflow called from another repository checks out its caller. Minimum set: +For each *applicable* scenario, evaluate every job's `if:`/`needs:` against the inputs. Emit the predicted **run/skip + version + release + artifact-end-state** table, then compare to the expected. A scenario governing a construct the repo does not contain is N/A, per `WORKFLOW.md` section 1, and an absent trigger is such a construct. Each scenario's trigger belongs to one workflow, so read that workflow's own `on:` block rather than the repo's type. For S1 to S4 the block is the pull request workflow's, and for S5 to S10 and S14 the publisher's. For S11 the block is the upstream tracker's, and for S12 and S13 the deploy workflow's. A publisher carrying only `workflow_dispatch` therefore records S5, S6 and S9 N/A, their push and schedule paths never firing there. A repo with no publisher lacks a construct every repo owes. So S7, S8, S10 and S14 fail there, and none is excluded from the verdict. S5, S6 and S9 turn on the `on:` block that publisher has yet to state, so each is judged once it lands. A publisher whose schedule never publishes, per D4.1, records the schedule paths of S7 and S9 N/A as well. Where a scenario's path runs through a workflow or composite action the repo only **calls**, trace that callee as the repo reaches it. Read it at the SHA the caller pins rather than at the callee's current default branch, which is the same evidence rule 5A states. Predicting from the callee's `main` predicts a table for YAML the audited repo never runs. A self-repository (`$/`) call or a job-level local (`./`) reusable-workflow call carries no pin of its own. It resolves at the calling workflow file's commit, so it is traced at that file's own commit. That commit is the SHA fixed by the pin that reached that file. Where that file is one of the audited repository's own workflows, it is the audited commit instead. A local (`./`) action reference carries no pin either, but it resolves against whatever the job checked out. So it is traced at that checkout's commit. That is the caller's commit where a reusable workflow called from another repository checks out its caller. Minimum set: | # | Input | Expected output | Exercises | | --- | --- | --- | --- | From 63558fe4f349e0de91ebf75cce0b1c0f70346a8d Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 25 Nov 2026 19:31:24 -0800 Subject: [PATCH 3/5] Bring the Copilot Runbook and Docs Under the Carried Rules The refreshed rules allow a Co-Authored-By line and ban a session link, so the Copilot runbook takes the hub's commit-message and coverage text, keeping this repo's Disproved Claims ledger. OPERATIONS.md "Local Verification" names the .NET half of the whole suite a push owes. And every copy-and-run command quotes its placeholders, per "Copy-and-Run Commands". Co-Authored-By: Claude Opus 5.5 --- .github/copilot-instructions.md | 4 ++-- Docs/ClosedCaptions.md | 2 +- HISTORY.md | 2 +- OPERATIONS.md | 4 ++-- README.md | 4 ++-- RegressionTests/README.md | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 353b4794..8e153790 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -8,7 +8,7 @@ Do not duplicate rules from `AGENTS.md`, `GOVERNANCE.md`, `CODESTYLE.md`, or `WO ## Commit Messages and Pull Request Titles -Use an imperative subject of at most 72 characters with no trailing period. Use US English and title case with lowercase short bind words. Do not add `Co-Authored-By:` unless requested. Do not put a release-bump magnitude in the title. The full contract is in [GOVERNANCE.md "Pull Request Title and Commit Message Conventions"](../GOVERNANCE.md#pull-request-title-and-commit-message-conventions). +Use an imperative subject of at most 72 characters with no trailing period. The limit measures the authored title, and the `(#N)` suffix a squash merge appends sits outside it. Use US English and title case, lowercasing only the short bind words `.github/skills/comment-and-doc-style/SKILL.md` lists, a list that is exhaustive. A `Co-Authored-By:` line is allowed unless the user disallows it or the repository's rules say otherwise. Never include a link to the agent's session, such as a `Claude-Session:` trailer, which nothing overrides. Do not put a release-bump magnitude in the title. The full contract is in [GOVERNANCE.md "Pull Request Title and Commit Message Conventions"](../GOVERNANCE.md#pull-request-title-and-commit-message-conventions). ## Reviewing Carried Fleet Content @@ -27,7 +27,7 @@ For every review: The review automation is `scripts/pr_review.py`, run from a hub checkout. Use its `status`, `wait`, `attest`, `comment`, and `reply --resolve` commands instead of reconstructing GraphQL queries or copying review identifiers by hand. Use `comment` for a suppressed-finding answer in the pull request conversation. Its status gate verifies the current head, diff coverage, output shape, inline threads, body-only findings, and required checks. -A formal review with no findings is complete only when it covers the current head. It also needs full diff coverage of the change set that head has, stated or read from a file table as below. A round covering the head states it. Where none does, a round covering the head whose own file table names exactly the changed files covers it. That is the reading a round at Balanced review effort gives. Where no round covering the head carries its own table, the newest round that does stands in where its table names exactly the changed files. Either table may leave out an added, modified, renamed, or deleted file with no changed line, such as a binary. That holds while some changed file has one. A table stands in only where no Copilot round on the pull request, on any commit, states partial coverage. So a pull request that ever had a partial round goes to the maintainer. A round reporting partial coverage of the diff blocks the merge, and so does a refusal. So does a head that no coverage statement, file table, or attested local pass covers. So does an output shape the digest notes and nobody has read by hand, an unresolved thread, or a body-only finding. The `pr-review-conduct` Skill's Merge Gate states the promotion cases outside these. Where the review policy hands the head to a local pass, an attested local pass covers it, `coverage=local` in the digest. By default that is a pull request into a branch other than the default. A partial round, a truncated review history, or a refusal on the head still blocks that reading. A refusal saying every changed file is in Copilot's default review exclusions is the exception. So is a policy that waits on no Copilot round, Copilot being off, ungated, or past its cap. There none of them blocks the reading, since no round is coming to settle them. Under the hub's default review policy, a pull request into the default branch, a promotion among them, always carries a Copilot round on its head. A repository's own `.github/agent-policy.json` can move or cap that round, and the digest reports what it decided. Re-run the loop after every fix push. Never infer review completion from `mergeStateStatus: CLEAN`. +[GOVERNANCE.md "PR Review Etiquette"](../GOVERNANCE.md#pr-review-etiquette) states when a review covers the current head and its full diff, and when to re-run the loop. A round reporting partial coverage of the diff blocks the merge, and so does a refusal. So does a head that no coverage statement, file table, or attested local pass covers. The `pr-review-conduct` Skill's Merge Gate states every case that blocks the merge, and the exceptions to the cases named here. Review effort is user-controlled. The automation observes `Lite`, `Balanced`, or `Max`, including an inherited `Default ()`, and never selects or changes the setting. Effort does not determine coverage or completion. A request can complete without a `copilot_work_started` event, so absence of that event is not a stalled-review verdict. When `wait` returns `PENDING` with `requested=yes`, report the state and rerun `wait` for another bounded interval by default. Read that field as acceptance of the request rather than as delivery of a round. Do not clear the request on that first timeout, because it may still be active. Where a second bounded wait times out as well, read the pending set. In that case, clear it only where no human or team reviewer is requested alongside the bot, and rerun `wait`. That rerun then has nothing outstanding to defer to and requests afresh. Where it finds no reviewer node id to request with, it polls instead and says so on its own auto-request line. The clear replaces that set rather than adding to it, and nothing restores a request it drops. So a stall on a pull request that has a human or team reviewer requested goes to the maintainer. So does one still pending after the wait that follows a clear. That clear is a recovery step the script does not implement, and `docs/pr-reviewer-reference.md`, in the hub checkout the script is run from, carries it. This recovery replaces only the review request and never changes the effort setting. A `wait` ending `REQUEST_NOT_RECORDED`, exit 40, is a different state and takes none of this recovery. The request returned success and left neither a pending reviewer nor a review-request event. That is how an exhausted Copilot allowance has shown itself. So clearing and requesting again does not clear this state, and it goes to the maintainer. diff --git a/Docs/ClosedCaptions.md b/Docs/ClosedCaptions.md index b05d007d..379604d1 100644 --- a/Docs/ClosedCaptions.md +++ b/Docs/ClosedCaptions.md @@ -178,7 +178,7 @@ FFmpeg [`filter_units` filter](https://ffmpeg.org/ffmpeg-bitstream-filters.html# E.g. ```shell -ffmpeg -loglevel error -i [in-filename] -c copy -map 0 -bsf:v filter_units=remove_types=6 [out-filename] +ffmpeg -loglevel error -i "" -c copy -map 0 -bsf:v filter_units=remove_types=6 "" ``` Closed captions SEI unit for H264 is `6`, `39` for H265, and `178` for MPEG2. diff --git a/HISTORY.md b/HISTORY.md index fa3b9a67..abd4cb07 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -64,7 +64,7 @@ Utility to optimize media files for Direct Play in Plex, Emby, Jellyfin, etc. - Instruments include the run file total and input byte total, in-flight and active-thread counts, the `work.total`/`work.completed` byte gauges and the `progress.ratio` and `eta.seconds` derived from them, cumulative per-outcome counters (completed, modified, errors, verify-failed, and a per-`State`-flag tally), and the `file.duration` and per-tool `tool.duration` histograms. Metrics are aggregate only, with bounded `state` and `tool` tags and no filename tags. - The run-scoped gauges reset at the start of every processing pass, so monitor mode and back-to-back commands each report their own run, while the counters stay cumulative for rate display. - Instruments are inert until a listener observes them, so the feature is always on with no configuration flag and negligible idle overhead. - - The meter is OpenTelemetry and `dotnet-monitor` compatible, and the Docker image ships a `counters` wrapper, so reading the metrics is `docker exec counters`. + - The meter is OpenTelemetry and `dotnet-monitor` compatible, and the Docker image ships a `counters` wrapper, so reading the metrics is `docker exec "" counters`. - Version 3.21: - Repair non-monotonic DTS muxer warnings losslessly instead of failing repair permanently. - `ffmpeg -f null` can exit `0` yet emit `Application provided invalid, non monotonically increasing dts to muxer` for files that may decode and play correctly. diff --git a/OPERATIONS.md b/OPERATIONS.md index 12b09882..108f7c1d 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -6,7 +6,7 @@ How this repository is run. PlexCleaner is a code repository, so its operations What verifying a change here requires, including the part CI cannot perform. -The clean-compile is the `.NET Format` VS Code task, chaining `CSharpier Format` -> `.NET Build` -> `dotnet format style --verify-no-changes --severity=info`, and it must pass before a commit, per [CODESTYLE.md](./CODESTYLE.md). CI runs the same checks plus the rest of the hub validator's gate, including unit tests with coverage, markdownlint, cspell, actionlint, editorconfig-checker, shellcheck, and shfmt. It also runs ruff, mypy, and the `unittest` suite over `RegressionTests/`, plus the prose and repo gates. `Lint: All (CI parity)` in [.vscode/tasks.json](./.vscode/tasks.json) runs the lint half locally except shellcheck, shfmt, and the prose and repo gates, and `Python Test` runs the `RegressionTests/` suite. A change to a shell script or to prose therefore owes those checks by hand, per the `shell-codestyle` and `comment-and-doc-style` Skills. A green clean-compile does not predict a green CI, so run the parity task before pushing a change that touches anything beyond `.cs` files. +The clean-compile is the `.NET Format` VS Code task, chaining `CSharpier Format` -> `.NET Build` -> `dotnet format style --verify-no-changes --severity=info`, and it must pass before a commit, per [CODESTYLE.md](./CODESTYLE.md). CI runs the same checks plus the rest of the hub validator's gate, including unit tests with coverage, markdownlint, cspell, actionlint, editorconfig-checker, shellcheck, and shfmt. It also runs ruff, mypy, and the `unittest` suite over `RegressionTests/`, plus the prose and repo gates. `Lint: All (CI parity)` in [.vscode/tasks.json](./.vscode/tasks.json) runs the lint half locally except shellcheck, shfmt, and the prose and repo gates, and `Python Test` runs the `RegressionTests/` suite. The whole suite a push owes is that task plus `dotnet test --project PlexCleanerTests/PlexCleanerTests.csproj` from the repository root. A change to a shell script or to prose therefore owes those checks by hand, per the `shell-codestyle` and `comment-and-doc-style` Skills. A green clean-compile does not predict a green CI, so run the parity task before pushing a change that touches anything beyond `.cs` files. The part CI structurally cannot exercise is media processing. The unit tests need no media files and run everywhere, but the behavior of the tool depends on the media it processes and on the external tools (FFmpeg, HandBrake, MkvToolNix, MediaInfo, 7-Zip) it drives, and a pull request runner has neither a media collection nor a reason to trust one. So a change to processing, sidecar, media-tool, or language-tag code is verified locally against real media, by the Docker test script and by the regression harness described under Runbooks, before it is called done. Read [ARCHITECTURE.md](./ARCHITECTURE.md) before changing that code. @@ -128,7 +128,7 @@ The repository is the record, and GitHub holds it. Nothing here keeps state outs ## Logs and Debugging -Workflow runs are the log for CI and publishing. `gh run list --branch [branch]` and `gh run view [id] --log-failed` reach them, and a local gate reproduces a CI lint failure exactly, so reproduce locally before reading workflow logs. +Workflow runs are the log for CI and publishing. `gh run list --branch ""` and `gh run view "" --log-failed` reach them, and a local gate reproduces a CI lint failure exactly, so reproduce locally before reading workflow logs. Application logging is Serilog, to the console and, with `--logfile`, to a file, and `--loglevel` sets the minimum level (`Debug` logs every media-tool invocation with its arguments, so a processing decision is traceable to the tool call that drove it). The sidecar file beside each media file (`filename.PlexCleaner`) caches the media attributes and the processing state, so re-processing a file reads it rather than the media, and a stale or suspect result is re-derived by deleting the sidecar. The regression harness keeps per-version results and logs for diffing. diff --git a/README.md b/README.md index 176c233a..d5b74089 100644 --- a/README.md +++ b/README.md @@ -577,7 +577,7 @@ See detailed command documentation below for all options and usage examples. --- Use the `PlexCleaner --help` commandline option to get a list of commands and options.\ -To get help for a specific command run `PlexCleaner --help`. +To get help for a specific command run `PlexCleaner "" --help`. ```text > PlexCleaner --help @@ -883,7 +883,7 @@ PlexCleaner publishes always-on runtime metrics via `System.Diagnostics.Metrics` Read the meter with [`dotnet-counters`][dotnet-counters-link]: - Local: `dotnet-counters monitor -p --counters PlexCleaner.Process` -- Docker: `docker exec counters` (a bundled wrapper that runs the same command against the in-container process) +- Docker: `docker exec "" counters` (a bundled wrapper that runs the same command against the in-container process) The meter is also OpenTelemetry and [`dotnet-monitor`][dotnet-monitor-link] compatible if you want an HTTP or Prometheus surface. diff --git a/RegressionTests/README.md b/RegressionTests/README.md index 29f0bab9..9dfbb53f 100644 --- a/RegressionTests/README.md +++ b/RegressionTests/README.md @@ -81,7 +81,7 @@ A Python tool's command-line arguments, such as `--run`, `--out`, `--settings`, Each run writes `buildinfo.json` beside its results. It records the image and every input that shapes the outcome. Those inputs are the mode, the corpus, the corpus snapshot cloned, and the process options. They also cover the settings file's SHA-256, whether coverage ran, and the plugins built. Writing it needs `jq` on the host. Compare a run against a baseline run in one step: ```shell -python3 check_results.py --baseline /Results_process.json --results /Results_process.json +python3 check_results.py --baseline "/Results_process.json" --results "/Results_process.json" ``` The comparison first checks the two runs' inputs. It reads each run's tool versions from the ` : Version:` lines at the start of its `PlexCleaner_process.log`. A log lacking the version of any tool PlexCleaner checks at startup records no tool versions. It warns of each input other than the image and the plugins that differs, or that either run does not record. A plugin difference is only noted, since the plugins run after `Results_process.json` is written. So a corpus refresh, a thread-count change, a settings change, or a tool update shows beside the outcome differences it can explain. It then prints one line per file whose result, new name, `Modified` flag, `State` flags, failed operation, or invalid reason differs. From ef5e40b1dd13897735df62825657de43f070cf48 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 25 Nov 2026 19:33:02 -0800 Subject: [PATCH 4/5] Keep the Hand-Check Sentence Next to the Checks It Names Co-Authored-By: Claude Opus 5.5 --- OPERATIONS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OPERATIONS.md b/OPERATIONS.md index 108f7c1d..e411e44b 100644 --- a/OPERATIONS.md +++ b/OPERATIONS.md @@ -6,7 +6,7 @@ How this repository is run. PlexCleaner is a code repository, so its operations What verifying a change here requires, including the part CI cannot perform. -The clean-compile is the `.NET Format` VS Code task, chaining `CSharpier Format` -> `.NET Build` -> `dotnet format style --verify-no-changes --severity=info`, and it must pass before a commit, per [CODESTYLE.md](./CODESTYLE.md). CI runs the same checks plus the rest of the hub validator's gate, including unit tests with coverage, markdownlint, cspell, actionlint, editorconfig-checker, shellcheck, and shfmt. It also runs ruff, mypy, and the `unittest` suite over `RegressionTests/`, plus the prose and repo gates. `Lint: All (CI parity)` in [.vscode/tasks.json](./.vscode/tasks.json) runs the lint half locally except shellcheck, shfmt, and the prose and repo gates, and `Python Test` runs the `RegressionTests/` suite. The whole suite a push owes is that task plus `dotnet test --project PlexCleanerTests/PlexCleanerTests.csproj` from the repository root. A change to a shell script or to prose therefore owes those checks by hand, per the `shell-codestyle` and `comment-and-doc-style` Skills. A green clean-compile does not predict a green CI, so run the parity task before pushing a change that touches anything beyond `.cs` files. +The clean-compile is the `.NET Format` VS Code task, chaining `CSharpier Format` -> `.NET Build` -> `dotnet format style --verify-no-changes --severity=info`, and it must pass before a commit, per [CODESTYLE.md](./CODESTYLE.md). CI runs the same checks plus the rest of the hub validator's gate, including unit tests with coverage, markdownlint, cspell, actionlint, editorconfig-checker, shellcheck, and shfmt. It also runs ruff, mypy, and the `unittest` suite over `RegressionTests/`, plus the prose and repo gates. `Lint: All (CI parity)` in [.vscode/tasks.json](./.vscode/tasks.json) runs the lint half locally except shellcheck, shfmt, and the prose and repo gates, and `Python Test` runs the `RegressionTests/` suite. A change to a shell script or to prose therefore owes those checks by hand, per the `shell-codestyle` and `comment-and-doc-style` Skills. The whole suite a push owes is the `Python Test` task plus `dotnet test --project PlexCleanerTests/PlexCleanerTests.csproj` from the repository root. A green clean-compile does not predict a green CI, so run the parity task before pushing a change that touches anything beyond `.cs` files. The part CI structurally cannot exercise is media processing. The unit tests need no media files and run everywhere, but the behavior of the tool depends on the media it processes and on the external tools (FFmpeg, HandBrake, MkvToolNix, MediaInfo, 7-Zip) it drives, and a pull request runner has neither a media collection nor a reason to trust one. So a change to processing, sidecar, media-tool, or language-tag code is verified locally against real media, by the Docker test script and by the regression harness described under Runbooks, before it is called done. Read [ARCHITECTURE.md](./ARCHITECTURE.md) before changing that code. From 0fa16aeb7679b5d70ad146fc26482d282ea093fe Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Wed, 25 Nov 2026 19:48:56 -0800 Subject: [PATCH 5/5] Quote Only the Placeholder in the check_results.py Example A path the reader supplies may open with ~, which the shell expands only outside the quotes. Co-Authored-By: Claude Opus 5.5 --- RegressionTests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RegressionTests/README.md b/RegressionTests/README.md index 9dfbb53f..d9993a87 100644 --- a/RegressionTests/README.md +++ b/RegressionTests/README.md @@ -81,7 +81,7 @@ A Python tool's command-line arguments, such as `--run`, `--out`, `--settings`, Each run writes `buildinfo.json` beside its results. It records the image and every input that shapes the outcome. Those inputs are the mode, the corpus, the corpus snapshot cloned, and the process options. They also cover the settings file's SHA-256, whether coverage ran, and the plugins built. Writing it needs `jq` on the host. Compare a run against a baseline run in one step: ```shell -python3 check_results.py --baseline "/Results_process.json" --results "/Results_process.json" +python3 check_results.py --baseline ""/Results_process.json --results ""/Results_process.json ``` The comparison first checks the two runs' inputs. It reads each run's tool versions from the ` : Version:` lines at the start of its `PlexCleaner_process.log`. A log lacking the version of any tool PlexCleaner checks at startup records no tool versions. It warns of each input other than the image and the plugins that differs, or that either run does not record. A plugin difference is only noted, since the plugins run after `Results_process.json` is written. So a corpus refresh, a thread-count change, a settings change, or a tool update shows beside the outcome differences it can explain. It then prints one line per file whose result, new name, `Modified` flag, `State` flags, failed operation, or invalid reason differs.