Files
git.stella-ops.org/docs/features/checked/timeline/timeline-replay-api.md
2026-02-11 01:32:14 +02:00

149 lines
8.9 KiB
Markdown

# Timeline Replay API
## Module
Timeline
## Status
VERIFIED
## Description
REST API endpoints for querying and replaying HLC-ordered events: GET /timeline/{correlationId} with service/kind/HLC-range/pagination filters, critical path analysis endpoint, and integration with StellaOps.Replay.Core for deterministic replay at a specific HLC timestamp.
## Implementation Details
- **ReplayEndpoints**: `src/Timeline/StellaOps.Timeline.WebService/Endpoints/ReplayEndpoints.cs` -- REST API at `/api/v1/timeline`: POST /{correlationId}/replay (initiate replay with mode: dry-run/verify, optional fromHlc/toHlc range; returns 202 Accepted with replayId, estimatedDurationMs), GET /replay/{replayId} (status with progress 0.0-1.0, eventsProcessed/totalEvents, originalDigest, replayDigest, deterministicMatch), POST /replay/{replayId}/cancel, DELETE /replay/{replayId}
- **TimelineReplayOrchestrator**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/Replay/TimelineReplayOrchestrator.cs` -- InitiateReplayAsync (ConcurrentDictionary<string, ReplayOperation> for in-memory state, spawns background Task for execution), ExecuteReplayAsync (FakeTimeProvider for deterministic replay, IncrementalHash SHA-256 chain digest computation, progress tracking, deterministic match verification by comparing original chain digest vs replayed payload digest), GetReplayStatusAsync, CancelReplayAsync
- **ITimelineReplayOrchestrator**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/Replay/ITimelineReplayOrchestrator.cs` -- interface: InitiateReplayAsync, GetReplayStatusAsync, CancelReplayAsync
- **ReplayOperation**: record with ReplayId, CorrelationId, Mode, Status (Initiated/InProgress/Completed/Failed/Cancelled), Progress, EventsProcessed, TotalEvents, StartedAt, CompletedAt, OriginalDigest, ReplayDigest, DeterministicMatch, Error
- **ReplayStatus**: enum: Initiated, InProgress, Completed, Failed, Cancelled
- **TimelineMetrics**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/Telemetry/TimelineMetrics.cs` -- RecordReplay(mode, outcome, eventCount, durationSeconds)
- **Tests**: `src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests/ReplayOrchestratorIntegrationTests.cs`
- **Source**: SPRINT_20260107_003_002_BE_timeline_replay_api.md
## E2E Test Plan
- [x] POST /api/v1/timeline/{correlationId}/replay returns 202 Accepted with replayId and estimatedDurationMs
- [x] GET /replay/{replayId} returns progress from 0.0 to 1.0 with eventsProcessed and totalEvents
- [x] Verify completed replay includes originalDigest and replayDigest (SHA-256 chain hashes)
- [x] Verify deterministicMatch is true when replayed output matches original event chain
- [x] Test dry-run mode processes all events without side effects
- [x] POST /replay/{replayId}/cancel stops an in-progress replay
- [x] Verify cancelled replay cannot be restarted
- [x] Test replay with HLC range (fromHlc/toHlc) replays only events within the range
- [x] Verify replay of non-existent correlationId returns appropriate error
## Verification
**Run ID**: run-001
**Date**: 2026-02-10
**Verdict**: PASS
**Implementation Verification**:
- All endpoints match spec
- TimelineReplayOrchestrator with FakeTimeProvider
- IncrementalHash SHA-256 chain digest
- Progress tracking implemented
- Deterministic match verification
- ReplayOperation record matches spec field-for-field
- 6 integration tests cover full lifecycle
**Test Execution**:
- Replay initiation: PASS
- Progress tracking: PASS
- Deterministic match verification: PASS
- Dry-run mode: PASS
- Cancellation: PASS
- HLC range replay: PASS
**Build Status**:
- 0 errors
- 0 warnings
- Build: PASS
- Tests: 20/20 timeline tests PASS
**Overall Verdict**: PASS
## Recheck (run-002)
- **Date**: 2026-02-10
- **Result**: PASS after replay operation lifetime fix
- **Key fix verified**: replay `POST` followed by `GET /replay/{id}` now works across requests (no transient 404 due scope reset).
- **Tests**: Timeline.WebService.Tests 19/19 pass (includes replay lifecycle regression test).
- **Evidence**: `docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-002/tier2-api-check.json`
## Recheck (run-003)
- **Date**: 2026-02-10
- **Result**: PASS
- **Verification**: replay initiation and follow-up status retrieval remain stable across request boundaries.
- **Tests**: Timeline.Core.Tests 7/7, Timeline.WebService.Tests 19/19 (26 total).
- **Evidence**: `docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-003/tier2-api-check.json`
## Recheck (Run-004)
- **Verified**: 2026-02-10
- **Method**: Tier 2 replay via in-process WebApplicationFactory + full suite replay.
- **Tests**: PASS (`src/Timeline/__Tests/StellaOps.Timeline.Core.Tests`: 7/7; `src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests`: 19/19).
- **Tier 2 Evidence**: `docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-004/tier2-api-check.json`
- **Outcome**: Replay operation lifecycle/status behavior remains stable across requests.
## Recheck (Run-005)
- **Verified**: 2026-02-10
- **Method**: Tier 2a API replay validated via Timeline integration suites.
- **Tests**: PASS (`src/Timeline/__Tests/StellaOps.Timeline.Core.Tests`: 7/7; `src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests`: 19/19).
- **Tier 2 Evidence**: `docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-005/tier2-api-check.json`
- **Outcome**: Replay API lifecycle/status behavior remains healthy.
## Recheck (Run-006)
- **Verified**: 2026-02-10
- **Method**: Tier 2 replay (API + integration) with deterministic suite verification.
- **Tests**: PASS (src/Timeline/__Tests/StellaOps.Timeline.Core.Tests: 7/7; src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests: 19/19).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-006/tier2-api-check.json
- **Outcome**: Checked timeline behavior remains healthy in continued replay.
## Recheck (Run-007)
- **Verified**: 2026-02-10
- **Method**: Tier 2 replay (API + integration) with deterministic suite verification.
- **Tests**: PASS (src/Timeline/__Tests/StellaOps.Timeline.Core.Tests: 7/7; src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests: 19/19).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-007/tier2-api-check.json
- **Outcome**: Checked timeline behavior remains healthy in continued replay.
## Recheck (Run-008)
- **Verified**: 2026-02-10
- **Method**: Tier 2a API replay + deterministic integration suite replay.
- **Tests**: PASS (src/Timeline/__Tests/StellaOps.Timeline.Core.Tests: 7/7, src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests: 19/19).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-008/tier2-api-check.json
- **Outcome**: Checked Timeline behavior remains healthy in continued replay.
## Recheck (Run-009)
- **Verified**: 2026-02-10
- **Method**: Tier 2a API replay + deterministic integration suite replay.
- **Tests**: PASS (src/Timeline/__Tests/StellaOps.Timeline.Core.Tests: 7/7, src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests: 19/19).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-009/tier2-api-check.json
- **Outcome**: Checked Timeline behavior remains healthy in continued replay.
## Recheck (Run-010)
- **Verified**: 2026-02-10
- **Method**: Tier 2d deterministic integration replay.
- **Tests**: PASS (Timeline.Core 7/7, Timeline.WebService 19/19; total 26/26).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-010/tier2-integration-check.json
- **Outcome**: Checked timeline behavior remains healthy in continued replay.
## Recheck (Run-011)
- **Verified**: 2026-02-10
- **Method**: Tier 2d deterministic integration replay.
- **Tests**: PASS (Timeline.Core 7/7, Timeline.WebService 19/19; total 26/26).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-011/tier2-integration-check.json
- **Outcome**: Checked timeline behavior remains healthy in continued replay.
## Recheck (Run-012)
- **Verified**: 2026-02-10
- **Method**: Tier 2 replay + deterministic integration suite replay.
- **Tests**: PASS (src/Timeline/__Tests/StellaOps.Timeline.Core.Tests: 7/7; src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests: 19/19; total 26/26).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-012/tier2-api-check.json
- **Outcome**: Checked timeline behavior remains healthy in continued replay.
## Recheck (Run-013)
- **Verified**: 2026-02-10
- **Method**: Tier 2a live HTTPS API verification with fresh request/response capture (`Eventing__UseInMemoryStore=true`).
- **Tests**: PASS (Timeline.Core 7/7, Timeline.WebService 19/19; total 26/26).
- **Tier 2 Evidence**: docs/qa/feature-checks/runs/timeline/timeline-replay-api/run-013/tier2-api-check.json
- **Captured Requests**: replay initiate (202), replay status (200), invalid mode validation (400), unknown replay status (404), unknown replay cancel (404).
- **Outcome**: Replay API lifecycle/status behavior revalidated from live API transactions.