Skip to content

test(daemon): cover provider usage periodic drain - #2797

Merged
Sinity merged 3 commits into
masterfrom
feature/fanout/usage-convergence
Jul 12, 2026
Merged

Sinity merged 3 commits into
masterfrom
feature/fanout/usage-convergence

Conversation

@Sinity

@Sinity Sinity commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Strengthen the provider-usage convergence regression by running its stale-rollup fixture through the daemon’s bounded periodic session-insight drain.

Problem

The usage-refresh mechanism was present, but its regression invoked the stale selector and executor directly. That did not prove the bounded daemon drain selected and refreshed stale provider-usage materialization.

Solution

Update tests/unit/storage/test_session_insight_refresh.py to use an isolated active archive root, establish a fresh insight bundle, corrupt a Codex provider-usage rollup, invoke _drain_session_insights_once(), and verify the repaired rollup, materialization stamp, and operator-visible debt transition.

Acceptance criteria

Ref polylogue-f2qv.

  • Satisfied: provider-usage materialization is included in the periodic session-insight stale selector.
  • Satisfied: the daemon drain refreshes an old provider-usage stamp and re-derives session_model_usage without a manual index rebuild.
  • Satisfied in an isolated archive: the Codex provider-usage zero-token debt row appears after corruption and clears after the daemon drain. This lane did not access the operator archive.
  • Satisfied: focused real-route regression passes.

Verification

  • POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest TMPDIR=/realm/tmp devtools test tests/unit/storage/test_session_insight_refresh.py -k stale_provider_usage_self_heals_via_session_insight_rebuild — 1 passed.
  • TMPDIR=/realm/tmp git push — required quick baseline passed all checks.

Adversarial review notes

  • Iteration 1: two real gaps found and fixed — missing-profile selection made the original test vacuous (8b295bbc0), and archive-debt AC coverage was absent (8aaaffa55).
  • Iteration 2: no legitimate gaps found across the f2qv.5 ACs.

Problem: the provider-usage self-heal regression covered the selector and executor directly, but not the daemon entry point that invokes them.

What changed: run the stale-rollup fixture through the bounded periodic session-insight drain against an isolated index tier, then assert the second pass is idle.

Ref polylogue-f2qv.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 66771dc8-1661-4a81-93e3-85e177ac6d52

📥 Commits

Reviewing files that changed from the base of the PR and between 901825e and 8aaaffa.

📒 Files selected for processing (1)
  • tests/unit/storage/test_session_insight_refresh.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fanout/usage-convergence

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 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c07d83bc69

ℹ️ 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".

Sinity and others added 2 commits July 13, 2026 00:16
Problem: the provider-usage drain fixture was selected through a missing profile, so it did not prove the provider-usage stale selector was necessary.

What changed: seed a fresh session-insight bundle before downgrading only the provider-usage materialization stamp.

Ref polylogue-f2qv.

Co-Authored-By: Claude <[email protected]>
Problem: the drain regression proved rollup repair but not the operator-visible zero-token debt transition required by the usage-refresh acceptance criteria.

What changed: use a Codex fixture, prove the seeded bundle is initially converged, and assert provider-usage debt appears after corruption then clears through the daemon drain.

Ref polylogue-f2qv.

Co-Authored-By: Claude <[email protected]>
@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 1

Findings:

  • Real gap: the original fixture had no fresh session_profile, so the drain could select it through the unrelated missing-profile branch. Fixed in 8b295bbc0 by materializing the initial insight bundle before corrupting provider usage.
  • Real gap: AC 3 promised the archive-debt transition but the test only checked storage rows, and its Claude-origin fixture could never produce the Codex-only provider-usage debt row. Fixed in 8aaaffa55: the fixture is now Codex-origin, proves the initial drain is idle, asserts the real archive_debt_list row appears after corruption, and asserts it disappears after the daemon drain.
  • Review comments: the substantive inline Codex finding was addressed above; CodeRabbit was rate-limited and supplied no review finding.

What survived scrutiny: the production drain, stale selector, insight rebuild, usage rollup, materialization stamp, and operator-visible debt surface are now exercised end-to-end against an isolated archive. Focused verification: POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest TMPDIR=/realm/tmp devtools test tests/unit/storage/test_session_insight_refresh.py -k stale_provider_usage_self_heals_via_session_insight_rebuild → 1 passed; required pre-push quick baseline passed all checks.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Adversarial review — iteration 2

No new legitimate findings. A cold review rechecked the full branch diff, f2qv/f2qv.5 design and notes, production stale-selection/rebuild/debt paths, PR claims, and current review discussion. The test’s fresh-bundle idle drain prevents missing-profile selection from masking provider-usage staleness; its Codex fixture proves the real archive-debt row appears and then clears through the bounded daemon drain.

@Sinity

Sinity commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

Final f2qv.5 acceptance-criteria matrix

Ref polylogue-f2qv.

AC Status Evidence
1. Materializer version plus periodic stale check Satisfied provider_usage materialization stamp is selected by the bounded daemon drain; the fixture begins with an idle fully fresh bundle.
2. Old version refreshes without manual rebuild Satisfied The test downgrades only the provider-usage stamp, runs _drain_session_insights_once(), and verifies restored token rows plus the current stamp.
3. Zero-token provider-usage debt drains Satisfied A Codex-origin fixture emits the real archive_debt_list zero-token row after corruption, then has no such row after the drain.
4. Focused test passes Satisfied POLYLOGUE_PYTEST_BASETEMP_ROOT=/realm/tmp/polylogue-pytest TMPDIR=/realm/tmp devtools test tests/unit/storage/test_session_insight_refresh.py -k stale_provider_usage_self_heals_via_session_insight_rebuild → 1 passed.

No criterion is deferred or misframed. The operator live archive was intentionally not accessed; that is not required for this isolated convergence contract.

@Sinity
Sinity merged commit bfbecc1 into master Jul 12, 2026
3 of 13 checks passed
@Sinity
Sinity deleted the feature/fanout/usage-convergence branch July 12, 2026 23:09
Sinity added a commit that referenced this pull request Jul 12, 2026
…789,2792,2797

d3xj, w8et, w379 (cost-honesty, PR #2776), fs1.3 (hermes-wedge, PR #2789), and
f2qv.5 (usage-convergence, PR #2797) fully satisfied — closed. cuxz
(temporal-provenance, PR #2786), th0 (test-harness, PR #2777), and fs1.11/
fs1.12 (hermes-wedge cluster, PR #2792) partially satisfied — noted with
disposition, left open per closure-discipline (no closing on partial ACs).

Co-Authored-By: Claude <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 79.F116 / P2: stale at the checked revision: The former missing-profile/provider-usage daemon selector test is absent at the pin. The current usage repair test directly invokes rebuild_session_insights_sync at tests/unit/storage/test_session_insight_refresh.py:873 and asserts repricing from retained provider usage, rather than claiming selection specifically through the removed provider_usage staleness branch.

Only the rows listed above are dispositioned. Held findings remain open.

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