fix(commands): make the scan status chain exhaustive - #14
Merged
0dillon merged 1 commit intoAug 7, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #11.
runScaninsrc/commands/scan.tslogged a line per key with anif / else if / elseoverreading.status:ok, thenlow, then everything else treated as archived. A fourthTtlStatusvariant would compile cleanly and be silently mislabelled "archived" — and sincescan's exit code is what people wire into shell checks, a silent mislabel is worse than a failed build. The issue's description matches the code exactly; no discrepancy found.What changed
src/commands/scan.ts: the status chain is now explicit —ok,low,archived— and the finalelseis an exhaustiveness check:const unhandled: never = reading.status; throw new Error(...). Adding a variant toTtlStatusmakes thatelsenarrow to the new variant, and assigning it toneverfailsnpm run buildinstead of falling through.Key design decisions
if / else ifstructure and added one explicitarchivedbranch plus anever-typedelse— the smallest diff that makes the chain exhaustive. The throw is unreachable today (classifyinsrc/rpc/ttl.tsonly ever returnsok | low | archived) but carries the key description so a future failure names the offending entry.readings.some((r) => r.status !== "ok") ? 2 : 0.Acceptance criteria
Exhaustive chain over
TtlStatus— verified by temporarily adding"expiring"toTtlStatusand confirmingnpm run buildfails:(build exit 2). Reverted before submitting.
Exit-code contract unchanged — 0 when everything is ok, 2 when anything is not; the
returnline is untouched.Verified locally as above by adding a fourth variant; reverted.
Validation
All clean on this branch:
npm run format:check— all files use Prettier stylenpm run lint— no issuesnpm run build— passes (src + test tsconfigs)npm test— 9 files, 100 tests passedFollow-ups
None. No new dependencies, no config or env changes.
Security note
Read-only change to
scanoutput classification; no signing path, key material, or network behavior touched.scanstill never readsLK_KEEPER_KEY.