Quality Targets Converge
Role: worker. The convergence close-out loop. Reads coverage, mutation, determinism, and wall-clock measurements; picks the largest gap; dispatches the smallest action that moves it; re-measures; repeats. The operator gates the loop and can waive any individual target.
You have been invoked with the /quality-targets-converge command.
Parse Arguments
Arguments: $ARGUMENTS
- Positional:
<repo-path>. --parent <issue-url>— parent issue URL (or empty).--repo-slug <slug>—.claude/memory/<workflow>/namespace.--workflow <name>— the workflow namespace under.claude/memory/and.claude/plans/. Defaults totest-improve. Callers pass their own namespace so parallel runs stay quarantined.--max-iterations <n>— safety cap. Default 10. The operator can extend mid-run.--refactor-mode <no-refactor|refactor-allowed>— gates whether Step 4's
"coverage gap, no existing seam" action may propose a paired
[Refactor-for-testability] Story (see Step 4). **Default
refactor-allowed** when the flag is absent or carries an unrecognized
value — this preserves today's unconditional-propose behavior for callers
other than /test-improve that don't pass the flag. Whenever the default
fires because the flag was absent or unrecognized, print
"refactor-mode not specified by caller — defaulting to refactor-allowed"
(naming the unrecognized value received, if any) so a caller that forgot
to wire the flag is visible in the run output rather than silently
indistinguishable from one that explicitly wants refactor-allowed.
Path templates. Every filesystem path in the Steps below carries <workflow> as a placeholder; the skill interpolates the resolved --workflow value at run time. There is no literal workflow-name string inside a path.
Steps
1. Load targets
Read .dev-team/quality-targets.json if it exists; otherwise use defaults:
{
"line_pct_min": 90,
"branch_pct_min": 90,
"surviving_mutants_max": 0,
"determinism_runs": 5,
"determinism_required_pass_rate": 1.0,
"wall_clock_target_seconds": null
}
wall_clock_target_seconds = null means "fastest achievable" — the loop tracks it but does not gate on a number.
2. Measure all four dimensions
In one pass before the loop body:
- Coverage — invoke
/coverage-delta <repo> --workflow <workflow>(no--story). Result lives in.dev-team-reports/<workflow>/<slug>/data/coverage-history.json. - Mutation scope — branch-vs-base changed set (cumulative, NOT whole-repo). Phase-8 validation measures mutation only over the code this branch changed, accumulated across every session on the branch — never the whole repo (issue #1208). Resolve the scope in three moves:
1. Resolve the branch base (same idiom as /build's Farley-Score step — skills/build/SKILL.md Step 7 sub-step 1): git merge-base HEAD origin/HEAD, falling back to origin/main, then main, master, develop. Degenerate-base guard (issue #916): treat base == HEAD, or every candidate ref unresolvable (single-branch / no-remote repo where merge-base fails outright, or every commit landed directly on the fallback branch so merge-base resolves to HEAD) as a resolution failure, not a valid base. On resolution failure, fall back to the plan's recorded plan-start anchor — the same anchor /build resolves against (issue #865): python3 ${CLAUDE_PLUGIN_ROOT}/scripts/build_rollback_point.py get-by-symbolic --path .claude/memory/build-rollback.json --symbolic plan-start --repo <repo> --ancestor-of HEAD (the --repo/--ancestor-of args reject a stale plan-start from an unrelated earlier build). If a qualifying entry is found, use its sha as <base>. If none is found, print Branch-base resolution degraded — cannot bound the changed set; scoping to the full in-scope component list this run. and scope to the full in-scope component list only as a surfaced last resort — so a widened run is visible in the output, never a silent whole-repo default.
2. Cumulative changed set: git diff --name-only <base>...HEAD (three-dot — everything the branch added since it forked, across all sessions, not just the last commit).
3. Scope is the source covered by the changed TESTS, not just changed source files. A test-improvement branch commonly changes no production source at all, so mapping only changed *.ts/*.py/etc. would scope to nothing. From the changed set, take every changed test file and resolve the production source it exercises: a co-located X.spec.ts / X.test.ts maps to its sibling X.ts (same basename, same directory); an a11y / contract / integration spec that names no co-located sibling maps to the first-party production modules it imports (parse the spec's import statements, drop third-party paths). Union that resolved-source set with any changed production source files. That union is the mutation --scope.
- Mutation — reuse rule (applied BEFORE the fresh
/mutation-testinginvocation below). The upstream phase already measured mutation per[Component tests]Story; that evidence is in.dev-team-reports/<workflow>/<slug>/data/mutation-history.json. Use it instead of re-running mutation against files (from the branch-scoped set above) the upstream phase already exercised:
1. For each in-scope file, look up the most recent entry in mutation-history.json.
2. Compare the entry's captured_at to the file's last committer date: git log -1 --format=%cI -- <file> (committer date — not file mtime. Uncommitted edits intentionally won't trigger re-measure; convergence runs over committed code).
3. If the entry post-dates the file's last commit AND status != "tool_unavailable", reuse the entry's survivors_after as the current count. Drop the file from the --scope glob passed to the fresh /mutation-testing run below.
4. Otherwise (no entry, stale entry, or prior status: "tool_unavailable") — measure the file fresh in the next bullet. The fresh result is written back to .dev-team-reports/<workflow>/<slug>/data/mutation-history.json as a synthetic entry with story: "converge-<iteration>" so within-iteration reuse works and so the next iteration sees the same evidence the upstream phase would have.
Backward compatibility — mutation-history.json absent. Workflows that pre-date this contract have no upstream mutation evidence. When the file is absent, fall through to measuring fresh: the next bullet runs /mutation-testing over every file in the branch-vs-base changed set defined above — the reuse rule is opportunistic, not required, but absence of history never widens the run back to whole-repo.
- Mutation (fresh measurement on files the reuse rule didn't cover). Invoke
/mutation-testing <repo> --scope <remaining-files> --workflow-managed-approval --emit-json <tmp>(where<remaining-files>is the branch-scoped set minus the files the reuse rule covered). Parse the surviving-mutant list from its JSON output (filterstatus: "equivalent"ANDstatus: "accepted"— both carry areasonand neither counts against convergence). Capture file + line + mutant operator for each survivor. Write back each freshly-measured file as a synthetic entry to.dev-team-reports/<workflow>/<slug>/data/mutation-history.json(see reuse rule above) via temp-file-then-rename (write to<path>.tmpthenmv -f <path>.tmp <path>) — the same idiom