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
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
classifyBranchSeed,
|
|
28
28
|
seedStoryBranchRef,
|
|
29
29
|
} from './lib/git-branch-lifecycle.js';
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
getStoryBranch,
|
|
32
|
+
gitSpawn,
|
|
33
|
+
gitSync,
|
|
34
|
+
parseStoryBranch,
|
|
35
|
+
} from './lib/git-utils.js';
|
|
31
36
|
import { Logger } from './lib/Logger.js';
|
|
32
37
|
import { TYPE_LABELS } from './lib/label-constants.js';
|
|
33
38
|
import { emitTerseResult } from './lib/observability/terse-result.js';
|
|
@@ -280,12 +285,13 @@ export async function reapClosedStoryWorktrees({
|
|
|
280
285
|
|
|
281
286
|
/**
|
|
282
287
|
* Reap merged `story-*` branches (excluding the current one), then the
|
|
283
|
-
* closed-Story worktrees, then stranded `agent::closing` Stories
|
|
288
|
+
* closed-Story worktrees, then stranded `agent::closing` Stories, then reports
|
|
289
|
+
* stalled `agent::executing` Stories (never this one). Never
|
|
284
290
|
* blocks init. Protected candidates (unpushed work, dirty worktree, open
|
|
285
291
|
* Story) are skipped; the lockfile is shared with `boot-sweep.js` via
|
|
286
292
|
* `resolveSweepLockPath` so concurrent reaps cannot race.
|
|
287
293
|
*
|
|
288
|
-
* @returns {Promise<{ worktreeSweep: object, closingReconcile: object }>}
|
|
294
|
+
* @returns {Promise<{ worktreeSweep: object, closingReconcile: object, stalledExecuting: object }>}
|
|
289
295
|
*/
|
|
290
296
|
export async function reapMergedStoryBranches({
|
|
291
297
|
cwd,
|
|
@@ -297,6 +303,7 @@ export async function reapMergedStoryBranches({
|
|
|
297
303
|
worktreeSweepFn,
|
|
298
304
|
acquireLockFn,
|
|
299
305
|
closingReconcileFn,
|
|
306
|
+
stalledExecutingFn,
|
|
300
307
|
}) {
|
|
301
308
|
const sweepFn =
|
|
302
309
|
injectedSweep ??
|
|
@@ -336,7 +343,20 @@ export async function reapMergedStoryBranches({
|
|
|
336
343
|
warn: (m) => progress('CLEANUP', `⚠️ ${m}`),
|
|
337
344
|
},
|
|
338
345
|
});
|
|
339
|
-
|
|
346
|
+
const report =
|
|
347
|
+
stalledExecutingFn ??
|
|
348
|
+
(await import('./lib/single-story-sweep/report-stalled-executing.js'))
|
|
349
|
+
.reportStalledExecuting;
|
|
350
|
+
const stalledExecuting = await report({
|
|
351
|
+
provider,
|
|
352
|
+
config,
|
|
353
|
+
excludeStoryIds: [parseStoryBranch(storyBranch)],
|
|
354
|
+
logger: {
|
|
355
|
+
info: (m) => progress('CLEANUP', m),
|
|
356
|
+
warn: (m) => progress('CLEANUP', `⚠️ ${m}`),
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
return { worktreeSweep, closingReconcile, stalledExecuting };
|
|
340
360
|
}
|
|
341
361
|
|
|
342
362
|
async function reapMergedBranches({
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* story-handoff.js — the story-worker's whole post-implementation tail in one
|
|
5
|
-
* command:
|
|
6
|
-
*
|
|
5
|
+
* command: merge origin/<base> → close's untagged duplication re-score →
|
|
6
|
+
* preflight (lint + quality-preview + baselined ratchets) → the one credited run → `--seat-missing` baseline seating →
|
|
7
7
|
* push + remote-ref check → held Story-scope review. Prints one JSON envelope on stdout.
|
|
8
8
|
*
|
|
9
9
|
* Exit 0 `ready` (hand off) · 2 `fix-required` (fix, commit, re-run; labels
|
|
@@ -26,7 +26,7 @@ const USAGE = {
|
|
|
26
26
|
invocation:
|
|
27
27
|
'node .agents/scripts/story-handoff.js --story <id> [--cwd <workCwd>]',
|
|
28
28
|
summary:
|
|
29
|
-
"Run the story-worker's post-implementation tail —
|
|
29
|
+
"Run the story-worker's post-implementation tail — base merge, duplication re-score, preflight, the one credited run, baseline seating, push and held review — and print one envelope: ready (exit 0), fix-required (exit 2) or blocked (exit 1).",
|
|
30
30
|
flags: [
|
|
31
31
|
['--story <id>', 'Story issue number; the branch is story-<id>.'],
|
|
32
32
|
['--cwd <path>', "The Story's worktree (default: the current directory)."],
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* story-outcomes-report.js — roll up the `story-outcome` records close writes
|
|
5
|
+
* when `delivery.feedbackLoop.outcomeRecord` is on: per-Story rows, first-pass
|
|
6
|
+
* rate, mean attempts to land, failed gates by count, and the same rates split
|
|
7
|
+
* by the mandrel version of each landing. Read-only; one paginated read.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { parseArgs } from 'node:util';
|
|
11
|
+
|
|
12
|
+
import { runAsCli } from './lib/cli-utils.js';
|
|
13
|
+
import { resolveConfig } from './lib/config-resolver.js';
|
|
14
|
+
import {
|
|
15
|
+
OUTCOME_COMMENT_TYPE,
|
|
16
|
+
parseOutcomeBody,
|
|
17
|
+
} from './lib/observability/story-outcome.js';
|
|
18
|
+
import { structuredCommentMarker } from './lib/orchestration/ticketing/reads.js';
|
|
19
|
+
import { createProvider } from './lib/provider-factory.js';
|
|
20
|
+
import { alignRows } from './review-dispositions-report.js';
|
|
21
|
+
|
|
22
|
+
const USAGE = {
|
|
23
|
+
invocation:
|
|
24
|
+
'node .agents/scripts/story-outcomes-report.js [--since <YYYY-MM-DD>] [--json]',
|
|
25
|
+
summary:
|
|
26
|
+
'Summarize the per-Story close outcome records (story-outcome comments) updated in the window: per-Story rows, first-pass rate, mean attempts to land, blocked/failed share of attempts, failed gates ranked by count, and the same rates by landing mandrel version.',
|
|
27
|
+
flags: [
|
|
28
|
+
['--since <YYYY-MM-DD>', 'Window start (default: 7 days ago).'],
|
|
29
|
+
['--json', 'Emit the report as JSON instead of a table.'],
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
34
|
+
const DEFAULT_WINDOW_DAYS = 7;
|
|
35
|
+
const DAY_MS = 86_400_000;
|
|
36
|
+
|
|
37
|
+
/** @param {number|null} r */
|
|
38
|
+
const pct = (r) => (r === null ? '-' : `${(r * 100).toFixed(1)}%`);
|
|
39
|
+
const ratio = (num, den) => (den > 0 ? num / den : null);
|
|
40
|
+
const mean = (values) =>
|
|
41
|
+
values.length > 0 ? values.reduce((a, b) => a + b, 0) / values.length : null;
|
|
42
|
+
|
|
43
|
+
function storyIdOf(comment) {
|
|
44
|
+
const match = /\/issues\/(\d+)$/.exec(String(comment?.issue_url ?? ''));
|
|
45
|
+
return match ? Number(match[1]) : null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Latest outcome comment per Story, by `updated_at`. */
|
|
49
|
+
function latestPerStory(comments) {
|
|
50
|
+
const marker = structuredCommentMarker(OUTCOME_COMMENT_TYPE);
|
|
51
|
+
const byStory = new Map();
|
|
52
|
+
for (const comment of comments ?? []) {
|
|
53
|
+
if (!String(comment?.body ?? '').includes(marker)) continue;
|
|
54
|
+
const storyId = storyIdOf(comment);
|
|
55
|
+
const prior = byStory.get(storyId);
|
|
56
|
+
if (!prior || String(comment.updated_at) > String(prior.updated_at)) {
|
|
57
|
+
byStory.set(storyId, comment);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return byStory;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function landingVersion(record) {
|
|
64
|
+
const landing = record.attempts.findLast((a) => a?.status === 'landed');
|
|
65
|
+
return landing?.mandrelVersion ?? 'unknown';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function storyRow(storyId, record) {
|
|
69
|
+
const s = record.summary;
|
|
70
|
+
return {
|
|
71
|
+
storyId: record.storyId ?? storyId,
|
|
72
|
+
attempts: s.attempts ?? 0,
|
|
73
|
+
byStatus: s.byStatus ?? {},
|
|
74
|
+
landed: Boolean(s.landedAt),
|
|
75
|
+
firstPass: s.firstPass === true,
|
|
76
|
+
landedOnAttempt: s.landedOnAttempt ?? null,
|
|
77
|
+
failedGates: s.failedGates ?? {},
|
|
78
|
+
mandrelVersion: s.landedAt ? landingVersion(record) : null,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function landingRates(rows) {
|
|
83
|
+
const landed = rows.filter((r) => r.landed);
|
|
84
|
+
return {
|
|
85
|
+
landed: landed.length,
|
|
86
|
+
firstPassRate: ratio(
|
|
87
|
+
landed.filter((r) => r.firstPass).length,
|
|
88
|
+
landed.length,
|
|
89
|
+
),
|
|
90
|
+
meanAttemptsToLand: mean(
|
|
91
|
+
landed.map((r) => r.landedOnAttempt).filter(Number.isInteger),
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @param {Array<object>} comments raw repo issue comments.
|
|
98
|
+
* @returns {object} the report.
|
|
99
|
+
*/
|
|
100
|
+
export function summarizeOutcomes(comments) {
|
|
101
|
+
const rows = [];
|
|
102
|
+
const unreadable = [];
|
|
103
|
+
for (const [storyId, comment] of latestPerStory(comments)) {
|
|
104
|
+
const record = parseOutcomeBody(comment.body);
|
|
105
|
+
if (record) rows.push(storyRow(storyId, record));
|
|
106
|
+
else unreadable.push({ storyId, commentId: comment.id ?? null });
|
|
107
|
+
}
|
|
108
|
+
rows.sort((a, b) => a.storyId - b.storyId);
|
|
109
|
+
const totalAttempts = rows.reduce((n, r) => n + r.attempts, 0);
|
|
110
|
+
const sumStatus = (status) =>
|
|
111
|
+
rows.reduce((n, r) => n + (r.byStatus[status] ?? 0), 0);
|
|
112
|
+
const gateCounts = {};
|
|
113
|
+
for (const row of rows) {
|
|
114
|
+
for (const [gate, count] of Object.entries(row.failedGates)) {
|
|
115
|
+
gateCounts[gate] = (gateCounts[gate] ?? 0) + count;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const versions = [
|
|
119
|
+
...new Set(rows.filter((r) => r.landed).map((r) => r.mandrelVersion)),
|
|
120
|
+
];
|
|
121
|
+
return {
|
|
122
|
+
stories: rows.length,
|
|
123
|
+
...landingRates(rows),
|
|
124
|
+
blockedShare: ratio(sumStatus('blocked'), totalAttempts),
|
|
125
|
+
failedShare: ratio(sumStatus('failed'), totalAttempts),
|
|
126
|
+
failedGates: Object.entries(gateCounts)
|
|
127
|
+
.map(([gate, count]) => ({ gate, count }))
|
|
128
|
+
.sort((a, b) => b.count - a.count || a.gate.localeCompare(b.gate)),
|
|
129
|
+
byMandrelVersion: Object.fromEntries(
|
|
130
|
+
versions
|
|
131
|
+
.sort()
|
|
132
|
+
.map((v) => [
|
|
133
|
+
v,
|
|
134
|
+
landingRates(rows.filter((r) => r.mandrelVersion === v)),
|
|
135
|
+
]),
|
|
136
|
+
),
|
|
137
|
+
unreadable,
|
|
138
|
+
rows,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function renderReport(report) {
|
|
143
|
+
const fmtMean = (m) => (m === null ? '-' : m.toFixed(2));
|
|
144
|
+
const storyTable = alignRows([
|
|
145
|
+
['story', 'attempts', 'landed', 'first-pass', 'version', 'failed gates'],
|
|
146
|
+
...report.rows.map((r) => [
|
|
147
|
+
`#${r.storyId}`,
|
|
148
|
+
String(r.attempts),
|
|
149
|
+
r.landed ? 'yes' : 'no',
|
|
150
|
+
r.firstPass ? 'yes' : 'no',
|
|
151
|
+
r.mandrelVersion ?? '-',
|
|
152
|
+
Object.keys(r.failedGates).join(', ') || '-',
|
|
153
|
+
]),
|
|
154
|
+
]);
|
|
155
|
+
const versionTable = alignRows([
|
|
156
|
+
['version', 'landed', 'first-pass', 'mean attempts'],
|
|
157
|
+
...Object.entries(report.byMandrelVersion).map(([v, r]) => [
|
|
158
|
+
v,
|
|
159
|
+
String(r.landed),
|
|
160
|
+
pct(r.firstPassRate),
|
|
161
|
+
fmtMean(r.meanAttemptsToLand),
|
|
162
|
+
]),
|
|
163
|
+
]);
|
|
164
|
+
return [
|
|
165
|
+
...storyTable,
|
|
166
|
+
'',
|
|
167
|
+
`stories ${report.stories} · landed ${report.landed} · first-pass ${pct(report.firstPassRate)} · mean attempts to land ${fmtMean(report.meanAttemptsToLand)} · blocked ${pct(report.blockedShare)} · failed ${pct(report.failedShare)} of attempts`,
|
|
168
|
+
`failed gates: ${report.failedGates.map((g) => `${g.gate} ${g.count}`).join(', ') || 'none'}`,
|
|
169
|
+
'',
|
|
170
|
+
...versionTable,
|
|
171
|
+
...(report.unreadable.length > 0
|
|
172
|
+
? [
|
|
173
|
+
'',
|
|
174
|
+
`unreadable: ${report.unreadable.map((u) => `#${u.storyId}`).join(', ')}`,
|
|
175
|
+
]
|
|
176
|
+
: []),
|
|
177
|
+
'',
|
|
178
|
+
].join('\n');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @param {string[]} [argv]
|
|
183
|
+
* @param {{ resolveConfigImpl?: typeof resolveConfig,
|
|
184
|
+
* providerFactory?: typeof createProvider,
|
|
185
|
+
* stdout?: { write: (s: string) => void }, cwd?: string, nowMs?: number }} [deps]
|
|
186
|
+
* @returns {Promise<object>} the report.
|
|
187
|
+
*/
|
|
188
|
+
export async function runStoryOutcomesReport(
|
|
189
|
+
argv = process.argv.slice(2),
|
|
190
|
+
deps = {},
|
|
191
|
+
) {
|
|
192
|
+
const {
|
|
193
|
+
resolveConfigImpl = resolveConfig,
|
|
194
|
+
providerFactory = createProvider,
|
|
195
|
+
stdout = process.stdout,
|
|
196
|
+
cwd = process.cwd(),
|
|
197
|
+
nowMs = Date.now(),
|
|
198
|
+
} = deps;
|
|
199
|
+
const { values } = parseArgs({
|
|
200
|
+
args: argv,
|
|
201
|
+
options: { since: { type: 'string' }, json: { type: 'boolean' } },
|
|
202
|
+
});
|
|
203
|
+
if (values.since !== undefined && !DATE.test(values.since)) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`story-outcomes-report: --since must be YYYY-MM-DD (got "${values.since}").`,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const since = values.since
|
|
209
|
+
? `${values.since}T00:00:00Z`
|
|
210
|
+
: new Date(nowMs - DEFAULT_WINDOW_DAYS * DAY_MS).toISOString();
|
|
211
|
+
const provider = providerFactory(resolveConfigImpl({ cwd }));
|
|
212
|
+
const report = summarizeOutcomes(await provider.getRepoCommentsSince(since));
|
|
213
|
+
stdout.write(
|
|
214
|
+
values.json
|
|
215
|
+
? `${JSON.stringify({ since, ...report }, null, 2)}\n`
|
|
216
|
+
: renderReport(report),
|
|
217
|
+
);
|
|
218
|
+
return report;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async function main() {
|
|
222
|
+
await runStoryOutcomesReport();
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
runAsCli(import.meta.url, main, {
|
|
227
|
+
source: 'story-outcomes-report',
|
|
228
|
+
propagateExitCode: true,
|
|
229
|
+
errorPrefix: '[story-outcomes-report] ❌ Fatal error',
|
|
230
|
+
usage: USAGE,
|
|
231
|
+
});
|
|
@@ -54,6 +54,14 @@ function formatTally(severity) {
|
|
|
54
54
|
return `critical=${s.critical ?? 0} high=${s.high ?? 0} medium=${s.medium ?? 0} suggestion=${s.suggestion ?? 0}`;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/** A no-verdict halt is blocked (no code change resolves it); else CRITICAL. */
|
|
58
|
+
function haltLine(deposit) {
|
|
59
|
+
if (deposit.haltCause === 'no-verdict') {
|
|
60
|
+
return `[story-review-compute] ⛔ BLOCKED: ${deposit.blockerReason}\n`;
|
|
61
|
+
}
|
|
62
|
+
return `[story-review-compute] ❌ CRITICAL: fix, commit and re-push before hand-off. Report:\n${deposit.report}\n`;
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
/**
|
|
58
66
|
* @param {{ storyId: number, cwd: string, config: object }} input
|
|
59
67
|
* @param {{
|
|
@@ -167,11 +175,7 @@ export async function runStoryReviewComputeCli(
|
|
|
167
175
|
`[story-review-compute] ✅ Held review for Story #${storyId} written → ${outcome.path}\n` +
|
|
168
176
|
`[story-review-compute] diff ${deposit.diffDigest.slice(0, 12)} @ ${deposit.headSha.slice(0, 12)} · ${formatTally(deposit.severity)}\n`,
|
|
169
177
|
);
|
|
170
|
-
if (deposit.halted)
|
|
171
|
-
stdout.write(
|
|
172
|
-
`[story-review-compute] ❌ CRITICAL: fix, commit and re-push before hand-off. Report:\n${deposit.report}\n`,
|
|
173
|
-
);
|
|
174
|
-
}
|
|
178
|
+
if (deposit.halted) stdout.write(haltLine(deposit));
|
|
175
179
|
return outcome;
|
|
176
180
|
}
|
|
177
181
|
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
resolveCoverageUpdaterScope,
|
|
15
15
|
} from './lib/baselines/coverage-updater-cli.js';
|
|
16
16
|
import { refreshBaseline } from './lib/baselines/refresh-service.js';
|
|
17
|
+
import { seatCoverageBaseline } from './lib/baselines/seat-missing.js';
|
|
17
18
|
import { runAsCli } from './lib/cli-utils.js';
|
|
18
19
|
import { getQuality, resolveConfig } from './lib/config-resolver.js';
|
|
19
20
|
import { Logger } from './lib/Logger.js';
|
|
@@ -21,7 +22,7 @@ import { Logger } from './lib/Logger.js';
|
|
|
21
22
|
/** `runAsCli` answers `--help` before `main`, so a usage probe never writes. */
|
|
22
23
|
const USAGE = {
|
|
23
24
|
invocation:
|
|
24
|
-
'node .agents/scripts/update-coverage-baseline.js [--full-scope | --diff-scope <ref>]',
|
|
25
|
+
'node .agents/scripts/update-coverage-baseline.js [--full-scope | --diff-scope <ref>] [--seat-missing]',
|
|
25
26
|
summary:
|
|
26
27
|
'Score → write the coverage baseline from the coverage artifact (`delivery.quality.gates.coverage.coveragePath`, Istanbul coverage-final.json) already on disk. With no scope flag the refresh is scoped to the files changed in `origin/main..HEAD`; out-of-scope rows are preserved verbatim.',
|
|
27
28
|
flags: [
|
|
@@ -33,6 +34,10 @@ const USAGE = {
|
|
|
33
34
|
'--diff-scope <ref>',
|
|
34
35
|
'Scope the refresh to files changed between <ref> and HEAD. Incompatible with --full-scope.',
|
|
35
36
|
],
|
|
37
|
+
[
|
|
38
|
+
'--seat-missing',
|
|
39
|
+
'Insert-only: write rows ONLY for changed files (merge-base of `--diff-scope <ref>`, default `origin/<baseBranch>`) that have no baseline row; every existing row stays byte-identical. Refuses unless a coverage capture stamp is fresh for the current tree; a changed file the artifact did not measure is logged, never seated. Prints `seated: N`. Incompatible with --full-scope.',
|
|
40
|
+
],
|
|
36
41
|
],
|
|
37
42
|
notes: [
|
|
38
43
|
"Run the coverage gate's `captureScript` first (`delivery.quality.gates.coverage.captureScript`) — this script never runs the suite itself.",
|
|
@@ -67,7 +72,12 @@ function main() {
|
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
|
|
70
|
-
|
|
75
|
+
async function seat() {
|
|
76
|
+
process.exitCode = await seatCoverageBaseline(process.argv.slice(2));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const seating = process.argv.includes('--seat-missing');
|
|
80
|
+
runAsCli(import.meta.url, seating ? seat : main, {
|
|
71
81
|
source: 'coverage-baseline',
|
|
72
82
|
usage: USAGE,
|
|
73
83
|
onError: (err) => {
|
|
@@ -78,9 +78,17 @@ async function main() {
|
|
|
78
78
|
epsilon: getBaselineEpsilon('crap'),
|
|
79
79
|
}),
|
|
80
80
|
);
|
|
81
|
+
logRefresh(result, options.absBaselinePath);
|
|
82
|
+
}
|
|
81
83
|
|
|
84
|
+
/** An ahead baseline was left untouched; otherwise report the write. */
|
|
85
|
+
function logRefresh(result, baselinePath) {
|
|
86
|
+
if (result.ahead) {
|
|
87
|
+
Logger.info(result.ahead.message);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
82
90
|
Logger.info(
|
|
83
|
-
`[CRAP] ✅ Baseline updated (kernelVersion=${result.envelope.kernelVersion}, escomplexVersion=${resolveEscomplexVersion()}, tsTranspilerVersion=${result.envelope.tsTranspilerVersion}). Wrote to ${
|
|
91
|
+
`[CRAP] ✅ Baseline updated (kernelVersion=${result.envelope.kernelVersion}, escomplexVersion=${resolveEscomplexVersion()}, tsTranspilerVersion=${result.envelope.tsTranspilerVersion}). Wrote to ${baselinePath}.`,
|
|
84
92
|
);
|
|
85
93
|
Logger.info(
|
|
86
94
|
`[CRAP] Wrote ${result.envelope.rows.length} row(s). scope=${result.scope.mode}, wrote=${result.wrote}.`,
|
|
@@ -83,6 +83,10 @@ How each tier changes the review protocol:
|
|
|
83
83
|
to check every caller in that block against the new signature or shape —
|
|
84
84
|
the one bug class a diff alone cannot show.
|
|
85
85
|
|
|
86
|
+
The `code-review` provider also maps depth to `claude --effort`: `low` at
|
|
87
|
+
`light` and `standard`, `high` at `deep`. `delivery.codeReview.effortByDepth`
|
|
88
|
+
overrides that per depth (`low`/`medium`/`high`/`xhigh`/`max`).
|
|
89
|
+
|
|
86
90
|
The LLM-backed review providers (code-review, codex, security-review,
|
|
87
91
|
ultrareview) render the resolved `depth` into the prompt/instructions they emit so the underlying
|
|
88
92
|
model actually changes thoroughness. The native provider deliberately ignores
|
|
@@ -122,6 +126,30 @@ collapsed under **Previously raised**. A repeat still halts unless an operator
|
|
|
122
126
|
overrode that CRITICAL with `--override-review-block` earlier, in which case
|
|
123
127
|
it is downgraded to a suggestion.
|
|
124
128
|
|
|
129
|
+
### Earlier CRITICALs stay blocking
|
|
130
|
+
|
|
131
|
+
A CRITICAL that survived grounding and verification stays open across later
|
|
132
|
+
runs. Each run settles every open one: raised again at an overlapping
|
|
133
|
+
location and still critical, it halts as a repeat; raised there but refuted
|
|
134
|
+
or ungrounded by this run, it is resolved. Otherwise (absent, or raised below
|
|
135
|
+
critical) the critical-verifier re-checks the stored finding at the current
|
|
136
|
+
head: one call each at any depth, at most 10 per run, 3 in flight. Only a
|
|
137
|
+
`refuted` verdict resolves it; confirmed, uncertain, an unproven
|
|
138
|
+
confirmation, an error, a missing CLI or the cap carries it into the run's
|
|
139
|
+
findings as a blocking CRITICAL (errors and the cap also record a
|
|
140
|
+
`critical-verification` degraded gate). A later delta touching its location
|
|
141
|
+
never clears it: only a verifier refutation at the current head or an
|
|
142
|
+
operator override does, and `--override-review-block` covers a carried
|
|
143
|
+
CRITICAL like any other. A resolved one is labelled `fixed` when its instance
|
|
144
|
+
files changed since the head that raised it, else `refuted` (reporting only).
|
|
145
|
+
The history keeps each CRITICAL's title, body (4,000 characters), location
|
|
146
|
+
and claim for the re-check, plus each run's outcomes; an older history reads
|
|
147
|
+
as before. When the history holds any earlier surviving CRITICAL, the comment
|
|
148
|
+
renders an **Earlier CRITICALs** section (id, title, last location, raising
|
|
149
|
+
head, status `still open` / `fixed` / `refuted` / `overridden`), on a
|
|
150
|
+
zero-finding run too; a carried finding renders only there, and the
|
|
151
|
+
unqualified no-findings claim is suppressed while one is still open.
|
|
152
|
+
|
|
125
153
|
### Review dispositions
|
|
126
154
|
|
|
127
155
|
When a Story lands, the post-land tail (before the temp purge reaps the
|
|
@@ -130,9 +158,11 @@ local, never-committed `<tempRoot>/review-dispositions.ndjson` (rotated at
|
|
|
130
158
|
1 MB, one `.1` generation kept). Precedence, with the last run as the final
|
|
131
159
|
review: `overridden` (an operator overrode it; the record carries the
|
|
132
160
|
redacted reason, clipped to 500 characters), `downgraded-ungrounded` and
|
|
133
|
-
`refuted-by-verifier` (flagged in the final run),
|
|
134
|
-
|
|
135
|
-
|
|
161
|
+
`refuted-by-verifier` (flagged in the final run), then an earlier
|
|
162
|
+
CRITICAL's last re-check resolution (`fixed` → `fixed-on-branch`, `refuted` →
|
|
163
|
+
`refuted-by-verifier`), `open-at-merge` (in the final run otherwise,
|
|
164
|
+
including a carried CRITICAL), `fixed-on-branch` (raised earlier, absent from
|
|
165
|
+
the final run). A record holds ids, provider, severity, class and run count only,
|
|
136
166
|
never a title, body, path or excerpt; a Story already recorded appends
|
|
137
167
|
nothing. Summarize with
|
|
138
168
|
`node .agents/scripts/review-dispositions-report.js [--since <YYYY-MM-DD>] [--json]`:
|
|
@@ -168,12 +198,36 @@ The pipeline will:
|
|
|
168
198
|
close-validation gate, so the review does not re-run it).
|
|
169
199
|
- Post a structured summary report to the `[TICKET_ID]` issue.
|
|
170
200
|
|
|
171
|
-
**What the review did not check is posted, not silent.**
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
201
|
+
**What the review did not check is posted, not silent.** Every degradation
|
|
202
|
+
lands in the **Degraded gates** section of the posted `verification-results`
|
|
203
|
+
comment with one of three kinds:
|
|
204
|
+
|
|
205
|
+
- `verdict-missing` — no verdict at all: the diff could not be read, the
|
|
206
|
+
`claude` CLI is not logged in or out of quota, the reviewer failed or its
|
|
207
|
+
output did not parse, every chunk failed, an optional chain entry such as
|
|
208
|
+
`llm-review` was skipped on a host without its CLI, or the base ref is
|
|
209
|
+
unresolvable. Close reports `gates.codeReview: "unreviewed"`.
|
|
210
|
+
- `coverage-partial` — part of the diff went unreviewed: one chunk failed
|
|
211
|
+
beside chunks that returned a verdict, files fell past the chunk bound, or a
|
|
212
|
+
chunk was truncated at the 200,000-character budget. Close reports
|
|
213
|
+
`"partial"`.
|
|
214
|
+
- `context-reduced` — reviewed with less context: a capped `<callers>`
|
|
215
|
+
block or truncated guidance. Close reports `"degraded"`.
|
|
216
|
+
|
|
217
|
+
Before recording a no-verdict, the `code-review` provider re-invokes the
|
|
218
|
+
reviewer **once** when the failure is transient-shaped (a non-zero exit that
|
|
219
|
+
is not a usage limit, an `is_error` result, a non-success subtype,
|
|
220
|
+
unparseable output). It never retries a failed auth preflight, a usage limit
|
|
221
|
+
or a timeout.
|
|
222
|
+
|
|
223
|
+
`delivery.codeReview.onNoVerdict` decides what a gap does. `report` (the
|
|
224
|
+
default) never halts. `block` halts handoff and close on any
|
|
225
|
+
`verdict-missing` or `coverage-partial` record with `haltCause:
|
|
226
|
+
"no-verdict"`: the blocker names the cause, its fix and the
|
|
227
|
+
`story-review-compute.js --story <id>` re-run command, handoff settles
|
|
228
|
+
`blocked` (no code change resolves it) and close refuses to arm auto-merge
|
|
229
|
+
unless re-run with `--override-review-block "<reason>"`. `context-reduced`
|
|
230
|
+
never halts.
|
|
177
231
|
|
|
178
232
|
### Story scope runs no lens pass
|
|
179
233
|
|