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
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @module lib/orchestration/check-baselines/phases/report
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { formatFailDetail } from './fail-detail.js';
|
|
8
|
+
|
|
7
9
|
function formatHeader(report) {
|
|
8
10
|
return (
|
|
9
11
|
`[check-baselines] ${report.gates.length} gate(s) — ` +
|
|
@@ -17,6 +19,19 @@ function formatGateStatus(g) {
|
|
|
17
19
|
return `FAIL (breaches=${g.breachCount}, regressions=${g.regressionCount ?? 0})`;
|
|
18
20
|
}
|
|
19
21
|
|
|
22
|
+
/** A `formatGateLine` FAIL line, optionally `[gate] `-prefixed by close. */
|
|
23
|
+
const GATE_FAIL_LINE = /^(?:\[[^\]]+\] )?\s*- ([a-z][a-z0-9-]*): FAIL \(/;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The kind a check-baselines FAIL line names, or `null`.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} line
|
|
29
|
+
* @returns {string|null}
|
|
30
|
+
*/
|
|
31
|
+
export function parseGateFailLine(line) {
|
|
32
|
+
return GATE_FAIL_LINE.exec(line)?.[1] ?? null;
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
function formatGateLine(g) {
|
|
21
36
|
const status = formatGateStatus(g);
|
|
22
37
|
const drift = g.kernelMatch
|
|
@@ -42,12 +57,16 @@ function formatViolationLine(component, v) {
|
|
|
42
57
|
|
|
43
58
|
function appendGateText(lines, g) {
|
|
44
59
|
lines.push(formatGateLine(g));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
const violations = g.components.flatMap((c) =>
|
|
61
|
+
c.violations.map((v) => formatViolationLine(c.component, v)),
|
|
62
|
+
);
|
|
63
|
+
const pass = formatGateStatus(g) === 'PASS';
|
|
64
|
+
lines.push(...(pass ? violations : formatFailDetail(g, violations)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** A skipped gate gets a line of its own so it never reads as a PASS. */
|
|
68
|
+
function formatSkipped(skipped = []) {
|
|
69
|
+
return skipped.map((s) => ` ~ SKIPPED (${s.kind}): ${s.message}`);
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
export function formatReport(report, format) {
|
|
@@ -57,5 +76,6 @@ export function formatReport(report, format) {
|
|
|
57
76
|
for (const s of report.schemaErrors) {
|
|
58
77
|
lines.push(` ! schema error (${s.kind}): ${s.message}`);
|
|
59
78
|
}
|
|
79
|
+
lines.push(...formatSkipped(report.skipped));
|
|
60
80
|
return lines.join('\n');
|
|
61
81
|
}
|
|
@@ -2,25 +2,37 @@
|
|
|
2
2
|
* lib/orchestration/code-review.js — in-process Story-scope code review:
|
|
3
3
|
* load the configured review adapter (default `native`), collect its
|
|
4
4
|
* `Finding[]`, render and post the `verification-results` comment (adapters
|
|
5
|
-
* never post), and report `halted` on any surviving critical finding
|
|
5
|
+
* never post), and report `halted` on any surviving critical finding or,
|
|
6
|
+
* under `onNoVerdict: "block"`, a missing verdict (`haltCause`).
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import picomatch from 'picomatch';
|
|
9
10
|
import { hasSurvivingCritical } from '../audit-suite/findings.js';
|
|
10
11
|
import { resolveConfig } from '../config-resolver.js';
|
|
12
|
+
import { gitSpawn } from '../git-utils.js';
|
|
11
13
|
import { PROJECT_ROOT } from '../project-root.js';
|
|
12
14
|
import { computeChangeSet } from './change-set.js';
|
|
13
15
|
import { remoteBaseRef } from './review-base-ref.js';
|
|
14
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
deriveChangeLevel,
|
|
18
|
+
resolveDepth,
|
|
19
|
+
resolveReviewEffort,
|
|
20
|
+
} from './review-depth.js';
|
|
15
21
|
import {
|
|
16
22
|
appendReviewRun,
|
|
23
|
+
earlierCriticals,
|
|
17
24
|
markRepeats,
|
|
25
|
+
raisedAgain,
|
|
18
26
|
readReviewHistory,
|
|
19
27
|
} from './review-history.js';
|
|
20
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
recheckCriticals,
|
|
30
|
+
vetFindings,
|
|
31
|
+
} from './review-providers/critical-verifier.js';
|
|
21
32
|
import {
|
|
22
33
|
collectProviderDegradations,
|
|
23
34
|
degradationEnvelope,
|
|
35
|
+
resolveNoVerdictHalt,
|
|
24
36
|
} from './review-providers/degraded-gates.js';
|
|
25
37
|
import { findingInstances } from './review-providers/finding-identity.js';
|
|
26
38
|
import {
|
|
@@ -125,6 +137,7 @@ function resolveStoryScope(opts, config) {
|
|
|
125
137
|
* postedCommentId: number|null,
|
|
126
138
|
* commentTargetId: number,
|
|
127
139
|
* halted: boolean,
|
|
140
|
+
* haltCause: 'critical'|'no-verdict'|null,
|
|
128
141
|
* criticalByProvider?: Record<string, number>,
|
|
129
142
|
* degraded: boolean, degradations: Array<object>,
|
|
130
143
|
* blockerReason: string|null,
|
|
@@ -277,23 +290,44 @@ function resolveCriticalByProvider({ findings, providerName, severity }) {
|
|
|
277
290
|
}
|
|
278
291
|
|
|
279
292
|
/** Tally, halt verdict and per-provider criticals of grounded findings. */
|
|
280
|
-
function scoreFindings(findings, providerName) {
|
|
293
|
+
function scoreFindings(findings, providerName, haltContext) {
|
|
281
294
|
const severity = countBySeverity(findings);
|
|
282
295
|
const halted = hasSurvivingCritical(severity);
|
|
283
296
|
return {
|
|
284
297
|
severity,
|
|
285
|
-
halted,
|
|
286
298
|
criticalByProvider: resolveCriticalByProvider({
|
|
287
299
|
findings,
|
|
288
300
|
providerName,
|
|
289
301
|
severity,
|
|
290
302
|
}),
|
|
291
|
-
|
|
292
|
-
? `code-review reported ${severity.critical} critical blocker(s)`
|
|
293
|
-
: null,
|
|
303
|
+
...resolveHalt(halted, severity, haltContext),
|
|
294
304
|
};
|
|
295
305
|
}
|
|
296
306
|
|
|
307
|
+
/**
|
|
308
|
+
* A surviving critical halts first; else `onNoVerdict: "block"` halts a
|
|
309
|
+
* review with a verdict-missing or coverage-partial degradation.
|
|
310
|
+
*/
|
|
311
|
+
function resolveHalt(
|
|
312
|
+
critical,
|
|
313
|
+
severity,
|
|
314
|
+
{ degradations, codeReviewConfig, ticketId },
|
|
315
|
+
) {
|
|
316
|
+
if (critical) {
|
|
317
|
+
return {
|
|
318
|
+
halted: true,
|
|
319
|
+
haltCause: 'critical',
|
|
320
|
+
blockerReason: `code-review reported ${severity.critical} critical blocker(s)`,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
const noVerdict = resolveNoVerdictHalt({
|
|
324
|
+
degradations,
|
|
325
|
+
onNoVerdict: codeReviewConfig?.onNoVerdict,
|
|
326
|
+
storyId: ticketId,
|
|
327
|
+
});
|
|
328
|
+
return noVerdict ?? { halted: false, haltCause: null, blockerReason: null };
|
|
329
|
+
}
|
|
330
|
+
|
|
297
331
|
/**
|
|
298
332
|
* Drop findings whose file, or every instance file, matches a `skipPaths`
|
|
299
333
|
* glob. Config only: guidance prose cannot reach this.
|
|
@@ -319,17 +353,155 @@ function resolveHistoryDeps(opts, config) {
|
|
|
319
353
|
return opts.reviewProvider ? null : { config };
|
|
320
354
|
}
|
|
321
355
|
|
|
322
|
-
/**
|
|
323
|
-
function
|
|
324
|
-
|
|
325
|
-
|
|
356
|
+
/** How the current run settles an earlier CRITICAL it raised again, if it did. */
|
|
357
|
+
function settleInRun(entry, findings) {
|
|
358
|
+
const again = findings.filter((f) => raisedAgain(f, entry.finding));
|
|
359
|
+
if (again.some((f) => f.severity === 'critical')) {
|
|
360
|
+
return { status: 'still-open' };
|
|
361
|
+
}
|
|
362
|
+
const flagged = again.find((f) => f.unverified || f.ungrounded);
|
|
363
|
+
return flagged
|
|
364
|
+
? { status: 'refuted', reason: flagged.unverified || flagged.ungrounded }
|
|
365
|
+
: null;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** A stored history record as a CRITICAL the verifier can re-check. */
|
|
369
|
+
function storedCritical({ id, finding: f }) {
|
|
370
|
+
const optional = Object.entries({
|
|
371
|
+
file: f.file ?? f.instances?.[0]?.file,
|
|
372
|
+
line: f.line,
|
|
373
|
+
claim: f.claim,
|
|
374
|
+
class: f.class,
|
|
375
|
+
provider: f.provider,
|
|
376
|
+
}).filter(([, v]) => v != null);
|
|
377
|
+
return {
|
|
378
|
+
severity: 'critical',
|
|
379
|
+
title: f.title ?? `Earlier CRITICAL ${id}`,
|
|
380
|
+
body: f.body ?? '',
|
|
381
|
+
...Object.fromEntries(optional),
|
|
382
|
+
instances: f.instances ?? [],
|
|
383
|
+
carriedId: id,
|
|
384
|
+
};
|
|
326
385
|
}
|
|
327
386
|
|
|
387
|
+
/** Reporting only: did the instance files change since the raising head? */
|
|
388
|
+
function instanceFilesChanged({ finding, headSha }, headRef, opts) {
|
|
389
|
+
const files = (finding.instances ?? []).map((i) => i.file);
|
|
390
|
+
if (files.length === 0) return false;
|
|
391
|
+
try {
|
|
392
|
+
const out = (opts.gitSpawnFn ?? gitSpawn)(
|
|
393
|
+
opts.cwd ?? PROJECT_ROOT,
|
|
394
|
+
'diff',
|
|
395
|
+
'--name-only',
|
|
396
|
+
headSha,
|
|
397
|
+
headRef,
|
|
398
|
+
'--',
|
|
399
|
+
...files,
|
|
400
|
+
);
|
|
401
|
+
return out?.status === 0 && String(out.stdout ?? '').trim() !== '';
|
|
402
|
+
} catch {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Settle every open earlier CRITICAL: re-raised, refuted in this run, or else
|
|
409
|
+
* re-verified at the current head. Only a verifier refutation resolves an
|
|
410
|
+
* absent one; anything else carries it into this run's findings as blocking.
|
|
411
|
+
*/
|
|
412
|
+
async function carryForward({ findings, history, reviewInput, opts }) {
|
|
413
|
+
const outcomes = [];
|
|
414
|
+
const absent = [];
|
|
415
|
+
for (const entry of earlierCriticals(history)) {
|
|
416
|
+
if (entry.status !== 'open') continue;
|
|
417
|
+
const inRun = settleInRun(entry, findings);
|
|
418
|
+
if (inRun) outcomes.push({ id: entry.id, ...inRun });
|
|
419
|
+
else absent.push(entry);
|
|
420
|
+
}
|
|
421
|
+
const stored = absent.map(storedCritical);
|
|
422
|
+
const checked = await recheckCriticals({
|
|
423
|
+
findings: stored,
|
|
424
|
+
reviewInput,
|
|
425
|
+
opts,
|
|
426
|
+
});
|
|
427
|
+
const carried = [];
|
|
428
|
+
absent.forEach((entry, i) => {
|
|
429
|
+
const { outcome, reason } = checked.results[i];
|
|
430
|
+
if (outcome === 'refuted') {
|
|
431
|
+
const fixed = instanceFilesChanged(entry, reviewInput.headRef, opts);
|
|
432
|
+
outcomes.push({
|
|
433
|
+
id: entry.id,
|
|
434
|
+
status: fixed ? 'fixed' : 'refuted',
|
|
435
|
+
reason,
|
|
436
|
+
});
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
carried.push({ ...stored[i], carried: reason });
|
|
440
|
+
outcomes.push({ id: entry.id, status: 'still-open', reason });
|
|
441
|
+
});
|
|
442
|
+
return { ...checked, findings: [...findings, ...carried], outcomes };
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** Every earlier surviving CRITICAL with this run's status for the comment. */
|
|
446
|
+
function earlierSection(history, outcomes) {
|
|
447
|
+
const now = new Map(outcomes.map((o) => [o.id, o]));
|
|
448
|
+
return earlierCriticals(history).map((e) => {
|
|
449
|
+
const settled = now.get(e.id) ?? e;
|
|
450
|
+
return {
|
|
451
|
+
id: e.id,
|
|
452
|
+
title: e.finding.title ?? null,
|
|
453
|
+
instances: e.finding.instances ?? [],
|
|
454
|
+
headSha: e.headSha,
|
|
455
|
+
status: settled.status,
|
|
456
|
+
...(settled.reason ? { reason: settled.reason } : {}),
|
|
457
|
+
};
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Mark repeats, then carry forward the open earlier CRITICALs. Without a
|
|
463
|
+
* history seam the findings pass through unchanged.
|
|
464
|
+
*/
|
|
465
|
+
async function applyHistory({
|
|
466
|
+
findings,
|
|
467
|
+
ticketId,
|
|
468
|
+
historyDeps,
|
|
469
|
+
reviewInput,
|
|
470
|
+
opts,
|
|
471
|
+
}) {
|
|
472
|
+
if (!historyDeps) {
|
|
473
|
+
return { findings, outcomes: null, earlier: [], degradations: [] };
|
|
474
|
+
}
|
|
475
|
+
const history = readReviewHistory(ticketId, historyDeps);
|
|
476
|
+
const carry = await carryForward({
|
|
477
|
+
findings: markRepeats(findings, history),
|
|
478
|
+
history,
|
|
479
|
+
reviewInput,
|
|
480
|
+
opts,
|
|
481
|
+
});
|
|
482
|
+
return { ...carry, earlier: earlierSection(history, carry.outcomes) };
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** Sum two verifier tallies; an absent second one adds nothing. */
|
|
486
|
+
const addVerification = (a, b = {}) =>
|
|
487
|
+
Object.fromEntries(Object.entries(a).map(([k, n]) => [k, n + (b[k] ?? 0)]));
|
|
488
|
+
|
|
328
489
|
/** Best-effort: a history write failure never fails the review. */
|
|
329
|
-
function recordRun({
|
|
490
|
+
function recordRun({
|
|
491
|
+
ticketId,
|
|
492
|
+
headRef,
|
|
493
|
+
findings,
|
|
494
|
+
outcomes,
|
|
495
|
+
historyDeps,
|
|
496
|
+
logger,
|
|
497
|
+
}) {
|
|
330
498
|
if (!historyDeps) return;
|
|
331
499
|
try {
|
|
332
|
-
appendReviewRun(
|
|
500
|
+
appendReviewRun(
|
|
501
|
+
ticketId,
|
|
502
|
+
{ headSha: headRef, findings, earlierCriticals: outcomes },
|
|
503
|
+
historyDeps,
|
|
504
|
+
);
|
|
333
505
|
} catch (err) {
|
|
334
506
|
logger?.warn?.(
|
|
335
507
|
`[code-review] Could not record the review history: ${err?.message ?? err}`,
|
|
@@ -361,8 +533,19 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
361
533
|
codeReviewConfig,
|
|
362
534
|
root: opts.cwd ?? PROJECT_ROOT,
|
|
363
535
|
});
|
|
536
|
+
const baseInput = buildReviewInput({
|
|
537
|
+
opts,
|
|
538
|
+
scope,
|
|
539
|
+
ticketId,
|
|
540
|
+
baseRef,
|
|
541
|
+
headRef,
|
|
542
|
+
});
|
|
364
543
|
const reviewInput = {
|
|
365
|
-
...
|
|
544
|
+
...baseInput,
|
|
545
|
+
effort: resolveReviewEffort(
|
|
546
|
+
baseInput.depth,
|
|
547
|
+
codeReviewConfig?.effortByDepth,
|
|
548
|
+
),
|
|
366
549
|
guidance: guidance.guidance,
|
|
367
550
|
};
|
|
368
551
|
|
|
@@ -389,11 +572,23 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
389
572
|
...(guidance.degradation ? [guidance.degradation] : []),
|
|
390
573
|
],
|
|
391
574
|
});
|
|
392
|
-
const { degradations, verification } = vetted;
|
|
393
575
|
const skip = applySkipPaths(vetted.findings, codeReviewConfig?.skipPaths);
|
|
394
576
|
const historyDeps = resolveHistoryDeps(opts, config);
|
|
395
|
-
const
|
|
396
|
-
|
|
577
|
+
const carry = await applyHistory({
|
|
578
|
+
findings: skip.findings,
|
|
579
|
+
ticketId,
|
|
580
|
+
historyDeps,
|
|
581
|
+
reviewInput,
|
|
582
|
+
opts,
|
|
583
|
+
});
|
|
584
|
+
const { findings } = carry;
|
|
585
|
+
const degradations = [...vetted.degradations, ...carry.degradations];
|
|
586
|
+
const verification = addVerification(vetted.verification, carry.verification);
|
|
587
|
+
const scored = scoreFindings(findings, providerName, {
|
|
588
|
+
degradations,
|
|
589
|
+
codeReviewConfig,
|
|
590
|
+
ticketId,
|
|
591
|
+
});
|
|
397
592
|
const report = renderFindingsFn({
|
|
398
593
|
scope,
|
|
399
594
|
ticketId,
|
|
@@ -405,8 +600,16 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
405
600
|
degradations,
|
|
406
601
|
verification,
|
|
407
602
|
skipped: skip.skipped,
|
|
603
|
+
earlierCriticals: carry.earlier,
|
|
604
|
+
});
|
|
605
|
+
recordRun({
|
|
606
|
+
ticketId,
|
|
607
|
+
headRef,
|
|
608
|
+
findings,
|
|
609
|
+
outcomes: carry.outcomes,
|
|
610
|
+
historyDeps,
|
|
611
|
+
logger,
|
|
408
612
|
});
|
|
409
|
-
recordRun({ ticketId, headRef, findings, historyDeps, logger });
|
|
410
613
|
|
|
411
614
|
const { posted, postedCommentId } = await postUnlessDeferred(opts, {
|
|
412
615
|
upsertCommentFn,
|
|
@@ -426,6 +629,7 @@ async function executeReviewPipeline({ opts, config, envelope }) {
|
|
|
426
629
|
postedCommentId,
|
|
427
630
|
commentTargetId,
|
|
428
631
|
halted: scored.halted,
|
|
632
|
+
haltCause: scored.haltCause,
|
|
429
633
|
criticalByProvider: scored.criticalByProvider,
|
|
430
634
|
...degradationEnvelope(degradations),
|
|
431
635
|
verification,
|