Skip to content

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

Merged
brettheap merged 2 commits into
mainfrom
feat/agents-shape-file
Sep 4, 2026
Merged

brettheap merged 2 commits into
mainfrom
feat/agents-shape-file

Conversation

@brettheap

@brettheap brettheap commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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.md at the assembly root and at the family holder — COPIED VERBATIM and DIGEST-PINNED (COPIED_VERBATIM / FAMILY_COPIED_VERBATIM). Verbatim means no {{placeholders}} ("the paths project.yaml names, spec/ and code/ by default"), so every project's copy digests identically and update-shape.py can 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 in shape-pin.yaml, the exit is upstream then update-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-local unasked); the layout confers NOTHING; declaring descent; the family's add/bump/remove. The holder's file is a separate document because a holder has no legs and no lockstep workflow refs.
  • AGENTS.md and CLAUDE.md at the root — TEMPLATED, not pinned: first line Read 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.md is Read AGENTS.md., byte-identical to this repository's. Each leg gets the same pair (rendered by copy_tree, so no list wiring), 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 stay (root-assistant-instructions); the collision follow-up for THOSE names says "add the pointer line to the existing file, then delete shape/<file>", not "merge". One function, shape_materialize.collision_follow_up, serves plan's prediction and execute'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 under scripts/ is a COPY" sentence is corrected to what is actually pinned.

Deliberate choices

  • The pinned file is 121 lines — the rules it exists for, no more.
  • tests/test_family.py gained an upstream_clone() helper: two tests cloned this repository's HEAD as "the upstream" while the fixture materialized from the working tree, which made any uncommitted templates/family-root/ addition read as upstream-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.
  • Existing shape-pin count expectations moved deliberately (family: exact set now includes AGENTS-shape.md; scaffold: floor 9 → 10).

Evidence

After this lands

Roll out to MedxEHR, MedxGlass, MedxScribe and the InkRouter members with update-shape.py check then apply --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:

  • Ship pinned shape-specific agent guidance and rendered repository-specific assistant instruction pointers across assembly roots, family holders, and both legs.
  • Preserve existing assistant instruction files during adoption while providing an explicit add-a-pointer-line collision follow-up.

Bug Fixes:

  • Keep adoption planning and execution consistent when assistant instruction files collide by sharing the same follow-up messaging.

Enhancements:

  • Document the new agent-facing files and their pinned versus project-owned status in the repository layout and README.
  • Make family update tests represent the working tree used to materialize templates, avoiding false upstream-removal results.

Documentation:

  • Document how agents should work from the assembly root, advance legs, respect pinned files, use shape commands, and avoid treating repository layout or membership as authority.

Tests:

  • Add coverage for pinned-file identity, digest registration, rule content, rendered pointers, leg guidance, family-holder guidance, adoption preservation, and collision follow-ups.

Chores:

  • Adjust shape-pin and README hygiene expectations for the new pinned agent guidance file.

brettheap and others added 2 commits September 4, 2026 09:35
…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]>
Copilot AI lite review requested due to automatic review settings September 4, 2026 13:37
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @brettheap, you've used your own review budget of 250,000 diff characters for the last 7 days.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

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

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

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

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

Flow diagram for preserving assistant instructions during adoption

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

File-Level Changes

Change Details Files
Add pinned, verbatim agent-facing shape rules and rendered repository-specific instruction pointers across assembly roots, family holders, and both legs.
  • Add 121-line assembly-root and separate family-holder AGENTS-shape.md documents.
  • Register pinned files in materialization lists and shape-pin digest rows.
  • Add templated AGENTS.md and one-line CLAUDE.md files with rendered repository and mount-path context.
  • Add leg stubs directing agents to the assembly root and clarifying that leg advancement does not advance the project.
  • Update README and root documentation to describe the new files and pinning model.
templates/assembly-root/AGENTS-shape.md
templates/assembly-root/AGENTS.md
templates/assembly-root/CLAUDE.md
templates/family-root/AGENTS-shape.md
templates/family-root/AGENTS.md
templates/family-root/CLAUDE.md
templates/spec-root/AGENTS.md
templates/spec-root/CLAUDE.md
templates/code-root/AGENTS.md
templates/code-root/CLAUDE.md
scripts/shape_materialize.py
templates/assembly-root/README.md
README.md
AGENTS.md
Make adoption preserve existing project assistant instructions while providing a precise, shared collision follow-up.
  • Keep source AGENTS.md and CLAUDE.md at the project root and materialize shape copies beside them.
  • For assistant-file collisions, instruct users to add the exact shape pointer line and delete the staged shape copy instead of merging or replacing.
  • Centralize collision wording so adopt plan predictions and execute reports remain identical.
adopt-project.py
scripts/shape_materialize.py
tests/test_adopt_e2e.py
tests/test_adopt_plan.py
Extend tests and fixtures to verify byte identity, pin integrity, rendered pointers, adoption behavior, family-holder behavior, and update-shape compatibility.
  • Verify pinned AGENTS-shape.md content, absence of placeholders, SHA-256 rows, and required rule text.
  • Verify root, holder, and leg stubs render correctly and leave source instructions untouched.
  • Add an upstream_clone fixture helper so family update tests use the materialized working tree as the upstream revision.
  • Adjust deliberate shape-pin row and README length expectations.
tests/test_scaffold_e2e.py
tests/test_family.py
tests/test_repo_hygiene.py

Assessment against linked issues

Issue Objective Addressed Explanation
#28 Ship digest-pinned agent-facing shape instructions at assembly roots and family holders, plus rendered AGENTS.md/CLAUDE.md pointer stubs at assembly roots and pointers in both project legs, covering the required workflow, layout, pinning, refusal, descent, and non-authority rules. ✅
#28 Update adopt-project.py so adoption preserves an existing source AGENTS.md/CLAUDE.md, writes the new pinned AGENTS-shape.md, and emits a follow-up instructing the adopter to add the shape pointer line rather than replacing the source instructions. ✅
#28 Extend update-shape.py so it detects an upstream-added pinned file and can add it to an existing project's shape only through an explicit add option. ❌ The PR explicitly leaves update-shape.py untouched and relies on the separate PR #29 for the --add behavior. This PR adds AGENTS-shape.md to the materializer's copy lists, but does not itself implement upstream-added detection or explicit-file addition.

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

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.

🟡 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.md templates (assembly root + family holder) and rendered AGENTS.md/CLAUDE.md pointer 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.

Comment thread tests/test_family.py
Comment on lines +681 to +684
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"))
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