Skip to content

test: Build evidence-summary outcomes through the production route - #5201

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

Sinity merged 1 commit into
masterfrom
fix/evidence-summary-fixtures

Conversation

@Sinity

@Sinity Sinity commented Sep 15, 2026

Copy link
Copy Markdown
Owner

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 fix: Report the evidence summary from the canonical tool outcome #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.ai/code/session_01DYUNBGoE652b3nfmq3CtqK

The cockpit evidence-summary tests wrote a tool_result with
outcome_unknown_reason="not_reported" and then SQL-patched the legacy
tool_result_is_error/tool_result_exit_code columns, expecting the
reported outcome to follow them. The `actions` view reads the
materialized `action_pairs` table, so patching `blocks` after the write
is inert: the canonical tool_outcome stayed 'unknown' and the strip
correctly reported unknown.

Construct the intended outcome through the production route instead --
the ParsedContentBlock passed to write_index_session -- and keep the
"distrusted result is never ok" invariant as its own explicit test that
patches the legacy pair to (is_error=0, exit_code=0) and still expects
unknown.

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 23 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: 9c50fedd-aa1b-4337-bd0c-dc671ba65c48

📥 Commits

Reviewing files that changed from the base of the PR and between 958e5df and 9ac1911.

📒 Files selected for processing (1)
  • tests/unit/daemon/test_web_reader.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

chatgpt-codex-connector Bot commented Sep 15, 2026 •

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-15T17:14:14.743792Z 9ac1911 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 81140e2 into master Sep 15, 2026
3 checks passed
@Sinity
Sinity deleted the fix/evidence-summary-fixtures branch September 15, 2026 17:18
Sinity added a commit that referenced this pull request Sep 15, 2026
## Summary

Two gates hardening the merge boundary. Delivers polylogue-z1c94 and
polylogue-33geb.

**Why now**: two regressions reached master today from the same gap — a
worker verifies its own focused selection, and the hosted merge gate is
`devtools verify --quick`, static gates only, no pytest. #5200 and #5201
were the repairs.

Both are **gates** registered in `devtools/gate.py`, not new commands:
no root verb, no `CommandSpec`, and
`test_top_level_command_surface_is_the_folded_twelve` passes untouched.

## `gate test-collection` (z1c94)

Runs `pytest -q --collect-only` over the declared corpus using
`CLOSED_WORLD_COLLECTION_ARGS` / `IGNORED_COLLECTION_ARGS` from
`pytest_invocation` — the same values that define what the corpus *is* —
with `managed_plugin_args(testmon=False, xdist=False)`. It writes no
testmon fingerprints, so the checkout's corpus graph is untouched. Fails
on non-zero exit, on exit 5 (nothing collected), and on a zero collected
count with a green exit.

**Honest reach, stated in the docstring and asserted in tests**: it
catches an unimportable module, a syntax error, a missing symbol, a
module-scope fixture reference. It catches **no failing assertion** — so
it would not have caught either of today's reds. It closes a different
hole in the same wall.

One non-obvious thing: `agent_env.py:refuse_bare_pytest` refuses any
pytest subprocess inside an agent job unless `POLYLOGUE_PYTEST_RUN_ID`
is set, so the gate was initially red in exactly the environment where
`verify --quick` runs. It now sets
`POLYLOGUE_PYTEST_RUN_ID=gate-test-collection` — the guard protects the
host's pytest *slot* from unmetered execution, and a collect-only run
executes nothing and holds no slot.

**Executed mutation**: a test module with `from devtools.gate import
DoesNotExist` → gate exit 1 naming `ImportError: cannot import name
'DoesNotExist'`. Reverted → exit 0, `23036 tests collect cleanly (none
executed)`.

## `gate schema-closure` (33geb)

Ratchets membership against `docs/plans/schema-closure-baseline.json`
(560 members, generated by `--update`). Growth is blocking and names
each new module; shrinking passes and reports stale baseline entries.
The comparison is over **membership, not a count**, so a same-size swap
is still growth. Direction matters here: the closure may shrink freely,
but growth must be deliberate and visible, because a closure-moving
change has to land before a production rebuild starts.

**`docs/internals.md` corrected.** Measured at head: **560 of 1,311
modules — storage 162, archive 99, sources 93, core 50**, against
documented 442 of 1,241. `sources/live/watcher.py` was listed as outside
the closure and is **inside**. The corrected prose pairs
`daemon/write_coordinator.py` + `sources/live/watcher.py` (in) against
`daemon/convergence.py` + `daemon/cli.py` (out), and points at the
baseline as the membership of record. (The bead said 561/1314; the live
measurement is 560/1311 — the bead's figure came from my dispatch, and
the worker's measurement supersedes it.)

**Executed mutations**: adding `import polylogue.daemon.convergence` to
a member file grew the closure 560→563 and turned the gate red, naming
all three new modules; then `--update` to 563 and reverting the import
left 560 against a 563 baseline, passing with `3 baseline entr(y/ies) no
longer feed the identity`. Baseline restored; `polylogue/` is byte-clean
in the diff.

## Verification

```
devtools test tests/unit/devtools/{test_verify,test_schema_closure,test_command_catalog,test_verify_test_collection}.py
    → exit 0, 85 tests (13 new)
devtools verify --quick → exit 0, incl. gate schema-closure ok (2.5s) and gate test-collection ok (93.3s)
devtools render all --check → exit 0, 0 "out of sync"
mypy → Success, 2896 source files
```

All seven changed/added files are **outside** the closure.

## Residual the reviewer should weigh

**`test-collection` adds ~93s to the quick gate on this host (148s
cold).** The bead said "seconds"; it is not seconds. It needs no pytest
slot and is cheap relative to `verify --quick`'s existing minutes, but
the merge gate got ~1.5 min slower and that is a real cost on every PR.

The `sources/revision_backfill.py` → `archive_tiers/archive.py` import
narrowing named in 33geb's "related structural fix" is **not** done —
separate import-hygiene work, now visible when someone does it, since
the closure will shrink and the gate will report stale baseline entries.

🤖 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