@ai-dossier/sched 0.2.0 → 0.2.1

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.
Files changed (53) hide show
  1. package/dist/dispatch.d.ts +103 -0
  2. package/dist/dispatch.d.ts.map +1 -0
  3. package/dist/dispatch.js +262 -0
  4. package/dist/dispatch.js.map +1 -0
  5. package/dist/engine.d.ts +71 -0
  6. package/dist/engine.d.ts.map +1 -0
  7. package/dist/engine.js +590 -0
  8. package/dist/engine.js.map +1 -0
  9. package/dist/enqueue.d.ts +38 -0
  10. package/dist/enqueue.d.ts.map +1 -0
  11. package/dist/enqueue.js +220 -0
  12. package/dist/enqueue.js.map +1 -0
  13. package/dist/groundtruth.d.ts +74 -0
  14. package/dist/groundtruth.d.ts.map +1 -0
  15. package/dist/groundtruth.js +114 -0
  16. package/dist/groundtruth.js.map +1 -0
  17. package/dist/index.d.ts +13 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +86 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/journal.d.ts +32 -0
  22. package/dist/journal.d.ts.map +1 -0
  23. package/dist/journal.js +113 -0
  24. package/dist/journal.js.map +1 -0
  25. package/dist/persist.d.ts +54 -0
  26. package/dist/persist.d.ts.map +1 -0
  27. package/dist/persist.js +334 -0
  28. package/dist/persist.js.map +1 -0
  29. package/dist/project.d.ts +41 -0
  30. package/dist/project.d.ts.map +1 -0
  31. package/dist/project.js +124 -0
  32. package/dist/project.js.map +1 -0
  33. package/dist/readiness.d.ts +43 -0
  34. package/dist/readiness.d.ts.map +1 -0
  35. package/dist/readiness.js +102 -0
  36. package/dist/readiness.js.map +1 -0
  37. package/dist/scheduler.d.ts +66 -0
  38. package/dist/scheduler.d.ts.map +1 -0
  39. package/dist/scheduler.js +174 -0
  40. package/dist/scheduler.js.map +1 -0
  41. package/dist/state.d.ts +39 -0
  42. package/dist/state.d.ts.map +1 -0
  43. package/dist/state.js +360 -0
  44. package/dist/state.js.map +1 -0
  45. package/dist/status.d.ts +32 -0
  46. package/dist/status.d.ts.map +1 -0
  47. package/dist/status.js +76 -0
  48. package/dist/status.js.map +1 -0
  49. package/dist/types.d.ts +214 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/types.js +87 -0
  52. package/dist/types.js.map +1 -0
  53. package/package.json +2 -2
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Types for the deterministic scheduler core (RFC-0001 §B/C.1/D, issue #460).
3
+ *
4
+ * The state unions below are the RFC-0001 §D state machines frozen into types.
5
+ * `state.ts` owns the transition tables; nothing here does I/O. The package
6
+ * itself never invokes an LLM: it spawns the agent process the operator
7
+ * configured (dispatch.ts) and reads ground truth via injectable subprocess
8
+ * exec (project.ts, groundtruth.ts) — never an LLM call of its own (AC7).
9
+ */
10
+ /** Execution mode of a queue entry. `full` runs the unchanged full-cycle; `slot` runs as a batch member. */
11
+ export type CycleMode = 'full' | 'slot';
12
+ /** Model tier the entry is dispatched at (RFC-0001 role-based routing: mechanical / generation / judgment). */
13
+ export type ModelTier = 'mechanical' | 'mid' | 'strong';
14
+ /**
15
+ * Issue lifecycle per RFC-0001 §D.1:
16
+ *
17
+ * ```
18
+ * queued → classified{full|slot}
19
+ * full: → dispatched → (full-cycle's own phase trail) → shipped → done
20
+ * slot: → batched(b) → waiting → in-work → committed(range) → validated
21
+ * → shipped-in-batch → done
22
+ * failure edges (any state):
23
+ * in-work/committed → evicted(reason) → requeued{full}
24
+ * any → blocked(dep-failed) | decision-pending | failed(escalation-cap)
25
+ * ```
26
+ */
27
+ export type IssueStatus = 'queued' | 'classified' | 'dispatched' | 'shipped' | 'done' | 'batched' | 'waiting' | 'in-work' | 'committed' | 'validated' | 'shipped-in-batch' | 'evicted' | 'requeued' | 'blocked' | 'decision-pending' | 'failed';
28
+ /** Issue statuses that cannot transition further. */
29
+ export declare const TERMINAL_ISSUE_STATUSES: ReadonlySet<IssueStatus>;
30
+ /**
31
+ * Statuses that mean the issue's work has merged. Dependency edges gate on
32
+ * these: "an issue with an unmerged dependency is never runnable" (AC5).
33
+ */
34
+ export declare const SATISFIED_ISSUE_STATUSES: ReadonlySet<IssueStatus>;
35
+ /**
36
+ * Batch lifecycle per RFC-0001 §D.2:
37
+ *
38
+ * ```
39
+ * forming → ready → executing(member i/N) ⟲ → validating → reviewing → shipping
40
+ * → awaiting-merge → merged → deployed → reported → done
41
+ * failure edges:
42
+ * validating → attributing → fixing(1 bounded attempt) → validating
43
+ * → evicting(revert range) → validating
44
+ * evictions > ⅓ OR revert-conflict → dissolving → members requeued
45
+ * awaiting-merge: CONFLICTING | auto-merge-blocked → rebasing → re-validating → shipping
46
+ * (2nd failure → dissolved)
47
+ * ```
48
+ */
49
+ export type BatchStatus = 'forming' | 'ready' | 'executing' | 'validating' | 'attributing' | 'fixing' | 'evicting' | 'reviewing' | 'shipping' | 'awaiting-merge' | 'rebasing' | 're-validating' | 'merged' | 'deployed' | 'reported' | 'done' | 'dissolving' | 'dissolved';
50
+ /** Batch statuses that cannot transition further. */
51
+ export declare const TERMINAL_BATCH_STATUSES: ReadonlySet<BatchStatus>;
52
+ /**
53
+ * Batch statuses that mean the batch's PR has merged. Cross-batch dependency
54
+ * edges gate on these (a batch is never dispatched while a batch it depends
55
+ * on is unmerged — RFC-0001 §E.4 "scheduler gates on merge").
56
+ */
57
+ export declare const MERGED_BATCH_STATUSES: ReadonlySet<BatchStatus>;
58
+ /**
59
+ * Worker slot lifecycle per RFC-0001 §D.3:
60
+ *
61
+ * ```
62
+ * idle → assigned(unit) → running(pid, phase, last_progress_at)
63
+ * → exited → verifying(reconcile vs GitHub/runstate) → complete → idle
64
+ * stall: running[30 min no progress] → recovering(redispatch tier+1, ≤2) → running | failed → idle
65
+ * ```
66
+ */
67
+ export type SlotStatus = 'idle' | 'assigned' | 'running' | 'exited' | 'verifying' | 'complete' | 'recovering' | 'failed';
68
+ /** Slot statuses that hold a live unit against `max_slots`. */
69
+ export declare const LIVE_SLOT_STATUSES: ReadonlySet<SlotStatus>;
70
+ /** One queued unit of work (RFC-0001 §C.1 "queue entries"). */
71
+ export interface QueueEntry {
72
+ /** GitHub issue number. Unique among active entries. */
73
+ issue: number;
74
+ /** Execution mode for this issue. */
75
+ mode: CycleMode;
76
+ /** Batch id when `mode === 'slot'`; always null for `full`. */
77
+ batch: string | null;
78
+ /** Issue numbers this entry depends on (edges gate readiness). */
79
+ deps: number[];
80
+ /** Model tier the entry is dispatched at. */
81
+ tier: ModelTier;
82
+ /** Current D.1 state. */
83
+ status: IssueStatus;
84
+ /** Free-form reason attached to failure-edge transitions (evicted/blocked/failed). */
85
+ reason: string | null;
86
+ enqueued_at: string;
87
+ updated_at: string;
88
+ }
89
+ /** A batch of slot-mode issues sharing one lifecycle (RFC-0001 §C.4/E.4). */
90
+ export interface BatchEntry {
91
+ id: string;
92
+ status: BatchStatus;
93
+ /** Member issue numbers, in dispatch order. */
94
+ members: number[];
95
+ base_branch: string;
96
+ /** Index of the member currently in work, when status is `executing` (1-based member pointer). */
97
+ executing_member: number;
98
+ created_at: string;
99
+ updated_at: string;
100
+ }
101
+ /** A worker slot (RFC-0001 §D.3). */
102
+ export interface SlotEntry {
103
+ id: number;
104
+ status: SlotStatus;
105
+ /** Unit identifier currently held: `issue:<n>` or `batch:<id>`; null when idle. */
106
+ unit: string | null;
107
+ /** OS pid of the spawned agent process, when known (#464 dispatch). */
108
+ pid: number | null;
109
+ /**
110
+ * `/proc/<pid>/stat` start-time (field 22) recorded at spawn, when
111
+ * available (Linux). Persisted so a restarted sched can verify a state.json
112
+ * pid still belongs to our agent — a mismatched start time means the pid
113
+ * was reused by an unrelated process and must never be signalled (decision
114
+ * 1, option C). Null on platforms without /proc: best-effort.
115
+ */
116
+ pid_start: number | null;
117
+ /** Scheduler phase the unit is in, when running. */
118
+ phase: string | null;
119
+ /** Last progress signal (new milestone or pushed commit) — stall-timer anchor. */
120
+ last_progress_at: string | null;
121
+ /** Working branch of the unit, captured from the setup milestone's `branch=` key. */
122
+ branch: string | null;
123
+ /** Last seen head sha of `branch` on origin — the "new pushed commit" stall signal. */
124
+ last_head: string | null;
125
+ /** Recovery attempts for the current unit (stall ladder, cap 2 — RFC-0001 §C.1). */
126
+ recoveries: number;
127
+ updated_at: string;
128
+ }
129
+ /** Hot operational truth, persisted transactionally to `state.json` (RFC-0001 §D.4). */
130
+ export interface SchedState {
131
+ schema_version: typeof SCHEMA_VERSION;
132
+ /** When true, `computeAssignments` returns no assignments (sched pause). */
133
+ paused: boolean;
134
+ entries: QueueEntry[];
135
+ batches: BatchEntry[];
136
+ slots: SlotEntry[];
137
+ /** Monotonic counter for stable slot ids. */
138
+ next_slot_id: number;
139
+ }
140
+ /** Durable intent, persisted separately in `config.json` (state.json is rebuildable hot truth). */
141
+ export interface SchedConfig {
142
+ max_slots: number;
143
+ /** Stall timeout in ms — no new milestone AND no new pushed commit for this long → redispatch stronger (default 30 min). */
144
+ stall_timeout_ms?: number;
145
+ /** Reconciliation tick interval in ms (default 60 000). */
146
+ reconcile_interval_ms?: number;
147
+ /** Agent dispatch settings (#464); every field optional with engine defaults. */
148
+ dispatch?: DispatchConfig;
149
+ }
150
+ /**
151
+ * Agent dispatch configuration (#464). The command is a template: `{model}`
152
+ * and `{issue}` placeholders are substituted per dispatch; a `{model}` item
153
+ * whose tier has no model configured drops together with its flag.
154
+ */
155
+ export interface DispatchConfig {
156
+ /** Command template, e.g. `['claude','-p','--output-format','json','--model','{model}']`. */
157
+ command?: string[];
158
+ /** Prompt template sent on the child's stdin; `{issue}` substituted. */
159
+ prompt?: string;
160
+ /** Tier → model id/alias mapping (defaults: haiku / sonnet / opus). */
161
+ tier_models?: Partial<Record<ModelTier, string>>;
162
+ }
163
+ /** The escalation ladder: one tier stronger, or null at the top (RFC-0001 §C.1). */
164
+ export declare const TIER_LADDER: Readonly<Record<ModelTier, ModelTier | null>>;
165
+ /** Cap on recovery attempts before a unit fails (RFC-0001 §C.1 "cap 2"). */
166
+ export declare const ESCALATION_CAP = 2;
167
+ /** Default stall timeout: 30 minutes without a milestone or pushed commit (RFC-0001 §C.1). */
168
+ export declare const DEFAULT_STALL_TIMEOUT_MS: number;
169
+ /** Default reconciliation tick: ~60s (RFC-0001 §C.1). */
170
+ export declare const DEFAULT_RECONCILE_INTERVAL_MS: number;
171
+ export declare const SCHEMA_VERSION: "1.1.0";
172
+ /** Schema versions `validateState` accepts on load (migrated to SCHEMA_VERSION on save). */
173
+ export declare const LEGACY_SCHEMA_VERSIONS: readonly string[];
174
+ export declare const CONFIG_SCHEMA_VERSION: "1.1.0";
175
+ /** Config schema versions `loadConfig` accepts (older configs carry only max_slots). */
176
+ export declare const LEGACY_CONFIG_SCHEMA_VERSIONS: readonly string[];
177
+ /** Config file shape (schema_version + the config itself). */
178
+ export interface SchedConfigFile {
179
+ schema_version: string;
180
+ max_slots: number;
181
+ stall_timeout_ms?: number;
182
+ reconcile_interval_ms?: number;
183
+ dispatch?: DispatchConfig;
184
+ }
185
+ export declare const DEFAULT_MAX_SLOTS = 3;
186
+ /** Bounds for `max_slots` when reading `config.json` (named — not magic numbers in persist.ts). */
187
+ export declare const MIN_MAX_SLOTS = 1;
188
+ export declare const MAX_MAX_SLOTS = 64;
189
+ /** Thrown by every non-declared state-machine edge. */
190
+ export declare class IllegalTransitionError extends Error {
191
+ readonly kind: 'issue' | 'batch' | 'slot';
192
+ readonly from: string;
193
+ readonly to: string;
194
+ constructor(kind: 'issue' | 'batch' | 'slot', from: string, to: string);
195
+ }
196
+ /** Thrown when an issue, batch, or slot id does not exist in the state. */
197
+ export declare class SchedNotFoundError extends Error {
198
+ constructor(message: string);
199
+ }
200
+ /** 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';
202
+ /** One journaled event. `ts` is stamped by the journal, never by callers. */
203
+ export interface JournalEvent {
204
+ ts: string;
205
+ event: JournalEventName;
206
+ /** Unit the event concerns (`issue:<n>` / `batch:<id>`), when applicable. */
207
+ unit?: string;
208
+ slot?: number;
209
+ issue?: number;
210
+ pid?: number;
211
+ tier?: ModelTier;
212
+ detail?: string;
213
+ }
214
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,4GAA4G;AAC5G,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAExC,+GAA+G;AAC/G,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC;AAIxD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,MAAM,GACN,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,WAAW,GACX,kBAAkB,GAClB,SAAS,GACT,UAAU,GACV,SAAS,GACT,kBAAkB,GAClB,QAAQ,CAAC;AAEb,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,WAAW,CAA+B,CAAC;AAE7F;;;GAGG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,WAAW,CAI5D,CAAC;AAIH;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,OAAO,GACP,WAAW,GACX,YAAY,GACZ,aAAa,GACb,QAAQ,GACR,UAAU,GACV,WAAW,GACX,UAAU,GACV,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,QAAQ,GACR,UAAU,GACV,UAAU,GACV,MAAM,GACN,YAAY,GACZ,WAAW,CAAC;AAEhB,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,WAAW,CAAkC,CAAC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UAAU,GACV,SAAS,GACT,eAAe,GACf,YAAY,GACZ,kBAAkB,GAClB,UAAU,GACV,eAAe,GACf,iBAAiB,GACjB,mBAAmB,GACnB,SAAS,GACT,cAAc,GACd,aAAa,GACb,oBAAoB,GACpB,UAAU,GACV,0BAA0B,GAC1B,aAAa,CAAC;AAElB,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,gBAAgB,CAAC;IACxB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
package/dist/types.js ADDED
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /**
3
+ * Types for the deterministic scheduler core (RFC-0001 §B/C.1/D, issue #460).
4
+ *
5
+ * The state unions below are the RFC-0001 §D state machines frozen into types.
6
+ * `state.ts` owns the transition tables; nothing here does I/O. The package
7
+ * itself never invokes an LLM: it spawns the agent process the operator
8
+ * configured (dispatch.ts) and reads ground truth via injectable subprocess
9
+ * exec (project.ts, groundtruth.ts) — never an LLM call of its own (AC7).
10
+ */
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;
13
+ /** Issue statuses that cannot transition further. */
14
+ exports.TERMINAL_ISSUE_STATUSES = new Set(['done', 'failed']);
15
+ /**
16
+ * Statuses that mean the issue's work has merged. Dependency edges gate on
17
+ * these: "an issue with an unmerged dependency is never runnable" (AC5).
18
+ */
19
+ exports.SATISFIED_ISSUE_STATUSES = new Set([
20
+ 'shipped',
21
+ 'shipped-in-batch',
22
+ 'done',
23
+ ]);
24
+ /** Batch statuses that cannot transition further. */
25
+ exports.TERMINAL_BATCH_STATUSES = new Set(['done', 'dissolved']);
26
+ /**
27
+ * Batch statuses that mean the batch's PR has merged. Cross-batch dependency
28
+ * edges gate on these (a batch is never dispatched while a batch it depends
29
+ * on is unmerged — RFC-0001 §E.4 "scheduler gates on merge").
30
+ */
31
+ exports.MERGED_BATCH_STATUSES = new Set([
32
+ 'merged',
33
+ 'deployed',
34
+ 'reported',
35
+ 'done',
36
+ ]);
37
+ /** Slot statuses that hold a live unit against `max_slots`. */
38
+ exports.LIVE_SLOT_STATUSES = new Set([
39
+ 'assigned',
40
+ 'running',
41
+ 'recovering',
42
+ ]);
43
+ /** The escalation ladder: one tier stronger, or null at the top (RFC-0001 §C.1). */
44
+ exports.TIER_LADDER = {
45
+ mechanical: 'mid',
46
+ mid: 'strong',
47
+ strong: null,
48
+ };
49
+ /** Cap on recovery attempts before a unit fails (RFC-0001 §C.1 "cap 2"). */
50
+ exports.ESCALATION_CAP = 2;
51
+ /** Default stall timeout: 30 minutes without a milestone or pushed commit (RFC-0001 §C.1). */
52
+ exports.DEFAULT_STALL_TIMEOUT_MS = 30 * 60 * 1000;
53
+ /** Default reconciliation tick: ~60s (RFC-0001 §C.1). */
54
+ exports.DEFAULT_RECONCILE_INTERVAL_MS = 60 * 1000;
55
+ exports.SCHEMA_VERSION = '1.1.0';
56
+ /** 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';
59
+ /** Config schema versions `loadConfig` accepts (older configs carry only max_slots). */
60
+ exports.LEGACY_CONFIG_SCHEMA_VERSIONS = ['1.0.0'];
61
+ exports.DEFAULT_MAX_SLOTS = 3;
62
+ /** Bounds for `max_slots` when reading `config.json` (named — not magic numbers in persist.ts). */
63
+ exports.MIN_MAX_SLOTS = 1;
64
+ exports.MAX_MAX_SLOTS = 64;
65
+ /** Thrown by every non-declared state-machine edge. */
66
+ class IllegalTransitionError extends Error {
67
+ kind;
68
+ from;
69
+ to;
70
+ constructor(kind, from, to) {
71
+ super(`Illegal ${kind} transition: ${from} → ${to}`);
72
+ this.name = 'IllegalTransitionError';
73
+ this.kind = kind;
74
+ this.from = from;
75
+ this.to = to;
76
+ }
77
+ }
78
+ exports.IllegalTransitionError = IllegalTransitionError;
79
+ /** Thrown when an issue, batch, or slot id does not exist in the state. */
80
+ class SchedNotFoundError extends Error {
81
+ constructor(message) {
82
+ super(message);
83
+ this.name = 'SchedNotFoundError';
84
+ }
85
+ }
86
+ exports.SchedNotFoundError = SchedNotFoundError;
87
+ //# sourceMappingURL=types.js.map
@@ -0,0 +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,SAAS;IACT,kBAAkB;IAClB,MAAM;CACP,CAAC,CAAC;AAsCH,qDAAqD;AACxC,QAAA,uBAAuB,GAA6B,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAEhG;;;;GAIG;AACU,QAAA,qBAAqB,GAA6B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E,GAAG,EAAE,CAAC;IACf,CAAC;CACF;AAZD,wDAYC;AAED,2EAA2E;AAC3E,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,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.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.",
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.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [