Skip to content

Drain processed zero-row files from Codex cost catch-up - #3075

Merged
steipete merged 2 commits into
mainfrom
codex-3071
Aug 19, 2026
Merged

Drain processed zero-row files from Codex cost catch-up#3075
steipete merged 2 commits into
mainfrom
codex-3071

Conversation

@steipete

Copy link
Copy Markdown
Owner

Summary

Fixes #3071. When an old Codex session file (content days entirely outside the scan window) gained a recent mtime — rsync, backup restore, touch — the active lookback queued it into pendingFilePaths permanently: queue completion required a cache entry, but zero-in-window-row files intentionally never get one. catchUpPending stayed true forever, the exact-inventory proof pass never ran, and the UI showed a perpetual "catching up".

The scanner now tracks processed-vs-deferred separately: a file that was fully processed drains from the queue even when it contributes zero in-window rows, and cache-less processed paths are excluded from the exact inventory. Deferred (genuinely unprocessed) files stay queued. Existing stuck queues self-heal on the next scan pass — no state reset needed.

Test plan

  • 7 focused tests: the issue's touched-old-file repro (drains, catchUpPending clears, proof pass runs), unprocessed files stay queued, self-heal of pre-existing stuck state
  • make check clean

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Drain processed zero-row files from Codex cost catch-up This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0690f76c8c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

state: &state,
maxBytesToRead: fullRescanAllowedBytes)
context.scanBudget?.consume(workBytes: fullRescanAllowedBytes)
return .processed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep partially scanned cacheless files queued

When a time- or byte-bounded rescan reads only a prefix of a file whose session already contributed through another rollout, rescanCodexFile can remove the cache entry because the prefix contains no unique rows, even though parsedBytes has not reached the file size. Returning .processed unconditionally here makes the new cacheless-path logic drain that file and exclude it from the exact inventory, so an old touched/resumed session can permanently lose valid in-window usage in its unread suffix. The outcome must remain deferred unless the rescan actually reached EOF or otherwise proved completion.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 114a6a0 into main Aug 19, 2026
14 of 17 checks passed
steipete added a commit that referenced this pull request Aug 19, 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.

Codex cost catch-up never completes when old session files are touched into the active lookback window

1 participant