Repository navigation
Closed
Labels
Description
Source PR: #355
Branch: feat/issue-343-doctor
Head reviewed: 1202f79
Push the fixes to the branch above; do not open a new pull request. Comment on the PR and on this issue when done.
Blocking findings
- An empty --target-dir value is treated as "flag absent" and silently selects the canonical-roots mode (
internal/cli/doctor.go): Both new dispatchers parse--target-dirby assigningtargetDir = args[index+1]and then branch onif targetDir == "", but""is also the sentinel for "no flag was given". A caller passing an empty value — the ordinary case of an unset shell variable — therefore lands in the wrong mode instead of being refused witherror=invalid_target(exit 64, as the stack's own docs promise for a missing path). runUninstallCommand is the dangerous one: it falls through to runUninstall, which resolves and uninstalls every canonical root. The fix is a separateseenboolean (the pattern update.go's parseUpdateArgs already avoids by rejecting an empty value in the same branch), so an empty value fails closed.- Failure scenario: An operator runs
cortex uninstall --target-dir "$SKILLS_DIR"in a shell where SKILLS_DIR is unset. args = ["--target-dir", ""], targetDir stays "", theif targetDir == ""branch calls runUninstall, and the command removes every verified Cortex-owned file from the pi, opencode and claude-code canonical roots — three installations the operator never named.cortex doctor --target-dir "$SKILLS_DIR"with the same unset variable prints the host runtimematrix and exits 0, so an automation precheck reports a healthy target it never inspected. Neither path is reachable by the tests, which only pass a non-empty directory.
- Failure scenario: An operator runs
Acceptance criteria
- Fixed: An empty --target-dir value is treated as "flag absent" and silently selects the canonical-roots mode (internal/cli/doctor.go). The scenario below no longer reproduces: An operator runs
cortex uninstall --target-dir "$SKILLS_DIR"in a shell where SKILLS_DIR is unset. args = ["--target-dir", ""], targetDir stays "", theif targetDir == ""branch calls runUninstall, and the command removes every verified Cortex-owned file from the pi, opencode and claude-code canonical roots — three installations the operator never named.cortex doctor --target-dir "$SKILLS_DIR"with the same unset variable prints the host runtimematrix and exits 0, so an automation precheck reports a healthy target it never inspected. Neither path is reachable by the tests, which only pass a non-empty directory.
Activity
barbatdev commentedon Nov 12, 2026
Fixed by #388 (merged 46f2870): an empty
--target-diris refused asinvalid_target(exit 64) for install, doctor, update and uninstall, without touching the directory or canonical roots. Covered byTestDirectoryTargetCommandsRefuseRelativeTargets(directory_lifecycle_test.go:224, plus the duplicate-flag case at :332), which passes on main.