Repository navigation
SWF(bug): keep in-window sessions whose transcript has an old mtime in stats - #46
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7f9f7d9c0
ℹ️ 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".
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".
| if codex and (kind != "session_meta" or not isinstance(record.get("payload"), dict)): | ||
| return None | ||
| stamp = record.get("timestamp") | ||
| return _local(_ts(stamp)) if isinstance(stamp, str) else None |
There was a problem hiding this comment.
Handle timestamp overflow in the old-file probe
When an old-mtime JSONL starts with a boundary timestamp such as 0001-01-01T00:00:00+01:00, _ts can raise OverflowError while converting it to UTC. This probe runs before collect()'s summarize() exception handler, so one such transcript aborts the entire stats command; handle the overflow at the parsing or collection boundary so it cannot escape.
Useful? React with 👍 / 👎.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
6c7fbdc to
e2ccd95
Compare
|
Capy couldn't review this pull request because Cojo's workspace is out of credits, add credits or enable auto-reload to resume automatic reviews. The code reviews included with your plan this billing period are used up, so reviews are paid from your credits until the plan resets. A Low or Medium effort review counts as 1 included review, and a High effort review counts as 2. |
…s-old-mtime Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…s-old-mtime Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> # Conflicts: # CHANGELOG.md
runledger statsno longer drops a session that started inside the window just because its transcript file has an older mtime (copied, restored or synced with a preserved/wrong mtime).Root cause
collect()inrunledger/stats.pyskipped every file withst_mtime < sincebefore it looked at the cache or the transcript, on the assumption that an old file can't hold a newer session. That assumption breaks whenever the mtime isn't the real last write, so the session vanished from the report (No sessions found ..., exit 1).Fix
The mtime check is now only a hint for which files to check cheaply, not a reason to drop them:
_session_startaccepts only standard Claude, Codex (session_metaand legacy untyped) and Droid headers; anything uncertain (unknown layout, unparsable or out-of-range timestamp) returnsNoneand falls back to the full parser, so it can never hide a session."kind": "start", store a UTC instant (so a time-zone change can't misplace them), are validated by the transcript'smtime_ns+ size, can't be returned as summaries, and share the normal_trim/MAX_CACHE_ENTRIESpath. Existing caches load unchanged (no version bump).Evidence
Real CLI, isolated home, one Claude transcript stamped
2026-05-10T12:00:00Zwith mtime set to 2020-01-01 viaos.utime:runledger stats --all --since 2026-05-01 --until 2026-05-31exit: 1No sessions found between 2026-05-01 and 2026-05-31.exit: 0RunLedger stats - any project (since 2026-05-01 until 2026-05-31, 1 session, 1 agent)claude-code 1 ...New regression test, run against
main'scollect()first:With the fix:
Tests also assert the probed start equals
summarize(path).startedfor Claude, Codex (modern and legacy) and Droid, that time-zone changes and year-1 / overflowing timestamps never misplace a session or abort the run, that genuinely old sessions are skipped withoutsummarize, that start records are invalidated by mtime or size changes, promoted to full summaries when the window widens, and trimmed with the rest.Full suite on the branch merged with current main:
4330 passed, 42 skipped.Benchmark (cold cache preserved)
3,000 transcripts of ~1 MB, 80% old start + old mtime, 20% in window. Real
runledger statssubprocesses (startup + discovery included), 15 repeats per side, alternating main/PR order, idle machine. Cold =.runledger/cachedeleted before the run (OS page cache not flushed); warm = immediately after cold. Main loaded from an unchanged worktree viaPYTHONPATH.Old out-of-window sessions are still never fully parsed (
summarize()runs 600 times per cold run on both sides). cProfile puts the added cold cost in 2,400 one-line header probes (~107 ms instrumented: mostlyopen/readline/json.loads). That is the price of not trusting mtimes; warm runs reuse the cached start and don't reopen those files.Try it
pip install -e . && runledger stats --all --since 7dwith a transcript whose mtime you backdate:python -c "import os;os.utime('<transcript.jsonl>',(1577880000,1577880000))"Not tested
Old-mtime non-JSONL transcripts (Aider history) have no cheap header, so a cold run now parses them once and caches the summary; not benchmarked separately. OS page cache was not flushed for "cold" runs.
CI stabilization
The approval test fixture now reads the POST body before sending a 401 response. On Windows, unread request input can reset the TCP connection before the client reads that response, which made
test_http_approver_wrong_key_falls_back_to_a_local_askintermittently lose the status code. This is a test-fixture-only change.Link to Devin session: https://app.devin.ai/sessions/985aa7d6d922481dad503dcb404e15d3
Open in Devin Desktop: https://app.devin.ai/desktop/session/985aa7d6d922481dad503dcb404e15d3?variant=devin
Requested by: @kodji7202-code
Implemented in session Keep in-window transcripts with old file mtimes
Review with Devin · Open in Devin Desktop