Skip to content

refactor(core): centralize full-prefix KV scans - #45583

Closed
kitlangton wants to merge 1 commit into
v2from
kv-scan-all
Closed

kitlangton wants to merge 1 commit into
v2from
kv-scan-all

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

Background-job recovery currently has to manage KV pagination itself, mixing storage cursor handling with recovery-record decoding. It also uses the default 100-entry page size even though it needs every matching record.

What Changes

Add KV.scanAll(prefix) to collect matching entries in key order using the existing paginated scan with 1,000-entry pages. Job.pendingBackground uses it and keeps the same recovery-record decoding and invalid-record filtering.

Case Result
No matching keys An empty array
1,001 matching keys All entries in key order across two pages
Evaluate the same scan effect after deleting a key A fresh result without the deleted entry or accumulated duplicates

The existing scan limits and cursor contract remain unchanged. Focused assertions cover literal special-character prefixes, ordering, pagination, and repeated evaluation.

Verification

# Repository root
bun install --frozen-lockfile
bunx prettier --check packages/core/src/kv.ts packages/core/src/job.ts packages/core/test/kv.test.ts
git diff --check
git diff --cached --check
git push -u origin kv-scan-all

# packages/core
bun typecheck
bun run test test/kv.test.ts test/job.test.ts
bun run test test/session-execution.test.ts test/tool-shell.test.ts
  • Dependency installation, formatting, whitespace checks, and core typechecking passed.
  • Focused KV/job tests: 15 passed, 0 failed, 147 assertions.
  • Recovery and shell tests: 98 passed, 19 skipped, 0 failed, 552 assertions. The skipped tests require PowerShell, which is unavailable locally.
  • The normal push hook ran the repository typecheck: 33 successful tasks, including 27 cache hits. Hooks were not bypassed.
  • The full core test suite and live application workflows were not run.

@kitlangton
kitlangton enabled auto-merge (squash) August 27, 2026 15:50
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@github-actions github-actions Bot closed this Sep 27, 2026
auto-merge was automatically disabled September 27, 2026 22:17

Pull request was closed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant