Repository navigation
update-shape.py apply now moves the README's trailing Shape: <repo> @ <sha>. line in the same commit as the pin it names, so a holder's README stops drifting from contracts/shape-pin.yaml (#148) - #152
Conversation
…@ <sha>.` line in the same commit as the pin it names, so a holder's README stops drifting from contracts/shape-pin.yaml (#148) A family holder's README is RENDERED with the commit it was cut from (`templates/family-root/README.md`), and nothing rewrote it afterwards: the line is not a pinned copy, so `apply` re-copied the digested files, moved `contracts/shape-pin.yaml` and `family.yaml`'s `shape:` block, and left the sentence claiming a revision that had not been true for weeks. InkRouter's holder read `6fe09a41535a` four re-pins after the pin reached `57ddeacc9f1d`; the one correction ever made to it was made BY HAND, and a day later it was stale again — a sha corrected outside the re-pin that moves the pin is a sha nothing keeps. `apply` gains a phase, beside the copies and the re-pin and inside the same `Rollback` ledger, that rewrites ONLY the 40 hex characters when the README carries exactly one line in the rendered form and it names the repository this pin is against. Everything else in the file is byte for byte what it was: no such line, two of them, one naming another repository, or a README that is not valid UTF-8 are all LEFT ALONE and said out loud, because each of those would have the tool choosing which of a project's own sentences is the true one. A red validator rolls the line back with everything else, since a README naming a pin the tree no longer carries is the same drift, made by the fix. `check` prints the answer first — `readme-shape-line: stale (… , pin will read …)` / `current` / `absent` — so the human sees it before saying yes, and it never moves that command's exit code: the line is prose. The state the issue was filed over, a stale line under a pin that is already at the target, says plainly that there is no commit to move it in and the next re-pin carries it. `shape-doctor.py`'s `shape currency` row reads the same line through the same compiled pattern and appends a `note`, never a finding, mirroring the rule `leg shape files` argues at length: `verdict_for` steps over a note, so prose cannot fail a repository whose every pin is current. THE PATTERN LIVES IN `scripts/shape_materialize.py`, beside the template lists that render the line, and `tests/test_family.py` renders a real holder through the real materializer and asserts it matches exactly one of the README's lines — and that an assembly root renders none. A reworded template now fails there rather than silently turning every holder's verdict into `absent`. AGENTS.md gains the one clause an assistant needs: the line is `apply`'s to rewrite and never theirs. Its cap moves 433 -> 440 with the reason in the hygiene test's docstring. No digest-pinned file is touched. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 1 day and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideThe PR keeps family-holder README Shape lines synchronized with the corresponding shape pin by sharing an exact parser, rewriting only an unambiguous stale SHA transactionally during apply, reporting the result in check, and exposing it as a non-blocking doctor note, with documentation and comprehensive tests. Sequence diagram for transactional README Shape line synchronizationsequenceDiagram
participant User
participant Apply as update-shape.py apply
participant Pin as Shape pin and family.yaml
participant Readme as README.md
participant Ledger as Rollback ledger
participant Validators
User->>Apply: cmd_apply()
Apply->>Pin: _repin()
Apply->>Readme: ReadmeShapeLine._classify()
alt exactly one matching stale Shape line
Apply->>Ledger: ReadmeShapeLine.rewrite()
Ledger->>Readme: Replace commit span only
Apply->>Validators: _refuse_red_validators()
alt validator failure
Ledger->>Readme: Roll back README bytes
Ledger->>Pin: Roll back pin changes
else validators pass
Apply->>Apply: commit_on_branch()
Apply->>Readme: Include README.md in commit
end
else absent, ambiguous, other repository, unreadable, or current
Apply->>Readme: Leave README.md untouched
end
Sequence diagram for check and shape-doctor README reportingsequenceDiagram
participant User
participant Check as update-shape.py check
participant Doctor as shape-doctor.py
participant Reader as ReadmeShapeLine
participant Pin as Shape pin
User->>Check: cmd_check()
Check->>Pin: Read target commit
Check->>Reader: _classify()
Reader-->>Check: stale, current, or absent verdict
Check-->>User: readme-shape-line row
User->>Doctor: check_shape_currency()
Doctor->>Reader: ReadmeShapeLine(ctx.root, repository, pinned)
alt stale README line and current pin
Reader-->>Doctor: README_STALE
Doctor-->>User: NOTE with readme_shape_line detail
else all other states
Reader-->>Doctor: non-stale state
Doctor-->>User: No README note
end
Flow diagram for README Shape line classificationflowchart TD
A[Read README.md as UTF-8 bytes] --> B{Exactly one Shape line?}
B -- No line --> C[absent]
B -- Multiple lines --> D[ambiguous; leave untouched]
B -- One line --> E{Repository matches pin?}
E -- No --> F[other-repository; leave untouched]
E -- Yes --> G{Commit matches target?}
G -- Yes --> H[current]
G -- No --> I[stale]
I --> J[Rewrite only the 40-character commit span]
J --> K[Include README.md with the pin commit]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
🟡 Changes recommended
Four moderate review findings remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Synchronizes holder README Shape references with contracts/shape-pin.yaml during shape updates, with check/doctor reporting and expanded tests.
Changes:
- Adds shared Shape-line parsing and byte-preserving README rewriting.
- Adds non-blocking check and doctor reporting.
- Adds rollback, parity, and hygiene coverage; documents the behavior.
Four unresolved moderate findings concern trailing-line matching, doctor target comparison, unrelated README edits, and inaccurate check previews.
File summaries
| File | Summary |
|---|---|
update-shape.py |
Rewrites README references and updates apply/check behavior. |
tests/test_update_shape.py |
Tests rewriting, rollback, untouched cases, and check output. |
tests/test_shape_doctor.py |
Tests stale-line notes and verdict behavior. |
tests/test_repo_hygiene.py |
Updates the documentation size cap. |
tests/test_family.py |
Verifies rendered README parity and holder updates. |
shape-doctor.py |
Reports stale README references as non-blocking notes. |
scripts/shape_materialize.py |
Centralizes Shape-line parsing. |
AGENTS.md |
Documents README synchronization ownership. |
Review details
Suppressed comments (2)
scripts/shape_materialize.py:291
- The
$anchor is used withre.MULTILINE, so this recognizes any matching line in the README, not only the trailing rendered line described by the template and AGENTS.md. A README containing one exact Shape line in an earlier section or code sample will therefore be classified as stale and rewritten. The shared reader should enforce that the eligible match is the final line (while still treating multiple exact lines as ambiguous) beforeapplychanges it.
README_SHAPE_LINE_RE = re.compile(
r"^Shape: `(?P<repository>[^`]+)` @ `(?P<commit>[0-9a-f]{40})`\.\r?$",
re.MULTILINE)
update-shape.py:1165
- When
pinned != targetbut no copied row changed,readme.statecan still beREADME_STALEbecause it was classified againsttarget;applywill then rewrite the README as well as the pin. The later preview still says it would move “the pin alone,” socheckis inaccurate for this common holder state. Include the README action in this branch and cover it with a test.
if readme.state == README_STALE:
# The exact state #148 was filed over, and the one run that
# cannot fix it: `apply` writes nothing when the pin already
# names the target, so the line moves with the NEXT re-pin.
print(f" ({README}'s Shape: line is stale, and this pin is "
"already at the target, so there is no commit to move "
"it in; the next re-pin carries it)")
- Files reviewed: 8/8 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.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4acb4fd77d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| paths = sorted({row.path for row in copied} | set(added) | ||
| | {"contracts/shape-pin.yaml", kind.manifest}) | ||
| | {"contracts/shape-pin.yaml", kind.manifest} | ||
| | ({README} if readme.rewritten else set())) |
There was a problem hiding this comment.
Avoid committing unrelated README edits
When apply --branch runs while README.md has unrelated uncommitted edits and a stale Shape line, adding the whole file to paths makes _land invoke git commit ... -- README.md; the inspected git commit -h describes this pathspec mode as “commit only specified files,” and Git records the README's complete working-tree contents, not just the rewritten SHA. The shape-update commit therefore silently absorbs the user's unrelated edits even though check reports only the Shape-line change; refuse a dirty README or otherwise ensure only the generated replacement enters the commit.
AGENTS.md reference: AGENTS.md:L282-L285
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Lane: openreposhape-2 (openRepoShape-2)
TAKEN, in baa77d0 — and proven in feaab50, which is this reply's evidence.
You are right about the mechanism: git commit -- README.md is pathspec mode and records the WORKING TREE version of that path. Every pinned copy is safe from it only because update-local-drift refuses first, and the README has no pin row — so an unrelated paragraph, staged or not, would have ridden into a re-pin the human approved from a check that never showed it.
The fix is a seventh reading rather than a refusal, because the line is prose and a stray paragraph must not be able to block a re-pin: readme_is_committed() asks git status --porcelain --ignored -- README.md, and any output at all — modified, staged, untracked, ignored — makes the README uncommitted, which apply leaves alone and says out loud (README.md: its Shape: line is behind, but the file has uncommitted changes, untouched — commit them and the next re-pin carries the line). It is never added to paths, so _land never names it. check prints the same row first, so the preview and the act still agree. The git question is asked LAST and only of a line that would otherwise move, so a README nobody is editing costs no subprocess.
Two tests carry it. test_a_readme_with_changes_of_its_own_is_left_alone_and_not_committed is your scenario end to end — a stale line plus an unrelated paragraph, apply --branch, and afterwards the paragraph and the sha are both exactly as they were and README.md is absent from git show --name-only. test_git_answers_three_ways_for_a_readme_and_one_of_them_is_committed (new in feaab50) puts the three git answers side by side, since one boolean stands for all of them: tracked and clean is the only True; tracked with edits is False; ignored and untracked is False too, which is the one plain --porcelain hides.
| if not self.path.is_file(): | ||
| return README_ABSENT | ||
| try: | ||
| self.text = self.path.read_bytes().decode("utf-8") |
There was a problem hiding this comment.
Refuse symlinked README files before rewriting
When an adopted root tracks README.md as a symlink whose target contains a matching stale line, Path.is_file() returns true and the subsequent reads and ledger write follow the link. apply can consequently modify another tracked file or a file outside the repository, while the later commit pathspec records only the unchanged symlink and therefore does not contain the advertised README update; classify symlinks as absent/refused or restrict rewriting to a regular file in the root.
AGENTS.md reference: AGENTS.md:L282-L285
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Lane: openreposhape-2 (openRepoShape-2)
TAKEN, in eec8705 — a symlinked README is its own reading now, and it is asked BEFORE the file is read rather than after.
Path.is_file() follows the link and ledger.write would have followed it again, so the replacement would have landed in the link's target — which a root is free to point outside itself — while the symlink git tracks stayed byte-identical: the commit this tool made would not have contained the edit it had just made to somebody else's file. _classify now answers symlink on self.path.is_symlink() before anything is read, apply leaves the file alone and says so (README.md: a symlink, untouched — a rewrite would land in its target rather than in this root), and check prints readme-shape-line: symlink (README.md is a symlink; apply never writes through one).
test_a_symlinked_readme_is_never_written_through points a root's README at a file in tmp_path that carries a matching stale line, runs apply --branch, and asserts that file's bytes are untouched and README.md is not in the commit. It skips on Windows, where making a symlink needs a privilege the runner does not have.
Your finding has a sibling that this round also closed: a HARD-linked regular README passes is_symlink() and looks clean to git, and writing through it would change the other name's file just as surely. feaab50 makes st_nlink > 1 a reading too (hard-link), for the same reason and with the same posture.
…ops previewing a commit smaller than the one it would make, and the doctor's note says what is true rather than promising a rewrite (#148) Three of Copilot's four findings on PR #152, taken in one commit. UNCOMMITTED CHANGES IN THE README ARE NOT THIS TOOL'S TO COMMIT. `git commit -- README.md` lands the WORKING TREE version of that path, and every pinned copy is safe from that only because `update-local-drift` refuses first — the README has no pin row, so a half-written paragraph, staged or not, would have ridden into a shape re-pin the human approved from a `check` that never showed it. That is exactly the sweep `commit_on_branch`'s explicit pathspecs were written against, arriving through the door this feature opened. A seventh reading, `uncommitted`, now joins the ones `apply` leaves alone and says so; the git question is asked last and only of a line that would otherwise move, so a README nobody is editing is classified with no subprocess at all. Untracked counts as uncommitted for a second reason: `git commit -- <path>` refuses a pathspec git has never heard of, and that failure would have arrived after every other byte was written. `CHECK` NO LONGER PREVIEWS A COMMIT SMALLER THAN THE ONE IT WOULD MAKE. On the commonest holder re-pin of all — a pin behind the standard with not one copied byte different — "`apply` would move the pin alone" described a commit that would have had a second file in it. It now names the README's `Shape:` line when that is what the run would do. THE DOCTOR STILL COMPARES AGAINST THE PIN, and the docstring now argues why: `contracts/shape-pin.yaml` is the authority on what revision this root is a copy of, so a README disagreeing with it is wrong about THIS tree today. Comparing against the standard's HEAD instead would put a note on every project that is merely behind — including one whose README names its own pin perfectly — which is the `SHAPE BEHIND` verdict the row already carries, said twice. What was fair in the finding is the wording: a README that has run AHEAD of the pin to the commit a re-pin is about to record is left alone by `apply`, so the clause no longer promises a rewrite. It says what holds in every case — `apply` owns that line, and the next re-pin leaves the two agreeing. Four tests join: an uncommitted README is untouched, unsaid by no-one and absent from the commit; `check`'s preview names the line; a behind project whose README names its own pin draws no note; and an uncommitted line draws none either. The doctor and update-shape fixtures now COMMIT the line they add, which is what a holder's README is. The fourth finding is declined on the thread: anchoring the match to the final line would stop rewriting any holder that has appended a section since it was scaffolded — returning the exact silent drift #148 is about — while the collision it guards against (a second exact line in a code sample) is already `ambiguous` and already untouched. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Copilot round 1, head baa77d0. The two inline threads are answered on the threads; these are the two SUPPRESSED findings from the review body, which have no thread to reply on.
Also in this round, from the Suite from this worktree, foreground, in chunks: 1153 passed / 1 skipped, 0 failed (1136 before + 17). SonarCloud green on the previous head; re-checked PR-scoped after this push. |
…rites-readme-shape-line (#148) ONE CONFLICT, IN THE AGENTS.md CAP, and it is two rules landing on one day rather than a disagreement: #150 raised it 433 -> 439 for `bump-leg.py`'s own `--trailer` point, this branch raises it for the README's `Shape:` line point. Both paragraphs stay, in the order the caps moved, and the assertion is the sum: 446 lines, which is what the merged file has. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings affect safe README rewriting and rollback.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
scripts/shape_materialize.py:291
- Because this pattern is compiled with
re.MULTILINE,$stops at every line ending rather than at end-of-file. A README with one matching sentence in the middle and other content after it is therefore classified as the holder's trailing Shape line and rewritten, even though the documented/template-owned form is the final line; this can alter ordinary project prose. Keep the duplicate scan, but require the sole accepted match to end at EOF (allowing the final newline) before treating it as rewriteable.
- Files reviewed: 8/8 changed files
- Comments generated: 3
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate issues affect rewrite eligibility and safe handling of ignored or symlinked READMEs.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (3)
tests/test_repo_hygiene.py:503
- The PR description says the hygiene cap moves from 433 to 440, but this change records the actual baseline as 439 and raises it to 446 (and updates the assertion to 446). Please reconcile the description with the diff so the stated reason is tied to the correct current AGENTS.md baseline.
2026-09-12: 439 -> 446 — the README's `Shape:` line (#148), landing
beside the point above on the same day. Seven lines, one numbered point
under "Updating a project's shape", and they buy the same thing that one
does: PERMISSION, and its withdrawal. A family holder's README is
rendered naming the commit it was cut from, and the only correction ever
made to a stale one was made BY HAND (InkRouter#18) — a day later it was
stale again, because a sha corrected outside the re-pin that moved the
pin is a sha nothing keeps. `apply` now carries it, so the point an
assistant needs is the one telling them not to reach for the file
themselves, and which readings the tool leaves alone."""
lines = (REPO / "AGENTS.md").read_text().splitlines()
assert len(lines) <= 446, f"AGENTS.md is {len(lines)} lines; the cap is 446"
update-shape.py:959
git status --porcelainsuppresses ignored untracked files. If an ignored, untrackedREADME.mdcontains the matching stale line, this check returns clean, so_rewrite_readmechanges it andpathslater asksgit commit -- README.mdto commit a path Git does not know. That commit fails after the ledger writes (theCommandFailedpath does not undo it), leaving the re-pin files and README modified; include ignored status (or explicitly require a tracked README) before allowing the rewrite.
proc = subprocess.run(["git", "status", "--porcelain", "--", README],
update-shape.py:1010
Path.is_file()follows symlinks. A trackedREADME.mdsymlink to an external regular file with a matching stale line is therefore treated as clean, and the laterledger.write(self.path, ...)writes the replacement into the symlink target outside the repository. Reject or otherwise leave symlinked READMEs untouched before reading and rewriting them.
if not self.path.is_file():
return README_ABSENT
try:
self.text = self.path.read_bytes().decode("utf-8")
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
…st not write, and the committed check now asks git with `--ignored` (#148) Copilot's second round on PR #152, both findings taken. `git status --porcelain` SAYS NOTHING AT ALL ABOUT AN IGNORED UNTRACKED FILE. A root whose `README.md` is ignored therefore read as clean, was rewritten, and then handed `git commit -- README.md` a pathspec git has never heard of — a failure arriving after every other byte was written, on the one arm of `cmd_apply` that does not roll back. `--ignored` closes it: untracked without an ignore rule was already caught, and this is the same hazard wearing the one hat `--porcelain` hides. `Path.is_file()` FOLLOWS A SYMLINK, and a root is free to point its README out of itself. Written through, the replacement would land in a file outside this repository — somebody else's — while the symlink git tracks stayed byte-identical, so the commit this tool made would not contain the edit it had just made. A symlinked README is now its own reading, left alone and said, and it is asked BEFORE the file is read rather than after. Both are the same rule the other five left-alone readings already carry: this tool writes the sha in a file it can account for, and says which reading it found when it does not. Two tests. The ignored one excludes `README.md` through `.git/info/exclude` rather than `.gitignore`, because `.gitignore` is a PINNED copy and editing it would be drift — the test would then be exercising that refusal instead. The symlink one points the README at a file in `tmp_path` and asserts its bytes are untouched; it skips on Windows, where making a symlink needs a privilege the runner does not have. AGENTS.md's point names the three READMEs this tool may not commit — uncommitted, ignored, a symlink — inside the seven lines the cap already allows. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Copilot round 2, head eec8705. Both code findings TAKEN; the third was this PR body and is corrected.
AGENTS.md's point now names all three READMEs this tool may not commit — uncommitted, ignored, a symlink — inside the seven lines the cap already allows. Suite: 1155 passed / 1 skipped, 0 failed. SonarCloud PR-scoped open issues: 0. |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings remain.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (4)
AGENTS.md:288
- This rule is added only to the standard checkout's
AGENTS.md, but the project-facing pinned instructions still say thatREADME.mdis the project's own content to edit (templates/assembly-root/AGENTS-shape.md:66-67, and the family counterpart attemplates/family-root/AGENTS-shape.md:117-118). New projects and holders therefore receive no exception for the managedShape:line, so their shipped guidance conflicts with the new behavior and can still lead agents to hand-edit it.
7. **A README's trailing `Shape: <repository> @ <sha>.` line — a family
holder renders one — is `apply`'s to rewrite and never yours.** It moves
the sha in the pin's own commit; `check` says first whether the line is
`stale`, `current` or `absent`. A line that is missing, doubled or names
another repository is left alone and said so, and so is any README this
tool may not commit: uncommitted, ignored, a symlink. The doctor notes a
line that is behind, never a finding — a hand edit is how it drifted.
scripts/shape_materialize.py:290
- The repository capture
[^]+can consume CR/LF, soreadme_shape_lines()can treat a malformed multi-line sequence as a Shape line. A README with one valid line plus such a wrapped sentence is then classified asambiguousand the valid stale line is not rewritten; restrict this group to a single line, e.g.[^\r\n]+.
r"^Shape: `(?P<repository>[^`]+)` @ `(?P<commit>[0-9a-f]{40})`\.\r?$",
update-shape.py:1673
_rewrite_readmeruns after_write_copiesand_repin, so a stale README that is readable but not writable (for example, mode 0444) makesPath.write_bytesraisePermissionError.cmd_applyonly rolls backRefusaland does not catchOSError, leaving the copied files and pin partially updated with an unhandled traceback; preflight this write or convert the failure into a rollback/refusal.
readme.rewrite(ledger)
update-shape.py:1027
- If
README.mdis a regular file butread_bytes()raises anOSError(for example, a permission failure or a concurrent removal), the exception escapes after_write_copiesand_repinhave already modified the tree.cmd_applyonly rolls back refusals, so this leaves a partial update; treatOSErrorlike the existing UTF-8 failure and returnREADME_UNREADABLEbefore attempting a rewrite.
self.text = self.path.read_bytes().decode("utf-8")
except UnicodeDecodeError:
return README_UNREADABLE
- Files reviewed: 8/8 changed files
- Comments generated: 1
- Review effort level: Lite
…inked or unreadable one is another README `apply` must not write, and a write it cannot make is a refusal rather than a traceback (#148) Copilot's third round on PR #152 and the two Codex P2s, taken together. AN EXAMPLE OF THE LINE IS NOT A CLAIM ABOUT THIS PIN. `README_SHAPE_LINE_RE` is anchored to a LINE, so every occurrence of the form read as this root's own sentence — including one inside a paragraph showing a reader what a holder's README ends with, which is the likeliest place in the estate for a second one to appear, since the projects most apt to quote the form are the ones nearest this standard. `apply` would have rewritten that prose to say something the prose does not mean: the documentation version of the drift #148 is about, made by the fix. `readme_trailing_shape_line` now decides eligibility in ONE place for both readers — the match the file ends with, nothing but whitespace after it — and a README carrying the form higher up reads `absent`. Round one declined this anchoring because a holder that appended a section would silently stop being rewritten; what makes it right now is that nothing here is silent: `absent` SAYS which absent it is (`its Shape: line is not the last line, so it is an example rather than this root's own claim`), so a holder that grew a section under the line is told, by both commands, rather than quietly left to drift. Two exact matches are still `ambiguous` and still untouched, which is the case the EOF rule does not dissolve: rewriting the last one while an example two paragraphs above names another commit would leave the file contradicting itself in this tool's name. A HARD-LINKED README IS A SECOND NAME FOR THE SAME BYTES. `is_symlink()` says no and git says clean, because nothing about the content differs — and every write this tool makes goes THROUGH a name: `Rollback.write` overwrites the inode and the undo writes back the same way. A rewrite would therefore have changed whatever else that inode is called, a file no `check` showed and no pin covers, while the commit recorded only `README.md`. It is a reading rather than a refusal, for the reason the other left-alone readings already carry — the line is prose, and prose must not be able to block a re-pin — and it is a reading rather than an inode-replacing write because replacing the inode would make this the one write in the command the ledger cannot undo: the other name would keep the old bytes and the link would be broken, and breaking a link is not something a rollback puts back. A README THE OS WILL NOT HAND OVER IS ALSO JUST A READING. `_classify` runs inside `apply` after the copies are on disk, and the `UnicodeDecodeError` branch was there because an exception escaping it lands on the one arm of `cmd_apply` that does not roll back; an `OSError` is the same hazard under another name, so it is caught beside it and the sentence says which of the two it was. WHAT IS LEFT IS THE WRITE, AND THAT ONE IS A REFUSAL. The refusal `update-readme-unwritable` names the file and rolls back, through the arm that already exists, so a disk that fills or a permission that changes under the run cannot end the command with a tree that has been re-copied and re-pinned and a traceback for a README. And the ledger now opens `r+b` BEFORE it records anything: a path it cannot write used to be read into the ledger first, so the undo would go on to raise on that same path and leave the copies and the pin half-restored — a rollback that cannot run is worse than the refusal it serves. The two Codex P2s are the two guards already in the branch, and this commit is where they get their proof. A README with unrelated uncommitted edits is `uncommitted` and is neither rewritten nor added to the commit pathspec (`test_git_answers_three_ways_for_a_readme_and_one_of_them_is_committed` puts the three git answers side by side: tracked and clean, tracked and edited, ignored and untracked), and a symlinked README is never written through (`test_a_symlinked_readme_is_never_written_through`, eec8705). Six tests. The uncommitted-README fixture now adds its paragraph ABOVE the trailing line, which is where an edit to a README that has one goes: under it the line would no longer be the last, and that is a different reading and a different test. `tests/test_family.py` asserts the other half in the one place that can catch a reworded template — a real rendered holder must END with the line, or every holder in the estate would answer `absent`. AGENTS.md's point 7 says the rule in the words a reader needs: only the line the file ends with, and the READMEs this tool cannot account for now include a hard link. The cap does not move; the point is the same seven lines. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
🔵 Needs a closer look
Address the newline-matching issue and add CRLF/BOM byte-preservation regression coverage.
Review details
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
scripts/shape_materialize.py:296
[^]+also matches newline characters, so withre.MULTILINEthis is not limited to a single rendered line. A malformed multi-line example can be counted as an additionalShape:match (or classified as another repository), causing an otherwise valid trailing line to be treated as ambiguous and skipped. Exclude\r/\n` from the repository capture so each match remains one line.
update-shape.py:1161
- The rewrite path explicitly promises to preserve CRLF endings and a UTF-8 BOM, but the new tests only exercise ordinary LF text. Because this code decodes and re-encodes the entire README while the shared regex handles line endings, please add a regression covering CRLF/BOM and asserting that bytes outside the SHA are unchanged, so a future change cannot silently normalize a holder README.
ledger.write(self.path, (self.text[:start] + self.target
+ self.text[end:]).encode("utf-8"))
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: feaab50840
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| proc = subprocess.run( | ||
| ["git", "status", "--porcelain", "--ignored", "--", README], | ||
| cwd=str(root), capture_output=True, text=True, check=False) | ||
| return proc.returncode == 0 and not proc.stdout.strip() |
There was a problem hiding this comment.
Check index flags before treating README as committed
When README.md is marked assume-unchanged or skip-worktree, this git status command returns no output even after its contents are edited; the inspected git update-index -h describes these flags as “mark files as not changing” and “mark files as index-only,” respectively. I verified that the subsequent git commit -- README.md nevertheless records the complete edited working-tree file. This is fresh evidence beyond the earlier dirty-README fix: apply can still classify such a stale README as safe, rewrite its SHA, and silently commit unrelated edits, so inspect these index flags or otherwise compare the file against committed content rather than trusting status alone.
AGENTS.md reference: AGENTS.md:L282-L288
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Lane: openreposhape-2 (openRepoShape-2)
TAKEN, in 201d473 — and you are right that this is fresh evidence rather than the earlier fix restated: --assume-unchanged and --skip-worktree both leave git status --porcelain --ignored -- README.md silent over a README somebody is part way through editing, while git commit -- README.md goes on recording the complete working-tree file. That is exactly the edit the last round closed, walking back in through a flag.
readme_is_committed() now asks the BYTES as well as the index: git hash-object -- README.md against git rev-parse HEAD:README.md, and the README is committed only when both questions are clean. That answers your finding and a little more — the comparison is blind to index flags, to ignore rules and to whether the path is in the index at all.
Why bytes rather than git ls-files -v's flag letters, which would also have worked: the letters answer the two flags that exist today, and the docstring's question is "is README.md exactly what HEAD has" — which stays the same question in every future git. hash-object applies the clean filter git add would, so a CRLF checkout under core.autocrlf hashes to the blob it was committed as rather than reading as a whole-file edit.
The status question is still asked, and still first, because it is the one your bytes check does NOT answer: a change staged and then reverted in the working tree leaves the file on disk matching HEAD, and git commit -- README.md would quietly drop what the human staged. Neither question answers the other, so both are asked — and only of a line that would otherwise move, so a README nobody is editing still costs nothing.
test_an_index_flag_does_not_make_an_edited_readme_committed sets each flag in turn, asserts git says nothing under it (the fixture would be vacuous otherwise), asserts readme_is_committed says no anyway, and then runs apply --branch under --assume-unchanged end to end: the paragraph and the sha both stay put, the run says uncommitted changes, untouched, and README.md is not in the commit. _git_answer also puts the no-git-at-all case where this docstring always claimed it was — not committed — rather than letting a FileNotFoundError escape a classification that must not raise.
…ick name broken over a line break is not a Shape: line, and the CRLF/BOM promise now has the test it was missing (#148) Codex's P2 and Copilot's two suppressed findings on PR #152, all three taken. `GIT STATUS` READS THE INDEX, AND TWO FLAGS TELL IT TO STOP LOOKING. `git update-index --assume-unchanged` and `--skip-worktree` both leave `git status --porcelain --ignored -- README.md` silent over a README somebody is part way through editing, while `git commit -- README.md` goes on recording the complete working-tree file (Codex, PR #152): exactly the edit the last round closed, back in through a flag. So the BYTES are asked for as well — what `git hash-object` makes of the file on disk against the blob `HEAD` records for that path — which no index flag, no ignore rule and no absence from the index can quiet. Reading the flag letters out of `git ls-files -v` would answer only the two flags that are known today; comparing the file with what was committed answers the question the docstring actually asks, and it is the same question in every future git. `hash-object` applies the clean filter `git add` would, so a CRLF checkout under `core.autocrlf` still hashes to the blob it was committed as rather than reading as a whole-file edit. The status question stays, and stays first: it is the one that catches a change STAGED and then reverted in the working tree, where the bytes on disk do match HEAD and the commit would quietly drop what the human staged. `_git_answer` also puts the `no git at all` case where the docstring always said it was — not committed — instead of letting a `FileNotFoundError` escape a classification that must not raise. A NEGATED CHARACTER CLASS IS NOT LINE-BOUND, and `re.MULTILINE` does not make it one: only `^` and `$` are per line, so ``[^`]+`` matched across a line break and a backtick-quoted name broken over two lines read as one `Shape:` line (Copilot, PR #152). The cost was not a bad rewrite but a missing one — a malformed example counted as a SECOND line, which made a holder's real one `ambiguous` and left it drifting, which is the failure #148 exists to end, reached through a typo in somebody's prose. ``[^`\r\n]+`` ends it. AND THE BYTE-PRESERVATION PROMISE NOW HAS A TEST. `_classify` decodes the whole README and `rewrite` re-encodes it, so every byte outside the 40 characters is a promise nothing was keeping: a holder checked out under `core.autocrlf`, or a README written by an editor that leads with a BOM, must come back with its endings and its BOM exactly as they were, or the next diff of that holder shows a whole-file change nobody asked for. Three tests. The index-flag one sets each flag in turn, asserts git says nothing, asserts `readme_is_committed` says no anyway, and then runs `apply` under `--assume-unchanged` end to end: the paragraph and the sha both stay and `README.md` is not in the commit. The CRLF one writes a BOM and CRLF endings, commits them, and asserts the file afterwards is the file before with the 40 characters swapped and nothing else. The line-break one puts a malformed two-line example above a real trailing line and asserts everything above that last line is byte for byte what it was — which covers the scaffolded sentence that names the same commit in prose of its own, a few lines further up. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
update-shape.py hashes README bytes without Git’s --path filtering, potentially misclassifying valid CRLF or clean-filtered files and skipping rewrites.
Review details
Suppressed comments (1)
update-shape.py:1008
git hash-objectonly applies Git's clean filters when given--path; this invocation hashes the raw working-tree bytes. A clean CRLF checkout (or any README clean filter) can therefore compare unequal toHEAD:README.md, classify the line asuncommitted, and skip a valid rewrite. Use the filtered hash form so the CRLF/BOM preservation test also works under the repository'score.autocrlfscenarios.
disk = _git_answer(root, ["hash-object", "--", README])
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
…filter, so a Windows holder's CRLF README is committed, and now has the test that says so (#148) Copilot read `git hash-object -- README.md` in `readme_is_committed()` as hashing the RAW worktree bytes, with no path context and so no clean filter: a holder checked out with CRLF would hash unequal to its own LF blob, be classified `uncommitted`, and keep its stale `Shape:` line for ever — this feature's byte-preserving CRLF support defeated on the one platform that needs it. THE PREMISE IS WRONG, AND THE WORRY IS RIGHT TO HAVE HAD. A file handed to `hash-object` as an argument is hashed AS the path it was handed, so the attributes that govern `README.md` are the ones that run; `--path` is for stdin and for files outside the working tree, and `--no-filters` is the flag that turns the conversion off. Adding `--path README.md` would change no answer this tool can reach. What was missing was not the flag but the proof, so the proof is what this commit adds. `test_a_readme_checked_out_with_crlf_is_committed_and_keeps_its_endings` puts LF in the index and CRLF on disk through `.git/info/attributes` — which outranks the `* text=auto eol=lf` the templates ship, and cannot be drift because it is not in the tree, the same per-clone lever the ignored-README test already uses. That is exactly what a clone under Git for Windows' `core.autocrlf=true` default gets. It then hashes the one file three ways: `git status` has nothing to say, `--no-filters` is NOT the committed blob, the filtered hash IS, `readme_is_committed` answers True, and `apply --branch` moves the 40 characters with every CRLF in the file left where it was. Turning the filter off turns the test red, which is the whole of the reviewer's scenario, run. The docstring now carries the argument next to the call, so the next reader of that line is told why no `--path` is passed rather than left to wonder. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Two moderate wording findings and one documentation nit remain unresolved.
Review details
Suppressed comments (3)
AGENTS.md:287
README_UNREADABLEis another explicit reading that_classifyleaves untouched and reports, but this operational guidance omits it from the list of README states thatapplywill not rewrite. Please include it so the documented safe/left-alone cases match the implementation.
README this tool cannot account for: uncommitted, ignored, a symlink, a
update-shape.py:1155
README_UNCOMMITTEDis reached for any committed-content mismatch with the requested target, so the named SHA can be ahead of the target (for example withcheck --at), not only behind it. Calling it “behind” gives the operator an incorrect diagnosis; describe the mismatch instead, and keep the correspondingsaidmessage consistent.
return (f"{README_UNCOMMITTED} ({self.named[:12]} is behind, but "
f"{README} has changes of its own; `apply` leaves it "
"alone rather than commit somebody else's edit)")
update-shape.py:1186
- This output repeats the same incorrect assumption as the verdict above: an uncommitted line may name a commit ahead of the target, so it is not necessarily “behind.” Use target-neutral wording here as well so
applydoes not tell the user to interpret an ahead line as an old one.
return (f" kept {README}: its Shape: line is behind, but the "
"file has uncommitted changes, untouched — commit them "
"and the next re-pin carries the line")
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
…n rather than which way, and AGENTS.md's left-alone list names `unreadable` too (#148) `README_UNCOMMITTED` is reached on ANY disagreement between the trailing line and the target, and `--at` is free to aim a re-pin at a commit older than the one the README already claims — rehearsing a rollback to a known-good standard is the ordinary way that happens. Both readings said "is behind" anyway, which is the one thing such a line is not (Copilot, PR #152): an operator told an ahead line is an old one reaches for the wrong repair. Both now name the two commits in the order `stale` already names them — `uncommitted (<named>, pin will read <target>, but README.md has changes of its own ...)` in `check`, and `its Shape: line names <named> and the pin will read <target> ...` in `apply` — which is true whichever way they lie. `stale` needed no change: it named both from the start. AGENTS.md's point 7 listed the READMEs `apply` will not rewrite and left out `unreadable`, which `_classify` has answered since the round that turned an `OSError` into a reading. A list that does not match the code is a list a reader has to check, so the word joins it; the file's line count is unchanged and the cap stays where it is. `test_an_uncommitted_line_ahead_of_the_target_is_not_behind` is the case in full: a README naming commit B under `check --at A`, where the line is provably AHEAD of the target, asserting that the row names both commits and that the word "behind" appears nowhere in the output. `check` is where that is reachable end to end, because `apply` declines a target the pin already names as nothing to do; the `apply` half of the same sentence is asserted in the test that already runs a real re-pin over an uncommitted README. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Copilot's round on 8cdb7b5 — all three taken, in 7874c14. They arrived as SUPPRESSED comments with no thread to reply on, so the answer is here.
Whole suite in the foreground from this worktree at 7874c14: 1184 passed / 1 skipped, 0 failed. |
There was a problem hiding this comment.
🔵 Needs a closer look
Restrict or sanitize repository names before printing to prevent terminal-control injection.
Review details
Suppressed comments (1)
scripts/shape_materialize.py:303
- The repository capture accepts any non-backtick/non-newline bytes, including ANSI control characters.
update-shape.pyprintsself.match['repository']in theother-repositorybranch, so a crafted README can inject terminal controls whencheck/applyreports it. Restrict this field to the repository-name alphabet already used byREPOSITORY_RE, or sanitize it before output; malformed lines can remain unrecognized.
r"^Shape: `(?P<repository>[^`\r\n]+)` @ `(?P<commit>[0-9a-f]{40})`\.\r?$",
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
… a name carrying an escape character never reaches the operator's terminal (#148) `README_SHAPE_LINE_RE` captured the repository as `[^`\r\n]+` — anything that was not a backtick, an ESC among them — and both readers print the name they read straight back to whoever ran them: `apply`'s `other-repository` line names it, and so does `check`'s row. A README whose line named `` `<ESC>[2J...` `` would therefore have played terminal control sequences into that operator's terminal (Copilot, PR #152), out of a file the operator need not have written: `shape-doctor.py` reads OTHER repositories' READMEs, which is the whole point of an estate sweep. The capture is now the shape a repository name actually has — an owner and a name of letters, digits, dots, hyphens and underscores with one slash between them, which is what the template renders and what `octo/Elsewhere` is in the tests that exercise the `other-repository` reading. A crafted name is not a `Shape:` line at all, so the file reads `absent` and is left exactly as it was: untouched, unprinted, and not a rewrite this tool was talked into. It also subsumes the line-break defect the class was narrowed for a round ago, since neither CR nor LF is in the new alphabet either. `test_a_name_carrying_an_escape_is_not_a_line_this_tool_reads` puts an ESC inside the backticks, asserts the reader finds no line at all, runs `apply --branch`, and asserts the README's bytes are untouched, that no ESC appears anywhere in stdout or stderr, and that the file is not in the commit. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Lane: openreposhape-2 (openRepoShape-2) Copilot's round on 7874c14 — taken, in 7f25e14. Suppressed comment again, so the answer is here.
Taken as the first of your two remedies, because the second would leave the tool holding a string it had decided to distrust. The capture is now the shape a repository name actually has — an owner and a name of letters, digits, dots, hyphens and underscores with one slash between them:
Whole suite in the foreground from this worktree at 7f25e14: 1185 passed / 1 skipped, 0 failed. |
|
There was a problem hiding this comment.
🔵 Needs a closer look
Two moderate findings remain, along with a requested invalid-UTF-8 regression test.
Review details
Suppressed comments (3)
shape-doctor.py:1033
- When
noteis non-empty here, the README has an eligible stale Shape line andapplywill rewrite it in the same pin-only update. This reason still says thatapplywould move “the pin alone”, contradicting both the new note and the commit that will be produced; make the phrase conditional on whether the README note is present.
"no copied file differs, but the pin names an older "
f"commit, so `apply` would move the pin alone; "
f"{summary} ({where}){note}",
update-shape.py:1886
- This phase runs after
_write_copies, which can replace the pinned.gitattributesfile.readme_is_committed()then evaluatesgit statusandhash-objectusing the new filter rules rather than the rules under which the README matchedHEAD; for example, a clean CRLF README under the old attributes can becomeuncommittedafter aneol=lfupdate, so its stale line is skipped and the pin/README remain out of sync. Snapshot the README classification before copying the pinned files, or compare it usingHEAD's attributes.
copied = _write_copies(root, rows, taking, ledger)
_repin(root, kind, ledger, rows, pinned, target, target_tree)
readme = _rewrite_readme(root, upstream, target, ledger)
update-shape.py:1104
- Please add a deterministic invalid-UTF-8 README fixture for this branch. The new tests exercise an OS read failure (which can skip on permissive/root runners), but do not verify that invalid bytes are reported as
unreadable, left untouched, and excluded from the commit—the other promised form of this reading.
self.text = self.path.read_bytes().decode("utf-8")
except UnicodeDecodeError:
return README_UNREADABLE
- Files reviewed: 8/8 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Lane: openreposhape-2 (openRepoShape-2) Copilot's round on 7f25e14 — STOPPING AT THE ROUND CAP, with the three findings recorded here rather than taken. This lane's brief allows at most three review rounds on one head before it reports back, and 7f25e14 is the third (8cdb7b5, 7874c14, 7f25e14); each fix has drawn a fresh round on a different part of the feature. All four checks are green at 7f25e14 and every earlier thread is answered, so this is a clean place to stop. My reading of the three, for whoever picks them up: 1. 2. 3. Suite in the foreground from this worktree at 7f25e14: 1185 passed / 1 skipped, 0 failed. tests / tests-macos / tests-windows / SonarCloud all green on that head. |
…ssifier's untested decode arm: PR #152's last three Copilot findings, taken (#158) (#159) * The doctor's behind-pin row stops saying `apply` would move the pin alone in the same breath as the note that says the README moves with it (#158) ONE SENTENCE THAT CLAIMED TWO THINGS. `readme_shape_note` is appended to the `behind_pin_only` reason unconditionally, and that reason promised "`apply` would move the pin alone" whatever the note went on to say — so the row a human reads before running `check`/`apply` contradicted itself in exactly the case the note exists for. `update-shape.py check` carried the same defect and baa77d0 took it out; the doctor's copy of the wording was missed and has read the old way ever since (Copilot, PR #152, round eight). THE CLAUSE IS SETTLED AGAINST THE TARGET RATHER THAN AGAINST THE NOTE, which is the same question `check` asks and not the one the note answers. The note weighs the README against the PIN, because the pin is the authority on what revision this root is a copy of; what `apply` would DO is settled against the commit it is about to re-pin onto. The two part company in both directions: the commonest holder re-pin of all — a README naming its own pin, with both of them behind this standard — draws no note and is rewritten all the same, while a README that has run AHEAD to the commit this re-pin will record draws a note and is left exactly where it is. Reading an empty note as "the README stays put" would have kept the false promise in precisely the case it is made most often. `what_a_re_pin_would_move` holds the second reading, so the branch inside `check_shape_currency` gains no condition of its own and the row's text is one substitution. The new test runs both directions past the same ahead standard and asserts what the row and the note say together: the pin-naming README draws no note and the row names it, the ahead README draws one and the row says "alone". Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * `apply` classifies the README before it writes the copies, so an upstream `.gitattributes` change no longer decides whether this root's Shape: line moves (#158) THE QUESTION WAS ASKED UNDER THE ANSWER'S OWN ATTRIBUTES. `.gitattributes` is a pinned copy, and `readme_is_committed` asks git two questions about `README.md` — `git status --porcelain --ignored` and `git hash-object` — that git answers through the attributes in the WORKING TREE. Classified after `_write_copies`, a root's README therefore had its fate decided by an upstream edit to `* text=auto eol=lf`: the standard's new rule was already on disk when the README was read, even though nothing about the README had changed. `apply` then silently left a stale line alone — or moved one it would otherwise have left — for a reason that has nothing to do with the README, and one no `check` run made before the copies landed could have predicted (Copilot, PR #152). THE FIXTURE CAME FIRST, because this is a phase order inside a command whose rollback is built around one. The new test is a holder cloned on Windows — CRLF in the working tree, LF in the index, a `git status` with nothing to say — re-pinned onto a standard whose one changed copied file is `.gitattributes`, gaining `README.md -text`. It hashes the same file both ways first, so the flip is bytes rather than a claim: under the pinned `* text=auto eol=lf` the CRLF file hashes to the LF blob it was committed as, and with that normalisation off it does not. Run against the old order the test fails exactly as the finding describes, with `apply` printing "the file has uncommitted changes, untouched". ONLY THE READING MOVED. Root, repository and target are all known before the first copy, so `_read_readme` takes the classification there; `_rewrite_readme` keeps the WRITE where the `Rollback` ledger wants it — after the pin move, before the validators — and now takes the already-classified line rather than building its own. Rollback semantics are untouched: a red validator still puts this line back with every other byte. `_classify`'s docstring loses the sentence about running after the copies, which is no longer where it runs; the argument for raising nothing there stands on `check` and the doctor, which read every root they are pointed at. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> * The `UnicodeDecodeError` arm of the README classifier gets a test that runs on every platform, rather than sharing the OSError arm's skip (#158) `_classify` turns every way of failing to READ this file into a reading rather than a raise, and until now only the `OSError` half of that had a test — `test_a_readme_the_os_will_not_read_is_a_reading_rather_than_a_traceback`, which takes a read away with `denied()`. That helper skips outright for root, for a filesystem mounted without permission bits, and on Windows, where there is no mode to take a read away with: three of the places the suite runs. So the branch `check`, `apply` and `shape-doctor.py` all lean on when they are pointed at somebody else's prose had no coverage that was guaranteed to run anywhere (Copilot, PR #152). BYTES THAT ARE NOT UTF-8 NEED NOBODY'S PERMISSION. The new test writes a rendered `Shape:` line with one byte corrupted — 0xFF begins no UTF-8 sequence at all, so there is no locale and no platform on which the file decodes — and asserts the three things every left-alone README here is asserted for: `apply` reports `not valid UTF-8, untouched` and exits 0, the bytes are exactly what they were, and the file is absent from the commit. `check`'s row is read too, because the wording it prints is the one that distinguishes this arm from the one below it. Lane: openreposhape-2 (openRepoShape-2) Co-Authored-By: Claude Fable 5.1 <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]>



Lane: openreposhape-2 (openRepoShape-2)
Claim: #148 (comment)
Closes #148.
Option 1, on Brett Heap's word 2026-09-12T17:2xZ ("do option 1 on 148"). Option 2 — dropping the line from the template — is NOT taken.
What was wrong
templates/family-root/README.md:140renders a trailingShape: `{{SHAPE_REPOSITORY}}` @ `{{SHAPE_COMMIT}}`.line naming the standard a holder was cut from, and nothing rewrote it afterwards.README.mdis deliberately not a pinned copy — it is the project's own document — soupdate-shape.py applyre-copied the digested files, movedcontracts/shape-pin.yamlandfamily.yaml'sshape:block, and left the sentence claiming a revision that had stopped being true.InkRouter/InkRouter's holder reads6fe09a41535awhile its pin reads57ddeacc9f1d, four re-pins later; the only correction ever made to that line was made by hand (InkRouter#18) and it was stale again a day later. The doctor did not read the README either, so no row reported it.What landed
update-shape.py: aReadmeShapeLinereader and a_rewrite_readmephase incmd_apply, after the copies and the pin/family.yamlmove and before the validators. It rewrites ONLY thecommitgroup's 40 hex characters, through theRollbackledger, when the README ends with exactly one line in the rendered form and that line names the repository this pin is against; the file is otherwise byte for byte what it was (bytes in, bytes out, so CRLF endings and a BOM survive). A rewritten README joins the pin's own commit, and the commit message names it. No new flags.applytouches that nobody pinned:absent(no line at all, or one that is not the last line — an example of the form rather than this root's claim),ambiguous(two of them),other-repository,unreadable(not valid UTF-8, or a file the OS will not hand over),uncommitted(a README with changes of its own, which names the two commits it lies between and never which way, because--atcan aim a re-pin backwards —git commit -- README.mdrecords the WORKING TREE version of a path with no pin row; untracked, ignored, and edits hidden behind--assume-unchanged/--skip-worktreeall count here, becausereadme_is_committedasks bothgit statusand the file's own bytes againstHEAD:README.md),symlinkandhard-link(this tool writes THROUGH a name, and both of those are a name for somebody else's bytes), andcurrent.Refusal("update-readme-unwritable", …)sends it through theexcept Refusal: ledger.undo()arm that already exists.Rollback.writenow opensr+bONCE, before recording anything, so a path this process cannot write is never a path the undo has promised to restore.checkgains areadme-shape-line: stale (6fe09a41535a, pin will read 57ddeacc9f1d)/current/absentrow, printed before the yes is asked for and never able to move its exit code. In the exact state A scaffolded README's trailingShape: … @ <sha>line is never rewritten by update-shape.py, so it drifts silently from contracts/shape-pin.yaml — InkRouter's holder reads 6fe09a4 four re-pins after the fact #148 was filed over — a stale line under a pin already at the target — it says there is no commit to move the line in and the next re-pin carries it.shape-doctor.py:check_shape_currencyappends anote(README.md's Shape: line names 6fe09a41535a, the pin 57ddeacc9f1d —applyrewrites it) and areadme_shape_lineentry in the row'sdetailwhen — and only when —applywould rewrite the line. A row that would readokreadsnote; a FINDING stays a FINDING.verdict_forsteps over a note, so prose never fails a repository whose every pin is current — the same ruleleg shape filesargues at length. The hunk stays inside the shape-currency code, clear of shape-doctor.py: the members row asks the origin question too, so a fork beside the holder is no longer called the member's working clone (#146) #147's members row and the imports consolidation.scripts/shape_materialize.py: ONE compiledREADME_SHAPE_LINE_RE(its repository capture is the shape a repository name HAS —[A-Za-z0-9._-]+/[A-Za-z0-9._-]+— rather than "anything that is not a backtick": a negated class is not line-bound underre.MULTILINE, so a name broken over two lines used to match as one, and both readers echo the name they read back to the operator's terminal, so one carrying an ESC used to be played there), plusreadme_shape_lines()(how many there are — the ambiguity question) andreadme_trailing_shape_line()(which one a rewrite may move — the match the file ENDS with, nothing but whitespace after it). Beside the template lists that render the line, read by both tools. (NOT inscripts/repo_shape.py, which is digest-pinned.)apply's to rewrite and never yours, with every reading it leaves alone named (unreadableamong them). The hygiene cap moves 439 -> 446 with the reason intests/test_repo_hygiene.py's docstring, in the form that file's earlier cap moves take — 439 rather than 433 because scripts/bump-leg.py's commit takes a repeatable--trailer, closing the gap #111 left in the third pin-moving tool (#150) #151 (bump-leg.py's--trailer) landed first and this branch has mergedorigin/main.No digest-pinned file is touched. Confirmed against the diff:
AGENTS.md,scripts/shape_materialize.py,shape-doctor.py,update-shape.pyand four test files, and nothing undertemplates/orcontracts/, noscripts/repo_shape.py, noscripts/validate-repository-naming.py.docs/cli.mdis unchanged — no--helptext moved, andscripts/render-cli-reference.pyregenerates it byte-identical.How it was proven
30 new tests, and the parity one is the load-bearing one.
tests/test_family.py::test_the_rendered_readme_carries_exactly_one_line_the_rewriter_reads— a REAL holder, rendered by the real materializer, matched by the shared pattern: exactly one line, this standard's name, the commit the pin records, and the whole line equal to what the template renders. It also asserts a scaffolded assembly root renders NO such line, soapplythere readsabsent. A reworded template fails here rather than silently turning every holder's verdict intoabsent.tests/test_family.py::test_update_shape_moves_the_holder_readmes_shape_line_with_the_pin— A scaffolded README's trailingShape: … @ <sha>line is never rewritten by update-shape.py, so it drifts silently from contracts/shape-pin.yaml — InkRouter's holder reads 6fe09a4 four re-pins after the fact #148 end to end on a real holder: the line moves with the pin, the file is the same length,validate-family.pystays green.tests/test_update_shape.py— the rewrite lands in the pin's own commit (README.mdingit show --name-only, named in the message); a red leg pin rolls the README back with everything else; no line / another repository's name / two lines are each untouched and said;check's three verdicts; and a stale line under--at <the pin>exits 0 with the "next re-pin carries it" sentence.tests/test_update_shape.py, the READMEsapplymust not write, one test each — uncommitted (the paragraph and the sha both stay,README.mdabsent from the commit), ignored-and-untracked (excluded through.git/info/exclude, because.gitignoreis a pinned copy), symlinked (the file outside the root keeps its bytes), hard-linked (os.link, both names unchanged), a mode0o444README (exit 2,update-readme-unwritable, the pin and the copies rolled back, validators green) and a mode0o000one (a reading, not a refusal). Each skips cleanly where the platform or the user makes the fixture impossible rather than failing about the machine.test_git_answers_three_ways_for_a_readme_and_one_of_them_is_committedputs the three git answers behind that one boolean side by side.tests/test_update_shape.py, the trailing rule — an embedded example with no trailing line readsabsentand is untouched; an example ABOVE a real trailing line isambiguousand untouched; a backtick name broken over a line break is not a line at all, and the trailing line above it still moves while every byte above it stays (including the scaffolded sentence that names the same commit in prose of its own).tests/test_update_shape.py, the bytes — a README that leads with a UTF-8 BOM and ends its lines in CRLF comes back as the same file with 40 characters swapped and nothing else, so a future change cannot normalise a holder's endings to move one sha.tests/test_update_shape.py, the CRLF CHECKOUT —test_a_readme_checked_out_with_crlf_is_committed_and_keeps_its_endingsputs LF in the index and CRLF on disk through.git/info/attributes(which outranks the* text=auto eol=lfthe templates ship and cannot be drift, because it is not in the tree), which is exactly what a clone under Git for Windows'core.autocrlf=truedefault gets.git statushas nothing to say,git hash-object --no-filtersis NOT the committed blob while the filtered hash IS,readme_is_committedanswersTrue, andapply --branchmoves the 40 characters with every CRLF in the file left where it was. Changing the call to--no-filtersturns it red.tests/test_update_shape.py, the DIRECTION —test_an_uncommitted_line_ahead_of_the_target_is_not_behindputs a README naming commit B undercheck --at A, where the line is provably AHEAD of the target, and asserts the row names both commits and that the word "behind" appears nowhere in the output.apply's half of the same sentence is asserted in the test that runs a real re-pin over an uncommitted README.tests/test_update_shape.py, the NAME —test_a_name_carrying_an_escape_is_not_a_line_this_tool_readsputs an ESC inside the backticks, asserts the reader finds no line at all, and then assertsapply --branchleaves the README's bytes untouched, puts no ESC anywhere in stdout or stderr, and does not commit the file.tests/test_update_shape.py, the index flags —--assume-unchangedand--skip-worktreeeach leavegit statussilent over an edited README, andreadme_is_committedsays no anyway;applyunder the flag leaves the paragraph and the sha where they are and does not commit the file.tests/test_shape_doctor.py— the note appears only on a mismatch (notestatus, COMPLIANT, exit 0,detail.readme_shape_line), says nothing when the line names the pin, and says nothing for the two readingsapplywould not rewrite;nextstaysNone.origin/main, and The two copies of "is this the same repository" become ONE definition in scripts/repo_shape.py, and #149's case rule lands with the move (#155) #156 brought eleven of its own). Collection across the rounds went 1163 -> 1169 -> 1172 -> 1184 -> 1185 -> 1186.tests/test_cli_reference.pygreen — no--helptext moved, sodocs/cli.mdis unchanged; the AST-level doctor guards (one shell verb, no other row grows a trailer, everyfixslotNone) green.🤖 Generated with Claude Code
Review rounds
Copilot round 1 (4acb4fd) — three of four taken in baa77d0. A README carrying uncommitted changes is a seventh reading,
uncommitted, thatapplyleaves alone, becausegit commit -- README.mdlands the working-tree version of a path with no pin row and no drift check: a half-written paragraph would have ridden into a re-pin the human approved from acheckthat never showed it.checkstops previewing "the pin alone" on the commonest holder re-pin of all. The doctor's clause says what holds in every case rather than promising a rewrite, and still compares against the PIN — comparing against the standard's HEAD would note every project that is merely behind, which is theSHAPE BEHINDverdict the row already carries. Declined: anchoring the pattern to the final line, because it would stop rewriting any holder that has appended a section since it was scaffolded — the exact silent drift #148 is about — while the collision it guards against is alreadyambiguousand already untouched.origin/mainmerged (f189818) — #151 landed thebump-leg.py --trailerpoint and moved the same AGENTS.md cap. One conflict, in the cap's docstring: both dated paragraphs stay, in the order the caps moved, and the assertion is the sum (446).Copilot round 2 (baa77d0, f189818) — both code findings taken in eec8705.
git status --porcelainsays nothing about an IGNORED untracked file, so an ignored README read as clean and would have been handed togit commitas a pathspec git has never heard of;--ignoredcloses it.Path.is_file()follows a SYMLINK, so a README pointing out of the root would have been rewritten in somebody else's file while the tracked symlink stayed byte-identical; a symlinked README is now its own reading, asked before the file is read. The third finding — this PR body saying 433 -> 440 — is fixed above. Two more tests; 1155 passed / 1 skipped.Codex (4acb4fd, two P2s) — both were already closed by the rounds above, and this round wrote their proof. A README with unrelated uncommitted edits is
uncommitted, so_landnever names it in the pathspec (baa77d0), and a symlinked README is never written through (eec8705); the replies on those threads name the tests, including the new three-wayreadme_is_committedone.Copilot round 3 (eec8705, three findings) — all three taken in feaab50. (1) The pattern was multiline-anchored but not EOF-anchored, so an embedded EXAMPLE of the form was read as this root's claim and would have been rewritten — the documentation version of the drift #148 is about. Eligibility is now the match the README ENDS with, decided in one place for both readers; two matches are still
ambiguous. This REVERSES round one's decline, and what makes it right is that the new answer is not silent:absentsays which absent it is, so a holder that appended a section under its line is told by both commands instead of quietly drifting. (2) A HARD-LINKED regular README passesis_symlink()and looks clean to git, and writing through it would change the other name's file; it is a reading now, not a refusal (the line is prose) and not an inode-replacing write (that would be the one write in the command the ledger could not undo — the docstring says so beside the guard). (3) AnOSErrorin the README phase escapedcmd_apply's rollback: read failures are now readings and write failures areupdate-readme-unwritable, and the ledger opensr+bbefore it records anything so the undo it runs can actually finish. Six more tests; 1168 passed / 1 skipped.Copilot round 4 and Codex (feaab50, three findings) — all three taken in 201d473. Codex's P2 is fresh evidence rather than the earlier fix restated:
git update-index --assume-unchanged/--skip-worktreeleavegit statussilent over an edited README whilegit commit -- README.mdstill records the whole working-tree file, soreadme_is_committednow asks the BYTES as well —git hash-objectagainstHEAD:README.md, which no index flag, ignore rule or absence from the index can quiet — and keeps the status question for the case bytes cannot answer (staged, then reverted in the working tree). Copilot's two arrived as suppressed comments with no thread, and are answered in a PR comment:[^`]+matched across newlines, so a backtick name broken over two lines counted as a secondShape:line and left a holder's real oneambiguousand drifting; and the CRLF/BOM byte-preservation promise now has the regression it was missing. Three more tests; 1171 passed / 1 skipped.Copilot round 5 (74c94b9, one finding) — DECLINED on its mechanism, TAKEN as the test it was missing, in 8cdb7b5. The finding read
git hash-object -- README.mdas hashing the RAW worktree bytes with no path context and so no clean filter, which would make a CRLF holder read asuncommittedand keep its stale line for ever — this feature's byte-preserving CRLF support defeated on the one platform that needs it. The premise does not hold: a file handed tohash-objectas an ARGUMENT is hashed as the path it was handed, so--path README.mdwould change no answer this tool can reach —--pathis for stdin and for files outside the working tree, and--no-filtersis the flag that turns the conversion off. Measured on git 2.43.0 undercore.autocrlf=truewith no attributes and under* text=auto eol=crlf, all three ofHEAD:README.md,hash-object --andhash-object --path README.md --agree and only--no-filtersdiffers. The half of the comment that IS right: under the* text=auto eol=lfthe templates ship, CRLF is not reachable by checkout at all, and a CRLF file written there afterwards is reportedMbygit status— so it isuncommittedone question BEFORE the bytes are hashed, which--pathwould not have touched either. What was missing was the proof rather than the flag, so the proof is what landed, plus the argument in the docstring beside the call. One more test; 1183 passed / 1 skipped.Copilot round 6 (8cdb7b5, three findings) — all three taken in 7874c14; they arrived as suppressed comments with no thread, and are answered in a PR comment. Two are one sentence in two readers:
README_UNCOMMITTEDis reached on ANY disagreement between the trailing line and the TARGET, and--atcan aim a re-pin at a commit OLDER than the one the README claims, so calling that line "behind" tells an operator the opposite of what is true and sends them to the wrong repair. Both now name the two commits in the orderstalealready names them and claim no direction between them. The third: AGENTS.md's list of the READMEsapplywill not rewrite left outunreadable, which_classifyhas answered since the round that turned anOSErrorinto a reading — the word joins the list in place, so the line count and the hygiene cap are unchanged. One more test; 1184 passed / 1 skipped.Copilot round 7 (7874c14, one finding) — taken in 7f25e14, and answered in a PR comment because it too arrived suppressed. The repository capture was
[^\r\n]+, anything that was not a backtick and an ESC among them, while both readers print the name they read back to whoever ran them — so a README naming ``[2J...`` would have played terminal control sequences into that operator's terminal, out of a file the operator need not have written, sinceshape-doctor.pyreads other repositories' READMEs. The capture is now the shape a repository name actually has, which is what the template renders and whatocto/Elsewhereis; a crafted one is not aShape:line at all, so the README readsabsent` and is left exactly as it was. It subsumes the line-break narrowing of two rounds ago, since neither CR nor LF is in the new alphabet. One more test; 1185 passed / 1 skipped.Copilot round 8 (7f25e14, three findings) — NOT TAKEN; this lane stops at three rounds on one head and 7f25e14 is the third. All four checks are green there and every earlier thread is answered. The three are recorded in a PR comment with my reading of each: (1)
shape-doctor.py'sbehind_pin_onlyreason still saysapplywould move "the pin alone" and then appends the README note that says otherwise — the same defectupdate-shape.py checkhad and baa77d0 fixed, missed one file along, and worth doing; (2)_rewrite_readmeruns after_write_copies, and.gitattributesis a PINNED copy, so an upstream change to it is on disk beforereadme_is_committed()asks git — which reads attributes from the working tree — and a README clean under the old rules can readuncommittedunder the new ones; real and subtle, and it wants a fixture no test here builds yet (an upstream commit that changes.gitattributes) rather than a hurried push; (3) theUnicodeDecodeErrorarm has no DETERMINISTIC test — theOSErrorone skips where a mode does not stop the user — which is fair and cheap.origin/mainmerged again (74c94b9) — #156 landed (313c57c) and moved the remote-url block out ofscripts/shape_materialize.pyintoscripts/repo_shape.py, leaving a pointer comment; this branch'sShape:-line pattern and its two readers sit several hundred lines above it,shape-doctor.pytakes #156's imports and keepsreadme_shape_note, andtests/test_shape_doctor.pytakes both sets of tests. Git merged all three files with no conflict; the suite is the check that it merged them correctly. One test fix rode in with it (bc80f8e):tests-windowswas red on 201d473 becausePath.write_texthands the fixture CRLF there, so the line-break assertion now finds its line by index and has no opinion about the ending — which is the promise the CRLF test in the same round makes.Summary by Sourcery
Synchronize eligible holder README Shape metadata with shape pins while keeping ambiguous or unsafe README states untouched.
New Features:
Shape: <repository> @ <sha>.line synchronized with the pin during shape updates and report its state during checks.Bug Fixes:
Enhancements:
Documentation:
Tests: