@atolis-hq/wake 0.2.49 → 0.2.51

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.
@@ -1,4 +1,5 @@
1
1
  import { access } from 'node:fs/promises';
2
+ import { LABELS_REQUESTED_EVENT } from '../../domain/event-types.js';
2
3
  import { buildResourceUri } from '../../domain/resource-uri.js';
3
4
  import { createEventEnvelope, createUnkeyedEventEnvelope } from '../../lib/event-log.js';
4
5
  import { readJsonFile } from '../../lib/json-file.js';
@@ -81,7 +82,7 @@ export function createFakeTicketingSystem(options) {
81
82
  },
82
83
  async deliverIntent(input) {
83
84
  const publishedAt = (options.now ?? (() => new Date()))().toISOString();
84
- if (input.event.sourceEventType === 'wake.labels.requested') {
85
+ if (input.event.sourceEventType === LABELS_REQUESTED_EVENT) {
85
86
  const ticket = options.tickets.find((issue) => issue.repo === input.event.sourceRefs.repo &&
86
87
  issue.number === input.event.sourceRefs.issueNumber);
87
88
  const currentLabels = ticket?.labels ?? [];
@@ -1,5 +1,6 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { autoApprovalLabel, resolveAutoApprovalIntent } from '../../core/approval-intents.js';
3
+ import { LABELS_REQUESTED_EVENT } from '../../domain/event-types.js';
3
4
  import { defaultAgentIdentity } from '../../domain/schema.js';
4
5
  import { buildResourceUri } from '../../domain/resource-uri.js';
5
6
  import { wakeStageLabelPrefix } from '../../domain/stages.js';
@@ -509,7 +510,7 @@ export function createGitHubIssuesWorkSource(deps) {
509
510
  throw new Error(`cannot deliver intent ${input.event.eventId}: malformed repo "${repo}"`);
510
511
  }
511
512
  const publishedAt = deps.now().toISOString();
512
- if (input.event.sourceEventType === 'wake.labels.requested') {
513
+ if (input.event.sourceEventType === LABELS_REQUESTED_EVENT) {
513
514
  // Outbound intents are keyed envelopes Wake itself minted, so the work
514
515
  // item is already named on the event — a direct read, not a lookup.
515
516
  const projection = await deps.stateStore.readIssueState(input.event.workItemKey);
@@ -594,7 +595,7 @@ export function createGitHubIssuesWorkSource(deps) {
594
595
  return [];
595
596
  }
596
597
  const publishedAt = deps.now().toISOString();
597
- if (input.event.sourceEventType === 'wake.labels.requested') {
598
+ if (input.event.sourceEventType === LABELS_REQUESTED_EVENT) {
598
599
  const projection = await deps.stateStore.readIssueState(input.event.workItemKey);
599
600
  const currentLabels = projection?.issue.labels ?? [];
600
601
  const expected = [
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto';
3
3
  import { mkdir, rm, writeFile } from 'node:fs/promises';
4
4
  import { dirname } from 'node:path';
5
5
  import { createProjectionUpdater } from '../../core/projection-updater.js';
6
+ import { RETRY_REQUESTED_EVENT } from '../../domain/event-types.js';
6
7
  import { configuredTicketSource } from '../../domain/sources.js';
7
8
  import { createEventEnvelope } from '../../lib/event-log.js';
8
9
  import { writeJsonFile } from '../../lib/json-file.js';
@@ -118,7 +119,7 @@ async function handleRequest(req, res, options, now, projectionUpdater) {
118
119
  streamScope: 'work-item',
119
120
  direction: 'internal',
120
121
  sourceSystem: 'wake',
121
- sourceEventType: 'wake.retry.requested',
122
+ sourceEventType: RETRY_REQUESTED_EVENT,
122
123
  sourceRefs: { repo: item.issue.repo, issueNumber: item.issue.number },
123
124
  occurredAt,
124
125
  ingestedAt: occurredAt,
@@ -1,3 +1,4 @@
1
+ import { LABELS_REQUESTED_EVENT, PUBLISH_INTENT_REQUESTED_EVENT } from '../domain/event-types.js';
1
2
  import { createEventEnvelope } from '../lib/event-log.js';
2
3
  import { extractTokenCount, formatCostUsd, formatDuration, formatTokenCount, } from '../lib/format.js';
3
4
  function isReviewThreadResourceUri(resourceUri) {
@@ -37,7 +38,7 @@ export function createPublishIntentEvent(input) {
37
38
  streamScope: 'work-item',
38
39
  direction: 'outbound',
39
40
  sourceSystem: 'wake',
40
- sourceEventType: 'wake.publish.intent.requested',
41
+ sourceEventType: PUBLISH_INTENT_REQUESTED_EVENT,
41
42
  sourceRefs: {
42
43
  repo: input.projection.issue.repo,
43
44
  issueNumber: input.projection.issue.number,
@@ -129,7 +130,7 @@ export function createLabelsEvent(input) {
129
130
  streamScope: 'work-item',
130
131
  direction: 'outbound',
131
132
  sourceSystem: 'wake',
132
- sourceEventType: 'wake.labels.requested',
133
+ sourceEventType: LABELS_REQUESTED_EVENT,
133
134
  sourceRefs: {
134
135
  repo: input.projection.issue.repo,
135
136
  issueNumber: input.projection.issue.number,
@@ -1,14 +1,12 @@
1
1
  import { randomUUID } from 'node:crypto';
2
+ import { LABELS_REQUESTED_EVENT, PUBLISH_CONFIRMED_EVENT, PUBLISH_FAILED_EVENT, PUBLISH_INTENT_REQUESTED_EVENT, PUBLISH_SENT_UNCONFIRMED_EVENT, } from '../domain/event-types.js';
2
3
  import { createEventEnvelope } from '../lib/event-log.js';
3
4
  const outboxMaxAttempts = 3;
4
- const outboundIntentEventTypes = new Set([
5
- 'wake.publish.intent.requested',
6
- 'wake.labels.requested',
7
- ]);
5
+ const outboundIntentEventTypes = new Set([PUBLISH_INTENT_REQUESTED_EVENT, LABELS_REQUESTED_EVENT]);
8
6
  const outboundConfirmationEventTypes = new Set([
9
7
  'ticket.reply.published',
10
8
  'ticket.labels.updated',
11
- 'wake.publish.confirmed',
9
+ PUBLISH_CONFIRMED_EVENT,
12
10
  'pr.comment.reply.published',
13
11
  'pr.review-comment.reply.published',
14
12
  ]);
@@ -29,7 +27,7 @@ export function createOutbox(deps) {
29
27
  streamScope: 'work-item',
30
28
  direction: 'internal',
31
29
  sourceSystem: 'wake',
32
- sourceEventType: 'wake.publish.failed',
30
+ sourceEventType: PUBLISH_FAILED_EVENT,
33
31
  sourceRefs: intentEvent.sourceRefs,
34
32
  occurredAt,
35
33
  ingestedAt: occurredAt,
@@ -53,7 +51,7 @@ export function createOutbox(deps) {
53
51
  streamScope: 'work-item',
54
52
  direction: 'internal',
55
53
  sourceSystem: 'wake',
56
- sourceEventType: 'wake.publish.sent-unconfirmed',
54
+ sourceEventType: PUBLISH_SENT_UNCONFIRMED_EVENT,
57
55
  sourceRefs: intentEvent.sourceRefs,
58
56
  occurredAt,
59
57
  ingestedAt: occurredAt,
@@ -76,7 +74,7 @@ export function createOutbox(deps) {
76
74
  streamScope: 'work-item',
77
75
  direction: 'internal',
78
76
  sourceSystem: 'wake',
79
- sourceEventType: 'wake.publish.confirmed',
77
+ sourceEventType: PUBLISH_CONFIRMED_EVENT,
80
78
  sourceRefs: intentEvent.sourceRefs,
81
79
  occurredAt: confirmedAt,
82
80
  ingestedAt: confirmedAt,
@@ -154,10 +152,10 @@ export function createOutbox(deps) {
154
152
  if (outboundConfirmationEventTypes.has(event.sourceEventType)) {
155
153
  confirmedIntentIds.add(intentEventId);
156
154
  }
157
- if (event.sourceEventType === 'wake.publish.failed') {
155
+ if (event.sourceEventType === PUBLISH_FAILED_EVENT) {
158
156
  failureAttempts.set(intentEventId, (failureAttempts.get(intentEventId) ?? 0) + 1);
159
157
  }
160
- if (event.sourceEventType === 'wake.publish.sent-unconfirmed') {
158
+ if (event.sourceEventType === PUBLISH_SENT_UNCONFIRMED_EVENT) {
161
159
  uncertainIntentIds.add(intentEventId);
162
160
  }
163
161
  }
@@ -1,9 +1,9 @@
1
- import { CORRELATION_PRIMARY_CONFLICT_EVENT, CORRELATION_REGISTERED_EVENT, CORRELATION_RETRACTED_EVENT, UNRESOLVED_WORK_ITEM_KEY, parseIssueStateRecord, } from '../domain/schema.js';
1
+ import { CORRELATION_PRIMARY_CONFLICT_EVENT, CORRELATION_REGISTERED_EVENT, CORRELATION_RETRACTED_EVENT, RETRY_REQUESTED_EVENT, RUN_CLAIMED_EVENT, RUN_COMPLETED_EVENT, WORKFLOW_SELECTED_EVENT, WORKSPACE_CLEANED_EVENT, } from '../domain/event-types.js';
2
+ import { UNRESOLVED_WORK_ITEM_KEY, parseIssueStateRecord } from '../domain/schema.js';
2
3
  import { doneRunnerSentinel, stageFromLabels } from '../domain/stages.js';
3
4
  import { builtInDefaultWorkflowDefinition, defaultWorkflowName, selectWorkflowForEvent, workflowStageVocabulary, } from '../domain/workflows.js';
4
5
  import { isCustomCommandAction } from '../domain/custom-commands.js';
5
6
  import { createEventEnvelope } from '../lib/event-log.js';
6
- const WORKFLOW_SELECTED_EVENT = 'wake.workflow.selected';
7
7
  function stringArrayFromPayload(value) {
8
8
  return Array.isArray(value)
9
9
  ? value.filter((entry) => typeof entry === 'string')
@@ -159,7 +159,7 @@ async function applyEvent(current, event, ctx, config) {
159
159
  },
160
160
  });
161
161
  }
162
- if (event.sourceEventType === 'wake.run.claimed') {
162
+ if (event.sourceEventType === RUN_CLAIMED_EVENT) {
163
163
  const payload = event.payload;
164
164
  if (payload.claimedStage === undefined) {
165
165
  return parseIssueStateRecord({
@@ -190,7 +190,7 @@ async function applyEvent(current, event, ctx, config) {
190
190
  },
191
191
  });
192
192
  }
193
- if (event.sourceEventType === 'wake.run.completed') {
193
+ if (event.sourceEventType === RUN_COMPLETED_EVENT) {
194
194
  const payload = event.payload;
195
195
  if (payload.watcherRun === true) {
196
196
  return parseIssueStateRecord({
@@ -317,7 +317,7 @@ async function applyEvent(current, event, ctx, config) {
317
317
  },
318
318
  });
319
319
  }
320
- if (event.sourceEventType === 'wake.retry.requested') {
320
+ if (event.sourceEventType === RETRY_REQUESTED_EVENT) {
321
321
  const nextContext = { ...current.context };
322
322
  delete nextContext.lastRunSentinel;
323
323
  delete nextContext.lastFailureClass;
@@ -332,7 +332,7 @@ async function applyEvent(current, event, ctx, config) {
332
332
  },
333
333
  });
334
334
  }
335
- if (event.sourceEventType === 'wake.workspace.cleaned') {
335
+ if (event.sourceEventType === WORKSPACE_CLEANED_EVENT) {
336
336
  return parseIssueStateRecord({
337
337
  ...current,
338
338
  wake: {
@@ -1,3 +1,4 @@
1
+ import { LABELS_REQUESTED_EVENT, PUBLISH_INTENT_REQUESTED_EVENT } from '../domain/event-types.js';
1
2
  export function createWorkSourceFanIn(sources) {
2
3
  return {
3
4
  async pollEvents(input) {
@@ -19,7 +20,7 @@ export function createWorkSourceFanIn(sources) {
19
20
  };
20
21
  }
21
22
  function intentKind(event) {
22
- if (event.sourceEventType !== 'wake.publish.intent.requested') {
23
+ if (event.sourceEventType !== PUBLISH_INTENT_REQUESTED_EVENT) {
23
24
  return null;
24
25
  }
25
26
  return typeof event.payload.kind === 'string' ? event.payload.kind : null;
@@ -54,14 +55,14 @@ function targetSinksForEvent(input) {
54
55
  const targetSinks = new Set();
55
56
  const origin = typeof input.event.payload.origin === 'string' ? input.event.payload.origin : undefined;
56
57
  const sourceOrigin = input.event.sourceRefs.sink ?? origin;
57
- if (input.event.sourceEventType === 'wake.labels.requested') {
58
+ if (input.event.sourceEventType === LABELS_REQUESTED_EVENT) {
58
59
  const projectionOrigin = typeof input.event.payload.origin === 'string' ? input.event.payload.origin : undefined;
59
60
  if (projectionOrigin !== undefined) {
60
61
  targetSinks.add(projectionOrigin);
61
62
  }
62
63
  }
63
64
  const resourceUri = input.event.sourceRefs.resourceUri;
64
- if (input.event.sourceEventType === 'wake.publish.intent.requested' &&
65
+ if (input.event.sourceEventType === PUBLISH_INTENT_REQUESTED_EVENT &&
65
66
  sourceOrigin !== undefined) {
66
67
  const resourceSink = resourceUri === undefined ? sourceOrigin : sinkNameForResourceUri(resourceUri, sourceOrigin);
67
68
  targetSinks.add(input.sinksByName.has(resourceSink) ? resourceSink : sourceOrigin);
@@ -1,4 +1,5 @@
1
1
  import { createLabelsEvent } from './event-builders.js';
2
+ import { RUN_COMPLETED_EVENT } from '../domain/event-types.js';
2
3
  import { stageLabelForStage } from '../domain/stages.js';
3
4
  import { workflowLabelForWorkflowName, workflowNameForProjection } from '../domain/workflows.js';
4
5
  import { createEventEnvelope } from '../lib/event-log.js';
@@ -80,7 +81,7 @@ export function createStaleRunReconciler(deps) {
80
81
  streamScope: 'work-item',
81
82
  direction: 'internal',
82
83
  sourceSystem: 'wake',
83
- sourceEventType: 'wake.run.completed',
84
+ sourceEventType: RUN_COMPLETED_EVENT,
84
85
  sourceRefs: {
85
86
  repo: projection.issue.repo,
86
87
  issueNumber: projection.issue.number,
@@ -167,7 +168,7 @@ export function createStaleRunReconciler(deps) {
167
168
  streamScope: 'work-item',
168
169
  direction: 'internal',
169
170
  sourceSystem: 'wake',
170
- sourceEventType: 'wake.run.completed',
171
+ sourceEventType: RUN_COMPLETED_EVENT,
171
172
  sourceRefs: {
172
173
  repo: record.repo,
173
174
  issueNumber: record.issueNumber,
@@ -3,7 +3,8 @@ import { createLifecycleService } from './lifecycle-service.js';
3
3
  import { createPolicyEngine } from './policy-engine.js';
4
4
  import { createProjectionUpdater } from './projection-updater.js';
5
5
  import { acquireFileLock } from '../lib/lock.js';
6
- import { CORRELATION_REGISTERED_EVENT, CORRELATION_PRIMARY_CONFLICT_EVENT, parseRunnerArtifacts, parseRunnerResult, } from '../domain/schema.js';
6
+ import { CORRELATION_REGISTERED_EVENT, CORRELATION_PRIMARY_CONFLICT_EVENT, PR_AUTO_MERGE_ENABLED_EVENT, PR_REVIEW_APPROVED_EVENT, PUBLISH_INTENT_REQUESTED_EVENT, RUN_CLAIMED_EVENT, RUN_COMPLETED_EVENT, } from '../domain/event-types.js';
7
+ import { parseRunnerArtifacts, parseRunnerResult } from '../domain/schema.js';
7
8
  import { maxConfiguredRunnerTimeoutMs, resolveRunnerRouting } from '../domain/runner-routing.js';
8
9
  import { awaitingApprovalRunnerSentinel, stageLabelForStage } from '../domain/stages.js';
9
10
  import { isMeaningfulRuntimeEvent } from '../domain/runtime-events.js';
@@ -184,7 +185,7 @@ export function createTickRunner(deps) {
184
185
  streamScope: 'work-item',
185
186
  direction: 'internal',
186
187
  sourceSystem: 'wake',
187
- sourceEventType: 'wake.run.completed',
188
+ sourceEventType: RUN_COMPLETED_EVENT,
188
189
  sourceRefs: {
189
190
  repo: input.projection.issue.repo,
190
191
  issueNumber: input.projection.issue.number,
@@ -214,7 +215,7 @@ export function createTickRunner(deps) {
214
215
  streamScope: 'work-item',
215
216
  direction: 'outbound',
216
217
  sourceSystem: 'wake',
217
- sourceEventType: 'wake.publish.intent.requested',
218
+ sourceEventType: PUBLISH_INTENT_REQUESTED_EVENT,
218
219
  sourceRefs: {
219
220
  repo: input.projection.issue.repo,
220
221
  issueNumber: input.projection.issue.number,
@@ -271,7 +272,7 @@ export function createTickRunner(deps) {
271
272
  streamScope: 'work-item',
272
273
  direction: 'internal',
273
274
  sourceSystem: 'wake',
274
- sourceEventType: 'wake.pr-review.approved',
275
+ sourceEventType: PR_REVIEW_APPROVED_EVENT,
275
276
  sourceRefs: {
276
277
  resourceUri: targetResourceUri,
277
278
  commentId: input.approvalResolution.triggeringCommentId,
@@ -295,7 +296,7 @@ export function createTickRunner(deps) {
295
296
  streamScope: 'work-item',
296
297
  direction: 'internal',
297
298
  sourceSystem: 'wake',
298
- sourceEventType: 'wake.pr-auto-merge.enabled',
299
+ sourceEventType: PR_AUTO_MERGE_ENABLED_EVENT,
299
300
  sourceRefs: {
300
301
  resourceUri: targetResourceUri,
301
302
  commentId: input.approvalResolution.triggeringCommentId,
@@ -493,7 +494,7 @@ export function createTickRunner(deps) {
493
494
  streamScope: 'work-item',
494
495
  direction: 'internal',
495
496
  sourceSystem: 'wake',
496
- sourceEventType: 'wake.run.completed',
497
+ sourceEventType: RUN_COMPLETED_EVENT,
497
498
  sourceRefs: {
498
499
  repo: projection.issue.repo,
499
500
  issueNumber: projection.issue.number,
@@ -914,7 +915,7 @@ export function createTickRunner(deps) {
914
915
  streamScope: 'work-item',
915
916
  direction: 'internal',
916
917
  sourceSystem: 'wake',
917
- sourceEventType: 'wake.run.completed',
918
+ sourceEventType: RUN_COMPLETED_EVENT,
918
919
  sourceRefs: {
919
920
  repo: candidate.issue.repo,
920
921
  issueNumber: candidate.issue.number,
@@ -1111,7 +1112,7 @@ export function createTickRunner(deps) {
1111
1112
  streamScope: 'work-item',
1112
1113
  direction: 'internal',
1113
1114
  sourceSystem: 'wake',
1114
- sourceEventType: 'wake.run.claimed',
1115
+ sourceEventType: RUN_CLAIMED_EVENT,
1115
1116
  sourceRefs: {
1116
1117
  repo: candidate.issue.repo,
1117
1118
  issueNumber: candidate.issue.number,
@@ -1492,7 +1493,7 @@ export function createTickRunner(deps) {
1492
1493
  streamScope: 'work-item',
1493
1494
  direction: 'internal',
1494
1495
  sourceSystem: 'wake',
1495
- sourceEventType: 'wake.run.completed',
1496
+ sourceEventType: RUN_COMPLETED_EVENT,
1496
1497
  sourceRefs: {
1497
1498
  repo: candidate.issue.repo,
1498
1499
  issueNumber: candidate.issue.number,
@@ -1630,7 +1631,7 @@ export function createTickRunner(deps) {
1630
1631
  streamScope: 'work-item',
1631
1632
  direction: 'internal',
1632
1633
  sourceSystem: 'wake',
1633
- sourceEventType: 'wake.run.completed',
1634
+ sourceEventType: RUN_COMPLETED_EVENT,
1634
1635
  sourceRefs: {
1635
1636
  repo: candidate.issue.repo,
1636
1637
  issueNumber: candidate.issue.number,
@@ -1,5 +1,6 @@
1
1
  import { rm } from 'node:fs/promises';
2
2
  import { isAbsolute, join, relative } from 'node:path';
3
+ import { WORKSPACE_CLEANED_EVENT, WORKSPACE_CLEANUP_FAILED_EVENT } from '../domain/event-types.js';
3
4
  import { createEventEnvelope } from '../lib/event-log.js';
4
5
  // Cleans up per-issue workspaces (and, unless retained, transcripts) once the
5
6
  // originating issue is closed. A cleanup failure is recorded as an event and
@@ -36,7 +37,7 @@ export function createWorkspaceCleanup(deps) {
36
37
  streamScope: 'work-item',
37
38
  direction: 'internal',
38
39
  sourceSystem: 'wake',
39
- sourceEventType: 'wake.workspace.cleanup-failed',
40
+ sourceEventType: WORKSPACE_CLEANUP_FAILED_EVENT,
40
41
  sourceRefs: {
41
42
  repo: projection.issue.repo,
42
43
  issueNumber: projection.issue.number,
@@ -58,7 +59,7 @@ export function createWorkspaceCleanup(deps) {
58
59
  streamScope: 'work-item',
59
60
  direction: 'internal',
60
61
  sourceSystem: 'wake',
61
- sourceEventType: 'wake.workspace.cleaned',
62
+ sourceEventType: WORKSPACE_CLEANED_EVENT,
62
63
  sourceRefs: {
63
64
  repo: projection.issue.repo,
64
65
  issueNumber: projection.issue.number,
@@ -0,0 +1,130 @@
1
+ export const AUTONOMOUS_DECISION_AUDIT_EVENT = 'wake.audit.autonomous-decision';
2
+ export const CORRELATION_PRIMARY_CONFLICT_EVENT = 'wake.correlation.primary-conflict';
3
+ export const CORRELATION_REGISTERED_EVENT = 'wake.correlation.registered';
4
+ export const CORRELATION_RETRACTED_EVENT = 'wake.correlation.retracted';
5
+ export const LABELS_REQUESTED_EVENT = 'wake.labels.requested';
6
+ export const PR_AUTO_MERGE_ENABLED_EVENT = 'wake.pr-auto-merge.enabled';
7
+ export const PR_REVIEW_APPROVED_EVENT = 'wake.pr-review.approved';
8
+ export const PUBLISH_CONFIRMED_EVENT = 'wake.publish.confirmed';
9
+ export const PUBLISH_FAILED_EVENT = 'wake.publish.failed';
10
+ export const PUBLISH_INTENT_REQUESTED_EVENT = 'wake.publish.intent.requested';
11
+ export const PUBLISH_SENT_UNCONFIRMED_EVENT = 'wake.publish.sent-unconfirmed';
12
+ export const RETRY_REQUESTED_EVENT = 'wake.retry.requested';
13
+ export const RUN_CLAIMED_EVENT = 'wake.run.claimed';
14
+ export const RUN_COMPLETED_EVENT = 'wake.run.completed';
15
+ export const WORKFLOW_SELECTED_EVENT = 'wake.workflow.selected';
16
+ export const WORK_ITEM_CREATED_EVENT = 'wake.workitem.created';
17
+ export const WORKSPACE_CLEANED_EVENT = 'wake.workspace.cleaned';
18
+ export const WORKSPACE_CLEANUP_FAILED_EVENT = 'wake.workspace.cleanup-failed';
19
+ export const wakeEventTypeValues = [
20
+ AUTONOMOUS_DECISION_AUDIT_EVENT,
21
+ CORRELATION_PRIMARY_CONFLICT_EVENT,
22
+ CORRELATION_REGISTERED_EVENT,
23
+ CORRELATION_RETRACTED_EVENT,
24
+ LABELS_REQUESTED_EVENT,
25
+ PR_AUTO_MERGE_ENABLED_EVENT,
26
+ PR_REVIEW_APPROVED_EVENT,
27
+ PUBLISH_CONFIRMED_EVENT,
28
+ PUBLISH_FAILED_EVENT,
29
+ PUBLISH_INTENT_REQUESTED_EVENT,
30
+ PUBLISH_SENT_UNCONFIRMED_EVENT,
31
+ RETRY_REQUESTED_EVENT,
32
+ RUN_CLAIMED_EVENT,
33
+ RUN_COMPLETED_EVENT,
34
+ WORKFLOW_SELECTED_EVENT,
35
+ WORK_ITEM_CREATED_EVENT,
36
+ WORKSPACE_CLEANED_EVENT,
37
+ WORKSPACE_CLEANUP_FAILED_EVENT,
38
+ ];
39
+ export const wakeEventTypeDefinitions = [
40
+ {
41
+ type: AUTONOMOUS_DECISION_AUDIT_EVENT,
42
+ description: 'Records an autonomous workflow decision and the inputs used to make it.',
43
+ payloadShape: '{ decisionType, workItemId, runId, workflowRevision, inputsConsidered, outcome, timestamp }',
44
+ },
45
+ {
46
+ type: CORRELATION_PRIMARY_CONFLICT_EVENT,
47
+ description: 'Warns that a requested primary resource correlation was downgraded because another work item already owns the resource.',
48
+ payloadShape: '{ resourceUri, incumbentWorkItemKey }',
49
+ },
50
+ {
51
+ type: CORRELATION_REGISTERED_EVENT,
52
+ description: 'Registers a resource URI as correlated to a work item.',
53
+ payloadShape: '{ resourceUri, role, relation, provenance, registeredBy? }',
54
+ },
55
+ {
56
+ type: CORRELATION_RETRACTED_EVENT,
57
+ description: 'Removes a resource URI correlation from a work item.',
58
+ payloadShape: '{ resourceUri }',
59
+ },
60
+ {
61
+ type: LABELS_REQUESTED_EVENT,
62
+ description: 'Requests outbound synchronization of Wake status, stage, and workflow labels.',
63
+ payloadShape: "{ statusLabel, stageLabel, workflowLabel, origin, idempotencyKey, deliveryState: 'PENDING' }",
64
+ },
65
+ {
66
+ type: PR_AUTO_MERGE_ENABLED_EVENT,
67
+ description: 'Records that Wake enabled auto-merge for an approved pull request.',
68
+ payloadShape: '{ idempotencyKey }',
69
+ },
70
+ {
71
+ type: PR_REVIEW_APPROVED_EVENT,
72
+ description: 'Records that Wake approved a pull request review after approval policy passed.',
73
+ payloadShape: '{ idempotencyKey }',
74
+ },
75
+ {
76
+ type: PUBLISH_CONFIRMED_EVENT,
77
+ description: 'Confirms that an outbound publish intent was delivered or intentionally suppressed.',
78
+ payloadShape: "{ intentEventId, idempotencyKey, deliveryState: 'CONFIRMED', ...sinkDetails }",
79
+ },
80
+ {
81
+ type: PUBLISH_FAILED_EVENT,
82
+ description: 'Records a failed outbound publish attempt for bounded retry.',
83
+ payloadShape: "{ intentEventId, intentEventType, idempotencyKey, deliveryState: 'PENDING', error }",
84
+ },
85
+ {
86
+ type: PUBLISH_INTENT_REQUESTED_EVENT,
87
+ description: 'Requests an outbound comment, reply, status update, question, or approval card.',
88
+ payloadShape: "{ kind, origin, body, action, sentinel, runId, idempotencyKey, deliveryState: 'PENDING', sessionId?, model?, cli?, duration?, tokens?, cost?, workspacePath?, failureRepeated?, previousFailureClass? }",
89
+ },
90
+ {
91
+ type: PUBLISH_SENT_UNCONFIRMED_EVENT,
92
+ description: 'Marks an outbound publish intent as sent before Wake has observed confirmation.',
93
+ payloadShape: "{ intentEventId, intentEventType, idempotencyKey, deliveryState: 'SENT_UNCONFIRMED' }",
94
+ },
95
+ {
96
+ type: RETRY_REQUESTED_EVENT,
97
+ description: 'Requests that a failed work item be retried.',
98
+ payloadShape: '{ requestedBy }',
99
+ },
100
+ {
101
+ type: RUN_CLAIMED_EVENT,
102
+ description: 'Records that Wake claimed a work item for an agent run.',
103
+ payloadShape: '{ action, priorStage, claimedStage?, sourceRevision, watcherRun?, watcherTrigger? }',
104
+ },
105
+ {
106
+ type: RUN_COMPLETED_EVENT,
107
+ description: 'Records the terminal result of an agent run or internal lifecycle transition.',
108
+ payloadShape: '{ action?, sentinel, nextStage?, runId, sessionId?, sessionCli?, workspacePath?, reason?, handledCommentId?, failureClass?, blockReason?, executionOutcome?, workflowOutcome?, watcherRun?, allowAutoApproval?, body? }',
109
+ },
110
+ {
111
+ type: WORKFLOW_SELECTED_EVENT,
112
+ description: 'Pins the workflow selected for a newly minted work item.',
113
+ payloadShape: '{ workflow, selectedFromEventId }',
114
+ },
115
+ {
116
+ type: WORK_ITEM_CREATED_EVENT,
117
+ description: 'Mints a Wake work item identity before resource correlation is registered.',
118
+ payloadShape: '{}',
119
+ },
120
+ {
121
+ type: WORKSPACE_CLEANED_EVENT,
122
+ description: 'Records successful cleanup of a closed issue workspace.',
123
+ payloadShape: '{ workspacePath }',
124
+ },
125
+ {
126
+ type: WORKSPACE_CLEANUP_FAILED_EVENT,
127
+ description: 'Records a workspace cleanup failure without aborting the cleanup sweep.',
128
+ payloadShape: '{ workspacePath, error }',
129
+ },
130
+ ];
@@ -7,6 +7,7 @@ import { runnerSentinelValues } from './stages.js';
7
7
  import { correlationProvenanceSchema, correlationRelationSchema, correlationRoleSchema, resourceUriSchema, } from './resource-uri.js';
8
8
  import { runtimeEventTypeValues } from './runtime-events.js';
9
9
  import { alwaysManualIgnoredLabels } from './manual-labels.js';
10
+ export { AUTONOMOUS_DECISION_AUDIT_EVENT, CORRELATION_PRIMARY_CONFLICT_EVENT, CORRELATION_REGISTERED_EVENT, CORRELATION_RETRACTED_EVENT, WORK_ITEM_CREATED_EVENT, } from './event-types.js';
10
11
  const isoTimestampSchema = z.string().datetime({ offset: true });
11
12
  const identifierSchema = z.string().min(1);
12
13
  export const reportedArtifactSchema = z.object({
@@ -225,12 +226,6 @@ export const eventEnvelopeSourceRefsSchema = z.object({
225
226
  // own locator grammar; this keeps that knowledge out of core/.
226
227
  parentResourceUri: resourceUriSchema.optional(),
227
228
  });
228
- /** Event type constants for the correlation registry (ADR 0001 §5). */
229
- export const WORK_ITEM_CREATED_EVENT = 'wake.workitem.created';
230
- export const CORRELATION_REGISTERED_EVENT = 'wake.correlation.registered';
231
- export const CORRELATION_RETRACTED_EVENT = 'wake.correlation.retracted';
232
- export const CORRELATION_PRIMARY_CONFLICT_EVENT = 'wake.correlation.primary-conflict';
233
- export const AUTONOMOUS_DECISION_AUDIT_EVENT = 'wake.audit.autonomous-decision';
234
229
  /**
235
230
  * Shared key for events whose resource failed mint qualification (spec D1').
236
231
  * Never a real work item: `readIssueState(UNRESOLVED_WORK_ITEM_KEY)` always
package/dist/src/main.js CHANGED
@@ -608,15 +608,8 @@ async function runTick(args) {
608
608
  console.error(details);
609
609
  }
610
610
  }
611
- async function runStart(args) {
612
- const runtime = await buildRuntime(args);
613
- await runtime.stateStore.assertStateHealthy();
614
- const runnerOverride = readFlagBeforeCommandTerminator('--runner', args);
615
- await runStartupPreflight(runtime.config, {
616
- ...(runnerOverride === undefined ? {} : { runnerOverride }),
617
- workspaceManager: runtime.workspaceManager,
618
- });
619
- const controlPlane = createControlPlane({
611
+ export function createResidentControlPlane(runtime) {
612
+ return createControlPlane({
620
613
  tickRunner: runtime.tickRunner,
621
614
  intervalMs: runtime.config.scheduler.intervalMs,
622
615
  maxIntervalMs: runtime.config.scheduler.maxIntervalMs,
@@ -638,6 +631,16 @@ async function runStart(args) {
638
631
  return readTickRequestId(runtime.stateStore.paths.tickRequestFile);
639
632
  },
640
633
  });
634
+ }
635
+ async function runStart(args) {
636
+ const runtime = await buildRuntime(args);
637
+ await runtime.stateStore.assertStateHealthy();
638
+ const runnerOverride = readFlagBeforeCommandTerminator('--runner', args);
639
+ await runStartupPreflight(runtime.config, {
640
+ ...(runnerOverride === undefined ? {} : { runnerOverride }),
641
+ workspaceManager: runtime.workspaceManager,
642
+ });
643
+ const controlPlane = createResidentControlPlane(runtime);
641
644
  const stop = () => controlPlane.stop();
642
645
  process.on('SIGINT', stop);
643
646
  process.on('SIGTERM', stop);
@@ -124,4 +124,4 @@ export function resolveWakeVersion(options = {}) {
124
124
  }
125
125
  return '0.1.0-dev';
126
126
  }
127
- export const wakeVersion = "g1785fe4";
127
+ export const wakeVersion = "g1a18fca";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {