Extend session store with real-time event capture and health invariants
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust
- Lĩnh vực
- backend, observability
Hướng nghiên cứu
Start by reading the existing persistence, search, and session-import paths in terraphim_sessions and the analysis entry points in terraphim-session-analyzer. Trace the listed integration points in terraphim_hooks, terraphim_service, terraphim_multi_agent, terraphim_types, and terraphim_mcp_server, then confirm scope before implementation; done means event capture, typed events, correlation IDs, invariant results, and the listed integrations are covered.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Extend terraphim_sessions and terraphim-session-analyzer with real-time event-level capture, structured event types, and health invariant queries. Not a new crate -- the session store already has persistence, search, and KG enrichment.
Why Not a Separate Event Store?
Originally proposed as a new terraphim_event_store crate. But terraphim_sessions already:
- Parses session logs into structured records (costs, tool usage, patterns)
- Uses
terraphim_persistencebackends (SQLite, DashMap, S3) - Supports KG-enriched search via Aho-Corasick automata
- Has rayon-based parallel processing
A session IS a sequence of events. Building parallel storage is over-engineering.
What's Missing (Gaps to Fill)
1. Real-time capture (not just post-hoc import)
Currently: session logs are imported after the session ends.
Needed: events captured as they happen during a session.
Add a SessionEventEmitter trait:
pub trait SessionEventEmitter: Send + Sync {
async fn emit(&self, event: SessionEvent) -> Result<()>;
}
Hook into existing infrastructure:
terraphim_hooks(PreToolUse, PostToolUse) -> emit events in real-timeterraphim_service(search, LLM calls) -> emit events on each operationterraphim_multi_agent(agent decisions) -> emit events per decision
2. Structured event types
Currently: session-analyzer parses free-text logs.
Needed: typed event records for structured queries.
pub enum SessionEvent {
LlmCall { model: String, tokens_in: u32, tokens_out: u32, cost_usd: f64, latency_ms: u64 },
SearchExecuted { query: String, results_count: u32, relevance_scores: Vec<f64> },
HookFired { hook_type: HookType, action: String, result: HookResult },
Prediction { id: Ulid, source: String, predicted_outcome: String, confidence: f64 },
Outcome { prediction_id: Ulid, actual_outcome: String, accuracy: f64 },
ToolUse { tool: String, input_summary: String, success: bool, duration_ms: u64 },
}
These coexist with existing free-text session import -- typed events are a superset.
3. Health invariant queries
Currently: session-analyzer identifies patterns post-hoc.
Needed: automated drift/anomaly detection over rolling windows.
Invariants to detect:
- Model version drift: responses from unexpected model versions
- Score distribution shift: ranking scores deviate >2 sigma from rolling baseline
- Latency degradation: P95 response time exceeds historical threshold
- Error rate spike: error rate exceeds N% over rolling window
- Cost anomaly: per-session cost exceeds historical P95
Implementation: add check_invariants() method to session-analyzer that runs over the last N sessions/events and returns violations.
4. Correlation IDs
Currently: events within a session are sequential but not linked.
Needed: link related events (e.g., Prediction -> Outcome, PreToolUse -> PostToolUse for same invocation).
Add correlation_id: Option<Ulid> to SessionEvent. Events in the same logical operation share a correlation ID.
Affected Crates
terraphim_sessions(primary -- add real-time emitter, event types)terraphim-session-analyzer(add health invariant queries)terraphim_hooks(emit events via SessionEventEmitter)terraphim_service(emit events for search/LLM calls)terraphim_types(add SessionEvent enum, HookType, etc.)terraphim_mcp_server(expose invariant check results as MCP resource)
Estimated Effort
~1 day for event types + real-time emitter + basic invariants. Ongoing integration per crate.
Part of
Epic #595
Downstream Dependents
- #598 Budget-aware routing (cost tracking via session events)
- #599 Enhanced learning capture (learning events are session events)
- #601 EIDOS episodic reasoning (predictions/outcomes stored as session events)
- #602 Confidence-driven KG promotion (queries session events for confidence scoring)
- Ngôn ngữ chính
- Rust
- Star
- 64
- Fork
- 5
- Merge trung bình
- 1 giờ 17 phút
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của terraphim/terraphim-ai
-
terraphim_rlm: require a per-sub-result verification plan (recheck / control / independent route)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
terraphim/terraphim-ai#969 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
terraphim/terraphim-ai#968 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
terraphim/terraphim-ai#967 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
terraphim/terraphim-ai#966 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
terraphim/terraphim-ai#965 · 2 bình luận ·
Tất cả issue của terraphim/terraphim-ai
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pnpm/pnpm#16635 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Bedrock request metadata forwarding does not work for /embeddingsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug llm translation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
pytest plugin: a crashed xdist worker aborts the whole session with INTERNALERRORCó thể đã có người làm @hazelxue đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
skillfs: one malformed chat-log line aborts the entire skill-usage analysis (skill_usage_from_chat_logs.py)Có thể đã có người làm @zjncs đã nhận hôm nay. Đang mởcomponent:skillfs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
agentic-os-org/ANOLISA#6116 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày