server: four identity checks still compare a Number ino, which can collide on Windows (#8750 follow-up)

Open
#9,351 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js

Research direction

Start with the four named sites in claude-tui-session.js, freshness/outbox.js, continuation-metadata-worker.js, and codex-native-resume.js; inspect their stat calls and identity comparisons. Then trace source.identity to confirm whether handlers/conversation-handlers.js needs a change. Add deterministic tests using colliding Number IDs and exact BigInt IDs; done means each affected comparison preserves exact identity and guards zero inodes, with macOS and Linux behavior unchanged.

Written by the indexing model from the issue text.

Description

from-review priority: low server

Context

Follow-up from #8750 (config-dir-migration.js's sameDir), which now stats with { bigint: true }.

On Windows, Node's plain fs.stat returns ino as a JS Number. An NTFS file ID is 64 bits, with a sequence number in the high bits, so the Number loses everything below the top 53 bits. Two different files or directories created close together can then report the same ino. With { bigint: true }, dev and ino are exact BigInts. This repo already uses that form in byok-tool-executor.js, handler-utils.js, jsonl-reader.js and freshness-sources/claude-transcript-adapter.js. The 0n case still needs a guard, because some Windows filesystems report no inode.

Sites that still compare or key on a Number ino (from origin/main d45e17149)

Site Stat What a false-equal ino does on Windows
claude-tui-session.js ~1270/1279 (_sinkBaseIdentity from fstatSync(fd)), compared at ~1403 against lstatSync(base) (~1329) Number The sink-base re-check ("was replaced with a different directory since it was validated") can read a recreated directory as the original. On Windows the uid/mode checks above it do not apply, so this dev/ino compare is the only replacement check there.
freshness/outbox.js ~110/114 and ~126/127 Number The rotation check (seen.ino !== known.ino) can miss a replaced file whose size is not smaller, so the cached tail of the old file is reused for duplicate detection.
continuation-metadata-worker.js ~11/13 Number The dev:ino:size:mtimeMs:ctimeMs key also needs the same size and both timestamps to collide, so the practical impact is negligible. Fix it for consistency.
codex-native-resume.js ~34/36 (directoryBinding digest) Number No impact today: bindNativeOwnership refuses on Windows (process.getuid is undefined there, and nativeMachineId() returns null). Fix it for consistency, so a future Windows path does not inherit the lossy key.

handlers/conversation-handlers.js:368 keys on source.identity. Its provenance looks like the bigint jsonl-reader identity, but that is unconfirmed: confirm it.

Acceptance Criteria

  • Each site above stats with { bigint: true }, guards ino === 0n where it compares identity, and compares or serializes the exact BigInt values. JSON.stringify cannot serialize a BigInt, so stringify it explicitly.
  • Each changed identity compare has a deterministic test that models the lossy Windows stat. The seam's fake stat must return Number(id) without bigint and the exact BigInt with it, using two IDs that collide only as Numbers, e.g. (1n << 60n) + 1n and (1n << 60n) + 2n. The test must go red on the Number compare, as in #8750's config-dir-migration.test.js.
  • No behavior change on macOS or Linux, where the IDs fit in a Number.

Note: claude-tui-session.js and codex-native-resume.js are provider session code, and freshness/ is under its own open work (#9312–#9325). Schedule each part with its area.

Dominant language
JavaScript
Stars
7
Forks
1
Avg merge
2h 3m
Merged PRs (30d)
333

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blamechris/chroxy

All issues in blamechris/chroxy

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.