Skip to content

test(insights): guard message-budget rebuild chunks - #2538

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/insight-convergence-1xc
Jul 4, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/insight-convergence-1xc

Conversation

@Sinity

@Sinity Sinity commented Jul 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the missing sync full-rebuild regression for bounded-WAL session insight rebuilds: the test keeps page_size larger than the fixture and forces chunking only through the message-budget planner, then proves intermediate committed session_profiles are visible from a second connection. It also documents session insights as an automatic daemon convergence invariant alongside FTS and embeddings.

Problem

rebuild_session_insights_sync already commits per chunk, but existing coverage could still pass if the full rebuild regressed to fixed-count chunking. That misses the original production failure shape: a small number of giant sessions can still create a huge WAL/write-lock window. Separately, the internals docs did not clearly state that insights are an automatic derived-model convergence invariant rather than operator maintenance.

Solution

  • Add test_full_rebuild_chunks_by_message_budget_before_page_size in tests/unit/storage/test_session_insight_refresh.py.
  • Keep the existing no-empty-window/per-chunk visibility proof and make the new test prove message-budget chunking specifically.
  • Fix the adjacent backfill-day fixture so it models a newly acquired older transcript instead of a stale replace the archive writer should reject.
  • Update docs/internals.md and regenerated AGENTS.md to describe insights as a daemon-enforced FTS/embed peer, including why rebuilds remain outside ingest transactions: WAL/lock isolation, hot-source batching, and materializer-version rebuildability.
  • Close Beads polylogue-1xc.1 and polylogue-1xc.9.

Verification

  • devtools test tests/unit/storage/test_session_insight_refresh.py::test_full_rebuild_chunks_by_message_budget_before_page_size tests/unit/storage/test_session_insight_refresh.py::test_full_rebuild_commits_incrementally_and_prunes_orphans tests/unit/daemon/test_convergence_stages.py::test_default_convergence_stages_retry_bounded_false_results -> 3 passed.
  • devtools render all --check -> OK.
  • devtools test tests/unit/storage/test_session_insight_refresh.py tests/unit/daemon/test_convergence_stages.py -> 61 passed.
  • devtools verify --quick -> passed, run 20260704T215833Z-quick-1935811-feb86f4f.
  • Pre-push devtools verify --quick -> passed on cb556339a64cd8ba9a8f40616f85b129434faf9f, run 20260704T220022Z-quick-1944727-a492c91b.

Ref polylogue-1xc.1
Ref polylogue-1xc.9

Summary by CodeRabbit

  • Documentation
    • Expanded internal guidance on convergence behavior to cover session insights, including rebuild timing, retry handling, and chunked processing limits.
  • Tests
    • Added regression coverage for session insight refreshes to verify rebuilds are processed in bounded chunks and complete successfully.
  • Chores
    • Updated issue and interaction tracking records to reflect completed work.

Problem: the bounded-WAL insight rebuild had coverage for per-chunk commits, but the sync full-rebuild regression forced chunks with page_size=1. That still left room to regress back to fixed-count chunking and miss the production failure shape where a small session count can represent a huge message window.

What changed: add a sync full-rebuild regression that keeps page_size larger than the fixture, patches the message budget small, and asserts multiple committed windows with intermediate session_profiles visible from a second connection. Document insights as an automatic daemon convergence invariant alongside FTS and embeddings, including why the rebuild stays outside ingest transactions. Also fix the adjacent backfill-day fixture so it exercises a newly acquired older transcript instead of a stale replace the archive writer correctly rejects.

Verification: devtools test tests/unit/storage/test_session_insight_refresh.py tests/unit/daemon/test_convergence_stages.py; devtools render all --check; devtools verify --quick (run 20260704T215833Z-quick-1935811-feb86f4f).
@Sinity
Sinity merged commit 6d8b459 into master Jul 4, 2026
11 of 12 checks passed
@Sinity
Sinity deleted the feature/fix/insight-convergence-1xc branch July 4, 2026 22:01
@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: eb82b8c3-d8f8-4a61-b222-5e63a15da635

📥 Commits

Reviewing files that changed from the base of the PR and between 1f629c9 and cb55633.

📒 Files selected for processing (5)
  • .beads/interactions.jsonl
  • .beads/issues.jsonl
  • AGENTS.md
  • docs/internals.md
  • tests/unit/storage/test_session_insight_refresh.py

📝 Walkthrough

Walkthrough

This PR documents session insights as a daemon convergence evidence category in AGENTS.md and docs/internals.md, adds a regression test for chunked full rebuild behavior and updates fixture comments in test_session_insight_refresh.py, and records closure of two beads issues.

Changes

Session insight convergence documentation and tests

Layer / File(s) Summary
Convergence evidence documentation
AGENTS.md, docs/internals.md
Documents session insights (profiles, work events, phases, threads, run projections) as convergence debt until rebuilt, notes idempotent rebuilds by session id/materializer version, chunked commits outside the ingest write transaction, and batching during quiet/hot windows.
Rebuild chunking test and fixture updates
tests/unit/storage/test_session_insight_refresh.py
Adds a regression test verifying full rebuild chunks by message budget before page size using progress callbacks, and updates a fixture timestamp with explanatory comments in an existing targeted rebuild test.
Issue closure records
.beads/issues.jsonl, .beads/interactions.jsonl
Records closure of issues polylogue-1xc.1 and polylogue-1xc.9 with close reasons, lifecycle timestamps, and interaction log entries.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/insight-convergence-1xc

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.

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