Skip to content

Credential store: versioned CAS records and hardened local backend #519

Description

@JAORMX

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/credentialstore with opaque []byte records, defensive copies, opaque versions, Get, conditional Put, conditional Delete, capabilities, and idempotent Close.
  • Typed errors through errors.Is: not found, conflict, closed, too large, invalid key/namespace, corrupt, and unavailable. Never classify by matching error text.
  • Put supports create-only and expected-version CAS; Delete supports 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, 0700 directory/0600 file 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

  1. self-assigned this
    on Aug 14, 2026
  2. added theissue type on Aug 14, 2026
  3. added
    enhancement
    on Aug 14, 2026
  4. jhrozek commented on Aug 14, 2026

    @jhrozek
    Contributor

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions