@lumenflow/core 1.5.0 → 2.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 (74) hide show
  1. package/README.md +325 -1
  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/context/context-computer.d.ts +46 -0
  11. package/dist/context/context-computer.js +125 -0
  12. package/dist/context/git-state-reader.d.ts +51 -0
  13. package/dist/context/git-state-reader.js +61 -0
  14. package/dist/context/index.d.ts +17 -0
  15. package/dist/context/index.js +17 -0
  16. package/dist/context/location-resolver.d.ts +48 -0
  17. package/dist/context/location-resolver.js +175 -0
  18. package/dist/context/wu-state-reader.d.ts +37 -0
  19. package/dist/context/wu-state-reader.js +76 -0
  20. package/dist/context-di.d.ts +184 -0
  21. package/dist/context-di.js +178 -0
  22. package/dist/context-validation-integration.d.ts +77 -0
  23. package/dist/context-validation-integration.js +157 -0
  24. package/dist/domain/context.schemas.d.ts +147 -0
  25. package/dist/domain/context.schemas.js +126 -0
  26. package/dist/domain/index.d.ts +14 -0
  27. package/dist/domain/index.js +18 -0
  28. package/dist/domain/recovery.schemas.d.ts +115 -0
  29. package/dist/domain/recovery.schemas.js +83 -0
  30. package/dist/domain/validation.schemas.d.ts +146 -0
  31. package/dist/domain/validation.schemas.js +114 -0
  32. package/dist/index.d.ts +17 -0
  33. package/dist/index.js +43 -0
  34. package/dist/lumenflow-config-schema.d.ts +41 -0
  35. package/dist/lumenflow-config-schema.js +37 -0
  36. package/dist/ports/context.ports.d.ts +135 -0
  37. package/dist/ports/context.ports.js +21 -0
  38. package/dist/ports/core-tools.ports.d.ts +266 -0
  39. package/dist/ports/core-tools.ports.js +21 -0
  40. package/dist/ports/git-validator.ports.d.ts +314 -0
  41. package/dist/ports/git-validator.ports.js +12 -0
  42. package/dist/ports/index.d.ts +20 -0
  43. package/dist/ports/index.js +20 -0
  44. package/dist/ports/recovery.ports.d.ts +58 -0
  45. package/dist/ports/recovery.ports.js +17 -0
  46. package/dist/ports/validation.ports.d.ts +74 -0
  47. package/dist/ports/validation.ports.js +17 -0
  48. package/dist/ports/wu-helpers.ports.d.ts +224 -0
  49. package/dist/ports/wu-helpers.ports.js +12 -0
  50. package/dist/recovery/index.d.ts +11 -0
  51. package/dist/recovery/index.js +11 -0
  52. package/dist/recovery/recovery-analyzer.d.ts +66 -0
  53. package/dist/recovery/recovery-analyzer.js +129 -0
  54. package/dist/usecases/analyze-recovery.usecase.d.ts +42 -0
  55. package/dist/usecases/analyze-recovery.usecase.js +45 -0
  56. package/dist/usecases/compute-context.usecase.d.ts +62 -0
  57. package/dist/usecases/compute-context.usecase.js +101 -0
  58. package/dist/usecases/index.d.ts +14 -0
  59. package/dist/usecases/index.js +18 -0
  60. package/dist/usecases/validate-command.usecase.d.ts +55 -0
  61. package/dist/usecases/validate-command.usecase.js +154 -0
  62. package/dist/validation/command-registry.d.ts +38 -0
  63. package/dist/validation/command-registry.js +229 -0
  64. package/dist/validation/index.d.ts +15 -0
  65. package/dist/validation/index.js +15 -0
  66. package/dist/validation/types.d.ts +135 -0
  67. package/dist/validation/types.js +11 -0
  68. package/dist/validation/validate-command.d.ts +27 -0
  69. package/dist/validation/validate-command.js +160 -0
  70. package/dist/wu-constants.d.ts +136 -0
  71. package/dist/wu-constants.js +124 -0
  72. package/dist/wu-helpers.d.ts +5 -1
  73. package/dist/wu-helpers.js +12 -1
  74. package/package.json +4 -2
@@ -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
+ });
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Validation Schemas
3
+ *
4
+ * WU-1093: INIT-002 Phase 1 - Define ports and domain schemas
5
+ *
6
+ * Zod schemas for validation-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/validation.schemas
10
+ */
11
+ import { z } from 'zod';
12
+ import { LocationTypeSchema } from './context.schemas.js';
13
+ export { LocationTypeSchema };
14
+ /**
15
+ * Validation error code values
16
+ *
17
+ * Mirrors CONTEXT_VALIDATION.ERROR_CODES from wu-constants.ts
18
+ */
19
+ export declare const VALIDATION_ERROR_CODE_VALUES: readonly ["WRONG_LOCATION", "WU_NOT_FOUND", "WU_ALREADY_EXISTS", "WRONG_WU_STATUS", "LANE_OCCUPIED", "WORKTREE_EXISTS", "WORKTREE_MISSING", "GATES_NOT_PASSED", "DIRTY_GIT", "REMOTE_UNAVAILABLE", "INCONSISTENT_STATE"];
20
+ /**
21
+ * Schema for validation error codes
22
+ */
23
+ export declare const ValidationErrorCodeSchema: z.ZodEnum<{
24
+ WU_NOT_FOUND: "WU_NOT_FOUND";
25
+ WRONG_LOCATION: "WRONG_LOCATION";
26
+ WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
27
+ WRONG_WU_STATUS: "WRONG_WU_STATUS";
28
+ LANE_OCCUPIED: "LANE_OCCUPIED";
29
+ WORKTREE_EXISTS: "WORKTREE_EXISTS";
30
+ WORKTREE_MISSING: "WORKTREE_MISSING";
31
+ GATES_NOT_PASSED: "GATES_NOT_PASSED";
32
+ DIRTY_GIT: "DIRTY_GIT";
33
+ REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
34
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
35
+ }>;
36
+ /**
37
+ * Severity values
38
+ *
39
+ * Mirrors CONTEXT_VALIDATION.SEVERITY from wu-constants.ts
40
+ */
41
+ export declare const PREDICATE_SEVERITY_VALUES: readonly ["error", "warning"];
42
+ /**
43
+ * Schema for predicate severity
44
+ */
45
+ export declare const PredicateSeveritySchema: z.ZodEnum<{
46
+ error: "error";
47
+ warning: "warning";
48
+ }>;
49
+ /**
50
+ * Schema for validation error with fix guidance
51
+ */
52
+ export declare const ValidationErrorSchema: z.ZodObject<{
53
+ code: z.ZodEnum<{
54
+ WU_NOT_FOUND: "WU_NOT_FOUND";
55
+ WRONG_LOCATION: "WRONG_LOCATION";
56
+ WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
57
+ WRONG_WU_STATUS: "WRONG_WU_STATUS";
58
+ LANE_OCCUPIED: "LANE_OCCUPIED";
59
+ WORKTREE_EXISTS: "WORKTREE_EXISTS";
60
+ WORKTREE_MISSING: "WORKTREE_MISSING";
61
+ GATES_NOT_PASSED: "GATES_NOT_PASSED";
62
+ DIRTY_GIT: "DIRTY_GIT";
63
+ REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
64
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
65
+ }>;
66
+ message: z.ZodString;
67
+ fixCommand: z.ZodNullable<z.ZodString>;
68
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
+ }, z.core.$strip>;
70
+ /**
71
+ * Schema for validation warning (non-blocking)
72
+ */
73
+ export declare const ValidationWarningSchema: z.ZodObject<{
74
+ id: z.ZodString;
75
+ message: z.ZodString;
76
+ }, z.core.$strip>;
77
+ /**
78
+ * Schema for validation result (partial, without context for serialization)
79
+ *
80
+ * Note: The full ValidationResult in types.ts includes the context object,
81
+ * but this schema is for serializable results without the context.
82
+ */
83
+ export declare const ValidationResultSchema: z.ZodObject<{
84
+ valid: z.ZodBoolean;
85
+ errors: z.ZodArray<z.ZodObject<{
86
+ code: z.ZodEnum<{
87
+ WU_NOT_FOUND: "WU_NOT_FOUND";
88
+ WRONG_LOCATION: "WRONG_LOCATION";
89
+ WU_ALREADY_EXISTS: "WU_ALREADY_EXISTS";
90
+ WRONG_WU_STATUS: "WRONG_WU_STATUS";
91
+ LANE_OCCUPIED: "LANE_OCCUPIED";
92
+ WORKTREE_EXISTS: "WORKTREE_EXISTS";
93
+ WORKTREE_MISSING: "WORKTREE_MISSING";
94
+ GATES_NOT_PASSED: "GATES_NOT_PASSED";
95
+ DIRTY_GIT: "DIRTY_GIT";
96
+ REMOTE_UNAVAILABLE: "REMOTE_UNAVAILABLE";
97
+ INCONSISTENT_STATE: "INCONSISTENT_STATE";
98
+ }>;
99
+ message: z.ZodString;
100
+ fixCommand: z.ZodNullable<z.ZodString>;
101
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
102
+ }, z.core.$strip>>;
103
+ warnings: z.ZodArray<z.ZodObject<{
104
+ id: z.ZodString;
105
+ message: z.ZodString;
106
+ }, z.core.$strip>>;
107
+ }, z.core.$strip>;
108
+ /**
109
+ * Schema for command predicate configuration (serializable)
110
+ *
111
+ * This schema represents the serializable configuration of a predicate,
112
+ * not the full CommandPredicate which includes the check function.
113
+ */
114
+ export declare const CommandPredicateConfigSchema: z.ZodObject<{
115
+ id: z.ZodString;
116
+ description: z.ZodString;
117
+ severity: z.ZodEnum<{
118
+ error: "error";
119
+ warning: "warning";
120
+ }>;
121
+ }, z.core.$strip>;
122
+ /**
123
+ * Schema for command definition configuration (serializable)
124
+ *
125
+ * This schema represents the serializable configuration of a command definition,
126
+ * not the full CommandDefinition which includes function references.
127
+ */
128
+ export declare const CommandDefinitionConfigSchema: z.ZodObject<{
129
+ name: z.ZodString;
130
+ description: z.ZodString;
131
+ requiredLocation: z.ZodNullable<z.ZodEnum<{
132
+ unknown: "unknown";
133
+ main: "main";
134
+ worktree: "worktree";
135
+ detached: "detached";
136
+ }>>;
137
+ requiredWuStatus: z.ZodNullable<z.ZodString>;
138
+ predicateIds: z.ZodArray<z.ZodString>;
139
+ }, z.core.$strip>;
140
+ export type ValidationErrorCode = z.infer<typeof ValidationErrorCodeSchema>;
141
+ export type PredicateSeverity = z.infer<typeof PredicateSeveritySchema>;
142
+ export type ValidationError = z.infer<typeof ValidationErrorSchema>;
143
+ export type ValidationWarning = z.infer<typeof ValidationWarningSchema>;
144
+ export type ValidationResult = z.infer<typeof ValidationResultSchema>;
145
+ export type CommandPredicateConfig = z.infer<typeof CommandPredicateConfigSchema>;
146
+ export type CommandDefinitionConfig = z.infer<typeof CommandDefinitionConfigSchema>;