fix(janitor): never delete DB-registered plugin install roots; log every deleted path - #334
Open
claudegoogl-sudo wants to merge 1 commit into
Open
fix(janitor): never delete DB-registered plugin install roots; log every deleted path#334claudegoogl-sudo wants to merge 1 commit into
claudegoogl-sudo wants to merge 1 commit into
Conversation
…ery deleted path The 2026-09-09 02:00Z apply reaped the live paperclip-messenger deploy tree (plugins.package_path = ~/work/paperclip-messenger-live-0.2.20): a plain-copy install has no .git and mtimes as old as its source tag, which classifyWorktree() + the age check read as an abandoned worktree. The cron log could not even name the deleted dirs. - Load plugins.package_path from the embedded Postgres (UNIX socket derived from the running postmaster, credential file enforced mode 0600, value never printed). A directory at, inside, or containing a registered root is never deletion-eligible regardless of age or git state. - Fail closed: if the registry lookup fails, worktree and /tmp pruning is disabled for that run and the reason is printed loudly (under-deleting is recoverable; deleting a live install is not). - Attribute every deletion: human output now lists every backup/run-log/ worktree/tmp path it deletes or would delete, plus per-candidate exclusion reasons (registered root, lookup-failure) and the registered-path list. Deployed copy on the host updated in the same shape (.bak kept beside it); live dry-run verified: messenger/cad/klipper/vault roots listed and the live messenger tree explicitly excluded; all other category counts unchanged. Tests: 34 existing + 9 new (hermetic via injected registry), 43/43 pass. Co-Authored-By: Paperclip <noreply@paperclip.ing>
claudegoogl-sudo
force-pushed
the
ops/janitor-registered-package-paths
branch
from
September 9, 2026 02:40
471cb5c to
c949440
Compare
Owner
Author
|
Pushed c949440: the first push failed the policy check because an explanatory comment and two test names cited an internal ticket id. All internal references are reworded to plain English (dates + description); no code paths changed. Test suite still 43/43 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
Linked Issues or Issue Description
No public issue exists for this change. The underlying problem, in bug-report fields:
What happened
The daily janitor
--applyrun classified a live plugin install directory as a stale worktree and deleted it. The install was a plain copy: no.git, and every file mtime older than the 30-day cutoff. The plugin worker restarted into a missing package and crash-looped. The cron log recorded onlyworktrees: 3/181 dirs deletedand could not name the directories.Expected behavior
A directory at, inside, or containing a path registered as a live plugin install is never deletion-eligible, whatever its age or git state. Every deleted path is named in the output.
Steps to reproduce
touch -d).plugins.package_pathin the embedded Postgres.node scripts/host-disk-janitor.mjs --dry-run. Before this change the directory is listed as a deletion candidate. After this change it is excluded with the registered root named as the reason.Version or commit
Janitor as deployed from the
ops/host-disk-janitormerge (the file is byte-identical toscripts/host-disk-janitor.mjsbefore this PR).Deployment mode
Self-hosted single host; embedded Postgres reachable over its UNIX socket only (
listen_addressesempty); janitor runs unprivileged from a cron entry.What Changed
loadRegisteredPackagePaths(): readsplugins.package_pathfrom the embedded Postgres over its UNIX socket (socket dir + port parsed frompostmaster.opts; data dir picked frompswith a preference for the instance data dir). Credential comes fromPGPASSWORDor the<dataDir>.pg-credentialfile, read only at mode 0600; the value is never printed or logged.findRegisteredOverlap(): a candidate directory that is equal to, inside, or containing a registered root is excluded. Both directions matter: deleting a parent would destroy a registered install inside it.evaluateWorktree()/evaluateTmpEntry()take the registered set and never returneligiblefor an overlapping path. Exclusion is independent of age and git state.pgdriver), worktree and/tmppruning is disabled for that run. The output prints the failure loudly and lists what would otherwise have been deleted. Backup and run-log pruning still run./tmppath deleted or would-be-deleted, one per line, plus per-candidate exclusion reasons and the full registered-path list. The JSON summary carries the same fields (prunedPaths,excludedRegistered,guardFailureExcludedPaths,registeredPackagePaths).Verification
node --test scripts/host-disk-janitor.test.mjs-> 43 pass, 0 fail (34 existing + 9 new). Existingrun()tests now inject a stub registry, so the suite is hermetic and does not need a Postgres (the real lookup fails closed by design, which would zero the worktree/tmp categories on a CI runner).touch -d "60 days ago"files. Dry-run output showedexcluded (registered package path root: ...)for the registered tree and for a parent directory containing a registered root, while an unregistered aged control stayed listed aswould delete. Fixture database dropped afterwards.Risks
/tmppruning pause for that night. Backup and run-log pruning still run, and the disk alarm is unchanged. The pause is printed loudly, so it should not fail silently.pgdriver is loaded throughcreateRequirefrom an explicit candidate list (global paperclipai module, checkoutnode_modules, barepg). If none resolves, the run fails closed rather than skipping the registry check.postmaster.optsnext to its data dir. A TCP-only deployment fails the lookup and fails closed; it never misdeletes./tmpliveness gating). Logical concerns do not overlap; whichever merges second needs a textual rebase.Model Used
Paperclip prime_local adapter (provider-routed model; the session does not expose the exact backing model id), extended thinking + tool use
Checklist
Fixes: #/Closes #/Refs #OR (b) described the issue in-PR following the relevant issue template#NNN/github.com/paperclipai/paperclipURLs)docs/...,fix/...) and contains no internal Paperclip ticket id or instance-derived details