Reconcile a repo that an EARLIER kit version already onboarded. It re-runs the classification
against today's rules, corrects the existing manifest rather than replacing it, migrates it to
the current schema, fills only the gaps in test coverage, and regenerates the report. It is the
idempotent successor to coverage-init for repos that already have a manifest, tests, and a
report.
-
Detect the prior state. Record what exists: the manifest (and any schema_version), the
test projects and roughly how many tests, the last report, and, if discoverable, which kit
version produced them. Note whether the manifest uses legacy prose CARVE-OUT: (a v1 signal)
and whether any exclusion is a folder glob carrying carve-outs (an ambiguity the current gate
flags).
-
Re-sweep the whole repo. Run the classification sweep EXACTLY as coverage-init step 4:
enumerate every source file, clear coverage/sweep/, write files.json, and run the
coverage-sweep workflow at a user-chosen parallelism with the CURRENT rubric (the table in
coverage-init, including the exclusion-signal principle and the DbContext-seam note). This
is what surfaces the misclassifications the old manifest baked in. The sweep is read-only on
source.
-
Diff the sweep against the existing manifest (single, at main). Read the on-disk evidence
(coverage/sweep/chunk-*.json) and the current manifest. Produce a reconciliation, not a
rewrite. Classify every delta into:
- False exclusion to fix: the sweep found a testable method inside a file the manifest
excludes (the DbContext-injected-service case, a mixed folder collapsed to one glob, a
branching validator under a
**/Model/** glob). Add the carve-out, or promote the file to
target, per the current rubric.
- Schema migration: legacy prose
CARVE-OUT: becomes a structured carve_outs: list;
a carve-out-bearing folder/multi-file pattern is split into one per-file entry each with its
own carve_outs and excluded_rest; a cannot_test entry with a non-canonical category is
moved to the canonical nature and given a mitigation. A manifest with no target block is
given the default (C0 95% / C1 85% on the Adjusted slice) so the report reads against the goal;
the existing gate and baseline are preserved (raising the diff gate to the target is a
reviewed change, not automatic).
- Preserve: an exclusion the sweep still agrees with, a still-valid carve-out, the
baseline, and the gate block are carried over unchanged.
- Gray zone: a genuine disagreement (vendored-vs-product, a host blanket that may hide a
slice) is carried into the step-9 report as an explicit question, not resolved silently.
Apply
coverage-init step 5's pattern-vs-path verification to every new or split pattern.
-
Guard the existing tests. For every reclassification, check the existing test files: a
method moving INTO scope that already has a carve-out test means that test now counts toward
Adjusted (reuse it, intact). A method moving OUT of scope that has a test is a potential
orphan: flag it in the report, do not delete it. Assert that no existing, passing test is
invalidated by a manifest change; if one is, that delta is a question for the human.
-
Critique the reconciled draft (single, not parallel). Run coverage-init step 6's
cross-project self-critique on the corrected manifest and the sweep evidence, with two added
checks specific to redo: (a) no existing test was orphaned by a reclassification, and (b) the
migration is complete (no prose CARVE-OUT: and no carve-out-bearing multi-file pattern
remain). Reconcile clear-cut corrections in a loop; leave only genuine gray zones.
-
Write the corrected manifest and STOP for confirmation. Write the reconciled, migrated
manifest (do not clobber without showing the diff). Present the diff grouped as: false
exclusions fixed, schema migrations, entries preserved, and open questions. Ask the user to
confirm or correct before any test is generated. This is the hard gate: do not proceed to
step 7 in the same turn without confirmation.
-
Generate tests for the NEW gaps only, and run it to completion. Run generate-tests in
characterization mode (this is existing code: freeze current behavior) with the reconciled
manifest. Its worklist is the newly-in-scope carve-outs and targets; items already covered by
existing tests are checked off and left untouched, per that skill's rules. Untestable-as-is units
are routed to cannot_test with a mitigation, exactly as in a normal backfill.
The manifest confirmation in step 6 is the ONE gate. After it, execute autonomously. For a
large newly-found backlog, fan it out with the parallel backfill: ask the user for the agent
count ONCE (or default to 3 on "go"), then run the fan-out to completion. Follow the
generate-tests fan-out contract EXACTLY (write coverage/backfill/worklist.json first and
confirm it is non-empty; pass args as a JSON object with worklistManifest, never an inline
worklist and never a stringified payload; invoke via scriptPath). Do NOT re-ask per batch,
re-explain the plan between phases, fresh-relaunch a run that can be resumed, or drop back to
sequential Agent() calls: those are the exact behaviors that turned a real redo into dozens of
back-and-forth turns. The goal is "every testable part has a branch-covered test or a cited
cannot_test entry"; keep going until that holds, reporting progress, not asking permission to
continue.
-
Re-baseline decision (explicit, human-gated). Re-measure with coverage-report. Because
newly-in-scope code entered the Adjusted denominator, the recorded coverage may have moved.
Present the old floor and the new measured Adjusted, and ask the user which to record. Never
lower baseline.recorded_overall automatically; raising it (once the new gaps are covered) is
the normal outcome.
-
New report and comprehensiveness gate. Regenerate the dated reports/<YYYY-MM-DD>/REPORT.{md,html} + CANNOT-TEST.md via
report.sh. Assert coverage-init step 11's comprehensiveness gate PLUS the redo-specific
ones: every enumerated file accounted for, no orphaned test, migration complete (the gate's
ambiguous-carve-out warning is empty). Report the before/after: files reclassified, carve-outs
added, tests generated, tests reused unchanged, and the coverage delta. Stop and hand the
human the summary and any open questions.