Repository navigation
fix(storage): Stamp the input binding the ingest refresh computed from - #5322
Conversation
The ingest materialize stage (refresh_session_insights_bulk) hydrates every changed session and writes its profile family, but never passed input_content_hash. inspect_session_profiles treats a profile with no stored binding as stale -- a row that cannot say what it was computed from never certifies itself -- so the daemon converger hydrated, rebuilt and rewrote the identical family on its next pass. Every ingested session was materialized twice by construction; the full-rebuild and degraded/large-session builders already stamp, so only the incremental hydrated paths were affected. Read the binding on the same connection as load_async_batch and pass it to build_session_insight_records in both the bulk and single-session paths. Verification: devtools test tests/unit/storage/test_session_insight_refresh.py -> 40 passed (receipt 20260921T023452Z-focused-test-2883215-700ba68f). Executed mutations: dropping the stamp, and stamping a constant instead of session_input_bindings_async, each turn the three new tests red. devtools verify --quick exit 0; devtools render all --check exit 0, no "out of sync"; devtools schema closure reports refresh.py out of the derived closure. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq
|
You have reached your Codex usage limits for security reviews. Please try again later. |
|
Warning Review limit reachedNext included review available in 51 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5af36574af
ℹ️ 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".
Summary
The ingest-path refresh wrote
session_profilesrows without stamping the inputbinding it computed from, so its own output could never be found stale.
Problem
storage/derived/session/refresh.pyis a second live writer ofsession_profiles/session_latency_profiles, reached frompipeline/services/ingest_batch/_core.py:3067andstorage/repository/archive/writes/sessions.py:5. It published rows without theinput-binding stamp that the derivation path uses to decide staleness — so a
row it wrote was doomed by construction: no later pass could tell whether the
inputs behind it had moved.
Solution
Stamp the binding the refresh actually computed from. The row now carries the
same evidence the derivation path carries, so staleness is decidable for both
writers.
This does not retire
refresh.pyas a second writer — that needsSessionInsightCountsfield changes whichrebuild.py:2211,2409also populate,and
rebuild.pywas outside this dispatch's scope. What lands here is thedoomed-by-construction half.
Verification
devtools test tests/unit/storage/test_session_insight_refresh.py— 40 passed,including 3 new tests over the live ingest materialize route
_apply_session_insight_session_update(s)_asyncfailed / 37 passed; pinning
input_content_hash="frozen-constant"→ 3 failed /37 passed. A constant stamp does not survive.
devtools test tests/unit/pipeline/test_ingest_batch.py— passed (theproduction caller of the changed function)
devtools verify --quick— exit 0, 23 gatesdevtools render all --check— exit 0,grep -ci 'out of sync'= 0devtools schema closure polylogue/storage/derived/session/refresh.py→ out.The only production file edited, so no identity move and no rebuild
constraint.
Two refutations worth recording
The bead's two self-justifying probes are stale. Duplicate
::note:presenceis deduped at
derivation.py:88-99withdict.fromkeys, comment naming thereason; the usage-committing publication wrapper was removed by #5312, which made
usage a prerequisite domain (
derivation.py:539). Neither survives on dead code—
publish_session_profile(derivation.py:411) is a callerless predecessor anda separate entry, not either probe.
The 2026-09-15 design note's "four families, only two have owners" is wrong at
head.
threads(index.py:955) andsession_tag_rollups(index.py:1718)are VIEWS, and provider/day is a read-time grouping helper
(
derived/session/aggregates.py). There are no retained thread/tag/provider-dayaggregate tables, so they need no partition key, inspect query or atomic
replacement. The retained family is two tables, not four; work-event and
phase rows were already retired.
Residuals
worker stopped rather than editing: separating marker delivery from profile
validity requires registering a domain in
daemon/session_profile_composition.py:59and changing where the preparedbundle binds
marker_candidates(rebuild.py:1839). One lane needs to owndaemon composition +
rebuild.py+derivation.pytogether.coalescing) is reproducible at the storage level today, but fixing it is the
full source-to-user batch/cursor protocol including a durable
source.dbaddition behind a verified backup. Out of one PR's scope.
tests/unit/storage/test_session_insight_profiles.pyfails 2, not the 1 theknown-red baseline records.
Advances polylogue-ylh7v.
🤖 Generated with Claude Code
https://claude.ai/code/session_015WCh9YW3cRfsg3CZBKU7Fq