feat: run snippet retention from the opencode plugin (#37) #38
Reference in New Issue
Block a user
Delete Branch "feat/rolling-retention"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #37.
knox snippets expirelanded in #36 but nothing called it. Rather than a systemd timer — a second thing to install, firing on an idle machine — retention runs from the opencode plugin while the machine is in use.The clock lives in the index
expire --every 24hconsults and updatessettings['snippets_expire_last_run']. That makes it safe for many callers:The plugin
plugins/maintenanceregisters aprompthook and runsknox snippets expire --days 7 --every 24h, fire-and-forget. The in-process 24h guard only avoids spawning a CLI that would immediately decide it is not due — the authoritative check is in knox.Registered in
opencode.json(user config, not in this repo) betweenclaimsandrecall.Tests
TestExpireSnippetsDue: first run sweeps and records; a second call inside the interval is a no-op even with work pending; past the interval it sweeps again.NextSnippetExpiryreports the next due time.go build ./... && go vet ./... && go test ./...pass.Not covered
Retention only runs when OpenCode is used. If the index should age out on an idle box, the watcher is the right owner — say so and I'll move it there instead.