Repository navigation
fix(cli): report an unreadable install state as invalid in doctor - #438
Conversation
Post-merge QA (glm)The merge does what issue #437 asked: an existing-but-unreadable install state is now reported as ownership=invalid instead of unowned, only a genuinely missing file yields unowned, and a CLI test pins both cases through the public doctor path. The change is minimal, has a single caller, and rollback is a single revert. One non-blocking docs point: the sentence the PR edited still claims an unreadable prior state exits with the conflict code install would hit, but ownership=invalid exits 0 (before and after this change); the PR body itself flags this as a separate maintainer decision. Suggestion (1)
Verdict: clean |
Post-merge QA (deepseek)Lens: evidence + test design. The fix is small and correctly targeted: Suggestion (1)
Verdict: clean |
Pull Request
Linked Issue
Fixes #437
PR Type
type:featureFeaturetype:bugBug fixtype:docsDocumentationtype:refactorRefactoringtype:choreMaintenancetype:breaking-changeBreaking changeSummary
doctor --target-dirreportedownership=unownedwhen.cortex/install-state.jsonexisted but could not be read, so an unreadable ownership record looked like no record at all. Only a missing file now meansunowned; any other read error reports the existinginvalidvalue.Changes
internal/cli/doctor.go:doctorTargetOwnershipreturnsunownedonly forfs.ErrNotExist, andinvalidfor any other read error.internal/cli/doctor_directory_test.go:TestDoctorDirectoryTargetUnreadableStateIsInvalid, through the publicdoctor --target-dirpath, for an undecodable state and a mode-0000 state (skipped as root).docs/operating.md: states which state-file cases giveunownedand which giveinvalid.Focused Tests
go test ./internal/cli -run TestDoctorDirectoryTarget -count=1before the fixownership=unownedwhereownership=invalidwas expectedTestDoctorDirectoryTargetStatesunownedandowned, exit 0go vet ./...;go test ./... -count=1;python3 -m unittest discover -s testsSide effects:
doctorTargetOwnershiphas one caller (doctor --target-dir); update and uninstall do not use it.Failed or not done: none.
Warnings:
docs/operating.mdsays an unreadable prior state exits with the conflict code install would hit, butownership=invalidexits 0, before and after this change. Exit 3 applies only topresence=unreadableorunwritable. This PR keeps the existing exit code; whetherinvalidshould exit non-zero is a separate maintainer decision.Runtime Harness
N/A: CLI diagnostic change covered by CLI tests.
Rollback
Revert the single commit.
Chain Dependencies / Out of Scope
ownership=invalid.Checklist
status:approved.type:*label is applied.