mandrel 2.111.0 → 2.112.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 +351 -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/preview-gates.js +29 -10
- package/.agents/scripts/lib/baselines/reader.js +36 -9
- package/.agents/scripts/lib/baselines/refresh-service.js +79 -18
- 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/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-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 +169 -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 +23 -8
- package/.agents/scripts/lib/orchestration/review-providers/code-review.js +82 -39
- package/.agents/scripts/lib/orchestration/review-providers/critical-verifier.js +64 -11
- package/.agents/scripts/lib/orchestration/review-providers/degraded-gates.js +98 -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 +15 -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-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 +20 -8
- package/.agents/scripts/lib/orchestration/story-deliver-terminal.js +7 -0
- package/.agents/scripts/lib/orchestration/story-handoff.js +774 -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 +46 -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
|
@@ -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,
|
|
@@ -13,7 +13,14 @@ import {
|
|
|
13
13
|
overBudgetPolicy,
|
|
14
14
|
QUALITY_PREVIEW_GATE_NAMES,
|
|
15
15
|
} from '../close-validation/gates.js';
|
|
16
|
+
import { getPostSeatChecks } from '../config/handoff.js';
|
|
16
17
|
import { COVERAGE_OVER_BUDGET_EXIT_CODE } from '../coverage-capture.js';
|
|
18
|
+
import {
|
|
19
|
+
COVERAGE_DEFERRED_REASONS,
|
|
20
|
+
deferCoverage,
|
|
21
|
+
deferralEnvelope,
|
|
22
|
+
} from '../coverage-deferral.js';
|
|
23
|
+
import { quoteFailureRows } from '../failure-rows.js';
|
|
17
24
|
import {
|
|
18
25
|
hashCommandConfig,
|
|
19
26
|
recordPass,
|
|
@@ -32,6 +39,7 @@ function closeGates(ctx) {
|
|
|
32
39
|
return buildDefaultGates({
|
|
33
40
|
config: ctx.config,
|
|
34
41
|
baseBranch: ctx.baseBranch,
|
|
42
|
+
baselineRef: ctx.baselineRef,
|
|
35
43
|
cwd: ctx.cwd,
|
|
36
44
|
evidenceCwd: ctx.evidenceCwd,
|
|
37
45
|
storyId: ctx.storyId,
|
|
@@ -43,13 +51,63 @@ function closeGates(ctx) {
|
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
54
|
+
* Gates whose argv ignores the changed-file set, so a baselines-only seat
|
|
55
|
+
* keeps their credit. Not `format`: its scoped argv names the changed files.
|
|
56
|
+
*/
|
|
57
|
+
const CARRYABLE_GATES = new Set(['lint', 'typecheck']);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* With `postSeatChecks` declared, `lint` runs bare: its credit is held until
|
|
61
|
+
* those checks pass at HEAD (story-handoff's `releaseHeldLint`).
|
|
62
|
+
*/
|
|
63
|
+
function holdsLint(ctx, gate) {
|
|
64
|
+
return gate.name === 'lint' && getPostSeatChecks(ctx.config).length > 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The argv a preflight check runs: bare when held, else deposited. */
|
|
68
|
+
function preflightArgv(ctx, gate, run) {
|
|
69
|
+
if (holdsLint(ctx, gate)) {
|
|
70
|
+
return { cmd: run.cmd, args: run.args, held: true };
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
cmd: 'node',
|
|
74
|
+
args: [
|
|
75
|
+
EVIDENCE_GATE,
|
|
76
|
+
'--standalone',
|
|
77
|
+
'--scope-id',
|
|
78
|
+
String(ctx.storyId),
|
|
79
|
+
'--gate',
|
|
80
|
+
gate.name,
|
|
81
|
+
'--worktree',
|
|
82
|
+
ctx.cwd,
|
|
83
|
+
'--cwd',
|
|
84
|
+
ctx.evidenceCwd,
|
|
85
|
+
'--',
|
|
86
|
+
run.cmd,
|
|
87
|
+
...run.args,
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A lint whose argv close never narrows to the changed files. */
|
|
93
|
+
function isWholeTreeLint(gate, run) {
|
|
94
|
+
return (
|
|
95
|
+
gate.name === 'lint' &&
|
|
96
|
+
!gate.changedFileScope &&
|
|
97
|
+
run.cmd === gate.cmd &&
|
|
98
|
+
run.args.length === gate.args.length &&
|
|
99
|
+
run.args.every((arg, i) => arg === gate.args[i])
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Close's preflight entries wrapped in `evidence-gate.js` with the argv close
|
|
105
|
+
* executes; a disabled or scoped-out gate deposits nothing.
|
|
48
106
|
*/
|
|
49
107
|
export function creditedPreflight(ctx) {
|
|
50
108
|
const checks = [];
|
|
51
109
|
for (const gate of closeGates(ctx).filter((g) =>
|
|
52
|
-
['lint', 'format'].includes(g.name),
|
|
110
|
+
['typecheck', 'lint', 'format'].includes(g.name),
|
|
53
111
|
)) {
|
|
54
112
|
const run = ctx.scopeGate({
|
|
55
113
|
gate,
|
|
@@ -59,59 +117,54 @@ export function creditedPreflight(ctx) {
|
|
|
59
117
|
if (run.skip) continue;
|
|
60
118
|
checks.push({
|
|
61
119
|
key: gate.name,
|
|
62
|
-
|
|
63
|
-
args: [
|
|
64
|
-
EVIDENCE_GATE,
|
|
65
|
-
'--standalone',
|
|
66
|
-
'--scope-id',
|
|
67
|
-
String(ctx.storyId),
|
|
68
|
-
'--gate',
|
|
69
|
-
gate.name,
|
|
70
|
-
'--worktree',
|
|
71
|
-
ctx.cwd,
|
|
72
|
-
'--cwd',
|
|
73
|
-
ctx.evidenceCwd,
|
|
74
|
-
'--',
|
|
75
|
-
run.cmd,
|
|
76
|
-
...run.args,
|
|
77
|
-
],
|
|
120
|
+
...preflightArgv(ctx, gate, run),
|
|
78
121
|
deposit: { cmd: run.cmd, args: run.args },
|
|
79
122
|
tolerateNoFilesProcessed: run.tolerateNoFilesProcessed,
|
|
123
|
+
wholeTree: isWholeTreeLint(gate, run),
|
|
80
124
|
});
|
|
81
125
|
}
|
|
82
126
|
return checks;
|
|
83
127
|
}
|
|
84
128
|
|
|
85
|
-
/**
|
|
86
|
-
export function
|
|
87
|
-
return
|
|
129
|
+
/** Record a passed carryable check's credit, hashed as close hashes it. */
|
|
130
|
+
export function recordPreflightCredit(ctx, check) {
|
|
131
|
+
if (!CARRYABLE_GATES.has(check.key)) return;
|
|
132
|
+
ctx.state.preflightCredits[check.key] = {
|
|
88
133
|
head: ctx.head,
|
|
89
134
|
configHash: hashCommandConfig({ ...check.deposit, cwd: ctx.cwd }),
|
|
90
135
|
};
|
|
91
136
|
}
|
|
92
137
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
* `format`: its scoped argv names the changed files, which the seat changes.
|
|
96
|
-
* Best-effort: a failed write only costs close a lint run.
|
|
97
|
-
*/
|
|
98
|
-
export function carryLintCredit(ctx, priorHead) {
|
|
99
|
-
const credit = ctx.state.lintCredit;
|
|
100
|
-
if (credit?.head !== priorHead) return;
|
|
138
|
+
/** Re-key one credit onto the seated HEAD; best-effort, like close's rerun. */
|
|
139
|
+
export function carryCredit(ctx, gateName, credit) {
|
|
101
140
|
try {
|
|
102
141
|
recordPass(
|
|
103
142
|
{
|
|
104
143
|
storyId: ctx.storyId,
|
|
105
|
-
gateName
|
|
144
|
+
gateName,
|
|
106
145
|
sha: ctx.head,
|
|
107
146
|
configHash: credit.configHash,
|
|
108
147
|
inputFingerprint: treeFingerprint(ctx.cwd, ctx.git),
|
|
109
148
|
},
|
|
110
149
|
{ cwd: ctx.evidenceCwd, standalone: true },
|
|
111
150
|
);
|
|
112
|
-
|
|
151
|
+
return { ...credit, head: ctx.head };
|
|
113
152
|
} catch (err) {
|
|
114
|
-
ctx.progress(
|
|
153
|
+
ctx.progress(
|
|
154
|
+
'seat',
|
|
155
|
+
`⚠️ ${gateName} credit not carried: ${err?.message ?? err}`,
|
|
156
|
+
);
|
|
157
|
+
return credit;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Re-key each credit deposited at `priorHead` onto the seated HEAD. */
|
|
162
|
+
export function carryPreflightCredits(ctx, priorHead) {
|
|
163
|
+
const credits = ctx.state.preflightCredits ?? {};
|
|
164
|
+
for (const [gateName, credit] of Object.entries(credits)) {
|
|
165
|
+
if (credit?.head === priorHead) {
|
|
166
|
+
credits[gateName] = carryCredit(ctx, gateName, credit);
|
|
167
|
+
}
|
|
115
168
|
}
|
|
116
169
|
}
|
|
117
170
|
|
|
@@ -121,25 +174,23 @@ export function carryLintCredit(ctx, priorHead) {
|
|
|
121
174
|
* @param {{ head: string, state: { coverageDeferredHead?: string } }} ctx
|
|
122
175
|
* @returns {boolean}
|
|
123
176
|
*/
|
|
124
|
-
function isCoverageDeferred(ctx) {
|
|
177
|
+
export function isCoverageDeferred(ctx) {
|
|
125
178
|
return Boolean(ctx.head) && ctx.state.coverageDeferredHead === ctx.head;
|
|
126
179
|
}
|
|
127
180
|
|
|
128
181
|
/**
|
|
129
|
-
* Did the capture
|
|
182
|
+
* Did the depositor — the capture or the `test` run — declare its slice over
|
|
183
|
+
* this host's budget?
|
|
130
184
|
*
|
|
131
|
-
* @param {
|
|
185
|
+
* @param {number} status
|
|
132
186
|
* @returns {boolean}
|
|
133
187
|
*/
|
|
134
|
-
export function
|
|
135
|
-
return
|
|
136
|
-
ctx.depositor === 'coverage-capture' &&
|
|
137
|
-
status === COVERAGE_OVER_BUDGET_EXIT_CODE
|
|
138
|
-
);
|
|
188
|
+
export function isOverBudgetExit(status) {
|
|
189
|
+
return status === COVERAGE_OVER_BUDGET_EXIT_CODE;
|
|
139
190
|
}
|
|
140
191
|
|
|
141
192
|
/**
|
|
142
|
-
* An over-budget
|
|
193
|
+
* An over-budget depositor's step result: deferred to CI (no credit, the
|
|
143
194
|
* coverage-reading gates skipped) or `blocked`, by `coverage.onOverBudget`.
|
|
144
195
|
*
|
|
145
196
|
* @param {object} ctx @param {string} name @param {object} extra
|
|
@@ -148,7 +199,7 @@ export function isOverBudgetCapture(ctx, status) {
|
|
|
148
199
|
export function settleOverBudget(ctx, name, extra) {
|
|
149
200
|
const exit = `exit ${COVERAGE_OVER_BUDGET_EXIT_CODE}`;
|
|
150
201
|
if (overBudgetPolicy(ctx.config) === 'defer-to-ci') {
|
|
151
|
-
ctx.state
|
|
202
|
+
deferCoverage(ctx.state, ctx.head, COVERAGE_DEFERRED_REASONS.overBudget);
|
|
152
203
|
return {
|
|
153
204
|
name,
|
|
154
205
|
outcome: 'deferred',
|
|
@@ -159,8 +210,9 @@ export function settleOverBudget(ctx, name, extra) {
|
|
|
159
210
|
return {
|
|
160
211
|
name,
|
|
161
212
|
outcome: 'failed',
|
|
162
|
-
detail:
|
|
213
|
+
detail: `${ctx.depositor} over budget (${exit}) under delivery.quality.gates.coverage.onOverBudget: block`,
|
|
163
214
|
reason: OVER_BUDGET_BLOCK_HINT,
|
|
215
|
+
cause: 'capture-over-budget',
|
|
164
216
|
stop: 'blocked',
|
|
165
217
|
...extra,
|
|
166
218
|
};
|
|
@@ -169,13 +221,7 @@ export function settleOverBudget(ctx, name, extra) {
|
|
|
169
221
|
/** The envelope's `coverage` field, present only after a deferral. */
|
|
170
222
|
export function coverageEnvelope(ctx) {
|
|
171
223
|
if (!isCoverageDeferred(ctx)) return {};
|
|
172
|
-
return {
|
|
173
|
-
coverage: {
|
|
174
|
-
status: 'deferred',
|
|
175
|
-
reason: 'over-budget',
|
|
176
|
-
policy: 'defer-to-ci',
|
|
177
|
-
},
|
|
178
|
-
};
|
|
224
|
+
return { coverage: deferralEnvelope(ctx.state.coverageDeferredReason) };
|
|
179
225
|
}
|
|
180
226
|
|
|
181
227
|
/**
|
|
@@ -187,6 +233,7 @@ export function coverageEnvelope(ctx) {
|
|
|
187
233
|
export function clearCoverageDeferral(state) {
|
|
188
234
|
if (state.coverageDeferredHead === undefined) return;
|
|
189
235
|
delete state.coverageDeferredHead;
|
|
236
|
+
delete state.coverageDeferredReason;
|
|
190
237
|
delete state.seatHead;
|
|
191
238
|
}
|
|
192
239
|
|
|
@@ -202,10 +249,13 @@ export function postCaptureSettled(ctx) {
|
|
|
202
249
|
return ctx.state.creditHead === ctx.head || isCoverageDeferred(ctx);
|
|
203
250
|
}
|
|
204
251
|
|
|
205
|
-
/**
|
|
252
|
+
/** Seat kinds that read the coverage artifact, which a deferral never writes. */
|
|
253
|
+
const ARTIFACT_SEATS = new Set(['crap', 'coverage']);
|
|
254
|
+
|
|
255
|
+
/** CRAP and coverage seating need a fresh artifact. */
|
|
206
256
|
export function seatableKinds(ctx, kinds) {
|
|
207
257
|
const deferred = isCoverageDeferred(ctx);
|
|
208
|
-
return kinds.filter((kind) =>
|
|
258
|
+
return kinds.filter((kind) => !deferred || !ARTIFACT_SEATS.has(kind));
|
|
209
259
|
}
|
|
210
260
|
|
|
211
261
|
/**
|
|
@@ -227,10 +277,33 @@ function postCaptureFilter(names, deferred) {
|
|
|
227
277
|
names.has(g.name) && !g.skip && !(deferred && g.readsCoverageArtifact);
|
|
228
278
|
}
|
|
229
279
|
|
|
280
|
+
/** The kinds a baselines entry scores; `null` without `--gate` (every kind). */
|
|
281
|
+
function gateKinds(gate) {
|
|
282
|
+
const i = gate.args.indexOf('--gate');
|
|
283
|
+
return i === -1 ? null : gate.args[i + 1];
|
|
284
|
+
}
|
|
285
|
+
|
|
230
286
|
/** The gate name, plus the kinds a baselines entry scores. */
|
|
231
287
|
function describeGate(gate) {
|
|
232
|
-
const
|
|
233
|
-
return
|
|
288
|
+
const kinds = gateKinds(gate);
|
|
289
|
+
return kinds ? `${gate.name} (kinds: ${kinds})` : gate.name;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Does a baselines entry score duplication? (No `--gate` scores every kind.) */
|
|
293
|
+
function scoresDuplication(gate) {
|
|
294
|
+
if (gate.name === QUALITY_PREVIEW_GATE_NAMES.crap) return false;
|
|
295
|
+
return (gateKinds(gate) ?? 'duplication').includes('duplication');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** A non-zero post-capture exit as the handoff's finding. */
|
|
299
|
+
function failure(gate, res) {
|
|
300
|
+
return {
|
|
301
|
+
gate: gate.name,
|
|
302
|
+
finding: `${describeGate(gate)} finding (exit ${res.status})${quoteFailureRows(res.output)} — fix and commit, then re-run`,
|
|
303
|
+
evidencePath: res.evidencePath,
|
|
304
|
+
scoresDuplication: scoresDuplication(gate),
|
|
305
|
+
baselineRef: gate.env?.BASELINE_REF,
|
|
306
|
+
};
|
|
234
307
|
}
|
|
235
308
|
|
|
236
309
|
/** Run each post-capture gate through `run`; the first non-zero exit is the finding. */
|
|
@@ -244,13 +317,7 @@ export async function scorePostCapture(ctx, run) {
|
|
|
244
317
|
gate.args,
|
|
245
318
|
env,
|
|
246
319
|
);
|
|
247
|
-
if (res.status !== 0) {
|
|
248
|
-
const finding = `${describeGate(gate)} finding (exit ${res.status}) — fix and commit, then re-run`;
|
|
249
|
-
return {
|
|
250
|
-
gates,
|
|
251
|
-
failed: { gate: gate.name, finding, evidencePath: res.evidencePath },
|
|
252
|
-
};
|
|
253
|
-
}
|
|
320
|
+
if (res.status !== 0) return { gates, failed: failure(gate, res) };
|
|
254
321
|
}
|
|
255
322
|
return { gates, failed: null };
|
|
256
323
|
}
|