Skip to content

scripts/bump-leg.py's commit takes a repeatable --trailer, closing the gap #111 left in the third pin-moving tool (#150) - #151

Merged
brettheap merged 1 commit into
mainfrom
feat/bump-leg-trailer
Sep 12, 2026
Merged

brettheap merged 1 commit into
mainfrom
feat/bump-leg-trailer

Conversation

@brettheap

@brettheap brettheap commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

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

Closes #150.

What was wrong

scripts/bump-leg.py is the third of the three pin-moving tools this
standard ships — update-shape.py apply, scripts/family.py bump, and this
one — and it was the only one of the three whose commit could not carry a
Lane:/Co-Authored-By: trailer. #111 → PR #112 (merged 3d3c155) gave
update-shape.py apply --branch and scripts/family.py bump a repeatable
--trailer "<Key>: <value>", validated at the argparse boundary by
scripts/shape_materialize.trailer_line and written through
scripts/shape_materialize.commit_trailers, so a lane's commit lands with
its Lane: line instead of being amended afterwards. bump-leg.py was not
in #111's scope: commit_once (scripts/bump-leg.py:395, before this
change) took (root, message, paths) and built
args = ["git", "commit", "-q", "-F", "-", "--", *paths] with no way to pass
a trailer, and build_parser (:767) defined --root, --leg, --to,
--local-remote-dir and --dry-run — no --trailer.

Today's four leg bumps in the InkRouter estate (IRRS#26, IRSS#26,
2026-09-12) each needed a git commit --amend --trailer … by hand before
the push, because bump-leg.py's own NEXT line has nothing to add a
trailer to — precisely the amend-after-the-fact step #111 existed to delete
for the other two tools.

What landed

commit_once gains a trailers parameter (default ()), appended to
the one commit it writes, in the order given, reusing
shape_materialize.trailer_line as the argparse type= and
shape_materialize.commit_trailers for the write — the same helpers #112
already gave the other two tools, no second implementation. Passed none,
commit_trailers hands the message and the extra git commit arguments
back unchanged ([]), which is what keeps a plain bump's message and argv
byte-identical to every one before it.

--trailer "<Key>: <value>", repeatable, on build_parser, wired
straight through to commit_once from cmd_bump.

--dry-run prints the trailers a real run would end the commit with,
after the old -> new line it already prints, through a new
_print_trailers helper. It is called once cmd_bump already knows there
is something to do — after the nothing to do early return, before the
--dry-run return — so a real run reports the same thing right before it
writes them, and a bump that has nothing to do never claims it will add
trailers it will not.

AGENTS.md's "Advancing a leg" section gains one numbered point (item
6) saying so, mirroring the wording #112 added under "Updating a project's
shape". The line cap in tests/test_repo_hygiene.py moves 433 -> 439, with
the reason in the test's own docstring, as every previous move did.

docs/cli.md is regenerated (python3 scripts/render-cli-reference.py)
for the new --help line; no other tool's --help moved.

No digest-pinned file is touched. scripts/bump-leg.py is standard-side
tooling (it runs from a checkout of this standard, pointed at a project) and
is not in contracts/shape-pin.yaml's copied-file list — confirmed against
the pinned-file list in this fan-out's own brief.

How it was proven

Five new tests in tests/test_bump_leg.py (16 -> 21 functions, 23
collected cases):

  • test_bump_with_two_trailers_ends_the_commit_message_in_the_order_given —
    two independent copies of the same starting clone, one bumped with
    --trailer twice and one without; message_of(trailed) == message_of(plain) + "\n" + "\n".join(TRAILERS) + "\n",
    trailers_of(trailed) == list(TRAILERS), trailers_of(plain) == [], and
    both commits touch the same paths (committed(trailed) == committed(plain)) — the ordering claim and the "no flag changes nothing"
    claim in one assertion, with no pasted copy of today's wording to go
    stale.
  • test_no_trailers_leaves_the_commit_argv_byte_identical — loads
    bump-leg.py in-process (importlib.util.spec_from_file_location, the
    same technique test_update_shape.py's update_shape fixture already
    uses for a hyphenated filename), spies on subprocess.run, and asserts
    the captured git commit argv is exactly ["git", "commit", "-q", "-F", "-", "--", "a.txt"] against a real commit in a real temporary
    repository — the literal argv claim --dry-run cannot show, since it
    makes no commit at all.
  • test_dry_run_prints_the_trailers_after_the_old_to_new_line — both
    trailers appear in --dry-run's stdout at a higher string index than the
    old -> new line.
  • test_dry_run_with_no_trailer_says_so — "trailers none" when
    nothing was passed.
  • test_a_malformed_trailer_is_refused_before_the_project_is_read,
    parametrized over "Lane xfactory-1", "Lane:xfactory-1", "Lane: " —
    exit 2, --trailer and usage: in stderr, and HEAD and the working tree
    are untouched, even though --to and the project are both otherwise
    valid — argparse's own error path refuses before cmd_bump ever runs.

python3 -m pytest tests -q -p no:cacheprovider: 1143 passed, 1 skipped
(1136 on origin/main at the branch point, +7 for the five new tests, one
parametrized three ways). The one skip is
test_adopt_plan.py::test_plan_on_medxehr_matches_the_rulings
(SHAPE_MEDXEHR_CLONE is unset on this machine) — a workstation-specific
real-clone dependency, unrelated to this change.

python3 scripts/render-cli-reference.py regenerated docs/cli.md, and
python3 -m pytest -q tests/test_cli_reference.py (13 passed) confirms it
matches the generator's own output. python3 -m pytest -q tests/test_repo_hygiene.py (48 passed) confirms the new 439-line
AGENTS.md cap.

🤖 Generated with Claude Code

Summary by Sourcery

Allow leg-bump commits to include repeatable validated trailers and preview them during dry runs.

New Features:

  • Add repeatable --trailer "<Key>: <value>" support to bump-leg.py commits.
  • Show commit trailers during --dry-run execution.

Bug Fixes:

  • Close the gap among pin-moving tools by allowing leg-bump commits to carry validated trailers without post-commit amendment.

Enhancements:

  • Reuse shared trailer validation and commit handling while preserving existing no-trailer commit behavior.

Documentation:

  • Document the new leg-bump trailer option in the CLI reference and agent guidance.

Tests:

  • Add coverage for trailer ordering, dry-run output, unchanged no-trailer behavior, and malformed trailer rejection.

…the gap #111 left in the third pin-moving tool (#150)

#111 -> PR #112 gave `update-shape.py apply --branch` and `scripts/family.py
bump` a repeatable `--trailer "<Key>: <value>"`, so a lane's commit lands
with its `Lane:` line instead of being amended afterwards. `bump-leg.py` —
the third pin-moving tool, which writes ONE commit moving the leg gitlink,
`contracts/<role>-pin.yaml` and every workflow `@<sha>` — was not in #111's
scope: `commit_once` took no trailers and `build_parser` had no `--trailer`
at all. Today's four leg bumps in the InkRouter estate (IRRS#26, IRSS#26,
2026-09-12) each needed a `git commit --amend --trailer` by hand before the
push, exactly the step #111 existed to delete for the other two tools.

`commit_once` gains a `trailers` parameter, reusing
`shape_materialize.trailer_line` as the argparse `type=` and
`shape_materialize.commit_trailers` for the write — the same helpers #112
already gave the other two tools, no second implementation. Passed none,
`commit_trailers` hands the message and the `git commit` argv back
unchanged, which keeps a plain bump byte-identical to every one before it.
`--dry-run` now prints the trailers a real run would end the commit with,
after the `old -> new` line it already prints, through a new
`_print_trailers` helper called once `cmd_bump` knows there is something to
do (after the `nothing to do` exit, before the `--dry-run` return) — so a
real run shows the same thing right before it writes them.

`AGENTS.md`'s "Advancing a leg" section gains one numbered point saying so,
mirroring the wording #112 added under "Updating a project's shape"; the
line cap in `tests/test_repo_hygiene.py` moves 433 -> 439 with the reason in
the test's own docstring, as every previous move did. `docs/cli.md` is
regenerated for the new `--help` line.

Five new tests in `tests/test_bump_leg.py`: two trailers end the commit
message in the order given, and the run without the flag carries none — one
assertion comparing a trailed bump against a plain one made from the same
starting clone, so there is no pasted copy of today's wording to go stale.
The `git commit` argv `commit_once` builds with no trailers is asserted
byte-identical to the one it always built, against a real commit, by loading
`bump-leg.py` in-process (`importlib.util.spec_from_file_location`, the same
technique `test_update_shape.py`'s `update_shape` fixture already uses for a
hyphenated filename) and spying on `subprocess.run`. `--dry-run` prints the
trailers after the `old -> new` line (and says `none` when there are none).
A malformed trailer is refused at the argparse boundary before `cmd_bump`
ever runs — HEAD does not move and the working tree stays clean — even
though `--to` and the project are both otherwise valid.

`python3 -m pytest tests -q -p no:cacheprovider`: 1143 passed, 1 skipped
(1136 on `origin/main`, +7 for the five new tests, one of them parametrized
three ways). The one skip, unrelated to this change, is
`test_adopt_plan.py::test_plan_on_medxehr_matches_the_rulings`
(`SHAPE_MEDXEHR_CLONE` is unset on this machine). `python3 scripts/render-
cli-reference.py` regenerated `docs/cli.md`, and `tests/test_cli_reference.py`
(13 passed) confirms it matches. `tests/test_repo_hygiene.py` (48 passed)
confirms the new AGENTS.md cap.

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:53
@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 closes the trailer-support gap in scripts/bump-leg.py by adding repeatable, shared-helper-validated commit trailers, exposing them through the CLI and dry-run output, and covering behavior and validation with tests. Documentation and the generated CLI reference are updated accordingly, while no-trailer commits retain their previous message and git argv.

Sequence diagram for bump-leg commit trailers

sequenceDiagram
    participant User
    participant BumpLeg as bump-leg.py
    participant Helpers as shape_materialize
    participant Git

    User->>BumpLeg: invoke --trailer "Key: value" repeatedly
    BumpLeg->>Helpers: trailer_line(value)
    Helpers-->>BumpLeg: validated trailer list
    BumpLeg->>BumpLeg: cmd_bump(args)
    BumpLeg->>Helpers: commit_trailers(message, trailers)
    Helpers-->>BumpLeg: message and trailer_args
    BumpLeg->>Git: git commit -q -F - trailer_args -- paths
    Git-->>BumpLeg: commit hash
Loading

Flow diagram for bump-leg dry-run trailer reporting

flowchart TD
    A["cmd_bump(args)"] --> B{Changes to apply?}
    B -->|No| C[Return without trailer output]
    B -->|Yes| D["_print_trailers(args.trailer)"]
    D --> E{--dry-run?}
    E -->|Yes| F[Print old to new and trailers]
    E -->|No| G[commit_once with args.trailer]
    G --> H[Commit ends with trailers in given order]
Loading

File-Level Changes

Change Details Files
Adds repeatable commit trailers to the leg-bump workflow using the shared trailer validation and commit helpers.
  • Extends commit_once to append validated trailers while preserving the no-trailer commit message and argv exactly.
  • Adds repeatable --trailer "Key: value" parsing and passes values through cmd_bump.
  • Displays trailer output during dry runs only when a bump will occur, after the old-to-new summary.
  • Adds coverage for ordering, unchanged no-trailer behavior, dry-run output, and argparse rejection of malformed values.
scripts/bump-leg.py
tests/test_bump_leg.py
Updates operator documentation and generated CLI reference for the new leg-bump option.
  • Documents trailer usage and dry-run behavior in the leg advancement instructions.
  • Regenerates the bump-leg.py help section in the CLI reference.
  • Raises the hygiene test line cap with an explanation for the documentation addition.
AGENTS.md
docs/cli.md
tests/test_repo_hygiene.py

Assessment against linked issues

Issue Objective Addressed Explanation
#150 Add a repeatable, validated --trailer "<Key>: <value>" option to scripts/bump-leg.py, pass the trailers to its single commit in the specified order, and preserve the existing commit behavior and argv when no trailers are supplied. ✅
#150 Use the shared shape_materialize.trailer_line and shape_materialize.commit_trailers helpers, and make --dry-run display the trailers that would be written after the existing old-to-new output. ✅
#150 Update the user-facing documentation, including the AGENTS.md guidance for advancing a leg and the generated docs/cli.md reference. ✅

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

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No blocking issues were identified; the remaining documentation note is minor.

Pull request overview

Adds repeatable, validated commit trailers to scripts/bump-leg.py, with dry-run visibility and supporting documentation/tests.

Changes:

  • Reuses shared trailer validation and commit handling.
  • Preserves existing behavior when no trailer is supplied.
  • Updates CLI and agent guidance and adds focused tests.
File summaries
File Summary
tests/test_repo_hygiene.py Updates the documentation line-count cap.
tests/test_bump_leg.py Adds coverage for trailers, ordering, validation, and dry-run output.
scripts/bump-leg.py Implements repeatable --trailer support.
docs/cli.md Regenerates the CLI reference.
AGENTS.md Documents trailer usage for leg advancement.
Review details

Suppressed comments (1)

AGENTS.md:326

  • This documents the new behavior only in the standard checkout's AGENTS.md, but project agents are directed to read the verbatim, digest-pinned templates/assembly-root/AGENTS-shape.md first. That template's advancing-a-leg procedure still omits --trailer and the dry-run trailer output, so existing projects will not receive this guidance through their pinned shape update. Please update the assembly-root shape template and its corresponding pin/update tests as well.
6. **`--trailer "<Key>: <value>"` puts a line on the commit this writes.**
   Repeatable, kept in the order given — the same flag `update-shape.py
   apply` and `family.py bump` already take. `--dry-run` prints the
   trailers it would write, after the `old -> new` line, so the human reads
   them before they land rather than after. A lane passes its `Lane:` line
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@brettheap
brettheap merged commit 779785f into main Sep 12, 2026
6 checks passed
@brettheap
brettheap deleted the feat/bump-leg-trailer branch September 12, 2026 18:08

@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: df536f28f0

ℹ️ 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 scripts/bump-leg.py
Comment on lines +421 to +422
message, trailer_args = commit_trailers(message, trailers)
args = ["git", "commit", "-q", "-F", "-", *trailer_args, "--", *paths]

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 Isolate trailer order from user Git configuration

When the host has trailer.<token>.where or trailer.<token>.ifExists configured, forwarding these values through native git commit --trailer can reorder or discard them even though the dry run prints the supplied order. For example, with trailer.Co-Authored-By.where=before, two Co-Authored-By arguments are committed in reverse order, while ifExists=replace keeps only the last; these behaviors follow Git's documented trailer configuration. Construct the validated trailer block independently of host Git configuration so the commit matches the plan and the documented repeatable, ordered contract.

AGENTS.md reference: AGENTS.md:L322-L327

Useful? React with 👍 / 👎.

brettheap added a commit that referenced this pull request Sep 12, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/bump-leg.py writes its one commit with no Lane:/Co-Authored-By: trailer and takes no --trailer, the gap #111 left in the third pin-moving tool

2 participants