#22 [Feature]: Add encrypted runtime cache inspection and cleanup
Originally created by: thomijasir
Originally owned by: thomijasir
Feature description
Provide supported commands for viewing cache metadata and removing old encrypted runtime cache entries.
Current behavior
Runtime cache files are managed internally. Users cannot see which environments are cached or remove entries without finding files in the data directory.
Why we need this
Cached secrets can outlive the project that created them. Users need a safe way to review cache age and remove stale data without opening or deleting internal files manually.
Proposed CLI interface
dopbase cache listdopbase cache clean --older-than 14ddopbase cache clean --alldopbase cache clean --dry-run [--older-than 14d|--all]
Expected behavior
- List server URL, project, environment, environment ID, fetch time, age, and aliases.
- Do not decrypt or display secret values for listing or cleanup decisions beyond the minimum metadata needed from the authenticated cache document.
- Default cleanup to entries older than 14 days.
- Require
--allfor deleting entries regardless of age. --dry-runprints the entries that would be removed without changing the cache.- Lock the cache during cleanup and write the remaining document atomically.
- Remove an empty cache document after its final entry is deleted.
- Support human tables and structured
--jsonoutput.
Security and compatibility
- Never print secret values, credential-derived keys, cache keys, nonces, or ciphertext.
- Keep existing server and credential isolation.
- Do not treat a corrupt cache as permission to delete it. Report the path and a safe manual recovery step.
Out of scope
- Changing runtime cache encryption.
- Cleaning saved sessions or client configuration.
- Adding cache freshness controls to
run.
Acceptance criteria
- [ ] List shows accurate metadata for every entry available to the active server and credential.
- [ ] Age cleanup removes only matching old entries.
- [ ]
--allremoves all matching entries after normal confirmation rules. - [ ] Dry run performs no writes.
- [ ] Cleanup survives concurrent CLI access without corrupting the cache.
- [ ] JSON output contains metadata and removal counts but no values.
Test scenarios
- Add cache command tests under
app/tests/cli/. - Cover empty caches, multiple entries, age boundaries, dry run, all mode, confirmation, JSON output, locking, atomic replacement, corrupt documents, and secret-value absence.
Documentation
Document cache location at a high level, metadata shown, the 14-day cleanup default, and recovery from corrupt cache files.
Dependencies
Build on the existing runtime cache locking and document format. The global non-interactive mode in [#19] governs cleanup confirmation.
Ticket changed by: dopbase