Skip to content

fix(server): detect replaced transcripts with large file identities - #21464

Merged
juliusmarminge merged 7 commits into
mainfrom
terminal-preview-12/windows-inode-scanner
Oct 20, 2026
Merged

juliusmarminge merged 7 commits into
mainfrom
terminal-preview-12/windows-inode-scanner

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Windows file IDs can exceed JavaScript’s safe-integer range. The scanner converted Effect’s exact bigint inode to Number, so adjacent IDs could collide and a same-path, same-size, same-timestamp replacement was incorrectly treated as already imported. Preserve the ID as a decimal string and normalize legacy numeric IDs only for comparison. Existing handle-bound reads and the completed-history shortcut remain in use.

Top layer of the maintainer takeover of #20346 by @Zacharon; contract compatibility is in #21463. Removed the original native fallback and its ABA workaround: current Effect already supplies exact bigint stat/fstat and reads from the same opened handle. No new filesystem service or diagnostic suppression remains.

Validation at bd90edff1c:

  • 84 → 84 passing tests across the existing scanner and importer suites (83 + 1). Replaced the original 250-line combined regression with one focused replacement/backfill flow and reused the numeric/provider shortcut test; no new test files. The takeover first split three cases, then removed two that covered existing handle behavior.
  • The fixture uses real files, renames and reads, with adjacent bigint IDs injected through Effect stat and opened-file stat. Reverting String to Number fails: expected Importable/replaced-session, received AlreadyImported/original-session with a rounded ID. Restoring the fix passes. Unsafe numeric and null records backfill once; safe numeric records remain compatible, and unchanged exact records avoid open/read.
  • Scoped server/contracts typechecks, changed-file lint/format and diff checks pass.
  • Round 1 found the unnecessary native adapter and a fixture that missed the actual normal-path bug. Both are corrected; Round 2 found unsafe numeric legacy IDs could still collide with an exact replacement ID; the existing flow failed before the safe-integer guard and passes afterward. Round 3 returned no code findings from both independent reviewers. CI also caught missing consumer type compatibility in the bottom layer; that type-only adjustment now belongs to the bottom and both layers pass independently. The layer-order correction preserved the complete tree; the subsequent legacy precision guard changes only the top layer.
  • The repository’s focused Windows scanner/importer test lane passed on this head. This verifies the suites on Windows; real production NTFS replacement acceptance remains unverified.
  • Macroscope’s current-head correctness check passed, but its approvability check requires human review because identity comparisons decide whether transcript processing is skipped.
  • Nonvisual server behavior: no screenshots apply. The regression fixtures use simulated NTFS IDs on real files; real Windows/NTFS replacement acceptance, macOS and packaged Electron are not verified. Existing clients and connection modes share this server path; native iOS/Android execution was not performed.
  • Downgrading to an older server after string IDs are persisted loses the completed-history shortcut for those records and rereads transcripts; it does not create duplicate threads.

Model and harness: GPT-6.1-Sol via Codex in T3 Code; tests GPT-6-Astra; independent reviews Claude Opus 5.5 and GPT-6-Sol.

Fixes #14838

@juliusmarminge
juliusmarminge added this pull request to stack #21465 October 19, 2026 03:25
@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 19, 2026
@juliusmarminge
juliusmarminge marked this pull request as draft October 19, 2026 03:26
@juliusmarminge juliusmarminge changed the title terminal preview 12/windows inode scanner fix(server): detect replaced transcripts with large file identities Oct 19, 2026
@github-actions github-actions Bot added the size:L 100-499 changed lines (additions + deletions). label Oct 19, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 19, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The PR is a focused fix for preserving large filesystem identities and includes targeted regression coverage. Human review is warranted because the identity comparison controls whether transcript processing is skipped or performed.

No code changes detected at 18bb059. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: a64e045 · PR result: 18bb059 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Oct 19, 2026
@juliusmarminge
juliusmarminge force-pushed the terminal-preview-12/windows-inode-scanner branch from c336490 to aa53fbb Compare October 19, 2026 03:37
@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). size:S 10-29 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). size:XS 0-9 changed lines (additions + deletions). labels Oct 19, 2026
@juliusmarminge
juliusmarminge marked this pull request as ready for review October 19, 2026 03:52
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 7f01dc92-967b-4a60-999e-13b63da81cb7
📥 Commits

Reviewing files that changed from the base of the PR and between bd90edf and 18bb059.

📒 Files selected for processing: 2
  • apps/server/src/project/AgentSessionScanner.test.ts
  • apps/server/src/project/AgentSessionScanner.ts

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

The scanner now stores transcript inode identities as strings and compares normalized string values. Tests cover large inode values, replacement transcripts, provider mismatches, legacy identifiers, and one-time backfilling.

Changes: Transcript Identity Matching

Layer / File(s) Summary
String-based inode comparison
apps/server/src/project/AgentSessionScanner.ts
Transcript identity creation stringifies inode values. Identity comparison rejects unsafe numeric inode values and compares normalized inode strings.
Identity matching and legacy backfill tests
apps/server/src/project/AgentSessionScanner.test.ts
Tests cover matching legacy numeric inodes, provider mismatches, replacements with unchanged size and modification time, large inode values, and one-time backfilling of null or rounded legacy identifiers.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 18bb0

The reviewed change has no identified merge-blocking issue. Real Windows replacement behavior has not been verified end to end.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise, conventional, and clearly identifies the main fix: detecting replaced transcripts with large file identities.
Description check Passed The description clearly explains the problem, the implementation, scope, compatibility considerations, and detailed verification results. It does not use the template headings and does not include an …
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.
Full details: Description check

Explanation

The description clearly explains the problem, the implementation, scope, compatibility considerations, and detailed verification results. It does not use the template headings and does not include an explicit maintainer approval comment, but it provides sufficient information for this focused bug fix.

✨ Finishing Touches
📝 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

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

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

Base automatically changed from terminal-preview-12/windows-inode-contract to main October 19, 2026 23:26
@juliusmarminge
juliusmarminge force-pushed the terminal-preview-12/windows-inode-scanner branch from bd90edf to 18bb059 Compare October 19, 2026 23:26
@juliusmarminge
juliusmarminge merged commit 16e442b into main Oct 20, 2026
31 checks passed
@juliusmarminge
juliusmarminge deleted the terminal-preview-12/windows-inode-scanner branch October 20, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:S 10-29 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Session scanner marks a replaced transcript as already imported on Windows

1 participant