@atolis-hq/wake 0.4.121 → 0.4.122
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/src/bootstrap/board-projection.d.ts +15 -0
- package/dist/src/bootstrap/board-projection.js +92 -7
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/surfaces/api/contracts/board.d.ts +15 -0
- package/dist/src/surfaces/web-assets/assets/index-CaZVets2.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/package.json +1 -1
- package/dist/src/surfaces/web-assets/assets/index-lG0PPaWe.js +0 -1192
|
@@ -25,6 +25,7 @@ interface StoredDelegatedCohort {
|
|
|
25
25
|
readonly children: Readonly<Record<string, string>>;
|
|
26
26
|
readonly finished: Readonly<Record<string, true>>;
|
|
27
27
|
readonly needsAttention: Readonly<Record<string, true>>;
|
|
28
|
+
readonly prerequisiteWaits?: Readonly<Record<string, BoardPrerequisiteWait>>;
|
|
28
29
|
readonly waiting?: true;
|
|
29
30
|
/** The parent's assessment handed a question about its children to a human. */
|
|
30
31
|
readonly escalated?: true;
|
|
@@ -36,12 +37,26 @@ export interface BoardDelegationWait {
|
|
|
36
37
|
readonly needsAttention: number;
|
|
37
38
|
readonly escalated?: true;
|
|
38
39
|
}
|
|
40
|
+
/** A reserved delegated child that has not started: what it was declared to wait on. */
|
|
41
|
+
export interface BoardPrerequisiteWait {
|
|
42
|
+
/** The journal's reason once prerequisite readiness blocked the child. */
|
|
43
|
+
readonly reason?: string;
|
|
44
|
+
readonly prerequisites: readonly {
|
|
45
|
+
readonly assignmentId: string;
|
|
46
|
+
readonly output: string;
|
|
47
|
+
readonly condition: string;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
39
50
|
interface StoredCard {
|
|
40
51
|
readonly workItemKey: string;
|
|
41
52
|
readonly workItemId: string;
|
|
42
53
|
readonly objective: string;
|
|
43
54
|
readonly condition: BoardConditionValue;
|
|
44
55
|
readonly frozen?: boolean;
|
|
56
|
+
/** The workflow instance was replaced; the card sits in Finished, not Error. */
|
|
57
|
+
readonly superseded?: true;
|
|
58
|
+
/** Present on a queued delegated child until its workflow starts. */
|
|
59
|
+
readonly prerequisiteWait?: BoardPrerequisiteWait;
|
|
45
60
|
readonly awaitingApproval?: boolean;
|
|
46
61
|
/** Present only while the primary workflow can accept a gate-budget extension. */
|
|
47
62
|
readonly extendEligible?: boolean;
|
|
@@ -66,6 +66,9 @@ function projectItemCreated(view, id, payload, occurredAt) {
|
|
|
66
66
|
workItemId: id,
|
|
67
67
|
objective: payload.objective,
|
|
68
68
|
condition: BoardCondition.Ready,
|
|
69
|
+
...(parent?.delegatedCohort?.prerequisiteWaits?.[id] === undefined
|
|
70
|
+
? {}
|
|
71
|
+
: { prerequisiteWait: parent.delegatedCohort.prerequisiteWaits[id] }),
|
|
69
72
|
dwellSince: occurredAt,
|
|
70
73
|
runCount: 0,
|
|
71
74
|
activeRuns: {},
|
|
@@ -115,7 +118,7 @@ function projectWork(view, event, occurredAt) {
|
|
|
115
118
|
cards: {
|
|
116
119
|
...view.cards,
|
|
117
120
|
[id]: {
|
|
118
|
-
...withoutDelegatedCohort(withoutExtendEligible(withoutAwaitingApproval(current))),
|
|
121
|
+
...withoutPrerequisiteWait(withoutDelegatedCohort(withoutExtendEligible(withoutAwaitingApproval(current)))),
|
|
119
122
|
condition: BoardCondition.Finished,
|
|
120
123
|
},
|
|
121
124
|
},
|
|
@@ -132,6 +135,8 @@ function projectWork(view, event, occurredAt) {
|
|
|
132
135
|
function projectWorkflow(view, event, occurredAt) {
|
|
133
136
|
if (isWorkflowEventType(event, OrchestrationEventType.InstanceStarted))
|
|
134
137
|
return projectWorkflowStarted(view, event, occurredAt);
|
|
138
|
+
if (isWorkflowEventType(event, OrchestrationEventType.DelegationPrerequisiteBlocked))
|
|
139
|
+
return projectPrerequisiteBlocked(view, event);
|
|
135
140
|
return projectDelegation(view, event) ?? projectWorkflowUpdate(view, event, occurredAt);
|
|
136
141
|
}
|
|
137
142
|
function isWorkflowEventType(event, eventType) {
|
|
@@ -183,20 +188,78 @@ function projectDelegationReserved(view, event) {
|
|
|
183
188
|
: { cohortId: reservation.cohortId, children: {}, finished: {}, needsAttention: {} };
|
|
184
189
|
const cohort = reservation.children.reduce((current, child) => ({
|
|
185
190
|
...withoutReplacedChild(current, child.replaces),
|
|
191
|
+
prerequisiteWaits: {
|
|
192
|
+
...withoutReplacedChild(current, child.replaces).prerequisiteWaits,
|
|
193
|
+
[child.workItemId]: {
|
|
194
|
+
prerequisites: (child.prerequisites ?? []).map(({ assignmentId, output, condition }) => ({
|
|
195
|
+
assignmentId,
|
|
196
|
+
output,
|
|
197
|
+
condition,
|
|
198
|
+
})),
|
|
199
|
+
},
|
|
200
|
+
},
|
|
186
201
|
children: {
|
|
187
202
|
...withoutReplacedChild(current, child.replaces).children,
|
|
188
203
|
[child.workItemId]: child.assignmentId,
|
|
189
204
|
},
|
|
190
205
|
}), previous);
|
|
206
|
+
const cards = queuedReservationCards(view, event, previous, cohort);
|
|
191
207
|
return {
|
|
192
208
|
...view,
|
|
193
209
|
delegatedChildren: {
|
|
194
210
|
...view.delegatedChildren,
|
|
195
211
|
...Object.fromEntries(reservation.children.map((child) => [child.workItemId, parentId])),
|
|
196
212
|
},
|
|
197
|
-
cards: { ...
|
|
213
|
+
cards: { ...cards, [parentId]: { ...card, delegatedCohort: cohort } },
|
|
198
214
|
};
|
|
199
215
|
}
|
|
216
|
+
function queuedReservationCards(view, event, previous, cohort) {
|
|
217
|
+
const cards = { ...view.cards };
|
|
218
|
+
// Children dropped by a replacement are no longer queued.
|
|
219
|
+
for (const droppedId of Object.keys(previous.children)) {
|
|
220
|
+
const dropped = cards[droppedId];
|
|
221
|
+
if (cohort.children[droppedId] === undefined && dropped !== undefined)
|
|
222
|
+
cards[droppedId] = withoutPrerequisiteWait(dropped);
|
|
223
|
+
}
|
|
224
|
+
for (const child of event.event.payload.children) {
|
|
225
|
+
const queued = cards[child.workItemId];
|
|
226
|
+
if (queued === undefined ||
|
|
227
|
+
queued.stage !== undefined ||
|
|
228
|
+
queued.condition === BoardCondition.Finished)
|
|
229
|
+
continue;
|
|
230
|
+
cards[child.workItemId] = {
|
|
231
|
+
...queued,
|
|
232
|
+
prerequisiteWait: {
|
|
233
|
+
...(queued.prerequisiteWait?.reason === undefined
|
|
234
|
+
? {}
|
|
235
|
+
: { reason: queued.prerequisiteWait.reason }),
|
|
236
|
+
prerequisites: (child.prerequisites ?? []).map((prerequisite) => ({
|
|
237
|
+
assignmentId: prerequisite.assignmentId,
|
|
238
|
+
output: prerequisite.output,
|
|
239
|
+
condition: prerequisite.condition,
|
|
240
|
+
})),
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return cards;
|
|
245
|
+
}
|
|
246
|
+
function projectPrerequisiteBlocked(view, event) {
|
|
247
|
+
const { childWorkItemId, reason } = event.event.payload;
|
|
248
|
+
const child = view.cards[childWorkItemId];
|
|
249
|
+
if (child?.prerequisiteWait === undefined)
|
|
250
|
+
return view;
|
|
251
|
+
return {
|
|
252
|
+
...view,
|
|
253
|
+
cards: {
|
|
254
|
+
...view.cards,
|
|
255
|
+
[childWorkItemId]: { ...child, prerequisiteWait: { ...child.prerequisiteWait, reason } },
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function withoutPrerequisiteWait(card) {
|
|
260
|
+
const { prerequisiteWait: _prerequisiteWait, ...rest } = card;
|
|
261
|
+
return rest;
|
|
262
|
+
}
|
|
200
263
|
function withoutReplacedChild(cohort, replaces) {
|
|
201
264
|
if (replaces === undefined || replaces.cohortId !== cohort.cohortId)
|
|
202
265
|
return cohort;
|
|
@@ -206,6 +269,7 @@ function withoutReplacedChild(cohort, replaces) {
|
|
|
206
269
|
return {
|
|
207
270
|
...cohort,
|
|
208
271
|
children: withoutKey(cohort.children, replaced),
|
|
272
|
+
prerequisiteWaits: withoutKey(cohort.prerequisiteWaits ?? {}, replaced),
|
|
209
273
|
finished: withoutKey(cohort.finished, replaced),
|
|
210
274
|
needsAttention: withoutKey(cohort.needsAttention, replaced),
|
|
211
275
|
};
|
|
@@ -244,6 +308,13 @@ function projectDelegationSettled(view, event) {
|
|
|
244
308
|
card.delegatedCohort.cohortId !== event.event.payload.cohortId)
|
|
245
309
|
return view;
|
|
246
310
|
const settled = withoutDelegatedCohort(card);
|
|
311
|
+
// A child that never started will not now; stop presenting it as queued.
|
|
312
|
+
const cards = { ...view.cards };
|
|
313
|
+
for (const childId of Object.keys(card.delegatedCohort.children)) {
|
|
314
|
+
const child = cards[childId];
|
|
315
|
+
if (child?.prerequisiteWait !== undefined)
|
|
316
|
+
cards[childId] = withoutPrerequisiteWait(child);
|
|
317
|
+
}
|
|
247
318
|
// A failed cohort is followed by InstanceBlocked, which decides the condition;
|
|
248
319
|
// a joined one resumes ordinary advancement, so it reads Ready until a Run starts.
|
|
249
320
|
const condition = event.event.eventType === OrchestrationEventType.DelegationFailed ||
|
|
@@ -252,7 +323,7 @@ function projectDelegationSettled(view, event) {
|
|
|
252
323
|
: hasPrimaryActiveRun(view, activeRunsFor(view, card, workId))
|
|
253
324
|
? BoardCondition.Active
|
|
254
325
|
: BoardCondition.Ready;
|
|
255
|
-
return { ...view, cards: { ...
|
|
326
|
+
return { ...view, cards: { ...cards, [workId]: { ...settled, condition } } };
|
|
256
327
|
}
|
|
257
328
|
/** Applies `update` to the parent's cohort when it matches, then re-derives a waiting card's condition. */
|
|
258
329
|
function updateCohort(view, workId, cohortId, update) {
|
|
@@ -333,6 +404,10 @@ function withoutEscalation(cohort) {
|
|
|
333
404
|
const { escalated: _escalated, ...rest } = cohort;
|
|
334
405
|
return rest;
|
|
335
406
|
}
|
|
407
|
+
function withoutSuperseded(card) {
|
|
408
|
+
const { superseded: _superseded, ...rest } = card;
|
|
409
|
+
return rest;
|
|
410
|
+
}
|
|
336
411
|
function withoutDelegatedCohort(card) {
|
|
337
412
|
const { delegatedCohort: _delegatedCohort, ...rest } = card;
|
|
338
413
|
return rest;
|
|
@@ -358,7 +433,7 @@ function projectWorkflowStarted(view, event, occurredAt) {
|
|
|
358
433
|
cards: {
|
|
359
434
|
...view.cards,
|
|
360
435
|
[workId]: {
|
|
361
|
-
...withoutDelegatedCohort(card),
|
|
436
|
+
...withoutSuperseded(withoutPrerequisiteWait(withoutDelegatedCohort(card))),
|
|
362
437
|
workflowName: event.event.payload.workflowName,
|
|
363
438
|
stage: event.event.payload.entry,
|
|
364
439
|
dwellSince: occurredAt,
|
|
@@ -368,6 +443,14 @@ function projectWorkflowStarted(view, event, occurredAt) {
|
|
|
368
443
|
workflows,
|
|
369
444
|
};
|
|
370
445
|
}
|
|
446
|
+
function projectFinishedCard(view, workId, card, event) {
|
|
447
|
+
if (event.event.eventType !== OrchestrationEventType.InstanceSuperseded)
|
|
448
|
+
return view;
|
|
449
|
+
return {
|
|
450
|
+
...view,
|
|
451
|
+
cards: { ...view.cards, [workId]: { ...withoutPrerequisiteWait(card), superseded: true } },
|
|
452
|
+
};
|
|
453
|
+
}
|
|
371
454
|
function projectWorkflowUpdate(view, event, occurredAt) {
|
|
372
455
|
if (view.children?.[event.stream.id] !== undefined)
|
|
373
456
|
return view;
|
|
@@ -380,7 +463,7 @@ function projectWorkflowUpdate(view, event, occurredAt) {
|
|
|
380
463
|
// closure (e.g. InstanceBlocked from the now-orphaned instance halting)
|
|
381
464
|
// must not resurrect the card out of Finished.
|
|
382
465
|
if (card.condition === BoardCondition.Finished)
|
|
383
|
-
return view;
|
|
466
|
+
return projectFinishedCard(view, workId, card, event);
|
|
384
467
|
// A new stage is always Ready regardless of the condition it inherits —
|
|
385
468
|
// Error from the prior stage's failed run, or whatever it held before the
|
|
386
469
|
// SignalAccepted that unblocked it — until a Run actually starts (Active)
|
|
@@ -443,6 +526,7 @@ function cardForWorkflowStatus(card, status, event) {
|
|
|
443
526
|
return {
|
|
444
527
|
...withoutExtendEligible(withoutBlockReason(cardForCohortStatus(card, status))),
|
|
445
528
|
condition: boardConditionForStatus(status, card),
|
|
529
|
+
...(status === WorkflowStatus.Superseded ? { superseded: true } : {}),
|
|
446
530
|
};
|
|
447
531
|
const extensionEligible = isExtendEligibleBlock(event.event.payload.reason);
|
|
448
532
|
const unblocked = withoutDelegatedCohort(card);
|
|
@@ -458,7 +542,7 @@ function cardForCohortStatus(card, status) {
|
|
|
458
542
|
return status === WorkflowStatus.Completed ||
|
|
459
543
|
status === WorkflowStatus.Blocked ||
|
|
460
544
|
status === WorkflowStatus.Superseded
|
|
461
|
-
? withoutDelegatedCohort(card)
|
|
545
|
+
? withoutPrerequisiteWait(withoutDelegatedCohort(card))
|
|
462
546
|
: card;
|
|
463
547
|
}
|
|
464
548
|
function boardConditionForStatus(status, card) {
|
|
@@ -475,8 +559,9 @@ function boardConditionForStatus(status, card) {
|
|
|
475
559
|
: BoardCondition.NeedsInput;
|
|
476
560
|
case WorkflowStatus.Completed:
|
|
477
561
|
return BoardCondition.Finished;
|
|
562
|
+
// A replaced instance is retired work, not a current failure.
|
|
478
563
|
case WorkflowStatus.Superseded:
|
|
479
|
-
return BoardCondition.
|
|
564
|
+
return BoardCondition.Finished;
|
|
480
565
|
}
|
|
481
566
|
}
|
|
482
567
|
function failedOrAmbiguousRun(outcome) {
|
|
@@ -124,6 +124,6 @@ export function resolveWakeVersion(options = {}) {
|
|
|
124
124
|
return `g${headHash.slice(0, 7)}`;
|
|
125
125
|
return '0.1.0-dev';
|
|
126
126
|
}
|
|
127
|
-
export const wakeVersion = "v0.4.
|
|
127
|
+
export const wakeVersion = "v0.4.122";
|
|
128
128
|
/** The registry-installable version used by packaged sandbox images. */
|
|
129
129
|
export const wakePackageVersion = packageVersion(defaultRepoRoot) ?? wakeVersion;
|
|
@@ -26,6 +26,17 @@ export interface BoardCardDelegationWait {
|
|
|
26
26
|
/** The parent handed a question about its children to a human. */
|
|
27
27
|
readonly escalated?: boolean;
|
|
28
28
|
}
|
|
29
|
+
/** What a queued delegated child (reserved, not yet started) was declared to wait on. */
|
|
30
|
+
export interface BoardCardPrerequisiteWait {
|
|
31
|
+
/** The orchestration reason, once prerequisite readiness blocked the child. */
|
|
32
|
+
readonly reason?: string;
|
|
33
|
+
/** Declared prerequisites; the journal does not say which one is unmet. */
|
|
34
|
+
readonly prerequisites: readonly {
|
|
35
|
+
readonly assignmentId: string;
|
|
36
|
+
readonly output: string;
|
|
37
|
+
readonly condition: string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
29
40
|
export interface BoardCardResponse {
|
|
30
41
|
readonly workItemKey: string;
|
|
31
42
|
readonly workItemId: string;
|
|
@@ -40,6 +51,10 @@ export interface BoardCardResponse {
|
|
|
40
51
|
* is Active unless a child is blocked or the parent escalated (Needs input).
|
|
41
52
|
*/
|
|
42
53
|
readonly delegationWait?: BoardCardDelegationWait;
|
|
54
|
+
/** Present on a queued delegated child that has not started its workflow. */
|
|
55
|
+
readonly prerequisiteWait?: BoardCardPrerequisiteWait;
|
|
56
|
+
/** The card's workflow instance was superseded; it is shown as finished. */
|
|
57
|
+
readonly superseded?: boolean;
|
|
43
58
|
readonly frozen?: boolean;
|
|
44
59
|
/**
|
|
45
60
|
* Present on delegated work held because an ancestor is frozen: the key of the
|