Skip to content

feat(canvas): vitest coverage instrumentation (#1815, no CI gate yet) - #2147

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
feat/canvas-coverage-instrumentation-1815
Apr 27, 2026
Merged

feat(canvas): vitest coverage instrumentation (#1815, no CI gate yet)#2147
HongmingWang-Rabbit merged 1 commit into
stagingfrom
feat/canvas-coverage-instrumentation-1815

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

[Molecule-Platform-Evolvement-Manager]

Closes step 1+2 of #1815. Step 3 (CI gate + threshold) is split into a follow-up because today's baseline is ~46% lines / ~45% statements, not the 70% the issue's draft thresholds assumed.

What this lands

  • `canvas/vitest.config.ts` — `coverage` block with v8 provider; reporters: text / html / json-summary. NO threshold — pure observability.
  • `canvas/package.json` — adds `test:coverage` script. Existing `test` script unchanged so the default workflow is identical.
  • `canvas/package-lock.json` — adds `@vitest/coverage-v8@^4.1.5`.

Why no threshold yet

Issue's draft threshold was 70%/70%/65%/70%. Local baseline today:

```
Statements : 45.19% (3248/7186)
Branches : 39.87% (2034/5101)
Functions : 40.99% (724/1766)
Lines : 46.36% (2905/6265)
```

Turning on a 70% gate today would fail CI immediately or get papered over with an ad-hoc exclude list. Better path: land observability now, gate later.

Top gaps (from local run)

  • `src/lib/runtime-names.ts` — 0%
  • `src/lib/utils.ts` — 0%
  • `src/lib/canvas-actions.ts` — 25%
  • `src/store/classNames.ts` — 17%
  • `src/store/canvas.ts` — 73% (largest absolute gap by lines)

Each is a concrete follow-up.

Test plan

  • `npx vitest run --coverage` produces `./coverage/index.html` + `coverage-summary.json`
  • Existing `npm run test` unchanged — instrumentation only activates with `--coverage`
  • No production-code changes — pure tooling addition

Follow-ups (separate PRs)

  • 3a — write tests for the 0% files
  • 3b — once baseline ≥ thresholds, add `thresholds` block + a `test:coverage` step in `.github/workflows/ci.yml`'s Canvas job

🤖 Generated with Claude Code

[Molecule-Platform-Evolvement-Manager]

Closes step 1+2 of #1815. Step 3 (CI gate + threshold) is split into
a follow-up because today's baseline is ~46% lines / ~45% statements,
not the 70% the issue's draft thresholds assumed.

## What this lands

- `canvas/vitest.config.ts` — `coverage` block with v8 provider,
  reporters: text (terminal) / html (./coverage/index.html) /
  json-summary (machine-readable for tooling). NO threshold —
  pure observability.
- `canvas/package.json` — adds `test:coverage` script
  (`vitest run --coverage`); existing `test` script is unchanged so
  the default workflow is identical.
- `canvas/package-lock.json` — adds @vitest/coverage-v8@^4.1.5 (the
  v8 provider Vitest uses for native coverage).

## Why no threshold yet

Issue draft threshold was 70%/70%/65%/70% (lines/funcs/branches/stmts).
Local baseline today:

```
Statements   : 45.19% (3248/7186)
Branches     : 39.87% (2034/5101)
Functions    : 40.99% (724/1766)
Lines        : 46.36% (2905/6265)
```

Turning on a 70% gate today would either fail CI immediately or get
papered over with an ad-hoc exclude list. Better path: land
observability now, run coverage in PR review for any new code
(via the new script), gate later when the baseline catches up.

## Heatmap (from local run, top gaps)

- `src/lib/runtime-names.ts` — 0% (untouched by tests)
- `src/lib/utils.ts` — 0%
- `src/lib/canvas-actions.ts` — 25%
- `src/store/classNames.ts` — 17%
- `src/store/canvas.ts` — 73% (already-tested but the largest absolute
  gap by lines)

Each is a concrete follow-up issue / PR target.

## Test plan

- [x] `npx vitest run --coverage` runs cleanly locally (~10s) and
      produces `./coverage/index.html` + a `coverage-summary.json`
- [x] Existing `npm run test` workflow unchanged — instrumentation
      only activates with `--coverage` flag
- [x] No production-code changes — pure tooling addition

## Follow-ups (each tracked separately; this PR keeps minimal scope)

- Step 3a — write tests for the 0% files above (~tiny each)
- Step 3b — once baseline ≥ thresholds, add `thresholds` block to
  vitest.config.ts + a `npm run test:coverage` step in
  `.github/workflows/ci.yml`'s Canvas job

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue Apr 27, 2026
Merged via the queue into staging with commit 516b58d Apr 27, 2026
14 of 16 checks passed
@molecule-ai
molecule-ai Bot deleted the feat/canvas-coverage-instrumentation-1815 branch May 20, 2026 06:21
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…o mislabelled runners (#2146)' (#2147) from fix/shellcheck-arm64-pilot-main-red-2146 into main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant