Repository navigation
CI: check out private legs with SHAPE_LEGS_TOKEN, degrade clearly without it - #7
Conversation
…hout it The assembly root's validate.yml did `actions/checkout` with `submodules: true`, so a private-legs project's required check hard-fails in checkout itself the instant a leg cannot be cloned with the default GITHUB_TOKEN — observed on the first real adoption (MedxSoft/MedxEHR #7), where `MedxEHR-spec`/`MedxEHR-code` are private siblings. Checkout now passes `token: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}` and never fetches submodules itself. A new failure-capturing step attempts `git submodule update --init --recursive`, sets `legs_available`, and prints a clear notice naming the secret and the leg URLs on failure. The naming and manifest validators always run; the lockstep pin validator (which needs the legs' trees) runs only when legs_available=true, otherwise a warning annotation explains the skip. The job fails only when SHAPE_LEGS_TOKEN is set and the fetch still failed — misconfiguration must not be silent. Documents the SHAPE_LEGS_TOKEN requirement in both READMEs, and has scaffold-project.py / adopt-project.py execute print a one-line reminder when they create private or internal legs. Adds a template-render test asserting the token expression and every guarded step, updates the pre-existing submodule-checkout test for the new structure, and bumps the README line cap (245 -> 265) for the added section. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
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 12 hours and 32 minutes by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuideUpdates the generated validation workflow to use SHAPE_LEGS_TOKEN for private submodules, capture fetch failures, preserve checks that do not require leg working trees, and clearly distinguish absent-secret degradation from misconfigured-secret failure; documentation, project-creation reminders, and structural tests are updated accordingly. Sequence diagram for validation with private leg checkoutsequenceDiagram
participant GitHub as GitHub Actions
participant Checkout as actions/checkout
participant Git as Git submodules
participant Checks as Naming and manifest validators
participant Pins as Lockstep pin validator
GitHub->>Checkout: checkout(token: SHAPE_LEGS_TOKEN || github.token, submodules: false)
Checkout-->>GitHub: Persist resolved credential
GitHub->>Git: git submodule update --init --recursive
alt legs fetched
Git-->>GitHub: legs_available=true
GitHub->>Checks: Run naming policy and project manifest
GitHub->>Pins: Run validate-pins.py
else legs unavailable
Git-->>GitHub: legs_available=false and warning with leg URLs
GitHub->>Checks: Run naming policy and project manifest
GitHub->>GitHub: Warn and skip lockstep pins
alt SHAPE_LEGS_TOKEN is set
GitHub-->>GitHub: Fail job for token misconfiguration
else SHAPE_LEGS_TOKEN is absent
GitHub-->>GitHub: Degrade without failing
end
end
Flow diagram for validation failure handlingflowchart TD
A[Checkout repository without submodules] --> B[Fetch submodules with persisted credential]
B -->|Success| C[Run naming and manifest checks]
C --> D[Run lockstep pin validator]
B -->|Failure| E[Emit warning with SHAPE_LEGS_TOKEN guidance and leg URLs]
E --> C
C --> F[Skip lockstep pin validator with warning]
F --> G{SHAPE_LEGS_TOKEN is set?}
G -->|No| H[Pass with degraded validation]
G -->|Yes| I[Fail for misconfigured token]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
🟡 Changes recommended
The new workflow’s “best-effort” submodule failure path can still fail the job under default runner bash -o pipefail, and one of the updated workflow assertions in tests is currently ineffective due to indentation mismatches.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the assembly-root validation workflow template to handle projects whose “leg” repositories (spec/code) are private/internal by authenticating submodule fetches via an optional SHAPE_LEGS_TOKEN, and by degrading gracefully when that secret is absent.
Changes:
- Update
templates/assembly-root/.github/workflows/validate.ymlto (a) passtoken: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}to checkout, (b) fetch submodules in a best-effort step, and (c) guard pin validation / fail only on misconfigured secrets. - Add/adjust tests to assert the rendered workflow structure (token expression, guarded steps, and new submodule-fetch step).
- Document
SHAPE_LEGS_TOKENin both root and assembly-root READMEs, and print a reminder from scaffold/adopt flows when creating private/internal legs.
File summaries
| File | Description |
|---|---|
| tests/test_scaffold_e2e.py | Updates and adds assertions that the rendered validate workflow uses the token fallback and guarded pin checks. |
| tests/test_repo_hygiene.py | Increases the README line cap with a dated rationale tied to the new documentation. |
| templates/assembly-root/README.md | Documents why/when SHAPE_LEGS_TOKEN is needed and how validation degrades without it. |
| templates/assembly-root/.github/workflows/validate.yml | Implements token fallback checkout, best-effort submodule fetch, guarded pin validation, and conditional failure on misconfigured secrets. |
| scaffold-project.py | Prints a reminder about configuring SHAPE_LEGS_TOKEN when legs are created private/internal. |
| README.md | Adds project-level documentation for SHAPE_LEGS_TOKEN and validation workflow behavior. |
| adopt-project.py | Prints a reminder about configuring SHAPE_LEGS_TOKEN when adoption creates private/internal legs. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| echo "::warning::submodule checkout failed (git exit $status). If the legs are PRIVATE or internal sibling repositories, the default GITHUB_TOKEN cannot read them. Set SHAPE_LEGS_TOKEN — a fine-grained PAT or GitHub App installation token with contents:read on the legs — as a repository or organisation secret. Leg URLs:" | ||
| git config --file .gitmodules --get-regexp '\.url$' | while read -r _ url; do | ||
| echo "::warning:: $url" | ||
| done |
| # defect: it hard-fails the whole job the instant a private leg cannot | ||
| # be cloned. The fetch is now a separate, failure-capturing step; only | ||
| # the checkout step itself must not carry the old setting. | ||
| assert "with:\n submodules: true" not in workflow |
| lines = workflow.splitlines() | ||
| start = next(i for i, line in enumerate(lines) if marker in line) | ||
| # walk back to the start of this step (` - ` at 6-space indent) | ||
| while not lines[start].startswith(" - "): | ||
| start -= 1 | ||
| end = start + 1 | ||
| while end < len(lines) and not lines[end].startswith(" - "): | ||
| end += 1 | ||
| return "\n".join(lines[start:end]) |



Observed failure
On the first real adoption (MedxSoft/MedxEHR #7), the assembly root's
.github/workflows/validate.yml— materialized fromtemplates/assembly-root/.github/workflows/validate.ymland digest-pinnedas a copied shape file in
contracts/shape-pin.yaml— doesactions/checkoutwith
submodules: true.MedxEHR-spec/MedxEHR-codeare private siblingrepositories; the default
GITHUB_TOKENcannot clone them, socheckoutitself fails and the required
validatecheck is red on every pull requestof a project with private legs.
Mechanism of the fix
actions/checkoutnow passestoken: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}and never fetchessubmodules itself (
submodules: false) — a fine-grained PAT or GitHub Appinstallation token with
contents:readon the legs, falling back to thedefault token for public-legs projects.
fetch the legs (submodules)step attemptsgit submodule update --init --recursive(reusing the credentialactions/checkoutpersisted), with its failure captured rather than letthrough as a step failure. It sets
legs_availableand, on failure,prints a clear notice naming
SHAPE_LEGS_TOKENand the leg URLs.working tree). The lockstep pin validator — which recomputes each leg's
tree digest and needs the legs actually checked out — runs only when
legs_available == 'true'; otherwise a warning annotation explains theskip.
SHAPE_LEGS_TOKENis set and the fetch stillfailed — an absent secret degrades quietly on a private-legs project that
hasn't configured one yet; a present, misconfigured one must not.
The secret
SHAPE_LEGS_TOKEN— a repository or organisation secret, a fine-grainedPAT or GitHub App installation token with
contents:readon the legs.Documented in both
README.mdandtemplates/assembly-root/README.md;scaffold-project.pyandadopt-project.py executenow print a one-linereminder when they create a private or internal leg.
Tests
Added a template-render test asserting the exact token expression and every
guarded step exist (string/YAML-structure assertions, no live run), and
updated the pre-existing submodule-checkout assertion for the new structure.
Nothing else was bumped — the workflow's actions stay pinned exactly as they
were (
actions/checkout@v4,actions/setup-python@v5).🤖 Generated with Claude Code
https://claude.ai/code/session_01HGKwdQsmvRZx4fGQESdFGZ
Summary by Sourcery
Make validation workflows handle private or internal leg repositories gracefully while requiring configured credentials to work correctly.
New Features:
Bug Fixes:
Enhancements:
CI:
Documentation:
Tests: