Skip to content

fix(usage): keep usage-ledger file ids exact so Windows NTFS ids stop colliding - #7089

Merged
lidge-jun merged 5 commits into
devfrom
fix/windows-history-stale-ledger
Oct 15, 2026
Merged

lidge-jun merged 5 commits into
devfrom
fix/windows-history-stale-ledger

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

Preserve usage-ledger device and inode identifiers as exact decimal strings captured with bigint fstat. NTFS identifiers can exceed 2^53, where distinct files collide as JavaScript Numbers. History metadata matching, ingest guards, cooperative scans and retention now compare exact identities. Old rounded metadata safely causes one index rebuild; corrected metadata is reused.

Merged current dev (7640a942b, including #7107) without rebasing or force-pushing. #7107 addresses Windows test-process cleanup and does not supersede this precision fix. Added deterministic SQLite tests for the colliding IDs 9007199254740992 and 9007199254740993 in both device and inode fields, plus a live-index regression for rebuild-once and subsequent reuse. The existing identity matcher is exported for direct regression coverage. Updated the owning structure document without increasing its line count.

Verification

  • bun install: pass.
  • OCX_TEST_NO_QUEUE=1 bun scripts/test.ts --parallel=2 tests/usage/request-history-rebuild-worker.test.ts tests/usage/request-history-index.test.ts tests/usage/usage-ledger-retention.test.ts tests/usage/usage-ledger-scanner.test.ts: 62 pass, 0 fail.
  • Red/green proof: temporarily restoring lossy Number comparisons makes the new deterministic precision test fail (0 pass / 1 fail); restoring exact comparisons passes (24 pass / 0 fail for the index file). No test stubs or skipped coverage added.
  • bun run typecheck, bun run structure:check, bun run privacy:scan, git diff --check: pass.
  • OCX_TEST_NO_QUEUE=1 bun run test:changed --parallel=2: interrupted under the resource exception after about eight minutes (exit 130; 25,628 passing records, incomplete run). Captured failures included audio readiness timeouts, sibling-home sync, and provider-header CLI handling. This broad import-connected selection approaches the full suite and many other worktrees were running on the host. Full local suite is deferred; broader coverage remains with hosted CI.
  • Baseline comparison on this head and clean dev 7640a942b: OCX_TEST_NO_QUEUE=1 bun scripts/test.ts --parallel=2 tests/cli/cli-access-audio-live.test.ts tests/cli/cli-headless-parity.test.ts tests/cli/sibling-home-client-sync.test.ts --test-name-pattern 'native open and non-readiness|provider edit --headers|a secondary ensure parent' gives the identical 1 pass / 4 fail / 4 errors (exit 1) on both. Audio has three timeout cases; sibling-home times out at 30 s. The provider-header case passes in isolation on both, so the broad-run failure was not reproduced. No unrelated product/test behavior was changed to hide these failures.
  • Independent code review: PASS on both fixes, with the deterministic precision-coverage objection resolved.
  • Exact-head cross-platform CI (lane=all, 9fd3031d5): https://github.com/lidge-jun/opencodex/actions/runs/38698612476 — queued, including Windows; pending is not passing evidence.
  • Gate diagnosis: both prior enforce-target attempts (38506374347, 38506509545) were cancelled before the gate ran. The original body passes assessPrDescription (ok: true); the author has admin permission, and the old branch was five dev commits behind. No description or ancestry rejection was present. The dev merge and this description refresh trigger a fresh exact-head gate; its completed verdict is still required.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (structure/dashboard-and-usage.md).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (no authentication or credential changes).

Refs #7070, #3842, #7087

… colliding

UsageLogRevision carried dev and ino as JS Numbers. NTFS file ids put a
sequence number in their high bits and routinely exceed 2^53, so two
different ledger files could round to the same Number and pass every
identity check: the history indexer, the ingest tail guard, the cooperative
ledger scanner and ledger retention would all treat a replaced ledger as the
recorded one. This is what made the stale-ledger build case fail on Windows
CI (#7070).

Read dev/ino through bigint fstat (exactFileIdentity) and carry them as
exact decimal strings end to end, including the schema_meta source identity,
following the Aside profile precedent in #3842. Indexes written by an older
build stored rounded values and rebuild once on mismatch.

The stale-ledger test goes back to perturbing ino, now exactly, and asserts
the revision matches bigint stats.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 14, 2026 03:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-14T03:31:17.711739Z ab9b3b1 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.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 5dff8457-51be-4756-b315-32a2c83998e2
📥 Commits

Reviewing files that changed from the base of the PR and between 9fd3031 and 0016d64.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7a15acfb-fc1d-488f-8d51-075923167377
📥 Commits

Reviewing files that changed from the base of the PR and between ab9b3b1 and 9fd3031.

📒 Files selected for processing: 3
  • src/routing/history/indexer.ts
  • structure/dashboard-and-usage.md
  • tests/usage/request-history-index.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Ledger device and inode identifiers are now captured and compared as exact decimal strings. Revision construction, history indexing and ingestion, ledger scanning, retention checks, and rebuild tests use exact identity values.

Changes: Ledger identity handling

Layer / File(s) Summary
Capture exact ledger identities
src/usage/log.ts, src/usage/ledger-scanner.ts
UsageLogRevision.dev and ino are strings. exactFileIdentity(fd) reads device and inode values through bigint fstat. Revision construction and scanner snapshots use the open file descriptor.
Compare exact ledger identities
src/routing/history/indexer.ts, src/routing/history/ingest.ts, src/usage/ledger-retention.ts, tests/usage/request-history-rebuild-worker.test.ts, tests/usage/request-history-index.test.ts, structure/dashboard-and-usage.md
History identity matching compares exact strings. Ingestion and retention check the opened ledger identity before proceeding. Tests cover large identifiers, rounded legacy metadata, and stale-revision rejection. The documentation describes exact identity handling and index rebuilding.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9fd30

No actionable issue is established in the supplied review. Merge readiness remains subject to the pending exact-head CI result.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 7 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving usage-ledger file identifiers exactly to prevent Windows NTFS identifier collisions. It matches the changes in src/usage/log.ts …
Full details: Docstring Coverage

Explanation

Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 7 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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: ab9b3b180b

ℹ️ 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".

Comment thread src/usage/log.ts
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 14, 2026
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration into dev (MAINTAINERS.md dev maintainer-integration policy; batch integration authorized by @lidge-jun on 2026-10-15).

  • Head: 0016d6429ea89562a1510082393c46d280c3bc43 (tree a66c7e2b6bdfc89c8af112d07f73bdde679609e1) = this branch merged with origin/dev 60bf4c7e0c.
  • Exact-head evidence: GitHub-hosted Actions for this account have not been assigning runners since 2026-10-15 13:30 UTC, so by owner decision the evidence is a full bun run test (Bun 1.4.3 test runner, root and GUI dependencies installed, GUI built) of this exact tree on a maintainer host (Linux x86_64): exit 1, 7 min, 31 failing test(s), each also failing in the same host's baseline run of dev 60bf4c7 (environment-only): Codex shim install readiness > a refused install exits unsuccessfully and preserves its re, Codex shim install readiness > keeps install advisory when the Codex config cannot be read, Codex shim install readiness > the install command surfaces readiness warnings without lea, GUI pairing client > sends one bodyless origin-bound capability and redacts rejected bodie, Node launcher PATH fallback activation > broken bundle reaches validated PATH Bun, Node launcher PATH fallback activation > inspection bundle reaches validated PATH Bun, Node launcher PATH fallback activation > missing bundle reaches validated PATH Bun, a secondary ensure parent preserves shared Grok, Codex and Claude agent bytes, ….
  • Local gates on the same tree: bun run typecheck, file-size ratchet, test-layout and structure:check.
  • Hosted CI checks for this head may still be queued; they are not claimed as evidence.

@lidge-jun
lidge-jun merged commit ade27f4 into dev Oct 15, 2026
54 of 57 checks passed
@lidge-jun
lidge-jun deleted the fix/windows-history-stale-ledger branch October 15, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant