Skip to content

Commit ccd3894

Browse files
BunsDevCopilot
andauthored
feat(memory): add lifecycle controls (#144)
fixes #109 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cd8a4dd commit ccd3894

8 files changed

Lines changed: 1151 additions & 14 deletions

File tree

docs/advanced.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,11 @@ Additional hosted invariants:
601601
remote tombstone always applies over local content, a local tombstone is
602602
never resurrected by a pull, and a file deleted locally after a sync is not
603603
silently re-created.
604+
- `coven-code memory` exposes operator controls for hosted memory lifecycle
605+
administration: list entries by directory or hosted tenant/repo/domain,
606+
expire entries, redact/delete by id or path, delete hosted scopes, and export
607+
a tombstone-only audit ledger. The ledger includes timestamps and reason
608+
stubs but not original redacted or deleted content.
604609
- A key with an unresolved team-memory pull conflict is blocked from further
605610
sync until the persisted conflict record under `.conflicts/` is resolved.
606611
- `/review` injects the ids and trust labels of every loaded memory entry into

docs/commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,6 +1240,7 @@ are CLI-only.
12401240
| `pr-comments` | Get comments from a GitHub PR. |
12411241
| `ultraplan` | Launch the Ultraplan agentic code planner with extended thinking. |
12421242
| `stats` | Aggregate token / cost / tool stats across saved sessions (in the TUI, `/usage stats` opens the stats dialog). |
1243+
| `memory` | Operator controls for hosted/local memory lifecycle: list, expire, redact, delete, and export the tombstone audit ledger. |
12431244

12441245
---
12451246

docs/configuration.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,17 @@ Frontmatter fields:
384384
| `deleted_at` | Marks memory as deleted. Hosted review excludes deleted entries from prompt loading. |
385385
| `created_at`, `created_by`, `session_id`, `transcript_ref`, `confidence` | Optional provenance fields for audit and review artifacts. |
386386

387+
Retention defaults apply only when `expires_at` is absent. Hosted review treats
388+
the effective expiry as `created_at + default window`; malformed dates fail open
389+
the same way as explicit expiry parsing, so operators should use `YYYY-MM-DD`.
390+
391+
| Retention class | Default window | Operator behavior |
392+
|-----------------|----------------|-------------------|
393+
| `standard` | No automatic expiry | Active until explicitly expired, redacted, or deleted. |
394+
| `short_lived` | 30 days from `created_at` | Automatically excluded from hosted loads after the default window. |
395+
| `security` | 90 days from `created_at` | Used for redaction stubs and security-sensitive audit records. |
396+
| `legal_hold` | No automatic expiry | Never auto-expires; `memory expire` and `memory delete` require `--force`. |
397+
387398
Local mode tolerates missing metadata for backward compatibility. Hosted review
388399
mode treats missing trust as `unknown`, ignores expired memory, and excludes
389400
memory below the configured trust threshold. Tagged hosted memory is injected
@@ -402,6 +413,20 @@ conflict record is written for operator review instead of overwriting local
402413
memory. Hosted team-memory sync also sends tenant, installation, repo, and
403414
domain scope metadata so the server can authorize the full tuple.
404415

416+
### Memory lifecycle operator controls
417+
418+
Use `coven-code memory` to inspect and administer local and hosted memory
419+
without exposing redacted or deleted content to the model.
420+
421+
| Command | Purpose |
422+
|---------|---------|
423+
| `coven-code memory list [--dir <path>] [--tenant <id>] [--repo <id>] [--domain <name>] [--json]` | List memory id, path, retention class, trust, created time, effective expiry, and status. With no `--dir`, scans the project auto-memory directory plus hosted scopes under the Coven Code config directory. |
424+
| `coven-code memory expire <id-or-path> [--at YYYY-MM-DD] [--force]` | Set `expires_at` in frontmatter. Defaults to today and refuses `legal_hold` entries unless `--force` is present. |
425+
| `coven-code memory redact <id-or-path> --reason <text>` | Replace the file with a redaction tombstone stub via `redact_memory_file`; the original body is removed. |
426+
| `coven-code memory delete <id-or-path> --reason <text> [--force]` | Replace the file with a deletion tombstone stub. `legal_hold` entries require `--force`. |
427+
| `coven-code memory delete --scope tenant=<t>,install=<i>,repo=<r>[,domain=<d>] --reason <text> [--force]` | Remove the hosted memory directory for a scoped tenant/installation/repo/domain. Scope deletion refuses legal-hold files unless forced. |
428+
| `coven-code memory ledger [--dir <path>] [--json]` | Export tombstoned entries only: id, path, redacted/deleted timestamp, retention class, tombstone reason line, and provenance source. The ledger reads tombstone stubs and never includes original memory body content. |
429+
405430
### @include directives
406431

407432
AGENTS.md files support `@include` to pull in content from other files:

docs/src/content/configuration.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ export function render() {
9292
}
9393
}</code></pre>
9494
95+
<h2>Memory Retention</h2>
96+
<p>AGENTS.md frontmatter supports lifecycle fields for hosted review memory. <code>expires_at</code> uses <code>YYYY-MM-DD</code> and always wins over retention defaults. <code>retention_class</code> can be <code>standard</code> (no automatic expiry), <code>short_lived</code> (30 days from <code>created_at</code>), <code>security</code> (90 days), or <code>legal_hold</code> (no automatic expiry and requires <code>--force</code> for operator expiry/deletion).</p>
97+
<p>Operators can run <code>coven-code memory list</code>, <code>expire</code>, <code>redact</code>, <code>delete</code>, and <code>ledger --json</code>. Redaction and deletion write tombstone stubs; the audit ledger exports ids, timestamps, reasons, and provenance without original removed content.</p>
98+
9599
<h2>Environment Variables</h2>
96100
97101
<table>

src-rust/crates/cli/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
mod codex_oauth_flow;
1212
mod headless;
13+
mod memory_admin;
1314
mod oauth_flow;
1415
mod stream_mode;
1516
mod upgrade;
@@ -444,6 +445,11 @@ async fn main() -> anyhow::Result<()> {
444445
return run_models_command(&raw_args[2..]).await;
445446
}
446447

448+
// Fast-path: `coven-code memory ...` — inspect and administer memory lifecycle controls.
449+
if raw_args.get(1).map(|s| s.as_str()) == Some("memory") {
450+
return memory_admin::handle_memory_command(&raw_args[2..]).await;
451+
}
452+
447453
// Fast-path: named commands (`claude agents`, `claude ide`, `claude branch`, …)
448454
// Check before Cli::parse() so these names don't conflict with positional prompt arg.
449455
if let Some(cmd_name) = raw_args.get(1).map(|s| s.as_str()) {

0 commit comments

Comments
 (0)