Task — engineering-spec@1

coverage-scope helper maps a task diff to per-file coverage

doneTASK-IMP-098
module improvement · class product · priority p2 · created 2026-07-17 · shipped 2026-07-17
depends on none · blocks none

TASK-IMP-098: coverage-scope helper maps a task diff to per-file coverage

Summary

The coverage gate's unit of judgment is "files this task touched", but run-gates emits whole-workspace numbers and every gate so far mapped diff to coverage by hand. Ship coverage-scope.mjs: give it a task id (or an explicit base ref) and a coverage report, get back the touched-file list joined to per-file percentages, emitted as a coverage-gate@1 skeleton ready for the author skill to complete.

Problem

Manual mapping is exactly the fatigue-prone mechanical work the machine-floor doctrine (TASK-IMP-084) moves into tools: reading a diff range, filtering to source files, and cross-walking a coverage report is deterministic - a human or model doing it fresh each gate re-derives bytes a script can own.

Proposed Solution

node .cyberos/docs-tools/coverage-scope.mjs <task-id> [--base <ref>] [--coverage <file>] [--repo <root>]. Base resolution: --base wins; otherwise find the entry-flip commit whose subject names the task id entering implementing (the corpus convention every batch commit follows), else fail with a clear message demanding --base. Touched files: git diff --name-only <base>...HEAD filtered to tracked source files. Coverage ingestion: c8/istanbul coverage-summary.json and lcov.info - the two shapes the detected stacks emit; anything else is refused by name. Output: a coverage-gate@1 skeleton (frontmatter with computed files_below_90pct, the per-file table, TODO markers for the judgment fields) to stdout or --out. Node stdlib only; build.sh vendors it with the guarded-copy pattern.

Alternatives Considered

Success Metrics

Scope

In scope: the CLI, base resolution, the two report shapes, the skeleton emitter, fixture suite, build.sh vendor line.

Out of scope / Non-Goals

Dependencies

AI Authorship Disclosure

1. Description (normative)

2. Acceptance criteria

3. Edge cases

Audit

TASK-IMP-098-coverage-scope-helper spec audit - audit_rubric@2.0 (machine floor + judgment)

Machine floor: task-lint clean (the batch's two TRACE-001 misses - uncited suite-landing clauses in 093/094 - were caught by the lint on first run and fixed before audit; the governed loop working as built). Judgment families: metrics carry baseline/target/deadline grounded in run evidence or the recorded 2026-07-16 research; alternatives distinct with real rejection reasons; scope subsections present; ops-verified ACs carry explicit rationales; COND-004 truthful; cone-sharing (install.sh trio, build.sh pair, ship-tasks.md pair) declared in Dependencies per §11a so the batch schedule serializes correctly.

ISSUE ISS-001 (QA-004, wontfix-info): consumer-repo and single-prose-line ACs are ops-verified with recorded-evidence rationales (same accepted pattern as TASK-IMP-086/087/090).

SUMMARY verdict: pass issues_open: 0 issues_human: 0 next_action: ship

§gate-log

Populated during implementation (ship-tasks testing phase).