Skip to content

v0: naming policy, assembly-root templates, scaffold, bootstrap, and the agent procedure - #1

Merged
brettheap merged 7 commits into
mainfrom
v0/scaffold
Sep 2, 2026
Merged

brettheap merged 7 commits into
mainfrom
v0/scaffold

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

The first usable version of the shape: naming policy, assembly-root templates,
scaffold, bootstrap, the lockstep validator, and the agent procedure. Built
against the staged openxFactory topic
ideation/staging/project-repo-schema/project-repo-schema.md and its
recommended answers, and against Brett's 2026-09-02 rulings (openRepoShape,
public, Apache-2.0; and the ASSEMBLY leg IS the per-project root repository).

What is buildable now

gh repo fork opensoft/openRepoShape --org <org> --clone
python3 scaffold-project.py --org <org> --project Atlas --dry-run
python3 scaffold-project.py --org <org> --project Atlas --elected-by 'Name'
git clone --recurse-submodules https://github.com/<org>/Atlas.git
cd Atlas && make bootstrap
  • contracts/repository-naming.yaml — the four families as data
    (open<Product>, <Domainx><Product>, <X>-Install, and the three project
    legs), each with a regex, real examples, counter-examples, and a declared
    PRECEDENCE, because openxFactory satisfies two forms and MedxChart
    satisfies two. scripts/validate-repository-naming.py classifies names from
    argv, stdin or a project.yaml, exits 1 on a name matching no family, and
    --explain prints every family a name satisfies so an overlap is visible
    rather than silently resolved.
  • templates/assembly-root/ — project.yaml (the SOURCE; a register row
    is derived from it, never the reverse), three pin files in the ratified
    pinned_contract_manifest shape, a Makefile, and a validate gate on
    pull_request with submodules: true. Plus minimal spec-root/ and
    code-root/ skeletons.
  • scripts/validate-pins.py — THE LOCKSTEP VALIDATOR. Per leg: gitlink ==
    pin-file commit: == every workflow <org>/<leg>/…@<sha>, plus the tree
    digest recomputed from the submodule's object store, plus per-file digests
    over every file the scaffold copied out of openRepoShape. Refuses (exit 2)
    rather than passing on an uninitialized submodule or an unresolvable commit.
  • scaffold-project.py — validates the three names before creating
    anything; --local-remote-dir makes bare repositories on disk instead of
    calling gh (the test path); --dry-run; no --force anywhere; a push
    refused by a ruleset fails loudly with the exact command and two legitimate
    exits, neither of which is a bypass.
  • bootstrap — legs onto tracking branches AT the pin (never advancing
    it, never moving an existing branch, printing pin versus tip when they
    differ), the three validators, then the authority readout — which prints
    exactly authority is not wallet-carried in this org and continues when no
    register is found. Schema-neutral: a one-repository project runs it and gets
    the same two of three steps.
  • AGENTS.md (80 lines) and a one-line CLAUDE.md.

Python 3 standard library only — no pip, so it runs in an org that cannot
install anything. That forces a small fail-closed YAML reader in
scripts/repo_shape.py, differential-tested against PyYAML over 1036 parseable
files of the openxFactory corpus: 925 exact, 11 differing only in
folded-scalar whitespace inside prose description fields, 98 refused outright
rather than guessed. tests/test_repo_hygiene.py checks every shipped script's
imports against sys.stdlib_module_names so nobody can undo the rule with a
one-line import yaml.

Two decisions recorded in the README. (1) The digest is
sorted-ls-tree-r-v1 — the sha256 of the sorted git ls-tree -r -z <commit>
listing — and not git archive, whose tar bytes carry a pax header naming the
commit, uname/gname, an mtime and .gitattributes export-ignore handling, so
one commit can digest differently across git versions and platforms. (2)
Bootstrap and the validators are COPIED into the assembly root, so a scaffolded
project runs its own gate in an org that may never speak to the upstream again;
the copies are digest-pinned, so editing one in place is reported as drift.

What the fragment leaves open

This PR builds the MECHANICS and settles none of the governance questions.

  • Q2 (what ASSEMBLY means) is ruled for this repository but still open in
    the fragment
    , and the openxFactory exit change may not be proposed until it
    carries a disposition. The per-project root here does NOT yet pin shared
    review-team assembly code from codexFactory; that overlay is deliberately v1.
  • Q5 / the register election — the additive schema and role fields on
    project-register.yaml are an openxFactory + aggregation delta and are not
    touched here. project.yaml is shaped so a register row is derivable from it.
  • Q10 still needs Brett's confirmation that a staged fragment may serve as
    a pilot's reference. The scaffold writes that fragment path as reference:
    by default, which is the form the answer would take.
  • Q12 overlays — no review lane, no wallet mechanics, no author act. The
    authority readout reports whatever rows a register carries and confers
    nothing.
  • Not built: git hooks (the fragment's bootstrap step (b) mentions them),
    bootstrap --check for upstream shape drift, a digested release for
    openxFactory to pin, and OpsxFactory's org-level naming/topic enforcement.

Tests

python3 -m pytest tests -q

83 passed in 9.60s

No network, no gh, and no real repository is ever created: the end-to-end
test scaffolds into three BARE repositories in a temporary directory, clones
the assembly root with --recurse-submodules, and runs bootstrap in the
clone — asserting exit 0, both legs on main at their pinned commit, the pin
unmoved, and the degrade line printed verbatim. The pin suite is one test per
way the three facts come apart, including the aggregation's August defect
reproduced (gitlink advanced alone). .github/workflows/tests.yml runs the
suite on pull_request.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ

brettheap and others added 7 commits September 2, 2026 17:05
The four live families — neutral products `open<Product>`, domain descendants
`<Domainx><Product>`, installs `<X>-Install`, and project legs `<Project>` /
`<Project>-spec` / `<Project>-code` — with a regex, a description, real
examples and counter-examples each, plus the `xf-project-<id>` topic form.

Precedence is declared IN THE DATA and applied first-match-wins, because some
names satisfy two forms: `openxFactory` is both `open`+product and an
x-stem+product, `MedxChart` is both a descendant and a bare assembly-root
token. `--explain` prints every family a name satisfies so an overlap stays
visible rather than being silently resolved.

`scripts/repo_shape.py` carries the shared, standard-library-only helpers:
a small fail-closed YAML reader (PyYAML would be one dependency and one is
more than "clone it and run it" allows in an org that cannot pip install),
the `sorted-ls-tree-r-v1` tree-digest definition, per-file sha256, and the
gitlink reader. The reader was differential-tested against PyYAML over 1036
parseable YAML files in the openxFactory corpus: 925 exact, 11 differing only
in folded-scalar whitespace inside prose `description` fields, and 98 refused
outright rather than guessed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
`templates/assembly-root/` is what the scaffold materializes for `<Project>`:
the self-describing `project.yaml` manifest (the SOURCE, from which an
aggregation's register row is DERIVED and not the reverse — the only
construction that works for an org with no register at all), three pin files
in the family's ratified `pinned_contract_manifest` shape, a Makefile with
`bootstrap` / `validate` / `pins`, and a `validate` gate that runs on pull
requests with `submodules: true`.

`scripts/validate-pins.py` is the lockstep validator. For each leg it asserts
that the gitlink, `contracts/<role>-pin.yaml` `commit:`, and every workflow
`<org>/<leg>/...@<sha>` reference name the same commit, and it recomputes the
leg's tree digest from the submodule's own object store on top — a gitlink and
a pin that agree on a commit whose bytes moved is drift the commit comparison
alone cannot see. It refuses (exit 2) rather than passing on an uninitialized
submodule or an unresolvable commit, because an unanswerable pin question is
never an implicit pass.

The shape pin is a COPY pin: openRepoShape is not mounted in a scaffolded
project, so identity is carried by per-file sha256 rows over the files the
scaffold copied, and editing a copied validator in place is reported as drift
with the exit named (carry it upstream, do not update the digest).

`scripts/bootstrap.py` pays the submodule tax: it creates each leg's tracking
branch AT the pinned commit, never advances a pin, never moves a branch that
already exists elsewhere, and prints pin versus tip when they differ. Its
authority readout degrades to one stated line rather than failing, and the
whole command is schema-neutral so a one-repository project runs it unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
`scaffold-project.py` validates the three names against the policy BEFORE it
creates anything (a naming mistake caught there costs a message; caught later
it costs three repositories and a rename), creates the remotes, materializes
and pushes the two legs, mounts them as submodules of the assembly root,
computes the three pins, and sets the `xf-project-<id>` topic.

`--local-remote-dir` makes three BARE repositories on disk and uses them as
origins instead of calling `gh`. That is the test path, and it is the only path
the suite is allowed to take: no test may create a real repository.

Submodules are added from the leg's WORKING TREE and the recorded URL is then
rewritten to the canonical remote, so the scaffold never depends on a push
having propagated and `--no-push` produces the same tree.

A push refused by an organisation ruleset fails LOUDLY: the exact command, its
exit code, its output, and two legitimate exits (an operator with the bypass
right seeds the branch, or push a seed branch and open a pull request).
Bypassing the ruleset is not among them. There is no --force anywhere: it
refuses to write over an existing remote or a non-empty working tree, because
re-running over a live project is not a scaffold.

The root `bootstrap` shim is for the case the doctrine requires to work and the
scaffold does not reach: a project that has NOT elected the schema — one
repository, no manifest, no submodules — running the same command and getting
the same two of three steps. A bootstrap that existed only for electing
projects would make the election worth something operationally.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
… run

83 tests, no network and no GitHub. The end-to-end fixture runs the scaffold
into bare repositories in a temporary directory, clones the assembly root with
`--recurse-submodules`, and runs `bootstrap` in the clone — asserting exit 0,
that both legs land on `main` at their pinned commit, that the pin did not
move, and that the degrade line is printed verbatim.

The pin suite is one test per way the three facts come apart: the gitlink
advanced alone (the aggregation's August defect, reproduced), a digest that no
longer recomputes, and a workflow `@<sha>` that disagrees with the gitlink —
plus a copied shape file edited in place, and the refusals that must not
degrade into passes (an uninitialized submodule, a commit absent from the
object store, a pin declaring a tag).

`test_repo_hygiene.py` enforces the constraint that makes the whole thing
forkable: every shipped script's imports are checked against
`sys.stdlib_module_names`, so nobody can quietly undo the no-pip rule with a
one-line `import yaml`, and every file in the assembly-root template must be
named in the scaffold's copy lists or it would silently never reach a project.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
README: what this is and what was ruled on 2026-09-02, the fork → scaffold →
clone → bootstrap flow with exact commands, what each leg holds, the double pin
and the lockstep invariant with the incident that earned it, the degrade rule
quoted verbatim, and this repository's layout.

Two decisions are recorded there rather than left implicit. WHAT IS DIGESTED:
the sha256 of the sorted `git ls-tree -r -z <commit>` listing, not
`git archive` — whose tar bytes carry a pax header naming the commit,
uname/gname, an mtime and `.gitattributes` export-ignore handling, so one
commit can digest differently across git versions and platforms, which is
disqualifying for a number two machines must agree on. WHERE BOOTSTRAP LIVES:
copied into the assembly root by the scaffold, so a scaffolded project runs its
own gate in an org that may never speak to the upstream again, with the copies
digest-pinned so drift is still reported.

AGENTS.md is the procedure for "tell my AI to scaffold a new project", which
Brett's phrasing makes a requirement rather than a figure of speech: confirm
five things, check the names, dry-run, get an explicit yes, then run. Its rule
that outranks the rest is that no repository is created without that yes and no
organisation ruleset is ever worked around.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
…bytecode

The parent's stdout is block-buffered when it is a pipe, so a validator child
writing straight to the fd appeared BEFORE the heading that introduced it —
flush around the subprocess calls. The per-leg line reads `[spec] spec:` rather
than `spec     spec:`, which stops looking like a stutter when the role and the
mount path happen to be the same word.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
Staging a directory rather than explicit paths is how compiled bytecode ends
up in a standard's first release. Removed from the index; the root `.gitignore`
added in the previous commit keeps it out.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
Copilot AI lite review requested due to automatic review settings September 2, 2026 21:22

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @brettheap, your pull request is larger than the review limit of 150,000 diff characters

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

templates/assembly-root/scripts/bootstrap.py claims the checkout “stays at the pin” when branch tip and pin disagree, but it doesn’t actually check out the pinned commit in that case.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR delivers the first end-to-end usable “openRepoShape” v0: a standard-library-only scaffolder plus assembly-root/spec-root/code-root templates, neutral validators (naming/manifest/pins), and bootstrap behavior, backed by a full pytest suite and an agent procedure (AGENTS.md) for safe execution in orgs with strict rulesets.

Changes:

  • Add repository naming policy as data (contracts/repository-naming.yaml) plus a CLI validator (scripts/validate-repository-naming.py).
  • Add assembly-root/spec-root/code-root templates including bootstrap + manifest/pin validators, and a scaffold tool (scaffold-project.py) that can target GitHub or local bare remotes for tests.
  • Add comprehensive pytest coverage and CI workflow to ensure the shape remains standard-library-only and the e2e scaffold/clone/bootstrap path works.
File summaries
File Description
tests/test_scaffold_e2e.py End-to-end test: local bare remotes scaffold, recursive clone, bootstrap behaviors.
tests/test_repo_hygiene.py Enforces “stdlib-only” for shipped scripts and template/scaffold completeness checks.
tests/test_pin_validator.py Tests lockstep pin validator drift/refusal modes.
tests/test_naming_policy.py Tests naming policy classification and CLI behavior (including overlaps).
tests/test_manifest_validator.py Tests manifest validator findings/refusals for project.yaml.
tests/conftest.py Shared fixtures for single scaffold + recursive clone reused across tests.
templates/spec-root/requirements/.gitkeep Seeds non-empty spec tree.
templates/spec-root/README.md Template README for spec leg with assembly-root-first workflow.
templates/code-root/src/.gitkeep Seeds non-empty code tree.
templates/code-root/README.md Template README for code leg with assembly-root-first workflow.
templates/assembly-root/scripts/validate-pins.py Lockstep validator: gitlink vs pin vs workflow refs, plus digest and copy-pin drift.
templates/assembly-root/scripts/validate-manifest.py Validates project.yaml envelope, roles/paths/org consistency, and naming-policy alignment.
templates/assembly-root/scripts/bootstrap.py Bootstrap: place legs on tracking branches at pins, run validators, report wallet register.
templates/assembly-root/README.md Assembly-root README template describing layout, invariants, and copied validators.
templates/assembly-root/project.yaml Project manifest template defining schema election, legs, pins, topic, and shape pin.
templates/assembly-root/Makefile Minimal targets: bootstrap/validate/pins.
templates/assembly-root/contracts/spec-pin.yaml Spec pin template (commit + digest + invariant notes).
templates/assembly-root/contracts/shape-pin.yaml Shape copy-pin template (commit + digest + per-file sha256 list placeholder).
templates/assembly-root/contracts/code-pin.yaml Code pin template (commit + digest + invariant notes).
templates/assembly-root/.gitignore Template ignore rules for scaffolded assembly roots.
templates/assembly-root/.github/workflows/validate.yml Template PR gate running neutral validators with submodules checkout.
scripts/validate-repository-naming.py Naming policy CLI validator (argv/stdin/project.yaml).
scripts/repo_shape.py Shared stdlib-only helpers: YAML subset parser, digests, naming policy, git helpers.
scaffold-project.py Main scaffold tool for creating/remotes + templating + pins + topics (supports local bare remotes).
README.md Expanded repo-level documentation: doctrine, invariants, digest definition, bootstrap behavior.
contracts/repository-naming.yaml Naming families + precedence + topic rules + negative examples as data.
CLAUDE.md Points Claude-based tooling at AGENTS.md.
bootstrap Shim to run bootstrap against non-scaffolded (one-repo) projects using canonical template script.
AGENTS.md Agent procedure for safe scaffolding (explicit confirmation, no ruleset bypass).
.gitignore Repo-level ignores for Python cache and pytest cache.
.github/workflows/tests.yml CI workflow running pytest (only installs pytest) and setting git identity for test scaffolds.
Review details
  • Files reviewed: 30/31 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +128 to +132
print(f" [{role}] {path}: PIN {_short(pin)} != branch {branch} tip "
f"{_short(local)}")
print(f" not moving an existing branch. The checkout stays at "
f"the pin; the recorded pin is authoritative and advancing it is an "
f"explicit commit in this repository.")
Comment thread scaffold-project.py
already exists. There is no --force: re-running over a live project is not a
scaffold, and the failure mode of getting it wrong is silent data loss.

EXIT CODES: 0 done · 1 nothing (dry run prints and exits 0) · 2 refusal.
@brettheap
brettheap merged commit 86bf553 into main Sep 2, 2026
3 checks passed
brettheap added a commit that referenced this pull request Sep 3, 2026
The copied `.github/workflows/validate.yml` was REJECTED by GitHub on the
first real projects (MedxSoft/MedxEHR PR #8, MedxSoft/MedxGlass PR #1):
"This run likely failed because of a workflow file issue", a push-event
run with zero jobs. Cause: the step `fail — SHAPE_LEGS_TOKEN is set but
the legs still could not be fetched` had
`if: ... && secrets.SHAPE_LEGS_TOKEN != ''` — the `secrets` context is not
available in a step-level `if:` expression ("unrecognized named-value
'secrets'"), so GitHub cannot parse the workflow file at all.

Fix: add a job-level `env: SHAPE_LEGS_TOKEN_SET: ${{ secrets.SHAPE_LEGS_TOKEN
!= '' }}` (the `secrets` context IS allowed in `env:`) and change the step
condition to `if: ... && env.SHAPE_LEGS_TOKEN_SET == 'true'`. The checkout
step's `token: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}` is unchanged
(allowed in `with:`).

- Updated the existing rendered-workflow assertion in
  tests/test_scaffold_e2e.py for the new step condition, and added
  test_no_if_expression_reads_the_secrets_context, which walks every `if:`
  line in the rendered workflow (not just the one step) asserting none
  contains `secrets.`, and that the job `env` carries
  `SHAPE_LEGS_TOKEN_SET`.
- Added an actionlint step to .github/workflows/tests.yml (pinned release
  binary v1.7.12, sha256-verified, no pip/go required) that lints
  templates/assembly-root/.github/workflows/validate.yml — confirmed
  locally that it flags exactly this defect on the pre-fix file and passes
  clean on the fix.
- Noted in both the aggregation README and the scaffolded-project template
  README that the SHAPE_LEGS_TOKEN presence check reads a job-level `env`
  value rather than the `secrets` context directly; bumped the README line
  cap 265 -> 267 (test_readme_is_short_enough_to_be_read) for the added
  sentence.

python3 -m pytest tests -q: 232 passed.


Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ

Co-authored-by: openRepoShape CI <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 10, 2026
…y, unambiguous by construction like -Install, creating nothing and conferring nothing (#81) (#86)

#81, under Brett Heap's ruling of 2026-09-09, on the workspace repository once
there are two engineers: "the new-workstation name is one per user right? so if
we have brett and scott as engineers, then we need something like brett-wip and
scott-wip right?" — and, for this slice, his word of 2026-09-10: "claim 81 and
start on it". The issue's two open decisions are taken as its own
recommendations: nothing in this standard creates a `<user>-wip` repository,
and `<user>` is the GitHub login lowercased. Follows #77 (park/resume, the
workspace manifest, Amendment 4) and #82.

THE FORM. `contracts/repository-naming.yaml` gains `workspace`, precedence 6,
`^[a-z0-9]+(?:-[a-z0-9]+)*-wip$`: one lowercase login token — single hyphens
inside it, as a GitHub login admits, and no doubled ones, none leading and none
trailing — then the literal `-wip`. It is NOT declared-only, and that is the
point: the suffix is spelled by no other form in the file, so it is unambiguous
by construction exactly as `<X>-Install` is and needs no `--role`. The prose is
the file's own register and says what it IS (the private repository one person
owns, holding `workspaces/<org>/…` manifests and `handoffs/<estate>/…`, which
is the handoff home Amendment 4 gives them), what it is NOT (not a project, not
a leg, not a family; it holds no code, elects nothing, is membership of nothing
and confers nothing), WHERE IT LIVES (the person's home organisation by
default, one per person, indexing every org with a folder per org inside it,
with the opt-in `orgs:` override in `~/.agents/workspace.yaml` for an
organisation whose work must not be indexed outside it — rulings 1 to 3), and
that NOTHING HERE CREATES ONE. Every existing form's text, pattern and
precedence is untouched.

NOTHING ELSE MOVED, which is the property the README states and the reason the
family form was declared-only. 2100 combinations — every name in the five older
families' own data, times five roles, times six pin sets, times two recorded
chains — classify identically before and after: family, role, `also_matches`,
reason and referent status. `tests/test_naming_policy.py` now carries that as a
TABLE rather than as a claim (`KEEPS_ITS_ANSWER`, 51 rows, one property), and
the table is extended with the sixth form's own positives and near-misses
rather than doubled by a parallel test. `brett-wip` matched NOTHING before this
form existed; a name of that spelling is the only kind whose answer changes.
`brett--wip` and `brett-wip-2` join `unclassified_examples:` in the contract,
because the negative half of the policy is data here too.

THE CLASSIFIER. `UNAMBIGUOUS_FORMS` in `scripts/repo_shape.py` is now the list
`classify()` reads for the forms that need nothing declared, and it is in CODE
rather than in the policy data deliberately: `repository-naming.yaml` and
`repo_shape.py` are SEPARATE rows of a project's `shape-pin.yaml` and
`update-shape.py` can move one without the other, so a
`unambiguous_by_construction:` key read out of the file would make a new
classifier reading an old copied policy classify every `open<Product>` as a
project leg. The residual tail no longer assumes the descendant family is among
the matches: it raised `KeyError: 'domain-descendant'` for any form with no
branch of its own — a data file crashing the tool that reads it, which is what
`brett-wip` would have hit had the form been added to the contract alone — and
a seventh form now reports by precedence with a reason saying this classifier
has no rule for it. `accepts_role` needed no change and refuses a workspace
name in every role, which is how "nothing creates one" is a check rather than a
sentence: `scaffold-project.py brett-wip` is refused as it always was, now
naming the form instead of "matches no family".

`validate-repository-naming.py` classifies `brett-wip` as `workspace`, and
`--explain` names the rule on the row it applies to — `<X>-Install` gains the
same note, which was always true of it and never printed. `--role workspace` is
refused as the unknown choice it is, for the same reason `--role install` always
has been: only a form that needs a DECLARATION is a value there, and this one
needs none. A role that IS a choice, declared over such a name, is ignored
rather than carried.

DOCS. The README's naming-families sentence is six with a line for
`<user>-wip`, and the Layout block's row with it; the "Carrying in-flight work
to another workstation" section gains one paragraph — the name, the home-org
default, the `orgs:` override, `resume <Name> --workspace <owner>/<user>-wip`
on a fresh machine, and that nothing here creates one; AGENTS.md's "What you
must not tell them" gains the sentence that a `<user>-wip` repository confers
nothing either. README 1203 -> 1219 and AGENTS.md 370 -> 374, both caps moved
with dated rationale in each function's own style.

EXISTING ROOTS TAKE IT THROUGH `update-shape.py`.
`contracts/repository-naming.yaml` is a COPIED, PINNED row of every scaffolded
project's `contracts/shape-pin.yaml` (`COPIED_FROM_SHAPE`, and
`FAMILY_COPIED_FROM_SHAPE` for a holder), so it reports `upstream-changed` and
`apply` moves it — alongside `scripts/repo_shape.py`, which is a row of its
own.

FOLLOW-UP, not in this commit. `docs/handbook.html` is the designed reading of
the README and follows in its own pass, as #81 says: its line 994 still says
five families and 1251 says four. Separately, and stale since #1 rather than
because of this change, `templates/assembly-root/README.md:150` says "the four
naming families".

887 passed, 1 skipped. No GitHub repository was created, and nothing was
pushed.

Lane: xfactory-2 (xFactory-2)

Co-authored-by: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 10, 2026
…s one command and points at the other installer, the command tests go with the files, and nothing under `templates/` moves (#92)

Slice S2 of #92: park and resume are opensoft/openRepoTools' now (PR #1 there, main 9fbf01c). openRepoShape --install places one command and prints the pointer at openRepoTools' installer without fetching from it; the command tests go with the files; the Make targets, AGENTS-shape.md and everything under templates/ are untouched, so no project receives an upstream-changed row. Adversarially reviewed: 1 body defect and 5 nits closed; Copilot's quoted-path finding fixed.

Lane: xfactory-2 (xFactory-2)
@brettheap
brettheap deleted the v0/scaffold branch September 11, 2026 20:06
brettheap added a commit that referenced this pull request Oct 12, 2026
…d must close there, so `k: [it's, a]` reads two items, `k: it's fine # note` drops its comment, and an unclosed `"abc` or a mid-key `[` is refused, not misread (#249, #250) (#284)

**The reader (`scripts/repo_shape.py`).** It now has one rule for where a quoted scalar starts and one for where it ends. That replaces three separate toggles and a first-and-last-character test.

- `_unquoted(text, flow=False)` yields each character that no quoted scalar holds. A quote opens a quoted scalar only where a scalar begins: at the start of the text, or after `- `, `: `, `[`, `{`, or a `,` inside a flow, with any spaces after each. Anywhere else (`it's`, `a"b`) the quote is an ordinary character of a plain scalar. On a block line, a `,` or `[` in the middle of a plain scalar is not structure either, so `k: a, 'b # c'` is the plain scalar `a, 'b` followed by a comment, which is how YAML reads it.
- `_quote_end(text, start)` decides where the scalar ends: at a `"` that no backslash escapes, or a `'` that is not doubled.
- `_strip_comment`, `_split_key` and `_split_flow` read structure through `_unquoted`, so all three agree (#249).
- `_scalar` hands any text that begins with a quote to the new `_quoted_scalar`. The whole text must be one quoted scalar, or it raises `quoted scalar without a closing quote: …` or `quoted scalar with text after its closing quote: …` (#250). `load_yaml` turns either into `REFUSED yaml-unparsable`.
- `_unquote_key` sends every key that begins with a quote through `_scalar`, so `"a" b: 1` is refused instead of becoming the key `"a" b`.
- `_split_key` refuses a `[` or `{` later in a key, by name (see "Why `_split_key` refuses a bracket later in a key" below). A `[` or `{` that opens the text still makes a flow item.
- One paragraph is added to the reader's header comment. `_split_key_flow`, `_flow`, `_flow_value`, `_tokenise` and `_parse_*` are untouched; #252 and #248 work in those and have landed.

**The template renderer (`scripts/shape_materialize.py` `render`).** In a `.yaml`/`.yml` template, a value that sits between double quotes (`"{{ELECTED_BY}}"`) is now spelled by `double_quoted`. That is the writer this reader takes back unchanged. For any value with no quote, no backslash and no character `str.isprintable` refuses, `double_quoted` returns the value itself between quotes. So commits, digests, dates and ordinary names (`O'Brien & Co: #1 [draft] {x} é 日本 😀` included) render byte for byte as before in all 19 templated files, and README/AGENTS templates keep raw values. A name that holds a character `str.isprintable` refuses (a no-break space, U+3000, the ideographic space common in Japanese names, a zero-width joiner in an emoji sequence, or a soft hyphen) now renders as an escape in `project.yaml`, `family.yaml` and `single-repository.yaml` (`山田\u3000太郎`), and reads back equal. It is the same rule the adoption plan writer already follows.

The two issues' tables, read with each tree's own reader (`issue_tables.py`). Every head result matches PyYAML 6.0.3:

| document | 150c41d | head |
|---|---|---|
| `k: [it's, a]` | `["it's, a"]` | `["it's", "a"]` |
| `k: {a: it's, b: 1}` | `{"a": "it's, b: 1"}` | `{"a": "it's", "b": 1}` |
| `k: it's fine # note` | `"it's fine # note"` | `"it's fine"` |
| `k: [it's, a] # note` | refused: not a flow collection | `["it's", "a"]` |
| `it's: 1` | refused: expected `key: value` | `{"it's": 1}` |
| `k: [a"b, c]` | `['a"b, c']` | `['a"b', 'c']` |
| `k: [a"b\", c]` | `['a"b\\", c']` | `['a"b\\"', 'c']` |
| `created_by: "Brett Heap` | `'"Brett Heap'` | refused: no closing quote |
| `k:\n  - "a\"` | `['a\\']` | refused: no closing quote |
| `k: "a" b "c"` | `'a" b "c'` | refused: text after its closing quote |
| `k: 'a' b 'c'` | `"a' b 'c"` | refused: text after its closing quote |
| `k: ["a\", b]` | `['"a\\", b']` | refused: no closing quote |

The other five #250 rows (`k: "abc`, `k: "a\", b`, `k: "a"b`, `k: 'abc`, `k: ["a, b]`) are refused on head the same way.

**Why `_split_key` refuses a bracket later in a key.** `_split_key` has always returned `None` for any `[` or `{` ("a flow collection is not a key in this subset"). On 150c41d a quote toggle hid the bracket whenever the key held a quote pair, so `note "[1]": x` was a mapping entry by accident. Reading quotes only where a scalar begins lets that rule see the bracket. As a mapping entry that would be a refusal, but `_parse_sequence` takes `None` to mean "a scalar item", so `- note "[1]": x` would have read as the string `note "[1]": x` where YAML has a mapping: a silent misread of valid YAML. Review found it (20 of the 300 documents that regressed on one fuzz seed read that way), so the rule is now in two parts. A `[` or `{` that OPENS the text still returns `None`, so `- [a, b]` and `- {a: b}` stay flow items. One LATER in the key, before its `: `, raises `a key holding `[` or `{` is not supported: <key>`.

| document | 150c41d | head | PyYAML |
|---|---|---|---|
| `- note "[1]": x` | `[{'note "[1]"': 'x'}]` | refused, names the key | `[{'note "[1]"': 'x'}]` |
| `note "[1]": x` | `{'note "[1]"': 'x'}` | refused, names the key | `{'note "[1]"': 'x'}` |
| `- a[b]: c` | `['a[b]: c']`, a string | refused, names the key | `[{'a[b]': 'c'}]` |
| `a[b]: c` | refused: expected `key: value` | refused, names the key | `{'a[b]': 'c'}` |
| `k:\n  - a{b}: c` | `{'k': ['a{b}: c']}`, a string | refused, names the key | `{'k': [{'a{b}': 'c'}]}` |
| `k: {a[b]: c}` | refused: flow mapping entry without a key | refused, names the key | refused |
| `- [a, b]`, `- {a: b}` | flow items | flow items | flow items |

So the bracket-in-key class is now refusals, not silent misreads, and the refusal covers 150c41d's own silent misread of `- a[b]: c` too. The class is narrow in practice: no writer in this tree can emit such a key (the adoption plan and manifest writers write literal keys and put free text in values), so only a hand edit of a fixed schema reaches it. Reading `a[b]: c` as YAML does (the key `a[b]`) would mean telling a block key from a flow-entry key, which is `_split_key_flow`'s business (#252's function); accepting a mid-key bracket in `_split_key` alone newly reads 6,521 more invalid documents on one seed. That stays a follow-up (see Left out).

**Why the renderer had to change as well.** `render` pasted free text raw between a template's double quotes. So `scaffold-project.py --elected-by 'Robert "Bob" Smith'` wrote `elected_by: "Robert "Bob" Smith"`, which is not YAML. The old reader read it correctly by accident. With the reader fix alone, the scaffold would create and push all three repositories and then write a manifest its own validator refuses. A mutant of this branch without the renderer change shows exactly that: three bare remotes exist, then `REFUSED yaml-unparsable: …/project.yaml: quoted scalar with text after its closing quote: '"Atlas "the" Project"'`. On 150c41d some values were already misread rather than refused: `--reference 'docs\notes # 1'` reads back as `docs`, a line feed and `otes # 1`. I rendered every quoting template with 11 free-text values through each tree's own `render` and reader (`render_real.py`). On 150c41d 64 of 88 read back exactly. On head all 88 do. The other free-text placeholders that reach `render` are `--name`, `--reference`, `family.py --created-by`/`--name`, and the adoption plan's `elected_by`/`reference`. All three writers (scaffold, adopt `execute`, `family.py init`) render through this one function, and none pre-escapes, so nothing is escaped twice. Nothing in the tree digests or re-renders a templated file: shape-pin `files:` rows digest only the verbatim and from-shape copies.

- `tests/test_yaml_flow_quotes.py`, `DANGLING_BACKSLASH_BEFORE_THE_CLOSER` (#213's review, N5). These four rows pinned the plain-text read of a double-quoted flow item whose last character is a backslash (`k: ["a\]` read as `['"a\\']`), and their block twins reading the same. The table's own comment said that if a later change refused an unterminated double-quoted scalar, "these become refusals together with their block twins, and that is the change to make here, not a regression". They are now refusals, with their twins. The test is renamed `…_is_refused_with_its_twin` and its docstring updated. Two sentences of the module docstring that described the old toggle are reworded.
- No test pinned a "quote in a plain item" read. The single-quoted toggle rows (`['x\', 'it''s, a]']`, `{'a\': 'it''s: b'}`) read exactly as before, and their test is unchanged.

- **New tests.** The three files below hold 157 cases:
  - `tests/test_yaml_quote_boundaries.py`, 73 cases: #249's rows and their neighbours, #250's rows plus key, flow-mapping and no-space-comment forms, rows that must not change, a `double_quoted` round trip beside a plain quote, a `load_yaml` refusal, and the bracket-in-a-key rows (eight refused by name, the message quoting the key, a file read through `load_yaml`, seven flow items and values that must still read). Two rows pin that a `:` with no space after it opens no quoted scalar: `k: [a:'b, c']` reads as the two items `a:'b` and `c'`, and `k: a:'b # c'` as `a:'b`.
  - `tests/test_template_quoted_values.py`, 67 cases: every quoting template times 7 free-text values, byte identity for ordinary values, raw values in a Markdown template, and one real scaffold into local bare remotes.
  - `tests/test_yaml_flow_quotes.py`, 17 cases, of which the four N5 rows changed.

  Every expectation was checked against PyYAML 6.0.3. They disagree on eight documents, and the subset refuses each on purpose. One is `k: "a"#c`: PyYAML reads `a`, but YAML requires a space before a comment, so the subset refuses it rather than guess. The other seven are new bracket-in-key rows, which PyYAML reads as a mapping whose key holds a bracket, and which the subset refuses by name. The module docstring of `tests/test_yaml_quote_boundaries.py` still names only the first; re-verification counted all eight.
- **Fail on 150c41d.** With the three files copied onto 150c41d, 77 of the 157 cases fail (48 of 73, 25 of 67, 4 of 17) and 80 pass; all 157 pass on head. The 80 that pass are guards, and free text that 150c41d reads by accident. Of the bracket-in-a-key rows, all ten refusal rows fail on 150c41d and the seven flow-item guards pass on both.
- **Mutations.** Each of the following makes at least one new test fail: each changed function reverted to its 150c41d body (`_strip_comment` 5, `_split_key` 9, `_unquote_key` 1, `_scalar` 21, `_split_flow` 14), each rule of the new helpers mutated (comma outside a flow 2, bracket mid-scalar 1, `- ` 2, `: ` 22, `''` 6, backslash 31, text after the close 6, unclosed read as plain 15, unclosed as an ordinary character 1), and each part of the bracket rule (no raise, the start-of-text test inverted, a bracket always `None`, the flag never set: 10 to 12 each). A `:` that opens a quoted scalar with no space after it fails 2, the two rows above; review found it surviving the earlier tests. Removing the renderer change fails 41, including the real scaffold. Escaping Markdown templates too fails 1. The mutants that survive change nothing on any valid document, as review showed: the header comment; `.yml` dropped from `render` (both `.yml` templates are verbatim copies and never rendered); `_strip_comment`'s `i == 0` branch (unreachable, `_significant_text` drops a whole-line comment first); `]`/`}` no longer closing a block-line flow; and a tab after `:` or `-` (PyYAML refuses those documents itself).
- **Reach.** All 14 tracked YAML files read identically on 150c41d and head, both raw (7 ok; 7 templates refuse identically on their raw block placeholders) and with `{{X}}` rendered to bare words, and again identically between this branch with and without the bracket refusal. Nothing this repository writes holds a quote in a plain scalar, a bracket in a key, an unclosed quoted scalar, or text after a closing quote:
  - `adopt-project.py` `y()` (the adoption plan, and `shape-doctor.py`'s placement plan) writes plain only for values matching `_PLAIN_RE`, and spells everything else with `double_quoted`. Its keys are literals, and plan paths are values.
  - The pin writers (`bump-leg.py`, `update-shape.py`, `family.py`, and the shape pin's `files:` rows) quote only hex.
  - `family.py`'s member rows and every unquoted template value pass `checked_value`/naming-policy alphabets, which hold no quote.
  - The one writer that could emit the #250 construct was `render`'s quoted placeholders. That is fixed above.
- **Differential fuzz.** PyYAML 6.0.3 as the oracle only.
  - Raw text in all six contexts (flow sequence, flow mapping, value, item, key, nested item; seed 2490250; 785,646 documents, 305,393 valid), this branch against current main (c3f4987):
    - 13,752 valid documents are fixed.
    - 768 valid documents regress, and every one is a refusal, with the new message: none reads as a string. Every one has a `[` or `{` in a key. Before the refusal, against 150c41d, the same 768 were 694 refusals and 74 reads as a string.
    - 73,380 invalid documents that main read are now refused, and 5,955 that main refused are now read: 5,154 are a plain scalar that begins with a flow indicator in a key (`,": v`; main reads the quote-free twin too, follow-up 3), 775 are a flow mapping with a stray closer and an empty value (`k: {a"]:}`; main refused only because its quote toggle swallowed the `:}`, and reads the twin `k: {a]x:}` the same way, a composition with #252's empty value, follow-up 2), and 26 are in other contexts.
    - 0 crashes.
  - The refusal alone, seed 7249250 (70,941 inputs, 425,646 documents), against main c3f4987, this branch before and after it. Regressions: 300, of which 280 refused and 20 silently read before; 300 refused and 0 read after. Fixed: 7,199 both. Invalid documents newly read: 3,560 both. Misreads of valid documents that become refusals: 538 before, 2,088 after, so 1,550 more, `- a[b]: c` among them. 0 crashes.
  - Flow against block, on the merged reader: seed 2490251, 100,000 documents, 0 wrong in the flow form, 0 in its block twin, 0 where they differ; seed 2490252 with the #199 code points, 60,000 documents, 0 wrong, 0 wrong, 0 differing. (Earlier, on the uncommitted first version: seeds 2130213 and 1990213, 0 wrong in either form; review re-ran two more seeds on 21fc213, 0 wrong.)
  - `double_quoted` round trip (seed 19913, 40,000 strings in 5 positions, 0 mismatches) and #249's class densely (seed 2130213, 50,000 valid documents; 150c41d reads 19,949 wrong, head reads 0 wrong) were run on the first version, and the review re-ran the round trip on 21fc213 (seed 4925049, 30,000 strings, 0 mismatches). Neither touches `_split_key`'s new rule, and they were not re-run on the merged head.
- **Targeted runs** (git-filter-repo 2.47.0 on PATH). The five streams below ran on b764657, the head before the last merge of `origin/main`. That merge (60588d5, #251 and a `family.py` change) touched neither `repo_shape.py` nor `render`, so on the pushed head b72ab0f I re-ran the four reader files (187 passed) and `test_scaffold_referent_chain_links`, `test_template_quoted_values`, `test_cli_reference` and `test_yaml_quote_boundaries` (197 passed).
  - The three new or changed files, `test_yaml_flow_mappings`, `test_yaml_block_scalar_keys`, `test_load_yaml_refusals`, `test_adopt_plan_escapes`, `test_manifest_validator`, `test_pin_validator`, `test_neutral_pin_validator`, `test_repo_hygiene`, `test_cli_reference` and `test_adopt_plan`: 512 passed, 1 skipped (`test_adopt_plan.py:393`, `SHAPE_MEDXEHR_CLONE` unset).
  - The four reader files alone (`test_yaml_quote_boundaries`, `test_yaml_block_scalar_keys`, `test_yaml_flow_quotes`, `test_yaml_flow_mappings`): 187 passed.
  - `test_shape_doctor`: 191 passed.
  - The renderer's callers, `test_scaffold_e2e`, `test_scaffold_pin_and_reuse`, `test_reference_default`, `test_family`, `test_windows_paths`, `test_naming_policy`: 366 passed.
  - `test_adopt_e2e`, `test_adopt_spec_only`, `test_update_shape`: 110 passed.
  - Review also ran, on 21fc213: `test_shape_advisory`, `test_bump_leg`, `test_reuse_visibility`, `test_update_shape_add`, `test_scaffold_ignored_shape_files` (97 passed) and `test_adopt_submodules` (132 passed). They were not re-run on the merged head.

This branch carries `origin/main` at 60588d5, by four merges (eb6df75, c3f4987, 5751460, 60588d5). Only the first conflicted, in one hunk of a comment: both this branch and #252 (landed as 4b2add8) add a paragraph to the reader's header comment right after "confident tone.". Both paragraphs are kept, this branch's first, with a `#` line between them. Every code hunk merged by itself, including #252's `_split_key_flow`, which calls this branch's `_split_key`, and `shape_materialize.py`. The merges of #248 (c3f4987, a block scalar's record as a pair), of #251 (23e16ae) and of the two others were clean. `repo_shape.py` is the same file after the last three merges as after the second. On the merged reader, `test_yaml_flow_mappings`, `test_yaml_block_scalar_keys` and `test_scaffold_referent_chain_links` pass beside this branch's files (see Evidence).

`git merge-tree --write-tree` of the head against `origin/main`: clean. Against another lane's open PR:

- #266 (`fix/leg-path-yaml-scalars`) conflicts in one place: the `from repo_shape import (…)` block of `scripts/shape_materialize.py`, where this branch adds `double_quoted` and #266 adds `parse_yaml`. Whichever lands second resolves it as `double_quoted, file_sha256, parse_yaml,`. There is no semantic interaction: a leg path is an unquoted template value, and `SAFE_PATH_RE` admits no quote.

- **Reading a `[` or `{` inside a plain block key as YAML does.** `a[b]: c` and `- a[b]: c` are refused by name here; YAML reads the key `a[b]`. Reading them needs block keys and flow-entry keys told apart (`_split_key_flow`'s business), and must refuse only a block key that BEGINS with `[` or `{`. A first try that accepted a mid-key bracket in `_split_key` alone fixed all 300 regressions on one seed, but newly read 6,521 more invalid documents (keys beginning `]` or `}`, and `{a[b]: c}` entries). Candidate follow-up.
- **A plain flow item followed by a nested flow, and unbalanced brackets.** `k: [x [a, b]]` reads as the one scalar `x [a, b]`, and `k: {a:}#}: b}` reads `{'a:}#}': 'b'}`, because `_flow` checks only a body's ends. PyYAML refuses both. Candidate follow-up.
- **Implicit single-pair mappings in a flow sequence.** `[k: v]` still reads as the string `'k: v'`, as #213's review (F4) found.
- **Not supported, by choice.** A quoted scalar spanning lines is outside the subset, and 150c41d did not always refuse it. When the continuation line was indented deeper, it was refused as unexpected indentation. When the continuation sat at the parent's column, it was MISREAD: `k: "a` then `b: c"` read as `{'k': '"a', 'b': 'c"'}`, and `- 'a` then `- b'` as `["'a", "b'"]`. Every such form is now refused at its first line, naming the unclosed scalar. `k: "a"#c` is refused too, as explained above.
- Not run locally: the full suite, and the macOS and Windows legs (CI ran them). The new tests write their files as bytes, pass no text to git's stdin, and pass the scaffold its arguments as a list.

Reviewed adversarially (APPROVE WITH NITS, 0 blockers). Fix round 1 ports the review's narrow `_split_key` refusal, adds the rows it asked for and merges main; its re-verification found no blocker or should-fix. CI is green on Linux, macOS and Windows.

Closes #249
Closes #250

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
… via #236) into fix/adopt-record-submodule-placement

Brings in b30595c (#249, #250), be2790e (#204) and 6d8d88b (#203) on top
of c3a9645. No rebase. b30595c changes scripts/repo_shape.py and
scripts/shape_materialize.py, as this branch does. be2790e changes
update-shape.py and 6d8d88b changes scripts/family.py, neither of which
this branch touches.

One conflict, in scripts/shape_materialize.py's `from repo_shape import`
block. b30595c imports `double_quoted` for `render`, and this branch
imports `PATH_CLIMBS`, `PATH_ITSELF`, `PATH_NOT_CANONICAL` and
`path_spelling_fault` for `_spelling_reason` and `LEG_SEGMENT_REASONS`.
Kept all of them, in the block's order.

Merged without a conflict, and checked:

- scripts/repo_shape.py: b30595c reads a quote as opening a quoted scalar
  only where a scalar begins, and requires the whole text to be that one
  scalar (`_unquoted`, `_quote_end`, `_quoted_scalar`; `_scalar` hands
  them any text that begins with a quote). The record writes every path
  and reason as one whole scalar through `double_quoted`. `double_quoted`,
  `_escaped`, `_ESCAPE_OF`, `_unescape`, `parse_yaml` and
  `path_spelling_fault` are unchanged by the merge. Through the merged
  reader, `submodule_record` then `parse_yaml`, path and resolution, there
  are 0 mismatches in each set:
  - 4,525 names, plus 35 more;
  - 240 aimed at #252 and #248;
  - 195 aimed at #249 and #250: `it's`, `a"b`, `"abc`, `a" b "c`,
    `a' b 'c`, `"a\"`, `a\`, `[it's, a]`, `note "[1]"`, `"Brett Heap`,
    `O'Brien & Co: #1 [draft] {x}`, and more.
- scripts/shape_materialize.py: b30595c spells a YAML template's
  `"{{KEY}}"` value with `double_quoted` in `render`. The record is
  appended after `render` has run (`text += append.get(rel, "")` in
  `_materialize`), so no part of it passes through `render`. This branch's
  `_spelling_reason`, `LEG_SEGMENT_REASONS` and `leg_path_problem` are
  unchanged.
- No top-level name is bound twice in adopt-project.py,
  scaffold-project.py, scripts/repo_shape.py, scripts/shape_materialize.py,
  shape-doctor.py, validate-manifest.py, update-shape.py or
  scripts/family.py. Each merged module's names are the base's plus what
  either side added. The only thing both sides changed is the import block
  above.
- The branch's diff against main is still #189 alone: 12 files, +1670
  -157, file by file the same as against c3a9645.

Lane: openreposhape-1 (openRepoShape-1)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 12, 2026
…refused `gh pr create`, and step 7 keys its way out to the exit it prints, so an `IS pushed` exit 2 is finished by hand, not re-run into a second pair of legs (#304) (#371)

AGENTS.md step 7 told an assistant that any non-zero exit of `adopt-project.py execute` is "to fix the plan and re-run into fresh legs". That is the way out of a failed verification, exit 1. In GitHub mode `execute` has two more non-zero exits, both exit 2, and both come after both legs and the split branch are pushed:

- `gh pr create` refused: `The branch IS pushed. Open the pull request by hand:` and the command. `execute` returned before `_verify`, so no table was printed and the pull request to open by hand was for a split nothing had checked.
- The topic will not set: after `adoption verified`, `The split IS pushed and the pull request IS open. Set the topic by hand:` and three commands.

On either, the way out is the printed command, and "re-run into fresh legs" abandons a finished adoption for a second pair of legs. No test reached either function, because `--local-remote-dir`, the path every test takes, skips both (`if not local:`).

- **AGENTS.md step 7**, four lines longer (477 -> 481 on origin/main, the cap raised with a dated entry in `tests/test_repo_hygiene.py`; #309 landed first and its `464 -> 477` entry is kept as it is). It keys the advice to the exit the tool prints: exit 1 keeps its content (the source is untouched, fix the plan, re-run into fresh legs); exit 2 saying `IS pushed` (GitHub only, `gh pr create` or the topic refused) comes after both legs and the split are pushed and verified, so finish with the command it prints and never re-run into fresh legs.
- **`adopt-project.py`, behaviour (fix round 1, below):** a refused `gh pr create` no longer returns before the verification. The by-hand command is printed after the table, and only when the table passed.
- **`adopt-project.py`, the module docstring's EXIT CODES paragraph.** It gave exit 2 one meaning, "the question could not be asked". It now names the two exit 2s that come after the push and the verification, in the tool's own words, and says that a failed verification outranks both. `--help` carries none of it, so `docs/cli.md` is unchanged (`scripts/render-cli-reference.py --check`: `docs/cli.md is what the generator produces`).
- **`tests/test_adopt_github_exits.py` (new, 11 tests).** The issue's reproduction as a test: a `#!/bin/sh` `gh` that refuses one command (the pattern of `tests/test_scaffold_leg_paths.py`, `WINDOWS_SKIP`) and a throwaway global git config rewriting `https://github.com/` to bare repositories under `tmp_path`, so no network. Each exit is asserted as exit 2 with its REFUSED block and its by-hand command word for word, a table, both legs and the split branch pushed; the command comes after the table in a merged stream; a verification that really fails gives exit 1 with a refused pull request and no command to open one. Step 7's anchors (`IS pushed`, `gh pr create`, the topic) and the EXIT CODES paragraph are asserted against what the tool prints, so rewording either side alone fails a test.

The issue's second "what would fix it" bullet. Reproduced on d3f71d6 first (a source with its own `contracts/shape-pin.yaml` kept in the root fails the verification for real, nothing in the tool replaced):

| scenario, GitHub mode, merged stdout+stderr | before (d3f71d6) | after |
|---|---|---|
| `gh pr create` refused, split verifies | exit 2; no table; `Open the pull request by hand` (line 19) | exit 2; table (27), `adoption verified` (33), then `Open the pull request by hand` (37), the last thing printed |
| `gh pr create` refused, split FAILS verification | exit 2; `Open the pull request by hand` for a split that is wrong, never verified | exit 1; the finding and the footer; `No pull request was opened, and none should be: the split above did not pass verification.`; no command to open one |
| topic refused, either | unchanged | unchanged (exit 2 / exit 1) |

**The order, and why.** The split is pushed, then `gh pr create` is tried; a refusal prints its REFUSED block at once (what failed); the topic is not tried; `_verify` runs; then the by-hand lines are printed or withheld by what `_verify` said. Evidence for each step:

- *The by-hand text has to come after the verdict.* The command is only right for a split that passed; a failed one must not get it (the brief), and a person who sees only the REFUSED block above, which names the exact `gh pr create ...` that was tried, may paste it. So `_open_it_by_hand` runs after `_verify`, and a failed split gets the sentence above in its place.
- *It flushes stdout first.* Under a pipe stdout is block-buffered and the table is on it. In the merged logs above (stdout to the same file as stderr), every stderr line lands ahead of every stdout line on d3f71d6: the topic's by-hand commands print at line 7 of 26, before the table at 20. A test (`..._comes_after_the_table`) fails without the flush.
- *The topic is not tried after a refused pull request*, as before (it returned early). Its by-hand message says the pull request IS open, so printing it would be false; the stub `gh` lets a topic through, and a test asserts it is never set on this path.
- *Verifying first and opening the pull request only on a pass* was considered and not done: it reorders every successful run's output (the pull request line moves below `adoption verified`, and `_verify`'s `NEXT: review the pull request` is printed first), and it is not "the code path the topic case uses". It would fix something real, below.

The code reuses the topic's path, with no second verification: `cmd_execute` already ran `_verify` after the topic step; the early `return 2` is gone, `_open_the_pull_request` prints the REFUSED block and returns False as before, and the by-hand lines moved to a small `_open_it_by_hand` called once the verdict is known. The exit is `2 if the pull request was refused or the topic failed`, and a failed verification outranks both with exit 1.

**Tests for it** (`tests/test_adopt_github_exits.py`, 7 tests, all end to end through the real CLI):
- `test_each_exit_after_the_push_is_exit_2_with_a_command_to_finish_by_hand[gh-pr-create-refused]` now expects the table, `adoption verified`, no pull request line, the topic never set;
- `..._the_command_to_open_a_refused_pull_request_comes_after_the_table`: merged stream, table < `adoption verified` < by-hand, which is the last thing printed;
- `..._a_failed_verification_outranks_a_refused_pull_request`: exit 1, the finding, no `Open the pull request by hand`, no `IS pushed`;
- `..._the_same_source_verifies_when_gh_opens_the_pull_request`: its control, exit 0.
Driving a real failing verification was practical (a source's own pin kept in the root, the way #188's tests do it), so nothing is injected.

**Fails before, passes after:** the 5 changed or new tests fail on d3f71d6 (the step 7 reading, the EXIT CODES reading, the pr-create run, the order run, the failed-verification run); the topic run and the control pass there, as they should. **Mutation probes of the new hunk**, each failing at least one new test: restoring the early `return 2` (3 fail); ignoring the verdict in `_open_it_by_hand` (the failed-verification test); removing the flush (the order test); trying the topic after a refusal (the pr-create run); returning 0 for a refused pull request (2 fail); AGENTS.md or the docstring back to d3f71d6 (their readings).

**S1, a closed stdout (should).** `_open_it_by_hand` flushed stdout with `sys.stdout.flush()`, which raises BrokenPipeError when nobody reads stdout any more (`execute ... | head`, `| true`), so the run ended in a traceback and the command to open the pull request, which main printed, was never printed. It now calls `_flush_stdout()`, which is lane 1's #188 helper under the same name and shape (`contextlib.suppress(OSError)`), at the same place in the file and with the same text, so the two merge to one definition. A test drives the real CLI with a stdout whose reading end is closed: the command is on stderr, there is no traceback, and the exit is 120, Python's own for a stdout it cannot flush as it exits, which main gave and 16aa9ff gave too (so the exit does not tell them apart; the traceback and the missing command do).

| `pr` scenario, stdout closed (`\| true`) | c7c02fa (main) | 16aa9ff | this head |
|---|---|---|---|
| by-hand command | printed | **not printed, traceback in `_open_it_by_hand`** | printed |
| exit | 120 | 120 (Python's, for the stdout it cannot flush as it exits) | 120 |

**S1, the other case, NOT built here.** If the verification itself raises (a `git` that will not list a tree, a full disk), the by-hand line is still lost: a `CommandFailed` gives exit 2 with two REFUSED blocks and no word that the legs and the split are pushed, an `OSError` a traceback with exit 1, which step 7 reads as "a failed verification". #188's `_verify` catches those, reports them with its notice and the branch to delete, and exits 2; composed, both give `REFUSED verifying the split`, the notice, and "No pull request was opened, and none should be". That needs #188's handler, so it is its to compose, not this PR's to build.

**S2.** origin/main is merged into the branch (merge commits c519f57 and a92fcad, no rebase or force). The one conflict was the AGENTS.md cap: #309's `464 -> 477` entry is kept as it is, this PR's entry is now `477 -> 481` and the cap is 481, the real `wc -l AGENTS.md` after the merge (477 on main, and step 7 grows from 5 lines to 9). The composition section above is refreshed against the current heads.

**Nits.**
- **N1.** The dated entry uses the file's em dash, and the five-versus-four sentence and "(fix round 1)" are gone: it describes the change, not the branch's history.
- **N2.** `NEXT: review the pull request on <root>` moved out of `_verify` into `_next_steps(names)`, which `cmd_execute` calls only when no pull request was refused. After a refused one, the by-hand command is the next step and the last line. Under `--local-remote-dir` it is unchanged (see "Left out").
- **N3.** The printed command now works without a terminal. `gh pr create` without `--title` and `--body` asks for them, and where there is no terminal it exits 1 before any request (`must provide --title and --body ... when not running interactively`; the review ran it offline with a bogus token, an empty config directory and an `.invalid` host, and this fix round did not run `gh` at all), so an assistant told by step 7 to "finish with the command it prints" could not. The tool already knew both, so `_pull_request_command` builds the arguments once, `_open_the_pull_request` runs them, and `_open_it_by_hand` prints the same list, shell-quoted. A test reads back the arguments the stub `gh` was refused with and compares them with the parsed printed command; nothing runs the printed command. Two costs, stated: the body is the split commit's message, which lists every moved path, so for a large repository the printed command is as long as that list (the REFUSED block above it already prints the same text unquoted); and the quoting is POSIX, as #188's printed `git ... --delete` already is. `_open_it_by_hand`'s signature is now `(repositories, names, tracking, branch, message, passed)`, which the #188 note carries.
- **N4.** The EXIT CODES paragraph said `execute` "has two more exit 2s". It now says it has other exit 2s once the leg repositories exist (a refused push, a refused mount) and that two of them are GitHub mode's alone.
- **N5.** The follow-up claiming #188's `_flush_stdout()` covers the topic's by-hand commands printing above the table was false; it is corrected above ("Left out").
- **N6.** Nothing to do: the coordinator lands with an explicit squash message.
- **N7.** Wording only, for the #188 composition: "was not verified" would be exact where #188's `_verify` could not verify at all. It is in the note on #188.
- **N8.** The end-to-end environment keeps the real `gh` unreachable. `subprocess` goes on to the next PATH directory when the program it found cannot be executed (a `noexec` temp directory gives EACCES), and the next `gh` would be the operator's. So the run's environment now carries `GH_TOKEN=bogus-token-for-tests` and `GH_CONFIG_DIR` an empty directory, and PATH is the stub first and then the inherited PATH WITH every directory that holds a `gh` taken out (`without_a_real_gh`), which finds `git` and `python` because the directories are taken out only when each of `git`, `git-filter-repo`, `python3`, `python`, `sh`, `env`, `sed`, `tr`, `uname` and `cat` is found at the same place without them. Where it is not (`/usr/bin` on Linux holds `gh` beside `git`, and Homebrew's `bin` beside the `git` a run is meant to use), PATH is returned whole and the token and the config directory are what keep the real `gh` from acting. The stub records the token and config directory it was run with, and a test holds them to the bogus token and the empty directory.

**Tests.** `tests/test_adopt_github_exits.py` is 11 tests now. On a throwaway worktree at 16aa9ff with this file: **5 failed, 6 passed**. Failing there: the EXIT CODES reading (N4), `[gh-pr-create-refused]` (N2), the order test (N2, N3), the printed-command test (N3) and the closed-stdout test (S1). Passing there, as they should: step 7, `[the-topic-will-not-set]`, the failed-verification test and its control, and the `without_a_real_gh` unit test and the environment test (N8: nothing in 16aa9ff's production code to fail, the environment is the test's). **Mutation probes** (15, each reverted by path in a throwaway worktree): the unguarded flush back, the flush removed, `_flush_stdout` not suppressing, the printed command cut to the old form, unquoted, run without the body, `NEXT` always or never said, the EXIT CODES paragraph reverted, the cap back to 477, the token or the config directory dropped from the environment, and `without_a_real_gh` either keeping every directory or dropping the shared ones: each is caught by at least one test, and a title with the leg names swapped, which no test caught at first, is caught by the title assertion added for it.

- **Reproduction** (the issue's script, unchanged but for temp paths, on c7c02fa, git 2.43.0): both loops exit 2 with every message the issue quotes; the first printed no `VERIFICATION` table.
- **Every non-zero exit of `execute`**, with line numbers, is tabulated in the lane's report. Also run: first `gh repo create` refused (exit 2, nothing created), second refused (spec leg exists, empty), split push refused by a hook (exit 2, legs pushed), and the naive re-run after the topic exit (refused at `gh repo create`, as a taken name is).
- **Targeted tests on the head (c5a8a55, origin/main a1b3a4b merged in):**
  - `tests/test_repo_hygiene.py tests/test_cli_reference.py tests/test_adopt_github_exits.py`: 74 passed.
  - `tests/test_adopt_e2e.py tests/test_adopt_plan.py`: 75 passed, 1 skipped (`SHAPE_MEDXEHR_CLONE` is unset: the MedxEHR-backed plan test needs a read-only clone of MedxSoft/MedxEHR).
  - `tests/test_adopt_execute_refusals.py tests/test_adopt_verify.py`: 53 passed.
  - `tests/test_git_output_decoding.py` (origin/main's text-mode guard, which reads test files like this PR's): 67 passed.
  - `scripts/render-cli-reference.py --check`: `docs/cli.md is what the generator produces`.

- origin/main, #184 (`fix/adopt-report-filter-repo-failure`, f416e13), #245 (`fix/adopt-relative-submodule-url`, d72544c, which now contains #309), and the lane-5 siblings F (69c54c9), K (21fbea4), L (8f43c96), M (14e2d68), Q (a30091f) and U (233dc71): all clean. #309 and #268 have landed; the one conflict with #309, the AGENTS.md cap in `tests/test_repo_hygiene.py`, is resolved in the merge commit (`477 -> 481`, cap 481 = `wc -l AGENTS.md`).
- **#188** (`fix/adopt-late-failure-notice`, 918e8f2): conflicts in AGENTS.md (step 7) and in six regions of `adopt-project.py`, all in code this PR rewrote and #188 edits (nine regions in all, and three of those are #188's own against origin/main since #268 landed, so they are not this PR's). Not resolved in either branch. The note for lane 1, with the joined step 7 (482 lines, cap 482), the join of each region and the one patch #188's tests need, is posted on #188: the two `[...-pull-request]` parametrizations of `test_a_gh_step_after_the_split_gets_its_by_hand_exit` call `_open_the_pull_request` alone and look for the by-hand text, which is `_open_it_by_hand`'s now. Checked on a throwaway tree (87373a6, where #188 merges clean, plus this PR's diff plus #188, joined by hand, never committed): 106 passed over `tests/test_adopt_github_exits.py`, the whole of `tests/test_adopt_late_failure.py`, `tests/test_adopt_verify.py` and the cap test; without the one test patch exactly those two parametrizations fail. `_flush_stdout()` and the two imports are the same text on both branches, at the same place, so they merge to one definition.
- `fix/adopt-record-submodule-placement` (#189, 3e86200), `fix/adopt-root-kept-symlinks` (6c44591), `fix/adopt-plan-quote-yaml-keywords` (e337f44): conflict in `adopt-project.py` (and, for #189, the cap line) in exactly the same regions with this PR absent (`git merge-tree origin/main <ref>`: 1 + 1, 3 and 3 conflict regions either way); none of them is this PR's. With #189 (cap 472, +8) as well the cap would be 489; arithmetic only. `README.md`, `docs/handbook.html` and `docs/cli.md` are not touched here, so the handbook's README-blob footer does not move.

**At opening** (origin/main 8cdca5e, which merges clean): lane 1 has since moved `fix/adopt-plan-quote-yaml-keywords` to d38e143, which now merges clean, and #189 to 27d039b.

- **README.md and docs/handbook.html: unchanged.** Neither states the rule: README's adoption section and the handbook's `#adopt` say that `execute` verifies and never say what a non-zero exit means; their "re-run" / "clean re-run" sentences are the scaffold's (`#partway`, lane 4's #309 territory). Changing the README would also move the handbook's machine-checked `README.md blob` footer for no gain.
- **The verification footer and `--help`.** The footer (`_verify`, exit 1) is true for the exit it describes, and `tests/test_adopt_verify.py` holds its text; #188 rewrites it. `--help` carries no exit-code text.
- **`NEXT: review the pull request on <root>` under `--local-remote-dir`** is still printed, as it always was, with no pull request ever opened. This PR stops saying it after a refused pull request (fix round 2); a local run is a test or rehearsal path, and its NEXT block is the only clone-and-bootstrap guidance it has.
- **Candidate follow-ups, not done:**
  - GitHub mode opens the pull request BEFORE it verifies, so a failed verification leaves a pull request open for the wrong split (probed, a source's own pin kept in the root: `pull request .../pull/1` printed, then the finding, exit 1). Verify, then open, would avoid it, at the cost of reordering every successful run's output.
  - After a refused pull request the topic is not tried and the by-hand text does not list the three `gh repo edit` commands, so a person who opens the pull request by hand still has no topic set.
  - The topic's by-hand commands print above the table in a merged log (line 21 of 26 with #188 composed, line 7 on main): `_set_the_topic` prints them before `_verify` runs, so #188's `_flush_stdout()` only stops them jumping ahead of the leg lines. `_set_the_topic`'s docstring ("the caller reports it after the table") is false on main and stays false with #188. Printing them after the verification, the way this PR does for the pull request, would make it true.
- **No remediation on three exit 2s** (a refused `gh repo create`, a refused split push, a failed `git filter-repo`): on c7c02fa each prints a REFUSED block or, for the last, nothing at all (probed: exit 2, empty stderr, two leg repositories left). #184 and #188 are the open PRs on these.

An adversarial review of 16aa9ff found 2 should-fix items and 8 nits. Fix round 2 addresses all of them. A re-verification of c5a8a55 found 0 blockers, 0 should-fix items and 4 nits:
- the end-to-end environment still passes `GH_HOST` and the enterprise tokens through;
- this body's composition tips had moved (refreshed above);
- two counts in lane 1's composition note were off (corrected before posting);
- the `not verified` half of the `NEXT` condition has no test.

No probe ran the real `gh`: every probe used a stub first on PATH, a bogus `GH_TOKEN` and an empty `GH_CONFIG_DIR`.

Reviewed adversarially: the first review asked for changes (two should-fix, eight nits), and a fix round addressed all ten. The re-verify approved with four nits, left as follow-ups: the end-to-end environment passes `GH_HOST` and the enterprise tokens through, the composition section was stale at that day's heads, two sentences of the #188 note were imprecise, and the `not verified` half of the new `NEXT` condition has no test. CI is green on Linux, macOS and Windows, with SonarCloud passing, at 34b9500 (c5a8a55 merged with main 161c6c9).

Closes #304

Lane: openreposhape-5 (openRepoShape-5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
brettheap added a commit that referenced this pull request Oct 14, 2026
….0 contains and promises, how to pin it by commit, what changed on the way grouped by the five tracking areas, and every known limit as the input that triggers it and what the person sees (#472) (#473)

#472 asks for one file that says what v1.0.0 covers and lists its known
limits. `docs/release-notes/v1.0.0.md` is that file. Its eight sections
are:

1. what openRepoShape is, and what 1.0 promises: every procedure in
   AGENTS.md works end to end for ordinary repositories on Linux, macOS
   and Windows, with park and resume under WSL2 on Windows;
2. what 1.0 contains, one line per procedure;
3. requirements and platforms;
4. how to pin 1.0.0, naming its commit rather than its tag;
5. what changed on the way: all 227 merged pull requests, #1 to #518,
   grouped by theme under the five tracking areas (#457 to #461);
6. the known limits: 43 open issues and 124 checklist lines from those
   five parents. Each line names the input that triggers the limit and
   what the person sees, and ends with the `v1.1.0` issue that schedules
   it, where there is one;
7. "Before tagging": the `v1.0.0` milestone, 1 open (#472, which this
   closes) and 46 closed;
8. links to the merged pull requests and the milestone.

The notes describe main at `b8b70627`. The last merge that section 5
covers is #518, at 2026-10-14T18:50:03Z. The first draft was `cbe44fe`.
Six later rounds brought it up to main as pull requests landed, the last
one after #518.

The file is new and nothing else changes. README.md stays at 1422 lines
and AGENTS.md at 490. No rule in `tests/test_repo_hygiene.py` asks for a
README Layout or handbook line for a file under `docs/`. Two rules read
every tracked `.md`: the host-absolute-path scan and the "<word> naming
families" count. They find nothing in this file. The hygiene tests gave
50 passed on the branch, and main's two patterns, applied to the file,
match nothing.

Section 7 and the `<release-commit>` placeholders in section 4 are for
the tag. The GitHub release body takes this text with `<release-commit>`
replaced by this commit's full sha and section 7 removed. The file keeps
both, because it cannot name the commit that adds it.

Closes #472

Lane: openreposhape-4 (openRepoShape-4)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Sonnet 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

Development

Successfully merging this pull request may close these issues.

2 participants