test: make credential classification independent of the host home - #851
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
devswha
marked this pull request as ready for review
September 15, 2026 14:48
devswha
added a commit
that referenced
this pull request
Sep 15, 2026
Re-measure the package surface at a1116bf (origin/dev 3622d3b merged: PR #847, #849, #850, #851; PR-06 retired by the owner). Root tarball 1,521,037 B / 5,703,327 B unpacked / sha256 8164d622; alias unchanged. Category estimates, policy-docs subset (94,452 B), and the validation record re-run at this tree; the artifacts/rebaseline-2025 shipped-file count is corrected from 7 to 6 (the packed list always had 6 files at the recorded 439,339 B). Conclusion unchanged: KEEP / NO PR-08.
devswha
added a commit
that referenced
this pull request
Sep 15, 2026
* docs: audit package reachability before removing shipped assets * docs: measure local-tree tarballs precisely; refresh audit onto dev b0a3934 * docs: final-refresh the package audit on the converged maintenance chain Re-measure the package surface at a1116bf (origin/dev 3622d3b merged: PR #847, #849, #850, #851; PR-06 retired by the owner). Root tarball 1,521,037 B / 5,703,327 B unpacked / sha256 8164d622; alias unchanged. Category estimates, policy-docs subset (94,452 B), and the validation record re-run at this tree; the artifacts/rebaseline-2025 shipped-file count is corrected from 7 to 6 (the packed list always had 6 files at the recorded 439,339 B). Conclusion unchanged: KEEP / NO PR-08.
Merged
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.
Problem
tests/unit/backend-auth.test.jswas partly dependent on the developer machine's actual login state:claude-cli.js#isAuthenticated()resolved~/.claude/.credentials.jsonthrough the realos.homedir()internally, so the wrapper test computed its expected value from the developer's real credential file (readClaudeCredentialState(join(homedir(), '.claude', '.credentials.json'))).geminiOAuthPresentfrom the real~/.gemini/gemini-credentials.jsonand skipped the env-key classification test entirely on hosts with a real Gemini OAuth login. The same suite therefore exercised different behavior depending on whether the developer happened to be logged in (observed on this maintenance host: the env-key test was skipped).Change (minimal internal test seam)
No-argument production behavior is unchanged; every default is the real runtime value, evaluated per call.
src/backends/claude-cli.js:readClaudeCredentialState(...) === 'ok' || hasMacOsKeychainCredentials(...)classification in the same short-circuit order.src/backends/gemini-cli.js:GEMINI_API_KEYsemantics.No public CLI/API/configuration change, no filesystem abstraction, no shared auth framework, no credential-format or policy change.
authHint()on both backends is untouched (Claude's was not under test; Gemini's is env-only and already deterministic).Compatibility
isAuthenticated()/authHint()with zero arguments (src/backends/index.js,src/commands/auth.js,bin/patina-skill.js); the optional deps object cannot break them.security find-generic-password -s 'Claude Code-credentials'with exactly{ stdio: 'ignore', timeout: 5000, killSignal: 'SIGKILL' }, fail-closed on error/timeout; the diff does not touchhasMacOsKeychainCredentials.Tests
Wrapper-level cases moved entirely onto owned, self-cleaning temp fixtures (
withOwnedDir); synthetic tokens are unmistakably fake (patina-test-fake-*). No test readsos.homedir(), real~/.claude/~/.gemini, the real Keychain, or invokes a real auth CLI.Claude coverage: missing file → false; valid/live file → true; expired/logged-out shape (blank tokens,
expiresAt: 0) → false; unknown layout → true (compat); non-darwin never probes the Keychain (recorded zero calls against a would-be-hit stub); darwin file-first short-circuit (file ok ⇒ Keychain not probed); darwin Keychain fallback when the file cannot authenticate; darwin miss + expired file → false.Gemini coverage (all combinations, zero host-dependent skips): OAuth file absent × {no key, blank/whitespace key, non-blank key} → {false, false, true}; OAuth file present (zero-byte: presence is the signal) × {no key, blank key} → {true, true}.
Removed host-dependent patterns: the
geminiOAuthPresentreal-home check and its skip (1 skip), and the real-home-derived Claude expectation.Regression sequence: the seam-using tests were run first against the un-seamed implementation on this host → exit 1, 3 failures, all "expected false, got true"-shaped because the old code consulted the real host authentication state instead of the owned fixture. After the seam: 8/8 pass, 0 skips. The developer's HOME/login state was never manipulated. Honest privacy record: that one pre-fix run exercised the old host-dependent implementation, which consulted real host authentication state — Claude's real credential path (
~/.claude/.credentials.jsonviaos.homedir(), classified byreadClaudeCredentialState()includingreadFileSync()when the file exists) and Gemini's real OAuth-file existence (existsSync(~/.gemini/gemini-credentials.json)). No credential value was intentionally printed, copied, committed, or included in test output; no real authentication CLI was invoked; the host is Linux, so the macOS Keychain probe did not run. This pre-fix execution did not follow the task's intended privacy boundary and is not claimed as compliant; it was not and will not be rerun, because repeating it would add no evidence.Validation (base
cca22f1979e9de454e4c7a0f8e0a9bb4148f5d4b, head7ae3267d00c47a269468885aaf4fa000074954c9, Node v24.18.0, Linux x64)node -r ./tests/helpers/real-tmpdir.cjs --test tests/unit/backend-auth.test.js(pre-seam, regression)npm run test:unitnpm testnpm run lintnpm run release:checknpm run check:no-private-assetsRemaining skip: 1 —
real Redis executes reservation/refund Lua atomically and preserves expiry(tests/unit/quota-redis.test.js), a pre-existing capability skip (no Redis server/CLI on this host), unrelated to credential classification. Zero skips remain that are caused by real Claude/Gemini login state.Profiles not run (documented non-applicability):
browser-fixture(no browser/playground surface),regression/benchmark(no detection-signal or scoring change),dogfood(no public-document change),live-model(no live login/model path; not authorized or required here).Independent review
Verdict: PASS / APPROVE — independent read-only review of head
7ae3267d00c47a269468885aaf4fa000074954c9against basecca22f1979e9de454e4c7a0f8e0a9bb4148f5d4b. Blocking implementation findings: none. The review verified: branch based on currentdev; effective diff limited to the three listed files; narrow optionalcredentialsFileseams preserve Claude file-first → Keychain fallback semantics and Gemini OAuth-file-presence OR trimmed-API-key semantics; zero-argument production behavior unchanged; host-login-dependent Gemini skipping removed; credential-classification tests use owned temporary fixture paths; Claude unknown-layout compatibility kept; Gemini OAuth file contents not newly validated; PR-03's Keychain probe unchanged (timeout: 5000,killSignal: 'SIGKILL'); hosted CI green on the exact head; no unrelated runtime/auth redesign.Historical context (not reviews): before this verdict, the authoring session provisionally recorded
inconclusiveafter several reviewer routes (architect category, code-reviewer / gate-reviewer / oracle agents, deep category) failed at spawn because every configured lane model was unavailable. Those failed routing attempts never produced a review and are not claimed as one.Credential safety
Current tests: all credential-classification fixtures are synthetic (
patina-test-fake-*) and created only under test-owned temporary directories; the post-fix suite never readsos.homedir()credential paths, real~/.claude/~/.gemini, the Keychain, or invokes a real auth CLI.Pre-fix regression run (honest record): the single regression-before-fix execution ran the seam-dependent tests against the OLD implementation, which consulted real host authentication state — Claude's real credential file classification (
~/.claude/.credentials.json, read viareadFileSyncwhen present) and Gemini's real OAuth-file existence check. No credential value was intentionally printed, copied, committed, or included in test output; no real authentication CLI was invoked; the host is Linux, so the macOS Keychain probe did not run. That pre-fix execution did not follow the task's intended privacy boundary; it is recorded here rather than hidden, and it was not and will not be rerun.Issue exemption
Test-only change that does not alter behavior (optional internal parameters; all production call sites no-argument), so no tracking Issue is opened per the low-risk exemption in
docs/WORKFLOW.md. Acceptance criteria: deterministic credential-classification tests with zero host-login-dependent skips and unchanged no-argument production behavior — verified by the evidence above.Rollback
After merge, revert the resulting PR merge/squash commit through a normal reviewed PR. The rollback removes only the Claude/Gemini internal credential-path seams and deterministic test changes; PR-03's Keychain timeout (
timeout: 5000,killSignal: 'SIGKILL') remains independently preserved.Diff
Raw = reviewable: 3 files, +124/−50 (174 lines), no generated output, lockfiles, or renames:
src/backends/claude-cli.js(+13/−2),src/backends/gemini-cli.js(+9/−2),tests/unit/backend-auth.test.js(+102/−46 net).