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
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-Story outcome record: one `story-outcome` structured comment on
|
|
3
|
+
* the Story issue, upserted on every close and confirm-merge terminal when
|
|
4
|
+
* `delivery.feedbackLoop.outcomeRecord` is on. Best-effort: a failure logs
|
|
5
|
+
* one warning and never touches the envelope, result or exit code.
|
|
6
|
+
*
|
|
7
|
+
* @module lib/observability/story-outcome
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
|
|
13
|
+
import { resolveConfig } from '../config-resolver.js';
|
|
14
|
+
import { Logger } from '../Logger.js';
|
|
15
|
+
import { findStructuredComment } from '../orchestration/ticketing/reads.js';
|
|
16
|
+
import { upsertStructuredComment } from '../orchestration/ticketing/state.js';
|
|
17
|
+
import { PROJECT_ROOT } from '../project-root.js';
|
|
18
|
+
import { createProvider } from '../provider-factory.js';
|
|
19
|
+
import {
|
|
20
|
+
emitCloseTerminalSignals,
|
|
21
|
+
retryCauseForTerminal,
|
|
22
|
+
tallyStoryTelemetry,
|
|
23
|
+
} from './close-telemetry.js';
|
|
24
|
+
import {
|
|
25
|
+
emitTerminalFriction,
|
|
26
|
+
RUNTIME_FRICTION_CATEGORIES,
|
|
27
|
+
} from './runtime-friction.js';
|
|
28
|
+
import { forEachLine } from './signals-writer.js';
|
|
29
|
+
|
|
30
|
+
export const OUTCOME_COMMENT_TYPE = 'story-outcome';
|
|
31
|
+
const OUTCOME_SCHEMA_VERSION = 1;
|
|
32
|
+
const MAX_ATTEMPTS = 100;
|
|
33
|
+
/** Headroom under GitHub's 65536-char comment limit for the marker prefix. */
|
|
34
|
+
const MAX_BODY_CHARS = 60000;
|
|
35
|
+
const MAX_FIELD_CHARS = 200;
|
|
36
|
+
const STATUSES = Object.freeze(['landed', 'pending', 'blocked', 'failed']);
|
|
37
|
+
/** Results that found the Story already closed or done: nothing happened. */
|
|
38
|
+
const NOOP_REASONS = new Set([
|
|
39
|
+
'already-closed',
|
|
40
|
+
'closed-not-planned',
|
|
41
|
+
'already-done',
|
|
42
|
+
]);
|
|
43
|
+
const JSON_BLOCK = /```json\n([\s\S]*?)\n```/;
|
|
44
|
+
|
|
45
|
+
/** @param {object|null|undefined} config */
|
|
46
|
+
function outcomeRecordEnabled(config) {
|
|
47
|
+
return config?.delivery?.feedbackLoop?.outcomeRecord === true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function readJsonOrNull(file) {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
53
|
+
} catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {string} [root]
|
|
60
|
+
* @returns {string|null}
|
|
61
|
+
*/
|
|
62
|
+
function resolveMandrelVersion(root = PROJECT_ROOT) {
|
|
63
|
+
const own = readJsonOrNull(path.join(root, 'package.json'));
|
|
64
|
+
const pkg =
|
|
65
|
+
own?.name === 'mandrel'
|
|
66
|
+
? own
|
|
67
|
+
: readJsonOrNull(
|
|
68
|
+
path.join(root, 'node_modules', 'mandrel', 'package.json'),
|
|
69
|
+
);
|
|
70
|
+
return typeof pkg?.version === 'string' ? pkg.version : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @param {Record<string, string>|null|undefined} gates */
|
|
74
|
+
function failedGateNames(gates) {
|
|
75
|
+
return Object.entries(gates ?? {})
|
|
76
|
+
.filter(([, outcome]) => outcome === 'failed')
|
|
77
|
+
.map(([name]) => name)
|
|
78
|
+
.sort();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function intOrNull(value) {
|
|
82
|
+
return Number.isInteger(value) ? value : null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function nonNegInt(value) {
|
|
86
|
+
return Number.isInteger(value) && value >= 0 ? value : 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Friction from this invocation only, so a re-close never re-counts. */
|
|
90
|
+
function windowedReviewCounts(rows, sinceMs) {
|
|
91
|
+
const counts = { reviewHalts: 0, reviewOverrides: 0 };
|
|
92
|
+
for (const row of rows) {
|
|
93
|
+
if (row?.kind !== 'friction' || row.details?.recovered === true) continue;
|
|
94
|
+
if (!(Date.parse(row.ts) >= sinceMs)) continue;
|
|
95
|
+
if (row.category === RUNTIME_FRICTION_CATEGORIES.REVIEW_BLOCKED) {
|
|
96
|
+
counts.reviewHalts += 1;
|
|
97
|
+
} else if (
|
|
98
|
+
row.category === RUNTIME_FRICTION_CATEGORIES.REVIEW_BLOCK_OVERRIDDEN
|
|
99
|
+
) {
|
|
100
|
+
counts.reviewOverrides += 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return counts;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function clip(value) {
|
|
107
|
+
return typeof value === 'string'
|
|
108
|
+
? value.slice(0, MAX_FIELD_CHARS)
|
|
109
|
+
: (value ?? null);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {{ envelope: object, tool: string, worker?: object, rows?: object[],
|
|
114
|
+
* nowMs?: number, mandrelVersion?: string|null }} args
|
|
115
|
+
* @returns {object}
|
|
116
|
+
*/
|
|
117
|
+
function buildAttempt({
|
|
118
|
+
envelope,
|
|
119
|
+
tool,
|
|
120
|
+
worker = {},
|
|
121
|
+
rows = [],
|
|
122
|
+
nowMs = Date.now(),
|
|
123
|
+
mandrelVersion = null,
|
|
124
|
+
}) {
|
|
125
|
+
const elapsedMs = nonNegInt(envelope.elapsedSeconds) * 1000;
|
|
126
|
+
return {
|
|
127
|
+
ts: new Date(nowMs).toISOString(),
|
|
128
|
+
tool,
|
|
129
|
+
status: envelope.status,
|
|
130
|
+
phase: envelope.phase ?? null,
|
|
131
|
+
cause: retryCauseForTerminal(envelope),
|
|
132
|
+
blockClass: envelope.blocked?.blockClass ?? null,
|
|
133
|
+
failedGates: failedGateNames(envelope.gates),
|
|
134
|
+
prNumber: intOrNull(envelope.pr?.number),
|
|
135
|
+
mandrelVersion,
|
|
136
|
+
workerModel: clip(worker.workerModel),
|
|
137
|
+
workerEffort: clip(worker.workerEffort),
|
|
138
|
+
workerTokens: intOrNull(worker.workerTokens),
|
|
139
|
+
...windowedReviewCounts(rows, nowMs - elapsedMs),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function countMap(raw) {
|
|
144
|
+
const out = {};
|
|
145
|
+
for (const [key, count] of Object.entries(raw ?? {})) {
|
|
146
|
+
if (Number.isInteger(count) && count > 0) out[key] = count;
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Coerces a prior (possibly foreign or hand-edited) summary to the contract. */
|
|
152
|
+
function normalizeSummary(raw = {}) {
|
|
153
|
+
const byStatus = {};
|
|
154
|
+
for (const status of STATUSES)
|
|
155
|
+
byStatus[status] = nonNegInt(raw.byStatus?.[status]);
|
|
156
|
+
return {
|
|
157
|
+
attempts: nonNegInt(raw.attempts),
|
|
158
|
+
byStatus,
|
|
159
|
+
failedGates: countMap(raw.failedGates),
|
|
160
|
+
acceptanceRounds: nonNegInt(raw.acceptanceRounds),
|
|
161
|
+
mandrelVersions: Array.isArray(raw.mandrelVersions)
|
|
162
|
+
? raw.mandrelVersions.filter((v) => typeof v === 'string')
|
|
163
|
+
: [],
|
|
164
|
+
landedAt: typeof raw.landedAt === 'string' ? raw.landedAt : null,
|
|
165
|
+
landedOnAttempt: intOrNull(raw.landedOnAttempt),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Counters carry forward from `prior`, so trimming old attempts (count or
|
|
171
|
+
* body-size cap) never lowers a count; `acceptanceRounds` is max-shaped.
|
|
172
|
+
*
|
|
173
|
+
* @param {object|null} prior
|
|
174
|
+
* @param {object} attempt
|
|
175
|
+
* @param {{ storyId: number, acceptanceRounds?: number }} ctx
|
|
176
|
+
* @returns {object}
|
|
177
|
+
*/
|
|
178
|
+
function mergeOutcomeRecord(prior, attempt, { storyId, acceptanceRounds = 0 }) {
|
|
179
|
+
const base = normalizeSummary(prior?.summary);
|
|
180
|
+
const attempts = base.attempts + 1;
|
|
181
|
+
const landedNow = attempt.status === 'landed' && base.landedAt === null;
|
|
182
|
+
const failedGates = { ...base.failedGates };
|
|
183
|
+
for (const gate of attempt.failedGates)
|
|
184
|
+
failedGates[gate] = (failedGates[gate] ?? 0) + 1;
|
|
185
|
+
const summary = {
|
|
186
|
+
attempts,
|
|
187
|
+
byStatus: {
|
|
188
|
+
...base.byStatus,
|
|
189
|
+
[attempt.status]: base.byStatus[attempt.status] + 1,
|
|
190
|
+
},
|
|
191
|
+
failedGates,
|
|
192
|
+
acceptanceRounds: Math.max(
|
|
193
|
+
base.acceptanceRounds,
|
|
194
|
+
nonNegInt(acceptanceRounds),
|
|
195
|
+
),
|
|
196
|
+
mandrelVersions: [
|
|
197
|
+
...new Set(
|
|
198
|
+
[...base.mandrelVersions, attempt.mandrelVersion].filter(Boolean),
|
|
199
|
+
),
|
|
200
|
+
],
|
|
201
|
+
landedAt: landedNow ? attempt.ts : base.landedAt,
|
|
202
|
+
landedOnAttempt: landedNow ? attempts : base.landedOnAttempt,
|
|
203
|
+
};
|
|
204
|
+
summary.firstPass =
|
|
205
|
+
summary.landedAt !== null &&
|
|
206
|
+
summary.byStatus.blocked === 0 &&
|
|
207
|
+
summary.byStatus.failed === 0;
|
|
208
|
+
const priorAttempts = Array.isArray(prior?.attempts) ? prior.attempts : [];
|
|
209
|
+
return {
|
|
210
|
+
schemaVersion: OUTCOME_SCHEMA_VERSION,
|
|
211
|
+
storyId,
|
|
212
|
+
attempts: [...priorAttempts, attempt].slice(-MAX_ATTEMPTS),
|
|
213
|
+
summary,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** @param {object} record */
|
|
218
|
+
function renderOutcomeBody(record) {
|
|
219
|
+
const { summary } = record;
|
|
220
|
+
const last = record.attempts.at(-1);
|
|
221
|
+
const gates = last?.failedGates?.length
|
|
222
|
+
? last.failedGates.join(', ')
|
|
223
|
+
: 'none';
|
|
224
|
+
return [
|
|
225
|
+
`**Story outcome** · attempts: ${summary.attempts} · status: ${last?.status ?? 'unknown'} · last failed gates: ${gates}`,
|
|
226
|
+
'',
|
|
227
|
+
'```json',
|
|
228
|
+
JSON.stringify(record),
|
|
229
|
+
'```',
|
|
230
|
+
].join('\n');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Drops the oldest attempts until the body fits; `summary` is untouched. */
|
|
234
|
+
function renderBoundedBody(record) {
|
|
235
|
+
let body = renderOutcomeBody(record);
|
|
236
|
+
while (body.length > MAX_BODY_CHARS && record.attempts.length > 1) {
|
|
237
|
+
const drop = Math.max(1, Math.floor(record.attempts.length / 10));
|
|
238
|
+
record.attempts = record.attempts.slice(drop);
|
|
239
|
+
body = renderOutcomeBody(record);
|
|
240
|
+
}
|
|
241
|
+
return body;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @param {string} body
|
|
246
|
+
* @returns {object|null} the record, or null when the JSON block is unusable.
|
|
247
|
+
*/
|
|
248
|
+
export function parseOutcomeBody(body) {
|
|
249
|
+
const match = JSON_BLOCK.exec(String(body ?? ''));
|
|
250
|
+
if (!match) return null;
|
|
251
|
+
try {
|
|
252
|
+
const record = JSON.parse(match[1]);
|
|
253
|
+
const usable =
|
|
254
|
+
record?.schemaVersion === OUTCOME_SCHEMA_VERSION &&
|
|
255
|
+
Array.isArray(record.attempts) &&
|
|
256
|
+
record.summary !== null &&
|
|
257
|
+
typeof record.summary === 'object';
|
|
258
|
+
return usable ? record : null;
|
|
259
|
+
} catch {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function shouldRecord(envelope, result) {
|
|
265
|
+
const storyId = envelope?.storyId;
|
|
266
|
+
return (
|
|
267
|
+
Number.isInteger(storyId) &&
|
|
268
|
+
storyId > 0 &&
|
|
269
|
+
STATUSES.includes(envelope.status) &&
|
|
270
|
+
!NOOP_REASONS.has(result?.reason)
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function readLocalRows(storyId, config, readFn) {
|
|
275
|
+
const rows = [];
|
|
276
|
+
try {
|
|
277
|
+
await readFn(null, storyId, (parsed) => rows.push(parsed), config);
|
|
278
|
+
} catch {
|
|
279
|
+
// A missing local stream is the cross-machine case, not an error.
|
|
280
|
+
}
|
|
281
|
+
return rows;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async function writeRecord({
|
|
285
|
+
envelope,
|
|
286
|
+
config,
|
|
287
|
+
provider,
|
|
288
|
+
tool,
|
|
289
|
+
worker,
|
|
290
|
+
readFn,
|
|
291
|
+
mandrelVersion,
|
|
292
|
+
}) {
|
|
293
|
+
const storyId = envelope.storyId;
|
|
294
|
+
const prior = await findStructuredComment(
|
|
295
|
+
provider,
|
|
296
|
+
storyId,
|
|
297
|
+
OUTCOME_COMMENT_TYPE,
|
|
298
|
+
);
|
|
299
|
+
const priorRecord = prior ? parseOutcomeBody(prior.body) : null;
|
|
300
|
+
if (prior && !priorRecord) {
|
|
301
|
+
Logger.warn(
|
|
302
|
+
`[story-outcome] Story #${storyId}: prior outcome record did not parse; replaced with a fresh record.`,
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
if (envelope.status === 'landed' && priorRecord?.summary?.landedAt)
|
|
306
|
+
return false;
|
|
307
|
+
const rows = await readLocalRows(storyId, config, readFn);
|
|
308
|
+
const attempt = buildAttempt({
|
|
309
|
+
envelope,
|
|
310
|
+
tool,
|
|
311
|
+
worker,
|
|
312
|
+
rows,
|
|
313
|
+
mandrelVersion,
|
|
314
|
+
});
|
|
315
|
+
const record = mergeOutcomeRecord(priorRecord, attempt, {
|
|
316
|
+
storyId,
|
|
317
|
+
acceptanceRounds: tallyStoryTelemetry(rows).acceptanceRounds,
|
|
318
|
+
});
|
|
319
|
+
await upsertStructuredComment(
|
|
320
|
+
provider,
|
|
321
|
+
storyId,
|
|
322
|
+
OUTCOME_COMMENT_TYPE,
|
|
323
|
+
renderBoundedBody(record),
|
|
324
|
+
);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Call after the envelope is emitted. Never throws.
|
|
330
|
+
*
|
|
331
|
+
* @param {{ envelope: object, result?: object|null, config?: object,
|
|
332
|
+
* cwd?: string, tool: string, worker?: object, provider?: object,
|
|
333
|
+
* providerFactory?: typeof createProvider,
|
|
334
|
+
* resolveConfigImpl?: typeof resolveConfig, readFn?: typeof forEachLine,
|
|
335
|
+
* mandrelVersion?: string|null }} args
|
|
336
|
+
* @returns {Promise<boolean>} true when a record was written.
|
|
337
|
+
*/
|
|
338
|
+
export async function recordStoryOutcome({
|
|
339
|
+
envelope,
|
|
340
|
+
result = null,
|
|
341
|
+
config,
|
|
342
|
+
cwd,
|
|
343
|
+
tool,
|
|
344
|
+
worker,
|
|
345
|
+
provider,
|
|
346
|
+
providerFactory = createProvider,
|
|
347
|
+
resolveConfigImpl = resolveConfig,
|
|
348
|
+
readFn = forEachLine,
|
|
349
|
+
mandrelVersion,
|
|
350
|
+
}) {
|
|
351
|
+
try {
|
|
352
|
+
if (!shouldRecord(envelope, result)) return false;
|
|
353
|
+
const root = cwd || undefined;
|
|
354
|
+
const resolved = config ?? resolveConfigImpl({ cwd: root });
|
|
355
|
+
if (!outcomeRecordEnabled(resolved)) return false;
|
|
356
|
+
return await writeRecord({
|
|
357
|
+
envelope,
|
|
358
|
+
config: resolved,
|
|
359
|
+
provider: provider ?? providerFactory(resolved),
|
|
360
|
+
tool,
|
|
361
|
+
worker,
|
|
362
|
+
readFn,
|
|
363
|
+
mandrelVersion:
|
|
364
|
+
mandrelVersion === undefined
|
|
365
|
+
? resolveMandrelVersion(root)
|
|
366
|
+
: mandrelVersion,
|
|
367
|
+
});
|
|
368
|
+
} catch (err) {
|
|
369
|
+
Logger.warn(
|
|
370
|
+
`[story-outcome] Story #${envelope?.storyId}: outcome record not written: ${err?.message ?? err}`,
|
|
371
|
+
);
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const CLOSE_TOOL = 'single-story-close';
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* The tail of the close terminal writer, after the envelope is out.
|
|
380
|
+
*
|
|
381
|
+
* @param {{ terminal: object, result?: object|null, config?: object,
|
|
382
|
+
* worker?: object, provider?: object }} args
|
|
383
|
+
*/
|
|
384
|
+
export async function finishCloseTerminal({ terminal, ...rest }) {
|
|
385
|
+
await emitTerminalFriction({ envelope: terminal, config: rest.config });
|
|
386
|
+
await recordStoryOutcome({ envelope: terminal, tool: CLOSE_TOOL, ...rest });
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/** The close CLI crash catch: no config in scope, so it is resolved here. */
|
|
390
|
+
export async function emitCloseCrashSignals(envelope) {
|
|
391
|
+
await emitCloseTerminalSignals({ envelope });
|
|
392
|
+
await recordStoryOutcome({ envelope, tool: CLOSE_TOOL });
|
|
393
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module lib/orchestration/check-baselines/phases/compare
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { decodeEnvelope } from '../../../baselines/codec.js';
|
|
8
9
|
import { EXIT_CONFIG } from '../../../baselines/exit-codes.js';
|
|
9
10
|
import { readBaseFromGit } from '../../../baselines/git-base.js';
|
|
10
11
|
import { getKindModule } from '../../../baselines/kernel.js';
|
|
@@ -63,7 +64,7 @@ function readBaseBaselinePayload(scope, kind, gateBlock, cwd) {
|
|
|
63
64
|
}
|
|
64
65
|
if (raw === null) return null;
|
|
65
66
|
try {
|
|
66
|
-
return JSON.parse(raw);
|
|
67
|
+
return decodeEnvelope(JSON.parse(raw));
|
|
67
68
|
} catch (cause) {
|
|
68
69
|
// An unparseable (e.g. text-merged) base blob is a failed read too.
|
|
69
70
|
throw buildBaseReadError({ kind, ref: scope.ref, file: rel, cause });
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { groupRows, resolveComponents } from '../../../baselines/components.js';
|
|
9
9
|
import {
|
|
10
|
+
checkBaselineAhead,
|
|
10
11
|
checkBaselineSemantics,
|
|
11
12
|
checkKernelVersion,
|
|
12
13
|
getKindModule,
|
|
@@ -67,7 +68,23 @@ function withComponentRollups(mod, rows, components) {
|
|
|
67
68
|
return out;
|
|
68
69
|
}
|
|
69
70
|
|
|
71
|
+
/** The kind's ahead-stamp skip, read off the raw baseline file. */
|
|
72
|
+
function aheadSkipOf(kind, cwd, configPath) {
|
|
73
|
+
const ahead = checkBaselineAhead(
|
|
74
|
+
kind,
|
|
75
|
+
reader.peek(kind, { cwd, configPath }),
|
|
76
|
+
);
|
|
77
|
+
return ahead ? { reason: 'ahead', ...ahead } : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
70
80
|
function loadHeadBaseline(kind, cwd, configPath) {
|
|
81
|
+
// Before the schema-validated load: a newer layout must not read as a
|
|
82
|
+
// schema error.
|
|
83
|
+
const skipped = aheadSkipOf(kind, cwd, configPath);
|
|
84
|
+
return skipped ? { skipped } : loadValidated(kind, cwd, configPath);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function loadValidated(kind, cwd, configPath) {
|
|
71
88
|
try {
|
|
72
89
|
return { baseline: reader.load(kind, { cwd, configPath }) };
|
|
73
90
|
} catch (err) {
|
|
@@ -122,7 +139,8 @@ export async function evaluateKind({
|
|
|
122
139
|
env = process.env,
|
|
123
140
|
}) {
|
|
124
141
|
const headLoad = loadHeadBaseline(kind, cwd, configPath);
|
|
125
|
-
|
|
142
|
+
// A schema error or a skip.
|
|
143
|
+
if (!headLoad.baseline) return { kind, ...headLoad };
|
|
126
144
|
const baseline = headLoad.baseline;
|
|
127
145
|
// Rows from superseded scoring semantics pass schema but are incomparable;
|
|
128
146
|
// fail closed.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lines a FAIL kind prints under its status: the diff-scoped remedy and
|
|
3
|
+
* the surviving regression rows. Never a full-scope or reanchor command.
|
|
4
|
+
*
|
|
5
|
+
* @module lib/orchestration/check-baselines/phases/fail-detail
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const MAX_REGRESSION_LINES = 20;
|
|
9
|
+
const SCRIPTS = 'node .agents/scripts';
|
|
10
|
+
const CAPTURE = `${SCRIPTS}/coverage-capture.js`;
|
|
11
|
+
|
|
12
|
+
/** Diff-scoped updaters; coverage and crap re-score a fresh capture first. */
|
|
13
|
+
const UPDATERS = Object.freeze({
|
|
14
|
+
coverage: { script: 'update-coverage-baseline.js', capture: true },
|
|
15
|
+
crap: { script: 'update-crap-baseline.js', capture: true },
|
|
16
|
+
duplication: { script: 'update-duplication-baseline.js' },
|
|
17
|
+
maintainability: { script: 'update-maintainability-baseline.js' },
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/** The command that re-scores a kind's rows, or `null` for an unknown kind. */
|
|
21
|
+
function remedyCommand(g) {
|
|
22
|
+
if (g.kind === 'mutation') {
|
|
23
|
+
return "re-running the project's own mutation run (Mandrel ships no updater)";
|
|
24
|
+
}
|
|
25
|
+
if (g.kind === 'bundle-size') {
|
|
26
|
+
return `\`${SCRIPTS}/update-bundle-size-baseline.js\``;
|
|
27
|
+
}
|
|
28
|
+
const updater = UPDATERS[g.kind];
|
|
29
|
+
if (!updater) return null;
|
|
30
|
+
const scope = g.baseRef ? ` --diff-scope ${g.baseRef}` : '';
|
|
31
|
+
const cmd = `\`${SCRIPTS}/${updater.script}${scope}\``;
|
|
32
|
+
return updater.capture ? `\`${CAPTURE}\` then ${cmd}` : cmd;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function formatRemedyLine(g) {
|
|
36
|
+
const cmd = remedyCommand(g);
|
|
37
|
+
if (!cmd) return [];
|
|
38
|
+
return [
|
|
39
|
+
` ↳ remedy: fix the named rows, re-score with ${cmd}, commit; a deliberate rise commits as \`baseline-refresh:\``,
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fmt = (n) => String(Number(n.toFixed(2)));
|
|
44
|
+
|
|
45
|
+
/** `<field> <base> → <head>` per numeric field that moved; `(new)` without a base. */
|
|
46
|
+
function formatRegressionLine({ key, head, base }) {
|
|
47
|
+
const numeric = Object.entries(head ?? {}).filter(
|
|
48
|
+
([, v]) => typeof v === 'number',
|
|
49
|
+
);
|
|
50
|
+
if (!base) {
|
|
51
|
+
const fields = numeric.map(([f, v]) => `${f} ${fmt(v)}`).join(', ');
|
|
52
|
+
return ` · ${key}: (new) → ${fields}`;
|
|
53
|
+
}
|
|
54
|
+
const moved = numeric
|
|
55
|
+
.filter(([f, v]) => typeof base[f] === 'number' && base[f] !== v)
|
|
56
|
+
.map(([f, v]) => `${f} ${fmt(base[f])} → ${fmt(v)}`);
|
|
57
|
+
return ` · ${key}: ${moved.join(', ')}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function formatRegressionLines(g) {
|
|
61
|
+
if (!Array.isArray(g.regressions)) return [];
|
|
62
|
+
const lines = g.regressions
|
|
63
|
+
.slice(0, MAX_REGRESSION_LINES)
|
|
64
|
+
.map(formatRegressionLine);
|
|
65
|
+
const more = g.regressions.length - MAX_REGRESSION_LINES;
|
|
66
|
+
if (more > 0) {
|
|
67
|
+
lines.push(
|
|
68
|
+
` · … and ${more} more — ${SCRIPTS}/check-baselines.js --gate ${g.kind} --format json`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return lines;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A FAIL kind's lines: remedy first (a capped quote keeps it), then the
|
|
76
|
+
* floor violations, then the surviving regression rows.
|
|
77
|
+
*
|
|
78
|
+
* @param {object} g - one gate report.
|
|
79
|
+
* @param {string[]} violations - its formatted floor-violation lines.
|
|
80
|
+
* @returns {string[]}
|
|
81
|
+
*/
|
|
82
|
+
export function formatFailDetail(g, violations) {
|
|
83
|
+
return [...formatRemedyLine(g), ...violations, ...formatRegressionLines(g)];
|
|
84
|
+
}
|
|
@@ -40,6 +40,7 @@ function emptyReport(cwd) {
|
|
|
40
40
|
totalRegressions: 0,
|
|
41
41
|
kernelDriftCount: 0,
|
|
42
42
|
schemaErrors: [],
|
|
43
|
+
skipped: [],
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -96,14 +97,22 @@ async function accumulateGateResult(result, ctx) {
|
|
|
96
97
|
ctx.frictionEvents.push(...events);
|
|
97
98
|
}
|
|
98
99
|
|
|
100
|
+
/** A skip is visible in the report and never fails the run. */
|
|
101
|
+
function accumulateSkipped(result, ctx) {
|
|
102
|
+
ctx.report.skipped.push({ kind: result.kind, ...result.skipped });
|
|
103
|
+
ctx.perKindExitCodes.push(EXIT_PASS);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function accumulatorFor(result) {
|
|
107
|
+
if (result.skipped) return accumulateSkipped;
|
|
108
|
+
if (result.schemaError) return accumulateSchemaError;
|
|
109
|
+
return accumulateGateResult;
|
|
110
|
+
}
|
|
111
|
+
|
|
99
112
|
async function consumePerKindResults(perKindResults, args, report) {
|
|
100
113
|
const ctx = { args, report, perKindExitCodes: [], frictionEvents: [] };
|
|
101
114
|
for (const result of perKindResults) {
|
|
102
|
-
|
|
103
|
-
await accumulateSchemaError(result, ctx);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
await accumulateGateResult(result, ctx);
|
|
115
|
+
await accumulatorFor(result)(result, ctx);
|
|
107
116
|
}
|
|
108
117
|
return {
|
|
109
118
|
exitCode: aggregateExitCodes(...ctx.perKindExitCodes),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @module lib/orchestration/check-baselines/phases/refresh-ack
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { decodeEnvelope } from '../../../baselines/codec.js';
|
|
8
9
|
import { resolveKindRefreshOverrides } from '../../../baselines/env-overrides.js';
|
|
9
10
|
import {
|
|
10
11
|
readBaseFromGit,
|
|
@@ -82,7 +83,7 @@ function readRowsAtRef(ref, baselinePath, cwd) {
|
|
|
82
83
|
}
|
|
83
84
|
if (raw === null) return { rows: [] };
|
|
84
85
|
try {
|
|
85
|
-
const payload = JSON.parse(raw);
|
|
86
|
+
const payload = decodeEnvelope(JSON.parse(raw));
|
|
86
87
|
return Array.isArray(payload?.rows) ? { rows: payload.rows } : null;
|
|
87
88
|
} catch {
|
|
88
89
|
return null;
|
|
@@ -114,7 +115,7 @@ function keysTouchedByCommit({ mod, rowsAtSha, rowsAtParent }) {
|
|
|
114
115
|
/**
|
|
115
116
|
* Classify head rows against a refresh commit's rows with the kind's own
|
|
116
117
|
* `compare()` and tolerance. Keys always come out of `compare()`: `keyField`
|
|
117
|
-
* is not the compare key (CRAP keys `path::method
|
|
118
|
+
* is not the compare key (CRAP keys `path::method`). `ok` =
|
|
118
119
|
* no worse since refresh; `drifted` = worse; additions are in neither.
|
|
119
120
|
*
|
|
120
121
|
* @returns {{ ok: string[], drifted: string[] } | null} null when the
|
|
@@ -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
|
}
|