fix(watchlist): report invalid lease-store paths
Invalid WRIT_LEASE_PATH values could be reported as a healthy empty watchlist because Path::exists() discarded filesystem errors. Reads now return the existing IO_ERROR envelope and exit 1 for invalid ancestors, unreadable paths and dangling store/ancestor links. Truly missing stores remain successful empty views and create no database; valid symlinks continue to work.
The implementation preserves Amp's published final-symlink repair and adds the remaining ancestor-link correction. A small private ancestor validator gives Windows-relevant fallback behavior direct coverage with real filesystem fixtures. No public API, JSON schema or production dependencies changed. Test fixtures now reuse the existing tempfile 3.27.0 dependency instead of predictable handwritten temporary-directory management.
Evidence:
- Original regular-file-ancestor and symlink-loop regressions failed with actual exit 0 before repair.
- The later dangling-ancestor regression failed on published peer head
72d4f19; it passes after the follow-up. - Current focused tests: 20 passed. Independent review found no actionable issue and independently checked coverage.
- Local native LLVM coverage recorded before the test-only fixture cleanup (production lookup unchanged): 34/34 production validation lines, and all changed executable lines (69/69 in
watchlist.rs, including inline tests; 119/119 in the CLI test file). Hosted Codecov is checked separately, with its threshold unchanged.
Final validation on 2219ac2509dd05477e5ba89289570dc76bee15d3, Rust 1.97.1 (workspace MSRV):
cargo fmt --all -- --check— passed.CC=/usr/bin/gcc CARGO_BUILD_JOBS=4 cargo clippy --locked --offline --workspace --all-targets --all-features -- -D warnings— passed.CC=/usr/bin/gcc CARGO_BUILD_JOBS=4 cargo test --locked --offline --workspace --all-features— 448 passed, zero failed/ignored.
No crate feature switches are declared. Hosted validation on 2219ac2509dd05477e5ba89289570dc76bee15d3 is complete: Ubuntu/macOS/Windows, fmt/Clippy, cargo audit, CodeQL, CodeScene, Codacy, Codecov and qlty pass; hosted patch coverage is 100%. No unresolved review threads remain. The independent local review is complete. CodeRabbit's latest attempt is quota-limited and Codex code review capacity was unavailable, so those are not counted as fresh completed reviews. No tests, assertions or check thresholds were weakened. Published peer commits and attribution remain intact.
Related: #1, a bounded follow-up rather than an epic closure. Current milestone is Linear writ — Collaboration MVP; historical GitHub milestones remain unassigned. #209 overlaps only doc comments and #190 remains preserved historical salvage.
Linear: RM-1955
Summary by cubic
Fixes watchlist reads so invalid, unreadable, or dangling lease-store paths fail with an IO_ERROR envelope and exit 1 instead of returning an empty ok:true view with exit 0. A genuinely missing store still renders an empty view without creating leases.db.
Bug Fixes
- Replaces
Path::exists()withtry_exists()plus dangling-symlink and ancestor checks that propagate filesystem errors, including Windows'NotFoundfor invalid ancestors. - Adds CLI tests for list/check/check-all in JSON and human output covering regular-file ancestors, dangling symlinks, symlink loops, directory stores, and corrupt stores, each preserving the offending path.
Tests
- Reuses the existing
tempfiledependency instead of handwritten temporary-directory management. - Pairs each view command with its expected envelope so CLI test contracts stay explicit.
CodeAnt-AI Description
Report invalid watchlist store paths instead of returning empty success
What Changed
- Watchlist list, check, and check-all commands now fail with an error when the lease store is unreadable, corrupt, a directory, behind a dangling symlink, or located under a file
- A genuinely missing store still returns an empty view without creating files
- Added coverage for JSON and human-readable errors while preserving invalid files, directories, and symlinks
Impact
✅ Fewer false successful watchlist results
✅ Clearer lease-store path errors
✅ Safer handling of corrupt or invalid stores
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.