Skip to main content

Module workspace_clean

Module workspace_clean 

Source
Expand description

sqry workspace clean <root> — discover and (optionally) remove stale .sqry/, .sqry-cache, .sqry-prof, and legacy .sqry-index artifacts (cluster-E §E.4).

Dry-run-by-default. The command emits a WorkspaceCleanReport summarising every artifact below <root>, classifies each, and prints the planned-removal set. Pass --apply to actually delete the planned set; the canonical active artifact and any artifact the running daemon currently has loaded are excluded unless --force is also passed. .sqry-index.user (user-curated state — aliases, recent queries) is excluded unless --include-user-state.

§Safety

  • walkdir is constructed with follow_links(false). A symlink that resolves to a .sqry/-shaped target is recorded as SkippedArtifact { reason: SymlinkRefused } and never deleted.
  • Every discovered path is canonicalised; entries whose canonical form does not start with canonical(root) land under SkippedArtifact { reason: OutsideRoot }.
  • Removal uses fs::remove_dir_all / fs::remove_file only on canonicalised absolute paths.

§Daemon hand-off

Before discovery, the command queries the running daemon’s daemon/active-artifacts IPC method (250 ms budget) for the list of .sqry/graph directories currently loaded. Those paths get is_daemon_locked = true in the report and are excluded from the removal plan unless --force is passed. When the daemon is down the list is treated as empty and a warning surfaces in the JSON envelope.

Functions§

run
Entry point for sqry workspace clean.