Skip to content

fix(lcm): session reads hide superseded replay copies (t_9cdad21b) - #1053

Merged
Kyzcreig merged 1 commit into
mainfrom
lcm/superseded-session-reads-t_9cdad21b
Sep 25, 2026
Merged

Kyzcreig merged 1 commit into
mainfrom
lcm/superseded-session-reads-t_9cdad21b

Conversation

@Kyzcreig

@Kyzcreig Kyzcreig commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Kanban t_9cdad21b (derived from t_f97bce35). Must land before/with the live replay-dedup apply.

Per-session store reads (tail/count/token total/messages/after/range/load page+window) now filter superseded_by IS NULL, backed by a partial index idx_msg_session_visible. Measured on the live store: COUNT on the largest session (63,392 rows) would go 2 ms -> 75 ms without the index. Index build on the 1.35 GB argus copy took 0.25 s; the 12 GB main DB should be a one-time few seconds at first open.

raw_session_count in reconcile means 'before ignore-pattern filtering', not 'including hidden copies', so it takes the visible count.

Tests: tests/context_engine/test_lcm_superseded_session_reads.py (6; 5 fail on main, including the reconcile re-bind test which re-appends the replay). Local narrow run: that file + test_dup_on_replay_fix + test_ingest_timestamp_fidelity, 35 pass. CI is the gate.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The replay-block dedup migration soft-hides NON-canonical replay copies
(superseded_by set; the higher store_ids, i.e. the session tail). Only
search/grep filtered them. Every per-session read - get_session_tail,
get_session_count, get_session_token_total, get_session_messages(_after),
get_range, load_session_page/count, load_session_window - returned them,
so re-bind reconcile matched incoming replays against hidden rows (the
new test re-appends the whole replay without this fix) and counts/token
totals kept counting ~899k hidden rows on the snapshot.

- store: _VISIBLE_MESSAGE_CLAUSE on all session-scoped reads. Raw by
  design: get()/get_many by store_id, whole-corpus coverage scan,
  delete_session_messages, get_source_stats, scan_session_retention_stats.
- db_bootstrap: partial index idx_msg_session_visible(session_id,
  store_id) WHERE superseded_by IS NULL, existence-checked first so a
  store open takes no write lock once built. Without it COUNT on the
  largest live session (63,392 rows) went 2 ms -> 75 ms.
- test: store reads, reconcile re-bind over a hidden block, index plan,
  and an AST detector that fails on any new per-session read in store.py
  lacking the clause (allowlist needs a reason).
@Kyzcreig

Copy link
Copy Markdown
Collaborator Author

🤖 merged-by: apollo · lane: kanban-merge-pass · gate: BYPASS: FleetReview paused by Ace 2026-09-22 (state/fleetreview-pause marker present) · why: t_9cdad21b: lcm store: get_session_tail / get_session_count / get_session_messages(_after) d; Argus off card review (Ace 13:08), CI green

@Kyzcreig
Kyzcreig added this pull request to the merge queue Sep 25, 2026
@Kyzcreig
Kyzcreig removed this pull request from the merge queue due to a manual request Sep 25, 2026
@Kyzcreig
Kyzcreig added this pull request to the merge queue Sep 25, 2026
Merged via the queue into main with commit 1273209 Sep 25, 2026
57 checks passed
@Kyzcreig
Kyzcreig deleted the lcm/superseded-session-reads-t_9cdad21b branch September 25, 2026 06:18
@Kyzcreig Kyzcreig added the fleetreview:post-merge Ask FleetReview to review this MERGED pull (merge commit vs first parent) label Sep 25, 2026
@ang-prism

ang-prism Bot commented Sep 27, 2026

Copy link
Copy Markdown

FleetReview

Review: post-merge · head 1273209b8dc3 · duration 5m 33s
Profile: light (merit: default light: lines 227<800, files 3<1000000, hunks 10<1000000, no hot path) · policy: below-size-and-path-gates
Roster: B-assert-ctx → gpt-6-sol (openai), C-assert-xhigh → claude-code-opus-5-5 (anthropic), F → gpt-6-sol (openai), G → grok-4.6 (xai)

Post-merge review (fleetreview:post-merge override): this reviewed the merge commit against its first parent — the bytes that already shipped. It is not a pre-merge gate pass.

profile: light (rule: default light: lines 227<800, files 3<1000000, hunks 10<1000000, no hot path) · round 0 · members: B-assert-ctx, C-assert-xhigh, F, G · families: anthropic,openai,xai

Confidence: 3/5

Findings

  • P1 plugins/context_engine/lcm/db_bootstrap.py:3489 — O(rows) CREATE INDEX runs synchronously on the engine-load path the first time an upgraded store opens · agreed: C-assert-xhigh,F (anthropic, openai)
  • P1 plugins/context_engine/lcm/store.py:1043 — Hidden anchors produce windows around unrelated messages · agreed: C-assert-xhigh,F (anthropic, openai)
  • P1 plugins/context_engine/lcm/store.py:930 — Filtered range breaks session-end prefix matching for raw replays · agreed: F (openai)

FleetReview provenance · models: B=gpt-6-sol, C=claude-code-opus-5-5, D=grok-4.6, F=gpt-6-sol · cost: $3.14 · duration: 5m 30s · rounds: 1 · files examined: 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleetreview:post-merge Ask FleetReview to review this MERGED pull (merge commit vs first parent)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant