Commit d0e02d7
feat(argus): structured observers + live progress polling (#39)
* feat(argus): wire structured observers + live progress polling
Bump QueryArgus to PR #2 merge (observability foundation) and consume
the new RunObserver hooks across QueryPal.
Backend
- Attach JsonFormatter handler to the `queryargus.run` logger at app
startup so structured events flow into the existing log pipeline.
- Wire StructuredLogObserver (module-level singleton) and a fresh
CostTracker per request into each Argus run.
- Surface report.cost on the serialized response so the UI can render
USD cost alongside token counts.
- Add LiveEventBuffer (per-job, ring-buffered, thread-safe) as a third
observer; expose `GET /argus/runs/{job_id}/events?cursor=N` with
rolled-up aggregates for live progress polling. Same auth-scoping as
get_run (404 leak-safe).
- Emit finding trace as JSONL so the UI can render structured steps.
Frontend
- ArgusReport gains `cost: RunCost | null` and the report header now
has a token<->USD toggle pill with per-model breakdown on hover.
- TraceView component parses the JSONL trace into per-step blocks
(iter chip, action, optional gate badge, reason); falls back to the
legacy <pre> for older reports.
- NotificationsContext polls the new events endpoint in parallel with
the status check, maintains a per-job cursor, and exposes runProgress.
- AppTopBar "In progress" rows show a live second line:
`iter N · M findings · K tok · → last_tool` plus a red tool-error
chip when any have failed.
No SSE, no new tables, no async refactor. Existing
`GET /argus/runs/{job_id}` contract unchanged.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(argus): defer log handler install to lifespan + black
- Module-level handler install on `queryargus.run` set `propagate=False`,
which broke the upstream observability tests that rely on `caplog`
(collection-time imports of `main` would silence the root logger before
pytest could capture records). Move into a lifespan helper so the
handler only attaches when the app actually boots; tests are unaffected.
- The helper is idempotent (handler tagged with `_querypal_argus`) so a
double lifespan run during tests can't double-install.
- Reformat with black to satisfy CI.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent dca0412 commit d0e02d7
8 files changed
Lines changed: 492 additions & 35 deletions
File tree
- backend
- routes
- services
- frontend
- components
- contexts
- pages
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
10 | 30 | | |
11 | 31 | | |
12 | 32 | | |
13 | 33 | | |
| 34 | + | |
14 | 35 | | |
15 | 36 | | |
16 | 37 | | |
| |||
Submodule queryargus updated 51 files
- .gitignore+1
- HANDOFF.md+217
- Makefile+19
- pyproject.toml+17-1
- scripts/refresh_prompt_baseline.py+84
- src/queryargus/agent/loop.py+93-3
- src/queryargus/agent/planner.py+9-3
- src/queryargus/llm/client.py+6-2
- src/queryargus/llm/gemini.py+2-2
- src/queryargus/models/report.py+14
- src/queryargus/observability/__init__.py+7
- src/queryargus/observability/cost.py+94
- src/queryargus/observability/logging_observer.py+147
- src/queryargus/observability/observer.py+174
- tests/llm/__init__.py
- tests/llm/test_response_model_field.py+27
- tests/models/test_audit_report_cost.py+52
- tests/observability/__init__.py
- tests/observability/test_agent_integration.py+100
- tests/observability/test_cost.py+118
- tests/observability/test_logging_observer.py+152
- tests/observability/test_observer.py+125
- tests/prompt_regression/README.md+86
- tests/prompt_regression/__init__.py
- tests/prompt_regression/conftest.py+128
- tests/prompt_regression/fixtures/actions/01_schema_sample_first.json+14
- tests/prompt_regression/fixtures/actions/02_run_query_before_schema_sample.json+15
- tests/prompt_regression/fixtures/actions/03_duplicate_run_query.json+23
- tests/prompt_regression/fixtures/actions/04_valid_run_query.json+22
- tests/prompt_regression/fixtures/actions/05_run_query_bad_input_shape.json+20
- tests/prompt_regression/fixtures/actions/06_get_stats_bad_operation.json+20
- tests/prompt_regression/fixtures/actions/07_late_schema_sample_warns.json+20
- tests/prompt_regression/fixtures/actions/08_conclude_before_schema_allowed.json+14
- tests/prompt_regression/fixtures/findings/01_valid_null_rate.json+16
- tests/prompt_regression/fixtures/findings/02_zero_affected_count.json+16
- tests/prompt_regression/fixtures/findings/03_empty_evidence_query.json+16
- tests/prompt_regression/fixtures/findings/04_critical_on_low_pct.json+16
- tests/prompt_regression/fixtures/findings/05_high_on_very_low_pct.json+16
- tests/prompt_regression/fixtures/findings/06_valid_outlier_value.json+16
- tests/prompt_regression/fixtures/findings/07_valid_type_mismatch.json+16
- tests/prompt_regression/llm_judge/__init__.py
- tests/prompt_regression/llm_judge/baseline.json+12
- tests/prompt_regression/llm_judge/gemini_judge.py+87
- tests/prompt_regression/llm_judge/metrics.py+92
- tests/prompt_regression/llm_judge/test_llm_judge.py+89
- tests/prompt_regression/prompts/system_prompt.txt+117
- tests/prompt_regression/prompts/user_prompt_01_schema_sample_first.txt+7
- tests/prompt_regression/prompts/user_prompt_03_duplicate_run_query.txt+11
- tests/prompt_regression/test_action_fixtures.py+49
- tests/prompt_regression/test_finding_fixtures.py+39
- tests/prompt_regression/test_prompt_snapshots.py+67
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
74 | 83 | | |
75 | 84 | | |
76 | 85 | | |
| |||
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
100 | 114 | | |
101 | 115 | | |
102 | 116 | | |
103 | 117 | | |
104 | 118 | | |
105 | 119 | | |
106 | 120 | | |
107 | | - | |
108 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
109 | 126 | | |
110 | | - | |
| 127 | + | |
| 128 | + | |
111 | 129 | | |
112 | 130 | | |
113 | 131 | | |
| |||
235 | 253 | | |
236 | 254 | | |
237 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
238 | 259 | | |
239 | 260 | | |
240 | 261 | | |
| |||
362 | 383 | | |
363 | 384 | | |
364 | 385 | | |
| 386 | + | |
| 387 | + | |
365 | 388 | | |
366 | 389 | | |
367 | 390 | | |
368 | 391 | | |
369 | 392 | | |
| 393 | + | |
370 | 394 | | |
371 | 395 | | |
372 | 396 | | |
| |||
500 | 524 | | |
501 | 525 | | |
502 | 526 | | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
503 | 559 | | |
504 | 560 | | |
505 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments