Skip to content

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

Merged
brettheap merged 11 commits into
mainfrom
feat/apply-rewrites-readme-shape-line
Sep 13, 2026

Conversation

@brettheap

@brettheap brettheap commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

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:140 renders a trailing Shape: `{{SHAPE_REPOSITORY}}` @ `{{SHAPE_COMMIT}}`. line naming the standard a holder was cut from, and nothing rewrote it afterwards. README.md is deliberately not a pinned copy — it is the project's own document — so update-shape.py 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 stopped being true. InkRouter/InkRouter's holder reads 6fe09a41535a while its pin reads 57ddeacc9f1d, 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: a ReadmeShapeLine reader and a _rewrite_readme phase in cmd_apply, after the copies and the pin/family.yaml move and before the validators. It rewrites ONLY the commit group's 40 hex characters, through the Rollback ledger, 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.
  • The other eight readings are LEFT ALONE and said out loud, because silence there reads as "done" in the one file apply touches 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 --at can aim a re-pin backwards — git commit -- README.md records the WORKING TREE version of a path with no pin row; untracked, ignored, and edits hidden behind --assume-unchanged/--skip-worktree all count here, because readme_is_committed asks both git status and the file's own bytes against HEAD:README.md), symlink and hard-link (this tool writes THROUGH a name, and both of those are a name for somebody else's bytes), and current.
  • A write it cannot make is a refusal, never a traceback: the phase runs after the copies and the pin, so Refusal("update-readme-unwritable", …) sends it through the except Refusal: ledger.undo() arm that already exists. Rollback.write now opens r+b ONCE, before recording anything, so a path this process cannot write is never a path the undo has promised to restore.
  • check gains a readme-shape-line: stale (6fe09a41535a, pin will read 57ddeacc9f1d) / current / absent row, printed before the yes is asked for and never able to move its exit code. In the exact state A scaffolded README's trailing Shape: … @ <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_currency appends a note (README.md's Shape: line names 6fe09a41535a, the pin 57ddeacc9f1d — apply rewrites it) and a readme_shape_line entry in the row's detail when — and only when — apply would rewrite the line. A row that would read ok reads note; a FINDING stays a FINDING. verdict_for steps over a note, so prose never fails a repository whose every pin is current — the same rule leg shape files argues 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 compiled README_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 under re.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), plus readme_shape_lines() (how many there are — the ambiguity question) and readme_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 in scripts/repo_shape.py, which is digest-pinned.)
  • AGENTS.md: one numbered point under "Updating a project's shape" — only the line the file ends with, and it is apply's to rewrite and never yours, with every reading it leaves alone named (unreadable among them). The hygiene cap moves 439 -> 446 with the reason in tests/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 merged origin/main.

No digest-pinned file is touched. Confirmed against the diff: AGENTS.md, scripts/shape_materialize.py, shape-doctor.py, update-shape.py and four test files, and nothing under templates/ or contracts/, no scripts/repo_shape.py, no scripts/validate-repository-naming.py. docs/cli.md is unchanged — no --help text moved, and scripts/render-cli-reference.py regenerates 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, so apply there reads absent. A reworded template fails here rather than silently turning every holder's verdict into absent.
  • tests/test_family.py::test_update_shape_moves_the_holder_readmes_shape_line_with_the_pin — A scaffolded README's trailing Shape: … @ <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.py stays green.
  • tests/test_update_shape.py — the rewrite lands in the pin's own commit (README.md in git 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 READMEs apply must not write, one test each — uncommitted (the paragraph and the sha both stay, README.md absent from the commit), ignored-and-untracked (excluded through .git/info/exclude, because .gitignore is a pinned copy), symlinked (the file outside the root keeps its bytes), hard-linked (os.link, both names unchanged), a mode 0o444 README (exit 2, update-readme-unwritable, the pin and the copies rolled back, validators green) and a mode 0o000 one (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_committed puts 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 reads absent and is untouched; an example ABOVE a real trailing line is ambiguous and 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_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), which is exactly what a clone under Git for Windows' core.autocrlf=true default gets. git status has nothing to say, git hash-object --no-filters is NOT the committed blob while 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. Changing the call to --no-filters turns it red.
  • tests/test_update_shape.py, the DIRECTION — test_an_uncommitted_line_ahead_of_the_target_is_not_behind puts a README naming commit B under check --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_reads puts an ESC inside the backticks, asserts the reader finds no line at all, and then asserts apply --branch leaves 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-unchanged and --skip-worktree each leave git status silent over an edited README, and readme_is_committed says no anyway; apply under 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 (note status, COMPLIANT, exit 0, detail.readme_shape_line), says nothing when the line names the pin, and says nothing for the two readings apply would not rewrite; next stays None.
  • Whole suite from this worktree, in one foreground run at the head of this branch: 1185 passed / 1 skipped, 0 failed (1171 before merging 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.py green — no --help text moved, so docs/cli.md is unchanged; the AST-level doctor guards (one shell verb, no other row grows a trailer, every fix slot None) 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, that apply leaves alone, because git commit -- README.md lands 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 a check that never showed it. check stops 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 the SHAPE BEHIND verdict 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 already ambiguous and already untouched.

origin/main merged (f189818) — #151 landed the bump-leg.py --trailer point 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 --porcelain says nothing about an IGNORED untracked file, so an ignored README read as clean and would have been handed to git commit as a pathspec git has never heard of; --ignored closes 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 _land never 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-way readme_is_committed one.

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: absent says 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 passes is_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) An OSError in the README phase escaped cmd_apply's rollback: read failures are now readings and write failures are update-readme-unwritable, and the ledger opens r+b before 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-worktree leave git status silent over an edited README while git commit -- README.md still records the whole working-tree file, so readme_is_committed now asks the BYTES as well — git hash-object against HEAD: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 second Shape: line and left a holder's real one ambiguous and 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.md as hashing the RAW worktree bytes with no path context and so no clean filter, which would make a CRLF holder read as uncommitted and 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 to hash-object as an ARGUMENT is hashed as the path it was handed, so --path README.md would change no answer this tool can reach — --path is for stdin and for files outside the working tree, and --no-filters is the flag that turns the conversion off. Measured on git 2.43.0 under core.autocrlf=true with no attributes and under * text=auto eol=crlf, all three of HEAD:README.md, hash-object -- and hash-object --path README.md -- agree and only --no-filters differs. The half of the comment that IS right: under the * text=auto eol=lf the templates ship, CRLF is not reachable by checkout at all, and a CRLF file written there afterwards is reported M by git status — so it is uncommitted one question BEFORE the bytes are hashed, which --path would 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_UNCOMMITTED is reached on ANY disagreement between the trailing line and the TARGET, and --at can 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 order stale already names them and claim no direction between them. The third: AGENTS.md's list of the READMEs apply will not rewrite left out unreadable, which _classify has answered since the round that turned an OSError into 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's behind_pin_only reason still says apply would move "the pin alone" and then appends the README note that says otherwise — the same defect update-shape.py check had and baa77d0 fixed, missed one file along, and worth doing; (2) _rewrite_readme runs after _write_copies, and .gitattributes is a PINNED copy, so an upstream change to it is on disk before readme_is_committed() asks git — which reads attributes from the working tree — and a README clean under the old rules can read uncommitted under 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) the UnicodeDecodeError arm has no DETERMINISTIC test — the OSError one skips where a mode does not stop the user — which is fair and cheap.

origin/main merged again (74c94b9) — #156 landed (313c57c) and moved the remote-url block out of scripts/shape_materialize.py into scripts/repo_shape.py, leaving a pointer comment; this branch's Shape:-line pattern and its two readers sit several hundred lines above it, shape-doctor.py takes #156's imports and keeps readme_shape_note, and tests/test_shape_doctor.py takes 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-windows was red on 201d473 because Path.write_text hands 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:

  • Keep a holder README’s trailing Shape: <repository> @ <sha>. line synchronized with the pin during shape updates and report its state during checks.
  • Expose stale README shape metadata as a non-blocking doctor note with structured detail.

Bug Fixes:

  • Prevent README metadata from drifting from the shape pin across re-pins.
  • Avoid rewriting ambiguous, unrelated, modified, unreadable, symlinked, or hard-linked READMEs, and roll back safely when a README cannot be written.

Enhancements:

  • Preserve README bytes, including BOMs and line endings, while updating only the referenced commit.
  • Improve apply and check reporting for README shape-line classifications and include README changes in the pin commit when applicable.

Documentation:

  • Document that apply owns eligible trailing README Shape lines and that users should not update them manually.

Tests:

  • Add coverage for README synchronization, classification, rollback, byte preservation, Git/index edge cases, and doctor reporting.

…@ <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]>
Copilot AI lite review requested due to automatic review settings September 12, 2026 17:54
@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 1 day and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The 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 synchronization

sequenceDiagram
    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
Loading

Sequence diagram for check and shape-doctor README reporting

sequenceDiagram
    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
Loading

Flow diagram for README Shape line classification

flowchart 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]
Loading

File-Level Changes

Change Details Files
Add shared parsing and byte-preserving rewrite support for the rendered README Shape line.
  • Compile one exact multiline regex and expose all matches through the materialization module.
  • Classify absent, current, stale, ambiguous, other-repository, and invalid-UTF-8 cases.
  • Rewrite only the 40-character commit span through the existing rollback ledger.
scripts/shape_materialize.py
update-shape.py
Integrate README synchronization into update-shape apply and check workflows.
  • Run the rewrite after pin and manifest updates but before validators, so it lands in the pin's commit and rolls back transactionally.
  • Report the README action without changing check's exit status, including the already-at-target stale case.
  • Include README.md in the commit path list and message only when rewritten.
update-shape.py
Surface stale README metadata as non-blocking doctor diagnostics.
  • Add a shape-currency note and JSON detail only when apply would unambiguously rewrite the line.
  • Keep compliant repositories compliant and preserve findings for actual pin or copied-file drift.
shape-doctor.py
Document the new ownership and add coverage for parsing, transactionality, reporting, and template parity.
  • Document that apply owns the rewrite and humans should not edit the line.
  • Test real rendered holder and assembly-root behavior, all untouched cases, commit inclusion, rollback, check states, and doctor notes.
  • Raise the AGENTS.md hygiene cap to cover the added guidance.
AGENTS.md
tests/test_family.py
tests/test_update_shape.py
tests/test_shape_doctor.py
tests/test_repo_hygiene.py

Assessment against linked issues

Issue Objective Addressed Explanation
#148 Make update-shape.py apply rewrite a scaffolded family holder's exact trailing Shape: <repository> @ <40-hex-sha> README line to the new pinned commit in the same commit, while preserving all other README bytes and leaving missing, ambiguous, unrelated, or invalid lines untouched. ✅
#148 Provide visibility into README shape-line drift without treating README prose as a repository failure, including reporting the line's state in check and exposing stale-line information as a non-failing shape currency doctor note. ✅
#148 Document and test the selected option-1 behavior without removing the family-root template's rendered Shape line or modifying digest-pinned files. ✅

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

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 with re.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) before apply changes 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 != target but no copied row changed, readme.state can still be README_STALE because it was classified against target; apply will then rewrite the README as well as the pin. The later preview still says it would move “the pin alone,” so check is 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.

Comment thread shape-doctor.py Resolved
Comment thread update-shape.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread update-shape.py
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()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment thread update-shape.py
Comment on lines +975 to +978
if not self.path.is_file():
return README_ABSENT
try:
self.text = self.path.read_bytes().decode("utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>
Copilot AI review requested due to automatic review settings September 12, 2026 18:15
@brettheap

Copy link
Copy Markdown
Contributor Author

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.

update-shape.py:1165 — check previewing "the pin alone": TAKEN. Right, and on the commonest holder re-pin of all: a pin behind the standard with not one copied byte different. apply moves the README's Shape: line in that same commit, so the preview described a commit that would have had a second file in it. It now reads no copied file differs; \apply` would move the pin and README.md's Shape: linewhen that is what the run would do, andtest_check_names_the_readme_in_the_pin_alone_previewcovers it against a private copy of the upstream advanced by a commit that changes nothing the project copies. (Thenothing to dobranch you quoted is the other state — pin already AT the target — whereapply` genuinely writes nothing; that sentence is unchanged and still true.)

scripts/shape_materialize.py:291 — anchoring to the final line: DECLINED, with the reason. The collision you describe is already covered by the rule you ask to keep: a README carrying a second exact line — a code sample plus the rendered one — is ambiguous, untouched, and said so. What a final-line rule would cost is the case that is not hypothetical: a holder that has appended a section since it was scaffolded would silently stop being rewritten, which is precisely the silent drift #148 was filed over, restored. A false positive also needs a documentation sample carrying a REAL 40-hex sha and no genuine trailing line; and where it happens, the sentence it rewrites is Shape: <this repository> @ <sha>. — a claim about this standard's revision wherever it sits — reported by check before the yes and visible in the diff a human approves. The form is anchored (^/$, whole line, this repository's name, 40 hex); the position is not, deliberately.

Also in this round, from the README.md commit-sweep thread: a line in a README that carries uncommitted changes is a seventh reading, uncommitted, that apply leaves alone — so the doctor notes nothing there either, and AGENTS.md names that case with the other three.

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]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

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

Comment thread update-shape.py Resolved
Comment thread update-shape.py Resolved
Comment thread update-shape.py Resolved
Copilot AI review requested due to automatic review settings September 12, 2026 18:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

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 --porcelain suppresses ignored untracked files. If an ignored, untracked README.md contains the matching stale line, this check returns clean, so _rewrite_readme changes it and paths later asks git commit -- README.md to commit a path Git does not know. That commit fails after the ledger writes (the CommandFailed path 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 tracked README.md symlink to an external regular file with a matching stale line is therefore treated as clean, and the later ledger.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

Comment thread scripts/shape_materialize.py Resolved
…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]>
Copilot AI review requested due to automatic review settings September 12, 2026 18:38
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openreposhape-2 (openRepoShape-2)

Copilot round 2, head eec8705. Both code findings TAKEN; the third was this PR body and is corrected.

update-shape.py:959 — git status --porcelain hides an IGNORED untracked file: TAKEN. Verified before fixing: a tracked clean README prints nothing, and so does an ignored untracked one — only --ignored distinguishes them (!! README.md). So an ignored README read as clean, would have been rewritten, and would then have handed git commit -- README.md a pathspec git has never heard of, failing after every other byte was written on the one arm of cmd_apply that does not roll back. The check now passes --ignored. test_an_ignored_untracked_readme_is_left_alone_rather_than_half_committed excludes the file through .git/info/exclude rather than .gitignore, because .gitignore is a PINNED copy and editing it would be drift — the test would have been exercising that refusal instead.

update-shape.py:1010 — Path.is_file() follows a symlink: TAKEN. A root may point its README out of itself; written through, the replacement lands in a file outside the repository while the symlink git tracks stays byte-identical, so the commit would not contain the edit it had just made. symlink is now its own reading, asked BEFORE the file is read, left alone and said (README.md: a symlink, untouched — a rewrite would land in its target rather than in this root). test_a_symlinked_readme_is_never_written_through asserts the outside file's bytes are unchanged; it skips on Windows, where a symlink needs a privilege the runner does not have.

tests/test_repo_hygiene.py:503 — the body said 433 -> 440 while the diff says 439 -> 446: TAKEN, and the reason is real rather than a typo: origin/main moved under this branch when #151 landed bump-leg.py's --trailer and raised the same cap 433 -> 439. This branch merged it (f189818) with one conflict, in that docstring; both dated paragraphs stay, in the order the caps moved, and the assertion is the sum. The PR body now says 439 -> 446 and a Review rounds section records it.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

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 that README.md is the project's own content to edit (templates/assembly-root/AGENTS-shape.md:66-67, and the family counterpart at templates/family-root/AGENTS-shape.md:117-118). New projects and holders therefore receive no exception for the managed Shape: 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_readme runs after _write_copies and _repin, so a stale README that is readable but not writable (for example, mode 0444) makes Path.write_bytes raise PermissionError. cmd_apply only rolls back Refusal and does not catch OSError, 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.md is a regular file but read_bytes() raises an OSError (for example, a permission failure or a concurrent removal), the exception escapes after _write_copies and _repin have already modified the tree. cmd_apply only rolls back refusals, so this leaves a partial update; treat OSError like the existing UTF-8 failure and return README_UNREADABLE before 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

Comment thread update-shape.py Resolved
…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]>
Copilot AI review requested due to automatic review settings September 12, 2026 19:25
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

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.

🔵 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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment thread update-shape.py Outdated
Comment on lines +967 to +970
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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]>

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.

🔵 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-object only 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 to HEAD:README.md, classify the line as uncommitted, and skip a valid rewrite. Use the filtered hash form so the CRLF/BOM preservation test also works under the repository's core.autocrlf scenarios.
    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]>
Copilot AI review requested due to automatic review settings September 12, 2026 23:15

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.

🔵 Needs a closer look

Two moderate wording findings and one documentation nit remain unresolved.

Review details

Suppressed comments (3)

AGENTS.md:287

  • README_UNREADABLE is another explicit reading that _classify leaves untouched and reports, but this operational guidance omits it from the list of README states that apply will 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_UNCOMMITTED is reached for any committed-content mismatch with the requested target, so the named SHA can be ahead of the target (for example with check --at), not only behind it. Calling it “behind” gives the operator an incorrect diagnosis; describe the mismatch instead, and keep the corresponding said message 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 apply does 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]>
Copilot AI review requested due to automatic review settings September 12, 2026 23:36
@brettheap

Copy link
Copy Markdown
Contributor Author

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.

update-shape.py:1155 and :1186 — "behind" is not a fact. Right, and it is the same sentence in two readers. 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 now name the two commits in the order stale already names them, and claim no direction between 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>, but the file has uncommitted changes, untouched — ... in apply. stale needed no change; it named both from the start.

test_an_uncommitted_line_ahead_of_the_target_is_not_behind is your example run: a README naming commit B under check --at A, so the line is provably AHEAD of the target, asserting the row names both commits and that the word "behind" appears nowhere in the output. check is where it is reachable end to end, because apply declines a target the pin already names as nothing to do — so the apply half of the same sentence is asserted in test_a_readme_with_changes_of_its_own_is_left_alone_and_not_committed, which runs a real re-pin over an uncommitted README.

AGENTS.md:287 — unreadable was missing from the left-alone list. Taken. _classify has answered unreadable since the round that turned an OSError into a reading rather than a traceback, and a list that does not match the code is a list the reader has to go and check. The word joins it in place; the file's line count is unchanged, so the hygiene cap stays at 446.

Whole suite in the foreground from this worktree at 7874c14: 1184 passed / 1 skipped, 0 failed.

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.

🔵 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.py prints self.match['repository'] in the other-repository branch, so a crafted README can inject terminal controls when check/apply reports it. Restrict this field to the repository-name alphabet already used by REPOSITORY_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]>
Copilot AI review requested due to automatic review settings September 13, 2026 00:04
@brettheap

Copy link
Copy Markdown
Contributor Author

Lane: openreposhape-2 (openRepoShape-2)

Copilot's round on 7874c14 — taken, in 7f25e14. Suppressed comment again, so the answer is here.

scripts/shape_materialize.py:303 — the repository capture took anything that was not a backtick, an ESC among them. Right, and the consequence is the one you name: update-shape.py prints match["repository"] back to whoever ran it — apply's other-repository line and check's row both do — so a README whose line named `<ESC>[2J...` would have played terminal control sequences into that operator's terminal. Worth adding that the file need not be one the operator wrote: shape-doctor.py reads OTHER repositories' READMEs, which is what an estate sweep is.

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: ^Shape: (?P[A-Za-z0-9.-]+/[A-Za-z0-9.-]+)@(?P[0-9a-f]{40})\.\r?$. That is what the family template renders and what octo/Elsewhere is in the tests that exercise the other-repository reading, so every real name still reads. A crafted one is not a Shape: line at all, which is absent — the file untouched, the name unprinted, and no rewrite this tool was talked into. It also subsumes the line-break defect the class was narrowed for two rounds 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.

Whole suite in the foreground from this worktree at 7f25e14: 1185 passed / 1 skipped, 0 failed.

@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.

🔵 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 note is non-empty here, the README has an eligible stale Shape line and apply will rewrite it in the same pin-only update. This reason still says that apply would 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 .gitattributes file. readme_is_committed() then evaluates git status and hash-object using the new filter rules rather than the rules under which the README matched HEAD; for example, a clean CRLF README under the old attributes can become uncommitted after an eol=lf update, 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 using HEAD'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

@brettheap

Copy link
Copy Markdown
Contributor Author

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. shape-doctor.py:1033 — REAL, and it is the same defect one file along from one this PR already fixed. The behind_pin_only reason says "apply would move the pin alone" and then appends {note}, which says apply will also rewrite the README — the row contradicts itself in the one case the note exists for. update-shape.py check had exactly this and was fixed in baa77d0 ("check stops previewing a commit smaller than the one it would make"); the doctor's copy was missed. The fix is the same shape: make the clause conditional on the note. Small, and worth doing.

2. update-shape.py:1886 — REAL AND SUBTLE, and the one I would not have taken blind. _rewrite_readme runs after _write_copies, and .gitattributes IS a pinned copy, so an upstream change to it is on disk before readme_is_committed() asks git anything — and git reads attributes from the working tree. A README that was clean under the old rules can read uncommitted under the new ones, and its stale line is skipped for a reason that has nothing to do with the README. Classification needs only the root, the repository and the target, all of which are known before the first byte is copied, so snapshotting the reading before _write_copies looks right — but it moves a phase inside a rollback-ordered command, and it deserves its own test (an upstream commit that changes .gitattributes, which no fixture here builds yet) rather than a hurried push.

3. update-shape.py:1104 — FAIR, and cheap. The UnicodeDecodeError arm has no deterministic test: test_a_readme_the_os_will_not_read_is_a_reading_rather_than_a_traceback covers the OSError arm and skips where the mode does not stop the user (root, or a filesystem mounted without permissions). A README written as invalid UTF-8 bytes needs no privilege and skips nowhere, and should assert the same three things the other left-alone readings do: unreadable said, the bytes untouched, and the file absent from the commit.

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.

@brettheap
brettheap merged commit b83ba5c into main Sep 13, 2026
6 checks passed
@brettheap
brettheap deleted the feat/apply-rewrites-readme-shape-line branch September 13, 2026 00:22
brettheap added a commit that referenced this pull request Sep 13, 2026
…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]>
This was referenced Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants