supipowers 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +71 -12
  2. package/package.json +4 -8
  3. package/skills/ui-design/SKILL.md +2 -2
  4. package/src/ai/final-message.ts +15 -1
  5. package/src/ai/schema-text.ts +60 -40
  6. package/src/ai/schema-validation.ts +88 -0
  7. package/src/ai/structured-output.ts +19 -19
  8. package/src/bootstrap.ts +3 -0
  9. package/src/commands/fix-pr.ts +166 -26
  10. package/src/commands/optimize-context.ts +153 -16
  11. package/src/commands/runbook.ts +511 -0
  12. package/src/config/schema.ts +102 -139
  13. package/src/context/rule-renderer.ts +274 -2
  14. package/src/context/runbook-extension-template.ts +193 -0
  15. package/src/context/startup-check.ts +197 -2
  16. package/src/context/startup-optimizer.ts +133 -10
  17. package/src/docs/contracts.ts +13 -23
  18. package/src/fix-pr/assessment.ts +63 -24
  19. package/src/fix-pr/contracts.ts +15 -23
  20. package/src/fix-pr/fetch-comments.ts +119 -0
  21. package/src/fix-pr/prompt-builder.ts +19 -8
  22. package/src/git/commit-contract.ts +13 -19
  23. package/src/git/commit.ts +168 -6
  24. package/src/harness/command.ts +98 -6
  25. package/src/harness/git-verification.ts +515 -0
  26. package/src/harness/git-verify-qa.ts +406 -0
  27. package/src/harness/pipeline.ts +17 -8
  28. package/src/harness/stages/implement-apply.ts +61 -4
  29. package/src/harness/stages/validate.ts +108 -0
  30. package/src/lsp/capabilities.ts +9 -12
  31. package/src/lsp/contracts.ts +15 -23
  32. package/src/planning/planning-ask-tool.ts +13 -2
  33. package/src/planning/spec.ts +21 -27
  34. package/src/planning/system-prompt.ts +1 -1
  35. package/src/planning/validate.ts +4 -7
  36. package/src/platform/progress.ts +11 -0
  37. package/src/quality/contracts.ts +15 -23
  38. package/src/quality/schemas.ts +40 -67
  39. package/src/release/contracts.ts +19 -28
  40. package/src/review/types.ts +142 -186
  41. package/src/types.ts +45 -2
  42. package/src/ui-design/session.ts +13 -2
  43. package/src/ui-design/system-prompt.ts +2 -2
  44. package/src/ultraplan/contracts.ts +458 -524
@@ -1,5 +1,5 @@
1
- import { Type, type TSchema } from "@sinclair/typebox";
2
- import { Value } from "@sinclair/typebox/value";
1
+ import { z } from "zod/v4";
2
+ import type { ZodType } from "zod/v4";
3
3
  import type {
4
4
  ResolvedUltraPlanCatalog,
5
5
  ResolvedUltraPlanSlotBinding,
@@ -61,6 +61,7 @@ import type {
61
61
  UltraPlanStackReview,
62
62
  } from "../types.js";
63
63
  import { getUltraPlanBatchGraphErrors } from "./batch/planner.js";
64
+ import { checkSchema, collectSchemaValidationErrors, parseSchema } from "../ai/schema-validation.js";
64
65
 
65
66
  export type {
66
67
  ResolvedUltraPlanCatalog,
@@ -222,170 +223,157 @@ export const ULTRAPLAN_AUTHORING_FINDING_SOURCES = [
222
223
  ] as const satisfies readonly UltraPlanAuthoringFindingSource[];
223
224
 
224
225
 
225
- function keyedObject(keys: readonly string[], valueSchema: TSchema) {
226
- return Type.Object(
227
- Object.fromEntries(keys.map((key) => [key, valueSchema])) as Record<string, TSchema>,
228
- { additionalProperties: false },
229
- );
226
+ function keyedObject(keys: readonly string[], valueSchema: ZodType) {
227
+ return z.object(
228
+ Object.fromEntries(keys.map((key) => [key, valueSchema])) as Record<string, ZodType>,
229
+ ).strict();
230
230
  }
231
231
 
232
- function sparseKeyedObject(keys: readonly string[], valueSchema: TSchema) {
233
- return Type.Partial(keyedObject(keys, valueSchema));
232
+ function sparseKeyedObject(keys: readonly string[], valueSchema: ZodType) {
233
+ return keyedObject(keys, valueSchema).partial();
234
234
  }
235
235
 
236
236
 
237
237
 
238
238
  function literalUnion<const TValue extends readonly string[]>(values: TValue) {
239
- return Type.Union(values.map((value) => Type.Literal(value)));
239
+ return z.enum([...values] as unknown as [TValue[number], ...TValue[number][]]);
240
240
  }
241
241
 
242
- export const UltraPlanProgressSummarySchema = Type.Object(
242
+ export const UltraPlanProgressSummarySchema = z.object(
243
243
  {
244
- total: Type.Number({ minimum: 0 }),
245
- terminal: Type.Number({ minimum: 0 }),
246
- blocked: Type.Number({ minimum: 0 }),
244
+ total: z.number().min(0),
245
+ terminal: z.number().min(0),
246
+ blocked: z.number().min(0),
247
247
  },
248
- { additionalProperties: false },
249
- );
248
+ ).strict();
250
249
 
251
- export const UltraPlanAffectedUnitRefSchema = Type.Object(
250
+ export const UltraPlanAffectedUnitRefSchema = z.object(
252
251
  {
253
- stack: Type.Union([literalUnion(ULTRAPLAN_STACKS), Type.Null()]),
254
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
255
- level: Type.Union([literalUnion(ULTRAPLAN_LEVELS), Type.Null()]),
256
- scenarioId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
252
+ stack: literalUnion(ULTRAPLAN_STACKS).nullable(),
253
+ domainId: z.string().min(1).nullable(),
254
+ level: literalUnion(ULTRAPLAN_LEVELS).nullable(),
255
+ scenarioId: z.string().min(1).nullable(),
257
256
  },
258
- { additionalProperties: false },
259
- );
257
+ ).strict();
260
258
 
261
- export const UltraPlanProofEvidenceSchema = Type.Object(
259
+ export const UltraPlanProofEvidenceSchema = z.object(
262
260
  {
263
- summary: Type.String({ minLength: 1 }),
264
- command: Type.Optional(Type.String({ minLength: 1 })),
265
- outputRef: Type.Optional(Type.String({ minLength: 1 })),
266
- metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
261
+ summary: z.string().min(1),
262
+ command: z.string().min(1).optional(),
263
+ outputRef: z.string().min(1).optional(),
264
+ metadata: z.record(z.string(), z.unknown()).optional(),
267
265
  },
268
- { additionalProperties: false },
269
- );
266
+ ).strict();
270
267
 
271
- export const UltraPlanProofSchema = Type.Object(
268
+ export const UltraPlanProofSchema = z.object(
272
269
  {
273
270
  type: literalUnion(ULTRAPLAN_PROOF_TYPES),
274
271
  phase: literalUnion(ULTRAPLAN_EXECUTION_PHASES),
275
- recordedAt: Type.String({ minLength: 1 }),
276
- actor: Type.String({ minLength: 1 }),
272
+ recordedAt: z.string().min(1),
273
+ actor: z.string().min(1),
277
274
  evidence: UltraPlanProofEvidenceSchema,
278
- artifactRef: Type.String({ minLength: 1 }),
275
+ artifactRef: z.string().min(1),
279
276
  },
280
- { additionalProperties: false },
281
- );
277
+ ).strict();
282
278
 
283
- export const UltraPlanBlockerSchema = Type.Object(
279
+ export const UltraPlanBlockerSchema = z.object(
284
280
  {
285
- code: Type.String({ minLength: 1 }),
286
- message: Type.String({ minLength: 1 }),
281
+ code: z.string().min(1),
282
+ message: z.string().min(1),
287
283
  scope: literalUnion(ULTRAPLAN_BLOCKER_SCOPES),
288
284
  affected: UltraPlanAffectedUnitRefSchema,
289
- recoverable: Type.Boolean(),
285
+ recoverable: z.boolean(),
290
286
  recoveryMode: literalUnion(ULTRAPLAN_RECOVERY_MODES),
291
- nextAction: Type.String({ minLength: 1 }),
292
- retryable: Type.Boolean(),
293
- detectedAt: Type.String({ minLength: 1 }),
294
- details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
287
+ nextAction: z.string().min(1),
288
+ retryable: z.boolean(),
289
+ detectedAt: z.string().min(1),
290
+ details: z.record(z.string(), z.unknown()).optional(),
295
291
  },
296
- { additionalProperties: false },
297
- );
292
+ ).strict();
298
293
 
299
- export const UltraPlanAgentBindingSchema = Type.Object(
294
+ export const UltraPlanAgentBindingSchema = z.object(
300
295
  {
301
296
  slot: literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES),
302
297
  agentType: literalUnion(ULTRAPLAN_AGENT_TYPES),
303
- agentName: Type.String({ minLength: 1 }),
304
- model: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
305
- thinkingLevel: Type.Union([literalUnion(ULTRAPLAN_THINKING_LEVELS), Type.Null()]),
298
+ agentName: z.string().min(1),
299
+ model: z.string().min(1).nullable(),
300
+ thinkingLevel: literalUnion(ULTRAPLAN_THINKING_LEVELS).nullable(),
306
301
  },
307
- { additionalProperties: false },
308
- );
302
+ ).strict();
309
303
 
310
- export const UltraPlanAgentSlotsSchema = Type.Object(
304
+ export const UltraPlanAgentSlotsSchema = z.object(
311
305
  {
312
306
  executor: UltraPlanAgentBindingSchema,
313
307
  tester: UltraPlanAgentBindingSchema,
314
- domainReviewEnabled: Type.Boolean(),
315
- stackReviewEnabled: Type.Boolean(),
316
- domainReviewer: Type.Optional(UltraPlanAgentBindingSchema),
317
- stackReviewer: Type.Optional(UltraPlanAgentBindingSchema),
308
+ domainReviewEnabled: z.boolean(),
309
+ stackReviewEnabled: z.boolean(),
310
+ domainReviewer: UltraPlanAgentBindingSchema.optional(),
311
+ stackReviewer: UltraPlanAgentBindingSchema.optional(),
318
312
  },
319
- { additionalProperties: false },
320
- );
313
+ ).strict();
321
314
 
322
- export const UltraPlanSlotOverrideSchema = Type.Object(
315
+ export const UltraPlanSlotOverrideSchema = z.object(
323
316
  {
324
- agentName: Type.Optional(Type.String({ minLength: 1 })),
325
- model: Type.Optional(Type.String({ minLength: 1 })),
326
- thinkingLevel: Type.Optional(literalUnion(ULTRAPLAN_THINKING_LEVELS)),
317
+ agentName: z.string().min(1).optional(),
318
+ model: z.string().min(1).optional(),
319
+ thinkingLevel: literalUnion(ULTRAPLAN_THINKING_LEVELS).optional(),
327
320
  },
328
- { additionalProperties: false },
329
- );
321
+ ).strict();
330
322
 
331
- export const UltraPlanReviewGatePolicySchema = Type.Object(
323
+ export const UltraPlanReviewGatePolicySchema = z.object(
332
324
  {
333
- enabled: Type.Boolean(),
325
+ enabled: z.boolean(),
334
326
  },
335
- { additionalProperties: false },
336
- );
327
+ ).strict();
337
328
 
338
- export const UltraPlanConfigSchema = Type.Object(
329
+ export const UltraPlanConfigSchema = z.object(
339
330
  {
340
- slots: Type.Optional(sparseKeyedObject(ULTRAPLAN_AGENT_SLOT_NAMES, UltraPlanSlotOverrideSchema)),
341
- reviewGates: Type.Optional(
342
- sparseKeyedObject(ULTRAPLAN_REVIEWER_SLOT_NAMES, UltraPlanReviewGatePolicySchema),
343
- ),
331
+ slots: sparseKeyedObject(ULTRAPLAN_AGENT_SLOT_NAMES, UltraPlanSlotOverrideSchema).optional(),
332
+ reviewGates: sparseKeyedObject(
333
+ ULTRAPLAN_REVIEWER_SLOT_NAMES,
334
+ UltraPlanReviewGatePolicySchema,
335
+ ).optional(),
344
336
  },
345
- { additionalProperties: false },
346
- );
337
+ ).strict();
347
338
 
348
- export const UltraPlanAgentDefinitionFrontmatterSchema = Type.Object(
339
+ export const UltraPlanAgentDefinitionFrontmatterSchema = z.object(
349
340
  {
350
- name: Type.String({ minLength: 1 }),
351
- description: Type.String({ minLength: 1 }),
352
- supportedSlots: Type.Array(literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES), { minItems: 1 }),
353
- model: Type.Optional(Type.String({ minLength: 1 })),
354
- thinkingLevel: Type.Optional(literalUnion(ULTRAPLAN_THINKING_LEVELS)),
355
- focus: Type.Optional(Type.String({ minLength: 1 })),
341
+ name: z.string().min(1),
342
+ description: z.string().min(1),
343
+ supportedSlots: z.array(literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES)).min(1),
344
+ model: z.string().min(1).optional(),
345
+ thinkingLevel: literalUnion(ULTRAPLAN_THINKING_LEVELS).optional(),
346
+ focus: z.string().min(1).optional(),
356
347
  },
357
- { additionalProperties: false },
358
- );
348
+ ).strict();
359
349
 
360
- export const ResolvedUltraPlanSlotBindingSchema = Type.Object(
350
+ export const ResolvedUltraPlanSlotBindingSchema = z.object(
361
351
  {
362
352
  slot: literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES),
363
353
  agentType: literalUnion(ULTRAPLAN_AGENT_TYPES),
364
- agentName: Type.String({ minLength: 1 }),
365
- model: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
366
- thinkingLevel: Type.Union([literalUnion(ULTRAPLAN_THINKING_LEVELS), Type.Null()]),
354
+ agentName: z.string().min(1),
355
+ model: z.string().min(1).nullable(),
356
+ thinkingLevel: literalUnion(ULTRAPLAN_THINKING_LEVELS).nullable(),
367
357
  selectionSource: literalUnion(ULTRAPLAN_SELECTION_SOURCES),
368
358
  definitionSource: literalUnion(ULTRAPLAN_DEFINITION_SOURCES),
369
359
  modelSource: literalUnion(ULTRAPLAN_RESOLVED_VALUE_SOURCES),
370
360
  thinkingLevelSource: literalUnion(ULTRAPLAN_RESOLVED_VALUE_SOURCES),
371
- definitionPath: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
361
+ definitionPath: z.string().min(1).nullable(),
372
362
  },
373
- { additionalProperties: false },
374
- );
363
+ ).strict();
375
364
 
376
- export const ResolvedUltraPlanCatalogSchema = Type.Object(
365
+ export const ResolvedUltraPlanCatalogSchema = z.object(
377
366
  {
378
367
  slots: keyedObject(
379
368
  ULTRAPLAN_AGENT_SLOT_NAMES,
380
- Type.Union([ResolvedUltraPlanSlotBindingSchema, Type.Null()]),
369
+ ResolvedUltraPlanSlotBindingSchema.nullable(),
381
370
  ),
382
371
  reviewGates: sparseKeyedObject(
383
372
  ULTRAPLAN_REVIEWER_SLOT_NAMES,
384
373
  UltraPlanReviewGatePolicySchema,
385
374
  ),
386
375
  },
387
- { additionalProperties: false },
388
- );
376
+ ).strict();
389
377
 
390
378
 
391
379
  const ULTRAPLAN_NON_TERMINAL_SCENARIO_STATUSES = [
@@ -400,280 +388,258 @@ const ULTRAPLAN_NON_TERMINAL_SCENARIO_STATUSES = [
400
388
  const ULTRAPLAN_TERMINAL_SCENARIO_STATUSES = ["green-proved", "review-passed", "done"] as const;
401
389
 
402
390
  const UltraPlanScenarioSharedShape = {
403
- id: Type.String({ minLength: 1 }),
404
- title: Type.String({ minLength: 1 }),
391
+ id: z.string().min(1),
392
+ title: z.string().min(1),
405
393
  stack: literalUnion(ULTRAPLAN_STACKS),
406
- domainId: Type.String({ minLength: 1 }),
394
+ domainId: z.string().min(1),
407
395
  level: literalUnion(ULTRAPLAN_LEVELS),
408
- steps: Type.Array(Type.String({ minLength: 1 })),
409
- assignedSlots: Type.Array(literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES)),
410
- dependencies: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
411
- blocker: Type.Optional(Type.Union([UltraPlanBlockerSchema, Type.Null()])),
396
+ steps: z.array(z.string().min(1)),
397
+ assignedSlots: z.array(literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES)),
398
+ dependencies: z.array(z.string().min(1)).optional(),
399
+ blocker: UltraPlanBlockerSchema.nullable().optional(),
412
400
  };
413
401
 
414
- export const UltraPlanScenarioSchema = Type.Union([
415
- Type.Object(
402
+ export const UltraPlanScenarioSchema = z.union([
403
+ z.object(
416
404
  {
417
405
  ...UltraPlanScenarioSharedShape,
418
406
  status: literalUnion(ULTRAPLAN_NON_TERMINAL_SCENARIO_STATUSES),
419
- proofs: Type.Array(UltraPlanProofSchema),
407
+ proofs: z.array(UltraPlanProofSchema),
420
408
  },
421
- { additionalProperties: false },
422
- ),
423
- Type.Object(
409
+ ).strict(),
410
+ z.object(
424
411
  {
425
412
  ...UltraPlanScenarioSharedShape,
426
413
  status: literalUnion(ULTRAPLAN_TERMINAL_SCENARIO_STATUSES),
427
- proofs: Type.Array(UltraPlanProofSchema, { minItems: 1 }),
414
+ proofs: z.array(UltraPlanProofSchema).min(1),
428
415
  },
429
- { additionalProperties: false },
430
- ),
416
+ ).strict(),
431
417
  ]);
432
418
 
433
- export const UltraPlanDomainReviewGateSchema = Type.Object(
419
+ export const UltraPlanDomainReviewGateSchema = z.object(
434
420
  {
435
- enabled: Type.Boolean(),
421
+ enabled: z.boolean(),
436
422
  status: literalUnion(ULTRAPLAN_REVIEW_STATUSES),
437
423
  },
438
- { additionalProperties: false },
439
- );
424
+ ).strict();
440
425
 
441
- export const UltraPlanDomainSchema = Type.Object(
426
+ export const UltraPlanDomainSchema = z.object(
442
427
  {
443
- id: Type.String({ minLength: 1 }),
444
- name: Type.String({ minLength: 1 }),
445
- unit: Type.Array(UltraPlanScenarioSchema),
446
- integration: Type.Array(UltraPlanScenarioSchema),
447
- e2e: Type.Array(UltraPlanScenarioSchema),
428
+ id: z.string().min(1),
429
+ name: z.string().min(1),
430
+ unit: z.array(UltraPlanScenarioSchema),
431
+ integration: z.array(UltraPlanScenarioSchema),
432
+ e2e: z.array(UltraPlanScenarioSchema),
448
433
  review: UltraPlanDomainReviewGateSchema,
449
434
  progress: UltraPlanProgressSummarySchema,
450
435
  },
451
- { additionalProperties: false },
452
- );
436
+ ).strict();
453
437
 
454
- export const UltraPlanStackSchema = Type.Object(
438
+ export const UltraPlanStackSchema = z.object(
455
439
  {
456
440
  stack: literalUnion(ULTRAPLAN_STACKS),
457
441
  applicability: literalUnion(ULTRAPLAN_APPLICABILITY),
458
- domains: Type.Array(UltraPlanDomainSchema),
442
+ domains: z.array(UltraPlanDomainSchema),
459
443
  status: literalUnion(ULTRAPLAN_SESSION_STATES),
460
444
  agentSlots: UltraPlanAgentSlotsSchema,
461
445
  progress: UltraPlanProgressSummarySchema,
462
446
  },
463
- { additionalProperties: false },
464
- );
447
+ ).strict();
465
448
 
466
- export const UltraPlanCursorSchema = Type.Object(
449
+ export const UltraPlanCursorSchema = z.object(
467
450
  {
468
451
  targetType: literalUnion(ULTRAPLAN_CURSOR_TARGETS),
469
- stack: Type.Union([literalUnion(ULTRAPLAN_STACKS), Type.Null()]),
470
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
471
- level: Type.Union([literalUnion(ULTRAPLAN_LEVELS), Type.Null()]),
472
- scenarioId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
452
+ stack: literalUnion(ULTRAPLAN_STACKS).nullable(),
453
+ domainId: z.string().min(1).nullable(),
454
+ level: literalUnion(ULTRAPLAN_LEVELS).nullable(),
455
+ scenarioId: z.string().min(1).nullable(),
473
456
  phase: literalUnion(ULTRAPLAN_EXECUTION_PHASES),
474
457
  status: literalUnion([
475
458
  ...ULTRAPLAN_SCENARIO_STATUSES,
476
459
  ...ULTRAPLAN_REVIEW_STATUSES,
477
460
  ...ULTRAPLAN_SESSION_STATES,
478
461
  ] as const),
479
- summary: Type.String({ minLength: 1 }),
462
+ summary: z.string().min(1),
480
463
  },
481
- { additionalProperties: false },
482
- );
464
+ ).strict();
483
465
 
484
- export const UltraPlanDomainReviewSchema = Type.Object(
466
+ export const UltraPlanDomainReviewSchema = z.object(
485
467
  {
486
468
  stack: literalUnion(ULTRAPLAN_STACKS),
487
- domainId: Type.String({ minLength: 1 }),
469
+ domainId: z.string().min(1),
488
470
  reviewerSlot: literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES),
489
471
  status: literalUnion(ULTRAPLAN_REVIEW_STATUSES),
490
- startedAt: Type.String({ minLength: 1 }),
491
- completedAt: Type.Optional(Type.String({ minLength: 1 })),
492
- summary: Type.String({ minLength: 1 }),
493
- artifactRef: Type.String({ minLength: 1 }),
472
+ startedAt: z.string().min(1),
473
+ completedAt: z.string().min(1).optional(),
474
+ summary: z.string().min(1),
475
+ artifactRef: z.string().min(1),
494
476
  },
495
- { additionalProperties: false },
496
- );
477
+ ).strict();
497
478
 
498
- export const UltraPlanStackReviewSchema = Type.Object(
479
+ export const UltraPlanStackReviewSchema = z.object(
499
480
  {
500
481
  stack: literalUnion(ULTRAPLAN_STACKS),
501
482
  reviewerSlot: literalUnion(ULTRAPLAN_AGENT_SLOT_NAMES),
502
483
  status: literalUnion(ULTRAPLAN_REVIEW_STATUSES),
503
- startedAt: Type.String({ minLength: 1 }),
504
- completedAt: Type.Optional(Type.String({ minLength: 1 })),
505
- summary: Type.String({ minLength: 1 }),
506
- artifactRef: Type.String({ minLength: 1 }),
484
+ startedAt: z.string().min(1),
485
+ completedAt: z.string().min(1).optional(),
486
+ summary: z.string().min(1),
487
+ artifactRef: z.string().min(1),
507
488
  },
508
- { additionalProperties: false },
509
- );
489
+ ).strict();
510
490
 
511
- export const UltraPlanAuthoredArtifactSchema = Type.Object(
491
+ export const UltraPlanAuthoredArtifactSchema = z.object(
512
492
  {
513
- sessionId: Type.String({ minLength: 1 }),
514
- title: Type.String({ minLength: 1 }),
515
- goal: Type.String({ minLength: 1 }),
516
- createdAt: Type.String({ minLength: 1 }),
517
- updatedAt: Type.String({ minLength: 1 }),
518
- stacks: Type.Array(UltraPlanStackSchema),
493
+ sessionId: z.string().min(1),
494
+ title: z.string().min(1),
495
+ goal: z.string().min(1),
496
+ createdAt: z.string().min(1),
497
+ updatedAt: z.string().min(1),
498
+ stacks: z.array(UltraPlanStackSchema),
519
499
  },
520
- { additionalProperties: false },
521
- );
500
+ ).strict();
522
501
 
523
- export const UltraPlanManifestAuthoredRefsSchema = Type.Object(
502
+ export const UltraPlanManifestAuthoredRefsSchema = z.object(
524
503
  {
525
- json: Type.String({ minLength: 1 }),
526
- markdown: Type.Optional(Type.String({ minLength: 1 })),
504
+ json: z.string().min(1),
505
+ markdown: z.string().min(1).optional(),
527
506
  },
528
- { additionalProperties: false },
529
- );
507
+ ).strict();
530
508
 
531
- export const UltraPlanManifestStackSummarySchema = Type.Object(
509
+ export const UltraPlanManifestStackSummarySchema = z.object(
532
510
  {
533
511
  stack: literalUnion(ULTRAPLAN_STACKS),
534
512
  applicability: literalUnion(ULTRAPLAN_APPLICABILITY),
535
513
  progress: UltraPlanProgressSummarySchema,
536
- domainCount: Type.Number({ minimum: 0 }),
537
- terminalDomainCount: Type.Number({ minimum: 0 }),
514
+ domainCount: z.number().min(0),
515
+ terminalDomainCount: z.number().min(0),
538
516
  },
539
- { additionalProperties: false },
540
- );
517
+ ).strict();
541
518
 
542
- export const UltraPlanManifestReviewReferenceSchema = Type.Object(
519
+ export const UltraPlanManifestReviewReferenceSchema = z.object(
543
520
  {
544
521
  type: literalUnion(["domain", "stack"] as const),
545
522
  stack: literalUnion(ULTRAPLAN_STACKS),
546
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
547
- path: Type.String({ minLength: 1 }),
523
+ domainId: z.string().min(1).nullable(),
524
+ path: z.string().min(1),
548
525
  status: literalUnion(ULTRAPLAN_REVIEW_STATUSES),
549
526
  },
550
- { additionalProperties: false },
551
- );
527
+ ).strict();
552
528
 
553
529
  // --- Authoring pipeline schemas ---------------------------------------------------
554
530
 
555
- export const UltraPlanAuthoringFindingSchema = Type.Object(
531
+ export const UltraPlanAuthoringFindingSchema = z.object(
556
532
  {
557
- id: Type.String({ minLength: 1 }),
533
+ id: z.string().min(1),
558
534
  severity: literalUnion(ULTRAPLAN_AUTHORING_FINDING_SEVERITIES),
559
535
  source: literalUnion(ULTRAPLAN_AUTHORING_FINDING_SOURCES),
560
- target: Type.Object(
536
+ target: z.object(
561
537
  {
562
- stack: Type.Union([literalUnion(ULTRAPLAN_STACKS), Type.Null()]),
563
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
564
- scenarioId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
538
+ stack: literalUnion(ULTRAPLAN_STACKS).nullable(),
539
+ domainId: z.string().min(1).nullable(),
540
+ scenarioId: z.string().min(1).nullable(),
565
541
  },
566
- { additionalProperties: false },
567
- ),
568
- message: Type.String({ minLength: 1 }),
569
- recommendation: Type.String({ minLength: 1 }),
570
- recordedAt: Type.String({ minLength: 1 }),
542
+ ).strict(),
543
+ message: z.string().min(1),
544
+ recommendation: z.string().min(1),
545
+ recordedAt: z.string().min(1),
571
546
  },
572
- { additionalProperties: false },
573
- );
547
+ ).strict();
574
548
 
575
- export const UltraPlanAuthoringFindingsArtifactSchema = Type.Object(
549
+ export const UltraPlanAuthoringFindingsArtifactSchema = z.object(
576
550
  {
577
- iteration: Type.Integer({ minimum: 1 }),
578
- draftRef: Type.String({ minLength: 1 }),
579
- recordedAt: Type.String({ minLength: 1 }),
580
- findings: Type.Array(UltraPlanAuthoringFindingSchema),
551
+ iteration: z.number().int().min(1),
552
+ draftRef: z.string().min(1),
553
+ recordedAt: z.string().min(1),
554
+ findings: z.array(UltraPlanAuthoringFindingSchema),
581
555
  },
582
- { additionalProperties: false },
583
- );
556
+ ).strict();
584
557
 
585
- export const UltraPlanAuthoringResearchRefSchema = Type.Object(
558
+ export const UltraPlanAuthoringResearchRefSchema = z.object(
586
559
  {
587
560
  stack: literalUnion(ULTRAPLAN_STACKS),
588
- path: Type.String({ minLength: 1 }),
561
+ path: z.string().min(1),
589
562
  },
590
- { additionalProperties: false },
591
- );
563
+ ).strict();
592
564
 
593
- export const UltraPlanAuthoringArtifactRefsSchema = Type.Object(
565
+ export const UltraPlanAuthoringArtifactRefsSchema = z.object(
594
566
  {
595
- intake: Type.Optional(Type.String({ minLength: 1 })),
596
- scout: Type.Optional(Type.String({ minLength: 1 })),
597
- discuss: Type.Optional(Type.String({ minLength: 1 })),
598
- deferredIdeas: Type.Optional(Type.String({ minLength: 1 })),
599
- research: Type.Optional(Type.Array(UltraPlanAuthoringResearchRefSchema)),
600
- researchSummary: Type.Optional(Type.String({ minLength: 1 })),
601
- draft: Type.Optional(Type.String({ minLength: 1 })),
602
- draftMarkdown: Type.Optional(Type.String({ minLength: 1 })),
603
- findings: Type.Optional(Type.String({ minLength: 1 })),
567
+ intake: z.string().min(1).optional(),
568
+ scout: z.string().min(1).optional(),
569
+ discuss: z.string().min(1).optional(),
570
+ deferredIdeas: z.string().min(1).optional(),
571
+ research: z.array(UltraPlanAuthoringResearchRefSchema).optional(),
572
+ researchSummary: z.string().min(1).optional(),
573
+ draft: z.string().min(1).optional(),
574
+ draftMarkdown: z.string().min(1).optional(),
575
+ findings: z.string().min(1).optional(),
604
576
  },
605
- { additionalProperties: false },
606
- );
577
+ ).strict();
607
578
 
608
- export const UltraPlanAuthoringStateSchema = Type.Object(
579
+ export const UltraPlanAuthoringStateSchema = z.object(
609
580
  {
610
581
  pipeline: literalUnion(ULTRAPLAN_AUTHORING_PIPELINE_MODES),
611
582
  stage: literalUnion(ULTRAPLAN_AUTHORING_STAGES),
612
583
  stageStatus: literalUnion(ULTRAPLAN_AUTHORING_STAGE_STATUSES),
613
- iteration: Type.Integer({ minimum: 1 }),
614
- stallReentryCount: Type.Integer({ minimum: 0 }),
584
+ iteration: z.number().int().min(1),
585
+ stallReentryCount: z.number().int().min(0),
615
586
  artifacts: UltraPlanAuthoringArtifactRefsSchema,
616
- blocker: Type.Union([UltraPlanBlockerSchema, Type.Null()]),
617
- startedAt: Type.String({ minLength: 1 }),
618
- updatedAt: Type.String({ minLength: 1 }),
587
+ blocker: UltraPlanBlockerSchema.nullable(),
588
+ startedAt: z.string().min(1),
589
+ updatedAt: z.string().min(1),
619
590
  },
620
- { additionalProperties: false },
621
- );
591
+ ).strict();
622
592
 
623
- export const UltraPlanAuthoringPipelineEventSchema = Type.Object(
593
+ export const UltraPlanAuthoringPipelineEventSchema = z.object(
624
594
  {
625
- recordedAt: Type.String({ minLength: 1 }),
595
+ recordedAt: z.string().min(1),
626
596
  stage: literalUnion(ULTRAPLAN_AUTHORING_STAGES),
627
597
  stageStatus: literalUnion(ULTRAPLAN_AUTHORING_STAGE_STATUSES),
628
- iteration: Type.Integer({ minimum: 1 }),
629
- summary: Type.String(),
630
- details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
598
+ iteration: z.number().int().min(1),
599
+ summary: z.string(),
600
+ details: z.record(z.string(), z.unknown()).optional(),
631
601
  },
632
- { additionalProperties: false },
633
- );
602
+ ).strict();
634
603
 
635
604
 
636
- export const UltraPlanManifestSchema = Type.Object(
605
+ export const UltraPlanManifestSchema = z.object(
637
606
  {
638
- sessionId: Type.String({ minLength: 1 }),
639
- projectName: Type.String({ minLength: 1 }),
640
- title: Type.String({ minLength: 1 }),
607
+ sessionId: z.string().min(1),
608
+ projectName: z.string().min(1),
609
+ title: z.string().min(1),
641
610
  authored: UltraPlanManifestAuthoredRefsSchema,
642
611
  state: literalUnion(ULTRAPLAN_SESSION_STATES),
643
- cursor: Type.Union([UltraPlanCursorSchema, Type.Null()]),
644
- lastCompleted: Type.Union([UltraPlanCursorSchema, Type.Null()]),
612
+ cursor: UltraPlanCursorSchema.nullable(),
613
+ lastCompleted: UltraPlanCursorSchema.nullable(),
645
614
  progress: UltraPlanProgressSummarySchema,
646
- stacks: Type.Array(UltraPlanManifestStackSummarySchema),
647
- blocker: Type.Union([UltraPlanBlockerSchema, Type.Null()]),
648
- reviews: Type.Array(UltraPlanManifestReviewReferenceSchema),
649
- createdAt: Type.String({ minLength: 1 }),
650
- updatedAt: Type.String({ minLength: 1 }),
651
- authoring: Type.Optional(UltraPlanAuthoringStateSchema),
615
+ stacks: z.array(UltraPlanManifestStackSummarySchema),
616
+ blocker: UltraPlanBlockerSchema.nullable(),
617
+ reviews: z.array(UltraPlanManifestReviewReferenceSchema),
618
+ createdAt: z.string().min(1),
619
+ updatedAt: z.string().min(1),
620
+ authoring: UltraPlanAuthoringStateSchema.optional(),
652
621
  },
653
- { additionalProperties: false },
654
- );
622
+ ).strict();
655
623
 
656
- export const UltraPlanIndexEntrySchema = Type.Object(
624
+ export const UltraPlanIndexEntrySchema = z.object(
657
625
  {
658
- sessionId: Type.String({ minLength: 1 }),
659
- title: Type.String({ minLength: 1 }),
626
+ sessionId: z.string().min(1),
627
+ title: z.string().min(1),
660
628
  state: literalUnion(ULTRAPLAN_SESSION_STATES),
661
629
  bucket: literalUnion(ULTRAPLAN_SESSION_BUCKETS),
662
- createdAt: Type.String({ minLength: 1 }),
663
- updatedAt: Type.String({ minLength: 1 }),
664
- cursor: Type.Union([UltraPlanCursorSchema, Type.Null()]),
665
- idleReason: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
666
- authoringStage: Type.Optional(Type.Union([literalUnion(ULTRAPLAN_AUTHORING_STAGES), Type.Null()])),
630
+ createdAt: z.string().min(1),
631
+ updatedAt: z.string().min(1),
632
+ cursor: UltraPlanCursorSchema.nullable(),
633
+ idleReason: z.string().min(1).nullable(),
634
+ authoringStage: literalUnion(ULTRAPLAN_AUTHORING_STAGES).nullable().optional(),
667
635
  },
668
- { additionalProperties: false },
669
- );
636
+ ).strict();
670
637
 
671
- export const UltraPlanIndexSchema = Type.Object(
638
+ export const UltraPlanIndexSchema = z.object(
672
639
  {
673
- sessions: Type.Array(UltraPlanIndexEntrySchema),
640
+ sessions: z.array(UltraPlanIndexEntrySchema),
674
641
  },
675
- { additionalProperties: false },
676
- );
642
+ ).strict();
677
643
 
678
644
  type UltraPlanTerminalProofRequirement = {
679
645
  phase: UltraPlanProof["phase"];
@@ -701,15 +667,15 @@ function getRequiredUltraPlanTerminalProofRequirements(
701
667
 
702
668
  function formatUltraPlanRequiredProofTypes(types: readonly UltraPlanProof["type"][]): string {
703
669
  return types.length === 1
704
- ? `\"${types[0]}\"`
705
- : types.map((type) => `\"${type}\"`).join(" or ");
670
+ ? `"${types[0]}"`
671
+ : types.map((type) => `"${type}"`).join(" or ");
706
672
  }
707
673
 
708
674
  function formatUltraPlanTerminalProofRequirements(
709
675
  requirements: readonly UltraPlanTerminalProofRequirement[],
710
676
  ): string {
711
677
  return requirements
712
- .map((requirement) => `a \"${requirement.phase}\" proof of type ${formatUltraPlanRequiredProofTypes(requirement.types)}`)
678
+ .map((requirement) => `a "${requirement.phase}" proof of type ${formatUltraPlanRequiredProofTypes(requirement.types)}`)
713
679
  .join(" or ");
714
680
  }
715
681
 
@@ -733,7 +699,7 @@ function collectUltraPlanScenarioProofErrors(
733
699
  }
734
700
 
735
701
  errors.push(
736
- `/stacks/${scenario.stack}/domains/${scenario.domainId}/${level}/${scenario.id} terminal scenario \"${scenario.id}\" with status \"${scenario.status}\" requires at least one terminal proof: ${formatUltraPlanTerminalProofRequirements(requirements)}`,
702
+ `/stacks/${scenario.stack}/domains/${scenario.domainId}/${level}/${scenario.id} terminal scenario "${scenario.id}" with status "${scenario.status}" requires at least one terminal proof: ${formatUltraPlanTerminalProofRequirements(requirements)}`,
737
703
  );
738
704
  }
739
705
  }
@@ -753,20 +719,21 @@ function getUltraPlanAuthoredArtifactSemanticErrors(authored: UltraPlanAuthoredA
753
719
  }
754
720
 
755
721
 
756
- export function getUltraPlanSchemaErrors(schema: TSchema, value: unknown): string[] {
757
- return [...Value.Errors(schema, value)].map((error) => `${error.path || "/"} ${error.message}`);
722
+ export function getUltraPlanSchemaErrors(schema: ZodType, value: unknown): string[] {
723
+ return collectSchemaValidationErrors(schema, value).map((error) => `${error.path === "(root)" ? "/" : error.path} ${error.message}`);
758
724
  }
759
725
 
760
- function buildValidationResult<T>(schema: TSchema, value: unknown):
726
+ function buildValidationResult<T>(schema: ZodType<T>, value: unknown):
761
727
  | { ok: true; value: T }
762
728
  | { ok: false; errors: string[] } {
763
- if (Value.Check(schema, value)) {
764
- return { ok: true, value: value as T };
729
+ const result = parseSchema<T>(schema, value);
730
+ if (result.success) {
731
+ return { ok: true, value: result.data };
765
732
  }
766
733
 
767
734
  return {
768
735
  ok: false,
769
- errors: getUltraPlanSchemaErrors(schema, value),
736
+ errors: result.errors.map((error) => `${error.path === "(root)" ? "/" : error.path} ${error.message}`),
770
737
  };
771
738
  }
772
739
 
@@ -813,53 +780,53 @@ export function validateUltraPlanAuthoredArtifact(value: unknown) {
813
780
  export function isUltraPlanAgentDefinitionFrontmatter(
814
781
  value: unknown,
815
782
  ): value is UltraPlanAgentDefinitionFrontmatter {
816
- return Value.Check(UltraPlanAgentDefinitionFrontmatterSchema, value);
783
+ return checkSchema(UltraPlanAgentDefinitionFrontmatterSchema, value);
817
784
  }
818
785
 
819
786
  export function isResolvedUltraPlanSlotBinding(value: unknown): value is ResolvedUltraPlanSlotBinding {
820
- return Value.Check(ResolvedUltraPlanSlotBindingSchema, value);
787
+ return checkSchema(ResolvedUltraPlanSlotBindingSchema, value);
821
788
  }
822
789
 
823
790
  export function isResolvedUltraPlanCatalog(value: unknown): value is ResolvedUltraPlanCatalog {
824
- return Value.Check(ResolvedUltraPlanCatalogSchema, value);
791
+ return checkSchema(ResolvedUltraPlanCatalogSchema, value);
825
792
  }
826
793
 
827
794
 
828
795
  export function isUltraPlanProof(value: unknown): value is UltraPlanProof {
829
- return Value.Check(UltraPlanProofSchema, value);
796
+ return checkSchema(UltraPlanProofSchema, value);
830
797
  }
831
798
 
832
799
  export function isUltraPlanBlocker(value: unknown): value is UltraPlanBlocker {
833
- return Value.Check(UltraPlanBlockerSchema, value);
800
+ return checkSchema(UltraPlanBlockerSchema, value);
834
801
  }
835
802
 
836
803
  export function isUltraPlanScenario(value: unknown): value is UltraPlanScenario {
837
- return Value.Check(UltraPlanScenarioSchema, value)
804
+ return checkSchema(UltraPlanScenarioSchema, value)
838
805
  && hasRequiredUltraPlanScenarioProof(value as UltraPlanScenario);
839
806
  }
840
807
 
841
808
  export function isUltraPlanDomain(value: unknown): value is UltraPlanDomain {
842
- return Value.Check(UltraPlanDomainSchema, value);
809
+ return checkSchema(UltraPlanDomainSchema, value);
843
810
  }
844
811
 
845
812
  export function isUltraPlanAgentSlots(value: unknown): value is UltraPlanAgentSlots {
846
- return Value.Check(UltraPlanAgentSlotsSchema, value);
813
+ return checkSchema(UltraPlanAgentSlotsSchema, value);
847
814
  }
848
815
 
849
816
  export function isUltraPlanStack(value: unknown): value is UltraPlanStack {
850
- return Value.Check(UltraPlanStackSchema, value);
817
+ return checkSchema(UltraPlanStackSchema, value);
851
818
  }
852
819
 
853
820
  export function isUltraPlanCursor(value: unknown): value is UltraPlanCursor {
854
- return Value.Check(UltraPlanCursorSchema, value);
821
+ return checkSchema(UltraPlanCursorSchema, value);
855
822
  }
856
823
 
857
824
  export function isUltraPlanDomainReview(value: unknown): value is UltraPlanDomainReview {
858
- return Value.Check(UltraPlanDomainReviewSchema, value);
825
+ return checkSchema(UltraPlanDomainReviewSchema, value);
859
826
  }
860
827
 
861
828
  export function isUltraPlanStackReview(value: unknown): value is UltraPlanStackReview {
862
- return Value.Check(UltraPlanStackReviewSchema, value);
829
+ return checkSchema(UltraPlanStackReviewSchema, value);
863
830
  }
864
831
 
865
832
  export function isUltraPlanAuthoredArtifact(value: unknown): value is UltraPlanAuthoredArtifact {
@@ -867,15 +834,15 @@ export function isUltraPlanAuthoredArtifact(value: unknown): value is UltraPlanA
867
834
  }
868
835
 
869
836
  export function isUltraPlanManifest(value: unknown): value is UltraPlanManifest {
870
- return Value.Check(UltraPlanManifestSchema, value);
837
+ return checkSchema(UltraPlanManifestSchema, value);
871
838
  }
872
839
 
873
840
  export function isUltraPlanIndexEntry(value: unknown): value is UltraPlanIndexEntry {
874
- return Value.Check(UltraPlanIndexEntrySchema, value);
841
+ return checkSchema(UltraPlanIndexEntrySchema, value);
875
842
  }
876
843
 
877
844
  export function isUltraPlanIndex(value: unknown): value is UltraPlanIndex {
878
- return Value.Check(UltraPlanIndexSchema, value);
845
+ return checkSchema(UltraPlanIndexSchema, value);
879
846
  }
880
847
 
881
848
 
@@ -919,294 +886,266 @@ export const ULTRAPLAN_RUNTIME_BLOCKER_CODES = [
919
886
  "migration-conflict",
920
887
  ] as const;
921
888
 
922
- export const UltraPlanLaunchContextSchema = Type.Object(
889
+ export const UltraPlanLaunchContextSchema = z.object(
923
890
  {
924
- attemptId: Type.String({ minLength: 1 }),
925
- attemptKey: Type.String({ minLength: 1 }),
891
+ attemptId: z.string().min(1),
892
+ attemptKey: z.string().min(1),
926
893
  sourceAgent: literalUnion(ULTRAPLAN_SOURCE_AGENTS),
927
- launchedAt: Type.String({ minLength: 1 }),
894
+ launchedAt: z.string().min(1),
928
895
  },
929
- { additionalProperties: false },
930
- );
896
+ ).strict();
931
897
 
932
- export const UltraPlanObservationTargetSchema = Type.Object(
898
+ export const UltraPlanObservationTargetSchema = z.object(
933
899
  {
934
900
  targetType: literalUnion(ULTRAPLAN_CURSOR_TARGETS),
935
- stack: Type.Union([literalUnion(ULTRAPLAN_STACKS), Type.Null()]),
936
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
937
- level: Type.Union([literalUnion(ULTRAPLAN_LEVELS), Type.Null()]),
938
- scenarioId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
901
+ stack: literalUnion(ULTRAPLAN_STACKS).nullable(),
902
+ domainId: z.string().min(1).nullable(),
903
+ level: literalUnion(ULTRAPLAN_LEVELS).nullable(),
904
+ scenarioId: z.string().min(1).nullable(),
939
905
  phase: literalUnion(ULTRAPLAN_EXECUTION_PHASES),
940
- resolvedSlot: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
906
+ resolvedSlot: z.string().min(1).nullable(),
941
907
  },
942
- { additionalProperties: false },
943
- );
908
+ ).strict();
944
909
 
945
- export const UltraPlanObservationCorrelationFailureSchema = Type.Object(
910
+ export const UltraPlanObservationCorrelationFailureSchema = z.object(
946
911
  {
947
- reason: Type.String({ minLength: 1 }),
948
- details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
912
+ reason: z.string().min(1),
913
+ details: z.record(z.string(), z.unknown()).optional(),
949
914
  },
950
- { additionalProperties: false },
951
- );
915
+ ).strict();
952
916
 
953
- export const UltraPlanHookObservationSchema = Type.Object(
917
+ export const UltraPlanHookObservationSchema = z.object(
954
918
  {
955
- sessionId: Type.String({ minLength: 1 }),
919
+ sessionId: z.string().min(1),
956
920
  hookEvent: literalUnion(ULTRAPLAN_HOOK_EVENT_NAMES),
957
921
  actorKind: literalUnion(ULTRAPLAN_ACTOR_KINDS),
958
- attemptId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
959
- attemptKey: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
922
+ attemptId: z.string().min(1).nullable(),
923
+ attemptKey: z.string().min(1).nullable(),
960
924
  sourceAgent: literalUnion(ULTRAPLAN_SOURCE_AGENTS),
961
- occurredAt: Type.String({ minLength: 1 }),
962
- causationId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
963
- fingerprint: Type.String({ minLength: 1 }),
964
- target: Type.Union([UltraPlanObservationTargetSchema, Type.Null()]),
965
- correlationFailure: Type.Union([UltraPlanObservationCorrelationFailureSchema, Type.Null()]),
966
- payloadSummary: Type.String(),
925
+ occurredAt: z.string().min(1),
926
+ causationId: z.string().min(1).nullable(),
927
+ fingerprint: z.string().min(1),
928
+ target: UltraPlanObservationTargetSchema.nullable(),
929
+ correlationFailure: UltraPlanObservationCorrelationFailureSchema.nullable(),
930
+ payloadSummary: z.string(),
967
931
  },
968
- { additionalProperties: false },
969
- );
932
+ ).strict();
970
933
 
971
- export const UltraPlanProofCandidateTargetSchema = Type.Object(
934
+ export const UltraPlanProofCandidateTargetSchema = z.object(
972
935
  {
973
936
  targetType: literalUnion(ULTRAPLAN_CURSOR_TARGETS),
974
- stack: Type.Union([literalUnion(ULTRAPLAN_STACKS), Type.Null()]),
975
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
976
- level: Type.Union([literalUnion(ULTRAPLAN_LEVELS), Type.Null()]),
977
- scenarioId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
937
+ stack: literalUnion(ULTRAPLAN_STACKS).nullable(),
938
+ domainId: z.string().min(1).nullable(),
939
+ level: literalUnion(ULTRAPLAN_LEVELS).nullable(),
940
+ scenarioId: z.string().min(1).nullable(),
978
941
  },
979
- { additionalProperties: false },
980
- );
942
+ ).strict();
981
943
 
982
- export const UltraPlanProofCandidateSchema = Type.Object(
944
+ export const UltraPlanProofCandidateSchema = z.object(
983
945
  {
984
946
  phase: literalUnion(ULTRAPLAN_EXECUTION_PHASES),
985
947
  type: literalUnion(ULTRAPLAN_PROOF_TYPES),
986
948
  target: UltraPlanProofCandidateTargetSchema,
987
949
  evidence: UltraPlanProofEvidenceSchema,
988
- artifactRef: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
989
- observationFingerprint: Type.String({ minLength: 1 }),
990
- fingerprint: Type.String({ minLength: 1 }),
950
+ artifactRef: z.string().min(1).nullable(),
951
+ observationFingerprint: z.string().min(1),
952
+ fingerprint: z.string().min(1),
991
953
  },
992
- { additionalProperties: false },
993
- );
954
+ ).strict();
994
955
 
995
- export const UltraPlanBlockerCandidateSchema = Type.Object(
956
+ export const UltraPlanBlockerCandidateSchema = z.object(
996
957
  {
997
958
  blocker: UltraPlanBlockerSchema,
998
- observationFingerprint: Type.String({ minLength: 1 }),
959
+ observationFingerprint: z.string().min(1),
999
960
  },
1000
- { additionalProperties: false },
1001
- );
961
+ ).strict();
1002
962
 
1003
- export const UltraPlanAttemptRecordSchema = Type.Object(
963
+ export const UltraPlanAttemptRecordSchema = z.object(
1004
964
  {
1005
- attemptId: Type.String({ minLength: 1 }),
1006
- attemptKey: Type.String({ minLength: 1 }),
965
+ attemptId: z.string().min(1),
966
+ attemptKey: z.string().min(1),
1007
967
  launchContext: UltraPlanLaunchContextSchema,
1008
- cursorSnapshot: Type.Union([UltraPlanCursorSchema, Type.Null()]),
1009
- observations: Type.Array(UltraPlanHookObservationSchema),
1010
- proofCandidates: Type.Array(UltraPlanProofCandidateSchema),
1011
- blockerCandidates: Type.Array(UltraPlanBlockerCandidateSchema),
1012
- outcome: Type.Union([literalUnion(ULTRAPLAN_ATTEMPT_OUTCOMES), Type.Null()]),
1013
- startedAt: Type.String({ minLength: 1 }),
1014
- finalizedAt: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
968
+ cursorSnapshot: UltraPlanCursorSchema.nullable(),
969
+ observations: z.array(UltraPlanHookObservationSchema),
970
+ proofCandidates: z.array(UltraPlanProofCandidateSchema),
971
+ blockerCandidates: z.array(UltraPlanBlockerCandidateSchema),
972
+ outcome: literalUnion(ULTRAPLAN_ATTEMPT_OUTCOMES).nullable(),
973
+ startedAt: z.string().min(1),
974
+ finalizedAt: z.string().min(1).nullable(),
1015
975
  },
1016
- { additionalProperties: false },
1017
- );
976
+ ).strict();
1018
977
 
1019
- export const UltraPlanScenarioStatusUpdateSchema = Type.Object(
978
+ export const UltraPlanScenarioStatusUpdateSchema = z.object(
1020
979
  {
1021
980
  stack: literalUnion(ULTRAPLAN_STACKS),
1022
- domainId: Type.String({ minLength: 1 }),
981
+ domainId: z.string().min(1),
1023
982
  level: literalUnion(ULTRAPLAN_LEVELS),
1024
- scenarioId: Type.String({ minLength: 1 }),
983
+ scenarioId: z.string().min(1),
1025
984
  nextStatus: literalUnion(ULTRAPLAN_SCENARIO_STATUSES),
1026
- appendProof: Type.Optional(UltraPlanProofSchema),
985
+ appendProof: UltraPlanProofSchema.optional(),
1027
986
  },
1028
- { additionalProperties: false },
1029
- );
987
+ ).strict();
1030
988
 
1031
- export const UltraPlanReviewStatusUpdateSchema = Type.Object(
989
+ export const UltraPlanReviewStatusUpdateSchema = z.object(
1032
990
  {
1033
991
  type: literalUnion(["domain", "stack"] as const),
1034
992
  stack: literalUnion(ULTRAPLAN_STACKS),
1035
- domainId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
993
+ domainId: z.string().min(1).nullable(),
1036
994
  nextStatus: literalUnion(ULTRAPLAN_REVIEW_STATUSES),
1037
- artifactRef: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
995
+ artifactRef: z.string().min(1).nullable(),
1038
996
  },
1039
- { additionalProperties: false },
1040
- );
997
+ ).strict();
1041
998
 
1042
- export const UltraPlanBlockerUpdateSchema = Type.Object(
999
+ export const UltraPlanBlockerUpdateSchema = z.object(
1043
1000
  {
1044
1001
  scope: literalUnion(ULTRAPLAN_BLOCKER_SCOPES),
1045
- nextValue: Type.Union([UltraPlanBlockerSchema, Type.Null()]),
1046
- clearedByObservationFingerprint: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1002
+ nextValue: UltraPlanBlockerSchema.nullable(),
1003
+ clearedByObservationFingerprint: z.string().min(1).nullable(),
1047
1004
  },
1048
- { additionalProperties: false },
1049
- );
1005
+ ).strict();
1050
1006
 
1051
- export const UltraPlanRepairActionSchema = Type.Union([
1052
- Type.Object(
1007
+ export const UltraPlanRepairActionSchema = z.union([
1008
+ z.object(
1053
1009
  {
1054
- op: Type.Literal("recompute-cursor"),
1055
- reason: Type.String({ minLength: 1 }),
1010
+ op: z.literal("recompute-cursor"),
1011
+ reason: z.string().min(1),
1056
1012
  },
1057
- { additionalProperties: false },
1058
- ),
1059
- Type.Object(
1013
+ ).strict(),
1014
+ z.object(
1060
1015
  {
1061
- op: Type.Literal("recompute-progress"),
1062
- reason: Type.String({ minLength: 1 }),
1016
+ op: z.literal("recompute-progress"),
1017
+ reason: z.string().min(1),
1063
1018
  },
1064
- { additionalProperties: false },
1065
- ),
1066
- Type.Object(
1019
+ ).strict(),
1020
+ z.object(
1067
1021
  {
1068
- op: Type.Literal("clear-active-attempt"),
1069
- reason: Type.String({ minLength: 1 }),
1022
+ op: z.literal("clear-active-attempt"),
1023
+ reason: z.string().min(1),
1070
1024
  },
1071
- { additionalProperties: false },
1072
- ),
1073
- Type.Object(
1025
+ ).strict(),
1026
+ z.object(
1074
1027
  {
1075
- op: Type.Literal("convert-active-to-interrupted"),
1076
- attemptId: Type.String({ minLength: 1 }),
1077
- reason: Type.String({ minLength: 1 }),
1028
+ op: z.literal("convert-active-to-interrupted"),
1029
+ attemptId: z.string().min(1),
1030
+ reason: z.string().min(1),
1078
1031
  },
1079
- { additionalProperties: false },
1080
- ),
1081
- Type.Object(
1032
+ ).strict(),
1033
+ z.object(
1082
1034
  {
1083
- op: Type.Literal("clear-blocker"),
1035
+ op: z.literal("clear-blocker"),
1084
1036
  scope: literalUnion(ULTRAPLAN_BLOCKER_SCOPES),
1085
- clearedByObservationFingerprint: Type.String({ minLength: 1 }),
1037
+ clearedByObservationFingerprint: z.string().min(1),
1086
1038
  },
1087
- { additionalProperties: false },
1088
- ),
1039
+ ).strict(),
1089
1040
  ]);
1090
1041
 
1091
- export const UltraPlanTrackerAttemptFinalizationSchema = Type.Object(
1042
+ export const UltraPlanTrackerAttemptFinalizationSchema = z.object(
1092
1043
  {
1093
- attemptId: Type.String({ minLength: 1 }),
1044
+ attemptId: z.string().min(1),
1094
1045
  outcome: literalUnion(ULTRAPLAN_ATTEMPT_OUTCOMES),
1095
- finalizedAt: Type.String({ minLength: 1 }),
1046
+ finalizedAt: z.string().min(1),
1096
1047
  },
1097
- { additionalProperties: false },
1098
- );
1048
+ ).strict();
1099
1049
 
1100
- export const UltraPlanMutationPlanSchema = Type.Object(
1050
+ export const UltraPlanMutationPlanSchema = z.object(
1101
1051
  {
1102
1052
  kind: literalUnion(ULTRAPLAN_MUTATION_KINDS),
1103
- rationale: Type.String({ minLength: 1 }),
1104
- appendObservationFingerprint: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1105
- scenarioStatusUpdate: Type.Union([UltraPlanScenarioStatusUpdateSchema, Type.Null()]),
1106
- reviewStatusUpdate: Type.Union([UltraPlanReviewStatusUpdateSchema, Type.Null()]),
1107
- blockerUpdate: Type.Union([UltraPlanBlockerUpdateSchema, Type.Null()]),
1108
- cursorUpdate: Type.Union([UltraPlanCursorSchema, Type.Null()]),
1109
- sessionStateUpdate: Type.Union([literalUnion(ULTRAPLAN_SESSION_STATES), Type.Null()]),
1110
- trackerAttemptFinalization: Type.Union([UltraPlanTrackerAttemptFinalizationSchema, Type.Null()]),
1111
- recomputeProgress: Type.Boolean(),
1112
- repairActions: Type.Array(UltraPlanRepairActionSchema),
1113
- notes: Type.Array(Type.String()),
1053
+ rationale: z.string().min(1),
1054
+ appendObservationFingerprint: z.string().min(1).nullable(),
1055
+ scenarioStatusUpdate: UltraPlanScenarioStatusUpdateSchema.nullable(),
1056
+ reviewStatusUpdate: UltraPlanReviewStatusUpdateSchema.nullable(),
1057
+ blockerUpdate: UltraPlanBlockerUpdateSchema.nullable(),
1058
+ cursorUpdate: UltraPlanCursorSchema.nullable(),
1059
+ sessionStateUpdate: literalUnion(ULTRAPLAN_SESSION_STATES).nullable(),
1060
+ trackerAttemptFinalization: UltraPlanTrackerAttemptFinalizationSchema.nullable(),
1061
+ recomputeProgress: z.boolean(),
1062
+ repairActions: z.array(UltraPlanRepairActionSchema),
1063
+ notes: z.array(z.string()),
1114
1064
  },
1115
- { additionalProperties: false },
1116
- );
1065
+ ).strict();
1117
1066
 
1118
- export const UltraPlanPendingMutationSchema = Type.Object(
1067
+ export const UltraPlanPendingMutationSchema = z.object(
1119
1068
  {
1120
- attemptId: Type.String({ minLength: 1 }),
1069
+ attemptId: z.string().min(1),
1121
1070
  mutationPlan: UltraPlanMutationPlanSchema,
1122
- expectedManifestFingerprint: Type.String({ minLength: 1 }),
1123
- stagedAt: Type.String({ minLength: 1 }),
1071
+ expectedManifestFingerprint: z.string().min(1),
1072
+ stagedAt: z.string().min(1),
1124
1073
  },
1125
- { additionalProperties: false },
1126
- );
1074
+ ).strict();
1127
1075
 
1128
- export const UltraPlanRuntimeTrackerSchema = Type.Object(
1076
+ export const UltraPlanRuntimeTrackerSchema = z.object(
1129
1077
  {
1130
- version: Type.Literal(1),
1131
- sessionId: Type.String({ minLength: 1 }),
1132
- activeAttempt: Type.Union([UltraPlanAttemptRecordSchema, Type.Null()]),
1133
- finalizedAttempts: Type.Array(UltraPlanAttemptRecordSchema),
1134
- appliedFingerprints: Type.Array(Type.String({ minLength: 1 })),
1135
- pendingMutation: Type.Union([UltraPlanPendingMutationSchema, Type.Null()]),
1136
- updatedAt: Type.String({ minLength: 1 }),
1078
+ version: z.literal(1),
1079
+ sessionId: z.string().min(1),
1080
+ activeAttempt: UltraPlanAttemptRecordSchema.nullable(),
1081
+ finalizedAttempts: z.array(UltraPlanAttemptRecordSchema),
1082
+ appliedFingerprints: z.array(z.string().min(1)),
1083
+ pendingMutation: UltraPlanPendingMutationSchema.nullable(),
1084
+ updatedAt: z.string().min(1),
1137
1085
  },
1138
- { additionalProperties: false },
1139
- );
1086
+ ).strict();
1140
1087
 
1141
- export const UltraPlanRepairDetailsSchema = Type.Object(
1088
+ export const UltraPlanRepairDetailsSchema = z.object(
1142
1089
  {
1143
- reason: Type.String({ minLength: 1 }),
1144
- actions: Type.Array(UltraPlanRepairActionSchema),
1090
+ reason: z.string().min(1),
1091
+ actions: z.array(UltraPlanRepairActionSchema),
1145
1092
  },
1146
- { additionalProperties: false },
1147
- );
1093
+ ).strict();
1148
1094
 
1149
- export const UltraPlanReducerActionSchema = Type.Union([
1150
- Type.Object(
1095
+ export const UltraPlanReducerActionSchema = z.union([
1096
+ z.object(
1151
1097
  {
1152
- kind: Type.Literal("session_started"),
1098
+ kind: z.literal("session_started"),
1153
1099
  observation: UltraPlanHookObservationSchema,
1154
- nowIso: Type.String({ minLength: 1 }),
1100
+ nowIso: z.string().min(1),
1155
1101
  },
1156
- { additionalProperties: false },
1157
- ),
1158
- Type.Object(
1102
+ ).strict(),
1103
+ z.object(
1159
1104
  {
1160
- kind: Type.Literal("attempt_started"),
1105
+ kind: z.literal("attempt_started"),
1161
1106
  observation: UltraPlanHookObservationSchema,
1162
1107
  launchContext: UltraPlanLaunchContextSchema,
1163
1108
  },
1164
- { additionalProperties: false },
1165
- ),
1166
- Type.Object(
1109
+ ).strict(),
1110
+ z.object(
1167
1111
  {
1168
- kind: Type.Literal("observation_staged"),
1112
+ kind: z.literal("observation_staged"),
1169
1113
  observation: UltraPlanHookObservationSchema,
1170
1114
  },
1171
- { additionalProperties: false },
1172
- ),
1173
- Type.Object(
1115
+ ).strict(),
1116
+ z.object(
1174
1117
  {
1175
- kind: Type.Literal("attempt_finalized"),
1118
+ kind: z.literal("attempt_finalized"),
1176
1119
  observation: UltraPlanHookObservationSchema,
1177
- nowIso: Type.String({ minLength: 1 }),
1120
+ nowIso: z.string().min(1),
1178
1121
  },
1179
- { additionalProperties: false },
1180
- ),
1181
- Type.Object(
1122
+ ).strict(),
1123
+ z.object(
1182
1124
  {
1183
- kind: Type.Literal("session_shutdown"),
1125
+ kind: z.literal("session_shutdown"),
1184
1126
  observation: UltraPlanHookObservationSchema,
1185
- nowIso: Type.String({ minLength: 1 }),
1127
+ nowIso: z.string().min(1),
1186
1128
  },
1187
- { additionalProperties: false },
1188
- ),
1189
- Type.Object(
1129
+ ).strict(),
1130
+ z.object(
1190
1131
  {
1191
- kind: Type.Literal("repair_applied"),
1192
- nowIso: Type.String({ minLength: 1 }),
1132
+ kind: z.literal("repair_applied"),
1133
+ nowIso: z.string().min(1),
1193
1134
  details: UltraPlanRepairDetailsSchema,
1194
1135
  },
1195
- { additionalProperties: false },
1196
- ),
1136
+ ).strict(),
1197
1137
  ]);
1198
1138
 
1199
- export const UltraPlanSessionMigrationRecordSchema = Type.Object(
1139
+ export const UltraPlanSessionMigrationRecordSchema = z.object(
1200
1140
  {
1201
- migratedAt: Type.String({ minLength: 1 }),
1202
- legacyPath: Type.String({ minLength: 1 }),
1203
- fingerprintBefore: Type.String({ minLength: 1 }),
1204
- fingerprintAfter: Type.String({ minLength: 1 }),
1205
- legacyRenamedTo: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1141
+ migratedAt: z.string().min(1),
1142
+ legacyPath: z.string().min(1),
1143
+ fingerprintBefore: z.string().min(1),
1144
+ fingerprintAfter: z.string().min(1),
1145
+ legacyRenamedTo: z.string().min(1).nullable(),
1206
1146
  kind: literalUnion(ULTRAPLAN_MIGRATION_KINDS),
1207
1147
  },
1208
- { additionalProperties: false },
1209
- );
1148
+ ).strict();
1210
1149
 
1211
1150
  // ---------------------------------------------------------------------------
1212
1151
  // Semantic validators for contracts that express invariants above schema.
@@ -1359,33 +1298,33 @@ export function validateUltraPlanSessionMigrationRecord(value: unknown) {
1359
1298
  }
1360
1299
 
1361
1300
  export function isUltraPlanLaunchContext(value: unknown): value is UltraPlanLaunchContext {
1362
- return Value.Check(UltraPlanLaunchContextSchema, value);
1301
+ return checkSchema(UltraPlanLaunchContextSchema, value);
1363
1302
  }
1364
1303
 
1365
1304
  export function isUltraPlanHookObservation(value: unknown): value is UltraPlanHookObservation {
1366
- return Value.Check(UltraPlanHookObservationSchema, value);
1305
+ return checkSchema(UltraPlanHookObservationSchema, value);
1367
1306
  }
1368
1307
 
1369
1308
  export function isUltraPlanProofCandidate(value: unknown): value is UltraPlanProofCandidate {
1370
- return Value.Check(UltraPlanProofCandidateSchema, value);
1309
+ return checkSchema(UltraPlanProofCandidateSchema, value);
1371
1310
  }
1372
1311
 
1373
1312
  export function isUltraPlanBlockerCandidate(value: unknown): value is UltraPlanBlockerCandidate {
1374
- return Value.Check(UltraPlanBlockerCandidateSchema, value);
1313
+ return checkSchema(UltraPlanBlockerCandidateSchema, value);
1375
1314
  }
1376
1315
 
1377
1316
  export function isUltraPlanAttemptRecord(value: unknown): value is UltraPlanAttemptRecord {
1378
- if (!Value.Check(UltraPlanAttemptRecordSchema, value)) return false;
1317
+ if (!checkSchema(UltraPlanAttemptRecordSchema, value)) return false;
1379
1318
  return getUltraPlanAttemptRecordSemanticErrors(value as UltraPlanAttemptRecord).length === 0;
1380
1319
  }
1381
1320
 
1382
1321
  export function isUltraPlanMutationPlan(value: unknown): value is UltraPlanMutationPlan {
1383
- if (!Value.Check(UltraPlanMutationPlanSchema, value)) return false;
1322
+ if (!checkSchema(UltraPlanMutationPlanSchema, value)) return false;
1384
1323
  return getUltraPlanMutationPlanSemanticErrors(value as UltraPlanMutationPlan).length === 0;
1385
1324
  }
1386
1325
 
1387
1326
  export function isUltraPlanPendingMutation(value: unknown): value is UltraPlanPendingMutation {
1388
- return Value.Check(UltraPlanPendingMutationSchema, value);
1327
+ return checkSchema(UltraPlanPendingMutationSchema, value);
1389
1328
  }
1390
1329
 
1391
1330
  export function isUltraPlanRuntimeTracker(value: unknown): value is UltraPlanRuntimeTracker {
@@ -1393,7 +1332,7 @@ export function isUltraPlanRuntimeTracker(value: unknown): value is UltraPlanRun
1393
1332
  }
1394
1333
 
1395
1334
  export function isUltraPlanReducerAction(value: unknown): value is UltraPlanReducerAction {
1396
- return Value.Check(UltraPlanReducerActionSchema, value);
1335
+ return checkSchema(UltraPlanReducerActionSchema, value);
1397
1336
  }
1398
1337
 
1399
1338
  export function isUltraPlanSessionMigrationRecord(value: unknown): value is UltraPlanSessionMigrationRecord {
@@ -1401,7 +1340,7 @@ export function isUltraPlanSessionMigrationRecord(value: unknown): value is Ultr
1401
1340
  }
1402
1341
 
1403
1342
  export function isUltraPlanRepairAction(value: unknown): value is UltraPlanRepairAction {
1404
- return Value.Check(UltraPlanRepairActionSchema, value);
1343
+ return checkSchema(UltraPlanRepairActionSchema, value);
1405
1344
  }
1406
1345
 
1407
1346
 
@@ -1444,75 +1383,70 @@ export const ULTRAPLAN_BATCH_JOURNAL_EVENT_TYPES = [
1444
1383
  "cleanup-warning",
1445
1384
  ] as const;
1446
1385
 
1447
- export const UltraPlanBatchWaveSchema = Type.Object(
1386
+ export const UltraPlanBatchWaveSchema = z.object(
1448
1387
  {
1449
- waveIndex: Type.Number({ minimum: 0 }),
1450
- sessionIds: Type.Array(Type.String({ minLength: 1 })),
1388
+ waveIndex: z.number().min(0),
1389
+ sessionIds: z.array(z.string().min(1)),
1451
1390
  },
1452
- { additionalProperties: false },
1453
- );
1391
+ ).strict();
1454
1392
 
1455
- export const UltraPlanBatchNodeSchema = Type.Object(
1393
+ export const UltraPlanBatchNodeSchema = z.object(
1456
1394
  {
1457
- nodeId: Type.String({ minLength: 1 }),
1458
- sessionId: Type.String({ minLength: 1 }),
1459
- title: Type.String({ minLength: 1 }),
1460
- waveIndex: Type.Number({ minimum: 0 }),
1461
- dependencies: Type.Array(Type.String({ minLength: 1 })),
1395
+ nodeId: z.string().min(1),
1396
+ sessionId: z.string().min(1),
1397
+ title: z.string().min(1),
1398
+ waveIndex: z.number().min(0),
1399
+ dependencies: z.array(z.string().min(1)),
1462
1400
  state: literalUnion(ULTRAPLAN_BATCH_NODE_STATES),
1463
- blockerKind: Type.Union([literalUnion(ULTRAPLAN_BATCH_NODE_BLOCKER_KINDS), Type.Null()]),
1464
- blockerSummary: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1465
- resumeRequestedAt: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1466
- branchName: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1467
- worktreePath: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1468
- updatedAt: Type.String({ minLength: 1 }),
1401
+ blockerKind: literalUnion(ULTRAPLAN_BATCH_NODE_BLOCKER_KINDS).nullable(),
1402
+ blockerSummary: z.string().min(1).nullable(),
1403
+ resumeRequestedAt: z.string().min(1).nullable(),
1404
+ branchName: z.string().min(1).nullable(),
1405
+ worktreePath: z.string().min(1).nullable(),
1406
+ updatedAt: z.string().min(1),
1469
1407
  },
1470
- { additionalProperties: false },
1471
- );
1408
+ ).strict();
1472
1409
 
1473
- export const UltraPlanBatchRunSchema = Type.Object(
1410
+ export const UltraPlanBatchRunSchema = z.object(
1474
1411
  {
1475
- runId: Type.String({ minLength: 1 }),
1476
- projectRoot: Type.String({ minLength: 1 }),
1477
- baseBranch: Type.String({ minLength: 1 }),
1478
- baseHead: Type.String({ minLength: 1 }),
1479
- currentBaseHead: Type.String({ minLength: 1 }),
1480
- createdAt: Type.String({ minLength: 1 }),
1481
- updatedAt: Type.String({ minLength: 1 }),
1412
+ runId: z.string().min(1),
1413
+ projectRoot: z.string().min(1),
1414
+ baseBranch: z.string().min(1),
1415
+ baseHead: z.string().min(1),
1416
+ currentBaseHead: z.string().min(1),
1417
+ createdAt: z.string().min(1),
1418
+ updatedAt: z.string().min(1),
1482
1419
  state: literalUnion(ULTRAPLAN_BATCH_RUN_STATES),
1483
- maxParallelism: Type.Number({ minimum: 1 }),
1484
- batchBlockerCode: Type.Union([literalUnion(ULTRAPLAN_BATCH_BLOCKER_CODES), Type.Null()]),
1485
- batchBlockerSummary: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1486
- batchResumeRequestedAt: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1487
- supervisorWorktreePath: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1488
- waves: Type.Array(UltraPlanBatchWaveSchema),
1489
- nodes: Type.Array(UltraPlanBatchNodeSchema),
1420
+ maxParallelism: z.number().min(1),
1421
+ batchBlockerCode: literalUnion(ULTRAPLAN_BATCH_BLOCKER_CODES).nullable(),
1422
+ batchBlockerSummary: z.string().min(1).nullable(),
1423
+ batchResumeRequestedAt: z.string().min(1).nullable(),
1424
+ supervisorWorktreePath: z.string().min(1).nullable(),
1425
+ waves: z.array(UltraPlanBatchWaveSchema),
1426
+ nodes: z.array(UltraPlanBatchNodeSchema),
1490
1427
  },
1491
- { additionalProperties: false },
1492
- );
1428
+ ).strict();
1493
1429
 
1494
- export const UltraPlanBatchActiveRunLeaseSchema = Type.Object(
1430
+ export const UltraPlanBatchActiveRunLeaseSchema = z.object(
1495
1431
  {
1496
- runId: Type.String({ minLength: 1 }),
1497
- ownerSessionId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1498
- leaseAcquiredAt: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1499
- leaseExpiresAt: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1500
- updatedAt: Type.String({ minLength: 1 }),
1432
+ runId: z.string().min(1),
1433
+ ownerSessionId: z.string().min(1).nullable(),
1434
+ leaseAcquiredAt: z.string().min(1).nullable(),
1435
+ leaseExpiresAt: z.string().min(1).nullable(),
1436
+ updatedAt: z.string().min(1),
1501
1437
  },
1502
- { additionalProperties: false },
1503
- );
1438
+ ).strict();
1504
1439
 
1505
- export const UltraPlanBatchJournalEventSchema = Type.Object(
1440
+ export const UltraPlanBatchJournalEventSchema = z.object(
1506
1441
  {
1507
- runId: Type.String({ minLength: 1 }),
1508
- sessionId: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
1442
+ runId: z.string().min(1),
1443
+ sessionId: z.string().min(1).nullable(),
1509
1444
  type: literalUnion(ULTRAPLAN_BATCH_JOURNAL_EVENT_TYPES),
1510
- recordedAt: Type.String({ minLength: 1 }),
1511
- summary: Type.String({ minLength: 1 }),
1512
- details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
1445
+ recordedAt: z.string().min(1),
1446
+ summary: z.string().min(1),
1447
+ details: z.record(z.string(), z.unknown()).optional(),
1513
1448
  },
1514
- { additionalProperties: false },
1515
- );
1449
+ ).strict();
1516
1450
 
1517
1451
  function parseBatchLeaseTimestamp(errors: string[], fieldName: string, value: string | null): number | null {
1518
1452
  if (value === null) {
@@ -1573,11 +1507,11 @@ export function validateUltraPlanBatchActiveRunLease(value: unknown) {
1573
1507
  }
1574
1508
 
1575
1509
  export function isUltraPlanBatchWave(value: unknown): value is UltraPlanBatchWave {
1576
- return Value.Check(UltraPlanBatchWaveSchema, value);
1510
+ return checkSchema(UltraPlanBatchWaveSchema, value);
1577
1511
  }
1578
1512
 
1579
1513
  export function isUltraPlanBatchNode(value: unknown): value is UltraPlanBatchNode {
1580
- return Value.Check(UltraPlanBatchNodeSchema, value);
1514
+ return checkSchema(UltraPlanBatchNodeSchema, value);
1581
1515
  }
1582
1516
 
1583
1517
  export function isUltraPlanBatchRun(value: unknown): value is UltraPlanBatchRun {
@@ -1589,5 +1523,5 @@ export function isUltraPlanBatchActiveRunLease(value: unknown): value is UltraPl
1589
1523
  }
1590
1524
 
1591
1525
  export function isUltraPlanBatchJournalEvent(value: unknown): value is UltraPlanBatchJournalEvent {
1592
- return Value.Check(UltraPlanBatchJournalEventSchema, value);
1593
- }
1526
+ return checkSchema(UltraPlanBatchJournalEventSchema, value);
1527
+ }