Skip to content

FIX: detect rollout activity despite stale Windows timestamps - #87

Merged
merefield merged 4 commits into
merefield:mainfrom
Peace7:codex/windows-rollout-activity
Oct 27, 2026
Merged

merefield merged 4 commits into
merefield:mainfrom
Peace7:codex/windows-rollout-activity

Conversation

@Peace7

@Peace7 Peace7 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Windows may retain an old rollout modification time while Codex keeps its writer handle open. Relying on that timestamp alone can produce a false CHECK SESSION warning during genuine activity, or exclude a live rollout once its apparent age exceeds the active-history horizon. This is separate from the older-turn failure restoration fixed in #90.

Activity detection

  • Combine modification time, observed file-size changes and valid owned event timestamps in the shared reader used by terminal and web Sessions.
  • Restore recent event freshness on startup, including plain JSONL and compressed histories, without treating historical token records as new spending.
  • Preserve real observed growth through compression and same-thread history rebasing. Track decoded JSONL byte size, including an unfinished tail, so restoring identical history does not masquerade as a fresh append.
  • Keep unchanged polls and repeated reads of the same incomplete bytes from refreshing activity. Real inactivity still expires normally. Existing shared-server statuses, blocking input/approval signals, session ownership and linked-agent grouping retain their precedence.
  • Preserve main's current-turn scoping, so late failures from older turns cannot overwrite the current session state.

Bounded work and cancellation

  • Target the final 256 KiB at startup, extending backward by at most 4 MiB to include an overlapping record.
  • Stream the bounded section in chunks rather than allocating an arbitrarily large overlapping record. Use the existing 4 MiB baseline record limit; oversized, incomplete, future-dated and inherited events are conservatively excluded from timestamp-based freshness. Later complete records are still inspected.
  • Propagate cancellation through activity bootstrap and compressed-history restoration verification. Do not commit a partially verified restoration.
  • Update the README with the Windows behaviour and explicit scan limits. No new dependencies, persistent ledger, UI controls, token-accounting rules or version bump relative to main.

Review and integration

Merged current main (v0.24.0), resolving the reader/README conflicts while retaining subsequent compressed-history, error-status and security fixes. Retained the original contributor's implementation and tests, then added coverage for the integration edge cases identified in review.

Validation

  • Full Go core race suite and all-package vet passed.
  • Separate all-17-language screen matrix with race detection passed.
  • Native Windows activity, compression/restoration, session-failure and live-reader regressions passed.
  • All 96 browser tests passed; frontend type/format checks and build passed, with embedded assets unchanged.
  • Go 1.27.3 govulncheck and both runtime-only/all-dependency frontend audits reported no vulnerabilities.
  • New regressions cover compressed startup with stale timestamps, identical restoration, partial-tail size baselines, preserved growth on compression/rebase, ownership/future timestamps, oversized-record bounds and cancellation, alongside the original stale-mtime, unchanged-poll, request-priority and large-record tests.

The optional local-session smoke test remains read-only and requires explicit environment opt-in. No new live Codex turn was started to test this change.

Peace7 and others added 3 commits October 23, 2026 13:28
Use owned event timestamps and observed size changes alongside filesystem
mtime. Bootstrap complete tail records, including oversized records, without
recounting tokens. Preserve definite requests and real inactivity warnings.
@merefield

Copy link
Copy Markdown
Owner

Updated and reviewed against main/v0.24.0. a05592b merges current main without rewriting the contributor commit. 8112a30 fixes the review findings: compressed-history event freshness and growth preservation, logical byte-size tracking including partial tails (so identical restores do not look like new activity), bounded/cancellable activity scans and cancellation during restoration verification. Main’s current-turn failure guards are retained. Added deterministic regressions for these paths and documented the conservative 4 MiB record limit. Validation passed: full Go core race suite, all-package vet, all-17-language screen matrix, all 96 browser tests, frontend checks/build, native Windows activity/history/failure tests, Go vulnerability scan and both frontend dependency audits. Embedded frontend assets remain unchanged. The PR description now reflects the actual delta from current main.

Copilot AI 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.

🟡 Changes recommended

Five unresolved moderate findings affect activity preservation, coverage freshness, bounded scanning, and ownership handling.

1 open issue
What changed in this PR

This pull request improves rollout activity detection when Windows modification times are stale, while preserving token accounting and session behavior across plain and compressed histories.

Changes:

  • Adds bounded, cancellable scanning for file growth and owned event timestamps.
  • Integrates activity tracking with discovery, polling, compression restoration, and same-thread rebasing.
  • Adds regression coverage and README documentation for Windows behavior and scan limits.

Review findings:

  • internal/codex/live_usage.go (moderate, 1 vote): Preserve the newer observed event timestamp during same-thread history rebasing.
  • internal/codex/live_usage.go (moderate, 1 vote): Use activity-based freshness and the reader clock when selecting linked-child coverage candidates.
  • internal/codex/live_usage_compressed.go (moderate, 3 votes): Restrict compressed-history event observation to the documented bounded decoded tail.
  • internal/codex/live_usage_compressed.go (moderate, 1 vote): Defer compressed event ownership checks until session metadata is known.
  • internal/codex/live_usage_compressed.go (moderate, 1 vote): Preserve the newer event timestamp during compressed same-thread rebasing.
File Description
README.md Documents stale Windows timestamps, fallback activity signals, and scan limits.
internal/​codex/​rollout_activity.go Implements bounded plain JSONL activity scanning, ownership filtering, and cancellation.
internal/​codex/​rollout_activity_test.go Tests stale timestamps, growth, partial records, ownership, boundaries, and precedence.
internal/​codex/​rollout_activity_smoke_test.go Adds an explicit opt-in read-only local-session smoke test.
internal/​codex/​rollout_activity_compressed_test.go Tests compressed restoration, rebasing, bounds, ownership, and cancellation.
internal/​codex/​live_usage.go Integrates activity signals into discovery, consumption, session grouping, and cancellation.
internal/​codex/​live_usage_test.go Makes inactivity behavior deterministic under the new activity model.
internal/​codex/​live_usage_exact_test.go Updates exact-usage tests for context-aware file discovery.
internal/​codex/​live_usage_compressed.go Restores compressed histories and tracks decoded size and event freshness.
internal/​codex/​live_usage_compressed_test.go Updates compressed-history integration coverage.

Review effort: Lite

Comment thread internal/codex/live_usage_compressed.go Outdated
@merefield
merefield merged commit 4827300 into merefield:main Oct 27, 2026
6 checks passed
@merefield

merefield commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

thanks @Peace7, this was released as https://github.com/merefield/codexometer/releases/tag/v0.24.1

@Peace7
Peace7 deleted the codex/windows-rollout-activity branch October 28, 2026 09:23
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.

3 participants