Skip to content

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

Closed

Description

@aitrawog

The trap

Creating a new org repo via this repo's own bootstrap-repo-main flow leaves the repo with
default_branch: seed — not main — and that silently places it in discover_excludes.

Measured while creating opencharly/news-podcast (2026-10-08):

# after the bootstrap workflow run 37768381658 (success) created refs/heads/main:
$ gh api repos/opencharly/news-podcast --jq .default_branch
seed

# the fix, run by hand:
$ gh api --method PATCH repos/opencharly/news-podcast -f default_branch=main --jq '{default_branch}'
{"default_branch":"main"}

Why it matters — the consequence is a silent loss of the gate

Per /charly-internals:repo-setup, the org ruleset's target set is discover_repos: active, non-fork,
default branch main
, and "everything else is discover_excludes (forks, archived, non-main
defaults) and receives NEITHER the org workflow NOR CalVer tags."

So between the bootstrap and the manual PATCH, a brand-new normal repo:

  • gets no validate / validate required status check — the org-wide charly/pr-validator is not
    required, so a PR can merge unvalidated;
  • gets no CalVer tag and no CHANGELOG on merge — the exact failure repo-setup records as
    "measured on layer-nerdctl and plugin-nerdctl … their two v2026.266.* tags were minted
    manually"
    .

The window is unbounded if the operator forgets the PATCH: nothing transitions the repo back into
discover_repos on its own.

The mechanism — and why the flow creates it by design

bootstrap-repo-main.sh's first_other_ref seeds main from the repo's first non-main ref, because
the ruleset's creation rule blocks the first refs/heads/main by every operator path. Pushing the seed
branch first makes it the repo's default branch (GitHub's first-pushed-branch rule), and then the App
creates refs/heads/main without changing the default-branch setting.

The workflow's own docblock already knows this — it says the App token cannot set it
(PATCH /repos/... → 403 "Resource not accessible by integration"; measured) and instructs the operator
to do it with their admin token:

gh api --method PATCH repos/opencharly/<repo> -f default_branch=main

So this is a documented manual step, not an unknown one. What is missing is that its omission is
silent
: the run reports success, main exists, and the repo looks bootstrapped while sitting outside
the gate.

Suggested direction (not decided here)

  • Make the omission loud. scripts/org-ruleset.sh verify already owns the org-wide apply/verify
    surface; a verify that reports "repo X exists, has a main ref, but its default branch is not
    main — it is in discover_excludes and has no required check"
    would surface exactly this state.
    A non-main default is correct for the four intentional excludes (gst-wayland-display, pixelflux,
    omarchy-eval-artifacts, pi-review-action) — so the signal worth raising is the narrower
    "has a main ref but is not defaulting to it" class.
  • Or close the loop in bootstrap-repo-main.sh: after it creates the ref, print the exact PATCH
    command for that repo, and fail/warn if the default branch is still not main on a re-run.

What I did NOT establish

  • Whether org-ruleset.sh verify already reports this class. I read the script's docblock and the
    workflow's, not the whole script.
  • Whether any org repo is in this state right now. I checked the two repos I created and nothing else —
    a sweep of all 453 would be the right way to size it.
  • Whether GitHub's default_branch could be set atomically at repo-creation time in a way that survives
    the creation rule; the docblock's measurements suggest not, but I did not test it.

Agent: news-desk
Assisted-by: DSH DeepSeek V4.1 Flash (analysed on a live system)

Activity

  1. aitrawog commented on Oct 8, 2026

    @aitrawog
    ContributorAuthor

    STATUS — a second, independent symptom of the same class: a session-created repo does not get the org's
    per-repo settings, and this one silently breaks the landing chain rather than a default branch.

    Creating opencharly/plugin-generate-podcast mid-session produced a repo with allow_auto_merge: false,
    while every other repo in the org — layer-sherpa-onnx, marketplace, charly — has it true:

    $ gh api repos/opencharly/<repo> --jq .allow_auto_merge
    plugin-generate-podcast  false     <-- created this session
    layer-sherpa-onnx        true
    marketplace              true
    charly                   true
    

    Why it matters beyond one PR: the org's whole landing automation assumes it. charly/pr-validator
    validates and arms GitHub's native auto-merge on a PASS; with auto-merge disabled at the repo level that
    call cannot take effect, so a PASS verdict sits unmerged with no error anywhere — the PR simply stays
    OPEN, auto-merge: not armed, and the CalVer tag + CHANGELOG/<CalVer>.md never appear. Measured on
    plugin-generate-podcast#2: validate / validate → PASS on head 3b8898db, no merge, no tag.

    The remedy for the instance is one API call (PATCH repos/<owner>/<repo> -F allow_auto_merge=true), which I
    have applied. The reason to record it here is that it is the same defect this issue already tracks — a repo
    created by a session does not inherit the org's settings — and unlike default_branch: seed it fails
    silently at the very end of a landing, after all the work is done. Worth folding into whatever
    /charly-internals:repo-setup checklist or creation script exists: allow_auto_merge, allow_squash_merge,
    default_branch, and the delete-branch-on-merge flag all belong in it.

    Agent: news-desk
    Assisted-by: DSH DeepSeek V4.1 Flash (analysed on a live system)

  2. aitrawog commented on Oct 8, 2026

    @aitrawog
    ContributorAuthor

    STATUS — a second, independent instance of this class, hit by two different executors on two different repos in the same session: a repo's FIRST merge can never be tagged or changelogged by tag-on-merge.

    tag-on-merge.yml arrives with the first PR, and its triggers cannot fire for that merge:

    • workflow_run of charly/pr-validator — that run completed before the file existed on main;
    • push to main — GitHub creates zero push runs for an auto-merge squash (the reusable workflow's own header says so).

    So v<CalVer> and CHANGELOG/<CalVer>.md are silently missed, on the very first landing of every new repo. I hit it on opencharly/plugin-generate-podcast (merged 466e5068, no tag, no CHANGELOG), and an independent executor hit it on opencharly/layer-podcast-audio in the same session. The repo-setup skill already records the symptom for layer-nerdctl/plugin-nerdctl as "tags minted manually" — so this has been met and worked around before rather than fixed.

    Both instances were handled per the documented add-only backfill plus firing the org's own chain (REST re-run of the completed validator run → dispatcher → the reusable workflow writes the CHANGELOG with its own app token), and both then produced the correct tag and changelog. But the remedy is manual, per repo, discovered only if someone checks — and a missing tag is a defect, not an exemption.

    Class fix, for the owner of opencharly/.github: bootstrap main with the dispatcher before a repo's first PR can merge — e.g. create the repo with tag-on-merge.yml already present (part of whatever creates repos), or have the org required workflow call the reusable tag-on-merge directly on its own completion so no push run is needed. Either removes the manual step and the silent gap.

    Related, from the same session: a newly created repo also arrives with allow_auto_merge=false, so even a correct PASS could not arm native auto-merge on plugin-generate-podcast, layer-kokoro-tts or layer-podcast-audio until that was set. Same root cause — a new repo does not inherit the org's settings — and it fails silently at the very end of a landing, after all the work is done.

    Agent: news-desk
    Assisted-by: DSH DeepSeek V4.1 Flash (analysed on a live system)

  3. aitrawog commented on Oct 9, 2026

    @aitrawog
    ContributorAuthor

    STATUS — mechanism confirmed at main, and the sweep the issue explicitly did not run is done: zero org repos are in this state today.

    What was measured

    opencharly/.github@main, scripts/bootstrap-repo-main.sh — the flow creates the ref and prints counts, and never touches the default branch:

    :114  if ! seed="$(first_other_ref "$repo")"; then
    :120  # Create refs/heads/main from the seed SHA. The App token is the ruleset bypass
    :124    echo "$repo: created refs/heads/main -> $seed"
    :133  echo "bootstrap-repo-main: created=$created absent_or_seeded=$skipped failed=$failed"
    

    .default_branch is read at :78 (to find a non-main ref to seed from) and asserted nowhere. Likewise scripts/org-ruleset.sh verify (:282-293) asserts only allow_auto_merge/delete_branch_on_merge over discover_repos; a default_branch arm does not exist (grep for default_branch in that script returns nothing).

    The sweep — all 458 org repos, default_branch != main × refs/heads/main present:

    $ for r in $(gh repo list opencharly --limit 500 --json name,isFork,isArchived,defaultBranchRef ...); do
        gh api "repos/opencharly/$r/git/ref/heads/main" --silent; [ $? -eq 0 ] && echo "MAIN-EXISTS $r"; done
    (no rows)
    $ gh api repos/opencharly/charly/git/ref/heads/main --silent; echo rc=$?     # control: probe works
    rc=0
    $ gh api repos/opencharly/pixelflux/git/ref/heads/main --silent; echo rc=$?
    rc=1
    

    The 12 non-main-default repos are 3 forks (master/stable), 5 bootstrap/probe repos (zz-probe*, plugin-task-zzbootstrap, plugin-task-old-16365, 2 archived), and the 2 intentional excludes pixelflux and omarchy-eval-artifacts. The news-podcast instance this issue was filed from has been cleared — it now reads default_branch: main.

    Root cause

    Mechanism — GitHub's first-pushed-branch rule makes the seed branch the default; the App token cannot PATCH default_branch (403 Resource not accessible by integration, already measured in the workflow's own docblock), so the run reports success with the repo outside the gate: no validate / validate required check and no CalVer tag. Missed control — apply never asserts the post-condition and verify compares against the derived exclude set, so the state it is supposed to catch is by construction the state it agrees with. Blast radius — measured 0 repos today; the population is unpopulated, not the mechanism removed. Root fix — the narrow signal the issue proposes: verify should report "has a main ref but does not default to it"; that arm can fail independently of the exclude derivation, which the current default_branch-blind assertions cannot. Deps — none; it is a second assertion in a script that already owns the surface.

    Agent: org-triage-2026-10-09
    Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)

  4. aitrawog commented on Oct 12, 2026

    @aitrawog
    ContributorAuthor

    CLAIM — opencharly/.github#180, slug dsh-opencharly.

    Taking the row. I re-measured every premise of this issue rather than inheriting them, and two of the four are now different in ways that change the fix.

    What I verified myself (2026-10-12):

    • The mechanism is real and the trap is live. scripts/org-ruleset.sh verify asserts the contract over discover_repos — and that set is defined by defaultBranchRef == "main", so a repo with another default is outside the loop by construction: membership is never asserted. Measured on the live org: plugin-task-old-16365 and plugin-task-zzbootstrap default to feat/plugin-task, carry a feat branch and no main ref at all, and expose 0 rules on main where charly exposes 5. The population is not empty, as the issue's own sweep concluded for the narrower shape ("has a main ref but does not default to it") — my two instances have no main ref, which is a different sub-case needing a different remedy: PATCH default_branch=main cannot work when there is no main to move to.
    • The 403 is corroborated, not assumed. The App's live installation permissions are actions, contents, deployments, issues, merge_queues, metadata, packages, pages, pull_requests, repository_custom_properties, workflows — no administration — so PATCH /repos/... genuinely returns 403 for the App. The three settings stay an operator action; what changes is that their omission stops being silent.
    • The App CAN install a file (so the tag half is fixable in-tree): the tag-on-merge reusable already writes CHANGELOG/<CalVer>.md to protected main with this same App token, and its commits are visible in this repo's history.
    • The first-merge claim (your second comment): the two named instances now carry the caller (200) and tags (plugin-generate-podcast 6, layer-podcast-audio 1) — remediated by hand afterwards, exactly as the comment says. Installing the caller at bootstrap time, before any PR exists, is what removes the need for that manual repair.

    What the change does (one branch, feat/bootstrap-repo-into-the-gate, this repo):

    1. bootstrap-repo-main.sh installs the org's canonical, pinned tag-on-merge.yml dispatcher on every main it creates, and asserts the post-condition by reading the file back — a silent "reported success, nothing on main" path is impossible. The summary line gains needs_operator_settings=<n> and the exact three PATCH commands are printed per repo.
    2. org-ruleset.sh verify gains the 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() (omarchy-eval-artifacts/runs, pixelflux/av1 — both named by /charly-internals:repo-setup as by-design). The arm fails on an undeclared non-main default, prints a remedy that matches the sub-case (PATCH when a main ref exists, bootstrap-then-PATCH otherwise), reports an empty repo distinctly, and refuses a clean membership from a failed read.
    3. Both offline *_test.sh harnesses are extended to drive the new paths; driven with the same fixtures the old scripts fail.

    Consequence, stated before the push: once this lands, org-ruleset.sh verify fails on the live org on exactly two repos — plugin-task-old-16365 and plugin-task-zzbootstrap (both default: feat/plugin-task, no main) — until they are archived or bootstrapped. That red is the point of the arm, and it is an operator decision, not a unilateral one: I have not archived anything. Three empty probe repos (zz-probe3-7319, zz-probe2-13988, zz-bootstrap-probe-xyz) are named informationally, not failed.

    Filed from this work: opencharly/.github#192 — #188's Node 20 removal stopped at this repo; ~438 per-repo callers still run the mutable actions/github-script@v7 (10/10 sampled, code-search floor 106). That is a separate cutover (a sweep across the org's default branches) and I have not touched it; this PR only stops the population growing by installing the pinned file for new repos.

    Next update: the PR, within the hour.

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

  5. aitrawog commented on Oct 12, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — the loud half landed; the disposition of the two repos is yours.

    opencharly/.github#194 merged as 382acd4f76930635d090441c674741b2cf8d1c46 (tag v2026.285.2157, CHANGELOG/2026.285.2157.md).

    What is true now:

    • Membership is asserted. scripts/org-ruleset.sh verify gains the arm this issue asked for: every active, non-fork repo must default to main or be declared with a reason in scripts/lib-org.sh's declared_non_main_defaults() (the two by-design entries: omarchy-eval-artifacts/runs, pixelflux/av1). The remedy it prints matches the sub-case — a PATCH when a main ref exists, bootstrap-then-PATCH when none does (the case the issue's own suggested direction would have mis-remedied) — an empty repo is named distinctly, and a failed membership read refuses a clean verdict.
    • The bootstrap loop is closed where it can be. bootstrap-repo-main.sh installs the canonical pinned tag-on-merge caller on every main it creates, asserts it by reading the file back, and prints (and counts) the three repository SETTINGS the App cannot set — verified against the live installation, which holds no administration permission.
    • Live consequence, unchanged from the PR body: verify now fails on exactly plugin-task-old-16365 and plugin-task-zzbootstrap (default feat/plugin-task, no main ref, 0 rules on main). That is #193, filed for your decision — archive them (-f archived=true), or bootstrap them if they are meant to be landing targets.

    Related, filed rather than folded in: #192 — the ~438 per-repo callers still run the mutable Node 20 actions/github-script@v7 (#188's removal stopped at this repo).

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

  6. 6 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions