supercov 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -12
- package/docs/agent-loop.md +17 -9
- package/docs/assertion-agent.md +146 -0
- package/docs/assertion-evidence.md +72 -663
- package/docs/assertion-maps.md +236 -0
- package/docs/assertions.md +132 -0
- package/docs/cli.md +40 -8
- package/docs/coverage-model.md +18 -0
- package/docs/evidence.md +28 -0
- package/docs/performance.md +16 -0
- package/docs/supported-suites.md +64 -147
- package/package.json +36 -35
- package/runtime/javascript/launchSupervisor.mjs +5 -0
- package/runtime/javascript/nodeTest.mjs +57 -41
- package/runtime/javascript/provenance.mjs +4 -1
- package/runtime/javascript/register.mjs +9 -5
- package/runtime/javascript/runnerEvidence.mjs +4 -1
- package/runtime/javascript/runtime.mjs +62 -36
- package/schemas/assertions.schema.json +276 -0
- package/analyzers/typescript/README.md +0 -59
- package/analyzers/typescript/bin/compiler-identity.mjs +0 -78
- package/analyzers/typescript/bin/identity.mjs +0 -71
- package/analyzers/typescript/bin/query.mjs +0 -29
- package/analyzers/typescript/dist/analyze.js +0 -5273
- package/analyzers/typescript/dist/archive.js +0 -337
- package/analyzers/typescript/dist/awaited-observations.js +0 -376
- package/analyzers/typescript/dist/build-identity.json +0 -1
- package/analyzers/typescript/dist/compiler.js +0 -32
- package/analyzers/typescript/dist/frontend.js +0 -75
- package/analyzers/typescript/dist/mock-counts.js +0 -2517
- package/analyzers/typescript/dist/native-frontend.js +0 -271
- package/analyzers/typescript/dist/pragmas.js +0 -186
- package/analyzers/typescript/dist/types.js +0 -1
- package/analyzers/typescript/package.json +0 -27
- package/analyzers/typescript/src/analyze.ts +0 -6180
- package/analyzers/typescript/src/archive.ts +0 -471
- package/analyzers/typescript/src/awaited-observations.ts +0 -561
- package/analyzers/typescript/src/compiler.ts +0 -49
- package/analyzers/typescript/src/frontend.ts +0 -136
- package/analyzers/typescript/src/mock-counts.ts +0 -3219
- package/analyzers/typescript/src/native-frontend.ts +0 -315
- package/analyzers/typescript/src/pragmas.ts +0 -284
- package/analyzers/typescript/src/types.ts +0 -45
- package/analyzers/typescript/tsconfig.json +0 -12
- package/docs/code-verification.md +0 -4
package/README.md
CHANGED
|
@@ -46,22 +46,30 @@ npx supercov -- python -m unittest
|
|
|
46
46
|
npx supercov -- bundle exec rspec
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
##
|
|
49
|
+
## Map what assertions check
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Each normal test run creates an assertion map automatically. An agent can
|
|
52
|
+
optionally fill in what the assertions check:
|
|
52
53
|
|
|
53
54
|
```sh
|
|
54
|
-
npx supercov runs latest assertions --
|
|
55
|
-
|
|
56
|
-
npx supercov runs
|
|
55
|
+
npx supercov runs latest assertions --json
|
|
56
|
+
# Pin the returned run ID. Inspect assertions and the source that ran:
|
|
57
|
+
npx supercov runs <run> assertion <assertion-id>
|
|
58
|
+
npx supercov runs <run> source src/example.ts
|
|
59
|
+
# Edit assertions.json, then validate and acknowledge:
|
|
60
|
+
npx supercov runs <run> assertions validate --json
|
|
61
|
+
# Copy examined expectedBasis tokens into assertions.json; save again.
|
|
62
|
+
npx supercov runs <run> assertions check --require-mappings --json
|
|
63
|
+
npx supercov runs <run> # includes the assertion percentage in the regular report
|
|
57
64
|
```
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
[
|
|
64
|
-
assertion
|
|
66
|
+
After code or tests change, run the same test command again. Supercov reuses the
|
|
67
|
+
newest available map for that command and language and identifies dirty flows. Rust owns
|
|
68
|
+
validation, change tracking and reporting; the agent supplies semantic reasoning.
|
|
69
|
+
The score is agent-assessed and separate from MC/DC. See
|
|
70
|
+
[assertion maps](docs/assertion-maps.md) for the format and JS/TS limits, or run
|
|
71
|
+
`supercov docs assertion-agent` for the agent workflow. `supercov assertions schema`
|
|
72
|
+
exports the editor schema; `assertions validate --file <path>` checks JSON syntax.
|
|
65
73
|
|
|
66
74
|
## Give Supercov a job
|
|
67
75
|
|
|
@@ -170,7 +178,7 @@ Supercov uses exact per-test attribution where an adapter is available. For othe
|
|
|
170
178
|
| --- | --- |
|
|
171
179
|
| Playwright | Exact per test, worker, retry, outcome, action, and assertion phase |
|
|
172
180
|
| Vitest | Exact per test, with setup execution kept separate |
|
|
173
|
-
| Jest | Exact per test, including parameterized tests; `expect`
|
|
181
|
+
| Jest | Exact per test, including parameterized tests; exact `expect` occurrence identity for assertion maps |
|
|
174
182
|
| `node:test` | Exact per test |
|
|
175
183
|
| AVA and Mocha | Aggregate structural coverage |
|
|
176
184
|
| Cargo's standard libtest runner | Exact test, attempt, and passing-assertion identity |
|
|
@@ -223,6 +231,7 @@ npx supercov clean # remove all runs and the build cache
|
|
|
223
231
|
|
|
224
232
|
- [Getting started](https://supercov.com/docs/getting-started)
|
|
225
233
|
- [Agent workflow](https://supercov.com/docs/agent-loop)
|
|
234
|
+
- [Understanding assertions](docs/assertions.md)
|
|
226
235
|
- [Troubleshooting](https://supercov.com/docs/troubleshooting)
|
|
227
236
|
- [CLI reference](https://supercov.com/docs/cli)
|
|
228
237
|
- [Supported languages and test suites](https://supercov.com/docs/supported-suites)
|
package/docs/agent-loop.md
CHANGED
|
@@ -53,18 +53,26 @@ The `line` query is useful before writing a test because it shows which tests
|
|
|
53
53
|
already reach that line. Extending a nearby test is often better than adding a
|
|
54
54
|
duplicate.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
## Add assertion coverage
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
For JavaScript and TypeScript projects, you can also ask the agent to explain
|
|
59
|
+
what each test assertion checks. Every normal run creates an `assertions.json`
|
|
60
|
+
map and carries forward compatible work from earlier runs of the same command.
|
|
61
|
+
|
|
62
|
+
```sh supercov
|
|
63
|
+
npx supercov runs latest assertions
|
|
64
|
+
npx supercov docs assertion-agent
|
|
61
65
|
```
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
Keep the printed run ID fixed while editing. The agent reads matching current
|
|
68
|
+
source, updates the map, validates its references and saves review tokens for
|
|
69
|
+
the explanations it examined. The regular run report then shows the assertion
|
|
70
|
+
percentage. It does not need another test run just to read the edited map.
|
|
71
|
+
|
|
72
|
+
Start with [Understanding assertion coverage](assertions.md) for a copyable
|
|
73
|
+
prompt. [Mapping assertions with an agent](assertion-agent.md) gives the complete
|
|
74
|
+
editing and checking loop. Use the evidence and recorded observations alongside
|
|
75
|
+
MC/DC when deciding which tests need stronger checks.
|
|
68
76
|
|
|
69
77
|
## Example
|
|
70
78
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Mapping assertions with an agent
|
|
2
|
+
|
|
3
|
+
Use these instructions when asking a coding agent to create or update an
|
|
4
|
+
assertion map. The agent reads your tests and source, explains what each
|
|
5
|
+
assertion checks, and edits the run's `assertions.json`. Supercov supplies the
|
|
6
|
+
run evidence and checks the file's references and freshness.
|
|
7
|
+
|
|
8
|
+
Start with [Understanding assertion coverage](assertions.md) for a prompt you
|
|
9
|
+
can copy. The steps below are the agent's working instructions.
|
|
10
|
+
|
|
11
|
+
## Choose a run and keep it fixed
|
|
12
|
+
|
|
13
|
+
1. Use a matching current run, or run the requested suite through
|
|
14
|
+
`supercov -- <test command>`. Use the full suite for a suite-wide result.
|
|
15
|
+
2. Read `supercov runs latest assertions --json` and keep `data.run` fixed for
|
|
16
|
+
this investigation. Edit the file at `data.map`.
|
|
17
|
+
3. Check `data.inheritance` for reused work or fallback errors. Keep the old
|
|
18
|
+
runs and maps. Inspect changes before renewing inherited flows.
|
|
19
|
+
4. Read the [map format](assertion-maps.md), also available through
|
|
20
|
+
`supercov docs assertion-maps`.
|
|
21
|
+
|
|
22
|
+
Use a single writer for the map. Save atomically if your editor supports it.
|
|
23
|
+
Do not change application code or tests unless the user also requested those
|
|
24
|
+
changes. Never edit `assertions.state.json` or the run's recorded evidence.
|
|
25
|
+
|
|
26
|
+
## Inspect the assertions and source
|
|
27
|
+
|
|
28
|
+
```sh supercov-example
|
|
29
|
+
npx supercov runs <run-id> assertions --limit 100 --json
|
|
30
|
+
npx supercov runs <run-id> assertions report --view statements --limit 100 --json
|
|
31
|
+
npx supercov runs <run-id> assertions report --view tests --limit 100 --json
|
|
32
|
+
npx supercov runs <run-id> assertions report --view changes --limit 100 --json
|
|
33
|
+
npx supercov runs <run-id> assertion <assertion-id>
|
|
34
|
+
npx supercov runs <run-id> source src/shipping.js --offset 0 --limit 100
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Follow every `pagination.nextOffset`; a page is not the whole result. Restart a
|
|
38
|
+
paged read if its `revision` changes. Current source must match the pinned run.
|
|
39
|
+
Use ordinary source-reading tools to inspect setup, inputs, mocks, callbacks,
|
|
40
|
+
branches, called functions, helpers and relevant configuration.
|
|
41
|
+
|
|
42
|
+
Preserve each assertion's ID and complete `at` anchor. Locations use one-based
|
|
43
|
+
lines and UTF-8 byte columns. Restore recognized sites marked `inMap: false`
|
|
44
|
+
when investigating them; removing an entry does not remove the assertion from
|
|
45
|
+
Supercov's list.
|
|
46
|
+
|
|
47
|
+
## Write precise explanations
|
|
48
|
+
|
|
49
|
+
For each assertion:
|
|
50
|
+
|
|
51
|
+
- Describe exactly what its predicate distinguishes in `observes`. Existence,
|
|
52
|
+
truthiness, length and substring checks do not imply equality of every field.
|
|
53
|
+
- Split independently maintainable explanations into flows with stable IDs.
|
|
54
|
+
Start a new or changed flow with `basis: null`.
|
|
55
|
+
- Choose `appliesTo` tests from the tests view using their exact file and name.
|
|
56
|
+
Select applicable cases explicitly for shared or parameterized assertions.
|
|
57
|
+
- Use complete source statements from the statements view as node anchors when
|
|
58
|
+
possible. Write the relationships that connect those nodes to `$assertion`.
|
|
59
|
+
- Put a node in `countsAsAsserted` only when its behavior is checked by this
|
|
60
|
+
assertion. Every counted node needs a recorded path to `$assertion`.
|
|
61
|
+
Counting a guard or block does not count the nested body automatically.
|
|
62
|
+
- Add helper, configuration and other dependency files to `watch`. Assertion,
|
|
63
|
+
selected-test and node files are already dependencies. Include relevant guards
|
|
64
|
+
and alternatives even when they do not appear as graph nodes.
|
|
65
|
+
- Keep uncertainty in `questions`. A flow's unresolved questions block its
|
|
66
|
+
credit. Assertion-level questions record broader unfinished investigation.
|
|
67
|
+
|
|
68
|
+
A fixture-only or absence explanation can have `countsAsAsserted: []`. For
|
|
69
|
+
absence, describe the ordering or barrier and the observation window. Never
|
|
70
|
+
credit an unexecuted body merely because executing it would violate the check.
|
|
71
|
+
|
|
72
|
+
There is no known number of flows an assertion should have. Do not label an
|
|
73
|
+
assertion complete just because you recorded one explanation.
|
|
74
|
+
|
|
75
|
+
## Check why a node receives no credit
|
|
76
|
+
|
|
77
|
+
Read the node's credit reason in assertion detail, or its computed `nodeCredit`
|
|
78
|
+
entry in JSON. Compare the statement's execution evidence and selected test's
|
|
79
|
+
outcome. Keep these report fields out of the editable map.
|
|
80
|
+
|
|
81
|
+
A source node can be context only, lack a measured statement, have stale inputs,
|
|
82
|
+
or lack matching passing assertion and execution evidence. Shared setup and
|
|
83
|
+
background execution do not count as execution by every consuming test. Skipped
|
|
84
|
+
and TODO tests supply no passing witness. An unobserved site in a passing test
|
|
85
|
+
can indicate an untaken branch or missing measurement.
|
|
86
|
+
|
|
87
|
+
Do not borrow another assertion's identity or another test's execution. Preserve
|
|
88
|
+
zero-credit explanations when they accurately describe what the test checks.
|
|
89
|
+
Use `assertions report --view excludedStatements` to inspect erased TypeScript
|
|
90
|
+
imports. See [Investigating assertion evidence](assertion-evidence.md) for
|
|
91
|
+
asynchronous and missing-evidence cases.
|
|
92
|
+
|
|
93
|
+
For a large flow, page `assertion <id> --flow <flow-id> --view nodes --json` and
|
|
94
|
+
`--view edges` separately. `--compact` omits repeated source text from the
|
|
95
|
+
report; read the matching source separately and never save the compact objects
|
|
96
|
+
back into the map.
|
|
97
|
+
|
|
98
|
+
## Assess changes before renewing flows
|
|
99
|
+
|
|
100
|
+
When inheriting a map, read every entry in `--view changes`. Recorded file
|
|
101
|
+
watches are a starting point; investigate whether other flows are affected too.
|
|
102
|
+
|
|
103
|
+
Add a `changeAssessments` entry for each managed change ID. Include all listed
|
|
104
|
+
`knownFlows` that still exist, plus any other affected flows. Explain why the
|
|
105
|
+
remaining claims are unaffected. An empty affected-flow list needs a reason.
|
|
106
|
+
Repair missing watches and update the affected graphs or selectors.
|
|
107
|
+
|
|
108
|
+
Save these edits, then validate:
|
|
109
|
+
|
|
110
|
+
```sh supercov-example
|
|
111
|
+
npx supercov assertions validate --file <map-path> --json
|
|
112
|
+
npx supercov runs <run-id> assertions validate --view changes --json
|
|
113
|
+
npx supercov runs <run-id> assertions validate --view flows --json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Page the validation views too. Overall validity covers the whole map even when
|
|
117
|
+
only one page is returned. Copy change `expectedBasis` tokens only after
|
|
118
|
+
examining the corresponding impact assessments, then save. Validate again and
|
|
119
|
+
copy flow tokens only for the claims you have examined.
|
|
120
|
+
|
|
121
|
+
Obtain final flow tokens after saving change tokens: a change assessment can
|
|
122
|
+
invalidate additional flows. Treat tokens as opaque; do not implement their
|
|
123
|
+
hashing or manufacture them. Changing a claim after getting its token makes
|
|
124
|
+
that token stale.
|
|
125
|
+
|
|
126
|
+
## Check and summarize
|
|
127
|
+
|
|
128
|
+
```sh supercov-example
|
|
129
|
+
npx supercov runs <run-id> assertions check --require-mappings --json
|
|
130
|
+
npx supercov runs <run-id> assertions report --view statements --limit 100 --json
|
|
131
|
+
npx supercov runs <run-id>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Add `--require-observed` when every mapped site and test selector is expected to
|
|
135
|
+
have passing evidence. Report skipped, TODO or untaken cases when that gate is
|
|
136
|
+
unmet. Use `--min <percentage>` only for the user's chosen target; do not lower
|
|
137
|
+
it or hide gaps to make a check pass.
|
|
138
|
+
|
|
139
|
+
Report the run ID, map path, assertion percentage and counts, unresolved changes,
|
|
140
|
+
missing execution and useful next tests. Distinguish statements credited by the
|
|
141
|
+
map from raw line coverage and MC/DC. Mention which claims were newly examined
|
|
142
|
+
and which were reused.
|
|
143
|
+
|
|
144
|
+
A valid file does not prove the explanation or its completeness. A credited
|
|
145
|
+
statement can change without failing a test when the edit preserves the observed
|
|
146
|
+
property. Keep that distinction clear when recommending code changes.
|