mandrel 2.87.0 → 2.88.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 +2 -1
- package/.agents/docs/configuration.md +12 -8
- package/.agents/docs/workflows.md +1 -1
- package/.agents/schemas/agentrc.schema.json +11 -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/deliver-run.js +11 -0
- package/.agents/scripts/diagnose-friction.js +3 -3
- package/.agents/scripts/lib/baselines/coverage-updater-cli.js +6 -14
- package/.agents/scripts/lib/baselines/crap-updater-cli.js +36 -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 +14 -38
- package/.agents/scripts/lib/baselines/preview-gates.js +4 -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/codex/skills-projection.js +1 -12
- 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-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.js +16 -1
- package/.agents/scripts/lib/crap-utils.js +59 -47
- 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 +14 -1
- 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/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 +10 -19
- 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 +2 -2
- 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 +29 -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
package/.agents/README.md
CHANGED
|
@@ -143,6 +143,12 @@ gitignored:
|
|
|
143
143
|
`project_doc_max_bytes` (default 32768). Bootstrap puts the Mandrel block at
|
|
144
144
|
the top for that reason; raise the limit in `.codex/config.toml` if your own
|
|
145
145
|
notes below it are cut.
|
|
146
|
+
- **Direct `gh` calls.** Mandrel's scripts set `GH_CONFIG_DIR` from
|
|
147
|
+
`github.cliConfigDir` ([GitHub authentication](#github-authentication)); a
|
|
148
|
+
`gh` command the agent runs directly does not. Export it in the host config
|
|
149
|
+
(Codex `shell_environment_policy`, Claude Code `env` in
|
|
150
|
+
`.claude/settings.local.json`) or prefix the command. A sandboxed network
|
|
151
|
+
denial is not an expired login: re-run with escalated permissions.
|
|
146
152
|
- **Doctor.** `mandrel doctor` adds `codex-skills-in-sync`,
|
|
147
153
|
`codex-agents-in-sync` (remedy: re-run `mandrel sync-commands` /
|
|
148
154
|
`mandrel sync-agents`) and `codex-instructions`, which fails when the
|
|
@@ -589,6 +595,29 @@ Set `GITHUB_TOKEN` in the process environment or in `.env` at the
|
|
|
589
595
|
project root; the resolver auto-loads `.env`. For local interactive
|
|
590
596
|
sessions, `gh auth login` is sufficient.
|
|
591
597
|
|
|
598
|
+
**Pinning one account (`github.cliConfigDir`).** With several GitHub
|
|
599
|
+
accounts, give the project its own `gh` credential store in the gitignored
|
|
600
|
+
`.agentrc.local.json`:
|
|
601
|
+
|
|
602
|
+
```json
|
|
603
|
+
{ "github": { "cliConfigDir": "~/.config/gh-work" } }
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
Log it in once with `GH_CONFIG_DIR=~/.config/gh-work gh auth login`. Relative
|
|
607
|
+
paths resolve against the project root and `~` expands to your home; a
|
|
608
|
+
missing directory is a config error. Config resolution exports
|
|
609
|
+
`GH_CONFIG_DIR`, so every `gh` call and child process Mandrel spawns reads
|
|
610
|
+
that store (a differing inherited value is overridden with a warning).
|
|
611
|
+
|
|
612
|
+
**Identity check.** With a real `github.operatorHandle` and a `gh`-store
|
|
613
|
+
credential, the provider checks the login (`GET /user`, once per process)
|
|
614
|
+
before its first write and refuses on a mismatch, naming both handles and the
|
|
615
|
+
`GH_CONFIG_DIR`. An exported `GITHUB_TOKEN` / `GH_TOKEN` is exempt.
|
|
616
|
+
|
|
617
|
+
**Transport is not auth.** A sandbox or network fault (denied spawn, timeout,
|
|
618
|
+
DNS or connection failure) is reported as transport: re-run with network
|
|
619
|
+
access. Only a confirmed not-logged-in or HTTP 401 says `gh auth login`.
|
|
620
|
+
|
|
592
621
|
---
|
|
593
622
|
|
|
594
623
|
## Self-Healing Checks
|
|
@@ -63,9 +63,10 @@ file is its standalone-agent form.
|
|
|
63
63
|
- This is a **read-only** analysis. Do **not** modify application code, styles,
|
|
64
64
|
configuration, dependencies, branches, or labels, and never open a PR.
|
|
65
65
|
- The **only** write you perform is the report artifact at
|
|
66
|
-
`{{
|
|
66
|
+
`{{auditResultsDir}}/audit-<lens>-results.md`, plus — only where the lens body
|
|
67
67
|
explicitly declares it — a single measurement/baseline artifact it names
|
|
68
|
-
(e.g. `perf-baseline.json`)
|
|
68
|
+
(e.g. `perf-baseline.json`) under `{{auditOutputDir}}`, never beside the
|
|
69
|
+
reports.
|
|
69
70
|
- Running **non-mutating** measurements/scanners the lens calls for (profilers,
|
|
70
71
|
timers, `npm audit`, read-only status commands) is permitted; running
|
|
71
72
|
anything that installs, mutates git/labels, or edits source is forbidden.
|
|
@@ -151,7 +152,7 @@ lens's size.
|
|
|
151
152
|
|
|
152
153
|
## Return contract
|
|
153
154
|
|
|
154
|
-
Return the **report path** (`{{
|
|
155
|
+
Return the **report path** (`{{auditResultsDir}}/audit-<lens>-results.md`) and
|
|
155
156
|
the report's **Executive Summary** (including the self-cross-check line). Do not
|
|
156
157
|
inline the full findings — the report artifact is the record of truth, and
|
|
157
158
|
`audit-to-stories` reads it from disk. If the lens resolved not-applicable or
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"projectNumber": null,
|
|
28
28
|
"projectOwner": null,
|
|
29
29
|
"operatorHandle": "@[USERNAME]",
|
|
30
|
+
"cliConfigDir": null,
|
|
30
31
|
"followUpRepos": {
|
|
31
32
|
"framework": "dsj1984/mandrel",
|
|
32
33
|
"platform": null
|
|
@@ -169,7 +170,7 @@
|
|
|
169
170
|
"ignoreGlobs": []
|
|
170
171
|
},
|
|
171
172
|
"mutation": {
|
|
172
|
-
"enabled":
|
|
173
|
+
"enabled": false,
|
|
173
174
|
"baselinePath": "baselines/mutation.json",
|
|
174
175
|
"tolerance": {
|
|
175
176
|
"kind": "percent",
|
|
@@ -102,6 +102,7 @@ GitHub provider identity plus the remote stance the bootstrap enforces. `owner`,
|
|
|
102
102
|
| `projectNumber` | No | `integer` \| `null` | `null` | Projects V2 board number the orchestrator syncs Story status onto. `null` disables board sync. |
|
|
103
103
|
| `projectOwner` | No | `string` \| `null` | `null` | Owner of the Projects V2 board when it lives outside `owner` (an org board fed by a user repo). `null` means the board shares `owner`. |
|
|
104
104
|
| `operatorHandle` | Yes | `string` | `"@[USERNAME]"` | The human the framework escalates to, `@`-prefixed. Used for HITL @-mentions on `agent::blocked`. |
|
|
105
|
+
| `cliConfigDir` | No | `string` \| `null` | `null` | 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. |
|
|
105
106
|
| `followUpRepos` | No | `object` | — | Repository slugs for the non-consumer follow-up ownership buckets, used when a CI gap, retro proposal, or audit finding belongs to someone other than the repo that surfaced it. |
|
|
106
107
|
| `followUpRepos.framework` | No | `string` | `"dsj1984/mandrel"` | `<owner>/<repo>` that owns framework-level defects. Defaults to the Mandrel mirror — the one bucket with a knowable default. |
|
|
107
108
|
| `followUpRepos.platform` | No | `string` \| `null` | `null` | `<owner>/<repo>` for a shared platform or infrastructure tracker (a shared base config, a runner fleet, a cross-repo toolchain). No default — nothing can guess a shared repo. Left unset, platform-owned findings file locally and say so. |
|
|
@@ -146,7 +147,7 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
146
147
|
| `tempRetention.classes` | No | `object` | — | Per-class opt-out. Each defaults to true; set one false to keep that family while the rest are purged. |
|
|
147
148
|
| `tempRetention.classes.orchestrationLogs` | No | `boolean` | `true` | <tempRoot>/orchestration/*.log — close gate transcripts and terse-result detail dumps. |
|
|
148
149
|
| `tempRetention.classes.validationEvidence` | No | `boolean` | `true` | Per-Story validation-evidence.json, lifecycle.ndjson, and manifest.md under the standalone and per-run story trees. |
|
|
149
|
-
| `tempRetention.classes.auditResults` | No | `boolean` | `true` | <tempRoot>/audits/ — audit lens reports. |
|
|
150
|
+
| `tempRetention.classes.auditResults` | No | `boolean` | `true` | <tempRoot>/audits/ — audit lens reports (audit-results/) and audit working artifacts. |
|
|
150
151
|
| `tempRetention.classes.planDirs` | No | `boolean` | `true` | <tempRoot>/plan-<slug>/ — abandoned plan authoring dirs. Age-floored only; the current run is always excluded. |
|
|
151
152
|
| `tempRetention.classes.scratch` | No | `boolean` | `true` | <tempRoot>/scratch/ — agent-authored scratch. `scratch/story-<id>/` is purged when that Story lands; any other `scratch/` entry is age-floored. |
|
|
152
153
|
| `deliverRunner` | No | `object` | — | Bounded-concurrency knob for the /mandrel-deliver fan-out. |
|
|
@@ -200,8 +201,8 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
200
201
|
| `quality.gates.maintainability.components` | No | `object<map>` | — | Per-gate component map — component name to the glob list whose rows roll up under it (matched against the row key: the file path, or the bundle name for bundle-size). `check-baselines` reports one rollup per component that matches a row and holds it to `floors.<component>`, falling back to `floors["*"]`. Defaults to `{ "*": ["**"] }` at the resolver layer. |
|
|
201
202
|
| `quality.gates.maintainability.targetDirs` | No | `string[]` or `{ append?, prepend? }` | `[]` | Directories whose JS sources the maintainability gate scores. Mandrel ships a `src/`-centric default; projects whose executable code lives elsewhere (e.g. this repo's `.agents/scripts/` plus `tests/`) override here. The framework default is intentionally not auto-discovered, so an override is the explicit, auditable signal. |
|
|
202
203
|
| `quality.gates.maintainability.ignoreGlobs` | No | `array<string>` | `[]` | Minimatch glob patterns matched against the canonicalised repo-relative path of each discovered file. Files matching any pattern are excluded from MI discovery before scoring. Orthogonal to `components` (grouping) — a file excluded here never appears in any component bucket. Absent or empty preserves the existing IGNORED_DIRS-only behaviour (Story #3217). |
|
|
203
|
-
| `quality.gates.mutation` | No | `object` | — | Stryker mutation-score ratchet.
|
|
204
|
-
| `quality.gates.mutation.enabled` | No | `boolean` | `
|
|
204
|
+
| `quality.gates.mutation` | No | `object` | — | Stryker mutation-score ratchet. Disabled by default: no framework path runs Stryker, so enable it only alongside a consumer-provided Stryker run that writes the mutation report the baseline is scored from. |
|
|
205
|
+
| `quality.gates.mutation.enabled` | No | `boolean` | `false` | When false, the checker exits 0 with a skip line and the gate is reported as `skipped`, never omitted. |
|
|
205
206
|
| `quality.gates.mutation.baselinePath` | No | `string` | `"baselines/mutation.json"` | Repo-root-relative path to the gate's committed baseline artifact. |
|
|
206
207
|
| `quality.gates.mutation.tolerance` | No | `object` | `{"kind":"percent","value":0}` | How much a rollup may drift from the committed baseline before the gate reports a regression. |
|
|
207
208
|
| `quality.gates.mutation.tolerance.kind` | Yes | `"absolute"` \| `"percent"` | — | Whether `value` is read as raw metric units (`absolute`) or as a percentage of the baseline (`percent`). |
|
|
@@ -235,10 +236,10 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
|
|
|
235
236
|
| `quality.navigability.routeGlobs` | No | `array<string>` | `[]` | Glob patterns (pages/**, app/**/route.ts) marking paths that add a user-facing route — the route-tree SSOT the navigability lens enumerates and the route-added routing predicate matches against. |
|
|
236
237
|
| `quality.navigability.navRegistry` | No | `array<string>` | `[]` | Tokens identifying the nav-registry SSOT the navigability lens checks every route resolves a nav door against. |
|
|
237
238
|
| `quality.navigability.journeySuite` | No | `string` | — | Path or command for the per-persona journey suite /mandrel-deliver's per-Story ceremony runs. |
|
|
238
|
-
| `mergeWatch` | No | `object` | — | 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. |
|
|
239
|
+
| `mergeWatch` | No | `object` | — | 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. |
|
|
239
240
|
| `mergeWatch.mode` | No | `"sync"` \| `"async"` | — | Close-time merge-wait posture (Story #4698). `sync` (default) keeps the in-close foreground merge wait unchanged. `async` caps the per-invocation wait to a short ~60s probe window — long enough to catch an instant merge and, via the head-anchored required-check predicate, an instantly-red required check — then returns the resumable `pending` terminal (exit 3) with a `nextCommand`. Opt in when slow CI makes the foreground wait routinely expire: the worker launches `nextCommand` in the background instead of burning the host tool slot polling. `maxBudgetSeconds` (the cumulative give-up) is unchanged. |
|
|
240
241
|
| `mergeWatch.maxWaitSeconds` | No | `integer` | — | Per-invocation merge-wait bound (seconds). Default 300 (5 minutes) — chosen to fit inside a single host tool invocation (~10 min ceiling) alongside the close gates that precede the wait. Expiry yields `pending` (exit 3), never a block. Headless callers with no host ceiling raise this to land in one block. |
|
|
241
|
-
| `mergeWatch.maxBudgetSeconds` | No | `integer` | `3600` | 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. |
|
|
242
|
+
| `mergeWatch.maxBudgetSeconds` | No | `integer` | `3600` | 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. |
|
|
242
243
|
| `codeReview` | No | `object` | — | Review-provider chain and on-branch remediation threshold for the /mandrel-deliver code-review ceremony. |
|
|
243
244
|
| `codeReview.providers[]` | No | `array<object>` | `[{"name":"native"},{"name":"code-review","scopes":["story"],"optional":true}]` | Review-provider chain (Story #2871). When unset or empty, falls back to this default: `native` (maintainability scoring of the changed files) then an optional story-scoped `code-review` — a low-effort `claude --print` bug review whose every finding is critical and halts close before auto-merge; hosts without the `claude` CLI skip it. `security-review` and `ultrareview` are opt-in. The orchestrator iterates inline entries in declaration order and merges their Finding[] before posting one structured comment; manual-prompt entries (e.g. ultrareview) contribute a trailing 'Manual review suggestions' section. Selecting an adapter whose probe fails hard-fails at factory construction unless declared `optional: true` in the chain. Each item has: name, scopes, optional, manualPrompt, when. |
|
|
244
245
|
| `codeReview.autoFixSeverity` | No | `"high"` \| `"medium"` | `"medium"` | Severity threshold for on-branch remediation in /mandrel-deliver Phase 5 (code-review). `medium` (default) routes 🔴/🟠/🟡 findings into the host-LLM focused-fix routing (Mediums batched per lens: one commit per lens, a single validation + rescan at the end) while 🟢 suggestions still graduate to follow-up issues; `high` reproduces the pre-4399 Critical/High-only routing. Hard cutover — no back-compat flag. |
|
|
@@ -291,9 +292,12 @@ names or defaults.
|
|
|
291
292
|
|
|
292
293
|
- **`paths` (required).** All three roots are required — the resolver applies
|
|
293
294
|
no code-level fallback, so a missing value is a validation error with a clear
|
|
294
|
-
`instancePath`. `auditOutputDir`
|
|
295
|
-
resolves to `${tempRoot}/audits` (the
|
|
296
|
-
|
|
295
|
+
`instancePath`. `auditOutputDir` and `auditResultsDir` are **derived, not
|
|
296
|
+
configurable**: `auditOutputDir` resolves to `${tempRoot}/audits` (the
|
|
297
|
+
audit working area — audit-suite prompt artifacts, audit-to-stories plans,
|
|
298
|
+
measurement artifacts) and `auditResultsDir` to
|
|
299
|
+
`${tempRoot}/audits/audit-results` (every `audit-*-results.md` report and
|
|
300
|
+
nothing else). Override `tempRoot` to relocate both.
|
|
297
301
|
- **`commands`.** Each string must be non-empty and pass the shell-injection
|
|
298
302
|
guard (`safeString` — disallows `;`, `&`, `|`, backtick, `$`, `<`, `>`).
|
|
299
303
|
`typecheck` is nullable; an explicit `null` is the canonical "not
|
|
@@ -68,7 +68,7 @@ description, edit the workflow file’s front-matter and regenerate.
|
|
|
68
68
|
| `/audit-security` | Audit dependency CVEs, input-validation gaps, secrets handling, auth boundaries, and the trust-boundary attack classes the baseline is silent on (business logic, SSRF/traversal, deserialization, crypto misuse, feature abuse, LLM tool-binding); emit a structured High/Medium/Low findings report. |
|
|
69
69
|
| `/audit-seo` | Audit SEO fundamentals and Generative Engine Optimization signals (meta, structured data, crawlability); only relevant for web targets. |
|
|
70
70
|
| `/audit-sre` | "Audit production-readiness for a release candidate: SLOs, observability, runbooks, error budgets, and rollback paths." |
|
|
71
|
-
| `/audit-to-stories` | Convert findings produced by the audit-\* workflows into actionable GitHub Stories. Reads temp/audits/audit-\*-results.md, groups findings cross-audit, deduplicates against existing Issues by fingerprint, and either chains into /mandrel-plan --seed-file or opens standalone Stories. |
|
|
71
|
+
| `/audit-to-stories` | Convert findings produced by the audit-\* workflows into actionable GitHub Stories. Reads temp/audits/audit-results/audit-\*-results.md, groups findings cross-audit, deduplicates against existing Issues by fingerprint, and either chains into /mandrel-plan --seed-file or opens standalone Stories. |
|
|
72
72
|
| `/audit-ux-ui` | Audit UX/UI consistency and design system adherence |
|
|
73
73
|
| `/clean-git` | Tidy the local checkout in four phases: fast-forward `main`, prune stale remote-tracking refs, sweep merged branches (squash-aware), and triage `git stash` entries — each step gated by operator confirmation. |
|
|
74
74
|
| `/clean-temp` | Clear the temp-tree backlog the land-time purge cannot attribute: sort every top-level entry under the project's tempRoot into framework, closed-issue, aged and kept buckets, preview by default, and delete only confirmed buckets. |
|
|
@@ -163,6 +163,12 @@
|
|
|
163
163
|
"description": "The human the framework escalates to, `@`-prefixed. Used for HITL @-mentions on `agent::blocked`.",
|
|
164
164
|
"default": "@[USERNAME]"
|
|
165
165
|
},
|
|
166
|
+
"cliConfigDir": {
|
|
167
|
+
"type": ["string", "null"],
|
|
168
|
+
"minLength": 1,
|
|
169
|
+
"description": "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.",
|
|
170
|
+
"default": null
|
|
171
|
+
},
|
|
166
172
|
"followUpRepos": {
|
|
167
173
|
"type": "object",
|
|
168
174
|
"description": "Repository slugs for the non-consumer follow-up ownership buckets, used when a CI gap, retro proposal, or audit finding belongs to someone other than the repo that surfaced it.",
|
|
@@ -448,7 +454,7 @@
|
|
|
448
454
|
},
|
|
449
455
|
"auditResults": {
|
|
450
456
|
"type": "boolean",
|
|
451
|
-
"description": "<tempRoot>/audits/ — audit lens reports.",
|
|
457
|
+
"description": "<tempRoot>/audits/ — audit lens reports (audit-results/) and audit working artifacts.",
|
|
452
458
|
"default": true
|
|
453
459
|
},
|
|
454
460
|
"planDirs": {
|
|
@@ -915,12 +921,12 @@
|
|
|
915
921
|
},
|
|
916
922
|
"mutation": {
|
|
917
923
|
"type": "object",
|
|
918
|
-
"description": "Stryker mutation-score ratchet.
|
|
924
|
+
"description": "Stryker mutation-score ratchet. Disabled by default: no framework path runs Stryker, so enable it only alongside a consumer-provided Stryker run that writes the mutation report the baseline is scored from.",
|
|
919
925
|
"properties": {
|
|
920
926
|
"enabled": {
|
|
921
927
|
"type": "boolean",
|
|
922
928
|
"description": "When false, the checker exits 0 with a skip line and the gate is reported as `skipped`, never omitted.",
|
|
923
|
-
"default":
|
|
929
|
+
"default": false
|
|
924
930
|
},
|
|
925
931
|
"baselinePath": {
|
|
926
932
|
"type": "string",
|
|
@@ -1247,7 +1253,7 @@
|
|
|
1247
1253
|
},
|
|
1248
1254
|
"mergeWatch": {
|
|
1249
1255
|
"type": "object",
|
|
1250
|
-
"description": "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.",
|
|
1256
|
+
"description": "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.",
|
|
1251
1257
|
"properties": {
|
|
1252
1258
|
"mode": {
|
|
1253
1259
|
"type": "string",
|
|
@@ -1262,7 +1268,7 @@
|
|
|
1262
1268
|
"maxBudgetSeconds": {
|
|
1263
1269
|
"type": "integer",
|
|
1264
1270
|
"minimum": 1,
|
|
1265
|
-
"description": "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.",
|
|
1271
|
+
"description": "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.",
|
|
1266
1272
|
"default": 3600
|
|
1267
1273
|
}
|
|
1268
1274
|
},
|
|
@@ -194,7 +194,7 @@
|
|
|
194
194
|
"elapsedSeconds": { "type": "number", "minimum": 0 },
|
|
195
195
|
"waitBudget": {
|
|
196
196
|
"type": ["object", "null"],
|
|
197
|
-
"description": "Merge-wait accounting. maxWaitSeconds bounds THIS invocation (defaulting under the host's single-tool-invocation ceiling); cumulativeSeconds is anchored at the PR's createdAt so a resume does not restart the clock, and maxBudgetSeconds bounds that cumulative total.",
|
|
197
|
+
"description": "Merge-wait accounting. maxWaitSeconds bounds THIS invocation (defaulting under the host's single-tool-invocation ceiling); cumulativeSeconds is anchored at the later of the PR's createdAt and its latest auto-merge arm, so a resume does not restart the clock while a re-arming re-close starts fresh, and maxBudgetSeconds bounds that cumulative total.",
|
|
198
198
|
"properties": {
|
|
199
199
|
"maxWaitSeconds": { "type": "integer", "minimum": 1 },
|
|
200
200
|
"waitedSeconds": { "type": "number", "minimum": 0 },
|
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
"minimum": 1,
|
|
44
44
|
"description": "The Story PR's number from the moment close parses it; null before then and throughout handoff."
|
|
45
45
|
},
|
|
46
|
+
"evidencePath": {
|
|
47
|
+
"type": ["string", "null"],
|
|
48
|
+
"minLength": 1,
|
|
49
|
+
"description": "Optional. The evidence log the current handoff step's child is streaming into, so a poller can tail it while the step runs. Absent when the phase runs no logged child."
|
|
50
|
+
},
|
|
46
51
|
"updatedAt": { "type": "string", "format": "date-time" }
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
import { Logger } from './lib/Logger.js';
|
|
36
36
|
import { parse as parseStoryBody } from './lib/story-body/story-body.js';
|
|
37
37
|
|
|
38
|
-
const DEFAULT_GLOB = 'temp/audits/audit-*-results.md';
|
|
38
|
+
const DEFAULT_GLOB = 'temp/audits/audit-results/audit-*-results.md';
|
|
39
39
|
const FAN_OUT_REPORT = 'audit-fan-out-results.md';
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -907,6 +907,7 @@ function persist(text, outPath) {
|
|
|
907
907
|
}
|
|
908
908
|
|
|
909
909
|
export const __testing = {
|
|
910
|
+
DEFAULT_GLOB,
|
|
910
911
|
meetsSeverity,
|
|
911
912
|
collectReportPaths,
|
|
912
913
|
buildPlan,
|
|
@@ -1097,7 +1098,7 @@ runAsCli(import.meta.url, main, {
|
|
|
1097
1098
|
invocation:
|
|
1098
1099
|
'node .agents/scripts/audit-to-stories.js (--scan | --auto | --emit-plan-seed | --emit-stories | --wire-edges) [options]',
|
|
1099
1100
|
summary:
|
|
1100
|
-
'Turn audit-lens findings under temp/audits/ into a dedup-checked plan seed or standalone Stories.',
|
|
1101
|
+
'Turn audit-lens findings under temp/audits/audit-results/ into a dedup-checked plan seed or standalone Stories.',
|
|
1101
1102
|
flags: [
|
|
1102
1103
|
['--scan', 'Print the grouped, deduplicated plan as JSON.'],
|
|
1103
1104
|
['--auto', 'Run the full scan → file pipeline and print the summary.'],
|
|
@@ -25,6 +25,7 @@ import { parseArgs } from 'node:util';
|
|
|
25
25
|
|
|
26
26
|
import { runAsCli } from './lib/cli-utils.js';
|
|
27
27
|
import { PROJECT_ROOT, resolveConfig } from './lib/config-resolver.js';
|
|
28
|
+
import { parseStoryBranch } from './lib/git-utils.js';
|
|
28
29
|
import { Logger } from './lib/Logger.js';
|
|
29
30
|
import { sweepStaleStoryWorktrees } from './lib/orchestration/plan-runner/worktree-sweep.js';
|
|
30
31
|
import { createProvider } from './lib/provider-factory.js';
|
|
@@ -47,8 +48,8 @@ import { sweepTempRetention } from './lib/temp-retention.js';
|
|
|
47
48
|
export function storyIdsFromBranches(branches) {
|
|
48
49
|
const ids = [];
|
|
49
50
|
for (const branch of Array.isArray(branches) ? branches : []) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
51
|
+
const id = parseStoryBranch(String(branch));
|
|
52
|
+
if (id !== null) ids.push(id);
|
|
52
53
|
}
|
|
53
54
|
return ids;
|
|
54
55
|
}
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import process from 'node:process';
|
|
12
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
12
13
|
import { runAsCli } from './lib/cli-utils.js';
|
|
14
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
13
15
|
import {
|
|
14
16
|
buildGraph,
|
|
15
17
|
collectJsFiles,
|
|
@@ -18,35 +20,28 @@ import {
|
|
|
18
20
|
} from './lib/import-graph.js';
|
|
19
21
|
|
|
20
22
|
// Shared with `audit-baselines.js`; re-exported as part of this module's contract.
|
|
21
|
-
export {
|
|
23
|
+
export {
|
|
24
|
+
buildGraph,
|
|
25
|
+
collectJsFiles,
|
|
26
|
+
DEFAULT_ROOTS,
|
|
27
|
+
parseRelativeImports,
|
|
28
|
+
readJsonBaseline as loadBaseline,
|
|
29
|
+
};
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* @param {string[]} argv
|
|
25
33
|
* @returns {{ baselinePath: string | null, rootPath: string | null, json: boolean }}
|
|
26
34
|
*/
|
|
27
35
|
export function parseArgv(argv = []) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
i += 1;
|
|
38
|
-
}
|
|
39
|
-
} else if (a === '--root') {
|
|
40
|
-
const next = argv[i + 1];
|
|
41
|
-
if (next && !next.startsWith('--')) {
|
|
42
|
-
rootPath = next;
|
|
43
|
-
i += 1;
|
|
44
|
-
}
|
|
45
|
-
} else if (a === '--json') {
|
|
46
|
-
json = true;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return { baselinePath, rootPath, json };
|
|
36
|
+
const flags = parseGateArgv(argv, {
|
|
37
|
+
strings: ['baseline', 'root'],
|
|
38
|
+
booleans: ['json'],
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
baselinePath: flags.baseline,
|
|
42
|
+
rootPath: flags.root,
|
|
43
|
+
json: flags.json,
|
|
44
|
+
};
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
/**
|
|
@@ -123,23 +118,6 @@ export function findCycles(graph) {
|
|
|
123
118
|
);
|
|
124
119
|
}
|
|
125
120
|
|
|
126
|
-
/**
|
|
127
|
-
* `null` when missing or unparseable.
|
|
128
|
-
*
|
|
129
|
-
* @param {string} baselinePath
|
|
130
|
-
* @returns {{ cycles?: string[][] } | null}
|
|
131
|
-
*/
|
|
132
|
-
export function loadBaseline(baselinePath) {
|
|
133
|
-
try {
|
|
134
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
135
|
-
const parsed = JSON.parse(fs.readFileSync(baselinePath, 'utf-8'));
|
|
136
|
-
if (!parsed || typeof parsed !== 'object') return null;
|
|
137
|
-
return parsed;
|
|
138
|
-
} catch {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
121
|
/**
|
|
144
122
|
* Both sides normalized, so a rotation never counts as drift.
|
|
145
123
|
*
|
|
@@ -208,7 +186,7 @@ export async function runCli({
|
|
|
208
186
|
if (presentScanDirs.length === 0) {
|
|
209
187
|
throw new Error(`[arch-cycles] no scan root found: ${scanDirs.join(', ')}`);
|
|
210
188
|
}
|
|
211
|
-
const baseline =
|
|
189
|
+
const baseline = readJsonBaseline(resolvedBaselinePath);
|
|
212
190
|
const allowlisted = Array.isArray(baseline?.cycles) ? baseline.cycles : [];
|
|
213
191
|
|
|
214
192
|
const files = presentScanDirs.flatMap((dir) => collectJsFiles(dir));
|
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
import fs from 'node:fs';
|
|
17
17
|
import path from 'node:path';
|
|
18
18
|
import process from 'node:process';
|
|
19
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
19
20
|
import { runAsCli } from './lib/cli-utils.js';
|
|
20
21
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
21
22
|
import { resolveDocTiers, tierTotalBytes } from './lib/doc-tiers.js';
|
|
23
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
24
|
+
|
|
25
|
+
export { readJsonBaseline as loadBaseline };
|
|
22
26
|
|
|
23
27
|
/**
|
|
24
28
|
* Measured tiers, in report order — only those a session is forced to read.
|
|
@@ -43,48 +47,16 @@ export const DEFAULT_TOLERANCE_BYTES = 2048;
|
|
|
43
47
|
* @returns {{ baselinePath: string|null, rootPath: string|null, update: boolean, json: boolean }}
|
|
44
48
|
*/
|
|
45
49
|
export function parseArgv(argv = []) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
i += 1;
|
|
57
|
-
}
|
|
58
|
-
} else if (a === '--root') {
|
|
59
|
-
const next = argv[i + 1];
|
|
60
|
-
if (next && !next.startsWith('--')) {
|
|
61
|
-
rootPath = next;
|
|
62
|
-
i += 1;
|
|
63
|
-
}
|
|
64
|
-
} else if (a === '--update') {
|
|
65
|
-
update = true;
|
|
66
|
-
} else if (a === '--json') {
|
|
67
|
-
json = true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return { baselinePath, rootPath, update, json };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* `null` when missing or unparseable.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} baselinePath
|
|
77
|
-
* @returns {{ toleranceBytes?: number, tiers?: Record<string, { totalBytes: number, files?: Array<{ path: string, bytes: number }> }> } | null}
|
|
78
|
-
*/
|
|
79
|
-
export function loadBaseline(baselinePath) {
|
|
80
|
-
try {
|
|
81
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
82
|
-
const parsed = JSON.parse(fs.readFileSync(baselinePath, 'utf-8'));
|
|
83
|
-
if (!parsed || typeof parsed !== 'object') return null;
|
|
84
|
-
return parsed;
|
|
85
|
-
} catch {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
50
|
+
const flags = parseGateArgv(argv, {
|
|
51
|
+
strings: ['baseline', 'root'],
|
|
52
|
+
booleans: ['update', 'json'],
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
baselinePath: flags.baseline,
|
|
56
|
+
rootPath: flags.root,
|
|
57
|
+
update: flags.update,
|
|
58
|
+
json: flags.json,
|
|
59
|
+
};
|
|
88
60
|
}
|
|
89
61
|
|
|
90
62
|
/**
|
|
@@ -300,7 +272,7 @@ function renderAgentBoot(tierMap) {
|
|
|
300
272
|
* @returns {0}
|
|
301
273
|
*/
|
|
302
274
|
function writeUpdatedBaseline({ tierMap, resolvedBaselinePath, json, stdout }) {
|
|
303
|
-
const existing =
|
|
275
|
+
const existing = readJsonBaseline(resolvedBaselinePath);
|
|
304
276
|
const tolerance = Number.isFinite(existing?.toleranceBytes)
|
|
305
277
|
? existing.toleranceBytes
|
|
306
278
|
: DEFAULT_TOLERANCE_BYTES;
|
|
@@ -468,7 +440,7 @@ export async function runCli({
|
|
|
468
440
|
});
|
|
469
441
|
}
|
|
470
442
|
|
|
471
|
-
const baseline =
|
|
443
|
+
const baseline = readJsonBaseline(resolvedBaselinePath);
|
|
472
444
|
if (!baseline) {
|
|
473
445
|
return reportMissingBaseline({
|
|
474
446
|
tierMap,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import fs from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import process from 'node:process';
|
|
12
|
+
import { parseGateArgv } from './lib/cli-args.js';
|
|
12
13
|
import { runAsCli } from './lib/cli-utils.js';
|
|
13
14
|
import { getQuality, resolveConfig } from './lib/config-resolver.js';
|
|
14
15
|
import {
|
|
@@ -20,47 +21,22 @@ import {
|
|
|
20
21
|
scanCyclomatic,
|
|
21
22
|
} from './lib/cyclomatic-ceiling.js';
|
|
22
23
|
import { resolveScanScope } from './lib/cyclomatic-scope.js';
|
|
24
|
+
import { readJsonBaseline } from './lib/gates/baseline-store.js';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* @param {string[]} argv
|
|
26
28
|
* @returns {{ baselinePath: string | null, json: boolean, update: boolean }}
|
|
27
29
|
*/
|
|
28
30
|
function parseArgv(argv = []) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
i += 1;
|
|
39
|
-
}
|
|
40
|
-
} else if (a === '--json') {
|
|
41
|
-
json = true;
|
|
42
|
-
} else if (a === '--update') {
|
|
43
|
-
update = true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { baselinePath, json, update };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* `null` when missing or unparseable — treated as empty, so a first run
|
|
51
|
-
* reports every breach rather than silently passing.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} baselinePath
|
|
54
|
-
* @returns {{ ceiling?: number, rows?: Array<object> } | null}
|
|
55
|
-
*/
|
|
56
|
-
function loadCyclomaticBaseline(baselinePath) {
|
|
57
|
-
try {
|
|
58
|
-
if (!fs.existsSync(baselinePath)) return null;
|
|
59
|
-
const parsed = JSON.parse(fs.readFileSync(baselinePath, 'utf-8'));
|
|
60
|
-
return parsed && typeof parsed === 'object' ? parsed : null;
|
|
61
|
-
} catch {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
31
|
+
const flags = parseGateArgv(argv, {
|
|
32
|
+
strings: ['baseline'],
|
|
33
|
+
booleans: ['json', 'update'],
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
baselinePath: flags.baseline,
|
|
37
|
+
json: flags.json,
|
|
38
|
+
update: flags.update,
|
|
39
|
+
};
|
|
64
40
|
}
|
|
65
41
|
|
|
66
42
|
/**
|
|
@@ -145,7 +121,7 @@ function warnAboutBaseline({ baseline, mustFix, baselinePath, stderr }) {
|
|
|
145
121
|
* stderr?: { write: (s: string) => void },
|
|
146
122
|
* resolveConfigImpl?: typeof resolveConfig,
|
|
147
123
|
* scanImpl?: typeof scanCyclomatic,
|
|
148
|
-
* loadBaselineImpl?: typeof
|
|
124
|
+
* loadBaselineImpl?: typeof readJsonBaseline,
|
|
149
125
|
* writeFileImpl?: (p: string, data: string) => void,
|
|
150
126
|
* }} [opts]
|
|
151
127
|
* @returns {Promise<number>} 0 = clean / improved; 1 = ratchet breached
|
|
@@ -157,7 +133,7 @@ export async function runCli({
|
|
|
157
133
|
stderr = process.stderr,
|
|
158
134
|
resolveConfigImpl = resolveConfig,
|
|
159
135
|
scanImpl = scanCyclomatic,
|
|
160
|
-
loadBaselineImpl =
|
|
136
|
+
loadBaselineImpl = readJsonBaseline,
|
|
161
137
|
writeFileImpl = (p, data) => fs.writeFileSync(p, data),
|
|
162
138
|
} = {}) {
|
|
163
139
|
const { baselinePath, json, update } = parseArgv(argv);
|