Artifact 542442b514e0603801f07214f1c20f539b6433f008de38c283061877ce29179d:
- File docs/design/credential-project.md — part of check-in [d66dc3f8af] at 2026-11-21 11:05:58 on branch docs-reorg — docs: short README; manual, reference, dev, design and archive under docs/; AGENTS.md; docs.sh checks docs against code; changelog.inc built at build time (user: dmestas, size: 3488) [annotate] [blame] [check-ins using] [more...]
The credential project (planned; starts after pic stage 2)
Status: proposed. pic's own sealed key store (pic login, see credentials) shipped first and does not depend on it.
A separate small C project that stores and manages credentials for pic and any other tool, under the same constraints as pic: C core and tests, Make/POSIX shell, vendored libfossil/SQLite, zlib and BearSSL only, crash tests at every commit boundary, sanitizers, fuzzing, Fil-C nightly, fastest native build in production.
Decisions (2026-11-18)
- Sanctioned credentials only. API keys, and OAuth for apps the provider lets you register (zeitforge, GitHub, Cloudflare, Google APIs, OpenAI's Sign in with ChatGPT if registered). Never consumer subscription tokens: Anthropic's Claude Code legal page reserves subscription OAuth for Claude Code and Anthropic's own apps and says developers "may not collect, store, or intermediate Claude.ai credentials or session tokens". That rules out a CLIProxyAPI-style subscription proxy.
- One authority on hetzner-hel, reached over SSH (
ssh host cred …over stdio). SSH provides authentication and encryption; machines are added and revoked by SSH key. No listening network server. Setup on hetzner-hel ships with its teardown script. - Timing. Starts after pic stage 2. Until then pic reads
ANTHROPIC_API_KEY, run asdoppler run -- pic …; the project imports from Doppler when it starts.
Shape
- Scope. Sealed store, OAuth login and refresh client, local broker. Not an inference proxy.
- At rest. libfossil-hosted SQLite; each value sealed with ChaCha20-Poly1305 (BearSSL) under a per-record key wrapped by a master key. Master key in the macOS login Keychain; on Linux a 0600 key file under a dedicated user, optionally wrapped by
systemd-creds. - Local access. Unix socket (0600 in a 0700 directory) with peer credentials; per-client grants (pic may read
anthropiconly); an append-only, hash-chained audit table that never holds values. - Refresh. Only the authority refreshes, because rotating refresh tokens are single-use. A refresh is a journaled effect (intent, started, done); a lost rotation ends in a clear "log in again" state.
- Never leaves the store. Refresh tokens, client secrets, the master key. Clients get short-lived access tokens, or API keys through
cred exec NAME -- cmd. - Threats covered. Stolen disk or backup, leaked replica, secrets in logs or core dumps, lost laptop, crash mid-rotation. Not covered: malware running as your user, root on the authority.
Stages
- Sealed store.
cred put|get|ls|rm|log|exec, no daemon. Crash suite at each commit boundary; sentinel test that plaintext never reaches the database, WAL or output. - Broker. Daemon, socket, peer credentials, grants, SSH stdio access. Fuzz the wire parser; kill the daemon mid-request.
- OAuth lifecycle. Device code (RFC 8628) and PKCE loopback, refresh, revoke; first provider zeitforge or GitHub. A fake token server in C; crashes before and after the token response.
- Many machines. Encrypted offline read cache, machine enrolment and revocation, master-key rotation.
pic's side
pic_cred_get(name, buf, cap, err, errcap) in src/cred.c is pic's only credential code. Today it reads the environment; later it runs a helper command (cred get NAME) and reads its stdout, the way git uses credential helpers. Nothing is linked between the projects.