Skip to content

feat(bootstrap): a new repo enters the gate, or the gap is loud (#180) - #194

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/bootstrap-repo-into-the-gate
Oct 12, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/bootstrap-repo-into-the-gate

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

A session-created repo did not inherit the org's settings, and every symptom of that was silent (opencharly/.github#180). Three of them were measured on live instances:

  1. The default branch stayed the first-pushed feat/... — so the repo fell into discover_excludes: no required validate / validate check, no CalVer tag, no CHANGELOG. Nothing transitions it back.
  2. The tag-on-merge caller arrived with the first PR — and could never fire for that first merge: the charly/pr-validator run completed before the file existed on main, and GitHub creates ZERO runs for an auto-merge squash. Two sessions hit this independently (plugin-generate-podcast, layer-podcast-audio) and repaired it by hand afterwards (both now carry the caller and have tags — verified).
  3. The bootstrap run reported success while 1 and 2 were true.

This change closes the loop that can be closed in-tree and makes the rest loud:

  • scripts/bootstrap-repo-main.sh now installs the org's canonical, pinned tag-on-merge.yml dispatcher on every main it creates, via the contents API — the capability the same App token already uses to write CHANGELOG/<CalVer>.md to protected main (20 of the last 40 commits in this repo are its CHANGELOG writes). The install is asserted by reading the file back, so a "reported success, nothing on main" path is impossible. The script then prints the three repository SETTINGS it cannot set and counts them: needs_operator_settings=<n>.
  • The three settings stay an operator action, and that is now measured, not assumed. The charly-auto-merge installation's live permissions are actions, contents, deployments, issues, merge_queues, metadata, packages, pages, pull_requests, repository_custom_properties, workflows — no administration — so PATCH /repos/... is genuinely 403 for the App.
  • scripts/org-ruleset.sh verify gains a MEMBERSHIP-INTEGRITY arm. The target set is defined by defaultBranchRef == "main", so the existing per-repo loop could never notice a repo that fell out of it. The arm now fails on any active, non-fork repo whose default is not main, unless it is declared with a reason in lib-org.sh's new declared_non_main_defaults() — the two by-design entries (omarchy-eval-artifacts/runs, pixelflux/av1) that /charly-internals:repo-setup names. It prints a remedy that matches the sub-case (a PATCH when a main ref exists; bootstrap-then-PATCH when none does), names an empty repo distinctly, and refuses to report a clean membership from a failed read.

Consequence, stated before the push. On the live org the arm fails on exactly two repos — plugin-task-old-16365 and plugin-task-zzbootstrap (both default: feat/plugin-task, no main ref, 0 rules on main vs charly's 5) — until they are archived or bootstrapped. Both are abandoned bootstrap experiments; the disposition is operator-owned (archiving is effectively permanent) and is filed as #193. Three empty probe repos (zz-probe3-7319, zz-probe2-13988, zz-bootstrap-probe-xyz) are named informationally, never failed: an empty repo cannot merge anything, and the moment it has a branch the arm fails.

Closes #180.

How tested

Committed head 37f9675 (git rev-parse HEAD; nothing else pushed from it).

# head 37f9675 (git rev-parse HEAD)
$ git diff --stat origin/main...HEAD
 .github/workflows/bootstrap-repo-main.yml | 30 +++++++++---
 scripts/bootstrap-repo-main.sh            | 81 ++++++++++++++++++++++++++++++-
 scripts/bootstrap-repo-main_test.sh       | 36 +++++++++++++-
 scripts/lib-org.sh                        | 23 +++++++++
 scripts/org-ruleset.sh                    | 48 ++++++++++++++++++
 scripts/org-ruleset_test.sh               | 55 +++++++++++++++++++--
 6 files changed, 260 insertions(+), 13 deletions(-)
$ git diff --check origin/main...HEAD; echo "exit=$?"
exit=0

Coverage fails without the change — the NEW tests, run against the OLD scripts (git archive origin/main into a scratch tree, then drop the new test files in):

# new tests, pre-change scripts (origin/main @ d328bdb)
$ bash /tmp/oldcheck/scripts/bootstrap-repo-main_test.sh;  echo "rc=$?"
FAIL: the tag-on-merge caller must be installed on a created main
rc=1
$ bash /tmp/oldcheck/scripts/org-ruleset_test.sh; echo "rc=$?"
FAIL: verify must fail on an active non-fork repo whose default branch is not main
rc=1

The new behaviour, on the committed tree:

# head 37f9675
$ bash scripts/bootstrap-repo-main_test.sh
bootstrap-repo-main_test: all assertions passed
exit=0    # installs the caller for both created mains, asserts the read-back, names the 3 settings
$ bash scripts/org-ruleset_test.sh
org-ruleset_test: all assertions passed (apply/verify/abort)
exit=0    # membership: undeclared non-main FAILS with the right remedy per sub-case;
          # declared-by-design and empty repos are reported and do not fail;
          # a FAILED membership read refuses a clean verdict

The whole offline battery on this head (this repo's change class):

# head 37f9675
$ bash scripts/org-ruleset_test.sh                        -> all assertions passed        exit=0
$ bash scripts/retire-per-repo-dispatchers_test.sh       -> all assertions passed        exit=0
$ bash scripts/retire-per-repo-candy-gates_test.sh       -> all assertions passed        exit=0
$ bash scripts/strip-config-version_test.sh              -> all assertions passed        exit=0
$ bash scripts/bootstrap-repo-main_test.sh               -> all assertions passed        exit=0
$ bash scripts/governance-reconcile.sh --self-test       -> all assertions passed        exit=0
$ bash scripts/governance-reconcile.sh --root "$PWD"     -> checked=26 skipped=53 fail=0 exit=0
$ python3 scripts/check-action-runtimes.py               -> OK (12 workflow files; 5 audited pins; node24)  exit=0
$ python3 scripts/check-action-runtimes.py --self-test    -> OK (Node 20 pins fail)      exit=0

The arm run against the live org (its exact query + its exact branching, read-only — this is the class of verification the change is about):

$ gh repo list opencharly --limit 1000 --json name,isFork,isArchived,defaultBranchRef \
    --jq '.[] | select(.isFork == false and .isArchived == false) | "\(.name)\t\(.defaultBranchRef.name)"'
INFO  zz-probe3-7319 — no default branch yet (empty repo)
FAIL  plugin-task-old-16365 — default 'feat/plugin-task', NO main ref → bootstrap then PATCH (or archive)
INFO  zz-probe2-13988 — no default branch yet (empty repo)
INFO  zz-bootstrap-probe-xyz — no default branch yet (empty repo)
FAIL  plugin-task-zzbootstrap — default 'feat/plugin-task', NO main ref → bootstrap then PATCH (or archive)
INFO  omarchy-eval-artifacts — default 'runs' declared by design
INFO  pixelflux — default 'av1' declared by design
$ gh api repos/opencharly/plugin-task-old-16365/rules/branches/main --jq length   # the consequence
0
$ gh api repos/opencharly/charly/rules/branches/main --jq length                   # control
5

Two supporting measurements the code depends on, both taken live rather than assumed:

$ gh api /orgs/opencharly/installations --jq '.installations[] | select(.app_slug=="charly-auto-merge") | .permissions'
{"actions":"write","contents":"write","deployments":"write","issues":"write","merge_queues":"write","metadata":"read","packages":"write","pages":"write","pull_requests":"write","repository_custom_properties":"write","workflows":"write"}
# no "administration" -> the operator PATCH is real, and the script must name it
$ gh repo list opencharly --json name,defaultBranchRef --jq '.[]|select(.name=="zz-probe3-7319")|"\(.defaultBranchRef)"'
{"name":""}      # an EMPTY repo reports an empty name, not "null" — the arm branches on empty

Not claimed: that the App's contents-PUT succeeds on a repo whose main was created seconds earlier. The mechanism is the one the reusable already exercises org-wide (its CHANGELOG commits), and the script asserts the read-back rather than trusting the response — so if that step ever fails it fails loudly and names the repo.

Rulebook compliance

  • R0 — git-workflow, repo-setup, root-cause-analyzer, strict-policy, agents loaded before this lane's first tool call, plus this repo's AGENTS.md (injected by the worktree): .github is PR-only and its gate/ruleset/template are self-modifying-security surfaces.
  • R1 — every premise of the issue was re-measured rather than inherited; two changed materially (the live population is not empty for the broader class, and the sub-case with no main ref needs a different remedy). The two findings this change surfaces but does not own are filed: #192 (per-repo callers still on Node 20) and #193 (the two abandoned repos). Nothing is parked; nothing is described as "pre-existing".
  • R2 — one declaration of the by-design non-main defaults (declared_non_main_defaults()), one membership rule, one remedy map; the caller template is the repo's single canonical file, not a second copy.
  • R3 — no sleep, no retry, no fallback: a failed membership read fails the verify (exit 1) instead of reading as a clean org; the installer asserts its post-condition instead of trusting a 2xx.
  • R4 — the product changed first: the script installs the caller and the verify arm enforces membership before either docblock is rewritten; the docblocks now describe exactly what runs, including the operator commands.
  • R5 — the retired claim ("the ref alone is enough; set the default branch by hand") is replaced in both surfaces it lived in; no dual path and no per-repo stub is added.
  • R6 — git status clean before and after the commit; worktree .worktrees/dsh-opencharly/dotgithub, branch feat/bootstrap-repo-into-the-gate off fresh origin/main (d328bdb); no force-push, no direct main, no hook bypass.
  • R7 — the new coverage fails without the change (pasted), and the changed branches execute: the offline harnesses drive the install, the read-back assertion, both remedy sub-cases and the failed-read refusal; the arm's exact query was run against the live org.
  • R8 — the live boundary is the real GitHub API; nothing is mocked outside the repo's own established mock-gh policy tests, which are not offered as proof of live behaviour.
  • R9/R10 — no charly runtime source changes. Change class: workflow/shell tooling, gated by this repo's CI (workflow-checks.yml) — the offline battery is pasted above from the committed tree.

Change classification

Hook/workflow infrastructure (org tooling: the bootstrap flow and the ruleset verifier); no charly runtime, deploy target or candy change. Gate: workflow-checks.yml plus the branch's live org reads. Attribution: analysed on a live system — the changed paths ran against real org state and their fixtures drive every new branch, without claiming the CI job of the pushed head has completed.

Filed issues

  • opencharly/.github#192 — the ~438 per-repo tag-on-merge.yml callers still run the mutable Node 20 actions/github-script@v7; #188's removal stopped at this repo (10/10 sampled, code-search floor 106). Needs a sweep + an arm, not this PR.
  • opencharly/.github#193 — the two abandoned repos this arm now fails on (plugin-task-old-16365, plugin-task-zzbootstrap): archive or bootstrap, operator-owned.

Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)

A session-created repo did not inherit the org's settings, and every symptom of
that was silent (#180): the default branch stayed the
first-pushed `feat/...`, so the repo fell into `discover_excludes` with no
required `validate / validate` check and no CalVer tag; the tag-on-merge caller
arrived with the first PR and so could never fire for that first merge; and the
run still reported `success`.

- bootstrap-repo-main.sh installs the org's canonical PINNED tag-on-merge
  dispatcher on every `main` it creates, asserts the post-condition by reading
  the file back, and prints the three repository SETTINGS the App token cannot
  set, counting them as needs_operator_settings=<n>. The App holds no
  `administration` permission (verified against the live installation).
- org-ruleset.sh verify gains a MEMBERSHIP-INTEGRITY arm: every active, non-fork
  repo must default to `main` or be declared with a reason in lib-org.sh's new
  declared_non_main_defaults() (the two by-design entries the repo-setup skill
  names). An undeclared non-main default fails, with a remedy matching the
  sub-case (a PATCH when a `main` ref exists; bootstrap-then-PATCH otherwise);
  an empty repo is named distinctly; and a failed membership read refuses to
  report a clean org.
- Both offline mock-gh harnesses drive the new paths; against the pre-change
  scripts the new assertions fail.

Measured live: `plugin-task-old-16365` and `plugin-task-zzbootstrap` default to
`feat/plugin-task` with no `main` ref and 0 rules on `main` (charly: 5), so
verify now fails on exactly those two until the operator archives or bootstraps
them; three empty probe repos are named informationally.

Filed: #192 (the per-repo tag-on-merge callers still on the
mutable Node 20 actions/github-script@v7) and #193 (the two
abandoned repos).

Closes #180.

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 37f9675d084f8cf8abf8f8368fcff495e9471bc2 (branch: feat/bootstrap-repo-into-the-gate)

Security screen: PASS — no secrets/exfil/eval, no dependency or pin changes, no guardrail weakening. The change is a self-modifying-security surface (.github gate/ruleset/template) but it STRENGTHENS the gate (new membership-integrity arm, read-back assertion, settings counter) and the posting account @aitrawog is in the maintainer set.

Checklist: All applicable rules PASS or NA.

  • A1/A2/A3 — body accounts for all 6 files, names change class (hook/workflow tooling), pastes failing-without-change and passing-with-change output, tier analysed on a live system not inflated; ends with Agent: then Assisted-by:; ## Filed issues lists real #192/#193.
  • R0–R10 — no runtime/bed change (N/A for R9/R10 bed); hard cutover single commit; retired workflow claim swept in same commit; no dual path; git-safety stated; coverage would fail without change (pasted); live boundary is real gh api, no mock offered as live proof.
  • CONC/HC — the two failing live repos are filed (#193), not parked as "pre-existing"; empty repos named, not silently skipped.
  • ARCH/DISP/QUAL/COORD — placement CORRECT (org tooling in .github, no core/sdk/candy drift); no autonomous destroy of a non-disposable resource; no Go/lint surface touched; no cross-PR BLOCKS relationship.

Comments: thread is empty (0 comments) — nothing to disposition.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 12, 2026 21:56
@github-actions
github-actions Bot merged commit 382acd4 into main Oct 12, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 12, 2026
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.

bootstrap-repo-main leaves a new repo with default_branch: seed, silently placing it in discover_excludes — no required validator, no CalVer tags

1 participant