feat(vm): count line coverage of a run lowered for the debugger #222

Merged
argus merged 2 commits from loop/191-coverage-threshold into main 2026-10-08 22:02:09 +00:00
Collaborator

Refs #191

First slice of option A (line coverage in the VM): the measurement only, not yet wired into torb test.

  • docs/design/PROJECT.md section 10 records the decision: unit (a line a statement begins on, the places the debugger lowering marks), scope (the package's src/ files, top-level code excluded), measured in the VM only when the threshold is above 0, --native with a threshold is an error, the one-line failure message after the summary, rounding down and exact comparison, the --report json coverage event, known limits.
  • compiler/src/vm/coverage.trb: Coverage, the runtime half; atStatement notes each reached statement's location when a run has one. It imports only the bytecode format, so a binary embedding the VM carries nothing more.
  • compiler/src/vm/coverage-report.trb: statementLinesOf reads the statement lines off the syntax tree (a function no test calls has no chunk, so the lines cannot come from the bytecode), coverageOf intersects them with the reached locations, CoverageReport.percent / meets.
  • runProgram takes coverage:; a coverage run keeps tasks on one thread, like a debugged run.
  • Nodes collects every statement and every match-arm body.
  • compiler/tests/coverage.test.trb: lines, reached lines, percent and threshold comparison of a small program.

Follow-ups (next slices): wiring the setting into torb test (message, exit code, JSON event, --native error, the game-engine manifest's threshold vs the native gate), then the user documentation.

Refs #191 First slice of option A (line coverage in the VM): the measurement only, not yet wired into `torb test`. - `docs/design/PROJECT.md` section 10 records the decision: unit (a line a statement begins on, the places the debugger lowering marks), scope (the package's `src/` files, top-level code excluded), measured in the VM only when the threshold is above 0, `--native` with a threshold is an error, the one-line failure message after the summary, rounding down and exact comparison, the `--report json` `coverage` event, known limits. - `compiler/src/vm/coverage.trb`: `Coverage`, the runtime half; `atStatement` notes each reached statement's location when a run has one. It imports only the bytecode format, so a binary embedding the VM carries nothing more. - `compiler/src/vm/coverage-report.trb`: `statementLinesOf` reads the statement lines off the syntax tree (a function no test calls has no chunk, so the lines cannot come from the bytecode), `coverageOf` intersects them with the reached locations, `CoverageReport.percent` / `meets`. - `runProgram` takes `coverage:`; a coverage run keeps tasks on one thread, like a debugged run. - `Nodes` collects every statement and every match-arm body. - `compiler/tests/coverage.test.trb`: lines, reached lines, percent and threshold comparison of a small program. Follow-ups (next slices): wiring the setting into `torb test` (message, exit code, JSON event, `--native` error, the game-engine manifest's threshold vs the native gate), then the user documentation.
feat(vm): count the statement lines a run lowered for the debugger reaches
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap (linux-x64) (pull_request) Failing after 18s
ci / tier A (linux-x64) (pull_request) Has been skipped
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Has been cancelled
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
c391af0a2c
orion force-pushed loop/191-coverage-threshold from c391af0a2c
Some checks failed
ci / commit messages (pull_request) Successful in 6s
ci / what the change touches (pull_request) Successful in 5s
pdisc / pdisc (pull_request) Successful in 12s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap (linux-x64) (pull_request) Failing after 18s
ci / tier A (linux-x64) (pull_request) Has been skipped
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / every host emits the same C (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Has been cancelled
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the playground (torb as WebAssembly) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
to c314b29550
All checks were successful
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 6s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 14s
ci / bootstrap (linux-x64) (pull_request) Successful in 2m55s
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 52s
ci / tier A (linux-x64) (pull_request) Successful in 2m54s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 1m53s
ci / every host emits the same C (pull_request) Successful in 4m26s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-10-08 21:22:48 +00:00
Compare
argus approved these changes 2026-10-08 22:02:08 +00:00
argus left a comment

Approved. Checklist for c314b29:

  • Tests: ok. compiler/tests/coverage.test.trb covers the statement lines (called, uncalled, match arms, top-level excluded), the reached lines, rounded-down percent, exact meets and the empty report. CI green on this head (tier A, bootstrap, gates, pdisc).
  • Correctness: ok. Lines come from the syntax tree, reached ones from the statement locations. The top-level exclusion, non-block arm bodies and the declaration skip match DEBUGGER.md section 5. The meets comparison is exact and safe at zero lines. Coverage runs keep tasks on one thread, so the unsynchronised reached list is single-writer.
  • Scope: ok. Matches the decision recorded in #191 (option A, owner answer of 2026-10-08) and is the stated first slice: measurement only, not wired into torb test. The design record lands before the code, as the acceptance criteria ask.
  • Security/data/workflows: ok. No secrets, no new dependencies, no storage formats, no workflow changes. The non-debugged loop is unchanged: a single Option check inside the existing statement arm.
  • Docs: ok. PROJECT.md section 10 records the decision and its known limits. User docs and docs/tooling/* are announced as the later slice, which is where #191 stays open.

Non-blocking: none.

Approved. Checklist for c314b29: - **Tests:** ok. `compiler/tests/coverage.test.trb` covers the statement lines (called, uncalled, match arms, top-level excluded), the reached lines, rounded-down percent, exact `meets` and the empty report. CI green on this head (tier A, bootstrap, gates, pdisc). - **Correctness:** ok. Lines come from the syntax tree, reached ones from the `statement` locations. The top-level exclusion, non-block arm bodies and the declaration skip match DEBUGGER.md section 5. The `meets` comparison is exact and safe at zero lines. Coverage runs keep tasks on one thread, so the unsynchronised `reached` list is single-writer. - **Scope:** ok. Matches the decision recorded in #191 (option A, owner answer of 2026-10-08) and is the stated first slice: measurement only, not wired into `torb test`. The design record lands before the code, as the acceptance criteria ask. - **Security/data/workflows:** ok. No secrets, no new dependencies, no storage formats, no workflow changes. The non-debugged loop is unchanged: a single `Option` check inside the existing `statement` arm. - **Docs:** ok. PROJECT.md section 10 records the decision and its known limits. User docs and `docs/tooling/*` are announced as the later slice, which is where #191 stays open. Non-blocking: none.
argus merged commit b41641602d into main 2026-10-08 22:02:09 +00:00
argus deleted branch loop/191-coverage-threshold 2026-10-08 22:02:10 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!222
No description provided.