Skip to content

fix: pharn status reports unreadable paths instead of crashing or misclassifying them - #82

Merged
PrzemekGalarowicz merged 2 commits into
mainfrom
fix/diff-unreadable-partition
Aug 11, 2026
Merged

fix: pharn status reports unreadable paths instead of crashing or misclassifying them#82
PrzemekGalarowicz merged 2 commits into
mainfrom
fix/diff-unreadable-partition

Conversation

@PrzemekGalarowicz

@PrzemekGalarowiczPrzemekGalarowicz commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • pharn status no longer crashes or misreports unreadable expected paths.lib/diff.ts now classifies paths through the same readDiskState helper pharn update uses, adding a fourth Unreadable drift partition for directories, symlinks (live or dangling), ENOTDIR parents, and unreadable files — instead of throwing EISDIR, folding symlinks into modified/ok, or reporting dangling links as missing.
  • pharn status --strict treats unreadable paths as drift. The DRIFT note renders a third subsection (after DIFFERS and MISSING, matching update's SKIP_ORDER) listing each path with its reason; plain status still exits 0.
  • One canonical sha256. The drift check drops its private hash() fork and uses shared sha256File; a test source-scan holds the claim.

Test plan

  • npm run check passes (636 tests)
  • New diff.test.ts cases cover directory, symlink (different/identical/dangling), ENOTDIR, sort determinism, and no node:fs/node:crypto in diff.ts
  • New status.test.ts cases cover --strict on unreadable-only drift, plain-run rendering, subsection ordering, and omission when empty
  • Fixed pre-existing vacuous "missing file" test so the missing arm is actually exercised
  • docs/commands/status.md and CHANGELOG.md updated

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes

    • pharn status now identifies unreadable paths—including directories, symlinks, dangling links, and invalid paths—without stopping comparisons for other files.
    • Unreadable paths display clear reasons and are skipped by pharn update.
    • Strict mode now fails consistently when unreadable paths are detected.
    • Drift hashing now uses consistent SHA-256 behavior.
  • Documentation

    • Updated status command documentation and the Unreleased changelog with the new unreadable-path behavior.
  • Tests

    • Added coverage for unreadable paths, ordering, continued comparisons, and strict-mode reporting.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

DiffPackageSupply Chain
Security
VulnerabilityQualityMaintenanceLicense
Addedglobals@​17.9.01001008696100

View full report

@coderabbitai

coderabbitaiBot commented Aug 11, 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 Plus

Run ID: 7f9587fa-d53c-435e-91ed-ada56a3b8673

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff7240 and 02492ca.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • .dev/features/diff-unreadable-partition/GRILL.md
  • .dev/features/diff-unreadable-partition/PLAN.md
  • .dev/features/diff-unreadable-partition/REGRESSION.md
  • .dev/features/diff-unreadable-partition/REVIEW.md
  • .dev/features/diff-unreadable-partition/SHIP.md
  • .dev/features/diff-unreadable-partition/VERIFY.md
  • .dev/features/diff-unreadable-partition/regression-report.json
  • .dev/features/diff-unreadable-partition/verify-report.json
  • .pharn/pharn-dev-verify/results.json
  • .pharn/writes-scope.json
  • CHANGELOG.md
  • docs/commands/status.md
  • package.json
  • src/commands/status.ts
  • src/lib/diff.ts
  • tests/diff.test.ts
  • tests/status.test.ts

📝 Walkthrough

Walkthrough

The change adds an unreadable partition to InstallDiff, classifies unreadable expected paths, reports them through pharn status, applies strict-mode failure rules, and adds tests, documentation, changelog entries, and validation records.

Changes

Unreadable path comparison

Layer / File(s)Summary
Diff classification and coverage
.dev/features/diff-unreadable-partition/PLAN.md, src/lib/diff.ts, tests/diff.test.ts
compareExpected uses readDiskState, records unreadable paths with reasons, sorts them, and uses shared SHA-256 hashing. Tests cover directories, symlinks, dangling links, invalid parents, missing files, ordering, and shared imports.

Status reporting and documentation

Layer / File(s)Summary
Status reporting and documentation
src/commands/status.ts, tests/status.test.ts, docs/commands/status.md, CHANGELOG.md
Status reports unreadable paths, includes them in clean-state checks and strict-mode failures, and documents the resulting behavior. Tests verify output, ordering, reasons, and empty-section handling.

Validation and delivery records

Layer / File(s)Summary
Validation and delivery records
.dev/features/diff-unreadable-partition/*, .pharn/*, package.json
The plan, review, regression, verification, and ship records document the implementation and passing gates. Scope metadata and development dependency ordering were updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant compareExpected
participant readDiskState
participant status
compareExpected->>readDiskState: classify expected project path
readDiskState-->>compareExpected: missing, unreadable, or file state
compareExpected-->>status: return InstallDiff
status->>status: render unreadable reasons
status-->>status: fail in strict mode when unreadable paths exist
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly and concisely describes the main change: handling unreadable paths in pharn status without crashes or misclassification.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck 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/diff-unreadable-partition

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.

@PrzemekGalarowicz
PrzemekGalarowicz merged commit dd8af18 into mainAug 11, 2026
8 checks passed
@PrzemekGalarowicz
PrzemekGalarowicz deleted the fix/diff-unreadable-partition branch August 11, 2026 10:44
Sign up for freeto 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.

1 participant

@PrzemekGalarowicz