mandrel 2.87.0 → 2.89.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/README.md +29 -0
- package/.agents/agents/auditor.md +4 -3
- package/.agents/docs/agentrc-reference.json +5 -2
- package/.agents/docs/configuration.md +14 -8
- package/.agents/docs/workflows.md +1 -1
- package/.agents/schemas/agentrc.schema.json +24 -5
- package/.agents/schemas/story-deliver-terminal.schema.json +1 -1
- package/.agents/schemas/story-progress.schema.json +5 -0
- package/.agents/scripts/audit-to-stories.js +3 -2
- package/.agents/scripts/boot-sweep.js +3 -2
- package/.agents/scripts/check-arch-cycles.js +19 -41
- package/.agents/scripts/check-context-budget.js +16 -44
- package/.agents/scripts/check-cyclomatic.js +13 -37
- package/.agents/scripts/check-dead-exports.js +16 -46
- package/.agents/scripts/clean-worktrees.js +1 -6
- package/.agents/scripts/coverage-capture.js +32 -49
- package/.agents/scripts/deliver-run.js +11 -0
- package/.agents/scripts/diagnose-friction.js +3 -3
- package/.agents/scripts/lib/audit-baselines/gate-surface.js +24 -11
- package/.agents/scripts/lib/audit-baselines/read.js +4 -2
- package/.agents/scripts/lib/audit-baselines/surface-entry.js +95 -11
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +6 -14
- package/.agents/scripts/lib/baselines/crap-preview-scan.js +3 -1
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +38 -26
- package/.agents/scripts/lib/baselines/duplication-scanner.js +20 -1
- package/.agents/scripts/lib/baselines/env-overrides.js +39 -34
- package/.agents/scripts/lib/baselines/kernel.js +3 -2
- package/.agents/scripts/lib/baselines/kinds/crap.js +50 -53
- package/.agents/scripts/lib/baselines/preview-gates.js +5 -1
- package/.agents/scripts/lib/baselines/refresh-service.js +65 -22
- package/.agents/scripts/lib/baselines/writer.js +5 -1
- package/.agents/scripts/lib/bdd-runner-detect.js +7 -10
- package/.agents/scripts/lib/child-exec.js +14 -1
- package/.agents/scripts/lib/child-stream.js +122 -0
- package/.agents/scripts/lib/clean-temp.js +19 -13
- package/.agents/scripts/lib/cli-args.js +49 -0
- package/.agents/scripts/lib/close-validation/gates.js +40 -9
- package/.agents/scripts/lib/codex/skills-projection.js +1 -12
- package/.agents/scripts/lib/config/gates/crap.schema.js +15 -0
- package/.agents/scripts/lib/config/gates/mutation.schema.js +2 -2
- package/.agents/scripts/lib/config/gh-config-dir.js +63 -0
- package/.agents/scripts/lib/config/github.js +2 -0
- package/.agents/scripts/lib/config/paths.js +14 -3
- package/.agents/scripts/lib/config/quality.js +49 -1
- package/.agents/scripts/lib/config-resolver.js +78 -64
- package/.agents/scripts/lib/config-settings-schema-delivery.js +4 -3
- package/.agents/scripts/lib/config-settings-schema.js +7 -0
- package/.agents/scripts/lib/coverage-baseline.js +2 -2
- package/.agents/scripts/lib/coverage-capture-affected.js +2 -1
- package/.agents/scripts/lib/coverage-capture-fullscope.js +2 -2
- package/.agents/scripts/lib/coverage-capture-incremental.js +1 -1
- package/.agents/scripts/lib/coverage-capture-passes.js +143 -0
- package/.agents/scripts/lib/coverage-capture-usage.js +1 -1
- package/.agents/scripts/lib/coverage-capture.js +45 -15
- package/.agents/scripts/lib/crap-utils.js +65 -49
- package/.agents/scripts/lib/full-suite-lock.js +1 -10
- package/.agents/scripts/lib/gates/baseline-store.js +10 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +1 -1
- package/.agents/scripts/lib/gh-exec.js +45 -2
- package/.agents/scripts/lib/gh-transport.js +27 -0
- package/.agents/scripts/lib/git-utils.js +16 -9
- package/.agents/scripts/lib/maintainability-engine.js +27 -6
- package/.agents/scripts/lib/maintainability-utils.js +20 -2
- package/.agents/scripts/lib/orchestration/check-baselines/phases/evaluate.js +4 -1
- package/.agents/scripts/lib/orchestration/evidence-stream.js +186 -0
- package/.agents/scripts/lib/orchestration/file-assumptions.js +2 -19
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/branches-reap.js +3 -7
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes-ff.js +34 -40
- package/.agents/scripts/lib/orchestration/git-cleanup/phases/git-probes.js +4 -3
- package/.agents/scripts/lib/orchestration/plan-persist/persist-helpers.js +2 -19
- package/.agents/scripts/lib/orchestration/pr-watch.js +1 -5
- package/.agents/scripts/lib/orchestration/project-meta-cache.js +17 -4
- package/.agents/scripts/lib/orchestration/reassert-status-column.js +1 -8
- package/.agents/scripts/lib/orchestration/resolve-stories.js +1 -0
- package/.agents/scripts/lib/orchestration/review-providers/native.js +2 -2
- package/.agents/scripts/lib/orchestration/single-story-close/phase-timer.js +43 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +37 -13
- package/.agents/scripts/lib/orchestration/single-story-close/phases/finish.js +264 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/open-pr.js +68 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/pre-push.js +106 -0
- package/.agents/scripts/lib/orchestration/single-story-close/phases/reconcile-done.js +43 -35
- package/.agents/scripts/lib/orchestration/single-story-close/phases/review-halt.js +52 -0
- package/.agents/scripts/lib/orchestration/single-story-close/result.js +273 -0
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +68 -776
- package/.agents/scripts/lib/orchestration/story-close/context-budget-writeback.js +20 -9
- package/.agents/scripts/lib/orchestration/story-close/duplication-close-rescore.js +2 -2
- package/.agents/scripts/lib/orchestration/story-close/ratchet-shrink-writeback.js +20 -12
- package/.agents/scripts/lib/orchestration/story-handoff.js +50 -21
- package/.agents/scripts/lib/orchestration/story-progress.js +32 -12
- package/.agents/scripts/lib/orchestration/ticket-validator.js +3 -13
- package/.agents/scripts/lib/orchestration/verify-credit.js +4 -1
- package/.agents/scripts/lib/qa/resolve-selection.js +1 -8
- package/.agents/scripts/lib/single-story/confirm-and-land.js +33 -0
- package/.agents/scripts/lib/single-story-sweep/reconcile-closing.js +43 -11
- package/.agents/scripts/lib/single-story-sweep/sweep-lock.js +130 -30
- package/.agents/scripts/lib/skills/parse-skill.js +1 -4
- package/.agents/scripts/lib/story-body/story-body.js +12 -1
- package/.agents/scripts/lib/suite-admission.js +3 -11
- package/.agents/scripts/lib/temp-retention.js +25 -11
- package/.agents/scripts/lib/test-run-credit.js +2 -5
- package/.agents/scripts/lib/transpile.js +193 -31
- package/.agents/scripts/lib/util/paths.js +31 -0
- package/.agents/scripts/lib/util/sleep.js +15 -0
- package/.agents/scripts/lib/validation-evidence.js +29 -3
- package/.agents/scripts/lib/wave-runner/live-probe.js +24 -0
- package/.agents/scripts/lib/workers/crap-worker.js +23 -12
- package/.agents/scripts/lib/workers/maintainability-report-worker.js +18 -12
- package/.agents/scripts/lib/workflow-closure.js +1 -8
- package/.agents/scripts/notify.js +83 -90
- package/.agents/scripts/plan-context.js +8 -4
- package/.agents/scripts/providers/github/auth.js +14 -30
- package/.agents/scripts/providers/github/blocked-by-add.js +11 -27
- package/.agents/scripts/providers/github/compose.js +1 -0
- package/.agents/scripts/providers/github/gh-token-diagnostics.js +130 -0
- package/.agents/scripts/providers/github/identity.js +158 -0
- package/.agents/scripts/providers/github/issues.js +2 -2
- package/.agents/scripts/providers/github/mappers.js +16 -19
- package/.agents/scripts/providers/github/projects-v2-graphql.js +4 -36
- package/.agents/scripts/providers/github/request-helpers.js +44 -0
- package/.agents/scripts/providers/github/sub-issue-add.js +11 -28
- package/.agents/scripts/providers/github.js +10 -2
- package/.agents/scripts/quality-preview.js +6 -19
- package/.agents/scripts/single-story-confirm-merge.js +8 -20
- package/.agents/scripts/single-story-init.js +0 -1
- package/.agents/scripts/stories-wave-tick.js +60 -46
- package/.agents/scripts/story-handoff.js +2 -23
- package/.agents/scripts/story-review-compute.js +3 -22
- package/.agents/scripts/sync-claude-agents.js +1 -12
- package/.agents/scripts/sync-claude-commands.js +1 -12
- package/.agents/scripts/update-crap-baseline.js +11 -20
- package/.agents/scripts/update-ticket-state.js +44 -45
- package/.agents/templates/docs/audit-sweep-runbook.md +1 -1
- package/.agents/workflows/audit-accessibility.md +1 -1
- package/.agents/workflows/audit-adrs.md +1 -1
- package/.agents/workflows/audit-architecture.md +1 -1
- package/.agents/workflows/audit-baselines.md +9 -4
- package/.agents/workflows/audit-clean-code.md +1 -1
- package/.agents/workflows/audit-data-model.md +1 -1
- package/.agents/workflows/audit-dependencies.md +1 -1
- package/.agents/workflows/audit-devops.md +1 -1
- package/.agents/workflows/audit-documentation.md +1 -1
- package/.agents/workflows/audit-exceptions.md +2 -2
- package/.agents/workflows/audit-mobile.md +1 -1
- package/.agents/workflows/audit-navigability.md +1 -1
- package/.agents/workflows/audit-performance.md +1 -1
- package/.agents/workflows/audit-privacy.md +1 -1
- package/.agents/workflows/audit-quality.md +1 -1
- package/.agents/workflows/audit-security.md +1 -1
- package/.agents/workflows/audit-seo.md +1 -1
- package/.agents/workflows/audit-sre.md +1 -1
- package/.agents/workflows/audit-to-stories.md +9 -7
- package/.agents/workflows/audit-ux-ui.md +1 -1
- package/.agents/workflows/helpers/audit-lens-core.md +8 -5
- package/.agents/workflows/helpers/deliver-digest.md +4 -5
- package/.agents/workflows/helpers/deliver-story-reference.md +4 -4
- package/.agents/workflows/mandrel-deliver.md +3 -1
- package/README.md +6 -3
- package/docs/CHANGELOG.md +42 -0
- package/lib/cli/doctor-checks/codex.js +240 -0
- package/lib/cli/doctor-checks/merge-driver.js +79 -0
- package/lib/cli/doctor-checks/payload.js +201 -0
- package/lib/cli/doctor-checks/read-json.js +16 -0
- package/lib/cli/doctor-checks/runtime-deps.js +146 -0
- package/lib/cli/doctor-checks/spawn.js +18 -0
- package/lib/cli/doctor-checks/sync-parity.js +205 -0
- package/lib/cli/doctor-checks/test-credit-path.js +270 -0
- package/lib/cli/doctor-checks/toolchain.js +137 -0
- package/lib/cli/doctor-checks/version-current.js +82 -0
- package/lib/cli/registry.js +40 -1330
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** `github.cliConfigDir` → `process.env.GH_CONFIG_DIR`, inherited by every `gh` child. */
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { Logger } from '../Logger.js';
|
|
7
|
+
|
|
8
|
+
function resolveGhConfigDir(value, root, { homedir = os.homedir } = {}) {
|
|
9
|
+
if (value === '~') return homedir();
|
|
10
|
+
if (value.startsWith('~/') || value.startsWith('~\\')) {
|
|
11
|
+
return path.join(homedir(), value.slice(2));
|
|
12
|
+
}
|
|
13
|
+
return path.resolve(root, value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isDirectory(fsImpl, dir) {
|
|
17
|
+
try {
|
|
18
|
+
return fsImpl.statSync(dir).isDirectory();
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sets `env.GH_CONFIG_DIR` from `github.cliConfigDir`, idempotently. Absent
|
|
26
|
+
* key = no-op. A missing directory is a config error, never a silent
|
|
27
|
+
* fallback to the default store; a differing inherited value is overridden
|
|
28
|
+
* with one warning naming both paths.
|
|
29
|
+
*
|
|
30
|
+
* @param {{ cliConfigDir?: string|null }|null|undefined} github
|
|
31
|
+
* @param {string} root
|
|
32
|
+
* @param {{ env?: NodeJS.ProcessEnv, fsImpl?: import('node:fs'),
|
|
33
|
+
* warn?: (msg: string) => void, homedir?: () => string }} [deps]
|
|
34
|
+
* @returns {string|null} the applied absolute path, or null when unset.
|
|
35
|
+
*/
|
|
36
|
+
export function applyGhConfigDir(
|
|
37
|
+
github,
|
|
38
|
+
root,
|
|
39
|
+
{
|
|
40
|
+
env = process.env,
|
|
41
|
+
fsImpl = fs,
|
|
42
|
+
warn = (msg) => Logger.warn(msg),
|
|
43
|
+
homedir,
|
|
44
|
+
} = {},
|
|
45
|
+
) {
|
|
46
|
+
const configured = github?.cliConfigDir;
|
|
47
|
+
if (typeof configured !== 'string' || configured.length === 0) return null;
|
|
48
|
+
const dir = resolveGhConfigDir(configured, root, { homedir });
|
|
49
|
+
if (!isDirectory(fsImpl, dir)) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`[config] github.cliConfigDir points at ${dir}, which is not an existing directory. ` +
|
|
52
|
+
'Create it (e.g. `GH_CONFIG_DIR=<dir> gh auth login`) or remove the key to use the default gh store.',
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
const inherited = env.GH_CONFIG_DIR;
|
|
56
|
+
if (inherited && path.resolve(inherited) !== dir) {
|
|
57
|
+
warn(
|
|
58
|
+
`[config] github.cliConfigDir (${dir}) overrides the inherited GH_CONFIG_DIR (${inherited}).`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
env.GH_CONFIG_DIR = dir;
|
|
62
|
+
return dir;
|
|
63
|
+
}
|
|
@@ -59,6 +59,7 @@ export const NOTIFICATIONS_DEFAULTS = Object.freeze({
|
|
|
59
59
|
* projectNumber: number|null,
|
|
60
60
|
* projectOwner: string|null,
|
|
61
61
|
* operatorHandle: string|null,
|
|
62
|
+
* cliConfigDir: string|null,
|
|
62
63
|
* branchProtection: { enforce: boolean, requiredChecks: Array<{name:string,cmd:readonly string[]}> },
|
|
63
64
|
* mergeMethods: typeof MERGE_METHODS_DEFAULTS,
|
|
64
65
|
* notifications: typeof NOTIFICATIONS_DEFAULTS,
|
|
@@ -81,6 +82,7 @@ export function getGitHub(config) {
|
|
|
81
82
|
projectNumber: gh.projectNumber ?? null,
|
|
82
83
|
projectOwner: gh.projectOwner ?? null,
|
|
83
84
|
operatorHandle: gh.operatorHandle ?? null,
|
|
85
|
+
cliConfigDir: gh.cliConfigDir ?? null,
|
|
84
86
|
branchProtection: {
|
|
85
87
|
enforce:
|
|
86
88
|
typeof userBranchProtection.enforce === 'boolean'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `project.paths` accessor; every `*Root` subdirectory
|
|
3
|
-
* is derived from `agentRoot` / `tempRoot`.
|
|
2
|
+
* `project.paths` accessor; every `*Root` subdirectory, `auditOutputDir` and
|
|
3
|
+
* `auditResultsDir` is derived from `agentRoot` / `tempRoot`.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export const PATHS_DEFAULTS = Object.freeze({
|
|
@@ -9,6 +9,16 @@ export const PATHS_DEFAULTS = Object.freeze({
|
|
|
9
9
|
tempRoot: 'temp',
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Audit working area and its reports-only subfolder.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} tempRoot
|
|
16
|
+
*/
|
|
17
|
+
function auditDirs(tempRoot) {
|
|
18
|
+
const auditOutputDir = `${tempRoot}/audits`;
|
|
19
|
+
return { auditOutputDir, auditResultsDir: `${auditOutputDir}/audit-results` };
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
/**
|
|
13
23
|
* @param {object|undefined} userPaths
|
|
14
24
|
* @returns {{
|
|
@@ -16,6 +26,7 @@ export const PATHS_DEFAULTS = Object.freeze({
|
|
|
16
26
|
* docsRoot: string,
|
|
17
27
|
* tempRoot: string,
|
|
18
28
|
* auditOutputDir: string,
|
|
29
|
+
* auditResultsDir: string,
|
|
19
30
|
* scriptsRoot: string,
|
|
20
31
|
* workflowsRoot: string,
|
|
21
32
|
* schemasRoot: string,
|
|
@@ -33,7 +44,7 @@ export function resolvePaths(userPaths) {
|
|
|
33
44
|
agentRoot,
|
|
34
45
|
docsRoot,
|
|
35
46
|
tempRoot,
|
|
36
|
-
|
|
47
|
+
...auditDirs(tempRoot),
|
|
37
48
|
scriptsRoot: `${agentRoot}/scripts`,
|
|
38
49
|
workflowsRoot: `${agentRoot}/workflows`,
|
|
39
50
|
schemasRoot: `${agentRoot}/schemas`,
|
|
@@ -58,6 +58,8 @@ export const CRAP_GATE_DEFAULTS = Object.freeze({
|
|
|
58
58
|
// Healthy runs resolve ~98%; a coordinate mismatch resolves 4–6%.
|
|
59
59
|
minMethodResolutionRate: 0.75,
|
|
60
60
|
incrementalCoverage: DEFAULT_INCREMENTAL_COVERAGE,
|
|
61
|
+
// npm script that writes the CRAP coverage artifact (never a shell command).
|
|
62
|
+
captureScript: 'test:coverage',
|
|
61
63
|
});
|
|
62
64
|
|
|
63
65
|
export const COVERAGE_GATE_DEFAULTS = Object.freeze({
|
|
@@ -96,6 +98,8 @@ const CRAP_GATE_KEYS = new Set([
|
|
|
96
98
|
'ignoreGlobs',
|
|
97
99
|
'minMethodResolutionRate',
|
|
98
100
|
'incrementalCoverage',
|
|
101
|
+
'coveragePath',
|
|
102
|
+
'captureScript',
|
|
99
103
|
]);
|
|
100
104
|
|
|
101
105
|
const COVERAGE_GATE_KEYS = new Set([
|
|
@@ -176,6 +180,48 @@ function resolveIncrementalCoverage(user, defaults) {
|
|
|
176
180
|
};
|
|
177
181
|
}
|
|
178
182
|
|
|
183
|
+
function nonEmptyString(value) {
|
|
184
|
+
return typeof value === 'string' && value.trim().length > 0
|
|
185
|
+
? value.trim()
|
|
186
|
+
: null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Directory part of a repo-relative path, separator-agnostic. */
|
|
190
|
+
function artifactDir(relPath) {
|
|
191
|
+
const parts = relPath.replace(/\\/g, '/').split('/').filter(Boolean);
|
|
192
|
+
parts.pop();
|
|
193
|
+
return parts.filter((p) => p !== '.').join('/');
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The CRAP gate's coverage source. A user `coveragePath` that
|
|
198
|
+
* differs from the coverage gate's is an OWN source; one in the same
|
|
199
|
+
* directory would share the per-directory capture stamp and cross-credit
|
|
200
|
+
* freshness, so it is refused here rather than silently falling back.
|
|
201
|
+
*
|
|
202
|
+
* @param {{ coveragePath?: unknown, captureScript?: unknown }} userCrap
|
|
203
|
+
* @param {string} coverageGatePath
|
|
204
|
+
* @returns {{ coveragePath: string, captureScript: string, ownCoverageSource: boolean }}
|
|
205
|
+
*/
|
|
206
|
+
function resolveCrapCoverageSource(userCrap, coverageGatePath) {
|
|
207
|
+
const userPath = nonEmptyString(userCrap?.coveragePath);
|
|
208
|
+
const captureScript =
|
|
209
|
+
nonEmptyString(userCrap?.captureScript) ?? CRAP_GATE_DEFAULTS.captureScript;
|
|
210
|
+
const coveragePath = userPath ?? coverageGatePath;
|
|
211
|
+
const ownCoverageSource =
|
|
212
|
+
userPath !== null &&
|
|
213
|
+
userPath.replace(/\\/g, '/') !== coverageGatePath.replace(/\\/g, '/');
|
|
214
|
+
if (
|
|
215
|
+
ownCoverageSource &&
|
|
216
|
+
artifactDir(userPath) === artifactDir(coverageGatePath)
|
|
217
|
+
) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
`[config] delivery.quality.gates.crap.coveragePath '${userPath}' sits in the same directory as delivery.quality.gates.coverage.coveragePath '${coverageGatePath}'. The capture stamp is per directory, so an own CRAP coverage source must live in its own directory.`,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return { coveragePath, captureScript, ownCoverageSource };
|
|
223
|
+
}
|
|
224
|
+
|
|
179
225
|
/**
|
|
180
226
|
* @param {object | undefined} userCrap
|
|
181
227
|
* @param {{ coveragePath: string }} coverageGate
|
|
@@ -195,6 +241,8 @@ export function resolveMaintainabilityCrap(userCrap, coverageGate) {
|
|
|
195
241
|
targetDirs: [...defaults.targetDirs],
|
|
196
242
|
newMethodCeiling: defaults.newMethodCeiling,
|
|
197
243
|
coveragePath: coverage.coveragePath,
|
|
244
|
+
captureScript: defaults.captureScript,
|
|
245
|
+
ownCoverageSource: false,
|
|
198
246
|
tolerance: toleranceScalar(
|
|
199
247
|
defaults.tolerance,
|
|
200
248
|
DEFAULT_CRAP_TOLERANCE.value,
|
|
@@ -213,7 +261,7 @@ export function resolveMaintainabilityCrap(userCrap, coverageGate) {
|
|
|
213
261
|
enabled: userCrap.enabled ?? defaults.enabled,
|
|
214
262
|
targetDirs: resolveListValue(defaults.targetDirs, userCrap.targetDirs),
|
|
215
263
|
newMethodCeiling: userCrap.newMethodCeiling ?? defaults.newMethodCeiling,
|
|
216
|
-
|
|
264
|
+
...resolveCrapCoverageSource(userCrap, coverage.coveragePath),
|
|
217
265
|
tolerance: toleranceScalar(
|
|
218
266
|
userCrap.tolerance,
|
|
219
267
|
toleranceScalar(defaults.tolerance, DEFAULT_CRAP_TOLERANCE.value),
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from './config/agentrc-overlay.js';
|
|
13
13
|
import { getCiDelivery } from './config/ci.js';
|
|
14
14
|
import { getCommands } from './config/commands.js';
|
|
15
|
+
import { applyGhConfigDir } from './config/gh-config-dir.js';
|
|
15
16
|
import { getGitHub } from './config/github.js';
|
|
16
17
|
import { resolvePaths } from './config/paths.js';
|
|
17
18
|
import { validateOrchestrationConfig } from './config/validate-orchestration.js';
|
|
@@ -52,9 +53,9 @@ export {
|
|
|
52
53
|
} from './config/worktree-isolation.js';
|
|
53
54
|
export { PROJECT_ROOT } from './project-root.js';
|
|
54
55
|
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
const
|
|
56
|
+
// Keyed by absolute root + validate mode, so per-worktree cwds and a
|
|
57
|
+
// `validate: false` read never answer a validating caller.
|
|
58
|
+
const _cacheByKey = new Map();
|
|
58
59
|
const _envLoadedRoots = new Set();
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -137,79 +138,92 @@ function applyDefaults(raw) {
|
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* throws.
|
|
141
|
+
* The merged raw config and a human description of where it came from;
|
|
142
|
+
* `raw: null` when neither file exists (zero-config).
|
|
143
143
|
*
|
|
144
|
-
* @param {
|
|
144
|
+
* @param {import('node:fs')} fsImpl
|
|
145
|
+
* @param {string} root
|
|
146
|
+
* @returns {{ raw: object|null, source: string }}
|
|
145
147
|
*/
|
|
146
|
-
|
|
147
|
-
const envCwd = process.env.AP_AGENTRC_CWD;
|
|
148
|
-
const root = path.resolve(opts?.cwd ?? envCwd ?? PROJECT_ROOT);
|
|
149
|
-
const validate = opts?.validate !== false;
|
|
150
|
-
const fsImpl = opts?.ctx?.fs ?? fs;
|
|
151
|
-
|
|
152
|
-
if (!opts?.bustCache && _cacheByRoot.has(root)) {
|
|
153
|
-
return _cacheByRoot.get(root);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (!_envLoadedRoots.has(root)) {
|
|
157
|
-
loadEnv(root);
|
|
158
|
-
_envLoadedRoots.add(root);
|
|
159
|
-
}
|
|
160
|
-
|
|
148
|
+
function readRawConfig(fsImpl, root) {
|
|
161
149
|
const agentrcPath = path.join(root, '.agentrc.json');
|
|
162
150
|
const localPath = path.join(root, '.agentrc.local.json');
|
|
163
151
|
const hasAgentrc = fsImpl.existsSync(agentrcPath);
|
|
164
152
|
const hasLocal = fsImpl.existsSync(localPath);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
153
|
+
if (!hasAgentrc) {
|
|
154
|
+
if (!hasLocal) return { raw: null, source: 'built-in defaults' };
|
|
155
|
+
return {
|
|
156
|
+
raw: deepMergeObjects(
|
|
157
|
+
{ ...ZERO_CONFIG_RAW },
|
|
158
|
+
readJsonConfigFile(fsImpl, localPath, '.agentrc.local.json'),
|
|
159
|
+
),
|
|
160
|
+
source: `${localPath} (overrides built-in defaults)`,
|
|
172
161
|
};
|
|
173
|
-
_cacheByRoot.set(root, resolved);
|
|
174
|
-
return resolved;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
let raw = hasAgentrc
|
|
178
|
-
? readJsonConfigFile(fsImpl, agentrcPath, '.agentrc.json')
|
|
179
|
-
: { ...ZERO_CONFIG_RAW };
|
|
180
|
-
|
|
181
|
-
let source = hasAgentrc ? agentrcPath : 'built-in defaults';
|
|
182
|
-
|
|
183
|
-
if (hasLocal) {
|
|
184
|
-
const localRaw = readJsonConfigFile(
|
|
185
|
-
fsImpl,
|
|
186
|
-
localPath,
|
|
187
|
-
'.agentrc.local.json',
|
|
188
|
-
);
|
|
189
|
-
raw = deepMergeObjects(raw, localRaw);
|
|
190
|
-
source =
|
|
191
|
-
source === 'built-in defaults'
|
|
192
|
-
? `${localPath} (overrides built-in defaults)`
|
|
193
|
-
: `${localPath} (overrides ${agentrcPath})`;
|
|
194
162
|
}
|
|
163
|
+
const raw = readJsonConfigFile(fsImpl, agentrcPath, '.agentrc.json');
|
|
164
|
+
if (!hasLocal) return { raw, source: agentrcPath };
|
|
165
|
+
return {
|
|
166
|
+
raw: deepMergeObjects(
|
|
167
|
+
raw,
|
|
168
|
+
readJsonConfigFile(fsImpl, localPath, '.agentrc.local.json'),
|
|
169
|
+
),
|
|
170
|
+
source: `${localPath} (overrides ${agentrcPath})`,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
195
173
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
174
|
+
/** @param {object} raw */
|
|
175
|
+
function assertSchemaValid(raw) {
|
|
176
|
+
const validateAgentrc = getAgentrcValidator();
|
|
177
|
+
if (!validateAgentrc(raw)) {
|
|
178
|
+
const details = formatAgentrcErrors(validateAgentrc.errors).join(', ');
|
|
179
|
+
throw new Error(`[config] Invalid .agentrc.json: ${details}`);
|
|
202
180
|
}
|
|
181
|
+
}
|
|
203
182
|
|
|
204
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Defaults applied over `raw`; a zero-config read is never validated.
|
|
185
|
+
*
|
|
186
|
+
* @param {{ raw: object|null, source: string }} read
|
|
187
|
+
* @param {boolean} validate
|
|
188
|
+
*/
|
|
189
|
+
function finalizeConfig({ raw, source }, validate) {
|
|
190
|
+
const checked = validate && raw !== null;
|
|
191
|
+
if (checked) assertSchemaValid(raw);
|
|
192
|
+
const blocks = applyDefaults(raw ?? { ...ZERO_CONFIG_RAW });
|
|
193
|
+
if (checked) validateOrchestrationConfig(blocks);
|
|
194
|
+
return { ...blocks, raw, source };
|
|
195
|
+
}
|
|
205
196
|
|
|
206
|
-
|
|
197
|
+
function ensureEnvLoaded(root) {
|
|
198
|
+
if (_envLoadedRoots.has(root)) return;
|
|
199
|
+
loadEnv(root);
|
|
200
|
+
_envLoadedRoots.add(root);
|
|
201
|
+
}
|
|
207
202
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Returns `{ project, github, planning, delivery, qa?, raw, source }`. A
|
|
205
|
+
* missing file falls back to defaults; malformed JSON or a schema failure
|
|
206
|
+
* throws. A set `github.cliConfigDir` is applied to `GH_CONFIG_DIR`. A call with an injected `ctx.fs` neither reads nor fills the
|
|
207
|
+
* shared cache.
|
|
208
|
+
*
|
|
209
|
+
* @param {{ bustCache?: boolean, cwd?: string, validate?: boolean, ctx?: object }} [opts]
|
|
210
|
+
*/
|
|
211
|
+
export function resolveConfig(opts) {
|
|
212
|
+
const root = path.resolve(
|
|
213
|
+
opts?.cwd ?? process.env.AP_AGENTRC_CWD ?? PROJECT_ROOT,
|
|
214
|
+
);
|
|
215
|
+
const validate = opts?.validate !== false;
|
|
216
|
+
const injectedFs = opts?.ctx?.fs;
|
|
217
|
+
const key = `${root}\0${validate}`;
|
|
218
|
+
if (!injectedFs && !opts?.bustCache && _cacheByKey.has(key)) {
|
|
219
|
+
return _cacheByKey.get(key);
|
|
220
|
+
}
|
|
221
|
+
ensureEnvLoaded(root);
|
|
222
|
+
const resolved = finalizeConfig(
|
|
223
|
+
readRawConfig(injectedFs ?? fs, root),
|
|
224
|
+
validate,
|
|
225
|
+
);
|
|
226
|
+
applyGhConfigDir(resolved.github, root, { fsImpl: injectedFs ?? fs });
|
|
227
|
+
if (!injectedFs) _cacheByKey.set(key, resolved);
|
|
214
228
|
return resolved;
|
|
215
229
|
}
|
|
@@ -183,7 +183,7 @@ const WORKTREE_ISOLATION_SCHEMA = {
|
|
|
183
183
|
const MERGE_WATCH_SCHEMA = {
|
|
184
184
|
type: 'object',
|
|
185
185
|
description:
|
|
186
|
-
"Knobs consumed by the close-and-land merge wait (Story #4543). `mode` (Story #4698) selects the close-time merge posture. `maxWaitSeconds` bounds ONE invocation of the merge wait and its expiry returns a resumable `pending` terminal with no label mutation; `maxBudgetSeconds` bounds the CUMULATIVE wait across resumes (anchored at the PR's createdAt, so a resume does not restart the clock) and exhausting it is the genuine give-up that classifies and blocks. The poll cadence is internal (at most 30s while checks run, at most 10s once they are green and the PR is unmerged); it and the cap of 3 behind-the-base updates are not configurable.",
|
|
186
|
+
"Knobs consumed by the close-and-land merge wait (Story #4543). `mode` (Story #4698) selects the close-time merge posture. `maxWaitSeconds` bounds ONE invocation of the merge wait and its expiry returns a resumable `pending` terminal with no label mutation; `maxBudgetSeconds` bounds the CUMULATIVE wait across resumes (anchored at the later of the PR's createdAt and its latest auto-merge arm, so a `--wait` resume does not restart the clock while a re-close that re-arms gets a fresh budget) and exhausting it is the genuine give-up that classifies and blocks. The poll cadence is internal (at most 30s while checks run, at most 10s once they are green and the PR is unmerged); it and the cap of 3 behind-the-base updates are not configurable.",
|
|
187
187
|
properties: {
|
|
188
188
|
mode: {
|
|
189
189
|
type: 'string',
|
|
@@ -201,7 +201,7 @@ const MERGE_WATCH_SCHEMA = {
|
|
|
201
201
|
type: 'integer',
|
|
202
202
|
minimum: 1,
|
|
203
203
|
description:
|
|
204
|
-
"Cumulative wall-clock budget (seconds) across merge-wait resumes, anchored at the PR's createdAt. Default 3600 (60 minutes). Exhausting this classifies the block and transitions the Story to agent::blocked.",
|
|
204
|
+
"Cumulative wall-clock budget (seconds) across merge-wait resumes, anchored at the later of the PR's createdAt and its latest auto-merge arm (`autoMergeRequest.enabledAt`), so a re-close that re-arms starts a fresh budget; without an arm time it falls back to createdAt, then to the invocation start. Default 3600 (60 minutes). Exhausting this classifies the block and transitions the Story to agent::blocked.",
|
|
205
205
|
default: 3600,
|
|
206
206
|
},
|
|
207
207
|
},
|
|
@@ -368,7 +368,8 @@ const TEMP_RETENTION_SCHEMA = {
|
|
|
368
368
|
},
|
|
369
369
|
auditResults: {
|
|
370
370
|
type: 'boolean',
|
|
371
|
-
description:
|
|
371
|
+
description:
|
|
372
|
+
'<tempRoot>/audits/ — audit lens reports (audit-results/) and audit working artifacts.',
|
|
372
373
|
default: true,
|
|
373
374
|
},
|
|
374
375
|
planDirs: {
|
|
@@ -351,6 +351,13 @@ const GITHUB_SCHEMA = {
|
|
|
351
351
|
'The human the framework escalates to, `@`-prefixed. Used for HITL @-mentions on `agent::blocked`.',
|
|
352
352
|
default: '@[USERNAME]',
|
|
353
353
|
},
|
|
354
|
+
cliConfigDir: {
|
|
355
|
+
type: ['string', 'null'],
|
|
356
|
+
minLength: 1,
|
|
357
|
+
description:
|
|
358
|
+
"Dedicated `gh` credential store (`GH_CONFIG_DIR`) for this project, set in the gitignored `.agentrc.local.json`. Relative paths resolve against the project root and a leading `~` expands to the home directory; the directory must exist. When set, every `gh` call Mandrel makes runs with `GH_CONFIG_DIR` pointed at it. `null` keeps `gh`'s default store.",
|
|
359
|
+
default: null,
|
|
360
|
+
},
|
|
354
361
|
followUpRepos: FOLLOW_UP_REPOS_SCHEMA,
|
|
355
362
|
branchProtection: BRANCH_PROTECTION_SCHEMA,
|
|
356
363
|
mergeMethods: MERGE_METHODS_SCHEMA,
|
|
@@ -9,7 +9,7 @@ import picomatch from 'picomatch';
|
|
|
9
9
|
import { write, writeFile } from './baselines/writer.js';
|
|
10
10
|
import {
|
|
11
11
|
captureStampPath,
|
|
12
|
-
|
|
12
|
+
MissingCoverageArtifactError,
|
|
13
13
|
} from './coverage-capture.js';
|
|
14
14
|
|
|
15
15
|
const COVERAGE_FINAL_PATH = 'coverage/coverage-final.json';
|
|
@@ -98,7 +98,7 @@ export function readCoverageFinal(cwd, opts = {}, fsImpl) {
|
|
|
98
98
|
? coveragePath
|
|
99
99
|
: path.resolve(cwd, coveragePath);
|
|
100
100
|
if (!resolvedFs.existsSync(abs)) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new MissingCoverageArtifactError(abs);
|
|
102
102
|
}
|
|
103
103
|
return JSON.parse(resolvedFs.readFileSync(abs, 'utf8'));
|
|
104
104
|
}
|
|
@@ -185,7 +185,8 @@ function writeMerged({
|
|
|
185
185
|
*/
|
|
186
186
|
async function captureAndMerge(opts) {
|
|
187
187
|
const run = await runScoped(opts);
|
|
188
|
-
if (run.code !== 0)
|
|
188
|
+
if (run.code !== 0)
|
|
189
|
+
return reportCaptureFailure(run.code, opts.logger, AFFECTED_CAPTURE_SCRIPT);
|
|
189
190
|
if (!writeMerged(opts)) return 1;
|
|
190
191
|
stampCapturedTree({
|
|
191
192
|
...opts,
|
|
@@ -96,7 +96,7 @@ export async function runFullScopeCapture({
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
logger.info(
|
|
99
|
-
`[coverage-capture] Coverage at ${crap.coveragePath} is ${describeFreshness(freshness, crap.targetDirs)}; running npm run test:coverage… ${detail}`,
|
|
99
|
+
`[coverage-capture] Coverage at ${crap.coveragePath} is ${describeFreshness(freshness, crap.targetDirs)}; running npm run ${crap.captureScript ?? 'test:coverage'}… ${detail}`,
|
|
100
100
|
);
|
|
101
101
|
const tree = snapshotCapturedTree({
|
|
102
102
|
cwd: args.cwd,
|
|
@@ -112,7 +112,7 @@ export async function runFullScopeCapture({
|
|
|
112
112
|
// After queueing behind another suite, which may have stamped this tree.
|
|
113
113
|
recheckFresh: () => probe().fresh === true,
|
|
114
114
|
});
|
|
115
|
-
if (code !== 0) return reportCaptureFailure(code, logger);
|
|
115
|
+
if (code !== 0) return reportCaptureFailure(code, logger, crap.captureScript);
|
|
116
116
|
|
|
117
117
|
stampCapturedTree({
|
|
118
118
|
...tree,
|
|
@@ -113,7 +113,7 @@ export async function tryIncrementalCapture({
|
|
|
113
113
|
log: (m) => logger.info(m),
|
|
114
114
|
recheckFresh: () => probe().fresh === true,
|
|
115
115
|
});
|
|
116
|
-
if (code !== 0) return reportCaptureFailure(code, logger);
|
|
116
|
+
if (code !== 0) return reportCaptureFailure(code, logger, crap.captureScript);
|
|
117
117
|
|
|
118
118
|
stampCapturedTree({
|
|
119
119
|
...tree,
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ordered capture passes for `coverage-capture.js` and the capture-script
|
|
3
|
+
* refusal. A shared source is one pass: the existing pipeline, scoped modes
|
|
4
|
+
* included. An own CRAP source (`crap.ownCoverageSource`) first refreshes the
|
|
5
|
+
* coverage gate's artifact exactly as before, then gives the CRAP artifact
|
|
6
|
+
* its own full-scope pass via `crap.captureScript`, stamped in its own
|
|
7
|
+
* directory. Scoped capture modes never apply to the own source.
|
|
8
|
+
*/
|
|
9
|
+
import { runFullScopeCapture } from './coverage-capture-fullscope.js';
|
|
10
|
+
|
|
11
|
+
const COVERAGE_GATE_SCRIPT = 'test:coverage';
|
|
12
|
+
const COVERAGE_PATH_KEY = 'delivery.quality.gates.coverage.coveragePath';
|
|
13
|
+
const CRAP_PATH_KEY = 'delivery.quality.gates.crap.coveragePath';
|
|
14
|
+
const CRAP_SCRIPT_KEY = 'delivery.quality.gates.crap.captureScript';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The exit code when no capture may run: the CRAP gate is off (0), or its
|
|
18
|
+
* capture script is missing from `package.json` (1, naming the fix).
|
|
19
|
+
*
|
|
20
|
+
* @param {{ crap: object, scripts: object, hasNpmScriptImpl: Function, logger: object }} opts
|
|
21
|
+
* @returns {number|null}
|
|
22
|
+
*/
|
|
23
|
+
export function captureRefusal({ crap, scripts, hasNpmScriptImpl, logger }) {
|
|
24
|
+
if (crap.enabled === false) {
|
|
25
|
+
logger.info('[coverage-capture] CRAP gate disabled — skipping capture.');
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
const script = crap.captureScript ?? COVERAGE_GATE_SCRIPT;
|
|
29
|
+
if (hasNpmScriptImpl(scripts, script)) return null;
|
|
30
|
+
// Name the fix rather than propagate npm's opaque "Missing script" exit.
|
|
31
|
+
logger.error(
|
|
32
|
+
`[coverage-capture] ✖ No "${script}" script in package.json (the CRAP capture script, set by ${CRAP_SCRIPT_KEY}). ` +
|
|
33
|
+
`Add one (e.g. "${script}": "node --test --experimental-test-coverage"), ` +
|
|
34
|
+
`point ${CRAP_SCRIPT_KEY} at an existing script, ` +
|
|
35
|
+
'or disable the CRAP gate via delivery.quality.gates.crap.enabled=false.',
|
|
36
|
+
);
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param {{ crap: object, coverage: object, scripts: object, hasNpmScriptImpl: Function, logger: object }} opts
|
|
42
|
+
* @returns {Array<{ crap: object, configKey: string, own: boolean }>}
|
|
43
|
+
*/
|
|
44
|
+
function planPasses({ crap, coverage, scripts, hasNpmScriptImpl, logger }) {
|
|
45
|
+
if (crap.ownCoverageSource !== true) {
|
|
46
|
+
return [{ crap, configKey: COVERAGE_PATH_KEY, own: false }];
|
|
47
|
+
}
|
|
48
|
+
const ownPass = { crap, configKey: CRAP_PATH_KEY, own: true };
|
|
49
|
+
if (!hasNpmScriptImpl(scripts, COVERAGE_GATE_SCRIPT)) {
|
|
50
|
+
logger.info(
|
|
51
|
+
`[coverage-capture] No "${COVERAGE_GATE_SCRIPT}" script — skipping the coverage gate's capture; only the CRAP source at ${crap.coveragePath} is refreshed.`,
|
|
52
|
+
);
|
|
53
|
+
return [ownPass];
|
|
54
|
+
}
|
|
55
|
+
const gateCrap = {
|
|
56
|
+
...crap,
|
|
57
|
+
coveragePath: coverage.coveragePath,
|
|
58
|
+
captureScript: COVERAGE_GATE_SCRIPT,
|
|
59
|
+
};
|
|
60
|
+
return [
|
|
61
|
+
{ crap: gateCrap, configKey: COVERAGE_PATH_KEY, own: false },
|
|
62
|
+
ownPass,
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A capture runner that defaults `script` to the pass's capture script; an
|
|
68
|
+
* explicit `script` (the affected scope's) still wins.
|
|
69
|
+
*
|
|
70
|
+
* @param {Function} capture
|
|
71
|
+
* @param {string|undefined} script
|
|
72
|
+
* @returns {Function}
|
|
73
|
+
*/
|
|
74
|
+
function withDefaultScript(capture, script) {
|
|
75
|
+
return script ? (opts) => capture({ script, ...opts }) : capture;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Run each planned pass; the first non-zero pass wins and no later pass runs.
|
|
80
|
+
*
|
|
81
|
+
* @param {{
|
|
82
|
+
* crap: object,
|
|
83
|
+
* coverage: object,
|
|
84
|
+
* args: object,
|
|
85
|
+
* scripts: object,
|
|
86
|
+
* hasNpmScriptImpl: Function,
|
|
87
|
+
* makeCapture: (source: { coveragePath: string, script?: string, configKey: string }) => Function,
|
|
88
|
+
* runShared: (opts: object) => Promise<number>,
|
|
89
|
+
* deps: object,
|
|
90
|
+
* }} opts
|
|
91
|
+
* @returns {Promise<number>}
|
|
92
|
+
*/
|
|
93
|
+
export async function runCapturePasses({
|
|
94
|
+
crap,
|
|
95
|
+
coverage,
|
|
96
|
+
args,
|
|
97
|
+
scripts,
|
|
98
|
+
hasNpmScriptImpl,
|
|
99
|
+
makeCapture,
|
|
100
|
+
runShared,
|
|
101
|
+
deps,
|
|
102
|
+
}) {
|
|
103
|
+
const { logger } = deps;
|
|
104
|
+
const passes = planPasses({
|
|
105
|
+
crap,
|
|
106
|
+
coverage,
|
|
107
|
+
scripts,
|
|
108
|
+
hasNpmScriptImpl,
|
|
109
|
+
logger,
|
|
110
|
+
});
|
|
111
|
+
for (const pass of passes) {
|
|
112
|
+
const capture = withDefaultScript(
|
|
113
|
+
makeCapture({
|
|
114
|
+
coveragePath: pass.crap.coveragePath,
|
|
115
|
+
script: pass.crap.captureScript,
|
|
116
|
+
configKey: pass.configKey,
|
|
117
|
+
}),
|
|
118
|
+
pass.crap.captureScript,
|
|
119
|
+
);
|
|
120
|
+
const code = pass.own
|
|
121
|
+
? await runOwnSource({ crap: pass.crap, coverage, args, capture, deps })
|
|
122
|
+
: await runShared({ crap: pass.crap, coverage, args, capture, deps });
|
|
123
|
+
if (code !== 0) return code;
|
|
124
|
+
}
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @param {{ crap: object, coverage: object, args: object, capture: Function, deps: object }} opts
|
|
130
|
+
* @returns {Promise<number>}
|
|
131
|
+
*/
|
|
132
|
+
function runOwnSource({ crap, coverage, args, capture, deps }) {
|
|
133
|
+
deps.logger.info(
|
|
134
|
+
`[coverage-capture] CRAP gate has its own coverage source (${CRAP_PATH_KEY}=${crap.coveragePath}, npm run ${crap.captureScript}).`,
|
|
135
|
+
);
|
|
136
|
+
return runFullScopeCapture({
|
|
137
|
+
...deps,
|
|
138
|
+
crap,
|
|
139
|
+
coverage,
|
|
140
|
+
args,
|
|
141
|
+
runCaptureImpl: capture,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
@@ -14,7 +14,7 @@ const COVERAGE_CAPTURE_USAGE = {
|
|
|
14
14
|
invocation:
|
|
15
15
|
'node .agents/scripts/coverage-capture.js [--skip-when-no-crap-files] [--require-credited] [--ref <git-ref>] [--cwd <path>]',
|
|
16
16
|
summary:
|
|
17
|
-
'Ensure coverage/coverage-final.json is present and fresh before the CRAP gate fires, spawning `npm run test:coverage` only when it is stale (`npm run test:coverage:affected`, with the base ref in MANDREL_COVERAGE_BASE_REF, under delivery.quality.gates.coverage.captureScope="affected"). Writes a content-digest capture stamp that close-validation reads to skip a redundant re-run.',
|
|
17
|
+
'Ensure coverage/coverage-final.json is present and fresh before the CRAP gate fires, spawning `npm run test:coverage` only when it is stale (`npm run test:coverage:affected`, with the base ref in MANDREL_COVERAGE_BASE_REF, under delivery.quality.gates.coverage.captureScope="affected"). Writes a content-digest capture stamp that close-validation reads to skip a redundant re-run. When delivery.quality.gates.crap.coveragePath names its own artifact, that artifact is then refreshed full-scope with `npm run <delivery.quality.gates.crap.captureScript>` and stamped in its own directory.',
|
|
18
18
|
flags: [
|
|
19
19
|
[
|
|
20
20
|
'--skip-when-no-crap-files',
|