Repository navigation
One command answers whether a repository is compliant: openRepoShape --doctor, and the machine check becomes --preflight - #96
Conversation
…epository doctor Brett Heap, 2026-09-10, in session: "lets use doctor for this, it is better fit. use preflight for the preflight." `--doctor` has meant "check this MACHINE and stop; creates nothing" since #59 — which is the run's own section (1), the preflight, and nothing else. The word a person actually reaches for when they mean "tell me what is wrong with this repository" was therefore spent on the one thing in this standard that is not a diagnosis of a repository at all. So the machine check takes the name that always described it, and `--doctor` is free for the repository doctor that lands next (#95). A RENAME AND NOTHING ELSE. No behaviour moves: the flag reaches `setup-project.py` through the same passthrough, returns from the same position in `_main` — before the git probe, before the checkout probe, before the `--org` handshake — and exits 0/1 on the same two conditions. `setup.sh` names neither flag and forwards every argument untouched, so it is not touched here either. openRepoShape `--doctor)` -> `--preflight)`, $DOCTOR -> $PREFLIGHT, the usage line, and the three comments that argue why the case exists for the variable rather than for the passing on. The case keeps a note saying what the flag was called until today, because a person with the old habit reads this file to find out where it went. setup-project.py `--preflight` in BOOLEAN_FLAGS and in `--help`, `Options.doctor` -> `Options.preflight`, `doctor()` -> `preflight_only()`. README.md both places (the Quick start callout and the worked example's requirements). Same line count. docs/handbook.html all four quotations, and the footer's README blob re-cut: the page quotes the README and the README moved. tests/ `test_openreposhape_command.py` (the USAGE_LINES row and every run), `test_setup_project_py.py`, and three comment lines in `test_repo_hygiene.py`'s cap history. `--doctor` appeared 38 times before this commit and `--preflight` appears 38 times after it; the two remaining `--doctor`s are the shim's note about what the flag used to be called. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…in sequence, one verdict Brett Heap, 2026-09-10: "what tools do we have to check a repo to make sure it is compliant with openRepoShape?" — then "add that". The answer was five tools and an order nobody had written down. `validate-repository-naming.py` classifies the names; the project's OWN `scripts/validate-manifest.py` and `scripts/validate-pins.py` are its pinned gate; `update-shape.py check` says whether the copies have fallen behind; a FAMILY holder runs `scripts/validate-family.py` instead of the first two; and a directory carrying neither manifest is not a shape root at all. This is that sequence, as one command, with one verdict at the end. IT REIMPLEMENTS NOTHING. Every row is somebody else's check — `update-shape.py`'s verdict machinery is IMPORTED (by path; the filename has a hyphen) rather than re-derived, and the validators are RUN, the project's own copies first because those are the pinned ones and that is the point. The row says which of the two answered. NO WRITES AND NO FETCH. The upstream a project's copies are compared against is THE CHECKOUT THE SCRIPT IS RUN FROM, which is the whole of why the verdict is offline. One row is the named exception and it is `n/a` by status: the `machine` row asks `gh` whether it is logged in, which `gh` answers by talking to its host. `n/a` never moves the verdict, because a workstation with no `gh` is not a repository being non-compliant. A REGISTRY, NOT A FUNCTION WITH EIGHT PARAGRAPHS IN IT. Each check is an `id`, the root kinds it `applies_to`, a `run(ctx) -> Row`, and a `fix` slot that is None in every one of them today: a repair mode hangs off that slot rather than a rewrite of this file, and a `--fix` that calls one does so only after printing its plan and getting the human's yes. Manifest validation is a SECOND registry keyed by the manifest's `kind:` — `project-manifest`, `family-manifest`, `pinned_contract_manifest`, the two policy kinds — so a `contracts/*.yaml` whose kind nothing validates is a FINDING that says so by name instead of a silence. A future inventory plugs in by adding one row. THE ROWS. naming · manifest · pins · manifest kinds · shape currency · legs · leg shape files · agent files · machine, for an assembly root; family · manifest kinds · shape currency · members · machine for a holder; and for a directory that is neither, what it is CALLED under the policy, what IS there, and the way in — `adopt-project.py plan` for a repository that exists, `setup.sh` for a new one. `leg shape files` compares each leg's `AGENTS.md`, `CLAUDE.md` and `.gitignore` against `templates/<role>-root/` and reports rather than judges: no leg file is pinned anywhere, so a `.gitignore` that has grown a line is not thereby wrong, and only an ABSENT file is a finding. THE VERDICT, and its exit code: COMPLIANT 0 · COMPLIANT, SHAPE BEHIND 1 · DRIFTED 1 · INVALID 1 · NOT A SHAPE ROOT 2 · usage or environment 3. Drift outranks a red validator deliberately — an edited shape copy is exactly what makes `validate-pins.py` red, so answering INVALID would send the reader at the symptom while the fix is `update-shape.py`. NOT A SHAPE ROOT adds one line saying the machine check is `openRepoShape --preflight` now, because `--doctor` meant that until this morning and a habit outlives a rename. THE SHIM. `--doctor [<path>]` runs `shape-doctor.py` from the checkout beside this file when there is one, and otherwise clones the standard into the temporary directory `workdir` already owns — `setup.sh`'s self-bootstrap, with one forced deviation: no `--depth 1`. A shallow clone has exactly one commit, and the shape-currency row compares a project's copies AT THE COMMIT ITS PIN NAMES against this standard's tip, which a one-commit history cannot answer. The path is eaten by the case rather than passed on, so it is never taken for the <Project> of a scaffold run, and every other argument beside `--doctor` is refused: they are all about creating something. `templates/` is untouched. Nothing here reaches a project that has not asked. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ith their reasons THE README gains a `###` under "Keeping a project's shape current" rather than a `## ` of its own: the handbook guard's table maps `## ` headings, and "is this repository still what the standard says" is the question that section is already about. Sixty-six lines, and the case for each part is in the cap's own dated entry — what it compares against (the checkout the script is run from, which is why the run is offline), the rows, the verdict table with its exit codes, why DRIFT outranks a red validator on that one line, and why `machine` is `n/a` and cannot move the verdict. One line is its row in the contents list and one names `shape-doctor.py` in the Layout block. THE HANDBOOK gets its own `<section id="doctor">` and a row in the section list, not a block folded into `#current`: a reader looking for "how do I check a repository" scans that list, and a doctor inside a section about re-syncing copies is a doctor they do not find. It is therefore a page section with no README `## ` behind it, which is a NAMED decision — `HANDBOOK_SECTION_WITHOUT_A_README_H2` carries it and says where it came from, the same way the other four are accounted for. The footer's prose names this addition and its `README.md blob` is re-cut to the working tree's own `git hash-object README.md`, which is the guard. AGENTS.md gains `## Checking a repository's compliance`, before "Updating a project's shape" — you run the doctor to find out whether you need that section. Five numbered points, and each is one way an assistant gets a report wrong: reading the verdict instead of the rows; improvising a repair instead of running the command the row NAMES (the hand-edited-pin failure, arriving through a new door); treating `NOT A SHAPE ROOT` as a task when adopting and scaffolding are two acts and the choice is the human's; reading the `machine` row as a fault in the repository; and `--json`, so an agent acting on a row is not parsing a table. Both caps move with a dated entry naming #95, which is the rule: a cap that never moves for a rule pushes the rule into tribal memory, and a cap that moves for prose is not a cap. `git diff --stat origin/main -- templates/` is empty — no project may get an `upstream-changed` row out of this. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…olded from it OFFLINE, AND AGAINST A STANDARD THE SUITE BUILDS. Every other suite here scaffolds from `REPO` — this checkout's WORKING TREE — and that is the one thing a doctor cannot be tested against: it compares a project's copies against the standard AT A COMMIT, so an uncommitted edit under `templates/` would produce a `locally-modified` row for a file nobody touched, on one developer's machine and nowhere else. The `standard` fixture therefore copies every TRACKED file into a temporary directory and makes one commit of it; the project is scaffolded from that, and `shape-doctor.py` is run out of it. The pin, the bytes and the comparison then name one commit on any machine — and the code under test is still what is on disk right now, which is the point of running a suite at all. Twenty-three tests. Compliant (exit 0, and the `--json` object: kind, verdict, exit, note, and the nine row ids a caller keys by, each row's own five fields, and that the project's OWN validators are the ones that answered). One edited shape copy -> DRIFTED, exit 1, the path named and `--accept-local <path>` handed over — with the pins row asserted RED beside it, because drift outranking a red validator on the verdict line is a decision and not an accident. A standard advanced by one commit on a copied template -> COMPLIANT, SHAPE BEHIND (1 upstream-changed, 0 upstream-added), with the project's own gate still green. A commit made INSIDE a leg -> the legs row red and `validate-pins.py` still green, which is exactly the gap that row closes: the gitlink did not move. An emptied mount. A `contracts/*.yaml` of an unregistered `kind:` -> the finding by name, and a YAML file with no `kind:` still invisible, which is the other half. A family holder -> six rows, the member at its pin, and the missing working clone REPORTED rather than made a finding. Three shapes of not-a-shape-root, including a `project.yaml` that declares the wrong `kind:`. A path that is not there -> 3. A lone copy of the script -> 3, naming what is missing. The shim from a file, from stdin against a local `$OPENREPOSHAPE_REPO`, its refusal of anything but a path, and its default of `.` — each with a `gh` and a `curl` on `$PATH` that refuse loudly, so a run that reached for the network would fail rather than pass slowly. TWO TESTS FOUND SOMETHING. `test_the_doctor_writes_nothing` snapshots every file under the root before and after: running a project's own `scripts/validate-pins.py` as a subprocess made CPython write `scripts/__pycache__/` into somebody else's repository, from a command whose first promise is that it writes nothing. `PYTHONDONTWRITEBYTECODE=1` is the fix, and the test is what holds it. And `test_the_registry_leaves_a_fix_slot_for_the_repair_mode` asserts that every check carries a `fix` and that every one is None: the day a repair fills one, somebody has to say so out loud rather than grow a second mechanism beside the registry. The rename of #95's first commit reached two identifiers a grep for `--doctor` could not see: `module.doctor(opts)` in `tests/test_setup_project_py.py`, and five test function names. Renamed here, where the suite that runs them is being touched anyway. `shape-doctor.py` joins `SHIPPED` in `tests/test_repo_hygiene.py`, so it is held to the standard-library-only rule and the compile check like everything else this repository ships. 816 tests before, 839 after; whole suite green. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
…install` ends with the machine Brett Heap, 2026-09-10: "add the two shim behaviours too." A BARE `openRepoShape` PRINTS ITS USAGE AND EXITS 1. It used to fall through into the scaffold path and refuse `no organisation to scaffold into` — an answer about a run the person had not asked for, and about the one of four things this command does that creates three repositories. The usage now opens with those four, one line each, in the order somebody meets them: install it, check the MACHINE (`--preflight`), diagnose a REPOSITORY (`--doctor`), scaffold a project. Exit 1 rather than 0, because typing a command and getting a page of text is a mistake being reported; `--help` is the same page and still exits 0, because asking is not. ANY SCAFFOLD ARGUMENT AT ALL KEEPS TODAY'S BEHAVIOUR, refusals included. A person who typed something meant something, and a usage page in place of the refusal they earned would hide WHICH of their arguments was the problem — which is the entire value of the refusal. `setup.sh` is untouched: it is the scaffold entry and not the installed command, and a bare `./setup.sh` in a checkout still means what it always meant. `--install` ENDS WITH A READ-ONLY MACHINE REPORT, inline, after the count line, the openRepoTools pointer and the PATH note. One line each for `git`, `gh` (with its login state, the one thing that cannot be learnt without asking), `python3`, and `git-filter-repo` — which only `adopt-project.py` needs and `--preflight` therefore does not ask about — each `present` or `MISSING`, and ONE closing line naming `openRepoShape --preflight` when anything is missing or `gh` is not logged in. WHAT IT DOES NOT DO IS THE USEFUL HALF. Four `command -v` probes, which execute nothing at all, and one `gh auth status`. No fetch, no prompt, no install, and NO CHANGE TO THE EXIT CODE: a machine missing a prerequisite did not make the copy that was just placed any less placed, and an install that failed because `gh` was not logged in is an install nobody could script. An offer belongs behind a typed yes, which is what `--preflight` is, so this points there rather than growing a second consent beside it. Twelve lines total; still one screenful. Tests. The bare run: the usage on stdout, exit 1, and — through the logging fake `gh` and `curl` — that NOTHING was requested, because a usage page printed after a round trip to github.com looks identical on screen. Three scaffold arguments, each still refused as before. `--help` still 0. The report with everything present and logged in (no closing line), with `git-filter-repo` withheld (that line MISSING, the closing line once, and the command still installed), and with a `gh` that is not logged in. And that it runs no installer: every fake on that `$PATH` logs its own argv and then fails loudly, so the log holding exactly `gh auth status` is the proof. The `$PATH` is one this test owns entirely — an absolute bash and symlinks to the seven programs `--install` itself runs — because there is no other way to make `command -v git` answer "no" on a machine that has git; `tests/test_setup_sh.py`'s git-missing test is the precedent. `test_install_from_a_file_never_calls_gh` asserted that `gh` was never reached. It now asserts WHAT was asked — exactly `auth status`, never a fetch — which is the stronger claim it was always trying to make. README, `docs/handbook.html` and AGENTS.md carry both, and both caps move with a dated entry naming #95. `templates/` untouched. 839 tests before, 849 after; whole suite green, and `/bin/bash -n` parses the shim. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 5 hours and 15 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideThis PR adds a read-only Sequence diagram for repository compliance diagnosissequenceDiagram
actor User
participant Shim as openRepoShape
participant Doctor as shape-doctor.py
participant Validators as Registered validators
participant Preflight as setup-project.py
participant Repo as Target repository
User->>Shim: --doctor [path]
Shim->>Doctor: Run from standard checkout
Doctor->>Repo: Read manifests, pins, legs, and shape files
Doctor->>Validators: Run project-owned copies first
Validators-->>Doctor: Return validation rows
Doctor->>Preflight: --preflight with stdin closed
Preflight-->>Doctor: Return machine status
Doctor-->>Shim: Rows and one verdict
Shim-->>User: Report and exit code
Note over Doctor,Repo: No writes or fetches
Flow diagram for compliance verdict precedenceflowchart TD
Start["openRepoShape --doctor"] --> Root{"Shape root?"}
Root -->|No| NotRoot["NOT A SHAPE ROOT<br/>exit 2"]
Root -->|Yes| Rows["Run registered checks<br/>and collect rows"]
Rows --> Drift{"Drift or leg off pin?"}
Drift -->|Yes| Drifted["DRIFTED<br/>exit 1"]
Drift -->|No| Invalid{"Validator finding?"}
Invalid -->|Yes| InvalidVerdict["INVALID<br/>exit 1"]
Invalid -->|No| Behind{"Shape behind upstream?"}
Behind -->|Yes| BehindVerdict["COMPLIANT, SHAPE BEHIND<br/>exit 1"]
Behind -->|No| Compliant["COMPLIANT<br/>exit 0"]
Machine["machine row: n/a"] -.-> Rows
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings affect ref validation, verdict correctness, remediation commands, and compliance detection.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds repository compliance diagnosis via openRepoShape --doctor, renames machine checks to --preflight, and documents the new workflows.
Changes:
- Adds registry-based checks, verdicts, exit codes, and JSON output.
- Updates shim, install, and preflight behavior.
- Adds tests and documentation across the repository.
File summaries
| File | Findings |
|---|---|
tests/test_shape_doctor.py |
Adds doctor behavior and read-only coverage; no final findings recorded. |
tests/test_setup_project_py.py |
Covers preflight behavior; no final findings recorded. |
tests/test_repo_hygiene.py |
Updates hygiene coverage; no final findings recorded. |
tests/test_openreposhape_command.py |
Covers shim modes and installation reporting; no final findings recorded. |
shape-doctor.py |
Critical (2 votes): pin mismatches are omitted from the “behind” verdict. Critical (1 vote each): validator remediation and off-pin leg commands emit invalid literal in arguments. Moderate findings cover manifest applicability, templated leg copying, detached-pin validation, sibling identity checks, exit-code mapping, dual-root ambiguity, import guarding, missing-file remediation, and missing-leg counting. |
setup-project.py |
Renames the machine check to --preflight; no final findings recorded. |
README.md |
Documents doctor and preflight workflows; no final findings recorded. |
openRepoShape |
Critical (2 votes): OPENREPOSHAPE_REF lacks equivalent ref validation. Moderate (2 votes): conflicting mode flags are not rejected. Nit (1 vote): usage text omits the comma in the verdict name. |
docs/handbook.html |
Adds handbook documentation; no final findings recorded. |
AGENTS.md |
Nit (1 vote each): document both adoption and scaffolding routes, and distinguish target diagnosis from the shim’s standard checkout. |
Review details
Suppressed comments (10)
AGENTS.md:205
- The doctor implementation emits only one
way-incommand based on whether the path already has.git, but this new instruction says aNOT A SHAPE ROOTreport must include both adoption and scaffolding commands. The rule and report therefore disagree: a git repository never shows the scaffold route, and a loose directory never shows the adopt route. Align the instruction with the actual state-specific output or emit both options.
verdict and both commands; adopt or scaffold nothing on your own
AGENTS.md:184
- This wording says the
openRepoShape --doctorcommand fetches nothing, but the installed/stdin shim explicitly clones the standard into a temporary checkout before invokingshape-doctor.py. Distinguish the read-only diagnosis of the target from the shim's one-time standard checkout so an agent does not promise an offline run that the installed entry point does not provide.
`openRepoShape --doctor [<path>]` — or `./shape-doctor.py --root <path>` from
a checkout — answers ONE question about ONE repository: is it compliant with
this shape, and what is missing. Run it before you propose a change to a
repository you did not scaffold, and again after any procedure above. It
writes nothing and fetches nothing, so there is no confirmation to get and no
`--dry-run` to do first. The checks are a REGISTRY with an empty `fix` slot
openRepoShape:83
- The usage text drops the comma from the actual verdict name
COMPLIANT, SHAPE BEHIND, so the command advertises a different status string than the doctor emits and the README documents.
one row per check and ONE verdict: COMPLIANT, COMPLIANT SHAPE BEHIND, DRIFTED,
shape-doctor.py:496
entryis treated as proof that this candidate was validated, butcovered_byis never consulted. For example, acontracts/*.yamlfile declaringproject-manifestinside a family, orpath-classification-policy(whose registry text explicitly says nothing validates it in a root), is added tovalidatedeven though no check reads that file. The registry needs to encode applicability and only mark a manifest known when the corresponding check actually covers it; otherwise this can report an unchecked manifest as compliant.
entry = MANIFEST_VALIDATORS.get(kind)
(known if entry else unknown).append(f"{rel} ({kind})")
shape-doctor.py:1127
- The module documents exit 3 for usage errors, but
argparse.ArgumentParser.parse_args()exits 2 directly for unknown options or missing option values. That makes the directshape-doctor.pyinterface violate its published exit-code contract; use a parser/error path that maps CLI usage failures to the documented 3.
def main(argv: list[str] | None = None) -> int:
args = build_parser().parse_args(argv)
shape-doctor.py:732
- This branch returns prose rather than an executable next command for missing root
AGENTS.mdorCLAUDE.md(write it, or take it from ...). The doctor’s documented contract is that every finding names the exact command that fixes it, so these findings leave the operator to invent a repair and do not meet that contract; provide a concrete rendering/materialization command or explicitly handle it as a manual decision.
"AGENTS-shape.md`") if "AGENTS-shape.md" in absent else (
f"the scaffold renders {' and '.join(absent)}; write it, or take it "
f"from templates/assembly-root/")
shape-doctor.py:281
- When both
project.yamlandfamily.yamlare valid manifests, this precedence silently treats the tree as a project. The project validator runs, but the family manifest is merely listed as a registered kind; no family validator runs, so a mutually exclusive dual-root tree can be reported compliant. Detect and report the ambiguity instead of selecting one root.
if project.is_file() and self._declares(project, "project-manifest"):
self.kind, self.manifest_path = PROJECT, project
elif family.is_file() and self._declares(family, "family-manifest"):
self.kind, self.manifest_path = FAMILY, family
shape-doctor.py:114
- The
shape-doctor-not-in-the-standardguard inmain()is unreachable when someone runs the shipped script withoutscripts/repo_shape.py: this top-level import raisesModuleNotFoundErrorbeforemain()executes, producing a traceback instead of the documented exit-3 refusal. Defer the local import until after the marker check, or provide a minimal bootstrap path for the check.
SHAPE_ROOT = Path(__file__).resolve().parent
sys.path.insert(0, str(SHAPE_ROOT / "scripts"))
from repo_shape import ( # noqa: E402
COMMIT_RE, PYTHON, Refusal, git_out, load_yaml, recorded_gitlink,
)
shape-doctor.py:1029
- Missing or unpopulated legs can have both
headandpinasNone, so they are excluded fromoff;len(off) or 1then reports one leg even when several legs are missing. The verdict's count should include missing gitlinks, unpopulated mounts, unreadable heads/pins, and mismatched commits.
off = [leg for leg in (legs.detail.get("legs") or [])
if leg.get("head") != leg.get("pin")]
reasons.append(f"{len(off) or 1} leg(s) not at the pin")
shape-doctor.py:779
- The member remediation has the same issue as the leg remediation:
python3 scripts/bootstrap.py in <root>passesinto the script and does not select<root>as its working directory. Use the absolute bootstrap path or a shellcdform so the advertised next command can actually run.
f"{PYTHON} scripts/bootstrap.py in {ctx.root} # what "
"`make bootstrap` runs in a holder: it fetches every "
"member at its pin", detail)
- Files reviewed: 10/10 changed files
- Comments generated: 9
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… commands, and five wrong answers Copilot's review of PR #96. Every one of these is a line that LOOKED right. FOUR REMEDIATIONS THAT WOULD HAVE FAILED WHOEVER PASTED THEM. A validator row printed `python3 validate-pins.py in <root>` and the legs and members rows printed `python3 scripts/bootstrap.py in <root>` — prose wearing a command's clothes, where `in` arrives as an argument and argparse refuses it. Every one of those scripts takes `--root`, so that is what is printed now, with the absolute path, and two new tests RUN the command the row hands over and assert it reproduces the finding and then fixes it. A missing leg file was offered a `cp` of `templates/<role>-root/AGENTS.md`, which carries `{{PLACEHOLDER}}`s the scaffold renders: the copy would have left a leg holding literal `{{PROJECT_NAME}}`, so a `cp` is now offered only for the verbatim files and the rendered ones are named as rendered. And a deleted `AGENTS-shape.md` was sent at `apply --add`, which refuses a path the pin already names, BY NAME — it is `copy-missing`, not `upstream-added`, so the row reads the pin's own `files:` rows and hands over `git checkout --` when there is one and `--add` only when there is not. THE PIN BEHIND WITH NO FILE DIFFERING WAS REPORTED COMPLIANT. `COMPLIANT` is documented as "every row ok AND the pin names this standard's commit", and an upstream commit that touches no copied file left every row `unchanged` and the verdict disagreeing with the sentence that defines it. `update-shape.py check` exits 1 there too, for the same reason: `apply` would move the pin alone. It is `COMPLIANT, SHAPE BEHIND` now. TWO MODES WAS LAST-WINS. `--doctor <path> --install` entered the install path and silently dropped the diagnosis; the other order dropped the install. Each does a different thing to a different place, so `set_mode` refuses the pair and names both. `$OPENREPOSHAPE_REF` REACHED `git checkout` UNCHECKED. `setup.sh` validates `--shape-ref` in three steps — length, then control characters, neither echoing the value back, then the shape, which by then is safe to echo — and this value lands in the same place. `checked_ref` is those three, in that order. The checkout is also spelled `"$REF" --` rather than `-- "$REF"`: a `--` before the argument makes git read it as a PATHSPEC and restore a file of that name. And a checkout that has no `shape-doctor.py` in it — a ref older than this commit — now refuses by name instead of leaving python3 to say `can't open file`. A SIBLING WAS ANY DIRECTORY WITH A `.git` IN IT. `scripts/siblings.py` asks whether the directory IS this project before it touches one, and this now asks the same way — `project.yaml`'s `kind` and `id` — so the report cannot tell somebody their working clone is beside the holder when what is there is somebody else's repository. AND ONE FINDING TAKEN HALF. Copilot asked for a member at its pin but on a BRANCH to be a failure. It is recorded (`symbolic-ref -q HEAD`) and said in the row, because a branch in the copy the gate reads is worth attention — but it is not a finding, because `family.py add` ITSELF leaves the member on a branch (`git submodule add` checks one out) and only a fresh `clone --recurse-submodules` is detached. A row that refused there would refuse a holder the standard's own tool had just made, which is a rule this standard has not made. The suite says both halves out loud. 849 tests before, 866 after; whole suite green. `templates/` still untouched. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
| checked_ref "$REF" | ||
| # `<ref> --`, never `-- <ref>`: a `--` BEFORE the argument makes git | ||
| # read it as a PATHSPEC and try to restore a file of that name from | ||
| # the index. AFTER it, it says "and no paths follow", which is the | ||
| # disambiguation this wants. The leading-dash case is refused by | ||
| # `checked_ref` above, which is where it belongs. | ||
| git -C "$SHAPE_DIR" checkout --quiet "$REF" -- || | ||
| die "cloned $REPO but could not check out '$REF'." |
| return Row(check_id, label, FINDING, reason, | ||
| f"{PYTHON} {used} {' '.join(args)} # read its output in " | ||
| "full; it names what it refused", detail) |
| for path in manifest_candidates(ctx.root): | ||
| data = Context._read(path) | ||
| if not isinstance(data, dict): | ||
| unreadable.append(path.relative_to(ctx.root).as_posix()) | ||
| continue | ||
| kind = data.get("kind") | ||
| if not isinstance(kind, str) or not kind: | ||
| continue | ||
| rel = path.relative_to(ctx.root).as_posix() | ||
| entry = MANIFEST_VALIDATORS.get(kind) | ||
| (known if entry else unknown).append(f"{rel} ({kind})") | ||
| detail = {"validated": known, "unregistered": unknown, | ||
| "unreadable": unreadable, | ||
| "registered_kinds": sorted(MANIFEST_VALIDATORS)} |
…and a lone copy died with the wrong exit Five fixes. The first two are why this had not earned a merge. DEFECT 1 — `INVALID` OVER AN ESTATE WHOSE EVERY GATE WAS GREEN. `shape-doctor.py --root ~/projects/InkRouter/IRRS` printed `INVALID (leg-shape-files)` and exited 1 because `spec/.gitignore` was absent — while `validate-manifest.py`, `validate-pins.py`, `validate-family.py` and `update-shape.py` were all green on that root. `templates/spec-root/ .gitignore` entered the standard at be488ed, AFTER IRRS was scaffolded, and no pin names a leg file, no validator asserts one, and the shape-currency row cannot even report it. So every project cut before that commit was failed by a rule this standard never made — contradicting the row's own docstring and README, both of which say it is a comparison and not a gate. THE FIX IS A FOURTH STATUS, not a deletion from a tuple. `note` is a difference NOTHING ASSERTS: printed, in `--json`, and stepped over by `verdict_for` and by its catch-all. `FINDING` now means exactly "something else asserts this" — a validator, a pin row, a manifest, a gitlink — and is the only status that can make this command exit non-zero about a repository. A `FINDING` row beside exit 0 was a contradiction the three-word vocabulary could not express. The agent-files row gets the same treatment one file along: `AGENTS-shape.md` is PINNED, so its absence stays a FINDING and `validate-pins.py` agrees, while a missing rendered `AGENTS.md` is a `note`. THE SUITE WAS BLIND TO IT because `standard` is always this checkout, so the fixture project always had every leg file the current templates carry. The new test builds history as it actually happened: a standard WITHOUT the file, a project scaffolded from it, then the file added. DEFECT 2 — A LONE `shape-doctor.py` DIED AT `import repo_shape` WITH EXIT 1, which is this tool's code for "the repository has findings": a caller scripting on it read an interpreter crash as a verdict about somebody's repository. The `SHAPE_MARKERS` guard that returns 3 lives inside `main()`, so the most obvious way to be "not in the standard" could never reach it. The refusal is a function defined BEFORE the first import now, and the import is wrapped. AND THE TEST THAT GUARDED IT COPIED `scripts/ repo_shape.py` IN BESIDE THE LONE FILE — precisely the file whose absence caused the death — so it asserted the opposite of its own docstring. The workaround is gone and the test proves exit 3 for real. DEFECT 3 — `COMPLIANT, SHAPE BEHIND (0 upstream-changed, 0 upstream-added)`. That branch is entered only when nothing differs, so the parenthetical was zero by construction: a clause stating nothing moved, under a verdict saying the shape is behind. It fired on both real estates here, so it was the common case. `detail["behind_pin_only"]` now spells it from the pin — `(pin 3a927a2 -> dfb23e1, no copied file differs)` — and the counted branch keeps its counts, which are true there. A test for each. NIT 1 — the doctor wrote `__pycache__/` into the STANDARD's checkout. `PYTHONDONTWRITEBYTECODE=1` covered the subprocess validators; `repo_shape` and `update-shape.py` are imported IN PROCESS. `sys.dont_write_bytecode = True` before the first import, and a test that sweeps the standard for `*.pyc` afterwards. NIT 2 — an unresolvable pin was `INVALID`. A pin naming a commit THIS checkout does not carry is this standard being unable to answer, which is the documented meaning of exit 3; labelling it INVALID told somebody their repository was wrong on the evidence that our copy was short a commit. New verdict `CANNOT ANSWER (<row>: <reason>)`, exit 3, with a `REFUSED shape-doctor-cannot-answer` line naming the fetch. AND ONE SENTENCE THAT WAS SIMPLY FALSE, from the review's NOTE: the machine row makes three calls to `gh`, not one (`--version`, `auth status`, `api user`). Said correctly in the docstring, README and the handbook. Read back on the real estates, read-only, both now: COMPLIANT, SHAPE BEHIND (pin 3a927a2 -> dfb23e1, no copied file differs) 866 tests before, 873 after; whole suite green. `templates/` untouched. Both caps move with dated entries naming #96's review. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate findings affect shim behavior, remediation commands, validation coverage, and offline test isolation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (17)
AGENTS.md:184
- The new compliance instructions repeat that the command “writes nothing and fetches nothing,” although an installed
openRepoShape --doctorclones the standard into a temporary directory before running the script. Scope this statement to the target repository or to a standalone checkout invocation so the operational behavior described here matches the shim.
`openRepoShape --doctor [<path>]` — or `./shape-doctor.py --root <path>` from
a checkout — answers ONE question about ONE repository: is it compliant with
this shape, and what is missing. Run it before you propose a change to a
repository you did not scaffold, and again after any procedure above. It
writes nothing and fetches nothing, so there is no confirmation to get and no
`--dry-run` to do first. The checks are a REGISTRY with an empty `fix` slot
README.md:1073
- This paragraph promises that the doctor “fetches nothing,” but the documented
openRepoShape --doctorentry point clones the standard into a temporary directory when run installed or from stdin, as the following sentence acknowledges. Qualify the promise as applying to the target repository/standalone script, or the documentation contradicts the actual shim behavior.
It **writes nothing and fetches nothing**, and it reimplements nothing: every
row is one of the checks this file already documents. The standard a project's
copies are compared against is the checkout the script is RUN FROM — beside
one it uses that one, installed it clones the standard into a temporary
openRepoShape:340
OPENREPOSHAPE_REFis validated only aftergit clonehas already fetched the repository. An invalid or overlong ref therefore still causes network access and temporary checkout creation before the promised early refusal; validate the ref beforeworkdir/git clone, then perform the checkout only after the clone succeeds.
git clone --quiet -- "$url" "$SHAPE_DIR" ||
die "could not clone $REPO into a temporary directory, so there is no
standard to check against. \`--doctor\` needs one: run it from a checkout
of openRepoShape, or make the clone work."
if [ -n "${OPENREPOSHAPE_REF:-}" ]; then
openRepoShape:247
shortis also set when onlygit-filter-repois missing, but the printed remediation is alwaysopenRepoShape --preflight; that preflight explicitly does not check or offer this adoption-only tool. Following the displayed command can therefore report the machine ready whileadopt-project.pystill cannot run. Distinguish this case or print an adoption-specific installation command.
[ "$short" -eq 0 ] ||
say " run: openRepoShape --preflight (offers what is missing; each install asks first)"
openRepoShape:60
- The linked issue's recorded command contract still specifies
./check-shape.pyandopenRepoShape --check [<path>], while this PR exposesshape-doctor.pyandopenRepoShape --doctor. The PR body mentions a later naming ruling, but the governing issue/acceptance text is not updated; either update that contract explicitly or retain compatibility aliases so closing #95 does not silently change the requested interface.
openRepoShape --install install (or update) this command into ~/.local/bin
openRepoShape --preflight check this MACHINE and stop; creates nothing
openRepoShape --doctor [<path>] diagnose a REPOSITORY against this standard
openRepoShape <Project> [--org <org>] [setup-project.py options] [-- <scaffold flags>]
shape-doctor.py:569
knownis based only on dictionary membership, so a known kind is reported as validated even when itscovered_bycheck is not applicable to this root or does not inspect this file. For example,contracts/rogue.yamlwithkind: family-manifestinside a project is silently accepted although only the project validator runs;ManifestKind.covered_byis never consulted. Make this registry/root mapping prove that the candidate is actually covered, or report such files as unvalidated findings.
entry = MANIFEST_VALIDATORS.get(kind)
(known if entry else unknown).append(f"{rel} ({kind})")
shape-doctor.py:677
- This generic remediation is emitted for every moved state, including
BOTH,UPSTREAM_REMOVED,UNMAPPED, andCOPY_MISSING, butupdate-shape.py applyrefuses those conflicts. In particular, aBOTHrow requires a human merge followed by--accept-local; this command omits that step and is guaranteed to fail when pasted. Branch the remediation on conflict state and describe the required resolution before the apply command.
return Row("shape-currency", "shape currency", FINDING,
f"{summary} ({where}): {named}",
f"{PYTHON} {ctx.shape / 'update-shape.py'} check --root "
f"{ctx.root} --upstream {ctx.shape} # then apply --at "
f"{target} --yes{accept} --branch shape/update-"
f"{target[:12]}", detail)
shape-doctor.py:584
- This row is a
FINDING, but itsnextvalue is prose rather than an executable remediation command. A caller following the documented contract that every finding names an exact next command cannot act on an unknown manifest kind; either emit a concrete command for the chosen action or represent the standard-maintenance action separately from a runnable repository fix.
return Row("manifest-kinds", "manifest kinds", FINDING,
"; ".join(parts),
"register the kind in shape-doctor.py's "
"MANIFEST_VALIDATORS, beside the check that validates it, "
"or remove the file from the root", detail)
shape-doctor.py:666
- The text before
#is onlyupdate-shape.py check, so executing thisnextvalue never performs the pin update; the purportedapplyis a shell comment. The doctor contract says a finding supplies the exact next command, so hand over an actual interactiveapplycommand (or expose check and apply as separate structured steps).
f"{PYTHON} {ctx.shape / 'update-shape.py'} check "
f"--root {ctx.root} --upstream {ctx.shape} # then "
f"apply --at {target} --yes --branch "
f"shape/update-{target[:12]}", detail)
shape-doctor.py:677
- When
update-shape.pyreports anupstream-addedfile,applydeliberately skips it unless--add <path>is supplied (update-shape.py:1140-1142). This generated command never includes any--add, so following it leaves the project behind and the doctor continues to reportSHAPE BEHIND; the handoff must explicitly surface the per-file add decisions instead of claiming this command fixes the row.
f"{PYTHON} {ctx.shape / 'update-shape.py'} check --root "
f"{ctx.root} --upstream {ctx.shape} # then apply --at "
f"{target} --yes{accept} --branch shape/update-"
f"{target[:12]}", detail)
shape-doctor.py:677
- The generated repair command unconditionally includes
--yesand, for locally modified rows, appends--accept-localviaaccept. That lets a caller execute the diagnostic'sNEXTline while bypassing the human decision to re-pin and to keep or revert local edits, contrary toAGENTS.md:240-247; do not auto-consent these options in a diagnostic handoff.
f"{PYTHON} {ctx.shape / 'update-shape.py'} check --root "
f"{ctx.root} --upstream {ctx.shape} # then apply --at "
f"{target} --yes{accept} --branch shape/update-"
f"{target[:12]}", detail)
shape-doctor.py:880
- On a FAMILY root this remediation always points at
scripts/validate-pins.py, but family holders shipscripts/validate-family.pyinstead. DeletingAGENTS-shape.mdin a holder therefore produces a NEXT command that fails even after the file is restored; select the validator fromctx.kind(and cover the family case).
f"`{PYTHON} {ctx.root / 'scripts' / 'validate-pins.py'} "
shape-doctor.py:1063
- The remediation has the same option-parsing hole: retyping the command for a name such as
--helpinvokes the validator's help and exits successfully instead of classifying that name. Keep the--separator in the emitted command as well.
f"{PYTHON} {script} --explain {' '.join(names)}", detail)
tests/test_openreposhape_command.py:75
- This constant is described as avoiding an index, but it is assigned from
USAGE_LINES[3]. Reordering the usage tuple would silently make the scaffold-refusal test assert against a different line; select the scaffold entry by its content instead.
USAGE_SCAFFOLD = USAGE_LINES[3]
tests/test_repo_hygiene.py:681
- This updated hygiene comment is grammatically incomplete: it says
--preflight“checks a” and then continues with “and creates nothing.” Add the missing noun so the documented assertion reads clearly.
# Homebrew, no terminal no offer), and that `--preflight` checks a
tests/test_shape_doctor.py:21
- The suite's ordinary
doctor()runs inherit the real environment, whileshape-doctor.pyinvokessetup-project.py --preflight; with an authenticatedgh, that path executesgh api user. Only the shim tests replacegh, so these tests can contact GitHub despite this module-level offline guarantee. Force a no-networkgh/environment for all doctor subprocesses.
NOTHING HERE REACHES A NETWORK. The scaffolds use `--local-remote-dir` (bare
repositories on disk as origins), and the two shim tests put a `gh` and a
`curl` on `$PATH` that refuse loudly, so a run that tried to fetch would fail
rather than quietly succeed against github.com.
tests/test_shape_doctor.py:343
- This new test docstring is grammatically malformed: “no validator is registered for used to be invisible” is missing the relative clause. Rephrase it so it says that no validator was registered for the manifest.
A `contracts/*.yaml` that declares a `kind:` no validator is registered
for used to be invisible — nothing walked the directory — and "we did not
- Files reviewed: 10/10 changed files
- Comments generated: 3
- Review effort level: Lite
| f"{PYTHON} {ctx.shape / 'update-shape.py'} check --root " | ||
| f"{ctx.root} --upstream {ctx.shape} # then apply --at " | ||
| f"{target} --yes{accept} --branch shape/update-" | ||
| f"{target[:12]}", detail) |
| # takes (Copilot, PR #96). | ||
| if detail["pinned"]: | ||
| first = detail["pinned"][0] | ||
| fix = (f"git -C {ctx.root} checkout -- {first} # the pin has a " |
| if not (sibling / ".git").exists(): | ||
| return False | ||
| manifest = Context._read(sibling / "project.yaml") | ||
| if not isinstance(manifest, dict): | ||
| return False |
… a root or a name with a space in it is a line that runs (#101) (#102) Lane: openreposhape-2 (openRepoShape-2) Claim: #101 (comment) Closes #101. ## What was wrong Copilot asked for shell quoting on PR #100, against the `placement` row. The finding was real and was never that row's: **every** next command since #96 builds its arguments with an f-string, so a root at `/srv/my projects/Atlas` produced a line argparse reads as three arguments and refuses — in front of whoever pasted it. That is exactly the failure `validator_row` already carries a comment about (`python3 validate-pins.py in <root>`, Copilot on PR #96), one class of value along. ## Why one form will not do, and why not `shlex.quote` The two shells are not one dialect, and **each reads the other's form as a different value with no error to say so**. `sh` reads PowerShell's doubled apostrophe as two adjacent quoted strings and concatenates them, so `'O''Brien'` arrives as `OBrien` — a different path, silently. And `\` is a literal character to PowerShell, whose escape is the backtick. Both directions are asserted (`test_the_two_shells_are_not_one_dialect`). `shlex.quote` could not be the one function either. Its module is documented as designed for Unix shells only, so it carries no promise at all about the shell a Windows reader is in — and since #49 this standard has a native Windows entry point and `shape-doctor.py` runs there by contract. Nor would its spelling do: `'C:\Users\Jane O'"'"'Neill\proj'` is a line a person is meant to **retype**, on a machine whose stock shell is Windows PowerShell 5.1 (`setup-project.py`'s own docstring), where that value is written `'C:\Users\Jane O''Neill\proj'`. ## What landed One `quote_arg(value, platform=None)` in `shape-doctor.py`: * a value matching the bare alphabet (`^[A-Za-z0-9_./:@%+=,-]+$`, plus backslashes on Windows) is returned **unchanged** — a table whose whole job is to be read would be worse, not better, for `--root '/srv/work/Atlas'` on every line of every clean run; * otherwise `'…'` with `'\''` for `sh`, and `'…'` with `''` for PowerShell; * `platform=` so both forms are testable on either host. **It lives in `shape-doctor.py`, not in `scripts/repo_shape.py`** — where the standard's other platform-aware constant (`PYTHON`) sits — because that file is a SHAPE COPY: `scripts/shape_materialize.py` writes it into every assembly root and every family holder and the shape pin digests it, so one function added there would put an `upstream-changed scripts/repo_shape.py` row in front of **every project in the estate** on its next `update-shape.py check`, for a helper no project's own copy would ever call. `shape-doctor.py` is in no copy list, by its own contract: it compares a project against the checkout it is RUN FROM. (`repo_shape.SAFE_PATH_RE` answers a different question anyway — what may become an argument to `git`, where every command is a list run with `shell=False` and the threat is argument injection, not a shell.) **Nineteen next-command strings** now pass through it — every row of all three root kinds, the two `NOT A SHAPE ROOT` way-in lines included, and the `machine` row's. `--json` carries the same quoted strings, because they are commands. `<your-org>` in the scaffold line is **not** quoted and must not be: it is a placeholder the reader replaces, not a value this command knows. ## The proof ``` FINDING naming Some Thing: FINDING naming-unclassified: Some Thing NEXT python3 …/validate-repository-naming.py --explain 'Some Thing' n/a the way in this is a git repository with no shape manifest… NEXT python3 …/adopt-project.py plan --source '…/my proj'\''ects/Some Thing' --project 'Some thing' ``` **33 tests added (8 functions), 0 existing tests changed** — `tests/test_shape_doctor.py` is pure addition, 0 lines removed, because the fixtures' paths have no spaces and every command they assert is one the quoter returns unchanged: * both forms parametrized over both platforms, over a space, an apostrophe, both at once, and a Windows drive path; * the POSIX form proved by `shlex.split` **round-trip** — the shell's own reader — rather than by a string the suite spelled; * the PowerShell form asserted exactly, apostrophes doubled; * the two dialects proved incompatible — `sh` reads `'O''Brien'` as `OBrien`; * the same Windows path quoted on POSIX and bare on Windows, said out loud; * a **whole report** of a project at `<tmp>/do ct'or/Atlas` with five rows red at once, each next command read by `shlex.split` and the root asserted to arrive as one token; * end to end: the shape-currency row's line run **verbatim** through `bash -c`, trailing `#` comment and all — it reports the drift (exit 1, naming `scripts/bootstrap.py`), where the unquoted spelling of the same line exits 2 before `python3` is reached, with bash's own `unexpected EOF while looking for matching` complaint. ## Housekeeping * `git diff --stat origin/main -- templates/` — **empty**. * `python3 scripts/render-cli-reference.py --check` — `[ok] docs/cli.md is what the generator produces`; no `--help` text moved. * Rule 1 (`test_no_committed_file_names_a_host_absolute_path`): the example paths are `/srv/...` and `C:\Users\Jane O'Neill\...` — this repository's own convention of putting a space in the Windows user name, which is what the examples illustrate anyway (`scripts/repo_shape.py`: "Jane Doe"). * No README/AGENTS.md change and therefore **no cap moved**: neither promises a copy-pasteable command, and `Run the one the row names` is unchanged prose that is now true in more cases. The `Invoke-WebRequest` single-match rule is untouched. ## Neighbouring, not taken `update-shape.py check` prints its own `NEXT …apply --root {root} --upstream {upstream.label}…` line with the same interpolation. It is out of #101's scope (which names `shape-doctor.py`) and wants its own issue and its own decision about where the quoter then lives. A path with a **non-ASCII** character in it is still flattened by `ascii_text`, which every row's text goes through — `/srv/josé/proj` prints as `/srv/jos?/proj`, quoted or not. That is this file's documented PURE ASCII rule ("a verdict a cp1252 console cannot render is a verdict nobody reads"), and unpicking it for the `next` field alone is a separate decision about the whole report, not a quoting bug. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ## Summary by Sourcery Make every command emitted by shape-doctor.py safe to read and run on the target platform, including paths and names that require shell quoting. New Features: - Add platform-aware shell argument quoting for commands emitted by shape-doctor.py, supporting POSIX shells and PowerShell. - Use platform-specific project setup commands so Windows reports setup-project.py while POSIX systems use setup.sh. Bug Fixes: - Ensure paths, project names, and other interpolated values containing spaces, apostrophes, shell metacharacters, or newlines remain valid single command arguments. - Normalize values before quoting so subsequent report formatting cannot invalidate quoted apostrophes. Enhancements: - Apply consistent quoting across all generated next-command strings, including JSON output and remediation commands. - Add platform-selectable interpreter formatting for cross-platform command generation. Tests: - Add comprehensive coverage for POSIX and PowerShell quoting, shell dialect differences, platform-specific command generation, awkward paths, and normalization edge cases. - Verify complete reports and pasted commands handle roots containing spaces and apostrophes correctly. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…and words the row in three functions instead of one loop, dropping its cognitive complexity from 29 to 8 (#134) `python:S3776` was OPEN against `check_members` at 29, over the 15 Sonar allows. One loop body read both copies of every member, decided which of three faults it had, decided whether its state was worth saying, and fed three different lists that the wording below the loop then read back. A reader who came here because a member was called `not populated` had to hold the whole loop in their head to see that the same pass had also decided whether a working clone was beside the holder. Three helpers, one per decision, each carrying the part of the WHY that moved with it: `member_state` both copies of ONE member as they are found, and why nothing is asked of a mount that is not populated: `git rev-parse HEAD` inside an empty submodule answers about the HOLDER, so an unfetched member would otherwise be reported as checked out at the holder's commit. The 40-hex rule for `pin.commit` moved here too. `member_problem` the three faults, in the only order they make sense in, and that a member at its pin but on a branch is deliberately not one of them. `members_verdict` the finding and the two `ok` wordings, and why only the pinned copies can make this row red -- the PR #96 argument about `family.py add` leaving a branch behind stays on the branch that records it. Behaviour is byte-identical: the same strings, in the same order, on every branch, and the `--json` entry for a member has the same keys in the same order it always had. The `if`/`elif` ladder over the three faults became three early returns in the helper, which answers in the same order and therefore with the same message. Measured with complexipy (SonarSource's spec): `check_members` 26 -> 8, and no helper above 8. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
… one question per function, every one of them under the 15 cognitive complexity allowed and behaviour byte-identical (#134) (#142) * shape-doctor.py: the leg-shape-files check answers one question per function instead of three in one body, dropping its cognitive complexity from 26 to 8 (#134) `python:S3776` was OPEN against `check_leg_shape_files` at 26, over the 15 Sonar allows. The body did three separate jobs: it classified every shape file of every leg through a five-way `if`/`elif` chain, it worded the row's reason, and it decided which of the missing files a copy would even fix. Each of those is a question with its own answer, and a reader who came here because the row said something unexpected had to trace all three to find out which one said it. Four helpers, one per decision, each carrying the part of the WHY that moved with it: `shape_file_state` the five-way chain: what ONE file is against the template's copy, and why `rendered` is an answer rather than `differs`. `leg_shape_comparison` ONE leg: its `--json` entry and the files that are not there, with both early returns saying which kind of "nothing to compare" they are. `leg_shape_summary` one leg's half of the row's reason. `missing_shape_file_fix` the next command, or why a copy is not one -- `copy_command` is still the only place a shell verb is spelled (#105), and the rendered-template argument from #96 moved into the docstring intact. Behaviour is byte-identical: the same strings, in the same order, on every branch. `LABEL_LEG_SHAPE_FILES` still names all three returns, the `note`-not-`FINDING` comment stays on the branch it argues, and the `CHECKS` entry is untouched. Measured with complexipy (SonarSource's spec): `check_leg_shape_files` 31 -> 8, and no helper above 6. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * shape-doctor.py: the placement check loads a policy, audits the legs and reaches a verdict in three functions instead of one body, dropping its cognitive complexity from 22 to 13 (#134) `python:S3776` was OPEN against `check_placement` at 22, over the 15 Sonar allows. The body opened with four different `n/a` refusals before it had classified a single path, closed with a five-branch precedence ladder, and wrote one leg's half of the reason as a conditional expression nested three deep inside a `join`. A reader who came here because the row said `n/a` had to read past the audit to find out which of the four refusals said it. Three helpers, one per decision, each carrying the part of the WHY that moved with it: `placement_policy` the three refusals that are THIS CHECKOUT being short rather than the repository being wrong, including the unreadable policy file, whose `n/a`-not-a-finding argument moved into the docstring intact. `leg_audit_summary` one leg's half of the row's reason: its counts, or the `state` that says why it has none -- with the Copilot PR #100 argument for printing the state rather than a zero. `placement_verdict` the precedence ladder, and why each branch outranks the one below it. It reads the counts out of the `detail` the row prints, so a number this judges on and a number the reader is shown cannot drift apart. Behaviour is byte-identical: the same strings, in the same order, on every branch. The row's `next` command is built before the verdict rather than after the first of its branches, which is a pure f-string and writes nothing. `placement_row` still puts the `--json` keys on every branch, the `placement` id and label are untouched, and no message text, exit code or written file changes. Measured with complexipy (SonarSource's spec): `check_placement` 25 -> 13, `placement_policy` 6, `placement_verdict` 7, `leg_audit_summary` 2. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * shape-doctor.py: the placement plan is composed a block at a time instead of in one run of appends, dropping its cognitive complexity from 22 to 7 (#134) `python:S3776` was OPEN against `placement_plan_text` at 22, over the 15 Sonar allows. The function wrote all four blocks of one YAML file into a single list: the header, every leg, every path to resolve, and what was never judged. Nothing separated them but blank-line appends, so a reader looking for the line that wrote a key they did not expect had to count indents to find out which block they were even in. Four helpers, one per block of the file, each carrying the part of the WHY that moved with it: `placement_plan_header` the first block, and that `kind:` is the SAFETY property -- `PLACEMENT_PLAN_KIND`, never `PLAN_KIND`, is what stops `adopt-project.py execute` being handed one of these. `placement_plan_leg` ONE leg's counts, and why a tracked name no plan can carry is written as a comment with its newlines flattened rather than as a value. `placement_plan_entry` ONE path, in an adoption plan entry's keys exactly -- the claim the adoption's own reader is held to in `test_the_placement_plans_entries_are_adoption_plan_entries`. `placement_plan_paths` the `paths:` block, including the empty one that says what its emptiness means when a leg could not be read at all. Behaviour is byte-identical: the same lines, in the same order, emitted through the same `adopt.y` and `adopt.emit`. Each helper builds and returns its own list rather than appending into the caller's, which is the only change to how the lines are accumulated; the file they join into is unchanged, `--placement-plan` still writes exactly one file where the caller named it, and `write_placement_plan` is untouched. Measured with complexipy (SonarSource's spec): `placement_plan_text` 22 -> 7, and no helper above 4. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * shape-doctor.py: the members check finds a member's state, judges it and words the row in three functions instead of one loop, dropping its cognitive complexity from 29 to 8 (#134) `python:S3776` was OPEN against `check_members` at 29, over the 15 Sonar allows. One loop body read both copies of every member, decided which of three faults it had, decided whether its state was worth saying, and fed three different lists that the wording below the loop then read back. A reader who came here because a member was called `not populated` had to hold the whole loop in their head to see that the same pass had also decided whether a working clone was beside the holder. Three helpers, one per decision, each carrying the part of the WHY that moved with it: `member_state` both copies of ONE member as they are found, and why nothing is asked of a mount that is not populated: `git rev-parse HEAD` inside an empty submodule answers about the HOLDER, so an unfetched member would otherwise be reported as checked out at the holder's commit. The 40-hex rule for `pin.commit` moved here too. `member_problem` the three faults, in the only order they make sense in, and that a member at its pin but on a branch is deliberately not one of them. `members_verdict` the finding and the two `ok` wordings, and why only the pinned copies can make this row red -- the PR #96 argument about `family.py add` leaving a branch behind stays on the branch that records it. Behaviour is byte-identical: the same strings, in the same order, on every branch, and the `--json` entry for a member has the same keys in the same order it always had. The `if`/`elif` ladder over the three faults became three early returns in the helper, which answers in the same order and therefore with the same message. Measured with complexipy (SonarSource's spec): `check_members` 26 -> 8, and no helper above 8. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * shape-doctor.py: each rung of the verdict ladder is its own function arguing its own place, dropping the ladder's cognitive complexity from 33 to 11 (#134) `python:S3776` was OPEN against `verdict_for` at 33, the highest in the file and over twice the 15 Sonar allows. The precedence the module docstring argues at length was one body with the argument scattered through it as comments between branches, so the order -- the thing a reader comes to this function for -- had to be reconstructed from forty lines of counting, comprehensions and early returns. Five helpers. The order of the calls in `verdict_for` is now the precedence, readable as the list it is, and each rung argues its own place in its own docstring: `drifted_file_reasons` the drifted copies quoted in the line, and why the two `if` chains were two groups: the states that MADE it drifted, then the states in which the standard and the copy no longer map onto each other. Same states, same order, still named only when non-zero. `drifted_reasons` that a drifted copy, a leg off its pin and a member off its pin are one verdict because they are one fact. `misplaced_verdict` UNDER DRIFTED AND OVER INVALID, and the PR #100 argument for why the list has to be non-empty rather than the row merely red. `invalid_verdict` the named gates, each of which somebody else owns. `behind_verdict` both kinds of behind, and why the pin-only one quotes commits where the other quotes counts. Behaviour is byte-identical: the same verdict strings and the same exit codes (0, 1, 2, 3) in the same order of precedence. `counts` is read inside the two helpers that use it instead of once at the top, which is the same dictionary read the same way. The catch-all stays in `verdict_for` with its comment, because it is the rung that exists so that a rung nobody wrote still fails loudly. Measured with complexipy (SonarSource's spec): `verdict_for` 38 -> 11, and no helper above 10. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
…d `open_glass` share one `SHAPE_PIN_SOURCE_<PRODUCT>`, so `--pin` refuses the pair and `validate-pins.py` notes a declared one and reads the variable for neither (#275) (#409) `pin_source_env_name` turns every character outside `[A-Z0-9_]` into `_`, so `open-glass`, `open_glass` and `open.glass` are three legal product names, with three pin files (`contracts/<product lowercased>-pin.yaml`), and one variable, `SHAPE_PIN_SOURCE_OPEN_GLASS`. On ab623dd (this branch's main parent; the same rows reproduce on c7c02fa), with the issue's own probe against local bare remotes and a `gh` that exits 97: | step | ab623dd | this head (6494714) | |---|---|---| | `scaffold-project.py --pin open-glass@<A> --pin open_glass@<B>` | exit 0, three repositories | exit 2 `scaffold-pin-collides`, nothing created | | `validate-pins.py`, no source, on a project that already declares the pair | exit 0, both skips offer `SHAPE_PIN_SOURCE_OPEN_GLASS` | exit 0, one `note neutral-pin-source-collides`; the skips offer `--pin-source <product>=<path>` and a sibling checkout only | | `SHAPE_PIN_SOURCE_OPEN_GLASS=<open-glass>` | `neutral-pin-source-unreadable` for `open_glass`, exit 1 | exit 0, the note; the variable is read for neither pin, so each pin is read from its own source or skipped | | `SHAPE_PIN_SOURCE_OPEN_GLASS=<open_glass>` | `neutral-pin-source-unreadable` for `open-glass`, exit 1 | the same | | `--pin-source open-glass=... --pin-source open_glass=...` | exit 0 | both pins recompute, exit 0, the note | **What changed.** Every variable name is kept: an operator may have set one and the docs name them. What is done instead: - `scripts/repo_shape.py`: `pin_source_env_collisions(products)` is the one pure answer, `{variable: [products]}` for each variable two or more distinct products share. Distinct means distinct PIN FILES (`pin_product_key`, `lower()`, which is what `contracts/<product lowercased>-pin.yaml` is named by), so a product typed twice or in two cases is #241's file collision and never this one. `pin_source_env_shared` is the set of those keys. - `scaffold-project.py`: `_refuse_colliding_pins` (left where it is) names each variable's `--pin` arguments as typed after #241's file sentences, in the same `scaffold-pin-collides` refusal. Dry run and real run say the same no, before any process starts and ahead of the leg-path refusal. #241's wording and remediation are unchanged when only a file collides. A NEW pair is still refused, so the situation is not created anew. - `templates/assembly-root/scripts/validate-pins.py`: one NOTE per variable, `neutral-pin-source-collides`, naming every product and the variable, the keyed `--pin-source <product>=<path>` that reads each pin, and that which declaration stays is the human's decision. It is never a finding and never moves the exit code. A product whose variable is shared does not read it (rule 2 of `resolve_neutral_pin_source`), and its skip hint offers the keyed `--pin-source <product>=<path>` and not the variable or the bare form. A variable one product has to itself reads and is offered exactly as before. - `scripts/repo_shape.py`, the two chain readers: `link_pins_from_trees` does not read a variable two links of one chain share, and the `declared-unverified` hint stops naming it. Only a hand-written chain can have two such links, since scaffold takes every link but the first from the naming policy's alphanumeric `open<Product>` form. Each reader of `pin_source_env_name`, decided: | site | decision | |---|---| | `scaffold-project.py --pin` | refuse (above) | | `validate-pins.py` rule 2 and the skip hint | a note, and the variable is neither read nor offered for a shared product | | `repo_shape.py` `resolve_link_source` (via `link_pins_from_trees`) | skip the variable when another link of the chain shares it | | `repo_shape.py` `_chain_link_findings` hint | omit the variable for a shared link | | `adopt-project.py --pin`, `plan`, `check`, `execute` | not in this PR, see below | **Fix round 1 (from the review of 34dbd86).** **The design change: a declared pair is a NOTE and not a finding. This is the lane coordinator's decision, and Brett may reverse it.** The first round made `neutral-pin-source-collides` a FINDING. Main through ab623dd scaffolds such a project (`--pin open-glass@A --pin open_glass@B` exits 0), and `update-shape.py apply` runs the NEW `validate-pins.py` over the rewritten root, so for a project already declaring the pair the finding ended every apply as `REFUSED update-validators-red`, rolled back, for this update and every later one, until a person deleted a true declaration of descent. AGENTS.md tells an agent never to edit "a pinned file, a digest or a manifest to make a row go green", and the finding's remediation was exactly that, so the person was locked out. The coordinator chose the review's option (b): it is a NOTE now. The guard stays (the variable is read for neither pin), each pin still verifies from its own source, scaffold still refuses a new pair, and `validate-pins.py` says the rest in one line. To put the finding back, restore 34dbd86's `report.finding(...)` call in `_report_pin_source_collisions` (it is not a word swap for `report.advise`: `advise` takes one string, `finding` a code and a detail), give the finding the remediation 34dbd86 had, and turn the tests that expect the note (and `test_a_project_declaring_a_colliding_pair_takes_a_shape_update`) back into exit 1; the first round's versions of all of them are on 34dbd86. - **Proved on a real old project.** Main (ab623dd) scaffolded the pair into local bare remotes; `update-shape.py apply` to the first round's head 34dbd86 exited 2 `REFUSED update-validators-red` and rolled back (`git branch` shows only `main`); to this head it exits 0, the project's validator passes and prints the note, and the doctor's `pins` row is `ok` before and after. The doctor prints `passes` for a validator that exits 0 and does not echo its stdout, so the note itself is visible in `update-shape.py apply`'s output and in `validate-pins.py`'s, and the verdict moves for no reason but the update (`COMPLIANT, SHAPE BEHIND` to `COMPLIANT`). It is now a test: `test_a_project_declaring_a_colliding_pair_takes_a_shape_update`, over local stand-ins beside the project, so no `gh` is asked. - **Collisions by the variable.** Pairs were decided by `casefold()`, but the pin file is `lower()`. `openß`/`openss`, `openſ`/`opens`, `openfi`/`openfi` and `openς`/`openσ` (the letters are U+00DF, U+017F, U+FB01 and U+03C2 beside U+03C3) share a variable and have two pin files, and were never found. They are now, from the pin-file fold (`pin_product_key`). A pool of 31 names is checked pairwise against `neutral_pin_path` and `pin_source_env_name` themselves, and no single product is ever a collision. They are reachable only from a hand-written `project.yaml`. - **Windows.** The guard's only test needed the `#!` `gh` stub and was skipped on Windows. `test_a_shared_variable_answers_for_neither_pin_with_no_gh` puts a checkout of each pin beside the project, names one in the variable, and needs no `gh`: on ab623dd it is `neutral-pin-source-unreadable`, here each pin reads its own sibling. The hint and the non-ASCII rows are tested in-process, with no skip and no filesystem. - **The hint.** For a product two pins share, the skip hint offers the keyed `--pin-source <product>=<path>`: the bare form answers for every pin with no more specific source, so with two pins it gives the other the finding this issue is about. - **Trailers and title.** The trailers of the earlier commits (a30091f and 34dbd86 name Sonnet 5.5) are settled in this message, which carries Opus 5.5. The PR title now names `repo_shape.py`. - `scaffold-project.py` is not touched this round: `fix/adopt-pin-writes-pin-file` moves that code, and the change would only conflict with it. **Left out.** - `adopt-project.py` is untouched. Its half arrives with #273's PR, which moves scaffold's pin machinery into a shared module and routes adopt through `pin_source_env_collisions`. Once it lands, the one place that still keys by `casefold()` (`pin_variable_collisions` in `scripts/shape_materialize.py`) should read `pin_product_key`; it cannot differ for an ASCII `--pin`, which is all `PIN_ARG_RE` takes. - `scaffold-project.py`'s own `_colliding_pin_variables` also keys its argument lists by `casefold()` and one docstring there still says the project's validator reports the pair "as a finding"; both go with the code when #273 moves it. #312's `PinSources` keys `--pin-source` by `casefold()` too, so `openß=` and `openss=` are one key there; that is #312's. - A product in `neutral_product_pins:` and a chain link in `naming.referent_chain` that share a variable are read by two validators in one process, and neither sees both sets. Not detected here. - The doctor does not print a passing validator's stdout, so its `pins` row does not carry the note. Not changed: it would add a file to this PR. - No `--help` text changed, so `docs/cli.md` is untouched. `README.md` is at its line cap and its blob is pinned by `docs/handbook.html`, so the one README sentence this wants needs a regenerated handbook and waits for its own change. - `validate-pins.py` and `repo_shape.py` ship into projects, so every project's `shape-pin.yaml` reads `upstream-changed` for both until `update-shape.py apply`, which now succeeds for a project that declares such a pair. **Evidence.** All on the head (6494714), with git-filter-repo 2.47.0 on PATH, a `gh` that cannot be reached (a stub first on PATH, `GH_TOKEN` bogus, an empty `GH_CONFIG_DIR`), and the repository-local `user.name` blanked at command-line scope, as the standard's checkout sets one that two scaffold tests read. - `tests/test_pin_source_env_collisions.py` is 137 tests and passes on this head. Laid over 34dbd86, 50 fail and 87 pass: the note and update tests, the non-ASCII rows, the hint, the sibling guard, and `pin_product_key` itself (which 34dbd86 does not have); the scaffold refusals, the chain readers and the controls hold on both. - Targeted, run on ad6f569, whose tree differs from this head in `tests/test_pin_source_env_collisions.py` only (the last edits made one comparison read the committed blob and wrapped one line): the new file, `test_pin_validator`, `test_neutral_pin_validator`, `test_cli_reference`, `test_manifest_validator`, `test_naming_policy` and `test_repo_hygiene` **445 passed**; the scaffold pin, collision, referent-chain, leg-path and e2e files **245 passed**; `tests/test_update_shape*.py` **218 passed, 3 skipped** (junctions, NTFS only); `tests/test_shape_doctor.py` **254 passed, 3 skipped** (the PowerShell line, a Windows host only). - On this head itself: the new file, `test_repo_hygiene`, `test_cli_reference`, `test_pin_validator` and `test_neutral_pin_validator` **244 passed**. - This head merged with origin/main a983e6a, in a throwaway worktree: the new file, `test_pin_validator`, `test_neutral_pin_validator`, the scaffold pin, collision, referent-chain and e2e files, the whole doctor file and `test_cli_reference` **590 passed, 3 skipped** (the PowerShell line); the new file alone, in its final form, **137 passed**. origin/main had moved twice since; the merge-tree below is against it. - Twelve mutation probes, each hunk reverted alone: all caught. The note-to-finding one is caught by the update test (a committed mutant, since the test clones the repository's HEAD) and the guards by the sibling test, run with every test that needs a `#!` stub deselected as a Windows runner would; the hint one by an in-process test. - Nothing ran on macOS or Windows before this PR's CI. **Merge-tree, as computed during the fix round on 2026-10-12** (every sha and head is the one it had then; main and the other branches have moved since). `git merge-tree --write-tree` of this head (6494714) against origin/main 1f90a0f is clean, and so is the merge of origin/main a983e6a, which the merged-tree runs above used. #312, #309, #270, #268, #228, #245 and #351 have landed. The rest were computed on ad6f569 (the same tree but for one test file) against a983e6a. Open PRs touching this branch's files, all clean against the head: #314, #355 and #373 (`scaffold-project.py`), #343 (`validate-pins.py`), #390 (`repo_shape.py`) and #394 (`repo_shape.py`, which conflicts with origin/main by itself). The other 25 open PRs and the lane-5 branches `fix/adopt-check-link-and-manifest`, `fix/scaffold-free-text-values`, `fix/family-init-values`, `docs/adopt-execute-exits`, `fix/yaml-flow-brackets-surrogates` and `fix/adopt-pin-writes-pin-file` (#273's, 7a94b6b, also clean for this head) are clean too. #356, #382 and `fix/adopt-record-submodule-placement` conflict with origin/main and not with this head; #358, `fix/adopt-late-failure-notice` and `fix/adopt-plan-quote-yaml-keywords` conflict with both, with origin/main by themselves, so they are not this branch's. Neither are the five PRs below #200 that origin/main has not landed (#94, #96, #98, #100 and #161), which conflict with it too. The PR set is read from the refs under `refs/pull/` that origin/main's history has no `(#n)` subject for, not from GitHub, so a closed one may be in it. **One conflict, with `fix/link-source-values` (#338, 40762ca) in `scripts/repo_shape.py`, four hunks.** Not resolved in either branch; take both sides: (1) `resolve_link_source`'s signature, `default_source=None, env_shared: bool = False, *, tried: list | None = None`; (2) its docstring, both paragraphs; (3) `link_pins_from_trees`'s docstring, both paragraphs; (4) its call, `default_source, pin_product_key(name) in shared, tried=asked)` followed by #338's `if tried is not None: tried[name] = asked`. The auto-merged `resolve_link_source` body already composes: a shared variable is never an `env` candidate and so never appears in #338's `tried`. **Known limits after the re-verification (APPROVE WITH NITS, 0 blockers, 0 should-fixes, 3 nits, at 6494714).** For the four non-ASCII pairs this change now detects (`ß`/`ss`, `ſ`/`s`, `fi`/`fi`, `ς`/`σ`), the keyed `--pin-source <product>=<path>` form does NOT separate the two pins: #312's source lookup folds both keys into one, so one pin can get a false `unreadable` finding. A sibling checkout does separate them. Only a hand-written `project.yaml` can declare such a pair. The doctor's `pins` row still prints only "passes" for a validator that passes, so it does not carry the collision note; that needs `shape-doctor.py`, and is left for a follow-up. The wording for restoring the finding is under "Fix round 1" above: it is 34dbd86's `report.finding(...)` call, not a word swap. Reviewed adversarially at 34dbd86 (CHANGES NEEDED: 0 blockers, 2 should-fixes, 5 nits). The first should-fix was the finding itself, which locked a project that already declares the pair out of every `update-shape.py apply`; the second was a description that had gone stale. Fix round 1 (6494714) made the pair a NOTE, which is the coordinator's decision and one Brett may reverse (the way back is above), keyed collisions by the pin file's own fold, gave the guard a test that runs on Windows, and made a shared product's skip hint offer the keyed `--pin-source`. Its re-verification at 6494714 found every finding handled: APPROVE WITH NITS (0 blockers, 0 should-fixes, 3 nits: the keyed form and the non-ASCII pairs, the doctor's silence about the note, and the wording for restoring the finding, each stated above). CI is green on Linux, macOS and Windows, with SonarCloud passing, at b70a07d (main a73b4e9 merged in). Its merge with main 5a25387 passed the targeted set (the six pin and scaffold test files, `tests/test_validate_pins_unreadable_workflow.py`, `tests/test_ruleset_hint_tracking_branch.py` and `tests/test_shape_doctor.py`): 850 passed, 3 skipped. Closes #275 Lane: openreposhape-5 (openRepoShape-5) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… writes its pin file as the scaffold does, so an adopted root passes `validate-pins.py` (#273); a `--pin-source` that cannot answer is `pin-source-unreadable` (#339) (#508) **Brought up to date after #409 squash-landed** by merging origin/main (9736424, #409's squash) as f9ed46f. Its `scaffold-project.py` conflict was resolved to this branch's side once `git diff b70a07d 9736424 -- scaffold-project.py` (#409's final head against its squash) came out empty. So the file is the one tested on this branch plus main's own later changes to it, and holds nothing of #409's; details below. This branch carries #275's adopt half. It was built on `fix/pin-source-env-collisions`, PR #409 (#275's scaffold half and its fix round), merged at 6494714 as 583f647, over the earlier 5690235 (34dbd86). After 6494714, #409 only merged main, five times, up to its final head b70a07d, and none of those merges has a hand edit (`git show --remerge-diff` is empty for each). Adopt's refusal of two products that share a source variable goes through #409's function, so this branch lands after #409. It was never rebased. `git diff b70a07d 9736424` is empty for each file #409 touched: `scaffold-project.py`, `scripts/repo_shape.py`, `templates/assembly-root/scripts/validate-pins.py` and `tests/test_pin_source_env_collisions.py`. What f9ed46f resolves, four files with one hunk each: - **`scaffold-project.py`.** - The conflict hunk is main's block from `PIN_COLLISION_REMEDIATION` through `_pin_collision_remediation`, which #409's squash edits: it adds `PIN_VARIABLE_REMEDIATION`, `_colliding_pin_variables` and `_pin_collision_remediation` and changes `_refuse_colliding_pins`. This branch moved all of that to `scripts/shape_materialize.py`. The hunk takes this branch's side. (The merge commit's message says "re-adds"; this is the exact account.) - #409's auto-merged import of `PIN_SOURCE_ENV_PREFIX, pin_source_env_collisions` is dropped, because nothing in the file uses either name any more. - It is not `git checkout --ours` of the whole file. Main changed the file beyond #409 since this branch last merged it: #355's `--tracking-branch` check (6c2a371) and a73b4e9's `RULESET_HINT`. Those lines stay. - The result is the file `git merge-tree` gives for this branch with main before the squash (518010b). Its diff from the file tested here has the same patch-id as main's own 3ef059c..518010b change to it. - **`templates/assembly-root/scripts/validate-pins.py`.** Main's side, which is #409's final blob, with main's #359 workflow reader in it. This branch had no change of its own to the file beyond #409. - **`adopt-project.py`, `_commit_the_split`.** - Main: #445 wraps the function in its late-failure `try`, and #394 builds an `append` with the plan's submodule record. - This branch: its only edits there were a comment and `neutral_pins=_recorded_pins(plan)` on the materializer call. - Both now sit on main's call inside the `try`: `append=append, neutral_pins=_recorded_pins(plan)`. - **`docs/cli.md`.** It is regenerated with `scripts/render-cli-reference.py`, and `--check` is ok. It differs from main's only in the `--pin`, `--pin-owner` and `--pin-source` help of `adopt-project.py plan`. `scripts/repo_shape.py`, `templates/assembly-root/scripts/validate-pins.py` and `tests/test_pin_source_env_collisions.py` are main's blobs, which are #409's: this branch adds nothing to them. Nothing of #409 is lost. Its scaffold behaviour is `shape_materialize.refuse_colliding_pins` and `pin_variable_collisions`, keyed by #409's `pin_product_key`. **73d65c6, after the merge.** - **The change.** `_read_pins` reads `plan.get("pins")` where it read `plan.data.get("pins")`. - **Why.** #445's `tests/test_adopt_late_failure.py` hands `_commit_the_split` a `SplitPlan` as its plan, a `dict` that adds `entries`. On f9ed46f, three of its tests stopped at "committing the split" with `AttributeError: 'SplitPlan' object has no attribute 'data'` (3 failed, 83 passed in that file). - **Nothing else changes.** `Plan.get` with no default returns `plan.data.get(key)` exactly, so a loaded plan reads as before. `adopt-project.py plan --pin` took a NAME only (`--pin openGlass`) and refused a trailing `@<commit>`. `plan`, `check` and `execute` each exited 0, and `execute` printed `adoption verified`. The manifest then listed the name in `neutral_product_pins:` with no `contracts/<product>-pin.yaml` beside it, and on its first run the adopted root's own `validate-pins.py` refused it as `neutral-pin-missing`. #273's table, reproduced on c7c02fa with the issue's own commands (local bare remotes, and a stub `gh` that exits 97): | `--pin` | c7c02fa | this branch | |---|---|---| | `openGlass` | `execute` exit 0, `- openGlass`; clone's `validate-pins.py` exit 2 `neutral-pin-missing` | `plan` exit 2 `pin-malformed`, with the scaffold's remediation (`--pin openGlass@<40 hex>`); no plan is written | | `opensoft/openGlass` | exit 0, `- opensoft/openGlass`; exit 2 `neutral-pin-missing` for `contracts/opensoft/openglass-pin.yaml` | `plan` exit 2 `pin-malformed` | | `spec` | exit 0; `validate-pins.py` exit 0, reading the leg's `contracts/spec-pin.yaml` as the neutral pin | `spec@<sha>` is `adopt-pin-collides` at `plan` | | `shape` | exit 0; `contracts/shape-pin.yaml` read as the neutral pin | `shape@<sha>` is `adopt-pin-collides` at `plan` | | `openGlass@<sha>`, `opensoft/openGlass@<sha>` | `plan` exit 2 `adopt-pin-malformed` | `plan`, `check` and `execute` exit 0, and `gh` is called 0 times. `contracts/openglass-pin.yaml` is written and the manifest lists `- openGlass`. In the clone, `validate-manifest.py` exits 0, and `validate-pins.py` exits 0 with `openGlass: pin commit … digest recomputes` | Brett ruled for decision 1's first option ("go with your recommendation on #273"): adopt takes the scaffold's pin and writes the scaffold's pin file. That reverses the NAME-only `--pin` from #6, and the comment that described it is replaced with the new contract. - **One implementation.** The scaffold's pin code moved into `scripts/shape_materialize.py`, next to `neutral_pin_path` and the materializer that writes the file. What moved: - `PIN_ARG_RE`, `parse_pin`, `pin_digest_from_source` and `pin_digest_from_gh`; - `declared_pin_values`, `declared_pin_products` and `PIN_COLLISION_REMEDIATION` (in #309's wording); - from #275's branch, `PIN_VARIABLE_REMEDIATION` and the variable check; - `_refuse_colliding_pins`, split into the pure `pin_collisions` and `pin_variable_collisions`, and `refuse_colliding_pins(refusal=...)`, which raises one refusal for both. The code did not move verbatim. `_refuse_colliding_pins` became the three functions above; `pin_digest_from_source` was rewritten for #339 (below); and fix round 1 changed three of them (below): `pin_variable_collisions` keys each pin by #275's `pin_product_key`, `pin_digest_from_source` spells a path that is not printable, and `pin_digest_from_gh` refuses a missing `gh`. The scaffold's behaviour is otherwise unchanged. `scaffold-project.py` imports what it calls under its old names. Lane 5's review ran 34 scaffold cases (every pin refusal, the `gh` stub's four modes, dry and real successes) on 34dbd86 and on this branch at 7a94b6b. rc, stdout, stderr, the `gh` log and the files made were identical, apart from the shape's own commit and digest and #339's row. Its pin tests and #275's pass as they are. `tests/test_git_output_decoding.py`'s exemption for `pin_digest_from_gh` follows the function to its new file. - **`plan`.** `--pin`, `--pin-owner` and `--pin-source` mean what they mean for the scaffold. `plan` reads the digest from `--pin-source` or `gh api`, and records product, repository, commit, digest and `digest_source` in the plan, so `check` and `execute` read no network for a pin. `plan` refuses: - a name with no `@<commit>`, as `pin-malformed`. That includes an empty `--pin ''`, which adopt used to drop and now refuses, as the scaffold always has; - `spec`, `code` and `shape`, in any case, as `adopt-pin-collides` (#273 decision 4), in the scaffold's sentence and remediation (#241, #309); - one product given twice, the same way, whether it is a repeat or two names that share one file (decision 5); - two products that one `SHAPE_PIN_SOURCE_<PRODUCT>` names, such as `open-glass` and `open_glass`, the same way, through #275's check; - a leg path over a pin's file, as `adopt-leg-path-collides`; - a `--pin-source` path that `check` would refuse in `digest_source:` (fix round 1), as `adopt-unwritable-value`. It is asked only when a `--pin` records the path; - with no `gh` on PATH and no `--pin-source`, `gh-not-found` (fix round 1). - **`check` and `execute`.** These are new `check` findings, and `execute` refuses each one before any leg exists. They come from `_leg_findings`, the list `check` and `_refuse_what_check_finds` share: - `plan-pin-unrecorded`: a name alone (an old plan's `pins: [openGlass]`, or a hand edit), or an entry missing its commit or digest; - `plan-pin-malformed`; - `plan-pin-collides`, which covers two pins at one file, a pin at a file the shape writes, and two products that share one source variable; - `plan-root-holds-pin`: a source path kept in the root at the pin's file. The materializer would write the shape's pin beside it under `shape/`, and `validate-pins.py` would read the source's file instead. How each finding ends: - `plan-pin-unrecorded` and `plan-pin-malformed` end with the `plan --pin <product>@<40 hex commit>` that records the pin whole. - `plan-pin-collides` ends with re-running `plan` with each product once, or, for two products that share a source variable, with one product of each such group. - `plan-root-holds-pin` ends with the kept path's own remedy: send that entry to a leg, `drop` it, or rename it in the source and re-run `plan`. A leg moved over a pin's file in the plan is `plan-leg-path-collides`. - **Also part of #386: its `pins:` row.** A hand-edited `pins:` that is not a list (a name such as `pins: openGlass`, a number, a mapping, a quoted string) is now `plan-pin-malformed` in `check` (`` `pins:` is 'openGlass', not a list of pins ``), and `execute` refuses it before any leg exists. - Where: `_read_pins` in `adopt-project.py`; the test row is `plan-pin-malformed-not-a-list` in `tests/test_adopt_pins.py`. - Before: on main, `check` said `plan ok` for the name, the mapping and the string, and gave a traceback for the number (reproduced by lane 5's review on cb7063f). #386 records that `execute` then wrote the name as eight one-letter pins. - Not fixed here: #386's other keys, `allow_empty_legs:`, `paths:`, `legs:` and `source:`, so #386 stays open. Lane 2's #435 takes all of #386, `pins:` included, and its `pins:` rule keeps only text items where this branch writes mappings; whichever lands second reconciles them (#435 (comment), and "Where the meaning meets" below). - **`execute`.** It writes each pin through `materialize_assembly_root(neutral_pins=...)`. The manifest lists the product with the owner stripped (decision 3), so the entry and the file agree. - **Docs.** `--help` is updated and `docs/cli.md` regenerated (`render-cli-reference.py --check` ok). `pin_digest_from_source` caught only `Refusal`. A directory that is no clone is git's own failure, so it was always `pin-source-unreadable`, exit 2. A path `subprocess.run` cannot enter never reaches git: it is a `FileNotFoundError`, `NotADirectoryError` or `PermissionError` out of `cwd=`, and nothing caught it. `scaffold-project.py --pin ... --pin-source <that>` ended `--dry-run` and the real run alike in a traceback, exit 1. Since the move above, `adopt-project.py plan --pin` reads its digest through the same function and ended the same way. Both reach it through `declared_pin_values`, and `check` and `execute` read no source, so that call is the only reader. The issue's table, run on ab623dd for the scaffold and on d806e8f for `adopt-project.py plan` (adopt has no `--pin-source` on ab623dd), then on this head. `gh` is a stub that logs and exits 97, with `GH_TOKEN` bogus and an empty `GH_CONFIG_DIR`; it was called 0 times in every run: | `--pin-source` | before | this branch | |---|---|---| | a directory that is not a clone | `pin-source-unreadable`, exit 2 | unchanged | | a path that does not exist | `FileNotFoundError` traceback, exit 1 | `pin-source-unreadable`, exit 2: `<path> could not answer for opensoft/openGlass @ <40 hex>: no such directory` | | a file | `NotADirectoryError`, exit 1 | exit 2, `... it is a file, not a directory` | | under a parent this user cannot enter | `PermissionError`, exit 1 | exit 2, `... Permission denied` | | a symlink loop (not in the issue) | `RuntimeError` out of `Path.resolve()` on 3.12, exit 1 | exit 2, `... Too many levels of symbolic links` | The real run and `--dry-run` give the same stdout and stderr, and nothing exists afterwards (no remote directory, no work directory; for adopt, no plan file). What changed, in `scripts/shape_materialize.py` only: - `pin_digest_from_source` catches `OSError` as well as `Refusal` and raises the existing `pin-source-unreadable` with its remediation unchanged. The message names the path and the reason. - `stat()` judges the source inside the guard, as #312 does in `validate-pins.py`, and the sentences are that file's: a missing path, or one beneath a file, is "no such directory"; a file is "it is a file, not a directory"; any other `OSError`, from `stat()` or from git's `cwd=`, is the system's own reason (`strerror`). It is not `exists()`/`is_dir()`, which before 3.14 swallow only a missing path. A source `stat()` can read but `cwd=` cannot enter, a directory with no search bit, fails in `tree_digest` and the same guard answers it. - `declared_pin_values` resolves the path through a guarded `_resolved_pin_source`. `Path.resolve()` raises a `RuntimeError` on a symlink loop before 3.13 (an `OSError` since), before the digest was asked for. As typed, `stat()` meets the loop and says so. - A source that answers is read exactly as before: a relative path resolves against the working directory, a symlink to a clone is followed, `digest_source` reads `local-clone (<path as typed>)`, and the digest is `tree_digest`'s. `tests/test_pin_source_unreadable.py` (46 tests in the #339 commit; fix round 1 adds 17 for S1 and moves one, below) runs each case through `scaffold-project.py --dry-run`, its real run and `adopt-project.py plan`: missing, a file, beneath a file, relative and missing, a parent and a source with no search bit (skipped on Windows and as root, by a mark, so before any fixture builds a directory), a 300-character name, a symlink loop (skipped on Windows) and a directory that is no clone. Each asserts exit 2, the refusal naming the path and the reason, its remediation, no traceback and nothing created. It also holds `--dry-run` and the real run to the same stdout and stderr, checks the path is printed escaped under an ASCII stderr and as a surrogate when it is not UTF-8, and checks that a relative source and a symlink to a clone read as before. The session `gh` guard fails any test whose run called `gh`. origin/main ab623dd reached this branch through implQ's branch: 34dbd86 is a30091f merged with ab623dd. One file conflicted there, `templates/assembly-root/scripts/validate-pins.py`, in seven hunks, because #312 (8cdca5e) replaced `keyed_sources` and `default_source` with `PinSources` and #275 added `env_shared` and `shared`. #312's blob is the same at its PR head, at the squash and at ab623dd, so it landed the file implQ resolved against. The resolution keeps #312's side in all seven and adds #275's on top: | # | hunk | resolution | |---|---|---| | 1 | `resolve_neutral_pin_source` signature | #312's `sources: PinSources` and 3-tuple return, plus #275's `env_shared: bool = False` | | 2 | its docstring tail | #312's `Returns (path, how, typed)` text, plus #275's "Rule 2 is skipped when `env_shared`" paragraph | | 3 | `_recompute_neutral_pin_digest` signature | #312's `sources`, plus #275's `shared: frozenset[str]` after `report` | | 4 | the `resolve_neutral_pin_source(...)` call inside it | #312's 3-tuple unpack, plus `env_shared = product.casefold() in shared` and the extra argument | | 5 | `_check_one_neutral_product_pin` signature | #312's `sources`, plus #275's `shared` | | 6 | its call of `_recompute_neutral_pin_digest` | `sources, report, shared` | | 7 | `_check_neutral_product_pins` docstring and body | #312's `PinSources(...)` and `_note_unused_pin_sources`, plus #275's paragraph, `_report_pin_source_collisions(products, report)` and `shared = frozenset(pin_source_env_shared(products))` | This branch's own merge of 34dbd86 (5690235) had no conflict, and neither had its merge of #409's fix round, 6494714 (583f647). That fix round made `neutral-pin-source-collides` a note and keyed "one product" by `repo_shape.pin_product_key`. At 421e4e5, `templates/assembly-root/scripts/validate-pins.py`, `scripts/repo_shape.py` and `tests/test_pin_source_env_collisions.py` were byte-identical to the tree `git merge-tree` gives for 6494714 with origin/main 3ef059c (blobs 5604007, 091966b, 5220787), so this branch added nothing to those three files beyond #409. The 34dbd86 merge brought in #335, #312, #317, #270 (f795cf7), #344 and #349 with no conflict. Earlier merges of origin/main (87373a6, for #309's reworded constant, and e43fa95) are unchanged. Fix round 1 merged origin/main three more times: - **cd1fc79 (2bcfa69).** It brought #245, #351, #350, #345, #372, #371, #354, #380, #377 and the rest since ab623dd, with no conflict. - **45e01f4 (4098b61).** It brought #396's `tests/test_agents_md_codes.py`. That test finds `scaffold-pin-collides` as a string constant of `scripts/shape_materialize.py`, which `SHIPPED` lists. - **3ef059c (421e4e5), #314.** One conflict, one hunk in `adopt-project.py`. This branch's `_refuse_an_unrecordable_pin_source` and #314's section "The project must be able to hold what `execute` writes into it (#261)" were added at the same place; both are kept. Where the two meet, lane 5's earlier recipe applies: - `_flag_plan` builds each pin as the `PIN_FIELDS` mapping `plan` writes, not `list(pins)` of products. So the plan `plan` asks the validator about is the plan it writes. - #314's `test_plan_asks_what_check_asks_of_the_same_keys` plans `--pin openGlass@<commit> --pin-source <stand-in>` where it planned the name alone, which `plan` now refuses. Then f9ed46f, after #409 squash-landed, and 73d65c6 after it (top of this description). On the merged tree exactly one test failed: `tests/test_adopt_template_values.py::test_check_finds_and_execute_refuses_a_hand_edited_value[pins-surrogate]`. It plans, then hand-edits the plan to `pins: ["openX\ud800"]`, a name-only pin with a lone surrogate. Before this branch the refusal's headline was `REFUSED plan-unwritable-value`. A name-only pin in a plan is now `plan-pin-unrecorded` (#273), so `check` has a second, independent finding for that very plan, and the headline is the first finding's: ``` REFUSED plan-pin-unrecorded: 2 finding(s) ... FINDING plan-pin-unrecorded: `pins:` entry 1, 'openX\ud800', is a name with no commit and no digest ... FINDING plan-unwritable-value: a `pins:` item is 'openX\ud800', which `execute` writes into the assembly root's `project.yaml`, and it holds a lone surrogate ... ``` Nothing about #270's contract changed. The lone surrogate is still found as `plan-unwritable-value`, listed under the refusal, and `execute` still refuses before any leg exists. `check` builds `_leg_findings`, where `_pin_findings` sits, before it calls `_value_findings`, so the pin finding comes first. d806e8f changes one assertion for that row, `pins` only: the headline is `REFUSED plan-pin-unrecorded: ` where it was `PLAN_REFUSED`. The other 15 rows and the finding assertions, including the `plan-unwritable-value` line, are untouched. Lane 5's review of 7a94b6b found 3 should-fix and 5 nits. Each is answered here: - **#409's `pin_product_key` (review N1).** The merge of #409's fix round could not carry it, because this branch had moved the function that used it out of `scaffold-project.py`. `pin_variable_collisions` now keys each pin by that function, where it casefolded. `openß` and `openss` are two pin files and one `SHAPE_PIN_SOURCE_OPENSS`, and a casefold named each of the two pins twice. No `--pin` or recorded `pins:` entry `PIN_ARG_RE` admits can spell either, so the test asks the function directly. `refuse_colliding_pins`' docstring now says, in #409's words, that the root's `validate-pins.py` only notes such a pair. - **S1, a `--pin-source` path that is not printable.** `pin_digest_from_source` names the path as typed unless it is not printable (`str.isprintable`), and then as Python's `repr` spells it (`shown_source`). That covers the refusal's head and git's own reason, which names the directory it ran in. Printed raw, an ESC reached the terminal, and a line break or a carriage return began a line of the path's choosing, a forged `REFUSED` line among them, from the scaffold and from adopt. The traceback #339 replaced had shown a `repr`. A printable path is named byte for byte as before. - **S2, no `gh` on PATH.** `pin_digest_from_gh` refuses as `gh-not-found`, exit 2, as `repo_shape.tree_digest_from_gh` names it, and offers `--pin-source`. It was a `FileNotFoundError` traceback, exit 1, from the scaffold and, new with this branch, from `adopt-project.py plan --pin`. - **S3, a hand-edited `commit:` or `tree_sha256:`.** The lane's decision is to accept it and document it (option (c)); no behaviour changed. A pair that disagrees passes `check` and `execute` (`adoption verified`), because neither reads a network for a pin, by design. The adopted root's own `validate-pins.py` then exits 1 with `neutral-pin-digest-mismatch` wherever it can read the product. `check` now says so once, after the pins it will write: "each pin as `plan` read it, not read again here: the root's own `validate-pins.py` recomputes its digest wherever it can read the product". Options (a), `execute` recomputes before it creates the legs, and (b), `check` recomputes from a clone still on the machine, are filed as #449. - **N2, a `--pin-source` that `plan` cannot record.** `plan` asks `check`'s question (`one_printable_line`) of the path it records in each pin's `digest_source:`, before any digest is read. It refuses one that fails as `adopt-unwritable-value`, in #270's words (`unwritable_reason`), or as "an invisible formatting character" where those name nothing. Before, it was planned, exit 0, and printed raw in the report. `check` then refused it as `plan-pin-malformed` and said to re-run the same `plan`. The report's `pin` line and `check`'s `write` line now spell the digest's source with `_shown`. The scaffold half is pre-existing (a line break in the path is written into the pin file; a byte that is not UTF-8 dies after all three repositories exist) and is filed as #450. - **N3, six hunks no test guarded.** Each now has a test that fails when it alone is reverted: - the two name guards (a `pins:` name holding an ESC and a forged line); - the lower-casing of the commit and the digest (an upper-cased hand edit); - the `digest_source` printability check; - the not-text check (`commit: 1234567` unquoted); - the gitlink filter (a submodule kept where the pin is written is `plan-submodule-root` alone). - **N4.** This body. - **N5, #339's third decision.** A `--pin-source` that nothing reads is still silent, now in adopt too. This PR does not decide it. #451, filed, lays out refuse, note and leave, so closing #339 loses nothing. Lane 5's second review, of 421e4e5, found no blocking item, 2 should-fix items and 3 nits. The two should-fix items are this body: the landing after #409 (above) and #386 (above). The code needed no change for them. f63d1ed adds two tests and no code: - **n1. `plan` asks nothing of a `--pin-source` no `--pin` records.** With the `args.pin and` guard dropped, such a path holding an ESC or a zero-width joiner was refused in a sentence naming no file ("`execute` writes into , and ..."), and every test still passed. `test_a_pin_source_no_pin_records_is_not_asked_about` holds the plan to exit 0 and `pins: []`, with the path named nowhere in the plan or the report. The ESC row is POSIX-only by the file's `POSIX_NAMES` mark; the zero-width joiner row runs everywhere. It holds #451's answer today, silence, so a decision there changes this test on purpose. - **n2. A printable `--pin-source` is printed as it is.** With `_spelled` in place of `_shown` in `plan`'s `pin` line, every test still passed. `test_a_printable_pin_source_is_printed_as_it_is` holds `plan`'s `pin` line, and `check`'s `write` line for the plan `plan` wrote, to their exact text, ending `(local-clone (<path>))` with no backtick. - **n3** needs a code change and is left out (below). **Fix round 2, on f63d1ed.** Each run had a `gh` stub first on PATH (it logs and exits 97), `GH_TOKEN` bogus, an empty `GH_CONFIG_DIR`, `git-filter-repo` 2.47.0 next on PATH, and the identity blanked with `GIT_CONFIG_COUNT`; the session `gh` guard came first inside each run. - **The pin set: 812 passed, 2 skipped.** It covers adopt pins, adopt plan, #339's file, #275's tests, the pin and neutral-pin validators, git output decoding, adopt template values, CLI reference, scaffold pin and reuse, scaffold pin collisions, #314's two files and #396's file. The skips are `test_adopt_plan.py:403` (no MedxEHR clone) and `test_adopt_template_values.py:223` (this host reads `git config user.name` from the repository, not from `GIT_CONFIG_GLOBAL`). That is fix round 1's 809 passed, plus the three new rows. - **Shape doctor and scaffold leg-path collisions: 369 passed, 3 skipped** (the PowerShell line exists only on a Windows host). - **Mutation probes**, each one line changed in a throwaway worktree, over `tests/test_adopt_pins.py` and `tests/test_pin_source_unreadable.py` less the five end-to-end adoptions: - the `args.pin and` guard dropped: 2 failed, both n1 rows; - `plan`'s `pin` line `_spelled`: 1 failed, the n2 test; - `check`'s `write` line `_spelled`: 2 failed, the n2 test and `test_an_upper_cased_hand_edit_is_written_lower_cased`; - `plan`'s `pin` line raw: 1 failed, the no-break-space test that already guarded that hunk. **On the merged tree, 73d65c6** (the merge f9ed46f and the `_read_pins` commit), with the same harness: - **The pin set** above, with #445's `test_adopt_late_failure.py`, `test_adopt_git_reads.py` and `test_adopt_filter_repo_failure.py` and #387's `test_adopt_empty_symlinks.py` and `test_adopt_root_manifest.py`: **988 passed, 2 skipped**. The skips are the two above. - **Shape doctor, scaffold leg-path collisions and the adopt suites:** **967 passed, 3 skipped** (the PowerShell line). The adopt suites are e2e, execute refusals, verify, root shape paths (#387's too), leg-path collisions, clone template, ignored shape files and submodules. - **On the merge alone, f9ed46f** (the same tree as before the `_read_pins` commit): `tests/test_adopt_late_failure.py` gave 3 failed, 83 passed, the three `AttributeError` rows above. - `render-cli-reference.py --check` is ok on the merged tree. pyflakes reports the same four warnings on `adopt-project.py`, `scaffold-project.py` and `scripts/shape_materialize.py` as before the merge. **Fix round 1, on 421e4e5.** Each run had `git-filter-repo` 2.47.0 on PATH and the identity blanked with `GIT_CONFIG_COUNT`. A `gh` stub that logs and exits 97 was first on PATH, with `GH_TOKEN` bogus and an empty `GH_CONFIG_DIR`, and the session `gh` guard came first inside each run. - **The pin set:** 809 passed, 2 skipped (the same files and skips as above). - **Doctor and scaffold:** 782 passed, 3 skipped (the PowerShell line exists only on a Windows host). It covers shape doctor, scaffold leg-path collisions, scaffold e2e, referent chain links, naming policy, repo hygiene and #351's free-text values. - **The adopt suites:** 882 passed. It covers e2e, execute refusals, verify, spec-only, leg paths, root shape paths, plan escapes, leg-path collisions, clone template and submodules. - **Before the #314 merge,** on 74ce4d9's tree: the first two sets gave 577 passed, 2 skipped and 782 passed, 3 skipped. On 2bcfa69's tree (the merges alone, before the fix) they gave 542 passed, 2 skipped and 782 passed, 3 skipped. After the 45e01f4 merge, `tests/test_agents_md_codes.py`, repo hygiene and CLI reference: 110 passed. - **Lane 5's second review** also ran 421e4e5 merged with main cb7063f and with 53bee5b: the pin set, the manifest-value set, and the doctor set with #357's `tests/test_doctor_validator_rows.py`. All passed, with only the skips above. Proof that fix round 1's tests test something: - **On 2bcfa69's tree,** with this head's two test files laid over it, 31 of the new rows fail: - S1: 17; - N2 and its report spelling: 7; - S2: 3; - the `pin_product_key` port: 2; - `check`'s S3 line: 1; - the not-UTF-8 `adopt plan` row: 1. The N3 rows pass there, as they must: they guard hunks this branch already had. - **Mutation probes.** Each hunk was reverted alone, in a throwaway worktree, and both test files were run: 18 of 18 were caught. - **The port:** the casefold keying (2 fail); the casefold lookup alone (2). - **S1:** the path named raw (13); git's reason named raw (2); every path `repr`'d, printable or not (27). - **S2:** no `except` (3). - **N2:** no `plan` check (11); only #270's question asked (1); the formatting-character reason said otherwise (1); the report's `pin` line raw (1); `check`'s `write` line raw (1). - **S3:** the line dropped (1). - **N3:** the `_pin_fix` name guard (1); the `_read_pins` path guard (1); the lower-casing (1); the `digest_source` check (1); the not-text check (1); the gitlink filter (1). - **The issue rows reproduced.** S1, S2 and N2 were reproduced on 2bcfa69's tree and shown gone on the fix (a probe driving both tools; `gh` was called 0 times). **Before fix round 1.** Runs were on 7a94b6b, with `git-filter-repo` 2.47.0 first on PATH and the repository-local `user.name` blanked with `GIT_CONFIG_COUNT` (a workstation whose standard checkout sets one fails `test_the_scaffold_refuses_with_no_elector` on main itself; CI sets none). 7a94b6b differs from ffd1297 in `tests/test_pin_source_unreadable.py` only, so the three suites that do not read that file ran on ffd1297: - the new file: 46 passed; - adopt pins, adopt plan, git output decoding: 172 passed, 1 skipped (the MedxEHR clone is absent); - scaffold pin and reuse, pin collisions, e2e, referent chain links, neutral pin and pin validators, #275's tests, naming policy, repo hygiene, CLI reference, scaffold leg-path collisions: 571 passed; - shape doctor: 254 passed, 3 skipped (the PowerShell line exists only on a Windows host); - the new file with repo hygiene, git output decoding and CLI reference, once more after the last edit: 176 passed. Earlier on 5690235 and d806e8f, before the #339 commit: the adopt suites (e2e, execute refusals, verify, spec-only, leg paths, root shape paths, plan escapes, leg-path collisions, clone template) 740 passed, and `tests/test_adopt_template_values.py` with #273's other adopt tests 489 passed, 2 skipped. They were not re-run on 7a94b6b: the #339 diff touches `pin_digest_from_source` and the call in `declared_pin_values`, which those suites reach through `test_adopt_pins.py` only. Nothing was run on macOS or Windows. Proof the new tests test something: - **On d806e8f.** 38 of the 46 fail, each on the traceback and its exit 1. The 8 that pass are the unchanged behaviour: the not-a-clone refusal (4 rows) and the valid-source rows (4). - **Mutation probes.** Ten hunks reverted one at a time, each failing at least one new test: the `OSError` catch (16 fail), the catch narrowed to `OSError` only (21), the missing-path clause (9), the clause narrowed to `FileNotFoundError` (3), the `S_ISDIR` judgement (3), the loop guard (4), no resolve at all (3), the old `.resolve()` call (4), the reason as `str(exc)` (12), and the file sentence as the OS's (3). - #273's own 52 tests still fail on c7c02fa (51 fail or error; the one that passes checks the test's own table), and its 18 mutation probes were each caught. **Re-verified after the merge.** An independent re-verification of f9ed46f and 73d65c6 found the code correct: - #409 is carried whole. A 30,000-case fuzz of `--pin` lists through #409's final refusal and this branch's port differed in 0 cases. - `scaffold-project.py` equals the tested file plus main's own changes that are not #409's (same patch-id). - `_commit_the_split` keeps #445's `try` and #394's `append`. - `_read_pins` reads a loaded plan as before. Its findings were all in this description (the #506 bullet and three stale facts), now fixed. Runs on the head and on its merge with main 48585e6: 988 passed, 2 skipped; and 967 passed, 3 skipped. `git merge-tree --write-tree` was run at 01:48Z on 2026-10-13, comparing hunks per file. Each PR head, fetched from `refs/pull/<n>/head` with no `gh`, was merged with 73d65c6 and with origin/main 9736424 alone. Two sets were asked about: - every PR this description listed before that main does not now contain; - every PR numbered above #468 whose head main does not contain: #473, #474, #490, #491, #493, #494, #495, #496, #497, #503, #504 and #505. **Open state, read with `gh` by the coordinator at 02:00Z and refreshed at 02:25Z after a re-verification on main 48585e6.** Every pull request named below is open. #184, #94, #96, #98, #100 and #161 are closed, and #465 landed as 48585e6. `fix/adopt-plan-quote-yaml-keywords` has no pull request. #506 (`fix/scaffold-reuse-seeded-legs`) opened after this list was made, and the re-verification reads it. - **Landed since the last draft of this list:** #343, #346, #355, #358, #373, #378, #382, #387, #394, #397, #401, #404, #409, #419, #452, #456, #465, #466 and #484. #394's `_commit_the_split` conflict and #401's `docs/cli.md` conflict are both resolved in f9ed46f, above. - **Clean, 20:** #266, #347, #356, #374, #376, #384, #395, #453, #467, #468, #473, #474, #490, #491, #493, #494, #495, #497, #503 and #505. #453, #468 and #491 were updated onto main since the first read and now merge clean. #507 (lane 5's #486-#488) shares only the generated `docs/cli.md` with this branch and merges clean with it. - **Conflicting with main alone, and this branch adds no hunk:** - #402: `shape-doctor.py` 5; - #496: `shape-doctor.py` 10 and `tests/test_shape_doctor.py` 1. **Conflicts this branch adds:** - **#435** (3efcc7a, lane 2's `fix/adopt-plan-field-types`, for #386). - It adds 2 hunks in `adopt-project.py`: 5 here, against 3 with main alone. They are `render_plan`'s `pins:` line and `Plan.pins`. - Keep this branch's `_pin_lines` and `_pin_products`. The rest is under "Where the meaning meets". - **#504** (37ef29a, `fix/adopt-root-kept-symlinks`). - It adds 1 hunk in `adopt-project.py`: 2 here, against 1 with main alone. It is the materializer call in `_commit_the_split`. - Keep both arguments and both comments: `append=append, neutral_pins=_recorded_pins(plan), spell=_spelled`. - **#506** (119d8c4, `fix/scaffold-reuse-seeded-legs`). - It adds 1 hunk in `scaffold-project.py`. With main alone, #506 conflicts only in `docs/handbook.html`. - #506 inserts `LEG_TEMPLATES` right after `declared_pin_products`, which this branch moved out, and rewrites `_reusable_remotes` further down. Keeping both sides breaks the file with an unterminated string literal. - Keep only #506's `LEG_TEMPLATES` block. Drop #506's `declared_pin_values`/`declared_pin_products`, which moved here, and this branch's three-line `_reusable_remotes` opener, which #506 rewrites below. Resolved that way, pyflakes is clean and #506's scaffold tests pass (88). - **`fix/adopt-plan-quote-yaml-keywords`** (ed9968f; a branch with no pull request). - It adds 2 hunks in `adopt-project.py`: 3 here, against 1 with main alone. - One is `render_plan`'s `pins:` line. Keep `_pin_lines`, which already sends product, repository and `digest_source` through `y`. - The other is `_refuse_unholdable_values`' signature. Keep `pins: dict`, with that branch's `_validator_judged` and `_named_as_read` above it. - `fix/adopt-late-failure-notice` is no longer on origin. #445, the late-failure notice, is on main and merged here. **Where the meaning meets:** - **#435 and #386.** The coordinator has said this on #435: #435 (comment) - #435's `_plan_key_findings` (`plan-bad-pins`) keeps only text items in `pins:`, and its `PINS_REMEDIATION` tells a person to write `pins: [openGlass]`. - This branch writes each pin as a mapping, and it makes a name alone `plan-pin-unrecorded`. - Read from #435's code, not run: on a tree with both, the plan `plan --pin` writes is `plan-bad-pins` in `check`. - Whichever lands second reconciles them, with three changes: - `_plan_key_findings` takes this branch's mappings, or leaves `pins:` items to `_read_pins`; - a `pins:` that is not a list gives one finding, not both `plan-bad-pins` and `plan-pin-malformed`; - `PINS_REMEDIATION` says the mapping `plan` writes. - Until that is done, `tests/test_adopt_pins.py::test_a_plan_with_a_whole_pin_checks_ok` fails. - **#314.** It landed, and it is merged here (above). - **`fix/adopt-plan-quote-yaml-keywords`.** Its pin tests are written against the name-only `--pin`. They need the `name@commit` form, and their expected `pins: [...]` line becomes `_pin_lines`'s mapping. - **Two unwritable values are refused in two runs (lane 5's second review, n3).** `plan --elected-by 'A<LF>B' --pin openGlass@<sha> --pin-source <a path holding an ESC>` refuses the elector alone, exit 2. Re-run with the elector retyped, it refuses the source; #270's refusal names every unwritable value at once. Reproduced on 421e4e5, with `gh` called 0 times. One refusal would need a code change, not made here: - `_refuse_an_unrecordable_pin_source` would split into a function that returns the sentence; - `_checked_plan_inputs` would ask it before #270's `unwritable_values` raise, and raise one `adopt-unwritable-value` that names both, with both remediations; - a test would add the two-value row. N2's question is `one_printable_line`, not `unwritable_reason`, so it cannot simply join #270's list. - **Docs.** The README, AGENTS.md and `docs/handbook.html` are unchanged, because none of them calls adopt's `--pin` a name. A sentence saying adopt now takes the scaffold's `--pin` is a follow-up. It costs an AGENTS.md line-cap raise, and a README edit forces the handbook's README blob to change. - **A product spelled `null`, `true` or `false`.** The scaffold already accepts `--pin null@<sha>`: it exits 0 and builds a root whose `validate-pins.py` exits 1 `neutral-pin-entry-malformed`. Adopt's `plan` writes `product: null` through `y`, and `check` then finds `plan-pin-malformed` and refuses it before any leg exists. The one fix for both tools is in `parse_pin`, and it would change the scaffold's behaviour. - **Wording shared with the scaffold.** `digest_source` is written bare into the pin file, so a `--pin-source` path holding ` #` is cut short there. `templates/assembly-root/contracts/neutral-product-pin.yaml` and `validate-pins.py`'s `neutral-pin-missing` remediation name only the scaffold as the writer. Two comments in `scripts/repo_shape.py` still name the scaffold's `pin_digest_from_gh`, in a digest-pinned shipped copy. - **Filed as follow-ups:** - #449: S3, a hand-edited `commit:` or `tree_sha256:` that disagrees, with options (a) and (b); - #450: the scaffold half of N2, a `--pin-source` path no file can hold; - #451: #339's third decision (N5), a `--pin-source` that nothing reads. - **`validate-pins.py` prints a `--pin-source` path raw** in `neutral-pin-source-unreadable`, the twin of S1. It is a shipped template that #409 and other open PRs edit, so it is left for its own change. No issue is filed for it yet. - **Windows and macOS** were not run here; CI ran both (below). Two assertions that depend on what Windows answers for a path (a name past the filesystem's limit, a path beneath a file) check only the refusal and its remediation there. Fix round 1's rows that need a control character or a byte that is not UTF-8 in a path, or a symlink to `git`, are skipped on Windows by a mark, and so is fix round 2's ESC row. The rows for a no-break space and a zero-width joiner run everywhere, and so does the in-process `gh-not-found` test. Reviewed independently by lane 5 at 7a94b6b (3 should-fix, 5 nits: fix round 1) and at 421e4e5 (0 blockers, 2 should-fix, 3 nits: fix round 2). After #409's squash, the re-verification of f9ed46f and 73d65c6 found the code correct; its 1 should-fix and 3 nits were in this description and are fixed. GitHub's update-branch then merged main twice (33bae3f, 2170526), with no hand edit. CI's tests, tests-macos and tests-windows and SonarCloud all passed at 2170526 (main cac6bb2 merged in). On that head merged with main 57c85e9 (#490, #474 and #468, none of which touches this branch's files), the pin and adopt set with `tests/test_update_shape_landing.py` gave 1112 passed, 2 skipped, and the doctor, adopt end-to-end, unfinished-merge and bootstrap set gave 1056 passed, 3 skipped (the doctor's PowerShell line, which exists only on a Windows host). Closes #273 Closes #339 Lane: openreposhape-5 (openRepoShape-5) Co-Authored-By: Claude Opus 5.5 <[email protected]>



Lane: openreposhape-2 (openRepoShape-2)
Claim: #95 (comment)
Closes #95.
Brett Heap, 2026-09-10: "what tools do we have to check a repo to make sure
it is compliant with openRepoShape?" → "add that", then the naming ruling
"lets use doctor for this, it is better fit. use preflight for the
preflight", then "add the two shim behaviours too".
Seven commits, and they read in order.
1.
c47cd65— the machine check is--preflight--doctorhas meant "check this MACHINE and stop" since #59, which is therun's own section (1) and nothing else. The word a person reaches for when
they mean "tell me what is wrong with this repository" was spent on the one
thing here that is not a diagnosis of a repository. A rename and nothing
else: the flag reaches
setup-project.pythrough the same passthrough andreturns from the same position in
_main.--doctorappeared 38 timesbefore,
--preflightappears 38 times after; the two remaining--doctors are the shim's note saying what the flag used to be called.setup.shnames neither and forwards everything untouched.2.
2986031—shape-doctor.py, andopenRepoShape --doctor [<path>]One command, one verdict, and it reimplements nothing:
update-shape.py's verdict machinery is imported (by path — the filename hasa hyphen), and the validators are run, the project's own copies first
because those are the pinned ones. No writes, no fetch: the upstream a
project is compared against is the checkout the script is run from.
The checks are a registry —
id,applies_to,run(ctx) -> Row, and afixslot that isNonein every one of them, which is where the repairmode hangs rather than a rewrite. Manifest validation is a second registry
keyed by
kind:, so acontracts/*.yamlnothing validates is a FINDING byname instead of a silence.
COMPLIANTCOMPLIANT, SHAPE BEHIND (n upstream-changed, m upstream-added)DRIFTED (…)— a copy edited here, or a leg off its pinINVALID (<rows>)NOT A SHAPE ROOTDrift outranks a red validator deliberately: an edited shape copy is what
makes
validate-pins.pyred, soINVALIDwould name the symptom while thefix is
update-shape.py.NOT A SHAPE ROOTadds one line saying the machinecheck is
openRepoShape --preflightnow.Rows:
naming·manifest·pins·manifest-kinds·shape-currency·legs·leg-shape-files·agent-files·machinefor a project;family·manifest-kinds·shape-currency·agent-files·members·machinefor a holder;naming·contents·way-in·machinefor adirectory that is neither.
machineisn/aby status and cannot move theverdict — it is the one row that asks a question (
gh auth status) thatleaves the disk.
The shim's
--doctorruns the script from the checkout beside it, elseclones the standard the way
setup.shself-bootstraps — with one forceddeviation, no
--depth 1: a one-commit history cannot answer acomparison against the commit a pin names.
3.
dd5e92c— README, handbook, AGENTS.mdA
###under "Keeping a project's shape current" (no new##— thehandbook guard maps those), its contents row,
shape-doctor.pyin the Layoutblock; a
<section id="doctor">on the page with its entry inHANDBOOK_SECTION_WITHOUT_A_README_H2and the footer re-cut togit hash-object README.md; and## Checking a repository's complianceinAGENTS.md — five points, each one a way an agent gets a report wrong.
4.
1201589— the suitetests/test_shape_doctor.py, 23 tests. The fixture commits this workingtree's tracked files into a temporary repository and scaffolds from that,
because a doctor cannot be tested against a working tree: an uncommitted edit
under
templates/would reportlocally-modifiedfor a file nobody touched.Two tests found something.
test_the_doctor_writes_nothingcaught thesubprocess validators writing
scripts/__pycache__/into somebody else'srepository — from a command whose first promise is that it writes nothing
(
PYTHONDONTWRITEBYTECODE=1is the fix). And the registry test asserts everyfixis stillNone, so the day one is filled somebody says so out loud.5.
b0796a4— the two shim edgesA bare
openRepoShapeprints its usage and exits 1 (any scaffold argumentkeeps today's behaviour and refusals;
--helpstill exits 0;setup.shuntouched).
--installends with a read-onlymachine:block —git,ghand its login state,
python3,git-filter-repo, eachpresentorMISSING— that installs nothing, asks nothing and changes no exit code, andpoints at
--preflightwhen something is missing.6.
dfb23e1— the review roundNine findings from Copilot, and every one of them a line that looked right.
Four remediations were not runnable commands:
python3 validate-pins.py in <root>and its twin in the legs and members rows emittedinas anargument; two new tests now RUN the command a row hands over and assert it
reproduces the finding and then fixes it. A missing leg file was offered a
cpof a template full of{{PLACEHOLDER}}s. A deletedAGENTS-shape.mdwas sent at
apply --add, which refuses a path the pin already names — it iscopy-missing, so the row reads the pin's own rows and hands overgit checkout --instead.A pin naming an older commit with no copied file differing was reported
COMPLIANT, contradicting the sentence that defines it; it is
COMPLIANT, SHAPE BEHINDnow, asupdate-shape.py checkhas alwaystreated it. Two modes was last-wins —
--doctor <path> --installdroppedthe diagnosis — and is a refusal naming both.
$OPENREPOSHAPE_REFreachedgit checkoutunchecked; it getssetup.sh's three checks insetup.sh'sorder, the checkout is spelled
"$REF" --rather than-- "$REF"(a leading--makes git read it as a pathspec), and a checkout with noshape-doctor.pyrefuses by name instead of leaving python3 to saycan't open file. A sibling was any directory with a.git; it is now askedwhether it IS this project, the way
scripts/siblings.pyasks.One finding was taken half, and the suite says so: a member at its pin but on
a BRANCH is recorded and reported, and is not a finding —
family.py additself leaves one on a branch, so refusing there would refuse a holder the
standard's own tool had just made.
7.
d9dc645— the adversarial reviewFive fixes, and the first two are why this had not earned a merge.
shape-doctor.py --root ~/projects/InkRouter/IRRSprintedINVALID (leg-shape-files)over an estate whose every real gate was green, becausetemplates/spec-root/.gitignoreentered the standard after IRRS wasscaffolded — so every project cut before that commit was failed by a rule
this standard never made. The fix is a fourth status:
noteis a differencenothing asserts, and
FINDINGnow means exactly something else assertsthis. The suite was blind to it (the fixture standard is always this
checkout), so the new test builds history as it happened: a standard without
the file, a project scaffolded from it, then the file added. A lone
shape-doctor.pydied atimport repo_shapewith exit 1 — this tool'scode for "the repository has findings" — because the
SHAPE_MARKERSguardlives inside
main(); the refusal is now a function defined before thefirst import, and the test's workaround (it copied
repo_shape.pyin besidethe lone file) is gone.
COMPLIANT, SHAPE BEHIND (0 upstream-changed, 0 upstream-added)was zeroby construction on that branch and fired on both real estates; it reads
(pin 3a927a2544e8 -> dfb23e1de1c2, no copied file differs)now. The doctorwrote
__pycache__/into the standard's own checkout via in-processimports. An unresolvable pin was
INVALID; it isCANNOT ANSWER, exit3, with a
REFUSEDline — that is this checkout failing to ask, not therepository being wrong. And one sentence that was false: the machine row
makes three calls to
gh, not one.Read back on both real estates, read-only:
COMPLIANT, SHAPE BEHIND (pin 3a927a2544e8 -> dfb23e1de1c2, no copied file differs).Acceptance
python3 -m pytest tests -q— 816 → 873 passed, 1 skipped.git diff --stat origin/main -- templates/— empty. No project gets anupstream-changedrow out of this.wc -l README.md AGENTS.md— 1324 / 400, against caps raised to 1324 / 400with dated docstring entries naming One command answers whether a repository is compliant with openRepoShape, and what is missing when it is not #95.
/bin/bash -n openRepoShapeparses (the macOS 3.2 claim).🤖 Generated with Claude Code