Skip to content

Drop the fork: setup.sh self-bootstraps from upstream; --org is explicit - #14

Merged
brettheap merged 8 commits into
mainfrom
feat/setup-self-bootstrap
Sep 4, 2026
Merged

brettheap merged 8 commits into
mainfrom
feat/setup-self-bootstrap

Conversation

@brettheap

@brettheap brettheap commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Lane: repo-shape

Brett Heap's ruling: drop the fork.

Rationale

Every scaffolded project already pins opensoft/openRepoShape directly (the
shape pin, contracts/shape-pin.yaml) and update-shape.py reads
straight from upstream, so a per-organisation fork was never load-bearing —
it only ever served as a place to run setup.sh from. Worse, its
origin/upstream-remote org detection was itself a defect: gh repo view
resolving upstream instead of origin could report opensoft for a
perfectly correct fork. The MedxSoft fork has already been deleted.

What changed

setup.sh now self-bootstraps: when it is not running inside a checkout of
openRepoShape (detected via git rev-parse --show-toplevel plus the
presence of scaffold-project.py and contracts/repository-naming.yaml), it
clones opensoft/openRepoShape (default branch, --depth 1; overridable
with $OPENREPOSHAPE_REPO and --shape-ref <commit-or-tag> for a fork or
mirror) into a mktemp -d temporary directory, re-executes itself from there
with the same arguments, and removes the temporary checkout on exit unless
--keep-shape-checkout is given. --org is REQUIRED in this mode — there is
no fork origin to read it from. Run from inside an existing checkout and
behavior is unchanged, except that an origin resolving to opensoft (the
upstream itself) now asks for an explicit --org instead of refusing
outright; --allow-upstream-org is kept only as the guard against
--org opensoft itself.

The one-liner:

curl -fsSL https://raw.githubusercontent.com/opensoft/openRepoShape/main/setup.sh \
    | bash -s -- --org <your-org> --project Atlas

plus a gh api ... | base64 -d | bash -s -- form for organisations that
block raw downloads. README, AGENTS.md and the "from a checkout" developer
path are all updated to match: every instruction to fork is gone, replaced
with the fact that a fork is only ever useful for contributing changes to
the standard itself.

Base branch

This PR is stacked on #13's branch (feat/legs-app-token) so the README
and AGENTS.md edits layer on its already-landed text instead of conflicting
with it. The coordinator will retarget this PR to main after #13 merges.

Tests

python3 -m pytest tests -q → 255 passed (25 in test_setup_sh.py,
including 4 new self-bootstrap tests). shellcheck is not available in this
environment, so it was not run; bash -n setup.sh passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T

Summary by Sourcery

Drop the organisation-specific fork requirement by making setup.sh bootstrap itself from upstream and require explicit target organisation selection.

New Features:

  • Enable setup.sh to self-bootstrap from the upstream repository when run outside an openRepoShape checkout, with optional ref selection and checkout retention.
  • Provide curl-based and GitHub API-based quick-start paths for scaffolding projects without creating an organisation-specific fork.

Bug Fixes:

  • Require an explicit organisation in self-bootstrap mode and prevent mistaken organisation detection from upstream remotes or checkouts.
  • Restrict the upstream-organisation override to explicit attempts to scaffold into opensoft.

Enhancements:

  • Update the contributor and user guidance to make direct upstream use the standard workflow while retaining checkout-based execution for developers.

Documentation:

  • Revise README.md and AGENTS.md to remove fork-first instructions and document self-bootstrapping, explicit organisation selection, and supported invocation paths.

Tests:

  • Add coverage for self-bootstrap execution, temporary checkout cleanup, checkout retention, missing organisation handling, and upstream checkout detection.

brettheap and others added 7 commits September 3, 2026 20:57
The leg-fetch step in the assembly-root validate workflow now tries an
App-minted token first (actions/create-github-app-token, pinned by
commit sha) and falls back to the existing SHAPE_LEGS_TOKEN PAT.

- new job-level env booleans SHAPE_LEGS_APP_SET / SHAPE_LEGS_TOKEN_SET
  (never secrets in an if:)
- a small step reads .gitmodules and emits the comma-separated leg
  names this repository's owner also owns (a foreign-owned leg is
  excluded with a warning: an installation token is per-owner)
- the mint step is guarded by SHAPE_LEGS_APP_SET, continue-on-error:
  false, and a dedicated failure step names both secrets and the
  required installation when a configured App cannot mint
- the leg-fetch step resolves App token -> PAT -> none, exposes which
  source won as step output legs_credential, and the existing degrade
  semantics (naming/manifest always, pins only when legs available,
  fail only when a configured credential still could not fetch) are
  unchanged in shape, just credential-source-aware

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
- mint step is pinned by 40-hex commit sha, scoped to permission-
  contents: read, guarded without secrets in any if:
- job env carries both SHAPE_LEGS_APP_SET and SHAPE_LEGS_TOKEN_SET
- the leg-fetch step references steps.app-token.outputs.token before
  SHAPE_LEGS_TOKEN, and exposes legs_credential: app|pat|none
- a misconfigured App fails loudly, naming both secrets and the
  required installation
- the .gitmodules -> leg-name extraction is exercised as the real
  shell it is: the exact run: body of the 'leg repository names from
  .gitmodules' step is pulled out of the rendered template and run,
  unmodified, against a crafted .gitmodules covering HTTPS, SSH and a
  foreign-owned leg (excluded from the App token, warned about)
- README.md's line-cap governance test moves 331 -> 359 with a new
  dated paragraph, matching the doc it guards

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Replaces the SHAPE_LEGS_TOKEN paragraph in README.md and
templates/assembly-root/README.md with a 'Reading private legs in CI'
section: preferred is a dedicated GitHub App (Contents: Read-only +
Metadata: Read, installed on each consuming org), registered as org
secrets SHAPE_LEGS_APP_ID and SHAPE_LEGS_APP_PRIVATE_KEY; fallback is
the existing fine-grained SHAPE_LEGS_TOKEN PAT. Includes the exact
gh secret set commands for both and the (unchanged) degrade
behaviour, now credential-source-aware.

scaffold-project.py and adopt-project.py's one-line NOTE printed when
a private/internal leg is created now names both options, App first.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
When setup.sh is not running inside a checkout of openRepoShape (detected
via git rev-parse --show-toplevel plus the presence of scaffold-project.py
and contracts/repository-naming.yaml), it now clones opensoft/openRepoShape
(default branch, --depth 1; overridable with $OPENREPOSHAPE_REPO and
--shape-ref) into a temporary directory, re-runs itself from there with the
same arguments, and removes the temporary checkout on exit unless
--keep-shape-checkout is given.

--org is REQUIRED in this self-bootstrap mode: there is no fork origin left
to read an organisation from. Running from inside an existing checkout is
unchanged, except that an origin resolving to opensoft (the upstream itself)
now asks for an explicit --org instead of refusing outright — that refusal
is narrowed to keep --allow-upstream-org as the guard against --org opensoft
itself.

Every scaffolded project already pins opensoft/openRepoShape directly (the
shape pin) and update-shape.py reads straight from upstream, so a
per-organisation fork never did anything but host this script — and its
origin-based org detection was itself a defect.

Ruled by Brett Heap: drop the fork.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Quick start is now one curl | bash line (plus a gh api / base64 form for
orgs that block raw downloads) that self-bootstraps a temporary checkout,
scaffolds, and cleans up. The from-a-checkout form survives as the developer
path. Every remaining mention of forking now says what the standard's
lockstep pin already makes true: a per-organisation fork is only for
contributing changes to openRepoShape itself, never a prerequisite for
running it or for staying current with it.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
The scaffold procedure no longer assumes a fork: it runs the one-liner (or
setup.sh from a checkout) with an explicit --org, still shows the human the
plan and waits for their yes, and never passes --allow-upstream-org on its
own initiative — that flag now guards only --org opensoft itself.

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
- a self-bootstrap end-to-end test: a lone copy of setup.sh outside any
  checkout, $OPENREPOSHAPE_REPO pointed at this checkout, scaffolds and
  removes its temporary shape checkout on exit
- --keep-shape-checkout keeps that checkout and prints its path
- self-bootstrap without --org refuses, naming --org
- running from the upstream checkout (origin == opensoft) without --org
  refuses with the new, narrower message; --org opensoft explicitly still
  hits the old --allow-upstream-org guard unchanged
- README.md's line cap moves 359 -> 388 for the Quick start rewrite

Lane: repo-shape
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_015WekBEXf55Xv64psGe5t3T
Copilot AI lite review requested due to automatic review settings September 4, 2026 01:15
@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR removes the operational need for organisation-specific forks by making setup.sh clone and execute the upstream shape from a temporary checkout, requiring --org when no trustworthy fork origin exists, and updating safeguards, documentation, and tests accordingly.

Sequence diagram for setup.sh self-bootstrap

sequenceDiagram
    actor User
    participant Setup as setup.sh
    participant Git as git
    participant Shape as openRepoShape
    participant Scaffold as scaffold-project.py
    participant Project as AssemblyRoot

    User->>Setup: invoke with --org and project arguments
    Setup->>Git: is_shape_checkout
    alt outside an openRepoShape checkout
        Setup->>Git: clone --depth 1 SHAPE_REPO into mktemp directory
        opt --shape-ref provided
            Setup->>Git: checkout SHAPE_REF
        end
        Setup->>Setup: bash temporary checkout/setup.sh with ORIGINAL_ARGS
        Setup->>Scaffold: scaffold-project.py
        Scaffold->>Project: create repositories and project files
        Setup->>Project: make bootstrap
        alt --keep-shape-checkout
            Setup-->>User: print kept checkout path
        else default cleanup
            Setup->>Git: remove temporary checkout
        end
    else inside an openRepoShape checkout
        Setup->>Setup: detect organisation from origin or explicit --org
        Setup->>Scaffold: scaffold-project.py
        Scaffold->>Project: create repositories and project files
        Setup->>Project: make bootstrap
    end
Loading

Flow diagram for setup.sh organisation resolution

flowchart TD
    Start["setup.sh invoked"] --> Checkout{"openRepoShape checkout?"}
    Checkout -- No --> Explicit{"--org provided?"}
    Explicit -- No --> Reject["Refuse: --org is required"]
    Explicit -- Yes --> Bootstrap["Clone shape to mktemp and re-exec"]
    Checkout -- Yes --> Origin{"origin resolves to opensoft?"}
    Origin -- Yes --> OrgArg{"Explicit --org provided?"}
    OrgArg -- No --> RejectUpstream["Refuse: pass --org"]
    OrgArg -- Yes --> Guard{"--org opensoft?"}
    Origin -- No --> Resolve["Use --org or detect from origin"]
    Bootstrap --> Guard
    Resolve --> Guard
    Guard -- "Yes, without --allow-upstream-org" --> RejectNamespace["Refuse opensoft namespace"]
    Guard -- "No, or explicitly allowed" --> Scaffold["Validate, confirm, scaffold, bootstrap"]
Loading

File-Level Changes

Change Details Files
Replace the fork-dependent entrypoint with a self-bootstrapping workflow that runs from a temporary upstream checkout when needed.
  • Detect an existing openRepoShape checkout using Git and required repository files.
  • Clone upstream or a configured mirror with optional shallow depth and ref selection.
  • Re-execute setup with the original arguments and clean up or retain the temporary checkout based on a flag.
  • Require explicit organisation selection outside a checkout.
setup.sh
Refine organisation detection and upstream safeguards for explicit-organisation operation.
  • Read the checkout's origin directly rather than allowing an upstream remote to influence detection.
  • Require --org for upstream-origin checkouts while permitting explicit organisation use there.
  • Restrict --allow-upstream-org to the intentional --org opensoft case.
setup.sh
Update operator and developer documentation from fork-based setup to one-command self-bootstrap.
  • Document curl and GitHub API invocation forms.
  • Document required --org, temporary checkout behavior, override options, and the contribution-only role of forks.
  • Retain and clarify the from-checkout developer path.
README.md
AGENTS.md
Extend setup coverage for self-bootstrap and adjust documentation hygiene expectations.
  • Add offline tests for temporary checkout creation, cleanup, retention, missing --org, and upstream-origin refusal.
  • Update the README line-count cap and setup test documentation.
tests/test_setup_sh.py
tests/test_repo_hygiene.py

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 changed the base branch from feat/legs-app-token to main September 4, 2026 01:16

@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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="setup.sh" line_range="178-180" />
<code_context>
+	# `--depth 1` only means something over a real transport; git warns and
+	# ignores it for a bare local path (what the tests use via
+	# $OPENREPOSHAPE_REPO), so skip it there rather than clone shallow noise.
+	case "$SHAPE_REPO" in
+	*://*) [ -n "$SHAPE_REF" ] || CLONE_SHAPE_CMD+=(--depth 1) ;;
+	esac
+	CLONE_SHAPE_CMD+=("$SHAPE_REPO" "$SHAPE_CHECKOUT")
+	say "  ${CLONE_SHAPE_CMD[*]}"
</code_context>
<issue_to_address>
**nitpick (performance):** Self-bootstrap clones an SSH/scp-style `$OPENREPOSHAPE_REPO` without `--depth 1`, because the case only adds the shallow-clone option for URLs containing `://`; mirrors configured as `git@host:org/repo.git` therefore download the full repository history.

**Triggers:** When `OPENREPOSHAPE_REPO` uses an SSH/scp-style URL and `--shape-ref` is not supplied.

**Suggested fix:** Recognize SSH/scp URLs as remote transports too, or use Git's transport-independent shallow-clone handling.

```suggestion
	case "$SHAPE_REPO" in
	*://*|*:*/*) [ -n "$SHAPE_REF" ] || CLONE_SHAPE_CMD+=(--depth 1) ;;
	esac
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. The new default executes a script fetched from GitHub and then uses its arguments to create repositories, so a compromised, changed, or incorrectly trusted upstream script could run arbitrary local commands and leave repositories or other side effects behind. Reverting this PR would not undo code already executed or repositories already created.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread setup.sh
Comment on lines +178 to +180
case "$SHAPE_REPO" in
*://*) [ -n "$SHAPE_REF" ] || CLONE_SHAPE_CMD+=(--depth 1) ;;
esac

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick (performance): Self-bootstrap clones an SSH/scp-style $OPENREPOSHAPE_REPO without --depth 1, because the case only adds the shallow-clone option for URLs containing ://; mirrors configured as git@host:org/repo.git therefore download the full repository history.

Triggers: When OPENREPOSHAPE_REPO uses an SSH/scp-style URL and --shape-ref is not supplied.

Suggested fix: Recognize SSH/scp URLs as remote transports too, or use Git's transport-independent shallow-clone handling.

Suggested change
case "$SHAPE_REPO" in
*://*) [ -n "$SHAPE_REF" ] || CLONE_SHAPE_CMD+=(--depth 1) ;;
esac
case "$SHAPE_REPO" in
*://*|*:*/*) [ -n "$SHAPE_REF" ] || CLONE_SHAPE_CMD+=(--depth 1) ;;
esac

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

The new self-bootstrap output can leak credentials by echoing $OPENREPOSHAPE_REPO, and the README’s base64 -d one-liner is not reliably portable to macOS/BSD.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates setup.sh and documentation to remove the per-organisation fork requirement by adding a self-bootstrap mode that clones the upstream shape into a temporary checkout, re-executes setup.sh from there, and cleans up afterward, while making --org explicit when no fork origin exists.

Changes:

  • Add self-bootstrap mode to setup.sh (temp clone, optional --shape-ref, optional --keep-shape-checkout) and adjust org detection/guards accordingly.
  • Update README/AGENTS guidance to remove “fork first” instructions and document the new one-liners.
  • Extend test coverage for the new self-bootstrap behavior and update the README line-count cap.
File summaries
File Description
setup.sh Implements self-bootstrap via temporary clone + re-exec; adjusts org detection and upstream-org safeguards.
README.md Replaces fork-based quickstart with `curl
AGENTS.md Updates agent workflow instructions to align with “drop the fork” and explicit --org guidance.
tests/test_setup_sh.py Adds self-bootstrap tests (temp checkout cleanup/retention, --org required behavior, upstream-checkout behavior).
tests/test_repo_hygiene.py Updates README length cap and documents the cap change rationale.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 2
  • 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 setup.sh
Comment on lines +181 to +183
CLONE_SHAPE_CMD+=("$SHAPE_REPO" "$SHAPE_CHECKOUT")
say " ${CLONE_SHAPE_CMD[*]}"
"${CLONE_SHAPE_CMD[@]}"
Comment thread README.md
Comment on lines +40 to +41
gh api repos/opensoft/openRepoShape/contents/setup.sh --jq .content \
| base64 -d | bash -s -- --org <your-org> --project Atlas
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

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.

2 participants