@lumenflow/core 1.4.0 → 1.6.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 (79) hide show
  1. package/README.md +362 -7
  2. package/dist/adapters/context-adapters.d.ts +90 -0
  3. package/dist/adapters/context-adapters.js +99 -0
  4. package/dist/adapters/index.d.ts +14 -0
  5. package/dist/adapters/index.js +18 -0
  6. package/dist/adapters/recovery-adapters.d.ts +40 -0
  7. package/dist/adapters/recovery-adapters.js +43 -0
  8. package/dist/adapters/validation-adapters.d.ts +52 -0
  9. package/dist/adapters/validation-adapters.js +59 -0
  10. package/dist/agent-patterns-registry.d.ts +100 -2
  11. package/dist/agent-patterns-registry.js +124 -0
  12. package/dist/arg-parser.js +7 -0
  13. package/dist/branch-check.d.ts +32 -3
  14. package/dist/branch-check.js +81 -15
  15. package/dist/color-support.d.ts +32 -0
  16. package/dist/color-support.js +64 -0
  17. package/dist/context/context-computer.d.ts +46 -0
  18. package/dist/context/context-computer.js +125 -0
  19. package/dist/context/git-state-reader.d.ts +51 -0
  20. package/dist/context/git-state-reader.js +61 -0
  21. package/dist/context/index.d.ts +17 -0
  22. package/dist/context/index.js +17 -0
  23. package/dist/context/location-resolver.d.ts +48 -0
  24. package/dist/context/location-resolver.js +175 -0
  25. package/dist/context/wu-state-reader.d.ts +37 -0
  26. package/dist/context/wu-state-reader.js +76 -0
  27. package/dist/context-di.d.ts +184 -0
  28. package/dist/context-di.js +178 -0
  29. package/dist/context-validation-integration.d.ts +77 -0
  30. package/dist/context-validation-integration.js +157 -0
  31. package/dist/cycle-detector.d.ts +51 -0
  32. package/dist/cycle-detector.js +89 -0
  33. package/dist/dependency-graph.js +1 -11
  34. package/dist/domain/context.schemas.d.ts +147 -0
  35. package/dist/domain/context.schemas.js +126 -0
  36. package/dist/domain/index.d.ts +14 -0
  37. package/dist/domain/index.js +18 -0
  38. package/dist/domain/recovery.schemas.d.ts +115 -0
  39. package/dist/domain/recovery.schemas.js +83 -0
  40. package/dist/domain/validation.schemas.d.ts +146 -0
  41. package/dist/domain/validation.schemas.js +114 -0
  42. package/dist/index.d.ts +17 -0
  43. package/dist/index.js +47 -0
  44. package/dist/lumenflow-config-schema.d.ts +47 -0
  45. package/dist/lumenflow-config-schema.js +84 -4
  46. package/dist/ports/context.ports.d.ts +135 -0
  47. package/dist/ports/context.ports.js +21 -0
  48. package/dist/ports/index.d.ts +14 -0
  49. package/dist/ports/index.js +14 -0
  50. package/dist/ports/recovery.ports.d.ts +58 -0
  51. package/dist/ports/recovery.ports.js +17 -0
  52. package/dist/ports/validation.ports.d.ts +74 -0
  53. package/dist/ports/validation.ports.js +17 -0
  54. package/dist/recovery/index.d.ts +11 -0
  55. package/dist/recovery/index.js +11 -0
  56. package/dist/recovery/recovery-analyzer.d.ts +66 -0
  57. package/dist/recovery/recovery-analyzer.js +129 -0
  58. package/dist/usecases/analyze-recovery.usecase.d.ts +42 -0
  59. package/dist/usecases/analyze-recovery.usecase.js +45 -0
  60. package/dist/usecases/compute-context.usecase.d.ts +62 -0
  61. package/dist/usecases/compute-context.usecase.js +101 -0
  62. package/dist/usecases/index.d.ts +14 -0
  63. package/dist/usecases/index.js +18 -0
  64. package/dist/usecases/validate-command.usecase.d.ts +55 -0
  65. package/dist/usecases/validate-command.usecase.js +154 -0
  66. package/dist/validation/command-registry.d.ts +38 -0
  67. package/dist/validation/command-registry.js +229 -0
  68. package/dist/validation/index.d.ts +15 -0
  69. package/dist/validation/index.js +15 -0
  70. package/dist/validation/types.d.ts +135 -0
  71. package/dist/validation/types.js +11 -0
  72. package/dist/validation/validate-command.d.ts +27 -0
  73. package/dist/validation/validate-command.js +160 -0
  74. package/dist/wu-constants.d.ts +136 -0
  75. package/dist/wu-constants.js +124 -0
  76. package/dist/wu-done-preflight.js +8 -1
  77. package/dist/wu-helpers.d.ts +5 -1
  78. package/dist/wu-helpers.js +12 -1
  79. package/package.json +3 -6
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Cycle Detection Module (WU-1088)
3
+ *
4
+ * Provides cycle detection for WU dependency graphs.
5
+ * Extracted from @lumenflow/initiatives to break circular dependency.
6
+ *
7
+ * @module @lumenflow/core/cycle-detector
8
+ */
9
+ /**
10
+ * WU object interface for validation and cycle detection
11
+ * Note: This interface is shared with @lumenflow/initiatives for backward compatibility
12
+ */
13
+ export interface WUObject {
14
+ id?: string;
15
+ blocks?: string[];
16
+ blocked_by?: string[];
17
+ initiative?: string;
18
+ phase?: number;
19
+ [key: string]: unknown;
20
+ }
21
+ /**
22
+ * Result of cycle detection
23
+ */
24
+ export interface CycleResult {
25
+ hasCycle: boolean;
26
+ cycles: string[][];
27
+ }
28
+ /**
29
+ * Detects circular dependencies in WU dependency graph using DFS
30
+ *
31
+ * Uses standard cycle detection: tracks visited nodes and nodes in current
32
+ * recursion stack. If we encounter a node already in the recursion stack,
33
+ * we've found a cycle.
34
+ *
35
+ * Note: This function treats both `blocks` and `blocked_by` as edges for
36
+ * traversal. This means if WU-A blocks WU-B, and WU-B's blocked_by includes
37
+ * WU-A, following both directions will find a path back to WU-A.
38
+ *
39
+ * @param wuMap - Map of WU ID to WU object
40
+ * @returns Cycle detection result with hasCycle boolean and cycles array
41
+ *
42
+ * @example
43
+ * const wuMap = new Map([
44
+ * ['WU-001', { id: 'WU-001', blocks: ['WU-002'] }],
45
+ * ['WU-002', { id: 'WU-002', blocks: ['WU-001'] }],
46
+ * ]);
47
+ * const result = detectCycles(wuMap);
48
+ * // result.hasCycle === true
49
+ * // result.cycles contains the cycle path
50
+ */
51
+ export declare function detectCycles(wuMap: Map<string, WUObject>): CycleResult;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Cycle Detection Module (WU-1088)
3
+ *
4
+ * Provides cycle detection for WU dependency graphs.
5
+ * Extracted from @lumenflow/initiatives to break circular dependency.
6
+ *
7
+ * @module @lumenflow/core/cycle-detector
8
+ */
9
+ /**
10
+ * Detects circular dependencies in WU dependency graph using DFS
11
+ *
12
+ * Uses standard cycle detection: tracks visited nodes and nodes in current
13
+ * recursion stack. If we encounter a node already in the recursion stack,
14
+ * we've found a cycle.
15
+ *
16
+ * Note: This function treats both `blocks` and `blocked_by` as edges for
17
+ * traversal. This means if WU-A blocks WU-B, and WU-B's blocked_by includes
18
+ * WU-A, following both directions will find a path back to WU-A.
19
+ *
20
+ * @param wuMap - Map of WU ID to WU object
21
+ * @returns Cycle detection result with hasCycle boolean and cycles array
22
+ *
23
+ * @example
24
+ * const wuMap = new Map([
25
+ * ['WU-001', { id: 'WU-001', blocks: ['WU-002'] }],
26
+ * ['WU-002', { id: 'WU-002', blocks: ['WU-001'] }],
27
+ * ]);
28
+ * const result = detectCycles(wuMap);
29
+ * // result.hasCycle === true
30
+ * // result.cycles contains the cycle path
31
+ */
32
+ export function detectCycles(wuMap) {
33
+ const visited = new Set();
34
+ const recursionStack = new Set();
35
+ const cycles = [];
36
+ /**
37
+ * DFS traversal to detect cycles
38
+ * @param wuId - Current WU ID
39
+ * @param path - Current path from root
40
+ * @returns True if cycle found
41
+ */
42
+ function dfs(wuId, path) {
43
+ // If node is in recursion stack, we found a cycle
44
+ if (recursionStack.has(wuId)) {
45
+ const cycleStart = path.indexOf(wuId);
46
+ if (cycleStart !== -1) {
47
+ cycles.push([...path.slice(cycleStart), wuId]);
48
+ }
49
+ else {
50
+ // Self-reference case
51
+ cycles.push([wuId, wuId]);
52
+ }
53
+ return true;
54
+ }
55
+ // If already fully visited, skip
56
+ if (visited.has(wuId)) {
57
+ return false;
58
+ }
59
+ // Mark as being processed
60
+ visited.add(wuId);
61
+ recursionStack.add(wuId);
62
+ // Get dependencies (both blocks and blocked_by create edges)
63
+ // Only use arrays - ignore legacy string format for backward compatibility
64
+ const wu = wuMap.get(wuId);
65
+ const blocks = Array.isArray(wu?.blocks) ? wu.blocks : [];
66
+ const blockedBy = Array.isArray(wu?.blocked_by) ? wu.blocked_by : [];
67
+ const deps = [...blocks, ...blockedBy];
68
+ // Visit all dependencies
69
+ for (const dep of deps) {
70
+ // Only traverse if the dependency exists in our map
71
+ if (wuMap.has(dep)) {
72
+ dfs(dep, [...path, wuId]);
73
+ }
74
+ }
75
+ // Remove from recursion stack (done processing)
76
+ recursionStack.delete(wuId);
77
+ return false;
78
+ }
79
+ // Run DFS from each node to find all cycles
80
+ for (const wuId of wuMap.keys()) {
81
+ if (!visited.has(wuId)) {
82
+ dfs(wuId, []);
83
+ }
84
+ }
85
+ return {
86
+ hasCycle: cycles.length > 0,
87
+ cycles,
88
+ };
89
+ }
@@ -3,17 +3,7 @@ import path from 'node:path';
3
3
  import { readWU } from './wu-yaml.js';
4
4
  import { WU_PATHS } from './wu-paths.js';
5
5
  import { STRING_LITERALS, WU_STATUS } from './wu-constants.js';
6
- // Optional import from @lumenflow/initiatives - if not available, provide stub
7
- let detectCycles;
8
- try {
9
- // Dynamic import for optional peer dependency
10
- const module = await import('@lumenflow/initiatives');
11
- detectCycles = module.detectCycles;
12
- }
13
- catch {
14
- // Fallback stub if @lumenflow/initiatives is not available
15
- detectCycles = () => ({ hasCycle: false, cycles: [] });
16
- }
6
+ import { detectCycles } from './cycle-detector.js';
17
7
  /**
18
8
  * Dependency Graph Module (WU-1247, WU-1568)
19
9
  *
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Context Schemas
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Zod schemas for context-related types in the context-aware validation system.
7
+ * Types are inferred from Zod schemas using z.infer<> for single source of truth.
8
+ *
9
+ * @module domain/context.schemas
10
+ */
11
+ import { z } from 'zod';
12
+ /**
13
+ * Location type enum values
14
+ *
15
+ * Mirrors CONTEXT_VALIDATION.LOCATION_TYPES from wu-constants.ts
16
+ */
17
+ export declare const LOCATION_TYPE_VALUES: readonly ["main", "worktree", "detached", "unknown"];
18
+ /**
19
+ * Schema for location types
20
+ */
21
+ export declare const LocationTypeSchema: z.ZodEnum<{
22
+ unknown: "unknown";
23
+ main: "main";
24
+ worktree: "worktree";
25
+ detached: "detached";
26
+ }>;
27
+ /**
28
+ * Schema for location context
29
+ *
30
+ * Captures where the command is being run from and related paths.
31
+ */
32
+ export declare const LocationContextSchema: z.ZodObject<{
33
+ type: z.ZodEnum<{
34
+ unknown: "unknown";
35
+ main: "main";
36
+ worktree: "worktree";
37
+ detached: "detached";
38
+ }>;
39
+ cwd: z.ZodString;
40
+ gitRoot: z.ZodString;
41
+ mainCheckout: z.ZodString;
42
+ worktreeName: z.ZodNullable<z.ZodString>;
43
+ worktreeWuId: z.ZodNullable<z.ZodString>;
44
+ }, z.core.$strip>;
45
+ /**
46
+ * Schema for git state
47
+ *
48
+ * Captures the current git state relevant to command execution.
49
+ */
50
+ export declare const GitStateSchema: z.ZodObject<{
51
+ branch: z.ZodNullable<z.ZodString>;
52
+ isDetached: z.ZodBoolean;
53
+ isDirty: z.ZodBoolean;
54
+ hasStaged: z.ZodBoolean;
55
+ ahead: z.ZodNumber;
56
+ behind: z.ZodNumber;
57
+ tracking: z.ZodNullable<z.ZodString>;
58
+ modifiedFiles: z.ZodArray<z.ZodString>;
59
+ hasError: z.ZodBoolean;
60
+ errorMessage: z.ZodNullable<z.ZodString>;
61
+ }, z.core.$strip>;
62
+ /**
63
+ * Schema for WU state result
64
+ *
65
+ * Result of reading WU state from YAML and state store.
66
+ */
67
+ export declare const WuStateResultSchema: z.ZodObject<{
68
+ id: z.ZodString;
69
+ status: z.ZodString;
70
+ lane: z.ZodString;
71
+ title: z.ZodString;
72
+ yamlPath: z.ZodString;
73
+ isConsistent: z.ZodBoolean;
74
+ inconsistencyReason: z.ZodNullable<z.ZodString>;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * Schema for session state
78
+ *
79
+ * Session state for active WU work.
80
+ */
81
+ export declare const SessionStateSchema: z.ZodObject<{
82
+ isActive: z.ZodBoolean;
83
+ sessionId: z.ZodNullable<z.ZodString>;
84
+ }, z.core.$strip>;
85
+ /**
86
+ * Schema for unified WU context
87
+ *
88
+ * Captures all environmental state relevant to command execution.
89
+ */
90
+ export declare const WuContextSchema: z.ZodObject<{
91
+ location: z.ZodObject<{
92
+ type: z.ZodEnum<{
93
+ unknown: "unknown";
94
+ main: "main";
95
+ worktree: "worktree";
96
+ detached: "detached";
97
+ }>;
98
+ cwd: z.ZodString;
99
+ gitRoot: z.ZodString;
100
+ mainCheckout: z.ZodString;
101
+ worktreeName: z.ZodNullable<z.ZodString>;
102
+ worktreeWuId: z.ZodNullable<z.ZodString>;
103
+ }, z.core.$strip>;
104
+ git: z.ZodObject<{
105
+ branch: z.ZodNullable<z.ZodString>;
106
+ isDetached: z.ZodBoolean;
107
+ isDirty: z.ZodBoolean;
108
+ hasStaged: z.ZodBoolean;
109
+ ahead: z.ZodNumber;
110
+ behind: z.ZodNumber;
111
+ tracking: z.ZodNullable<z.ZodString>;
112
+ modifiedFiles: z.ZodArray<z.ZodString>;
113
+ hasError: z.ZodBoolean;
114
+ errorMessage: z.ZodNullable<z.ZodString>;
115
+ }, z.core.$strip>;
116
+ wu: z.ZodNullable<z.ZodObject<{
117
+ id: z.ZodString;
118
+ status: z.ZodString;
119
+ lane: z.ZodString;
120
+ title: z.ZodString;
121
+ yamlPath: z.ZodString;
122
+ isConsistent: z.ZodBoolean;
123
+ inconsistencyReason: z.ZodNullable<z.ZodString>;
124
+ }, z.core.$strip>>;
125
+ session: z.ZodObject<{
126
+ isActive: z.ZodBoolean;
127
+ sessionId: z.ZodNullable<z.ZodString>;
128
+ }, z.core.$strip>;
129
+ worktreeGit: z.ZodOptional<z.ZodObject<{
130
+ branch: z.ZodNullable<z.ZodString>;
131
+ isDetached: z.ZodBoolean;
132
+ isDirty: z.ZodBoolean;
133
+ hasStaged: z.ZodBoolean;
134
+ ahead: z.ZodNumber;
135
+ behind: z.ZodNumber;
136
+ tracking: z.ZodNullable<z.ZodString>;
137
+ modifiedFiles: z.ZodArray<z.ZodString>;
138
+ hasError: z.ZodBoolean;
139
+ errorMessage: z.ZodNullable<z.ZodString>;
140
+ }, z.core.$strip>>;
141
+ }, z.core.$strip>;
142
+ export type LocationType = z.infer<typeof LocationTypeSchema>;
143
+ export type LocationContext = z.infer<typeof LocationContextSchema>;
144
+ export type GitState = z.infer<typeof GitStateSchema>;
145
+ export type WuStateResult = z.infer<typeof WuStateResultSchema>;
146
+ export type SessionState = z.infer<typeof SessionStateSchema>;
147
+ export type WuContext = z.infer<typeof WuContextSchema>;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Context Schemas
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Zod schemas for context-related types in the context-aware validation system.
7
+ * Types are inferred from Zod schemas using z.infer<> for single source of truth.
8
+ *
9
+ * @module domain/context.schemas
10
+ */
11
+ import { z } from 'zod';
12
+ /**
13
+ * Location type enum values
14
+ *
15
+ * Mirrors CONTEXT_VALIDATION.LOCATION_TYPES from wu-constants.ts
16
+ */
17
+ export const LOCATION_TYPE_VALUES = ['main', 'worktree', 'detached', 'unknown'];
18
+ /**
19
+ * Schema for location types
20
+ */
21
+ export const LocationTypeSchema = z.enum(LOCATION_TYPE_VALUES);
22
+ /**
23
+ * Schema for location context
24
+ *
25
+ * Captures where the command is being run from and related paths.
26
+ */
27
+ export const LocationContextSchema = z.object({
28
+ /** Location type: 'main', 'worktree', 'detached', or 'unknown' */
29
+ type: LocationTypeSchema,
30
+ /** Absolute path to current working directory */
31
+ cwd: z.string(),
32
+ /** Absolute path to git root (top-level of working tree) */
33
+ gitRoot: z.string(),
34
+ /** Absolute path to main checkout (primary repo) */
35
+ mainCheckout: z.string(),
36
+ /** Worktree name if in a worktree (e.g., 'framework-core-wu-1090') */
37
+ worktreeName: z.string().nullable(),
38
+ /** WU ID extracted from worktree path (e.g., 'WU-1090') */
39
+ worktreeWuId: z.string().nullable(),
40
+ });
41
+ /**
42
+ * Schema for git state
43
+ *
44
+ * Captures the current git state relevant to command execution.
45
+ */
46
+ export const GitStateSchema = z.object({
47
+ /** Current branch name (null if detached) */
48
+ branch: z.string().nullable(),
49
+ /** Whether HEAD is detached */
50
+ isDetached: z.boolean(),
51
+ /** Whether working tree has uncommitted changes */
52
+ isDirty: z.boolean(),
53
+ /** Whether there are staged changes */
54
+ hasStaged: z.boolean(),
55
+ /** Commits ahead of tracking branch */
56
+ ahead: z.number().int().min(0),
57
+ /** Commits behind tracking branch */
58
+ behind: z.number().int().min(0),
59
+ /** Tracking branch (e.g., 'origin/main') */
60
+ tracking: z.string().nullable(),
61
+ /** List of modified files */
62
+ modifiedFiles: z.array(z.string()),
63
+ /** Whether an error occurred reading state */
64
+ hasError: z.boolean(),
65
+ /** Error message if hasError is true */
66
+ errorMessage: z.string().nullable(),
67
+ });
68
+ /**
69
+ * Schema for WU state result
70
+ *
71
+ * Result of reading WU state from YAML and state store.
72
+ */
73
+ export const WuStateResultSchema = z.object({
74
+ /** WU ID (uppercase, e.g., 'WU-1090') */
75
+ id: z.string(),
76
+ /** Current status from YAML */
77
+ status: z.string(),
78
+ /** Lane name */
79
+ lane: z.string(),
80
+ /** WU title */
81
+ title: z.string(),
82
+ /** Absolute path to WU YAML file */
83
+ yamlPath: z.string(),
84
+ /** Whether YAML and state store are consistent */
85
+ isConsistent: z.boolean(),
86
+ /** Reason for inconsistency if not consistent */
87
+ inconsistencyReason: z.string().nullable(),
88
+ });
89
+ /**
90
+ * Schema for session state
91
+ *
92
+ * Session state for active WU work.
93
+ */
94
+ export const SessionStateSchema = z.object({
95
+ /** Whether a session is active */
96
+ isActive: z.boolean(),
97
+ /** Session ID if active */
98
+ sessionId: z.string().nullable(),
99
+ });
100
+ /**
101
+ * Schema for unified WU context
102
+ *
103
+ * Captures all environmental state relevant to command execution.
104
+ */
105
+ export const WuContextSchema = z.object({
106
+ /** Location context (main vs worktree) */
107
+ location: LocationContextSchema,
108
+ /** Git state (branch, dirty, staged, ahead/behind) */
109
+ git: GitStateSchema,
110
+ /** WU state (null if no WU specified) */
111
+ wu: WuStateResultSchema.nullable(),
112
+ /** Session state */
113
+ session: SessionStateSchema,
114
+ /**
115
+ * Git state of the WU's worktree (WU-1092).
116
+ *
117
+ * When running wu:done from main checkout, we need to check the worktree's
118
+ * git state, not main's. This field is populated when:
119
+ * - Running from main checkout (location.type === 'main')
120
+ * - A WU is specified (wu !== null)
121
+ * - WU has an active worktree (status === 'in_progress')
122
+ *
123
+ * If undefined, predicates should fall back to checking `git.isDirty`.
124
+ */
125
+ worktreeGit: GitStateSchema.optional(),
126
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Domain Schemas Index
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Re-exports all domain schemas and types for the context-aware validation system.
7
+ *
8
+ * @module domain
9
+ */
10
+ export * from './context.schemas.js';
11
+ export { VALIDATION_ERROR_CODE_VALUES, ValidationErrorCodeSchema, PREDICATE_SEVERITY_VALUES, PredicateSeveritySchema, ValidationErrorSchema, ValidationWarningSchema, ValidationResultSchema, CommandPredicateConfigSchema, CommandDefinitionConfigSchema, type ValidationErrorCode, type PredicateSeverity, type ValidationError, type ValidationWarning, type ValidationResult, type CommandPredicateConfig, type CommandDefinitionConfig, } from './validation.schemas.js';
12
+ export * from './recovery.schemas.js';
13
+ export * from './orchestration.schemas.js';
14
+ export * from './orchestration.constants.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Domain Schemas Index
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Re-exports all domain schemas and types for the context-aware validation system.
7
+ *
8
+ * @module domain
9
+ */
10
+ // Context schemas (primary definitions for location, git, wu state)
11
+ export * from './context.schemas.js';
12
+ // Validation schemas (excludes re-exports from context.schemas)
13
+ export { VALIDATION_ERROR_CODE_VALUES, ValidationErrorCodeSchema, PREDICATE_SEVERITY_VALUES, PredicateSeveritySchema, ValidationErrorSchema, ValidationWarningSchema, ValidationResultSchema, CommandPredicateConfigSchema, CommandDefinitionConfigSchema, } from './validation.schemas.js';
14
+ // Recovery schemas
15
+ export * from './recovery.schemas.js';
16
+ // Orchestration schemas (existing)
17
+ export * from './orchestration.schemas.js';
18
+ export * from './orchestration.constants.js';
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Recovery Schemas
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Zod schemas for recovery-related types in the context-aware validation system.
7
+ * Types are inferred from Zod schemas using z.infer<> for single source of truth.
8
+ *
9
+ * @module domain/recovery.schemas
10
+ */
11
+ import { z } from 'zod';
12
+ /**
13
+ * Recovery issue code values
14
+ *
15
+ * Mirrors CONTEXT_VALIDATION.RECOVERY_ISSUES from wu-constants.ts
16
+ */
17
+ export declare const RECOVERY_ISSUE_CODE_VALUES: readonly ["PARTIAL_CLAIM", "ORPHAN_CLAIM", "INCONSISTENT_STATE", "ORPHAN_BRANCH", "STALE_LOCK", "LEFTOVER_WORKTREE"];
18
+ /**
19
+ * Schema for recovery issue codes
20
+ */
21
+ export declare const RecoveryIssueCodeSchema: z.ZodEnum<{
22
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
23
+ PARTIAL_CLAIM: "PARTIAL_CLAIM";
24
+ ORPHAN_CLAIM: "ORPHAN_CLAIM";
25
+ ORPHAN_BRANCH: "ORPHAN_BRANCH";
26
+ STALE_LOCK: "STALE_LOCK";
27
+ LEFTOVER_WORKTREE: "LEFTOVER_WORKTREE";
28
+ }>;
29
+ /**
30
+ * Recovery action type values
31
+ *
32
+ * Mirrors CONTEXT_VALIDATION.RECOVERY_ACTIONS from wu-constants.ts
33
+ */
34
+ export declare const RECOVERY_ACTION_TYPE_VALUES: readonly ["resume", "reset", "nuke", "cleanup"];
35
+ /**
36
+ * Schema for recovery action types
37
+ */
38
+ export declare const RecoveryActionTypeSchema: z.ZodEnum<{
39
+ reset: "reset";
40
+ resume: "resume";
41
+ nuke: "nuke";
42
+ cleanup: "cleanup";
43
+ }>;
44
+ /**
45
+ * Schema for recovery issue
46
+ *
47
+ * Issue detected during recovery analysis.
48
+ */
49
+ export declare const RecoveryIssueSchema: z.ZodObject<{
50
+ code: z.ZodEnum<{
51
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
52
+ PARTIAL_CLAIM: "PARTIAL_CLAIM";
53
+ ORPHAN_CLAIM: "ORPHAN_CLAIM";
54
+ ORPHAN_BRANCH: "ORPHAN_BRANCH";
55
+ STALE_LOCK: "STALE_LOCK";
56
+ LEFTOVER_WORKTREE: "LEFTOVER_WORKTREE";
57
+ }>;
58
+ description: z.ZodString;
59
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
60
+ }, z.core.$strip>;
61
+ /**
62
+ * Schema for recovery action
63
+ *
64
+ * Suggested recovery action.
65
+ */
66
+ export declare const RecoveryActionSchema: z.ZodObject<{
67
+ type: z.ZodEnum<{
68
+ reset: "reset";
69
+ resume: "resume";
70
+ nuke: "nuke";
71
+ cleanup: "cleanup";
72
+ }>;
73
+ description: z.ZodString;
74
+ command: z.ZodString;
75
+ requiresForce: z.ZodBoolean;
76
+ warning: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ /**
79
+ * Schema for recovery analysis result
80
+ *
81
+ * Result of recovery analysis.
82
+ */
83
+ export declare const RecoveryAnalysisSchema: z.ZodObject<{
84
+ hasIssues: z.ZodBoolean;
85
+ issues: z.ZodArray<z.ZodObject<{
86
+ code: z.ZodEnum<{
87
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
88
+ PARTIAL_CLAIM: "PARTIAL_CLAIM";
89
+ ORPHAN_CLAIM: "ORPHAN_CLAIM";
90
+ ORPHAN_BRANCH: "ORPHAN_BRANCH";
91
+ STALE_LOCK: "STALE_LOCK";
92
+ LEFTOVER_WORKTREE: "LEFTOVER_WORKTREE";
93
+ }>;
94
+ description: z.ZodString;
95
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
96
+ }, z.core.$strip>>;
97
+ actions: z.ZodArray<z.ZodObject<{
98
+ type: z.ZodEnum<{
99
+ reset: "reset";
100
+ resume: "resume";
101
+ nuke: "nuke";
102
+ cleanup: "cleanup";
103
+ }>;
104
+ description: z.ZodString;
105
+ command: z.ZodString;
106
+ requiresForce: z.ZodBoolean;
107
+ warning: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strip>>;
109
+ wuId: z.ZodNullable<z.ZodString>;
110
+ }, z.core.$strip>;
111
+ export type RecoveryIssueCode = z.infer<typeof RecoveryIssueCodeSchema>;
112
+ export type RecoveryActionType = z.infer<typeof RecoveryActionTypeSchema>;
113
+ export type RecoveryIssue = z.infer<typeof RecoveryIssueSchema>;
114
+ export type RecoveryAction = z.infer<typeof RecoveryActionSchema>;
115
+ export type RecoveryAnalysis = z.infer<typeof RecoveryAnalysisSchema>;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Recovery Schemas
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Zod schemas for recovery-related types in the context-aware validation system.
7
+ * Types are inferred from Zod schemas using z.infer<> for single source of truth.
8
+ *
9
+ * @module domain/recovery.schemas
10
+ */
11
+ import { z } from 'zod';
12
+ /**
13
+ * Recovery issue code values
14
+ *
15
+ * Mirrors CONTEXT_VALIDATION.RECOVERY_ISSUES from wu-constants.ts
16
+ */
17
+ export const RECOVERY_ISSUE_CODE_VALUES = [
18
+ 'PARTIAL_CLAIM',
19
+ 'ORPHAN_CLAIM',
20
+ 'INCONSISTENT_STATE',
21
+ 'ORPHAN_BRANCH',
22
+ 'STALE_LOCK',
23
+ 'LEFTOVER_WORKTREE',
24
+ ];
25
+ /**
26
+ * Schema for recovery issue codes
27
+ */
28
+ export const RecoveryIssueCodeSchema = z.enum(RECOVERY_ISSUE_CODE_VALUES);
29
+ /**
30
+ * Recovery action type values
31
+ *
32
+ * Mirrors CONTEXT_VALIDATION.RECOVERY_ACTIONS from wu-constants.ts
33
+ */
34
+ export const RECOVERY_ACTION_TYPE_VALUES = ['resume', 'reset', 'nuke', 'cleanup'];
35
+ /**
36
+ * Schema for recovery action types
37
+ */
38
+ export const RecoveryActionTypeSchema = z.enum(RECOVERY_ACTION_TYPE_VALUES);
39
+ /**
40
+ * Schema for recovery issue
41
+ *
42
+ * Issue detected during recovery analysis.
43
+ */
44
+ export const RecoveryIssueSchema = z.object({
45
+ /** Issue code from RECOVERY_ISSUES */
46
+ code: RecoveryIssueCodeSchema,
47
+ /** Human-readable description */
48
+ description: z.string(),
49
+ /** Additional context for the issue */
50
+ context: z.record(z.string(), z.unknown()).optional(),
51
+ });
52
+ /**
53
+ * Schema for recovery action
54
+ *
55
+ * Suggested recovery action.
56
+ */
57
+ export const RecoveryActionSchema = z.object({
58
+ /** Action type from RECOVERY_ACTIONS */
59
+ type: RecoveryActionTypeSchema,
60
+ /** Human-readable description of what this action does */
61
+ description: z.string(),
62
+ /** Command to execute (copy-paste ready) */
63
+ command: z.string(),
64
+ /** Whether this action requires --force flag */
65
+ requiresForce: z.boolean(),
66
+ /** Warning message if any */
67
+ warning: z.string().optional(),
68
+ });
69
+ /**
70
+ * Schema for recovery analysis result
71
+ *
72
+ * Result of recovery analysis.
73
+ */
74
+ export const RecoveryAnalysisSchema = z.object({
75
+ /** Whether any issues were found */
76
+ hasIssues: z.boolean(),
77
+ /** List of detected issues */
78
+ issues: z.array(RecoveryIssueSchema),
79
+ /** Suggested recovery actions */
80
+ actions: z.array(RecoveryActionSchema),
81
+ /** WU ID analyzed */
82
+ wuId: z.string().nullable(),
83
+ });