@cleocode/core 2026.3.43 → 2026.3.44
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.
- package/dist/admin/export-tasks.d.ts.map +1 -1
- package/dist/agents/agent-schema.d.ts +358 -0
- package/dist/agents/agent-schema.d.ts.map +1 -0
- package/dist/agents/capacity.d.ts +57 -0
- package/dist/agents/capacity.d.ts.map +1 -0
- package/dist/agents/index.d.ts +17 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/registry.d.ts +115 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/retry.d.ts +83 -0
- package/dist/agents/retry.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +4 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/payload-schemas.d.ts +214 -0
- package/dist/hooks/payload-schemas.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16443 -2160
- package/dist/index.js.map +4 -4
- package/dist/inject/index.d.ts.map +1 -1
- package/dist/intelligence/impact.d.ts +51 -0
- package/dist/intelligence/impact.d.ts.map +1 -0
- package/dist/intelligence/index.d.ts +15 -0
- package/dist/intelligence/index.d.ts.map +1 -0
- package/dist/intelligence/patterns.d.ts +66 -0
- package/dist/intelligence/patterns.d.ts.map +1 -0
- package/dist/intelligence/prediction.d.ts +51 -0
- package/dist/intelligence/prediction.d.ts.map +1 -0
- package/dist/intelligence/types.d.ts +221 -0
- package/dist/intelligence/types.d.ts.map +1 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/issue/template-parser.d.ts +8 -2
- package/dist/issue/template-parser.d.ts.map +1 -1
- package/dist/lifecycle/pipeline.d.ts +2 -2
- package/dist/lifecycle/pipeline.d.ts.map +1 -1
- package/dist/lifecycle/state-machine.d.ts +1 -1
- package/dist/lifecycle/state-machine.d.ts.map +1 -1
- package/dist/memory/brain-lifecycle.d.ts.map +1 -1
- package/dist/memory/brain-retrieval.d.ts.map +1 -1
- package/dist/memory/brain-row-types.d.ts +40 -6
- package/dist/memory/brain-row-types.d.ts.map +1 -1
- package/dist/memory/brain-search.d.ts.map +1 -1
- package/dist/memory/brain-similarity.d.ts.map +1 -1
- package/dist/memory/claude-mem-migration.d.ts.map +1 -1
- package/dist/nexus/discover.d.ts.map +1 -1
- package/dist/orchestration/bootstrap.d.ts.map +1 -1
- package/dist/orchestration/skill-ops.d.ts +4 -4
- package/dist/orchestration/skill-ops.d.ts.map +1 -1
- package/dist/otel/index.d.ts +1 -1
- package/dist/otel/index.d.ts.map +1 -1
- package/dist/sessions/briefing.d.ts.map +1 -1
- package/dist/sessions/handoff.d.ts.map +1 -1
- package/dist/sessions/index.d.ts +1 -1
- package/dist/sessions/index.d.ts.map +1 -1
- package/dist/sessions/types.d.ts +8 -42
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/signaldock/signaldock-transport.d.ts +1 -1
- package/dist/signaldock/signaldock-transport.d.ts.map +1 -1
- package/dist/skills/injection/subagent.d.ts +3 -3
- package/dist/skills/injection/subagent.d.ts.map +1 -1
- package/dist/skills/manifests/contribution.d.ts +2 -2
- package/dist/skills/manifests/contribution.d.ts.map +1 -1
- package/dist/skills/orchestrator/spawn.d.ts +6 -6
- package/dist/skills/orchestrator/spawn.d.ts.map +1 -1
- package/dist/skills/orchestrator/startup.d.ts +1 -1
- package/dist/skills/orchestrator/startup.d.ts.map +1 -1
- package/dist/skills/orchestrator/validator.d.ts +2 -2
- package/dist/skills/orchestrator/validator.d.ts.map +1 -1
- package/dist/skills/precedence-types.d.ts +24 -1
- package/dist/skills/precedence-types.d.ts.map +1 -1
- package/dist/skills/types.d.ts +70 -4
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/store/export.d.ts +5 -4
- package/dist/store/export.d.ts.map +1 -1
- package/dist/store/tasks-schema.d.ts +12 -2
- package/dist/store/tasks-schema.d.ts.map +1 -1
- package/dist/store/typed-query.d.ts +12 -0
- package/dist/store/typed-query.d.ts.map +1 -0
- package/dist/store/validation-schemas.d.ts +2422 -50
- package/dist/store/validation-schemas.d.ts.map +1 -1
- package/dist/system/inject-generate.d.ts.map +1 -1
- package/dist/validation/doctor/checks.d.ts +5 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/engine.d.ts +10 -10
- package/dist/validation/engine.d.ts.map +1 -1
- package/dist/validation/index.d.ts +6 -2
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/protocol-common.d.ts +10 -2
- package/dist/validation/protocol-common.d.ts.map +1 -1
- package/migrations/drizzle-tasks/20260320013731_wave0-schema-hardening/migration.sql +84 -0
- package/migrations/drizzle-tasks/20260320013731_wave0-schema-hardening/snapshot.json +4060 -0
- package/migrations/drizzle-tasks/20260320020000_agent-dimension/migration.sql +35 -0
- package/migrations/drizzle-tasks/20260320020000_agent-dimension/snapshot.json +4312 -0
- package/package.json +2 -2
- package/src/admin/export-tasks.ts +2 -5
- package/src/agents/__tests__/capacity.test.ts +219 -0
- package/src/agents/__tests__/registry.test.ts +457 -0
- package/src/agents/__tests__/retry.test.ts +289 -0
- package/src/agents/agent-schema.ts +107 -0
- package/src/agents/capacity.ts +151 -0
- package/src/agents/index.ts +68 -0
- package/src/agents/registry.ts +449 -0
- package/src/agents/retry.ts +255 -0
- package/src/hooks/index.ts +20 -1
- package/src/hooks/payload-schemas.ts +199 -0
- package/src/index.ts +69 -0
- package/src/inject/index.ts +14 -14
- package/src/intelligence/__tests__/impact.test.ts +453 -0
- package/src/intelligence/__tests__/patterns.test.ts +450 -0
- package/src/intelligence/__tests__/prediction.test.ts +418 -0
- package/src/intelligence/impact.ts +638 -0
- package/src/intelligence/index.ts +47 -0
- package/src/intelligence/patterns.ts +621 -0
- package/src/intelligence/prediction.ts +621 -0
- package/src/intelligence/types.ts +273 -0
- package/src/internal.ts +82 -1
- package/src/issue/template-parser.ts +65 -4
- package/src/lifecycle/pipeline.ts +14 -7
- package/src/lifecycle/state-machine.ts +6 -2
- package/src/memory/brain-lifecycle.ts +5 -11
- package/src/memory/brain-retrieval.ts +44 -38
- package/src/memory/brain-row-types.ts +43 -6
- package/src/memory/brain-search.ts +53 -32
- package/src/memory/brain-similarity.ts +9 -8
- package/src/memory/claude-mem-migration.ts +4 -3
- package/src/nexus/__tests__/nexus-e2e.test.ts +1481 -0
- package/src/nexus/discover.ts +1 -0
- package/src/orchestration/bootstrap.ts +11 -17
- package/src/orchestration/skill-ops.ts +52 -32
- package/src/otel/index.ts +48 -4
- package/src/sessions/__tests__/briefing.test.ts +31 -2
- package/src/sessions/briefing.ts +27 -42
- package/src/sessions/handoff.ts +52 -86
- package/src/sessions/index.ts +5 -1
- package/src/sessions/types.ts +9 -43
- package/src/signaldock/signaldock-transport.ts +5 -2
- package/src/skills/injection/subagent.ts +10 -16
- package/src/skills/manifests/contribution.ts +5 -13
- package/src/skills/orchestrator/__tests__/spawn-tier.test.ts +44 -30
- package/src/skills/orchestrator/spawn.ts +18 -31
- package/src/skills/orchestrator/startup.ts +78 -65
- package/src/skills/orchestrator/validator.ts +26 -31
- package/src/skills/precedence-types.ts +24 -1
- package/src/skills/types.ts +72 -5
- package/src/store/__tests__/test-db-helper.d.ts +4 -4
- package/src/store/__tests__/test-db-helper.js +5 -16
- package/src/store/__tests__/test-db-helper.ts +5 -18
- package/src/store/chain-schema.ts +1 -1
- package/src/store/export.ts +22 -12
- package/src/store/tasks-schema.ts +65 -8
- package/src/store/typed-query.ts +17 -0
- package/src/store/validation-schemas.ts +347 -23
- package/src/system/inject-generate.ts +9 -23
- package/src/validation/doctor/checks.ts +24 -2
- package/src/validation/engine.ts +11 -11
- package/src/validation/index.ts +131 -3
- package/src/validation/protocol-common.ts +54 -3
- package/dist/tasks/reparent.d.ts +0 -38
- package/dist/tasks/reparent.d.ts.map +0 -1
- package/src/tasks/reparent.ts +0 -134
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* directly from Drizzle table definitions in `./schema.ts`. This ensures
|
|
6
6
|
* validation rules stay in sync with the database schema automatically.
|
|
7
7
|
*
|
|
8
|
+
* Also exports canonical Zod enum schemas for all domain enums so that
|
|
9
|
+
* consumers (e.g. CleoOS, plugins) can import them instead of duplicating.
|
|
10
|
+
*
|
|
8
11
|
* @module validation-schemas
|
|
9
12
|
* @task T3.4
|
|
10
13
|
*/
|
|
@@ -20,17 +23,67 @@ const { createInsertSchema, createSelectSchema } = createSchemaFactory(
|
|
|
20
23
|
z as unknown as Parameters<typeof createSchemaFactory>[0],
|
|
21
24
|
);
|
|
22
25
|
|
|
26
|
+
// Brain enum constants
|
|
27
|
+
import {
|
|
28
|
+
BRAIN_CONFIDENCE_LEVELS,
|
|
29
|
+
BRAIN_DECISION_TYPES,
|
|
30
|
+
BRAIN_EDGE_TYPES,
|
|
31
|
+
BRAIN_IMPACT_LEVELS,
|
|
32
|
+
BRAIN_LINK_TYPES,
|
|
33
|
+
BRAIN_MEMORY_TYPES,
|
|
34
|
+
BRAIN_NODE_TYPES,
|
|
35
|
+
BRAIN_OBSERVATION_SOURCE_TYPES,
|
|
36
|
+
BRAIN_OBSERVATION_TYPES,
|
|
37
|
+
BRAIN_OUTCOME_TYPES,
|
|
38
|
+
BRAIN_PATTERN_TYPES,
|
|
39
|
+
BRAIN_STICKY_COLORS,
|
|
40
|
+
BRAIN_STICKY_PRIORITIES,
|
|
41
|
+
BRAIN_STICKY_STATUSES,
|
|
42
|
+
} from './brain-schema.js';
|
|
43
|
+
|
|
44
|
+
// Status constants from the canonical registry
|
|
45
|
+
import {
|
|
46
|
+
ADR_STATUSES,
|
|
47
|
+
GATE_STATUSES,
|
|
48
|
+
LIFECYCLE_PIPELINE_STATUSES,
|
|
49
|
+
LIFECYCLE_STAGE_STATUSES,
|
|
50
|
+
MANIFEST_STATUSES,
|
|
51
|
+
SESSION_STATUSES,
|
|
52
|
+
TASK_STATUSES,
|
|
53
|
+
} from './status-registry.js';
|
|
23
54
|
import {
|
|
55
|
+
// Agent enum constants
|
|
56
|
+
AGENT_INSTANCE_STATUSES,
|
|
57
|
+
AGENT_TYPES,
|
|
58
|
+
agentErrorLog,
|
|
59
|
+
agentInstances,
|
|
24
60
|
architectureDecisions,
|
|
25
61
|
auditLog,
|
|
62
|
+
// Enum constants (non-status) from tasks-schema
|
|
63
|
+
EXTERNAL_LINK_TYPES,
|
|
64
|
+
externalTaskLinks,
|
|
65
|
+
LIFECYCLE_EVIDENCE_TYPES,
|
|
66
|
+
LIFECYCLE_GATE_RESULTS,
|
|
67
|
+
LIFECYCLE_STAGE_NAMES,
|
|
68
|
+
LIFECYCLE_TRANSITION_TYPES,
|
|
26
69
|
lifecycleEvidence,
|
|
27
70
|
lifecycleGateResults,
|
|
28
71
|
lifecyclePipelines,
|
|
29
72
|
lifecycleStages,
|
|
30
73
|
lifecycleTransitions,
|
|
31
74
|
manifestEntries,
|
|
75
|
+
pipelineManifest,
|
|
76
|
+
releaseManifests,
|
|
77
|
+
SYNC_DIRECTIONS,
|
|
32
78
|
schemaMeta,
|
|
33
79
|
sessions,
|
|
80
|
+
TASK_PRIORITIES,
|
|
81
|
+
TASK_RELATION_TYPES,
|
|
82
|
+
TASK_SIZES,
|
|
83
|
+
TASK_TYPES,
|
|
84
|
+
TOKEN_USAGE_CONFIDENCE,
|
|
85
|
+
TOKEN_USAGE_METHODS,
|
|
86
|
+
TOKEN_USAGE_TRANSPORTS,
|
|
34
87
|
taskDependencies,
|
|
35
88
|
taskRelations,
|
|
36
89
|
tasks,
|
|
@@ -38,6 +91,104 @@ import {
|
|
|
38
91
|
tokenUsage,
|
|
39
92
|
} from './tasks-schema.js';
|
|
40
93
|
|
|
94
|
+
// =========================================================================
|
|
95
|
+
// CANONICAL ZOD ENUM SCHEMAS
|
|
96
|
+
// =========================================================================
|
|
97
|
+
// These are the single source of truth for enum validation that consumers
|
|
98
|
+
// (e.g. CleoOS tRPC routers) should import instead of duplicating.
|
|
99
|
+
// Each wraps the corresponding `as const` array from tasks-schema.ts,
|
|
100
|
+
// status-registry.ts, or brain-schema.ts.
|
|
101
|
+
|
|
102
|
+
// --- Task enums ---
|
|
103
|
+
/** Zod enum schema for task statuses. */
|
|
104
|
+
export const taskStatusSchema = z.enum(TASK_STATUSES);
|
|
105
|
+
/** Zod enum schema for task priorities. */
|
|
106
|
+
export const taskPrioritySchema = z.enum(TASK_PRIORITIES);
|
|
107
|
+
/** Zod enum schema for task types. */
|
|
108
|
+
export const taskTypeSchema = z.enum(TASK_TYPES);
|
|
109
|
+
/** Zod enum schema for task sizes. */
|
|
110
|
+
export const taskSizeSchema = z.enum(TASK_SIZES);
|
|
111
|
+
|
|
112
|
+
// --- Session enums ---
|
|
113
|
+
/** Zod enum schema for session statuses. */
|
|
114
|
+
export const sessionStatusSchema = z.enum(SESSION_STATUSES);
|
|
115
|
+
|
|
116
|
+
// --- Lifecycle enums ---
|
|
117
|
+
/** Zod enum schema for lifecycle pipeline statuses. */
|
|
118
|
+
export const lifecyclePipelineStatusSchema = z.enum(LIFECYCLE_PIPELINE_STATUSES);
|
|
119
|
+
/** Zod enum schema for lifecycle stage statuses. */
|
|
120
|
+
export const lifecycleStageStatusSchema = z.enum(LIFECYCLE_STAGE_STATUSES);
|
|
121
|
+
/** Zod enum schema for lifecycle stage names. */
|
|
122
|
+
export const lifecycleStageNameSchema = z.enum(LIFECYCLE_STAGE_NAMES);
|
|
123
|
+
/** Zod enum schema for lifecycle gate results. */
|
|
124
|
+
export const lifecycleGateResultSchema = z.enum(LIFECYCLE_GATE_RESULTS);
|
|
125
|
+
/** Zod enum schema for lifecycle evidence types. */
|
|
126
|
+
export const lifecycleEvidenceTypeSchema = z.enum(LIFECYCLE_EVIDENCE_TYPES);
|
|
127
|
+
|
|
128
|
+
// --- Governance enums ---
|
|
129
|
+
/** Zod enum schema for ADR statuses. */
|
|
130
|
+
export const adrStatusSchema = z.enum(ADR_STATUSES);
|
|
131
|
+
/** Zod enum schema for gate statuses. */
|
|
132
|
+
export const gateStatusSchema = z.enum(GATE_STATUSES);
|
|
133
|
+
/** Zod enum schema for manifest statuses. */
|
|
134
|
+
export const manifestStatusSchema = z.enum(MANIFEST_STATUSES);
|
|
135
|
+
|
|
136
|
+
// --- Token usage enums ---
|
|
137
|
+
/** Zod enum schema for token usage measurement methods. */
|
|
138
|
+
export const tokenUsageMethodSchema = z.enum(TOKEN_USAGE_METHODS);
|
|
139
|
+
/** Zod enum schema for token usage confidence levels. */
|
|
140
|
+
export const tokenUsageConfidenceSchema = z.enum(TOKEN_USAGE_CONFIDENCE);
|
|
141
|
+
/** Zod enum schema for token usage transports. */
|
|
142
|
+
export const tokenUsageTransportSchema = z.enum(TOKEN_USAGE_TRANSPORTS);
|
|
143
|
+
|
|
144
|
+
// --- Task relation enums ---
|
|
145
|
+
/** Zod enum schema for task relation types. */
|
|
146
|
+
export const taskRelationTypeSchema = z.enum(TASK_RELATION_TYPES);
|
|
147
|
+
|
|
148
|
+
// --- External task link enums ---
|
|
149
|
+
/** Zod enum schema for external task link types. */
|
|
150
|
+
export const externalLinkTypeSchema = z.enum(EXTERNAL_LINK_TYPES);
|
|
151
|
+
/** Zod enum schema for sync directions. */
|
|
152
|
+
export const syncDirectionSchema = z.enum(SYNC_DIRECTIONS);
|
|
153
|
+
|
|
154
|
+
// --- Lifecycle transition enums ---
|
|
155
|
+
/** Zod enum schema for lifecycle transition types. */
|
|
156
|
+
export const lifecycleTransitionTypeSchema = z.enum(LIFECYCLE_TRANSITION_TYPES);
|
|
157
|
+
|
|
158
|
+
// --- Brain enums ---
|
|
159
|
+
/** Zod enum schema for brain observation types. */
|
|
160
|
+
export const brainObservationTypeSchema = z.enum(BRAIN_OBSERVATION_TYPES);
|
|
161
|
+
/** Zod enum schema for brain observation source types. */
|
|
162
|
+
export const brainObservationSourceTypeSchema = z.enum(BRAIN_OBSERVATION_SOURCE_TYPES);
|
|
163
|
+
/** Zod enum schema for brain decision types. */
|
|
164
|
+
export const brainDecisionTypeSchema = z.enum(BRAIN_DECISION_TYPES);
|
|
165
|
+
/** Zod enum schema for brain confidence levels. */
|
|
166
|
+
export const brainConfidenceLevelSchema = z.enum(BRAIN_CONFIDENCE_LEVELS);
|
|
167
|
+
/** Zod enum schema for brain outcome types. */
|
|
168
|
+
export const brainOutcomeTypeSchema = z.enum(BRAIN_OUTCOME_TYPES);
|
|
169
|
+
/** Zod enum schema for brain pattern types. */
|
|
170
|
+
export const brainPatternTypeSchema = z.enum(BRAIN_PATTERN_TYPES);
|
|
171
|
+
/** Zod enum schema for brain impact levels. */
|
|
172
|
+
export const brainImpactLevelSchema = z.enum(BRAIN_IMPACT_LEVELS);
|
|
173
|
+
/** Zod enum schema for brain link types. */
|
|
174
|
+
export const brainLinkTypeSchema = z.enum(BRAIN_LINK_TYPES);
|
|
175
|
+
/** Zod enum schema for brain memory entity types. */
|
|
176
|
+
export const brainMemoryTypeSchema = z.enum(BRAIN_MEMORY_TYPES);
|
|
177
|
+
/** Zod enum schema for brain sticky note statuses. */
|
|
178
|
+
export const brainStickyStatusSchema = z.enum(BRAIN_STICKY_STATUSES);
|
|
179
|
+
/** Zod enum schema for brain sticky note colors. */
|
|
180
|
+
export const brainStickyColorSchema = z.enum(BRAIN_STICKY_COLORS);
|
|
181
|
+
/** Zod enum schema for brain sticky note priorities. */
|
|
182
|
+
export const brainStickyPrioritySchema = z.enum(BRAIN_STICKY_PRIORITIES);
|
|
183
|
+
/** Zod enum schema for brain page node types. */
|
|
184
|
+
export const brainNodeTypeSchema = z.enum(BRAIN_NODE_TYPES);
|
|
185
|
+
/** Zod enum schema for brain page edge types. */
|
|
186
|
+
export const brainEdgeTypeSchema = z.enum(BRAIN_EDGE_TYPES);
|
|
187
|
+
|
|
188
|
+
// =========================================================================
|
|
189
|
+
// DRIZZLE-DERIVED INSERT/SELECT SCHEMAS WITH BUSINESS LOGIC REFINEMENTS
|
|
190
|
+
// =========================================================================
|
|
191
|
+
|
|
41
192
|
// === TASKS ===
|
|
42
193
|
|
|
43
194
|
/** Task field refinements matching schema-validator.ts constraints. */
|
|
@@ -57,13 +208,23 @@ export const selectTaskDependencySchema = createSelectSchema(taskDependencies);
|
|
|
57
208
|
|
|
58
209
|
// === TASK RELATIONS ===
|
|
59
210
|
|
|
60
|
-
|
|
61
|
-
|
|
211
|
+
/** Task relation refinements — enforce enum values for relation_type. */
|
|
212
|
+
const taskRelationRefinements = {
|
|
213
|
+
reason: (s: z.ZodString) => s.max(500),
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const insertTaskRelationSchema = createInsertSchema(taskRelations, taskRelationRefinements);
|
|
217
|
+
export const selectTaskRelationSchema = createSelectSchema(taskRelations, taskRelationRefinements);
|
|
62
218
|
|
|
63
219
|
// === SESSIONS ===
|
|
64
220
|
|
|
65
|
-
|
|
66
|
-
|
|
221
|
+
/** Session refinements — name constraints and timestamp validation. */
|
|
222
|
+
const sessionRefinements = {
|
|
223
|
+
name: (s: z.ZodString) => s.min(1).max(200),
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const insertSessionSchema = createInsertSchema(sessions, sessionRefinements);
|
|
227
|
+
export const selectSessionSchema = createSelectSchema(sessions, sessionRefinements);
|
|
67
228
|
|
|
68
229
|
// Session domain types (Session, SessionScope, SessionStats, SessionTaskWork)
|
|
69
230
|
// are defined in @cleocode/contracts — the single source of truth.
|
|
@@ -77,18 +238,60 @@ export const selectWorkHistorySchema = createSelectSchema(taskWorkHistory);
|
|
|
77
238
|
|
|
78
239
|
// === LIFECYCLE PIPELINES ===
|
|
79
240
|
|
|
80
|
-
|
|
81
|
-
|
|
241
|
+
/** Lifecycle pipeline refinements — status and timestamp constraints. */
|
|
242
|
+
const lifecyclePipelineRefinements = {
|
|
243
|
+
id: (s: z.ZodString) => s.min(1),
|
|
244
|
+
taskId: (s: z.ZodString) => s.min(1),
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const insertLifecyclePipelineSchema = createInsertSchema(
|
|
248
|
+
lifecyclePipelines,
|
|
249
|
+
lifecyclePipelineRefinements,
|
|
250
|
+
);
|
|
251
|
+
export const selectLifecyclePipelineSchema = createSelectSchema(
|
|
252
|
+
lifecyclePipelines,
|
|
253
|
+
lifecyclePipelineRefinements,
|
|
254
|
+
);
|
|
82
255
|
|
|
83
256
|
// === LIFECYCLE STAGES ===
|
|
84
257
|
|
|
85
|
-
|
|
86
|
-
|
|
258
|
+
/** Lifecycle stage refinements — sequence must be non-negative. */
|
|
259
|
+
const lifecycleStageRefinements = {
|
|
260
|
+
id: (s: z.ZodString) => s.min(1),
|
|
261
|
+
pipelineId: (s: z.ZodString) => s.min(1),
|
|
262
|
+
blockReason: (s: z.ZodString) => s.max(1000),
|
|
263
|
+
skipReason: (s: z.ZodString) => s.max(1000),
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export const insertLifecycleStageSchema = createInsertSchema(
|
|
267
|
+
lifecycleStages,
|
|
268
|
+
lifecycleStageRefinements,
|
|
269
|
+
);
|
|
270
|
+
export const selectLifecycleStageSchema = createSelectSchema(
|
|
271
|
+
lifecycleStages,
|
|
272
|
+
lifecycleStageRefinements,
|
|
273
|
+
);
|
|
87
274
|
|
|
88
275
|
// === LIFECYCLE GATE RESULTS ===
|
|
89
276
|
|
|
90
|
-
|
|
91
|
-
|
|
277
|
+
/** Lifecycle gate result refinements — gate name and checker constraints. */
|
|
278
|
+
const lifecycleGateResultRefinements = {
|
|
279
|
+
id: (s: z.ZodString) => s.min(1),
|
|
280
|
+
stageId: (s: z.ZodString) => s.min(1),
|
|
281
|
+
gateName: (s: z.ZodString) => s.min(1).max(100),
|
|
282
|
+
checkedBy: (s: z.ZodString) => s.min(1).max(100),
|
|
283
|
+
details: (s: z.ZodString) => s.max(2000),
|
|
284
|
+
reason: (s: z.ZodString) => s.max(1000),
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export const insertLifecycleGateResultSchema = createInsertSchema(
|
|
288
|
+
lifecycleGateResults,
|
|
289
|
+
lifecycleGateResultRefinements,
|
|
290
|
+
);
|
|
291
|
+
export const selectLifecycleGateResultSchema = createSelectSchema(
|
|
292
|
+
lifecycleGateResults,
|
|
293
|
+
lifecycleGateResultRefinements,
|
|
294
|
+
);
|
|
92
295
|
|
|
93
296
|
// === LIFECYCLE EVIDENCE ===
|
|
94
297
|
|
|
@@ -136,10 +339,126 @@ export const AuditLogSelectSchema = selectAuditLogSchema;
|
|
|
136
339
|
|
|
137
340
|
// === ARCHITECTURE DECISIONS ===
|
|
138
341
|
|
|
139
|
-
|
|
140
|
-
|
|
342
|
+
/** Architecture decision refinements — title length and content constraints. */
|
|
343
|
+
const architectureDecisionRefinements = {
|
|
344
|
+
id: (s: z.ZodString) => s.min(1),
|
|
345
|
+
title: (s: z.ZodString) => s.min(1).max(200),
|
|
346
|
+
content: (s: z.ZodString) => s.min(1),
|
|
347
|
+
summary: (s: z.ZodString) => s.max(500),
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
export const insertArchitectureDecisionSchema = createInsertSchema(
|
|
351
|
+
architectureDecisions,
|
|
352
|
+
architectureDecisionRefinements,
|
|
353
|
+
);
|
|
354
|
+
export const selectArchitectureDecisionSchema = createSelectSchema(
|
|
355
|
+
architectureDecisions,
|
|
356
|
+
architectureDecisionRefinements,
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
// === TOKEN USAGE ===
|
|
360
|
+
|
|
361
|
+
/** Token usage refinements — enforce non-negative token counts. */
|
|
362
|
+
const tokenUsageRefinements = {
|
|
363
|
+
id: (s: z.ZodString) => s.min(1),
|
|
364
|
+
provider: (s: z.ZodString) => s.min(1).max(100),
|
|
365
|
+
model: (s: z.ZodString) => s.max(200),
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
export const insertTokenUsageSchema = createInsertSchema(tokenUsage, tokenUsageRefinements);
|
|
369
|
+
export const selectTokenUsageSchema = createSelectSchema(tokenUsage, tokenUsageRefinements);
|
|
370
|
+
|
|
371
|
+
// === MANIFEST ENTRIES ===
|
|
372
|
+
|
|
373
|
+
export const insertManifestEntrySchema = createInsertSchema(manifestEntries);
|
|
374
|
+
export const selectManifestEntrySchema = createSelectSchema(manifestEntries);
|
|
375
|
+
|
|
376
|
+
// === PIPELINE MANIFEST ===
|
|
377
|
+
|
|
378
|
+
/** Pipeline manifest refinements — type and content constraints. */
|
|
379
|
+
const pipelineManifestRefinements = {
|
|
380
|
+
id: (s: z.ZodString) => s.min(1),
|
|
381
|
+
type: (s: z.ZodString) => s.min(1).max(100),
|
|
382
|
+
content: (s: z.ZodString) => s.min(1),
|
|
383
|
+
};
|
|
141
384
|
|
|
142
|
-
|
|
385
|
+
export const insertPipelineManifestSchema = createInsertSchema(
|
|
386
|
+
pipelineManifest,
|
|
387
|
+
pipelineManifestRefinements,
|
|
388
|
+
);
|
|
389
|
+
export const selectPipelineManifestSchema = createSelectSchema(
|
|
390
|
+
pipelineManifest,
|
|
391
|
+
pipelineManifestRefinements,
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
// === RELEASE MANIFESTS ===
|
|
395
|
+
|
|
396
|
+
/** Release manifest refinements — semver format for version. */
|
|
397
|
+
const releaseManifestRefinements = {
|
|
398
|
+
id: (s: z.ZodString) => s.min(1),
|
|
399
|
+
version: (s: z.ZodString) => s.regex(/^\d{4}\.\d+\.\d+$|^\d+\.\d+\.\d+(-[\w.]+)?(\+[\w.]+)?$/),
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export const insertReleaseManifestSchema = createInsertSchema(
|
|
403
|
+
releaseManifests,
|
|
404
|
+
releaseManifestRefinements,
|
|
405
|
+
);
|
|
406
|
+
export const selectReleaseManifestSchema = createSelectSchema(
|
|
407
|
+
releaseManifests,
|
|
408
|
+
releaseManifestRefinements,
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
// === EXTERNAL TASK LINKS ===
|
|
412
|
+
|
|
413
|
+
/** External task link refinements — URL format and field length constraints. */
|
|
414
|
+
const externalTaskLinkRefinements = {
|
|
415
|
+
id: (s: z.ZodString) => s.min(1),
|
|
416
|
+
taskId: (s: z.ZodString) => s.min(1),
|
|
417
|
+
providerId: (s: z.ZodString) => s.min(1).max(100),
|
|
418
|
+
externalId: (s: z.ZodString) => s.min(1),
|
|
419
|
+
externalUrl: (s: z.ZodString) => s.url(),
|
|
420
|
+
externalTitle: (s: z.ZodString) => s.max(500),
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export const insertExternalTaskLinkSchema = createInsertSchema(
|
|
424
|
+
externalTaskLinks,
|
|
425
|
+
externalTaskLinkRefinements,
|
|
426
|
+
);
|
|
427
|
+
export const selectExternalTaskLinkSchema = createSelectSchema(
|
|
428
|
+
externalTaskLinks,
|
|
429
|
+
externalTaskLinkRefinements,
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
// === AGENT INSTANCES ===
|
|
433
|
+
|
|
434
|
+
/** Agent instance refinements — ID format and metadata constraints. */
|
|
435
|
+
const agentInstanceRefinements = {
|
|
436
|
+
id: (s: z.ZodString) => s.regex(/^agt_\d{14}_[0-9a-f]{6}$/),
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
export const insertAgentInstanceSchema = createInsertSchema(
|
|
440
|
+
agentInstances,
|
|
441
|
+
agentInstanceRefinements,
|
|
442
|
+
);
|
|
443
|
+
export const selectAgentInstanceSchema = createSelectSchema(
|
|
444
|
+
agentInstances,
|
|
445
|
+
agentInstanceRefinements,
|
|
446
|
+
);
|
|
447
|
+
|
|
448
|
+
// === AGENT ERROR LOG ===
|
|
449
|
+
|
|
450
|
+
export const insertAgentErrorLogSchema = createInsertSchema(agentErrorLog);
|
|
451
|
+
export const selectAgentErrorLogSchema = createSelectSchema(agentErrorLog);
|
|
452
|
+
|
|
453
|
+
// --- Agent enums ---
|
|
454
|
+
/** Zod enum schema for agent instance statuses. */
|
|
455
|
+
export const agentInstanceStatusSchema = z.enum(AGENT_INSTANCE_STATUSES);
|
|
456
|
+
/** Zod enum schema for agent types. */
|
|
457
|
+
export const agentTypeSchema = z.enum(AGENT_TYPES);
|
|
458
|
+
|
|
459
|
+
// =========================================================================
|
|
460
|
+
// INFERRED TYPES
|
|
461
|
+
// =========================================================================
|
|
143
462
|
|
|
144
463
|
export type InsertTask = z.infer<typeof insertTaskSchema>;
|
|
145
464
|
export type SelectTask = z.infer<typeof selectTaskSchema>;
|
|
@@ -182,21 +501,26 @@ export type AuditLogInsert = InsertAuditLog;
|
|
|
182
501
|
/** Canonical type alias for audit log select (T4848). */
|
|
183
502
|
export type AuditLogSelect = SelectAuditLog;
|
|
184
503
|
|
|
185
|
-
// === TOKEN USAGE ===
|
|
186
|
-
|
|
187
|
-
export const insertTokenUsageSchema = createInsertSchema(tokenUsage);
|
|
188
|
-
export const selectTokenUsageSchema = createSelectSchema(tokenUsage);
|
|
189
|
-
|
|
190
504
|
export type InsertTokenUsage = z.infer<typeof insertTokenUsageSchema>;
|
|
191
505
|
export type SelectTokenUsage = z.infer<typeof selectTokenUsageSchema>;
|
|
192
506
|
|
|
193
507
|
export type InsertArchitectureDecision = z.infer<typeof insertArchitectureDecisionSchema>;
|
|
194
508
|
export type SelectArchitectureDecision = z.infer<typeof selectArchitectureDecisionSchema>;
|
|
195
509
|
|
|
196
|
-
// === MANIFEST ENTRIES ===
|
|
197
|
-
|
|
198
|
-
export const insertManifestEntrySchema = createInsertSchema(manifestEntries);
|
|
199
|
-
export const selectManifestEntrySchema = createSelectSchema(manifestEntries);
|
|
200
|
-
|
|
201
510
|
export type InsertManifestEntry = z.infer<typeof insertManifestEntrySchema>;
|
|
202
511
|
export type SelectManifestEntry = z.infer<typeof selectManifestEntrySchema>;
|
|
512
|
+
|
|
513
|
+
export type InsertPipelineManifest = z.infer<typeof insertPipelineManifestSchema>;
|
|
514
|
+
export type SelectPipelineManifest = z.infer<typeof selectPipelineManifestSchema>;
|
|
515
|
+
|
|
516
|
+
export type InsertReleaseManifest = z.infer<typeof insertReleaseManifestSchema>;
|
|
517
|
+
export type SelectReleaseManifest = z.infer<typeof selectReleaseManifestSchema>;
|
|
518
|
+
|
|
519
|
+
export type InsertExternalTaskLink = z.infer<typeof insertExternalTaskLinkSchema>;
|
|
520
|
+
export type SelectExternalTaskLink = z.infer<typeof selectExternalTaskLinkSchema>;
|
|
521
|
+
|
|
522
|
+
export type InsertAgentInstance = z.infer<typeof insertAgentInstanceSchema>;
|
|
523
|
+
export type SelectAgentInstance = z.infer<typeof selectAgentInstanceSchema>;
|
|
524
|
+
|
|
525
|
+
export type InsertAgentErrorLog = z.infer<typeof insertAgentErrorLogSchema>;
|
|
526
|
+
export type SelectAgentErrorLog = z.infer<typeof selectAgentErrorLogSchema>;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { existsSync, readFileSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
|
-
import { getSessionsPath } from '../paths.js';
|
|
9
8
|
import type { DataAccessor } from '../store/data-accessor.js';
|
|
10
9
|
import { getAccessor } from '../store/data-accessor.js';
|
|
11
10
|
|
|
@@ -15,14 +14,6 @@ export interface InjectGenerateResult {
|
|
|
15
14
|
version: string;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
interface SessionLike {
|
|
19
|
-
id: string;
|
|
20
|
-
status: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
scope?: { type: string; rootTaskId?: string };
|
|
23
|
-
taskWork?: { taskId?: string | null };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
17
|
/** Generate Minimum Viable Injection (MVI) markdown. */
|
|
27
18
|
export async function generateInjection(
|
|
28
19
|
projectRoot: string,
|
|
@@ -46,7 +37,7 @@ export async function generateInjection(
|
|
|
46
37
|
let sessionScope: string | null = null;
|
|
47
38
|
|
|
48
39
|
const acc = accessor ?? (await getAccessor(projectRoot));
|
|
49
|
-
const focusMeta = await acc.getMetaValue<{ currentTask?: string }>('
|
|
40
|
+
const focusMeta = await acc.getMetaValue<{ currentTask?: string | null }>('focus_state');
|
|
50
41
|
const activeSessionMeta = await acc.getMetaValue<string>('activeSession');
|
|
51
42
|
|
|
52
43
|
if (focusMeta) {
|
|
@@ -56,22 +47,17 @@ export async function generateInjection(
|
|
|
56
47
|
activeSessionName = activeSessionMeta;
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
//
|
|
50
|
+
// Load active session from SQLite (ADR-006/ADR-020)
|
|
60
51
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (active) {
|
|
68
|
-
activeSessionName = active.name || active.id;
|
|
69
|
-
focusTask = active.taskWork?.taskId ?? focusTask;
|
|
70
|
-
sessionScope = `${active.scope?.type}:${active.scope?.rootTaskId}`;
|
|
71
|
-
}
|
|
52
|
+
const sessions = await acc.loadSessions();
|
|
53
|
+
const active = sessions.find((s) => s.status === 'active');
|
|
54
|
+
if (active) {
|
|
55
|
+
activeSessionName = active.name || active.id;
|
|
56
|
+
focusTask = active.taskWork?.taskId ?? focusTask;
|
|
57
|
+
sessionScope = `${active.scope?.type}:${active.scope?.rootTaskId}`;
|
|
72
58
|
}
|
|
73
59
|
} catch {
|
|
74
|
-
// fallback to
|
|
60
|
+
// fallback to meta-only data
|
|
75
61
|
}
|
|
76
62
|
|
|
77
63
|
// Storage engine is always sqlite (ADR-006)
|
|
@@ -414,9 +414,26 @@ export function checkCleoGitignore(projectRoot?: string): CheckResult {
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Detect the storage engine from project config.
|
|
417
|
-
*
|
|
417
|
+
*
|
|
418
|
+
* Per ADR-006, SQLite is the only supported storage engine. This function
|
|
419
|
+
* checks the project's .cleo/config.json for an explicit storageEngine
|
|
420
|
+
* override (for forward compatibility) but defaults to 'sqlite'.
|
|
421
|
+
*
|
|
422
|
+
* The projectRoot parameter is used to locate the project-level config.
|
|
418
423
|
*/
|
|
419
|
-
function detectStorageEngine(
|
|
424
|
+
function detectStorageEngine(projectRoot: string): string {
|
|
425
|
+
const configPath = join(projectRoot, '.cleo', 'config.json');
|
|
426
|
+
if (existsSync(configPath)) {
|
|
427
|
+
try {
|
|
428
|
+
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
429
|
+
if (typeof config.storageEngine === 'string' && config.storageEngine) {
|
|
430
|
+
return config.storageEngine;
|
|
431
|
+
}
|
|
432
|
+
} catch {
|
|
433
|
+
// Invalid config; fall through to default
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// ADR-006: SQLite is the canonical and only supported storage engine
|
|
420
437
|
return 'sqlite';
|
|
421
438
|
}
|
|
422
439
|
|
|
@@ -968,6 +985,11 @@ export function checkNodeVersion(): CheckResult {
|
|
|
968
985
|
/**
|
|
969
986
|
* Check that global schemas at ~/.cleo/schemas/ are installed and not stale.
|
|
970
987
|
* Delegates to checkGlobalSchemas() from schema-management.ts.
|
|
988
|
+
*
|
|
989
|
+
* The projectRoot parameter exists for API consistency with other check
|
|
990
|
+
* functions in runAllGlobalChecks(), but global schemas live at ~/.cleo/schemas/
|
|
991
|
+
* (not per-project). The parameter is intentionally unused because schema
|
|
992
|
+
* health is a system-wide concern, not project-scoped.
|
|
971
993
|
*/
|
|
972
994
|
export function checkGlobalSchemaHealth(_projectRoot?: string): CheckResult {
|
|
973
995
|
try {
|
package/src/validation/engine.ts
CHANGED
|
@@ -559,7 +559,8 @@ export interface Task {
|
|
|
559
559
|
[key: string]: unknown;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
-
|
|
562
|
+
/** Task data shape for validation functions. */
|
|
563
|
+
export interface TaskData {
|
|
563
564
|
tasks: Task[];
|
|
564
565
|
project?: {
|
|
565
566
|
currentPhase?: string;
|
|
@@ -572,19 +573,18 @@ export interface TaskFile {
|
|
|
572
573
|
}
|
|
573
574
|
>;
|
|
574
575
|
};
|
|
575
|
-
[key: string]: unknown;
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
-
|
|
578
|
+
/** Archive data shape for validation functions. */
|
|
579
|
+
export interface ArchiveData {
|
|
579
580
|
archived_tasks: Task[];
|
|
580
|
-
[key: string]: unknown;
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
/**
|
|
584
584
|
* Check ID uniqueness within and across files.
|
|
585
585
|
* @task T4523
|
|
586
586
|
*/
|
|
587
|
-
export function checkIdUniqueness(taskFile:
|
|
587
|
+
export function checkIdUniqueness(taskFile: TaskData, archiveFile?: ArchiveData): ValidationResult {
|
|
588
588
|
const errors: ValidationError[] = [];
|
|
589
589
|
|
|
590
590
|
const taskIds = taskFile.tasks.map((t) => t.id).filter((id): id is string => !!id);
|
|
@@ -822,7 +822,7 @@ export function validateNoCircularDeps(
|
|
|
822
822
|
* Validate only one phase is active.
|
|
823
823
|
* @task T4523
|
|
824
824
|
*/
|
|
825
|
-
export function validateSingleActivePhase(taskFile:
|
|
825
|
+
export function validateSingleActivePhase(taskFile: TaskData): ValidationResult {
|
|
826
826
|
const phases = taskFile.project?.phases;
|
|
827
827
|
if (!phases) return { valid: true, errors: [], warnings: [] };
|
|
828
828
|
|
|
@@ -849,7 +849,7 @@ export function validateSingleActivePhase(taskFile: TaskFile): ValidationResult
|
|
|
849
849
|
* Validate currentPhase matches an active phase.
|
|
850
850
|
* @task T4523
|
|
851
851
|
*/
|
|
852
|
-
export function validateCurrentPhaseConsistency(taskFile:
|
|
852
|
+
export function validateCurrentPhaseConsistency(taskFile: TaskData): ValidationResult {
|
|
853
853
|
const currentPhase = taskFile.project?.currentPhase;
|
|
854
854
|
if (!currentPhase) return { valid: true, errors: [], warnings: [] };
|
|
855
855
|
|
|
@@ -892,7 +892,7 @@ export function validateCurrentPhaseConsistency(taskFile: TaskFile): ValidationR
|
|
|
892
892
|
* Validate phase timestamp ordering.
|
|
893
893
|
* @task T4523
|
|
894
894
|
*/
|
|
895
|
-
export function validatePhaseTimestamps(taskFile:
|
|
895
|
+
export function validatePhaseTimestamps(taskFile: TaskData): ValidationResult {
|
|
896
896
|
const phases = taskFile.project?.phases;
|
|
897
897
|
if (!phases) return { valid: true, errors: [], warnings: [] };
|
|
898
898
|
|
|
@@ -917,7 +917,7 @@ export function validatePhaseTimestamps(taskFile: TaskFile): ValidationResult {
|
|
|
917
917
|
* Validate phase status requirements (e.g., active phases must have startedAt).
|
|
918
918
|
* @task T4523
|
|
919
919
|
*/
|
|
920
|
-
export function validatePhaseStatusRequirements(taskFile:
|
|
920
|
+
export function validatePhaseStatusRequirements(taskFile: TaskData): ValidationResult {
|
|
921
921
|
const phases = taskFile.project?.phases;
|
|
922
922
|
if (!phases) return { valid: true, errors: [], warnings: [] };
|
|
923
923
|
|
|
@@ -962,8 +962,8 @@ export interface ComprehensiveValidationResult {
|
|
|
962
962
|
* @task T4523
|
|
963
963
|
*/
|
|
964
964
|
export function validateAll(
|
|
965
|
-
taskFile:
|
|
966
|
-
archiveFile?:
|
|
965
|
+
taskFile: TaskData,
|
|
966
|
+
archiveFile?: ArchiveData,
|
|
967
967
|
): ComprehensiveValidationResult {
|
|
968
968
|
let schemaErrors = 0;
|
|
969
969
|
let semanticErrors = 0;
|