Skip to content

Stop using a cached projection watermark as a usage cursor - #295

Merged
ccch1mneyyy merged 1 commit into
devfrom
fix/35-usage-cached-cursor
Oct 17, 2026
Merged

ccch1mneyyy merged 1 commit into
devfrom
fix/35-usage-cached-cursor

Conversation

@ccch1mneyyy

Copy link
Copy Markdown
Collaborator

Issue

Refs #35. This fixes a Usage read error reported there. It does not claim to fix the "Bot @" no-response symptom, so the issue stays open.

What changed / 改了什么

Usage scans each Session log up to a cursor taken from the Session-list row. Those projections are hints: only kind: 'sequenced' shares the Session log's sequence space, while kind: 'cached' carries the persisted projection cache's own watermark. The scan used either as throughSeq, so a cached watermark ahead of the log made page() fail with "past cursor" and dropped that whole Session from the totals, and one behind the log left later calls uncounted.

Only a sequenced hint now cuts the page. Every other row (cached, or a hint from an older DSH without kind) reads the Session's exact cursor, as scanSession already does when no hint is usable. The change is one helper plus four regression tests; no API or client change.

Changelog

Usage totals no longer miss calls when a Session list serves a cached projection watermark.

How I checked it / 怎么验证的

  • npm test (in ds-bot/): 652 of 652
  • node scripts/build-client.mjs --check
  • npm run lint: 0 errors, 13 warnings
  • Smoke test: 41 of 41 on DSH Web with the mock model
  • Screenshot attached, for interface changes — not an interface change

Checklist / 检查

  • One issue, one subject. / 只做一件事。
  • No src/client/ change, so client.js is untouched. / 改了 src/client/ 就已重新 build 并提交 client.js。
  • No keys, tokens or personal data. / 没有密钥、token 或个人信息。
  • No AI tool as author or Co-authored-by. / 没有把 AI 工具写成作者或 Co-authored-by。

The diagnosis and an earlier patch came from @EventHorizonXT in #35. This version is rebased on dev (d2f21d2) and keeps the same one-line fix with regression tests.

A Session-list row's projections are hints, not cursors. Only a 'sequenced' block shares the Session log's sequence space; a 'cached' block carries the persisted cache's own watermark. Using that watermark as throughSeq either dropped later calls or failed the whole Session with 'past cursor', so its usage vanished from the totals.

Read the Session's exact cursor unless the hint is sequenced. Tests cover a cached watermark ahead of the log, one behind it, a hint without a sequence space, and the sequenced fast path.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T11:45:10.437495Z 3b0e84a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ccch1mneyyy ccch1mneyyy mentioned this pull request Oct 17, 2026
1 task done
@ccch1mneyyy
ccch1mneyyy merged commit 59ec526 into dev Oct 17, 2026
12 of 14 checks passed
@ccch1mneyyy
ccch1mneyyy deleted the fix/35-usage-cached-cursor branch October 17, 2026 11:56
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