Skip to content

fix: harden reliability audit edge cases#22

Merged
colinvkim merged 8 commits into
mainfrom
fix/reliability-audit-round-two
Jul 12, 2026
Merged

fix: harden reliability audit edge cases#22
colinvkim merged 8 commits into
mainfrom
fix/reliability-audit-round-two

Conversation

@colinvkim

@colinvkim colinvkim commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved file search accuracy by preventing search index reuse across different file trees with the same snapshot identifier.
    • Incremental scans now more conservatively fall back to a full scan when subtree scan history can’t be safely used.
    • Prevented overflow in directory size and descendant file-count calculations across scanning and summary steps.
    • Improved treemap hit testing consistency for fractional chart sizes.
  • Security & Reliability
    • Added explicit, enforced byte-size limits when previewing/importing scan archives, rejecting oversized sections early.
  • Tests
    • Added coverage for clamping behavior, archive oversize rejection, search index caching isolation, incremental rescan edge cases, and hit testing.

Copilot AI review requested due to automatic review settings July 12, 2026 21:46

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f9cd4f6-2857-427d-96f6-b22e9323aa41

📥 Commits

Reviewing files that changed from the base of the PR and between 4679f07 and 13cec69.

📒 Files selected for processing (2)
  • Radix/Services/FileBrowserSearch.swift
  • RadixCoreTests/TreemapGeometryTests.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • RadixCoreTests/TreemapGeometryTests.swift

📝 Walkthrough

Walkthrough

Adds overflow-safe scan aggregation, bounded scan archive reads, tree-aware search index caching, and full-scan fallback for failed incremental scans. It also updates related tests for archive limits, reconciliation, search isolation, treemap hit-testing, and integer clamping.

Changes

Overflow-Safe Integer Accumulation

Layer / File(s) Summary
ScanIntegerMath helper and package wiring
Radix/Services/ScanIntegerMath.swift, Package.swift
Adds generic clamped addition and registers the new source file.
Clamped accumulation in summary accumulators
Radix/Services/AtomicDirectoryParallelSummary.swift, Radix/Services/AtomicDirectorySummaryModels.swift
Uses clamped arithmetic for sizes and descendant counts.
Clamped accumulation in probe, walker, and scan engine
Radix/Services/AtomicDirectorySummaryProbe.swift, Radix/Services/AtomicDirectorySummaryWalker.swift, Radix/Services/ScanEngine.swift
Applies clamped aggregation across probing, walking, and directory assembly.
Overflow clamping test
RadixCoreTests/ScanEngineTests.swift
Verifies maximum values remain clamped during accumulation and merging.

Bounded Archive Section Reading

Layer / File(s) Summary
Bounded archive reader and limits
Radix/Services/ScanArchiveService.swift
Adds section limits, size calculations, and chunked bounded reads.
Bounded read integration
Radix/Services/ScanArchiveService.swift
Applies limits to stats, topology, warnings, and manifest loading.
Oversized section tests
RadixCoreTests/ScanArchiveServiceTests.swift
Verifies oversized archive sections are rejected before decoding.

File Search Index Cache Key Fix

Layer / File(s) Summary
Composite cache key and pruning
Radix/Services/FileBrowserSearch.swift
Keys indexes by snapshot ID and tree content ID and updates pruning.
Tree-specific index test
RadixCoreTests/FileBrowserModelTests.swift
Verifies indexes are not reused across different trees with the same snapshot ID.

Incremental Scan Fallback to Full Scan

Layer / File(s) Summary
Incremental fallback handling
Radix/Services/IncrementalScanService.swift
Forwards a full scan when incremental subtree data is unavailable, fails, or produces no replacement snapshot.
Fallback test and history hook
RadixCoreTests/IncrementalScanServiceTests.swift
Tests subtree disappearance during history planning and the resulting full-scan fallback.

Confirm-Move Trash Batch Test Update

Layer / File(s) Summary
Partial reconciliation assertion
RadixCoreTests/AppModelDependencyTests.swift
Asserts partial reconciliation after a later trash-batch failure.

Treemap Hit-Testing Fractional Size Test

Layer / File(s) Summary
Fractional chart hit-testing
RadixCoreTests/TreemapGeometryTests.swift
Compares hit-test results with rendered rectangles across fractional chart sizes.

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

Possibly related PRs

  • colinvkim/Radix#12: Both modify ScanArchiveService.swift, including archive import behavior and bounded section reads.
  • colinvkim/Radix#19: Adds related treemap geometry and hit-testing coverage.

Suggested labels: enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the PR’s main theme: hardening reliability edge cases across scanning and archive handling.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/reliability-audit-round-two

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
RadixCoreTests/TreemapGeometryTests.swift (1)

186-186: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a failure message with the sampled point for easier debugging.

If a mismatch occurs, the bare XCTAssertEqual won't indicate which point triggered it. Including the point coordinates in the failure message would significantly reduce debugging time.

🔧 Suggested improvement
-                XCTAssertEqual(index.segment(at: point, in: size)?.id, expected?.id)
+                XCTAssertEqual(
+                    index.segment(at: point, in: size)?.id,
+                    expected?.id,
+                    "Hit-test mismatch at point \(point)"
+                )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@RadixCoreTests/TreemapGeometryTests.swift` at line 186, Update the
XCTAssertEqual assertion in the treemap geometry test to include the sampled
point’s coordinates in its failure message, while preserving the existing ID
comparison and expected-value behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Radix/Services/FileBrowserSearch.swift`:
- Line 66: Update the cache-miss assignment in the index lookup flow to mutate
the existing indexes dictionary by key rather than replacing the dictionary.
Make the assignment at the line-66 cache path match the keyed update already
used in the corresponding flow near line 102, preserving previously cached tree
indexes.

---

Nitpick comments:
In `@RadixCoreTests/TreemapGeometryTests.swift`:
- Line 186: Update the XCTAssertEqual assertion in the treemap geometry test to
include the sampled point’s coordinates in its failure message, while preserving
the existing ID comparison and expected-value behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef4546f8-c4c9-4131-b524-d626f3d274fd

📥 Commits

Reviewing files that changed from the base of the PR and between 5764e43 and 4679f07.

📒 Files selected for processing (16)
  • Package.swift
  • Radix/Services/AtomicDirectoryParallelSummary.swift
  • Radix/Services/AtomicDirectorySummaryModels.swift
  • Radix/Services/AtomicDirectorySummaryProbe.swift
  • Radix/Services/AtomicDirectorySummaryWalker.swift
  • Radix/Services/FileBrowserSearch.swift
  • Radix/Services/IncrementalScanService.swift
  • Radix/Services/ScanArchiveService.swift
  • Radix/Services/ScanEngine.swift
  • Radix/Services/ScanIntegerMath.swift
  • RadixCoreTests/AppModelDependencyTests.swift
  • RadixCoreTests/FileBrowserModelTests.swift
  • RadixCoreTests/IncrementalScanServiceTests.swift
  • RadixCoreTests/ScanArchiveServiceTests.swift
  • RadixCoreTests/ScanEngineTests.swift
  • RadixCoreTests/TreemapGeometryTests.swift

Comment thread Radix/Services/FileBrowserSearch.swift Outdated
@colinvkim
colinvkim merged commit 3f8731f into main Jul 12, 2026
1 check passed
@colinvkim
colinvkim deleted the fix/reliability-audit-round-two branch July 12, 2026 22:21
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.

2 participants