Repository navigation
fix: Report the evidence summary from the canonical tool outcome - #5195
Conversation
The session evidence-summary endpoint re-derived each action's outcome
from blocks' legacy tool_result_exit_code/tool_result_is_error compat
pair, so a tool_result the parser deliberately marked
tool_outcome='unknown' while retaining the provider's exit_code = 0 was
counted as ok -- treating a distrusted outcome as success.
Read actions.result_state instead, which the view already computes from
the canonical tool_outcome. outcome_unknown and no_result both report
unknown, matching what the compat derivation produced for those rows.
Verification:
devtools test tests/unit/daemon/test_daemon_http.py -> PASSED exit=0
devtools verify --quick -> exit=0
Anti-vacuity: restoring the exit_code/is_error derivation fails the new
test with outcomes {'ok': 2, 'failed': 1, 'unknown': 0}.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 7 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…5201) ## Summary **Master was red.** Three `TestCockpitAggregateRoutes` tests patched legacy outcome columns by SQL after writing, which #5195 made inert. Fixed at the test layer — no production code changed. ## What was actually wrong My first diagnosis was that `result_state` was returning `no_result` because the tool_use↔tool_result pairing by `tool_id` had failed. **That was wrong**, and the probe that disproved it also explains why my own attempted fix (also setting `tool_outcome` on the result block) did nothing: `actions` is a view over a **materialized `action_pairs` table**, not a live join, and its `result_state` comes from `action_pairs.tool_outcome` — the outcome captured at write time on the tool_use side. Any post-write `UPDATE blocks …` is inert against it. On a fresh archive built from the exact fixture: ``` BLOCKS: …:n:m:0 tool_use tool-evidence unknown …:n:m:1 tool_result tool-evidence unknown ACTIONS: …:n:m:0 …:n:m:1 outcome_unknown ← pairing fine, result_block_id NOT NULL AFTER legacy-only UPDATE (is_error=1, exit_code=0): outcome_unknown AFTER also setting tool_outcome='ok' on the result: outcome_unknown ``` No `no_result`, no pairing problem, no endpoint-mapping problem. `polylogue/storage/sqlite/action_relation.py` is not involved and was not touched. The old parametrization also encoded the legacy SQL's precedence rather than any intent: `(is_error=1, exit_code=0) → ok` is self-contradictory evidence that the production derivation refuses outright. ## Solution Outcomes are now built through the production route — on the `ParsedContentBlock` passed to `write_index_session` — instead of SQL-patched afterwards: - `test_evidence_summary_matches_structural_tool_relations`: consistent parser evidence (`is_error=True, exit_code=2 → failed`; `is_error=False, exit_code=0 → ok`), SQL `UPDATE` removed. Still protects "a genuinely-ok call reports ok, a genuinely-failed one reports failed, through canonical `result_state`". - **New** `test_evidence_summary_reports_a_distrusted_result_as_unknown`: writes `outcome_unknown_reason="not_reported"`, then *deliberately* patches the legacy pair to `(is_error=0, exit_code=0)` and asserts `{"ok":0,"failed":0,"unknown":1}`. This pins the defect #5195 fixed — reverting to exit-code derivation turns it red. - `test_evidence_summary_composes_prefix_sharing_tool_evidence`: parent tool_result carries its outcome at parse time; inert post-write UPDATE removed. Still asserts inherited `ok:1` across the composed prefix. - Incidental repair: restored `parent_id = write_index_session(…)` in `test_session_read_page_renders_lineage_banner_for_fork_family`, clipped by a first-pass string replace and caught by the wider run before commit. ## Verification ``` devtools test "tests/unit/daemon/test_web_reader.py::TestCockpitAggregateRoutes" → PASSED exit 0 devtools test tests/unit/daemon/test_web_reader.py tests/unit/daemon/test_daemon_http.py → PASSED exit 0 devtools verify --quick → exit 0, all 19 gates ``` No non-test file changed; schema identity unmoved. ## How this reached master, and one residual #5195's worker verified `tests/unit/daemon/test_daemon_http.py`; the affected tests live in `test_web_reader.py`. The hosted merge gate is `devtools verify --quick` — static gates only, no pytest — so a behavioral change that breaks a test outside the worker's chosen selection merges clean. This is the second such regression today; the scheduled nightly corpus run declared in #5196 is the mechanism that catches this class, and it is not applied yet. Residual worth someone's call: `action_relation.py`'s `result_state` CASE still carries exit_code/is_error fallback arms, but the deployed `actions` view does not use that SQL — it reads `action_pairs`. Any consumer of `action_relation_select_sql` may still be on the legacy precedence path. Not investigated; out of scope for this red. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Problem
polylogue/daemon/http.py:4161-4167derived the tool outcome fromexit_code/is_error— the fields CLAUDE.md names as legacy nullable compatibility fields — while theactionsview already computes the canonicalresult_state(storage/sqlite/action_relation.py:96).grep result_state polylogue/daemon/http.pyreturned zero hits.A distrusted
tool_outcome='unknown'with a retainedexit_code=0was therefore reported asok, violating the rule thatunknownis never treated as success.Solution
The evidence-summary tally reads
actions.result_state:outcome_success→ok,outcome_error→failed, everything else (outcome_unknown,no_result) →unknown.action_relation.pyis untouched — it is IN the closure and already correct. No shared HTTP plumbing changed./api/sessions/:id/evidence-summaryhad no test at all. The new one seeds three paired tool calls through the canonical row writer, demotes the third totool_outcome='unknown'withexit_codestill 0 (asserted), drives the real handler, and asserts{"ok": 1, "failed": 1, "unknown": 1}.Verification
Anti-vacuity executed: restoring the
exit_code/is_errorderivation →FAILED exit=1,{'ok': 2, 'unknown': 0} != {'ok': 1, 'unknown': 1}. Reverted.Closure:
daemon/http.pyis out. No rebuild-ordering constraint.Note
derive_tool_outcomesrefusesunknownalongside a retained exit code at parse time, so this row shape arrives from durable archives written by other or older paths rather than a fresh parse — which is why the test constructs it by direct SQL. The endpoint's contract is to report correctly on whatever durable rows exist.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK