@ai-dev-orchestrator/schemas 0.1.1

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 (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/artifacts/agreement-artifacts.d.ts +311 -0
  4. package/dist/artifacts/agreement-artifacts.js +48 -0
  5. package/dist/artifacts/artifact-dependency-graph.d.ts +775 -0
  6. package/dist/artifacts/artifact-dependency-graph.js +57 -0
  7. package/dist/artifacts/artifact-system.d.ts +657 -0
  8. package/dist/artifacts/artifact-system.js +124 -0
  9. package/dist/artifacts/index.d.ts +3 -0
  10. package/dist/artifacts/index.js +3 -0
  11. package/dist/config/configuration.d.ts +324 -0
  12. package/dist/config/configuration.js +93 -0
  13. package/dist/config/event-bus-config.d.ts +153 -0
  14. package/dist/config/event-bus-config.js +27 -0
  15. package/dist/config/event-payloads.d.ts +919 -0
  16. package/dist/config/event-payloads.js +304 -0
  17. package/dist/config/event-system.d.ts +3231 -0
  18. package/dist/config/event-system.js +428 -0
  19. package/dist/config/event-types.d.ts +62 -0
  20. package/dist/config/event-types.js +66 -0
  21. package/dist/config/index.d.ts +5 -0
  22. package/dist/config/index.js +5 -0
  23. package/dist/dashboard/dashboard-api.d.ts +149 -0
  24. package/dist/dashboard/dashboard-api.js +80 -0
  25. package/dist/dashboard/dashboard-domain.d.ts +1076 -0
  26. package/dist/dashboard/dashboard-domain.js +305 -0
  27. package/dist/dashboard/index.d.ts +3 -0
  28. package/dist/dashboard/index.js +3 -0
  29. package/dist/dashboard/run-creation-params.d.ts +111 -0
  30. package/dist/dashboard/run-creation-params.js +14 -0
  31. package/dist/governance/governance.d.ts +1119 -0
  32. package/dist/governance/governance.js +111 -0
  33. package/dist/governance/index.d.ts +3 -0
  34. package/dist/governance/index.js +3 -0
  35. package/dist/governance/policy-engine.d.ts +634 -0
  36. package/dist/governance/policy-engine.js +214 -0
  37. package/dist/governance/review-resolution.d.ts +1053 -0
  38. package/dist/governance/review-resolution.js +67 -0
  39. package/dist/index.d.ts +10 -0
  40. package/dist/index.js +10 -0
  41. package/dist/observability/diagnostics.d.ts +185 -0
  42. package/dist/observability/diagnostics.js +63 -0
  43. package/dist/observability/index.d.ts +2 -0
  44. package/dist/observability/index.js +2 -0
  45. package/dist/observability/metrics.d.ts +187 -0
  46. package/dist/observability/metrics.js +67 -0
  47. package/dist/persistence/execution-analytics.d.ts +173 -0
  48. package/dist/persistence/execution-analytics.js +71 -0
  49. package/dist/persistence/index.d.ts +5 -0
  50. package/dist/persistence/index.js +5 -0
  51. package/dist/persistence/project-context.d.ts +164 -0
  52. package/dist/persistence/project-context.js +88 -0
  53. package/dist/persistence/repository-model.d.ts +27 -0
  54. package/dist/persistence/repository-model.js +16 -0
  55. package/dist/persistence/run-manifest.d.ts +422 -0
  56. package/dist/persistence/run-manifest.js +118 -0
  57. package/dist/persistence/state-persistence.d.ts +276 -0
  58. package/dist/persistence/state-persistence.js +83 -0
  59. package/dist/runner/built-in-runner-ids.d.ts +8 -0
  60. package/dist/runner/built-in-runner-ids.js +11 -0
  61. package/dist/runner/collaboration-model.d.ts +100 -0
  62. package/dist/runner/collaboration-model.js +19 -0
  63. package/dist/runner/confidence.d.ts +17 -0
  64. package/dist/runner/confidence.js +11 -0
  65. package/dist/runner/index.d.ts +8 -0
  66. package/dist/runner/index.js +8 -0
  67. package/dist/runner/permission-approval.d.ts +38 -0
  68. package/dist/runner/permission-approval.js +14 -0
  69. package/dist/runner/prompt-engine.d.ts +1467 -0
  70. package/dist/runner/prompt-engine.js +193 -0
  71. package/dist/runner/role-system.d.ts +458 -0
  72. package/dist/runner/role-system.js +94 -0
  73. package/dist/runner/runner-system.d.ts +1721 -0
  74. package/dist/runner/runner-system.js +268 -0
  75. package/dist/runner/task-brief.d.ts +18 -0
  76. package/dist/runner/task-brief.js +12 -0
  77. package/dist/shared/index.d.ts +3 -0
  78. package/dist/shared/index.js +3 -0
  79. package/dist/shared/shared.d.ts +30 -0
  80. package/dist/shared/shared.js +27 -0
  81. package/dist/shared/string-enums.d.ts +59 -0
  82. package/dist/shared/string-enums.js +24 -0
  83. package/dist/shared/utils.d.ts +25 -0
  84. package/dist/shared/utils.js +22 -0
  85. package/dist/specification/canonical-specification.d.ts +475 -0
  86. package/dist/specification/canonical-specification.js +151 -0
  87. package/dist/specification/index.d.ts +3 -0
  88. package/dist/specification/index.js +3 -0
  89. package/dist/specification/intake.d.ts +419 -0
  90. package/dist/specification/intake.js +70 -0
  91. package/dist/specification/iteration-contracts.d.ts +421 -0
  92. package/dist/specification/iteration-contracts.js +61 -0
  93. package/dist/workflow/index.d.ts +4 -0
  94. package/dist/workflow/index.js +4 -0
  95. package/dist/workflow/workflow-dsl.d.ts +81 -0
  96. package/dist/workflow/workflow-dsl.js +38 -0
  97. package/dist/workflow/workflow-engine.d.ts +5788 -0
  98. package/dist/workflow/workflow-engine.js +414 -0
  99. package/dist/workflow/workflow-file.d.ts +331 -0
  100. package/dist/workflow/workflow-file.js +41 -0
  101. package/dist/workflow/workflow-journal.d.ts +520 -0
  102. package/dist/workflow/workflow-journal.js +151 -0
  103. package/package.json +39 -0
@@ -0,0 +1,520 @@
1
+ import { z } from 'zod/v4';
2
+ export declare const JOURNAL_EVENT_TYPES: readonly ["run_started", "run_completed", "run_failed", "run_aborted", "run_resumed", "state_transition", "worker_dispatched", "worker_completed", "worker_failed", "worker_retried", "script_started", "script_completed", "artifact_stored", "artifact_staleness_detected", "governance_decision", "agreement_produced", "escalation", "finding_raised", "finding_resolved", "human_input_requested", "human_input_received", "human_approval", "human_rejection", "error", "model_escalation"];
3
+ export declare const journalEventTypeSchema: z.ZodEnum<{
4
+ error: "error";
5
+ escalation: "escalation";
6
+ run_started: "run_started";
7
+ run_completed: "run_completed";
8
+ run_failed: "run_failed";
9
+ run_aborted: "run_aborted";
10
+ run_resumed: "run_resumed";
11
+ state_transition: "state_transition";
12
+ worker_dispatched: "worker_dispatched";
13
+ worker_completed: "worker_completed";
14
+ worker_failed: "worker_failed";
15
+ worker_retried: "worker_retried";
16
+ script_started: "script_started";
17
+ script_completed: "script_completed";
18
+ artifact_stored: "artifact_stored";
19
+ artifact_staleness_detected: "artifact_staleness_detected";
20
+ governance_decision: "governance_decision";
21
+ agreement_produced: "agreement_produced";
22
+ finding_raised: "finding_raised";
23
+ finding_resolved: "finding_resolved";
24
+ human_input_requested: "human_input_requested";
25
+ human_input_received: "human_input_received";
26
+ human_approval: "human_approval";
27
+ human_rejection: "human_rejection";
28
+ model_escalation: "model_escalation";
29
+ }>;
30
+ export type JournalEventType = z.infer<typeof journalEventTypeSchema>;
31
+ export declare const runLifecycleDataSchema: z.ZodObject<{
32
+ kind: z.ZodLiteral<"run_lifecycle">;
33
+ workflowName: z.ZodString;
34
+ workflowVersion: z.ZodString;
35
+ status: z.ZodOptional<z.ZodString>;
36
+ reason: z.ZodOptional<z.ZodString>;
37
+ finalState: z.ZodOptional<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export type RunLifecycleData = z.infer<typeof runLifecycleDataSchema>;
40
+ export declare const stateTransitionDataSchema: z.ZodObject<{
41
+ kind: z.ZodLiteral<"state_transition">;
42
+ from: z.ZodString;
43
+ to: z.ZodString;
44
+ trigger: z.ZodEnum<{
45
+ timeout: "timeout";
46
+ failure: "failure";
47
+ completion: "completion";
48
+ review_approved: "review_approved";
49
+ review_rejected: "review_rejected";
50
+ iteration_exhausted: "iteration_exhausted";
51
+ judge_approved: "judge_approved";
52
+ judge_rejected: "judge_rejected";
53
+ escalation: "escalation";
54
+ human_input: "human_input";
55
+ human_approved: "human_approved";
56
+ human_rejected: "human_rejected";
57
+ }>;
58
+ durationMs: z.ZodNumber;
59
+ guardsEvaluated: z.ZodNumber;
60
+ guardsPassed: z.ZodNumber;
61
+ governanceRequired: z.ZodBoolean;
62
+ governanceOutcome: z.ZodOptional<z.ZodEnum<{
63
+ allowed: "allowed";
64
+ denied: "denied";
65
+ escalated: "escalated";
66
+ }>>;
67
+ contractId: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>;
69
+ export type StateTransitionData = z.infer<typeof stateTransitionDataSchema>;
70
+ export declare const workerEventDataSchema: z.ZodObject<{
71
+ kind: z.ZodLiteral<"worker">;
72
+ workerId: z.ZodString;
73
+ role: z.ZodString;
74
+ stateId: z.ZodString;
75
+ status: z.ZodString;
76
+ inputTokens: z.ZodOptional<z.ZodNumber>;
77
+ outputTokens: z.ZodOptional<z.ZodNumber>;
78
+ durationMs: z.ZodOptional<z.ZodNumber>;
79
+ error: z.ZodOptional<z.ZodString>;
80
+ retryCount: z.ZodOptional<z.ZodNumber>;
81
+ outputArtifacts: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
82
+ type: z.ZodEnum<{
83
+ intake_requirements: "intake_requirements";
84
+ canonical_specification: "canonical_specification";
85
+ clarification_questions: "clarification_questions";
86
+ clarification_answers: "clarification_answers";
87
+ plan: "plan";
88
+ plan_review: "plan_review";
89
+ test_plan: "test_plan";
90
+ implementation: "implementation";
91
+ static_review: "static_review";
92
+ security_review: "security_review";
93
+ performance_review: "performance_review";
94
+ adversarial_review: "adversarial_review";
95
+ design_review: "design_review";
96
+ docs_review: "docs_review";
97
+ ux_review: "ux_review";
98
+ review_report: "review_report";
99
+ remediation_plan: "remediation_plan";
100
+ verification: "verification";
101
+ judge_decision: "judge_decision";
102
+ planning_agreement: "planning_agreement";
103
+ implementation_agreement: "implementation_agreement";
104
+ verification_agreement: "verification_agreement";
105
+ release_summary: "release_summary";
106
+ release_agreement: "release_agreement";
107
+ escalation_context: "escalation_context";
108
+ run_manifest: "run_manifest";
109
+ codebase_context: "codebase_context";
110
+ test_suite: "test_suite";
111
+ acceptance_validation: "acceptance_validation";
112
+ review_findings: "review_findings";
113
+ task_breakdown: "task_breakdown";
114
+ decomposition_review: "decomposition_review";
115
+ task_specifications: "task_specifications";
116
+ pr_diff_context: "pr_diff_context";
117
+ }>;
118
+ name: z.ZodString;
119
+ version: z.ZodNumber;
120
+ checksum: z.ZodString;
121
+ }, z.core.$strip>>>>;
122
+ }, z.core.$strip>;
123
+ export type WorkerEventData = z.infer<typeof workerEventDataSchema>;
124
+ export declare const artifactEventDataSchema: z.ZodObject<{
125
+ kind: z.ZodLiteral<"artifact">;
126
+ artifactRef: z.ZodObject<{
127
+ type: z.ZodEnum<{
128
+ intake_requirements: "intake_requirements";
129
+ canonical_specification: "canonical_specification";
130
+ clarification_questions: "clarification_questions";
131
+ clarification_answers: "clarification_answers";
132
+ plan: "plan";
133
+ plan_review: "plan_review";
134
+ test_plan: "test_plan";
135
+ implementation: "implementation";
136
+ static_review: "static_review";
137
+ security_review: "security_review";
138
+ performance_review: "performance_review";
139
+ adversarial_review: "adversarial_review";
140
+ design_review: "design_review";
141
+ docs_review: "docs_review";
142
+ ux_review: "ux_review";
143
+ review_report: "review_report";
144
+ remediation_plan: "remediation_plan";
145
+ verification: "verification";
146
+ judge_decision: "judge_decision";
147
+ planning_agreement: "planning_agreement";
148
+ implementation_agreement: "implementation_agreement";
149
+ verification_agreement: "verification_agreement";
150
+ release_summary: "release_summary";
151
+ release_agreement: "release_agreement";
152
+ escalation_context: "escalation_context";
153
+ run_manifest: "run_manifest";
154
+ codebase_context: "codebase_context";
155
+ test_suite: "test_suite";
156
+ acceptance_validation: "acceptance_validation";
157
+ review_findings: "review_findings";
158
+ task_breakdown: "task_breakdown";
159
+ decomposition_review: "decomposition_review";
160
+ task_specifications: "task_specifications";
161
+ pr_diff_context: "pr_diff_context";
162
+ }>;
163
+ name: z.ZodString;
164
+ version: z.ZodNumber;
165
+ checksum: z.ZodString;
166
+ }, z.core.$strip>;
167
+ producedBy: z.ZodString;
168
+ sizeBytes: z.ZodNumber;
169
+ }, z.core.$strip>;
170
+ export type ArtifactEventData = z.infer<typeof artifactEventDataSchema>;
171
+ export declare const governanceEventDataSchema: z.ZodObject<{
172
+ kind: z.ZodLiteral<"governance">;
173
+ outcome: z.ZodEnum<{
174
+ allowed: "allowed";
175
+ denied: "denied";
176
+ escalated: "escalated";
177
+ }>;
178
+ reason: z.ZodString;
179
+ transitionFrom: z.ZodOptional<z.ZodString>;
180
+ transitionTo: z.ZodOptional<z.ZodString>;
181
+ policiesEvaluated: z.ZodOptional<z.ZodNumber>;
182
+ agreementType: z.ZodOptional<z.ZodString>;
183
+ escalationReason: z.ZodOptional<z.ZodEnum<{
184
+ iteration_limit_exceeded: "iteration_limit_exceeded";
185
+ quality_gate_failed: "quality_gate_failed";
186
+ unresolvable_conflict: "unresolvable_conflict";
187
+ human_requested: "human_requested";
188
+ token_budget_exceeded: "token_budget_exceeded";
189
+ retry_limit_exceeded: "retry_limit_exceeded";
190
+ confidence_too_low: "confidence_too_low";
191
+ }>>;
192
+ }, z.core.$strip>;
193
+ export type GovernanceEventData = z.infer<typeof governanceEventDataSchema>;
194
+ export declare const findingEventDataSchema: z.ZodObject<{
195
+ kind: z.ZodLiteral<"finding">;
196
+ findingId: z.ZodString;
197
+ severity: z.ZodString;
198
+ status: z.ZodString;
199
+ title: z.ZodString;
200
+ blocking: z.ZodString;
201
+ resolvedBy: z.ZodOptional<z.ZodString>;
202
+ }, z.core.$strip>;
203
+ export type FindingEventData = z.infer<typeof findingEventDataSchema>;
204
+ export declare const humanEventDataSchema: z.ZodObject<{
205
+ kind: z.ZodLiteral<"human">;
206
+ action: z.ZodString;
207
+ stateId: z.ZodString;
208
+ reason: z.ZodOptional<z.ZodString>;
209
+ inputType: z.ZodOptional<z.ZodString>;
210
+ approvedBy: z.ZodOptional<z.ZodString>;
211
+ sessionId: z.ZodOptional<z.ZodString>;
212
+ }, z.core.$strip>;
213
+ export type HumanEventData = z.infer<typeof humanEventDataSchema>;
214
+ export declare const errorDataSchema: z.ZodObject<{
215
+ kind: z.ZodLiteral<"error">;
216
+ errorCode: z.ZodString;
217
+ message: z.ZodString;
218
+ stateId: z.ZodOptional<z.ZodString>;
219
+ recoverable: z.ZodBoolean;
220
+ }, z.core.$strip>;
221
+ export type ErrorData = z.infer<typeof errorDataSchema>;
222
+ export declare const artifactStalenessDataSchema: z.ZodObject<{
223
+ kind: z.ZodLiteral<"artifact_staleness">;
224
+ trigger: z.ZodString;
225
+ staleCount: z.ZodNumber;
226
+ rebuildOrder: z.ZodReadonly<z.ZodArray<z.ZodString>>;
227
+ }, z.core.$strip>;
228
+ export type ArtifactStalenessData = z.infer<typeof artifactStalenessDataSchema>;
229
+ export declare const modelEscalationDataSchema: z.ZodObject<{
230
+ kind: z.ZodLiteral<"model_escalation">;
231
+ fromModel: z.ZodString;
232
+ toModel: z.ZodString;
233
+ roleId: z.ZodString;
234
+ confidenceScore: z.ZodNumber;
235
+ heuristicScore: z.ZodNumber;
236
+ finalScore: z.ZodNumber;
237
+ }, z.core.$strip>;
238
+ export type ModelEscalationData = z.infer<typeof modelEscalationDataSchema>;
239
+ export declare const scriptEventDataSchema: z.ZodObject<{
240
+ kind: z.ZodLiteral<"script">;
241
+ script: z.ZodString;
242
+ stateId: z.ZodString;
243
+ exitCode: z.ZodOptional<z.ZodNumber>;
244
+ durationMs: z.ZodOptional<z.ZodNumber>;
245
+ stdout: z.ZodOptional<z.ZodString>;
246
+ stderr: z.ZodOptional<z.ZodString>;
247
+ success: z.ZodOptional<z.ZodBoolean>;
248
+ }, z.core.$strip>;
249
+ export type ScriptEventData = z.infer<typeof scriptEventDataSchema>;
250
+ export declare const journalEventDataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
251
+ kind: z.ZodLiteral<"run_lifecycle">;
252
+ workflowName: z.ZodString;
253
+ workflowVersion: z.ZodString;
254
+ status: z.ZodOptional<z.ZodString>;
255
+ reason: z.ZodOptional<z.ZodString>;
256
+ finalState: z.ZodOptional<z.ZodString>;
257
+ }, z.core.$strip>, z.ZodObject<{
258
+ kind: z.ZodLiteral<"state_transition">;
259
+ from: z.ZodString;
260
+ to: z.ZodString;
261
+ trigger: z.ZodEnum<{
262
+ timeout: "timeout";
263
+ failure: "failure";
264
+ completion: "completion";
265
+ review_approved: "review_approved";
266
+ review_rejected: "review_rejected";
267
+ iteration_exhausted: "iteration_exhausted";
268
+ judge_approved: "judge_approved";
269
+ judge_rejected: "judge_rejected";
270
+ escalation: "escalation";
271
+ human_input: "human_input";
272
+ human_approved: "human_approved";
273
+ human_rejected: "human_rejected";
274
+ }>;
275
+ durationMs: z.ZodNumber;
276
+ guardsEvaluated: z.ZodNumber;
277
+ guardsPassed: z.ZodNumber;
278
+ governanceRequired: z.ZodBoolean;
279
+ governanceOutcome: z.ZodOptional<z.ZodEnum<{
280
+ allowed: "allowed";
281
+ denied: "denied";
282
+ escalated: "escalated";
283
+ }>>;
284
+ contractId: z.ZodOptional<z.ZodString>;
285
+ }, z.core.$strip>, z.ZodObject<{
286
+ kind: z.ZodLiteral<"worker">;
287
+ workerId: z.ZodString;
288
+ role: z.ZodString;
289
+ stateId: z.ZodString;
290
+ status: z.ZodString;
291
+ inputTokens: z.ZodOptional<z.ZodNumber>;
292
+ outputTokens: z.ZodOptional<z.ZodNumber>;
293
+ durationMs: z.ZodOptional<z.ZodNumber>;
294
+ error: z.ZodOptional<z.ZodString>;
295
+ retryCount: z.ZodOptional<z.ZodNumber>;
296
+ outputArtifacts: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
297
+ type: z.ZodEnum<{
298
+ intake_requirements: "intake_requirements";
299
+ canonical_specification: "canonical_specification";
300
+ clarification_questions: "clarification_questions";
301
+ clarification_answers: "clarification_answers";
302
+ plan: "plan";
303
+ plan_review: "plan_review";
304
+ test_plan: "test_plan";
305
+ implementation: "implementation";
306
+ static_review: "static_review";
307
+ security_review: "security_review";
308
+ performance_review: "performance_review";
309
+ adversarial_review: "adversarial_review";
310
+ design_review: "design_review";
311
+ docs_review: "docs_review";
312
+ ux_review: "ux_review";
313
+ review_report: "review_report";
314
+ remediation_plan: "remediation_plan";
315
+ verification: "verification";
316
+ judge_decision: "judge_decision";
317
+ planning_agreement: "planning_agreement";
318
+ implementation_agreement: "implementation_agreement";
319
+ verification_agreement: "verification_agreement";
320
+ release_summary: "release_summary";
321
+ release_agreement: "release_agreement";
322
+ escalation_context: "escalation_context";
323
+ run_manifest: "run_manifest";
324
+ codebase_context: "codebase_context";
325
+ test_suite: "test_suite";
326
+ acceptance_validation: "acceptance_validation";
327
+ review_findings: "review_findings";
328
+ task_breakdown: "task_breakdown";
329
+ decomposition_review: "decomposition_review";
330
+ task_specifications: "task_specifications";
331
+ pr_diff_context: "pr_diff_context";
332
+ }>;
333
+ name: z.ZodString;
334
+ version: z.ZodNumber;
335
+ checksum: z.ZodString;
336
+ }, z.core.$strip>>>>;
337
+ }, z.core.$strip>, z.ZodObject<{
338
+ kind: z.ZodLiteral<"artifact">;
339
+ artifactRef: z.ZodObject<{
340
+ type: z.ZodEnum<{
341
+ intake_requirements: "intake_requirements";
342
+ canonical_specification: "canonical_specification";
343
+ clarification_questions: "clarification_questions";
344
+ clarification_answers: "clarification_answers";
345
+ plan: "plan";
346
+ plan_review: "plan_review";
347
+ test_plan: "test_plan";
348
+ implementation: "implementation";
349
+ static_review: "static_review";
350
+ security_review: "security_review";
351
+ performance_review: "performance_review";
352
+ adversarial_review: "adversarial_review";
353
+ design_review: "design_review";
354
+ docs_review: "docs_review";
355
+ ux_review: "ux_review";
356
+ review_report: "review_report";
357
+ remediation_plan: "remediation_plan";
358
+ verification: "verification";
359
+ judge_decision: "judge_decision";
360
+ planning_agreement: "planning_agreement";
361
+ implementation_agreement: "implementation_agreement";
362
+ verification_agreement: "verification_agreement";
363
+ release_summary: "release_summary";
364
+ release_agreement: "release_agreement";
365
+ escalation_context: "escalation_context";
366
+ run_manifest: "run_manifest";
367
+ codebase_context: "codebase_context";
368
+ test_suite: "test_suite";
369
+ acceptance_validation: "acceptance_validation";
370
+ review_findings: "review_findings";
371
+ task_breakdown: "task_breakdown";
372
+ decomposition_review: "decomposition_review";
373
+ task_specifications: "task_specifications";
374
+ pr_diff_context: "pr_diff_context";
375
+ }>;
376
+ name: z.ZodString;
377
+ version: z.ZodNumber;
378
+ checksum: z.ZodString;
379
+ }, z.core.$strip>;
380
+ producedBy: z.ZodString;
381
+ sizeBytes: z.ZodNumber;
382
+ }, z.core.$strip>, z.ZodObject<{
383
+ kind: z.ZodLiteral<"governance">;
384
+ outcome: z.ZodEnum<{
385
+ allowed: "allowed";
386
+ denied: "denied";
387
+ escalated: "escalated";
388
+ }>;
389
+ reason: z.ZodString;
390
+ transitionFrom: z.ZodOptional<z.ZodString>;
391
+ transitionTo: z.ZodOptional<z.ZodString>;
392
+ policiesEvaluated: z.ZodOptional<z.ZodNumber>;
393
+ agreementType: z.ZodOptional<z.ZodString>;
394
+ escalationReason: z.ZodOptional<z.ZodEnum<{
395
+ iteration_limit_exceeded: "iteration_limit_exceeded";
396
+ quality_gate_failed: "quality_gate_failed";
397
+ unresolvable_conflict: "unresolvable_conflict";
398
+ human_requested: "human_requested";
399
+ token_budget_exceeded: "token_budget_exceeded";
400
+ retry_limit_exceeded: "retry_limit_exceeded";
401
+ confidence_too_low: "confidence_too_low";
402
+ }>>;
403
+ }, z.core.$strip>, z.ZodObject<{
404
+ kind: z.ZodLiteral<"finding">;
405
+ findingId: z.ZodString;
406
+ severity: z.ZodString;
407
+ status: z.ZodString;
408
+ title: z.ZodString;
409
+ blocking: z.ZodString;
410
+ resolvedBy: z.ZodOptional<z.ZodString>;
411
+ }, z.core.$strip>, z.ZodObject<{
412
+ kind: z.ZodLiteral<"human">;
413
+ action: z.ZodString;
414
+ stateId: z.ZodString;
415
+ reason: z.ZodOptional<z.ZodString>;
416
+ inputType: z.ZodOptional<z.ZodString>;
417
+ approvedBy: z.ZodOptional<z.ZodString>;
418
+ sessionId: z.ZodOptional<z.ZodString>;
419
+ }, z.core.$strip>, z.ZodObject<{
420
+ kind: z.ZodLiteral<"error">;
421
+ errorCode: z.ZodString;
422
+ message: z.ZodString;
423
+ stateId: z.ZodOptional<z.ZodString>;
424
+ recoverable: z.ZodBoolean;
425
+ }, z.core.$strip>, z.ZodObject<{
426
+ kind: z.ZodLiteral<"artifact_staleness">;
427
+ trigger: z.ZodString;
428
+ staleCount: z.ZodNumber;
429
+ rebuildOrder: z.ZodReadonly<z.ZodArray<z.ZodString>>;
430
+ }, z.core.$strip>, z.ZodObject<{
431
+ kind: z.ZodLiteral<"script">;
432
+ script: z.ZodString;
433
+ stateId: z.ZodString;
434
+ exitCode: z.ZodOptional<z.ZodNumber>;
435
+ durationMs: z.ZodOptional<z.ZodNumber>;
436
+ stdout: z.ZodOptional<z.ZodString>;
437
+ stderr: z.ZodOptional<z.ZodString>;
438
+ success: z.ZodOptional<z.ZodBoolean>;
439
+ }, z.core.$strip>, z.ZodObject<{
440
+ kind: z.ZodLiteral<"model_escalation">;
441
+ fromModel: z.ZodString;
442
+ toModel: z.ZodString;
443
+ roleId: z.ZodString;
444
+ confidenceScore: z.ZodNumber;
445
+ heuristicScore: z.ZodNumber;
446
+ finalScore: z.ZodNumber;
447
+ }, z.core.$strip>], "kind">;
448
+ export type JournalEventData = z.infer<typeof journalEventDataSchema>;
449
+ /** Mapped type -- cannot be expressed as Zod schema. */
450
+ export interface JournalEventMap {
451
+ run_started: RunLifecycleData;
452
+ run_completed: RunLifecycleData;
453
+ run_failed: RunLifecycleData;
454
+ run_aborted: RunLifecycleData;
455
+ run_resumed: RunLifecycleData;
456
+ state_transition: StateTransitionData;
457
+ worker_dispatched: WorkerEventData;
458
+ worker_completed: WorkerEventData;
459
+ worker_failed: WorkerEventData;
460
+ worker_retried: WorkerEventData;
461
+ script_started: ScriptEventData;
462
+ script_completed: ScriptEventData;
463
+ artifact_stored: ArtifactEventData;
464
+ artifact_staleness_detected: ArtifactStalenessData;
465
+ governance_decision: GovernanceEventData;
466
+ agreement_produced: GovernanceEventData;
467
+ escalation: GovernanceEventData;
468
+ finding_raised: FindingEventData;
469
+ finding_resolved: FindingEventData;
470
+ human_input_requested: HumanEventData;
471
+ human_input_received: HumanEventData;
472
+ human_approval: HumanEventData;
473
+ human_rejection: HumanEventData;
474
+ error: ErrorData;
475
+ model_escalation: ModelEscalationData;
476
+ }
477
+ /** Mapped type -- cannot be expressed as Zod schema. */
478
+ export type JournalEvent = {
479
+ [K in JournalEventType]: {
480
+ readonly timestamp: string;
481
+ readonly runId: string;
482
+ readonly sequence: number;
483
+ readonly type: K;
484
+ readonly data: JournalEventMap[K];
485
+ };
486
+ }[JournalEventType];
487
+ export declare const journalFilterSchema: z.ZodObject<{
488
+ eventType: z.ZodOptional<z.ZodEnum<{
489
+ error: "error";
490
+ escalation: "escalation";
491
+ run_started: "run_started";
492
+ run_completed: "run_completed";
493
+ run_failed: "run_failed";
494
+ run_aborted: "run_aborted";
495
+ run_resumed: "run_resumed";
496
+ state_transition: "state_transition";
497
+ worker_dispatched: "worker_dispatched";
498
+ worker_completed: "worker_completed";
499
+ worker_failed: "worker_failed";
500
+ worker_retried: "worker_retried";
501
+ script_started: "script_started";
502
+ script_completed: "script_completed";
503
+ artifact_stored: "artifact_stored";
504
+ artifact_staleness_detected: "artifact_staleness_detected";
505
+ governance_decision: "governance_decision";
506
+ agreement_produced: "agreement_produced";
507
+ finding_raised: "finding_raised";
508
+ finding_resolved: "finding_resolved";
509
+ human_input_requested: "human_input_requested";
510
+ human_input_received: "human_input_received";
511
+ human_approval: "human_approval";
512
+ human_rejection: "human_rejection";
513
+ model_escalation: "model_escalation";
514
+ }>>;
515
+ stateId: z.ZodOptional<z.ZodString>;
516
+ role: z.ZodOptional<z.ZodString>;
517
+ after: z.ZodOptional<z.ZodString>;
518
+ before: z.ZodOptional<z.ZodString>;
519
+ }, z.core.$strip>;
520
+ export type JournalFilter = z.infer<typeof journalFilterSchema>;
@@ -0,0 +1,151 @@
1
+ import { z } from 'zod/v4';
2
+ import { artifactRefSchema } from '../artifacts/artifact-system';
3
+ import { escalationReasonSchema, governanceOutcomeSchema } from '../governance/governance';
4
+ import { transitionTriggerSchema } from './workflow-engine';
5
+ export const JOURNAL_EVENT_TYPES = [
6
+ 'run_started',
7
+ 'run_completed',
8
+ 'run_failed',
9
+ 'run_aborted',
10
+ 'run_resumed',
11
+ 'state_transition',
12
+ 'worker_dispatched',
13
+ 'worker_completed',
14
+ 'worker_failed',
15
+ 'worker_retried',
16
+ 'script_started',
17
+ 'script_completed',
18
+ 'artifact_stored',
19
+ 'artifact_staleness_detected',
20
+ 'governance_decision',
21
+ 'agreement_produced',
22
+ 'escalation',
23
+ 'finding_raised',
24
+ 'finding_resolved',
25
+ 'human_input_requested',
26
+ 'human_input_received',
27
+ 'human_approval',
28
+ 'human_rejection',
29
+ 'error',
30
+ 'model_escalation',
31
+ ];
32
+ export const journalEventTypeSchema = z.enum(JOURNAL_EVENT_TYPES);
33
+ export const runLifecycleDataSchema = z.object({
34
+ kind: z.literal('run_lifecycle'),
35
+ workflowName: z.string(),
36
+ workflowVersion: z.string(),
37
+ status: z.string().optional(),
38
+ reason: z.string().optional(),
39
+ finalState: z.string().optional(),
40
+ });
41
+ export const stateTransitionDataSchema = z.object({
42
+ kind: z.literal('state_transition'),
43
+ from: z.string(),
44
+ to: z.string(),
45
+ trigger: transitionTriggerSchema,
46
+ durationMs: z.number(),
47
+ guardsEvaluated: z.number(),
48
+ guardsPassed: z.number(),
49
+ governanceRequired: z.boolean(),
50
+ governanceOutcome: governanceOutcomeSchema.optional(),
51
+ contractId: z.string().optional(),
52
+ });
53
+ export const workerEventDataSchema = z.object({
54
+ kind: z.literal('worker'),
55
+ workerId: z.string(),
56
+ role: z.string(),
57
+ stateId: z.string(),
58
+ status: z.string(),
59
+ inputTokens: z.number().optional(),
60
+ outputTokens: z.number().optional(),
61
+ durationMs: z.number().optional(),
62
+ error: z.string().optional(),
63
+ retryCount: z.number().optional(),
64
+ outputArtifacts: z.array(artifactRefSchema).readonly().optional(),
65
+ });
66
+ export const artifactEventDataSchema = z.object({
67
+ kind: z.literal('artifact'),
68
+ artifactRef: artifactRefSchema,
69
+ producedBy: z.string(),
70
+ sizeBytes: z.number(),
71
+ });
72
+ export const governanceEventDataSchema = z.object({
73
+ kind: z.literal('governance'),
74
+ outcome: governanceOutcomeSchema,
75
+ reason: z.string(),
76
+ transitionFrom: z.string().optional(),
77
+ transitionTo: z.string().optional(),
78
+ policiesEvaluated: z.number().optional(),
79
+ agreementType: z.string().optional(),
80
+ escalationReason: escalationReasonSchema.optional(),
81
+ });
82
+ export const findingEventDataSchema = z.object({
83
+ kind: z.literal('finding'),
84
+ findingId: z.string(),
85
+ severity: z.string(),
86
+ status: z.string(),
87
+ title: z.string(),
88
+ blocking: z.string(),
89
+ resolvedBy: z.string().optional(),
90
+ });
91
+ export const humanEventDataSchema = z.object({
92
+ kind: z.literal('human'),
93
+ action: z.string(),
94
+ stateId: z.string(),
95
+ reason: z.string().optional(),
96
+ inputType: z.string().optional(),
97
+ approvedBy: z.string().optional(),
98
+ sessionId: z.string().optional(),
99
+ });
100
+ export const errorDataSchema = z.object({
101
+ kind: z.literal('error'),
102
+ errorCode: z.string(),
103
+ message: z.string(),
104
+ stateId: z.string().optional(),
105
+ recoverable: z.boolean(),
106
+ });
107
+ export const artifactStalenessDataSchema = z.object({
108
+ kind: z.literal('artifact_staleness'),
109
+ trigger: z.string(),
110
+ staleCount: z.number(),
111
+ rebuildOrder: z.array(z.string()).readonly(),
112
+ });
113
+ export const modelEscalationDataSchema = z.object({
114
+ kind: z.literal('model_escalation'),
115
+ fromModel: z.string(),
116
+ toModel: z.string(),
117
+ roleId: z.string(),
118
+ confidenceScore: z.number().min(0).max(1),
119
+ heuristicScore: z.number().min(0).max(1),
120
+ finalScore: z.number().min(0).max(1),
121
+ });
122
+ export const scriptEventDataSchema = z.object({
123
+ kind: z.literal('script'),
124
+ script: z.string(),
125
+ stateId: z.string(),
126
+ exitCode: z.number().optional(),
127
+ durationMs: z.number().optional(),
128
+ stdout: z.string().optional(),
129
+ stderr: z.string().optional(),
130
+ success: z.boolean().optional(),
131
+ });
132
+ export const journalEventDataSchema = z.discriminatedUnion('kind', [
133
+ runLifecycleDataSchema,
134
+ stateTransitionDataSchema,
135
+ workerEventDataSchema,
136
+ artifactEventDataSchema,
137
+ governanceEventDataSchema,
138
+ findingEventDataSchema,
139
+ humanEventDataSchema,
140
+ errorDataSchema,
141
+ artifactStalenessDataSchema,
142
+ scriptEventDataSchema,
143
+ modelEscalationDataSchema,
144
+ ]);
145
+ export const journalFilterSchema = z.object({
146
+ eventType: journalEventTypeSchema.optional(),
147
+ stateId: z.string().optional(),
148
+ role: z.string().optional(),
149
+ after: z.string().optional(),
150
+ before: z.string().optional(),
151
+ });