Repository navigation
CI: root checks out with the default token; SHAPE_LEGS_TOKEN is used only to fetch the legs - #12
Conversation
…only to fetch the legs
The validate workflow's root checkout carried
token: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}, so a token scoped
only to the leg repositories (the sensible scope for a contents-read
token) broke the ROOT checkout, and a mis-scoped or unapproved token broke
the whole job instead of degrading. Observed on the first real use of the
secret (MedxSoft, runs 33821509948 / 33821512605 on MedxEHR / MedxGlass,
workflow_dispatch on main): SHAPE_LEGS_TOKEN_SET: true, then
actions/checkout@v4 itself failed with a 403 on the root repository, which
is always readable by the default github.token.
Fix: actions/checkout now uses the default github.token (no token:
override), with submodules: false and persist-credentials: false. The
guarded submodule-fetch step reads SHAPE_LEGS_TOKEN via its own env: and,
when present, rewrites both https://github.com/ and [email protected]: leg
URLs to an x-access-token form scoped to that step alone, falling back to
a plain git submodule update --init --recursive when the secret is
absent. legs_available, the warning naming the secret and leg URLs,
always-run naming/manifest, and validate-pins.py-only-when-available are
all unchanged. The only-failure-case message now says the token cannot
read one of the LEG repositories (named from .gitmodules) and that the
root checkout no longer depends on it. secrets stays out of every if:;
actionlint stays green.
Updated README.md and templates/assembly-root/README.md's SHAPE_LEGS_TOKEN
paragraphs accordingly, and added tests asserting the checkout step has no
token: key and that the submodule step references SHAPE_LEGS_TOKEN via
env: and uses insteadOf.
Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Reviewer's GuideThe PR fixes CI failures caused by applying a legs-scoped SHAPE_LEGS_TOKEN to the root checkout by using the default workflow token for the root, authenticating submodules through a step-local Git URL rewrite for HTTPS and SSH URLs, preserving graceful validation behavior, and adding documentation and regression tests. Sequence diagram for root checkout and authenticated leg fetchingsequenceDiagram
participant Workflow
participant RootRepo
participant Git
participant LegRepos
Workflow->>RootRepo: actions/checkout@v4
RootRepo-->>Workflow: Root files via github.token
Workflow->>Git: git submodule update --init --recursive
alt SHAPE_LEGS_TOKEN is present
Git->>LegRepos: Fetch legs via HTTPS/SSH insteadOf rewrite
LegRepos-->>Git: Leg contents
else SHAPE_LEGS_TOKEN is absent
Git->>LegRepos: Fetch legs without token
LegRepos-->>Git: Public legs or fetch failure
end
Git-->>Workflow: legs_available result
Flow diagram for graceful leg-fetch validationflowchart TD
A[Checkout root with github.token] --> B[Fetch submodules best effort]
B --> C{Legs available?}
C -->|Yes| D[Run naming, manifest, and validate-pins.py checks]
C -->|No| E[Run naming and manifest checks]
E --> F[Skip validate-pins.py with warning]
F --> G{SHAPE_LEGS_TOKEN_SET?}
G -->|No| H[Degrade without failing]
G -->|Yes| I[Fail with LEG repository access error]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="templates/assembly-root/.github/workflows/validate.yml" line_range="72-76" />
<code_context>
run: |
set +e
- git submodule update --init --recursive
+ if [ -n "$SHAPE_LEGS_TOKEN" ]; then
+ git \
+ -c "url.https://x-access-token:${SHAPE_LEGS_TOKEN}@github.com/.insteadOf=https://github.com/" \
+ -c "url.https://x-access-token:${SHAPE_LEGS_TOKEN}@github.com/[email protected]:" \
+ submodule update --init --recursive
+ else
+ git submodule update --init --recursive
</code_context>
<issue_to_address>
**issue (bug_risk):** When `.gitmodules` contains a relative leg URL such as `../Project-spec.git`, neither `insteadOf` rule matches it, so Git attempts the fetch without `SHAPE_LEGS_TOKEN`; private relative legs fail even though the token is configured and has access.
**Triggers:** When an adopted root uses relative submodule URLs and the leg repositories are private or internal.
**Suggested fix:** Resolve relative submodule URLs against the root repository's GitHub origin before applying the credential rewrite, or add a rewrite covering the resolved GitHub URL form.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and the workflow now injects a legs-scoped credential into Git URL rewrites, changing which repositories the CI job can authenticate to and potentially exposing or misusing that access if the rewrite or masking behavior is wrong. Reverting stops the behavior for future runs, but any credential exposure or private-leg access that occurred before the revert cannot be undone.
Blocking findings: templates/assembly-root/.github/workflows/validate.yml:76
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if [ -n "$SHAPE_LEGS_TOKEN" ]; then | ||
| git \ | ||
| -c "url.https://x-access-token:${SHAPE_LEGS_TOKEN}@github.com/.insteadOf=https://github.com/" \ | ||
| -c "url.https://x-access-token:${SHAPE_LEGS_TOKEN}@github.com/[email protected]:" \ | ||
| submodule update --init --recursive |
There was a problem hiding this comment.
issue (bug_risk): When .gitmodules contains a relative leg URL such as ../Project-spec.git, neither insteadOf rule matches it, so Git attempts the fetch without SHAPE_LEGS_TOKEN; private relative legs fail even though the token is configured and has access.
Triggers: When an adopted root uses relative submodule URLs and the leg repositories are private or internal.
Suggested fix: Resolve relative submodule URLs against the root repository's GitHub origin before applying the credential rewrite, or add a rewrite covering the resolved GitHub URL form.
There was a problem hiding this comment.
🟡 Changes recommended
There are minor but concrete correctness/clarity issues in the updated workflow comments/diagnostics and an e2e test name/docstring that should be corrected to avoid misleading future maintenance.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the assembly-root CI template to ensure the root repository always checks out using the default workflow token, and scopes SHAPE_LEGS_TOKEN usage to the submodule (legs) fetch step only—preventing legs-scoped tokens from breaking the root checkout while preserving the existing “degrade when legs unavailable” behavior.
Changes:
- Remove the
token:override from the rootactions/checkout@v4step and disable credential persistence (persist-credentials: false). - Fetch leg submodules in a guarded step that conditionally uses
SHAPE_LEGS_TOKENviagit -c url.<...>.insteadOf=<...>rewriting (HTTPS + SSH URL forms). - Update docs and tests to reflect/lock in the new token-scoping behavior and failure messaging.
File summaries
| File | Description |
|---|---|
| templates/assembly-root/.github/workflows/validate.yml | Root checkout uses default token; legs token is step-scoped to submodule fetch; failure messaging updated to reference leg repos. |
| tests/test_scaffold_e2e.py | Adds/adjusts assertions to enforce “no checkout token override” and step-scoped legs token usage. |
| README.md | Clarifies that SHAPE_LEGS_TOKEN is for legs only and the root checkout never uses it. |
| templates/assembly-root/README.md | Mirrors the updated CI/token-scoping guidance for scaffolded assembly roots. |
| tests/test_repo_hygiene.py | Updates README line-cap justification and threshold after doc additions. |
Review details
Suppressed comments (2)
templates/assembly-root/.github/workflows/validate.yml:135
git config --get-regexp '\.url$'exits 1 when there are no matches, and with Actions' defaultbash -e -o pipefailthat would stop the step before it prints any URLs. Since this block is meant to provide diagnostics (and the step already exits 1 explicitly), make the URL listing resilient to missing/malformed.gitmodulesentries.
echo "::error::SHAPE_LEGS_TOKEN is configured but 'git submodule update --init --recursive' still failed. The root checkout does not use this token — it reads with the workflow's default token — so this means SHAPE_LEGS_TOKEN cannot read one or more of the following LEG repositories (wrong token scope, a missing contents:read grant, or a leg URL problem):"
git config --file .gitmodules --get-regexp '\.url$' | while read -r _ url; do
echo "::error:: $url"
done
tests/test_scaffold_e2e.py:360
- This test no longer asserts anything about the root checkout using SHAPE_LEGS_TOKEN (that behavior was removed and is now covered by
test_the_ci_workflow_root_checkout_uses_the_default_token), so the function name and docstring are now misleading. Renaming it will make failures easier to interpret.
fetch = _step_block(workflow, "id: submodules")
assert "git submodule update --init --recursive" in fetch
assert "legs_available=true" in fetch
assert "legs_available=false" in fetch
assert "SHAPE_LEGS_TOKEN" in fetch
- Files reviewed: 5/5 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.
| # `SHAPE_LEGS_TOKEN` is scoped to THIS STEP alone via `env:` — never to | ||
| # the job, never onto the root checkout above — and is used only | ||
| # through a scoped `git -c url.<...>.insteadOf=<...>` rewrite, never | ||
| # echoed or interpolated into a URL that gets printed. Two rewrites | ||
| # cover both submodule URL forms an adopted repository may carry: |



Lane: repo-shape
Observed on the first real use of the
SHAPE_LEGS_TOKENorg secret (MedxSoft, runs 33821509948 and 33821512605 on MedxEHR and MedxGlass, workflow_dispatch on main):SHAPE_LEGS_TOKEN_SET: true, thenactions/checkout@v4itself failed:fatal: unable to access 'https://github.com/MedxSoft/MedxEHR/': The requested URL returned error: 403.Cause:
templates/assembly-root/.github/workflows/validate.ymlsettoken: ${{ secrets.SHAPE_LEGS_TOKEN || github.token }}on the ROOT checkout, so a token scoped only to the leg repositories (the sensible scope for a contents-read token) broke the root checkout, and a mis-scoped or unapproved token broke the whole job instead of degrading. The root repository is always readable by the defaultgithub.token; only the legs need the secret.Fix:
actions/checkoutnow uses the DEFAULTgithub.token(notoken:override), withsubmodules: falseandpersist-credentials: false.SHAPE_LEGS_TOKENwhen present, scoped to that step only, viagit -c "url.https://x-access-token:${SHAPE_LEGS_TOKEN}@github.com/.insteadOf=https://github.com/" -c "[email protected]:" submodule update --init --recursive, with the secret passed viaenv:— never echoed, never in a printed URL — falling back to a plaingit submodule update --init --recursivewhen the secret is absent. SSH-form ([email protected]:) leg URLs are handled by the secondinsteadOf.legs_availableoutput, the warning naming the secret and leg URLs on failure, naming/manifest always run,validate-pins.pyonly when legs are available, and FAIL only when the secret is set but the fetch still failed — the failure message now says the token cannot read one of the LEG repositories (named from.gitmodules) and that the root checkout no longer depends on it.SHAPE_LEGS_TOKEN_SETenv is unchanged.secretsstays out of everyif:; actionlint stays green.templates/assembly-root/README.mdandREADME.md'sSHAPE_LEGS_TOKENparagraphs: the token needs Contents read on the LEG repositories only; the root is read with the workflow's default token.token:key and that the submodule step referencesSHAPE_LEGS_TOKENviaenv:and usesinsteadOf.python3 -m pytest tests -q: 249 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Summary by Sourcery
Use the default workflow token for root checkouts and reserve SHAPE_LEGS_TOKEN for fetching leg repositories.
Bug Fixes:
Enhancements:
Documentation:
Tests: