Skip to content

test: raise coverage and add CI coverage gates - #2

Merged
danielglh merged 2 commits into
mainfrom
chore/test-coverage
Aug 27, 2026
Merged

test: raise coverage and add CI coverage gates#2
danielglh merged 2 commits into
mainfrom
chore/test-coverage

Conversation

@danielglh

Copy link
Copy Markdown
Owner

Follow-up to #1: closes the coverage gaps surfaced by the pre-release analysis, test-first throughout.

Baseline → now

Suite Tests Line coverage
server 30 → 84 79.2% → 96.0%
web 19 → 57 measured files only; api.ts (the ~800-line SessionStore state machine) was at 0% → now 80.5%, overall 93.4%

What's newly covered

Server

  • fs.ts (10%→96%): pickers + deleteOmpSession — the only user-file-destroying function
  • omp.ts (8%→97%): CLI bridge via a generated fake omp binary (arg passing, parsing, failure, timeout kill); session-history scanner with injectable root
  • sessions/manager.ts (88%→99%): delete data safety (real removal + resumedFromHistory protection), the full non-mock spawn identity handshake run against a fake omp binary (sh wrapper exec'ing the mock host), spawn-failure surfacing, start() retry
  • rpc/process.ts: readiness timeout, close() SIGTERM→SIGKILL escalation (real child processes), kill(), frame delivery
  • rpc/frame.ts: chunk metadata/base64/sequence validation to 100% lines
  • app.ts: cross-site WS upgrade refusal, fs picker endpoints, WS refresh/stop control messages, non-mock omp CLI error surfacing

Web

  • SessionStore driven by a fake transport: hello/hydration, message upsert + history dedupe, immutable tool executions (+ late-joiner synthesis), extension dialog queue/cancel/answer, widgets/status/editor surfaces, open_url http(s)-only gating, caps, registry refcounting (constructor gained injectable socket options)
  • markdown unescape/tag-strip pipeline; format/content helpers

Real bugs the new tests exposed (fixed)

  1. spawnOmpProcess threw synchronously on spawn failure — its rejected ready promise was left unconsumed. Failures now flow through ready.
  2. start() could never retry a session whose spawn had failed (a dead process handle blocked respawning) — errored sessions now restart from scratch.

De-flake

The replay-pruning test no longer sleeps for the replay burst: it waits for the private auto-hydration response (queued after all buffered frames) before asserting absence.

CI

Test step now runs under --coverage with ratcheted thresholds (server ≥93%, web ≥90%) — both currently pass locally — plus a README badge.

Follow-up to the hardening pass — closes the coverage gaps the review
surfaced, test-first throughout.

Server (30 → 84 tests; line coverage 79% → 96%):
- fs.ts (10%→96%): listDir/searchDir/searchPaths pickers and
  deleteOmpSession — the only function that destroys user files
- omp.ts (8%→97%): CLI bridge via a generated fake omp binary (arg passing,
  stdout parsing, failure + timeout kill) and listOmpSessions header
  scanning with an injectable sessions root
- sessions/manager.ts (88%→99%): delete data-safety (real file removal,
  resumedFromHistory protection), non-mock spawn identity handshake run
  against the bundled mock host as a fake omp binary, spawn-failure
  surfacing and start() retry semantics
- rpc/process.ts (80%→87%): readiness timeout, close() SIGTERM→SIGKILL
  escalation, kill(), frame delivery
- rpc/frame.ts (100% lines): chunk metadata/base64/sequence validation
- app.ts (75%→88%): cross-site WS upgrade refusal, fs picker endpoints,
  WS refresh_session/stop_session control messages, non-mock omp CLI error
  surfacing; replay-pruning test de-flaked with a sentinel

Web (19 → 57 tests; measured files now include api.ts at 80%):
- SessionStore state machine driven by a fake transport (new injectable
  socket options on the constructor): hello/hydration, message upsert +
  history dedupe, immutable tool executions with late-joiner synthesis,
  extension dialog queue/cancel/answer, widget/status/editor surfaces,
  open_url http(s)-only gating, notice/output caps, registry refcounting
- markdown unescape/tag-strip pipeline; format/content helpers

Also fixes two real bugs the new tests exposed:
- spawnOmpProcess threw synchronously on spawn failure, leaving its rejected
  `ready` promise unconsumed; it now reports failures through `ready`
- start() could never retry a session whose spawn had failed (dead process
  handle blocked respawning)

CI: test step now runs under `--coverage` with ratcheted thresholds
(server ≥93%, web ≥90%) and a README badge.
@danielglh
danielglh merged commit 328329f into main Aug 27, 2026
1 check passed
@danielglh
danielglh deleted the chore/test-coverage branch August 27, 2026 04:51
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