Files
git.stella-ops.org/docs/features/checked/timeline/timeline-indexer-service.md

61 lines
3.7 KiB
Markdown

# Timeline Indexer Service
## Module
Timeline
## Status
VERIFIED
## Description
Dedicated service for ingesting, indexing, and querying timeline events across all platform modules, with Postgres-backed storage (RLS), REST APIs for event retrieval, and evidence linkage to correlate events with attestation artifacts.
## Implementation Details
- **TimelineQueryService**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/TimelineQueryService.cs` -- central query service: GetByCorrelationIdAsync (HLC range, service/kind filters, limit/offset pagination, cursor-based paging via HLC sortable strings), GetCriticalPathAsync (builds stage list from consecutive event pairs, sorts by duration descending), GetByServiceAsync (service-scoped queries with HLC cursor)
- **ITimelineQueryService**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/ITimelineQueryService.cs` -- query interface
- **ITimelineEventStore**: referenced from `StellaOps.Eventing.Storage` -- PostgreSQL-backed event store: GetByCorrelationIdAsync, GetByHlcRangeAsync, GetByServiceAsync, CountByCorrelationIdAsync; append-only with RLS for tenant isolation
- **TimelineEndpoints**: `src/Timeline/StellaOps.Timeline.WebService/Endpoints/TimelineEndpoints.cs` -- REST API: GET /api/v1/timeline/{correlationId} (with fromHlc, toHlc, services, kinds, limit, offset query parameters; returns events, totalCount, hasMore, nextCursor), GET /{correlationId}/critical-path
- **ExportEndpoints**: `src/Timeline/StellaOps.Timeline.WebService/Endpoints/ExportEndpoints.cs` -- export API: POST /{correlationId}/export (NDJSON/JSON format, optional DSSE signing), GET /export/{exportId} (status), GET /export/{exportId}/download (bundle download)
- **TimelineBundleBuilder**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/Export/TimelineBundleBuilder.cs` -- asynchronous bundle building with progress tracking, NDJSON/JSON serialization, optional DSSE signing via IEventSigner
- **ServiceCollectionExtensions**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/ServiceCollectionExtensions.cs` -- DI registration for timeline services
- **TimelineMetrics**: `src/Timeline/__Libraries/StellaOps.Timeline.Core/Telemetry/TimelineMetrics.cs` -- OpenTelemetry metrics: replay and export operation tracking
- **Tests**: `src/Timeline/__Tests/StellaOps.Timeline.Core.Tests/TimelineQueryServiceTests.cs`, `src/Timeline/__Tests/StellaOps.Timeline.WebService.Tests/TimelineApiIntegrationTests.cs`
- **Source**: SPRINT_0165_0001_0001_timelineindexer.md
## E2E Test Plan
- [x] Verify GET /api/v1/timeline/{correlationId} returns indexed events with correct HLC ordering
- [x] Test service and kind filters narrow indexed results
- [x] Verify HLC range queries (fromHlc/toHlc) return correct event subsets
- [x] Test cursor-based pagination produces consistent results across pages
- [x] Verify critical path endpoint computes stage durations and percentages correctly
- [x] Test export API: initiate -> check status -> download bundle
- [x] Verify NDJSON export includes all event fields (event_id, t_hlc, ts_wall, service, kind, payload_digest, engine_version)
- [x] Test evidence linkage: events with attestation references are queryable by correlation
## Verification
**Run ID**: run-001
**Date**: 2026-02-10
**Verdict**: PASS
**Implementation Verification**:
- Complete query engine with HLC range, service/kind filters, cursor paging, critical path analysis
- PostgreSQL materialized view migration present
- Full REST API with all specified endpoints
- 15 tests (7 unit + 8 integration)
**Test Execution**:
- Query engine tests: PASS
- HLC range filtering: PASS
- Service/kind filtering: PASS
- Cursor pagination: PASS
- Critical path analysis: PASS
- Export API: PASS
- Evidence linkage: PASS
**Build Status**:
- 0 errors
- 0 warnings
- Build: PASS
**Overall Verdict**: PASS