# Progress: ALKS CLI Keystore — Replace keytar with a Node-24-Compatible Keychain Library

> Tasks: spec-driven/alks-cli-keystore-keytar-replacement/tasks.md | Mode: sequential | Total: 8 tasks / 5 bundles

## Current State

- **Phase**: Complete
- **Active bundle**: — (all bundles complete)
- **Last completed**: TASK-8
- **Next up**: —
- **Status**: complete — 8/8 tasks
- **Baseline**: 5b7ea93
- **Baseline exit code**: 0 (39 suites, 375 tests)

## Task Status

| Task | Bundle | Trace | Status |
|------|--------|-------|--------|
| TASK-1 | Bundle 1 | STEP-1 → FR-1 | done (ea89952) |
| TASK-2 | Bundle 2 | STEP-2 → FR-1, FR-2 | done (bce37a8) |
| TASK-3 | Bundle 2 | STEP-3 → FR-2 | done (f06a804) |
| TASK-4 | Bundle 2 | STEP-4 → FR-3 | done (05dff6e) |
| TASK-5 | Bundle 3 | STEP-5 → FR-4, FR-1 | done (52fcc9f) |
| TASK-6 | Bundle 3 | STEP-6 → FR-4 | done (0a81675) |
| TASK-7 | Bundle 4 | STEP-7 → FR-3 | done (1e59912) |
| TASK-8 | Bundle 5 | STEP-8 → FR-1, All FRs | done (verification-only) |

## Session Log

- 2026-07-30 — Task decomposition generated and finalized (8 tasks, 5 bundles, sequential). Validation: subagent (0 fail / 3 advisory, resolved). Awaiting execution.

### 2026-07-30 — Bundle 1: Foundation
- Completed: TASK-1 (ea89952) — swapped keytar → @napi-rs/keyring in package.json (dependencies), full lockfile regen against public npm.
- Verification: napi loads (AsyncEntry present), keytar absent from tree/manifest/lockfile. Regression gate: passed (exit 0, 375/375).
- Decisions: none
- Next: TASK-2 — rewrite getKeytar.ts adapter

### 2026-07-30 — Bundle 2: Adapter, Honest Errors, and Support Contract
- Completed: TASK-2 (bce37a8) getKeytar adapter over @napi-rs/keyring; TASK-3 (f06a804) honest storeToken error + fallback; TASK-4 (05dff6e) engines >=20.
- Verification: getKeytar 7/7, storeToken+getTokenFromKeystore 6/6, engines AC-3.1/3.2 pass. Regression gate: passed (exit 0, 42 suites / 388 tests).
- Decisions: Empirically, @napi-rs/keyring on macOS returns null/false on a missing entry (does NOT throw NoEntry, contrary to the spec/plan assumption). Adapter passes null through as undefined and still defensively catches a thrown NoEntry for cross-platform portability. getKeytar kept as a dynamic import so a load failure degrades to the plaintext fallback (AD-2).
- Next: TASK-5 — non-mocked keystore round-trip integration test

### 2026-07-30 — Bundle 3: Regression Guard (Non-Mocked) and CI
- Completed: TASK-5 (52fcc9f) non-mocked getKeytar.integration.test.ts (load assertion + real macOS round-trip, 2/2); TASK-6 (0a81675) CI provisions libsecret+gnome-keyring, runs tests under dbus-run-session with KEYSTORE_ROUNDTRIP=1.
- Verification: integration 2/2 (real keychain, no prompt). Regression gate: passed (exit 0, 43 suites / 390 tests).
- Deferred: TASK-6 AC-4.2 red/green-on-push behavior requires an actual CI matrix run — verify on branch push (cannot run GitHub Actions locally). Also: apt-get/sudo availability on the self-hosted cai-standard-x86-linux runner is unverified.
- Next: TASK-7 — changelog + release note

### 2026-07-30 — Bundle 4: Documentation and Release Notes
- Completed: TASK-7 (1e59912) — changelog entry for keytar->@napi-rs/keyring swap, honest keystore errors, engines >=20 (BREAKING), Linux libsecret runtime note.
- Verification: grep checks for napi-rs/keyring, engines/node20/keychain, libsecret all pass. (Docs-only; regression gate folded into Bundle 5.)
- Next: TASK-8 — full verification + migration check

### 2026-07-30 — Bundle 5: Verification [TASK-8]
- Completed: TASK-8 — full build + suite green (exit 0, 43 suites / 390 tests); empirical keytar->napi migration check PASSED.
- Migration (Open Question 1 RESOLVED): the new adapter read a keytar-format generic-password entry (service+account) written via macOS `security` and deleted it cleanly. No migration code needed. Used a disposable service key — no real alkscli/alkstoken token touched.
- No code change committed for TASK-8 (verification-only; migration passed so no migration code added).
- Deferred (runtime, cannot run locally): TASK-6 CI matrix red/green-on-push behavior (AC-4.2) and apt/sudo availability on the self-hosted Linux runner; AC-1.1/AC-1.5 on a clean published Node 24 install and for a real upgrading user (spec post-deploy verification).

### 2026-07-30 — Verification + remediation
- Verify verdict: PASS (0 CRITICAL/HIGH; 4 MEDIUM, 4 LOW, 6 INFO). Report: verify-report.md.
- Remediated VF-1/VF-2/VF-3 + added a CLAUDE.md principle (commit 5f5a4d7). Full suite green: 44 suites / 397 passed + 1 skipped.
- VF-3 migration test is opt-in (KEYSTORE_MIGRATION_CHECK=1, macOS): cross-creator keychain read prompts an ACL dialog that hangs headless runs — same reason AC-1.5 stayed a manual check.
- Open: VF-4 (AC-2.1 "no reinstall string" wording) left as a spec-author decision.

