T-U3YQ-fix-two-pre-existing-failing-tests-on-main-task-auto-define
Status: closed/done · Impact: medium · Complexity: small
Two tests fail deterministically on main, so bun test is red on a clean
checkout. Both are test-side defects, not product regressions: one behavioural
fixture invokes a code path that requires an origin remote it never sets up,
and two committed CLI-help golden snapshots drifted from live output as new
config verbs were legitimately added. Make both suites green without changing
any production behaviour.
| Location | Role today |
|---|---|
plugin/skills/task-auto-define/tests/task_auto_define.test.ts#initRepo | Behavioural fixture inits an isolated tmp repo with git init but never adds an origin remote; the test then invokes ensure_ready_mutate.ts --commit-on main, which needs one — so it fails |
plugin/lib/services/git/commit-to-main.ts#commitToMainViaWorktree | Production isolation primitive the --commit-on main path routes through; it runs git fetch origin main and throws git fetch origin/main failed: ... when no origin exists. Correct as written — the fixture is the problem |
plugin/skills/task-ensure-ready/tests/ensure_ready.test.ts#pushToFreshOrigin | Sibling suite’s helper that creates a bare origin.git, adds it as a remote, and pushes main — exactly the setup the failing fixture omits. The pattern to mirror |
plugin/cli/tests/goldens.test.ts | Byte-match asserts live sdlc --help / sdlc --help --advanced stdout against committed goldens; both top-level cases fail on a stale config op list |
plugin/cli/tests/goldens/top-help.txt | Golden for sdlc --help; its config line is missing the get-backlog-policy and get-spawn-policy ops the live CLI now prints |
plugin/cli/tests/goldens/top-help-advanced.txt | Golden for sdlc --help --advanced; carries the identical stale config line |
Proposed
Section titled “Proposed”Both suites — plugin/skills/task-auto-define/tests/task_auto_define.test.ts and
plugin/cli/tests/goldens.test.ts — pass under bun test on a clean checkout
with no origin remote pre-configured. The behavioural fixture stands up its own bare
origin before invoking --commit-on main; the two top-level help goldens are
re-snapshotted from live output so the byte-match holds. No file under
plugin/lib/ or plugin/cli/sdlc.ts (production code) is changed — this is a
test-fixture fix plus a golden re-capture.
Approach
Section titled “Approach”- In
task_auto_define.test.ts, add a bare-origin setup mirroringensure_ready.test.ts#pushToFreshOrigin: after the seed commit (currently at thechore: seed gappy taskcommit, before theparse-touchpointssanity check), create a bareorigin.gitbeside the repo,git remote add origin, andgit push -u origin main. Because the test later re-writes and commits the auto-defined body, ensure the branch that--commit-on mainfetches (origin/main) carries that body commit — either push again after thedocs(tasks): auto-define tidy-foocommit, or move the origin setup so the body commit is included before the mutate call. The mutate step lands its frontmatter-stamp commit onorigin/mainvia the ephemeral worktree; the existing assertions onHEAD/HEAD~1then compare against the local branch, so confirm they still hold (adjust to readorigin/mainif the localHEADno longer advances). - Re-snapshot the two top-level help goldens from live output:
bun run plugin/cli/sdlc.ts --help 2>&1 > plugin/cli/tests/goldens/top-help.txtandbun run plugin/cli/sdlc.ts --help --advanced 2>&1 > plugin/cli/tests/goldens/top-help-advanced.txt. Goldens are captured2>&1(see thegoldens.test.tsheader comment); there is no UPDATE env var or regen script, so the re-capture is manual. Diff the result to confirm the ONLY change is theconfigop list gainingget-backlog-policyandget-spawn-policy— no other drift. - Run both suites and confirm green.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
plugin/skills/task-auto-define/tests/task_auto_define.test.ts | modify | Add a bare-origin fixture (mirror pushToFreshOrigin) so --commit-on main can fetch/push; reconcile the HEAD/HEAD~1 assertions with the origin-backed flow |
plugin/cli/tests/goldens/top-help.txt | modify | Re-snapshot from live sdlc --help (adds get-backlog-policy, get-spawn-policy to the config line) |
plugin/cli/tests/goldens/top-help-advanced.txt | modify | Re-snapshot from live sdlc --help --advanced (same config-line delta) |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1:
bun testofplugin/skills/task-auto-define/tests/task_auto_define.test.tspasses with nooriginremote pre-configured in the environment (the fixture stands up its own remote), and the case “auto-defined spec passes the readiness gate > fills a gap; ensure-ready verifiers reach ENSURE-READY-OK; marker survives” no longer errors withgit fetch origin/main failed. - AC-2:
bun testofplugin/cli/tests/goldens.test.tspasses; thesdlc --helpandsdlc --help --advancedbyte-match goldens match live output. - AC-3: The diff to
top-help.txtandtop-help-advanced.txtchanges ONLY theconfigop list (addsget-backlog-policyandget-spawn-policy); no other line moves. - AC-4: No file under
plugin/lib/and noplugin/cli/sdlc.tsis modified — the fix is confined to the test file and the two golden snapshots.
Out of scope
Section titled “Out of scope”- Changing
commit-to-main.tsproduction behaviour (itsgit fetch origin mainrequirement is correct; the fixture, not the code, is at fault). - Adding a golden-regeneration mechanism (UPDATE env var / script). The goldens are re-captured manually here; automating that is a separate concern.
- The
sdlc task --helphidden-verb golden (task-help.after.txt) and the JSON dispatch goldens — those cases already pass.
Dependencies
Section titled “Dependencies”- none
Discovery context
Section titled “Discovery context”Found while triaging bun test on main. Two deterministic failures:
plugin/skills/task-auto-define/tests/task_auto_define.test.ts— case “behavioural layer: auto-defined spec passes the readiness gate > fills a gap; ensure-ready verifiers reach ENSURE-READY-OK; marker survives”. Observed:mutate stderr: git fetch origin/main failed: fatal: 'origin' does not appear to be a git repository(mutate exit 4, expected 0). Root cause:initReponever creates anorigin, but the test usesensure_ready_mutate.ts --commit-on main, which routes throughcommit-to-main.ts#commitToMainViaWorktreeand fetchesorigin main. The siblingensure_ready.test.tsalready solves this withpushToFreshOrigin; this fixture just omits it. Fails everywhere (not environment-only) — a test-fixture bug, not a product regression.plugin/cli/tests/goldens.test.ts— cases “sdlc --helpbyte-matches its golden” and “sdlc --help --advancedbyte-matches its golden”. Observed diff: liveconfigline readsRegistry-generated ops (get-backlog-policy, get-quality-checks, get-spawn-policy, get-worktree-init, set-quality-checks, set-worktree-init)while the golden still reads the pre-backlog-policy/spawn-policylist. The ops are real (plugin/lib/services/config/ops/get-backlog-policy.ts,get-spawn-policy.ts; added by commitsddcaeaf7andc7712ec2); the last golden re-snapshot (6dd70bbd) predates them. The help output is correct — the goldens are stale. Fix is a re-capture, not a code change.