Skip to content

fix: avoid keychain secret reads for exists checks#65

Merged
rianjs merged 4 commits into
mainfrom
fix/keychain-exists-metadata-probe
Jun 30, 2026
Merged

fix: avoid keychain secret reads for exists checks#65
rianjs merged 4 commits into
mainfrom
fix/keychain-exists-metadata-probe

Conversation

@rianjs

@rianjs rianjs commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • prefer keyring metadata lookups for Store.Exists before falling back to full secret reads
  • keep fallback behavior for backends that cannot answer metadata without credentials
  • cover the keychain-friendly path with focused backend tests

Closes #68
Release tag: v0.4.1

Verification

  • go test ./credstore
  • local stale-item probe: published Exists path took about 6.3s, patched path about 10ms on the same stale keychain item

@rianjs-bot

rianjs-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: 3d3f982b83c3
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Severity Findings
blocking 0
major 0
minor 0
nits 0

0 PR discussion threads considered. 0 summarized; 0 resolved.


Completed in 25s | unavailable | gpt-5.4 | cr 0.10.196
Field Value
Model gpt-5.4
Reviewers unavailable
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 25s wall · 23s compute
Cost unavailable
Tokens 56.8k in / 784 out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 46.3k 664 41.0k unavailable unavailable 18s
orchestrator-rollup gpt-5.4 10.5k 120 7.6k unavailable unavailable 4s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: approved.

@rianjs-bot

rianjs-bot Bot commented Jun 29, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: b7b622955d49
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Severity Findings
blocking 0
major 0
minor 0
nits 0

0 PR discussion threads considered. 0 summarized; 0 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 23s | unavailable | gpt-5.4 | cr 0.10.196
Field Value
Model gpt-5.4
Reviewers unavailable
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 23s wall · 21s compute
Cost unavailable
Tokens 46.4k in / 774 out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 25.0k 465 19.2k unavailable unavailable 12s
orchestrator-rollup gpt-5.4 21.3k 309 17.7k unavailable unavailable 8s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: approved.

@rianjs-bot

rianjs-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: b7b622955d49
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Severity Findings
blocking 0
major 0
minor 0
nits 0

0 PR discussion threads considered. 0 summarized; 0 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 28s | unavailable | gpt-5.4 | cr 0.10.196
Field Value
Model gpt-5.4
Reviewers unavailable
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 28s wall · 26s compute
Cost unavailable
Tokens 60.0k in / 833 out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 37.9k 549 26.8k unavailable unavailable 15s
orchestrator-rollup gpt-5.4 22.1k 284 18.2k unavailable unavailable 11s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: approved.

@rianjs rianjs force-pushed the fix/keychain-exists-metadata-probe branch from b7b6229 to ec3fd5f Compare June 30, 2026 13:19
@rianjs-bot

rianjs-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: ec3fd5f04e20
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Reviewer Findings
go:implementation-tests 0
documentation:docs 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable Review scope was limited to the assigned credstore Go implementation and tests.; go test ./credstore was verified with writable cache overrides (GOCACHE=/private/tmp/codex-go-build-cache and CLANG_MODULE_CACHE_PATH=/private/tmp/codex-clang-cache) because the sandbox blocks the default Go/Clang cache locations.
documentation:docs complete_broad .codereview/agents/go/implementation-tests/prompt.md unavailable Review scope was intentionally limited to the assigned documentation-only change in .codereview/agents/go/implementation-tests/prompt.md.

0 PR discussion threads considered. 0 summarized; 0 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 2m 51s | unavailable | gpt-5.4 | cr 0.10.197
Field Value
Model gpt-5.4
Reviewers go:implementation-tests, documentation:docs
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 2m 51s wall · 3m 38s compute
Cost unavailable
Tokens 419.9k in / 9.1k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 54.7k 1.4k 41.5k unavailable unavailable 34s
go:implementation-tests gpt-5.4 273.5k 5.0k 236.9k unavailable unavailable 2m 02s
documentation:docs gpt-5.4 80.4k 2.6k 63.5k unavailable unavailable 56s
orchestrator-rollup gpt-5.4 11.2k 76 9.6k unavailable unavailable 4s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: approved.

@rianjs-bot

rianjs-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: f1014d850c08
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Reviewer Findings
go:implementation-tests 1
go:implementation-tests (1 finding)

Major - credstore/osbackend_byteness.go:68

bytenessBackend.metadata now treats any successful Keyring.GetMetadata call as proof that the key exists, but github.com/byteness/keyring v1.11.0 does not uphold that contract for every backend. In particular, its pass, OP, and OPConnect implementations return Metadata{}, nil without checking the requested key, so Store.Exists will start returning true for missing credentials on CGO builds for those backends. The new tests only cover the happy metadata path and the explicit unsupported fallback, so this regression is currently untested. Fix by marking those stubbed backends as metadata-unsupported (or otherwise gating the fast path to backends with real existence-aware metadata), and add a focused test proving Exists returns false for a missing key on the affected ByteNess-backed backends.

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_byteness_test.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable Review scope limited to the assigned credstore/ Go files and nearby package context.; Verified with go test ./credstore after redirecting GOCACHE, TMPDIR, and CLANG_MODULE_CACHE_PATH because the sandbox blocked the default cache locations.
unassigned incomplete_unassigned unavailable .codereview/agents/go/implementation-tests/prompt.md changed files were not assigned to a selected reviewer

0 PR discussion threads considered. 0 summarized; 0 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 3m 25s | unavailable | gpt-5.4 | cr 0.10.197
Field Value
Model gpt-5.4
Reviewers go:implementation-tests
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 3m 25s wall · 3m 17s compute
Cost unavailable
Tokens 712.0k in / 8.4k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 26.5k 737 20.2k unavailable unavailable 17s
go:implementation-tests gpt-5.4 674.0k 7.6k 618.9k unavailable unavailable 2m 55s
orchestrator-rollup gpt-5.4 11.5k 123 7.6k unavailable unavailable 4s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: request_changes.

Comment thread credstore/osbackend_byteness.go
@rianjs-bot

rianjs-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: 89a13fb994d1
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Reviewer Findings
go:implementation-tests 0
policies:conventions 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_byteness_test.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable go test ./credstore could not be completed in this sandbox because the CGO/clang toolchain attempted to write temporary/module-cache files under restricted paths (/Users/rianjs/.cache/clang), so validation here was limited to static review of the changed Go code and tests.
policies:conventions complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_byteness_test.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable Review scoped to the assigned changed files plus repo-local/shared standards docs relevant to credential-store behavior.; go test ./credstore could not be completed in this sandbox because Go failed to initialize its build cache under the managed scratch path (operation not permitted).
unassigned incomplete_unassigned unavailable .codereview/agents/go/implementation-tests/prompt.md changed files were not assigned to a selected reviewer

1 PR discussion threads considered. 1 summarized; 1 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 5m 43s | unavailable | gpt-5.4 | cr 0.10.197
Field Value
Model gpt-5.4
Reviewers go:implementation-tests, policies:conventions
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 5m 43s wall · 7m 11s compute
Cost unavailable
Tokens 1.1M in / 16.4k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 121.9k 2.8k 75.5k unavailable unavailable 1m 19s
go:implementation-tests gpt-5.4 651.6k 9.0k 591.5k unavailable unavailable 3m 45s
policies:conventions gpt-5.4 273.1k 4.5k 219.8k unavailable unavailable 2m 01s
orchestrator-rollup gpt-5.4 11.1k 84 7.6k unavailable unavailable 4s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: comment.

@rianjs-bot

rianjs-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

Automated PR Review

Reviewed commit: 89a13fb994d1
Profile: codex-rianjs-bot - Posting as: rianjs-bot[bot]

Summary

Reviewer Findings
go:implementation-tests 1
policies:conventions 0
structure:repo-health 0
go:implementation-tests (1 finding)

Minor - credstore/osbackend_byteness.go:80

The new md.Item == nil branch is a backend-specific contract edge and the added tests never exercise its successful path. byteness/keyring's file backend returns Metadata{ModificationTime: ...} with a nil Item for existing entries, so if this branch regresses to errKeyringMetadataUnsupported the cgo/Windows file backend will silently fall back to Get, reintroducing a secret read/passphrase prompt on Exists without failing the current suite. Add a focused test that returns metadata with Item:nil and a non-zero ModificationTime, then assert exists returns true and Get is not called.

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
go:implementation-tests complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_byteness_test.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable Sandbox prevented executing go test because the configured Go build cache path was not writable (operation not permitted), so the review relied on source inspection and existing test code.
policies:conventions complete_broad credstore/filebackend_nocgo_unix.go, credstore/osbackend_byteness.go, credstore/osbackend_byteness_test.go, credstore/osbackend_core.go, credstore/osbackend_test.go, credstore/passbackend_nocgo_unix.go, credstore/secretservice_core.go unavailable Review limited to the assigned changed files and the visible repo-local/shared standards docs; this review focused on convention drift, copied policy, and missing durable docs/checks rather than general implementation correctness.
structure:repo-health complete_broad .codereview/agents/go/implementation-tests/prompt.md unavailable Scope limited to the assigned review surface .codereview/agents/go/implementation-tests/prompt.md; broader PR code changes were intentionally not reviewed by this agent.

0 PR discussion threads considered. 0 summarized; 0 resolved.


Note: This PR modifies reviewer definitions under .codereview/agents/. The review was conducted using base-branch versions; changes will affect future reviews after merge.


Completed in 4m 12s | unavailable | gpt-5.4 | cr 0.10.197
Field Value
Model gpt-5.4
Reviewers go:implementation-tests, policies:conventions, structure:repo-health
Engine codex_cli · gpt-5.4
Reviewed by cr · rianjs-bot[bot]
Duration 4m 12s wall · 6m 32s compute
Cost unavailable
Tokens 968.8k in / 17.7k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection gpt-5.4 26.4k 1.1k 20.2k unavailable unavailable 24s
go:implementation-tests gpt-5.4 533.0k 9.3k 443.0k unavailable unavailable 3m 10s
policies:conventions gpt-5.4 308.5k 4.8k 263.2k unavailable unavailable 1m 54s
structure:repo-health gpt-5.4 77.8k 2.2k 59.9k unavailable unavailable 46s
orchestrator-rollup gpt-5.4 23.0k 254 15.1k unavailable unavailable 16s

@rianjs-bot rianjs-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR review completed with outcome: approved.

return keyringItem{}, err
}
}
if md.Item == nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new md.Item == nil branch is a backend-specific contract edge and the added tests never exercise its successful path. byteness/keyring's file backend returns Metadata{ModificationTime: ...} with a nil Item for existing entries, so if this branch regresses to errKeyringMetadataUnsupported the cgo/Windows file backend will silently fall back to Get, reintroducing a secret read/passphrase prompt on Exists without failing the current suite. Add a focused test that returns metadata with Item:nil and a non-zero ModificationTime, then assert exists returns true and Get is not called.

Reply inline to this comment.

@rianjs rianjs merged commit 97cbd64 into main Jun 30, 2026
4 checks passed
@rianjs rianjs deleted the fix/keychain-exists-metadata-probe branch June 30, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

credstore: avoid secret reads for Exists metadata probes

1 participant