checkchange 0.4.1 → 0.4.2
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 +420 -106
- package/dist/crapCalc.d.ts +1 -1
- package/dist/crapCalc.js +1 -1
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +1 -1
- package/dist/providers/config.d.ts +0 -1
- package/dist/providers/config.js +19 -2
- package/dist/providers/prepare.d.ts +4 -2
- package/dist/providers/prepare.js +64 -5
- package/dist/rules.d.ts +1 -1
- package/dist/rules.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,76 +1,323 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CheckChange
|
|
2
2
|
|
|
3
|
-
Independent, deterministic evidence
|
|
3
|
+
**Independent, deterministic evidence for AI-assisted software development.**
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](.nvmrc)
|
|
5
|
+
AI coding tools can make a lot of software changes very quickly. That's useful, but it also creates a new question:
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
**How do we independently check the change without simply asking another AI what it thinks?**
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
That's what CheckChange is for.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
CheckChange looks at the functions changed in a Git repository and uses measurable evidence such as complexity, test coverage, coverage attribution, and deterministic CRAP calculations to produce evidence about the change.
|
|
12
|
+
|
|
13
|
+
It is not trying to decide whether the code is correct. It is not another AI code reviewer. It gives developers, CI systems, and other tools something concrete to look at.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What it does
|
|
19
|
+
|
|
20
|
+
At a high level:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
Git change
|
|
24
|
+
↓
|
|
25
|
+
Changed functions
|
|
26
|
+
↓
|
|
27
|
+
Complexity + coverage
|
|
28
|
+
↓
|
|
29
|
+
Coverage attribution
|
|
30
|
+
↓
|
|
31
|
+
CRAP calculation
|
|
32
|
+
↓
|
|
33
|
+
Deterministic rules
|
|
34
|
+
↓
|
|
35
|
+
Evidence
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The result tells you what CheckChange was able to establish about the change, rather than pretending that missing evidence is the same thing as good evidence.
|
|
39
|
+
|
|
40
|
+
For example, a changed function might produce:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
Complexity
|
|
44
|
+
12 → 17
|
|
45
|
+
|
|
46
|
+
Coverage
|
|
47
|
+
84% → 61%
|
|
48
|
+
|
|
49
|
+
CRAP
|
|
50
|
+
increased
|
|
51
|
+
|
|
52
|
+
Result
|
|
53
|
+
WARN
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That does **not** mean the function is defective. It means there is evidence worth looking at.
|
|
57
|
+
|
|
58
|
+
CheckChange is intended to be used as:
|
|
59
|
+
|
|
60
|
+
- a developer-side check
|
|
61
|
+
- a CI step
|
|
62
|
+
- a pull-request signal
|
|
63
|
+
- an input to another automated system
|
|
64
|
+
- an independent verification step after an AI coding agent makes a change
|
|
65
|
+
|
|
66
|
+
The important part is the separation:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
AI coding agent
|
|
70
|
+
|
|
|
71
|
+
| makes a change
|
|
72
|
+
v
|
|
73
|
+
CheckChange
|
|
74
|
+
|
|
|
75
|
+
| produces evidence
|
|
76
|
+
v
|
|
77
|
+
Human / CI / downstream system
|
|
78
|
+
|
|
|
79
|
+
v
|
|
80
|
+
decision
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The system that made the change does not get to decide whether the evidence is sufficient.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## What CheckChange is not
|
|
88
|
+
|
|
89
|
+
CheckChange does **not** claim to:
|
|
90
|
+
|
|
91
|
+
- prove that code is correct
|
|
92
|
+
- predict defects
|
|
93
|
+
- replace human code review
|
|
94
|
+
- replace testing
|
|
95
|
+
- certify production readiness
|
|
96
|
+
- provide a universal software-quality score
|
|
97
|
+
|
|
98
|
+
A `PASS` means the available evidence satisfied the applicable deterministic rules.
|
|
99
|
+
|
|
100
|
+
A `WARN` means the evidence crossed a condition worth investigating.
|
|
101
|
+
|
|
102
|
+
An `INCOMPLETE` or `NOT_EVALUATED` result means CheckChange could not establish everything needed for a meaningful evaluation.
|
|
103
|
+
|
|
104
|
+
Those are evidence states, not judgments about whether the software is ultimately good or bad.
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
# Install
|
|
109
|
+
|
|
110
|
+
The package is published on npm as `checkchange`.
|
|
111
|
+
|
|
112
|
+
Current registry version: **0.4.1**
|
|
113
|
+
|
|
114
|
+
### npm
|
|
13
115
|
|
|
14
116
|
```bash
|
|
15
117
|
npm install -g checkchange
|
|
16
|
-
|
|
118
|
+
checkchange --help
|
|
17
119
|
```
|
|
18
120
|
|
|
121
|
+
Or use it without installing globally:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npx checkchange check --base main --json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### pnpm
|
|
128
|
+
|
|
19
129
|
```bash
|
|
20
130
|
pnpm add -g checkchange
|
|
21
|
-
pnpm dlx checkchange check --base main --json
|
|
22
131
|
```
|
|
23
132
|
|
|
133
|
+
Or:
|
|
134
|
+
|
|
24
135
|
```bash
|
|
25
|
-
|
|
26
|
-
npx checkchange check --base main --json
|
|
136
|
+
pnpm dlx checkchange check --base main --json
|
|
27
137
|
```
|
|
28
138
|
|
|
29
|
-
### From
|
|
139
|
+
### From source
|
|
30
140
|
|
|
31
141
|
```bash
|
|
32
142
|
git clone https://github.com/victor-petropoulos/CheckChange.git
|
|
33
143
|
cd CheckChange
|
|
144
|
+
|
|
34
145
|
corepack enable
|
|
35
146
|
pnpm install --frozen-lockfile
|
|
36
147
|
pnpm run build
|
|
148
|
+
|
|
37
149
|
node dist/cli.js check --base main --json
|
|
38
150
|
```
|
|
39
151
|
|
|
40
|
-
|
|
152
|
+
---
|
|
41
153
|
|
|
42
|
-
|
|
154
|
+
# Requirements
|
|
43
155
|
|
|
44
|
-
|
|
156
|
+
- Node **24**
|
|
157
|
+
- pnpm **11.17.0**
|
|
158
|
+
- Git
|
|
45
159
|
|
|
46
|
-
|
|
47
|
-
- pnpm 11.17.0 (`package.json:5`)
|
|
160
|
+
The repository includes an `.nvmrc` and the required pnpm version is specified in `package.json`.
|
|
48
161
|
|
|
49
|
-
|
|
162
|
+
For repositories using the Python analysis path, Python 3 plus the relevant testing/coverage tooling may also be required.
|
|
50
163
|
|
|
51
|
-
|
|
164
|
+
---
|
|
52
165
|
|
|
53
|
-
|
|
166
|
+
# Quickstart
|
|
54
167
|
|
|
55
|
-
|
|
168
|
+
If you are working from a source checkout:
|
|
56
169
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
- **Where/who**: any git repo that produces coverage output — a PR pipeline, a developer's pre-commit hook, or an AI coding agent checking its own change. The latter two are common setups; this CLI installs neither.
|
|
62
|
-
- **Verified CI output formats**: `--format github|junit|sarif` (`src/help.ts:39`).
|
|
170
|
+
```bash
|
|
171
|
+
pnpm install
|
|
172
|
+
pnpm run build
|
|
173
|
+
```
|
|
63
174
|
|
|
64
|
-
|
|
175
|
+
Then run:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
node dist/cli.js check --base main --json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
If CheckChange is installed globally:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
checkchange check --base main --json
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
You can also run the project's own test suite with:
|
|
65
188
|
|
|
66
189
|
```bash
|
|
67
190
|
pnpm exec vitest run --coverage
|
|
68
191
|
```
|
|
69
192
|
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
# Basic usage
|
|
196
|
+
|
|
197
|
+
The three most common starting points are:
|
|
198
|
+
|
|
70
199
|
```bash
|
|
71
|
-
|
|
200
|
+
checkchange check --base main --json
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Analyze the changes relative to `main` and produce machine-readable evidence.
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
checkchange check --crap-threshold 25 --format github
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Run the analysis with a custom CRAP threshold and GitHub-oriented output.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
checkchange check --auto-coverage --verbose
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Allow CheckChange to detect/configure the appropriate coverage path and show additional diagnostic information.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# Commands
|
|
220
|
+
|
|
221
|
+
| Command | Purpose |
|
|
222
|
+
|---|---|
|
|
223
|
+
| `check` | Analyze changed functions and produce evidence |
|
|
224
|
+
| `doctor` | Check runtime and repository prerequisites |
|
|
225
|
+
| `prepare-repo` | Detect, plan, approve, install, and verify test/coverage tooling |
|
|
226
|
+
| `explain` | Explain the rationale behind a result |
|
|
227
|
+
| `trace` | Show the evidence trace for a function |
|
|
228
|
+
| `delta` | Compare evidence between two states |
|
|
229
|
+
|
|
230
|
+
Run:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
checkchange --help
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
for the current command and option list.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
# Configuration
|
|
241
|
+
|
|
242
|
+
Some of the most useful options are:
|
|
243
|
+
|
|
244
|
+
| Option | Description | Default |
|
|
245
|
+
|---|---|---|
|
|
246
|
+
| `--base <ref>` | Git base reference for the change | auto-detect |
|
|
247
|
+
| `--crap-threshold <n>` | CRAP warning threshold | `30` |
|
|
248
|
+
| `--coverage-file <path>` | Explicit coverage file | auto-detect |
|
|
249
|
+
| `--format <github\|junit\|sarif>` | CI output format | none |
|
|
250
|
+
| `--json` | Produce machine-readable evidence | off |
|
|
251
|
+
| `--verbose` | Show additional diagnostics | off |
|
|
252
|
+
| `--auto-coverage` | Attempt automatic coverage setup | off |
|
|
253
|
+
|
|
254
|
+
The base reference is automatically detected when `--base` is not supplied.
|
|
255
|
+
|
|
256
|
+
Provider configuration can be supplied explicitly or discovered from the repository.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
# Supported languages and coverage
|
|
261
|
+
|
|
262
|
+
The current implementation supports analysis for:
|
|
263
|
+
|
|
264
|
+
- TypeScript
|
|
265
|
+
- JavaScript
|
|
266
|
+
- Python
|
|
267
|
+
|
|
268
|
+
Coverage can be supplied through the supported coverage paths, including Istanbul-compatible coverage and LCOV.
|
|
269
|
+
|
|
270
|
+
CheckChange also supports CI-oriented output formats:
|
|
271
|
+
|
|
272
|
+
```text
|
|
273
|
+
github
|
|
274
|
+
junit
|
|
275
|
+
sarif
|
|
72
276
|
```
|
|
73
277
|
|
|
278
|
+
The supported provider/configuration surface is intentionally narrower than "anything that can produce a coverage report." Check the current documentation before assuming a particular repository or coverage setup is supported.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
# How the analysis works
|
|
283
|
+
|
|
284
|
+
The current pipeline is roughly:
|
|
285
|
+
|
|
286
|
+
1. **Git diff**
|
|
287
|
+
Determine what changed relative to the selected base.
|
|
288
|
+
|
|
289
|
+
2. **Changed functions**
|
|
290
|
+
Identify the functions affected by the change.
|
|
291
|
+
|
|
292
|
+
3. **Complexity**
|
|
293
|
+
Measure complexity using the appropriate provider.
|
|
294
|
+
|
|
295
|
+
4. **Coverage**
|
|
296
|
+
Find available test-coverage evidence.
|
|
297
|
+
|
|
298
|
+
5. **Attribution**
|
|
299
|
+
Associate coverage evidence with the changed functions.
|
|
300
|
+
|
|
301
|
+
6. **CRAP calculation**
|
|
302
|
+
Combine complexity and coverage into the deterministic CRAP signal.
|
|
303
|
+
|
|
304
|
+
7. **Rules**
|
|
305
|
+
Apply the project's deterministic rules and thresholds.
|
|
306
|
+
|
|
307
|
+
8. **Evidence**
|
|
308
|
+
Produce the structured evidence result.
|
|
309
|
+
|
|
310
|
+
9. **Output**
|
|
311
|
+
Present the result for a developer, CI system, or another machine.
|
|
312
|
+
|
|
313
|
+
The evidence output includes information about completeness and provenance so that a number is not presented without context.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
# Example
|
|
318
|
+
|
|
319
|
+
A typical machine-readable result looks roughly like:
|
|
320
|
+
|
|
74
321
|
```json
|
|
75
322
|
{
|
|
76
323
|
"schemaVersion": "0.5",
|
|
@@ -78,11 +325,6 @@ node dist/cli.js check --base main --json
|
|
|
78
325
|
"base": "<resolved-base-sha>",
|
|
79
326
|
"target": "current"
|
|
80
327
|
},
|
|
81
|
-
"capabilities": {
|
|
82
|
-
"git": "available",
|
|
83
|
-
"complexity": "unavailable",
|
|
84
|
-
"coverageArtifact": "unavailable"
|
|
85
|
-
},
|
|
86
328
|
"changedFunctions": [],
|
|
87
329
|
"ruleResults": [],
|
|
88
330
|
"policy": {
|
|
@@ -94,123 +336,195 @@ node dist/cli.js check --base main --json
|
|
|
94
336
|
}
|
|
95
337
|
```
|
|
96
338
|
|
|
97
|
-
|
|
339
|
+
The exact output depends on the repository and evidence available.
|
|
340
|
+
|
|
341
|
+
For example, a clean checkout may have no changed functions. In that case there is nothing to evaluate and `NOT_EVALUATED` is a valid result.
|
|
342
|
+
|
|
343
|
+
You can use:
|
|
98
344
|
|
|
99
345
|
```bash
|
|
100
|
-
|
|
346
|
+
checkchange doctor
|
|
101
347
|
```
|
|
102
348
|
|
|
349
|
+
to see why a repository is or is not ready for analysis.
|
|
350
|
+
|
|
351
|
+
Example:
|
|
352
|
+
|
|
103
353
|
```text
|
|
104
354
|
gitExecutable: ok
|
|
105
355
|
gitRepo: ok
|
|
106
356
|
defaultBase: ok (origin/main)
|
|
357
|
+
|
|
107
358
|
providerAvailability: no-changed-files
|
|
108
|
-
↳ no changed files detected against the base
|
|
359
|
+
↳ no changed files detected against the base
|
|
360
|
+
|
|
109
361
|
coverageArtifact: present
|
|
110
362
|
```
|
|
111
363
|
|
|
112
|
-
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
# Why the evidence matters
|
|
113
367
|
|
|
114
|
-
|
|
368
|
+
One of the design goals of CheckChange is to distinguish **"we measured it"** from **"we don't have enough evidence."**
|
|
369
|
+
|
|
370
|
+
For example:
|
|
371
|
+
|
|
372
|
+
```text
|
|
373
|
+
Coverage: 72%
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
is less useful than:
|
|
377
|
+
|
|
378
|
+
```text
|
|
379
|
+
Coverage: 72%
|
|
380
|
+
Evidence: ATTRIBUTED
|
|
381
|
+
Provider: LCOV
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
And that is still different from:
|
|
385
|
+
|
|
386
|
+
```text
|
|
387
|
+
Coverage: unavailable
|
|
388
|
+
Completeness: INCOMPLETE
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
The goal is to make those distinctions visible rather than hide them behind a single score.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
# Deterministic by design
|
|
396
|
+
|
|
397
|
+
The core evidence pipeline does not use an LLM to decide whether a change looks risky.
|
|
398
|
+
|
|
399
|
+
Given the same relevant inputs and CheckChange version, the goal is reproducible evidence.
|
|
400
|
+
|
|
401
|
+
That makes the output suitable for:
|
|
402
|
+
|
|
403
|
+
- CI
|
|
404
|
+
- automated workflows
|
|
405
|
+
- comparison between runs
|
|
406
|
+
- downstream AI systems
|
|
407
|
+
- human review
|
|
408
|
+
|
|
409
|
+
An AI system can consume the evidence if that's useful. CheckChange itself does not need to become another AI reviewer.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
# CI
|
|
414
|
+
|
|
415
|
+
CheckChange can produce output intended for CI systems, including:
|
|
115
416
|
|
|
116
417
|
```bash
|
|
117
|
-
checkchange check --
|
|
418
|
+
checkchange check --format github
|
|
118
419
|
```
|
|
119
420
|
|
|
120
421
|
```bash
|
|
121
|
-
checkchange check --
|
|
422
|
+
checkchange check --format junit
|
|
122
423
|
```
|
|
123
424
|
|
|
124
425
|
```bash
|
|
125
|
-
checkchange check --
|
|
426
|
+
checkchange check --format sarif
|
|
126
427
|
```
|
|
127
428
|
|
|
128
|
-
|
|
429
|
+
Machine-readable JSON is also available:
|
|
129
430
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
| `doctor` | Verify runtime prerequisites (Node, pnpm, coverage, git) |
|
|
134
|
-
| `prepare-repo` | Bootstrap test runners & coverage tooling (detect → plan → approve → install → verify) |
|
|
135
|
-
| `explain` | Show rule rationale for a given verdict |
|
|
136
|
-
| `trace` | Print evidence trace for a specific function |
|
|
137
|
-
| `delta` | Compare evidence between two refs |
|
|
431
|
+
```bash
|
|
432
|
+
checkchange check --json
|
|
433
|
+
```
|
|
138
434
|
|
|
139
|
-
|
|
435
|
+
This makes it possible to use the same evidence both for human-facing development workflows and automated pipelines.
|
|
140
436
|
|
|
141
|
-
|
|
437
|
+
---
|
|
142
438
|
|
|
143
|
-
|
|
439
|
+
# Dependencies and external tools
|
|
144
440
|
|
|
145
|
-
|
|
146
|
-
2. **Complexity** — per-function CRAP via `crap-typescript` (TS/JS) or Python AST (`src/complexity-providers/pythonASTComplexityProvider.ts`)
|
|
147
|
-
3. **Coverage** — map LCOV/istanbul lines to changed functions (`src/coverage-providers/lcovProvider.ts`)
|
|
148
|
-
4. **Attribution** — case-insensitive suffix match to provider-lowercased paths (`src/attribution.ts:91`)
|
|
149
|
-
5. **crapCalc** — combine complexity + coverage → CRAP score (`src/crapCalc.ts:5`)
|
|
150
|
-
6. **Rules** — INV-01..04 evaluated against thresholds (`src/evidence.ts:828`)
|
|
151
|
-
7. **Evidence** — schema 0.5 (`src/evidence.ts:644`, `src/delta.ts:35`)
|
|
152
|
-
8. **Output** — human-readable summary by default; JSON via `--json`, or `--format github|junit|sarif` for CI annotations
|
|
441
|
+
CheckChange uses a small number of external packages and tools for its analysis.
|
|
153
442
|
|
|
154
|
-
|
|
443
|
+
The main runtime requirements are:
|
|
155
444
|
|
|
156
|
-
|
|
445
|
+
- Node 24
|
|
446
|
+
- pnpm 11.17.0
|
|
447
|
+
- Git
|
|
157
448
|
|
|
158
|
-
|
|
449
|
+
The supported analysis paths also use packages for TypeScript/JavaScript complexity and coverage processing, along with Python tooling where the Python analysis path is used.
|
|
159
450
|
|
|
160
|
-
|
|
161
|
-
|------|-------------|---------|
|
|
162
|
-
| `--base <ref>` | Git base ref for diff | auto-detect |
|
|
163
|
-
| `--crap-threshold <n>` | CRAP WARN threshold | 30 |
|
|
164
|
-
| `--coverage-file <path>` | Explicit LCOV/istanbul path | auto-detect |
|
|
165
|
-
| `--format <github\|junit\|sarif>` | Output format; JSON is the `--json` flag | none |
|
|
451
|
+
For the authoritative dependency versions and provider details, see `package.json` and the project documentation.
|
|
166
452
|
|
|
167
|
-
|
|
453
|
+
---
|
|
168
454
|
|
|
169
|
-
|
|
455
|
+
# Development
|
|
170
456
|
|
|
171
|
-
|
|
457
|
+
Install dependencies:
|
|
172
458
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
| `@barney-media/crap-typescript-core` | 0.5.0 | Core engine: `findAllTypeScriptFilesUnderSourceRoots` + `parseFileMethods` (`src/complexity.ts:1`), `parseCoverageReport` + `coverageForMethods` (`src/coverage.ts:6`, `src/attribution.ts:1-2`), CRAP calc provenance (`src/evidence.ts:684`, `src/attribution.ts:17`) | [npm](https://www.npmjs.com/package/@barney-media/crap-typescript-core) |
|
|
459
|
+
```bash
|
|
460
|
+
pnpm install
|
|
461
|
+
```
|
|
177
462
|
|
|
178
|
-
|
|
463
|
+
Run tests:
|
|
179
464
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
465
|
+
```bash
|
|
466
|
+
pnpm test
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
Run the TypeScript compiler:
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
npx tsc --noEmit
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Build:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
pnpm run build
|
|
479
|
+
```
|
|
188
480
|
|
|
189
|
-
|
|
481
|
+
Before making changes, check the repository's development documentation and current project status. CheckChange has a fairly deliberate evidence contract, and changes to evidence semantics should not be treated like ordinary refactoring.
|
|
190
482
|
|
|
191
|
-
|
|
192
|
-
|------|----------------------|---------|----------|
|
|
193
|
-
| `node` | 24 | Runtime; bin shebang `src/cli.ts:1` `#!/usr/bin/env node` | `.nvmrc:1` |
|
|
194
|
-
| `pnpm` | 11.17.0 | Install + build; `prepare` needs pnpm+tsc | `package.json:5` |
|
|
195
|
-
| `git` | system | Diff enumeration `git diff --unified=0` (`src/evidence.ts:839`), `git ls-files` (`src/complexity.ts:20`) | `src/git.ts:1,18,35,59,145` |
|
|
196
|
-
| `lcov` | file format `.info`/`.lcov` | Alternate coverage input; parsed via `parseLcovContent` (`src/coverage-providers/lcovProvider.ts:17`) | `src/coverage.ts:404,469` |
|
|
197
|
-
| `python` + `coverage.py` + `pytest` | python3 | Python stack detection + coverage conversion (`src/providers/config.ts:67-73,92-96`) | `src/coverage.ts:65,247` |
|
|
483
|
+
---
|
|
198
484
|
|
|
199
|
-
|
|
485
|
+
# Contributing
|
|
200
486
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
487
|
+
Issues and pull requests are welcome.
|
|
488
|
+
|
|
489
|
+
If you want to contribute, please keep the project's core ideas in mind:
|
|
490
|
+
|
|
491
|
+
- evidence should be deterministic where practical
|
|
492
|
+
- provenance should remain visible
|
|
493
|
+
- incomplete evidence should not be disguised as complete evidence
|
|
494
|
+
- technical behavior should be reproducible
|
|
495
|
+
- evidence and interpretation should remain separate
|
|
496
|
+
- new capabilities should be justified by actual use cases
|
|
497
|
+
|
|
498
|
+
The repository contains additional architecture, contract, testing, experiment, and development documentation.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
# Where this is going
|
|
503
|
+
|
|
504
|
+
The immediate goal is not to turn CheckChange into a giant platform.
|
|
505
|
+
|
|
506
|
+
The more interesting question is whether an independent evidence layer becomes genuinely useful as AI-assisted development becomes more common.
|
|
507
|
+
|
|
508
|
+
The basic model is:
|
|
509
|
+
|
|
510
|
+
```text
|
|
511
|
+
AI writes
|
|
512
|
+
↓
|
|
513
|
+
CheckChange checks the change
|
|
514
|
+
↓
|
|
515
|
+
Evidence
|
|
516
|
+
↓
|
|
517
|
+
Human / CI / another system decides what to do
|
|
518
|
+
```
|
|
205
519
|
|
|
206
|
-
|
|
520
|
+
If that turns out to be useful, there is plenty more we can build around it.
|
|
207
521
|
|
|
208
|
-
|
|
522
|
+
---
|
|
209
523
|
|
|
210
|
-
|
|
524
|
+
# License
|
|
211
525
|
|
|
212
|
-
MIT — see [LICENSE
|
|
526
|
+
MIT — see [`LICENSE`](LICENSE).
|
|
213
527
|
|
|
214
|
-
|
|
528
|
+
# Changelog
|
|
215
529
|
|
|
216
|
-
See [CHANGELOG.md](CHANGELOG.md).
|
|
530
|
+
See [`CHANGELOG.md`](CHANGELOG.md).
|
package/dist/crapCalc.d.ts
CHANGED
package/dist/crapCalc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Provenance for the crapCalc lineage stage. Self tool version tracks package.json
|
|
2
2
|
// (matches existing hard-coded '0.5.0' style for the core package).
|
|
3
|
-
export const crapCalcProvenance = { tool: 'checkchange', version: '0.4.
|
|
3
|
+
export const crapCalcProvenance = { tool: 'checkchange', version: '0.4.2' };
|
|
4
4
|
export function calculateCrap(cc, coveragePercent) {
|
|
5
5
|
if (coveragePercent == null) {
|
|
6
6
|
return null;
|
package/dist/evidence.d.ts
CHANGED
package/dist/evidence.js
CHANGED
|
@@ -19,7 +19,7 @@ import * as path from 'path';
|
|
|
19
19
|
import { loadProviderConfig, deriveRegistry, builtinConfig, createGenericCommandProvider } from './providers/index.js';
|
|
20
20
|
const requireFromEvidence = createRequire(import.meta.url);
|
|
21
21
|
// Self provenance; version mirrors package.json (existing codebase style hard-codes '0.5.0').
|
|
22
|
-
export const evidenceProvenance = { tool: 'checkchange', version: '0.4.
|
|
22
|
+
export const evidenceProvenance = { tool: 'checkchange', version: '0.4.2' };
|
|
23
23
|
function sha256Hex(content) {
|
|
24
24
|
return createHash('sha256').update(content).digest('hex');
|
|
25
25
|
}
|
package/dist/providers/config.js
CHANGED
|
@@ -47,11 +47,9 @@ export function builtinConfig() {
|
|
|
47
47
|
language: 'python',
|
|
48
48
|
extensions: PY_EXTENSIONS,
|
|
49
49
|
coverageFiles: ['.coverage', 'coverage.xml', 'coverage.json', 'coverage/coverage-final.json'],
|
|
50
|
-
coverageCmd: 'coverage json -o {out}',
|
|
51
50
|
testRunners: [PYTEST_RUNNER],
|
|
52
51
|
},
|
|
53
52
|
],
|
|
54
|
-
allowlist: ['./checkchange.providers.json', './.checkchange/providers.json'],
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
// ---- Config loading ----
|
|
@@ -82,6 +80,24 @@ function validateInstallField(install, i, j) {
|
|
|
82
80
|
if (!Array.isArray(install.packages))
|
|
83
81
|
throw new Error(`config: providers[${i}].testRunners[${j}].install.packages must be an array`);
|
|
84
82
|
}
|
|
83
|
+
// BEHAVIOR CHANGE: providers[].coverageCmd moves from silently-ignored to REJECTED at load.
|
|
84
|
+
// It was declared (ProviderEntry.coverageCmd) and mapped (deriveRegistry) but never executed —
|
|
85
|
+
// nothing in src/ spawns it. Exact error text:
|
|
86
|
+
// config: providers[<i>].coverageCmd not supported (never executed); remove the key
|
|
87
|
+
// Option (a) taken: reject at validateConfig (the schema choke point for both file-based load
|
|
88
|
+
// paths, :166 + :187) and strip builtinConfig's own copy, since the builtin path :189 bypasses
|
|
89
|
+
// validateConfig. deriveRegistry stays a pure mapper. Any present value rejects, including an
|
|
90
|
+
// explicit `coverageCmd: null` — the operator wrote the key, so tell them to delete it rather
|
|
91
|
+
// than silently accept a field the tool ignores.
|
|
92
|
+
// Migration: delete coverageCmd from checkchange.providers.json / .checkchange/providers.json.
|
|
93
|
+
// The same change removed the dead `allowlist` field (zero readers; it duplicated
|
|
94
|
+
// REPO_ROOT_NAMES below). JSON configs carrying it still load unchanged, so no migration.
|
|
95
|
+
// ponytail: own function to match validateTestRunner/validateInstallField above.
|
|
96
|
+
function rejectCoverageCmd(entry, i) {
|
|
97
|
+
if (entry.coverageCmd !== undefined) {
|
|
98
|
+
throw new Error(`config: providers[${i}].coverageCmd not supported (never executed); remove the key`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
85
101
|
function validateConfig(raw) {
|
|
86
102
|
if (!isRecord(raw))
|
|
87
103
|
throw new Error('config: not an object');
|
|
@@ -96,6 +112,7 @@ function validateConfig(raw) {
|
|
|
96
112
|
throw new Error(`config: providers[${i}].language missing`);
|
|
97
113
|
if (!Array.isArray(entry.extensions))
|
|
98
114
|
throw new Error(`config: providers[${i}].extensions missing`);
|
|
115
|
+
rejectCoverageCmd(entry, i);
|
|
99
116
|
if (entry.testRunners !== undefined) {
|
|
100
117
|
if (!Array.isArray(entry.testRunners))
|
|
101
118
|
throw new Error(`config: providers[${i}].testRunners not an array`);
|
|
@@ -98,8 +98,10 @@ export declare function executeInstallPlan(plan: InstallPlan[], options: Prepare
|
|
|
98
98
|
* Flush config pins (provider install specs) to disk after a successful install.
|
|
99
99
|
* Reads the existing config file (JSON.parse if present, else empty {}), merges
|
|
100
100
|
* pin provider entries by language → testRunner name (updating `install` on match,
|
|
101
|
-
* appending otherwise), and writes atomically via tmp file
|
|
102
|
-
*
|
|
101
|
+
* appending otherwise), and writes atomically via a pid-suffixed tmp file created
|
|
102
|
+
* with O_EXCL + rename, after a realpath containment check against cwd (the sync
|
|
103
|
+
* mirror of the hardened pattern in src/cache.ts writeEntry()). Returns the
|
|
104
|
+
* config-file keys that were written.
|
|
103
105
|
*/
|
|
104
106
|
export declare function flushConfigUpdates(plan: InstallPlan[], cwd: string): string[];
|
|
105
107
|
/** Per self-analyzer probe result. */
|
|
@@ -330,12 +330,45 @@ export async function executeInstallPlan(plan, options) {
|
|
|
330
330
|
ok: !actions.some((r) => r.status === 'failed'),
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Containment guard, sync mirror of cache.ts isWithin(): the candidate must
|
|
335
|
+
* realpath inside root. Best-effort, not a proof — the realpath arm and the
|
|
336
|
+
* write that follows are separate operations, so a swap between them is not
|
|
337
|
+
* covered. The lexical fallback is what keeps the check usable BEFORE the
|
|
338
|
+
* config file exists (first flush into a fresh repo).
|
|
339
|
+
*/
|
|
340
|
+
function resolvesWithin(candidate, root) {
|
|
341
|
+
let realCandidate = candidate;
|
|
342
|
+
let realRoot = root;
|
|
343
|
+
try {
|
|
344
|
+
realCandidate = fs.realpathSync(candidate);
|
|
345
|
+
realRoot = fs.realpathSync(root);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
// one of the two does not resolve yet — fall back to the lexical check
|
|
349
|
+
}
|
|
350
|
+
const rel = path.relative(realRoot, realCandidate);
|
|
351
|
+
return !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
352
|
+
}
|
|
353
|
+
/** Unlink that never throws. unlink does not follow symlinks, so this frees a
|
|
354
|
+
* tmp slot without ever touching a link target. A stale tmp costs one skipped
|
|
355
|
+
* write, never a crash. */
|
|
356
|
+
function unlinkQuiet(p) {
|
|
357
|
+
try {
|
|
358
|
+
fs.unlinkSync(p);
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
// best effort
|
|
362
|
+
}
|
|
363
|
+
}
|
|
333
364
|
/**
|
|
334
365
|
* Flush config pins (provider install specs) to disk after a successful install.
|
|
335
366
|
* Reads the existing config file (JSON.parse if present, else empty {}), merges
|
|
336
367
|
* pin provider entries by language → testRunner name (updating `install` on match,
|
|
337
|
-
* appending otherwise), and writes atomically via tmp file
|
|
338
|
-
*
|
|
368
|
+
* appending otherwise), and writes atomically via a pid-suffixed tmp file created
|
|
369
|
+
* with O_EXCL + rename, after a realpath containment check against cwd (the sync
|
|
370
|
+
* mirror of the hardened pattern in src/cache.ts writeEntry()). Returns the
|
|
371
|
+
* config-file keys that were written.
|
|
339
372
|
*/
|
|
340
373
|
export function flushConfigUpdates(plan, cwd) {
|
|
341
374
|
const written = new Set();
|
|
@@ -350,6 +383,10 @@ export function flushConfigUpdates(plan, cwd) {
|
|
|
350
383
|
if (!pinProviders?.length)
|
|
351
384
|
continue;
|
|
352
385
|
const configPath = path.resolve(cwd, configKey);
|
|
386
|
+
// Containment BEFORE any I/O: a symlink holding configPath (or a swapped
|
|
387
|
+
// cwd) would otherwise be read through and then clobbered by the rename.
|
|
388
|
+
if (!resolvesWithin(configPath, cwd))
|
|
389
|
+
continue;
|
|
353
390
|
let existing;
|
|
354
391
|
try {
|
|
355
392
|
existing = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
@@ -381,9 +418,31 @@ export function flushConfigUpdates(plan, cwd) {
|
|
|
381
418
|
existingProviders.push(pinProvider);
|
|
382
419
|
}
|
|
383
420
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
421
|
+
// Atomic write. The tmp name is pid-suffixed so concurrent flushes do not
|
|
422
|
+
// share a slot, and `flag: 'wx'` (O_EXCL) makes the create fail EEXIST
|
|
423
|
+
// rather than write THROUGH anything already holding that name — a planted
|
|
424
|
+
// symlink's target is therefore never modified. On any failure the name is
|
|
425
|
+
// unlinked so a later flush retries on a clean slot, the key is left out of
|
|
426
|
+
// `written`, and a console.warn names the failure — an absent JSON entry alone
|
|
427
|
+
// was not enough, since the human path prints nothing about the config write.
|
|
428
|
+
const tmpPath = `${configPath}.tmp.${process.pid}`;
|
|
429
|
+
try {
|
|
430
|
+
fs.writeFileSync(tmpPath, JSON.stringify(existing, null, 2), { flag: 'wx' });
|
|
431
|
+
// Re-check both endpoints after the write, before the rename overwrites.
|
|
432
|
+
if (!resolvesWithin(tmpPath, cwd) || !resolvesWithin(configPath, cwd)) {
|
|
433
|
+
unlinkQuiet(tmpPath);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
fs.renameSync(tmpPath, configPath);
|
|
437
|
+
}
|
|
438
|
+
catch (err) {
|
|
439
|
+
unlinkQuiet(tmpPath);
|
|
440
|
+
// Never silent: the caller derives its exit code from install.ok alone,
|
|
441
|
+
// so a swallowed failure here would leave the operator believing the
|
|
442
|
+
// provider pin was recorded when it was not.
|
|
443
|
+
console.warn(`prepare-repo: could not write ${configKey} via ${tmpPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
387
446
|
written.add(configKey);
|
|
388
447
|
}
|
|
389
448
|
}
|
package/dist/rules.d.ts
CHANGED
package/dist/rules.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Provenance for the rules lineage stage. Self tool version tracks package.json.
|
|
2
|
-
export const rulesProvenance = { tool: 'checkchange', version: '0.4.
|
|
2
|
+
export const rulesProvenance = { tool: 'checkchange', version: '0.4.2' };
|
|
3
3
|
/**
|
|
4
4
|
* Evaluate changed functions against the high-CRAP rule.
|
|
5
5
|
* @param changed Array of changed functions
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkchange",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"packageManager": "pnpm@11.17.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"checkchange": "
|
|
9
|
-
"code-risk": "
|
|
8
|
+
"checkchange": "dist/cli.js",
|
|
9
|
+
"code-risk": "dist/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|