@lumenflow/core 1.0.0

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 (263) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +119 -0
  3. package/dist/active-wu-detector.d.ts +33 -0
  4. package/dist/active-wu-detector.js +106 -0
  5. package/dist/adapters/filesystem-metrics.adapter.d.ts +108 -0
  6. package/dist/adapters/filesystem-metrics.adapter.js +519 -0
  7. package/dist/adapters/terminal-renderer.adapter.d.ts +106 -0
  8. package/dist/adapters/terminal-renderer.adapter.js +337 -0
  9. package/dist/arg-parser.d.ts +63 -0
  10. package/dist/arg-parser.js +560 -0
  11. package/dist/backlog-editor.d.ts +98 -0
  12. package/dist/backlog-editor.js +179 -0
  13. package/dist/backlog-generator.d.ts +111 -0
  14. package/dist/backlog-generator.js +381 -0
  15. package/dist/backlog-parser.d.ts +45 -0
  16. package/dist/backlog-parser.js +102 -0
  17. package/dist/backlog-sync-validator.d.ts +78 -0
  18. package/dist/backlog-sync-validator.js +294 -0
  19. package/dist/branch-drift.d.ts +34 -0
  20. package/dist/branch-drift.js +51 -0
  21. package/dist/cleanup-install-config.d.ts +33 -0
  22. package/dist/cleanup-install-config.js +37 -0
  23. package/dist/cleanup-lock.d.ts +139 -0
  24. package/dist/cleanup-lock.js +313 -0
  25. package/dist/code-path-validator.d.ts +146 -0
  26. package/dist/code-path-validator.js +537 -0
  27. package/dist/code-paths-overlap.d.ts +55 -0
  28. package/dist/code-paths-overlap.js +245 -0
  29. package/dist/commands-logger.d.ts +77 -0
  30. package/dist/commands-logger.js +254 -0
  31. package/dist/commit-message-utils.d.ts +25 -0
  32. package/dist/commit-message-utils.js +41 -0
  33. package/dist/compliance-parser.d.ts +150 -0
  34. package/dist/compliance-parser.js +507 -0
  35. package/dist/constants/backlog-patterns.d.ts +20 -0
  36. package/dist/constants/backlog-patterns.js +23 -0
  37. package/dist/constants/dora-constants.d.ts +49 -0
  38. package/dist/constants/dora-constants.js +53 -0
  39. package/dist/constants/gate-constants.d.ts +15 -0
  40. package/dist/constants/gate-constants.js +15 -0
  41. package/dist/constants/linter-constants.d.ts +16 -0
  42. package/dist/constants/linter-constants.js +16 -0
  43. package/dist/constants/tokenizer-constants.d.ts +15 -0
  44. package/dist/constants/tokenizer-constants.js +15 -0
  45. package/dist/core/scope-checker.d.ts +97 -0
  46. package/dist/core/scope-checker.js +163 -0
  47. package/dist/core/tool-runner.d.ts +161 -0
  48. package/dist/core/tool-runner.js +393 -0
  49. package/dist/core/tool.constants.d.ts +105 -0
  50. package/dist/core/tool.constants.js +101 -0
  51. package/dist/core/tool.schemas.d.ts +226 -0
  52. package/dist/core/tool.schemas.js +226 -0
  53. package/dist/core/worktree-guard.d.ts +130 -0
  54. package/dist/core/worktree-guard.js +242 -0
  55. package/dist/coverage-gate.d.ts +108 -0
  56. package/dist/coverage-gate.js +196 -0
  57. package/dist/date-utils.d.ts +75 -0
  58. package/dist/date-utils.js +140 -0
  59. package/dist/dependency-graph.d.ts +142 -0
  60. package/dist/dependency-graph.js +550 -0
  61. package/dist/dependency-guard.d.ts +54 -0
  62. package/dist/dependency-guard.js +142 -0
  63. package/dist/dependency-validator.d.ts +105 -0
  64. package/dist/dependency-validator.js +154 -0
  65. package/dist/docs-path-validator.d.ts +36 -0
  66. package/dist/docs-path-validator.js +95 -0
  67. package/dist/domain/orchestration.constants.d.ts +99 -0
  68. package/dist/domain/orchestration.constants.js +97 -0
  69. package/dist/domain/orchestration.schemas.d.ts +280 -0
  70. package/dist/domain/orchestration.schemas.js +211 -0
  71. package/dist/domain/orchestration.types.d.ts +133 -0
  72. package/dist/domain/orchestration.types.js +12 -0
  73. package/dist/error-handler.d.ts +116 -0
  74. package/dist/error-handler.js +136 -0
  75. package/dist/file-classifiers.d.ts +62 -0
  76. package/dist/file-classifiers.js +108 -0
  77. package/dist/gates-agent-mode.d.ts +81 -0
  78. package/dist/gates-agent-mode.js +94 -0
  79. package/dist/generate-traceability.d.ts +107 -0
  80. package/dist/generate-traceability.js +411 -0
  81. package/dist/git-adapter.d.ts +395 -0
  82. package/dist/git-adapter.js +649 -0
  83. package/dist/git-staged-validator.d.ts +32 -0
  84. package/dist/git-staged-validator.js +48 -0
  85. package/dist/hardcoded-strings.d.ts +61 -0
  86. package/dist/hardcoded-strings.js +270 -0
  87. package/dist/incremental-lint.d.ts +78 -0
  88. package/dist/incremental-lint.js +129 -0
  89. package/dist/incremental-test.d.ts +39 -0
  90. package/dist/incremental-test.js +61 -0
  91. package/dist/index.d.ts +42 -0
  92. package/dist/index.js +61 -0
  93. package/dist/invariants/check-automated-tests.d.ts +50 -0
  94. package/dist/invariants/check-automated-tests.js +166 -0
  95. package/dist/invariants-runner.d.ts +103 -0
  96. package/dist/invariants-runner.js +527 -0
  97. package/dist/lane-checker.d.ts +50 -0
  98. package/dist/lane-checker.js +319 -0
  99. package/dist/lane-inference.d.ts +39 -0
  100. package/dist/lane-inference.js +195 -0
  101. package/dist/lane-lock.d.ts +211 -0
  102. package/dist/lane-lock.js +474 -0
  103. package/dist/lane-validator.d.ts +48 -0
  104. package/dist/lane-validator.js +114 -0
  105. package/dist/logs-lib.d.ts +104 -0
  106. package/dist/logs-lib.js +207 -0
  107. package/dist/lumenflow-config-schema.d.ts +272 -0
  108. package/dist/lumenflow-config-schema.js +207 -0
  109. package/dist/lumenflow-config.d.ts +95 -0
  110. package/dist/lumenflow-config.js +236 -0
  111. package/dist/manual-test-validator.d.ts +80 -0
  112. package/dist/manual-test-validator.js +200 -0
  113. package/dist/merge-lock.d.ts +115 -0
  114. package/dist/merge-lock.js +251 -0
  115. package/dist/micro-worktree.d.ts +159 -0
  116. package/dist/micro-worktree.js +427 -0
  117. package/dist/migration-deployer.d.ts +69 -0
  118. package/dist/migration-deployer.js +151 -0
  119. package/dist/orchestration-advisory-loader.d.ts +28 -0
  120. package/dist/orchestration-advisory-loader.js +87 -0
  121. package/dist/orchestration-advisory.d.ts +58 -0
  122. package/dist/orchestration-advisory.js +94 -0
  123. package/dist/orchestration-di.d.ts +48 -0
  124. package/dist/orchestration-di.js +57 -0
  125. package/dist/orchestration-rules.d.ts +57 -0
  126. package/dist/orchestration-rules.js +201 -0
  127. package/dist/orphan-detector.d.ts +131 -0
  128. package/dist/orphan-detector.js +226 -0
  129. package/dist/path-classifiers.d.ts +57 -0
  130. package/dist/path-classifiers.js +93 -0
  131. package/dist/piped-command-detector.d.ts +34 -0
  132. package/dist/piped-command-detector.js +64 -0
  133. package/dist/ports/dashboard-renderer.port.d.ts +112 -0
  134. package/dist/ports/dashboard-renderer.port.js +25 -0
  135. package/dist/ports/metrics-collector.port.d.ts +132 -0
  136. package/dist/ports/metrics-collector.port.js +26 -0
  137. package/dist/process-detector.d.ts +84 -0
  138. package/dist/process-detector.js +172 -0
  139. package/dist/prompt-linter.d.ts +72 -0
  140. package/dist/prompt-linter.js +312 -0
  141. package/dist/prompt-monitor.d.ts +15 -0
  142. package/dist/prompt-monitor.js +205 -0
  143. package/dist/rebase-artifact-cleanup.d.ts +145 -0
  144. package/dist/rebase-artifact-cleanup.js +433 -0
  145. package/dist/retry-strategy.d.ts +189 -0
  146. package/dist/retry-strategy.js +283 -0
  147. package/dist/risk-detector.d.ts +108 -0
  148. package/dist/risk-detector.js +252 -0
  149. package/dist/rollback-utils.d.ts +76 -0
  150. package/dist/rollback-utils.js +104 -0
  151. package/dist/section-headings.d.ts +43 -0
  152. package/dist/section-headings.js +49 -0
  153. package/dist/spawn-escalation.d.ts +90 -0
  154. package/dist/spawn-escalation.js +253 -0
  155. package/dist/spawn-monitor.d.ts +229 -0
  156. package/dist/spawn-monitor.js +672 -0
  157. package/dist/spawn-recovery.d.ts +82 -0
  158. package/dist/spawn-recovery.js +298 -0
  159. package/dist/spawn-registry-schema.d.ts +98 -0
  160. package/dist/spawn-registry-schema.js +108 -0
  161. package/dist/spawn-registry-store.d.ts +146 -0
  162. package/dist/spawn-registry-store.js +273 -0
  163. package/dist/spawn-tree.d.ts +121 -0
  164. package/dist/spawn-tree.js +285 -0
  165. package/dist/stamp-status-validator.d.ts +84 -0
  166. package/dist/stamp-status-validator.js +134 -0
  167. package/dist/stamp-utils.d.ts +100 -0
  168. package/dist/stamp-utils.js +229 -0
  169. package/dist/state-machine.d.ts +26 -0
  170. package/dist/state-machine.js +83 -0
  171. package/dist/system-map-validator.d.ts +80 -0
  172. package/dist/system-map-validator.js +272 -0
  173. package/dist/telemetry.d.ts +80 -0
  174. package/dist/telemetry.js +213 -0
  175. package/dist/token-counter.d.ts +51 -0
  176. package/dist/token-counter.js +145 -0
  177. package/dist/usecases/get-dashboard-data.usecase.d.ts +52 -0
  178. package/dist/usecases/get-dashboard-data.usecase.js +61 -0
  179. package/dist/usecases/get-suggestions.usecase.d.ts +100 -0
  180. package/dist/usecases/get-suggestions.usecase.js +153 -0
  181. package/dist/user-normalizer.d.ts +41 -0
  182. package/dist/user-normalizer.js +141 -0
  183. package/dist/validators/phi-constants.d.ts +97 -0
  184. package/dist/validators/phi-constants.js +152 -0
  185. package/dist/validators/phi-scanner.d.ts +58 -0
  186. package/dist/validators/phi-scanner.js +215 -0
  187. package/dist/worktree-ownership.d.ts +50 -0
  188. package/dist/worktree-ownership.js +74 -0
  189. package/dist/worktree-scanner.d.ts +103 -0
  190. package/dist/worktree-scanner.js +168 -0
  191. package/dist/worktree-symlink.d.ts +99 -0
  192. package/dist/worktree-symlink.js +359 -0
  193. package/dist/wu-backlog-updater.d.ts +17 -0
  194. package/dist/wu-backlog-updater.js +37 -0
  195. package/dist/wu-checkpoint.d.ts +124 -0
  196. package/dist/wu-checkpoint.js +233 -0
  197. package/dist/wu-claim-helpers.d.ts +26 -0
  198. package/dist/wu-claim-helpers.js +63 -0
  199. package/dist/wu-claim-resume.d.ts +106 -0
  200. package/dist/wu-claim-resume.js +276 -0
  201. package/dist/wu-consistency-checker.d.ts +95 -0
  202. package/dist/wu-consistency-checker.js +567 -0
  203. package/dist/wu-constants.d.ts +1275 -0
  204. package/dist/wu-constants.js +1382 -0
  205. package/dist/wu-create-validators.d.ts +42 -0
  206. package/dist/wu-create-validators.js +93 -0
  207. package/dist/wu-done-branch-only.d.ts +63 -0
  208. package/dist/wu-done-branch-only.js +191 -0
  209. package/dist/wu-done-messages.d.ts +119 -0
  210. package/dist/wu-done-messages.js +185 -0
  211. package/dist/wu-done-pr.d.ts +72 -0
  212. package/dist/wu-done-pr.js +174 -0
  213. package/dist/wu-done-retry-helpers.d.ts +85 -0
  214. package/dist/wu-done-retry-helpers.js +172 -0
  215. package/dist/wu-done-ui.d.ts +37 -0
  216. package/dist/wu-done-ui.js +69 -0
  217. package/dist/wu-done-validators.d.ts +411 -0
  218. package/dist/wu-done-validators.js +1229 -0
  219. package/dist/wu-done-worktree.d.ts +182 -0
  220. package/dist/wu-done-worktree.js +1097 -0
  221. package/dist/wu-helpers.d.ts +128 -0
  222. package/dist/wu-helpers.js +248 -0
  223. package/dist/wu-lint.d.ts +70 -0
  224. package/dist/wu-lint.js +234 -0
  225. package/dist/wu-paths.d.ts +171 -0
  226. package/dist/wu-paths.js +178 -0
  227. package/dist/wu-preflight-validators.d.ts +86 -0
  228. package/dist/wu-preflight-validators.js +251 -0
  229. package/dist/wu-recovery.d.ts +138 -0
  230. package/dist/wu-recovery.js +341 -0
  231. package/dist/wu-repair-core.d.ts +131 -0
  232. package/dist/wu-repair-core.js +669 -0
  233. package/dist/wu-schema-normalization.d.ts +17 -0
  234. package/dist/wu-schema-normalization.js +82 -0
  235. package/dist/wu-schema.d.ts +793 -0
  236. package/dist/wu-schema.js +881 -0
  237. package/dist/wu-spawn-helpers.d.ts +121 -0
  238. package/dist/wu-spawn-helpers.js +271 -0
  239. package/dist/wu-spawn.d.ts +158 -0
  240. package/dist/wu-spawn.js +1306 -0
  241. package/dist/wu-state-schema.d.ts +213 -0
  242. package/dist/wu-state-schema.js +156 -0
  243. package/dist/wu-state-store.d.ts +264 -0
  244. package/dist/wu-state-store.js +691 -0
  245. package/dist/wu-status-transition.d.ts +63 -0
  246. package/dist/wu-status-transition.js +382 -0
  247. package/dist/wu-status-updater.d.ts +25 -0
  248. package/dist/wu-status-updater.js +116 -0
  249. package/dist/wu-transaction-collectors.d.ts +116 -0
  250. package/dist/wu-transaction-collectors.js +272 -0
  251. package/dist/wu-transaction.d.ts +170 -0
  252. package/dist/wu-transaction.js +273 -0
  253. package/dist/wu-validation-constants.d.ts +60 -0
  254. package/dist/wu-validation-constants.js +66 -0
  255. package/dist/wu-validation.d.ts +118 -0
  256. package/dist/wu-validation.js +243 -0
  257. package/dist/wu-validator.d.ts +62 -0
  258. package/dist/wu-validator.js +325 -0
  259. package/dist/wu-yaml-fixer.d.ts +97 -0
  260. package/dist/wu-yaml-fixer.js +264 -0
  261. package/dist/wu-yaml.d.ts +86 -0
  262. package/dist/wu-yaml.js +222 -0
  263. package/package.json +114 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Orchestration Domain Constants
3
+ *
4
+ * Centralised constants for the agent orchestration dashboard.
5
+ * Avoids magic numbers and hardcoded strings throughout the orchestration layer.
6
+ *
7
+ * @module orchestration.constants
8
+ * @see {@link ../ports/dashboard-renderer.port.mjs} - Uses these constants
9
+ * @see {@link ../ports/metrics-collector.port.mjs} - Uses these constants
10
+ */
11
+ /**
12
+ * Total number of Definition of Done checkpoints.
13
+ * Used by dashboard to show DoD progress (X/11).
14
+ */
15
+ export const DOD_TOTAL = 11;
16
+ /**
17
+ * Valid lane names in the LumenFlow system.
18
+ * Used for type-safe lane validation.
19
+ */
20
+ export const LANES = [
21
+ 'Intelligence',
22
+ 'Experience',
23
+ 'Core Systems',
24
+ 'Operations',
25
+ 'Discovery',
26
+ ];
27
+ /**
28
+ * Known agent names in the orchestration system.
29
+ * Includes both mandatory (Tier 1) and suggested (Tier 2) agents.
30
+ */
31
+ export const AGENT_NAMES = [
32
+ 'security-auditor',
33
+ 'beacon-guardian',
34
+ 'test-engineer',
35
+ 'code-reviewer',
36
+ ];
37
+ /**
38
+ * Alert severity levels for dashboard display.
39
+ * HIGH = action required immediately
40
+ * MEDIUM = action suggested
41
+ * LOW = informational
42
+ */
43
+ export const SEVERITY_LEVELS = ['high', 'medium', 'low'];
44
+ /**
45
+ * Default timeline window for dashboard display (hours).
46
+ */
47
+ export const TIMELINE_WINDOW_HOURS = 24;
48
+ /**
49
+ * Maximum alerts to display in dashboard.
50
+ */
51
+ export const MAX_ALERTS_DISPLAY = 10;
52
+ /**
53
+ * Agent result statuses for WU progress tracking.
54
+ */
55
+ export const AGENT_RESULT_STATUSES = ['pending', 'pass', 'fail', 'skipped'];
56
+ /**
57
+ * Timeline event types for orchestration history.
58
+ */
59
+ export const TIMELINE_EVENT_TYPES = ['claim', 'done', 'block', 'agent', 'gates'];
60
+ /**
61
+ * Event severity levels for timeline display.
62
+ */
63
+ export const EVENT_SEVERITY_LEVELS = ['info', 'warning', 'error'];
64
+ /**
65
+ * User choice options for execution plan confirmation.
66
+ */
67
+ export const USER_CHOICE_OPTIONS = ['approve', 'reject', 'edit'];
68
+ /**
69
+ * Mandatory agent names (subset of AGENT_NAMES)
70
+ */
71
+ export const MANDATORY_AGENT_NAMES = ['security-auditor', 'beacon-guardian'];
72
+ /**
73
+ * Mandatory agent triggers - glob patterns that indicate when agents must be invoked.
74
+ * Uses minimatch patterns (NOT regex) for file path matching.
75
+ *
76
+ * @example
77
+ * // Check if a path triggers security-auditor:
78
+ * import { minimatch } from 'minimatch';
79
+ * const triggers = MANDATORY_TRIGGERS['security-auditor'];
80
+ * const shouldTrigger = triggers.some(pattern => minimatch(filePath, pattern));
81
+ */
82
+ export const MANDATORY_TRIGGERS = {
83
+ 'security-auditor': ['supabase/migrations/**', '**/auth/**', '**/rls/**', '**/permissions/**'],
84
+ 'beacon-guardian': ['**/prompts/**', '**/classification/**', '**/detector/**', '**/llm/**'],
85
+ };
86
+ /**
87
+ * File system paths for metrics collection.
88
+ * Used by FileSystemMetricsCollector to avoid hardcoded strings.
89
+ */
90
+ export const FILESYSTEM_PATHS = {
91
+ WU_DIR: 'docs/04-operations/tasks/wu',
92
+ STATUS_FILE: 'docs/04-operations/tasks/status.md',
93
+ BACKLOG_FILE: 'docs/04-operations/tasks/backlog.md',
94
+ TELEMETRY_DIR: '.beacon/telemetry',
95
+ STAMPS_DIR: '.beacon/stamps',
96
+ SESSION_FILE: '.beacon/sessions/current.json',
97
+ };
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Orchestration Domain Schemas
3
+ *
4
+ * Zod schemas for runtime validation of orchestration domain types.
5
+ * Single source of truth - types are inferred from these schemas.
6
+ *
7
+ * @module orchestration.schemas
8
+ * @see {@link ./orchestration.types.mjs} - Types inferred from these schemas
9
+ * @see {@link ./orchestration.constants.mjs} - Constants used in validation
10
+ */
11
+ import { z } from 'zod';
12
+ /**
13
+ * Schema for global orchestration status.
14
+ * Shows high-level dashboard metrics at a glance.
15
+ */
16
+ export declare const GlobalStatusSchema: z.ZodObject<{
17
+ activeWUs: z.ZodNumber;
18
+ completed24h: z.ZodNumber;
19
+ blocked: z.ZodNumber;
20
+ gatesFailing: z.ZodNumber;
21
+ longestRunning: z.ZodNullable<z.ZodObject<{
22
+ wuId: z.ZodString;
23
+ lane: z.ZodEnum<{
24
+ Operations: "Operations";
25
+ Intelligence: "Intelligence";
26
+ Experience: "Experience";
27
+ "Core Systems": "Core Systems";
28
+ Discovery: "Discovery";
29
+ }>;
30
+ durationMs: z.ZodNumber;
31
+ }, z.core.$strip>>;
32
+ pendingMandatory: z.ZodArray<z.ZodObject<{
33
+ wuId: z.ZodString;
34
+ agent: z.ZodEnum<{
35
+ "security-auditor": "security-auditor";
36
+ "beacon-guardian": "beacon-guardian";
37
+ "test-engineer": "test-engineer";
38
+ "code-reviewer": "code-reviewer";
39
+ }>;
40
+ }, z.core.$strip>>;
41
+ activeSession: z.ZodNullable<z.ZodObject<{
42
+ sessionId: z.ZodString;
43
+ wuId: z.ZodString;
44
+ started: z.ZodString;
45
+ contextTier: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
46
+ incidentsLogged: z.ZodNumber;
47
+ }, z.core.$strip>>;
48
+ worktreesWithUncommittedChanges: z.ZodArray<z.ZodObject<{
49
+ wuId: z.ZodString;
50
+ worktreePath: z.ZodString;
51
+ uncommittedFileCount: z.ZodNumber;
52
+ lastActivityTimestamp: z.ZodString;
53
+ }, z.core.$strip>>;
54
+ }, z.core.$strip>;
55
+ /**
56
+ * Schema for per-agent metrics.
57
+ * Tracks invocation counts, pass rates, and timing.
58
+ */
59
+ export declare const AgentMetricSchema: z.ZodObject<{
60
+ invoked: z.ZodNumber;
61
+ passRate: z.ZodNumber;
62
+ avgDurationMs: z.ZodNumber;
63
+ lastRun: z.ZodNullable<z.ZodObject<{
64
+ wuId: z.ZodString;
65
+ timestamp: z.ZodString;
66
+ result: z.ZodEnum<{
67
+ pass: "pass";
68
+ fail: "fail";
69
+ }>;
70
+ }, z.core.$strip>>;
71
+ }, z.core.$strip>;
72
+ /**
73
+ * Schema for WU progress tracking.
74
+ * Shows DoD progress and agent status per WU.
75
+ */
76
+ export declare const WUProgressSchema: z.ZodObject<{
77
+ wuId: z.ZodString;
78
+ lane: z.ZodEnum<{
79
+ Operations: "Operations";
80
+ Intelligence: "Intelligence";
81
+ Experience: "Experience";
82
+ "Core Systems": "Core Systems";
83
+ Discovery: "Discovery";
84
+ }>;
85
+ title: z.ZodString;
86
+ dodProgress: z.ZodNumber;
87
+ dodTotal: z.ZodLiteral<11>;
88
+ agents: z.ZodRecord<z.ZodString, z.ZodEnum<{
89
+ pass: "pass";
90
+ pending: "pending";
91
+ fail: "fail";
92
+ skipped: "skipped";
93
+ }>>;
94
+ headline: z.ZodString;
95
+ }, z.core.$strip>;
96
+ /**
97
+ * Schema for timeline events.
98
+ * Records orchestration history for dashboard display.
99
+ */
100
+ export declare const TimelineEventSchema: z.ZodObject<{
101
+ timestamp: z.ZodString;
102
+ event: z.ZodEnum<{
103
+ done: "done";
104
+ gates: "gates";
105
+ agent: "agent";
106
+ block: "block";
107
+ claim: "claim";
108
+ }>;
109
+ wuId: z.ZodString;
110
+ detail: z.ZodString;
111
+ severity: z.ZodEnum<{
112
+ info: "info";
113
+ error: "error";
114
+ warning: "warning";
115
+ }>;
116
+ }, z.core.$strip>;
117
+ /**
118
+ * Schema for dashboard alerts.
119
+ * Highlights items requiring attention.
120
+ */
121
+ export declare const AlertSchema: z.ZodObject<{
122
+ severity: z.ZodEnum<{
123
+ high: "high";
124
+ medium: "medium";
125
+ low: "low";
126
+ }>;
127
+ message: z.ZodString;
128
+ wuId: z.ZodString;
129
+ action: z.ZodString;
130
+ }, z.core.$strip>;
131
+ /**
132
+ * Schema for orchestration suggestions.
133
+ * Recommendations for next actions.
134
+ */
135
+ export declare const SuggestionSchema: z.ZodObject<{
136
+ id: z.ZodString;
137
+ priority: z.ZodEnum<{
138
+ high: "high";
139
+ medium: "medium";
140
+ low: "low";
141
+ }>;
142
+ action: z.ZodString;
143
+ reason: z.ZodString;
144
+ command: z.ZodString;
145
+ }, z.core.$strip>;
146
+ /**
147
+ * Schema for execution plans.
148
+ * Proposed sequence of orchestration actions.
149
+ */
150
+ export declare const ExecutionPlanSchema: z.ZodObject<{
151
+ wuId: z.ZodString;
152
+ steps: z.ZodArray<z.ZodObject<{
153
+ order: z.ZodNumber;
154
+ agent: z.ZodOptional<z.ZodString>;
155
+ action: z.ZodOptional<z.ZodString>;
156
+ status: z.ZodEnum<{
157
+ pass: "pass";
158
+ pending: "pending";
159
+ fail: "fail";
160
+ skipped: "skipped";
161
+ }>;
162
+ }, z.core.$strip>>;
163
+ estimatedTokens: z.ZodNumber;
164
+ }, z.core.$strip>;
165
+ /**
166
+ * Schema for user choices on execution plans.
167
+ */
168
+ export declare const UserChoiceSchema: z.ZodObject<{
169
+ choice: z.ZodEnum<{
170
+ approve: "approve";
171
+ reject: "reject";
172
+ edit: "edit";
173
+ }>;
174
+ modifications: z.ZodOptional<z.ZodArray<z.ZodString>>;
175
+ }, z.core.$strip>;
176
+ /**
177
+ * Schema for complete dashboard data.
178
+ * Aggregates all data needed for dashboard rendering.
179
+ */
180
+ export declare const DashboardDataSchema: z.ZodObject<{
181
+ globalStatus: z.ZodObject<{
182
+ activeWUs: z.ZodNumber;
183
+ completed24h: z.ZodNumber;
184
+ blocked: z.ZodNumber;
185
+ gatesFailing: z.ZodNumber;
186
+ longestRunning: z.ZodNullable<z.ZodObject<{
187
+ wuId: z.ZodString;
188
+ lane: z.ZodEnum<{
189
+ Operations: "Operations";
190
+ Intelligence: "Intelligence";
191
+ Experience: "Experience";
192
+ "Core Systems": "Core Systems";
193
+ Discovery: "Discovery";
194
+ }>;
195
+ durationMs: z.ZodNumber;
196
+ }, z.core.$strip>>;
197
+ pendingMandatory: z.ZodArray<z.ZodObject<{
198
+ wuId: z.ZodString;
199
+ agent: z.ZodEnum<{
200
+ "security-auditor": "security-auditor";
201
+ "beacon-guardian": "beacon-guardian";
202
+ "test-engineer": "test-engineer";
203
+ "code-reviewer": "code-reviewer";
204
+ }>;
205
+ }, z.core.$strip>>;
206
+ activeSession: z.ZodNullable<z.ZodObject<{
207
+ sessionId: z.ZodString;
208
+ wuId: z.ZodString;
209
+ started: z.ZodString;
210
+ contextTier: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
211
+ incidentsLogged: z.ZodNumber;
212
+ }, z.core.$strip>>;
213
+ worktreesWithUncommittedChanges: z.ZodArray<z.ZodObject<{
214
+ wuId: z.ZodString;
215
+ worktreePath: z.ZodString;
216
+ uncommittedFileCount: z.ZodNumber;
217
+ lastActivityTimestamp: z.ZodString;
218
+ }, z.core.$strip>>;
219
+ }, z.core.$strip>;
220
+ agentMetrics: z.ZodRecord<z.ZodString, z.ZodObject<{
221
+ invoked: z.ZodNumber;
222
+ passRate: z.ZodNumber;
223
+ avgDurationMs: z.ZodNumber;
224
+ lastRun: z.ZodNullable<z.ZodObject<{
225
+ wuId: z.ZodString;
226
+ timestamp: z.ZodString;
227
+ result: z.ZodEnum<{
228
+ pass: "pass";
229
+ fail: "fail";
230
+ }>;
231
+ }, z.core.$strip>>;
232
+ }, z.core.$strip>>;
233
+ wuProgress: z.ZodArray<z.ZodObject<{
234
+ wuId: z.ZodString;
235
+ lane: z.ZodEnum<{
236
+ Operations: "Operations";
237
+ Intelligence: "Intelligence";
238
+ Experience: "Experience";
239
+ "Core Systems": "Core Systems";
240
+ Discovery: "Discovery";
241
+ }>;
242
+ title: z.ZodString;
243
+ dodProgress: z.ZodNumber;
244
+ dodTotal: z.ZodLiteral<11>;
245
+ agents: z.ZodRecord<z.ZodString, z.ZodEnum<{
246
+ pass: "pass";
247
+ pending: "pending";
248
+ fail: "fail";
249
+ skipped: "skipped";
250
+ }>>;
251
+ headline: z.ZodString;
252
+ }, z.core.$strip>>;
253
+ timeline: z.ZodArray<z.ZodObject<{
254
+ timestamp: z.ZodString;
255
+ event: z.ZodEnum<{
256
+ done: "done";
257
+ gates: "gates";
258
+ agent: "agent";
259
+ block: "block";
260
+ claim: "claim";
261
+ }>;
262
+ wuId: z.ZodString;
263
+ detail: z.ZodString;
264
+ severity: z.ZodEnum<{
265
+ info: "info";
266
+ error: "error";
267
+ warning: "warning";
268
+ }>;
269
+ }, z.core.$strip>>;
270
+ alerts: z.ZodArray<z.ZodObject<{
271
+ severity: z.ZodEnum<{
272
+ high: "high";
273
+ medium: "medium";
274
+ low: "low";
275
+ }>;
276
+ message: z.ZodString;
277
+ wuId: z.ZodString;
278
+ action: z.ZodString;
279
+ }, z.core.$strip>>;
280
+ }, z.core.$strip>;
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Orchestration Domain Schemas
3
+ *
4
+ * Zod schemas for runtime validation of orchestration domain types.
5
+ * Single source of truth - types are inferred from these schemas.
6
+ *
7
+ * @module orchestration.schemas
8
+ * @see {@link ./orchestration.types.mjs} - Types inferred from these schemas
9
+ * @see {@link ./orchestration.constants.mjs} - Constants used in validation
10
+ */
11
+ import { z } from 'zod';
12
+ import { LANES, AGENT_NAMES, SEVERITY_LEVELS, AGENT_RESULT_STATUSES, TIMELINE_EVENT_TYPES, EVENT_SEVERITY_LEVELS, USER_CHOICE_OPTIONS, DOD_TOTAL, } from './orchestration.constants.js';
13
+ /**
14
+ * Schema for the longest running WU information.
15
+ */
16
+ const LongestRunningSchema = z.object({
17
+ wuId: z.string().min(1),
18
+ lane: z.enum(LANES),
19
+ durationMs: z.number().nonnegative(),
20
+ });
21
+ /**
22
+ * Schema for pending mandatory agent information.
23
+ */
24
+ const PendingMandatorySchema = z.object({
25
+ wuId: z.string().min(1),
26
+ agent: z.enum(AGENT_NAMES),
27
+ });
28
+ /**
29
+ * Schema for active agent session (WU-1438).
30
+ */
31
+ const ActiveSessionSchema = z.object({
32
+ sessionId: z.string().uuid(),
33
+ wuId: z.string().min(1),
34
+ started: z.string().datetime(),
35
+ contextTier: z.union([z.literal(1), z.literal(2), z.literal(3)]),
36
+ incidentsLogged: z.number().int().nonnegative(),
37
+ });
38
+ /**
39
+ * Schema for worktree with uncommitted changes (WU-1748).
40
+ * Used for cross-agent visibility of abandoned WU work.
41
+ */
42
+ const WorktreeWithUncommittedChangesSchema = z.object({
43
+ /** WU ID extracted from worktree branch name */
44
+ wuId: z.string().min(1),
45
+ /** Worktree directory path */
46
+ worktreePath: z.string().min(1),
47
+ /** Number of uncommitted files */
48
+ uncommittedFileCount: z.number().int().nonnegative(),
49
+ /** Last git activity timestamp (ISO 8601) */
50
+ lastActivityTimestamp: z.string(),
51
+ });
52
+ /**
53
+ * Schema for global orchestration status.
54
+ * Shows high-level dashboard metrics at a glance.
55
+ */
56
+ export const GlobalStatusSchema = z.object({
57
+ /** Number of WUs currently in progress */
58
+ activeWUs: z.number().int().nonnegative(),
59
+ /** Number of WUs completed in the last 24 hours */
60
+ completed24h: z.number().int().nonnegative(),
61
+ /** Number of currently blocked WUs */
62
+ blocked: z.number().int().nonnegative(),
63
+ /** Number of WUs with failing gates */
64
+ gatesFailing: z.number().int().nonnegative(),
65
+ /** Information about the longest running WU, or null if none active */
66
+ longestRunning: LongestRunningSchema.nullable(),
67
+ /** List of WUs with pending mandatory agents */
68
+ pendingMandatory: z.array(PendingMandatorySchema),
69
+ /** Current active agent session, or null if none (WU-1438) */
70
+ activeSession: ActiveSessionSchema.nullable(),
71
+ /** Worktrees with uncommitted changes for cross-agent visibility (WU-1748) */
72
+ worktreesWithUncommittedChanges: z.array(WorktreeWithUncommittedChangesSchema),
73
+ });
74
+ /**
75
+ * Schema for last run information within agent metrics.
76
+ */
77
+ const LastRunSchema = z.object({
78
+ wuId: z.string().min(1),
79
+ timestamp: z.string().datetime(),
80
+ result: z.enum(['pass', 'fail']),
81
+ });
82
+ /**
83
+ * Schema for per-agent metrics.
84
+ * Tracks invocation counts, pass rates, and timing.
85
+ */
86
+ export const AgentMetricSchema = z.object({
87
+ /** Total number of times this agent has been invoked */
88
+ invoked: z.number().int().nonnegative(),
89
+ /** Pass rate as percentage (0-100) */
90
+ passRate: z.number().min(0).max(100),
91
+ /** Average duration in milliseconds */
92
+ avgDurationMs: z.number().nonnegative(),
93
+ /** Information about the most recent run, or null if never run */
94
+ lastRun: LastRunSchema.nullable(),
95
+ });
96
+ /**
97
+ * Schema for WU progress tracking.
98
+ * Shows DoD progress and agent status per WU.
99
+ */
100
+ export const WUProgressSchema = z.object({
101
+ /** Work Unit ID (e.g., "WU-1234") */
102
+ wuId: z.string().min(1),
103
+ /** Lane the WU is assigned to */
104
+ lane: z.enum(LANES),
105
+ /** Human-readable title of the WU */
106
+ title: z.string().min(1),
107
+ /** Current DoD checkpoint progress (0 to DOD_TOTAL) */
108
+ dodProgress: z.number().int().min(0).max(DOD_TOTAL),
109
+ /** Total DoD checkpoints (always DOD_TOTAL) */
110
+ dodTotal: z.literal(DOD_TOTAL),
111
+ /** Status of each agent that has been or should be run */
112
+ agents: z.record(z.string(), z.enum(AGENT_RESULT_STATUSES)),
113
+ /** Tufte-style headline sentence describing current state */
114
+ headline: z.string(),
115
+ });
116
+ /**
117
+ * Schema for timeline events.
118
+ * Records orchestration history for dashboard display.
119
+ */
120
+ export const TimelineEventSchema = z.object({
121
+ /** ISO 8601 timestamp of the event */
122
+ timestamp: z.string().datetime(),
123
+ /** Type of orchestration event */
124
+ event: z.enum(TIMELINE_EVENT_TYPES),
125
+ /** Associated Work Unit ID */
126
+ wuId: z.string().min(1),
127
+ /** Human-readable event description */
128
+ detail: z.string(),
129
+ /** Visual severity for display */
130
+ severity: z.enum(EVENT_SEVERITY_LEVELS),
131
+ });
132
+ /**
133
+ * Schema for dashboard alerts.
134
+ * Highlights items requiring attention.
135
+ */
136
+ export const AlertSchema = z.object({
137
+ /** Alert severity level */
138
+ severity: z.enum(SEVERITY_LEVELS),
139
+ /** Human-readable alert message */
140
+ message: z.string().min(1),
141
+ /** Associated Work Unit ID */
142
+ wuId: z.string().min(1),
143
+ /** Suggested action or command */
144
+ action: z.string().min(1),
145
+ });
146
+ /**
147
+ * Schema for orchestration suggestions.
148
+ * Recommendations for next actions.
149
+ */
150
+ export const SuggestionSchema = z.object({
151
+ /** Unique suggestion identifier */
152
+ id: z.string().min(1),
153
+ /** Suggestion priority level */
154
+ priority: z.enum(SEVERITY_LEVELS),
155
+ /** Short action description */
156
+ action: z.string().min(1),
157
+ /** Reason for the suggestion */
158
+ reason: z.string().min(1),
159
+ /** CLI command to execute the suggestion */
160
+ command: z.string().min(1),
161
+ });
162
+ /**
163
+ * Schema for execution plan steps.
164
+ */
165
+ const ExecutionStepSchema = z.object({
166
+ /** Execution order (1-based) */
167
+ order: z.number().int().positive(),
168
+ /** Agent to run (if applicable) */
169
+ agent: z.string().optional(),
170
+ /** Action to perform (if not an agent) */
171
+ action: z.string().optional(),
172
+ /** Step execution status */
173
+ status: z.enum(AGENT_RESULT_STATUSES),
174
+ });
175
+ /**
176
+ * Schema for execution plans.
177
+ * Proposed sequence of orchestration actions.
178
+ */
179
+ export const ExecutionPlanSchema = z.object({
180
+ /** Work Unit ID this plan is for */
181
+ wuId: z.string().min(1),
182
+ /** Ordered list of steps to execute */
183
+ steps: z.array(ExecutionStepSchema),
184
+ /** Estimated token cost for the full plan */
185
+ estimatedTokens: z.number().int().nonnegative(),
186
+ });
187
+ /**
188
+ * Schema for user choices on execution plans.
189
+ */
190
+ export const UserChoiceSchema = z.object({
191
+ /** User's choice */
192
+ choice: z.enum(USER_CHOICE_OPTIONS),
193
+ /** Modifications if choice is 'edit' */
194
+ modifications: z.array(z.string()).optional(),
195
+ });
196
+ /**
197
+ * Schema for complete dashboard data.
198
+ * Aggregates all data needed for dashboard rendering.
199
+ */
200
+ export const DashboardDataSchema = z.object({
201
+ /** Global status metrics */
202
+ globalStatus: GlobalStatusSchema,
203
+ /** Per-agent metrics keyed by agent name */
204
+ agentMetrics: z.record(z.string(), AgentMetricSchema),
205
+ /** Progress for all active WUs */
206
+ wuProgress: z.array(WUProgressSchema),
207
+ /** Recent timeline events */
208
+ timeline: z.array(TimelineEventSchema),
209
+ /** Current alerts */
210
+ alerts: z.array(AlertSchema),
211
+ });