Repository navigation
feat(ci): bootstrap the initial main on empty org repos - #112
Conversation
The org ruleset's creation rule blocks a new repo from creating its first main by every operator path (push, contents API, auto_init, rename). The ruleset's only bypass actor is the charly-auto-merge App, so add an App-token workflow + script that creates refs/heads/main via the git-data refs API (no branch-must-exist precondition), never moving an existing main. - scripts/bootstrap-repo-main.sh — create main from the default-branch HEAD - scripts/bootstrap-repo-main_test.sh — offline mock-gh test - .github/workflows/bootstrap-repo-main.yml — App-token dispatch - README.md — document the gap + the one-time bootstrap - validator-harness.yml — run the new offline test on every PR Assisted-by: opencode deepseek-v4.1-flash
Review — BLOCKHead SHA: Change class: Security screen: FINDING — T3 command injection in the new workflow (block 2 below). Blocks
Dispositions on non-blocking items
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…concile the contents-API status codes - workflow: expand the workflow_dispatch repos input via a quoted env var, never interpolated into run: (the step holds the org-wide App token). - docs: document the two measured contents-API outcomes per repo state (409 on a repo with no refs; 404 on a repo with other refs but no main) consistently in bootstrap-repo-main.sh and README.md. Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: Security screen: PASS — the prior T3 command-injection is resolved in the current diff. The Blocks
Comment disposition — prior Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)
Review — PASSHead SHA: Security screen: PASS — no Comments: both prior BLOCKs
Checklist: All applicable rules PASS or NA. Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
Summary of changes
The org-wide ruleset (
#109) carries thecreationrule onrefs/heads/main, so a brand-new repo cannot create its firstmainby any operator path. Measured on the three repos created after the ruleset landed:The ruleset's only bypass actor is the
charly-auto-mergeApp, and a repo with nomaincannot produce the requiredvalidate / validatecheck (the required workflow does not exist on the default branch) — a genuine deadlock reached from a clean start.This PR adds the missing bootstrap, in the same shape the org already uses for
retire-per-repo-dispatchers(an App-token workflow for a write an operator token may not make):scripts/bootstrap-repo-main.sh— createsrefs/heads/mainfrom the repo's current default-branch HEAD viaPOST /git/refs(the git-data API has no branch-must-exist precondition; the contents API does). It never moves an existingmain(skipped), skips a repo with no non-main ref to seed from, and is idempotent.GH_TOKENis required; a repo-discovery failure aborts.scripts/bootstrap-repo-main_test.sh— the offline mock-ghtest (the repo's established pattern), covering: seed from the defaultfeat/x, seed from a non-main default, skip-already-has-main, skip-nothing-to-seed, idempotent re-run, explicit-repo targeting, discovery-failure abort, and missing-GH_TOKENabort..github/workflows/bootstrap-repo-main.yml— mints thecharly-auto-mergeApp token and runs the script (optionally scoped to named repos). Needs only the App's existingcontents: write; noworkflows: write.reposworkflow_dispatchinput is passed through the environment (env: REPOS) and expanded quoted (read -ra targets <<<"$REPOS"; "${targets[@]}"), never interpolated into therun:body. Raw${{ inputs.repos }}insiderun:is unsanitized, and this step holds the org-wide App token (the ruleset bypass credential), so an injectedx; <cmd>would be a real escalation — the quoted-env form removes the injection. The input only ever reaches the script as repo-name arguments, and the script resolves each name against the org (repos/$ORG/$repo); it neverevals an argument.workflow_dispatchalready requires write access.README.md— documents the gap, the measured evidence, and the two-command bootstrap (App creates the ref; the operator sets the default branch with an admin token)..github/workflows/validator-harness.yml— runs the new offline test on every PR.Closes / relates to: closes #111. Follow-up to #109 (the ruleset that introduced the
creationrule) and #110 (the App-token precedent).Breaking change + rollback: none — purely additive (a new script, its test, a workflow, and README prose). Rollback = revert this commit.
Change class
hook/workflow(org-wide CI configuration: a workflow + its owner script).How R10-tested — exact gate, commands, and pasted output
ghscript tests, run in CI byvalidator-harness.ymlon every PR. There is nocharly checkbed for a.githubscript change, and none is claimed. The script's core assumption (an App token can createmainwhere an operator cannot) was proven on a live spike before the script was written (RDD — see the RDD line below).N/A — no charly bed exists for a .github script/CI change class(the validator-harness workflow is the committed gate).N/A — no charly binary involved(bash + GitHub Actions YAML).creationrule (spike workflow onlayer-qdrant, run 35761704739):{"default_branch":"main"}), which is why the README documents both steps.N/A — a repo-bootstrap ref creation, not a shared-state change.1. Fresh-rebuild gate output:
2. Each changed code path executing:
Plus the LIVE App-token ref creation above (run 35761704739).
3. Docs-only evidence:
Attribution tier
fully tested and validated— the changed script path (the git-data ref creation) executed live against the real org with the real App token (the ref was created), and the offline coverage gate passes. The workflow YAML itself is validated by GitHub on push (the spike workflows ran successfully under the samecreate-github-app-tokenaction andworkflow_dispatch/pushgrammar).Harness rulebook compliance — state HOW each is satisfied
/charly-internals:git-workflow(branch/PR-only landing),/charly-internals:strict-policy(RDD + live-or-skip), and/charly-check:check(the bed/gate-by-change-class mapping) loaded.creationrule having no bootstrap path for an empty repo (measured on four paths + the org-wide repo scan), not classified as a flake; fixed at the root with a bypass-actor bootstrap. The review's second block (a documentation divergence on the contents-API status code) is fixed here: the two measured codes are now documented per condition (409 on a repo with no refs; 404 on a repo with other refs but nomain) consistently across the script header, the README, and this body. No warnings.main— the org ruleset'screationrule has no bootstrap path #111 tracks the same fix.retire-per-repo-dispatchers_test.shpattern rather than inventing a second harness style.N/A — purely additive, no identifier removed or renamed. No false claim is swept: no existing doc asserted a bootstrap path existed.git statuschecked before staging; no force-push; landed via afeat/branch + PR (not a direct push tomain).N/A — no charly runtime path changed; the live proof is the App-token ref creation above.N/A — no generated artifact.N/A — no charly binary, no new runtime OS dep..githubscript; per the change class the non-runtime standards apply. Coverage ships and would FAIL without the script:bootstrap-repo-main_test.shasserts each behaviour (seed, skip, idempotent, explicit-target, abort paths) and runs in CI.mainunder thecreationrule?") was proven by a live spike BEFORE the script was written; the spike also proved the two negative cases (contents API and default-branch PATCH). No bed on a settled item. ADEN/A — no candy changed. SDDN/A — no schema/.cue.N/A — org CI config, not core/sdk.N/A — no destroy/rebuild.N/A — no Go. Shell syntax checked (bash -n) both files.N/A — opencharly/.github keeps no CHANGELOG/ on this branch's diff; the tag-on-merge workflow writes it from this PR body(verified the repo's CHANGELOG entries are all written post-merge bytag-on-merge,docs: add CHANGELOG ... for PR #N).Assisted-by: opencode deepseek-v4.1-flash (fully tested and validated)