@namzu/sdk 20.1.0 → 20.2.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/CHANGELOG.md +47 -0
- package/dist/runtime/query/checkpoint.d.ts +20 -0
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +47 -0
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/store/run/listing.d.ts.map +1 -1
- package/dist/store/run/listing.js +65 -6
- package/dist/store/run/listing.js.map +1 -1
- package/dist/types/hitl/index.d.ts +27 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/run/checkpoint-store.d.ts +69 -19
- package/dist/types/run/checkpoint-store.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/runtime/query/checkpoint.ts +51 -0
- package/src/store/run/listing.ts +84 -6
- package/src/types/hitl/index.ts +28 -0
- package/src/types/run/checkpoint-store.ts +72 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 20.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- d9cbbfe: An approval inbox can now be triaged. `listDurableRuns` takes
|
|
8
|
+
`orderBy: 'createdAt'` and returns runs oldest first, so "which run has been
|
|
9
|
+
waiting longest" has an answer.
|
|
10
|
+
|
|
11
|
+
It could not before, and the reason was structural rather than an oversight.
|
|
12
|
+
A cursor has to sort on a key that cannot _move_, or a paging caller skips
|
|
13
|
+
rows and repeats them — and every timestamp a checkpoint store could derive
|
|
14
|
+
moves: the newest checkpoint's advances whenever the run checkpoints again,
|
|
15
|
+
the oldest one's advances whenever pruning deletes oldest-first. That left
|
|
16
|
+
`runId`, which is stable and carries no timestamp, so paging was safe and the
|
|
17
|
+
order was meaningless.
|
|
18
|
+
|
|
19
|
+
So there is now a key with both properties. `IterationCheckpoint.runCreatedAt`
|
|
20
|
+
records when the run was **attributed** — not when the checkpoint was written
|
|
21
|
+
— and is copied onto every checkpoint of the run. Pruning cannot reach a
|
|
22
|
+
value every survivor also holds, and a resume adopts the recorded one instead
|
|
23
|
+
of minting a fresh start, so the key never moves. It is `readonly`, settled
|
|
24
|
+
once per run and never reassigned.
|
|
25
|
+
|
|
26
|
+
- New: `DurableRunOrder` (`'runId' | 'createdAt'`),
|
|
27
|
+
`ListDurableRunsOptions.orderBy`, `DurableRunEntry.runCreatedAt`,
|
|
28
|
+
`IterationCheckpoint.runCreatedAt`.
|
|
29
|
+
- **The default order is unchanged** (`'runId'`), so a caller paging today
|
|
30
|
+
keeps walking the same sequence. Pass `orderBy` to opt in.
|
|
31
|
+
- A cursor is a position in one order. Do not carry one across a change of
|
|
32
|
+
`orderBy`. The listing now **refuses a cursor it did not issue** rather
|
|
33
|
+
than treating an arbitrary string as a position — if you were constructing
|
|
34
|
+
cursors from a `runId`, pass back the `cursor` from the previous page
|
|
35
|
+
instead. The encoding is not part of the contract.
|
|
36
|
+
|
|
37
|
+
**Runs checkpointed before this release have no stamp.** Under
|
|
38
|
+
`orderBy: 'createdAt'` they come first, and `runCreatedAt` is absent on the
|
|
39
|
+
row so you can render "unknown" rather than a date nobody recorded. First is
|
|
40
|
+
not a guess: the stamp is written by the checkpoint manager, so a run without
|
|
41
|
+
one was checkpointed by a build that predates the stamp and therefore
|
|
42
|
+
predates every run that has one. Nothing needs migrating — a run that
|
|
43
|
+
checkpoints again after upgrading records its real attribution instant, which
|
|
44
|
+
is its original one.
|
|
45
|
+
|
|
46
|
+
An emergency dump's projection carries the stamp too, from the dump's own
|
|
47
|
+
`startedAt`. A crashed run is the one an operator is looking for, and it
|
|
48
|
+
would have been the one with no age.
|
|
49
|
+
|
|
3
50
|
## 20.1.0
|
|
4
51
|
|
|
5
52
|
### Minor Changes
|
|
@@ -75,6 +75,26 @@ export declare class CheckpointManager {
|
|
|
75
75
|
private traceSource?;
|
|
76
76
|
/** See {@link setParkTtl}. */
|
|
77
77
|
private parkTtlMs?;
|
|
78
|
+
/**
|
|
79
|
+
* The run's attribution instant, stamped onto every checkpoint this
|
|
80
|
+
* manager writes.
|
|
81
|
+
*
|
|
82
|
+
* Settled exactly once, by whichever of two things happens first, and
|
|
83
|
+
* never reassigned — every write to it below is `??=`, and there are only
|
|
84
|
+
* two:
|
|
85
|
+
*
|
|
86
|
+
* - `restore` ADOPTS it from the checkpoint a resume came back through.
|
|
87
|
+
* A resumed run is the same run, and its creation is already on the
|
|
88
|
+
* record; a fresh process minting a new one would move the key that
|
|
89
|
+
* exists specifically because it does not move.
|
|
90
|
+
* - `create` MINTS it from the run's own start instant when nothing was
|
|
91
|
+
* adopted, which is the fresh-run case.
|
|
92
|
+
*
|
|
93
|
+
* Restore runs during run setup, before the first iteration and therefore
|
|
94
|
+
* before the first `create`, so the adopt always wins on the resume path
|
|
95
|
+
* without either site needing to know which path it is on.
|
|
96
|
+
*/
|
|
97
|
+
private runCreatedAt?;
|
|
78
98
|
/**
|
|
79
99
|
* @param store scope-keyed checkpoint persistence. The default query
|
|
80
100
|
* pipeline passes the run's disk-backed store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAE1E,OAAO,KAAK,EACX,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,MAAM,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC9F,OAAO,KAAK,EAAE,i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34
|
return {
|
|
35
35
|
id: `cp_emergency_${emergencySuffix}`,
|
|
36
36
|
runId: dump.runId,
|
|
37
|
+
// The dump records the run's start, so this projection carries the
|
|
38
|
+
// same stamp an ordinary checkpoint of that run would — a run whose
|
|
39
|
+
// only surviving record is an emergency dump still has a real
|
|
40
|
+
// attribution instant, and dropping it here would put that run in the
|
|
41
|
+
// "never recorded" bucket for no reason.
|
|
42
|
+
runCreatedAt: dump.startedAt,
|
|
37
43
|
iteration: dump.currentIteration,
|
|
38
44
|
messages: dump.messages,
|
|
39
45
|
tokenUsage: dump.tokenUsage,
|
|
@@ -115,6 +121,26 @@ export class CheckpointManager {
|
|
|
115
121
|
traceSource;
|
|
116
122
|
/** See {@link setParkTtl}. */
|
|
117
123
|
parkTtlMs;
|
|
124
|
+
/**
|
|
125
|
+
* The run's attribution instant, stamped onto every checkpoint this
|
|
126
|
+
* manager writes.
|
|
127
|
+
*
|
|
128
|
+
* Settled exactly once, by whichever of two things happens first, and
|
|
129
|
+
* never reassigned — every write to it below is `??=`, and there are only
|
|
130
|
+
* two:
|
|
131
|
+
*
|
|
132
|
+
* - `restore` ADOPTS it from the checkpoint a resume came back through.
|
|
133
|
+
* A resumed run is the same run, and its creation is already on the
|
|
134
|
+
* record; a fresh process minting a new one would move the key that
|
|
135
|
+
* exists specifically because it does not move.
|
|
136
|
+
* - `create` MINTS it from the run's own start instant when nothing was
|
|
137
|
+
* adopted, which is the fresh-run case.
|
|
138
|
+
*
|
|
139
|
+
* Restore runs during run setup, before the first iteration and therefore
|
|
140
|
+
* before the first `create`, so the adopt always wins on the resume path
|
|
141
|
+
* without either site needing to know which path it is on.
|
|
142
|
+
*/
|
|
143
|
+
runCreatedAt;
|
|
118
144
|
/**
|
|
119
145
|
* @param store scope-keyed checkpoint persistence. The default query
|
|
120
146
|
* pipeline passes the run's disk-backed store
|
|
@@ -139,9 +165,16 @@ export class CheckpointManager {
|
|
|
139
165
|
this.traceSource = source;
|
|
140
166
|
}
|
|
141
167
|
async create(runMgr, iteration, extra) {
|
|
168
|
+
// The run's own start, not `Date.now()`. This is meant to say when the
|
|
169
|
+
// run was attributed; taking the clock at the first checkpoint would
|
|
170
|
+
// say when it first became durable, which is a different and later
|
|
171
|
+
// fact, and naming it after the earlier one would make it wrong in
|
|
172
|
+
// exactly the way that is hard to notice.
|
|
173
|
+
this.runCreatedAt ??= runMgr.getSession().startedAt ?? Date.now();
|
|
142
174
|
const checkpoint = {
|
|
143
175
|
id: generateCheckpointId(),
|
|
144
176
|
runId: runMgr.id,
|
|
177
|
+
runCreatedAt: this.runCreatedAt,
|
|
145
178
|
iteration,
|
|
146
179
|
messages: [...runMgr.messages],
|
|
147
180
|
tokenUsage: { ...runMgr.tokenUsage },
|
|
@@ -284,6 +317,20 @@ export class CheckpointManager {
|
|
|
284
317
|
details: { checkpointId, runId: this.scope.runId },
|
|
285
318
|
});
|
|
286
319
|
}
|
|
320
|
+
// Adopt the run's recorded attribution. A resumed run is the SAME run
|
|
321
|
+
// under the same id, and its creation is already on the record; a
|
|
322
|
+
// fresh process minting a new one would step the stamp forward on
|
|
323
|
+
// every resume, which is the motion it exists to avoid.
|
|
324
|
+
//
|
|
325
|
+
// This needs no "is it really my run" guard, and one was written and
|
|
326
|
+
// removed: `readCheckpoint` is keyed by THIS manager's scope, so the
|
|
327
|
+
// only checkpoints reachable here are the ones belonging to
|
|
328
|
+
// `scope.runId`. A replay fork never arrives here at all — it reads
|
|
329
|
+
// its origin through the SOURCE scope in `prepareReplayState` and
|
|
330
|
+
// starts a fresh run, so it mints its own stamp rather than claiming
|
|
331
|
+
// its origin's age. A guard that no input can trip would have read as
|
|
332
|
+
// protection and been none.
|
|
333
|
+
this.runCreatedAt ??= checkpoint.runCreatedAt;
|
|
287
334
|
return checkpoint;
|
|
288
335
|
}
|
|
289
336
|
async list() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../../../src/runtime/query/checkpoint.ts"],"names":[],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zB"}
|
|
@@ -108,9 +108,20 @@ export function toDurableRunEntry(scope, checkpoints, now) {
|
|
|
108
108
|
if (checkpoints.length === 0)
|
|
109
109
|
return null;
|
|
110
110
|
let latest = checkpoints[0];
|
|
111
|
+
// The EARLIEST recorded stamp, not the one on any particular checkpoint.
|
|
112
|
+
// Every checkpoint of a run carries the same value, so under that
|
|
113
|
+
// invariant the minimum is that value. Taking the minimum rather than
|
|
114
|
+
// reading one checkpoint is what makes the read safe if the invariant is
|
|
115
|
+
// ever broken: it can only err toward the run's true attribution, never
|
|
116
|
+
// away from it, and it cannot move when a later checkpoint is added.
|
|
117
|
+
let runCreatedAt;
|
|
111
118
|
for (const cp of checkpoints) {
|
|
112
119
|
if (cp.createdAt > latest.createdAt)
|
|
113
120
|
latest = cp;
|
|
121
|
+
if (cp.runCreatedAt !== undefined &&
|
|
122
|
+
(runCreatedAt === undefined || cp.runCreatedAt < runCreatedAt)) {
|
|
123
|
+
runCreatedAt = cp.runCreatedAt;
|
|
124
|
+
}
|
|
114
125
|
}
|
|
115
126
|
const park = summarizePark(checkpoints, now);
|
|
116
127
|
return {
|
|
@@ -119,6 +130,7 @@ export function toDurableRunEntry(scope, checkpoints, now) {
|
|
|
119
130
|
sessionId: scope.sessionId,
|
|
120
131
|
runId: scope.runId,
|
|
121
132
|
...(scope.parentRunId ? { parentRunId: scope.parentRunId } : {}),
|
|
133
|
+
...(runCreatedAt !== undefined ? { runCreatedAt } : {}),
|
|
122
134
|
checkpointCount: checkpoints.length,
|
|
123
135
|
latestCheckpointId: latest.id,
|
|
124
136
|
latestCheckpointAt: latest.createdAt,
|
|
@@ -138,11 +150,12 @@ export function paginateDurableRuns(entries, options) {
|
|
|
138
150
|
const filtered = wanted && wanted.length > 0
|
|
139
151
|
? entries.filter((e) => e.park !== undefined && wanted.includes(e.park.state))
|
|
140
152
|
: entries;
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
153
|
+
// Both orders sort on a key that cannot move under a paging caller — see
|
|
154
|
+
// the contract comment on `listDurableRuns`.
|
|
155
|
+
const orderBy = options?.orderBy ?? 'runId';
|
|
156
|
+
const ordered = [...filtered].sort((a, b) => compareKeys(sortKey(a, orderBy), sortKey(b, orderBy)));
|
|
157
|
+
const after = options?.cursor === undefined ? undefined : decodeCursor(options.cursor, orderBy);
|
|
158
|
+
const start = after === undefined ? 0 : ordered.findIndex((e) => compareKeys(sortKey(e, orderBy), after) > 0);
|
|
146
159
|
const from = start < 0 ? ordered.length : start;
|
|
147
160
|
const limit = Math.max(1, Math.trunc(options?.limit ?? DEFAULT_DURABLE_RUN_LIMIT));
|
|
148
161
|
const page = ordered.slice(from, from + limit);
|
|
@@ -153,9 +166,55 @@ export function paginateDurableRuns(entries, options) {
|
|
|
153
166
|
// terminates rather than fetching one empty page to find out.
|
|
154
167
|
...(exhausted || page.length === 0
|
|
155
168
|
? {}
|
|
156
|
-
: { cursor: page[page.length - 1]
|
|
169
|
+
: { cursor: encodeCursor(sortKey(page[page.length - 1], orderBy)) }),
|
|
157
170
|
};
|
|
158
171
|
}
|
|
172
|
+
function sortKey(entry, orderBy) {
|
|
173
|
+
if (orderBy === 'runId')
|
|
174
|
+
return [0, 0, entry.runId];
|
|
175
|
+
return entry.runCreatedAt === undefined
|
|
176
|
+
? [0, 0, entry.runId]
|
|
177
|
+
: [1, entry.runCreatedAt, entry.runId];
|
|
178
|
+
}
|
|
179
|
+
function compareKeys(a, b) {
|
|
180
|
+
if (a[0] !== b[0])
|
|
181
|
+
return a[0] - b[0];
|
|
182
|
+
if (a[1] !== b[1])
|
|
183
|
+
return a[1] - b[1];
|
|
184
|
+
return a[2] < b[2] ? -1 : a[2] > b[2] ? 1 : 0;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The cursor is the last row's key, and nothing else.
|
|
188
|
+
*
|
|
189
|
+
* Opaque to callers by contract — the shape is written down here rather than
|
|
190
|
+
* in the type so a host is not tempted to construct one. Run ids come from a
|
|
191
|
+
* 36-character lowercase alphabet with a `run_` prefix and contain no
|
|
192
|
+
* separator, so joining on `:` is unambiguous.
|
|
193
|
+
*/
|
|
194
|
+
function encodeCursor(key) {
|
|
195
|
+
return `${key[0]}:${key[1]}:${key[2]}`;
|
|
196
|
+
}
|
|
197
|
+
function decodeCursor(cursor, orderBy) {
|
|
198
|
+
const first = cursor.indexOf(':');
|
|
199
|
+
const second = cursor.indexOf(':', first + 1);
|
|
200
|
+
if (first < 0 || second < 0) {
|
|
201
|
+
throw new NamzuError({
|
|
202
|
+
code: 'invalid_config',
|
|
203
|
+
message: `listDurableRuns: "${cursor}" is not a cursor this listing issued. Pass back the \`cursor\` from the previous page rather than constructing one; its shape is not part of the contract.`,
|
|
204
|
+
details: { cursor, orderBy },
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const rank = Number(cursor.slice(0, first));
|
|
208
|
+
const stamp = Number(cursor.slice(first + 1, second));
|
|
209
|
+
if (!Number.isFinite(rank) || !Number.isFinite(stamp)) {
|
|
210
|
+
throw new NamzuError({
|
|
211
|
+
code: 'invalid_config',
|
|
212
|
+
message: `listDurableRuns: cursor "${cursor}" is malformed — its position fields are not numbers. Pass back the \`cursor\` from the previous page.`,
|
|
213
|
+
details: { cursor, orderBy },
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return [rank, stamp, cursor.slice(second + 1)];
|
|
217
|
+
}
|
|
159
218
|
/**
|
|
160
219
|
* Every run with durable state under a scope, refusing when the store cannot
|
|
161
220
|
* answer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listing.js","sourceRoot":"","sources":["../../../src/store/run/listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"listing.js","sourceRoot":"","sources":["../../../src/store/run/listing.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;A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O,EAAE,4BAA4B,MAAM,wGAAwG;YACnJ,OAAO,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;SAC5B,CAAC,CAAA;IACH,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,KAAsB,EACtB,KAA6B,EAC7B,OAAgC;IAEhC,IAAI,OAAO,KAAK,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QACjD,MAAM,IAAI,UAAU,CAAC;YACpB,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EACN,+VAA+V;YAChW,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;SACrC,CAAC,CAAA;IACH,CAAC;IACD,4BAA4B,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;IACtD,OAAO,KAAK,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAC7C,CAAC"}
|
|
@@ -217,6 +217,33 @@ export interface IterationCheckpoint {
|
|
|
217
217
|
* @deprecated No producer. Removed in the next major.
|
|
218
218
|
*/
|
|
219
219
|
planStatus?: PlanStatus;
|
|
220
|
+
/**
|
|
221
|
+
* When the RUN was attributed — not when this checkpoint was written.
|
|
222
|
+
* See {@link IterationCheckpoint.createdAt} for the latter.
|
|
223
|
+
*
|
|
224
|
+
* Denormalized onto every checkpoint of the run, identically, and that
|
|
225
|
+
* repetition is the whole point. A listing above the run needs a key it
|
|
226
|
+
* can order by, and a key a paging caller can trust is one that cannot
|
|
227
|
+
* MOVE. Every other time a checkpoint store can derive per run moves: the
|
|
228
|
+
* newest checkpoint's `createdAt` advances every time the run checkpoints
|
|
229
|
+
* again, and the oldest one's advances every time `prune` deletes
|
|
230
|
+
* oldest-first. Carried on all of them, this one survives both — pruning
|
|
231
|
+
* cannot reach a value every survivor also holds.
|
|
232
|
+
*
|
|
233
|
+
* `readonly`, and written exactly once per run by
|
|
234
|
+
* {@link import('../../runtime/query/checkpoint.js').CheckpointManager},
|
|
235
|
+
* which settles it on whichever comes first — adopting it from the
|
|
236
|
+
* checkpoint a resume restores, or minting it from the run's own start
|
|
237
|
+
* instant — and never reassigns after. A field that COULD be updated is
|
|
238
|
+
* one edit away from moving again, which would put the ordering back
|
|
239
|
+
* where it started.
|
|
240
|
+
*
|
|
241
|
+
* Absent on checkpoints written before this existed. That absence is
|
|
242
|
+
* information, not a gap: a run with no stamp on any of its checkpoints
|
|
243
|
+
* was attributed before the stamp existed, and therefore before every
|
|
244
|
+
* run that has one.
|
|
245
|
+
*/
|
|
246
|
+
readonly runCreatedAt?: number;
|
|
220
247
|
/**
|
|
221
248
|
* Present when the run parked at this checkpoint awaiting a human.
|
|
222
249
|
* See {@link PendingDecision}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,YAAY,EAAE,YAAY,EAAE,CAAA;AAE5B,MAAM,MAAM,kBAAkB,GAC3B;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GACtB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA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AE,kBAAkB,CAAA;CACtC;AAED,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,YAAY,CAAA;IAChB,KAAK,EAAE,KAAK,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,QAAQ,CAAA;IAClB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IAEvB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAE9B;;;OAGG;IACH,OAAO,CAAC,EAAE,eAAe,CAAA;IACzB,UAAU,EAAE;QACX,cAAc,EAAE,MAAM,CAAA;QACtB,SAAS,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;IAEjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEzC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAA;IAEnC;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAA;CACpC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAwB5F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/hitl/index.ts"],"names":[],"mappings":"AAwRA,MAAM,UAAU,kBAAkB,CAAC,OAA4B;IAC9D,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,eAAe;YACnB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAA;QACnD,KAAK,aAAa;YACjB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAA;QACpD,KAAK,sBAAsB;YAC1B,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QAC/C,KAAK,eAAe;YACnB,2DAA2D;YAC3D,yDAAyD;YACzD,6DAA6D;YAC7D,uCAAuC;YACvC,OAAO,OAAO,CAAC,OAAO,CAAC;gBACtB,MAAM,EAAE,iBAAiB;gBACzB,iBAAiB,EAAE,EAAE;gBACrB,QAAQ,EAAE,mEAAmE;gBAC7E,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,UAAU;aACvC,CAAC,CAAA;QACH,OAAO,CAAC,CAAC,CAAC;YACT,MAAM,WAAW,GAAU,OAAO,CAAA;YAClC,MAAM,IAAI,KAAK,CAAC,gCAAiC,WAAmC,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7F,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -145,6 +145,20 @@ export interface ParkSummary {
|
|
|
145
145
|
* scope, intersect with the host's own run records, resume the difference.
|
|
146
146
|
*/
|
|
147
147
|
export interface DurableRunEntry extends CheckpointRunScope {
|
|
148
|
+
/**
|
|
149
|
+
* When the run was attributed. Absent when it was never recorded.
|
|
150
|
+
*
|
|
151
|
+
* The only per-run key this store holds that does not move, which is why
|
|
152
|
+
* it is the one an oldest-first listing can page over — see
|
|
153
|
+
* {@link CheckpointStore.listDurableRuns} and
|
|
154
|
+
* `IterationCheckpoint.runCreatedAt`.
|
|
155
|
+
*
|
|
156
|
+
* **Absent means "not recorded", and a caller should render it that way
|
|
157
|
+
* rather than as a date it invents.** Every run checkpointed by a build
|
|
158
|
+
* carrying the stamp has one; a run that has none was checkpointed
|
|
159
|
+
* before the stamp existed.
|
|
160
|
+
*/
|
|
161
|
+
readonly runCreatedAt?: number;
|
|
148
162
|
/** How many checkpoints the run has right now. Pruning lowers it. */
|
|
149
163
|
readonly checkpointCount: number;
|
|
150
164
|
/** Newest checkpoint by `createdAt` — the one a resume restores by default. */
|
|
@@ -154,8 +168,44 @@ export interface DurableRunEntry extends CheckpointRunScope {
|
|
|
154
168
|
/** Absent when the run has never parked. */
|
|
155
169
|
readonly park?: ParkSummary;
|
|
156
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Which order a listing comes back in.
|
|
173
|
+
*
|
|
174
|
+
* Explicit rather than implied, because the two available orders answer
|
|
175
|
+
* different questions and neither is right for both. "Show me every run
|
|
176
|
+
* waiting on a human" wants stable paging; "show me the one that has been
|
|
177
|
+
* waiting longest" wants chronology. A listing that silently picked one
|
|
178
|
+
* would be the same ambiguity the scope type removed by splitting.
|
|
179
|
+
*/
|
|
180
|
+
export type DurableRunOrder =
|
|
181
|
+
/**
|
|
182
|
+
* By `runId` ascending. Stable and total, and meaningless as chronology —
|
|
183
|
+
* run ids carry no timestamp. The default, because it is what shipped.
|
|
184
|
+
*/
|
|
185
|
+
'runId'
|
|
186
|
+
/**
|
|
187
|
+
* Oldest first, by {@link DurableRunEntry.runCreatedAt} then `runId`.
|
|
188
|
+
* This is the triage order: it answers which run has been waiting
|
|
189
|
+
* longest. Safe to page over, because the stamp is recorded once at
|
|
190
|
+
* attribution and never rewritten.
|
|
191
|
+
*
|
|
192
|
+
* **Runs whose creation was never recorded come FIRST**, ordered among
|
|
193
|
+
* themselves by `runId`. That is not a guess dressed up as a date: the
|
|
194
|
+
* stamp is written by the checkpoint manager, so a run lacking it on
|
|
195
|
+
* every checkpoint was checkpointed by a build that predates the stamp,
|
|
196
|
+
* and therefore predates every run that has one. Their
|
|
197
|
+
* `runCreatedAt` is absent on the row, so a caller can render "unknown"
|
|
198
|
+
* instead of a date nobody recorded.
|
|
199
|
+
*/
|
|
200
|
+
| 'createdAt';
|
|
157
201
|
/** Filters and paging for {@link CheckpointStore.listDurableRuns}. */
|
|
158
202
|
export interface ListDurableRunsOptions {
|
|
203
|
+
/**
|
|
204
|
+
* Ordering, and therefore what the cursor is a position in. Defaults to
|
|
205
|
+
* `'runId'`. A cursor is only meaningful within one order — do not carry
|
|
206
|
+
* one across a change of `orderBy`.
|
|
207
|
+
*/
|
|
208
|
+
readonly orderBy?: DurableRunOrder;
|
|
159
209
|
/**
|
|
160
210
|
* Keep only runs whose park is in one of these states. A run that never
|
|
161
211
|
* parked has no state and is excluded by ANY value here; omit the filter
|
|
@@ -239,30 +289,30 @@ export interface CheckpointStore {
|
|
|
239
289
|
* for an unanswered park, and until this existed the sweep had no way to
|
|
240
290
|
* enumerate what to sweep.
|
|
241
291
|
*
|
|
242
|
-
* ### Ordering
|
|
292
|
+
* ### Ordering
|
|
243
293
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
294
|
+
* Two orders, named by `options.orderBy`, and the cursor is a position in
|
|
295
|
+
* whichever one was asked for. See {@link DurableRunOrder}.
|
|
246
296
|
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
297
|
+
* Both sort on a key that cannot MOVE, which is the property a cursor
|
|
298
|
+
* needs — sort on a moving key and a paging caller skips rows and repeats
|
|
299
|
+
* rows. That rules out every time a checkpoint store can derive on its
|
|
300
|
+
* own: the newest checkpoint's timestamp advances whenever the run
|
|
301
|
+
* checkpoints again, and the oldest one's advances whenever
|
|
302
|
+
* `CheckpointManager.prune` deletes oldest-first, which is what pruning
|
|
303
|
+
* does. It leaves `runId`, which is immutable and unique but carries no
|
|
304
|
+
* timestamp, and `runCreatedAt`, which is recorded once at attribution
|
|
305
|
+
* and denormalized onto every checkpoint so pruning cannot reach it.
|
|
256
306
|
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
307
|
+
* `'runId'` alone is already a total order. `'createdAt'` tiebreaks on
|
|
308
|
+
* `runId`, which is the rule `orderChildren` follows: sort on a key that
|
|
309
|
+
* cannot move, make the order total with an id.
|
|
260
310
|
*
|
|
261
311
|
* A run whose FIRST checkpoint is written after paging began may be
|
|
262
|
-
* missed by that pass — it lands
|
|
263
|
-
* behind the cursor. That is the right trade for a queue:
|
|
264
|
-
* again and picks it up next pass, whereas a moving sort
|
|
265
|
-
* that already existed.
|
|
312
|
+
* missed by that pass, in either order — it lands wherever its key puts
|
|
313
|
+
* it, possibly behind the cursor. That is the right trade for a queue:
|
|
314
|
+
* the sweep runs again and picks it up next pass, whereas a moving sort
|
|
315
|
+
* key loses runs that already existed.
|
|
266
316
|
*
|
|
267
317
|
* @param scope contiguous prefix; `tenantId` required. Implementations
|
|
268
318
|
* reject a hole (`sessionId` with no `projectId`) rather than guessing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoint-store.d.ts","sourceRoot":"","sources":["../../../src/types/run/checkpoint-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC,2CAA2C;IAC3C,QAAQ,EAAE,QAAQ,CAAA;IAClB,gDAAgD;IAChD,SAAS,EAAE,SAAS,CAAA;IACpB,wCAAwC;IACxC,SAAS,EAAE,SAAS,CAAA;IACpB,2CAA2C;IAC3C,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,sBAAsB;IACtC,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,mEAAmE;IAC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AC,CAAA;IAE1F,6EAA6E;IAC7E,cAAc,CACb,KAAK,EAAE,kBAAkB,EACzB,YAAY,EAAE,YAAY,GACxB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAA;IAEtC;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAA;IAE1E,wEAAwE;IACxE,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEtF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,eAAe,CAAC,CACf,KAAK,EAAE,sBAAsB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,cAAc,CAAC,CAAA;CAC1B"}
|
package/package.json
CHANGED
|
@@ -51,6 +51,12 @@ export function projectEmergencyToCheckpoint(dump: EmergencySaveData): Iteration
|
|
|
51
51
|
return {
|
|
52
52
|
id: `cp_emergency_${emergencySuffix}` as CheckpointId,
|
|
53
53
|
runId: dump.runId,
|
|
54
|
+
// The dump records the run's start, so this projection carries the
|
|
55
|
+
// same stamp an ordinary checkpoint of that run would — a run whose
|
|
56
|
+
// only surviving record is an emergency dump still has a real
|
|
57
|
+
// attribution instant, and dropping it here would put that run in the
|
|
58
|
+
// "never recorded" bucket for no reason.
|
|
59
|
+
runCreatedAt: dump.startedAt,
|
|
54
60
|
iteration: dump.currentIteration,
|
|
55
61
|
messages: dump.messages,
|
|
56
62
|
tokenUsage: dump.tokenUsage,
|
|
@@ -148,6 +154,27 @@ export class CheckpointManager {
|
|
|
148
154
|
/** See {@link setParkTtl}. */
|
|
149
155
|
private parkTtlMs?: number
|
|
150
156
|
|
|
157
|
+
/**
|
|
158
|
+
* The run's attribution instant, stamped onto every checkpoint this
|
|
159
|
+
* manager writes.
|
|
160
|
+
*
|
|
161
|
+
* Settled exactly once, by whichever of two things happens first, and
|
|
162
|
+
* never reassigned — every write to it below is `??=`, and there are only
|
|
163
|
+
* two:
|
|
164
|
+
*
|
|
165
|
+
* - `restore` ADOPTS it from the checkpoint a resume came back through.
|
|
166
|
+
* A resumed run is the same run, and its creation is already on the
|
|
167
|
+
* record; a fresh process minting a new one would move the key that
|
|
168
|
+
* exists specifically because it does not move.
|
|
169
|
+
* - `create` MINTS it from the run's own start instant when nothing was
|
|
170
|
+
* adopted, which is the fresh-run case.
|
|
171
|
+
*
|
|
172
|
+
* Restore runs during run setup, before the first iteration and therefore
|
|
173
|
+
* before the first `create`, so the adopt always wins on the resume path
|
|
174
|
+
* without either site needing to know which path it is on.
|
|
175
|
+
*/
|
|
176
|
+
private runCreatedAt?: number
|
|
177
|
+
|
|
151
178
|
/**
|
|
152
179
|
* @param store scope-keyed checkpoint persistence. The default query
|
|
153
180
|
* pipeline passes the run's disk-backed store
|
|
@@ -182,9 +209,17 @@ export class CheckpointManager {
|
|
|
182
209
|
workingState?: WorkingStateSnapshot
|
|
183
210
|
},
|
|
184
211
|
): Promise<IterationCheckpoint> {
|
|
212
|
+
// The run's own start, not `Date.now()`. This is meant to say when the
|
|
213
|
+
// run was attributed; taking the clock at the first checkpoint would
|
|
214
|
+
// say when it first became durable, which is a different and later
|
|
215
|
+
// fact, and naming it after the earlier one would make it wrong in
|
|
216
|
+
// exactly the way that is hard to notice.
|
|
217
|
+
this.runCreatedAt ??= runMgr.getSession().startedAt ?? Date.now()
|
|
218
|
+
|
|
185
219
|
const checkpoint: IterationCheckpoint = {
|
|
186
220
|
id: generateCheckpointId(),
|
|
187
221
|
runId: runMgr.id,
|
|
222
|
+
runCreatedAt: this.runCreatedAt,
|
|
188
223
|
iteration,
|
|
189
224
|
messages: [...runMgr.messages],
|
|
190
225
|
tokenUsage: { ...runMgr.tokenUsage },
|
|
@@ -342,6 +377,22 @@ export class CheckpointManager {
|
|
|
342
377
|
details: { checkpointId, runId: this.scope.runId },
|
|
343
378
|
})
|
|
344
379
|
}
|
|
380
|
+
|
|
381
|
+
// Adopt the run's recorded attribution. A resumed run is the SAME run
|
|
382
|
+
// under the same id, and its creation is already on the record; a
|
|
383
|
+
// fresh process minting a new one would step the stamp forward on
|
|
384
|
+
// every resume, which is the motion it exists to avoid.
|
|
385
|
+
//
|
|
386
|
+
// This needs no "is it really my run" guard, and one was written and
|
|
387
|
+
// removed: `readCheckpoint` is keyed by THIS manager's scope, so the
|
|
388
|
+
// only checkpoints reachable here are the ones belonging to
|
|
389
|
+
// `scope.runId`. A replay fork never arrives here at all — it reads
|
|
390
|
+
// its origin through the SOURCE scope in `prepareReplayState` and
|
|
391
|
+
// starts a fresh run, so it mints its own stamp rather than claiming
|
|
392
|
+
// its origin's age. A guard that no input can trip would have read as
|
|
393
|
+
// protection and been none.
|
|
394
|
+
this.runCreatedAt ??= checkpoint.runCreatedAt
|
|
395
|
+
|
|
345
396
|
return checkpoint
|
|
346
397
|
}
|
|
347
398
|
|
package/src/store/run/listing.ts
CHANGED
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
CheckpointRunScope,
|
|
16
16
|
CheckpointStore,
|
|
17
17
|
DurableRunEntry,
|
|
18
|
+
DurableRunOrder,
|
|
18
19
|
DurableRunPage,
|
|
19
20
|
ListDurableRunsOptions,
|
|
20
21
|
ParkState,
|
|
@@ -139,8 +140,21 @@ export function toDurableRunEntry(
|
|
|
139
140
|
if (checkpoints.length === 0) return null
|
|
140
141
|
|
|
141
142
|
let latest = checkpoints[0] as IterationCheckpoint
|
|
143
|
+
// The EARLIEST recorded stamp, not the one on any particular checkpoint.
|
|
144
|
+
// Every checkpoint of a run carries the same value, so under that
|
|
145
|
+
// invariant the minimum is that value. Taking the minimum rather than
|
|
146
|
+
// reading one checkpoint is what makes the read safe if the invariant is
|
|
147
|
+
// ever broken: it can only err toward the run's true attribution, never
|
|
148
|
+
// away from it, and it cannot move when a later checkpoint is added.
|
|
149
|
+
let runCreatedAt: number | undefined
|
|
142
150
|
for (const cp of checkpoints) {
|
|
143
151
|
if (cp.createdAt > latest.createdAt) latest = cp
|
|
152
|
+
if (
|
|
153
|
+
cp.runCreatedAt !== undefined &&
|
|
154
|
+
(runCreatedAt === undefined || cp.runCreatedAt < runCreatedAt)
|
|
155
|
+
) {
|
|
156
|
+
runCreatedAt = cp.runCreatedAt
|
|
157
|
+
}
|
|
144
158
|
}
|
|
145
159
|
|
|
146
160
|
const park = summarizePark(checkpoints, now)
|
|
@@ -151,6 +165,7 @@ export function toDurableRunEntry(
|
|
|
151
165
|
sessionId: scope.sessionId,
|
|
152
166
|
runId: scope.runId,
|
|
153
167
|
...(scope.parentRunId ? { parentRunId: scope.parentRunId } : {}),
|
|
168
|
+
...(runCreatedAt !== undefined ? { runCreatedAt } : {}),
|
|
154
169
|
checkpointCount: checkpoints.length,
|
|
155
170
|
latestCheckpointId: latest.id,
|
|
156
171
|
latestCheckpointAt: latest.createdAt,
|
|
@@ -176,12 +191,16 @@ export function paginateDurableRuns(
|
|
|
176
191
|
? entries.filter((e) => e.park !== undefined && wanted.includes(e.park.state))
|
|
177
192
|
: entries
|
|
178
193
|
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
const
|
|
194
|
+
// Both orders sort on a key that cannot move under a paging caller — see
|
|
195
|
+
// the contract comment on `listDurableRuns`.
|
|
196
|
+
const orderBy = options?.orderBy ?? 'runId'
|
|
197
|
+
const ordered = [...filtered].sort((a, b) =>
|
|
198
|
+
compareKeys(sortKey(a, orderBy), sortKey(b, orderBy)),
|
|
199
|
+
)
|
|
182
200
|
|
|
183
|
-
const after = options?.cursor
|
|
184
|
-
const start =
|
|
201
|
+
const after = options?.cursor === undefined ? undefined : decodeCursor(options.cursor, orderBy)
|
|
202
|
+
const start =
|
|
203
|
+
after === undefined ? 0 : ordered.findIndex((e) => compareKeys(sortKey(e, orderBy), after) > 0)
|
|
185
204
|
const from = start < 0 ? ordered.length : start
|
|
186
205
|
|
|
187
206
|
const limit = Math.max(1, Math.trunc(options?.limit ?? DEFAULT_DURABLE_RUN_LIMIT))
|
|
@@ -194,8 +213,67 @@ export function paginateDurableRuns(
|
|
|
194
213
|
// terminates rather than fetching one empty page to find out.
|
|
195
214
|
...(exhausted || page.length === 0
|
|
196
215
|
? {}
|
|
197
|
-
: { cursor: (page[page.length - 1] as DurableRunEntry)
|
|
216
|
+
: { cursor: encodeCursor(sortKey(page[page.length - 1] as DurableRunEntry, orderBy)) }),
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A row's position in the requested order, as a comparable tuple.
|
|
222
|
+
*
|
|
223
|
+
* The first element is a rank rather than the timestamp itself, so that
|
|
224
|
+
* "never recorded" is a position in its own right instead of a number
|
|
225
|
+
* standing in for one. In `createdAt` order it ranks 0 and everything
|
|
226
|
+
* stamped ranks 1 — unrecorded runs first, and truthfully so: the stamp is
|
|
227
|
+
* written by the checkpoint manager, so a run without one was checkpointed
|
|
228
|
+
* by a build that predates it, and predates every run that has one.
|
|
229
|
+
*/
|
|
230
|
+
type SortKey = readonly [number, number, string]
|
|
231
|
+
|
|
232
|
+
function sortKey(entry: DurableRunEntry, orderBy: DurableRunOrder): SortKey {
|
|
233
|
+
if (orderBy === 'runId') return [0, 0, entry.runId]
|
|
234
|
+
return entry.runCreatedAt === undefined
|
|
235
|
+
? [0, 0, entry.runId]
|
|
236
|
+
: [1, entry.runCreatedAt, entry.runId]
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function compareKeys(a: SortKey, b: SortKey): number {
|
|
240
|
+
if (a[0] !== b[0]) return a[0] - b[0]
|
|
241
|
+
if (a[1] !== b[1]) return a[1] - b[1]
|
|
242
|
+
return a[2] < b[2] ? -1 : a[2] > b[2] ? 1 : 0
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The cursor is the last row's key, and nothing else.
|
|
247
|
+
*
|
|
248
|
+
* Opaque to callers by contract — the shape is written down here rather than
|
|
249
|
+
* in the type so a host is not tempted to construct one. Run ids come from a
|
|
250
|
+
* 36-character lowercase alphabet with a `run_` prefix and contain no
|
|
251
|
+
* separator, so joining on `:` is unambiguous.
|
|
252
|
+
*/
|
|
253
|
+
function encodeCursor(key: SortKey): string {
|
|
254
|
+
return `${key[0]}:${key[1]}:${key[2]}`
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function decodeCursor(cursor: string, orderBy: DurableRunOrder): SortKey {
|
|
258
|
+
const first = cursor.indexOf(':')
|
|
259
|
+
const second = cursor.indexOf(':', first + 1)
|
|
260
|
+
if (first < 0 || second < 0) {
|
|
261
|
+
throw new NamzuError({
|
|
262
|
+
code: 'invalid_config',
|
|
263
|
+
message: `listDurableRuns: "${cursor}" is not a cursor this listing issued. Pass back the \`cursor\` from the previous page rather than constructing one; its shape is not part of the contract.`,
|
|
264
|
+
details: { cursor, orderBy },
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
const rank = Number(cursor.slice(0, first))
|
|
268
|
+
const stamp = Number(cursor.slice(first + 1, second))
|
|
269
|
+
if (!Number.isFinite(rank) || !Number.isFinite(stamp)) {
|
|
270
|
+
throw new NamzuError({
|
|
271
|
+
code: 'invalid_config',
|
|
272
|
+
message: `listDurableRuns: cursor "${cursor}" is malformed — its position fields are not numbers. Pass back the \`cursor\` from the previous page.`,
|
|
273
|
+
details: { cursor, orderBy },
|
|
274
|
+
})
|
|
198
275
|
}
|
|
276
|
+
return [rank, stamp, cursor.slice(second + 1)]
|
|
199
277
|
}
|
|
200
278
|
|
|
201
279
|
/**
|
package/src/types/hitl/index.ts
CHANGED
|
@@ -210,6 +210,34 @@ export interface IterationCheckpoint {
|
|
|
210
210
|
*/
|
|
211
211
|
planStatus?: PlanStatus
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* When the RUN was attributed — not when this checkpoint was written.
|
|
215
|
+
* See {@link IterationCheckpoint.createdAt} for the latter.
|
|
216
|
+
*
|
|
217
|
+
* Denormalized onto every checkpoint of the run, identically, and that
|
|
218
|
+
* repetition is the whole point. A listing above the run needs a key it
|
|
219
|
+
* can order by, and a key a paging caller can trust is one that cannot
|
|
220
|
+
* MOVE. Every other time a checkpoint store can derive per run moves: the
|
|
221
|
+
* newest checkpoint's `createdAt` advances every time the run checkpoints
|
|
222
|
+
* again, and the oldest one's advances every time `prune` deletes
|
|
223
|
+
* oldest-first. Carried on all of them, this one survives both — pruning
|
|
224
|
+
* cannot reach a value every survivor also holds.
|
|
225
|
+
*
|
|
226
|
+
* `readonly`, and written exactly once per run by
|
|
227
|
+
* {@link import('../../runtime/query/checkpoint.js').CheckpointManager},
|
|
228
|
+
* which settles it on whichever comes first — adopting it from the
|
|
229
|
+
* checkpoint a resume restores, or minting it from the run's own start
|
|
230
|
+
* instant — and never reassigns after. A field that COULD be updated is
|
|
231
|
+
* one edit away from moving again, which would put the ordering back
|
|
232
|
+
* where it started.
|
|
233
|
+
*
|
|
234
|
+
* Absent on checkpoints written before this existed. That absence is
|
|
235
|
+
* information, not a gap: a run with no stamp on any of its checkpoints
|
|
236
|
+
* was attributed before the stamp existed, and therefore before every
|
|
237
|
+
* run that has one.
|
|
238
|
+
*/
|
|
239
|
+
readonly runCreatedAt?: number
|
|
240
|
+
|
|
213
241
|
/**
|
|
214
242
|
* Present when the run parked at this checkpoint awaiting a human.
|
|
215
243
|
* See {@link PendingDecision}.
|
|
@@ -152,6 +152,21 @@ export interface ParkSummary {
|
|
|
152
152
|
* scope, intersect with the host's own run records, resume the difference.
|
|
153
153
|
*/
|
|
154
154
|
export interface DurableRunEntry extends CheckpointRunScope {
|
|
155
|
+
/**
|
|
156
|
+
* When the run was attributed. Absent when it was never recorded.
|
|
157
|
+
*
|
|
158
|
+
* The only per-run key this store holds that does not move, which is why
|
|
159
|
+
* it is the one an oldest-first listing can page over — see
|
|
160
|
+
* {@link CheckpointStore.listDurableRuns} and
|
|
161
|
+
* `IterationCheckpoint.runCreatedAt`.
|
|
162
|
+
*
|
|
163
|
+
* **Absent means "not recorded", and a caller should render it that way
|
|
164
|
+
* rather than as a date it invents.** Every run checkpointed by a build
|
|
165
|
+
* carrying the stamp has one; a run that has none was checkpointed
|
|
166
|
+
* before the stamp existed.
|
|
167
|
+
*/
|
|
168
|
+
readonly runCreatedAt?: number
|
|
169
|
+
|
|
155
170
|
/** How many checkpoints the run has right now. Pruning lowers it. */
|
|
156
171
|
readonly checkpointCount: number
|
|
157
172
|
/** Newest checkpoint by `createdAt` — the one a resume restores by default. */
|
|
@@ -162,8 +177,46 @@ export interface DurableRunEntry extends CheckpointRunScope {
|
|
|
162
177
|
readonly park?: ParkSummary
|
|
163
178
|
}
|
|
164
179
|
|
|
180
|
+
/**
|
|
181
|
+
* Which order a listing comes back in.
|
|
182
|
+
*
|
|
183
|
+
* Explicit rather than implied, because the two available orders answer
|
|
184
|
+
* different questions and neither is right for both. "Show me every run
|
|
185
|
+
* waiting on a human" wants stable paging; "show me the one that has been
|
|
186
|
+
* waiting longest" wants chronology. A listing that silently picked one
|
|
187
|
+
* would be the same ambiguity the scope type removed by splitting.
|
|
188
|
+
*/
|
|
189
|
+
export type DurableRunOrder =
|
|
190
|
+
/**
|
|
191
|
+
* By `runId` ascending. Stable and total, and meaningless as chronology —
|
|
192
|
+
* run ids carry no timestamp. The default, because it is what shipped.
|
|
193
|
+
*/
|
|
194
|
+
| 'runId'
|
|
195
|
+
/**
|
|
196
|
+
* Oldest first, by {@link DurableRunEntry.runCreatedAt} then `runId`.
|
|
197
|
+
* This is the triage order: it answers which run has been waiting
|
|
198
|
+
* longest. Safe to page over, because the stamp is recorded once at
|
|
199
|
+
* attribution and never rewritten.
|
|
200
|
+
*
|
|
201
|
+
* **Runs whose creation was never recorded come FIRST**, ordered among
|
|
202
|
+
* themselves by `runId`. That is not a guess dressed up as a date: the
|
|
203
|
+
* stamp is written by the checkpoint manager, so a run lacking it on
|
|
204
|
+
* every checkpoint was checkpointed by a build that predates the stamp,
|
|
205
|
+
* and therefore predates every run that has one. Their
|
|
206
|
+
* `runCreatedAt` is absent on the row, so a caller can render "unknown"
|
|
207
|
+
* instead of a date nobody recorded.
|
|
208
|
+
*/
|
|
209
|
+
| 'createdAt'
|
|
210
|
+
|
|
165
211
|
/** Filters and paging for {@link CheckpointStore.listDurableRuns}. */
|
|
166
212
|
export interface ListDurableRunsOptions {
|
|
213
|
+
/**
|
|
214
|
+
* Ordering, and therefore what the cursor is a position in. Defaults to
|
|
215
|
+
* `'runId'`. A cursor is only meaningful within one order — do not carry
|
|
216
|
+
* one across a change of `orderBy`.
|
|
217
|
+
*/
|
|
218
|
+
readonly orderBy?: DurableRunOrder
|
|
219
|
+
|
|
167
220
|
/**
|
|
168
221
|
* Keep only runs whose park is in one of these states. A run that never
|
|
169
222
|
* parked has no state and is excluded by ANY value here; omit the filter
|
|
@@ -256,30 +309,30 @@ export interface CheckpointStore {
|
|
|
256
309
|
* for an unanswered park, and until this existed the sweep had no way to
|
|
257
310
|
* enumerate what to sweep.
|
|
258
311
|
*
|
|
259
|
-
* ### Ordering
|
|
312
|
+
* ### Ordering
|
|
260
313
|
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
314
|
+
* Two orders, named by `options.orderBy`, and the cursor is a position in
|
|
315
|
+
* whichever one was asked for. See {@link DurableRunOrder}.
|
|
263
316
|
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
317
|
+
* Both sort on a key that cannot MOVE, which is the property a cursor
|
|
318
|
+
* needs — sort on a moving key and a paging caller skips rows and repeats
|
|
319
|
+
* rows. That rules out every time a checkpoint store can derive on its
|
|
320
|
+
* own: the newest checkpoint's timestamp advances whenever the run
|
|
321
|
+
* checkpoints again, and the oldest one's advances whenever
|
|
322
|
+
* `CheckpointManager.prune` deletes oldest-first, which is what pruning
|
|
323
|
+
* does. It leaves `runId`, which is immutable and unique but carries no
|
|
324
|
+
* timestamp, and `runCreatedAt`, which is recorded once at attribution
|
|
325
|
+
* and denormalized onto every checkpoint so pruning cannot reach it.
|
|
273
326
|
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
327
|
+
* `'runId'` alone is already a total order. `'createdAt'` tiebreaks on
|
|
328
|
+
* `runId`, which is the rule `orderChildren` follows: sort on a key that
|
|
329
|
+
* cannot move, make the order total with an id.
|
|
277
330
|
*
|
|
278
331
|
* A run whose FIRST checkpoint is written after paging began may be
|
|
279
|
-
* missed by that pass — it lands
|
|
280
|
-
* behind the cursor. That is the right trade for a queue:
|
|
281
|
-
* again and picks it up next pass, whereas a moving sort
|
|
282
|
-
* that already existed.
|
|
332
|
+
* missed by that pass, in either order — it lands wherever its key puts
|
|
333
|
+
* it, possibly behind the cursor. That is the right trade for a queue:
|
|
334
|
+
* the sweep runs again and picks it up next pass, whereas a moving sort
|
|
335
|
+
* key loses runs that already existed.
|
|
283
336
|
*
|
|
284
337
|
* @param scope contiguous prefix; `tenantId` required. Implementations
|
|
285
338
|
* reject a hole (`sessionId` with no `projectId`) rather than guessing.
|