feat(subjects): add Langfuse #58
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.44) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 266 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.334
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #58"
general
weight: 0.35
chrikrah
Resolves #43.
What this PR does
Adds the Langfuse Python SDK (
langfuse.openai) as a subject, reading its nativelangfuse.observation.*attributes:1. Conventions (
conventions.py&checks.py):- Added
in_langfuse: bool = TruetoFactdataclass.- Added
"langfuse.observation.type"toLLM_MARKERS.- Read token counts from JSON string
langfuse.observation.usage_details(prompt_tokensandcompletion_tokens).- Mapped
langfuse.observation.model.nametoresponse_model, and allow it to accept the request model name if unseparated.- Facts undefined by Langfuse (
request_model,response_id,finish_reasons,cache_read_tokens,cache_write_tokens,reasoning_tokens) are markedin_langfuse=Falseand graded asn/avialangfuse_only.- On error scenarios,
error.typeis graded asn/afor Langfuse spans.2. Subject Adapter (
subjects/langfuse/):-
subject.toml: Pinnedlangfuse==5.2.0,providers = ["openai"], tracked.-
instrument.py: InitializedLangfusewith throwaway keys so it does not disable itself, and pointsbase_urlto the harness receiver so that Langfuse's internal OTLP export does not attempt outbound calls.3. Tests & Changelog:
- Added unit tests in
test_checks.pyandtest_subjects.py.- Documented in
CHANGELOG.mdunder[Unreleased].Subject Findings (
spantruth run --subject langfuse)openai/stream-dropped&openai/async-stream-dropped(❌ wrong - ST07 False OK):- In
langfuse/openai.py:1102-1114, generator'straced_iteratorexecutesfinally: finalize_once()upon exception without marking the span status asERROR, leaving it asUNSET.openai/stream-helper&openai/async-stream-helper(🟡 missing - ST01 Ghost span):- Raw response streaming calls are explicitly passed through untraced by Langfuse (
openai.py:23-28).Verification
uv run pytest -m "not slow" -q: 422 passeduv run pytest -m slow -q: 13 passed (both controls pass end-to-end)uv run ruff check . && uv run ruff format --check .: Clean