Repository navigation
fix(core): normalise session list limits at the store boundary - #1013
Conversation
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. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Normalize list limits and verify query behavior packages/core/src/session/store.ts, packages/core/test/session-store.test.ts |
SessionStore.list normalizes supplied limits before querying. Tests cover omitted and non-finite limits, fractional limits, zero, and negative values. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
developing-today/opencode#992— This change applies a local page-limit policy at theSessionStore.listboundary, which matches the issue’s described normalization objective.developing-today/opencode#993— This change truncates limits, clamps them to at least one, and does not add a ceiling, matching the described page-limit policy.
Possibly related PRs
- developing-today/opencode#983 — It normalizes limits for
SessionStore.messages; this PR applies normalization toSessionStore.listin the same store and test file.
Suggested labels: needs:issue
Suggested reviewers: kitlangton
Merge Risk: 
Minimal · previous review 4cdcf
-
Standard invalid limits are normalized. An existing failure for exceptionally large finite limits remains.
Pre-merge checks: 
5
-
Full details: Description check
-
Explanation
The description explains the issue, implementation, intended behavior, scope, and verification steps. It omits the explicit Type of change and Checklist sections, but the core required information is present. The Screenshots section is not needed because this is not a UI change.
Full details: Linked Issues check
-
Explanation
Issue
#1010is the only directly linked issue. Its coding requirements are met at the reviewed head.- Store-boundary normalisation [
#1010]:listLimitin packages/core/src/session/store.ts returnsundefinedfor a non-finite limit. For a finite limit it returnsMath.max(Math.trunc(limit), 1).SessionStore.listuses this value before calling drizzle.limit(...). A present limit no longer reaches drizzle raw. - Truncation and floor [
#1010]: 2.9 yields 2, 1.5 yields 1, 0.5 yields 1, 0 yields 1, -1 and -5 yield 1. The regression test asserts each of these row counts. - Non-finite policy [
#1010]: NaN, +Infinity and -Infinity are treated as absent (unbounded). The code comment and the test comment document this. The issue allows this option. - Absent limit [
#1010]:input.limit === undefinedstill takes the unboundedquery.all()path. The test asserts 3 rows for an omitted limit. - No ceiling [
#1010]:listLimithas no upper bound. The test with a limit of 2 returns 2 rows, and no maximum is applied. - Regression tests [
#1010]: the newit.effectcase in packages/core/test/session-store.test.ts callsstore.listdirectly. It covers -5, -1, 0, 0.5, 1.5, 2.9, NaN, +Infinity and -Infinity. Existing tests are unchanged in the diff. - Plugin and HTTP unchanged [
#1010]: the diff touches only store.ts and the session-store test.sessionListLimitand the HTTP handler are not modified.
Session.listinherits the fix by forwarding tostore.list. This forwarding is stated in the issue and the PR description. I did not re-read the forwarding line in packages/core/src/session.ts, because the read was truncated. The PR diff does not change session.ts.Residual uncertainty: the issue does not require very large finite limits. The change does not test them. A value such as 1e300 is finite and has no ceiling. Its behaviour under SQLite LIMIT binding was not verified. This does not affect the listed requirements.
- Store-boundary normalisation [
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff against the merge base changes two files. Both serve
#1010.- packages/core/src/session/store.ts: adds
listLimitand routesSessionStore.listthrough it. This is the requirement itself. - packages/core/test/session-store.test.ts: adds one regression test for
SessionStore.listlimit normalisation. This is supporting test coverage for the same requirement.
No change touches the plugin
sessionListLimit, the HTTP handler,messagesLimit,Session.listsource, or any protocol schema. The change does not add a ceiling, does not alter the messages path, and does not alter omitted-limit behaviour. No unrelated change was found in the diff. - packages/core/src/session/store.ts: adds
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Fixes #1010
SessionStore.listpassed a present limit to drizzle untouched — the one paging method inpackages/core/src/session/store.tsthe #981/#983 store-boundary normalisation did not cover. A negative limit silently widened to every session (SQLite treats a negative LIMIT as unlimited) and a fractional/non-finite limit defected the read.listLimitat the store boundary: a finite present limit is truncated and floored to 1, with no ceiling (the HTTP surface applies none).Session.listinherits the fix by forwarding to the store. PluginsessionListLimitand the HTTP handler are unchanged.packages/core/test/session-store.test.tscalllistdirectly with limit in {-5, -1, 0, 0.5, 1.5, 2.9, NaN, ±Infinity} and pin the normalised behaviour.Tests (laptop):
bun test test/session-store.test.ts(in packages/core) — 4 pass, including the new list-limit case and the existing messages-limit casebun run typecheck— passNeed help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit