mandrel 2.72.0 → 2.73.0
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.
|
@@ -11,6 +11,8 @@ import { isCoverageFresh } from '../coverage-capture.js';
|
|
|
11
11
|
import { loadCoverage as loadCoverageDefault } from '../coverage-utils.js';
|
|
12
12
|
import { checkResolutionFloor, scanAndScore } from '../crap-utils.js';
|
|
13
13
|
import { Logger } from '../Logger.js';
|
|
14
|
+
import { isIgnoredByGlobs } from '../maintainability-utils.js';
|
|
15
|
+
import { isScorableSourceFile } from '../source-extensions.js';
|
|
14
16
|
import { parseDiffScopeFlag } from './diff-scope-cli.js';
|
|
15
17
|
import {
|
|
16
18
|
checkSeatResolution,
|
|
@@ -187,11 +189,60 @@ export function buildCrapUpdaterScorer(
|
|
|
187
189
|
/** Stamp scopes a capture may have written; any one fresh stamp suffices. */
|
|
188
190
|
const CAPTURE_SCOPES = ['full', 'incremental', 'affected'];
|
|
189
191
|
|
|
192
|
+
/**
|
|
193
|
+
* The coverage artifact when any capture stamp marks it fresh for the
|
|
194
|
+
* current tree; otherwise `null`.
|
|
195
|
+
*
|
|
196
|
+
* @param {{coveragePath: string, targetDirs: string[]}} options
|
|
197
|
+
* @param {{isFresh: Function, loadCoverage: Function, cwd: string}} deps
|
|
198
|
+
* @returns {object|null}
|
|
199
|
+
*/
|
|
200
|
+
function loadFreshCoverage(options, { isFresh, loadCoverage, cwd }) {
|
|
201
|
+
const fresh = CAPTURE_SCOPES.some(
|
|
202
|
+
(requireScope) =>
|
|
203
|
+
isFresh({
|
|
204
|
+
coveragePath: options.coveragePath,
|
|
205
|
+
targetDirs: options.targetDirs,
|
|
206
|
+
cwd,
|
|
207
|
+
requireScope,
|
|
208
|
+
}).fresh,
|
|
209
|
+
);
|
|
210
|
+
return fresh ? loadCoverage(path.resolve(cwd, options.coveragePath)) : null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Whether `file` (repo-relative) is one the CRAP scan would score: a scorable
|
|
215
|
+
* source under a `targetDirs` entry and not ignored. It may over-include
|
|
216
|
+
* against the walk's directory skips — that only keeps the refusal, never
|
|
217
|
+
* seats an unmeasured file.
|
|
218
|
+
*
|
|
219
|
+
* @param {string} file
|
|
220
|
+
* @param {{targetDirs: string[], ignoreGlobs: string[]}} options
|
|
221
|
+
* @param {string} cwd
|
|
222
|
+
* @returns {boolean}
|
|
223
|
+
*/
|
|
224
|
+
function isInCrapScope(file, { targetDirs, ignoreGlobs }, cwd) {
|
|
225
|
+
if (!isScorableSourceFile(file)) return false;
|
|
226
|
+
const abs = path.resolve(cwd, file);
|
|
227
|
+
const underTarget = targetDirs.some((dir) => {
|
|
228
|
+
const rel = path.relative(path.resolve(cwd, dir), abs);
|
|
229
|
+
return (
|
|
230
|
+
rel !== '' &&
|
|
231
|
+
rel !== '..' &&
|
|
232
|
+
!rel.startsWith(`..${path.sep}`) &&
|
|
233
|
+
!path.isAbsolute(rel)
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
return underTarget && !isIgnoredByGlobs(abs, ignoreGlobs, cwd);
|
|
237
|
+
}
|
|
238
|
+
|
|
190
239
|
/**
|
|
191
240
|
* The `--seat-missing` scorer: refuses (throws {@link SeatRefusal}) unless
|
|
192
241
|
* the coverage artifact is fresh for the current tree and every in-scope
|
|
193
242
|
* method resolved a coverage entry — a wrong-coordinate row stays wrong even
|
|
194
|
-
* when it is only inserted.
|
|
243
|
+
* when it is only inserted. A diff with no in-scope file seats nothing and
|
|
244
|
+
* never consults coverage: affected-mode capture rightly writes no artifact
|
|
245
|
+
* for it.
|
|
195
246
|
*
|
|
196
247
|
* @param {ReturnType<typeof resolveCrapUpdaterOptions>} options
|
|
197
248
|
* @param {{loadCoverage: Function, scan?: Function, isFresh?: Function,
|
|
@@ -210,22 +261,13 @@ export function buildCrapSeatScorer(
|
|
|
210
261
|
) {
|
|
211
262
|
const fixCommand = `node .agents/scripts/coverage-capture.js --cwd ${cwd}`;
|
|
212
263
|
return async (files) => {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
coveragePath: options.coveragePath,
|
|
217
|
-
targetDirs: options.targetDirs,
|
|
218
|
-
cwd,
|
|
219
|
-
requireScope,
|
|
220
|
-
}).fresh,
|
|
221
|
-
);
|
|
222
|
-
const coverage = fresh
|
|
223
|
-
? loadCoverage(path.resolve(cwd, options.coveragePath))
|
|
224
|
-
: null;
|
|
264
|
+
const inScope = files.filter((file) => isInCrapScope(file, options, cwd));
|
|
265
|
+
if (inScope.length === 0) return [];
|
|
266
|
+
const coverage = loadFreshCoverage(options, { isFresh, loadCoverage, cwd });
|
|
225
267
|
if (!coverage) {
|
|
226
268
|
throw new SeatRefusal(
|
|
227
269
|
`[CRAP] --seat-missing refused: no coverage artifact at ${options.coveragePath} is fresh for the current tree ` +
|
|
228
|
-
`(method resolution unmeasured; unresolved files: ${
|
|
270
|
+
`(method resolution unmeasured; unresolved files: ${inScope.join(', ')}).\n` +
|
|
229
271
|
`Fix: re-capture coverage for the current tree — ${fixCommand}`,
|
|
230
272
|
);
|
|
231
273
|
}
|
|
@@ -235,7 +277,7 @@ export function buildCrapSeatScorer(
|
|
|
235
277
|
requireCoverage: options.requireCoverage,
|
|
236
278
|
cwd,
|
|
237
279
|
ignoreGlobs: options.ignoreGlobs,
|
|
238
|
-
scopeFiles:
|
|
280
|
+
scopeFiles: inScope,
|
|
239
281
|
});
|
|
240
282
|
reportScanSummary(summary, logger);
|
|
241
283
|
const refusal = checkSeatResolution(summary.resolution, fixCommand);
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,13 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
-->
|
|
16
16
|
<!-- markdownlint-disable-file MD004 MD012 MD037 -->
|
|
17
17
|
|
|
18
|
+
## [2.73.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.72.0...mandrel-v2.73.0) (2026-10-02)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
* **baselines:** CRAP --seat-missing seats nothing, without demanding coverage, when no diff file is in the gate's scope ([#5540](https://github.com/dsj1984/mandrel/issues/5540)) ([#5541](https://github.com/dsj1984/mandrel/issues/5541)) ([169798e](https://github.com/dsj1984/mandrel/commit/169798ef90e32030148203e8e881f60ee907e404))
|
|
24
|
+
|
|
18
25
|
## [2.72.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.71.0...mandrel-v2.72.0) (2026-10-01)
|
|
19
26
|
|
|
20
27
|
|
package/package.json
CHANGED