fix: coalesce cost polling without changing tracker API - #198
fix: coalesce cost polling without changing tracker API#198mldangelo-oai wants to merge 3 commits into
Conversation
|
@codex review Please review the exact current head |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
Fixes #31. Builds directly on #177 and preserves @SiavashShams's original contributor-authored commit.
ScanCostTracker.start()instead of replacing the existing refresh serializer.stop()authoritative: stopping clears the timer, suppresses any stale follow-up, and serializes exactly one final session refresh behind the in-flight poll.onErrorexactly once and allow the coalesced follow-up to recover normally.Why
Each budgeted scan polls the Codex session tree every 100 ms. On
main, every tick appends another full traversal to the refresh promise chain when filesystem work takes longer than the interval. The result is an unbounded backlog and unnecessarily long scan shutdown.The existing refresh serializer already provides the ordering required by explicit refreshes and
stop(). Coalescing only the interval producer fixes the actual source of the backlog while retaining those established semantics and avoiding a second scheduler.With 3,000 real session files and no injected filesystem latency, a representative local run produced:
mainThe new polling regression fails against unmodified
main: four overlapping polling requests are observed where the fixed implementation permits one.Validation
pnpm run types.pnpm run format.pnpm run build.pnpm packand complete package-contract validation: 179 verified entries.git diff --check.This change addresses refresh backlog and shutdown latency. It does not claim to eliminate the separate cost of recursively discovering historical session files.