@atolis-hq/wake 0.4.101 → 0.4.103

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.
Files changed (74) hide show
  1. package/dist/src/activities/pr/policy.d.ts +2 -0
  2. package/dist/src/activities/pr/policy.js +9 -1
  3. package/dist/src/artifacts/application/operator-instructions-service.js +2 -2
  4. package/dist/src/bootstrap/artifact-mcp.js +3 -4
  5. package/dist/src/bootstrap/delegation-authority.js +1 -1
  6. package/dist/src/bootstrap/integration-runtime.js +1 -1
  7. package/dist/src/bootstrap/persistence-composition.js +1 -1
  8. package/dist/src/bootstrap/surface-api-delivery.d.ts +1 -1
  9. package/dist/src/bootstrap/surface-api-delivery.js +8 -4
  10. package/dist/src/bootstrap/version.js +1 -1
  11. package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +2 -1
  12. package/dist/src/control-plane/application/activation-scheduler.js +2 -1
  13. package/dist/src/control-plane/application/advance-once-dispatch.d.ts +2 -4
  14. package/dist/src/control-plane/application/advance-once-dispatch.js +6 -4
  15. package/dist/src/control-plane/domain/delivery-capacity.d.ts +2 -5
  16. package/dist/src/control-plane/domain/delivery-capacity.js +3 -4
  17. package/dist/src/control-plane/domain/open-work-policy.d.ts +2 -10
  18. package/dist/src/control-plane/domain/open-work-policy.js +2 -3
  19. package/dist/src/execution/application/run-repository.d.ts +2 -2
  20. package/dist/src/execution/application/run-repository.js +3 -3
  21. package/dist/src/integrations/application/delegation-outputs.js +41 -5
  22. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts +9 -1
  23. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts.map +1 -1
  24. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.js +62 -7
  25. package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts +2 -5
  26. package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts.map +1 -1
  27. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +12 -13
  28. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
  29. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +168 -109
  30. package/dist/src/orchestration/application/deferred-signals.d.ts +4 -2
  31. package/dist/src/orchestration/application/deferred-signals.js +47 -37
  32. package/dist/src/orchestration/application/delegated-work.d.ts +48 -2
  33. package/dist/src/orchestration/application/delegated-work.js +145 -27
  34. package/dist/src/orchestration/application/delegation-commands.d.ts +48 -1
  35. package/dist/src/orchestration/application/delegation-commands.js +5 -4
  36. package/dist/src/orchestration/application/delegation-gate.d.ts +16 -7
  37. package/dist/src/orchestration/application/delegation-gate.js +62 -14
  38. package/dist/src/orchestration/application/delegation-ledger.d.ts +2 -0
  39. package/dist/src/orchestration/application/delegation-ledger.js +8 -0
  40. package/dist/src/orchestration/application/delegation-prerequisites.d.ts +28 -0
  41. package/dist/src/orchestration/application/delegation-prerequisites.js +118 -0
  42. package/dist/src/orchestration/application/delegation-reservation.js +1 -1
  43. package/dist/src/orchestration/application/delegation-wait-graph.d.ts +7 -0
  44. package/dist/src/orchestration/application/delegation-wait-graph.js +122 -0
  45. package/dist/src/orchestration/application/orchestration-repository.d.ts +5 -0
  46. package/dist/src/orchestration/application/orchestration-repository.js +3 -0
  47. package/dist/src/orchestration/application/orchestration-service.d.ts +87 -0
  48. package/dist/src/orchestration/application/orchestration-service.js +13 -7
  49. package/dist/src/orchestration/application/prerequisite-readiness.d.ts +68 -0
  50. package/dist/src/orchestration/application/prerequisite-readiness.js +217 -0
  51. package/dist/src/orchestration/contracts/delegation-ports.d.ts +2 -1
  52. package/dist/src/orchestration/contracts/delegation.d.ts +88 -0
  53. package/dist/src/orchestration/contracts/delegation.js +36 -1
  54. package/dist/src/orchestration/contracts/event-decoder.js +8 -1
  55. package/dist/src/orchestration/contracts/event-factory.js +5 -4
  56. package/dist/src/orchestration/contracts/events.d.ts +13 -1
  57. package/dist/src/orchestration/contracts/events.js +3 -0
  58. package/dist/src/orchestration/contracts/vocabulary.d.ts +27 -0
  59. package/dist/src/orchestration/contracts/vocabulary.js +25 -0
  60. package/dist/src/orchestration/domain/workflow-instance-events.js +3 -0
  61. package/dist/src/orchestration/index.d.ts +2 -2
  62. package/dist/src/orchestration/index.js +1 -1
  63. package/dist/src/surfaces/mcp/delegation.js +18 -10
  64. package/dist/src/work/application/work-index.d.ts +21 -0
  65. package/dist/src/work/application/work-index.js +73 -0
  66. package/dist/src/work/application/work-repository.d.ts +2 -2
  67. package/dist/src/work/application/work-repository.js +2 -2
  68. package/dist/src/work/application/work-service.d.ts +5 -2
  69. package/dist/src/work/application/work-service.js +5 -2
  70. package/dist/src/work/{application → domain}/delivery-availability.d.ts +4 -7
  71. package/dist/src/work/{application → domain}/delivery-availability.js +3 -3
  72. package/dist/src/work/index.d.ts +2 -1
  73. package/dist/src/work/index.js +2 -1
  74. package/package.json +2 -1
@@ -3,11 +3,14 @@ import type { ActivationId, ActivityName, ActivityOutcome, ActivityOutcomeKind }
3
3
  import type { WorkItemId } from '../../work/index.js';
4
4
  import type { OrchestrationWaitingActivityOutcome } from './activity-outcome.js';
5
5
  import type { ApprovalAuthority, CompiledResourceTransition, CompiledWorkflow, StageConfig, TransitionTarget } from './config.js';
6
- import type { DelegationReservation, DelegationResult } from './delegation.js';
6
+ import type { DelegationInputs, DelegationReservation, DelegationResult } from './delegation.js';
7
7
  import type { CommandName, OrchestrationGroupId, SignalName, StageName, WorkflowInstanceId, WorkflowName } from './identifiers.js';
8
8
  import type { ChildOrchestrationGroupStreamId, ChildOrchestrationGroupStreamRef, PrimaryOrchestrationGroupStreamRef, WorkflowDefinitionsStreamRef, WorkflowInstanceStreamRef } from './streams.js';
9
9
  export declare const OrchestrationEventType: {
10
10
  readonly DelegationReserved: "orchestration.delegation-reserved";
11
+ readonly DelegationInputsResolved: "orchestration.delegation-inputs-resolved";
12
+ readonly DelegationChildBlocked: "orchestration.delegation-child-blocked";
13
+ readonly DelegationPrerequisiteBlocked: "orchestration.delegation-prerequisite-blocked";
11
14
  readonly DelegationRegistered: "orchestration.delegation-registered";
12
15
  readonly DelegationResultSelected: "orchestration.delegation-result-selected";
13
16
  readonly DelegationWaitStarted: "orchestration.delegation-wait-started";
@@ -53,6 +56,15 @@ export interface DeferredWorkflowSignal {
53
56
  readonly target?: TransitionTarget;
54
57
  }
55
58
  export interface OrchestrationEventPayloads {
59
+ readonly [OrchestrationEventType.DelegationChildBlocked]: {
60
+ readonly childWorkItemId: WorkItemId;
61
+ readonly reason: string;
62
+ };
63
+ readonly [OrchestrationEventType.DelegationInputsResolved]: DelegationInputs;
64
+ readonly [OrchestrationEventType.DelegationPrerequisiteBlocked]: {
65
+ readonly childWorkItemId: WorkItemId;
66
+ readonly reason: string;
67
+ };
56
68
  readonly [OrchestrationEventType.SignalDeferred]: DeferredWorkflowSignal;
57
69
  readonly [OrchestrationEventType.DelegationFailed]: {
58
70
  readonly cohortId: string;
@@ -1,6 +1,9 @@
1
1
  import { signalName } from './identifiers.js';
2
2
  export const OrchestrationEventType = {
3
3
  DelegationReserved: 'orchestration.delegation-reserved',
4
+ DelegationInputsResolved: 'orchestration.delegation-inputs-resolved',
5
+ DelegationChildBlocked: 'orchestration.delegation-child-blocked',
6
+ DelegationPrerequisiteBlocked: 'orchestration.delegation-prerequisite-blocked',
4
7
  DelegationRegistered: 'orchestration.delegation-registered',
5
8
  DelegationResultSelected: 'orchestration.delegation-result-selected',
6
9
  DelegationWaitStarted: 'orchestration.delegation-wait-started',
@@ -50,3 +50,30 @@ export type ConversationSurfaceCapability = ValueOf<typeof ConversationSurfaceCa
50
50
  export declare const DelegationOutputKind: {
51
51
  readonly Change: "change";
52
52
  };
53
+ export declare const DelegationPrerequisiteCondition: {
54
+ readonly AcceptedOutput: "accepted-output";
55
+ readonly PushedChange: "pushed-change";
56
+ readonly DeliveryReady: "delivery-ready";
57
+ readonly MergedChange: "merged-change";
58
+ };
59
+ export declare const DelegationConflictCode: {
60
+ readonly SelfDependency: "self-dependency";
61
+ readonly MissingTarget: "missing-target";
62
+ readonly MissingOutput: "missing-output";
63
+ readonly OutputKind: "output-kind";
64
+ readonly CrossRepositoryBase: "cross-repository-base";
65
+ readonly CrossRepositoryChange: "cross-repository-change";
66
+ readonly MultipleBases: "multiple-bases";
67
+ readonly WaitCycle: "wait-cycle";
68
+ readonly StalePlan: "stale-plan";
69
+ };
70
+ export type DelegationConflictCode = ValueOf<typeof DelegationConflictCode>;
71
+ export declare const PrerequisiteBlockCode: {
72
+ readonly Waiting: "prerequisite-waiting";
73
+ readonly Changed: "prerequisite-changed";
74
+ readonly Failed: "prerequisite-failed";
75
+ readonly Unavailable: "prerequisite-unavailable";
76
+ readonly Cycle: "prerequisite-cycle";
77
+ readonly Blocked: "prerequisite-blocked";
78
+ };
79
+ export type PrerequisiteBlockCode = ValueOf<typeof PrerequisiteBlockCode>;
@@ -43,3 +43,28 @@ export const ConversationSurfaceCapability = defineClosedVocabulary({
43
43
  Operator: 'operator-surface',
44
44
  });
45
45
  export const DelegationOutputKind = defineClosedVocabulary({ Change: 'change' });
46
+ export const DelegationPrerequisiteCondition = defineClosedVocabulary({
47
+ AcceptedOutput: 'accepted-output',
48
+ PushedChange: 'pushed-change',
49
+ DeliveryReady: 'delivery-ready',
50
+ MergedChange: 'merged-change',
51
+ });
52
+ export const DelegationConflictCode = defineClosedVocabulary({
53
+ SelfDependency: 'self-dependency',
54
+ MissingTarget: 'missing-target',
55
+ MissingOutput: 'missing-output',
56
+ OutputKind: 'output-kind',
57
+ CrossRepositoryBase: 'cross-repository-base',
58
+ CrossRepositoryChange: 'cross-repository-change',
59
+ MultipleBases: 'multiple-bases',
60
+ WaitCycle: 'wait-cycle',
61
+ StalePlan: 'stale-plan',
62
+ });
63
+ export const PrerequisiteBlockCode = defineClosedVocabulary({
64
+ Waiting: 'prerequisite-waiting',
65
+ Changed: 'prerequisite-changed',
66
+ Failed: 'prerequisite-failed',
67
+ Unavailable: 'prerequisite-unavailable',
68
+ Cycle: 'prerequisite-cycle',
69
+ Blocked: 'prerequisite-blocked',
70
+ });
@@ -180,6 +180,9 @@ function applyCoordinationFact(state, event) {
180
180
  };
181
181
  return;
182
182
  case OrchestrationEventType.DelegationRegistered:
183
+ case OrchestrationEventType.DelegationInputsResolved:
184
+ case OrchestrationEventType.DelegationPrerequisiteBlocked:
185
+ case OrchestrationEventType.DelegationChildBlocked:
183
186
  case OrchestrationEventType.DelegationResultSelected:
184
187
  return;
185
188
  case OrchestrationEventType.DelegationWaitStarted:
@@ -33,7 +33,7 @@ export * from './domain/workflow-selector.js';
33
33
  export * from './application/work-completion-summary.js';
34
34
  export type { WorkflowCompileDiagnostic } from './domain/compile-diagnostics.js';
35
35
  export type { DelegationArtifacts, DelegationRepositories } from './contracts/delegation-ports.js';
36
- export { DelegationPendingError } from './contracts/delegation.js';
36
+ export { DelegationConflictError, DelegationPendingError } from './contracts/delegation.js';
37
37
  export type { DelegationAuthority } from './contracts/delegation-ports.js';
38
38
  export { delegationSubmissionSchema } from './contracts/delegation.js';
39
- export type { DelegationCaller, DelegationReservation, DelegationSubmission, } from './contracts/delegation.js';
39
+ export type { DelegationCaller, DelegationInputs, DelegationPrerequisite, DelegationReservation, DelegationResult, DelegationSubmission, } from './contracts/delegation.js';
@@ -31,5 +31,5 @@ export * from './domain/interpreter.js';
31
31
  export * from './domain/workflow-instance.js';
32
32
  export * from './domain/workflow-selector.js';
33
33
  export * from './application/work-completion-summary.js';
34
- export { DelegationPendingError } from './contracts/delegation.js';
34
+ export { DelegationConflictError, DelegationPendingError } from './contracts/delegation.js';
35
35
  export { delegationSubmissionSchema } from './contracts/delegation.js';
@@ -1,17 +1,25 @@
1
- import { delegationSubmissionSchema, } from '../../orchestration/index.js';
1
+ import { DelegationConflictError, delegationSubmissionSchema, } from '../../orchestration/index.js';
2
2
  /** The bound caller is never accepted as a tool argument. */
3
3
  export function registerDelegationTools(server, input) {
4
4
  server.registerTool('wake_delegation_submit', {
5
- description: 'Submit independent child work under this workflow delegation policy. End the current activity normally after submission; Wake waits and resumes it with joined results.',
5
+ description: 'Submit child work with optional queued named-output prerequisites under this workflow delegation policy. Use expectedPlanRevision from inspection; useAsBase selects only a same-repository upstream change. End the current activity normally after submission; Wake waits and resumes it with joined results or terminal failure facts. Inspect failureReason and blockers before submitting replacement assignments in a new cohort; existing receipts remain immutable.',
6
6
  inputSchema: delegationSubmissionSchema,
7
- }, async (command) => ({
8
- content: [
9
- {
10
- type: 'text',
11
- text: JSON.stringify(await input.orchestration.submitDelegation(await input.caller(), command, input.commandContext())),
12
- },
13
- ],
14
- }));
7
+ }, async (command) => {
8
+ try {
9
+ const reservation = await input.orchestration.submitDelegation(await input.caller(), command, input.commandContext());
10
+ return { content: [{ type: 'text', text: JSON.stringify(reservation) }] };
11
+ }
12
+ catch (error) {
13
+ if (!(error instanceof DelegationConflictError))
14
+ throw error;
15
+ return {
16
+ isError: true,
17
+ content: [
18
+ { type: 'text', text: JSON.stringify({ code: error.code, message: error.message }) },
19
+ ],
20
+ };
21
+ }
22
+ });
15
23
  server.registerTool('wake_delegation_inspect', {
16
24
  description: 'Inspect this delivery tree, child workflows, results and blockers, and the Repository Resource IDs an explicit repository selection may name.',
17
25
  }, async () => ({
@@ -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, JournalReadOptions } from '@atolis-hq/eventing';
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, options?: JournalReadOptions): Promise<LoadedWorkItem>;
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, options) {
10
- const events = await this.journal.readStream(workItemStream(workItemId), options);
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, type JournalReadOptions } from '@atolis-hq/eventing';
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, options?: JournalReadOptions): Promise<WorkItemView | null>;
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, options) {
74
- return (await repository.load(workItemId, options)).view;
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
- /** Ancestry comes from Work's validated creation facts, never descriptive links. */
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 async function readDeliveryAvailability(id, work) {
4
- const item = await work.get(id, { fresh: true });
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
- ...(await Promise.all((item?.delegation?.ancestors ?? []).map(async (ancestor) => [ancestor, await work.get(ancestor, { fresh: true })]))),
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` };
@@ -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 './application/delivery-availability.js';
13
+ export * from './domain/delivery-availability.js';
14
+ export * from './application/work-index.js';
@@ -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 './application/delivery-availability.js';
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.101",
3
+ "version": "0.4.103",
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 .",