2.9 KiB
2.9 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||
|---|---|---|---|---|---|---|---|---|---|
| schema/numeric-methods-and-defaults | Implement categorical numeric functions and resolveDefaults | completed |
|
narrow | low | component | implementation |
Description
Implement the standalone numeric functions that map categorical enum values to their numeric equivalents, plus resolveDefaults which fills in defaults for unassessed fields and computes derived numeric values. These live in src/analysis/defaults.ts per the project structure.
Acceptance Criteria
src/analysis/defaults.tsexports:scopeCostEstimate(scope: TaskScope): number— maps to 1.0–5.0 per tablescopeTokenEstimate(scope: TaskScope): number— maps to 500–10000 per tableriskSuccessProbability(risk: TaskRisk): number— maps to 0.50–0.98 per tableriskWeight(risk: TaskRisk): number— maps to 0.02–0.50 (equals 1 - successProbability)impactWeight(impact: TaskImpact): number— maps to 1.0–3.0 per tableresolveDefaults(attrs: Partial<TaskGraphNodeAttributes> & Pick<TaskGraphNodeAttributes, 'name'>): ResolvedTaskAttributes
- All numeric mapping tables match schemas.md exactly:
- Scope: single=1.0/500, narrow=2.0/1500, moderate=3.0/3000, broad=4.0/6000, system=5.0/10000
- Risk: trivial=0.98/0.02, low=0.90/0.10, medium=0.80/0.20, high=0.65/0.35, critical=0.50/0.50
- Impact: isolated=1.0, component=1.5, phase=2.0, project=3.0
resolveDefaultshandles null/undefined categorical fields by falling back to: risk→medium, scope→narrow, impact→isolatedresolveDefaultspopulates derived fields: costEstimate, tokenEstimate, successProbability, riskWeight, impactWeight- Label-only fields (level, priority, status) remain nullable after resolution — no default value assigned
riskWeight(risk)equals1 - riskSuccessProbability(risk)— guaranteed by implementation- Unit tests covering every enum value's numeric mapping and resolveDefaults with mixed null/present inputs
References
- docs/architecture/schemas.md — numeric method tables, ResolvedTaskAttributes definition
- docs/architecture/graph-model.md — categorical field defaults
Notes
Floating-point comparison in tests uses toBeCloseTo for riskWeight and successProbability due to IEEE 754 precision (e.g., 1 - 0.98 = 0.020000000000000018).
Summary
Implemented categorical numeric functions and resolveDefaults.
- Modified:
src/analysis/defaults.ts— 5 standalone numeric functions (scopeCostEstimate, scopeTokenEstimate, riskSuccessProbability, riskWeight, impactWeight) + resolveDefaults - Modified:
src/schema/results.ts— added ResolvedTaskAttributes TypeBox schema and type alias - Created:
test/defaults.test.ts— 30 tests covering every enum value mapping and resolveDefaults with mixed null/present inputs - Tests: 30 new, all 218 total passing; lint clean