@cat-factory/worker 0.176.0 → 0.178.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +9 -0
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/binaryStores.d.ts +15 -0
- package/dist/infrastructure/binaryStores.d.ts.map +1 -0
- package/dist/infrastructure/binaryStores.js +48 -0
- package/dist/infrastructure/binaryStores.js.map +1 -0
- package/dist/infrastructure/container-artifact-storage.d.ts +16 -3
- package/dist/infrastructure/container-artifact-storage.d.ts.map +1 -1
- package/dist/infrastructure/container-artifact-storage.js +21 -6
- package/dist/infrastructure/container-artifact-storage.js.map +1 -1
- package/dist/infrastructure/container-assembly.d.ts.map +1 -1
- package/dist/infrastructure/container-assembly.js +11 -3
- package/dist/infrastructure/container-assembly.js.map +1 -1
- package/dist/infrastructure/container-notification-deps.d.ts +45 -2
- package/dist/infrastructure/container-notification-deps.d.ts.map +1 -1
- package/dist/infrastructure/container-notification-deps.js +87 -3
- package/dist/infrastructure/container-notification-deps.js.map +1 -1
- package/dist/infrastructure/container-registries.d.ts +1 -1
- package/dist/infrastructure/container-registries.d.ts.map +1 -1
- package/dist/infrastructure/container-registries.js +15 -0
- package/dist/infrastructure/container-registries.js.map +1 -1
- package/dist/infrastructure/container-shared-services.d.ts +3 -0
- package/dist/infrastructure/container-shared-services.d.ts.map +1 -1
- package/dist/infrastructure/container-shared-services.js +1 -0
- package/dist/infrastructure/container-shared-services.js.map +1 -1
- package/dist/infrastructure/container.d.ts.map +1 -1
- package/dist/infrastructure/container.js +14 -22
- package/dist/infrastructure/container.js.map +1 -1
- package/dist/infrastructure/containers/CloudflareContainerTransport.d.ts.map +1 -1
- package/dist/infrastructure/containers/CloudflareContainerTransport.js +29 -12
- package/dist/infrastructure/containers/CloudflareContainerTransport.js.map +1 -1
- package/dist/infrastructure/containers/RunContainer.d.ts +62 -10
- package/dist/infrastructure/containers/RunContainer.d.ts.map +1 -1
- package/dist/infrastructure/containers/RunContainer.js +83 -18
- package/dist/infrastructure/containers/RunContainer.js.map +1 -1
- package/dist/infrastructure/containers/stopCause.d.ts +147 -12
- package/dist/infrastructure/containers/stopCause.d.ts.map +1 -1
- package/dist/infrastructure/containers/stopCause.js +223 -18
- package/dist/infrastructure/containers/stopCause.js.map +1 -1
- package/dist/infrastructure/github-deps.js +2 -2
- package/dist/infrastructure/github-deps.js.map +1 -1
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.d.ts +1 -0
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.d.ts.map +1 -1
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.js +30 -0
- package/dist/infrastructure/repositories/D1BinaryArtifactMetadataStore.js.map +1 -1
- package/dist/infrastructure/repositories/D1NotificationSettingsRepository.d.ts +11 -0
- package/dist/infrastructure/repositories/D1NotificationSettingsRepository.d.ts.map +1 -0
- package/dist/infrastructure/repositories/D1NotificationSettingsRepository.js +30 -0
- package/dist/infrastructure/repositories/D1NotificationSettingsRepository.js.map +1 -0
- package/dist/infrastructure/repositories/chunk.d.ts +10 -2
- package/dist/infrastructure/repositories/chunk.d.ts.map +1 -1
- package/dist/infrastructure/repositories/chunk.js +13 -4
- package/dist/infrastructure/repositories/chunk.js.map +1 -1
- package/dist/infrastructure/wireCredentialServices.d.ts.map +1 -1
- package/dist/infrastructure/wireCredentialServices.js +6 -6
- package/dist/infrastructure/wireCredentialServices.js.map +1 -1
- package/migrations/0088_notification_settings.sql +15 -0
- package/package.json +18 -18
|
@@ -12,9 +12,30 @@
|
|
|
12
12
|
export type ContainerStopCause = 'rollout' | 'idle';
|
|
13
13
|
/** DO-storage key holding the {@link StopCauseRecord} of the most recent self-observed stop. */
|
|
14
14
|
export declare const STOP_CAUSE_KEY = "containerStopCause";
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* What the runtime reported when the workload stopped, mirroring the container base class's
|
|
17
|
+
* `StopParams`. Recorded for EVERY stop, including the ones no {@link ContainerStopCause}
|
|
18
|
+
* explains, because it answers a different question: the cause decides the recovery BUDGET, the
|
|
19
|
+
* exit state is the only account of the death anyone gets afterwards.
|
|
20
|
+
*
|
|
21
|
+
* A Cloudflare Container's stdout is delivered to the deployment's Workers logs and is not
|
|
22
|
+
* readable back from inside the Durable Object, so this is the whole of the post-mortem this
|
|
23
|
+
* runtime can mint. It is still the difference between "container evicted or crashed" and "exit
|
|
24
|
+
* code 137", i.e. between a run nobody can diagnose and an out-of-memory kill.
|
|
25
|
+
*/
|
|
26
|
+
export interface ContainerExitState {
|
|
27
|
+
code: number;
|
|
28
|
+
reason: 'exit' | 'runtime_signal';
|
|
29
|
+
}
|
|
30
|
+
/** What the container persists when it observes its own stop. */
|
|
16
31
|
export interface StopCauseRecord {
|
|
17
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The infrastructure-churn cause, when the container recognised one. Absent for a stop it
|
|
34
|
+
* cannot explain (a crash, an OOM kill), which is exactly the case {@link exit} exists for.
|
|
35
|
+
*/
|
|
36
|
+
cause?: ContainerStopCause;
|
|
37
|
+
/** What the runtime reported about the stop, when a hook that carries it fired. */
|
|
38
|
+
exit?: ContainerExitState;
|
|
18
39
|
/** Epoch ms the stop was observed. */
|
|
19
40
|
at: number;
|
|
20
41
|
/**
|
|
@@ -49,6 +70,42 @@ export declare const ATTRIBUTION_WINDOW_MS: {
|
|
|
49
70
|
rollout: number;
|
|
50
71
|
idle: number;
|
|
51
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* How long a stop this container could NOT attribute (a crash, an OOM kill) may still explain a
|
|
75
|
+
* 404 poll, i.e. the window governing a record that carries only an {@link ContainerExitState}.
|
|
76
|
+
*
|
|
77
|
+
* The same reasoning as the `idle` window, and deliberately the same number: what separates the
|
|
78
|
+
* death from the poll that discovers it is the POLL GAP, and a crash is discovered by the same
|
|
79
|
+
* ~15s tick an idle reclaim is, stretched by whatever delayed the driver. Sizing this to the
|
|
80
|
+
* rollout case instead would read every crash discovered after a re-drive as unexplained, which
|
|
81
|
+
* is the class this record exists to explain.
|
|
82
|
+
*
|
|
83
|
+
* Wide is affordable here for a reason the cause windows do not share: an exit state changes no
|
|
84
|
+
* verdict. It is attached to the failure `detail`, so the cost of over-attributing is a
|
|
85
|
+
* misleading sentence, never a wrongly-extended recovery budget.
|
|
86
|
+
*/
|
|
87
|
+
export declare const EXIT_ATTRIBUTION_WINDOW_MS: number;
|
|
88
|
+
/**
|
|
89
|
+
* How far apart two hook calls may be and still be treated as observations of ONE stop, i.e. the
|
|
90
|
+
* bound on {@link recordStopCause}'s merge.
|
|
91
|
+
*
|
|
92
|
+
* The merge exists for a single reason: `onError` and `onStop` are two views of the same death,
|
|
93
|
+
* fired by the runtime within moments of each other. Anything older is a DIFFERENT, earlier
|
|
94
|
+
* stop, and merging onto it is not conservative, it is destructive twice over: the new
|
|
95
|
+
* observation inherits the old record's `at`, so it is born already aged, and both halves then
|
|
96
|
+
* fall out of their own attribution windows and explain nothing. A record that is 40 minutes old
|
|
97
|
+
* would silently swallow the crash that just happened.
|
|
98
|
+
*
|
|
99
|
+
* Sized generously against what it models (two hooks, milliseconds apart) and far below the
|
|
100
|
+
* narrowest attribution window, so it cannot be the thing that decides an attribution: what a
|
|
101
|
+
* merge may do is complete an account of one stop, never date it.
|
|
102
|
+
*/
|
|
103
|
+
export declare const STOP_MERGE_WINDOW_MS = 60000;
|
|
104
|
+
/** What a container observed about its own stop, once attributed to the job that reads it. */
|
|
105
|
+
export interface StopObservation {
|
|
106
|
+
cause?: ContainerStopCause;
|
|
107
|
+
exit?: ContainerExitState;
|
|
108
|
+
}
|
|
52
109
|
/**
|
|
53
110
|
* The message the base container class surfaces when the RUNTIME (not the workload) stopped a
|
|
54
111
|
* container: a deploy draining the old version. Its own exit-code parser is keyed on the plain
|
|
@@ -57,18 +114,43 @@ export declare const ATTRIBUTION_WINDOW_MS: {
|
|
|
57
114
|
*/
|
|
58
115
|
export declare function isRolloutSignal(error: unknown): boolean;
|
|
59
116
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
117
|
+
* What a container should record about a stop the runtime just reported, or undefined when it
|
|
118
|
+
* should record nothing.
|
|
119
|
+
*
|
|
120
|
+
* Two rules, both about what the stop MEANS rather than what it says:
|
|
121
|
+
*
|
|
122
|
+
* - A `runtime_signal` 143 is the rollout drain surfacing through this hook instead of (or as
|
|
123
|
+
* well as) `onError`, depending on the runtime version, so it names the same cause.
|
|
124
|
+
* - A stop the container ASKED for records nothing at all. Its idle reclaim and its shutdown RPC
|
|
125
|
+
* both work by signalling the container, so the exit that comes back is this container's own
|
|
126
|
+
* request echoed at it (escalating to a SIGKILL 137 when the workload does not exit inside the
|
|
127
|
+
* grace period), not an observation of how anything died. Recorded anyway, it is read back as
|
|
128
|
+
* the container's cause of death and reported to the operator as "most often an out-of-memory
|
|
129
|
+
* kill" underneath a verdict that says the platform reclaimed an idle container. The cause the
|
|
130
|
+
* caller recorded when it decided to stop is the whole account, and it is already stored.
|
|
131
|
+
*/
|
|
132
|
+
export declare function observationForStop(params: {
|
|
133
|
+
exitCode: number;
|
|
134
|
+
reason: 'exit' | 'runtime_signal';
|
|
135
|
+
}, selfInitiated: boolean): StopObservation | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* What a stored record still explains at `now`, or an EMPTY observation when it explains
|
|
138
|
+
* nothing.
|
|
62
139
|
*
|
|
63
|
-
*
|
|
64
|
-
* the record outlived its
|
|
140
|
+
* An empty observation covers three things that all mean the same to the caller: nothing was
|
|
141
|
+
* recorded, the record outlived its window (the container recovered and ran on, so a later death
|
|
65
142
|
* is its own), or the record names a cause this build no longer has. The last is possible
|
|
66
143
|
* because the record is PERSISTED and the vocabulary is closed: a deploy that retires a member
|
|
67
144
|
* leaves rows behind. All three land on the caller's existing default, reporting the eviction
|
|
68
145
|
* as a `crash`, which is the honest reading of "no attribution" and the conservative one:
|
|
69
146
|
* it costs a run one restart of its recovery budget, never a wrongly-extended one.
|
|
147
|
+
*
|
|
148
|
+
* The two halves are attributed INDEPENDENTLY, on their own windows: a record can be too old to
|
|
149
|
+
* excuse the eviction as churn while still being the only account of how the container died, and
|
|
150
|
+
* dropping the exit state with the cause would throw away the diagnostic to protect a budget the
|
|
151
|
+
* diagnostic never touches.
|
|
70
152
|
*/
|
|
71
|
-
export declare function attributeStopCause(record: unknown, now: number, claimant: string):
|
|
153
|
+
export declare function attributeStopCause(record: unknown, now: number, claimant: string): StopObservation;
|
|
72
154
|
/**
|
|
73
155
|
* The slice of DO storage the bookkeeping below needs. Narrowed to three methods so the rules
|
|
74
156
|
* can be exercised against a plain fake. The alternative is asserting them through a real
|
|
@@ -79,8 +161,57 @@ export interface StopCauseStorage {
|
|
|
79
161
|
put: (key: string, value: StopCauseRecord) => Promise<void>;
|
|
80
162
|
delete: (key: string) => Promise<unknown>;
|
|
81
163
|
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Persist what this container just observed about its own stop, MERGING onto an unclaimed record
|
|
166
|
+
* of the SAME stop rather than replacing it.
|
|
167
|
+
*
|
|
168
|
+
* Merging is the point. One stop reaches this container through up to two hooks carrying
|
|
169
|
+
* different halves of the answer: `onError` recognises a rollout drain and knows no exit state,
|
|
170
|
+
* `onStop` carries `{ exitCode, reason }` and cannot name the churn. They fire in either order
|
|
171
|
+
* (and, on some runtime versions, both), so a plain overwrite means whichever landed second
|
|
172
|
+
* silently discarded the other's half: either the recovery budget or the only account of the
|
|
173
|
+
* death, depending on the ordering that day.
|
|
174
|
+
*
|
|
175
|
+
* Two records are never merged:
|
|
176
|
+
*
|
|
177
|
+
* - a CLAIMED one, which has already explained somebody's eviction, so anything observed after
|
|
178
|
+
* it belongs to the next one;
|
|
179
|
+
* - one older than {@link STOP_MERGE_WINDOW_MS}, which is a different stop entirely. This
|
|
180
|
+
* container's records are not reliably cleared between stops (`takeStopCause` deliberately
|
|
181
|
+
* leaves an expired record in place, and only an accepted dispatch deletes one), so a stale
|
|
182
|
+
* record is the ORDINARY state of a container that idled out and was re-driven, not an edge
|
|
183
|
+
* case. Merging onto it would back-date the new observation to the old stop's `at` and age it
|
|
184
|
+
* out of its own attribution window on arrival: the crash that just happened would be
|
|
185
|
+
* recorded, read back, and dropped as too old to explain the eviction it caused.
|
|
186
|
+
*
|
|
187
|
+
* The kept `at` is the EARLIEST of the two observations, which within the merge window is a
|
|
188
|
+
* choice between timestamps moments apart: both describe one stop, and the window measures how
|
|
189
|
+
* long ago that stop happened.
|
|
190
|
+
*/
|
|
191
|
+
export declare function recordStopCause(storage: StopCauseStorage, observed: StopObservation, now: number): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* The one-line account of a container's stop for the eviction `detail`, or undefined when
|
|
194
|
+
* nothing was recorded.
|
|
195
|
+
*
|
|
196
|
+
* `cause` is the account the run has ALREADY been given, and passing it is what keeps the detail
|
|
197
|
+
* from arguing with the verdict beside it. The two halves are recorded independently and the
|
|
198
|
+
* exit state is attached whether or not a cause was recognised, so they routinely describe one
|
|
199
|
+
* event twice: an idle reclaim is performed BY the platform with a SIGKILL, so a run correctly
|
|
200
|
+
* reported as "idle container reclaimed between polls" carries exit 137, and read as an
|
|
201
|
+
* unexplained death that code says "most often an out-of-memory kill". The operator is then
|
|
202
|
+
* holding a verdict and a detail that cannot both be true, which is worse than either alone,
|
|
203
|
+
* because there is no way to tell which one to act on.
|
|
204
|
+
*
|
|
205
|
+
* So the interpretation is offered only where it is the only account there is. Where a cause was
|
|
206
|
+
* named, the exit code is reported as the MECHANICS of that stop: still the difference between
|
|
207
|
+
* "reclaimed" and "reclaimed with a SIGKILL", and never a second, competing cause of death.
|
|
208
|
+
*
|
|
209
|
+
* Either way it states the platform's own limit rather than leaving it to be inferred: a
|
|
210
|
+
* Cloudflare Container writes its stdout to the deployment's Workers logs, and nothing inside
|
|
211
|
+
* the Durable Object can read it back, so an operator who reads this and goes looking for a log
|
|
212
|
+
* tail here should be told where the tail actually is.
|
|
213
|
+
*/
|
|
214
|
+
export declare function describeContainerExit(exit: ContainerExitState | undefined, cause?: ContainerStopCause): string | undefined;
|
|
84
215
|
/**
|
|
85
216
|
* Forget whatever this container observed before now.
|
|
86
217
|
*
|
|
@@ -93,13 +224,17 @@ export declare function recordStopCause(storage: StopCauseStorage, cause: Contai
|
|
|
93
224
|
*/
|
|
94
225
|
export declare function clearStopCause(storage: StopCauseStorage): Promise<void>;
|
|
95
226
|
/**
|
|
96
|
-
* Read
|
|
227
|
+
* Read what explains `claimant`'s 404 poll, CLAIMING it for that job.
|
|
97
228
|
*
|
|
98
|
-
* One
|
|
229
|
+
* One stop explains exactly one job's eviction: the engine answers one by re-dispatching onto
|
|
99
230
|
* a fresh container under the same DO id, so an unclaimed record would still be sitting there to
|
|
100
231
|
* excuse the next death, whenever and for whatever reason it came. The claim is written rather
|
|
101
232
|
* than the record deleted so a REPLAYED poll for the same job reads back the same answer (see
|
|
102
233
|
* {@link StopCauseRecord.claimedBy}).
|
|
234
|
+
*
|
|
235
|
+
* The claim covers the record, not one half of it: an exit state read here is spent as surely as
|
|
236
|
+
* a cause is, because attaching one container's death to two runs' failures is the same lie
|
|
237
|
+
* either way.
|
|
103
238
|
*/
|
|
104
|
-
export declare function takeStopCause(storage: StopCauseStorage, now: number, claimant: string): Promise<
|
|
239
|
+
export declare function takeStopCause(storage: StopCauseStorage, now: number, claimant: string): Promise<StopObservation>;
|
|
105
240
|
//# sourceMappingURL=stopCause.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopCause.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/containers/stopCause.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAAA;AAEnD,gGAAgG;AAChG,eAAO,MAAM,cAAc,uBAAuB,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;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,eAAe,CAYjB;AAOD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IACtC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,IAAI,CAAC,CAUf;AAmDD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,kBAAkB,GAAG,SAAS,EACpC,KAAK,CAAC,EAAE,kBAAkB,GACzB,MAAM,GAAG,SAAS,CAgBpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAS1B"}
|
|
@@ -26,6 +26,37 @@ export const ATTRIBUTION_WINDOW_MS = {
|
|
|
26
26
|
rollout: 120_000,
|
|
27
27
|
idle: 30 * 60_000,
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* How long a stop this container could NOT attribute (a crash, an OOM kill) may still explain a
|
|
31
|
+
* 404 poll, i.e. the window governing a record that carries only an {@link ContainerExitState}.
|
|
32
|
+
*
|
|
33
|
+
* The same reasoning as the `idle` window, and deliberately the same number: what separates the
|
|
34
|
+
* death from the poll that discovers it is the POLL GAP, and a crash is discovered by the same
|
|
35
|
+
* ~15s tick an idle reclaim is, stretched by whatever delayed the driver. Sizing this to the
|
|
36
|
+
* rollout case instead would read every crash discovered after a re-drive as unexplained, which
|
|
37
|
+
* is the class this record exists to explain.
|
|
38
|
+
*
|
|
39
|
+
* Wide is affordable here for a reason the cause windows do not share: an exit state changes no
|
|
40
|
+
* verdict. It is attached to the failure `detail`, so the cost of over-attributing is a
|
|
41
|
+
* misleading sentence, never a wrongly-extended recovery budget.
|
|
42
|
+
*/
|
|
43
|
+
export const EXIT_ATTRIBUTION_WINDOW_MS = 30 * 60_000;
|
|
44
|
+
/**
|
|
45
|
+
* How far apart two hook calls may be and still be treated as observations of ONE stop, i.e. the
|
|
46
|
+
* bound on {@link recordStopCause}'s merge.
|
|
47
|
+
*
|
|
48
|
+
* The merge exists for a single reason: `onError` and `onStop` are two views of the same death,
|
|
49
|
+
* fired by the runtime within moments of each other. Anything older is a DIFFERENT, earlier
|
|
50
|
+
* stop, and merging onto it is not conservative, it is destructive twice over: the new
|
|
51
|
+
* observation inherits the old record's `at`, so it is born already aged, and both halves then
|
|
52
|
+
* fall out of their own attribution windows and explain nothing. A record that is 40 minutes old
|
|
53
|
+
* would silently swallow the crash that just happened.
|
|
54
|
+
*
|
|
55
|
+
* Sized generously against what it models (two hooks, milliseconds apart) and far below the
|
|
56
|
+
* narrowest attribution window, so it cannot be the thing that decides an attribution: what a
|
|
57
|
+
* merge may do is complete an account of one stop, never date it.
|
|
58
|
+
*/
|
|
59
|
+
export const STOP_MERGE_WINDOW_MS = 60_000;
|
|
29
60
|
/**
|
|
30
61
|
* The message the base container class surfaces when the RUNTIME (not the workload) stopped a
|
|
31
62
|
* container: a deploy draining the old version. Its own exit-code parser is keyed on the plain
|
|
@@ -36,6 +67,31 @@ export function isRolloutSignal(error) {
|
|
|
36
67
|
const message = error instanceof Error ? error.message : typeof error === 'string' ? error : String(error);
|
|
37
68
|
return /new version rollout|runtime signalled the container to exit/i.test(message);
|
|
38
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* What a container should record about a stop the runtime just reported, or undefined when it
|
|
72
|
+
* should record nothing.
|
|
73
|
+
*
|
|
74
|
+
* Two rules, both about what the stop MEANS rather than what it says:
|
|
75
|
+
*
|
|
76
|
+
* - A `runtime_signal` 143 is the rollout drain surfacing through this hook instead of (or as
|
|
77
|
+
* well as) `onError`, depending on the runtime version, so it names the same cause.
|
|
78
|
+
* - A stop the container ASKED for records nothing at all. Its idle reclaim and its shutdown RPC
|
|
79
|
+
* both work by signalling the container, so the exit that comes back is this container's own
|
|
80
|
+
* request echoed at it (escalating to a SIGKILL 137 when the workload does not exit inside the
|
|
81
|
+
* grace period), not an observation of how anything died. Recorded anyway, it is read back as
|
|
82
|
+
* the container's cause of death and reported to the operator as "most often an out-of-memory
|
|
83
|
+
* kill" underneath a verdict that says the platform reclaimed an idle container. The cause the
|
|
84
|
+
* caller recorded when it decided to stop is the whole account, and it is already stored.
|
|
85
|
+
*/
|
|
86
|
+
export function observationForStop(params, selfInitiated) {
|
|
87
|
+
if (selfInitiated)
|
|
88
|
+
return undefined;
|
|
89
|
+
const rollout = params.reason === 'runtime_signal' && params.exitCode === 143;
|
|
90
|
+
return {
|
|
91
|
+
...(rollout ? { cause: 'rollout' } : {}),
|
|
92
|
+
exit: { code: params.exitCode, reason: params.reason },
|
|
93
|
+
};
|
|
94
|
+
}
|
|
39
95
|
/**
|
|
40
96
|
* Whether a value read back out of DO storage is still a cause this build knows. Derived from
|
|
41
97
|
* the window table's own keys rather than restated, so retiring a cause fails the build here
|
|
@@ -45,32 +101,177 @@ function isContainerStopCause(value) {
|
|
|
45
101
|
return typeof value === 'string' && Object.hasOwn(ATTRIBUTION_WINDOW_MS, value);
|
|
46
102
|
}
|
|
47
103
|
/**
|
|
48
|
-
*
|
|
49
|
-
* attribute.
|
|
104
|
+
* Whether a value read back out of DO storage is an exit state this build can render.
|
|
50
105
|
*
|
|
51
|
-
* `
|
|
52
|
-
*
|
|
106
|
+
* The `reason` union is closed and PERSISTED, so an unknown member is possible after a runtime
|
|
107
|
+
* bump; it degrades to "no exit state recorded" rather than being rendered as a bare string,
|
|
108
|
+
* because a reason nobody has worded says less than the exit code alone already does.
|
|
109
|
+
*/
|
|
110
|
+
function isContainerExitState(value) {
|
|
111
|
+
if (!value || typeof value !== 'object')
|
|
112
|
+
return false;
|
|
113
|
+
const { code, reason } = value;
|
|
114
|
+
return typeof code === 'number' && (reason === 'exit' || reason === 'runtime_signal');
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What a stored record still explains at `now`, or an EMPTY observation when it explains
|
|
118
|
+
* nothing.
|
|
119
|
+
*
|
|
120
|
+
* An empty observation covers three things that all mean the same to the caller: nothing was
|
|
121
|
+
* recorded, the record outlived its window (the container recovered and ran on, so a later death
|
|
53
122
|
* is its own), or the record names a cause this build no longer has. The last is possible
|
|
54
123
|
* because the record is PERSISTED and the vocabulary is closed: a deploy that retires a member
|
|
55
124
|
* leaves rows behind. All three land on the caller's existing default, reporting the eviction
|
|
56
125
|
* as a `crash`, which is the honest reading of "no attribution" and the conservative one:
|
|
57
126
|
* it costs a run one restart of its recovery budget, never a wrongly-extended one.
|
|
127
|
+
*
|
|
128
|
+
* The two halves are attributed INDEPENDENTLY, on their own windows: a record can be too old to
|
|
129
|
+
* excuse the eviction as churn while still being the only account of how the container died, and
|
|
130
|
+
* dropping the exit state with the cause would throw away the diagnostic to protect a budget the
|
|
131
|
+
* diagnostic never touches.
|
|
58
132
|
*/
|
|
59
133
|
export function attributeStopCause(record, now, claimant) {
|
|
60
134
|
if (!record || typeof record !== 'object')
|
|
61
|
-
return
|
|
62
|
-
const { cause, at, claimedBy } = record;
|
|
63
|
-
if (
|
|
64
|
-
return
|
|
135
|
+
return {};
|
|
136
|
+
const { cause, exit, at, claimedBy } = record;
|
|
137
|
+
if (typeof at !== 'number')
|
|
138
|
+
return {};
|
|
65
139
|
// Spent on somebody else's eviction. Only the job that claimed it may read it back, which is
|
|
66
140
|
// what lets a replay be idempotent without letting one reclaim excuse two deaths.
|
|
67
141
|
if (claimedBy !== undefined && claimedBy !== claimant)
|
|
142
|
+
return {};
|
|
143
|
+
const age = now - at;
|
|
144
|
+
return {
|
|
145
|
+
...(isContainerStopCause(cause) && age <= ATTRIBUTION_WINDOW_MS[cause] ? { cause } : {}),
|
|
146
|
+
...(isContainerExitState(exit) && age <= EXIT_ATTRIBUTION_WINDOW_MS ? { exit } : {}),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** Whether an observation carries anything at all (i.e. whether claiming it is worth a write). */
|
|
150
|
+
function isEmptyObservation(observation) {
|
|
151
|
+
return !observation.cause && !observation.exit;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Persist what this container just observed about its own stop, MERGING onto an unclaimed record
|
|
155
|
+
* of the SAME stop rather than replacing it.
|
|
156
|
+
*
|
|
157
|
+
* Merging is the point. One stop reaches this container through up to two hooks carrying
|
|
158
|
+
* different halves of the answer: `onError` recognises a rollout drain and knows no exit state,
|
|
159
|
+
* `onStop` carries `{ exitCode, reason }` and cannot name the churn. They fire in either order
|
|
160
|
+
* (and, on some runtime versions, both), so a plain overwrite means whichever landed second
|
|
161
|
+
* silently discarded the other's half: either the recovery budget or the only account of the
|
|
162
|
+
* death, depending on the ordering that day.
|
|
163
|
+
*
|
|
164
|
+
* Two records are never merged:
|
|
165
|
+
*
|
|
166
|
+
* - a CLAIMED one, which has already explained somebody's eviction, so anything observed after
|
|
167
|
+
* it belongs to the next one;
|
|
168
|
+
* - one older than {@link STOP_MERGE_WINDOW_MS}, which is a different stop entirely. This
|
|
169
|
+
* container's records are not reliably cleared between stops (`takeStopCause` deliberately
|
|
170
|
+
* leaves an expired record in place, and only an accepted dispatch deletes one), so a stale
|
|
171
|
+
* record is the ORDINARY state of a container that idled out and was re-driven, not an edge
|
|
172
|
+
* case. Merging onto it would back-date the new observation to the old stop's `at` and age it
|
|
173
|
+
* out of its own attribution window on arrival: the crash that just happened would be
|
|
174
|
+
* recorded, read back, and dropped as too old to explain the eviction it caused.
|
|
175
|
+
*
|
|
176
|
+
* The kept `at` is the EARLIEST of the two observations, which within the merge window is a
|
|
177
|
+
* choice between timestamps moments apart: both describe one stop, and the window measures how
|
|
178
|
+
* long ago that stop happened.
|
|
179
|
+
*/
|
|
180
|
+
export async function recordStopCause(storage, observed, now) {
|
|
181
|
+
const mergeable = mergeableRecord(await storage.get(STOP_CAUSE_KEY), now);
|
|
182
|
+
const at = mergeable ? Math.min(mergeable.at, now) : now;
|
|
183
|
+
const cause = observed.cause ?? mergeable?.cause;
|
|
184
|
+
const exit = observed.exit ?? mergeable?.exit;
|
|
185
|
+
await storage.put(STOP_CAUSE_KEY, {
|
|
186
|
+
...(cause ? { cause } : {}),
|
|
187
|
+
...(exit ? { exit } : {}),
|
|
188
|
+
at,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The stored record a new observation may complete, i.e. an unclaimed one describing the same
|
|
193
|
+
* stop. Anything else (absent, malformed, claimed, or from an earlier stop) is undefined, and
|
|
194
|
+
* the new observation stands alone.
|
|
195
|
+
*/
|
|
196
|
+
function mergeableRecord(stored, now) {
|
|
197
|
+
if (!stored || typeof stored !== 'object')
|
|
198
|
+
return undefined;
|
|
199
|
+
const record = stored;
|
|
200
|
+
if (record.claimedBy !== undefined)
|
|
68
201
|
return undefined;
|
|
69
|
-
|
|
202
|
+
if (typeof record.at !== 'number')
|
|
203
|
+
return undefined;
|
|
204
|
+
// `now - at` rather than an absolute difference: a record stamped in the FUTURE (a clock
|
|
205
|
+
// adjustment between two hook calls) is one of ours moments ago, not a stale one.
|
|
206
|
+
if (now - record.at > STOP_MERGE_WINDOW_MS)
|
|
207
|
+
return undefined;
|
|
208
|
+
return record;
|
|
70
209
|
}
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
210
|
+
/**
|
|
211
|
+
* What an exit code IS, independent of why the container stopped.
|
|
212
|
+
*
|
|
213
|
+
* A bounded map rather than a `128 + n` derivation on purpose: the platform reports one number
|
|
214
|
+
* and only a couple of them are worth translating, while decoding an arbitrary code into a
|
|
215
|
+
* signal name would confidently mislabel an application exit code that merely happens to exceed
|
|
216
|
+
* 128. An unmapped code is reported as itself.
|
|
217
|
+
*/
|
|
218
|
+
const EXIT_SIGNAL_NAMES = {
|
|
219
|
+
137: 'SIGKILL',
|
|
220
|
+
143: 'SIGTERM',
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* What an exit code SUGGESTS about a death nothing else explains. Read only when no
|
|
224
|
+
* {@link ContainerStopCause} was recognised, which is what makes the guess worth offering: the
|
|
225
|
+
* alternative there is silence.
|
|
226
|
+
*
|
|
227
|
+
* Kept apart from {@link EXIT_SIGNAL_NAMES} because the two are different kinds of claim. The
|
|
228
|
+
* signal name is a fact about the number; this is an inference from the absence of any other
|
|
229
|
+
* account, and it is false exactly when that absence is false.
|
|
230
|
+
*/
|
|
231
|
+
const UNEXPLAINED_EXIT_NOTES = {
|
|
232
|
+
// Killed outright rather than exiting. With nothing else to explain it, on this runtime that
|
|
233
|
+
// is overwhelmingly the instance running out of memory, which is why it is worth saying.
|
|
234
|
+
137: 'most often an out-of-memory kill or a forced stop',
|
|
235
|
+
// Something asked it to stop, and whatever it was left no cause behind for us to name.
|
|
236
|
+
143: 'something asked the container to stop',
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* The one-line account of a container's stop for the eviction `detail`, or undefined when
|
|
240
|
+
* nothing was recorded.
|
|
241
|
+
*
|
|
242
|
+
* `cause` is the account the run has ALREADY been given, and passing it is what keeps the detail
|
|
243
|
+
* from arguing with the verdict beside it. The two halves are recorded independently and the
|
|
244
|
+
* exit state is attached whether or not a cause was recognised, so they routinely describe one
|
|
245
|
+
* event twice: an idle reclaim is performed BY the platform with a SIGKILL, so a run correctly
|
|
246
|
+
* reported as "idle container reclaimed between polls" carries exit 137, and read as an
|
|
247
|
+
* unexplained death that code says "most often an out-of-memory kill". The operator is then
|
|
248
|
+
* holding a verdict and a detail that cannot both be true, which is worse than either alone,
|
|
249
|
+
* because there is no way to tell which one to act on.
|
|
250
|
+
*
|
|
251
|
+
* So the interpretation is offered only where it is the only account there is. Where a cause was
|
|
252
|
+
* named, the exit code is reported as the MECHANICS of that stop: still the difference between
|
|
253
|
+
* "reclaimed" and "reclaimed with a SIGKILL", and never a second, competing cause of death.
|
|
254
|
+
*
|
|
255
|
+
* Either way it states the platform's own limit rather than leaving it to be inferred: a
|
|
256
|
+
* Cloudflare Container writes its stdout to the deployment's Workers logs, and nothing inside
|
|
257
|
+
* the Durable Object can read it back, so an operator who reads this and goes looking for a log
|
|
258
|
+
* tail here should be told where the tail actually is.
|
|
259
|
+
*/
|
|
260
|
+
export function describeContainerExit(exit, cause) {
|
|
261
|
+
if (!exit)
|
|
262
|
+
return undefined;
|
|
263
|
+
const signal = EXIT_SIGNAL_NAMES[exit.code];
|
|
264
|
+
const note = cause
|
|
265
|
+
? signal
|
|
266
|
+
: [signal, UNEXPLAINED_EXIT_NOTES[exit.code]].filter(Boolean).join(', ');
|
|
267
|
+
const how = cause
|
|
268
|
+
? 'the runtime reported it as'
|
|
269
|
+
: exit.reason === 'runtime_signal'
|
|
270
|
+
? 'the runtime signalled it to exit, with'
|
|
271
|
+
: 'the workload inside it exited, with';
|
|
272
|
+
return (`The run's container stopped while the job was running: ${how} exit code ${exit.code}` +
|
|
273
|
+
`${note ? ` (${note})` : ''}. The container's own output is not readable from the Worker; ` +
|
|
274
|
+
`it is in this deployment's Workers logs.`);
|
|
74
275
|
}
|
|
75
276
|
/**
|
|
76
277
|
* Forget whatever this container observed before now.
|
|
@@ -86,23 +287,27 @@ export async function clearStopCause(storage) {
|
|
|
86
287
|
await storage.delete(STOP_CAUSE_KEY);
|
|
87
288
|
}
|
|
88
289
|
/**
|
|
89
|
-
* Read
|
|
290
|
+
* Read what explains `claimant`'s 404 poll, CLAIMING it for that job.
|
|
90
291
|
*
|
|
91
|
-
* One
|
|
292
|
+
* One stop explains exactly one job's eviction: the engine answers one by re-dispatching onto
|
|
92
293
|
* a fresh container under the same DO id, so an unclaimed record would still be sitting there to
|
|
93
294
|
* excuse the next death, whenever and for whatever reason it came. The claim is written rather
|
|
94
295
|
* than the record deleted so a REPLAYED poll for the same job reads back the same answer (see
|
|
95
296
|
* {@link StopCauseRecord.claimedBy}).
|
|
297
|
+
*
|
|
298
|
+
* The claim covers the record, not one half of it: an exit state read here is spent as surely as
|
|
299
|
+
* a cause is, because attaching one container's death to two runs' failures is the same lie
|
|
300
|
+
* either way.
|
|
96
301
|
*/
|
|
97
302
|
export async function takeStopCause(storage, now, claimant) {
|
|
98
303
|
const record = await storage.get(STOP_CAUSE_KEY);
|
|
99
|
-
const
|
|
304
|
+
const observation = attributeStopCause(record, now, claimant);
|
|
100
305
|
// Nothing to claim: either there was no record, it was spent, or it is too old to explain
|
|
101
306
|
// anything. Leaving an expired record in place costs one key until the next reclaim
|
|
102
307
|
// overwrites it, and rewriting it here would only re-date somebody else's observation.
|
|
103
|
-
if (
|
|
104
|
-
return
|
|
308
|
+
if (isEmptyObservation(observation))
|
|
309
|
+
return observation;
|
|
105
310
|
await storage.put(STOP_CAUSE_KEY, { ...record, claimedBy: claimant });
|
|
106
|
-
return
|
|
311
|
+
return observation;
|
|
107
312
|
}
|
|
108
313
|
//# sourceMappingURL=stopCause.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopCause.js","sourceRoot":"","sources":["../../../src/infrastructure/containers/stopCause.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,yFAAyF;AACzF,uFAAuF;AACvF,yFAAyF;AACzF,4FAA4F;AAC5F,8CAA8C;AAe9C,gGAAgG;AAChG,MAAM,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CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,gEAAgE;QAC3F,0CAA0C,CAC3C,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAyB;IAC5D,MAAM,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAyB,EACzB,GAAW,EACX,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAChD,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC7D,0FAA0F;IAC1F,oFAAoF;IACpF,uFAAuF;IACvF,IAAI,kBAAkB,CAAC,WAAW,CAAC;QAAE,OAAO,WAAW,CAAA;IACvD,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,GAAI,MAA0B,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;IAC1F,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { makeResolveRepoFilesForCoords, makeResolveRunRepoContext,
|
|
1
|
+
import { makeResolveRepoFilesForCoords, makeResolveRunRepoContext, providerRoutingGitHubClient, logger, } from '@cat-factory/server';
|
|
2
2
|
import { buildGitLabEngineClient } from '@cat-factory/gitlab';
|
|
3
3
|
import { selectWorkerVcsConnectDeps } from './vcsConnect';
|
|
4
4
|
import { buildAppRegistry, buildResolveRepoTarget } from './container';
|
|
@@ -96,7 +96,7 @@ export function selectGitHubDeps(env, config, db, clock, idGenerator, repoFilesC
|
|
|
96
96
|
// the GitHub-issue/docs consumers keep the raw App `githubClient` (they must not gain the
|
|
97
97
|
// GitLab fallback, per CLAUDE.md's VCS rule).
|
|
98
98
|
const moduleClient = gitlabConnectClient
|
|
99
|
-
?
|
|
99
|
+
? providerRoutingGitHubClient({
|
|
100
100
|
installations: githubInstallationRepository,
|
|
101
101
|
github: githubClient,
|
|
102
102
|
gitlab: gitlabConnectClient,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-deps.js","sourceRoot":"","sources":["../../src/infrastructure/github-deps.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,2BAA2B,EAC3B,MAAM,GACP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAG7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAA;AACtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC1F,OAAO,EAAE,iCAAiC,EAAE,MAAM,kDAAkD,CAAA;AACpG,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAA;AACxF,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAC9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAE5E,8EAA8E;AAC9E,mFAAmF;AACnF,qFAAqF;AACrF,sFAAsF;AACtF,0FAA0F;AAC1F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YACvC,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,uBAAuB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;YACjF,OAAO,KAAK,CAAC,SAAS,KAAK,OAAO,CAAA;QACpC,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -12,6 +12,7 @@ export declare class D1BinaryArtifactMetadataStore implements BinaryArtifactMeta
|
|
|
12
12
|
countByExecution(workspaceId: string, executionId: string): Promise<number>;
|
|
13
13
|
listByBlock(workspaceId: string, blockId: string): Promise<BinaryArtifactRecord[]>;
|
|
14
14
|
listByDocument(workspaceId: string, document: DocumentArtifactRef): Promise<BinaryArtifactRecord[]>;
|
|
15
|
+
listByDocuments(workspaceId: string, documents: readonly DocumentArtifactRef[]): Promise<BinaryArtifactRecord[]>;
|
|
15
16
|
deleteByIds(workspaceId: string, ids: readonly string[]): Promise<number>;
|
|
16
17
|
delete(workspaceId: string, id: string): Promise<void>;
|
|
17
18
|
listOlderThan(workspaceId: string, olderThan: number): Promise<BinaryArtifactRecord[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1BinaryArtifactMetadataStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1BinaryArtifactMetadataStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"D1BinaryArtifactMetadataStore.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1BinaryArtifactMetadataStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAqD3D,+FAA+F;AAC/F,qBAAa,6BAA8B,YAAW,2BAA2B;IAC/E,OAAO,CAAC,QAAQ,CA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AS7E;IAEK,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAM1E;IAEK,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5D;CACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dedupeDocumentRefs } from '@cat-factory/kernel';
|
|
1
2
|
import { chunkForIn } from './chunk';
|
|
2
3
|
function rowToRecord(row) {
|
|
3
4
|
return {
|
|
@@ -20,6 +21,13 @@ function rowToRecord(row) {
|
|
|
20
21
|
createdAt: row.created_at,
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Order rows the way every list read on this table returns them (`created_at`, then `id`), for a
|
|
26
|
+
* batch read whose result is the concatenation of several statements.
|
|
27
|
+
*/
|
|
28
|
+
function sortArtifactRows(rows) {
|
|
29
|
+
return rows.sort((a, b) => a.created_at - b.created_at || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
|
|
30
|
+
}
|
|
23
31
|
/** D1-backed metadata store for binary artifacts (see migration 0017). Bytes live in R2/S3. */
|
|
24
32
|
export class D1BinaryArtifactMetadataStore {
|
|
25
33
|
db;
|
|
@@ -77,6 +85,28 @@ export class D1BinaryArtifactMetadataStore {
|
|
|
77
85
|
.all();
|
|
78
86
|
return (results ?? []).map(rowToRecord);
|
|
79
87
|
}
|
|
88
|
+
async listByDocuments(workspaceId, documents) {
|
|
89
|
+
const refs = dedupeDocumentRefs(documents);
|
|
90
|
+
if (!refs.length)
|
|
91
|
+
return [];
|
|
92
|
+
const rows = [];
|
|
93
|
+
// Two bound params per ref (source + external id), so the chunk size is derived from that
|
|
94
|
+
// rather than from the scalar-`IN` default.
|
|
95
|
+
for (const chunk of chunkForIn(refs, 2)) {
|
|
96
|
+
const clauses = chunk
|
|
97
|
+
.map(() => '(document_source = ? AND document_external_id = ?)')
|
|
98
|
+
.join(' OR ');
|
|
99
|
+
const { results } = await this.db
|
|
100
|
+
.prepare(`SELECT * FROM binary_artifacts WHERE workspace_id = ? AND (${clauses})`)
|
|
101
|
+
.bind(workspaceId, ...chunk.flatMap((ref) => [ref.source, ref.externalId]))
|
|
102
|
+
.all();
|
|
103
|
+
rows.push(...(results ?? []));
|
|
104
|
+
}
|
|
105
|
+
// Sorted here rather than per statement: with more than one chunk the concatenation is
|
|
106
|
+
// ordered by chunk, and the caller's "newest render for a view wins" rule reads the WHOLE
|
|
107
|
+
// list in order.
|
|
108
|
+
return sortArtifactRows(rows).map(rowToRecord);
|
|
109
|
+
}
|
|
80
110
|
async deleteByIds(workspaceId, ids) {
|
|
81
111
|
let removed = 0;
|
|
82
112
|
for (const chunk of chunkForIn(ids)) {
|