Skip to content

test(session_id): ≥80% population guard via two-session ingest run (#554) - #561

Merged
robotrocketscience merged 1 commit into
mainfrom
test/issue-554-session-id-population-rate
May 10, 2026
Merged

test(session_id): ≥80% population guard via two-session ingest run (#554)#561
robotrocketscience merged 1 commit into
mainfrom
test/issue-554-session-id-population-rate

Conversation

@robotrocketscience

@robotrocketscience robotrocketscience commented May 10, 2026

Copy link
Copy Markdown
Owner

Closes #554. Adds a single integration-level test on top of the per-surface unit tests already in tests/test_session_id_propagation.py.

tests/test_session_id_population_rate.py drives 12 ingest calls into one shared MemoryStore:

  • Session A: 4 ingest_turn (2 explicit, 2 env-fallback) + 2 _cmd_lock (1 explicit, 1 env-fallback).
  • Session B: 4 mcp_server.tool_lock (2 explicit, 2 env-fallback).
  • 2 ingest_turn with neither explicit session_id nor $AELF_SESSION_ID (the NULL remainder).

Asserts count(beliefs WHERE session_id IS NOT NULL) / count(beliefs) >= 0.80. The synthetic run yields 10/12 ≈ 83.3%, which is above threshold but with the NULL remainder kept non-zero so the threshold is meaningful.

No production code changes. The integration guard catches regressions where a future surface lands without going through resolve_session_id and silently inflates the NULL rate.

Summary by Sourcery

Tests:

  • Introduce a two-session integration test that exercises ingest_turn, CLI lock, and MCP tool_lock against a shared MemoryStore and asserts a minimum 80% non-NULL session_id population rate.

)

Adds an integration-level assertion that at least 80% of beliefs in a
synthetic two-session run carry a non-NULL session_id.  The synthetic
run drives 12 ingest calls across all three entry points (ingest_turn,
cli._cmd_lock, mcp_server.tool_lock) into a single shared store,
interleaving explicit session_id kwargs and AELF_SESSION_ID env
fallbacks for session-a and session-b, with two NULL-session calls left
as the intentional remainder so the population rate is meaningful rather
than trivially 100%.
@sourcery-ai

sourcery-ai Bot commented May 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds an integration-level test that performs a synthetic two-session ingest run across CLI, ingest_turn, and MCP tool surfaces against a shared MemoryStore, then asserts that at least 80% of resulting beliefs have a non-NULL session_id, providing a regression guard for session_id propagation coverage across entry points.

File-Level Changes

Change Details Files
Introduce an integration test that exercises session_id propagation across ingest_turn, CLI _cmd_lock, and mcp_server.tool_lock into a shared MemoryStore and asserts a minimum 80% non-NULL session_id population rate.
  • Add pytest fixtures to provide a temporary db path and reset session_id-related environment and warning state between tests.
  • Add helpers to construct CLI argparse.Namespace arguments and to read session_id values from the beliefs table in the MemoryStore.
  • Within a single test, perform 12 ingest operations split between two explicit sessions and a null remainder, using both explicit session_id parameters and AELF_SESSION_ID environment fallbacks across the three entry points.
  • Monkeypatch aelfrice.cli._open_store so CLI lock operations write to the same MemoryStore instance used by direct ingest and MCP server calls.
  • Compute the ratio of non-NULL session_id beliefs to total beliefs and assert that it is at least 0.80, failing with a detailed message if the threshold is not met.
tests/test_session_id_population_rate.py

Assessment against linked issues

Issue Objective Addressed Explanation
#554 Add an integration-level test (e.g., tests/test_session_id_population_rate.py) that spins up a fresh MemoryStore, performs a synthetic two-session ingest across ingest_turn, CLI _cmd_lock, and mCP mcp_server.tool_lock using both explicit session_id, AELF_SESSION_ID env fallback, and a small remainder with no session_id, and asserts that count(beliefs WHERE session_id IS NOT NULL) / count(beliefs) ≥ 0.80.
#554 Do not modify any production (non-test) code as part of implementing this guard.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@robotrocketscience has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 30 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 702cd3f0-be7e-4b7b-a6c6-8af9d728ca87

📥 Commits

Reviewing files that changed from the base of the PR and between e45fde3 and 4bb9ffe.

📒 Files selected for processing (1)
  • tests/test_session_id_population_rate.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/issue-554-session-id-population-rate

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 and usage tips.

@robotrocketscience robotrocketscience added author-Planck PR coordination mutex attn:review Needs review (PR open, awaiting reviewer) labels May 10, 2026

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • The test reaches into MemoryStore._conn and assumes a beliefs(session_id) schema; if possible, prefer going through a public API or helper to avoid coupling the integration guard to internal implementation details.
  • The population-rate logic implicitly relies on the current number of ingest calls (10/12); consider computing the expected non-null/total values from the scenario definition and asserting those first so future edits to the scenario don’t accidentally weaken the guard while still clearing the 80% threshold.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The test reaches into `MemoryStore._conn` and assumes a `beliefs(session_id)` schema; if possible, prefer going through a public API or helper to avoid coupling the integration guard to internal implementation details.
- The population-rate logic implicitly relies on the current number of ingest calls (10/12); consider computing the expected non-null/total values from the scenario definition and asserting those first so future edits to the scenario don’t accidentally weaken the guard while still clearing the 80% threshold.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@robotrocketscience

Copy link
Copy Markdown
Owner Author

[claim:review:Maxwell:2026-05-10T05:17:53Z]

@robotrocketscience
robotrocketscience merged commit 4bb9ffe into main May 10, 2026
22 of 29 checks passed
@robotrocketscience
robotrocketscience deleted the test/issue-554-session-id-population-rate branch May 10, 2026 05:18
@robotrocketscience

Copy link
Copy Markdown
Owner Author

[release:review:Maxwell:2026-05-10T05:18:56Z]

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

Labels

attn:review Needs review (PR open, awaiting reviewer) author-Planck PR coordination mutex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2.1] follow-up: integration test for session_id population rate

1 participant