mandrel 2.122.0 → 2.124.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.
- package/.agents/README.md +1 -1
- package/.agents/docs/agentrc-reference.json +1 -0
- package/.agents/docs/configuration.md +10 -7
- package/.agents/runtime-deps.json +2 -2
- package/.agents/schemas/agentrc.schema.json +26 -4
- package/.agents/schemas/audit-rules.schema.json +1 -1
- package/.agents/schemas/story-deliver-terminal.schema.json +7 -2
- package/.agents/scripts/check-doc-links.js +4 -4
- package/.agents/scripts/lib/audit-baselines/surface-entry.js +2 -2
- package/.agents/scripts/lib/audit-exceptions/globs.js +2 -2
- package/.agents/scripts/lib/audit-exceptions/scope.js +2 -2
- package/.agents/scripts/lib/audit-suite/selector.js +3 -3
- package/.agents/scripts/lib/baselines/bundle-size-scorer.js +3 -3
- package/.agents/scripts/lib/baselines/components.js +2 -2
- package/.agents/scripts/lib/baselines/kinds/_crap-new-method-gate.js +2 -2
- package/.agents/scripts/lib/bdd-runner-detect.js +3 -4
- package/.agents/scripts/lib/close-validation/base-sync-revalidation.js +2 -2
- package/.agents/scripts/lib/close-validation/gates.js +16 -3
- package/.agents/scripts/lib/close-validation/test-delta.js +9 -4
- package/.agents/scripts/lib/config/gates/coverage.schema.js +2 -2
- package/.agents/scripts/lib/config/handoff.js +21 -6
- package/.agents/scripts/lib/config-settings-schema-delivery.js +19 -10
- package/.agents/scripts/lib/config-settings-schema-quality.js +1 -1
- package/.agents/scripts/lib/coverage-baseline.js +8 -4
- package/.agents/scripts/lib/coverage-capture-delta.js +2 -2
- package/.agents/scripts/lib/coverage-capture-own-fix.js +2 -2
- package/.agents/scripts/lib/generated/agentrc-validator.js +2 -2
- package/.agents/scripts/lib/git-test-guard.js +119 -0
- package/.agents/scripts/lib/git-utils.js +3 -0
- package/.agents/scripts/lib/maintainability-utils.js +4 -4
- package/.agents/scripts/lib/observability/handoff-telemetry.js +2 -0
- package/.agents/scripts/lib/orchestration/acceptance-eval-decision.js +3 -2
- package/.agents/scripts/lib/orchestration/block-class-recovery.js +44 -0
- package/.agents/scripts/lib/orchestration/code-review.js +35 -19
- package/.agents/scripts/lib/orchestration/diff-magnitude.js +1 -1
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/filters.js +3 -3
- package/.agents/scripts/lib/orchestration/handoff-suite-of-record.js +15 -7
- package/.agents/scripts/lib/orchestration/merge-queue.js +36 -10
- package/.agents/scripts/lib/orchestration/plan-persist/audit-attribution.js +3 -4
- package/.agents/scripts/lib/orchestration/review-history.js +9 -10
- package/.agents/scripts/lib/orchestration/review-providers/code-review.js +9 -2
- package/.agents/scripts/lib/orchestration/review-providers/codex-cli.js +8 -5
- package/.agents/scripts/lib/orchestration/review-providers/codex.js +3 -11
- package/.agents/scripts/lib/orchestration/review-providers/mi-exemptions.js +2 -2
- package/.agents/scripts/lib/orchestration/review-providers/review-depth.js +22 -0
- package/.agents/scripts/lib/orchestration/review-providers/security-review.js +10 -2
- package/.agents/scripts/lib/orchestration/review-providers/types.js +2 -0
- package/.agents/scripts/lib/orchestration/review-providers/ultrareview.js +13 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +40 -15
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +8 -1
- package/.agents/scripts/lib/orchestration/story-handoff.js +216 -54
- package/.agents/scripts/lib/test-temp.js +5 -5
- package/.agents/scripts/lib/test-tiers.js +3 -3
- package/.agents/scripts/lib/util/glob-match.js +64 -0
- package/.agents/scripts/lib/wave-runner/footprint.js +3 -3
- package/.agents/scripts/run-tests.js +2 -1
- package/.agents/scripts/single-story-init.js +3 -3
- package/.agents/workflows/helpers/code-review.md +8 -1
- package/.agents/workflows/helpers/deliver-digest.md +23 -24
- package/.agents/workflows/helpers/deliver-reference.md +62 -26
- package/.agents/workflows/helpers/deliver-story-reference.md +10 -3
- package/.agents/workflows/helpers/deliver-story.md +27 -7
- package/.agents/workflows/mandrel-deliver.md +8 -2
- package/docs/CHANGELOG.md +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git-test-guard.js — refuses a branch- or ref-moving git command in the
|
|
3
|
+
* checkout under test.
|
|
4
|
+
*
|
|
5
|
+
* `run-tests.js` sets `MANDREL_TEST_GUARD_ROOT` to the repository it tests.
|
|
6
|
+
* A test that forgets its temp cwd would otherwise check out and fast-forward
|
|
7
|
+
* that checkout mid-suite, swapping the source tree under parallel tests.
|
|
8
|
+
* Production never sets the variable, so this is a no-op outside the suite.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { spawnCapture } from './child-exec.js';
|
|
14
|
+
|
|
15
|
+
const TEST_GUARD_ROOT_ENV = 'MANDREL_TEST_GUARD_ROOT';
|
|
16
|
+
|
|
17
|
+
const MOVING = new Set([
|
|
18
|
+
'checkout',
|
|
19
|
+
'switch',
|
|
20
|
+
'merge',
|
|
21
|
+
'reset',
|
|
22
|
+
'rebase',
|
|
23
|
+
'pull',
|
|
24
|
+
'stash',
|
|
25
|
+
'worktree',
|
|
26
|
+
'commit',
|
|
27
|
+
'update-ref',
|
|
28
|
+
]);
|
|
29
|
+
const BRANCH_MOVING_FLAGS = new Set([
|
|
30
|
+
'-f',
|
|
31
|
+
'--force',
|
|
32
|
+
'-d',
|
|
33
|
+
'-D',
|
|
34
|
+
'--delete',
|
|
35
|
+
'-m',
|
|
36
|
+
'-M',
|
|
37
|
+
'--move',
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
/** First non-option argument, skipping `-c k=v` and `-C <dir>` pairs. */
|
|
41
|
+
function subcommandOf(args) {
|
|
42
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
43
|
+
if (args[i] === '-c' || args[i] === '-C') i += 1;
|
|
44
|
+
else if (!String(args[i]).startsWith('-')) return { name: args[i], at: i };
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isMoving(args) {
|
|
50
|
+
const sub = subcommandOf(args);
|
|
51
|
+
if (!sub) return false;
|
|
52
|
+
if (MOVING.has(sub.name)) return true;
|
|
53
|
+
return (
|
|
54
|
+
sub.name === 'branch' &&
|
|
55
|
+
args.slice(sub.at + 1).some((a) => BRANCH_MOVING_FLAGS.has(a))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// `.native` expands Windows 8.3 short names (RUNNER~1) that git never prints.
|
|
60
|
+
function realpathOr(p) {
|
|
61
|
+
try {
|
|
62
|
+
return fs.realpathSync.native(path.resolve(p));
|
|
63
|
+
} catch {
|
|
64
|
+
return path.resolve(p);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Windows paths compare case-insensitively. */
|
|
69
|
+
function samePath(a, b) {
|
|
70
|
+
return process.platform === 'win32'
|
|
71
|
+
? a?.toLowerCase() === b.toLowerCase()
|
|
72
|
+
: a === b;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The toplevel of the repository `cwd` sits in, or null outside one. */
|
|
76
|
+
function toplevelOf(cwd) {
|
|
77
|
+
const env = Object.fromEntries(
|
|
78
|
+
Object.entries(process.env).filter(([k]) => !k.startsWith('GIT_')),
|
|
79
|
+
);
|
|
80
|
+
const res = spawnCapture('git', ['rev-parse', '--show-toplevel'], {
|
|
81
|
+
cwd,
|
|
82
|
+
env,
|
|
83
|
+
});
|
|
84
|
+
return res.status === 0 ? realpathOr(res.stdout) : null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Arm a test child env with the checkout under test: an inherited root wins,
|
|
89
|
+
* else the toplevel of the current directory.
|
|
90
|
+
*
|
|
91
|
+
* @param {NodeJS.ProcessEnv} env mutated in place
|
|
92
|
+
* @param {NodeJS.ProcessEnv} baseEnv
|
|
93
|
+
* @returns {NodeJS.ProcessEnv} `env`
|
|
94
|
+
*/
|
|
95
|
+
export function armGitGuard(env, baseEnv) {
|
|
96
|
+
const root = baseEnv[TEST_GUARD_ROOT_ENV] ?? toplevelOf(process.cwd());
|
|
97
|
+
if (root) env[TEST_GUARD_ROOT_ENV] = root;
|
|
98
|
+
return env;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Throw before a moving git command runs in the guarded checkout. A nested
|
|
103
|
+
* fixture repository has its own toplevel, so it is never refused.
|
|
104
|
+
*
|
|
105
|
+
* @param {string} cwd
|
|
106
|
+
* @param {string[]} args
|
|
107
|
+
* @param {NodeJS.ProcessEnv} [env]
|
|
108
|
+
* @returns {void}
|
|
109
|
+
*/
|
|
110
|
+
export function assertGitAllowed(cwd, args, env = process.env) {
|
|
111
|
+
const root = env[TEST_GUARD_ROOT_ENV];
|
|
112
|
+
if (!root || !isMoving(args)) return;
|
|
113
|
+
const dir = realpathOr(cwd ?? process.cwd());
|
|
114
|
+
if (!fs.existsSync(dir) || !samePath(toplevelOf(dir), realpathOr(root)))
|
|
115
|
+
return;
|
|
116
|
+
throw new Error(
|
|
117
|
+
`git ${subcommandOf(args).name} refused in the checkout under test (${root}) — pass a temp cwd`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
7
7
|
import { execFileCapture, spawnCapture } from './child-exec.js';
|
|
8
|
+
import { assertGitAllowed } from './git-test-guard.js';
|
|
8
9
|
import { defaultSleep } from './util/sleep.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -62,6 +63,7 @@ export function __setGitRunners(exec, spawn) {
|
|
|
62
63
|
* @returns {string}
|
|
63
64
|
*/
|
|
64
65
|
function runGitSync(exec, cwd, args) {
|
|
66
|
+
assertGitAllowed(cwd, args);
|
|
65
67
|
return String(
|
|
66
68
|
execFileCapture('git', args, {
|
|
67
69
|
run: exec,
|
|
@@ -79,6 +81,7 @@ function runGitSync(exec, cwd, args) {
|
|
|
79
81
|
* @returns {GitResult}
|
|
80
82
|
*/
|
|
81
83
|
function runGitSpawn(spawn, cwd, args) {
|
|
84
|
+
assertGitAllowed(cwd, args);
|
|
82
85
|
return spawnCapture('git', args, {
|
|
83
86
|
run: spawn,
|
|
84
87
|
cwd,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import picomatch from 'picomatch';
|
|
3
2
|
import { canonicalise as canonicalisePath } from './baselines/path-canon.js';
|
|
4
3
|
import { POOL_SERIAL_THRESHOLD, runOnPool } from './cpu-pool.js';
|
|
5
4
|
import { Logger } from './Logger.js';
|
|
@@ -7,6 +6,7 @@ import { scoreFile } from './maintainability-engine.js';
|
|
|
7
6
|
import { isScored, reportUnscorable } from './maintainability-unscorable.js';
|
|
8
7
|
import { isScorableSourceFile } from './source-extensions.js';
|
|
9
8
|
import { CompilerMissingError } from './transpile.js';
|
|
9
|
+
import { globMatcher, isGlobMatch } from './util/glob-match.js';
|
|
10
10
|
import { walkFiles } from './util/paths.js';
|
|
11
11
|
|
|
12
12
|
const MAINTAINABILITY_WORKER_URL = new URL(
|
|
@@ -33,7 +33,7 @@ export const IGNORED_DIRS = new Set([
|
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Compiled matchers plus a per-path verdict memo, keyed on the pattern list:
|
|
36
|
-
* `
|
|
36
|
+
* `isGlobMatch()` recompiles per call, and the gates ask about the
|
|
37
37
|
* same path once per CRAP row. Inputs are immutable config, so it is bounded.
|
|
38
38
|
* `\u0000` is the join separator because it cannot occur in a glob, so two
|
|
39
39
|
* different lists cannot collide onto one key.
|
|
@@ -55,7 +55,7 @@ function ignoreMatcherEntry(ignoreGlobs) {
|
|
|
55
55
|
entry = {
|
|
56
56
|
matchers: ignoreGlobs
|
|
57
57
|
.filter((g) => typeof g === 'string')
|
|
58
|
-
.map((g) =>
|
|
58
|
+
.map((g) => globMatcher(g, { dot: true })),
|
|
59
59
|
verdicts: new Map(),
|
|
60
60
|
};
|
|
61
61
|
IGNORE_MATCHER_CACHE.set(key, entry);
|
|
@@ -69,7 +69,7 @@ function ignoreMatcherEntry(ignoreGlobs) {
|
|
|
69
69
|
* match.
|
|
70
70
|
*
|
|
71
71
|
* @param {string} filePath absolute or relative path to the source file
|
|
72
|
-
* @param {string[]} ignoreGlobs
|
|
72
|
+
* @param {string[]} ignoreGlobs glob patterns; empty/absent is a no-op
|
|
73
73
|
* @param {string} [cwd] root for repo-relative resolution; defaults to cwd
|
|
74
74
|
* @returns {boolean} true when the file matches at least one ignore glob
|
|
75
75
|
*/
|
|
@@ -22,6 +22,7 @@ const HANDOFF_CAUSES = Object.freeze(
|
|
|
22
22
|
'base-merge-conflict',
|
|
23
23
|
'base-merge-failed',
|
|
24
24
|
'preflight-unresolved',
|
|
25
|
+
'first-check',
|
|
25
26
|
'lint',
|
|
26
27
|
'format',
|
|
27
28
|
'quality-preview',
|
|
@@ -42,6 +43,7 @@ const HANDOFF_CAUSES = Object.freeze(
|
|
|
42
43
|
'ref-behind',
|
|
43
44
|
'push-hook',
|
|
44
45
|
'review-critical',
|
|
46
|
+
'review-cap',
|
|
45
47
|
'other',
|
|
46
48
|
]),
|
|
47
49
|
);
|
|
@@ -17,12 +17,13 @@ const EPIC_SIGNALS_BASENAME = 'signals.ndjson';
|
|
|
17
17
|
const MET_VERDICTS = Object.freeze(new Set(['met']));
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Integer ≥ 1 — the last guard against an unbounded redraft loop.
|
|
20
|
+
* Integer ≥ 1 — the last guard against an unbounded redraft loop. Shared
|
|
21
|
+
* with the handoff's held-review round cap, so the two gates cannot drift.
|
|
21
22
|
*
|
|
22
23
|
* @param {unknown} value
|
|
23
24
|
* @returns {number}
|
|
24
25
|
*/
|
|
25
|
-
function effectiveCap(value) {
|
|
26
|
+
export function effectiveCap(value) {
|
|
26
27
|
if (typeof value !== 'number' || !Number.isInteger(value) || value < 1) {
|
|
27
28
|
return 1;
|
|
28
29
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// .agents/scripts/lib/orchestration/block-class-recovery.js
|
|
2
|
+
/**
|
|
3
|
+
* block-class-recovery.js — who clears each terminal block class: the
|
|
4
|
+
* delivering session (`agent`) or a human (`operator`).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ADVISORY_GATE_INCONCLUSIVE_CLASS,
|
|
9
|
+
ADVISORY_GATE_RED_CLASS,
|
|
10
|
+
CHECKS_FAILED_CLASS,
|
|
11
|
+
} from './merge-poll.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Who clears each block: `agent` classes have a remedy the delivering session
|
|
15
|
+
* executes itself (fix + push, rerun, re-confirm), so they are not the HITL
|
|
16
|
+
* pause; `operator` classes need a setting, approval or decision the agent
|
|
17
|
+
* cannot make.
|
|
18
|
+
*/
|
|
19
|
+
export const BLOCK_CLASS_RECOVERY = Object.freeze({
|
|
20
|
+
[CHECKS_FAILED_CLASS]: 'agent',
|
|
21
|
+
'checks-pending-timeout': 'agent',
|
|
22
|
+
'branch-protection-human-required': 'operator',
|
|
23
|
+
'arm-failure': 'operator',
|
|
24
|
+
'api-race-other': 'agent',
|
|
25
|
+
'predicate-refused': 'operator',
|
|
26
|
+
[ADVISORY_GATE_RED_CLASS]: 'agent',
|
|
27
|
+
[ADVISORY_GATE_INCONCLUSIVE_CLASS]: 'agent',
|
|
28
|
+
'merge-queue-rest-unsupported': 'operator',
|
|
29
|
+
'queue-ejected': 'agent',
|
|
30
|
+
'merged-flip-failed': 'agent',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} blockClass
|
|
35
|
+
* @returns {'agent'|'operator'}
|
|
36
|
+
* @throws {Error} on a class the table does not cover.
|
|
37
|
+
*/
|
|
38
|
+
export function recoveryOf(blockClass) {
|
|
39
|
+
const recovery = BLOCK_CLASS_RECOVERY[blockClass];
|
|
40
|
+
if (!recovery) {
|
|
41
|
+
throw new Error(`recoveryOf: unclassified block class "${blockClass}"`);
|
|
42
|
+
}
|
|
43
|
+
return recovery;
|
|
44
|
+
}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* under `onNoVerdict: "block"`, a missing verdict (`haltCause`).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import picomatch from 'picomatch';
|
|
10
9
|
import { hasSurvivingCritical } from '../audit-suite/findings.js';
|
|
11
10
|
import { resolveConfig } from '../config-resolver.js';
|
|
12
11
|
import { gitSpawn } from '../git-utils.js';
|
|
13
12
|
import { PROJECT_ROOT } from '../project-root.js';
|
|
13
|
+
import { globMatcher } from '../util/glob-match.js';
|
|
14
14
|
import { computeChangeSet } from './change-set.js';
|
|
15
15
|
import { remoteBaseRef } from './review-base-ref.js';
|
|
16
16
|
import {
|
|
@@ -183,9 +183,16 @@ function resolveInjectedChangedFiles({ opts, baseRef, headRef }) {
|
|
|
183
183
|
|
|
184
184
|
/**
|
|
185
185
|
* Build the `runReview` input with its depth; an unenumerable diff yields
|
|
186
|
-
* `standard`.
|
|
186
|
+
* `standard`. A first pass is always `deep` and `exhaustive`.
|
|
187
187
|
*/
|
|
188
|
-
function buildReviewInput({
|
|
188
|
+
function buildReviewInput({
|
|
189
|
+
opts,
|
|
190
|
+
scope,
|
|
191
|
+
ticketId,
|
|
192
|
+
baseRef,
|
|
193
|
+
headRef,
|
|
194
|
+
firstPass,
|
|
195
|
+
}) {
|
|
189
196
|
const changedFiles = resolveInjectedChangedFiles({ opts, baseRef, headRef });
|
|
190
197
|
const changedFileCount =
|
|
191
198
|
typeof opts.changedFileCount === 'number'
|
|
@@ -203,10 +210,14 @@ function buildReviewInput({ opts, scope, ticketId, baseRef, headRef }) {
|
|
|
203
210
|
baseRef,
|
|
204
211
|
headRef,
|
|
205
212
|
labels: Array.isArray(opts.ticketLabels) ? opts.ticketLabels : [],
|
|
206
|
-
depth,
|
|
213
|
+
...depthFields(firstPass, depth),
|
|
207
214
|
};
|
|
208
215
|
}
|
|
209
216
|
|
|
217
|
+
/** A first pass reviews `deep` and exhaustively, whatever the diff derived. */
|
|
218
|
+
const depthFields = (firstPass, depth) =>
|
|
219
|
+
firstPass ? { depth: 'deep', exhaustive: true } : { depth };
|
|
220
|
+
|
|
210
221
|
/**
|
|
211
222
|
* Optional `getPromptMessages`; absent or throwing yields `[]`.
|
|
212
223
|
*/
|
|
@@ -336,7 +347,7 @@ function applySkipPaths(findings, skipPaths) {
|
|
|
336
347
|
if (!Array.isArray(skipPaths) || skipPaths.length === 0) {
|
|
337
348
|
return { findings, skipped: 0 };
|
|
338
349
|
}
|
|
339
|
-
const isSkipped =
|
|
350
|
+
const isSkipped = globMatcher(skipPaths, { dot: true });
|
|
340
351
|
const kept = findings.filter((f) => {
|
|
341
352
|
const files = findingInstances(f).map((i) => i.file);
|
|
342
353
|
return !(files.length > 0 && files.every((file) => isSkipped(file)));
|
|
@@ -353,6 +364,14 @@ function resolveHistoryDeps(opts, config) {
|
|
|
353
364
|
return opts.reviewProvider ? null : { config };
|
|
354
365
|
}
|
|
355
366
|
|
|
367
|
+
/** A first pass has a history seam and no recorded run. */
|
|
368
|
+
const isFirstPass = (history) => history?.runs.length === 0;
|
|
369
|
+
|
|
370
|
+
/** The Story's review history, or `null` without a history seam. */
|
|
371
|
+
function readHistory(ticketId, historyDeps) {
|
|
372
|
+
return historyDeps ? readReviewHistory(ticketId, historyDeps) : null;
|
|
373
|
+
}
|
|
374
|
+
|
|
356
375
|
/** How the current run settles an earlier CRITICAL it raised again, if it did. */
|
|
357
376
|
function settleInRun(entry, findings) {
|
|
358
377
|
const again = findings.filter((f) => raisedAgain(f, entry.finding));
|
|
@@ -460,19 +479,12 @@ function earlierSection(history, outcomes) {
|
|
|
460
479
|
|
|
461
480
|
/**
|
|
462
481
|
* Mark repeats, then carry forward the open earlier CRITICALs. Without a
|
|
463
|
-
* history seam the findings pass through unchanged.
|
|
482
|
+
* history seam (`history` null) the findings pass through unchanged.
|
|
464
483
|
*/
|
|
465
|
-
async function applyHistory({
|
|
466
|
-
|
|
467
|
-
ticketId,
|
|
468
|
-
historyDeps,
|
|
469
|
-
reviewInput,
|
|
470
|
-
opts,
|
|
471
|
-
}) {
|
|
472
|
-
if (!historyDeps) {
|
|
484
|
+
async function applyHistory({ findings, history, reviewInput, opts }) {
|
|
485
|
+
if (!history) {
|
|
473
486
|
return { findings, outcomes: null, earlier: [], degradations: [] };
|
|
474
487
|
}
|
|
475
|
-
const history = readReviewHistory(ticketId, historyDeps);
|
|
476
488
|
const carry = await carryForward({
|
|
477
489
|
findings: markRepeats(findings, history),
|
|
478
490
|
history,
|
|
@@ -492,6 +504,7 @@ function recordRun({
|
|
|
492
504
|
headRef,
|
|
493
505
|
findings,
|
|
494
506
|
outcomes,
|
|
507
|
+
exhaustive,
|
|
495
508
|
historyDeps,
|
|
496
509
|
logger,
|
|
497
510
|
}) {
|
|
@@ -499,7 +512,7 @@ function recordRun({
|
|
|
499
512
|
try {
|
|
500
513
|
appendReviewRun(
|
|
501
514
|
ticketId,
|
|
502
|
-
{ headSha: headRef, findings, earlierCriticals: outcomes },
|
|
515
|
+
{ headSha: headRef, findings, earlierCriticals: outcomes, exhaustive },
|
|
503
516
|
historyDeps,
|
|
504
517
|
);
|
|
505
518
|
} catch (err) {
|
|
@@ -533,12 +546,16 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
533
546
|
codeReviewConfig,
|
|
534
547
|
root: opts.cwd ?? PROJECT_ROOT,
|
|
535
548
|
});
|
|
549
|
+
// One history snapshot drives both the first-pass decision and carry-forward.
|
|
550
|
+
const historyDeps = resolveHistoryDeps(opts, config);
|
|
551
|
+
const history = readHistory(ticketId, historyDeps);
|
|
536
552
|
const baseInput = buildReviewInput({
|
|
537
553
|
opts,
|
|
538
554
|
scope,
|
|
539
555
|
ticketId,
|
|
540
556
|
baseRef,
|
|
541
557
|
headRef,
|
|
558
|
+
firstPass: isFirstPass(history),
|
|
542
559
|
});
|
|
543
560
|
const reviewInput = {
|
|
544
561
|
...baseInput,
|
|
@@ -573,11 +590,9 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
573
590
|
],
|
|
574
591
|
});
|
|
575
592
|
const skip = applySkipPaths(vetted.findings, codeReviewConfig?.skipPaths);
|
|
576
|
-
const historyDeps = resolveHistoryDeps(opts, config);
|
|
577
593
|
const carry = await applyHistory({
|
|
578
594
|
findings: skip.findings,
|
|
579
|
-
|
|
580
|
-
historyDeps,
|
|
595
|
+
history,
|
|
581
596
|
reviewInput,
|
|
582
597
|
opts,
|
|
583
598
|
});
|
|
@@ -607,6 +622,7 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
607
622
|
headRef,
|
|
608
623
|
findings,
|
|
609
624
|
outcomes: carry.outcomes,
|
|
625
|
+
exhaustive: reviewInput.exhaustive,
|
|
610
626
|
historyDeps,
|
|
611
627
|
logger,
|
|
612
628
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Contracts: lines are additions + deletions, never net (a big deletion is
|
|
8
8
|
* not trivial); a pure rename is free but its file still counts; exemption
|
|
9
9
|
* is from counting, never from sensitive-path risk. Companion globs are a
|
|
10
|
-
* positive list — a `!`
|
|
10
|
+
* positive list — a `!` glob pattern widens rather than narrows. Every
|
|
11
11
|
* export is total.
|
|
12
12
|
*
|
|
13
13
|
* @module lib/orchestration/diff-magnitude
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* @module lib/orchestration/git-cleanup/phases/filters
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import { globMatcher } from '../../../util/glob-match.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Pure: build a `(branch) => boolean` filter from include/exclude globs.
|
|
11
11
|
*/
|
|
12
12
|
export function buildGlobFilter({ include = [], exclude = [] } = {}) {
|
|
13
|
-
const includeMatch = include.length > 0 ?
|
|
14
|
-
const excludeMatch = exclude.length > 0 ?
|
|
13
|
+
const includeMatch = include.length > 0 ? globMatcher(include) : () => true;
|
|
14
|
+
const excludeMatch = exclude.length > 0 ? globMatcher(exclude) : () => false;
|
|
15
15
|
return (branch) => includeMatch(branch) && !excludeMatch(branch);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* handoff-suite-of-record.js — the credited-run step under
|
|
3
3
|
* `coverage.suiteOfRecord: "ci"`, decided from config before any lock or spawn
|
|
4
|
-
* but the changed-tests guard.
|
|
4
|
+
* but the changed-tests guard, whichever depositor was resolved.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { suiteOfRecord } from '../close-validation/gates.js';
|
|
@@ -14,6 +14,14 @@ import { changedTestsGuard } from './handoff-changed-tests.js';
|
|
|
14
14
|
const UNDECLARED_DETAIL =
|
|
15
15
|
'delivery.quality.gates.coverage.suiteOfRecord is "ci" but delivery.quality.gates.coverage.ciRatchetCheck is unset — name the CI check that runs coverage-ratchet.js, or set suiteOfRecord to "local"';
|
|
16
16
|
|
|
17
|
+
/** Why this depositor holds the credited run, named in the deferred detail. */
|
|
18
|
+
function depositorReason(ctx) {
|
|
19
|
+
if (ctx.depositor === 'coverage-capture') return 'coverage-capture';
|
|
20
|
+
return ctx.skipBranch
|
|
21
|
+
? 'test (no changed file under crap.targetDirs)'
|
|
22
|
+
: 'test (no active coverage capture)';
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* The deferred step, once the changed-tests guard did not stop the run.
|
|
19
27
|
*
|
|
@@ -25,25 +33,25 @@ function deferred(ctx, name, ciRatchetCheck, checked) {
|
|
|
25
33
|
return {
|
|
26
34
|
name,
|
|
27
35
|
outcome: 'deferred',
|
|
28
|
-
detail: `coverage deferred to CI (suiteOfRecord: ci, ratchet check "${ciRatchetCheck}") — no
|
|
36
|
+
detail: `coverage deferred to CI (suiteOfRecord: ci, ratchet check "${ciRatchetCheck}", depositor ${depositorReason(ctx)}) — no suite spawned and no credit was deposited${checked.note}`,
|
|
29
37
|
depositor: ctx.depositor,
|
|
30
38
|
...checked.extra,
|
|
31
39
|
};
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
/**
|
|
35
|
-
* The
|
|
36
|
-
* `blocked` when no `ciRatchetCheck` would take the
|
|
37
|
-
*
|
|
43
|
+
* The credited-run step under the `ci` posture, for either depositor:
|
|
44
|
+
* deferred to CI, or `blocked` when no `ciRatchetCheck` would take the
|
|
45
|
+
* ratchet. `null` when the posture is off.
|
|
38
46
|
*
|
|
39
|
-
* @param {{ config: object, depositor: string, head: string, state: object }} ctx
|
|
47
|
+
* @param {{ config: object, depositor: string, skipBranch?: boolean, head: string, state: object }} ctx
|
|
40
48
|
* @param {string} name
|
|
41
49
|
* @param {{ run: Function, signal: AbortSignal }} guard runs `testChanged`.
|
|
42
50
|
* @returns {Promise<object|null>}
|
|
43
51
|
*/
|
|
44
52
|
export async function settleSuiteOfRecord(ctx, name, guard) {
|
|
45
53
|
const { ci, ciRatchetCheck } = suiteOfRecord(ctx.config);
|
|
46
|
-
if (!ci
|
|
54
|
+
if (!ci) return null;
|
|
47
55
|
const extra = { depositor: ctx.depositor };
|
|
48
56
|
if (!ciRatchetCheck) {
|
|
49
57
|
return {
|
|
@@ -187,12 +187,21 @@ function ejectingRunOf(runs) {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
/** First rule wins: inherited (capped), own, unknown. */
|
|
190
|
-
function classifyEjection({
|
|
190
|
+
function classifyEjection({ conclusion, parentRuns, entries }) {
|
|
191
191
|
const inherited =
|
|
192
|
-
|
|
192
|
+
conclusion === 'cancelled' ||
|
|
193
193
|
parentRuns.some((r) => RED_RUN.has(r.conclusion));
|
|
194
194
|
if (inherited) return entries > MAX_INHERITED_REARMS ? 'own' : 'inherited';
|
|
195
|
-
return
|
|
195
|
+
return conclusion === 'failure' ? 'own' : 'unknown';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** A cancelled run with a job that failed on its own was a fail-fast cancel. */
|
|
199
|
+
async function settledConclusion(get, ejecting) {
|
|
200
|
+
if (ejecting.conclusion !== 'cancelled') {
|
|
201
|
+
return { conclusion: ejecting.conclusion, jobs: null };
|
|
202
|
+
}
|
|
203
|
+
const jobs = await readFailedJobs(get, ejecting.id);
|
|
204
|
+
return { conclusion: jobs?.length ? 'failure' : 'cancelled', jobs };
|
|
196
205
|
}
|
|
197
206
|
|
|
198
207
|
/**
|
|
@@ -239,8 +248,9 @@ export async function readQueueEjection({
|
|
|
239
248
|
const parentRuns = (
|
|
240
249
|
(await get(`${QUEUE_RUNS}&head_sha=${parentSha}`))?.workflow_runs ?? []
|
|
241
250
|
).filter((r) => r.head_sha === parentSha);
|
|
251
|
+
const settled = await settledConclusion(get, ejecting);
|
|
242
252
|
const verdict = classifyEjection({
|
|
243
|
-
|
|
253
|
+
conclusion: settled.conclusion,
|
|
244
254
|
parentRuns,
|
|
245
255
|
entries: new Set(runs.map((r) => r.head_sha)).size,
|
|
246
256
|
});
|
|
@@ -251,24 +261,40 @@ export async function readQueueEjection({
|
|
|
251
261
|
conclusion: ejecting.conclusion,
|
|
252
262
|
};
|
|
253
263
|
const failedJobs =
|
|
254
|
-
verdict === 'own'
|
|
264
|
+
verdict === 'own'
|
|
265
|
+
? await failedJobsOf(get, ejecting.id, settled.jobs)
|
|
266
|
+
: [];
|
|
255
267
|
return { verdict, labels, run, failedJobs };
|
|
256
268
|
} catch (err) {
|
|
257
269
|
return { verdict: 'unknown', labels, detail: describeGhFailure(err) };
|
|
258
270
|
}
|
|
259
271
|
}
|
|
260
272
|
|
|
261
|
-
|
|
273
|
+
const OWN_FAILURE = new Set(['failure', 'timed_out']);
|
|
274
|
+
|
|
275
|
+
/** A run cancel rewrites a running job to `cancelled`; its failed step keeps `failure`. */
|
|
276
|
+
function failedOnItsOwn(job) {
|
|
277
|
+
if (OWN_FAILURE.has(job.conclusion)) return true;
|
|
278
|
+
return (
|
|
279
|
+
job.conclusion === 'cancelled' &&
|
|
280
|
+
(job.steps ?? []).some((s) => s.conclusion === 'failure')
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Failed job names, reusing a read already made; `[]` when unreadable. */
|
|
285
|
+
async function failedJobsOf(get, runId, jobs) {
|
|
286
|
+
return jobs ?? (await readFailedJobs(get, runId)) ?? [];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** Names of a run's jobs that failed on their own; `null` when unreadable. */
|
|
262
290
|
async function readFailedJobs(get, runId) {
|
|
263
291
|
try {
|
|
264
292
|
const body = await get(
|
|
265
293
|
`repos/{owner}/{repo}/actions/runs/${runId}/jobs?filter=latest&per_page=100`,
|
|
266
294
|
);
|
|
267
|
-
return (body?.jobs ?? [])
|
|
268
|
-
.filter((j) => j.conclusion === 'failure')
|
|
269
|
-
.map((j) => j.name);
|
|
295
|
+
return (body?.jobs ?? []).filter(failedOnItsOwn).map((j) => j.name);
|
|
270
296
|
} catch {
|
|
271
|
-
return
|
|
297
|
+
return null;
|
|
272
298
|
}
|
|
273
299
|
}
|
|
274
300
|
|
|
@@ -6,8 +6,6 @@
|
|
|
6
6
|
* the union path (`audit-provenance.js`).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import picomatch from 'picomatch';
|
|
10
|
-
|
|
11
9
|
import { parseAuditFindingRecords } from '../../findings/audit-finding-record.js';
|
|
12
10
|
import { ownedProvenanceSource } from '../../findings/provenance-field.js';
|
|
13
11
|
import {
|
|
@@ -15,6 +13,7 @@ import {
|
|
|
15
13
|
parseFingerprintFooter,
|
|
16
14
|
parseSemanticKeyFooter,
|
|
17
15
|
} from '../../findings/route-finding.js';
|
|
16
|
+
import { globMatcher } from '../../util/glob-match.js';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* @param {unknown} changes — `changes[]` entries, strings or `{ path }`.
|
|
@@ -27,7 +26,7 @@ function coverageMatchers(changes) {
|
|
|
27
26
|
.filter((p) => typeof p === 'string' && p.trim().length > 0)
|
|
28
27
|
.map((p) => {
|
|
29
28
|
const glob = p.trim();
|
|
30
|
-
const match =
|
|
29
|
+
const match = globMatcher(glob, { dot: true });
|
|
31
30
|
return (file) => file === glob || match(file);
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -83,7 +82,7 @@ function attributionApplies(storyCount, provenanceSource) {
|
|
|
83
82
|
* Attribute each seed finding to the Stories that cover it. Order per Story:
|
|
84
83
|
* an authored `provenance` wins outright; otherwise the Story owns every
|
|
85
84
|
* finding one of whose files its `changes[]` covers (exact path, or a glob
|
|
86
|
-
* under
|
|
85
|
+
* under `dot: true`). A finding no Story owns is unattributed: it
|
|
87
86
|
* rides on every non-authored Story and is named in the warnings.
|
|
88
87
|
*
|
|
89
88
|
* @param {Array<{ provenance: object|null, changes?: unknown }>} stories — draft order.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @typedef {{ id: string, status: 'still-open'|'fixed'|'refuted',
|
|
14
14
|
* reason?: string }} EarlierOutcome
|
|
15
15
|
* @typedef {{ runs: { headSha: string, findings: HistoryFinding[],
|
|
16
|
-
* earlierCriticals?: EarlierOutcome[] }[],
|
|
16
|
+
* earlierCriticals?: EarlierOutcome[], exhaustive?: true }[],
|
|
17
17
|
* overridden: string[], overrideReason?: string }} ReviewHistory
|
|
18
18
|
* @typedef {{ id: string, finding: HistoryFinding, headSha: string,
|
|
19
19
|
* status: 'open'|'fixed'|'refuted'|'overridden', reason?: string }} EarlierCritical
|
|
@@ -136,24 +136,23 @@ function toHistoryFinding(f) {
|
|
|
136
136
|
/**
|
|
137
137
|
* @param {number} storyId
|
|
138
138
|
* @param {{ headSha: string, findings: Finding[],
|
|
139
|
-
* earlierCriticals?: EarlierOutcome[] }}
|
|
139
|
+
* earlierCriticals?: EarlierOutcome[], exhaustive?: boolean }} entry
|
|
140
140
|
* @param {{ config?: object, fsImpl?: typeof nodeFs }} [deps]
|
|
141
141
|
*/
|
|
142
|
-
export function appendReviewRun(
|
|
143
|
-
|
|
144
|
-
{ headSha, findings, earlierCriticals },
|
|
145
|
-
deps,
|
|
146
|
-
) {
|
|
147
|
-
const run = toHistoryRun(headSha, findings, earlierCriticals);
|
|
142
|
+
export function appendReviewRun(storyId, entry, deps) {
|
|
143
|
+
const run = toHistoryRun(entry);
|
|
148
144
|
updateReviewHistory(storyId, (h) => ({ ...h, runs: [...h.runs, run] }), deps);
|
|
149
145
|
}
|
|
150
146
|
|
|
151
|
-
function toHistoryRun(headSha, findings, earlierCriticals) {
|
|
147
|
+
function toHistoryRun({ headSha, findings, earlierCriticals, exhaustive }) {
|
|
152
148
|
const run = { headSha, findings: findings.map(toHistoryFinding) };
|
|
153
149
|
if (Array.isArray(earlierCriticals)) run.earlierCriticals = earlierCriticals;
|
|
154
|
-
return run;
|
|
150
|
+
return { ...run, ...exhaustiveField(exhaustive) };
|
|
155
151
|
}
|
|
156
152
|
|
|
153
|
+
const exhaustiveField = (exhaustive) =>
|
|
154
|
+
exhaustive ? { exhaustive: true } : {};
|
|
155
|
+
|
|
157
156
|
const list = (v) => (Array.isArray(v) ? v : []);
|
|
158
157
|
const RESOLVED = new Set(['fixed', 'refuted']);
|
|
159
158
|
|
|
@@ -44,7 +44,10 @@ import {
|
|
|
44
44
|
} from './claude-verdict.js';
|
|
45
45
|
import { readDiff } from './generated-diff.js';
|
|
46
46
|
import { BUG_CLASS_RULE } from './parse-findings.js';
|
|
47
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
renderDepthDirective,
|
|
49
|
+
renderExhaustiveDirective,
|
|
50
|
+
} from './review-depth.js';
|
|
48
51
|
import { renderGuidanceBlock } from './review-guidance.js';
|
|
49
52
|
import { probeClaudeCli } from './security-review.js';
|
|
50
53
|
|
|
@@ -220,7 +223,11 @@ function buildPrompt(
|
|
|
220
223
|
.replace('{headRef}', input.headRef)
|
|
221
224
|
.replace('{ticketId}', String(input.ticketId))
|
|
222
225
|
.replace('{scopeNote}', scope)
|
|
223
|
-
.replace(
|
|
226
|
+
.replace(
|
|
227
|
+
'{depthDirective}',
|
|
228
|
+
renderDepthDirective(input.depth) +
|
|
229
|
+
renderExhaustiveDirective(input.exhaustive),
|
|
230
|
+
)
|
|
224
231
|
.replace('{guidance}', () => renderGuidanceBlock(input.guidance));
|
|
225
232
|
return `${head}<diff>\n${body}${note}\n</diff>\n${callers}`;
|
|
226
233
|
}
|