feat: run snippet retention on a rolling schedule from the opencode plugin #37
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
knox snippets expireexists (#36) but nothing calls it, so the candidate queue refills until someone remembers to run it by hand. The alternative on the table was a systemd timer.A timer is a second thing to install, fires on an idle machine, and duplicates a schedule knox already tracks. Retention is curation, and curation happens while the agent is in use — so drive it from the plugin.
Design
knox snippets expire --every 24hruns only whensettings['snippets_expire_last_run']is at least that old, and records the run (even when nothing expired, since the window was still checked).plugins/maintenanceplugin calls it from theprompthook, fire-and-forget, with an in-process 24h guard.The clock lives in the index rather than the plugin on purpose: this plugin is one caller among several. A cron job or a human running the same command shares one schedule, and restarting OpenCode (which reloads the module) cannot cause a burst of sweeps. The in-process guard is only an optimisation, to avoid spawning a CLI that would immediately decide it is not due.
Expected
encodedsnippets are never touched; expiry stays reversible withreopen.