Repository navigation
perf(storage): Retire the derived session_events.summary column - #5446
Conversation
`session_events.summary` was a write-time render of `payload_json["summary"] or payload_json["text"]`, stored beside the payload it was derived from. Measured on the live index (read-only, 7,403,923 rows): the column reproduces from the retained payload in 7,403,923 of 7,403,923 rows with zero exceptions, and costs 178.9 MB. It was already declared non-load-bearing: absent from SESSION_EVENT_PROJECTION_COLUMNS, listed in SESSION_EVENT_EXCLUDED_COLUMNS as "not read by sync_session_events_batch", never selected by the read path (storage/sqlite/queries/session_events.py), and absent from the SessionEvent read model. One writer used it as primary rather than derived storage: record_capture_gap wrote its prose into `summary` with an empty payload. That evidence now goes into the payload as four named fields plus its rendered summary, so the gap is queryable by field instead of by substring. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
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. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (13)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b866cc027
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…mn (#5458) ## Summary Repairs a regression introduced by **#5446**, which I landed earlier today. ## Problem #5446 retired `session_events.summary` — a derived column that reproduced from `payload_json` in **7,403,923 of 7,403,923** live rows, costing 178.9 MB. One test fixture still wrote it: ``` sqlite3.OperationalError: table session_events has no column named summary ``` `tests/unit/storage/test_session_profile_derivation.py:462` inserted `(session_id, source_message_id, position, event_type, summary, payload_json)`. ## Solution The event's summary rides in `payload_json` — which is where the retired column was reproducing it from in the first place, so the fixture now writes the shape production actually stores. ## Verification ``` devtools test tests/unit/storage/test_session_profile_derivation.py -> PASSED (32/32) devtools verify --quick -> PASSED exit=0 ``` Before: 31 passed / 1 failed. ## How it was found A `gpt-5.6-luna` worker on an unrelated bead (polylogue-bp12n.1) reported it as an *inherited* baseline failure rather than absorbing it or working around it. That is the reporting discipline paying off — the worker had no stake in this file and still surfaced it with the receipt. It also shows the gap in my own landing of #5446: `devtools verify --quick` was green on that branch because the quick set does not run this suite, and the branch's own focused selection did not include it. A retired column needs a grep for its writers across `tests/` as well as `polylogue/`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
## Summary Completes the cleanup of **#5446** (retiring `session_events.summary`). My first repair, **#5458**, fixed one file; three more were still referencing the dropped column. ## What was still broken on master | file | how | |---|---| | `tests/unit/pipeline/test_ingest_batch.py` | `SELECT event_type, summary` + two assertions on `event["summary"]` | | `tests/unit/storage/test_archive_tiers_archive.py` | `SELECT event_type, summary` at two sites + two assertions | | `tests/unit/storage/test_archive_tiers_write.py` | `SELECT … summary …` plus **three** stale `"summary"` keys in its expected rows | All now read `payload_json` — which is exactly what the retired column reproduced from, in **7,403,923 of 7,403,923** live rows. ## Verification ``` devtools test test_ingest_batch.py test_archive_tiers_archive.py test_archive_tiers_write.py -> 265 passed / 265, exit 0 devtools verify --quick -> PASSED exit=0 ``` The write-path file needed three separate passes: each stale `"summary"` key in the expected-row list surfaced only after the previous one was removed, because the assertion compares whole dicts and reports the first differing index. ## How this was found, and what it says about my own process A `gpt-5.6-luna` worker on an unrelated bead (polylogue-3szyi) reported it as an *inherited* baseline failure. That is the second time today a worker with no stake in the file surfaced this regression — the first led to #5458. My #5458 fix was incomplete because I grepped for **writers** (`INSERT`) and stopped. Retiring a column needs a search for **every** reference — reads, expected-row fixtures and assertions included. `devtools verify --quick` cannot catch this: none of these suites are in the quick set. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
…ases (#5467) ## Summary Produces per-case verdicts for the two writer cases polylogue-asp4b left unestablished. Test-only; schema closure not applicable. Produced by a `gpt-5.6-luna` worker. ## Why this exists `asp4b` AC1 asks that *"each **real remaining** named writer bug has a discriminating fixture."* Three of its five cases were already fixed at head. Two — **sibling-append** and **supersession** — were reported UNESTABLISHED by two separate workers: neither could locate a seam. "Nobody could find it" is absence of evidence, not evidence of absence, and closing on it is the closure-by-assertion pattern this campaign's own audit condemned. So the ask was a verdict per case: either a discriminating fixture that reproduces the defect, or an argument from the writer's construction that the case **cannot occur**. Both are now answered, in opposite directions. ## Sibling-append — cannot occur, by construction `thread_sessions` keys each membership by `(thread_id, session_id)`. An append therefore adds exactly one distinct child and preserves every prior membership; **there is no last-writer choice for a sibling to make**. Pinned by an assertion that the parent thread holds 3 rows / 3 distinct sessions after two appends, alongside the existing "no membership rebuild" check. ## Supersession — real, and now pinned A revised hook claim must leave **exactly one** authoritative parent per child. The fixture asserts that after revision. Anti-vacuity **executed**: removing the supersession demotion left **both** the old and revised parents authoritative. Production code restored. ## Verification ``` devtools verify --quick -> PASSED exit=0 devtools test test_archive_tiers_write.py test_topology_hook_authority_conflict.py -> 134 passed / 134 ``` The first run of that selection failed on `no such column: summary` — my own regression from #5446, unrelated to this branch. Rebasing onto master with #5465 merged cleared it. AC2-AC4 were already landed at head; the compound owner FK remains at `archive_tiers_specs.py:94,642`. No production change was needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Expanded automated coverage for session membership updates, verifying appended sessions remain distinct and existing memberships are preserved. * Added checks confirming revised hook claims are reflected in stored session links. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary Fixes the tests that fail on clean master, and the two product defects behind the biggest groups of them. ## Problem On clean master (checked at `2da021c54`), 11 tests in the web reader, MCP raw-session operations, thread profiles and browser capture failed, 35 in `test_privileged_tools.py` and `test_facade_mutation_census.py`, 5 in `test_session_insight_refresh.py`, and 4 more elsewhere. Two of the causes are product defects: - **API-owned mutations were refused through the daemon.** The daemon labels every machine-protocol principal as surface `cli`. `user.*` overlay operations and `mutation.facade.*` products have no CLI route, and their actuators allow only `mcp`/`api`/`facade`. So a web-reader saved-view save, or an annotation or saved-view delete, answered 409 `SurfaceDeniedError`. Every Python-API or MCP facade write through a running daemon also failed; for example, `add_tag` returned "did not complete: failed". - **The async insight rebuild never cleared profile demand.** `rebuild_session_insights_async` replaced profiles but left the `session_profile_demand` row they satisfied. The profile therefore read `stale` forever, although its binding matched. The sync twin already acknowledges the captured revision. The remaining failures were stale tests, each against a deliberate change: - The index version counter restarted at 1, so `user_version = 1` no longer mismatches. - Raw coverage rows follow configured source order since #5632. - `session_events.summary` was retired in #5446. - Markers are consumed from source-owned accepted inputs since #5493. - #5550 deleted `_execute_facade_mutation`, which the census measured. - `add_raw` gained `prepared_artifact`. - The census wrapper gained a phase commit in #5550. - Retained preparation runs in a spawned worker since #5565, so a 3 s completion bound times out on a loaded host. - `CliRunner.output` interleaves stderr, where `--allow-no-auth` writes its warning. ## Solution - `MutationPrincipal.on_surface(...)`. The user-overlay handler and the facade product handlers now execute as the `api` surface, the public surface that owns them, whichever transport delivered the request. - The facade client lowers tuple arguments to JSON arrays before the strict request models validate them. `bulk_tag_sessions` and `post_blackboard_note` were refused before any daemon call. - The saved-view HTTP route validates its query spec strictly, so a bad field is a 400 with `field`, not a 409 failed operation. - The async rebuild deletes the exact captured demand revision for each rebuilt session. The derived-sweep census declares it and is regenerated; the regeneration also reorders the stale `daemon_ingest.py` entry. - The MCP write, run and confirm-gate tests now run against the real resident operation stack (`running_daemon_operations`). The executor spies and failure-propagation proofs therefore observe the daemon's executor. - `test_facade_mutation_census.py` is deleted. Its own retirement condition fired: the helper is gone and every facade mutation submits a declared operation. - Each stale test is realigned with the contract it tests; see the commit messages. ## Verification - `devtools test` over the 11 affected test files plus the three `test_revision_backfill.py` ids and `test_raw_observation_owner.py`: `707 passed` (receipt `20260927T193036Z-focused-test-1998248-bb6cdb4a`, pre-rebase; the rebase onto `917fcaa17` applied cleanly and touched none of these files except an unrelated appended web-reader test). - `devtools verify --quick` passed before the last two test-only edits; the hosted quick gate covers the pushed head. - Derived-sweep census round-trip re-checked on the rebased tree: identical. - `devtools schema closure`: `mutation_transaction.py` and `derived/session/rebuild.py` are IN, so this lands before a rebuild. The other changed production files are OUT. ## Residuals - The route-family declarations carry placeholder examples (`default`/`route`) that no handler accepts, for example `/api/import/explain` and `/api/webui/freshness` return 400. The example replay now covers the kernel-bound routes only; `polylogue-otmpm` tracks making the family examples real. - A pre-reset archive (index `user_version` 67) is now classified `upgrade_runtime`, because the counter restarted at 1. The old archive is inert salvage and is never opened, so this was not changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013Vn4qhKjhyaVBG4aPiqNW4 --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
|
Closing out open Codex review threads on this PR (evidence checked against master at ef10e59):
Resolving the fixed, stale and refuted threads; tracked threads stay open. |
Summary
Retires a derived-tier column that reproduces from its own input in 7,403,923 of 7,403,923 live rows, zero exceptions, costing 178.9 MB. Bead: polylogue-kc8eq (all five criteria); polylogue-wzgpf not attempted, premise corrected.
Premise correction
Both beads recorded that live-archive measurement is blocked by
SchemaSkewError. That is wrong for read-only measurement — the wall applies to archive-opening maintenance routes; a plain read-onlysqlite3URI connection bypasses it. The census the kc8eq addendum declared impossible was run.Measurement (frozen live index, 7,403,923 rows)
claude_queue_operationfunction_callfunction_call_outputExactly one carrier clears the 20% rule, and it is kept: it is not a derived projection — it carries queued prompt content that exists nowhere else.
Decomposing by field ownership found the real redundancy.
session_events.summaryis a write-time render ofpayload_json["summary"] or payload_json["text"], stored next to its own input. Three independent declarations already said it was not load-bearing: absent fromSESSION_EVENT_PROJECTION_COLUMNS; listed inSESSION_EVENT_EXCLUDED_COLUMNSas "not read by sync_session_events_batch"; never selected bystorage/sqlite/queries/session_events.py; absent from theSessionEventread model.A hazard found and fixed before deleting
record_capture_gapwas the single writer using the column as primary storage — a prose summary with an empty payload. Deleting the column blind would have silently destroyed that evidence. Its four values now persist as named payload fields, queryable by field rather than by substring.Verification
The single failure is
tests/unit/demo/test_demo_seed_verify.py::test_seed_demo_embedding_session_is_classified_fresh_not_pending, which is pre-existing — I confirmed it atcba0480d7, before any of today's merges, and it is untouched by this branch.Anti-vacuity executed through the real production route (
demo/seed.py->record_capture_gap_event), not a fixture: withholding the summary from the capture_gap payload givesSchema
Additive-derived (a derived-tier column removal);
indexcarries no version chain, so no migration. Five changed files are IN the closure (archive_tiers_specs.py,write.py,revision_governance.py,ingest_precedence.py,input_binding.py);demo/constructs.pyis out. Index identity moves015a941a75ea6903…->01317a7dccde0d6f…. Must land before a fresh rebuild starts, never during one.polylogue-wzgpf — not attempted, with a corrected premise
AC2 is satisfied pre-existing (#5284), verified at head:
zip_acquisition_replay.py:3states the hint contract,:236passessource_indexas a hint into structural resolution,decoder_zip.py:326emitssource_index=Noneon the whole-member path.AC1/AC3/AC4/AC5/AC6 not attempted — corpus reclassification plus a durable migration, and the bead is
write_scope: NONE.One finding the bead does not record: the durable side is entirely unmigrated. Live
raw_sessionshassource_indexand noaddressing_modeand nocontent_identitycolumn, and all 11,803 rows have non-nullsource_index— so zero of the 43 whole-member blobs have been reclassified. At headaddressing_modeexists only onsource_generations/source_items, not per-raw. AC6 is therefore unsatisfied by schema, not merely by missing receipts, and its successor is a durable additive migration.No operator data is committed; the measurement was read-only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ToWqpkXotr573DiQex5vcy
Summary by CodeRabbit
Data Storage
Bug Fixes
Tests