@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.
- package/dist/dispatch.d.ts +103 -0
- package/dist/dispatch.d.ts.map +1 -0
- package/dist/dispatch.js +262 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/engine.d.ts +71 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +590 -0
- package/dist/engine.js.map +1 -0
- package/dist/enqueue.d.ts +38 -0
- package/dist/enqueue.d.ts.map +1 -0
- package/dist/enqueue.js +220 -0
- package/dist/enqueue.js.map +1 -0
- package/dist/groundtruth.d.ts +74 -0
- package/dist/groundtruth.d.ts.map +1 -0
- package/dist/groundtruth.js +114 -0
- package/dist/groundtruth.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/journal.d.ts +32 -0
- package/dist/journal.d.ts.map +1 -0
- package/dist/journal.js +113 -0
- package/dist/journal.js.map +1 -0
- package/dist/persist.d.ts +54 -0
- package/dist/persist.d.ts.map +1 -0
- package/dist/persist.js +334 -0
- package/dist/persist.js.map +1 -0
- package/dist/project.d.ts +41 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +124 -0
- package/dist/project.js.map +1 -0
- package/dist/readiness.d.ts +43 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +102 -0
- package/dist/readiness.js.map +1 -0
- package/dist/scheduler.d.ts +66 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +174 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/state.d.ts +39 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +360 -0
- package/dist/state.js.map +1 -0
- package/dist/status.d.ts +32 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +76 -0
- package/dist/status.js.map +1 -0
- package/dist/types.d.ts +214 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +87 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
package/dist/enqueue.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Enqueue: accept queue entries from CLI flags or a batch-prep manifest
|
|
4
|
+
* (RFC-0001 §C.1 — "queue entries (issue → mode, batch membership, deps, tier)
|
|
5
|
+
* written by batch-prep"). Pure validation + state mutation: rejects duplicate
|
|
6
|
+
* active issues, mode/batch mismatches, self-dependencies, and dependency
|
|
7
|
+
* cycles at enqueue time rather than at assignment time.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EnqueueError = void 0;
|
|
11
|
+
exports.parseManifest = parseManifest;
|
|
12
|
+
exports.assertNoDependencyCycle = assertNoDependencyCycle;
|
|
13
|
+
exports.enqueueEntries = enqueueEntries;
|
|
14
|
+
const state_1 = require("./state");
|
|
15
|
+
const types_1 = require("./types");
|
|
16
|
+
class EnqueueError extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'EnqueueError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.EnqueueError = EnqueueError;
|
|
23
|
+
function asPositiveInt(value, label) {
|
|
24
|
+
if (!Number.isInteger(value) || value <= 0) {
|
|
25
|
+
throw new EnqueueError(`${label} must be a positive integer, got ${String(value)}`);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse a `--from-manifest` payload. Accepts either a bare array of entries or
|
|
31
|
+
* `{ "project": "...", "entries": [...] }` (the batch-prep output shape;
|
|
32
|
+
* `project` is accepted and ignored — the CLI resolves the project itself).
|
|
33
|
+
*/
|
|
34
|
+
function parseManifest(raw) {
|
|
35
|
+
const list = Array.isArray(raw)
|
|
36
|
+
? raw
|
|
37
|
+
: raw && typeof raw === 'object' && Array.isArray(raw.entries)
|
|
38
|
+
? raw.entries
|
|
39
|
+
: null;
|
|
40
|
+
if (list === null) {
|
|
41
|
+
throw new EnqueueError('Manifest must be a JSON array of entries or { "entries": [...] }');
|
|
42
|
+
}
|
|
43
|
+
return list.map((item, i) => {
|
|
44
|
+
if (!item || typeof item !== 'object') {
|
|
45
|
+
throw new EnqueueError(`Manifest entry [${i}] must be an object`);
|
|
46
|
+
}
|
|
47
|
+
const obj = item;
|
|
48
|
+
const input = {
|
|
49
|
+
issue: asPositiveInt(obj.issue, `Manifest entry [${i}]: issue`),
|
|
50
|
+
};
|
|
51
|
+
if (obj.mode !== undefined) {
|
|
52
|
+
if (obj.mode !== 'full' && obj.mode !== 'slot') {
|
|
53
|
+
throw new EnqueueError(`Manifest entry [${i}]: mode must be 'full' or 'slot'`);
|
|
54
|
+
}
|
|
55
|
+
input.mode = obj.mode;
|
|
56
|
+
}
|
|
57
|
+
if (obj.batch !== undefined && obj.batch !== null) {
|
|
58
|
+
if (typeof obj.batch !== 'string' || obj.batch.length === 0) {
|
|
59
|
+
throw new EnqueueError(`Manifest entry [${i}]: batch must be a non-empty string`);
|
|
60
|
+
}
|
|
61
|
+
input.batch = obj.batch;
|
|
62
|
+
}
|
|
63
|
+
if (obj.deps !== undefined) {
|
|
64
|
+
if (!Array.isArray(obj.deps)) {
|
|
65
|
+
throw new EnqueueError(`Manifest entry [${i}]: deps must be an array`);
|
|
66
|
+
}
|
|
67
|
+
input.deps = obj.deps.map((d, j) => asPositiveInt(d, `Manifest entry [${i}]: deps[${j}]`));
|
|
68
|
+
}
|
|
69
|
+
if (obj.tier !== undefined) {
|
|
70
|
+
if (obj.tier !== 'mechanical' && obj.tier !== 'mid' && obj.tier !== 'strong') {
|
|
71
|
+
throw new EnqueueError(`Manifest entry [${i}]: tier must be mechanical | mid | strong`);
|
|
72
|
+
}
|
|
73
|
+
input.tier = obj.tier;
|
|
74
|
+
}
|
|
75
|
+
if (obj.base_branch !== undefined) {
|
|
76
|
+
if (typeof obj.base_branch !== 'string' || obj.base_branch.length === 0) {
|
|
77
|
+
throw new EnqueueError(`Manifest entry [${i}]: base_branch must be a non-empty string`);
|
|
78
|
+
}
|
|
79
|
+
input.base_branch = obj.base_branch;
|
|
80
|
+
}
|
|
81
|
+
return input;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Dependency-cycle detection over the combined graph (existing entries +
|
|
86
|
+
* inputs). Deps pointing at issues not in the graph are allowed — they stay
|
|
87
|
+
* permanently unsatisfied and surface in `sched status`'s blocked set.
|
|
88
|
+
*/
|
|
89
|
+
function assertNoDependencyCycle(state, inputs) {
|
|
90
|
+
const edges = new Map();
|
|
91
|
+
for (const entry of state.entries) {
|
|
92
|
+
edges.set(entry.issue, [...entry.deps]);
|
|
93
|
+
}
|
|
94
|
+
for (const input of inputs) {
|
|
95
|
+
const existing = edges.get(input.issue) ?? [];
|
|
96
|
+
edges.set(input.issue, [...existing, ...(input.deps ?? [])]);
|
|
97
|
+
}
|
|
98
|
+
const WHITE = 0;
|
|
99
|
+
const GRAY = 1;
|
|
100
|
+
const BLACK = 2;
|
|
101
|
+
const color = new Map();
|
|
102
|
+
const visit = (node, stack) => {
|
|
103
|
+
const c = color.get(node) ?? WHITE;
|
|
104
|
+
if (c === BLACK)
|
|
105
|
+
return;
|
|
106
|
+
if (c === GRAY) {
|
|
107
|
+
const cycleStart = stack.indexOf(node);
|
|
108
|
+
const cycle = [...stack.slice(cycleStart), node].join(' → ');
|
|
109
|
+
throw new EnqueueError(`Dependency cycle detected: ${cycle}`);
|
|
110
|
+
}
|
|
111
|
+
color.set(node, GRAY);
|
|
112
|
+
for (const dep of edges.get(node) ?? []) {
|
|
113
|
+
if (edges.has(dep))
|
|
114
|
+
visit(dep, [...stack, node]);
|
|
115
|
+
}
|
|
116
|
+
color.set(node, BLACK);
|
|
117
|
+
};
|
|
118
|
+
for (const node of edges.keys()) {
|
|
119
|
+
visit(node, []);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Append validated entries to the queue (AC1). Returns the new state; throws
|
|
124
|
+
* `EnqueueError` on any rejection — the caller saves nothing when it throws.
|
|
125
|
+
*/
|
|
126
|
+
function enqueueEntries(state, inputs, now = new Date()) {
|
|
127
|
+
if (inputs.length === 0) {
|
|
128
|
+
throw new EnqueueError('No entries to enqueue');
|
|
129
|
+
}
|
|
130
|
+
const seen = new Set();
|
|
131
|
+
for (const input of inputs) {
|
|
132
|
+
asPositiveInt(input.issue, 'issue');
|
|
133
|
+
if (input.deps?.includes(input.issue)) {
|
|
134
|
+
throw new EnqueueError(`Issue ${input.issue} cannot depend on itself`);
|
|
135
|
+
}
|
|
136
|
+
if (seen.has(input.issue)) {
|
|
137
|
+
throw new EnqueueError(`Duplicate issue in enqueue input: ${input.issue}`);
|
|
138
|
+
}
|
|
139
|
+
// The persistence boundary: enqueue must only ever produce state that
|
|
140
|
+
// validateState (and therefore the next load) accepts.
|
|
141
|
+
if (input.batch !== undefined && input.batch !== null && input.batch.length === 0) {
|
|
142
|
+
throw new EnqueueError(`Issue ${input.issue}: batch must be a non-empty string`);
|
|
143
|
+
}
|
|
144
|
+
if (input.mode !== undefined && input.mode !== 'full' && input.mode !== 'slot') {
|
|
145
|
+
throw new EnqueueError(`Issue ${input.issue}: mode must be 'full' or 'slot'`);
|
|
146
|
+
}
|
|
147
|
+
if (input.tier !== undefined &&
|
|
148
|
+
input.tier !== 'mechanical' &&
|
|
149
|
+
input.tier !== 'mid' &&
|
|
150
|
+
input.tier !== 'strong') {
|
|
151
|
+
throw new EnqueueError(`Issue ${input.issue}: tier must be mechanical | mid | strong`);
|
|
152
|
+
}
|
|
153
|
+
seen.add(input.issue);
|
|
154
|
+
}
|
|
155
|
+
for (const input of inputs) {
|
|
156
|
+
const existing = state.entries.find((e) => e.issue === input.issue);
|
|
157
|
+
if (existing && !types_1.TERMINAL_ISSUE_STATUSES.has(existing.status)) {
|
|
158
|
+
throw new EnqueueError(`Issue ${input.issue} is already in the queue (status: ${existing.status})`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
assertNoDependencyCycle(state, inputs);
|
|
162
|
+
const timestamp = now.toISOString();
|
|
163
|
+
const entries = inputs.map((input) => {
|
|
164
|
+
const mode = input.mode ?? 'full';
|
|
165
|
+
const batch = input.batch ?? null;
|
|
166
|
+
if (mode === 'slot' && batch === null) {
|
|
167
|
+
throw new EnqueueError(`Issue ${input.issue}: slot mode requires a batch id`);
|
|
168
|
+
}
|
|
169
|
+
if (mode === 'full' && batch !== null) {
|
|
170
|
+
throw new EnqueueError(`Issue ${input.issue}: full mode cannot carry a batch id`);
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
issue: input.issue,
|
|
174
|
+
mode,
|
|
175
|
+
batch,
|
|
176
|
+
deps: input.deps ? [...input.deps] : [],
|
|
177
|
+
tier: input.tier ?? 'mid',
|
|
178
|
+
status: 'queued',
|
|
179
|
+
reason: null,
|
|
180
|
+
enqueued_at: timestamp,
|
|
181
|
+
updated_at: timestamp,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
// Create batches for unseen slot batch ids; reject joining a batch that has
|
|
185
|
+
// already left `forming` (composition is frozen when the batch seals). Only
|
|
186
|
+
// batches actually joined get `updated_at` bumped — a blanket rewrite would
|
|
187
|
+
// churn the audit signal on every enqueue.
|
|
188
|
+
const batches = state.batches.map((b) => ({ ...b }));
|
|
189
|
+
for (const input of inputs) {
|
|
190
|
+
const batchId = input.batch;
|
|
191
|
+
if (batchId === null || batchId === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
const existing = (0, state_1.findBatch)({ ...state, batches }, batchId);
|
|
194
|
+
if (existing) {
|
|
195
|
+
if (existing.status !== 'forming') {
|
|
196
|
+
throw new EnqueueError(`Batch ${batchId} is ${existing.status} — members can only join while forming`);
|
|
197
|
+
}
|
|
198
|
+
if (input.base_branch !== undefined && input.base_branch !== existing.base_branch) {
|
|
199
|
+
throw new EnqueueError(`Batch ${batchId} was enqueued with base '${existing.base_branch}' — refusing to silently rebase it to '${input.base_branch}'`);
|
|
200
|
+
}
|
|
201
|
+
if (existing.members.includes(input.issue))
|
|
202
|
+
continue;
|
|
203
|
+
existing.members = [...existing.members, input.issue];
|
|
204
|
+
existing.updated_at = timestamp;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
batches.push({
|
|
208
|
+
id: batchId,
|
|
209
|
+
status: 'forming',
|
|
210
|
+
members: [input.issue],
|
|
211
|
+
base_branch: input.base_branch ?? 'main',
|
|
212
|
+
executing_member: 0,
|
|
213
|
+
created_at: timestamp,
|
|
214
|
+
updated_at: timestamp,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return { ...state, entries: [...state.entries, ...entries], batches };
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=enqueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enqueue.js","sourceRoot":"","sources":["../src/enqueue.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmCH,sCAiDC;AAOD,0DAiCC;AAMD,wCA4GC;AA5OD,mCAAoC;AAEpC,mCAAkD;AAElD,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAYD,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAK,KAAgB,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,YAAY,CAAC,GAAG,KAAK,oCAAoC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,KAAe,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAA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AAO,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ground truth for completion verification (#464, AC2 — "an agent exiting is
|
|
3
|
+
* never proof of completion"). The engine never trusts the spawned agent's own
|
|
4
|
+
* exit; it reconciles the claimed state against the durable sources — the
|
|
5
|
+
* issue's runstate milestone trail (`ai-dossier runstate last`) and GitHub
|
|
6
|
+
* itself (`gh issue view`), plus `git ls-remote` for the "new pushed commit"
|
|
7
|
+
* stall signal.
|
|
8
|
+
*
|
|
9
|
+
* Everything is injectable (the `ExecFn` pattern from project.ts): tests —
|
|
10
|
+
* and any consumer — supply fake ground truth and no subprocess runs.
|
|
11
|
+
*/
|
|
12
|
+
import { type ExecFn } from './project';
|
|
13
|
+
/** The latest runstate milestone on an issue, as `runstate last --json` reports it. */
|
|
14
|
+
export interface GroundTruthMilestone {
|
|
15
|
+
phase: string;
|
|
16
|
+
status: string;
|
|
17
|
+
run: string;
|
|
18
|
+
at: string;
|
|
19
|
+
/** Every `key=value` line of the milestone, including the header's. */
|
|
20
|
+
keys: Record<string, string>;
|
|
21
|
+
}
|
|
22
|
+
export interface GroundTruth {
|
|
23
|
+
/**
|
|
24
|
+
* Latest runstate milestone on the issue. **Tri-state (decision 2, option
|
|
25
|
+
* A):** an object = the milestone; `null` = the issue verifiably has NO
|
|
26
|
+
* milestone (known-absent); `undefined` = the poll FAILED (unreachable —
|
|
27
|
+
* gh auth expired, `ai-dossier` missing, network down). Callers must PAUSE
|
|
28
|
+
* decisions that need truth (stall, verify-fail) while unreachable, never
|
|
29
|
+
* treat it as "no progress".
|
|
30
|
+
*/
|
|
31
|
+
latestMilestone(issue: number): GroundTruthMilestone | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the GitHub issue is CLOSED (a merged PR auto-closes it). False
|
|
34
|
+
* when unreachable — an unreachable poll can never *confirm* completion,
|
|
35
|
+
* which is the only direction this signal is used in.
|
|
36
|
+
*/
|
|
37
|
+
issueClosed(issue: number): boolean;
|
|
38
|
+
/** Current head sha of `branch` on origin, or null when unknown/absent/unreachable. */
|
|
39
|
+
branchHead(branch: string): string | null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Default exec for ground-truth calls: like project.ts's `defaultExec` (never
|
|
43
|
+
* throws) but with a hard timeout so a hung `gh`/`git` cannot stall a tick
|
|
44
|
+
* indefinitely (ground truth is polled outside the state lock), and a failure
|
|
45
|
+
* observer that warns on stderr — a broken ground-truth environment (gh auth
|
|
46
|
+
* expired, `ai-dossier` missing from a cron PATH) is never silent.
|
|
47
|
+
*/
|
|
48
|
+
export declare const groundTruthExec: ExecFn;
|
|
49
|
+
/** Parse the stdout of `ai-dossier runstate last --issue N --json`. */
|
|
50
|
+
export declare function parseMilestoneJson(stdout: string | null): GroundTruthMilestone | null;
|
|
51
|
+
/**
|
|
52
|
+
* Ground truth backed by subprocess calls:
|
|
53
|
+
* - `ai-dossier runstate last --issue N --json` — the milestone trail
|
|
54
|
+
* - `gh issue view N --json state --jq .state` — issue closed
|
|
55
|
+
* - `git ls-remote origin <branch>` — branch head
|
|
56
|
+
*
|
|
57
|
+
* `repoDir` is the cwd for git; gh resolves the repo from cwd by default.
|
|
58
|
+
* Every failure degrades safely: a failed milestone poll reports UNREACHABLE
|
|
59
|
+
* (undefined — decision 2, option A), a failed closed-poll reports false, a
|
|
60
|
+
* failed head-poll null. Ground truth being unreachable pauses the engine's
|
|
61
|
+
* stall/verify decisions; it never crashes a tick.
|
|
62
|
+
*/
|
|
63
|
+
export declare function createExecGroundTruth(exec?: ExecFn, opts?: {
|
|
64
|
+
repoDir?: string;
|
|
65
|
+
runstateBin?: string;
|
|
66
|
+
}): GroundTruth;
|
|
67
|
+
/**
|
|
68
|
+
* Completion rule (AC2): a unit's work is verified complete when the issue's
|
|
69
|
+
* latest milestone is the final `report done` — the full-cycle trail's last
|
|
70
|
+
* phase — or when GitHub itself says the issue is closed (a merged PR
|
|
71
|
+
* auto-closes it, which is ground truth no milestone can contradict).
|
|
72
|
+
*/
|
|
73
|
+
export declare function isVerifiedComplete(milestone: GroundTruthMilestone | null, issueClosed: boolean): boolean;
|
|
74
|
+
//# sourceMappingURL=groundtruth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groundtruth.d.ts","sourceRoot":"","sources":["../src/groundtruth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAEtD,uFAAuF;AACvF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC;IACxE;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,uFAAuF;IACvF,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC3C;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,MAK5B,CAAC;AAEH,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,GAAG,IAAI,CA2BrF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,GAAE,MAAwB,EAC9B,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,WAAW,CA+Bb;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,oBAAoB,GAAG,IAAI,EACtC,WAAW,EAAE,OAAO,GACnB,OAAO,CAGT"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Ground truth for completion verification (#464, AC2 — "an agent exiting is
|
|
4
|
+
* never proof of completion"). The engine never trusts the spawned agent's own
|
|
5
|
+
* exit; it reconciles the claimed state against the durable sources — the
|
|
6
|
+
* issue's runstate milestone trail (`ai-dossier runstate last`) and GitHub
|
|
7
|
+
* itself (`gh issue view`), plus `git ls-remote` for the "new pushed commit"
|
|
8
|
+
* stall signal.
|
|
9
|
+
*
|
|
10
|
+
* Everything is injectable (the `ExecFn` pattern from project.ts): tests —
|
|
11
|
+
* and any consumer — supply fake ground truth and no subprocess runs.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.groundTruthExec = void 0;
|
|
15
|
+
exports.parseMilestoneJson = parseMilestoneJson;
|
|
16
|
+
exports.createExecGroundTruth = createExecGroundTruth;
|
|
17
|
+
exports.isVerifiedComplete = isVerifiedComplete;
|
|
18
|
+
const project_1 = require("./project");
|
|
19
|
+
/** Subprocess timeout: a hung gh/git call must not stall a tick. */
|
|
20
|
+
const GROUND_TRUTH_TIMEOUT_MS = 30_000;
|
|
21
|
+
/**
|
|
22
|
+
* Default exec for ground-truth calls: like project.ts's `defaultExec` (never
|
|
23
|
+
* throws) but with a hard timeout so a hung `gh`/`git` cannot stall a tick
|
|
24
|
+
* indefinitely (ground truth is polled outside the state lock), and a failure
|
|
25
|
+
* observer that warns on stderr — a broken ground-truth environment (gh auth
|
|
26
|
+
* expired, `ai-dossier` missing from a cron PATH) is never silent.
|
|
27
|
+
*/
|
|
28
|
+
exports.groundTruthExec = (0, project_1.createExecFn)(GROUND_TRUTH_TIMEOUT_MS, {
|
|
29
|
+
onError: (file, args, err) => process.stderr.write(`⚠ sched ground truth: '${file} ${args.join(' ')}' failed: ${err.message}\n`),
|
|
30
|
+
});
|
|
31
|
+
/** Parse the stdout of `ai-dossier runstate last --issue N --json`. */
|
|
32
|
+
function parseMilestoneJson(stdout) {
|
|
33
|
+
if (stdout === null || stdout.trim() === '' || stdout.trim() === 'null')
|
|
34
|
+
return null;
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(stdout);
|
|
37
|
+
if (parsed === null || typeof parsed !== 'object')
|
|
38
|
+
return null;
|
|
39
|
+
const obj = parsed;
|
|
40
|
+
if (typeof obj.phase !== 'string' ||
|
|
41
|
+
typeof obj.status !== 'string' ||
|
|
42
|
+
typeof obj.at !== 'string') {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const keys = {};
|
|
46
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
47
|
+
if (typeof value === 'string')
|
|
48
|
+
keys[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
phase: obj.phase,
|
|
52
|
+
status: obj.status,
|
|
53
|
+
run: typeof obj.run === 'string' ? obj.run : '',
|
|
54
|
+
at: obj.at,
|
|
55
|
+
keys,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Ground truth backed by subprocess calls:
|
|
64
|
+
* - `ai-dossier runstate last --issue N --json` — the milestone trail
|
|
65
|
+
* - `gh issue view N --json state --jq .state` — issue closed
|
|
66
|
+
* - `git ls-remote origin <branch>` — branch head
|
|
67
|
+
*
|
|
68
|
+
* `repoDir` is the cwd for git; gh resolves the repo from cwd by default.
|
|
69
|
+
* Every failure degrades safely: a failed milestone poll reports UNREACHABLE
|
|
70
|
+
* (undefined — decision 2, option A), a failed closed-poll reports false, a
|
|
71
|
+
* failed head-poll null. Ground truth being unreachable pauses the engine's
|
|
72
|
+
* stall/verify decisions; it never crashes a tick.
|
|
73
|
+
*/
|
|
74
|
+
function createExecGroundTruth(exec = exports.groundTruthExec, opts = {}) {
|
|
75
|
+
const runstateBin = opts.runstateBin ?? 'ai-dossier';
|
|
76
|
+
return {
|
|
77
|
+
latestMilestone(issue) {
|
|
78
|
+
const out = exec(runstateBin, ['runstate', 'last', '--issue', String(issue), '--json'], opts.repoDir);
|
|
79
|
+
if (out === null)
|
|
80
|
+
return undefined; // subprocess failed — unreachable, NOT known-absent
|
|
81
|
+
return parseMilestoneJson(out); // 'null' output → null (verifiably no milestone)
|
|
82
|
+
},
|
|
83
|
+
issueClosed(issue) {
|
|
84
|
+
return (exec('gh', ['issue', 'view', String(issue), '--json', 'state', '--jq', '.state']) ===
|
|
85
|
+
'CLOSED');
|
|
86
|
+
},
|
|
87
|
+
branchHead(branch) {
|
|
88
|
+
// The branch string originates from milestone output written by the
|
|
89
|
+
// spawned agent — validate it as a ref name and end git's option
|
|
90
|
+
// parsing with `--` so a crafted "branch" (e.g. `--upload-pack=…`)
|
|
91
|
+
// can never become a git option (CWE-88). A rejected ref degrades to
|
|
92
|
+
// null head: the pushed-commit progress signal just doesn't fire.
|
|
93
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(branch))
|
|
94
|
+
return null;
|
|
95
|
+
const out = exec('git', ['ls-remote', 'origin', '--', branch], opts.repoDir);
|
|
96
|
+
if (out === null || out === '')
|
|
97
|
+
return null;
|
|
98
|
+
const sha = out.split('\t')[0]?.trim();
|
|
99
|
+
return sha && /^[0-9a-f]{40}$/i.test(sha) ? sha : null;
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Completion rule (AC2): a unit's work is verified complete when the issue's
|
|
105
|
+
* latest milestone is the final `report done` — the full-cycle trail's last
|
|
106
|
+
* phase — or when GitHub itself says the issue is closed (a merged PR
|
|
107
|
+
* auto-closes it, which is ground truth no milestone can contradict).
|
|
108
|
+
*/
|
|
109
|
+
function isVerifiedComplete(milestone, issueClosed) {
|
|
110
|
+
if (issueClosed)
|
|
111
|
+
return true;
|
|
112
|
+
return milestone !== null && milestone.phase === 'report' && milestone.status === 'done';
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=groundtruth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"groundtruth.js","sourceRoot":"","sources":["../src/groundtruth.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAoDH,gDA2BC;AAcD,sDAkCC;AAQD,gDAMC;AA3ID,uCAAsD;AAgCtD,oEAAoE;AACpE,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC;;;;;;GAMG;AACU,QAAA,eAAe,GAAW,IAAA,sBAAY,EAAC,uBAAuB,EAAE;IAC3E,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,0BAA0B,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,GAAG,CAAC,OAAO,IAAI,CAC7E;CACJ,CAAC,CAAC;AAEH,uEAAuE;AACvE,SAAgB,kBAAkB,CAAC,MAAqB;IACtD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACrF,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC/D,MAAM,GAAG,GAAG,MAAiC,CAAC;QAC9C,IACE,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ;YAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,QAAQ;YAC9B,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,EAC1B,CAAC;YAC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E,MAAM,EAAE,QAAQ,CAAC,CAAC;gBACjF,QAAQ,CACT,CAAC;QACJ,CAAC;QACD,UAAU,CAAC,MAAc;YACvB,oEAAoE;YACpE,iEAAiE;YACjE,mEAAmE;YACnE,qEAAqE;YACrE,kEAAkE;YAClE,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,MAAM,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC7E,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,EAAE;gBAAE,OAAO,IAAI,CAAC;YAC5C,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;YACvC,OAAO,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,SAAsC,EACtC,WAAoB;IAEpB,IAAI,WAAW;QAAE,OAAO,IAAI,CAAC;IAC7B,OAAO,SAAS,KAAK,IAAI,IAAI,SAAS,CAAC,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC;AAC3F,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { buildAgentCommand, buildPrompt, createSpawnDeps, DEFAULT_DISPATCH_COMMAND, DEFAULT_PROMPT_TEMPLATE, DEFAULT_TIER_MODELS, escalateTier, OPENCODE_DISPATCH_COMMAND, type ResolvedDispatch, resolveDispatch, type SpawnDeps, unitLogName, } from './dispatch';
|
|
2
|
+
export { type EngineDeps, runLoop, type TickResult, tick } from './engine';
|
|
3
|
+
export { assertNoDependencyCycle, EnqueueError, type EnqueueInput, enqueueEntries, parseManifest, } from './enqueue';
|
|
4
|
+
export { createExecGroundTruth, type GroundTruth, type GroundTruthMilestone, groundTruthExec, isVerifiedComplete, parseMilestoneJson, } from './groundtruth';
|
|
5
|
+
export { issueOfUnit, JOURNAL_FILE, Journal, readJsonl, unitEvent } from './journal';
|
|
6
|
+
export { CorruptStateError, LockTimeoutError, SchedStore, writeAtomic } from './persist';
|
|
7
|
+
export { createExecFn, defaultExec, type ExecFn, resolveProjectSlug, sanitizeSlug, schedStateDir, } from './project';
|
|
8
|
+
export { DISPATCHABLE_ISSUE_STATUSES } from './readiness';
|
|
9
|
+
export { type Assignment, abandonBatch, abandonIssue, batchBlockers, computeAssignments, type DependencyBlocker, dependencyBlockers, type RunnableUnit, runnableUnits, setPaused, } from './scheduler';
|
|
10
|
+
export { createEmptyState, findBatch, findEntry, TRANSITIONS, transitionBatch, transitionIssue, transitionSlot, validateState, } from './state';
|
|
11
|
+
export { type BlockedItem, buildStatusReport, type StatusReport } from './status';
|
|
12
|
+
export { type BatchEntry, type BatchStatus, CONFIG_SCHEMA_VERSION, type CycleMode, DEFAULT_MAX_SLOTS, DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_STALL_TIMEOUT_MS, type DispatchConfig, ESCALATION_CAP, IllegalTransitionError, type IssueStatus, type JournalEvent, type JournalEventName, LEGACY_CONFIG_SCHEMA_VERSIONS, LEGACY_SCHEMA_VERSIONS, LIVE_SLOT_STATUSES, MAX_MAX_SLOTS, MERGED_BATCH_STATUSES, MIN_MAX_SLOTS, type ModelTier, type QueueEntry, SATISFIED_ISSUE_STATUSES, SCHEMA_VERSION, type SchedConfig, type SchedConfigFile, SchedNotFoundError, type SchedState, type SlotEntry, type SlotStatus, TERMINAL_BATCH_STATUSES, TERMINAL_ISSUE_STATUSES, TIER_LADDER, } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,eAAe,EACf,KAAK,SAAS,EACd,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,UAAU,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,KAAK,YAAY,EACjB,cAAc,EACd,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,KAAK,MAAM,EACX,kBAAkB,EAClB,YAAY,EACZ,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,KAAK,UAAU,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,YAAY,EACjB,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,WAAW,EACX,eAAe,EACf,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,WAAW,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,qBAAqB,EACrB,KAAK,SAAS,EACd,iBAAiB,EACjB,6BAA6B,EAC7B,wBAAwB,EACxB,KAAK,cAAc,EACnB,cAAc,EACd,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,KAAK,SAAS,EACd,KAAK,UAAU,EACf,wBAAwB,EACxB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,kBAAkB,EAClB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,UAAU,EACf,uBAAuB,EACvB,uBAAuB,EACvB,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateState = exports.transitionSlot = exports.transitionIssue = exports.transitionBatch = exports.TRANSITIONS = exports.findEntry = exports.findBatch = exports.createEmptyState = exports.setPaused = exports.runnableUnits = exports.dependencyBlockers = exports.computeAssignments = exports.batchBlockers = exports.abandonIssue = exports.abandonBatch = exports.DISPATCHABLE_ISSUE_STATUSES = exports.schedStateDir = exports.sanitizeSlug = exports.resolveProjectSlug = exports.defaultExec = exports.createExecFn = exports.writeAtomic = exports.SchedStore = exports.LockTimeoutError = exports.CorruptStateError = exports.unitEvent = exports.readJsonl = exports.Journal = exports.JOURNAL_FILE = exports.issueOfUnit = exports.parseMilestoneJson = exports.isVerifiedComplete = exports.groundTruthExec = exports.createExecGroundTruth = exports.parseManifest = exports.enqueueEntries = exports.EnqueueError = exports.assertNoDependencyCycle = exports.tick = exports.runLoop = exports.unitLogName = exports.resolveDispatch = exports.OPENCODE_DISPATCH_COMMAND = exports.escalateTier = exports.DEFAULT_TIER_MODELS = exports.DEFAULT_PROMPT_TEMPLATE = exports.DEFAULT_DISPATCH_COMMAND = exports.createSpawnDeps = exports.buildPrompt = exports.buildAgentCommand = void 0;
|
|
4
|
+
exports.TIER_LADDER = exports.TERMINAL_ISSUE_STATUSES = exports.TERMINAL_BATCH_STATUSES = exports.SchedNotFoundError = exports.SCHEMA_VERSION = exports.SATISFIED_ISSUE_STATUSES = exports.MIN_MAX_SLOTS = exports.MERGED_BATCH_STATUSES = exports.MAX_MAX_SLOTS = exports.LIVE_SLOT_STATUSES = exports.LEGACY_SCHEMA_VERSIONS = exports.LEGACY_CONFIG_SCHEMA_VERSIONS = exports.IllegalTransitionError = exports.ESCALATION_CAP = exports.DEFAULT_STALL_TIMEOUT_MS = exports.DEFAULT_RECONCILE_INTERVAL_MS = exports.DEFAULT_MAX_SLOTS = exports.CONFIG_SCHEMA_VERSION = exports.buildStatusReport = void 0;
|
|
5
|
+
var dispatch_1 = require("./dispatch");
|
|
6
|
+
Object.defineProperty(exports, "buildAgentCommand", { enumerable: true, get: function () { return dispatch_1.buildAgentCommand; } });
|
|
7
|
+
Object.defineProperty(exports, "buildPrompt", { enumerable: true, get: function () { return dispatch_1.buildPrompt; } });
|
|
8
|
+
Object.defineProperty(exports, "createSpawnDeps", { enumerable: true, get: function () { return dispatch_1.createSpawnDeps; } });
|
|
9
|
+
Object.defineProperty(exports, "DEFAULT_DISPATCH_COMMAND", { enumerable: true, get: function () { return dispatch_1.DEFAULT_DISPATCH_COMMAND; } });
|
|
10
|
+
Object.defineProperty(exports, "DEFAULT_PROMPT_TEMPLATE", { enumerable: true, get: function () { return dispatch_1.DEFAULT_PROMPT_TEMPLATE; } });
|
|
11
|
+
Object.defineProperty(exports, "DEFAULT_TIER_MODELS", { enumerable: true, get: function () { return dispatch_1.DEFAULT_TIER_MODELS; } });
|
|
12
|
+
Object.defineProperty(exports, "escalateTier", { enumerable: true, get: function () { return dispatch_1.escalateTier; } });
|
|
13
|
+
Object.defineProperty(exports, "OPENCODE_DISPATCH_COMMAND", { enumerable: true, get: function () { return dispatch_1.OPENCODE_DISPATCH_COMMAND; } });
|
|
14
|
+
Object.defineProperty(exports, "resolveDispatch", { enumerable: true, get: function () { return dispatch_1.resolveDispatch; } });
|
|
15
|
+
Object.defineProperty(exports, "unitLogName", { enumerable: true, get: function () { return dispatch_1.unitLogName; } });
|
|
16
|
+
var engine_1 = require("./engine");
|
|
17
|
+
Object.defineProperty(exports, "runLoop", { enumerable: true, get: function () { return engine_1.runLoop; } });
|
|
18
|
+
Object.defineProperty(exports, "tick", { enumerable: true, get: function () { return engine_1.tick; } });
|
|
19
|
+
var enqueue_1 = require("./enqueue");
|
|
20
|
+
Object.defineProperty(exports, "assertNoDependencyCycle", { enumerable: true, get: function () { return enqueue_1.assertNoDependencyCycle; } });
|
|
21
|
+
Object.defineProperty(exports, "EnqueueError", { enumerable: true, get: function () { return enqueue_1.EnqueueError; } });
|
|
22
|
+
Object.defineProperty(exports, "enqueueEntries", { enumerable: true, get: function () { return enqueue_1.enqueueEntries; } });
|
|
23
|
+
Object.defineProperty(exports, "parseManifest", { enumerable: true, get: function () { return enqueue_1.parseManifest; } });
|
|
24
|
+
var groundtruth_1 = require("./groundtruth");
|
|
25
|
+
Object.defineProperty(exports, "createExecGroundTruth", { enumerable: true, get: function () { return groundtruth_1.createExecGroundTruth; } });
|
|
26
|
+
Object.defineProperty(exports, "groundTruthExec", { enumerable: true, get: function () { return groundtruth_1.groundTruthExec; } });
|
|
27
|
+
Object.defineProperty(exports, "isVerifiedComplete", { enumerable: true, get: function () { return groundtruth_1.isVerifiedComplete; } });
|
|
28
|
+
Object.defineProperty(exports, "parseMilestoneJson", { enumerable: true, get: function () { return groundtruth_1.parseMilestoneJson; } });
|
|
29
|
+
var journal_1 = require("./journal");
|
|
30
|
+
Object.defineProperty(exports, "issueOfUnit", { enumerable: true, get: function () { return journal_1.issueOfUnit; } });
|
|
31
|
+
Object.defineProperty(exports, "JOURNAL_FILE", { enumerable: true, get: function () { return journal_1.JOURNAL_FILE; } });
|
|
32
|
+
Object.defineProperty(exports, "Journal", { enumerable: true, get: function () { return journal_1.Journal; } });
|
|
33
|
+
Object.defineProperty(exports, "readJsonl", { enumerable: true, get: function () { return journal_1.readJsonl; } });
|
|
34
|
+
Object.defineProperty(exports, "unitEvent", { enumerable: true, get: function () { return journal_1.unitEvent; } });
|
|
35
|
+
var persist_1 = require("./persist");
|
|
36
|
+
Object.defineProperty(exports, "CorruptStateError", { enumerable: true, get: function () { return persist_1.CorruptStateError; } });
|
|
37
|
+
Object.defineProperty(exports, "LockTimeoutError", { enumerable: true, get: function () { return persist_1.LockTimeoutError; } });
|
|
38
|
+
Object.defineProperty(exports, "SchedStore", { enumerable: true, get: function () { return persist_1.SchedStore; } });
|
|
39
|
+
Object.defineProperty(exports, "writeAtomic", { enumerable: true, get: function () { return persist_1.writeAtomic; } });
|
|
40
|
+
var project_1 = require("./project");
|
|
41
|
+
Object.defineProperty(exports, "createExecFn", { enumerable: true, get: function () { return project_1.createExecFn; } });
|
|
42
|
+
Object.defineProperty(exports, "defaultExec", { enumerable: true, get: function () { return project_1.defaultExec; } });
|
|
43
|
+
Object.defineProperty(exports, "resolveProjectSlug", { enumerable: true, get: function () { return project_1.resolveProjectSlug; } });
|
|
44
|
+
Object.defineProperty(exports, "sanitizeSlug", { enumerable: true, get: function () { return project_1.sanitizeSlug; } });
|
|
45
|
+
Object.defineProperty(exports, "schedStateDir", { enumerable: true, get: function () { return project_1.schedStateDir; } });
|
|
46
|
+
var readiness_1 = require("./readiness");
|
|
47
|
+
Object.defineProperty(exports, "DISPATCHABLE_ISSUE_STATUSES", { enumerable: true, get: function () { return readiness_1.DISPATCHABLE_ISSUE_STATUSES; } });
|
|
48
|
+
var scheduler_1 = require("./scheduler");
|
|
49
|
+
Object.defineProperty(exports, "abandonBatch", { enumerable: true, get: function () { return scheduler_1.abandonBatch; } });
|
|
50
|
+
Object.defineProperty(exports, "abandonIssue", { enumerable: true, get: function () { return scheduler_1.abandonIssue; } });
|
|
51
|
+
Object.defineProperty(exports, "batchBlockers", { enumerable: true, get: function () { return scheduler_1.batchBlockers; } });
|
|
52
|
+
Object.defineProperty(exports, "computeAssignments", { enumerable: true, get: function () { return scheduler_1.computeAssignments; } });
|
|
53
|
+
Object.defineProperty(exports, "dependencyBlockers", { enumerable: true, get: function () { return scheduler_1.dependencyBlockers; } });
|
|
54
|
+
Object.defineProperty(exports, "runnableUnits", { enumerable: true, get: function () { return scheduler_1.runnableUnits; } });
|
|
55
|
+
Object.defineProperty(exports, "setPaused", { enumerable: true, get: function () { return scheduler_1.setPaused; } });
|
|
56
|
+
var state_1 = require("./state");
|
|
57
|
+
Object.defineProperty(exports, "createEmptyState", { enumerable: true, get: function () { return state_1.createEmptyState; } });
|
|
58
|
+
Object.defineProperty(exports, "findBatch", { enumerable: true, get: function () { return state_1.findBatch; } });
|
|
59
|
+
Object.defineProperty(exports, "findEntry", { enumerable: true, get: function () { return state_1.findEntry; } });
|
|
60
|
+
Object.defineProperty(exports, "TRANSITIONS", { enumerable: true, get: function () { return state_1.TRANSITIONS; } });
|
|
61
|
+
Object.defineProperty(exports, "transitionBatch", { enumerable: true, get: function () { return state_1.transitionBatch; } });
|
|
62
|
+
Object.defineProperty(exports, "transitionIssue", { enumerable: true, get: function () { return state_1.transitionIssue; } });
|
|
63
|
+
Object.defineProperty(exports, "transitionSlot", { enumerable: true, get: function () { return state_1.transitionSlot; } });
|
|
64
|
+
Object.defineProperty(exports, "validateState", { enumerable: true, get: function () { return state_1.validateState; } });
|
|
65
|
+
var status_1 = require("./status");
|
|
66
|
+
Object.defineProperty(exports, "buildStatusReport", { enumerable: true, get: function () { return status_1.buildStatusReport; } });
|
|
67
|
+
var types_1 = require("./types");
|
|
68
|
+
Object.defineProperty(exports, "CONFIG_SCHEMA_VERSION", { enumerable: true, get: function () { return types_1.CONFIG_SCHEMA_VERSION; } });
|
|
69
|
+
Object.defineProperty(exports, "DEFAULT_MAX_SLOTS", { enumerable: true, get: function () { return types_1.DEFAULT_MAX_SLOTS; } });
|
|
70
|
+
Object.defineProperty(exports, "DEFAULT_RECONCILE_INTERVAL_MS", { enumerable: true, get: function () { return types_1.DEFAULT_RECONCILE_INTERVAL_MS; } });
|
|
71
|
+
Object.defineProperty(exports, "DEFAULT_STALL_TIMEOUT_MS", { enumerable: true, get: function () { return types_1.DEFAULT_STALL_TIMEOUT_MS; } });
|
|
72
|
+
Object.defineProperty(exports, "ESCALATION_CAP", { enumerable: true, get: function () { return types_1.ESCALATION_CAP; } });
|
|
73
|
+
Object.defineProperty(exports, "IllegalTransitionError", { enumerable: true, get: function () { return types_1.IllegalTransitionError; } });
|
|
74
|
+
Object.defineProperty(exports, "LEGACY_CONFIG_SCHEMA_VERSIONS", { enumerable: true, get: function () { return types_1.LEGACY_CONFIG_SCHEMA_VERSIONS; } });
|
|
75
|
+
Object.defineProperty(exports, "LEGACY_SCHEMA_VERSIONS", { enumerable: true, get: function () { return types_1.LEGACY_SCHEMA_VERSIONS; } });
|
|
76
|
+
Object.defineProperty(exports, "LIVE_SLOT_STATUSES", { enumerable: true, get: function () { return types_1.LIVE_SLOT_STATUSES; } });
|
|
77
|
+
Object.defineProperty(exports, "MAX_MAX_SLOTS", { enumerable: true, get: function () { return types_1.MAX_MAX_SLOTS; } });
|
|
78
|
+
Object.defineProperty(exports, "MERGED_BATCH_STATUSES", { enumerable: true, get: function () { return types_1.MERGED_BATCH_STATUSES; } });
|
|
79
|
+
Object.defineProperty(exports, "MIN_MAX_SLOTS", { enumerable: true, get: function () { return types_1.MIN_MAX_SLOTS; } });
|
|
80
|
+
Object.defineProperty(exports, "SATISFIED_ISSUE_STATUSES", { enumerable: true, get: function () { return types_1.SATISFIED_ISSUE_STATUSES; } });
|
|
81
|
+
Object.defineProperty(exports, "SCHEMA_VERSION", { enumerable: true, get: function () { return types_1.SCHEMA_VERSION; } });
|
|
82
|
+
Object.defineProperty(exports, "SchedNotFoundError", { enumerable: true, get: function () { return types_1.SchedNotFoundError; } });
|
|
83
|
+
Object.defineProperty(exports, "TERMINAL_BATCH_STATUSES", { enumerable: true, get: function () { return types_1.TERMINAL_BATCH_STATUSES; } });
|
|
84
|
+
Object.defineProperty(exports, "TERMINAL_ISSUE_STATUSES", { enumerable: true, get: function () { return types_1.TERMINAL_ISSUE_STATUSES; } });
|
|
85
|
+
Object.defineProperty(exports, "TIER_LADDER", { enumerable: true, get: function () { return types_1.TIER_LADDER; } });
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,uCAaoB;AAZlB,6GAAA,iBAAiB,OAAA;AACjB,uGAAA,WAAW,OAAA;AACX,2GAAA,eAAe,OAAA;AACf,oHAAA,wBAAwB,OAAA;AACxB,mHAAA,uBAAuB,OAAA;AACvB,+GAAA,mBAAmB,OAAA;AACnB,wGAAA,YAAY,OAAA;AACZ,qHAAA,yBAAyB,OAAA;AAEzB,2GAAA,eAAe,OAAA;AAEf,uGAAA,WAAW,OAAA;AAEb,mCAA2E;AAAjD,iGAAA,OAAO,OAAA;AAAmB,8FAAA,IAAI,OAAA;AACxD,qCAMmB;AALjB,kHAAA,uBAAuB,OAAA;AACvB,uGAAA,YAAY,OAAA;AAEZ,yGAAA,cAAc,OAAA;AACd,wGAAA,aAAa,OAAA;AAEf,6CAOuB;AANrB,oHAAA,qBAAqB,OAAA;AAGrB,8GAAA,eAAe,OAAA;AACf,iHAAA,kBAAkB,OAAA;AAClB,iHAAA,kBAAkB,OAAA;AAEpB,qCAAqF;AAA5E,sGAAA,WAAW,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,kGAAA,OAAO,OAAA;AAAE,oGAAA,SAAS,O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,OAAA;AACvB,gHAAA,uBAAuB,OAAA;AACvB,oGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Append-only event journal (#464, AC6 — "all events journaled"; RFC-0001 §D.4
|
|
3
|
+
* "Audit"). Every engine decision lands here as one JSONL line in
|
|
4
|
+
* `<sched-dir>/events.jsonl`. The journal must never crash a tick: write
|
|
5
|
+
* failures are swallowed after a one-line stderr warning — state.json remains
|
|
6
|
+
* the operational truth, the journal is the operator's flight recorder.
|
|
7
|
+
*/
|
|
8
|
+
import type { JournalEvent, JournalEventName } from './types';
|
|
9
|
+
/** The journal file name — the single source (persist.ts's journalPath uses it). */
|
|
10
|
+
export declare const JOURNAL_FILE = "events.jsonl";
|
|
11
|
+
export declare class Journal {
|
|
12
|
+
readonly filePath: string;
|
|
13
|
+
constructor(dir: string);
|
|
14
|
+
/** Append one event, stamping `ts` from the caller's clock. Never throws. */
|
|
15
|
+
append(event: Omit<JournalEvent, 'ts'>, now?: Date): void;
|
|
16
|
+
/** Read every event, oldest first; malformed lines are skipped. */
|
|
17
|
+
read(): JournalEvent[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read a JSONL file oldest-first, skipping malformed lines; `[]` when the
|
|
21
|
+
* file is absent or unreadable. Shared by the journal and the CLI's run log
|
|
22
|
+
* so the read-loop exists once.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readJsonl<T>(file: string): T[];
|
|
25
|
+
/** `issue:464` → 464; null for batch or malformed unit ids. */
|
|
26
|
+
export declare function issueOfUnit(unit: string | null): number | null;
|
|
27
|
+
/** Convenience: build the journaled event for a unit without repeating ids. */
|
|
28
|
+
export declare function unitEvent(event: JournalEventName, unit: string, extra?: Omit<JournalEvent, 'ts' | 'event' | 'unit'>): Omit<JournalEvent, 'ts' | 'event' | 'unit'> & {
|
|
29
|
+
event: JournalEventName;
|
|
30
|
+
unit: string;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=journal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../src/journal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE9D,oFAAoF;AACpF,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,qBAAa,OAAO;IAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,GAAG,EAAE,MAAM;IAIvB,6EAA6E;IAC7E,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,GAAG,GAAE,IAAiB,GAAG,IAAI;IAerE,mEAAmE;IACnE,IAAI,IAAI,YAAY,EAAE;CAGvB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,CAgB9C;AAED,+DAA+D;AAC/D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAI9D;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CACvB,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,CAAM,GACtD,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC,GAAG;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAGzF"}
|