# Remediation Brief: alks-cli-keystore-keytar-replacement

Verdict was PASS (no CRITICAL/HIGH). These MEDIUM findings were selected for remediation as follow-up hardening.

## VF-1: isNoEntryError message-regex could swallow a genuine error

**Severity**: MEDIUM · **Dimension**: Code Quality / Test Quality
**Evidence**: `src/lib/getKeytar.ts:24-31`; propagation branches untested in `src/lib/getKeytar.test.ts`
**Fix**: Keep the `.code`/`NoEntry` check as the primary signal; narrow the message fallback to keychain/entry-specific phrasings (drop bare `/not found/i`, which can match unrelated IO errors). Add tests: a non-NoEntry error propagates (rejects); a message-only NoEntry is still swallowed; an unrelated "file not found" is NOT swallowed.
**Complexity**: Simple.

## VF-2: removeToken does not await the async adapter delete

**Severity**: MEDIUM · **Dimension**: Test Quality / Code Quality / Security
**Evidence**: `src/lib/removeToken.ts:10` (no await); caller `alks-developer-logout2fa.ts:11-17` already has try/catch.
**Fix**: `await` the `deletePassword` call so a real failure propagates to the logout handler's existing catch (which prints "Error removing token!") instead of a false "Token removed!" + unhandled rejection. Add `removeToken.test.ts`.
**Complexity**: Simple.

## VF-3: AC-1.5 backward-compat has no automated test

**Severity**: MEDIUM · **Dimension**: Test Quality
**Evidence**: manual-only check in `progress.md` (TASK-8)
**Fix**: Add a darwin-gated test that writes a keytar-format entry via `security add-generic-password`, reads it back through the adapter, and cleans up — mirroring the manual TASK-8 procedure as a committed regression guard.
**Complexity**: Simple (platform-gated).

## Convention principle (VF-1 + VF-2 theme)

Add to CLAUDE.md: classify benign errors by a stable code (not message text), propagate/handle every other error rather than swallow, and await async cleanup so failures surface.
