feat(schema/result-types): define analysis result TypeBox schemas

This commit is contained in:
2026-04-27 10:59:57 +00:00
parent 8725a26b43
commit e367215e43
3 changed files with 401 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
---
id: schema/result-types
name: Define analysis result TypeBox schemas (RiskPathResult, DecomposeResult, WorkflowCostResult, etc.)
status: pending
status: completed
depends_on:
- schema/enums
scope: narrow
@@ -16,7 +16,7 @@ Define all analysis function return type schemas in `src/schema/results.ts`. The
## Acceptance Criteria
- [ ] `src/schema/results.ts` exports all result schemas and types:
- [x] `src/schema/results.ts` exports all result schemas and types:
- `RiskPathResult`: `{ path: string[], totalRisk: number }`
- `DecomposeResult`: `{ shouldDecompose: boolean, reasons: string[] }`
- `WorkflowCostOptions`: `{ includeCompleted?, limit?, propagationMode?, defaultQualityRetention? }`
@@ -24,9 +24,9 @@ Define all analysis function return type schemas in `src/schema/results.ts`. The
- `EvConfig`: `{ retries?, fallbackCost?, timeLost?, valueRate? }` with defaults (0, 0, 0, 0)
- `EvResult`: `{ ev, pSuccess, expectedRetries }`
- `RiskDistributionResult`: `{ trivial, low, medium, high, critical, unspecified }` — each `string[]`
- [ ] All schemas use `Static<typeof>` for type aliases, no manual interface definitions
- [ ] `WorkflowCostOptions.propagationMode` is `Type.Union([Type.Literal("independent"), Type.Literal("dag-propagate")])`
- [ ] Re-exported from `src/schema/index.ts`
- [x] All schemas use `Static<typeof>` for type aliases, no manual interface definitions
- [x] `WorkflowCostOptions.propagationMode` is `Type.Union([Type.Literal("independent"), Type.Literal("dag-propagate")])`
- [x] Re-exported from `src/schema/index.ts`
## References
@@ -35,8 +35,11 @@ Define all analysis function return type schemas in `src/schema/results.ts`. The
## Notes
> To be filled by implementation agent
All schemas follow the TypeBox-as-single-source-of-truth pattern. WorkflowCostTaskEntry is an internal schema (not exported) used within WorkflowCostResult's tasks array. EvConfig fields use `Type.Number({ default: 0 })` per architecture spec for defaults. The `WorkflowCostOptions.propagationMode` is correctly a `Type.Union` of two `Type.Literal` values as specified. Results.js was already re-exported from index.ts.
## Summary
> To be filled on completion
Implemented all 7 analysis result TypeBox schemas with `Static<typeof>` type aliases.
- Created: `src/schema/results.ts` (7 schema constants + 7 type aliases + 1 internal WorkflowCostTaskEntry)
- Modified: `test/schema.test.ts` (46 new tests: 39 runtime validation + 7 compile-time type alias verification)
- Tests: 137 total, all passing; `tsc --noEmit` clean