Skip to content

bump-leg: advance ONE leg of an assembly root in ONE lockstep commit - #35

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

brettheap merged 1 commit into
mainfrom
feat/bump-leg

Conversation

@brettheap

@brettheap brettheap commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Lane: codex-intake-shape
Claim: #33 (comment)

What

Closes #33. scripts/bump-leg.py --root <path> --leg spec|code --to <40 hex>, run from a checkout of the standard, moves a root's leg pin the way the lockstep invariant demands and family.py bump already does for members: gitlink, contracts/<role>-pin.yaml (commit: + digests.tree_sha256, nothing else), and every .github/workflows/*.y{a,}ml reference to THIS leg — in ONE commit, with the root's own validators run first and every byte rolled back (including the leg's previous placement) if one goes red. Prints the next step: push the branch, open a pull request.

Refusals, each named: short sha; a commit no remote branch contains (git fetch <sha> exits 0 for an object already local, so reachability is checked, not the fetch); a commit made in the mount and never pushed; a dirty root (tracked changes); a root on its tracking branch or detached; a family holder (family.py bump); an undeclared leg; a missing pin. Exit 0 committed · 1 nothing to do (no empty commit on re-run) · 2 refused.

Evidence

🤖 Generated with Claude Code

Summary by Sourcery

Add a safe command to advance one assembly-root leg while keeping its gitlink, pin metadata, digest, and workflow references synchronized in one validated commit.

New Features:

  • Add scripts/bump-leg.py to advance a project's spec or code leg pin in a single lockstep commit.
  • Update workflow references associated with the selected leg while preserving references to other legs and actions.

Bug Fixes:

  • Prevent partial pin updates by rolling back the leg checkout, gitlink, pin files, workflow changes, and index when validation fails.
  • Reject unsafe or invalid bump scenarios, including unpublished commits, dirty roots, tracking-branch checkouts, missing pins, and undeclared legs.

Enhancements:

  • Recompute the leg tree digest and run the root project's validators before committing.
  • Support dry runs, no-op detection, explicit commit messaging, and pull-request next-step guidance.

Documentation:

  • Document leg advancement workflow, safety requirements, refusal conditions, rollback behavior, and bootstrap follow-up steps in AGENTS.md and README.md.

Tests:

  • Add comprehensive offline coverage for lockstep updates, workflow scoping, dry runs, refusals, rollback behavior, and validator-expression parity.
  • Include the new script in repository hygiene checks.

Advancing a leg is a lockstep commit — the gitlink, `commit:` and the
`sorted-ls-tree-r-v1` digest in `contracts/<role>-pin.yaml`, and every
`.github/workflows/*.y{a,}ml` `<owner>/<leg>/…@<sha>` reference — and
`validate-pins.py` refuses when they disagree. `scripts/family.py bump` did
this for a holder's member pins; nothing did it for a root's LEG pins, so every
project bumped by hand (the xFactory aggregation moved the gitlink alone seven
times in a row). `scripts/bump-leg.py --root <path> --leg spec|code --to <40 hex>`
is that, from a checkout of the standard.

It fetches the leg's remote refs and requires the target to be reachable from a
remote branch (a commit made inside the mount and never pushed is refused as
`bump-leg-commit-local-only`, because `git fetch <sha>` returns 0 for an object
that is already local), checks the leg out AT the commit (bootstrap re-places
it), rewrites only `commit:` and `digests.tree_sha256`, rewrites workflow
references to THIS leg only, stages by explicit pathspec BEFORE the validators
run (recorded_gitlink reads the index first), runs the root's own
`validate-pins.py` and `validate-manifest.py`, and rolls every byte — pin,
workflows, and the leg's previous placement — back if either goes red. It
refuses a short sha, a dirty root, a root standing on its tracking branch (the
NEXT step is a pull request, never a push to the default branch), a detached
root, a family holder (`family.py bump` is the tool), and a leg the manifest
does not declare. Exit 0 committed, 1 nothing to do, 2 refused.

Sixteen offline tests, including the rollback and the reference-regex identity
with the template validator. README 544 -> 573; AGENTS.md 235 -> 266.

Closes #33.

Lane: codex-intake-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 5, 2026 04:47
@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 11 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.

@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@sourcery-ai

sourcery-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces scripts/bump-leg.py to advance exactly one declared assembly-root leg by synchronizing its gitlink, pin metadata, and targeted workflow references in one validated commit, with explicit refusal and complete rollback behavior. Documentation and offline tests describe and verify the workflow, safety constraints, and pull-request handoff.

Sequence diagram for advancing an assembly-root leg

sequenceDiagram
    participant User
    participant BumpLeg as bump-leg.py
    participant Root as AssemblyRoot
    participant Leg as LegRepository
    participant Validators as RootValidators
    participant Git as Git

    User->>BumpLeg: invoke --root --leg --to [--dry-run]
    BumpLeg->>Root: check manifest, branch, cleanliness, gitlink, pin
    BumpLeg->>Leg: fetch and verify remote reachability
    BumpLeg->>Leg: checkout --detach target commit
    BumpLeg->>Root: rewrite pin commit and tree_sha256
    BumpLeg->>Root: rewrite workflow refs for this leg
    BumpLeg->>Validators: validate-pins.py and validate-manifest.py
    alt validator fails
        BumpLeg->>Root: restore files and index
        BumpLeg->>Leg: restore previous placement
        BumpLeg-->>User: refusal, exit 2
    else validation succeeds
        BumpLeg->>Git: commit_once with explicit pathspecs
        BumpLeg-->>User: committed, print push and pull-request step
    end
Loading

Flow diagram for bump-leg safety and commit flow

flowchart TD
    Start([bump-leg.py]) --> Preconditions{Preconditions pass?}
    Preconditions -- No --> Refuse[Refuse with exit 2]
    Preconditions -- Yes --> Remote{Target reachable from leg remote?}
    Remote -- No --> Refuse
    Remote -- Yes --> Plan[Plan gitlink, pin, and targeted workflow changes]
    Plan --> DryRun{--dry-run?}
    DryRun -- Yes --> Preview[Print old to new and write nothing]
    DryRun -- No --> Rewrite[Rewrite files and detach leg at target]
    Rewrite --> Validate[Run validate-pins.py and validate-manifest.py]
    Validate -- Fails --> Rollback[Rollback files, index, checkout, and placement]
    Rollback --> Refuse
    Validate -- Passes --> Commit[Create one explicit-pathspec commit]
    Commit --> Next[Print push branch and open pull request]
Loading

File-Level Changes

Change Details Files
Add a command that advances one assembly-root leg while preserving the lockstep pin invariant in a single commit.
  • Validate the target commit, project type, leg declaration, gitlink, branch state, cleanliness, and remote reachability.
  • Fetch and verify the leg commit, recompute its tree digest, and update only the corresponding pin fields.
  • Rewrite workflow references that target the selected leg while leaving sibling and external action references unchanged.
  • Stage explicit paths, run the root's validators, commit once, and print push/PR follow-up instructions.
  • Rollback pin, workflows, leg checkout, and index on validator or rewrite failure; support dry-run and no-op exit behavior.
scripts/bump-leg.py
Document the leg-advancement workflow, invariants, refusal behavior, rollback guarantees, and post-commit procedure.
  • Add operator guidance for dry-runs, pull-request-only branches, remote reachability, and detached-leg behavior.
  • Describe the command, affected files, workflow matching rules, validator execution, and exit semantics.
  • List the new script in the repository layout.
AGENTS.md
README.md
Add offline coverage for the lockstep bump behavior and its safety boundaries.
  • Test gitlink, pin, digest, workflow, commit-message, detached-leg, dry-run, and no-op behavior.
  • Test selective workflow rewriting, regex parity with the validator, all named refusals, remote reachability, and full rollback.
  • Include the new script in repository hygiene checks and update documentation line caps.
tests/test_bump_leg.py
tests/test_repo_hygiene.py

Assessment against linked issues

Issue Objective Addressed Explanation
#33 Implement a scripts/bump-leg.py command that advances one declared root leg to a specified full 40-hex commit, while refusing invalid, unreachable, dirty, detached, tracking-branch, family-root, undeclared-leg, or missing-pin cases. ✅
#33 Move the leg gitlink, the pin file's commit: and digests.tree_sha256 values, and all workflow references to that leg's repository in one lockstep commit, without changing other leg or action references. ✅
#33 Validate the resulting root, roll back all changes if validation fails, support a no-op/dry-run workflow, leave the leg at the target commit, and document the push/pull-request follow-up. ✅

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

@brettheap
brettheap merged commit cf15ab8 into main Sep 5, 2026
4 checks passed

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

It introduces a substantial new git-manipulating automation tool (with rollback semantics) that is operationally safety-critical and warrants final human review despite strong test coverage.

Pull request overview

Adds a new standard-side maintenance tool, scripts/bump-leg.py, to advance exactly one assembly-root leg (spec/code) while keeping the lockstep invariant intact (gitlink, contracts/<role>-pin.yaml, and workflow @<sha> references), with rollback on validator failures and comprehensive offline test coverage.

Changes:

  • Introduce scripts/bump-leg.py to perform a one-commit lockstep leg pin advance with reachability checks and rollback-on-red validation.
  • Add an offline integration-style test suite (tests/test_bump_leg.py) covering the happy path, dry-run/no-op behavior, workflow rewrite scoping, refusals, and rollback semantics.
  • Document the new “advance a leg” procedure and update repo hygiene caps to reflect the added documentation.
File summaries
File Description
scripts/bump-leg.py New CLI tool to advance one leg pin in a single lockstep commit with validations and rollback.
tests/test_bump_leg.py New offline tests validating lockstep updates, refusal cases, and rollback correctness.
tests/test_repo_hygiene.py Ensures the new script is treated as shipped code; updates README/AGENTS line-count caps.
README.md Documents the new bump-leg workflow and tool listing entry.
AGENTS.md Adds the “Advancing a leg” procedure block and updates the document header scope.
Review details
  • 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.

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.

bump-leg: move a root's leg pin in ONE lockstep commit (gitlink + contracts/<role>-pin.yaml + workflow @<sha>)

2 participants