Repository navigation
Description
Parent: #518
Outcome
Provide an OAuth-agnostic credential-storage boundary that safely supports rotating opaque credentials and additional backends later. Ship a deterministic memory backend/conformance suite and a hardened encrypted local-workstation backend. Do not couple the contract to MCP, OAuth, product config files, prompting, or cloud SDKs.
Design requirements
- Add a narrow package under
internal/adapter/credentialstorewith opaque[]byterecords, defensive copies, opaque versions,Get, conditionalPut, conditionalDelete, capabilities, and idempotentClose. - Typed errors through
errors.Is: not found, conflict, closed, too large, invalid key/namespace, corrupt, and unavailable. Never classify by matching error text. Putsupports create-only and expected-version CAS;Deletesupports expected-version CAS. One credential lifecycle is one opaque record, so no transaction framework is needed.- Bind stores to validated namespaces with unambiguous encoding and no cross-namespace fallback.
- Provide a memory backend and reusable conformance suite.
- Provide a local encrypted-file backend with a versioned envelope, authenticated encryption, bounded key/value/file sizes, exact 32-byte injected key material, stable cross-process lock identity, context-aware lock acquisition, CAS under the lock, explicit symlink/no-follow and ownership/permission policy,
0700directory/0600file posture, same-directory temp + file sync + atomic replace + directory sync where supported, corruption-safe failure, and key clearing on close. - Key acquisition is an explicit adapter concern. No plaintext, weak-password, project-file, or environment fallback.
- No global logger, stdin prompt, implicit XDG lookup, singleton, provider registry, list-all, cleanup-all, or raw encryption API.
Acceptance criteria
- Conformance covers arbitrary bytes/invalid UTF-8, defensive copies, bounds, typed errors, create/current/stale-version operations, one concurrent CAS winner, namespace isolation, cancellation, and post-close behavior.
- File tests cover two handles and subprocess contention, stable lock behavior, wrong key, truncation/corruption/oversize, unsafe path/symlink/permissions, fault points around replacement, stale CAS, and no commit after cancellation.
- File decoding and key/namespace validation are fuzzed; race tests are clean.
- The contract imports only the standard library and contains no OAuth/MCP types.
- Default mecatl composition performs no file/key-source access when no backend is selected.
- Documentation calls this a local encrypted-file backend and explicitly does not claim Kubernetes, distributed, or tenant-isolated semantics.
Security constraints
Never log keys or values. Versions are opaque. Never accept user passwords directly as encryption keys. Never silently replace a corrupt store. Add all outlives-a-call resources to docs/adr/0027-cloud-native.md.
Verification
Package tests, conformance suite, subprocess/fault tests, fuzzers, race coverage, task lint, and task test.
Dependencies and sizing
None; implement first. SDK qualification can run independently.
Size: XL. Complexity: high/security-critical. Execution: chunk by contract+memory/conformance, then encrypted backend; review as one security contract.
Activity
jhrozek commentedon Aug 14, 2026
would it make sense to point the agents at the credential store of pkg/authserver? I don't think it can be lifted, but there's already a pluggable interface with a memory and a redis back end
refactor(credentialstore): split read and mutation ports
feat(credentialstore): add versioned encrypted CAS store
test(credentialstore): cover version isolation
refactor(credentialstore): split read and mutation ports
feat(credentialstore): add versioned encrypted CAS store (#536)