mandrel 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/agents/.markdownlint.json +4 -0
- package/.agents/agents/acceptance-critic.md +30 -5
- package/.agents/agents/auditor.md +36 -19
- package/.agents/agents/plan-critic.md +31 -5
- package/.agents/agents/story-worker.md +91 -100
- package/.agents/docs/configuration.md +16 -4
- package/.agents/docs/execution-reference.md +13 -0
- package/.agents/docs/workflows.md +1 -1
- package/.agents/instructions.md +131 -265
- package/.agents/rules/git-conventions.md +47 -83
- package/.agents/rules/orchestration-error-handling.md +28 -0
- package/.agents/schemas/agentrc.schema.json +24 -2
- package/.agents/schemas/validation-evidence.schema.json +3 -1
- package/.agents/scripts/acceptance-eval.js +1 -1
- package/.agents/scripts/apply-quality-bootstrap.js +1 -1
- package/.agents/scripts/check-test-temp-hygiene.js +438 -0
- package/.agents/scripts/deliver-recover.js +23 -6
- package/.agents/scripts/lib/audit-suite/index.js +5 -0
- package/.agents/scripts/lib/audit-suite/lens-diff-floor.js +179 -0
- package/.agents/scripts/lib/audit-suite/selector.js +1 -1
- package/.agents/scripts/lib/config/temp-paths.js +121 -1
- package/.agents/scripts/lib/config-settings-schema-delivery.js +30 -0
- package/.agents/scripts/lib/config-settings-schema.js +1 -1
- package/.agents/scripts/lib/observability/metrics-ledger.js +217 -0
- package/.agents/scripts/lib/observability/runtime-friction.js +7 -0
- package/.agents/scripts/lib/orchestration/complexity-gate.js +113 -2
- package/.agents/scripts/lib/orchestration/deliver-recover.js +137 -10
- package/.agents/scripts/lib/orchestration/merge-block-class.js +36 -15
- package/.agents/scripts/lib/orchestration/merge-poll.js +213 -0
- package/.agents/scripts/lib/orchestration/plan-context.js +57 -0
- package/.agents/scripts/lib/orchestration/plan-critic-conditions.js +182 -9
- package/.agents/scripts/lib/orchestration/plan-critics-evaluate.js +29 -2
- package/.agents/scripts/lib/orchestration/plan-metrics.js +31 -82
- package/.agents/scripts/lib/orchestration/plan-persist/run-plan-persist.js +102 -2
- package/.agents/scripts/lib/orchestration/plan-persist/story-ops.js +215 -14
- package/.agents/scripts/lib/orchestration/resolve-stories.js +7 -0
- package/.agents/scripts/lib/orchestration/review-providers/native.js +34 -16
- package/.agents/scripts/lib/orchestration/single-story-close/phases/code-review.js +8 -3
- package/.agents/scripts/lib/orchestration/single-story-close/phases/confirm-merge.js +230 -79
- package/.agents/scripts/lib/orchestration/story-close/phases/local-lens-review.js +89 -1
- package/.agents/scripts/lib/orchestration/story-close/phases/review-core.js +73 -0
- package/.agents/scripts/lib/templates/decomposer-prompts.js +13 -6
- package/.agents/scripts/lib/test-env.js +65 -0
- package/.agents/scripts/plan-context.js +66 -9
- package/.agents/scripts/plan-critics.js +115 -3
- package/.agents/scripts/plan-persist.js +11 -1
- package/.agents/scripts/plan-run-epilogue.js +1 -1
- package/.agents/scripts/single-story-confirm-merge.js +65 -5
- package/.agents/scripts/stories-wave-tick.js +1 -1
- package/.agents/workflows/deliver.md +86 -230
- package/.agents/workflows/helpers/deliver-reference.md +167 -0
- package/.agents/workflows/helpers/deliver-story-reference.md +203 -0
- package/.agents/workflows/helpers/deliver-story.md +114 -432
- package/.agents/workflows/helpers/plan-reference.md +211 -0
- package/.agents/workflows/plan.md +107 -304
- package/docs/CHANGELOG.md +27 -0
- package/package.json +1 -1
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* short-circuits to a `noop` envelope.
|
|
28
28
|
*
|
|
29
29
|
* Usage:
|
|
30
|
-
* node single-story-confirm-merge.js --story <STORY_ID> [--pr <n>]
|
|
30
|
+
* node single-story-confirm-merge.js --story <STORY_ID> [--pr <n>] [--wait]
|
|
31
|
+
* [--max-wait-seconds <n>]
|
|
31
32
|
* [--cwd <main-repo>]
|
|
32
33
|
*
|
|
33
34
|
* Exit codes: 0 ok (merged, pending, or noop), 1 error.
|
|
@@ -40,12 +41,13 @@ import { parseSprintArgs } from './lib/cli-args.js';
|
|
|
40
41
|
import { runAsCli } from './lib/cli-utils.js';
|
|
41
42
|
import { resolveConfig } from './lib/config-resolver.js';
|
|
42
43
|
import { formatCliError } from './lib/error-redactor.js';
|
|
43
|
-
import {
|
|
44
|
+
import { createGh } from './lib/gh-exec.js';
|
|
44
45
|
import { getStoryBranch } from './lib/git-utils.js';
|
|
45
46
|
import { Logger } from './lib/Logger.js';
|
|
46
47
|
import { emitTerminalFriction } from './lib/observability/runtime-friction.js';
|
|
47
48
|
import { emitTerseResult } from './lib/observability/terse-result.js';
|
|
48
49
|
import { MERGED_FLIP_FAILED_BLOCK_CLASS } from './lib/orchestration/lifecycle/emit-merge-flip-failed.js';
|
|
50
|
+
import { MERGE_WAIT_GH_TIMEOUT_MS } from './lib/orchestration/merge-poll.js';
|
|
49
51
|
import { parsePrNumber } from './lib/orchestration/single-story-close/phases/code-review.js';
|
|
50
52
|
import { runConfirmMergePhase as defaultRunConfirmMergePhase } from './lib/orchestration/single-story-close/phases/confirm-merge.js';
|
|
51
53
|
import { parseCloseOptions } from './lib/orchestration/single-story-close/phases/options.js';
|
|
@@ -64,6 +66,25 @@ const progress = Logger.createProgress('single-story-confirm-merge', {
|
|
|
64
66
|
stderr: true,
|
|
65
67
|
});
|
|
66
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Default `gh` facade for this CLI, bound to the merge wait's spawn-level
|
|
71
|
+
* timeout (Story #4710). This CLI is the resume surface async mode hands the
|
|
72
|
+
* merge wait to — a background invocation with no host tool ceiling — so an
|
|
73
|
+
* un-timeboxed `gh pr list` / `gh pr view` here could strand the resume the
|
|
74
|
+
* same way an un-timeboxed probe stranded the in-close wait.
|
|
75
|
+
*/
|
|
76
|
+
const defaultGh = createGh(undefined, { timeoutMs: MERGE_WAIT_GH_TIMEOUT_MS });
|
|
77
|
+
|
|
78
|
+
/** One usage string for the throw path and `--help` (Story #4710). */
|
|
79
|
+
const USAGE =
|
|
80
|
+
'Usage: node single-story-confirm-merge.js --story <STORY_ID> [--pr <n>] [--wait] ' +
|
|
81
|
+
'[--max-wait-seconds <n>] [--cwd <main-repo>]\n\n' +
|
|
82
|
+
' --wait resume the bounded merge wait instead of probing once\n' +
|
|
83
|
+
' --max-wait-seconds per-invocation wait bound override, threaded to\n' +
|
|
84
|
+
' resolveMergeWaitConfig exactly as the close does (wins\n' +
|
|
85
|
+
' over delivery.mergeWatch.maxWaitSeconds and the async\n' +
|
|
86
|
+
' probe-window cap; only meaningful with --wait)';
|
|
87
|
+
|
|
67
88
|
/**
|
|
68
89
|
* Read the `--pr <n>` flag from `process.argv` for the direct-CLI path.
|
|
69
90
|
* Injection callers pass `pr` directly and never reach this. Returns the
|
|
@@ -106,6 +127,33 @@ function readWaitFlag() {
|
|
|
106
127
|
}
|
|
107
128
|
}
|
|
108
129
|
|
|
130
|
+
/**
|
|
131
|
+
* `--max-wait-seconds <n>`: per-invocation wait-bound override for the
|
|
132
|
+
* `--wait` resume path (Story #4710). The close CLI already accepted this
|
|
133
|
+
* flag, but the resume CLI — the exact command async mode's `pending`
|
|
134
|
+
* terminal hands off to — did not, so the documented per-run override was
|
|
135
|
+
* unreachable where it mattered most and a slow-CI landing depended on an
|
|
136
|
+
* unbounded chain of short invocations. Threaded to `runConfirmMergePhase`
|
|
137
|
+
* (and thence `resolveMergeWaitConfig`) exactly as close threads its own
|
|
138
|
+
* flag. Returns `undefined` when absent or not a positive integer — the
|
|
139
|
+
* phase's config/default resolution owns that case.
|
|
140
|
+
*
|
|
141
|
+
* @returns {number|undefined}
|
|
142
|
+
*/
|
|
143
|
+
function readMaxWaitSecondsFlag() {
|
|
144
|
+
try {
|
|
145
|
+
const { values } = parseArgs({
|
|
146
|
+
args: process.argv.slice(2),
|
|
147
|
+
options: { 'max-wait-seconds': { type: 'string' } },
|
|
148
|
+
strict: false,
|
|
149
|
+
});
|
|
150
|
+
const parsed = Number.parseInt(String(values['max-wait-seconds']), 10);
|
|
151
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
152
|
+
} catch {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
109
157
|
/**
|
|
110
158
|
* Resolve the PR number for the Story branch when one was not passed on
|
|
111
159
|
* the CLI. Probes `gh pr list --head <branch> --state all` (the merged PR
|
|
@@ -262,6 +310,7 @@ export async function runConfirmMerge({
|
|
|
262
310
|
cwd: cwdParam,
|
|
263
311
|
pr: prParam,
|
|
264
312
|
wait: waitParam,
|
|
313
|
+
maxWaitSeconds: maxWaitSecondsParam,
|
|
265
314
|
injectedProvider,
|
|
266
315
|
injectedConfig,
|
|
267
316
|
injectedGh,
|
|
@@ -275,11 +324,10 @@ export async function runConfirmMerge({
|
|
|
275
324
|
});
|
|
276
325
|
|
|
277
326
|
if (!storyId) {
|
|
278
|
-
throw new Error(
|
|
279
|
-
'Usage: node single-story-confirm-merge.js --story <STORY_ID> [--pr <n>] [--wait] [--cwd <main-repo>]',
|
|
280
|
-
);
|
|
327
|
+
throw new Error(USAGE);
|
|
281
328
|
}
|
|
282
329
|
const wait = waitParam ?? readWaitFlag();
|
|
330
|
+
const maxWaitSeconds = maxWaitSecondsParam ?? readMaxWaitSecondsFlag();
|
|
283
331
|
|
|
284
332
|
const startedAtMs = Date.now();
|
|
285
333
|
const config = injectedConfig || resolveConfig({ cwd });
|
|
@@ -346,6 +394,10 @@ export async function runConfirmMerge({
|
|
|
346
394
|
// The close already armed it; this CLI is resuming that wait, not
|
|
347
395
|
// deciding whether to arm.
|
|
348
396
|
autoMergeEnabled: true,
|
|
397
|
+
// The per-run override (`--max-wait-seconds`), resolved by
|
|
398
|
+
// `resolveMergeWaitConfig` exactly as the close resolves its own flag —
|
|
399
|
+
// it wins over the config value and the async probe-window cap.
|
|
400
|
+
maxWaitSeconds,
|
|
349
401
|
provider,
|
|
350
402
|
config,
|
|
351
403
|
progress,
|
|
@@ -450,6 +502,14 @@ export async function runConfirmMerge({
|
|
|
450
502
|
* or none at all; "none at all" is what Story #4543 removes.
|
|
451
503
|
*/
|
|
452
504
|
async function main() {
|
|
505
|
+
if (process.argv.includes('--help')) {
|
|
506
|
+
// Print usage (including --max-wait-seconds) and exit cleanly — the
|
|
507
|
+
// resume-path override is only discoverable if the CLI can say it exists.
|
|
508
|
+
// `process.stdout.write` (not console.log) keeps the CLI within the
|
|
509
|
+
// no-console repo invariant while still writing help to stdout.
|
|
510
|
+
process.stdout.write(`${USAGE}\n`);
|
|
511
|
+
return 0;
|
|
512
|
+
}
|
|
453
513
|
try {
|
|
454
514
|
const outcome = await runConfirmMerge();
|
|
455
515
|
return exitCodeForTerminal(outcome?.terminal ?? { status: 'failed' });
|
|
@@ -7,20 +7,24 @@ description:
|
|
|
7
7
|
|
|
8
8
|
# /deliver <storyId...>
|
|
9
9
|
|
|
10
|
+
> **Lean spine.** Happy path + gate list. Sequencing edge cases, dispatch
|
|
11
|
+
> mechanics, lite-route inline execution, checklist threading, ceremony, and
|
|
12
|
+
> the per-run epilogue live in the on-demand
|
|
13
|
+
> [`helpers/deliver-reference.md`](helpers/deliver-reference.md).
|
|
14
|
+
|
|
10
15
|
## Role
|
|
11
16
|
|
|
12
|
-
Single delivery path
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
merges.
|
|
17
|
+
Single delivery path, single input shape: **a list of Story ids**. `/deliver`
|
|
18
|
+
owns input resolution and sequencing only — every Story runs through
|
|
19
|
+
[`helpers/deliver-story.md`](helpers/deliver-story.md). No Epic wave loop, no
|
|
20
|
+
`epic/<id>` integration branch, no `--no-ff` wave merges.
|
|
17
21
|
|
|
18
22
|
The dependency graph is **discovered, not declared**: `resolve-stories.js`
|
|
19
|
-
reads it from live state (body edges ∪ native GitHub `blocked_by` edges,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
reads it from live state (body edges ∪ native GitHub `blocked_by` edges, every
|
|
24
|
+
blocker resolved against its real issue state). You never hand it a graph, and
|
|
25
|
+
there is no batch label — which is what lets you deliver Stories **across plan
|
|
26
|
+
runs and over time**. The `plan-run::<id>` grouping label is filter metadata
|
|
27
|
+
only — never a resolution input (there is no `--run` or `--dep` axis).
|
|
24
28
|
|
|
25
29
|
## Inputs
|
|
26
30
|
|
|
@@ -29,55 +33,39 @@ weeks ago in a different run is simply ready.
|
|
|
29
33
|
| `/deliver <storyId>` | Deliver one Story via `helpers/deliver-story.md`. |
|
|
30
34
|
| `/deliver <storyId> <storyId> ...` | Resolve the set with `resolve-stories.js`, then sequence by the discovered graph via `stories-wave-tick.js`. Default concurrency is **3**. |
|
|
31
35
|
|
|
32
|
-
Any named ticket that is not `type::story`, or
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
silently dropping the offending id and under-delivering.
|
|
36
|
-
|
|
37
|
-
> **No batch identity (Story #4540).** There is no `--run`, `plan-run::<id>`,
|
|
38
|
-
> or `--dep` axis: ordering lives in the dependency edges, so delivering the
|
|
39
|
-
> ids resolves the graph itself.
|
|
36
|
+
Any named ticket that is not `type::story`, or still carrying an `Epic: #N`
|
|
37
|
+
footer, is a **hard error** naming the id and the fix (close or re-plan as a v2
|
|
38
|
+
Story). Resolution refuses the whole set rather than silently under-delivering.
|
|
40
39
|
|
|
41
40
|
## Flags
|
|
42
41
|
|
|
43
42
|
| Flag | Meaning |
|
|
44
43
|
| --- | --- |
|
|
45
|
-
| `--concurrency <n>` | **Optional** per-run override of the
|
|
44
|
+
| `--concurrency <n>` | **Optional** per-run override of the fan-out cap. Omit it to honor `delivery.deliverRunner.concurrencyCap` (config default **3**, including any `.agentrc.local.json` override); pass it **only** for a one-run cap. `1` = sequential. |
|
|
46
45
|
| `--yes` | Suppress the multi-Story confirmation gate. |
|
|
47
46
|
| `--steal` | Forwarded to `single-story-init.js` / lease steal. |
|
|
48
|
-
| `--wait-merge` | Force close-and-land (the default; `delivery.routing.closeAndLand
|
|
49
|
-
| `--no-wait-merge` | Opt out
|
|
47
|
+
| `--wait-merge` | Force close-and-land (the default; `delivery.routing.closeAndLand`). |
|
|
48
|
+
| `--no-wait-merge` | Opt out; stop at `agent::closing` for a human land. |
|
|
50
49
|
|
|
51
50
|
**Operator-merge implies no-wait.** `--no-auto-merge` and
|
|
52
|
-
`delivery.ci.autoMerge: "strict"`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
blocks, because that is a fault to report rather than an operator decision
|
|
58
|
-
to respect.
|
|
51
|
+
`delivery.ci.autoMerge: "strict"` leave the PR un-armed: the Story rests at
|
|
52
|
+
`agent::closing` for the human merge and is **not** flipped to `agent::blocked`
|
|
53
|
+
(`--wait-merge` does not override this). A genuine *arm failure* differs — it
|
|
54
|
+
still waits and still blocks, because that is a fault to report, not an operator
|
|
55
|
+
decision to respect.
|
|
59
56
|
|
|
60
57
|
## Procedure
|
|
61
58
|
|
|
62
59
|
1. **Resolve the set.** One command, for one Story or many:
|
|
60
|
+
`node .agents/scripts/resolve-stories.js --ids <id,id,...>`. It validates
|
|
61
|
+
the set and shows what will run: read `stories[]`, `dag[]`, and `done[]` to
|
|
62
|
+
present the order in step 2. You do **not** thread them into step 3 — the
|
|
63
|
+
tick re-resolves the graph itself every beat. Resolution hard-errors
|
|
64
|
+
(exit 1) on a named id that is not a Story, carries an `Epic: #N` footer, or
|
|
65
|
+
whose native edges cannot be read — a missing gate would co-dispatch a Story
|
|
66
|
+
against an unlanded blocker.
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
node .agents/scripts/resolve-stories.js --ids <id,id,...>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
This validates the set and shows the operator what will run: read
|
|
69
|
-
`stories[]`, `dag[]`, and `done[]` to present the order in step 2. You do
|
|
70
|
-
**not** thread them into step 3 — the tick re-resolves the graph itself
|
|
71
|
-
from the same machinery, every beat. Do **not** rebuild the graph by hand;
|
|
72
|
-
it is discovered from live state, including edges a body does not spell
|
|
73
|
-
out and blockers outside the delivered set.
|
|
74
|
-
|
|
75
|
-
Resolution hard-errors (exit 1) on a named id that is not a Story, still
|
|
76
|
-
carries an `Epic: #N` footer, or whose native dependency edges cannot be
|
|
77
|
-
read. A failed edge read is fatal by design: a missing gate would
|
|
78
|
-
co-dispatch a Story against an unlanded blocker.
|
|
79
|
-
|
|
80
|
-
2. **Confirm (N>1).** Present the order and wait unless `--yes`.
|
|
68
|
+
2. **Confirm (N>1).** Present the order; wait unless `--yes`.
|
|
81
69
|
|
|
82
70
|
3. **Sequence.** Loop until the tick reports `epilogueDue: true`:
|
|
83
71
|
|
|
@@ -88,218 +76,86 @@ to respect.
|
|
|
88
76
|
```
|
|
89
77
|
|
|
90
78
|
**Do not add `--concurrency` unless the operator explicitly asked for a
|
|
91
|
-
per-run cap.** Omitting it
|
|
79
|
+
per-run cap.** Omitting it lets the tick resolve the cap from
|
|
92
80
|
`delivery.deliverRunner.concurrencyCap` — including a `.agentrc.local.json`
|
|
93
|
-
override. An explicit `--concurrency <n>` wins over config for that run
|
|
94
|
-
(`
|
|
95
|
-
filling in a literal — e.g. the documented default `3` — silently defeats
|
|
96
|
-
the operator's configured override. Thread `--concurrency` through here
|
|
97
|
-
only when it was passed to `/deliver`.
|
|
98
|
-
|
|
99
|
-
Each beat re-probes live state: it re-resolves the graph, classifies done
|
|
100
|
-
(`agent::done` or a closed issue — including foreign blockers that landed
|
|
101
|
-
in another run), and derives in-flight from live `agent::executing` /
|
|
102
|
-
`agent::closing` labels. You never compute `done` or `in-flight` — that
|
|
103
|
-
accounting is read from reality every beat (Story #4594).
|
|
81
|
+
override. An explicit `--concurrency <n>` wins over config for that run, so a
|
|
82
|
+
filled-in literal (e.g. `3`) silently defeats the operator's override.
|
|
104
83
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
it back and a second sub-agent would join the first on the same branch and
|
|
113
|
-
worktree, interleaving commits. `--dispatched` closes that residual
|
|
114
|
-
same-run window.
|
|
115
|
-
|
|
116
|
-
**Cross-run de-confliction is automatic (Story #4620).** A Story another
|
|
117
|
-
operator is delivering is withheld without any bookkeeping from you: the
|
|
118
|
-
probe reads the Story's assignee lease and, when it belongs to a different
|
|
119
|
-
operator, withholds the Story and reports it in the envelope's
|
|
120
|
-
`foreignHeld: [{ id, holder }]` (with `foreignHeldReason`). That is not a
|
|
121
|
-
failure or a wedge — the holder's run owns the branch, and this run picks
|
|
122
|
-
the Story up automatically once their lease clears. Init is the backstop:
|
|
123
|
-
it refuses a Story already labelled `agent::executing`, or one whose lease a
|
|
124
|
-
different operator holds, unless you pass `--steal`. Assignee-based
|
|
125
|
-
withholding needs `github.operatorHandle` set (in `.agentrc.local.json`);
|
|
126
|
-
without it the probe logs a warning and leans on init's lease refusal alone.
|
|
127
|
-
|
|
128
|
-
The rule is **append-only: add each id as you dispatch it and never remove
|
|
129
|
-
one.** The flag is additive, not authoritative — the probe unions it into
|
|
130
|
-
the label-derived set and then filters it against live state, so an id that
|
|
131
|
-
has since gone `agent::done` is dropped for you. Re-listing an id costs
|
|
132
|
-
nothing and cannot double-count a slot; *omitting* one is the only way to
|
|
133
|
-
get this wrong. This is why `--dispatched` is not the `--done` bookkeeping
|
|
134
|
-
#4594 retired, and why `--in-flight` remains rejected under `--probe-live`.
|
|
84
|
+
Each beat re-probes live state to derive done / in-flight itself; you never
|
|
85
|
+
compute them (Story #4594). `--dispatched` is the one thing you must supply —
|
|
86
|
+
the append-only list of every id you spawned this run — and cross-run
|
|
87
|
+
de-confliction via the assignee lease is automatic
|
|
88
|
+
([`helpers/deliver-reference.md` § Sequencing edge cases](helpers/deliver-reference.md);
|
|
89
|
+
[§ Dispatch mechanics](helpers/deliver-reference.md) covers role-scoped
|
|
90
|
+
spawn, lite-route execution, and `checklistPath`).
|
|
135
91
|
|
|
136
92
|
Branch on the exit code:
|
|
137
|
-
- **0** — dispatch each `ready` id (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
A blocked Story outranks a wedge (its blockers are moot while a human
|
|
161
|
-
owes a decision) but not a cycle (exit 2 — fix the graph first).
|
|
162
|
-
|
|
163
|
-
**Dispatch each `ready` Story (role-scoped by default).** When
|
|
164
|
-
`delivery.routing.roleScopedAgents` is enabled (the **default**) and the
|
|
165
|
-
host exposes agent dispatch, spawn each ready Story as its own
|
|
166
|
-
`subagent_type: story-worker` sub-agent — it boots on the role-scoped
|
|
167
|
-
[`story-worker`](../agents/story-worker.md) context (its own system prompt,
|
|
168
|
-
no `CLAUDE.md` @-closure) carrying the load-bearing delivery MUSTs
|
|
169
|
-
standalone. The sub-agent executes
|
|
170
|
-
[`helpers/deliver-story.md`](helpers/deliver-story.md) end to end
|
|
171
|
-
(init → implement → acceptance self-eval → close-and-land). Thread into its
|
|
172
|
-
prompt:
|
|
173
|
-
- `storyId` — the id to deliver.
|
|
174
|
-
- `docsDigestPath` — the per-run docs digest (digest-first reading,
|
|
175
|
-
[`instructions.md` § 3](../instructions.md)); null when
|
|
176
|
-
`project.docsContextFiles` is unset.
|
|
177
|
-
- `checklistPath` — the footprint-matched write-time audit checklist,
|
|
178
|
-
produced at dispatch (below).
|
|
179
|
-
- the **change-set discipline** — the worker computes the change set once
|
|
180
|
-
with `computeChangeSet` and hands that one list to every acceptance critic
|
|
181
|
-
(Story #4593); it never lets a critic re-derive the diff.
|
|
182
|
-
|
|
183
|
-
**Produce `checklistPath` before the spawn (Story #4627).** Compute the
|
|
184
|
-
payload from the Story's predicted footprint (its `changes[]` /
|
|
185
|
-
`references[]` path entries) with `buildDispatchChecklist` and write it to
|
|
186
|
-
the run temp dir, then thread the resulting path (empty when nothing
|
|
187
|
-
matched):
|
|
188
|
-
|
|
189
|
-
```bash
|
|
190
|
-
node --input-type=module -e '
|
|
191
|
-
import { buildDispatchChecklist } from "<main-repo>/.agents/scripts/lib/audit-suite/index.js";
|
|
192
|
-
import { parse } from "<main-repo>/.agents/scripts/lib/story-body/story-body.js";
|
|
193
|
-
// storyBody is the fetched Story issue body.
|
|
194
|
-
const { changes, references } = parse(process.env.STORY_BODY);
|
|
195
|
-
const { checklistPath } = buildDispatchChecklist({
|
|
196
|
-
storyId: <storyId>, changes, references, runTempDir: "temp/run-<id>",
|
|
197
|
-
});
|
|
198
|
-
console.log(checklistPath ?? "");
|
|
199
|
-
'
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
`buildDispatchChecklist` (`lib/audit-suite/dispatch-checklist.js`) is a pure
|
|
203
|
-
function of the footprint and the on-disk checklists; an empty match prints
|
|
204
|
-
nothing and the worker runs with no write-time checklist — the maker-blind
|
|
205
|
-
close-scope pass still covers it.
|
|
206
|
-
|
|
207
|
-
**Inline fallback (`roleScopedAgents: false` / no-nesting harness).** When
|
|
208
|
-
the kill-switch is off, or the host cannot spawn a sub-agent at this nesting
|
|
209
|
-
depth, do **not** stall: read
|
|
210
|
-
[`helpers/deliver-story.md`](helpers/deliver-story.md) **in full** and
|
|
211
|
-
execute it directly, in this turn, threading the same `docsDigestPath` /
|
|
212
|
-
`checklistPath` / change-set discipline. Under `--yes` / injected helper
|
|
213
|
-
content, execute directly without a re-read turn. The engine, gates, and
|
|
214
|
-
terminal envelope are identical either way — only the isolation differs.
|
|
215
|
-
|
|
216
|
-
4. **Per-run epilogue (N>1).** Once step 3 reports `epilogueDue: true`
|
|
217
|
-
(every Story done), keyed on the delivered id set:
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
node .agents/scripts/plan-run-epilogue.js --stories 101,102
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
This executes, in order:
|
|
224
|
-
- `audit-roster` — selects cross-Story audit lenses over the combined
|
|
225
|
-
landed tip and posts `plan-run-audit-roster` on the primary Story;
|
|
226
|
-
the host MUST walk each listed lens against the combined diff
|
|
227
|
-
- `follow-up-rollup` — friction follow-ups across every Story in the
|
|
228
|
-
run (files issues when auto-file is on; posts `follow-ups`)
|
|
229
|
-
- `sibling-coherence` — Spec/Acceptance coherence check across sibling
|
|
230
|
-
bodies (`plan-run-sibling-coherence`)
|
|
231
|
-
|
|
232
|
-
A single-Story run skips the epilogue — follow-ups are captured on
|
|
233
|
-
merge confirm instead (`captureStoryFollowUps`).
|
|
93
|
+
- **0** — dispatch each `ready` id (already capped and overlap-free). Empty
|
|
94
|
+
`ready` with work in flight means "waiting"; keep looping.
|
|
95
|
+
`epilogueDue: true` means every Story is done — go to step 4.
|
|
96
|
+
- **2** — `cycleError`: the graph is self-referential. Fix the `depends_on`
|
|
97
|
+
declarations; do not retry.
|
|
98
|
+
- **3** — `wedged`: nothing dispatchable, nothing in flight, undone Stories
|
|
99
|
+
waiting on blockers that are not done. The envelope names the stuck ids and
|
|
100
|
+
unmet blockers. Land the blocker or include it in `--ids`; do not retry
|
|
101
|
+
unchanged.
|
|
102
|
+
- **4** — `blocked`: a Story carries `agent::blocked`, named in `blocked[]`
|
|
103
|
+
with `blockedReason` — the protocol's HITL pause
|
|
104
|
+
([`instructions.md` § 1.J](../instructions.md)). **Stop the loop and
|
|
105
|
+
surface it; do not poll.** Read the friction comment
|
|
106
|
+
(`gh issue view <id> --comments`) and resume only once the operator
|
|
107
|
+
unblocks it (`update-ticket-state.js --ticket <id> --state agent::ready`).
|
|
108
|
+
A blocked Story outranks a wedge but not a cycle (fix the graph first).
|
|
109
|
+
|
|
110
|
+
4. **Per-run epilogue (N>1).** Once step 3 reports `epilogueDue: true`, run
|
|
111
|
+
`node .agents/scripts/plan-run-epilogue.js --stories 101,102` — audit
|
|
112
|
+
roster, follow-up roll-up, sibling coherence. A single-Story run skips it.
|
|
113
|
+
Detail:
|
|
114
|
+
[`helpers/deliver-reference.md` § Per-run epilogue](helpers/deliver-reference.md).
|
|
234
115
|
|
|
235
116
|
## Branch model (authoritative)
|
|
236
117
|
|
|
237
|
-
Every Story:
|
|
238
|
-
|
|
239
118
|
```text
|
|
240
119
|
story-<id> → PR → main (squash + required checks)
|
|
241
120
|
```
|
|
242
121
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
Ceremony depth is selected by `delivery.routing.ceremonyProfile`
|
|
250
|
-
(`minimal` | `standard` | `strict`, default `standard`) and the **change
|
|
251
|
-
level derived from the Story's own diff** — the changed files' intersection
|
|
252
|
-
with the sensitive-path classes in `audit-rules.json`
|
|
253
|
-
(`review-depth.js#deriveChangeLevel`), not a planner-authored verdict
|
|
254
|
-
(Story #4542):
|
|
255
|
-
|
|
256
|
-
| Profile | Acceptance critic | When to use |
|
|
257
|
-
| --- | --- | --- |
|
|
258
|
-
| `minimal` | Always inline | Tiny trusted N=1 Stories |
|
|
259
|
-
| `standard` | Derived-level routed (+ sampling floor) | Default |
|
|
260
|
-
| `strict` | Always fresh-context | High-assurance / regulated surfaces |
|
|
261
|
-
|
|
262
|
-
| Scope | What runs | Mechanism |
|
|
263
|
-
| --- | --- | --- |
|
|
264
|
-
| **Per-Story (always)** | Gates, branch discipline, close-and-land | `deliver-story` / `single-story-close` |
|
|
265
|
-
| **Per-Story (profile + derived level)** | Acceptance critic mode; review depth | `ceremony-routing.js` + `review-depth.js` + `code-review.js` |
|
|
266
|
-
| **Per-run (N>1)** | Audit roster · follow-up roll-up · sibling coherence | `plan-run-epilogue.js` once at run end |
|
|
267
|
-
| **Per-Story land tail** | Follow-up capture · status resync · ref cleanup · base fast-forward | `single-story-close/phases/post-land.js` (in-process, per-step reported) |
|
|
122
|
+
No `epic/<id>` integration branch and no `--no-ff` wave merge. Dependent
|
|
123
|
+
Stories land sequentially so each builds on the previous merge to `main`.
|
|
124
|
+
Ceremony depth (profiles + derived level via `ceremony-routing.js`,
|
|
125
|
+
review depth reading the same level) and the mechanism table:
|
|
126
|
+
[`helpers/deliver-reference.md` § Ceremony](helpers/deliver-reference.md).
|
|
268
127
|
|
|
269
128
|
## Reading a Story's outcome
|
|
270
129
|
|
|
271
130
|
Each Story's delivery ends in exactly one schema-validated terminal envelope
|
|
272
131
|
([`story-deliver-terminal.schema.json`](../schemas/story-deliver-terminal.schema.json),
|
|
273
|
-
Story #4543) — `landed` | `pending` | `blocked` | `failed
|
|
274
|
-
|
|
132
|
+
Story #4543) — `landed` | `pending` | `blocked` | `failed`, the SSOT for the
|
|
133
|
+
shape; this workflow does not restate its fields.
|
|
275
134
|
|
|
276
135
|
`pending` is **not** a failure: the bounded merge wait expired with the PR
|
|
277
|
-
healthy
|
|
278
|
-
|
|
279
|
-
|
|
136
|
+
healthy (or a human owns the merge), nothing was mutated, and the
|
|
137
|
+
`nextCommand` resumes it — run that rather than re-dispatching. The slow-CI
|
|
138
|
+
`async` mode (Story #4698) returns `pending` by design — launch its
|
|
139
|
+
`nextCommand` as a background invocation (reference appendix).
|
|
280
140
|
|
|
281
141
|
For a Story in an unclear state — including the merged-but-label-stale one a
|
|
282
|
-
`/deliver` re-run refuses outright — probe it read-only
|
|
283
|
-
|
|
284
|
-
```bash
|
|
285
|
-
node .agents/scripts/deliver-recover.js --story <storyId>
|
|
286
|
-
```
|
|
142
|
+
`/deliver` re-run refuses outright — probe it read-only with
|
|
143
|
+
`node .agents/scripts/deliver-recover.js --story <storyId>`.
|
|
287
144
|
|
|
288
145
|
## Constraints
|
|
289
146
|
|
|
290
147
|
- **Land or block — never a silent local build.** Worktrees, `story-<id>`
|
|
291
|
-
branches, close-validation, and PR-to-`main` are the only sanctioned
|
|
292
|
-
|
|
293
|
-
(`delivery.routing.closeAndLand: true`); use `--no-wait-merge` only when
|
|
294
|
-
|
|
295
|
-
- `/deliver` never plans — tickets come from [`/plan`](plan.md).
|
|
296
|
-
|
|
297
|
-
script invocation per Story.
|
|
148
|
+
branches, close-validation, and PR-to-`main` are the only sanctioned delivery
|
|
149
|
+
mechanism. Attended delivers default to close-and-land
|
|
150
|
+
(`delivery.routing.closeAndLand: true`); use `--no-wait-merge` only when a
|
|
151
|
+
human lands the PR.
|
|
152
|
+
- `/deliver` never plans — tickets come from [`/plan`](plan.md). The router
|
|
153
|
+
performs no git/label mutations; `deliver-story` owns every script.
|
|
298
154
|
|
|
299
155
|
## See also
|
|
300
156
|
|
|
301
157
|
- [`/plan`](plan.md) — unified planning entry point.
|
|
302
158
|
- [`helpers/deliver-story.md`](helpers/deliver-story.md) — the one Story
|
|
303
159
|
delivery engine.
|
|
304
|
-
-
|
|
305
|
-
|
|
160
|
+
- [`helpers/deliver-reference.md`](helpers/deliver-reference.md) — sequencing,
|
|
161
|
+
dispatch, ceremony, and epilogue detail.
|