Skip to content

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.

LocationRole today
plugin/skills/task-auto-define/tests/task_auto_define.test.ts#initRepoBehavioural 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#commitToMainViaWorktreeProduction 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#pushToFreshOriginSibling 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.tsByte-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.txtGolden 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.txtGolden for sdlc --help --advanced; carries the identical stale config line

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.

  1. In task_auto_define.test.ts, add a bare-origin setup mirroring ensure_ready.test.ts#pushToFreshOrigin: after the seed commit (currently at the chore: seed gappy task commit, before the parse-touchpoints sanity check), create a bare origin.git beside the repo, git remote add origin, and git push -u origin main. Because the test later re-writes and commits the auto-defined body, ensure the branch that --commit-on main fetches (origin/main) carries that body commit — either push again after the docs(tasks): auto-define tidy-foo commit, or move the origin setup so the body commit is included before the mutate call. The mutate step lands its frontmatter-stamp commit on origin/main via the ephemeral worktree; the existing assertions on HEAD / HEAD~1 then compare against the local branch, so confirm they still hold (adjust to read origin/main if the local HEAD no longer advances).
  2. 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.txt and bun run plugin/cli/sdlc.ts --help --advanced 2>&1 > plugin/cli/tests/goldens/top-help-advanced.txt. Goldens are captured 2>&1 (see the goldens.test.ts header 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 the config op list gaining get-backlog-policy and get-spawn-policy — no other drift.
  3. Run both suites and confirm green.
LocationKindChange
plugin/skills/task-auto-define/tests/task_auto_define.test.tsmodifyAdd 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.txtmodifyRe-snapshot from live sdlc --help (adds get-backlog-policy, get-spawn-policy to the config line)
plugin/cli/tests/goldens/top-help-advanced.txtmodifyRe-snapshot from live sdlc --help --advanced (same config-line delta)
  • AC-1: bun test of plugin/skills/task-auto-define/tests/task_auto_define.test.ts passes with no origin remote 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 with git fetch origin/main failed.
  • AC-2: bun test of plugin/cli/tests/goldens.test.ts passes; the sdlc --help and sdlc --help --advanced byte-match goldens match live output.
  • AC-3: The diff to top-help.txt and top-help-advanced.txt changes ONLY the config op list (adds get-backlog-policy and get-spawn-policy); no other line moves.
  • AC-4: No file under plugin/lib/ and no plugin/cli/sdlc.ts is modified — the fix is confined to the test file and the two golden snapshots.
  • Changing commit-to-main.ts production behaviour (its git fetch origin main requirement 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 --help hidden-verb golden (task-help.after.txt) and the JSON dispatch goldens — those cases already pass.
  • none

Found while triaging bun test on main. Two deterministic failures:

  1. 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: initRepo never creates an origin, but the test uses ensure_ready_mutate.ts --commit-on main, which routes through commit-to-main.ts#commitToMainViaWorktree and fetches origin main. The sibling ensure_ready.test.ts already solves this with pushToFreshOrigin; this fixture just omits it. Fails everywhere (not environment-only) — a test-fixture bug, not a product regression.
  2. plugin/cli/tests/goldens.test.ts — cases “sdlc --help byte-matches its golden” and “sdlc --help --advanced byte-matches its golden”. Observed diff: live config line reads Registry-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-policy list. The ops are real (plugin/lib/services/config/ops/get-backlog-policy.ts, get-spawn-policy.ts; added by commits ddcaeaf7 and c7712ec2); 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.

← Back to Tasks