Skip to content

perf(api): count consolidation summaries without loading records - #1772

Closed
zack-dev-cm wants to merge 1 commit into
rohitg00:mainfrom
zack-dev-cm:fix/1735-consolidation-summary-count
Closed

zack-dev-cm wants to merge 1 commit into
rohitg00:mainfrom
zack-dev-cm:fix/1735-consolidation-summary-count

Conversation

@zack-dev-cm

@zack-dev-cm zack-dev-cm commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

The consolidation-status reader loads every stored summary just to count it. Use the existing key-list API for that count, keeping the value-list fallback for adapters or backends without key listing.

The existing recurring-pattern filtering, other collections' null handling, response shape and 30-second count cache are preserved. This addresses the summary-count path in #1735; the other count paths and list pagination remain separate.

Validation:

  • Eight unit tests: 6 passed and 2 failed before the change; all 8 pass after it. Covers file/Redis response formats, null rows, cache reuse, legacy fallback and read failures.
  • Build, skills generation/check, docs sync/check and CI eval typecheck passed; broad source typechecking retains the same 28 baseline errors.
  • Full suite with project-pinned npm 11.17.0: 4,926 passed, 7 skipped, and the same 13 mesh failures reproduced on unchanged source.
  • Freshly extracted npm archives with cached dependencies and native iii 0.25.1 on Linux/Node 22 passed both original and corrected two-case fixtures with identical status JSON. One 21-summary/20 MiB observation took 1,001 ms before and 11 ms after; this is a fixture timing, not a general benchmark.

Refs #1735

Summary by CodeRabbit

  • Bug Fixes
    • Consolidation status counts now use key listing when available, with a fallback to value listing if key listing is unavailable or fails. If both methods fail, the count remains zero.
    • Counts are reused on subsequent reads, and nullable rows and memory patterns are handled correctly.

Signed-off-by: zack-dev-cm <112114097+zack-dev-cm@users.noreply.github.com>
@vercel

vercel Bot commented Nov 13, 2026

Copy link
Copy Markdown

@zack-dev-cm is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The consolidation status reader now counts summary records through key listing when available. It falls back to value listing when key listing is unavailable or fails. Tests cover file and Redis backends, filtering, cached counts, and read failures.

Changes: Consolidation summary counts

Layer / File(s) Summary
Summary count path
src/triggers/api.ts, test/consolidation-summary-counts.test.ts
The reader uses kv.listKeys to count summaries when available. If key listing is unavailable or throws, it uses kv.list; a failed fallback returns zero. Tests cover both backends, null rows, pattern filtering, cached count reuse, and read failures.

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

Change: Refactor

Possibly related issues

  • rohitg00/agentmemory#1735 — This change addresses the summary-count path in createConsolidationStatusReader; other count paths and list pagination described by the issue are outside this change.

Suggested reviewers: rohitg00

Merge Risk: Minimal · up to 0ee14

The change speeds up consolidation status by counting summaries without loading their records. It keeps the existing fallback for adapters without key listing. No actionable merge risk remains from the supplied evidence.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "perf(api): count consolidation summaries without loading records" matches the main change. The PR changes the consolidation-status reader in src/triggers/api.ts to count summaries with kv.l…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "perf(api): count consolidation summaries without loading records" matches the main change. The PR changes the consolidation-status reader in src/triggers/api.ts to count summaries with kv.listKeys, falling back to kv.list when key listing is absent or throws. The added tests check that counts come from key listing without fetching summary values. The title names the performance aim and the affected area, and it is concise and specific.

Finishing Touches

Generate unit tests (beta)

  • 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4e8eb16f-9c72-4204-b31b-3e1c5816f6d2
Commits

Reviewing files that changed from the base of the PR and between cf9a738 and 0ee14fa.

Files selected for processing: 2

  • src/triggers/api.ts
  • test/consolidation-summary-counts.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@rohitg00

Copy link
Copy Markdown
Owner

Merged as part of #1811, which kept your commits and added review fixes on top (details in its description). Thanks for the contribution.

@rohitg00 rohitg00 closed this Nov 18, 2026
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.

2 participants