Skip to content

tests/: a red composite assert names both halves, and a leaked sys.path names none (#115) - #116

Merged
brettheap merged 1 commit into
mainfrom
chore/tests-split-assertions-and-monkeypatch
Sep 11, 2026
Merged

brettheap merged 1 commit into
mainfrom
chore/tests-split-assertions-and-monkeypatch

Conversation

@brettheap

@brettheap brettheap commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Lane: openreposhape-2 (openRepoShape-2)
Claim: #115 (comment)

Closes #115.

What was wrong

SonarCloud flagged 30 sites in tests/, two rules:

python:S9073 "Split this composite assertion into separate assertions" (22
sites): an assert a and b (or a and b, msg) prints only AssertionError
on a red run, with no way to tell which half broke without opening the file.

python:S8997 "Use the monkeypatch fixture for temporary modifications
instead of manually modifying global state" (8 sites): each was a bare
sys.path.insert(0, str(REPO / "scripts")) inside a test function, with
nothing to undo it — the entry leaked into sys.path for the rest of the
test process once that test returned.

What landed

Every composite assert became two assert statements, each keeping (or
duplicating) a message that still says what failed. What is actually checked
is unchanged. Site by site:

  • tests/test_scaffold_e2e.py:280 S9073 → assert " code" in status and " spec" in status split, each keeping status as the message
  • tests/test_scaffold_e2e.py:282 S9073 → assert 'path = spec' in modules and 'path = code' in modules split, each keeping modules as the message
  • tests/test_scaffold_e2e.py:574 S9073 → assert "legs_credential" in fetch and "GITHUB_OUTPUT" in fetch split
  • tests/test_scaffold_e2e.py:732 S9073 → assert "AGENTS.md" not in rows and "CLAUDE.md" not in rows, (...) split, message duplicated on both
  • tests/test_scaffold_e2e.py:755 S9073 → assert (A in flat and B in flat) split into two plain asserts
  • tests/test_scaffold_e2e.py:773 S9073 → assert "spec/" in body and "code/" in body split
  • tests/test_scaffold_e2e.py:788 S9073 → assert f"{ORG}/{PROJECT}" in text and "AGENTS-shape.md" in text split
  • tests/test_family.py:231 S9073 → assert NAME in agents and "inkrouter" in agents and ORG in agents split into three
  • tests/test_family.py:234 S9073 → assert "AGENTS.md" not in rows and "CLAUDE.md" not in rows, (...) split, message duplicated
  • tests/test_family.py:909 S9073 → assert folder.is_dir() and not (folder / ".git").exists(), (...) split, message duplicated
  • tests/test_family.py:978 S9073 → assert not (tmp_path / "a").exists() and not (tmp_path / "b").exists() split
  • tests/test_family.py:1166 S9073 → assert holder.is_dir() and (holder / "family.yaml").is_file(), (...) split, message duplicated
  • tests/test_shape_doctor.py:779 S9073 → assert check.id and check.label split
  • tests/test_shape_doctor.py:883 S9073 → assert "git -C" in row["next"] and "checkout --" in row["next"], row["next"] split, message kept on both
  • tests/test_shape_doctor.py:1518 (line 1519 in this tree) S9073 → assert entry["misplaced"] == 0 and entry["review_required"] == 0 split, each given entry as its message to match the sibling assert on the line above
  • tests/test_repo_hygiene.py:152 S9073 → assert "#51" in text and "2026-09-05" in text, (...) split, message duplicated
  • tests/test_repo_hygiene.py:1172 S9073 → assert runs and all(run == out_file for run in runs), (...) split, message duplicated
  • tests/test_free_plan_hint.py:68 S9073 → assert "SHAPE_LEGS_APP_ID" in hint and "SHAPE_LEGS_APP_PRIVATE_KEY" in hint split
  • tests/test_openreposhape_command.py:734 S9073 → assert "gh api" in body and "curl -fsSL" in body split
  • tests/test_setup_project_py.py:1054 S9073 → assert command.strip() and command.isascii() split
  • tests/test_setup_sh.py:168 S9073 → assert "git " in out and re.search(...), out split, message kept on both
  • tests/test_update_shape_add.py:459 S9073 → assert ADDED not in checked.stdout and ADDED_SCRIPT not in checked.stdout split

For S8997, each site now takes the monkeypatch fixture and calls
monkeypatch.syspath_prepend(str(REPO / "scripts")) in place of the manual
sys.path.insert(0, ...), so pytest restores sys.path at teardown instead
of the entry leaking into later tests:

  • tests/test_family.py:183 S8997 → test_init_copies_the_siblings_utility_and_the_makefile_target takes monkeypatch
  • tests/test_family.py:207 S8997 → test_init_writes_the_holders_agent_files takes monkeypatch
  • tests/test_family.py:243 S8997 → test_the_holder_says_what_its_bytes_are takes monkeypatch
  • tests/test_scaffold_e2e.py:688 S8997 → test_the_shape_pin_records_the_openreposhape_commit takes monkeypatch
  • tests/test_scaffold_e2e.py:716 S8997 → test_the_pinned_agent_file_is_byte_identical_to_the_template takes monkeypatch
  • tests/test_scaffold_e2e.py:814 S8997 → test_the_default_visibility_is_private takes monkeypatch
  • tests/test_scaffold_e2e.py:841 S8997 → test_internal_visibility_is_accepted takes monkeypatch (the call sits mid-test, after an unrelated run_script)
  • tests/test_scaffold_e2e.py:897 S8997 → test_the_scaffolded_root_says_what_its_bytes_are takes monkeypatch

Converting all 5 sites in tests/test_scaffold_e2e.py left import sys
unused there (nothing else in the file touched sys), so that import line
is removed. tests/test_family.py keeps import sys — it still has one
module-level sys.path.insert outside any test function (not in scope for
either rule, since it runs once at import time, not per test).

No digest-pinned file (scripts/repo_shape.py,
scripts/validate-repository-naming.py, contracts/repository-naming.yaml,
the templates/assembly-root/ or templates/family-root/ scripts) was
touched — everything here is under tests/.

tests/test_naming_policy.py is untouched: another lane in this fan-out
owns it.

How it was proven

python3 -m py_compile on all nine changed files, clean.

Full suite, foreground, from this worktree: timeout 1200 python3 -m pytest tests -q -p no:cacheprovider — 984 passed, 1 skipped, 1 failed in
8m40s. The one failure is the known pre-existing, machine-dependent flake
called out in the fan-out brief, untouched by this PR:
tests/test_naming_policy.py::test_cli_reports_an_unread_link_as_a_warning_and_still_classifies.
No other test regressed.

No tool's --help text changed, so scripts/render-cli-reference.py and
tests/test_cli_reference.py were not re-run.

🤖 Generated with Claude Code

Summary by Sourcery

Improve test isolation and failure diagnostics across the test suite.

Bug Fixes:

  • Prevent test-process state leakage by replacing manual sys.path modifications with pytest's monkeypatch fixture.
  • Make failing composite test assertions identify each individual unmet condition.

Enhancements:

  • Improve failure diagnostics across the test suite by splitting composite assertions into independent checks while preserving their existing validation and messages.

Tests:

  • Update tests throughout the suite to use isolated temporary import-path changes and clearer assertion failures.

Chores:

  • Remove the now-unused sys import from the end-to-end scaffold tests.

…th names none (#115)

SonarCloud's python:S9073 flagged 22 `assert a and b` sites across nine
tests/ files: a failure there prints only `AssertionError`, with no way to
tell which half broke without opening the file and re-deriving it. Each is
now two `assert`s, each keeping (or duplicating) a message that still says
what failed, with no change to what is actually being checked.

python:S8997 flagged 8 sites, all a bare `sys.path.insert(0, str(REPO /
"scripts"))` inside a test function with no matching cleanup, so the entry
leaks into `sys.path` for the rest of the test process once the test that
added it returns. Each now takes the `monkeypatch` fixture and calls
`monkeypatch.syspath_prepend(...)` instead, which pytest undoes at teardown
on its own. Removing the last `sys.path.insert` in tests/test_scaffold_e2e.py
left `import sys` unused there, so that import goes with it.

tests/test_naming_policy.py is untouched: another lane in this fan-out owns
it. Nothing outside tests/ changed.

Lane: openreposhape-2 (openRepoShape-2)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 11, 2026 20:23
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@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, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 2 days and 21 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR updates tests only: it makes composite assertions report which condition failed and replaces per-test sys.path mutations with teardown-safe monkeypatch.syspath_prepend calls, without changing production behavior or the assertions’ intended checks.

File-Level Changes

Change Details Files
Replaced composite assertions with independent assertions to identify the specific failed condition.
  • Split 22 assert ... and ... expressions across the test suite.
  • Preserved or duplicated diagnostic messages where the original assertion supplied one.
  • Removed the now-unused sys import from the end-to-end test module.
tests/test_family.py
tests/test_free_plan_hint.py
tests/test_openreposhape_command.py
tests/test_repo_hygiene.py
tests/test_scaffold_e2e.py
tests/test_setup_project_py.py
tests/test_setup_sh.py
tests/test_shape_doctor.py
tests/test_update_shape_add.py
Scoped temporary script-path changes to individual tests through pytest's monkeypatch fixture.
  • Changed eight tests from sys.path.insert to monkeypatch.syspath_prepend.
  • Added the monkeypatch fixture parameter to each affected test.
  • Ensured pytest restores sys.path during teardown while preserving import behavior, including a mid-test path change.
tests/test_family.py
tests/test_scaffold_e2e.py

Assessment against linked issues

Issue Objective Addressed Explanation
#115 Split all 22 composite assertions in tests/ into separate assertions while preserving the original conditions and retaining useful diagnostic messages. ✅
#115 Replace all 8 per-test manual sys.path.insert mutations in tests/ with monkeypatch.syspath_prepend and add the monkeypatch fixture so sys.path is restored after each test. ✅

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sonarqubecloud

Copy link
Copy Markdown

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.

🟢 Approval recommended

No unresolved review issues remain, and the changes are limited to test diagnostics and isolation.

Pull request overview

This test-only PR improves assertion diagnostics and prevents temporary sys.path leakage.

Changes:

  • Splits composite assertions into independent checks.
  • Uses pytest’s monkeypatch for temporary import paths.
  • Removes the unused sys import.
File summaries
File Description
tests/test_update_shape_add.py Splits a composite assertion.
tests/test_shape_doctor.py Splits composite assertions.
tests/test_setup_sh.py Splits a composite assertion.
tests/test_setup_project_py.py Splits a composite assertion.
tests/test_scaffold_e2e.py Improves assertions and isolates import paths.
tests/test_repo_hygiene.py Splits composite assertions.
tests/test_openreposhape_command.py Splits a composite assertion.
tests/test_free_plan_hint.py Splits a composite assertion.
tests/test_family.py Improves assertions and isolates import paths.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@brettheap
brettheap merged commit bbc6c86 into main Sep 11, 2026
6 checks passed
@brettheap
brettheap deleted the chore/tests-split-assertions-and-monkeypatch branch September 11, 2026 20:38
brettheap added a commit that referenced this pull request Sep 11, 2026
… `AGENTS-shape.md`, and `LANES_LANE` is promised to carry a `Lane:` argument only for a name that survives a paste (#111)

BOTH OF COPILOT'S FOURTH ROUND ON PR #112 — two suppressed documentation
findings on the same two lines of `AGENTS.md`, and neither is about what the
tools do. They are about who is told, and about a promise wider than the code
behind it.

A PROJECT READS ITS OWN `AGENTS-shape.md`, NOT THIS CHECKOUT'S `AGENTS.md`.
`scripts/shape_materialize.py` copies `templates/assembly-root/AGENTS-shape.md`
verbatim into every scaffolded assembly root and digest-pins it, and that file
is where an agent standing in such a project learns the shape's mechanics —
including how a re-pin is run. Its "never edit a pinned file" section named the
exit (upstream, then `update-shape.py` from a checkout of the standard, landed
as a pull request) and stopped there, so the one thing the previous commits
added to that procedure reached the standard's own readers and no project's.
The section now carries the two-command block and a paragraph in the file's own
voice: `apply` takes a repeatable `--trailer`, appended in the order given, and
only alongside `--branch` because without one there is no commit to put a line
on; `apply` composes that message itself, so a `Lane:` line or a
`Co-Authored-By:` reaches the re-pin commit this way and no other rather than
by amending it afterwards; `check` writes nothing and takes none. This is the
same fix round 3 took in `templates/family-root/AGENTS-shape.md` for
`family.py bump`, applied to the other holder of the same kind of doc.

Both are pinned copies, so this moves the digest of
`templates/assembly-root/AGENTS-shape.md` and every scaffolded project will
report `upstream-changed` for it until its estate re-pins — the ordinary cost
of changing a copy, and the reason the change is one section rather than a
rewrite. `tests/test_scaffold_e2e.py` and `tests/test_family.py` recompute
those digests from the bytes on disk, so nothing is hard-coded to move with
them; each now also asserts `--trailer` is IN the file it checks, because a
procedure that reached only the standard once can do so again.

"WHERE `LANES_LANE` IS SET" PROMISED MORE THAN `lane_trailer` DELIVERS. That
function deliberately offers nothing for a lane name that would not survive
being pasted — a quote, a `$`, a backtick, a backslash, a newline, surrounding
whitespace — because a printed next command is there to be copied, and one that
breaks or expands when it is copied is worse than no line at all. A reader with
such a name, told the `NEXT` line "already carries the `Lane:` argument", would
go looking for a bug. The sentence now says what is true on both sides: where
`LANES_LANE` holds a name that survives being pasted the two printed lines
carry the argument already, and one that would not is offered on neither. Seven
lines to seven, so the 433-line cap in `tests/test_repo_hygiene.py` is
untouched.

THE THIRD ITEM THIS ROUND RAISED WAS ALREADY TAKEN. `unicodedata.category` of a
lone surrogate is `Cs`, and `UNPRINTABLE_CATEGORIES` has listed `Cs` since the
previous commit, with the grammar cases in `tests/test_commit_trailers.py`
(`NOT_TEXT`) to prove it. Verified again here rather than assumed:
`subprocess.run(["true", "Lane: a\ud800b"])` raises `UnicodeEncodeError`
instead of mangling the value, which is exactly the failure `--trailer` must
refuse at the boundary rather than let reach `git commit`.

PROVEN ON A TREE REBASED ONTO `origin/main` AT e9fa826 (#116, #117 and #121
landed under this branch while it was open) — the rebase was conflict-free,
because #121 touched `scripts/repo_shape.py`,
`scripts/render-cli-reference.py`, `setup-project.py` and the leg-template
validators and this branch edits none of them. The commit itself sits on
c19a595 unrebased: the branch ruleset refuses a force-push, which is the
correct answer, and GitHub tests the merge with `main` regardless. 1131
passed, 1 skipped on the rebased tree; the one red is the machine-dependent
`test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` in
`tests/test_naming_policy.py`, pre-existing and not this branch's.
`docs/cli.md` regenerates byte-identical on both trees — through the old
`render-cli-reference.py` and through #121's new one — so no `--help` text
moved.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
…le `--trailer`, and the printed `apply` already carries the lane, so the commit they write ends with its `Lane:` line instead of being amended afterwards (#111) (#112)

* `update-shape.py apply --branch` and `family.py bump` take a repeatable `--trailer`, and the printed `apply` already carries the lane, so the commit they write ends with its `Lane:` line instead of being amended afterwards (#111)

Both tools compose their own commit message — "Re-sync the shape copies to
<repo> @ <sha12>", "Bump <Member> to <sha12> in the <Family> family" — so the
`Lane: <name>` line the lane-collision protocol wants on every artifact a lane
produces, and the `Co-Authored-By:` this estate adds beside it, reached those
commits through nothing at all. Four InkRouter re-pins landed on 2026-09-11
carrying neither, each one run exactly as a printed `NEXT` line said.

`--trailer "<Key>: <value>"` is repeatable, kept in the order given, and
validated at the argparse boundary, so a line that is not a trailer is refused
with the usage beside it and before a repository is opened. On `apply` it needs
`--branch`, refused under the same `update-branch-required` id as `--push` and
`--pr` and now naming whichever of the three was passed: a trailer is a line on
a commit, and without `--branch` there is no commit to put one on.

The write is `git commit --trailer` where the host git is 2.32 or newer, probed
once from `git --version` and parsed conservatively, and an append to the
message text where it is not — the same commit either way, which
`tests/test_commit_trailers.py` writes both of and compares. Passed no trailer,
the message and the `git commit` argv are the ones these tools always built.

`update-shape.py check`'s `NEXT` line and the doctor's `shape currency` row now
end with `--trailer "Lane: <$LANES_LANE>"` when the environment names a lane,
quoted through the doctor's own platform-aware `quote_arg` on its rows, so the
line survives being pasted; with no lane set nothing is added and both are
byte-identical to what they printed before. Only the lane is derived — a
co-author names a person or a model no environment variable knows.

What a trailer is, which git takes the option, and which variable names the
lane live in `scripts/shape_materialize.py`, imported by both tools already and
in no copy list; `scripts/repo_shape.py` would have put an `upstream-changed`
row in front of every project in the estate for a helper none of their copies
would call, which is the argument `shape-doctor.py` makes about its quoter.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* A trailer is matched with `fullmatch` and the lane is read RAW, so a newline in either is refused instead of reaching the commit message and argv (#111)

TWO HOLES OF ONE SHAPE, both found by Copilot on PR #112, and both about
"one line" being asserted by something that does not assert it.

`trailer_line` matched with `re.match` against a pattern ending in `$`, and
`$` stops just before a FINAL newline — so `--trailer "Lane: x\n"` was
accepted whole and the newline went into the message `git commit -F -` reads
and into the `--trailer` argument beside it. `.fullmatch` is what requires the
value whole, which is the lesson `shape-doctor.py`'s `quote_arg` took on PR
#102 against `"Atlas\n"`; this is the same defect one file along. And the
middle of the pattern was `[^\n]`, which is not "one line" either: `\r`, `\v`,
`\f` and a bare `\t` all went through, each a line break or a column jump to
some reader of the commit. Both classes now admit no control character at all,
and the refusal says so.

`lane_trailer` asked the alphabet about a `.strip()`ed name, so
`LANES_LANE="xfactory-1\n"` — the shape `$(cat …)` and a CRLF file produce —
was offered on the printed next command as `Lane: xfactory-1`: a name the
contract says is not offered, trimmed into one that is, with nothing said. The
raw bytes are what `LANE_NAME_RE` is now asked about, and a value with
whitespace around it is NOT a lane name, decided that way because `TRAILER_RE`
refuses a value starting or ending in whitespace — a printed line offering a
trailer this tool's own `--trailer` would then refuse is worse than one
offering none. Stripping decides exactly one thing now: that an all-whitespace
variable means no lane, which is `LANES_LANE=` spelled with a space in it.

Fourteen cases, including the trailing newline that got through, each control
character the interior class admitted, every whitespace-around-the-name shape,
and the invariant the two rules exist to keep: a lane the printer offers is a
trailer `--trailer` would accept.

The review's third finding — `AGENTS.md` at 434 lines against a cap of 433 —
does not reproduce: `wc -l AGENTS.md` is 433, the file carries 433 newlines
and 433 `splitlines()` entries and ends with one, and
`test_agents_md_is_short_enough_to_be_read` passes. The cap is untouched.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* A trailer is ONE line because `splitlines()` and `unicodedata` say so, not because an ASCII class does, and the holder's own instructions show `bump`'s trailers (#111)

THREE FINDINGS FROM COPILOT'S THIRD ROUND ON PR #112, one of them a hole in
the grammar the previous round opened and two of them about what a reader —
a person or a test — is told.

`[^\x00-\x1f\x7f]` READS AS "NO CONTROL CHARACTER" AND IS NOT ONE. It names
C0 and DEL and stops there, so the C1 block `\x80`-`\x9f`, U+0085 NEXT LINE,
U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR all went through a
pattern whose whole job was "one line" — and Python's own `str.splitlines()`
treats every one of them as a line boundary, so a value the tool called one
line arrived as two in anything that read the commit message back that way.
The `Cf` characters got through the same gap without even being breaks: two
trailers differing by a zero-width joiner look identical to a reader and are
not, which is the confusion a trailer exists to avoid.

A CHARACTER CLASS LARGE ENOUGH TO NAME THEM ALL WOULD BE A SECOND, WORSE COPY
OF THE UNICODE TABLES, so `one_printable_line` asks the two questions in
their own words instead: `value.splitlines() != [value]` is this
interpreter's own definition of a line boundary, and moves by itself the day
a future Python adds one; `unicodedata.category` then refuses `Cc`, `Cf`,
`Zl`, `Zp` and `Cs`. `Cs` is there because a byte the locale could not decode
reaches `sys.argv` as a lone surrogate, which is not text at all — git is
handed that undecodable byte straight back, or, on the pre-2.32 path that
appends trailers to the MESSAGE, `subprocess` raises `UnicodeEncodeError` on
a value `--trailer` had already accepted.

`is_trailer` IS THE WHOLE RULE AND BOTH CALLERS USE IT, so the invariant the
last round established — what `--trailer` refuses, no printed next command
offers — holds by construction rather than by two checks that agree today.
`LANE_NAME_RE` needs no second guard bolted on: it is a positive alphabet of
printable ASCII, so nothing `one_printable_line` refuses can be in a lane
name, and there is now a test saying that out loud for the day somebody
widens it.

`templates/family-root/AGENTS-shape.md` IS THE PINNED, AGENT-FACING MECHANICS
DOC copied into every holder, and its `family.py bump` example still showed a
bare bump. A procedure an agent reads in the holder it is standing in is the
one it follows, so the example carries `--trailer` and a paragraph says what
it is for: `bump` composes its own message, so a `Lane:` line reaches that
commit this way and no other, and `add` and `remove` do not take it. This
repository's `AGENTS.md` said it already; the copy every holder carries did
not.

THE BASELINE HALF OF A WITH/WITHOUT COMPARISON INHERITED THE RUNNER'S LANE.
`tests/conftest.py::run_script` now blanks `LANES_LANE` for every tool under
test unless the CALLER names it — which is how a test asks for a lane — so a
suite run inside a lane asserts the same lines as one run outside it. The
baseline of the test that compares the two pins it explicitly as well: the
assertion there is "the lane run is the plain one PLUS the trailer", and a
baseline that had quietly been a second lane run would have compared two
identical lines and passed.

Sixty-five new cases in `tests/test_commit_trailers.py`, 60 to 125: every
line boundary, every invisible and every lone surrogate in the middle of a
value and at the end of one, each of the two checks proved to be the one that
catches its own half, the lane alphabet proved to exclude all of them, and
`is_trailer` proved to be the single predicate both callers use. `docs/cli.md`
regenerates byte-identical — no `--help` text moved. 1131 passed, 1 skipped;
the one red is the machine-dependent
`test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` in
`tests/test_naming_policy.py`, which is pre-existing and not this branch's.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

* The re-pin trailers reach a scaffolded project through its OWN pinned `AGENTS-shape.md`, and `LANES_LANE` is promised to carry a `Lane:` argument only for a name that survives a paste (#111)

BOTH OF COPILOT'S FOURTH ROUND ON PR #112 — two suppressed documentation
findings on the same two lines of `AGENTS.md`, and neither is about what the
tools do. They are about who is told, and about a promise wider than the code
behind it.

A PROJECT READS ITS OWN `AGENTS-shape.md`, NOT THIS CHECKOUT'S `AGENTS.md`.
`scripts/shape_materialize.py` copies `templates/assembly-root/AGENTS-shape.md`
verbatim into every scaffolded assembly root and digest-pins it, and that file
is where an agent standing in such a project learns the shape's mechanics —
including how a re-pin is run. Its "never edit a pinned file" section named the
exit (upstream, then `update-shape.py` from a checkout of the standard, landed
as a pull request) and stopped there, so the one thing the previous commits
added to that procedure reached the standard's own readers and no project's.
The section now carries the two-command block and a paragraph in the file's own
voice: `apply` takes a repeatable `--trailer`, appended in the order given, and
only alongside `--branch` because without one there is no commit to put a line
on; `apply` composes that message itself, so a `Lane:` line or a
`Co-Authored-By:` reaches the re-pin commit this way and no other rather than
by amending it afterwards; `check` writes nothing and takes none. This is the
same fix round 3 took in `templates/family-root/AGENTS-shape.md` for
`family.py bump`, applied to the other holder of the same kind of doc.

Both are pinned copies, so this moves the digest of
`templates/assembly-root/AGENTS-shape.md` and every scaffolded project will
report `upstream-changed` for it until its estate re-pins — the ordinary cost
of changing a copy, and the reason the change is one section rather than a
rewrite. `tests/test_scaffold_e2e.py` and `tests/test_family.py` recompute
those digests from the bytes on disk, so nothing is hard-coded to move with
them; each now also asserts `--trailer` is IN the file it checks, because a
procedure that reached only the standard once can do so again.

"WHERE `LANES_LANE` IS SET" PROMISED MORE THAN `lane_trailer` DELIVERS. That
function deliberately offers nothing for a lane name that would not survive
being pasted — a quote, a `$`, a backtick, a backslash, a newline, surrounding
whitespace — because a printed next command is there to be copied, and one that
breaks or expands when it is copied is worse than no line at all. A reader with
such a name, told the `NEXT` line "already carries the `Lane:` argument", would
go looking for a bug. The sentence now says what is true on both sides: where
`LANES_LANE` holds a name that survives being pasted the two printed lines
carry the argument already, and one that would not is offered on neither. Seven
lines to seven, so the 433-line cap in `tests/test_repo_hygiene.py` is
untouched.

THE THIRD ITEM THIS ROUND RAISED WAS ALREADY TAKEN. `unicodedata.category` of a
lone surrogate is `Cs`, and `UNPRINTABLE_CATEGORIES` has listed `Cs` since the
previous commit, with the grammar cases in `tests/test_commit_trailers.py`
(`NOT_TEXT`) to prove it. Verified again here rather than assumed:
`subprocess.run(["true", "Lane: a\ud800b"])` raises `UnicodeEncodeError`
instead of mangling the value, which is exactly the failure `--trailer` must
refuse at the boundary rather than let reach `git commit`.

PROVEN ON A TREE REBASED ONTO `origin/main` AT e9fa826 (#116, #117 and #121
landed under this branch while it was open) — the rebase was conflict-free,
because #121 touched `scripts/repo_shape.py`,
`scripts/render-cli-reference.py`, `setup-project.py` and the leg-template
validators and this branch edits none of them. The commit itself sits on
c19a595 unrebased: the branch ruleset refuses a force-push, which is the
correct answer, and GitHub tests the merge with `main` regardless. 1131
passed, 1 skipped on the rebased tree; the one red is the machine-dependent
`test_cli_reports_an_unread_link_as_a_warning_and_still_classifies` in
`tests/test_naming_policy.py`, pre-existing and not this branch's.
`docs/cli.md` regenerates byte-identical on both trees — through the old
`render-cli-reference.py` and through #121's new one — so no `--help` text
moved.

Lane: openreposhape-2 (openRepoShape-2)
Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
brettheap added a commit that referenced this pull request Sep 11, 2026
…uash landing is tested instead of only the pull request it squashed (#122) (#124)

`.github/workflows/tests.yml` ran on `pull_request` and `workflow_dispatch`
only, so `main` itself was never tested by CI: a squash of several disjoint
pull requests landing in one evening (tonight's #116, #117 and #121) is a
tree no run had ever exercised, even though each one was green on its own
run. SonarCloud already analyses every push to `main`; the test record
stopped at each pull request's last run instead of following it there too.

Brett Heap ruled "do option 1 on 122": `on:` gains `push: { branches:
[main] }`, and `tests-windows` / `tests-macos` each gain `if:
github.event_name != 'push'` so they keep running on `pull_request` and a
manual `workflow_dispatch` but skip on the main push — a squash-interaction
regression is not OS-specific, so the ubuntu job on `main` is the gate for
that, and the two jobs GitHub bills at 2x (Windows) and 10x (macOS) stay the
pull-request-only gate they already were. A top-level `concurrency:` group
keyed on the PR number (falling back to `github.ref`) cancels a superseded
run of the same PR or the same branch, without touching an unrelated PR's
in-flight run. The header comment gets one paragraph saying so, for the next
reader.

Nothing under `templates/` changes; the assembly-root `validate.yml` is a
project's own gate and stays digest-pinned.

Lane: openreposhape-2 (openRepoShape-2)

Co-authored-by: Claude Fable 5.1 <[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.

tests/: split composite assertions and replace manual sys.path mutation with monkeypatch (SonarCloud S9073, S8997)

2 participants