@atolis-hq/wake 0.4.101 → 0.4.102
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/artifacts/application/operator-instructions-service.js +2 -2
- package/dist/src/bootstrap/artifact-mcp.js +3 -4
- package/dist/src/bootstrap/delegation-authority.js +1 -1
- package/dist/src/bootstrap/integration-runtime.js +1 -1
- package/dist/src/bootstrap/persistence-composition.js +1 -1
- package/dist/src/bootstrap/surface-api-delivery.d.ts +1 -1
- package/dist/src/bootstrap/surface-api-delivery.js +2 -2
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +2 -1
- package/dist/src/control-plane/application/activation-scheduler.js +2 -1
- package/dist/src/control-plane/application/advance-once-dispatch.d.ts +2 -4
- package/dist/src/control-plane/application/advance-once-dispatch.js +6 -4
- package/dist/src/control-plane/domain/delivery-capacity.d.ts +2 -5
- package/dist/src/control-plane/domain/delivery-capacity.js +3 -4
- package/dist/src/control-plane/domain/open-work-policy.d.ts +2 -10
- package/dist/src/control-plane/domain/open-work-policy.js +2 -3
- package/dist/src/execution/application/run-repository.d.ts +2 -2
- package/dist/src/execution/application/run-repository.js +3 -3
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts +9 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.js +62 -7
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts +2 -5
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +12 -13
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +168 -109
- package/dist/src/orchestration/application/deferred-signals.d.ts +4 -2
- package/dist/src/orchestration/application/deferred-signals.js +47 -37
- package/dist/src/orchestration/application/delegated-work.d.ts +2 -0
- package/dist/src/orchestration/application/delegated-work.js +10 -6
- package/dist/src/orchestration/application/delegation-commands.d.ts +1 -1
- package/dist/src/orchestration/application/delegation-commands.js +1 -2
- package/dist/src/orchestration/application/delegation-gate.d.ts +12 -5
- package/dist/src/orchestration/application/delegation-gate.js +36 -10
- package/dist/src/orchestration/application/orchestration-service.js +10 -5
- package/dist/src/work/application/work-index.d.ts +21 -0
- package/dist/src/work/application/work-index.js +73 -0
- package/dist/src/work/application/work-repository.d.ts +2 -2
- package/dist/src/work/application/work-repository.js +2 -2
- package/dist/src/work/application/work-service.d.ts +5 -2
- package/dist/src/work/application/work-service.js +5 -2
- package/dist/src/work/{application → domain}/delivery-availability.d.ts +4 -7
- package/dist/src/work/{application → domain}/delivery-availability.js +3 -3
- package/dist/src/work/index.d.ts +2 -1
- package/dist/src/work/index.js +2 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
|
-
import {
|
|
2
|
+
import type { WorkService } from '../../work/index.js';
|
|
3
3
|
import type { DelegationAuthority } from '../contracts/delegation-ports.js';
|
|
4
4
|
import { type DelegationCaller, type DelegationSubmission } from '../contracts/delegation.js';
|
|
5
5
|
import type { WorkflowInstanceView } from '../contracts/views.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readDeliveryAvailability } from '../../work/index.js';
|
|
2
1
|
import { delegationSubmissionSchema, } from '../contracts/delegation.js';
|
|
3
2
|
import { WorkflowStatus } from '../contracts/vocabulary.js';
|
|
4
3
|
/** Agent inputs describe work; authority comes from the current Run and workflow. */
|
|
@@ -25,7 +24,7 @@ export class DelegationCommands {
|
|
|
25
24
|
caller.activationId ||
|
|
26
25
|
(parent.status !== WorkflowStatus.Active && parent.status !== WorkflowStatus.Waiting))
|
|
27
26
|
throw new Error('Delegation requires the current active activation');
|
|
28
|
-
const availability = await
|
|
27
|
+
const availability = (await this.work.deliverySnapshot()).availability(parent.workItemId);
|
|
29
28
|
if (availability.reason !== undefined)
|
|
30
29
|
throw new Error(availability.reason);
|
|
31
30
|
const policy = (await this.workflows.definitionFor(parent)).delegation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ActivationId } from '../../activities/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { WorkService } from '../../work/index.js';
|
|
3
3
|
import type { WorkflowInstanceId } from '../contracts/identifiers.js';
|
|
4
4
|
import type { WorkflowInstanceView } from '../contracts/views.js';
|
|
5
5
|
import type { OrchestrationRepository } from './orchestration-repository.js';
|
|
@@ -8,13 +8,20 @@ export declare class DelegationGate {
|
|
|
8
8
|
private readonly repository;
|
|
9
9
|
private readonly work;
|
|
10
10
|
constructor(repository: OrchestrationRepository, work: WorkService);
|
|
11
|
+
/** Standalone work keeps existing freeze semantics; only delegated trees and fenced parents are held. */
|
|
12
|
+
private heldBy;
|
|
13
|
+
/** Commit-boundary check for one instance; batches use `filterAvailable`. */
|
|
11
14
|
unavailable(view: WorkflowInstanceView): Promise<boolean>;
|
|
12
15
|
allows(view: WorkflowInstanceView): boolean;
|
|
13
16
|
fenced(id: WorkflowInstanceId): Promise<boolean>;
|
|
17
|
+
/** The subset of `ids` whose workflow is fenced or held, against one Work synchronisation. */
|
|
18
|
+
fencedAmong(ids: readonly WorkflowInstanceId[]): Promise<ReadonlySet<WorkflowInstanceId>>;
|
|
14
19
|
run<T>(id: WorkflowInstanceId, operation: () => Promise<T>): Promise<T>;
|
|
15
20
|
outcome<T>(id: WorkflowInstanceId, activationId: ActivationId, operation: () => Promise<T>, held: () => Promise<T>): Promise<T>;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Admits the items whose workflow may advance, against one synchronisation
|
|
23
|
+
* with Work however many items there are. Nothing is read when none are
|
|
24
|
+
* unfenced, so a quiet tick costs no storage round trip.
|
|
25
|
+
*/
|
|
26
|
+
filterAvailable<T>(items: readonly T[], viewOf: (item: T) => WorkflowInstanceView | null): Promise<T[]>;
|
|
20
27
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readDeliveryAvailability } from '../../work/index.js';
|
|
2
1
|
import { DelegationPendingError } from '../contracts/delegation.js';
|
|
3
2
|
/** One admission policy for ordinary advancement while a committed cohort owns the parent. */
|
|
4
3
|
export class DelegationGate {
|
|
@@ -8,12 +7,18 @@ export class DelegationGate {
|
|
|
8
7
|
this.repository = repository;
|
|
9
8
|
this.work = work;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
/** Standalone work keeps existing freeze semantics; only delegated trees and fenced parents are held. */
|
|
11
|
+
heldBy(snapshot, view) {
|
|
12
|
+
if (snapshot.invalid(view.workItemId))
|
|
13
|
+
return true;
|
|
14
|
+
if (snapshot.get(view.workItemId)?.delegation === undefined &&
|
|
15
|
+
view.delegationFence === undefined)
|
|
15
16
|
return false;
|
|
16
|
-
return (
|
|
17
|
+
return snapshot.availability(view.workItemId).reason !== undefined;
|
|
18
|
+
}
|
|
19
|
+
/** Commit-boundary check for one instance; batches use `filterAvailable`. */
|
|
20
|
+
async unavailable(view) {
|
|
21
|
+
return this.heldBy(await this.work.deliverySnapshot(), view);
|
|
17
22
|
}
|
|
18
23
|
allows(view) {
|
|
19
24
|
return view.delegationFence === undefined;
|
|
@@ -22,6 +27,17 @@ export class DelegationGate {
|
|
|
22
27
|
const view = (await this.repository.load(id)).view;
|
|
23
28
|
return view !== null && (!this.allows(view) || (await this.unavailable(view)));
|
|
24
29
|
}
|
|
30
|
+
/** The subset of `ids` whose workflow is fenced or held, against one Work synchronisation. */
|
|
31
|
+
async fencedAmong(ids) {
|
|
32
|
+
const loaded = await Promise.all(ids.map(async (id) => [id, (await this.repository.load(id)).view]));
|
|
33
|
+
const views = loaded.filter((entry) => entry[1] !== null);
|
|
34
|
+
const snapshot = views.some(([, view]) => this.allows(view))
|
|
35
|
+
? await this.work.deliverySnapshot()
|
|
36
|
+
: undefined;
|
|
37
|
+
return new Set(views
|
|
38
|
+
.filter(([, view]) => !this.allows(view) || this.heldBy(snapshot, view))
|
|
39
|
+
.map(([id]) => id));
|
|
40
|
+
}
|
|
25
41
|
async run(id, operation) {
|
|
26
42
|
if (await this.fenced(id))
|
|
27
43
|
throw new DelegationPendingError(id);
|
|
@@ -37,9 +53,19 @@ export class DelegationGate {
|
|
|
37
53
|
throw new DelegationPendingError(id);
|
|
38
54
|
return held();
|
|
39
55
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Admits the items whose workflow may advance, against one synchronisation
|
|
58
|
+
* with Work however many items there are. Nothing is read when none are
|
|
59
|
+
* unfenced, so a quiet tick costs no storage round trip.
|
|
60
|
+
*/
|
|
61
|
+
async filterAvailable(items, viewOf) {
|
|
62
|
+
const unfenced = items.filter((item) => {
|
|
63
|
+
const view = viewOf(item);
|
|
64
|
+
return view !== null && this.allows(view);
|
|
65
|
+
});
|
|
66
|
+
if (unfenced.length === 0)
|
|
67
|
+
return [];
|
|
68
|
+
const snapshot = await this.work.deliverySnapshot();
|
|
69
|
+
return unfenced.filter((item) => !this.heldBy(snapshot, viewOf(item)));
|
|
44
70
|
}
|
|
45
71
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { expireTimedOutAwait } from '../domain/interpreter.js';
|
|
1
2
|
import { DeferredSignals } from './deferred-signals.js';
|
|
2
3
|
import { DelegatedWork } from './delegated-work.js';
|
|
3
4
|
import { DelegationCommands } from './delegation-commands.js';
|
|
@@ -63,7 +64,7 @@ export class OrchestrationService {
|
|
|
63
64
|
this.delegationCommands = new DelegationCommands(repository, work, this.startWorkflow, this.definitions, this.delegatedWork, dependencies?.authority ?? unavailableDelegationAuthority);
|
|
64
65
|
this.advanceWorkflow = new AdvanceWorkflow(repository, this.startWorkflow, (command, context) => this.acceptOutcome(command, context), isAgentActivity);
|
|
65
66
|
this.acceptWorkflowSignal = new AcceptSignal(repository, this.startWorkflow, work);
|
|
66
|
-
this.deferredSignals = new DeferredSignals(repository, (id, signal, context) => this.delegationGate.run(id, () => this.acceptWorkflowSignal.execute(id, signal, context)), (id, target, evidenceId, context) => this.delegationGate.run(id, () => this.advanceWorkflow.applyResourceTransition(id, target, evidenceId, context)), (
|
|
67
|
+
this.deferredSignals = new DeferredSignals(repository, (id, signal, context) => this.delegationGate.run(id, () => this.acceptWorkflowSignal.execute(id, signal, context)), (id, target, evidenceId, context) => this.delegationGate.run(id, () => this.advanceWorkflow.applyResourceTransition(id, target, evidenceId, context)), (ids) => this.delegationGate.fencedAmong(ids));
|
|
67
68
|
this.childWorkflows = new RequestChild(repository, this.claims, new GroupBudgetRecorder(journal), this.startWorkflow, this.advanceWorkflow);
|
|
68
69
|
this.acceptActivityOutcome = new AcceptActivityOutcome(repository, this.startWorkflow, async (context) => {
|
|
69
70
|
await this.delegatedWork.reconcile(context);
|
|
@@ -299,15 +300,19 @@ export class OrchestrationService {
|
|
|
299
300
|
}
|
|
300
301
|
async listPendingActivations(workItemId) {
|
|
301
302
|
const entries = await this.advanceWorkflow.listPendingActivations(workItemId);
|
|
302
|
-
|
|
303
|
-
!(await this.delegationGate.unavailable(entry.workflow))));
|
|
304
|
-
return entries.filter((_, index) => available[index]);
|
|
303
|
+
return this.delegationGate.filterAvailable(entries, (entry) => entry.workflow);
|
|
305
304
|
}
|
|
306
305
|
listWaiting(signalKind) {
|
|
307
306
|
return this.advanceWorkflow.listWaiting(signalKind);
|
|
308
307
|
}
|
|
309
308
|
async expireTimedOutWaits(context) {
|
|
310
|
-
|
|
309
|
+
// Only instances whose await has actually timed out need the gate, which is almost never any.
|
|
310
|
+
const due = (await this.repository.list()).filter(({ view }) => view !== null &&
|
|
311
|
+
expireTimedOutAwait(view, {
|
|
312
|
+
occurredAt: context.occurredAt,
|
|
313
|
+
causationId: context.commandId,
|
|
314
|
+
}).kind !== 'ignored');
|
|
315
|
+
return expireTimedOutWaits(this.repository, context, await this.delegationGate.filterAvailable(due, ({ view }) => view));
|
|
311
316
|
}
|
|
312
317
|
listAll() {
|
|
313
318
|
return this.advanceWorkflow.listAll();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type EventJournal } from '@atolis-hq/eventing';
|
|
2
|
+
import { type DeliveryAvailability, type DeliveryWorkState } from '../domain/delivery-availability.js';
|
|
3
|
+
/** Work state as of one point in the journal, answerable without further I/O. */
|
|
4
|
+
export interface DeliverySnapshot {
|
|
5
|
+
get(id: string): DeliveryWorkState | null;
|
|
6
|
+
/** True when the item's events could not be decoded or folded; it must be treated as held. */
|
|
7
|
+
invalid(id: string): boolean;
|
|
8
|
+
availability(id: string): DeliveryAvailability;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Every WorkItem folded once and extended as the journal grows. Batch readers
|
|
12
|
+
* (dispatch, gating, capacity) ask for one snapshot and evaluate any number of
|
|
13
|
+
* items against it, instead of reading each item's stream from storage. Each
|
|
14
|
+
* journal read observes every append committed before it, so a snapshot
|
|
15
|
+
* includes writes by other processes.
|
|
16
|
+
*/
|
|
17
|
+
export declare class WorkIndex {
|
|
18
|
+
private readonly state;
|
|
19
|
+
constructor(journal: Pick<EventJournal, 'readAll' | 'latestGlobalPosition'>);
|
|
20
|
+
snapshot(): Promise<DeliverySnapshot>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { foldedJournalView, } from '@atolis-hq/eventing';
|
|
2
|
+
import { selectWorkEvent } from '../contracts/events.js';
|
|
3
|
+
import { isWorkItemStream } from '../contracts/streams.js';
|
|
4
|
+
import { deliveryAvailability, } from '../domain/delivery-availability.js';
|
|
5
|
+
import { foldWorkItem } from '../domain/work-item.js';
|
|
6
|
+
/**
|
|
7
|
+
* Every WorkItem folded once and extended as the journal grows. Batch readers
|
|
8
|
+
* (dispatch, gating, capacity) ask for one snapshot and evaluate any number of
|
|
9
|
+
* items against it, instead of reading each item's stream from storage. Each
|
|
10
|
+
* journal read observes every append committed before it, so a snapshot
|
|
11
|
+
* includes writes by other processes.
|
|
12
|
+
*/
|
|
13
|
+
export class WorkIndex {
|
|
14
|
+
state;
|
|
15
|
+
constructor(journal) {
|
|
16
|
+
this.state = foldedJournalView(journal, {
|
|
17
|
+
initial: { streams: new Map(), items: new Map(), invalid: new Set() },
|
|
18
|
+
extend: extendWorkIndex,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
async snapshot() {
|
|
22
|
+
const { items, invalid } = await this.state.get();
|
|
23
|
+
const get = (id) => items.get(id) ?? null;
|
|
24
|
+
return {
|
|
25
|
+
get,
|
|
26
|
+
invalid: (id) => invalid.has(id),
|
|
27
|
+
availability: (id) => deliveryAvailability(id, get),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// A malformed stream poisons only its own item. That item is then unknown and
|
|
32
|
+
// held, rather than failing availability for every other item.
|
|
33
|
+
function extendWorkIndex(state, events) {
|
|
34
|
+
const invalid = new Set(state.invalid);
|
|
35
|
+
const added = new Map();
|
|
36
|
+
for (const envelope of events) {
|
|
37
|
+
if (!isWorkItemStream(envelope.stream) || invalid.has(envelope.stream.id))
|
|
38
|
+
continue;
|
|
39
|
+
try {
|
|
40
|
+
const event = selectWorkEvent(envelope);
|
|
41
|
+
if (event === null)
|
|
42
|
+
continue;
|
|
43
|
+
const stream = added.get(envelope.stream.id);
|
|
44
|
+
if (stream === undefined)
|
|
45
|
+
added.set(envelope.stream.id, [event]);
|
|
46
|
+
else
|
|
47
|
+
stream.push(event);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
invalid.add(envelope.stream.id);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const streams = new Map(state.streams);
|
|
54
|
+
const items = new Map(state.items);
|
|
55
|
+
for (const [id, more] of added) {
|
|
56
|
+
if (invalid.has(id)) {
|
|
57
|
+
items.delete(id);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const all = [...(streams.get(id) ?? []), ...more];
|
|
61
|
+
streams.set(id, all);
|
|
62
|
+
try {
|
|
63
|
+
const view = foldWorkItem(all);
|
|
64
|
+
if (view !== null)
|
|
65
|
+
items.set(id, view);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
invalid.add(id);
|
|
69
|
+
items.delete(id);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { streams, items, invalid };
|
|
73
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventJournal
|
|
1
|
+
import type { EventJournal } from '@atolis-hq/eventing';
|
|
2
2
|
import { type WorkEvent, type WorkEventData } from '../contracts/events.js';
|
|
3
3
|
import type { WorkItemId } from '../contracts/identifiers.js';
|
|
4
4
|
import type { WorkItemView } from '../contracts/views.js';
|
|
@@ -10,6 +10,6 @@ export interface LoadedWorkItem {
|
|
|
10
10
|
export declare class WorkRepository {
|
|
11
11
|
private readonly journal;
|
|
12
12
|
constructor(journal: EventJournal);
|
|
13
|
-
load(workItemId: WorkItemId
|
|
13
|
+
load(workItemId: WorkItemId): Promise<LoadedWorkItem>;
|
|
14
14
|
append(workItemId: WorkItemId, expectedSequence: number, drafts: readonly WorkEventData[]): Promise<readonly WorkEvent[]>;
|
|
15
15
|
}
|
|
@@ -6,8 +6,8 @@ export class WorkRepository {
|
|
|
6
6
|
constructor(journal) {
|
|
7
7
|
this.journal = journal;
|
|
8
8
|
}
|
|
9
|
-
async load(workItemId
|
|
10
|
-
const events = await this.journal.readStream(workItemStream(workItemId)
|
|
9
|
+
async load(workItemId) {
|
|
10
|
+
const events = await this.journal.readStream(workItemStream(workItemId));
|
|
11
11
|
const owned = events.map(selectWorkEvent).filter((event) => event !== null);
|
|
12
12
|
return { sequence: events.length, events: owned, view: foldWorkItem(owned) };
|
|
13
13
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type CommandContext, type EventJournal
|
|
1
|
+
import { type CommandContext, type EventJournal } from '@atolis-hq/eventing';
|
|
2
2
|
import type { CreateWorkItem, LinkWorkItems, ReviseWorkObjective } from '../contracts/commands.js';
|
|
3
3
|
import type { WorkItemId } from '../contracts/identifiers.js';
|
|
4
4
|
import type { WorkItemView } from '../contracts/views.js';
|
|
5
|
+
import { type DeliverySnapshot } from './work-index.js';
|
|
5
6
|
export interface WorkService {
|
|
6
7
|
create(command: CreateWorkItem, context: CommandContext): Promise<WorkItemView>;
|
|
7
8
|
revise(command: ReviseWorkObjective, context: CommandContext): Promise<WorkItemView>;
|
|
@@ -13,6 +14,8 @@ export interface WorkService {
|
|
|
13
14
|
freeze(workItemId: WorkItemId, context: CommandContext): Promise<WorkItemView>;
|
|
14
15
|
unfreeze(workItemId: WorkItemId, context: CommandContext): Promise<WorkItemView>;
|
|
15
16
|
delete(workItemId: WorkItemId, context: CommandContext): Promise<WorkItemView>;
|
|
16
|
-
get(workItemId: WorkItemId
|
|
17
|
+
get(workItemId: WorkItemId): Promise<WorkItemView | null>;
|
|
18
|
+
/** One synchronisation with the journal, then in-memory delivery answers for any number of items. */
|
|
19
|
+
deliverySnapshot(): Promise<DeliverySnapshot>;
|
|
17
20
|
}
|
|
18
21
|
export declare function createWorkService(journal: EventJournal): WorkService;
|
|
@@ -3,6 +3,7 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
3
3
|
import { createWorkEventData } from '../contracts/event-factory.js';
|
|
4
4
|
import { WorkEventType, } from '../contracts/events.js';
|
|
5
5
|
import { WorkStatus } from '../contracts/vocabulary.js';
|
|
6
|
+
import { WorkIndex } from './work-index.js';
|
|
6
7
|
import { WorkRepository } from './work-repository.js';
|
|
7
8
|
/** Delegated ancestry is derived from the validated parent, never trusted from the command. */
|
|
8
9
|
async function assertDelegationAncestry(repository, command) {
|
|
@@ -20,6 +21,7 @@ async function assertDelegationAncestry(repository, command) {
|
|
|
20
21
|
}
|
|
21
22
|
export function createWorkService(journal) {
|
|
22
23
|
const repository = new WorkRepository(journal);
|
|
24
|
+
const index = new WorkIndex(journal);
|
|
23
25
|
const change = (workItemId, context, draft, allowMissing, requireOpen) => changeWorkItem(repository, workItemId, context, draft, allowMissing, requireOpen);
|
|
24
26
|
return {
|
|
25
27
|
async create(command, context) {
|
|
@@ -70,9 +72,10 @@ export function createWorkService(journal) {
|
|
|
70
72
|
delete(workItemId, context) {
|
|
71
73
|
return setDeleted(repository, change, workItemId, context);
|
|
72
74
|
},
|
|
73
|
-
async get(workItemId
|
|
74
|
-
return (await repository.load(workItemId
|
|
75
|
+
async get(workItemId) {
|
|
76
|
+
return (await repository.load(workItemId)).view;
|
|
75
77
|
},
|
|
78
|
+
deliverySnapshot: () => index.snapshot(),
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
81
|
async function changeWorkItem(repository, workItemId, context, draft, allowMissing = false, requireOpen = true) {
|
|
@@ -6,12 +6,9 @@ export interface DeliveryWorkState {
|
|
|
6
6
|
readonly deleted?: boolean;
|
|
7
7
|
readonly delegation?: WorkDelegation;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
export declare function readDeliveryAvailability(id: string, work: {
|
|
11
|
-
get(id: WorkItemId, options?: {
|
|
12
|
-
readonly fresh?: boolean;
|
|
13
|
-
}): Promise<DeliveryWorkState | null>;
|
|
14
|
-
}): Promise<{
|
|
9
|
+
export interface DeliveryAvailability {
|
|
15
10
|
readonly rootWorkItemId: string;
|
|
16
11
|
readonly reason?: string;
|
|
17
|
-
}
|
|
12
|
+
}
|
|
13
|
+
/** Ancestry comes from Work's validated creation facts, never descriptive links. */
|
|
14
|
+
export declare function deliveryAvailability(id: string, lookup: (id: WorkItemId) => DeliveryWorkState | null): DeliveryAvailability;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { WorkStatus } from '../contracts/vocabulary.js';
|
|
2
2
|
/** Ancestry comes from Work's validated creation facts, never descriptive links. */
|
|
3
|
-
export
|
|
4
|
-
const item =
|
|
3
|
+
export function deliveryAvailability(id, lookup) {
|
|
4
|
+
const item = lookup(id);
|
|
5
5
|
const rootWorkItemId = item?.delegation?.rootWorkItemId ?? id;
|
|
6
6
|
for (const [key, member] of [
|
|
7
7
|
[id, item],
|
|
8
|
-
...(
|
|
8
|
+
...(item?.delegation?.ancestors ?? []).map((ancestor) => [ancestor, lookup(ancestor)]),
|
|
9
9
|
]) {
|
|
10
10
|
if (unavailable(member))
|
|
11
11
|
return { rootWorkItemId, reason: `Delivery work ${key} is unavailable` };
|
package/dist/src/work/index.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export * from './contracts/streams.js';
|
|
|
10
10
|
export * from './contracts/views.js';
|
|
11
11
|
export * from './contracts/vocabulary.js';
|
|
12
12
|
export * from './domain/work-item.js';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './domain/delivery-availability.js';
|
|
14
|
+
export * from './application/work-index.js';
|
package/dist/src/work/index.js
CHANGED
|
@@ -10,4 +10,5 @@ export * from './contracts/streams.js';
|
|
|
10
10
|
export * from './contracts/views.js';
|
|
11
11
|
export * from './contracts/vocabulary.js';
|
|
12
12
|
export * from './domain/work-item.js';
|
|
13
|
-
export * from './
|
|
13
|
+
export * from './domain/delivery-availability.js';
|
|
14
|
+
export * from './application/work-index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atolis-hq/wake",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.102",
|
|
4
4
|
"description": "Local autonomous agent control plane for software development",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
55
55
|
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
56
56
|
"test:e2e:live": "vitest run --config vitest.live-e2e.config.ts",
|
|
57
|
+
"test:stress": "vitest run --config vitest.stress.config.ts",
|
|
57
58
|
"lint:contracts": "node scripts/check-contract-vocabulary.mjs",
|
|
58
59
|
"knip": "knip --config knip.json",
|
|
59
60
|
"lint": "eslint --cache --cache-strategy content --cache-location node_modules/.cache/eslint/.eslintcache .",
|