Skip to content

fix: Report the evidence summary from the canonical tool outcome - #5195

Merged
Sinity merged 1 commit into
masterfrom
fix/evidence-summary-result-state
Sep 15, 2026
Merged

Sinity merged 1 commit into
masterfrom
fix/evidence-summary-result-state

Conversation

@Sinity

@Sinity Sinity commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Problem

polylogue/daemon/http.py:4161-4167 derived the tool outcome from exit_code/is_error — the fields CLAUDE.md names as legacy nullable compatibility fields — while the actions view already computes the canonical result_state (storage/sqlite/action_relation.py:96). grep result_state polylogue/daemon/http.py returned zero hits.

A distrusted tool_outcome='unknown' with a retained exit_code=0 was therefore reported as ok, violating the rule that unknown is 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.py is untouched — it is IN the closure and already correct. No shared HTTP plumbing changed.

/api/sessions/:id/evidence-summary had no test at all. The new one seeds three paired tool calls through the canonical row writer, demotes the third to tool_outcome='unknown' with exit_code still 0 (asserted), drives the real handler, and asserts {"ok": 1, "failed": 1, "unknown": 1}.

Verification

devtools test tests/unit/daemon/test_daemon_http.py → EXIT 0  (receipt 20260915T161306Z-…)
devtools verify --quick → EXIT 0, all 19 gates

Anti-vacuity executed: restoring the exit_code/is_error derivation → FAILED exit=1, {'ok': 2, 'unknown': 0} != {'ok': 1, 'unknown': 1}. Reverted.

Closure: daemon/http.py is out. No rebuild-ordering constraint.

Note

derive_tool_outcomes refuses unknown alongside 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

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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 50d67611-1754-4922-a6da-cd77b4fbbe86

📥 Commits

Reviewing files that changed from the base of the PR and between 1c77e31 and 027e210.

📒 Files selected for processing (2)
  • polylogue/daemon/http.py
  • tests/unit/daemon/test_daemon_http.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-15T16:28:30.388931Z 027e210 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Sinity
Sinity merged commit 1043acf into master Sep 15, 2026
3 checks passed
@Sinity
Sinity deleted the fix/evidence-summary-result-state branch September 15, 2026 16:33
Sinity added a commit that referenced this pull request Sep 15, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant