# ISIS v2 WS07-008: Per-Shot Cost and Latency Forecasting

## Scope

`WS07-008` adds deterministic per-shot cost and latency forecasting to sequence
continuity orchestration so production teams can plan schedule and spend before
execution.

## Research and Existing Implementation Alignment

- Aligned forecasting assumptions with existing pay-per-second cost handling in
  generation-api (`ISIS_COST_RATE_*_USD_PER_SECOND` and runtime cost backfill
  patterns).
- Integrated directly into sequence orchestration because that is where shot
  ordering, shot metadata, and continuity planning are already resolved.
- Preserved deterministic outputs to keep planning reproducible for timeline and
  budget scheduling tools.

## Deliverables

1. Extended sequence orchestration request contracts:

- Added `forecasting` request config with provider/rate-card/performance knobs.

2. Added per-shot forecast contracts:

- `ShotCostLatencyForecast` with confidence, duration source, complexity
  multiplier, processing/queue/latency (P50/P95), and estimated USD cost.
- `SequenceCostLatencyForecast` aggregate totals + assumptions.

3. Added forecast output on orchestration results:

- `SequenceOrchestrationResult.forecast`
- `SequenceShotResult.forecast`

4. Implemented deterministic forecast engine:

- Duration resolution from shot/shared parameters and metadata.
- Complexity multipliers from resolution, sampling steps, controls,
  keyframe-sample count, and render-pass count.
- Processing and queue latency estimation with configurable heuristics.
- Cost estimation from provider USD/second rate cards.

5. Added tests:

- Forecast generation with custom provider rate-card assumptions.
- Forecast disable behavior.
- Validation that forecast is present on standard sequence runs.

## Verification Commands

```bash
pnpm --filter @isis/workflows exec vitest run src/consistency/sequence-orchestration.spec.ts src/workflows.spec.ts
node scripts/isis/validate-v2-compliance-gate.mjs
```
