feat(cost-benefit): implement calculateTaskEv pure function

Implement the core EV calculation: EV = p*C_success + (1-p)*C_fail
where C_success = scopeCost*impactWeight, C_fail = scopeCost*impactWeight + fallbackCost + timeLost*expectedRetries.

- expectedRetries = (1-p)/p when p>0, else 0 (geometric series)
- Caps expectedRetries at config.retries when retries > 0
- Multiplies final EV by config.valueRate when non-zero
- 30 unit tests covering formula, edge cases, and Python research model values
This commit is contained in:
2026-04-27 11:51:59 +00:00
parent 9ad0ec902c
commit 6016e81162
3 changed files with 397 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
---
id: cost-benefit/ev-calculation
name: Implement calculateTaskEv pure function
status: pending
status: completed
depends_on:
- schema/numeric-methods-and-defaults
- schema/result-types
@@ -41,8 +41,12 @@ Where `C_fail = scopeCost + fallbackCost + timeLost × expectedRetries`.
## Notes
> To be filled by implementation agent
All acceptance criteria verified via 30 unit tests covering formula correctness, edge cases, config variations, and known Python research model values.
## Summary
> To be filled on completion
Implemented `calculateTaskEv` pure function in `src/analysis/cost-benefit.ts`.
- Modified: `src/analysis/cost-benefit.ts` — full implementation of calculateTaskEv
- Modified: `test/cost-benefit.test.ts` — 30 comprehensive unit tests
- Tests: 30, all passing (286 total across suite)
- Lint: clean (tsc --noEmit passes)