@ai-dossier/sched 0.2.1 → 0.3.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/dist/status.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  /**
3
- * `sched status` report (AC4): queue, slots, batches, and the blocked/failed
4
- * sets as a machine-readable report. Text rendering lives in the CLI
5
- * (`cli/src/commands/sched.ts`, on top of the CLI's shared `renderTable`) —
6
- * the package deliberately has no dependency on CLI utilities.
3
+ * `sched status` report (AC4): queue, slots, batches, parked PRs, and the
4
+ * blocked/failed sets as a machine-readable report. Text rendering lives in
5
+ * the CLI (`cli/src/commands/sched.ts`, on top of the CLI's shared
6
+ * `renderTable`) — the package deliberately has no dependency on CLI
7
+ * utilities.
7
8
  */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.buildStatusReport = buildStatusReport;
@@ -59,6 +60,9 @@ function buildStatusReport(state, config, project) {
59
60
  }
60
61
  }
61
62
  const units = state.paused ? [] : (0, readiness_1.runnableUnits)(state);
63
+ const parked = state.entries
64
+ .filter((e) => e.status === 'parked' && e.pr !== null)
65
+ .map((e) => ({ issue: e.issue, pr: e.pr, since: e.updated_at }));
62
66
  return {
63
67
  project,
64
68
  paused: state.paused,
@@ -67,6 +71,8 @@ function buildStatusReport(state, config, project) {
67
71
  queue: state.entries,
68
72
  slots: state.slots,
69
73
  batches: state.batches,
74
+ parked,
75
+ last_pr_poll_at: state.last_pr_poll_at,
70
76
  runnable: units.length,
71
77
  runnable_units: units.map((u) => u.kind === 'issue' ? `issue:${u.issue}` : `batch:${u.batch}`),
72
78
  blocked,
@@ -1 +1 @@
1
- {"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAoCH,8CA4EC;AA9GD,2CAKqB;AAErB,mCAAgG;AA2BhG,SAAgB,iBAAiB,CAC/B,KAAiB,EACjB,MAAmB,EACnB,OAAe;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AAK;QAClB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM;QACN,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,QAAQ,EAAE,KAAK,CAAC,MAAM;QACtB,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9B,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,CAC7D;QACD,OAAO;QACP,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Script-based teardown for merged units (#468 AC2) — the tail work that the
3
+ * fleet pattern used to re-dispatch a whole full-cycle run for.
4
+ *
5
+ * Two scripts, chosen by the run's `setup` milestone:
6
+ * - pool-claimed worktree → `worktree-pool return --path <wt> --json` — the
7
+ * pool's own self-check (#453: `verification.entry_status`) is the
8
+ * verification; a non-`warm` entry or a failed exit is a failed step.
9
+ * - cold worktree → `git worktree remove --force <wt>` + a path-gone check
10
+ * (verify-first, so a re-run after a crash between subprocess and state
11
+ * write is idempotent).
12
+ *
13
+ * `--force` on the remove is deliberate: the WIP-sync rule pushes everything
14
+ * durable to origin, so untracked leftovers (logs, warmup status) are trash.
15
+ *
16
+ * A failed teardown is DEGRADATION, never unit failure — the PR is already
17
+ * merged. The outcome is recorded as `cleanup=failed-<step>` on the entry and
18
+ * journaled, and the report agent is dispatched regardless so the failure is
19
+ * surfaced in the report.
20
+ *
21
+ * Everything runs through an injectable `ExecFn` (the project.ts pattern) —
22
+ * tests script the subprocesses, no real pool or git is touched.
23
+ */
24
+ import type { SetupInfo } from './groundtruth';
25
+ import type { ExecFn } from './project';
26
+ import type { CleanupStatus } from './types';
27
+ /** Timeout for teardown subprocesses — pool return shells out through npx and recycles a worktree (git ops), which is slow. */
28
+ export declare const TEARDOWN_TIMEOUT_MS = 120000;
29
+ /** The outcome recorded on the entry's `cleanup` and in the journal. */
30
+ export interface TeardownResult {
31
+ /** `done` or `failed-<step>` — the entry's `cleanup` value verbatim. */
32
+ cleanup: CleanupStatus;
33
+ /** Human-readable detail for the journal (empty when none). */
34
+ detail: string;
35
+ }
36
+ /** Whether a path exists (injectable so tests need no filesystem). */
37
+ export type FsExists = (p: string) => boolean;
38
+ /**
39
+ * Containment check for a worktree path recovered from an issue comment
40
+ * (#468): the path must be absolute and fully resolved (no `..`/`.`/symlink
41
+ * variance), and — for COLD worktrees — live under one of the two worktree
42
+ * roots this project uses: `<repo>/worktrees/` (setup-issue-workflow's
43
+ * inside-repo convention) or `<repo>/../worktrees/` (the AGENTS.md sibling
44
+ * convention). A crafted milestone can otherwise make the scheduler
45
+ * `git worktree remove --force` ANY registered worktree — including a
46
+ * parallel agent's (CWE-22). Pool-claimed worktrees are validated by the
47
+ * pool itself (return only accepts paths in pool state), so containment
48
+ * applies to the cold path only.
49
+ */
50
+ export declare function isSafeWorktree(repoRoot: string, worktree: string): boolean;
51
+ /**
52
+ * Run the teardown script for one merged unit. `info` comes from the unit's
53
+ * setup milestone (groundtruth.setupInfo); a missing `info` is the caller's
54
+ * `failed-missing-setup-info` case — this function always has one.
55
+ */
56
+ export declare function runTeardown(exec: ExecFn, repoDir: string, info: SetupInfo, fsExists?: FsExists): TeardownResult;
57
+ //# sourceMappingURL=teardown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teardown.d.ts","sourceRoot":"","sources":["../src/teardown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,+HAA+H;AAC/H,eAAO,MAAM,mBAAmB,SAAU,CAAC;AAY3C,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,OAAO,EAAE,aAAa,CAAC;IACvB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sEAAsE;AACtE,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAM1E;AAsBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,EACf,QAAQ,GAAE,QAMT,GACA,cAAc,CAsBhB"}
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ /**
3
+ * Script-based teardown for merged units (#468 AC2) — the tail work that the
4
+ * fleet pattern used to re-dispatch a whole full-cycle run for.
5
+ *
6
+ * Two scripts, chosen by the run's `setup` milestone:
7
+ * - pool-claimed worktree → `worktree-pool return --path <wt> --json` — the
8
+ * pool's own self-check (#453: `verification.entry_status`) is the
9
+ * verification; a non-`warm` entry or a failed exit is a failed step.
10
+ * - cold worktree → `git worktree remove --force <wt>` + a path-gone check
11
+ * (verify-first, so a re-run after a crash between subprocess and state
12
+ * write is idempotent).
13
+ *
14
+ * `--force` on the remove is deliberate: the WIP-sync rule pushes everything
15
+ * durable to origin, so untracked leftovers (logs, warmup status) are trash.
16
+ *
17
+ * A failed teardown is DEGRADATION, never unit failure — the PR is already
18
+ * merged. The outcome is recorded as `cleanup=failed-<step>` on the entry and
19
+ * journaled, and the report agent is dispatched regardless so the failure is
20
+ * surfaced in the report.
21
+ *
22
+ * Everything runs through an injectable `ExecFn` (the project.ts pattern) —
23
+ * tests script the subprocesses, no real pool or git is touched.
24
+ */
25
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ var desc = Object.getOwnPropertyDescriptor(m, k);
28
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
29
+ desc = { enumerable: true, get: function() { return m[k]; } };
30
+ }
31
+ Object.defineProperty(o, k2, desc);
32
+ }) : (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ o[k2] = m[k];
35
+ }));
36
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
37
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
38
+ }) : function(o, v) {
39
+ o["default"] = v;
40
+ });
41
+ var __importStar = (this && this.__importStar) || (function () {
42
+ var ownKeys = function(o) {
43
+ ownKeys = Object.getOwnPropertyNames || function (o) {
44
+ var ar = [];
45
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
46
+ return ar;
47
+ };
48
+ return ownKeys(o);
49
+ };
50
+ return function (mod) {
51
+ if (mod && mod.__esModule) return mod;
52
+ var result = {};
53
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
54
+ __setModuleDefault(result, mod);
55
+ return result;
56
+ };
57
+ })();
58
+ Object.defineProperty(exports, "__esModule", { value: true });
59
+ exports.TEARDOWN_TIMEOUT_MS = void 0;
60
+ exports.isSafeWorktree = isSafeWorktree;
61
+ exports.runTeardown = runTeardown;
62
+ const fs = __importStar(require("node:fs"));
63
+ const path = __importStar(require("node:path"));
64
+ /** Timeout for teardown subprocesses — pool return shells out through npx and recycles a worktree (git ops), which is slow. */
65
+ exports.TEARDOWN_TIMEOUT_MS = 120_000;
66
+ /**
67
+ * Pool CLI invocation. Requires ≥0.6.0 — `status --json`, `return --json`,
68
+ * and the `verification.entry_status` self-check (#453) all landed there, so
69
+ * `^0.5.1` (which resolves to ≤0.5.3) cannot ever satisfy the JSON contract
70
+ * and every pool teardown would record `failed-pool-return`. Versions ≤0.5.0
71
+ * additionally carry the data-loss `gc` bug — never pin lower.
72
+ */
73
+ const POOL_BIN = 'npx';
74
+ const POOL_ARGS_PREFIX = ['-y', '@ai-dossier/worktree-pool@^0.6.0'];
75
+ /**
76
+ * Containment check for a worktree path recovered from an issue comment
77
+ * (#468): the path must be absolute and fully resolved (no `..`/`.`/symlink
78
+ * variance), and — for COLD worktrees — live under one of the two worktree
79
+ * roots this project uses: `<repo>/worktrees/` (setup-issue-workflow's
80
+ * inside-repo convention) or `<repo>/../worktrees/` (the AGENTS.md sibling
81
+ * convention). A crafted milestone can otherwise make the scheduler
82
+ * `git worktree remove --force` ANY registered worktree — including a
83
+ * parallel agent's (CWE-22). Pool-claimed worktrees are validated by the
84
+ * pool itself (return only accepts paths in pool state), so containment
85
+ * applies to the cold path only.
86
+ */
87
+ function isSafeWorktree(repoRoot, worktree) {
88
+ if (worktree.includes('\0'))
89
+ return false;
90
+ if (!path.isAbsolute(worktree))
91
+ return false;
92
+ if (path.resolve(worktree) !== worktree)
93
+ return false;
94
+ const roots = [path.resolve(repoRoot, 'worktrees'), path.resolve(repoRoot, '..', 'worktrees')];
95
+ return roots.some((root) => worktree.startsWith(root + path.sep));
96
+ }
97
+ /** The repo's toplevel directory (containment root), or null when git cannot say. */
98
+ function repoToplevel(exec, repoDir) {
99
+ const out = exec('git', ['rev-parse', '--show-toplevel'], repoDir);
100
+ return out !== null && path.isAbsolute(out) ? path.resolve(out) : null;
101
+ }
102
+ /** Path-listing of `git worktree list --porcelain` (null when the call fails). */
103
+ function worktreeList(exec, repoDir) {
104
+ return exec('git', ['worktree', 'list', '--porcelain'], repoDir);
105
+ }
106
+ /** Whether `worktree` still appears in git's worktree listing. */
107
+ function listedAsWorktree(exec, repoDir, worktree) {
108
+ const list = worktreeList(exec, repoDir);
109
+ if (list === null)
110
+ return true; // unknown — assume still present (conservative)
111
+ return list
112
+ .split('\n')
113
+ .some((line) => line.startsWith('worktree ') && line.slice('worktree '.length) === worktree);
114
+ }
115
+ /**
116
+ * Run the teardown script for one merged unit. `info` comes from the unit's
117
+ * setup milestone (groundtruth.setupInfo); a missing `info` is the caller's
118
+ * `failed-missing-setup-info` case — this function always has one.
119
+ */
120
+ function runTeardown(exec, repoDir, info, fsExists = (p) => {
121
+ try {
122
+ return fs.existsSync(p);
123
+ }
124
+ catch {
125
+ return false;
126
+ }
127
+ }) {
128
+ // The worktree path originates from an issue comment written by the spawned
129
+ // agent — validate it before any destructive subprocess (CWE-22).
130
+ if (info.worktree.includes('\0') || !path.isAbsolute(info.worktree)) {
131
+ return {
132
+ cleanup: 'failed-invalid-worktree',
133
+ detail: `worktree path rejected (must be absolute): ${info.worktree}`,
134
+ };
135
+ }
136
+ if (info.poolClaimed) {
137
+ // Pool membership is validated by the pool's own `return` (it only
138
+ // accepts paths in pool state) — no local containment root applies.
139
+ return poolReturn(exec, repoDir, info.worktree);
140
+ }
141
+ const root = repoToplevel(exec, repoDir) ?? path.resolve(repoDir);
142
+ if (!isSafeWorktree(root, info.worktree)) {
143
+ return {
144
+ cleanup: 'failed-invalid-worktree',
145
+ detail: `worktree path rejected (must be a resolved path under the repo's worktrees root ${path.join(root, 'worktrees')}): ${info.worktree}`,
146
+ };
147
+ }
148
+ return worktreeRemove(exec, repoDir, info.worktree, fsExists);
149
+ }
150
+ function poolReturn(exec, repoDir, worktree) {
151
+ // Verify-first idempotency: if the pool already lists this path as a warm
152
+ // (unassigned) spare, a previous return landed and the state write was
153
+ // lost — claim done rather than erroring a second return.
154
+ const statusJson = exec(POOL_BIN, [...POOL_ARGS_PREFIX, 'status', '--json'], repoDir);
155
+ if (statusJson !== null && poolEntryFor(statusJson, worktree) === 'warm') {
156
+ return { cleanup: 'done', detail: 'already returned to pool (idempotent re-run)' };
157
+ }
158
+ const out = exec(POOL_BIN, [...POOL_ARGS_PREFIX, 'return', '--path', worktree, '--json'], repoDir);
159
+ if (out === null) {
160
+ return {
161
+ cleanup: 'failed-pool-return',
162
+ detail: 'worktree-pool return failed (non-zero exit, timeout, or npx unavailable) — entry left unverified; inspect `worktree-pool status`',
163
+ };
164
+ }
165
+ // Verified before claimed: the pool's own self-check must report the
166
+ // recycled entry as `warm` — anything else is a failed step.
167
+ const entryStatus = parseReturnVerification(out);
168
+ if (entryStatus === null) {
169
+ return {
170
+ cleanup: 'failed-pool-return',
171
+ detail: 'worktree-pool return produced unparseable output',
172
+ };
173
+ }
174
+ if (entryStatus !== 'warm') {
175
+ return {
176
+ cleanup: 'failed-pool-return',
177
+ detail: `pool self-check reports entry_status=${entryStatus}`,
178
+ };
179
+ }
180
+ return { cleanup: 'done', detail: 'returned to pool as a warm spare' };
181
+ }
182
+ function worktreeRemove(exec, repoDir, worktree, fsExists) {
183
+ // Verify-first idempotency: already gone → a previous remove landed.
184
+ if (!fsExists(worktree) && !listedAsWorktree(exec, repoDir, worktree)) {
185
+ return { cleanup: 'done', detail: 'worktree already removed (idempotent re-run)' };
186
+ }
187
+ const out = exec('git', ['worktree', 'remove', '--force', '--', worktree], repoDir);
188
+ if (out === null) {
189
+ return {
190
+ cleanup: 'failed-worktree-remove',
191
+ detail: 'git worktree remove failed (non-zero exit or timeout)',
192
+ };
193
+ }
194
+ // Verified before claimed: the path must be gone AND git must no longer
195
+ // list it — a lingering entry means the removal did not fully land.
196
+ if (fsExists(worktree) || listedAsWorktree(exec, repoDir, worktree)) {
197
+ return {
198
+ cleanup: 'failed-worktree-remove',
199
+ detail: 'worktree still present after git worktree remove',
200
+ };
201
+ }
202
+ return { cleanup: 'done', detail: 'worktree removed' };
203
+ }
204
+ /** The pool entry status (`warm`/`assigned`/…) for `worktree`, or null when absent/unparseable. */
205
+ function poolEntryFor(statusJson, worktree) {
206
+ try {
207
+ const parsed = JSON.parse(statusJson);
208
+ if (parsed === null || typeof parsed !== 'object')
209
+ return null;
210
+ const worktrees = parsed.worktrees;
211
+ if (!Array.isArray(worktrees))
212
+ return null;
213
+ for (const raw of worktrees) {
214
+ if (raw === null || typeof raw !== 'object')
215
+ continue;
216
+ const entry = raw;
217
+ if (entry.path === worktree && typeof entry.status === 'string')
218
+ return entry.status;
219
+ }
220
+ return null;
221
+ }
222
+ catch {
223
+ return null;
224
+ }
225
+ }
226
+ /** `verification.entry_status` of a successful `return --json`, or null when unparseable. */
227
+ function parseReturnVerification(returnJson) {
228
+ try {
229
+ const parsed = JSON.parse(returnJson);
230
+ if (parsed === null || typeof parsed !== 'object')
231
+ return null;
232
+ const verification = parsed.verification;
233
+ if (verification === null || typeof verification !== 'object')
234
+ return null;
235
+ const status = verification.entry_status;
236
+ return typeof status === 'string' ? status : null;
237
+ }
238
+ catch {
239
+ return null;
240
+ }
241
+ }
242
+ //# sourceMappingURL=teardown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"teardown.js","sourceRoot":"","sources":["../src/teardown.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CH,wCAMC;AA2BD,kCAiCC;AA5GD,4CAA8B;AAC9B,gDAAkC;AAKlC,+HAA+H;AAClH,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,kCAAkC,CAAC,CAAC;AAapE;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAAC,QAAgB,EAAE,QAAgB;IAC/D,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAA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CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,SAAS,uBAAuB,CAAC,UAAkB;IACjD,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC/D,MAAM,YAAY,GAAI,MAAqC,CAAC,YAAY,CAAC;QACzE,IAAI,YAAY,KAAK,IAAI,IAAI,OAAO,YAAY,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3E,MAAM,MAAM,GAAI,YAA2C,CAAC,YAAY,CAAC;QACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/types.d.ts CHANGED
@@ -17,6 +17,8 @@ export type ModelTier = 'mechanical' | 'mid' | 'strong';
17
17
  * ```
18
18
  * queued → classified{full|slot}
19
19
  * full: → dispatched → (full-cycle's own phase trail) → shipped → done
20
+ * #468 detached ship: dispatched → parked{pr} (PR on auto-merge;
21
+ * the watcher owns the merge wait) → shipped → done
20
22
  * slot: → batched(b) → waiting → in-work → committed(range) → validated
21
23
  * → shipped-in-batch → done
22
24
  * failure edges (any state):
@@ -24,7 +26,7 @@ export type ModelTier = 'mechanical' | 'mid' | 'strong';
24
26
  * any → blocked(dep-failed) | decision-pending | failed(escalation-cap)
25
27
  * ```
26
28
  */
27
- export type IssueStatus = 'queued' | 'classified' | 'dispatched' | 'shipped' | 'done' | 'batched' | 'waiting' | 'in-work' | 'committed' | 'validated' | 'shipped-in-batch' | 'evicted' | 'requeued' | 'blocked' | 'decision-pending' | 'failed';
29
+ export type IssueStatus = 'queued' | 'classified' | 'dispatched' | 'parked' | 'shipped' | 'done' | 'batched' | 'waiting' | 'in-work' | 'committed' | 'validated' | 'shipped-in-batch' | 'evicted' | 'requeued' | 'blocked' | 'decision-pending' | 'failed';
28
30
  /** Issue statuses that cannot transition further. */
29
31
  export declare const TERMINAL_ISSUE_STATUSES: ReadonlySet<IssueStatus>;
30
32
  /**
@@ -32,6 +34,8 @@ export declare const TERMINAL_ISSUE_STATUSES: ReadonlySet<IssueStatus>;
32
34
  * these: "an issue with an unmerged dependency is never runnable" (AC5).
33
35
  */
34
36
  export declare const SATISFIED_ISSUE_STATUSES: ReadonlySet<IssueStatus>;
37
+ /** Teardown outcome values (#468): verified cleanup or a failed step. */
38
+ export type CleanupStatus = 'done' | `failed-${string}`;
35
39
  /**
36
40
  * Batch lifecycle per RFC-0001 §D.2:
37
41
  *
@@ -83,6 +87,18 @@ export interface QueueEntry {
83
87
  status: IssueStatus;
84
88
  /** Free-form reason attached to failure-edge transitions (evicted/blocked/failed). */
85
89
  reason: string | null;
90
+ /**
91
+ * PR number the unit parked on `auto-merge` (#468), from the ship phase's
92
+ * `awaiting-merge` milestone (`pr=` key). Set when the agent exits parked;
93
+ * drives the PR watcher until the merge is accepted.
94
+ */
95
+ pr: number | null;
96
+ /**
97
+ * Teardown outcome for a merged unit (#468): `done` or `failed-<step>`, or
98
+ * null while teardown is still pending. Recorded only after the cleanup
99
+ * was verified (pool return self-check / worktree path gone).
100
+ */
101
+ cleanup: CleanupStatus | null;
86
102
  enqueued_at: string;
87
103
  updated_at: string;
88
104
  }
@@ -136,6 +152,13 @@ export interface SchedState {
136
152
  slots: SlotEntry[];
137
153
  /** Monotonic counter for stable slot ids. */
138
154
  next_slot_id: number;
155
+ /**
156
+ * When the PR watcher last polled (#468) — parked PRs are polled every
157
+ * `pr_poll_interval_ms` (default 150 s). Polled on each reconcile tick
158
+ * when due (a `reconcile_interval_ms` longer than the interval slows the
159
+ * effective cadence); persisted so the cadence survives a sched restart.
160
+ */
161
+ last_pr_poll_at: string | null;
139
162
  }
140
163
  /** Durable intent, persisted separately in `config.json` (state.json is rebuildable hot truth). */
141
164
  export interface SchedConfig {
@@ -144,6 +167,11 @@ export interface SchedConfig {
144
167
  stall_timeout_ms?: number;
145
168
  /** Reconciliation tick interval in ms (default 60 000). */
146
169
  reconcile_interval_ms?: number;
170
+ /**
171
+ * Parked-PR poll interval in ms (#468, default 150 000 — "every 2–3 min").
172
+ * Checked on each reconcile tick when due; see `SchedState.last_pr_poll_at`.
173
+ */
174
+ pr_poll_interval_ms?: number;
147
175
  /** Agent dispatch settings (#464); every field optional with engine defaults. */
148
176
  dispatch?: DispatchConfig;
149
177
  }
@@ -159,19 +187,29 @@ export interface DispatchConfig {
159
187
  prompt?: string;
160
188
  /** Tier → model id/alias mapping (defaults: haiku / sonnet / opus). */
161
189
  tier_models?: Partial<Record<ModelTier, string>>;
190
+ /**
191
+ * Prompt template for the report agent dispatched after a merged PR
192
+ * (#468); `{issue}`, `{pr}` and `{cleanup}` substituted. Defaults to
193
+ * `DEFAULT_REPORT_PROMPT_TEMPLATE`.
194
+ */
195
+ report_prompt?: string;
162
196
  }
163
197
  /** The escalation ladder: one tier stronger, or null at the top (RFC-0001 §C.1). */
164
198
  export declare const TIER_LADDER: Readonly<Record<ModelTier, ModelTier | null>>;
199
+ /** The ladder as an ordered array (weakest first) — the single ordering source. */
200
+ export declare const TIER_ORDER: readonly ModelTier[];
165
201
  /** Cap on recovery attempts before a unit fails (RFC-0001 §C.1 "cap 2"). */
166
202
  export declare const ESCALATION_CAP = 2;
167
203
  /** Default stall timeout: 30 minutes without a milestone or pushed commit (RFC-0001 §C.1). */
168
204
  export declare const DEFAULT_STALL_TIMEOUT_MS: number;
169
205
  /** Default reconciliation tick: ~60s (RFC-0001 §C.1). */
170
206
  export declare const DEFAULT_RECONCILE_INTERVAL_MS: number;
171
- export declare const SCHEMA_VERSION: "1.1.0";
207
+ /** Default parked-PR poll interval: 2.5 min (#468 AC1 "every 2–3 min"). */
208
+ export declare const DEFAULT_PR_POLL_INTERVAL_MS: number;
209
+ export declare const SCHEMA_VERSION: "1.2.0";
172
210
  /** Schema versions `validateState` accepts on load (migrated to SCHEMA_VERSION on save). */
173
211
  export declare const LEGACY_SCHEMA_VERSIONS: readonly string[];
174
- export declare const CONFIG_SCHEMA_VERSION: "1.1.0";
212
+ export declare const CONFIG_SCHEMA_VERSION: "1.2.0";
175
213
  /** Config schema versions `loadConfig` accepts (older configs carry only max_slots). */
176
214
  export declare const LEGACY_CONFIG_SCHEMA_VERSIONS: readonly string[];
177
215
  /** Config file shape (schema_version + the config itself). */
@@ -180,6 +218,7 @@ export interface SchedConfigFile {
180
218
  max_slots: number;
181
219
  stall_timeout_ms?: number;
182
220
  reconcile_interval_ms?: number;
221
+ pr_poll_interval_ms?: number;
183
222
  dispatch?: DispatchConfig;
184
223
  }
185
224
  export declare const DEFAULT_MAX_SLOTS = 3;
@@ -198,7 +237,7 @@ export declare class SchedNotFoundError extends Error {
198
237
  constructor(message: string);
199
238
  }
200
239
  /** Every event the engine journals to `events.jsonl` (append-only). */
201
- export type JournalEventName = 'assigned' | 'spawned' | 'exit-detected' | 'orphan-pid' | 'external-advance' | 'progress' | 'phase-updated' | 'verify-complete' | 'verify-incomplete' | 'stalled' | 'redispatched' | 'unit-failed' | 'dependents-blocked' | 'requeued' | 'ground-truth-unreachable' | 'tick-failed';
240
+ export type JournalEventName = 'assigned' | 'spawned' | 'exit-detected' | 'orphan-pid' | 'external-advance' | 'progress' | 'phase-updated' | 'verify-complete' | 'verify-incomplete' | 'stalled' | 'redispatched' | 'unit-failed' | 'dependents-blocked' | 'requeued' | 'ground-truth-unreachable' | 'tick-failed' | 'pr-parked' | 'merge-accepted' | 'pr-watch-failed' | 'pr-watch-waiting' | 'teardown-done' | 'teardown-failed' | 'report-dispatched' | 'report-failed';
202
241
  /** One journaled event. `ts` is stamped by the journal, never by callers. */
203
242
  export interface JournalEvent {
204
243
  ts: string;
@@ -1 +1 @@
1
- {"version":3,"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.ts, groundtruth.ts) — never an LLM call of its own (AC7).
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SchedNotFoundError = exports.IllegalTransitionError = exports.MAX_MAX_SLOTS = exports.MIN_MAX_SLOTS = exports.DEFAULT_MAX_SLOTS = exports.LEGACY_CONFIG_SCHEMA_VERSIONS = exports.CONFIG_SCHEMA_VERSION = exports.LEGACY_SCHEMA_VERSIONS = exports.SCHEMA_VERSION = exports.DEFAULT_RECONCILE_INTERVAL_MS = exports.DEFAULT_STALL_TIMEOUT_MS = exports.ESCALATION_CAP = exports.TIER_LADDER = exports.LIVE_SLOT_STATUSES = exports.MERGED_BATCH_STATUSES = exports.TERMINAL_BATCH_STATUSES = exports.SATISFIED_ISSUE_STATUSES = exports.TERMINAL_ISSUE_STATUSES = void 0;
12
+ exports.SchedNotFoundError = exports.IllegalTransitionError = exports.MAX_MAX_SLOTS = exports.MIN_MAX_SLOTS = exports.DEFAULT_MAX_SLOTS = exports.LEGACY_CONFIG_SCHEMA_VERSIONS = exports.CONFIG_SCHEMA_VERSION = exports.LEGACY_SCHEMA_VERSIONS = exports.SCHEMA_VERSION = exports.DEFAULT_PR_POLL_INTERVAL_MS = exports.DEFAULT_RECONCILE_INTERVAL_MS = exports.DEFAULT_STALL_TIMEOUT_MS = exports.ESCALATION_CAP = exports.TIER_ORDER = exports.TIER_LADDER = exports.LIVE_SLOT_STATUSES = exports.MERGED_BATCH_STATUSES = exports.TERMINAL_BATCH_STATUSES = exports.SATISFIED_ISSUE_STATUSES = exports.TERMINAL_ISSUE_STATUSES = void 0;
13
13
  /** Issue statuses that cannot transition further. */
14
14
  exports.TERMINAL_ISSUE_STATUSES = new Set(['done', 'failed']);
15
15
  /**
@@ -46,18 +46,22 @@ exports.TIER_LADDER = {
46
46
  mid: 'strong',
47
47
  strong: null,
48
48
  };
49
+ /** The ladder as an ordered array (weakest first) — the single ordering source. */
50
+ exports.TIER_ORDER = ['mechanical', 'mid', 'strong'];
49
51
  /** Cap on recovery attempts before a unit fails (RFC-0001 §C.1 "cap 2"). */
50
52
  exports.ESCALATION_CAP = 2;
51
53
  /** Default stall timeout: 30 minutes without a milestone or pushed commit (RFC-0001 §C.1). */
52
54
  exports.DEFAULT_STALL_TIMEOUT_MS = 30 * 60 * 1000;
53
55
  /** Default reconciliation tick: ~60s (RFC-0001 §C.1). */
54
56
  exports.DEFAULT_RECONCILE_INTERVAL_MS = 60 * 1000;
55
- exports.SCHEMA_VERSION = '1.1.0';
57
+ /** Default parked-PR poll interval: 2.5 min (#468 AC1 "every 2–3 min"). */
58
+ exports.DEFAULT_PR_POLL_INTERVAL_MS = 150 * 1000;
59
+ exports.SCHEMA_VERSION = '1.2.0';
56
60
  /** Schema versions `validateState` accepts on load (migrated to SCHEMA_VERSION on save). */
57
- exports.LEGACY_SCHEMA_VERSIONS = ['1.0.0'];
58
- exports.CONFIG_SCHEMA_VERSION = '1.1.0';
61
+ exports.LEGACY_SCHEMA_VERSIONS = ['1.0.0', '1.1.0'];
62
+ exports.CONFIG_SCHEMA_VERSION = '1.2.0';
59
63
  /** Config schema versions `loadConfig` accepts (older configs carry only max_slots). */
60
- exports.LEGACY_CONFIG_SCHEMA_VERSIONS = ['1.0.0'];
64
+ exports.LEGACY_CONFIG_SCHEMA_VERSIONS = ['1.0.0', '1.1.0'];
61
65
  exports.DEFAULT_MAX_SLOTS = 3;
62
66
  /** Bounds for `max_slots` when reading `config.json` (named — not magic numbers in persist.ts). */
63
67
  exports.MIN_MAX_SLOTS = 1;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA2CH,qDAAqD;AACxC,QAAA,uBAAuB,GAA6B,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7F;;;GAGG;AACU,QAAA,wBAAwB,GAA6B,IAAI,GAAG,CAAC;IACxE,S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oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-dossier/sched",
3
- "version": "0.2.1",
4
- "description": "Deterministic scheduler core for dossier batch cycles queue, slots, persistent state machine, dispatch engine with completion verification and stall/escalation ladder. The scheduler never invokes an LLM.",
3
+ "version": "0.3.0",
4
+ "description": "Deterministic scheduler core for dossier batch cycles \u2014 queue, slots, persistent state machine, dispatch engine with completion verification and stall/escalation ladder. The scheduler never invokes an LLM.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [