mandrel 2.115.0 → 2.116.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.
@@ -282,6 +282,14 @@ Everything `/mandrel-deliver` and `single-story-close` consume: worktree isolati
282
282
  | `pullRequest.bodyTrailers` | No | `array<string>` | `[]` | Story #5875. Git-trailer keys close lifts from the Story branch commits into the PR body, for a consumer whose required check reads a body line (e.g. `Policy-impact`). For each key the last branch commit carrying `<Key>: <value>` as a trailer wins, and the line is appended after the auto-opened marker and before any `BREAKING CHANGE:` footer. A key no commit carries appends nothing and logs one info line. Workers record the value with `git commit --trailer`. Default [] leaves the body unchanged. |
283
283
  | `handoff` | No | `object` | — | Story #5960. What `story-handoff.js` runs beyond close's own gates. |
284
284
  | `handoff.postSeatChecks[]` | No | `array<object>` | `[]` | Story #5960. Consumer checks the handoff re-runs in its post-capture step, after the seat commits the Story's new baseline rows: each `{ cmd, args? }` runs in the worktree without a shell, with `MANDREL_HANDOFF_STEP=post-capture`, and a non-zero exit settles `fix-required`. Declare the check a consumer downgrades during `preflight` (keyed on `MANDREL_HANDOFF_STEP`) here, so a row the seat did not write still fails the handoff; while any is declared the preflight `lint` credit is withheld until they pass at HEAD. Skipped under a coverage deferral. Default [] runs nothing extra. Each item has: cmd, args. |
285
+ | `orchestrate` | No | `object` | — | Story #6040. Project facts `/mandrel-orchestrate` cannot derive: how this repository re-queues an ejected PR, and the release veto. Thresholds and authority defaults are constants, not config. |
286
+ | `orchestrate.requeueCommand` | No | `object` | — | Story #6040. `{ cmd, args? }` the inventory offers for an eligible ejected PR; `{pr}` in an arg is replaced by the PR number. Run without a shell, and only when the operator granted `requeue`. Unset, the inventory reports `command: null`. |
287
+ | `orchestrate.requeueCommand.cmd` | Yes | `string` | — | — |
288
+ | `orchestrate.requeueCommand.args` | No | `array<string>` | — | — |
289
+ | `orchestrate.releaseVeto` | No | `object` | — | Story #6040. `{ prLabel, cmd, args? }`: on a PR carrying `prLabel`, the inventory runs `cmd` (no shell, main checkout) and a non-zero exit holds a re-queue or auto-merge arm on that PR. Unset, no PR is vetoed. |
290
+ | `orchestrate.releaseVeto.prLabel` | Yes | `string` | — | — |
291
+ | `orchestrate.releaseVeto.cmd` | Yes | `string` | — | — |
292
+ | `orchestrate.releaseVeto.args` | No | `array<string>` | — | — |
285
293
  | `routing` | No | `object` | — | v2 delivery-spawn routing: role-scoped boot contexts and the ceremony profile. The v1 singleDelivery epic-route kill-switch was removed in Stage 6; the freshCriticSampleRate sampling floor was retired in Story #5313 and the derived-level ceremony routing in Story #5343. |
286
294
  | `routing.roleScopedAgents` | No | `boolean` | `true` | Epic #4478 (M7-B). Kill-switch for the role-scoped boot contexts. When true (default), a converted delivery spawn (`story-worker`, `acceptance-critic`) boots on its own `.claude/agents/<role>.md` system prompt instead of re-paying the full entry-doc (AGENTS.md or CLAUDE.md) @-import closure. When false, every converted spawn falls back to `subagent_type: general-purpose` — the instant, code-rollback-free per-consumer revert, and the universal escape for hosts that ignore `.claude/agents/`. The fallback is the full-closure agent that ran before M7-B, so flipping it off never drops a gate. |
287
295
  | `routing.ceremonyProfile` | No | `"minimal"` \| `"standard"` \| `"strict"` | `"standard"` | Acceptance-ceremony depth — who authors the Story acceptance verdict. minimal and standard (default) = the inline self-eval, whatever the diff touches; strict = a fresh-context maker-blind critic. Review depth is a separate decision and still derives `deep` for any sensitive path (review-depth.js). |
@@ -51,7 +51,7 @@ by `node .agents/scripts/generate-workflows-doc.js`; `npm run docs:check`
51
51
  fails when it drifts from the on-disk workflow set. To change a command’s
52
52
  description, edit the workflow file’s front-matter and regenerate.
53
53
 
54
- ## Commands (38)
54
+ ## Commands (39)
55
55
 
56
56
  | Command | Description |
57
57
  | --- | --- |
@@ -86,6 +86,7 @@ description, edit the workflow file’s front-matter and regenerate.
86
86
  | `/git-deliver` | Single ad-hoc delivery command for working-tree changes. Detects the git setup and escalates to the right terminal step — commit only, commit + push, or commit + push + open a PR with native auto-merge — picking the default from observable state and letting flags pin any level explicitly. Replaces the retired git-commit-all, git-push, and git-pr-all trio. |
87
87
  | `/mandrel-deliver` | Unified delivery entry point. Takes Story ids or a plain-language prompt, derives which path the work belongs on, and lands it via the single deliver-story engine — story-<id> → PR → main. |
88
88
  | `/mandrel-leverage` | Evidence-cited leverage review — draft five to twelve bets on how the project could be ~10x more useful, reliable or valuable, refute most of them with two maker-blind skeptics each, write the survivors, downgrades and refutations to temp/leverage/<run-id>/bets.md, and hand each survivor to /mandrel-plan behind a HITL gate. |
89
+ | `/mandrel-orchestrate` | One session that keeps every in-flight delivery moving — sweep the open PRs into exactly one state each, act only within the authority the operator recorded, message each owner once, close out every landed Story, and print the hand-back summary on stop. Reactive only; the host loop paces the sweeps. |
89
90
  | `/mandrel-plan` | Unified planning entry point. Interrogate → author → persist. Emits one Story by default; splits into N>1 only under the default-single split policy. |
90
91
  | `/mandrel-update` | npm-era upgrade wraparound for a Mandrel consumer. Runs `npx mandrel update` (resolve newest published version → install → re-materialize `.agents/` → migrate → doctor → surface changelog) as the single mechanical step, then walks the operator through the judgment wraparound the CLI deliberately leaves unowned: reconcile `.agentrc.json`, install the stabilized quality-gate surface, refresh the harness permission allowlist, reconcile the consumer's `AGENTS.md` / runbooks against the surfaced changelog, and stage + commit the dependency bump the CLI's closing report describes. |
91
92
  | `/memory-consolidate` | Attended consolidation pass over this project's agent memory pool — merge duplicates, verify claims against the current tree, prune with operator confirmation, rewrite the index, and stamp the pool with the date and entry count the /mandrel-plan advisory measures its next nudge against. |
@@ -1700,6 +1700,53 @@
1700
1700
  },
1701
1701
  "additionalProperties": false
1702
1702
  },
1703
+ "orchestrate": {
1704
+ "type": "object",
1705
+ "description": "Story #6040. Project facts `/mandrel-orchestrate` cannot derive: how this repository re-queues an ejected PR, and the release veto. Thresholds and authority defaults are constants, not config.",
1706
+ "properties": {
1707
+ "requeueCommand": {
1708
+ "type": "object",
1709
+ "properties": {
1710
+ "cmd": {
1711
+ "type": "string",
1712
+ "minLength": 1
1713
+ },
1714
+ "args": {
1715
+ "type": "array",
1716
+ "items": {
1717
+ "type": "string"
1718
+ }
1719
+ }
1720
+ },
1721
+ "required": ["cmd"],
1722
+ "additionalProperties": false,
1723
+ "description": "Story #6040. `{ cmd, args? }` the inventory offers for an eligible ejected PR; `{pr}` in an arg is replaced by the PR number. Run without a shell, and only when the operator granted `requeue`. Unset, the inventory reports `command: null`."
1724
+ },
1725
+ "releaseVeto": {
1726
+ "type": "object",
1727
+ "properties": {
1728
+ "prLabel": {
1729
+ "type": "string",
1730
+ "minLength": 1
1731
+ },
1732
+ "cmd": {
1733
+ "type": "string",
1734
+ "minLength": 1
1735
+ },
1736
+ "args": {
1737
+ "type": "array",
1738
+ "items": {
1739
+ "type": "string"
1740
+ }
1741
+ }
1742
+ },
1743
+ "required": ["prLabel", "cmd"],
1744
+ "additionalProperties": false,
1745
+ "description": "Story #6040. `{ prLabel, cmd, args? }`: on a PR carrying `prLabel`, the inventory runs `cmd` (no shell, main checkout) and a non-zero exit holds a re-queue or auto-merge arm on that PR. Unset, no PR is vetoed."
1746
+ }
1747
+ },
1748
+ "additionalProperties": false
1749
+ },
1703
1750
  "routing": {
1704
1751
  "type": "object",
1705
1752
  "description": "v2 delivery-spawn routing: role-scoped boot contexts and the ceremony profile. The v1 singleDelivery epic-route kill-switch was removed in Stage 6; the freshCriticSampleRate sampling floor was retired in Story #5313 and the derived-level ceremony routing in Story #5343.",
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * closeout-audit.js — report every landed Story whose close-out did not
5
+ * finish; `--execute` repairs each drifted check through its existing seam.
6
+ *
7
+ * Exit codes: 0 nothing drifted (or all repaired), 2 drift remains, 1 the
8
+ * audit itself could not run.
9
+ */
10
+
11
+ import path from 'node:path';
12
+ import { parseArgs } from 'node:util';
13
+
14
+ import { runAsCli } from './lib/cli-utils.js';
15
+ import { PROJECT_ROOT, resolveConfig } from './lib/config-resolver.js';
16
+ import {
17
+ buildProbes,
18
+ buildRepairs,
19
+ buildWithLock,
20
+ DEFAULT_SINCE_HOURS,
21
+ exitCodeFor,
22
+ listMergedStoryIds,
23
+ renderAudit,
24
+ runCloseoutAudit,
25
+ } from './lib/orchestration/closeout-audit.js';
26
+ import { createProvider } from './lib/provider-factory.js';
27
+
28
+ const USAGE = {
29
+ invocation:
30
+ 'node .agents/scripts/closeout-audit.js [--story <id[,id…]>] [--since-hours <n>] [--execute] [--json] [--cwd <main-repo>]',
31
+ summary:
32
+ 'Audit landed Stories for an unfinished close-out (state, board, branches, worktree, scratch). Dry-run unless --execute.',
33
+ flags: [
34
+ ['--story <ids>', 'Audit exactly these Story ids (comma-separated).'],
35
+ [
36
+ '--since-hours <n>',
37
+ `Without --story: Stories whose story-<id> PR merged in the last n hours (default ${DEFAULT_SINCE_HOURS}).`,
38
+ ],
39
+ [
40
+ '--execute',
41
+ 'Repair each drifted check through its existing seam, then re-audit.',
42
+ ],
43
+ ['--json', 'Print one closeout-audit envelope on stdout.'],
44
+ ['--cwd <path>', 'Main-repo checkout (default: project root).'],
45
+ ],
46
+ notes: [
47
+ 'Exit 0 nothing drifted, 2 drift remains, 1 the audit could not run.',
48
+ 'An unknown check (probe could not run) is reported, never repaired.',
49
+ ],
50
+ };
51
+
52
+ export function parseCloseoutArgv(argv) {
53
+ const { values } = parseArgs({
54
+ args: argv,
55
+ options: {
56
+ story: { type: 'string' },
57
+ 'since-hours': { type: 'string' },
58
+ execute: { type: 'boolean', default: false },
59
+ json: { type: 'boolean', default: false },
60
+ cwd: { type: 'string' },
61
+ },
62
+ strict: true,
63
+ });
64
+ const storyIds = values.story
65
+ ? values.story.split(',').map((s) => Number.parseInt(s.trim(), 10))
66
+ : null;
67
+ if (storyIds?.some((id) => !Number.isInteger(id) || id <= 0)) {
68
+ throw new Error(
69
+ `--story must be positive integer ids (got "${values.story}")`,
70
+ );
71
+ }
72
+ const sinceHours =
73
+ values['since-hours'] === undefined
74
+ ? DEFAULT_SINCE_HOURS
75
+ : Number(values['since-hours']);
76
+ if (!(sinceHours > 0))
77
+ throw new Error('--since-hours must be a positive number');
78
+ return {
79
+ storyIds,
80
+ sinceHours,
81
+ execute: values.execute,
82
+ json: values.json,
83
+ cwd: path.resolve(values.cwd ?? PROJECT_ROOT),
84
+ };
85
+ }
86
+
87
+ const stderrLogger = {
88
+ info: (m) => process.stderr.write(`${m}\n`),
89
+ warn: (m) => process.stderr.write(`${m}\n`),
90
+ error: (m) => process.stderr.write(`${m}\n`),
91
+ };
92
+
93
+ /* node:coverage ignore next -- CLI wiring over the tested lib */
94
+ async function main() {
95
+ const args = parseCloseoutArgv(process.argv.slice(2));
96
+ const config = resolveConfig({ cwd: args.cwd });
97
+ const provider = createProvider(config);
98
+ const deps = { cwd: args.cwd, config, provider, logger: stderrLogger };
99
+ const storyIds =
100
+ args.storyIds ??
101
+ (await listMergedStoryIds({
102
+ baseBranch: config.project?.baseBranch ?? 'main',
103
+ sinceHours: args.sinceHours,
104
+ }));
105
+ const envelope = await runCloseoutAudit({
106
+ storyIds,
107
+ scope: args.storyIds
108
+ ? { mode: 'explicit', storyIds, execute: args.execute }
109
+ : {
110
+ mode: 'window',
111
+ sinceHours: args.sinceHours,
112
+ storyIds,
113
+ execute: args.execute,
114
+ },
115
+ probes: buildProbes(deps),
116
+ repairs: buildRepairs(deps),
117
+ execute: args.execute,
118
+ withLock: buildWithLock(deps),
119
+ });
120
+ process.stdout.write(
121
+ args.json
122
+ ? `${JSON.stringify(envelope, null, 2)}\n`
123
+ : renderAudit(envelope),
124
+ );
125
+ return exitCodeFor(envelope);
126
+ }
127
+
128
+ runAsCli(import.meta.url, main, {
129
+ source: 'closeout-audit',
130
+ propagateExitCode: true,
131
+ usage: USAGE,
132
+ });
@@ -259,6 +259,18 @@ export function runTempDir(rid, config) {
259
259
  return path.join(anchorTempRoot(tempRootFrom(config)), `run-${runId(rid)}`);
260
260
  }
261
261
 
262
+ /**
263
+ * `<tempRoot>/orchestrate/<run-id>`: one `/mandrel-orchestrate` run's ledger.
264
+ *
265
+ * @param {string} rid
266
+ * @param {object} [config]
267
+ * @returns {string}
268
+ */
269
+ export function orchestrateRunDir(rid, config) {
270
+ const root = anchorTempRoot(tempRootFrom(config));
271
+ return path.join(root, 'orchestrate', artifactName(rid));
272
+ }
273
+
262
274
  /**
263
275
  * `eid === null` routes to `<tempRoot>/standalone/stories/story-<sid>/`.
264
276
  *
@@ -376,6 +376,39 @@ const HANDOFF_SCHEMA = {
376
376
  additionalProperties: false,
377
377
  };
378
378
 
379
+ const ORCHESTRATE_COMMAND_PROPS = {
380
+ cmd: { type: 'string', minLength: 1 },
381
+ args: { type: 'array', items: { type: 'string' } },
382
+ };
383
+
384
+ const ORCHESTRATE_SCHEMA = {
385
+ type: 'object',
386
+ description:
387
+ 'Story #6040. Project facts `/mandrel-orchestrate` cannot derive: how this repository re-queues an ejected PR, and the release veto. Thresholds and authority defaults are constants, not config.',
388
+ properties: {
389
+ requeueCommand: {
390
+ type: 'object',
391
+ properties: ORCHESTRATE_COMMAND_PROPS,
392
+ required: ['cmd'],
393
+ additionalProperties: false,
394
+ description:
395
+ 'Story #6040. `{ cmd, args? }` the inventory offers for an eligible ejected PR; `{pr}` in an arg is replaced by the PR number. Run without a shell, and only when the operator granted `requeue`. Unset, the inventory reports `command: null`.',
396
+ },
397
+ releaseVeto: {
398
+ type: 'object',
399
+ properties: {
400
+ prLabel: { type: 'string', minLength: 1 },
401
+ ...ORCHESTRATE_COMMAND_PROPS,
402
+ },
403
+ required: ['prLabel', 'cmd'],
404
+ additionalProperties: false,
405
+ description:
406
+ 'Story #6040. `{ prLabel, cmd, args? }`: on a PR carrying `prLabel`, the inventory runs `cmd` (no shell, main checkout) and a non-zero exit holds a re-queue or auto-merge arm on that PR. Unset, no PR is vetoed.',
407
+ },
408
+ },
409
+ additionalProperties: false,
410
+ };
411
+
379
412
  const REFACTOR_STAGE_SCHEMA = {
380
413
  type: 'object',
381
414
  description:
@@ -517,6 +550,7 @@ export const DELIVERY_SCHEMA = {
517
550
  ci: CI_DELIVERY_SCHEMA,
518
551
  pullRequest: PULL_REQUEST_DELIVERY_SCHEMA,
519
552
  handoff: HANDOFF_SCHEMA,
553
+ orchestrate: ORCHESTRATE_SCHEMA,
520
554
  routing: ROUTING_SCHEMA,
521
555
  },
522
556
  additionalProperties: false,