# Credential files

| Contract | Status |
| --- | --- |
| Cross-process write lock, private temporary file, flush and fsync, atomic replace, `.bak` of the last good file | In place |
| Secret inventory, backup redaction | In place |
| Folders made 0700 when created, and `auth/` with each provider's folder tightened on every write; a read of a provider with no list creates no folder or lock | In place |
| ACL, owner, symlink or inode checks | Excluded |
| Permission audit and repair, revision conflicts, restore journal | Excluded |
| OS keychain, encrypted database, new env, file or exec secret backends | Excluded |

Excluded items are built only on an explicit user request. `audit_credentials` and `repair_credentials` remain as interfaces that return nothing; `expected_revision` is accepted and ignored. Existing `credential_process` is unchanged.

## Code

| File | Holds |
| --- | --- |
| `models/auth/credentials/io.py` | Locked atomic write and update, shared by `AuthStore` and `state/config.py` |
| `models/auth/credentials/inventory.py` | `SECRET_INVENTORY` |
| `models/auth/credentials/redaction.py` | Field redaction |

## Secret inventory

| Path under the state root | Secret | Backup | Delete |
| --- | --- | --- | --- |
| `config.json` | `api_keys` | redacted | clear field |
| `auth/*/*.json` | whole file | with `--include-credentials` | unlink |
| `channels/*/accounts/*/credentials.json` | whole file | with `--include-credentials` | unlink |
| `channels/*/accounts/*/access.json` | `pending`, short-lived | never | clear field |
| `mcp_servers.json` | `servers.*.env`, `.headers`, `.auth.token`, `.auth.client_secret` | redacted | clear field |
| `mcp_tokens/*.json` | whole file | with `--include-credentials` | unlink |
| `web/token` | whole file, short-lived | never | unlink |

Not secret: `channels/…/account.json`, `owner.json`, WeChat `cursor.json`, `web/access.json`. Deletion is logical; old backups keep old values until pruned.

**How peers store credentials**

| Project | Design |
| --- | --- |
| Claude Code | Secure credential storage; `apiKeyHelper` with TTL and explicit precedence |
| Codex | Optional keyring, by version and configuration |
| OpenClaw | SecretRef over env, file and exec, with preflight and audit; plaintext still allowed |
| OpenCode | Local file `~/.local/share/opencode/auth.json` |
| Hermes | Advisory locks, version fields, lock timeouts on its auth path; backup and import |
| CodeBuddy | OS credential storage, several entries |

From official documentation and pinned source snapshots: see the [feature matrix method](https://fzkuji.github.io/OpenProgram/docs/reference/design/framework-comparison/feature-matrix.html#method). OS-keychain storage is evaluated and not planned.

[Auth storage](https://fzkuji.github.io/OpenProgram/docs/reference/design/providers/auth/unified-auth-storage.html)
