Skip to content

validate-pins.py (assembly-root template): a .github/workflows/ directory that this user cannot list or search is a workflow-unreadable refusal naming it, exit 2, so the project's pins gate no longer ends in a PermissionError traceback, exit 1, where a workflow file it cannot open already was one (#434) - #633

Merged
brettheap merged 2 commits into
mainfrom
fix/434-validate-pins-workflows-dir
Oct 16, 2026

Conversation

@brettheap

@brettheap brettheap commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-4 (openRepoShape-4)

Claim: #434 (comment)

What changed and why

_workflow_refs in templates/assembly-root/scripts/validate-pins.py reached the workflows with three calls that had no handler: workflows.is_dir(), workflows.iterdir() and is_file() on each child. main() catches Refusal alone, so a .github/workflows/ this user could not list, one it could list but not search, or a .github/ it could not search ended the run in a PermissionError traceback, exit 1, the code this validator gives a finding. #359 refused a workflow FILE it cannot open and left the directory around it unguarded.

All three modes the issue probes are now refusals, exit 2, under the id #359 introduced (workflow-unreadable), so one id says "this validator cannot read the workflows" whatever the cause:

mode now
.github/workflows/ 000 REFUSED workflow-unreadable: .github/workflows: cannot be listed (Permission denied)
.github/ r-- (workflows/ never reached) the same refusal and the same line
.github/workflows/ r-- (listable, not searchable) the one file refusal, one line per .yml/.yaml: .github/workflows/legs.yml: cannot be read (Permission denied)
.github/workflows/ 755 pins ok, as before

Same code, not a sibling. The issue asks for workflow-unreadable in #359's words, and #383 gave bump-leg.py one id for the file and the directory. The words fit: <path>: cannot be listed (<reason>) is cannot be read (<reason>) for a directory. The remediation did not fit (_workflow_unreadable opens "N workflow file(s) ... cannot be read" and a directory has no files to count), so the directory gets its own remediation under the same id: why every file is read and never skipped, then "Restore read and search access to .github/workflows/ and to every directory above it inside the root (chmod u+rx on each, or fix who owns them). Then run the same command again." A cause that is no permission (I/O error, too many open files) is not told to chmod.

One edit outside _workflow_refs and the new helpers: the file refusal's cannot be read advice now also says "and search access to every directory above it inside the root", because in the r-- row each file is named while its own mode is fine; without it the remedy is wrong for that row. It still says "restore read access" and still never says "re-save" (#359's test holds both).

_is_a, not is_dir()/is_file(). Those raise a refused stat up to Python 3.13 and answer False to ANY OSError from 3.14. Wrapping them in a handler would have fixed 3.12 and left 3.14 reading an unsearchable .github/ as "no workflows" and every file of a listable-but-unsearchable directory as "not a file": pins ok over workflows nobody read, which is what the gate exists to prevent (#383's bump-leg hit exactly this on CI's 3.14). _is_a asks stat() and answers False only for the errors pathlib ignored up to 3.13 (ENOENT, ENOTDIR, EBADF, ELOOP, Windows' 21, 123, 1921), so every Python gives one answer, a name with nothing at it stays "no workflows", and any other OSError is named. It is bump-leg.py's helper of the same name, minus the NUL branch no path here can reach.

Pinned template copy. templates/assembly-root/scripts/validate-pins.py is the only copy in this repository (git ls-files | grep validate-pins), and nothing in the tree records its digest or blob (searched for the old sha256 and blob: none). A scaffold computes the digest of the copy it writes; a project already cut sees scripts/validate-pins.py as upstream-changed until its owner runs update-shape.py apply, as with #359. #359 and #412 changed only this file and a new test file, and this one does the same. --help is the docstring's first line, unchanged, so docs/cli.md is unchanged; no README, AGENTS.md or handbook sentence says what this validator refuses for a workflow, so none is false.

Tests

New file tests/test_validate_pins_unreadable_workflows_dir.py (28 tests), on #359's harness (tests/test_validate_pins_unreadable_workflow.py): the validator a real scaffold wrote, over a committed tree, with chmod, restored in a finally.

  • The issue's rows: 000, r--, .github/ r--, and 755 as the control (test_the_remedy_is_the_whole_of_it runs the same command with the mode back and gets pins ok). Each asserts exit 2, the refusal id, the line in full, the remediation in full for the directory, no Traceback, no PermissionError, no absolute path, and that nothing was written (every file under the root outside .git and __pycache__ unchanged, git status clean). The validator has no --dry-run.
  • The doctor's pins row quotes the directory's line.
  • Controls that must not change: nothing at the name (no workflow files, no workflows/, no .github/) and a file where a directory should be are still "no workflows" (the run then reaches the shape pin's own shape-copy-missing finding, exit 1, as before).
  • In-process cases that run on every Python, root and Windows included: a refused stat answered as 3.14 answers it (is_dir/is_file/exists False to any OSError), for the directory and for each child; two refused children named in ONE refusal; a listing that fails with EIO/EMFILE; ENOENT/ENOTDIR/ELOOP/EBADF and the three Windows errors stay absent; EACCES/EPERM/EIO/ENAMETOOLONG are refused, and only the permission ones are told to chmod.
  • The mode tests skip on Windows and as root. This container runs as uid 1000, so they ran here; none skipped.

On main's unmodified template the new file is 16 failed, 12 passed: the three mode rows end in the PermissionError traceback, the doctor row says "crashed before reaching a verdict (exit 1): PermissionError", and the in-process refusals fail; the 12 that pass are the controls (nothing at the name, a file where a directory should be, the Windows errors) and the 755 control. With the fix, 28 passed.

Targeted run, one background run: 1692 passed, 3 skipped in 21m52s, exit 0, across the new file and 25 existing files that run the code (test_validate_pins_* x4, test_pin_validator, test_neutral_pin_validator, test_pin_source_unreadable, test_pin_source_env_collisions, test_refusal_default_remediation, test_validator_child_encoding, test_shape_pin_files_not_a_list, test_doctor_validator_rows, test_doctor_validator_verdicts, test_doctor_gitlink_repairs, test_bump_leg_unreadable, test_bump_leg_unopenable, test_update_shape_kept_helper, test_template_text_placeholders, test_scaffold_e2e, test_scaffold_pin_and_reuse, test_adopt_e2e, test_adopt_root_symlinks, test_shape_doctor, test_repo_hygiene, test_cli_reference, test_agents_md_codes). The 3 skips are tests/test_shape_doctor.py:9965 (PowerShell line, Windows host only).

Fix round 1 (head ac508957, tests only; the template is byte-for-byte as in f7f5de51). SonarCloud's gate failed on f7f5de51: 3.3% new duplication, and one python:S5958 ("assertion too broad"). The duplicate was my 19-line copy of refused_stat from tests/test_bump_leg_unopenable.py:586-604 (the #383 stand-in for 3.14's answer to a refused stat); it is now imported, so the same four patches run from one definition. The S5958 was pytest.raises(Exception) in refusal_of; it now takes the loaded validator module and raises on validator.Refusal, so any other error fails the test, and each caller still asserts the refusal's code, detail and remediation. The two duplicate blocks Sonar also listed in validate-pins.py (:829, :851, against validate-family.py) are code this change does not touch. No case or assertion was dropped: still 28 tests in the new file. Re-run on ac508957: the new file plus every tests/test_validate_pins_* file and tests/test_repo_hygiene.py, 176 passed, no skips, exit 0.

Mutants, each reverting one part of the fix, run against the new file (re-run on ac508957, same kills), each killed:

mutant killed by
directory _is_a(workflows, S_ISDIR) back to workflows.is_dir() 1: the 3.14 stand-in for the directory (on 3.12 the raise is caught by the same try, so only the stand-in sees it)
the except OSError around the listing removed 12: rows 1 and 3, the doctor row, the in-process refusals
child _is_a(path, S_ISREG) back to path.is_file() 2: the two 3.14 stand-ins for children
_ABSENT_ERRNOS emptied 7: the nothing-at-the-name controls
_ABSENT_WINERRORS emptied (extra) 3: the Windows-error cases

What it cannot tell

  • The same shape of unguarded call remains outside _workflow_refs, which the issue says it did not probe and this PR leaves alone: with contracts/ mode 000, validate-pins.py still ends in a PermissionError traceback, exit 1, at pin_path.is_file() in _load_leg_pin (measured on this branch); a pin file that is only unreadable is already yaml-unreadable. On 3.14 the same is_file() would read the pin as missing. For the known-limits checklists.
  • Mode tests cannot run as root or on Windows; the in-process cases stand in for them there.
  • Windows' three winerror values are tested with a stand-in exception, not a real Windows disk.

Shared files

templates/assembly-root/scripts/validate-pins.py and a new test file only. Base 8f453d0e; head ac508957 (two commits: f7f5de51, then the Sonar fix round).

  • git merge-tree --write-tree HEAD 4cf5fb07 (origin/main, read from GitHub after the fix round; main touched none of my files since the base): exit 0, clean, tree 92bd6d0814a32ba9f59284f1e35c24cfae3a9585.
  • git merge-tree --write-tree HEAD 97335473 (fix/443-validators-non-list, read with ls-remote): exit 0, clean, tree 0a0788657de2e1872326051ee5d25d60199c4e9d. It changes validate-pins.py at _check_neutral_product_pins (@@ -1207 and @@ -1209); this PR's hunks are the docstring, imports, _workflow_unreadable's advice and _workflow_refs with its new helpers, so no hunk overlaps.

Closes #434

🤖 Generated with Claude Code

…ectory that this user cannot list or search is a `workflow-unreadable` refusal naming it, exit 2, so the project's pins gate no longer ends in a PermissionError traceback, exit 1, where a workflow file it cannot open already was one (#434)

`_workflow_refs` reached the workflows with three calls that had no handler:
`workflows.is_dir()`, `workflows.iterdir()` and `is_file()` on each child.
`main()` catches `Refusal` alone, so a `.github/workflows/` this user could
not list, one it could list but not search, or a `.github/` it could not
search ended the run in a `PermissionError` traceback, exit 1, the code this
validator gives a finding. #359 refused a workflow FILE it cannot open and
left the directory its own file sits in unguarded; `shape-doctor.py`'s `pins`
row quoted the last line of that traceback.

The three modes the issue probes are now refusals, exit 2, under the id #359
introduced, so one id says "this validator cannot read the workflows"
whatever the cause:

- `.github/workflows/` mode 000, and `.github/` mode r-- (so `workflows/` is
  never reached): `.github/workflows: cannot be listed (Permission denied)`,
  in the words a file's `cannot be read (...)` line uses, POSIX and relative
  to the root. The remediation is the directory's own, because
  `_workflow_unreadable` counts files and a directory has none to count: it
  says why every file is read and never skipped, then to restore read and
  search access to the directory and every one above it inside the root, then
  to run the same command again. A cause that is no permission (an I/O error,
  too many open files) is not told to `chmod`.
- `.github/workflows/` mode r--: listable, so each `.yml` and `.yaml` child
  whose `stat` is refused is named, with the others, in the ONE file refusal
  as `<path>: cannot be read (Permission denied)`, as #383 names them for
  `bump-leg.py`. That refusal's advice now also says to restore search access
  to the directories above the file, since the file's own mode is fine.

`is_dir()` and `is_file()` raise a refused `stat` up to Python 3.13 and answer
False to ANY `OSError` from 3.14. Left in place under a handler, 3.14 would
have read an unsearchable `.github/` as "no workflows" and every file of a
listable-but-unsearchable directory as "not a file": `pins ok` over workflows
nobody read, which a skipped file could hide a stale `@<sha>` behind. `_is_a`
asks `stat()` itself and answers False only for the errors pathlib ignored up
to 3.13 (`ENOENT`, `ENOTDIR`, `EBADF`, `ELOOP` and Windows' three), so every
Python gives one answer and a name with nothing at it stays "no workflows".

Not changed: the `is_file()` calls on the pins and the manifest, which the
issue notes have the same shape and are not part of this function; `--help`,
so `docs/cli.md` is as it was.

The file is a pinned template copy and the only one in this repository, and
nothing here records its digest or blob: a scaffold computes the digest of
the copy it writes, and a project already cut sees `scripts/validate-pins.py`
as `upstream-changed` until its owner runs `update-shape.py apply`.

`tests/test_validate_pins_unreadable_workflows_dir.py` runs each row of the
issue as the validator a real scaffold wrote, and again through the doctor's
`pins` row; the in-process cases stand in for Python 3.14's answer and for a
listing that fails for another reason, so they run on every Python, root
included.

Closes #434

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes workflow pin validation fail safely with a single workflow-unreadable refusal whenever workflow discovery is blocked, while preserving absent-path behavior and adding broad regression tests for permissions, OS errors, Python-version differences, doctor integration, and remediation guidance.

Sequence diagram for workflow-unreadable refusal handling

sequenceDiagram
    participant V as validate-pins.py
    participant D as Workflow directory
    participant F as Workflow file
    V->>D: _is_a(workflows, stat.S_ISDIR)
    alt directory stat or listing refused
        D-->>V: OSError
        V->>V: _workflows_unlistable(root, workflows, exc)
        V-->>V: Refusal workflow-unreadable
    else directory is readable
        V->>D: iterdir()
        D-->>V: child paths
        V->>F: _is_a(path, stat.S_ISREG)
        alt file stat refused
            F-->>V: OSError
            V->>V: Add cannot be read line
            V-->>V: Refusal workflow-unreadable
        else regular file
            V->>F: _read_workflow(root, path)
            F-->>V: workflow text or read problem
        end
    end
Loading

File-Level Changes

Change Details Files
Harden workflow discovery so inaccessible workflow directories and files produce controlled workflow-unreadable refusals instead of tracebacks or false passes.
  • Added _is_a to normalize stat() behavior across Python versions and distinguish absent paths from operational errors.
  • Guarded directory stat/listing and child stat operations, reporting directory failures as cannot be listed and preserving per-file refusals.
  • Applied permission-specific remediation only when appropriate, including search access for parent directories.
  • Updated validator documentation to describe unreadable workflow directories.
templates/assembly-root/scripts/validate-pins.py
Added comprehensive regression coverage for unreadable workflow directories, cross-version filesystem behavior, and unchanged path controls.
  • Tested permission modes for .github/workflows/ and .github/, successful remediation, doctor output, and no-write guarantees.
  • Covered refused stats, listing I/O failures, absent-path errno and Windows error handling, multiple unreadable children, and non-permission remediation.
  • Verified missing or replaced workflow paths retain their prior behavior.
tests/test_validate_pins_unreadable_workflows_dir.py

Assessment against linked issues

Issue Objective Addressed Explanation
#434 Refuse when .github/workflows/ or a directory above it cannot be accessed, rather than ending in a PermissionError traceback or treating workflows as absent. ✅
#434 Treat workflow files whose metadata cannot be checked because the workflows directory is not searchable as unreadable, rather than silently skipping them. ✅
#434 Report these failures as workflow-unreadable refusals naming the relevant path, exit 2, with remediation to restore access and rerun the command. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

…in is `refused_stat` imported from `tests/test_bump_leg_unopenable.py` and no second copy of it, and `refusal_of` expects the project's own `Refusal` and not a bare `Exception`, so SonarCloud's 3.3% new duplication and its S5958 on #633 are cleared (#434)

The new file carried a 19-line copy of `refused_stat`, the stand-in #383
made for Python 3.14's answer to a refused `stat` (`Path.stat` refused, and
`is_file`, `is_dir` and `exists` answering False to any `OSError`).
SonarCloud matched it block for block against
`tests/test_bump_leg_unopenable.py:586-604` and put the pull request's new
duplication at 3.3%, over the gate of 3%. It is imported now: the helper is
the same four patches, takes the same arguments, and is called the same way,
so every case that used it is unchanged. The duplicate blocks it also listed
in `validate-pins.py` (`:829` and `:851`, against `validate-family.py`) are
code this change does not touch.

`refusal_of` was `pytest.raises(Exception)` followed by a check of the
exception's class NAME, which SonarCloud's S5958 calls too broad: the
assertion passes for any error and names the type only after the fact. It
takes the loaded `validator` module now and raises on `validator.Refusal`,
the class the project's own `repo_shape` defines and `main()` catches, so any
other error propagates and fails the test, and each caller still asserts the
refusal's code, detail and remediation.

No case and no assertion was dropped: the new file is still 28 tests, and
each of the five mutants (the directory's `stat`, the listing's handler, the
child's `stat`, the absent errnos, the absent winerrors) is killed by the
same tests as before. The template is unchanged.

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@sourcery-ai

sourcery-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown

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 11 hours and 10 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@brettheap
brettheap merged commit f1c73e2 into main Oct 16, 2026
4 checks passed
@brettheap
brettheap deleted the fix/434-validate-pins-workflows-dir branch October 16, 2026 10:43
brettheap pushed a commit that referenced this pull request Oct 16, 2026
Main gained #626 (`family.py add`, `bump` and `remove` refuse before their
first write), #633, #642, #590 and #641 (`git status --porcelain` and
`git config user.name` read as bytes) since this branch's base 8f453d0.

One conflict, in scripts/family.py: the comment above the single shared
`from shape_materialize import unwritable_reason` line. #433 and #641 each
added a use of that import and each wrote its own comment above it. The
resolution keeps both uses and all three issue numbers (#426 for the creator
read from `git config user.name`, #255 and #433 for the holder's clone URL):

    # Whether a value `init` writes into the holder is one line of text a file
    # can hold: the creator read from `git config user.name` (#426), and the
    # holder's clone URL under `--local-remote-dir` (#255, #433). It is the
    # question the scaffold and `adopt-project.py` ask of theirs.

scaffold-project.py auto-merged. No other hunk conflicted.

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 16, 2026
…h, the `switch -c` remedy says to give it another name, or go back only if it holds work not merged yet, and the docs say `family/add-<Project>` (#607) (#637)

### Fix round 1 (rv607)

Review rv607 of 6212c31 said CHANGES NEEDED: 0 blockers, 2 should, 7 nits. This round is one new commit, 66b1043, on top of 6212c31. No amend, and main is not merged in. Each point:

- **S1, the sentence.** It sent a person back to the old branch first. That is right only where the branch holds work not merged yet. `BRANCH_LEFT` now puts another name first and going back second (the text is under "L2-46" below). It is word for word the same in `scripts/family.py`, in the pinned `validate-family.py` and in the pinned test constant, and the comments that described the old order are rewritten. Two new tests type the printed line in the states the review probed: `main` has moved since the earlier act, and a commit was made on a detached HEAD.
- **S2, a guard for every `_switch_line` remedy.** A new test reads the validator's source with `ast` and fails any remedy that names `_switch_line` whose prose does not end with `BRANCH_LEFT`. On a merge of this head with #634 it fails at `_lockstep`, which is the point: whichever of #637 and #634 lands second adds the sentence there. #634's lines are not on this branch and are not touched.
- **N1.** Under "Left out".
- **N2.** The commit body of 6212c31 said neither tool can print the one line that works by asking first. That holds for the validator only. `family.py` could ask; it says the validator's words so the two tools keep one rule. Decision 1 says so, and the new commit's body corrects the old one.
- **N3.** The merge table is refreshed: current origin/main, #620, #622, #626, #630 to #636, #638, #639 (lane 5's #611) and #634 (S2).
- **N4.** Decision 1 no longer says the typed line works "in every shell". It says what a person types is "the printed line with one word changed (the branch name, or `-c` taken out)", so it keeps the printed quoting, and that the tests type both changes as printed.
- **N5.** Decision 3 now says the case of the branch name "does not matter to `add`", and adds the note about case-insensitive disks.
- **N6.** The `init` NEXT STEPS test read the lines with a regex whose `--family-root \S+` breaks on a root with a space in it (`C:\Users\Jane Doe`, or any `tmp_path` with a space). It now reads the words with `host_words`, as the NEXT STEPS test beside it does. Run with a space in the base temp directory, the old test fails with `AttributeError: 'NoneType' object has no attribute 'group'` and the new one passes.
- **N7.** "Three existing tests take the new text" was wrong. It is two test functions plus `GITLINK_REMEDY`, a constant four cases share. Fixed under "Tests". The one new test that passes on BASE is disclosed there too.

### Fix round 2 (rv607b)

The re-verify rv607b of 66b1043 said APPROVE WITH NITS: 0 blockers, 0 should, 5 nits. This round is one new commit, a277695, on top of 66b1043. No amend, and main is not merged in. It changes comments and docstrings only, so no behaviour moves and no mutation row changes.

- **Nit 1.** Two comments called another name "right in every state". It is not: where the old branch holds work not merged yet, another name leaves that work behind. The comment above `BRANCH_LEFT` in `scripts/family.py` and the one in the pinned `validate-family.py` now say a new branch starts where the holder stands now, "which works in every state". The three `BRANCH_LEFT` texts are unchanged and still equal.
- **Nit 3.** The guard's docstring said it finds each `_switch_line` call "however it is passed on". A switch line moved into a variable would defeat that. It now says "wherever the call stands inside the string expression that is passed on".
- **Nit 4.** The N4 line above now quotes decision 1 as written.
- **Nit 5, the docstring half.** The docstring of `test_another_name_works_where_main_has_moved_since` said going back to the old branch conflicts, but the test does not assert that. It now says the test shows the other name works, and that the conflict on the old branch is shown by rv607's probe and decision 2's table. No assertion is added.
- **Nit 2, left as written.** The guard's control counts stay: each case fails loudly with a clear message.

Checks on a277695: the diff to 66b1043 adds ten lines and removes seven, in three files, all comments and docstrings, and the `ast` of each file is equal once docstrings are blanked. The four files `test_family_switch_branch_exists.py`, `test_validate_family_branch_step.py`, `test_validate_family_unnamed_mounts.py` and `test_family_tracking_branch.py` give `96 passed in 51.34s`, and `test_repo_hygiene.py` gives `65 passed in 1.39s`.

### L2-46, the fix

`family.py add`, `bump` and `remove` refuse the holder's tracking branch with `git -C <holder> switch -c family/<act>-<member>` (#487). The holder's `validate-family.py` names the same line before each `add` and `remove` it prints (#539, landed as 54041cc). If an earlier act left that branch, the line fails with `fatal: a branch named 'family/add-atlas' already exists` (exit 128), and neither tool said what to do next.

Both tools now add one sentence, in the same words (`BRANCH_LEFT` in each file):

> If `git switch -c` says that branch already exists, an earlier act left it: give the branch another name, which starts it where the holder stands, or, only if that branch holds work not merged yet, the same command with `switch` in place of `switch -c` goes back to it and keeps every commit on it.

- `scripts/family.py`: the sentence comes on its own line, right under the `switch -c` line, in the `family-on-tracking-branch` and `family-holder-detached` refusals (`_checked_branch`), and in the dry run's `branch` lines (`_branch_said`).
- `templates/family-root/scripts/validate-family.py`: the sentence ends the remedy text of `member-gitlink-absent`, `member-duplicate-id` and `member-gitlink-unnamed`, the three remedies that print `_switch_line`. The command lines under them are unchanged.

### L2-45, rides along

AGENTS.md, the holder's README, its AGENTS-shape.md and `init`'s NEXT STEPS spelled the branch `family/add-<project>`, right beside `--member <org>/<Project>`. All four now say `family/add-<Project>`, the one placeholder the validator already uses for both (`PROJECT_PLACEHOLDER`, #539).

**1. What the remedy prints when the branch exists: one sentence that names the way out, not a second command line.**

- *One line that works in both states* (`git switch X 2>/dev/null || git switch -c X`): rejected. On Windows, `family.py` quotes its lines for PowerShell (`shell_line` uses `os.name`; README.md:155-158 says so). Windows PowerShell 5.1 has no `||`; `&&` and `||` arrived in PowerShell 7, and `family.py`'s own `_print_next_steps` docstring says 5.1 rejects `&&`. PowerShell also has no `/dev/null`. And `2>/dev/null` would hide the real reason a `switch` fails, such as a changed file it would overwrite.
- *The tool checks and prints the one line that works*: rejected for the validator. Its report is read in CI: the holder's `validate.yml` runs `python3 scripts/validate-family.py` (and `--no-members`) in a runner's checkout, which holds none of the person's branches. `family.py` could check, but then the two tools would follow two rules, and one rule in the same words was the aim. So `family.py` says the validator's words; it is not that it cannot ask.
- *Two printed lines, one per state*: rejected. In the validator, each indented line is a step to run in order, and going back to the branch replaces step one; it is not another step. In `family.py`, a new `git switch` line would also be quoted for PowerShell on Windows. README.md:155-158 lists exactly which `family.py` lines are quoted that way (`NEXT`, `switch -c`, `add`, `git rm -r --cached`). That sentence would become false, and fixing it would mean editing README § "Starting a project in a new organisation". Seven handbook parts record that section's hash (`grep -c` gives 7).
- *Chosen*: a sentence that names both ways out. It prints no new command, so nothing new needs quoting, and the text is the same in both tools. What a person types is the printed line with one word changed (the branch name, or `-c` taken out), so it keeps the printed quoting. The tests type both changes as printed (tests below); none of them runs a shell, and Windows and macOS are not checked (see "Left out").

**2. Another name first, going back second (S1).** The reviewer's probes, and mine, in real local holders (a holder `Orbit`, members `Atlas` and `Beacon`, local bare remotes, the `gh` stub first on PATH):

| State of the old branch `family/add-atlas` | `git switch family/add-atlas` (going back) | `git switch -c family/add-atlas-2` (another name) |
|---|---|---|
| No commit on it, `main` has not moved (rv607) | works | works |
| Holds a commit of its own, not merged yet (mine: `probe-atlas.sh`, `probe-b.sh`) | works; `add` then commits on top of it, and the earlier commit is the parent | works, but the earlier commit stays only on the old branch (`git branch --contains` names `family/add-atlas` alone) |
| `main` has moved: a later member (`Beacon`) was squash-merged (mine: `probe-d.sh`; test `test_another_name_works_where_main_has_moved_since`) | `add` exits 0, but `git merge-tree --write-tree main family/add-atlas` exits 1 (`CONFLICT (add/add)` in `.gitmodules`, `CONFLICT (content)` in `family.yaml`), and an untracked `members/Beacon` is left (`warning: unable to rmdir 'members/Beacon'`) | `add` exits 0, `git merge-tree --write-tree main family/add-atlas-2` exits 0, and the validator says `2 member(s)` |
| Merged, then the member removed and that merged too; the old branch is still local (rv607's probe, and mine: `probe-c.sh`) | `add` says `member-already-present`, whose remedy points at `bump` and `remove`: a dead end | `add` exits 0, once the object store `remove` leaves behind is deleted, as its NOTE says (either choice needs that) |
| Detached HEAD with a commit made on it (mine: `probe-detached.sh`; test `test_another_name_keeps_a_commit_made_on_a_detached_head`) | `Warning: you are leaving 1 commit behind, not connected to any of your branches`, and `git branch --contains` names no branch | the commit stays: `git branch --contains` names the new branch |

So going back is right only where the branch holds work not merged yet, and another name is right in every state but that one. The sentence says so, in that order.

**3. The person's earlier work on that branch is never discarded.** `git switch <branch>` keeps the branch's commits. It refuses to switch when that would overwrite a changed file. The act then commits on top of what the branch holds; the tests check that the earlier commit is the parent of the act's commit. "Give the branch another name" leaves the old branch alone. No printed line names `switch -C` (which resets a branch), `branch -D`, `reset` or `--discard-changes`; a test checks that too.

**4. The placeholder: `<Project>` everywhere.**

- The validator already said `family/add-<Project>` beside `--member <org>/<Project>` (#539's fix round, pinned by `tests/test_validate_family_unnamed_mounts.py`). It is the only spelling that is one placeholder for both values.
- The other option, a sentence saying the branch word is the name in lowercase, does not fit: AGENTS.md is at its cap, 492 of 492 lines (`tests/test_repo_hygiene.py:633`). This change keeps it at 492.
- The case of the branch name does not matter to `add`. `_checked_branch` takes any branch but the tracking one, so `family/add-IRQS`, the doc line filled in as written, is a branch `add` commits on (test). Where the tools know the name, they still print it lowercased (`_suggested_branch`). On a case-insensitive disk (macOS, Windows) `family/add-Atlas` and `family/add-atlas` can be one loose ref there. That is untested: CI is Linux only.

**5. Pinned copies.** This changes two pinned holder files: `templates/family-root/scripts/validate-family.py` and `templates/family-root/AGENTS-shape.md` (`scripts/shape_materialize.py` lists the pinned set). Each holder takes them as two `upstream-changed` rows on its next `update-shape.py` run. The holder's README is rendered once and is not pinned. No test pins those files' bytes; the tests that compare them read the template at run time. Fix round 1 changes only `validate-family.py` of the two.

New file `tests/test_family_switch_branch_exists.py`, 25 tests (21 before the fix round). Four are new in the fix round:

- `test_another_name_works_where_main_has_moved_since` (S1, state (d)): `family/add-irqs` is left at the `main` of its day; a later member (`IRXS`, scaffolded in the test) is added on a branch and squash-merged onto `main`, so `main` has one new commit; the refusal's `switch -c`, typed as printed, fails with `already exists` (exit 128); the same line with another name works; `add` exits 0, `git merge-tree --write-tree main <branch>` exits 0, and the validator passes.
- `test_another_name_keeps_a_commit_made_on_a_detached_head` (S1): the refusal is `family-holder-detached`; after the printed line with another name, `git branch --contains <the commit>` names the new branch and no other.
- `test_every_remedy_that_names_a_switch_line_ends_with_the_sentence` (S2, the guard) and `test_the_guard_sees_a_remedy_left_without_the_sentence` (its control: the source with the sentence taken out of any one remedy fails it, and so does a fourth remedy built by a helper as `_lockstep` builds its, until the sentence ends it).

The other 21:

- `test_the_refusal_typed_as_printed_puts_the_act_on_its_branch` [add, bump, remove] x [no-branch, branch-left]: the refusal, then its line typed as printed. With no branch, the `switch -c` makes one. With a branch an earlier act left, holding a commit of its own, the `switch -c` fails with `fatal: a branch named '<branch>' already exists` (exit 128) and changes nothing, and the same command with `switch` in place of `switch -c` goes back to that branch. The act then commits on top of the earlier commit, and NEXT pushes that branch.
- `test_a_dry_run_on_the_tracking_branch_says_it_too` [add, bump, remove].
- `test_a_missing_gitlinks_remedy_typed_as_printed`, `test_a_duplicate_ids_remedy_typed_as_printed` (with the `remove` run as printed) and `test_an_unnamed_gitlinks_remedy_typed_as_printed`, each in both states.
- `test_the_two_tools_say_the_same_words`.
- `test_each_doc_spells_the_branch_as_its_member` [AGENTS.md, AGENTS-shape.md, holder README], `test_init_next_steps_spell_the_branch_as_its_member` (read with `host_words` now, N6), and `test_the_branch_filled_in_as_written_is_one_add_commits_on`.

Two existing test functions take the new text: `test_init_next_steps_make_the_branch_before_the_add` (`<Project>`) and `test_a_missing_gitlink_remedy_makes_the_branch_and_names_the_holder` (the remedy line). `GITLINK_REMEDY` in `test_validate_family_unnamed_mounts.py`, a constant four cases share (`test_a_member_mounted_by_hand_is_two_findings` x 3 and `test_a_removed_row_is_named_by_its_gitlink_and_its_section`), ends with the sentence. The sentence is pinned once, as text, in `tests/test_validate_family_branch_step.py`.

Before and after, with the four changed test files copied in (`run9.sh`, the `gh` stub first on PATH):

- On BASE 396c0ff: `30 failed, 66 passed` in the four files. 24 of the 25 new-module tests fail. The one that passes, `test_the_branch_filled_in_as_written_is_one_add_commits_on`, is the evidence for decision 4: it shows behaviour this PR keeps.
- On 6212c31: `23 failed, 56 passed` in the three files that pin the sentence. Both new S1 tests fail there, where they assert the new wording. The two guard tests pass there: they check where the sentence stands, not its words.
- On the head 66b1043: the new module alone, `25 passed`.

### Targeted runs on the head 66b1043, BASE 396c0ff

- Set A, 29 files: every `tests/test_family*.py` and `tests/test_validate_family*.py`, plus `test_bump_leg.py`, `test_bump_leg_dry_run_tracking.py`, `test_bump_leg_dry_run_truth.py`, `test_bump_leg_paste_lines.py` and `test_update_shape_branch_any_directory.py`. Result: `1016 passed, 20 skipped in 511.01s`.
- From set B: `test_repo_hygiene.py`, `test_agents_md_codes.py`, `test_readme_sections.py` and `test_cli_reference.py`. Result: `210 passed in 15.73s`. The fix round changes no template other than `validate-family.py`'s text, so the rest of set B (the 27 files of the first round) is not re-run.
- Every skip is a platform skip that was there before this change (a case-ignoring disk, a Windows default, powershell.exe), or a template-quoting skip in `test_family_init_values.py`.

A real holder `Orbit`, made with `family.py init`, and a member `Atlas`, scaffolded with `scaffold-project.py --local-remote-dir`.

- **On BASE 396c0ff** (first round): `add` refuses with `switch -c family/add-atlas`. Typed as printed, that gives `fatal: a branch named 'family/add-atlas' already exists`, exit 128, and the remedy says nothing more. The validator's `member-gitlink-absent` remedy prints the same line, with the same result.
- **On the head, an unmerged act** (`probe-atlas.sh`, a branch holding a commit of its own): the refusal prints the new sentence. The same command with `switch` for `switch -c` gives `Switched to branch 'family/add-atlas'`, exit 0, at the earlier commit. `add` then exits 0, its NEXT pushes `family/add-atlas`, and its commit's parent is the earlier commit. The validator carries the same sentence.
- **On the head, `main` moved** (`probe-d.sh`): the printed line fails (128). With another name: `add` exits 0, `git merge-tree --write-tree main family/add-atlas-2` exits 0, `family ok: Orbit (orbit), 2 member(s)`. Going back instead: `add` exits 0, and `git merge-tree --write-tree main family/add-atlas` exits 1 with the two conflicts in decision 2.
- **On the head, a detached HEAD with a commit** (`probe-detached.sh`): the printed line fails (128). With another name, `git branch --contains` names `family/add-atlas-2`. Going back with `switch`: git warns it is leaving 1 commit behind, and no branch contains it.

No row needs real GitHub.

Each change below was made alone in a scratch clone of the head, then the new module was run (and, for the validator changes, the two other files that pin the sentence), and the file was put back. Every change that alters behaviour makes at least one new test fail:

| Change | Result |
|---|---|
| `family.py` `BRANCH_LEFT` back to the first round's words | 12 failed: the six refusal cases, the three dry-run cases, both new S1 tests, `test_the_two_tools_say_the_same_words` |
| `family.py` `BRANCH_LEFT` one clause dropped (`only if`) | 12 failed, the same tests |
| `_checked_branch` remedy with no sentence | 8 failed: the six refusal cases and both new S1 tests |
| sentence printed above the `switch -c` line, not under it | 8 failed: the same eight |
| `_branch_said` (dry run) with no sentence | 3 failed: `test_a_dry_run_on_the_tracking_branch_says_it_too` [add, bump, remove] |
| `_switch_command` prints `switch -C` | 11 failed, both new S1 tests among them: the printed line no longer fails `already exists` |
| validator `BRANCH_LEFT` back to the first round's words | 12 failed in the three files, `test_the_two_tools_say_the_same_words` among them |
| validator `member-gitlink-absent` with no sentence | 5 failed: its two typed-as-printed cases, the remedy test, the guard and its control |
| validator `member-duplicate-id` with no sentence | 4 failed: its two typed-as-printed cases, the guard and its control |
| validator `member-gitlink-unnamed` with no sentence | 8 failed: its two typed-as-printed cases, the four `GITLINK_REMEDY` cases, the guard and its control |
| **S2:** a fourth remedy added that names `_switch_line` and does not end with the sentence (built by a helper, as #634's `_lockstep` does) | 2 failed: the guard and its control, and nothing else in the three files |
| **S2:** the same fourth remedy ending with `{BRANCH_LEFT}` | 79 passed |
| `init` NEXT STEPS branch back to `<project>`; its `--member` lowercased | 1 failed each: `test_init_next_steps_spell_the_branch_as_its_member` |
| AGENTS.md, AGENTS-shape.md, holder README: branch back to `<project>` (and AGENTS.md's `--member`) | 1 failed each: `test_each_doc_spells_the_branch_as_its_member` for that doc |

The other hunks change only docstrings and comments (`_checked_branch`, `_branch_said`, `_print_next_steps`, `_switch_line`, and the comments above the two constants). They change no behaviour, so no test can catch reverting them.

| Ref | Result |
|---|---|
| origin/main f6376d7 (#614 landed; main has moved since BASE through #625, #583, #596) | clean, tree eb91b600. A committed merge of the head with it, e26dca8c, ran set A and #625's `test_family_bump_to_local_only.py`: `1024 passed, 20 skipped in 500.52s` |
| #620 a2b4f89 | clean (it conflicted in `adopt-project.py` in the first round; it no longer does) |
| #622 227bc3b (lane 2, #609, `scripts/family.py`) | clean |
| #626 207d4e1 (lane 4, `scripts/family.py`) | clean |
| #630 82f9403, #631 9733547, #632 86c6b9c, #633 f7f5de5, #635 2c0b157, #636 4aade9f | clean |
| #638 64e6621 | clean |
| #634 40a85e1 (lane 2, #610: `_lockstep` prints a fourth `switch -c`) | clean, and S2 fires on it. A committed merge, 4d1a7161: the new module, `test_validate_family_branch_step.py` and #634's `test_pinned_copy_text.py` give `2 failed, 86 passed`. The two failures are the guard, `assert [124] == []` (line 124 of the merged file is `_lockstep`'s return), and its control. With one line added to `_lockstep`, `f"moving one alone is what this refuses. {BRANCH_LEFT}"` in place of the plain string, the same merge gives `306 passed` over the nine files that read the validator or the lockstep rule (`test_validate_family*.py`, `test_family.py`, `test_family_tracking_branch.py`, `test_pinned_copy_text.py` and the new module). So the second PR to land needs that one line and nothing else. |
| #639 6f938ed (lane 5, #611) | conflicts in the same one sentence, in the same two places: the end of the `member-gitlink-unnamed` remedy text in `validate-family.py` (`_check_gitlinks_named`), and the `GITLINK_REMEDY` constant in `tests/test_validate_family_unnamed_mounts.py`. #611 adds "and commit that removal, since `family.py add` refuses ..." and this PR appends `BRANCH_LEFT`. Resolved as in the first round, keeping #611's clause and appending ` {BRANCH_LEFT}` in the validator and `+ BRANCH_LEFT` in the test constant, in a committed merge (92602308): `scripts/family.py` merged cleanly, and the six test files that either PR changes or pins gave `157 passed`. Neither branch was resolved. |

- No compound `||` line and no state check: see decision 1.
- No README.md edit: no README sentence becomes false, because no new kind of line is printed.
- The docs do not mention the exists case. AGENTS.md is at its cap, and the tools print the sentence where the failure happens.
- The `switch -c` in `init`'s NEXT STEPS gets no sentence: a holder `init` just made has no branch an earlier act could have left.
- **A branch checked out in another worktree (N1).** Where `family/add-atlas` is checked out in another worktree of the holder, `git switch family/add-atlas` gives `fatal: 'family/add-atlas' is already used by worktree at '<path>'` (exit 128), so the going-back half of the sentence does not work there. Git names the worktree, and another name works (`probe-n1.sh`: `switch -c family/add-atlas-2` exits 0). The sentence is not made longer for it.
- I could not run Windows PowerShell or macOS here. The tests read `family.py`'s lines with `host_words`, which parses PowerShell's quoting on Windows. They make the earlier branch with `commit-tree` and `update-ref`, move `main` with the same two, write no file with `write_text` and compare nothing CRLF-sensitive. `test_another_name_works_where_main_has_moved_since` runs `git merge-tree --write-tree`, which needs git 2.38 or newer. No CI job checks Windows or macOS.

- **bump-leg.py: the `git switch -c bump/<role>-<sha12>` remedy fails `already exists` when an earlier bump left that branch.** `_switch_command` (scripts/bump-leg.py:1124) prints the line for the two refusals and the dry run's closing hint. Like #607, it says nothing about a branch that is already there.
- **setup-project.py: the family `git -C <holder> switch -c family/add-<project>` line has the same gap.** The NEXT lines a scaffold into a family folder ends with (setup-project.py:2358) print it with no word on an existing branch. It matters only when an earlier attempt left that branch.

- L2-46 ([#459 comment](#459 (comment)))
- L2-45 ([#459 comment](#459 (comment)))

Review: rv607 found 0 blockers, 2 should-fix and 7 nits on 6212c31 (CHANGES NEEDED), fixed in 66b1043; the re-verify rv607b found 5 nits on 66b1043 (APPROVE WITH NITS), of which nits 1, 3 and 4 and the docstring half of nit 5 are fixed in a277695, and nit 2 is left. CI (Brett Heap's ruling 27, with his fast-refresh ruling of 2026-10-15T22:48:35Z): H0 a277695 passed tests (Linux), tests-git-bash and SonarCloud; the head 62263d2 is a clean update-branch merge of main a524542 (over e041867, a clean merge of 5b29ee1), with SonarCloud, tests-git-bash and package green on it, and the local gate passed on the head itself: the family and validator set, 1016 passed (20 skipped), and the hygiene, AGENTS.md-code, README-section and CLI-reference sets, 222 passed. Landed on Brett Heap's word of 2026-10-16T11:21:49Z, "Merge #637 when its turn comes".

Closes #607

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Oct 16, 2026
main gained #563's own #590 (fe237ec) and #599 (32c22b0), whose trees
this branch already held through #599's 750366b (#599's final head,
eaa0cda, is 750366b plus a merge of main), and #626, #633, #642, #641,
#643, #644, #632, #636, #631, #638, #635, #640, #623, #637 and #622. No
conflict: the merged tree is 9be0d0d, the tree `git merge-tree
--write-tree` predicted. AGENTS.md, docs/cli.md and
tests/test_repo_hygiene.py merged as text; README.md and
docs/handbook.html are unchanged by the merge. README.md is 1461 lines,
its cap (1449 + 12, tests/readme-cap.d/563.txt), and AGENTS.md 494, its
cap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap pushed a commit that referenced this pull request Oct 16, 2026
… tab shows the one-line install for Git Bash, held to the other copies by a test, and the notes are current to main d4a7fab with the fifteen pull requests since 4cf5fb0, the environments, the tag ruleset and the rehearsal (#563, #461)

The handbook (#461's line "The handbook's step 3 has no Git Bash path",
which lane 3 told lane 5 on #473 that #630 settles): step 3's install
block was `data-platform="linux mac wsl"`, so a reader on the Windows tab
never saw the one line the Windows panel says Git Bash runs. The Windows
tab now has a lead, "In Git Bash, the bash that Git for Windows installs,
the one-line install works as on Linux:", the Linux tab's block copied
byte for byte as `data-lang="sh"`, and the panel's caveat: the preflight
it ends with cannot take a typed `yes` in Git Bash. README.md is
unchanged: no test asked for it, and it is at its cap.

tests/test_repo_hygiene.py: the test above it finds one copy of the one
line per file; `test_every_handbook_copy_of_the_one_line_install_is_the_same`
holds every handbook copy (the masthead's and step 3's two) to
ONE_LINE_INSTALL, so a copy edited on one tab alone fails. A drifted
Windows copy fails it; the page as committed passes.

The release notes:
- "What changed since v1.0.1" gains one entry per pull request that
  landed after 4cf5fb0 and is not #563's own, from `git log
  --first-parent 4cf5fb0..origin/main` at d4a7fab: under update-shape.py
  and bump-leg.py, #644, #633 and #631; under scaffold, family and the
  materializer, #622, #643, #640, #641, #623, #638, #635, #626, #637 and
  #642; under shape-doctor.py, #636 and #632. Each from its squash
  commit and the issues GitHub says it closes.
- The list's placeholder says it is current to main d4a7fab and stays a
  placeholder for what lands after it; the counts are refreshed inside
  their placeholder (66 pull requests, 75 of 97 milestone issues closed).
- #590 and #599 are cited beside #563, and "Before tagging" says they
  landed (fe237ec, 32c22b0) and lists the 22 open milestone issues.
- "How this release is cut": Brett Heap's word at 2026-10-16T12:06:40Z,
  the environments testpypi (12:07:31Z) and pypi (12:07:39Z), the tag
  ruleset 25237399 (12:08:14Z), and the rehearsal, run 38898735926
  (12:10:53Z-12:12:00Z, success, both uploads skipped), each read back
  from the API. The trusted publishers' date stays a placeholder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 17, 2026
… symlink and a looping symlink named `.yml`, and both of siblings.py's headers print the holder's root and folder spelled, so the `S_ISREG` child check made `lambda mode: True`, or either path printed raw, now fails a test (#664) (#706)

Tests only: no product file, pin, digest or template copy changes. Two mutants survived review, and each is now killed.

validate-pins.py, the assembly-root template (#434, #633). `_workflow_refs` skips a child of `.github/workflows/` that is no regular file, by `_is_a(path, stat.S_ISREG)`. Replacing the kind with `lambda mode: True` left every validate-pins suite that reads the scan passing (130 tests on main `8062810d`), though over a directory named `.github/workflows/sub.yml` the gate then refused a tree with nothing unreadable in it: `REFUSED workflow-unreadable: .github/workflows/sub.yml: cannot be read (Is a directory)`. A directory named `sub.yml` and one named `sub.yaml` are now each skipped: the scan returns the references it returned before the entry was made, the leg's among them, and the run says `pins ok`. A dangling and a looping symlink are the same row, and kill a different mutant than that one: `_is_a` answers False to a `stat` that found nothing (ENOENT, ELOOP) before it asks the kind, so the symlinks pass under `lambda mode: True`, and fail under a child check that lets that `OSError` through (a bare `path.stat()`), which refuses `dangling.yml` as `cannot be read (No such file or directory)`. The rows are mode-free, so they run as root and on every platform; the symlink rows skip where a link cannot be made.

siblings.py, the family-root template (#454, #642). Both reports open with `siblings: <name> (<root>) — N member(s)` and a `family folder` line, each spelled. `tests/test_siblings_family_name.py` always stands its holder at a plain path, so printing the root raw in the placement header left all 150 of its tests passing, and so did each of the other three spellings (the dispatch header's root, and the `family folder` line of each run). The holder now stands under a folder named with U+2028, U+202E or ESC (ESC skips on Windows, which refuses a control character in a name), at `<tmp>/<folder>/InkRouter/InkRouter`, so the run still passes its folder check. For the placement and the dispatch dry run alike, the first line and the `family folder` line hold the path with the character written out, the last line is the run's own, and no character a terminal must not be handed is printed.

Each mutant was applied to the product file, failed the new rows, and was restored to the committed bytes (checked by sha256).

Closes #664

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 17, 2026
… or a leg checkout the gate cannot reach or read is refused by name, relative to the root, once and with its cause's advice, and every name and path it prints is spelled (#712) (#827)

Issue #712 gathers lane 4's checklist lines L4-103, L4-104, L4-106 and
L4-144, with the riders L4-105, L4-143 and L4-102, on the assembly root's
lockstep gate. This takes all seven.

L4-103. The leg pin, the shape pin, each shape copy, each neutral-product
pin and the manifest were asked with `Path.is_file()`. Up to Python 3.13 it
raised a refused `stat`, so a `contracts/` at mode 000 or r-- ended the run
in a PermissionError traceback, exit 1; on 3.14 it answered False, and the
run refused `pin-missing`, a present file said not to exist, under THE
LOCKSTEP RULE's remedy. The five sites are `_is_file` now: #633's `_is_a`,
and a refused `stat` is a refusal naming the file. A name no `stat` can be
handed (a NUL in a role or a product) is no file, as `is_file()` answered.
A shape copy at mode 000 passed its `stat` and ended in `file_sha256`'s
PermissionError on every Python, in the same function; its open is the same
refusal. A copy has no id for one, so it is `shape-copy-unreadable`, beside
`shape-copy-missing` and `shape-copy-drift`; the YAML files keep
`yaml-unreadable`, the id `load_yaml` gives them.

Checkouts this user cannot search (RV827's S1, fix round 1). A leg's
checkout at 000 or r-- (`_check_pin_digest`'s `(submodule /
".git").exists()`) and a checkout beside the root at 000
(`resolve_neutral_pin_source`'s) raised `PermissionError` out of the run on
3.11 to 3.13; from 3.14 the leg would have read as an uninitialized
submodule and the sibling been passed over for `gh api`. Both ask
`_is_there`, `_is_a` with any kind. The leg is `pin-submodule-unreadable`,
beside `pin-submodule-uninitialized`, naming the `.git` it could not reach
(`spec/.git: cannot be read (Permission denied)`) with the cause's advice;
the sibling is there, so it is the source, and the pin's
`neutral-pin-source-unreadable` finding says it could not answer.

L4-104. A pin this user cannot open was `load_yaml`'s line, `<absolute
path>: [Errno 13] Permission denied: '<absolute path>'`, with the lockstep
remedy, which moves a pin and says nothing of access. `_load` reads the
`OSError` the refusal is raised from, which `load_yaml` has chained since it
was written, and names the file relative to the root, POSIX, once:
`contracts/spec-pin.yaml: cannot be read (Permission denied)`, with a remedy
of its own, so `main` adds no other. Read off the cause and not off new
library words, so a root whose `scripts/repo_shape.py` is older than its
`validate-pins.py` names the file the same way (#370, #610). `load_yaml`
itself names the path once for every caller: `<path>: cannot be read
(<the system's reason>)`.

One rule for every file the gate names, on the coordinator's ruling: the
other refusals `load_yaml` raises here (not UTF-8, not parsable) keep their
id, words and remedy and name the file relative to the root, and so do
`not a mapping` for the four YAML files, `shape-pin-missing`,
`manifest-missing` and `manifest-no-legs`, which named the absolute path
raw.

L4-105. Every file this gate cannot open is told what its cause needs. A
permission keeps the words it had (a workflow) or gets bump-leg.py's (#383)
for a pin, the manifest or a copy: `chmod u+r` on a file, `u+rx` on each
directory above it. Any other cause, an I/O error or a name too long, gets
bump-leg.py's other sentence and is never told to `chmod`. `_Unreadable`
carries the cause, so one workflow refusal naming both kinds says both.

L4-106, L4-144 and every other print, on the coordinator's ruling (option
A). A workflow's name, a pin's path built from a role or a
`neutral_product_pins:` entry, a leg's path, role and repository, a pin's
`source_repository`, a declared product, a shape row's path and digest, the
shape pin's and the manifest's commits, a `--pin-source` value with no path
and the root in a printed `bump-leg.py` line each reached stderr or stdout
raw: a newline began a line, a bidi control reordered one, a C1 control
broke one, an ESC was the control it is. Each is printed as `_shown`
spells it now: `repr` where a character is not printable, the same bytes
where every one is. A word of a printed command is `shlex.quote`d as before
where it is printable, and `_shown`'s where it is not (`_quoted`): no
quoting makes a control character pasteable, and quoted it still reached
the terminal. The workflow-reference note's repository is not spelled: it
prints only a repository equal to a reference `WORKFLOW_REF_RE` matched,
which is printable ASCII.

L4-143. A `--pin-source` under a `neutral_product_pins:` that is not a list
was noted "project.yaml declares no neutral-product pin"; it says the field
is not a list and points at the `manifest-neutral-product-pins` finding.

L4-102. `PinSources` keys `--pin-source` products by `pin_product_key`, the
pin file's own fold, as #638 keys the naming gate's `LinkSources`:
`casefold()` took `openss=` for `openß`, two pin files.

Re-pin: `templates/assembly-root/scripts/validate-pins.py` and
`scripts/repo_shape.py` are pinned shape copies. As #634 says, no digest is
recorded in this repository; each root and holder reads the copies it
carries as `upstream-changed` in its `contracts/shape-pin.yaml` (both in an
assembly root, `scripts/repo_shape.py` in a family holder), which
`update-shape.py apply` re-copies and re-pins.

Tests: tests/test_validate_pins_named_and_spelled.py (new): the issue's
modes through the real gate, the five sites under a refused `stat` on every
Python, every file named relative to the root, each cause's advice, one row
for each print over a newline, a bidi control, a C1 control, an ESC and a
byte that is not UTF-8 (and a printable control), the issue's own pin entry
and workflow names, the L4-143 note and the L4-102 keys, a leg checkout
and a checkout beside the root this user cannot search, and a role or a
product spelled as an absolute path. Four existing
tests held the old absolute path: tests/test_refusal_default_remediation.py
(the `yaml-unparsable` line under the lockstep remedy),
tests/test_bump_leg_unreadable.py (the validator names the other leg's pin
POSIX now, on Windows too), tests/test_reader_refusals_named.py (#817's
`yaml-unparsable` line from the root's gate, which names
`contracts/spec-pin.yaml`) and a docstring in
tests/test_validate_pins_unreadable_workflow.py.

Closes #712

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant