The workflowCost function had includeCompleted defaulting to true, but the api-surface.md specifies the default should be false. Fixed the default and updated test suite to verify the correct default behavior and add explicit test for includeCompleted: true opt-in case. All 562 tests passing across 12 test files.
2.8 KiB
2.8 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||
|---|---|---|---|---|---|---|---|---|---|
| cost-benefit/workflow-cost | Implement workflowCost orchestration function | completed |
|
moderate | medium | component | implementation |
Description
Implement workflowCost(graph: TaskGraph, options?: WorkflowCostOptions): WorkflowCostResult in src/analysis/cost-benefit.ts. This orchestrates the per-task EV calculations, handles DAG propagation, and enriches results with taskId and name from the graph.
Acceptance Criteria
workflowCostacceptsWorkflowCostOptionswith optional:includeCompleted,limit,propagationMode,defaultQualityRetention- Default propagation mode:
"dag-propagate"per ADR-004 - Default
defaultQualityRetention: 0.9 - Each task in result includes:
taskId,name,ev,pIntrinsic,pEffective,probability(=pEffective),scopeCost,impactWeight totalEv: sum of all task EVs (excluding completed tasks from output whenincludeCompleted: false)averageEv:totalEv / tasks.lengthpropagationMode: reflected in result- When
includeCompleted: false: completed tasks excluded fromtasksarray but remain in propagation chain with p=1.0 - When
includeCompleted: false: only"completed"status triggers exclusion;"failed"and"blocked"are always included - When
limitis set: returns at mostlimittasks (sorted by EV descending? or topological order? spec says "limits the number of tasks in the result" — use topological order with limit) - Throws
CircularDependencyErrorif graph is cyclic - Unit tests: full workflow cost calculation, independent vs dag-propagate comparison, excludeCompleted scenarios, limit behavior
References
- docs/architecture/cost-benefit.md — workflow cost, skip-completed semantics
- docs/architecture/api-surface.md — workflowCost signature, WorkflowCostOptions
- docs/architecture/decisions/004-workflow-cost-dag-propagation.md — ADR-004
Notes
Fixed includeCompleted default from true to false to match the api-surface.md specification. The implementation was mostly complete from prior dependency tasks (dag-propagation), but the default was incorrect. Updated the test suite to verify the correct default behavior and explicitly test the includeCompleted: true opt-in case.
Summary
Implemented workflowCost orchestration function and fixed includeCompleted default to false per api-surface.md.
- Modified:
src/analysis/cost-benefit.ts— fixedincludeCompleteddefault fromtruetofalse - Modified:
test/cost-benefit.test.ts— updated default-behavior test and added explicitincludeCompleted: truetest - Tests: 64 cost-benefit tests, all passing; 562 total tests across 12 test files, all passing