Repository navigation
Ship the shape's rules to agents: a pinned AGENTS-shape.md, pointer stubs in the root and legs, and an add-a-line adopt follow-up - #30
Conversation
…tubs in the root and legs, and an add-a-line adopt follow-up
A scaffolded or adopted project carried human READMEs in all four roots and no
agent-facing file. Agents open AGENTS.md/CLAUDE.md, not the README — this
repository's own CLAUDE.md is "Read AGENTS.md." — and an agent standing in a
leg clone saw none of the shape's rules at all.
`templates/assembly-root/AGENTS-shape.md` and `templates/family-root/AGENTS-shape.md`
are COPIED VERBATIM and DIGEST-PINNED: the sentence "never edit a file with a
row in shape-pin.yaml" is worthless if the file saying it can be edited, and
verbatim (no placeholders — "the paths `project.yaml` names") is what lets
every project's copy digest identically. They carry the lockstep rule for
advancing a leg, the drift rule and its upstream exit, what goes where, the
three make targets, the refusals (never --admin, never a direct push, never
--allow-upstream-org/--yes/--accept-local unasked), that the layout confers
NOTHING, how descent is declared, and the family's add/bump/remove.
`AGENTS.md` (first line: `Read AGENTS-shape.md first — the rules of this
repository's shape.`, then the rendered repositories and paths, then the
project's own text) and `CLAUDE.md` ("Read AGENTS.md.") are TEMPLATED, not
pinned: an upstream fix must never overwrite what a project's agents are told
about the project. Each leg gets the same pair, rendered by copy_tree, saying
whose leg it is, where the rules are, and that advancing the leg is not
advancing the project.
Adopt: a source's own AGENTS.md/CLAUDE.md are kept (root-assistant-instructions)
and the collision follow-up for THOSE names says "add the pointer line, then
delete shape/<file>", not "merge" — one function, `collision_follow_up`, used
by plan's prediction and execute's report so the two cannot disagree.
Tests: byte-identity and pin row for the pinned file, the rule strings it
exists for, the stubs' first lines and rendered names, both legs, the holder,
adopt's untouched source files and add-a-line follow-up, gate green. README
513 -> 525.
Closes #28.
Lane: codex-intake-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…/agents-shape-file One conflict, the README cap in tests/test_repo_hygiene.py: both PRs moved it from 513. Both dated notes kept in landing order; the cap is the merged README's actual length. Lane: codex-intake-shape Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
@codex review |
There was a problem hiding this comment.
Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 2 days and 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideThe PR makes the shape's operational rules travel with every scaffolded or adopted repository through verbatim, digest-pinned AGENTS-shape.md files, while rendered AGENTS.md/CLAUDE.md pointers guide agents from roots, holders, and leg clones. Adoption preserves existing assistant instructions and uses one shared add-a-line collision message, with extensive tests covering materialization, pinning, rendering, family handling, and update-shape behavior. Sequence diagram for agent guidance in a shaped projectsequenceDiagram
actor Agent
participant Root as AssemblyRoot
participant ShapeRules as AGENTS_shape_md
participant Leg as LegClone
Agent->>Root: clone --recurse-submodules
Agent->>Root: make bootstrap
Agent->>Root: Read AGENTS.md
Root-->>Agent: Read AGENTS-shape.md first
Agent->>ShapeRules: Read pinned shape rules
Agent->>Leg: Work on leg branch
Leg-->>Agent: Leg instructions point back to assembly root
Agent->>Root: Commit gitlink + role pin + workflow @sha together
Flow diagram for preserving assistant instructions during adoptionflowchart TD
Source[Existing source repository]
Plan[adopt-project.py plan]
Collision{AGENTS.md or CLAUDE.md exists?}
AddLine[Add shape pointer line to existing file]
DeleteStub[Delete shape collision stub]
Execute[adopt-project.py execute]
Report[Report the same collision follow-up]
Source --> Plan
Plan --> Collision
Collision -->|yes| AddLine
AddLine --> DeleteStub
Collision -->|no| Execute
DeleteStub --> Execute
Execute --> Report
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
🟡 Changes recommended
upstream_clone() in tests/test_family.py overlays the working tree onto a clone without handling deletions, which can make the “upstream” fixture incorrect in PRs that remove files.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds agent-facing, digest-pinned shape rules (AGENTS-shape.md) plus rendered pointer stubs (AGENTS.md/CLAUDE.md) across assembly roots, legs, and family holders, and updates adoption collision follow-ups so existing assistant-instruction files are preserved (add-a-line guidance instead of “merge”).
Changes:
- Introduce pinned
AGENTS-shape.mdtemplates (assembly root + family holder) and renderedAGENTS.md/CLAUDE.mdpointer stubs for root/legs/holder. - Centralize adopt collision follow-up wording via
shape_materialize.collision_follow_up()and assert plan/execute consistency in tests. - Update tests and documentation to reflect the new pinned file and ensure family update-shape tests use an “upstream” consistent with the materialized working tree.
File summaries
| File | Description |
|---|---|
| tests/test_scaffold_e2e.py | Adds assertions for pinned agent rules file, pointers, and validator “gate green” behavior; updates shape-pin floor. |
| tests/test_repo_hygiene.py | Updates README line cap to account for the new agent-file documentation. |
| tests/test_family.py | Extends shape-pin expectations for holders, adds holder agent-file tests, and adjusts update-shape fixture upstream cloning. |
| tests/test_adopt_plan.py | Asserts adopt plan predicts the add-a-line follow-up for assistant instruction collisions. |
| tests/test_adopt_e2e.py | Verifies source AGENTS/CLAUDE files remain untouched and follow-ups instruct “add a line” (not merge). |
| templates/spec-root/CLAUDE.md | Adds one-line pointer stub for spec leg. |
| templates/spec-root/AGENTS.md | Adds spec-leg agent guidance pointing to assembly-root rules. |
| templates/family-root/CLAUDE.md | Adds one-line pointer stub for family holder. |
| templates/family-root/AGENTS.md | Adds holder AGENTS.md pointer stub and “below this line is yours” scaffold. |
| templates/family-root/AGENTS-shape.md | Adds pinned holder-specific shape rules (family mechanics, pins, refusals). |
| templates/code-root/CLAUDE.md | Adds one-line pointer stub for code leg. |
| templates/code-root/AGENTS.md | Adds code-leg agent guidance pointing to assembly-root rules. |
| templates/assembly-root/README.md | Documents new agent files in layout and clarifies which files are pinned vs project-owned. |
| templates/assembly-root/CLAUDE.md | Adds one-line pointer stub for assembly root. |
| templates/assembly-root/AGENTS.md | Adds rendered project-owned agent instructions file with first-line pointer to pinned rules. |
| templates/assembly-root/AGENTS-shape.md | Adds pinned, verbatim shape rules for assembly roots (leg advancement, drift policy, refusals, etc.). |
| scripts/shape_materialize.py | Adds pinned/templated file lists for agent docs; introduces SHAPE_POINTER_LINE and collision_follow_up(). |
| README.md | Documents why AGENTS-shape.md is pinned and updates repo layout list. |
| AGENTS.md | Updates this repo’s agent procedure to mention reading AGENTS-shape.md in scaffolded projects. |
| adopt-project.py | Uses shared collision_follow_up() wording so plan prediction matches execute messaging for AGENTS/CLAUDE collisions. |
Review details
- Files reviewed: 20/20 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| subprocess.run(["git", "clone", "-q", str(REPO), str(path)], check=True) | ||
| shutil.copytree(REPO, path, dirs_exist_ok=True, symlinks=True, | ||
| ignore=shutil.ignore_patterns(".git", "__pycache__", | ||
| ".pytest_cache")) |



Lane: codex-intake-shape
Claim: #28 (comment)
What
Closes #28 (PR A of two; PR B was #29). A scaffolded or adopted project carried human READMEs and no agent-facing file; an agent in a leg clone saw none of the shape's rules. Now:
AGENTS-shape.mdat the assembly root and at the family holder — COPIED VERBATIM and DIGEST-PINNED (COPIED_VERBATIM/FAMILY_COPIED_VERBATIM). Verbatim means no{{placeholders}}("the pathsproject.yamlnames,spec/andcode/by default"), so every project's copy digests identically andupdate-shape.pycan say whether it drifted. Content: work from the root, not a leg clone; advancing a leg is ONE commit moving gitlink +contracts/<role>-pin.yaml+ workflow@<sha>; never edit a file with a row inshape-pin.yaml, the exit is upstream thenupdate-shape.py, never update a digest in place; what goes where (contracts the code reads but does not own live in spec); the three make targets; the refusals (never--admin, never a direct push, never--allow-upstream-org/--yes/--accept-localunasked); the layout confers NOTHING; declaring descent; the family'sadd/bump/remove. The holder's file is a separate document because a holder has no legs and no lockstep workflow refs.AGENTS.mdandCLAUDE.mdat the root — TEMPLATED, not pinned: first lineRead AGENTS-shape.md first — the rules of this repository's shape., then the rendered repositories and mount paths, then a line saying the rest is the project's own.CLAUDE.mdisRead AGENTS.md., byte-identical to this repository's. Each leg gets the same pair (rendered bycopy_tree, so no list wiring), saying whose leg it is, where the rules are, and that advancing the leg is not advancing the project.AGENTS.md/CLAUDE.mdstay (root-assistant-instructions); the collision follow-up for THOSE names says "add the pointer line to the existing file, then deleteshape/<file>", not "merge". One function,shape_materialize.collision_follow_up, servesplan's prediction andexecute's report so the plan a human approves matches the message they read afterwards.templates/assembly-root/README.md: the Layout block names the three new files and the "everything underscripts/is a COPY" sentence is corrected to what is actually pinned.Deliberate choices
tests/test_family.pygained anupstream_clone()helper: two tests cloned this repository's HEAD as "the upstream" while the fixture materialized from the working tree, which made any uncommittedtemplates/family-root/addition read asupstream-removed. The helper commits the working tree into the clone; unchanged behaviour on a clean checkout. Any future family-template file would have hit this.AGENTS-shape.md; scaffold: floor 9 → 10).Evidence
python3 -m pytest tests -qon the merged tree (main at 8800d6a, update-shape.py:checkreportsupstream-added;apply --add <path>takes a file the standard gained since the pin #29 included): 396 passed.checkreportsupstream-added;apply --add <path>takes a file the standard gained since the pin #29, the README cap intests/test_repo_hygiene.py: both notes kept in landing order, cap = merged README length (532 → 544).update-shape.pyuntouched — it derives its tables from the materializer's lists, soAGENTS-shape.mdis already re-syncable, and with update-shape.py:checkreportsupstream-added;apply --add <path>takes a file the standard gained since the pin #29's--addit can reach the existing projects.After this lands
Roll out to MedxEHR, MedxGlass, MedxScribe and the InkRouter members with
update-shape.py checkthenapply --at <this merge> --yes --add AGENTS-shape.md, each as a pull request, on the owners' word.🤖 Generated with Claude Code
Summary by Sourcery
Provide every materialized repository with pinned shape rules and project-owned assistant pointers while preserving existing instructions during adoption.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: