@atolis-hq/wake 0.4.100 → 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.
Files changed (72) hide show
  1. package/dist/src/artifacts/application/operator-instructions-service.js +2 -2
  2. package/dist/src/bootstrap/artifact-mcp.d.ts +1 -0
  3. package/dist/src/bootstrap/artifact-mcp.js +27 -2
  4. package/dist/src/bootstrap/composition-root.js +6 -1
  5. package/dist/src/bootstrap/config/root-schema.d.ts +14 -0
  6. package/dist/src/bootstrap/delegation-authority.d.ts +10 -0
  7. package/dist/src/bootstrap/delegation-authority.js +52 -0
  8. package/dist/src/bootstrap/integration-runtime.js +5 -3
  9. package/dist/src/bootstrap/persistence-composition.js +1 -1
  10. package/dist/src/bootstrap/surface-api-delivery.d.ts +4 -0
  11. package/dist/src/bootstrap/surface-api-delivery.js +35 -0
  12. package/dist/src/bootstrap/surface-api-work-applications.js +2 -0
  13. package/dist/src/bootstrap/version.js +1 -1
  14. package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +4 -1
  15. package/dist/src/control-plane/application/activation-scheduler.js +2 -1
  16. package/dist/src/control-plane/application/advance-once-dispatch.d.ts +4 -15
  17. package/dist/src/control-plane/application/advance-once-dispatch.js +15 -26
  18. package/dist/src/control-plane/application/trigger-recovery.js +2 -1
  19. package/dist/src/control-plane/application/trigger-workflow.d.ts +2 -1
  20. package/dist/src/control-plane/application/work-cancellation-policy.d.ts +1 -0
  21. package/dist/src/control-plane/application/work-cancellation-policy.js +6 -1
  22. package/dist/src/control-plane/domain/delivery-capacity.d.ts +9 -0
  23. package/dist/src/control-plane/domain/delivery-capacity.js +40 -0
  24. package/dist/src/control-plane/domain/dispatch-policy.d.ts +1 -0
  25. package/dist/src/control-plane/domain/dispatch-policy.js +6 -0
  26. package/dist/src/control-plane/domain/open-work-policy.d.ts +2 -7
  27. package/dist/src/control-plane/domain/open-work-policy.js +12 -9
  28. package/dist/src/execution/application/repository-assignments.d.ts +1 -1
  29. package/dist/src/execution/application/repository-assignments.js +7 -4
  30. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts +9 -1
  31. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts.map +1 -1
  32. package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.js +62 -7
  33. package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts +2 -5
  34. package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts.map +1 -1
  35. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +12 -13
  36. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
  37. package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +168 -109
  38. package/dist/src/orchestration/application/deferred-signals.d.ts +4 -2
  39. package/dist/src/orchestration/application/deferred-signals.js +47 -37
  40. package/dist/src/orchestration/application/delegated-work.d.ts +54 -0
  41. package/dist/src/orchestration/application/delegated-work.js +64 -1
  42. package/dist/src/orchestration/application/delegation-commands.d.ts +119 -0
  43. package/dist/src/orchestration/application/delegation-commands.js +99 -0
  44. package/dist/src/orchestration/application/delegation-gate.d.ts +15 -5
  45. package/dist/src/orchestration/application/delegation-gate.js +44 -4
  46. package/dist/src/orchestration/application/orchestration-service.d.ts +150 -2
  47. package/dist/src/orchestration/application/orchestration-service.js +52 -6
  48. package/dist/src/orchestration/contracts/config.d.ts +16 -0
  49. package/dist/src/orchestration/contracts/config.js +10 -0
  50. package/dist/src/orchestration/contracts/delegation-ports.d.ts +10 -1
  51. package/dist/src/orchestration/contracts/delegation.d.ts +34 -0
  52. package/dist/src/orchestration/contracts/delegation.js +8 -0
  53. package/dist/src/orchestration/domain/compiler.js +7 -0
  54. package/dist/src/orchestration/index.d.ts +3 -0
  55. package/dist/src/orchestration/index.js +1 -0
  56. package/dist/src/surfaces/api/contracts/work.d.ts +14 -0
  57. package/dist/src/surfaces/index.d.ts +1 -0
  58. package/dist/src/surfaces/index.js +1 -0
  59. package/dist/src/surfaces/mcp/delegation.d.ts +9 -0
  60. package/dist/src/surfaces/mcp/delegation.js +25 -0
  61. package/dist/src/surfaces/web-assets/assets/index-C5R-aWzH.js +1192 -0
  62. package/dist/src/surfaces/web-assets/index.html +1 -1
  63. package/dist/src/work/application/work-index.d.ts +21 -0
  64. package/dist/src/work/application/work-index.js +73 -0
  65. package/dist/src/work/application/work-service.d.ts +3 -0
  66. package/dist/src/work/application/work-service.js +3 -0
  67. package/dist/src/work/domain/delivery-availability.d.ts +14 -0
  68. package/dist/src/work/domain/delivery-availability.js +20 -0
  69. package/dist/src/work/index.d.ts +2 -0
  70. package/dist/src/work/index.js +2 -0
  71. package/package.json +2 -1
  72. package/dist/src/surfaces/web-assets/assets/index-s9CWgq-s.js +0 -1192
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Wake</title>
7
- <script type="module" crossorigin src="/assets/index-s9CWgq-s.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-C5R-aWzH.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-EVgZ9q9N.css">
9
9
  </head>
10
10
  <body>
@@ -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
+ }
@@ -2,6 +2,7 @@ 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>;
@@ -14,5 +15,7 @@ export interface WorkService {
14
15
  unfreeze(workItemId: WorkItemId, context: CommandContext): Promise<WorkItemView>;
15
16
  delete(workItemId: WorkItemId, context: CommandContext): Promise<WorkItemView>;
16
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) {
@@ -73,6 +75,7 @@ export function createWorkService(journal) {
73
75
  async get(workItemId) {
74
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) {
@@ -0,0 +1,14 @@
1
+ import type { WorkDelegation } from '../contracts/commands.js';
2
+ import type { WorkItemId } from '../contracts/identifiers.js';
3
+ export interface DeliveryWorkState {
4
+ readonly state?: string;
5
+ readonly frozen?: boolean;
6
+ readonly deleted?: boolean;
7
+ readonly delegation?: WorkDelegation;
8
+ }
9
+ export interface DeliveryAvailability {
10
+ readonly rootWorkItemId: string;
11
+ readonly reason?: string;
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;
@@ -0,0 +1,20 @@
1
+ import { WorkStatus } from '../contracts/vocabulary.js';
2
+ /** Ancestry comes from Work's validated creation facts, never descriptive links. */
3
+ export function deliveryAvailability(id, lookup) {
4
+ const item = lookup(id);
5
+ const rootWorkItemId = item?.delegation?.rootWorkItemId ?? id;
6
+ for (const [key, member] of [
7
+ [id, item],
8
+ ...(item?.delegation?.ancestors ?? []).map((ancestor) => [ancestor, lookup(ancestor)]),
9
+ ]) {
10
+ if (unavailable(member))
11
+ return { rootWorkItemId, reason: `Delivery work ${key} is unavailable` };
12
+ }
13
+ return { rootWorkItemId };
14
+ }
15
+ function unavailable(member) {
16
+ return (member === null ||
17
+ member.deleted === true ||
18
+ member.frozen === true ||
19
+ (member.state !== undefined && member.state !== WorkStatus.Open));
20
+ }
@@ -10,3 +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 './domain/delivery-availability.js';
14
+ export * from './application/work-index.js';
@@ -10,3 +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 './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.100",
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 .",