mandrel 2.111.0 → 2.113.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/agents/acceptance-critic.md +14 -0
- package/.agents/agents/auditor.md +14 -0
- package/.agents/agents/plan-critic.md +5 -0
- package/.agents/agents/story-worker.md +4 -1
- package/.agents/docs/agentrc-reference.json +22 -10
- package/.agents/docs/configuration.md +367 -37
- package/.agents/docs/execution-reference.md +11 -0
- package/.agents/rules/git-conventions-reference.md +7 -0
- package/.agents/schemas/agentrc.schema.json +174 -14
- package/.agents/schemas/baselines/baseline-envelope.schema.json +16 -4
- package/.agents/schemas/baselines/bundle-size.schema.json +1 -0
- package/.agents/schemas/baselines/coverage.schema.json +1 -0
- package/.agents/schemas/baselines/crap.schema.json +37 -10
- package/.agents/schemas/baselines/duplication.schema.json +1 -0
- package/.agents/schemas/baselines/maintainability.schema.json +1 -0
- package/.agents/schemas/baselines/mutation.schema.json +1 -0
- package/.agents/schemas/crap-report.schema.json +6 -5
- package/.agents/schemas/story-deliver-terminal.schema.json +41 -2
- package/.agents/schemas/story-progress.schema.json +1 -1
- package/.agents/schemas/validation-evidence.schema.json +2 -2
- package/.agents/scripts/boot-sweep.js +41 -3
- package/.agents/scripts/coverage-capture.js +37 -3
- package/.agents/scripts/coverage-ratchet.js +106 -0
- package/.agents/scripts/evidence-gate.js +84 -21
- package/.agents/scripts/lib/audit-baselines/read.js +8 -1
- package/.agents/scripts/lib/audit-baselines/trend.js +2 -1
- package/.agents/scripts/lib/baseline-loader.js +4 -2
- package/.agents/scripts/lib/baselines/codec.js +57 -0
- package/.agents/scripts/lib/baselines/crap-preview-incremental.js +8 -3
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +10 -16
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +4 -13
- package/.agents/scripts/lib/baselines/kernel.js +19 -1
- package/.agents/scripts/lib/baselines/kinds/_crap-codec.js +171 -0
- package/.agents/scripts/lib/baselines/kinds/_crap-read.js +56 -16
- package/.agents/scripts/lib/baselines/kinds/_shared-metric.js +0 -59
- package/.agents/scripts/lib/baselines/kinds/crap.js +283 -319
- package/.agents/scripts/lib/baselines/merge-envelopes.js +46 -1
- package/.agents/scripts/lib/baselines/preview-gates.js +29 -10
- package/.agents/scripts/lib/baselines/reader.js +36 -9
- package/.agents/scripts/lib/baselines/refresh-service.js +93 -21
- package/.agents/scripts/lib/baselines/seat-missing.js +173 -7
- package/.agents/scripts/lib/baselines/writer.js +36 -21
- package/.agents/scripts/lib/changed-files.js +70 -6
- package/.agents/scripts/lib/child-exec.js +10 -0
- package/.agents/scripts/lib/claude/agents-projection.js +5 -5
- package/.agents/scripts/lib/close-lock-events.js +8 -3
- package/.agents/scripts/lib/close-validation/ci-deferral.js +40 -0
- package/.agents/scripts/lib/close-validation/gates.js +111 -35
- package/.agents/scripts/lib/close-validation/process.js +16 -7
- package/.agents/scripts/lib/close-validation/projections/crap.js +43 -10
- package/.agents/scripts/lib/close-validation/runner.js +55 -23
- package/.agents/scripts/lib/close-validation/skip-branch-test.js +144 -0
- package/.agents/scripts/lib/close-validation/test-delta.js +33 -8
- package/.agents/scripts/lib/codex/agents-projection.js +6 -0
- package/.agents/scripts/lib/config/agentrc-overlay.js +9 -5
- package/.agents/scripts/lib/config/explain.js +5 -2
- package/.agents/scripts/lib/config/gates/coverage.schema.js +45 -1
- package/.agents/scripts/lib/config/gates/crap-incremental-coverage.schema.js +1 -1
- package/.agents/scripts/lib/config/git-roots.js +38 -4
- package/.agents/scripts/lib/config/handoff.js +24 -0
- package/.agents/scripts/lib/config/quality.js +26 -13
- package/.agents/scripts/lib/config/worktree-isolation.js +2 -5
- package/.agents/scripts/lib/config-resolver.js +22 -2
- package/.agents/scripts/lib/config-settings-schema-delivery.js +87 -4
- package/.agents/scripts/lib/config-settings-schema-quality.js +36 -1
- package/.agents/scripts/lib/config-settings-schema.js +1 -1
- package/.agents/scripts/lib/coverage-capture-affected.js +1 -0
- package/.agents/scripts/lib/coverage-capture-delta.js +164 -32
- package/.agents/scripts/lib/coverage-capture-own-fix.js +232 -0
- package/.agents/scripts/lib/coverage-capture-usage.js +2 -2
- package/.agents/scripts/lib/coverage-capture.js +15 -0
- package/.agents/scripts/lib/coverage-deferral.js +96 -0
- package/.agents/scripts/lib/coverage-ratchet.js +187 -0
- package/.agents/scripts/lib/crap-baseline-join.js +5 -5
- package/.agents/scripts/lib/crap-engine.js +3 -3
- package/.agents/scripts/lib/crap-method-identity.js +104 -48
- package/.agents/scripts/lib/error-redactor.js +20 -0
- package/.agents/scripts/lib/escomplex-anchor.js +135 -0
- package/.agents/scripts/lib/escomplex-kernel.js +30 -1
- package/.agents/scripts/lib/failure-rows.js +121 -0
- package/.agents/scripts/lib/full-suite-lock.js +44 -4
- package/.agents/scripts/lib/full-suite-queue.js +89 -13
- package/.agents/scripts/lib/generated/agentrc-validator.js +8 -2
- package/.agents/scripts/lib/gh-env.js +3 -6
- package/.agents/scripts/lib/gh-pr-rest.js +1 -0
- package/.agents/scripts/lib/git/base-sync-probe.js +182 -0
- package/.agents/scripts/lib/git/baseline-conflict-rows.js +60 -0
- package/.agents/scripts/lib/git/sync-from-base.js +18 -9
- package/.agents/scripts/lib/git-branch-lifecycle.js +9 -0
- package/.agents/scripts/lib/observability/close-telemetry.js +37 -2
- package/.agents/scripts/lib/observability/handoff-telemetry.js +170 -0
- package/.agents/scripts/lib/observability/review-dispositions.js +23 -6
- package/.agents/scripts/lib/observability/runtime-friction.js +17 -4
- package/.agents/scripts/lib/observability/source-classifier.js +3 -0
- package/.agents/scripts/lib/observability/story-outcome.js +393 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/compare.js +2 -1
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +19 -1
- package/.agents/scripts/lib/orchestration/check-baselines/phases/fail-detail.js +84 -0
- package/.agents/scripts/lib/orchestration/check-baselines/phases/pipeline.js +14 -5
- package/.agents/scripts/lib/orchestration/check-baselines/phases/refresh-ack.js +3 -2
- package/.agents/scripts/lib/orchestration/check-baselines/phases/report.js +26 -6
- package/.agents/scripts/lib/orchestration/code-review.js +223 -19
- package/.agents/scripts/lib/orchestration/handoff-gates.js +129 -62
- package/.agents/scripts/lib/orchestration/handoff-rescore.js +170 -0
- package/.agents/scripts/lib/orchestration/handoff-suite-of-record.js +45 -0
- package/.agents/scripts/lib/orchestration/preflight-lanes.js +208 -0
- package/.agents/scripts/lib/orchestration/review-base-ref.js +40 -17
- package/.agents/scripts/lib/orchestration/review-deposit.js +38 -12
- package/.agents/scripts/lib/orchestration/review-depth.js +21 -0
- package/.agents/scripts/lib/orchestration/review-history.js +124 -20
- package/.agents/scripts/lib/orchestration/review-providers/claude-verdict.js +41 -12
- package/.agents/scripts/lib/orchestration/review-providers/code-review.js +90 -39
- package/.agents/scripts/lib/orchestration/review-providers/critical-verifier.js +64 -11
- package/.agents/scripts/lib/orchestration/review-providers/degraded-gates.js +102 -3
- package/.agents/scripts/lib/orchestration/review-providers/finding-identity.js +6 -2
- package/.agents/scripts/lib/orchestration/review-providers/findings-renderer.js +55 -8
- package/.agents/scripts/lib/orchestration/review-providers/review-guidance.js +1 -0
- package/.agents/scripts/lib/orchestration/review-providers/review-provider-factory.js +42 -15
- package/.agents/scripts/lib/orchestration/review-providers/types.js +6 -0
- package/.agents/scripts/lib/orchestration/single-story-close/failed-terminal.js +10 -1
- package/.agents/scripts/lib/orchestration/single-story-close/gate-log.js +10 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/base-sync.js +7 -4
- package/.agents/scripts/lib/orchestration/single-story-close/phases/close-validation.js +16 -3
- package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +59 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +6 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +15 -4
- package/.agents/scripts/lib/orchestration/single-story-close/phases/land-review-record.js +213 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/normalize-pr-title.js +9 -12
- package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +26 -12
- package/.agents/scripts/lib/orchestration/single-story-close/phases/post-land.js +51 -26
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-gate-steps.js +2 -1
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +3 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pull-request.js +50 -17
- package/.agents/scripts/lib/orchestration/single-story-close/phases/push.js +59 -11
- package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +1 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-block.js +31 -13
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +29 -6
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-outcome.js +10 -12
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-override.js +19 -4
- package/.agents/scripts/lib/orchestration/single-story-close/result.js +30 -13
- package/.agents/scripts/lib/orchestration/single-story-close/review-overlap.js +73 -39
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +11 -3
- package/.agents/scripts/lib/orchestration/story-close/baseline-upward-writeback.js +3 -2
- package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +77 -15
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +7 -0
- package/.agents/scripts/lib/orchestration/story-handoff.js +796 -196
- package/.agents/scripts/lib/orchestration/ticketing/reads.js +2 -0
- package/.agents/scripts/lib/pr-body-lines.js +32 -0
- package/.agents/scripts/lib/single-story/ci-ratchet-gate.js +140 -0
- package/.agents/scripts/lib/single-story/confirm-and-land.js +17 -7
- package/.agents/scripts/lib/single-story/confirm-merge.js +12 -3
- package/.agents/scripts/lib/single-story-sweep/report-stalled-executing.js +202 -0
- package/.agents/scripts/lib/standalone-ratchets.js +37 -0
- package/.agents/scripts/lib/suite-admission.js +20 -8
- package/.agents/scripts/lib/suite-sizing.js +146 -0
- package/.agents/scripts/lib/workspace-provisioner.js +2 -2
- package/.agents/scripts/merge-baseline.js +14 -3
- package/.agents/scripts/providers/github/comments.js +19 -3
- package/.agents/scripts/providers/github.js +1 -0
- package/.agents/scripts/review-dispositions-report.js +1 -1
- package/.agents/scripts/role-scope-guard.js +267 -0
- package/.agents/scripts/single-story-close.js +4 -4
- package/.agents/scripts/single-story-confirm-merge.js +31 -5
- package/.agents/scripts/single-story-init.js +24 -4
- package/.agents/scripts/story-handoff.js +3 -3
- package/.agents/scripts/story-outcomes-report.js +231 -0
- package/.agents/scripts/story-review-compute.js +9 -5
- package/.agents/scripts/update-coverage-baseline.js +12 -2
- package/.agents/scripts/update-crap-baseline.js +9 -1
- package/.agents/workflows/helpers/code-review.md +63 -9
- package/.agents/workflows/helpers/deliver-digest.md +53 -54
- package/.agents/workflows/helpers/deliver-reference.md +233 -67
- package/.agents/workflows/helpers/deliver-story-reference.md +19 -8
- package/.agents/workflows/helpers/deliver-story.md +7 -2
- package/.agents/workflows/helpers/parallel-tooling.md +29 -0
- package/docs/CHANGELOG.md +55 -0
- package/lib/cli/doctor-checks/coverage-ratchet.js +54 -0
- package/lib/cli/doctor-checks/effective-agentrc.js +23 -0
- package/lib/cli/doctor-checks/llm-review.js +2 -11
- package/lib/cli/doctor-checks/sync-parity.js +5 -1
- package/lib/cli/doctor-checks/test-credit-path.js +7 -2
- package/lib/cli/registry.js +5 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @typedef {import('./types.js').Finding} Finding
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { redactPii } from '../../error-redactor.js';
|
|
8
9
|
import { isObject } from '../../json-utils.js';
|
|
9
10
|
import { CLAIM_SCHEMA } from './claim-grounding.js';
|
|
10
11
|
import { buildFinding, unwrapEnvelope } from './parse-findings.js';
|
|
@@ -63,13 +64,21 @@ function tryParseJson(text) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
const AUTH_PREFIX_CHARS = 200;
|
|
68
|
+
const AUTH_RETRY_DELAY_MS = 2000;
|
|
69
|
+
|
|
70
|
+
/** A PII-free, length-capped prefix of raw CLI output. */
|
|
71
|
+
const prefixOf = (text) =>
|
|
72
|
+
redactPii(text).replace(/\s+/g, ' ').trim().slice(0, AUTH_PREFIX_CHARS);
|
|
73
|
+
|
|
66
74
|
/**
|
|
67
75
|
* `claude auth status --json`. Only `authMethod` and `subscriptionType`
|
|
68
76
|
* are ever named: the payload also carries the account email, org name
|
|
69
|
-
* and ids, which no reason or log line may repeat.
|
|
77
|
+
* and ids, which no reason or log line may repeat. Non-JSON output on a
|
|
78
|
+
* zero exit is transient, so it is `retryable` after `delayMs`.
|
|
70
79
|
*
|
|
71
|
-
* @param {{ status: number, stdout: string }} result
|
|
72
|
-
* @returns {{ ok: true, detail: string } | { ok: false, reason: string }}
|
|
80
|
+
* @param {{ status: number, stdout: string, stderr?: string }} result
|
|
81
|
+
* @returns {{ ok: true, detail: string } | { ok: false, reason: string, retryable?: boolean, delayMs?: number }}
|
|
73
82
|
*/
|
|
74
83
|
export function readAuthStatus(result) {
|
|
75
84
|
if (result.status !== 0) {
|
|
@@ -82,7 +91,12 @@ export function readAuthStatus(result) {
|
|
|
82
91
|
if (!parsed || typeof parsed !== 'object') {
|
|
83
92
|
return {
|
|
84
93
|
ok: false,
|
|
85
|
-
reason:
|
|
94
|
+
reason:
|
|
95
|
+
'claude auth status returned unparseable output ' +
|
|
96
|
+
`(stdout: "${prefixOf(result.stdout)}", ` +
|
|
97
|
+
`stderr: "${prefixOf(result.stderr)}")`,
|
|
98
|
+
retryable: true,
|
|
99
|
+
delayMs: AUTH_RETRY_DELAY_MS,
|
|
86
100
|
};
|
|
87
101
|
}
|
|
88
102
|
const method =
|
|
@@ -187,11 +201,21 @@ function toFindings(entries) {
|
|
|
187
201
|
.filter(Boolean);
|
|
188
202
|
}
|
|
189
203
|
|
|
204
|
+
const resultTextOf = (envelope) =>
|
|
205
|
+
typeof envelope?.result === 'string' ? envelope.result : '';
|
|
206
|
+
|
|
207
|
+
function isUsageLimited(result, envelope) {
|
|
208
|
+
const text = [result.stderr, resultTextOf(envelope), result.stdout];
|
|
209
|
+
return USAGE_LIMIT_RE.test(text.join('\n'));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function isRetryable(result, envelope) {
|
|
213
|
+
return Number.isInteger(result.status) && !isUsageLimited(result, envelope);
|
|
214
|
+
}
|
|
215
|
+
|
|
190
216
|
function failureReason(result, envelope) {
|
|
191
|
-
const resultText =
|
|
192
|
-
|
|
193
|
-
const text = [result.stderr, resultText, result.stdout].join('\n');
|
|
194
|
-
if (USAGE_LIMIT_RE.test(text)) {
|
|
217
|
+
const resultText = resultTextOf(envelope);
|
|
218
|
+
if (isUsageLimited(result, envelope)) {
|
|
195
219
|
return 'the claude CLI account is out of quota (usage limit reached)';
|
|
196
220
|
}
|
|
197
221
|
if (result.status !== 0) {
|
|
@@ -237,19 +261,24 @@ function resultTextFindings(text) {
|
|
|
237
261
|
/**
|
|
238
262
|
* Verdict resolution: (a) a successful envelope's `structured_output`,
|
|
239
263
|
* (b) the fallback parser over its `result` text, (c) no verdict.
|
|
264
|
+
* `retryable` excludes a usage limit and a `status: null` timeout.
|
|
240
265
|
*
|
|
241
|
-
* @param {{ status: number, stdout: string, stderr: string }} result
|
|
242
|
-
* @returns {{ findings: Finding[] } | { reason: string }}
|
|
266
|
+
* @param {{ status: number|null, stdout: string, stderr: string }} result
|
|
267
|
+
* @returns {{ findings: Finding[] } | { reason: string, retryable: boolean }}
|
|
243
268
|
*/
|
|
244
269
|
export function resolveVerdict(result) {
|
|
245
270
|
const envelope = parseEnvelope(result.stdout);
|
|
271
|
+
const retryable = isRetryable(result, envelope);
|
|
246
272
|
if (!isSuccess(result, envelope)) {
|
|
247
|
-
return { reason: noVerdictReason(result, envelope) };
|
|
273
|
+
return { reason: noVerdictReason(result, envelope), retryable };
|
|
248
274
|
}
|
|
249
275
|
const entries =
|
|
250
276
|
structuredFindings(envelope.structured_output) ??
|
|
251
277
|
resultTextFindings(envelope.result);
|
|
252
278
|
return entries
|
|
253
279
|
? { findings: toFindings(entries) }
|
|
254
|
-
: {
|
|
280
|
+
: {
|
|
281
|
+
reason: 'the reviewer output did not parse as a findings verdict',
|
|
282
|
+
retryable,
|
|
283
|
+
};
|
|
255
284
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* review-providers/code-review.js — a
|
|
3
|
-
*
|
|
2
|
+
* review-providers/code-review.js — a model bug review of the Story diff
|
|
3
|
+
* through `claude --print --effort <input.effort ?? low>`. It asks only for
|
|
4
4
|
* merge-blocking problems, so every parsed finding is `critical` and halts
|
|
5
5
|
* close before auto-merge. The reviewer is handed the diff range, the Story
|
|
6
6
|
* id and the diff text — never `acceptance[]` or the self-eval verdict: this
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
* OS temp cwd (no CLAUDE.md discovery), user-only settings, no MCP, no tools.
|
|
11
11
|
*
|
|
12
12
|
* A missing CLI throws at construction (the chain entry is optional). A
|
|
13
|
-
* review with no verdict records
|
|
14
|
-
*
|
|
13
|
+
* transient failure is retried once; a review still with no verdict records
|
|
14
|
+
* one degraded gate via `getDegradations()` and returns no findings.
|
|
15
15
|
* A diff over the cap is reviewed chunk by chunk (file-aligned, sequential,
|
|
16
16
|
* findings merged). Source sections pack before tests and docs, and every
|
|
17
17
|
* chunk is told it is a slice and handed the whole changed-file manifest so
|
|
18
|
-
* a file changed in another chunk never reads as unchanged. What went
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* a file changed in another chunk never reads as unchanged. What went
|
|
19
|
+
* unchecked — a truncated file, files past the chunk bound, a chunk with no
|
|
20
|
+
* verdict (`coverage-partial`), a capped `<callers>` block
|
|
21
|
+
* (`context-reduced`) — is recorded beside the findings, naming the files.
|
|
21
22
|
*
|
|
22
23
|
* @typedef {import('./types.js').Finding} Finding
|
|
23
24
|
* @typedef {import('./types.js').ReviewInput} ReviewInput
|
|
@@ -28,9 +29,13 @@
|
|
|
28
29
|
import fs from 'node:fs';
|
|
29
30
|
import os from 'node:os';
|
|
30
31
|
import path from 'node:path';
|
|
31
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
spawnCaptureAsync,
|
|
34
|
+
spawnCaptureNullableAsync,
|
|
35
|
+
} from '../../child-exec.js';
|
|
32
36
|
import { gitSpawn } from '../../git-utils.js';
|
|
33
37
|
import { PROJECT_ROOT } from '../../project-root.js';
|
|
38
|
+
import { defaultSleep } from '../../util/sleep.js';
|
|
34
39
|
import { buildCallersSection } from './callers-context.js';
|
|
35
40
|
import {
|
|
36
41
|
FINDINGS_SCHEMA_JSON,
|
|
@@ -43,10 +48,11 @@ import { renderDepthDirective } from './review-depth.js';
|
|
|
43
48
|
import { renderGuidanceBlock } from './review-guidance.js';
|
|
44
49
|
import { probeClaudeCli } from './security-review.js';
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
/** @param {string} effort */
|
|
52
|
+
const claudeArgs = (effort) => [
|
|
47
53
|
'--print',
|
|
48
54
|
'--effort',
|
|
49
|
-
|
|
55
|
+
effort,
|
|
50
56
|
'--output-format',
|
|
51
57
|
'json',
|
|
52
58
|
'--json-schema',
|
|
@@ -56,7 +62,7 @@ const CLAUDE_ARGS = Object.freeze([
|
|
|
56
62
|
'--strict-mcp-config',
|
|
57
63
|
'--tools',
|
|
58
64
|
'',
|
|
59
|
-
]
|
|
65
|
+
];
|
|
60
66
|
const AUTH_ARGS = Object.freeze(['auth', 'status', '--json']);
|
|
61
67
|
const INVOKE_TIMEOUT_MS = 10 * 60 * 1000;
|
|
62
68
|
const AUTH_TIMEOUT_MS = 15 * 1000;
|
|
@@ -239,19 +245,22 @@ function quoteWindowsArg(arg) {
|
|
|
239
245
|
* @param {{ cwd: string, input?: string, timeout: number, run?: Function, platform: string }} opts
|
|
240
246
|
* @returns {Promise<{ status: number, stdout: string, stderr: string }>}
|
|
241
247
|
*/
|
|
242
|
-
export function runClaude(args,
|
|
248
|
+
export function runClaude(args, opts) {
|
|
249
|
+
return spawnCaptureAsync('claude', ...claudeSpawn(args, opts));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** `runClaude`, but a timeout, kill or spawn error stays `status: null`. */
|
|
253
|
+
function runClaudeNullable(args, opts) {
|
|
254
|
+
return spawnCaptureNullableAsync('claude', ...claudeSpawn(args, opts));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The argv and spawn options both runners share. */
|
|
258
|
+
function claudeSpawn(args, { cwd, input, timeout, run, platform }) {
|
|
243
259
|
const shell = platform === 'win32';
|
|
244
|
-
return
|
|
245
|
-
'claude',
|
|
260
|
+
return [
|
|
246
261
|
shell ? args.map(quoteWindowsArg) : [...args],
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
input: input ?? '',
|
|
250
|
-
shell,
|
|
251
|
-
timeout,
|
|
252
|
-
...(run ? { run } : {}),
|
|
253
|
-
},
|
|
254
|
-
);
|
|
262
|
+
{ cwd, input: input ?? '', shell, timeout, ...(run ? { run } : {}) },
|
|
263
|
+
];
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
/**
|
|
@@ -280,8 +289,8 @@ function runAuthStatus(runDir, deps) {
|
|
|
280
289
|
});
|
|
281
290
|
}
|
|
282
291
|
|
|
283
|
-
function runReviewer(runDir, prompt, deps) {
|
|
284
|
-
return
|
|
292
|
+
function runReviewer(runDir, prompt, effort, deps) {
|
|
293
|
+
return runClaudeNullable(claudeArgs(effort), {
|
|
285
294
|
cwd: runDir,
|
|
286
295
|
input: prompt,
|
|
287
296
|
timeout: INVOKE_TIMEOUT_MS,
|
|
@@ -293,22 +302,41 @@ function runReviewer(runDir, prompt, deps) {
|
|
|
293
302
|
/**
|
|
294
303
|
* Preflight, then the review, both from a fresh OS temp dir removed after.
|
|
295
304
|
*
|
|
296
|
-
* @returns {Promise<{ findings: Finding[] } | { reason: string }>}
|
|
305
|
+
* @returns {Promise<{ findings: Finding[] } | { reason: string, retryable?: boolean }>}
|
|
297
306
|
*/
|
|
298
|
-
async function reviewInTempDir(prompt, deps) {
|
|
307
|
+
async function reviewInTempDir(prompt, effort, deps) {
|
|
299
308
|
const runDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mandrel-code-review-'));
|
|
300
309
|
try {
|
|
301
310
|
const auth = readAuthStatus(await runAuthStatus(runDir, deps));
|
|
302
311
|
if (!auth.ok) return auth;
|
|
303
312
|
deps.logger?.info?.(
|
|
304
|
-
`[code-review] Invoking claude --print --effort
|
|
313
|
+
`[code-review] Invoking claude --print --effort ${effort} (${auth.detail})...`,
|
|
305
314
|
);
|
|
306
|
-
return resolveVerdict(await runReviewer(runDir, prompt, deps));
|
|
315
|
+
return resolveVerdict(await runReviewer(runDir, prompt, effort, deps));
|
|
307
316
|
} finally {
|
|
308
317
|
fs.rmSync(runDir, { recursive: true, force: true });
|
|
309
318
|
}
|
|
310
319
|
}
|
|
311
320
|
|
|
321
|
+
/** Waits out the failure's `delayMs`, when it names one. */
|
|
322
|
+
async function pauseFor({ delayMs }, deps) {
|
|
323
|
+
if (delayMs) await (deps.sleepFn ?? defaultSleep)(delayMs);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** One invocation, re-run once when its failure is transient-shaped. */
|
|
327
|
+
async function reviewWithRetry(prompt, effort, deps) {
|
|
328
|
+
const first = await reviewInTempDir(prompt, effort, deps);
|
|
329
|
+
if (!first.retryable) return first;
|
|
330
|
+
deps.logger?.warn?.(
|
|
331
|
+
`[code-review] No verdict (${first.reason}); retrying once.`,
|
|
332
|
+
);
|
|
333
|
+
await pauseFor(first, deps);
|
|
334
|
+
return reviewInTempDir(prompt, effort, deps);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** @param {ReviewInput} input */
|
|
338
|
+
const effortOf = (input) => input.effort ?? 'low';
|
|
339
|
+
|
|
312
340
|
function assertCliPresent(probeFn) {
|
|
313
341
|
if (probeFn()) return;
|
|
314
342
|
throw new Error(
|
|
@@ -325,6 +353,7 @@ function assertCliPresent(probeFn) {
|
|
|
325
353
|
* gitSpawnFn?: typeof gitSpawn,
|
|
326
354
|
* spawnFn?: Function,
|
|
327
355
|
* authSpawnFn?: Function,
|
|
356
|
+
* sleepFn?: (ms: number) => Promise<void>,
|
|
328
357
|
* platform?: string,
|
|
329
358
|
* logger?: { info?: Function, warn?: Function },
|
|
330
359
|
* }} [deps] - `spawnFn` / `authSpawnFn` replace the async runner for the
|
|
@@ -339,18 +368,38 @@ export function createCodeReviewProviderForRegistry(deps = {}) {
|
|
|
339
368
|
let degradations = [];
|
|
340
369
|
|
|
341
370
|
/** Record a not-checked slice without replacing the findings. */
|
|
342
|
-
function noteDegradation(reason) {
|
|
343
|
-
degradations.push({ ...DEGRADATION_BASE, reason });
|
|
371
|
+
function noteDegradation(reason, kind) {
|
|
372
|
+
degradations.push({ ...DEGRADATION_BASE, kind, reason });
|
|
344
373
|
deps.logger?.warn?.(`[code-review] Not checked: ${reason}.`);
|
|
345
374
|
}
|
|
346
375
|
|
|
347
376
|
function settle(verdict) {
|
|
348
377
|
if (!('reason' in verdict)) return verdict.findings;
|
|
349
|
-
degradations.push({
|
|
378
|
+
degradations.push({
|
|
379
|
+
...DEGRADATION_BASE,
|
|
380
|
+
kind: 'verdict-missing',
|
|
381
|
+
reason: verdict.reason,
|
|
382
|
+
});
|
|
350
383
|
deps.logger?.warn?.(`[code-review] No verdict: ${verdict.reason}.`);
|
|
351
384
|
return [];
|
|
352
385
|
}
|
|
353
386
|
|
|
387
|
+
/**
|
|
388
|
+
* No chunk with a verdict is a review with none: one record naming every
|
|
389
|
+
* file. Otherwise each chunk without one is a partial gap.
|
|
390
|
+
*/
|
|
391
|
+
function noteChunkGaps(failed, total) {
|
|
392
|
+
if (failed.length > 0 && failed.length === total) {
|
|
393
|
+
const reasons = [...new Set(failed.map((f) => f.reason))].join('; ');
|
|
394
|
+
const files = failed.map((f) => f.files).join(', ');
|
|
395
|
+
noteDegradation(`no verdict for ${files}: ${reasons}`, 'verdict-missing');
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
for (const { files, reason } of failed) {
|
|
399
|
+
noteDegradation(`no verdict for ${files}: ${reason}`, 'coverage-partial');
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
354
403
|
/**
|
|
355
404
|
* The `<callers>` block, guidance, the slice note and the manifest ride every chunk,
|
|
356
405
|
* so they come out of the budget; chunk numbers are one digit, so the
|
|
@@ -376,15 +425,18 @@ export function createCodeReviewProviderForRegistry(deps = {}) {
|
|
|
376
425
|
noteDegradation(
|
|
377
426
|
`review bounded at ${MAX_REVIEW_CHUNKS} chunks: ${overflow.length} ` +
|
|
378
427
|
`file(s) not reviewed: ${overflow.join(', ')}`,
|
|
428
|
+
'coverage-partial',
|
|
379
429
|
);
|
|
380
430
|
}
|
|
381
431
|
const findings = [];
|
|
432
|
+
const failed = [];
|
|
382
433
|
for (const [index, chunk] of chunks.entries()) {
|
|
383
434
|
const files = chunk.sections.map((s) => s.file).join(', ');
|
|
384
435
|
if (chunk.size > budget) {
|
|
385
436
|
noteDegradation(
|
|
386
437
|
`${files} truncated at ${budget} characters: ` +
|
|
387
438
|
`${chunk.size - budget} characters not reviewed`,
|
|
439
|
+
'coverage-partial',
|
|
388
440
|
);
|
|
389
441
|
}
|
|
390
442
|
const prompt = buildPrompt(
|
|
@@ -394,13 +446,11 @@ export function createCodeReviewProviderForRegistry(deps = {}) {
|
|
|
394
446
|
budget,
|
|
395
447
|
sliceNote(index + 1, chunks.length) + manifest,
|
|
396
448
|
);
|
|
397
|
-
const verdict = await
|
|
398
|
-
if ('reason' in verdict) {
|
|
399
|
-
|
|
400
|
-
} else {
|
|
401
|
-
findings.push(...verdict.findings);
|
|
402
|
-
}
|
|
449
|
+
const verdict = await reviewWithRetry(prompt, effortOf(input), runDeps);
|
|
450
|
+
if ('reason' in verdict) failed.push({ files, reason: verdict.reason });
|
|
451
|
+
else findings.push(...verdict.findings);
|
|
403
452
|
}
|
|
453
|
+
noteChunkGaps(failed, chunks.length);
|
|
404
454
|
return dedupeFindings(findings);
|
|
405
455
|
}
|
|
406
456
|
|
|
@@ -417,13 +467,14 @@ export function createCodeReviewProviderForRegistry(deps = {}) {
|
|
|
417
467
|
cwd: PROJECT_ROOT,
|
|
418
468
|
gitSpawnFn,
|
|
419
469
|
});
|
|
420
|
-
if (callers.reason) noteDegradation(callers.reason);
|
|
470
|
+
if (callers.reason) noteDegradation(callers.reason, 'context-reduced');
|
|
421
471
|
if (diff.text.length > MAX_DIFF_CHARS) {
|
|
422
472
|
return reviewInChunks(input, diff.text, callers.text);
|
|
423
473
|
}
|
|
424
474
|
return settle(
|
|
425
|
-
await
|
|
475
|
+
await reviewWithRetry(
|
|
426
476
|
buildPrompt(input, diff.text, callers.text),
|
|
477
|
+
effortOf(input),
|
|
427
478
|
runDeps,
|
|
428
479
|
),
|
|
429
480
|
);
|
|
@@ -256,6 +256,18 @@ function boundDegradation(skipped) {
|
|
|
256
256
|
];
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
function voterContext(args) {
|
|
260
|
+
return {
|
|
261
|
+
baseRef: args.baseRef,
|
|
262
|
+
headRef: args.headRef,
|
|
263
|
+
cwd: args.cwd ?? PROJECT_ROOT,
|
|
264
|
+
spawnFn: args.spawnFn,
|
|
265
|
+
platform: args.platform ?? process.platform,
|
|
266
|
+
gitSpawnFn: args.gitSpawnFn ?? gitSpawn,
|
|
267
|
+
cliPresent: (args.probeFn ?? probeClaudeCli)(),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
259
271
|
/**
|
|
260
272
|
* Verify every `critical` finding; findings below critical are never sent.
|
|
261
273
|
* One verifier at `light`/`standard`, three at `deep`.
|
|
@@ -278,15 +290,7 @@ async function verifyCriticals(args) {
|
|
|
278
290
|
}
|
|
279
291
|
const checked = criticals.slice(0, MAX_VERIFIED_CRITICALS);
|
|
280
292
|
const voters = args.depth === 'deep' ? 3 : 1;
|
|
281
|
-
const ctx =
|
|
282
|
-
baseRef: args.baseRef,
|
|
283
|
-
headRef: args.headRef,
|
|
284
|
-
cwd: args.cwd ?? PROJECT_ROOT,
|
|
285
|
-
spawnFn: args.spawnFn,
|
|
286
|
-
platform: args.platform ?? process.platform,
|
|
287
|
-
gitSpawnFn: args.gitSpawnFn ?? gitSpawn,
|
|
288
|
-
cliPresent: (args.probeFn ?? probeClaudeCli)(),
|
|
289
|
-
};
|
|
293
|
+
const ctx = voterContext(args);
|
|
290
294
|
args.logger?.info?.(
|
|
291
295
|
`[code-review] Verifying ${checked.length} critical(s) with ${voters} verifier(s) each...`,
|
|
292
296
|
);
|
|
@@ -313,6 +317,56 @@ async function verifyCriticals(args) {
|
|
|
313
317
|
};
|
|
314
318
|
}
|
|
315
319
|
|
|
320
|
+
/** Whether the review gets a verifier: built-in, or injected seams. */
|
|
321
|
+
const hasVerifier = (opts) => Boolean(opts.verifier || !opts.reviewProvider);
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Re-check earlier CRITICALs at the current head: one call each whatever the
|
|
325
|
+
* depth, the same pool and cap as `verifyCriticals`. Each result is the voter
|
|
326
|
+
* outcome; past the cap or with no verifier the outcome is `skipped`.
|
|
327
|
+
*
|
|
328
|
+
* @param {{ findings: Finding[], reviewInput: { baseRef: string,
|
|
329
|
+
* headRef: string }, opts: object }} args
|
|
330
|
+
* @returns {Promise<{ results: { outcome: string, reason: string }[],
|
|
331
|
+
* degradations: GateDegradation[], verification: VerificationSummary }>}
|
|
332
|
+
*/
|
|
333
|
+
export async function recheckCriticals({ findings, reviewInput, opts }) {
|
|
334
|
+
const verification = emptyVerification();
|
|
335
|
+
if (findings.length === 0 || !hasVerifier(opts)) {
|
|
336
|
+
const reason = 'no verifier for this review';
|
|
337
|
+
return {
|
|
338
|
+
results: findings.map(() => ({ outcome: 'skipped', reason })),
|
|
339
|
+
degradations: [],
|
|
340
|
+
verification,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
const checked = findings.slice(0, MAX_VERIFIED_CRITICALS);
|
|
344
|
+
const ctx = voterContext({
|
|
345
|
+
baseRef: reviewInput.baseRef,
|
|
346
|
+
headRef: reviewInput.headRef,
|
|
347
|
+
cwd: opts.cwd,
|
|
348
|
+
gitSpawnFn: opts.gitSpawnFn,
|
|
349
|
+
...opts.verifier,
|
|
350
|
+
});
|
|
351
|
+
const votes = await runPooled(
|
|
352
|
+
checked.map((f) => () => runVoter(f, ctx)),
|
|
353
|
+
MAX_IN_FLIGHT,
|
|
354
|
+
);
|
|
355
|
+
for (const v of votes) verification[v.outcome] += 1;
|
|
356
|
+
verification.attempted = votes.length;
|
|
357
|
+
return {
|
|
358
|
+
results: findings.map(
|
|
359
|
+
(_, i) =>
|
|
360
|
+
votes[i] ?? { outcome: 'skipped', reason: 'verification cap reached' },
|
|
361
|
+
),
|
|
362
|
+
degradations: [
|
|
363
|
+
...checked.flatMap((f, i) => voteDegradations(f, [votes[i]])),
|
|
364
|
+
...boundDegradation(findings.slice(MAX_VERIFIED_CRITICALS)),
|
|
365
|
+
],
|
|
366
|
+
verification,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
316
370
|
/**
|
|
317
371
|
* The pipeline step: ground every finding, then verify the CRITICALs left.
|
|
318
372
|
* An injected review provider gets no verifier unless `opts.verifier` (the
|
|
@@ -337,8 +391,7 @@ export async function vetFindings({
|
|
|
337
391
|
degradations,
|
|
338
392
|
gitSpawnFn: opts.gitSpawnFn,
|
|
339
393
|
});
|
|
340
|
-
const verify =
|
|
341
|
-
opts.verifier || !opts.reviewProvider ? verifyCriticals : skipVerification;
|
|
394
|
+
const verify = hasVerifier(opts) ? verifyCriticals : skipVerification;
|
|
342
395
|
const verified = await verify({
|
|
343
396
|
findings: grounded.findings,
|
|
344
397
|
baseRef,
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* review-providers/degraded-gates.js — the "a gate did not run" channel,
|
|
3
|
-
* travelling beside `Finding[]` so "never ran" cannot read as clean.
|
|
4
|
-
*
|
|
3
|
+
* travelling beside `Finding[]` so "never ran" cannot read as clean. Its
|
|
4
|
+
* `kind` blocks only under `delivery.codeReview.onNoVerdict: "block"`.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
+
* @typedef {'verdict-missing'|'coverage-partial'|'context-reduced'} DegradationKind
|
|
8
9
|
* @typedef {object} GateDegradation
|
|
9
10
|
* @property {string} tool
|
|
10
11
|
* @property {string} gate
|
|
11
12
|
* @property {string} surface Sub-surface that could not run.
|
|
13
|
+
* @property {DegradationKind} kind
|
|
12
14
|
* @property {string} reason
|
|
13
15
|
*/
|
|
14
16
|
|
|
17
|
+
const DEGRADATION_KINDS = Object.freeze([
|
|
18
|
+
'verdict-missing',
|
|
19
|
+
'coverage-partial',
|
|
20
|
+
'context-reduced',
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
/** An absent or unknown kind is the one kind that can never block. */
|
|
24
|
+
const kindOf = (kind) =>
|
|
25
|
+
DEGRADATION_KINDS.includes(kind) ? kind : 'context-reduced';
|
|
26
|
+
|
|
15
27
|
/**
|
|
16
28
|
* Keep only well-formed records, so a misbehaving provider cannot corrupt output.
|
|
17
29
|
*
|
|
@@ -30,12 +42,99 @@ export function normalizeDegradations(input) {
|
|
|
30
42
|
tool: typeof d.tool === 'string' ? d.tool : 'unknown',
|
|
31
43
|
gate: typeof d.gate === 'string' ? d.gate : 'unknown',
|
|
32
44
|
surface,
|
|
45
|
+
kind: kindOf(d.kind),
|
|
33
46
|
reason,
|
|
34
47
|
});
|
|
35
48
|
}
|
|
36
49
|
return out;
|
|
37
50
|
}
|
|
38
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Close's `gates.codeReview`: overridden > unreviewed > partial > degraded > passed.
|
|
54
|
+
*
|
|
55
|
+
* @param {unknown} degradations
|
|
56
|
+
* @param {{ overridden?: boolean }} [opts]
|
|
57
|
+
* @returns {'overridden'|'unreviewed'|'partial'|'degraded'|'passed'}
|
|
58
|
+
*/
|
|
59
|
+
export function reviewGateValue(degradations, { overridden = false } = {}) {
|
|
60
|
+
if (overridden) return 'overridden';
|
|
61
|
+
const kinds = new Set(normalizeDegradations(degradations).map((d) => d.kind));
|
|
62
|
+
if (kinds.has('verdict-missing')) return 'unreviewed';
|
|
63
|
+
if (kinds.has('coverage-partial')) return 'partial';
|
|
64
|
+
return kinds.size > 0 ? 'degraded' : 'passed';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const REDUCED_CONTEXT =
|
|
68
|
+
'⚠️ Review ran DEGRADED — reviewed with reduced context, so the surface(s) ' +
|
|
69
|
+
'above were not fully checked. The close is not blocked by reduced ' +
|
|
70
|
+
'context, but nothing here vouches for those surfaces.';
|
|
71
|
+
|
|
72
|
+
const NOT_VOUCHED =
|
|
73
|
+
'unless `delivery.codeReview.onNoVerdict` is `block`; nothing here vouches ' +
|
|
74
|
+
'for those surfaces.';
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {unknown} degradations
|
|
78
|
+
* @returns {string[]}
|
|
79
|
+
*/
|
|
80
|
+
export function reviewGapLines(degradations) {
|
|
81
|
+
const gate = reviewGateValue(degradations);
|
|
82
|
+
if (gate === 'unreviewed') {
|
|
83
|
+
return [
|
|
84
|
+
`⚠️ Review UNREVIEWED — no verdict for the surface(s) above. The close is not blocked ${NOT_VOUCHED}`,
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
if (gate === 'partial') {
|
|
88
|
+
return [
|
|
89
|
+
`⚠️ Review ran PARTIAL — part of the diff above was not reviewed. The close is not blocked ${NOT_VOUCHED}`,
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
return gate === 'degraded' ? [REDUCED_CONTEXT] : [];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The fix each no-verdict cause needs; matched on the record, never on PII. */
|
|
96
|
+
const NO_VERDICT_FIXES = [
|
|
97
|
+
[
|
|
98
|
+
/auth status returned unparseable output/,
|
|
99
|
+
'the auth preflight output was transient; re-run `story-review-compute.js`',
|
|
100
|
+
],
|
|
101
|
+
[/not logged in|auth status/, 'run `claude auth login`'],
|
|
102
|
+
[/out of quota|usage limit/, 'wait for the usage-limit reset'],
|
|
103
|
+
[/skipped/, 'install the `claude` or `codex` CLI'],
|
|
104
|
+
[/remote-base-ref-unresolved/, 'fetch the base ref'],
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
function fixFor(reason) {
|
|
108
|
+
const hit = NO_VERDICT_FIXES.find(([re]) => re.test(reason));
|
|
109
|
+
return hit ? hit[1] : 'fix the cause';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Under `onNoVerdict: "block"`, a verdict-missing or coverage-partial record
|
|
114
|
+
* halts the review; context-reduced never does.
|
|
115
|
+
*
|
|
116
|
+
* @param {{ degradations: unknown, onNoVerdict?: string, storyId: number|string }} args
|
|
117
|
+
* @returns {{ halted: true, haltCause: 'no-verdict', blockerReason: string }|null}
|
|
118
|
+
*/
|
|
119
|
+
export function resolveNoVerdictHalt({ degradations, onNoVerdict, storyId }) {
|
|
120
|
+
if (onNoVerdict !== 'block') return null;
|
|
121
|
+
const blocking = normalizeDegradations(degradations).filter(
|
|
122
|
+
(d) => d.kind !== 'context-reduced',
|
|
123
|
+
);
|
|
124
|
+
if (blocking.length === 0) return null;
|
|
125
|
+
const causes = blocking.map(
|
|
126
|
+
(d) => `${d.surface} [${d.kind}]: ${d.reason} — ${fixFor(d.reason)}`,
|
|
127
|
+
);
|
|
128
|
+
return {
|
|
129
|
+
halted: true,
|
|
130
|
+
haltCause: 'no-verdict',
|
|
131
|
+
blockerReason:
|
|
132
|
+
`code-review produced no verdict for part or all of the diff ` +
|
|
133
|
+
`(delivery.codeReview.onNoVerdict: block): ${causes.join('; ')}. ` +
|
|
134
|
+
`Then re-run \`node .agents/scripts/story-review-compute.js --story ${storyId}\`.`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
39
138
|
/**
|
|
40
139
|
* Feature-detected; a throw degrades to empty. MUST be called after
|
|
41
140
|
* `runReview`, which is when a provider records its degradations.
|
|
@@ -152,7 +251,7 @@ export function renderDegradedGatesSection(degradations) {
|
|
|
152
251
|
];
|
|
153
252
|
for (const d of rows) {
|
|
154
253
|
lines.push(
|
|
155
|
-
`- \`${d.gate}\` → \`${d.surface}\` could not execute — ${d.reason} (emitter: \`${d.tool}\`).`,
|
|
254
|
+
`- \`${d.gate}\` → \`${d.surface}\` (${d.kind}) could not execute — ${d.reason} (emitter: \`${d.tool}\`).`,
|
|
156
255
|
);
|
|
157
256
|
}
|
|
158
257
|
lines.push('');
|
|
@@ -34,12 +34,16 @@ function normalizeTitle(title) {
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* First 12 hex chars of sha256 over class (else category), first instance
|
|
37
|
-
* file and, for a class-less finding, its normalized title.
|
|
37
|
+
* file and, for a class-less finding, its normalized title. A finding carried
|
|
38
|
+
* forward from the review history keeps the id it was recorded under.
|
|
38
39
|
*
|
|
39
40
|
* @param {Finding} finding
|
|
40
41
|
* @returns {string}
|
|
41
42
|
*/
|
|
42
|
-
export
|
|
43
|
+
export const findingId = (finding) => finding?.carriedId ?? contentId(finding);
|
|
44
|
+
|
|
45
|
+
/** @param {Finding} finding */
|
|
46
|
+
function contentId(finding) {
|
|
43
47
|
const cls = finding?.class;
|
|
44
48
|
const parts = [
|
|
45
49
|
cls || finding?.category || 'bug',
|