@ai-dossier/sched 0.7.0 → 0.8.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/README.md CHANGED
@@ -97,9 +97,10 @@ where every mechanical supervision decision is code, not remembered prose:
97
97
  5. **Immediate refill (AC5)** — a slot freed by a terminal state is refilled in the SAME
98
98
  tick; a runnable unit never waits while a slot is idle (pinned by a regression test).
99
99
  6. **Journal (AC6)** — every event (assigned, spawned, exit-detected, external-advance,
100
- progress, stalled, redispatched, unit-failed, dependents-blocked, suspect-dispatch,
101
- dispatch-unhealthy, …) is appended to `events.jsonl`; `sched status` shows the live
102
- phase per unit. `label-blocked`/`label-check-failed` (#507) are the one pair journaled
100
+ progress, stalled, redispatched, fence-written, fence-failed, unit-failed,
101
+ dependents-blocked, suspect-dispatch, dispatch-unhealthy, …) is appended to
102
+ `events.jsonl`; `sched status` shows the live phase per unit, plus each slot's `gen`
103
+ and `fenced` state (#504). `label-blocked`/`label-check-failed` (#507) are the one pair journaled
103
104
  OUTSIDE the engine — `sched enqueue` appends them at enqueue time, before dispatch.
104
105
  7. **Dispatch-health pause (#505)** — an unverified exit within `SUSPECT_DISPATCH_WINDOW_MS`
105
106
  (60s) of a slot's last progress is `suspect-dispatch`: real work rarely produces zero
@@ -135,6 +136,47 @@ Two engine-safety policies were explicit product decisions on #464:
135
136
  Only `issue:<n>` units are dispatched today — batch member sequencing is a follow-up
136
137
  (#464 non-goal).
137
138
 
139
+ ### Zombie-run fencing (#504)
140
+
141
+ The ladder redispatches the SAME run, so a takeover inherits the run id and its milestone
142
+ trail. In the #472 race that turned out to be a hole: `enterRecovery` kills the pid it
143
+ knows about, but an agent it cannot see or signal — throttled, cwd outside the worktree —
144
+ survives, and nothing on the trail tells that agent it was replaced. Both runs implemented
145
+ the same issue, and both kept posting milestones on one trail. The doctrine, one step past
146
+ "an agent exiting is not proof of merge": **no visible process is not proof of death.**
147
+
148
+ A **generation** now fences the trail:
149
+
150
+ - Before the takeover is spawned, the engine calls `ai-dossier runstate fence`, which
151
+ posts a `status=superseded` milestone carrying `gen=<n>` and `takeover=<label>`.
152
+ Written first, on purpose, so it survives the takeover dying too.
153
+ - The takeover is told its generation in its prompt and passes `--gen <n>` to every
154
+ `runstate post`. **The CLI refuses any post below the trail's fenced generation**, so
155
+ the superseded agent cannot extend the trail even though it never checks — and an agent
156
+ running an older dossier implicitly sits at generation 0, fenced out the moment
157
+ generation 1 exists.
158
+ - `ai-dossier runstate check --issue <n> --run <id> --gen <g>` exits `3` when the caller
159
+ has been superseded: the checkpoint a workflow runs before implement, review, and ship.
160
+ - A takeover that posts NOTHING is watched on the **shorter** of
161
+ `fence_takeover_timeout_ms` (default 15 min) and the phase's own stall allowance — the
162
+ fence window can only ever bring recovery forward, never delay it — so a takeover that
163
+ dies at birth re-enters the ladder in minutes and the next fence supersedes it in turn.
164
+ The first progress signal disarms the short window. `ESCALATION_CAP` still bounds the
165
+ whole ladder.
166
+ - Report agents ride the same rail: a fenced report slot is told its generation too, or
167
+ its `report done` milestone would be refused and it would recover to the cap on a PR
168
+ that already merged.
169
+ - The read side is hardened, because a milestone is an issue comment: only comments from
170
+ an account with **write access** count as a fence, a forged `takeover=` label is dropped
171
+ rather than echoed into an agent's prompt, and the engine refuses to fence a run id that
172
+ does not belong to the issue it is working on (that would journal success while the real
173
+ zombie stayed free to write).
174
+
175
+ Fencing is defense-in-depth, not a precondition: if the fence cannot be written (no run id
176
+ on the trail yet, gh unreachable, no fencer configured) the redispatch proceeds unfenced
177
+ and journals `fence-failed`. Stranding a stalled unit forever would be the worse failure —
178
+ but the unprotected redispatch is never silent.
179
+
138
180
  ## Batch failure recovery (#472)
139
181
 
140
182
  What happens when a batch's aggregate suite goes red, or its PR will not merge
@@ -215,6 +257,12 @@ a report slot in the first place) with the persisted `phase` as a fallback when
215
257
  matching entry exists. A backfilled role is a best-effort inference, not a guarantee —
216
258
  see `validateState` in `state.ts` for the exact rule.
217
259
 
260
+ Schema 1.6.0: `SlotEntry` gains `gen` (number — the runstate generation the slot's agent
261
+ owns, 0 for a first dispatch) and `fenced_at` (ISO string or null — set when a takeover is
262
+ fenced in, cleared by its first progress signal; #504 above). 1.5.0 states migrate on
263
+ load: nothing was fenced before fencing existed, so `0`/`null` is the exact backfill, not
264
+ a guess. Both reset with the slot on release (`CLEARED_SLOT_FIELDS`).
265
+
218
266
  Schema 1.5.0: `SchedState` gains `consecutive_suspect_dispatches` (number) and
219
267
  `last_suspect_dispatch_unit` (string or null) — the dispatch-health pause's cross-unit
220
268
  suspect-dispatch streak (#505 above). The two fields are a single fact and must agree
@@ -238,15 +286,25 @@ import {
238
286
  // dependents-unblocked/report-dispatched/teardown/completed/
239
287
  // redispatched/failed/blocked)
240
288
  type EngineDeps, // inject everything the engine touches (store/journal/spawn/ground
241
- // truth/clock/repoDir/teardownExec)
289
+ // truth/clock/repoDir/teardownExec/fencer)
242
290
  createSpawnDeps, // real detached-spawn process I/O
243
291
  createExecGroundTruth, // runstate/gh/git ground truth via subprocesses (injectable exec);
244
292
  // since #468 also gh pr view PR state + setup info from comments
245
293
  resolveDispatch, // config → resolved command/prompt/report-prompt/tier-models/timers
246
294
  stallTimeoutForPhase, // the stall allowance for the phase now in flight (#495 per-phase
247
295
  // map → global, hardened against a prototype-name phase)
296
+ stallTimeoutForSlot, // #504: that allowance, shortened to fenceTakeoverTimeoutMs while
297
+ // a takeover has posted nothing (Math.min — never longer)
298
+ takeoverInstruction, // the TAKEOVER prompt suffix appended for gen > 0
299
+ SUPERSESSION_CHECKPOINT_INSTRUCTION, // the check-before-implement/review/ship clause
300
+ // every dispatch prompt carries
301
+ createExecRunFencer, // default fencer: shells `ai-dossier runstate fence --json`
302
+ parseFenceGeneration, // fence stdout → the installed generation (null = unfenced)
303
+ type RunFencer, // inject the takeover-record writer: (issue, run, phase, takeover)
304
+ type FenceOutcome, // {ok, gen} | {ok: false, reason} — a failure carries its cause
305
+ FENCE_TIMEOUT_MS, // fence subprocess timeout (60 s — two gh round trips)
248
306
  DEFAULT_PHASE_STALL_TIMEOUT_MS, // built-in per-phase stall allowances (implement: 90 min)
249
- buildReportPrompt, // report-agent prompt ({issue}/{pr}/{cleanup} substituted)
307
+ buildReportPrompt, // report-agent prompt ({issue}/{pr}/{cleanup}/{gen} substituted)
250
308
  reportTierFor, // report (re)dispatch tier after N escalations
251
309
  isParkedMilestone, // ship-phase awaiting-merge + pr= → the park signal
252
310
  prOfMilestone, // a milestone's pr= key as a positive integer
@@ -279,7 +337,7 @@ import {
279
337
  transitionIssue, transitionBatch, transitionSlot, // typed §D transitions
280
338
  TRANSITIONS, // the transition tables themselves (for previews)
281
339
  buildStatusReport, // machine-readable status incl. blocked/failed sets
282
- validateState, // strict persisted-state validation (1.0.0-1.4.0 files migrate)
340
+ validateState, // strict persisted-state validation (1.0.0-1.5.0 files migrate)
283
341
  IllegalTransitionError, EnqueueError, CorruptStateError, LockTimeoutError,
284
342
  SchedNotFoundError,
285
343
  } from '@ai-dossier/sched';
@@ -297,7 +355,8 @@ fake agents and stub ground truth; no LLM calls anywhere.
297
355
  ~/.dossier/sched/<project>/
298
356
  ├── state.json # hot operational truth — atomic tmp+fsync+rename writes;
299
357
  ├── config.json # durable intent: max_slots, stall_timeout_ms, reconcile_interval_ms,
300
- │ # pr_poll_interval_ms, dispatch (incl. report_prompt, phase_stall_timeout_ms)
358
+ │ # pr_poll_interval_ms, dispatch (incl. report_prompt,
359
+ │ # phase_stall_timeout_ms, fence_takeover_timeout_ms)
301
360
  ├── events.jsonl # append-only event journal (the operator's flight recorder)
302
361
  ├── runs/ # per-unit agent output logs (issue-<n>.log)
303
362
  └── .sched-lock/ # cross-process directory mutex (pid; stolen from dead holders)
@@ -312,13 +371,13 @@ fake agents and stub ground truth; no LLM calls anywhere.
312
371
  never a silent queue reset. `state.json` is deletable and rebuildable from GitHub,
313
372
  which remains the system of record.
314
373
  - **Schema**: state/config files from #460 (schema 1.0.0), #464 (1.1.0), #468 (1.2.0),
315
- #472 (1.3.0) and #500 (1.4.0) load and migrate to 1.5.0 automatically (slot
374
+ #472 (1.3.0), #500 (1.4.0) and #505 (1.5.0) load and migrate to 1.6.0 automatically (slot
316
375
  `branch`/`last_head`/`pid_start`, slot `role` (inferred from the unit's queue entry,
317
376
  with the persisted `phase` as a fallback — #500), entry `pr`/`cleanup`/
318
377
  `failure_evidence`, batch `anchor`/`branch`/`run_id`/`eviction_groups`/`evictions`/
319
378
  `fix_attempts`/`rebase_attempts`, state-level `last_pr_poll_at` backfill to null, and
320
379
  state-level `consecutive_suspect_dispatches`/`last_suspect_dispatch_unit` backfill to
321
- `0`/`null` — #505).
380
+ `0`/`null` — #505, and slot `gen`/`fenced_at` backfill to `0`/`null` — #504).
322
381
  - **`max_slots`** bounds live units (`assigned | running | recovering`); dependency
323
382
  edges gate readiness — an issue with an unmerged dependency, and a batch behind an
324
383
  unmerged batch, are never runnable.
@@ -1 +1 @@
1
- {"version":3,"file":"bisect.d.ts","sourceRoot":"","sources":["../src/bisect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAuC,MAAM,eAAe,CAAC;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,mCAAmC;AACnC,MAAM,MAAM,aAAa;AACvB,yEAAyE;AACvE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACnD,yFAAyF;GACvF;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;AACnB,0FAA0F;GACxF;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACzD,gFAAgF;GAC9E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,uC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;;;OAKG;IACH,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,uFAAuF;IACvF,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,aAAa,CAuGrF"}
package/dist/bisect.js CHANGED
@@ -13,8 +13,6 @@
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.runAttributionBisect = runAttributionBisect;
15
15
  const attribution_1 = require("./attribution");
16
- /** `<sha> is the first bad commit` — the line every git version prints on success. */
17
- const FIRST_BAD_RE = /^([0-9a-f]{7,40}) is the first bad commit/im;
18
16
  /**
19
17
  * Bisect the batch branch for the commit that broke `testCommand`.
20
18
  *
@@ -79,19 +77,20 @@ function runAttributionBisect(exec, opts) {
79
77
  detail: `git bisect start failed (is ${opts.good} an ancestor of ${opts.bad}?)`,
80
78
  };
81
79
  }
82
- const out = git(['bisect', 'run', ...opts.testCommand]);
83
- if (out === null) {
80
+ if (git(['bisect', 'run', ...opts.testCommand]) === null) {
84
81
  return { kind: 'error', detail: 'git bisect run failed' };
85
82
  }
86
83
  // Ask git for the answer rather than reading its prose: a completed bisect
87
- // leaves `refs/bisect/bad` pointing at the first bad commit. The
88
- // "<sha> is the first bad commit" line is printed on stdout by some git
89
- // versions and stderr by others, so parsing it alone makes the result
90
- // depend on which git the machine happens to have it stays only as the
91
- // fallback for a git that somehow leaves no ref.
92
- const sha = git(['rev-parse', '--verify', '--quiet', 'refs/bisect/bad'])?.trim() ??
93
- FIRST_BAD_RE.exec(out)?.[1] ??
94
- '';
84
+ // leaves `refs/bisect/bad` pointing at the first bad commit — set by git's
85
+ // own bisect algorithm from the test command's EXIT CODE alone, never from
86
+ // anything the command prints. There is deliberately no fallback that
87
+ // parses `git bisect run`'s captured output: that stream interleaves git's
88
+ // own lines with the failing test command's stdout, so a member-authored
89
+ // test could forge an "<sha> is the first bad commit" line naming another
90
+ // member's real commit to shift blame (#503). Every supported git writes
91
+ // this ref, and the module's contract is "no answer is an error, never a
92
+ // guess" — so no ref means no answer, not a guess from prose.
93
+ const sha = git(['rev-parse', '--verify', '--quiet', 'refs/bisect/bad'])?.trim() ?? '';
95
94
  if (!attribution_1.SHA_RE.test(sha)) {
96
95
  // No answer is an error, never a guess.
97
96
  return { kind: 'error', detail: 'git bisect run identified no first-bad commit' };
@@ -1 +1 @@
1
- {"version":3,"file":"bisect.js","sourceRoot":"","sources":["../src/bisect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAiDH,oDAuGC;AAtJD,+CAAyF;AAqCzF,sFAAsF;AACtF,MAAM,YAAY,GAAG,6CAA6C,CAAC;AAEnE;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,IAAY,EAAE,IAAmB;IACpE,yEAAyE;IACzE,oEAAoE;IACpE,oDAAoD;IACpD,IAAI,CAAC,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,kCAAkC,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAClG,CAAC;IACD,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC;IACnE,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,IAAc,EAAiB,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,GAAkB,E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E,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACtC,IAAI,CAAC,MAAM,EAAE,CAAC,+DAA+D,CAAC,CAAC;QACjF,CAAC;QACD,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -34,6 +34,21 @@ export declare const OPENCODE_DISPATCH_COMMAND: readonly string[];
34
34
  * only reads already-merged state and never spawns a long command.
35
35
  */
36
36
  export declare const NO_BACKGROUND_EXIT_INSTRUCTION: string;
37
+ /**
38
+ * The supersession checkpoint every dispatched run is told to keep (#504 AC2).
39
+ *
40
+ * This has to be in the DEFAULT prompt, not only in `takeoverInstruction`: the run that
41
+ * gets fenced is the one that was already running, and at dispatch time it is generation
42
+ * 0 like every other first dispatch. Telling only takeovers to check would leave exactly
43
+ * the agent this mechanism exists to stop — the #472 zombie — with no instruction to
44
+ * stop, which is the difference between "a fenced run cannot write" and "a fenced run
45
+ * knows it lost and gets out of the way".
46
+ *
47
+ * The checkpoints are the three expensive ones: implement, review, and ship. `--comment`
48
+ * leaves one short, deduplicated record on the issue, so a run that vanishes mid-cycle
49
+ * is explained rather than merely absent.
50
+ */
51
+ export declare const SUPERSESSION_CHECKPOINT_INSTRUCTION: string;
37
52
  /**
38
53
  * Default prompt sent on the child's stdin. Detached ship mode (#468): the
39
54
  * agent parks the PR on `auto-merge` and STOPS — the scheduler's PR watcher
@@ -60,7 +75,7 @@ export declare const DEFAULT_FIX_PROMPT_TEMPLATE: string;
60
75
  export interface ResolvedDispatch {
61
76
  /** Command template with `{model}`/`{issue}` placeholders. */
62
77
  command: string[];
63
- /** Prompt template with `{issue}` placeholder. */
78
+ /** Prompt template with `{issue}`/`{gen}` placeholders (`{gen}` since #504). */
64
79
  prompt: string;
65
80
  /** Report-agent prompt template with `{issue}`/`{pr}`/`{cleanup}` placeholders (#468). */
66
81
  reportPrompt: string;
@@ -81,6 +96,12 @@ export interface ResolvedDispatch {
81
96
  reconcileIntervalMs: number;
82
97
  /** Parked-PR poll interval (#468 AC1, default 150 s — "every 2–3 min"). */
83
98
  prPollIntervalMs: number;
99
+ /**
100
+ * Stall allowance for a takeover that has posted NOTHING since it was fenced in
101
+ * (#504 AC4). Selected over the phase timeout only while `SlotEntry.fenced_at` is
102
+ * set — see `stallTimeoutForSlot`.
103
+ */
104
+ fenceTakeoverTimeoutMs: number;
84
105
  }
85
106
  /** Resolve engine dispatch settings from the (possibly sparse) config. */
86
107
  export declare function resolveDispatch(config: SchedConfig): ResolvedDispatch;
@@ -101,6 +122,15 @@ export declare function resolveDispatch(config: SchedConfig): ResolvedDispatch;
101
122
  * function and silently disable the stall check via a `NaN` comparison.
102
123
  */
103
124
  export declare function stallTimeoutForPhase(dispatch: ResolvedDispatch, phase: string | null): number;
125
+ /**
126
+ * The stall allowance for a slot: the phase timeout, shortened to
127
+ * `fenceTakeoverTimeoutMs` while a takeover has posted nothing at all (#504 AC4).
128
+ *
129
+ * `Math.min`, so the short window can only ever bring recovery FORWARD. A phase whose
130
+ * own allowance is already shorter than the fence window keeps it — a takeover should
131
+ * never get MORE time than a first dispatch would have had for the same phase.
132
+ */
133
+ export declare function stallTimeoutForSlot(dispatch: ResolvedDispatch, phase: string | null, fencedAt: string | null): number;
104
134
  /**
105
135
  * Build the concrete agent argv for one dispatch: substitute `{issue}` and
106
136
  * `{model}`. When the tier's model is null, the `{model}` item AND its
@@ -108,10 +138,32 @@ export declare function stallTimeoutForPhase(dispatch: ResolvedDispatch, phase:
108
138
  * carries a flag whose value is missing.
109
139
  */
110
140
  export declare function buildAgentCommand(template: readonly string[], tier: ModelTier, issue: number, tierModels: Readonly<Record<ModelTier, string | null>>): string[];
111
- /** Build the child's stdin prompt for one dispatch. */
112
- export declare function buildPrompt(template: string, issue: number): string;
113
- /** Build the report agent's stdin prompt (#468): `{issue}`/`{pr}`/`{cleanup}` substituted. */
114
- export declare function buildReportPrompt(template: string, issue: number, pr: number, cleanup: string): string;
141
+ /**
142
+ * What a takeover agent is told about the run it inherited (#504).
143
+ *
144
+ * Appended only for `gen > 0`, so an ordinary first dispatch reads exactly as it does
145
+ * today. Two instructions, both load-bearing: pass `--gen` so the agent's own posts are
146
+ * accepted (the CLI refuses a lower generation), and CHECK before the expensive phases so
147
+ * it discovers its own supersession early if it is itself replaced later.
148
+ */
149
+ export declare function takeoverInstruction(issue: number, gen: number): string;
150
+ /**
151
+ * Build the child's stdin prompt for one dispatch.
152
+ *
153
+ * `gen` is the runstate generation the agent owns; 0 (the default) is a first dispatch
154
+ * and produces today's prompt unchanged.
155
+ */
156
+ export declare function buildPrompt(template: string, issue: number, gen?: number): string;
157
+ /**
158
+ * Build the report agent's stdin prompt (#468): `{issue}`/`{pr}`/`{cleanup}`/`{gen}`
159
+ * substituted, with the takeover instruction appended for `gen > 0` (#504).
160
+ *
161
+ * A report slot rides the same recovery ladder as a cycle slot, so it can be fenced and
162
+ * respawned as a takeover — and a report agent that did not know its generation would
163
+ * have its `report done` milestone refused, recovering to the escalation cap on a PR
164
+ * that already merged.
165
+ */
166
+ export declare function buildReportPrompt(template: string, issue: number, pr: number, cleanup: string, gen?: number): string;
115
167
  /**
116
168
  * Build the fix agent's stdin prompt (#472): `{issue}`, `{batch}` and the
117
169
  * failing-test list substituted. Tests are rendered one per line so the agent
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAML,KAAK,SAAS,EACd,KAAK,WAAW,EAGjB,MAAM,SAAS,CAAC;AAEjB,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAInE,CAAC;AAEF,0FAA0F;AAC1F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C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAyEvD"}
package/dist/dispatch.js CHANGED
@@ -50,10 +50,12 @@ var __importStar = (this && this.__importStar) || (function () {
50
50
  };
51
51
  })();
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.STOP_POLL_MAX_MS = exports.STOP_POLL_MIN_MS = exports.DEFAULT_FIX_PROMPT_TEMPLATE = exports.DEFAULT_REPORT_PROMPT_TEMPLATE = exports.DEFAULT_PROMPT_TEMPLATE = exports.NO_BACKGROUND_EXIT_INSTRUCTION = exports.OPENCODE_DISPATCH_COMMAND = exports.DEFAULT_DISPATCH_COMMAND = exports.DEFAULT_TIER_MODELS = void 0;
53
+ exports.STOP_POLL_MAX_MS = exports.STOP_POLL_MIN_MS = exports.DEFAULT_FIX_PROMPT_TEMPLATE = exports.DEFAULT_REPORT_PROMPT_TEMPLATE = exports.DEFAULT_PROMPT_TEMPLATE = exports.SUPERSESSION_CHECKPOINT_INSTRUCTION = exports.NO_BACKGROUND_EXIT_INSTRUCTION = exports.OPENCODE_DISPATCH_COMMAND = exports.DEFAULT_DISPATCH_COMMAND = exports.DEFAULT_TIER_MODELS = void 0;
54
54
  exports.resolveDispatch = resolveDispatch;
55
55
  exports.stallTimeoutForPhase = stallTimeoutForPhase;
56
+ exports.stallTimeoutForSlot = stallTimeoutForSlot;
56
57
  exports.buildAgentCommand = buildAgentCommand;
58
+ exports.takeoverInstruction = takeoverInstruction;
57
59
  exports.buildPrompt = buildPrompt;
58
60
  exports.buildReportPrompt = buildReportPrompt;
59
61
  exports.buildFixPrompt = buildFixPrompt;
@@ -111,6 +113,39 @@ exports.NO_BACKGROUND_EXIT_INSTRUCTION = 'IMPORTANT — this is a HEADLESS sessi
111
113
  function withNoBackgroundExit(template) {
112
114
  return `${template}\n\n${exports.NO_BACKGROUND_EXIT_INSTRUCTION}`;
113
115
  }
116
+ /**
117
+ * The supersession checkpoint every dispatched run is told to keep (#504 AC2).
118
+ *
119
+ * This has to be in the DEFAULT prompt, not only in `takeoverInstruction`: the run that
120
+ * gets fenced is the one that was already running, and at dispatch time it is generation
121
+ * 0 like every other first dispatch. Telling only takeovers to check would leave exactly
122
+ * the agent this mechanism exists to stop — the #472 zombie — with no instruction to
123
+ * stop, which is the difference between "a fenced run cannot write" and "a fenced run
124
+ * knows it lost and gets out of the way".
125
+ *
126
+ * The checkpoints are the three expensive ones: implement, review, and ship. `--comment`
127
+ * leaves one short, deduplicated record on the issue, so a run that vanishes mid-cycle
128
+ * is explained rather than merely absent.
129
+ */
130
+ exports.SUPERSESSION_CHECKPOINT_INSTRUCTION = 'SUPERSESSION CHECKPOINT — before implement, before review, and before ship, run ' +
131
+ '`ai-dossier runstate check --issue {issue} --run <run_id> --gen {gen} --comment`. A non-zero ' +
132
+ 'exit means another agent has taken this issue over while you were working: STOP immediately ' +
133
+ '— do not push, do not open a PR, do not post another milestone — and end the session. The ' +
134
+ 'same applies if `ai-dossier runstate post` ever refuses a milestone as SUPERSEDED: that is ' +
135
+ 'not an error to retry or work around.';
136
+ /**
137
+ * Append {@link SUPERSESSION_CHECKPOINT_INSTRUCTION} to a prompt template, once.
138
+ *
139
+ * Idempotent so it can be applied both to the built-in default and again at resolve
140
+ * time: an operator who overrides `dispatch.prompt` must not silently lose the
141
+ * checkpoint, which is exactly how a safety instruction that lives only on a constant
142
+ * stops protecting the deployments that need it most.
143
+ */
144
+ function withSupersessionCheckpoint(template) {
145
+ return template.includes(exports.SUPERSESSION_CHECKPOINT_INSTRUCTION)
146
+ ? template
147
+ : `${template}\n\n${exports.SUPERSESSION_CHECKPOINT_INSTRUCTION}`;
148
+ }
114
149
  /**
115
150
  * Default prompt sent on the child's stdin. Detached ship mode (#468): the
116
151
  * agent parks the PR on `auto-merge` and STOPS — the scheduler's PR watcher
@@ -119,12 +154,12 @@ function withNoBackgroundExit(template) {
119
154
  * Operators wanting attached runs (agent drives to the final report itself)
120
155
  * override `dispatch.prompt` in config.json.
121
156
  */
122
- exports.DEFAULT_PROMPT_TEMPLATE = withNoBackgroundExit('Run the full-cycle-issue workflow for GitHub issue #{issue} in this repository.\n\n' +
157
+ exports.DEFAULT_PROMPT_TEMPLATE = withSupersessionCheckpoint(withNoBackgroundExit('Run the full-cycle-issue workflow for GitHub issue #{issue} in this repository.\n\n' +
123
158
  'Begin by fetching the workflow: ai-dossier run imboard-ai/git/full-cycle-issue --pull\n\n' +
124
159
  'Then execute it for issue #{issue} in detached ship mode (ship_mode=detached), following every ' +
125
160
  'phase (gate, setup, plan, implement, review) without asking questions, until Phase 5 parks the ' +
126
161
  'PR: apply the auto-merge label, post the awaiting-merge milestone, and STOP. Do not wait for ' +
127
- 'the merge, do not run teardown or report — the scheduler watches the PR and dispatches those.');
162
+ 'the merge, do not run teardown or report — the scheduler watches the PR and dispatches those.'));
128
163
  /**
129
164
  * Default prompt for the report agent dispatched after a merged PR (#468
130
165
  * AC2) — a cheap-tier run of the report phase only, never a full cycle.
@@ -134,7 +169,13 @@ exports.DEFAULT_REPORT_PROMPT_TEMPLATE = 'Run the report phase for GitHub issue
134
169
  'The work is DONE: pull request #{pr} is merged (merge commit via `gh pr view {pr}`), the issue ' +
135
170
  'is closed, and the worktree is already torn down (cleanup status: {cleanup}). Do not ' +
136
171
  're-implement, re-review, or re-ship anything — produce the final report for issue #{issue} and ' +
137
- 'post its runstate milestone.';
172
+ 'post its runstate milestone.\n\n' +
173
+ // A report slot is assigned fresh, so it starts at generation 0 — but it reports on
174
+ // the SAME run id, which may have been fenced earlier in the cycle. Without this the
175
+ // report milestone is refused and the unit recovers to the cap on a merged PR.
176
+ 'This run may have been superseded earlier: read its generation with `ai-dossier runstate ' +
177
+ 'verify --issue {issue} --json` and pass that `generation` value as `--gen <n>` on your ' +
178
+ '`runstate post`, or the milestone will be refused.';
138
179
  /**
139
180
  * Default prompt for the ONE bounded fix attempt a batch member gets before it
140
181
  * is evicted (#472 AC2). Deliberately narrow: the agent fixes the named
@@ -150,6 +191,14 @@ exports.DEFAULT_FIX_PROMPT_TEMPLATE = withNoBackgroundExit('The aggregate test s
150
191
  're-plan the issue, and do not open a PR. Commit the fix on this branch with the `(#{issue})` ' +
151
192
  'subject trailer. This is the only fix attempt — if the suite is still red afterwards the ' +
152
193
  "member's commits are reverted and it is requeued as a standalone full-cycle run.");
194
+ /**
195
+ * Substitute `{name}` placeholders. Unknown placeholders are left as-is, so a template
196
+ * naming a variable this build does not supply reads as an obvious defect rather than
197
+ * silently becoming an empty string.
198
+ */
199
+ function renderTemplate(template, vars) {
200
+ return Object.entries(vars).reduce((out, [key, value]) => out.replaceAll(`{${key}}`, String(value)), template);
201
+ }
153
202
  /** Failing tests rendered into the fix prompt before it is truncated. */
154
203
  const MAX_PROMPT_TESTS = 50;
155
204
  /** Characters kept per rendered test id. */
@@ -164,7 +213,9 @@ function resolveDispatch(config) {
164
213
  };
165
214
  return {
166
215
  command: dispatch.command ?? [...exports.DEFAULT_DISPATCH_COMMAND],
167
- prompt: dispatch.prompt ?? exports.DEFAULT_PROMPT_TEMPLATE,
216
+ // Wrapped here, not only on the constant: a configured prompt is still a cycle
217
+ // agent that can be superseded mid-run.
218
+ prompt: withSupersessionCheckpoint(dispatch.prompt ?? exports.DEFAULT_PROMPT_TEMPLATE),
168
219
  reportPrompt: dispatch.report_prompt ?? exports.DEFAULT_REPORT_PROMPT_TEMPLATE,
169
220
  fixPrompt: dispatch.fix_prompt ?? exports.DEFAULT_FIX_PROMPT_TEMPLATE,
170
221
  tierModels,
@@ -172,6 +223,7 @@ function resolveDispatch(config) {
172
223
  phaseStallTimeoutMs: resolvePhaseStallTimeouts(config),
173
224
  reconcileIntervalMs: config.reconcile_interval_ms ?? types_1.DEFAULT_RECONCILE_INTERVAL_MS,
174
225
  prPollIntervalMs: config.pr_poll_interval_ms ?? types_1.DEFAULT_PR_POLL_INTERVAL_MS,
226
+ fenceTakeoverTimeoutMs: dispatch.fence_takeover_timeout_ms ?? types_1.DEFAULT_FENCE_TAKEOVER_TIMEOUT_MS,
175
227
  };
176
228
  }
177
229
  /**
@@ -213,6 +265,18 @@ function stallTimeoutForPhase(dispatch, phase) {
213
265
  }
214
266
  return dispatch.stallTimeoutMs;
215
267
  }
268
+ /**
269
+ * The stall allowance for a slot: the phase timeout, shortened to
270
+ * `fenceTakeoverTimeoutMs` while a takeover has posted nothing at all (#504 AC4).
271
+ *
272
+ * `Math.min`, so the short window can only ever bring recovery FORWARD. A phase whose
273
+ * own allowance is already shorter than the fence window keeps it — a takeover should
274
+ * never get MORE time than a first dispatch would have had for the same phase.
275
+ */
276
+ function stallTimeoutForSlot(dispatch, phase, fencedAt) {
277
+ const phaseMs = stallTimeoutForPhase(dispatch, phase);
278
+ return fencedAt === null ? phaseMs : Math.min(phaseMs, dispatch.fenceTakeoverTimeoutMs);
279
+ }
216
280
  /**
217
281
  * Build the concrete agent argv for one dispatch: substitute `{issue}` and
218
282
  * `{model}`. When the tier's model is null, the `{model}` item AND its
@@ -237,16 +301,45 @@ function buildAgentCommand(template, tier, issue, tierModels) {
237
301
  }
238
302
  return argv;
239
303
  }
240
- /** Build the child's stdin prompt for one dispatch. */
241
- function buildPrompt(template, issue) {
242
- return template.replaceAll('{issue}', String(issue));
304
+ /**
305
+ * What a takeover agent is told about the run it inherited (#504).
306
+ *
307
+ * Appended only for `gen > 0`, so an ordinary first dispatch reads exactly as it does
308
+ * today. Two instructions, both load-bearing: pass `--gen` so the agent's own posts are
309
+ * accepted (the CLI refuses a lower generation), and CHECK before the expensive phases so
310
+ * it discovers its own supersession early if it is itself replaced later.
311
+ */
312
+ function takeoverInstruction(issue, gen) {
313
+ return (`TAKEOVER — you are generation ${gen} of the run on issue #${issue}: an earlier agent was ` +
314
+ 'superseded and fenced out of the runstate trail. Pass `--gen ' +
315
+ `${gen}\` on EVERY \`ai-dossier runstate post\` for this issue, or the post is refused. ` +
316
+ `Before implement, before review, and before ship, run \`ai-dossier runstate check --issue ${issue} ` +
317
+ `--run <run_id> --gen ${gen}\`; a non-zero exit means YOU have been superseded in turn — stop ` +
318
+ 'immediately, do not push, and do not open a PR. Resume the existing work rather than ' +
319
+ 'restarting it: the trail and the pushed branch are the durable state.');
320
+ }
321
+ /**
322
+ * Build the child's stdin prompt for one dispatch.
323
+ *
324
+ * `gen` is the runstate generation the agent owns; 0 (the default) is a first dispatch
325
+ * and produces today's prompt unchanged.
326
+ */
327
+ function buildPrompt(template, issue, gen = 0) {
328
+ const rendered = renderTemplate(template, { issue, gen });
329
+ return gen > 0 ? `${rendered}\n\n${takeoverInstruction(issue, gen)}` : rendered;
243
330
  }
244
- /** Build the report agent's stdin prompt (#468): `{issue}`/`{pr}`/`{cleanup}` substituted. */
245
- function buildReportPrompt(template, issue, pr, cleanup) {
246
- return template
247
- .replaceAll('{issue}', String(issue))
248
- .replaceAll('{pr}', String(pr))
249
- .replaceAll('{cleanup}', cleanup);
331
+ /**
332
+ * Build the report agent's stdin prompt (#468): `{issue}`/`{pr}`/`{cleanup}`/`{gen}`
333
+ * substituted, with the takeover instruction appended for `gen > 0` (#504).
334
+ *
335
+ * A report slot rides the same recovery ladder as a cycle slot, so it can be fenced and
336
+ * respawned as a takeover — and a report agent that did not know its generation would
337
+ * have its `report done` milestone refused, recovering to the escalation cap on a PR
338
+ * that already merged.
339
+ */
340
+ function buildReportPrompt(template, issue, pr, cleanup, gen = 0) {
341
+ const rendered = renderTemplate(template, { issue, pr, cleanup, gen });
342
+ return gen > 0 ? `${rendered}\n\n${takeoverInstruction(issue, gen)}` : rendered;
250
343
  }
251
344
  /**
252
345
  * Build the fix agent's stdin prompt (#472): `{issue}`, `{batch}` and the
@@ -271,10 +364,11 @@ function buildFixPrompt(template, issue, batch, tests) {
271
364
  .join('\n')
272
365
  : '- (none reported)';
273
366
  const truncated = tests.length > MAX_PROMPT_TESTS ? `\n- …and ${tests.length - MAX_PROMPT_TESTS} more` : '';
274
- return template
275
- .replaceAll('{issue}', String(issue))
276
- .replaceAll('{batch}', flatten(batch))
277
- .replaceAll('{tests}', rendered + truncated);
367
+ return renderTemplate(template, {
368
+ issue,
369
+ batch: flatten(batch),
370
+ tests: rendered + truncated,
371
+ });
278
372
  }
279
373
  /** One tier stronger on the ladder, or null at the top (RFC-0001 §C.1). */
280
374
  function escalateTier(tier) {
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqJH,0CAkBC;AAsCD,oDAKC;AAQD,8CAqBC;AAGD,kCAEC;AAGD,8CAUC;AAaD,wCAwBC;AAGD,oCAEC;AAQD,sCAEC;AAiCD,kCAEC;AAYD,sCAcC;AAcD,0CAyEC;AAvcD,2DAA2C;AAC3C,4CAA8B;AAC9B,gDAAkC;AAClC,uCAAyC;AACzC,mCAUiB;AAEjB,8EAA8E;AACjE,QAAA,mBAAmB,GAAwC;IACtE,UAAU,EAAE,OAAO;IACnB,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,MAAM;CACf,CAAC;AAEF,0FAA0F;AAC7E,QAAA,wBAAwB,GAAsB;IACzD,QAAQ;IACR,IAAI;IACJ,iBAAiB;IACjB,MAAM;IACN,SAAS;IACT,SAAS;CACV,CAAC;AAEF,oEAAoE;AACvD,QAAA,yBAAyB,GAAsB;IAC1D,UAAU;IACV,KAAK;IACL,QAAQ;IACR,UAAU;IACV,MAAM;IACN,SAAS;IACT,SAAS;CACV,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,8BAA8B,GACzC,+FAA+F;IAC/F,gGAAgG;IAChG,0FAA0F;IAC1F,mBAAmB,CAAC;AAEtB,mGAAmG;AACnG,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,OAAO,GAAG,QAAQ,OAAO,sCAA8B,EAAE,CAAC;AAC5D,CAAC;AAED;;;;;;;GAOG;AACU,QAAA,uBAAuB,GAAG,oBAAoB,CACzD,qFAAqF;IACnF,2FAA2F;IAC3F,iGAAiG;IACjG,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AC,GAAG,CAAC,CAAC;gBACvC,IAAI,KAAK,KAAK,IAAI;oBAAE,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACxD,OAAO,KAAK,CAAC,GAAG,CAAC;YACnB,CAAC;oBAAS,CAAC;gBACT,wEAAwE;gBACxE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,GAAW,EAAE,aAAsB;YACtC,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;gBAC9C,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC,CAAC,oDAAoD;YACpE,CAAC;YACD,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QACD,OAAO,CAAC,GAAW,EAAE,aAAsB;YACzC,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACrB,OAAO,oBAAoB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;YAClD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAQ,GAA6B,CAAC,IAAI,KAAK,OAAO,CAAC;YACzD,CAAC;QACH,CAAC;QACD,YAAY,CAAC,GAAW;YACtB,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/engine.d.ts CHANGED
@@ -52,6 +52,7 @@
52
52
  * member sequencing is a follow-up (#464 non-goal).
53
53
  */
54
54
  import { type SpawnDeps } from './dispatch';
55
+ import type { RunFencer } from './fence';
55
56
  import { type GroundTruth } from './groundtruth';
56
57
  import { type Journal } from './journal';
57
58
  import type { SchedStore } from './persist';
@@ -67,6 +68,12 @@ export interface EngineDeps {
67
68
  repoDir: string;
68
69
  /** Exec for teardown scripts (#468); injectable so tests never touch git/npx. */
69
70
  teardownExec: ExecFn;
71
+ /**
72
+ * Writes the takeover record before a redispatch respawns (#504). Optional: an
73
+ * engine constructed without one redispatches exactly as it did before fencing
74
+ * existed, journaling `fence-failed` so the gap is visible rather than silent.
75
+ */
76
+ fencer?: RunFencer;
70
77
  }
71
78
  /** What one tick did — surfaced by `sched start`. */
72
79
  export interface TickResult {
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAGH,OAAO,EAQL,KAAK,SAAS,EAKf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAe,KAAK,OAAO,EAAa,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAIxC,OAAO,EAML,KAAK,WAAW,EAMjB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;IACrB,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qDAAqD;AACrD,MAAM,WAAW,UAAU;IACzB,8DAA8D;IAC9D,OAAO,EAAE,MAAM,E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