Skip to content

Disk Space, Storage & Garbage Collection (/gc) ​

Long-running coding sessions accumulate transcripts, tool-call journals, background process logs, session scratch directories, and runtime caches. Kompile provides a single garbage-collection and storage-inspection engine (GcService + ManagedCacheCatalog) shared across three surfaces so disk accounting never drifts:

  • Inside chat: /gc (terminal and browser chat)
  • From your shell: kompile gc
  • In the browser: the /storage screen in the Web Harness (kompile chat --web), which displays a non-overlapping disk breakdown of ~/.kompile and the active project, an interactive file browser, one-click cleanup actions, conversation pin/unpin/restore, and live gc-config.json editing.

NOTE

Safe by default: Bare /gc and kompile gc always run a dry-run report — nothing is modified or deleted unless you pass --yes (or apply=true on the gc tool). Nothing runs automatically at startup unless you opt in (autoArchiveAtStartup: true).


What the harness stores on disk ​

Kompile separates user-wide state under ~/.kompile/ from repository-specific state under <project>/.kompile/ (and <project>/data/ for local RAG/crawls). Every major category has a dedicated storage layout and cleanup lifecycle:

Conversations & transcripts (~/.kompile/conversations/) ​

Each session (native Kompile or imported source__id) owns a bundle of sibling files and a session directory:

PathWhat it storesManaged by
<id>.txtHuman-readable chat transcriptchats (reversible files.tar.gz archive) / trash
<id>.ledger.jsonlStructured append-only conversation ledger (preserved across /compact)Follows owning session (chats / trash)
<id>.metrics.json, <id>.token-usage.jsonl, <id>.title, <id>.todos.json, <id>.activity, <id>.progress.jsonl, <id>.subagent.json, <id>.subagent-total.jsonPer-session token/cost ledger, title, task list, activity feed, /progress-reports, and subagent rollupsFollows owning session (chats / trash)
<id>/claude-code/<native-id>.jsonlZero-copy symlink (or .path pointer) to Claude Code's native JSONLMoved as link on archive; never traverses or deletes provider targets
.search-index.dbSQLite FTS search projection across transcriptssearch-index (drops retired rows and rebuilds from surviving sources)
.trash/<id>/…, .retired/<id>, <id>.pinnedPacked SHA-256-verified archives, retirement tombstones, and pin markerstrash (explicit opt-in only) / /gc pin & /gc restore

Tool calls, payloads & large-result caches ​

Large tool outputs and structured invocation logs live outside LLM context so compaction never discards evidence:

PathWhat it storesManaged by
~/.kompile/conversations/tool-calls/<id>.jsonlPer-session tool-call journal (powers /diffs, /stats, tool_call_catalog)Follows owning session
~/.kompile/conversations/tool-calls/details/<id>/<invocation>.json.gzFull per-invocation tool request/response payloadscompress (gzips legacy uncompressed dirs) / follows session
~/.kompile/conversations/tool-calls/all-tool-calls.jsonl, tool-usage.jsonlShared cross-session tool-call and usage journalsjournals (ToolJournalCompactor, compacts out purged sessions)
~/.kompile/conversations/<id>/result-cache/, <id>/tool-results/Cached large-output handles (fetch_result / ref:ID payloads)Follows owning session
~/.kompile/truncated-outputs/OutputTruncator spillover files for >12 KiB tool outputstemp (7-day TTL)

Process output & runtime logs ​

PathWhat it storesManaged by
<project>/.kompile/process-output/<session>/, ~/.kompile/process-output/<session>/proc-NNN.log stdout/stderr logs for background commands and buildsprocess-output (exited sessions idle >processOutputMaxIdleDays, default 7d; 12h startup sweep; active/pinned protected)
~/.kompile/logs/, <project>/.kompile/logs/Agent, subprocess (logs/subprocesses/<id>.log + .log.1), crawl, LSP (logs/lsp/), and CLI logslogs (rotated and gzip-archived per log-retention.json)
~/.kompile/logs/transcripts/<segment>/Per-session transcript log directoriesaux-state (orphaned dirs >7d after session removal)

Temp & scratch directories (no OS /tmp sprawl) ​

Kompile bans agent writes to OS /tmp and redirects temporary files into Kompile-managed directories:

PathWhat it storesManaged by
~/.kompile/conversations/<id>/tmp/Per-session scratch directory (redirect target for /tmp writes)session-tmp (idle >sessionTmpMaxIdleDays, default 7d; active/current/pinned protected)
~/.kompile/tmp/Kompile's own shared temp files and embedded Tomcat work dirs (tmp/tomcat/<pid>)session-tmp & temp (>24h; live Tomcat PIDs and lock/credential files protected)
~/.kompile/run/web-chat-attachment-*Staged web-chat attachment dirs left behind on abnormal exittemp (>24h)
conversations/.metrics-*.tmp, .search-index.db.gc-*, sessions/registry-*.tmpAbandoned atomic-write temporaries from crashed writerstemp (>24h)

Auxiliary session & enforcement state (aux-state) ​

Operational files outside conversations/ cleaned past auxMaxAgeDays (default 30 days, or 1–7 days for short-TTL files):

  • ~/.kompile/queues/queue-*.json — queued chat messages (empty queues >1d, non-empty >7d)
  • ~/.kompile/sessions/<id>/ — per-session registry/state dirs (active/current protected)
  • ~/.kompile/subagents/breakdowns/*.json — /subagent-breakdown token reports
  • ~/.kompile/web-session-state/* — Web Harness session UI state (*.lock excluded)
  • ~/.kompile/chat_input_history_* — per-session input history (>7d; main history capped at 1 MiB)
  • ~/.kompile/memory-backups/ & <project>/.kompile/memory-backups/ — snapshots kept by /gc memory (retains newest memoryBackupsKeep, default 5)
  • <project>/.kompile/enforcer-archive/<session>/ — archived turn diffs for /archive & /rollback (>7d)
  • <project>/.kompile/coordination/* — multi-agent edit-lock & mailbox state (>7d; *.lock excluded)

Quick commands ​

Inspect disk usage (dry run — always safe) ​

text
/gc                              # Inside chat: sizes every store and shows what cleanup would reclaim
bash
kompile gc                       # Same dry-run report from your shell
kompile gc report                # Explicit report action

Everyday reversible cleanup & compression ​

text
/gc run --yes                    # Clean default reversible targets (chats, logs, temp, session-tmp, process-output, aux-state, compress)
/gc compress --yes               # Losslessly compress pre-existing archives & legacy stores in place
/gc chats --older-than 14 --yes  # Archive and gzip-pack sessions idle >14 days (reversible)
/gc memory                       # Dry-run memory deduplication plan (project + global)
/gc memory apply                 # Apply memory deduplication plan

The standalone CLI mirrors the same actions (kompile gc run --yes, kompile gc compress --yes, kompile gc chats --older-than 14 --yes, kompile gc memory --yes, kompile gc drafts --yes).

Protect or restore sessions ​

text
/gc pin <session-id>             # Protect a session from age/size/count archival
/gc unpin <session-id>           # Allow a pinned session to age normally again
/gc restore <session-id>         # Unpack a packed files.tar.gz archive and auto-pin it

Compact journals & search index (or permanently purge trash) ​

text
/gc purge --yes                                    # Compacts journals & search-index (NEVER deletes conversations)
/gc purge trash --grace 7 --delete-conversations --yes   # IRREVERSIBLE: delete retired archives older than 7 days

WARNING

Conversations are never permanently deleted by default. /gc chats and /gc run only archive and compress sessions reversibly (files.tar.gz + SHA-256 manifest). /gc purge compacts journals and the search index — it refuses to delete archived conversations unless you pass both trash and --delete-conversations (allow_conversation_deletion=true on the gc tool).


What lives on disk (cleanable vs. protected stores) ​

1. Cleanable targets (GcService + GcTool) ​

Target IDIncluded in default /gc run?What it managesReversible?
chatsYesArchives and gzip-packs unpinned idle sessions into files.tar.gz + SHA-256 manifestYes (/gc restore <id>)
compressYesLosslessly compresses pre-existing archives and legacy stores in placeYes
logsYesRotated agent, subprocess, crawl, LSP, and CLI logs under ~/.kompile/logs/ and <project>/.kompile/logs/ (per log-retention.json)Gzip-archived per policy
tempYesAbandoned temp files (~/.kompile/tmp, dead Tomcat PID dirs, .metrics-*.tmp, registry-*.tmp, run/web-chat-attachment-* >24h, truncated-outputs/ >7d)Removes expired temp
session-tmpYesPer-session scratch dirs (~/.kompile/conversations/<id>/tmp) created by the /tmp write-ban redirect and aged ~/.kompile/tmp entries (protects active/current sessions; pass --session <id> to empty one session)Removes expired scratch
process-outputYesExited sessions' background process logs under <project>/.kompile/process-output/ and ~/.kompile/process-output/ idle past processOutputMaxIdleDaysRemoves expired logs
aux-stateYesStale auxiliary state (queues, stale session dirs, breakdowns, web state, enforcer diff archive, coordination, orphaned transcript logs) past auxMaxAgeDays, plus trimming old memory & deploy-jar backupsRemoves expired state
journals/gc purge defaultCompacts shared tool-call journals (ToolJournalCompactor)Irreversible compaction
search-index/gc purge defaultDrops retired rows and rebuilds .search-index.db from surviving sourcesRebuilt from sources
memoryOptionalDeduplicates project and global memory files (MemoryCompactor)Keeps backup snapshots (memoryBackupsKeep)
draftsOptionalRuns git GC on .kompile/drafts.gitCompacts git objects
cacheExplicit opt-in onlyClears Kompile-managed caches under ~/.kompile/cache/ (Vulkan, Triton, DSP plans, CDS, LSP, MCP adapters)Rebuilt on demand
external-cachesExplicit opt-in onlyClears external sibling caches (~/.nd4j, ~/.cache/nd4j, ~/.javacpp/cache, ~/.cache/huggingface, .kompile/javacpp)Rebuilt on demand
trashExplicit opt-in onlyPermanently deletes retired archives older than --grace days (minimum 1, default 7) — requires --delete-conversationsIrreversible

2. Report-only protected stores (never deleted by /gc) ​

/gc measures and reports these directories so you can see where gigabytes are going, but never deletes files from them:

StorePathWhat it holds
models~/.kompile/modelsDownloaded and staged local models (manage with kompile local-models remove)
components~/.kompile/componentsInstalled distribution components
native-libs~/.kompile/native-libsNative accelerator libraries
code-index~/.kompile/code-indexLocal code search indices
lib~/.kompile/libDistribution JARs
backups~/.kompile/backupsUser and deployment backups
agent-state~/.kompile/agent-stateAgent state and diff index

3. Managed & external runtime caches (ManagedCacheCatalog) ​

Both /gc and the Web Harness /storage view also catalog Kompile-managed caches under ~/.kompile/cache/ (including the ND4J DSP plan cache) and sibling runtime caches outside ~/.kompile:

  • ~/.nd4j and ~/.cache/nd4j
  • ~/.javacpp/cache and project-local .kompile/javacpp
  • ~/.cache/huggingface

Per-project storage (<project>/.kompile/ & data/) ​

Kompile keeps user-wide state under ~/.kompile/ and repository-specific state inside <project>/.kompile/ (and <project>/data/ when using local RAG/crawls). Running /gc inside chat, kompile gc from your repository root, or opening /storage in the Web Harness inspects both ~/.kompile/ and the active project side by side without double-counting:

Project pathWhat lives hereManaged by /gc?
<project>/.kompile/process-output/Background command and subagent logs for sessions run in this repoYes — process-output target sweeps exited sessions idle past processOutputMaxIdleDays (7 days)
<project>/.kompile/drafts.gitPer-repo bare git store holding staged draft overlays and apply recordsOptional — /gc run drafts --yes or kompile gc drafts --yes runs git GC
<project>/.kompile/agent-state/diff-index/Project-scoped diff_index edit history mined from transcripts and kompile-draft commitsProtected — report-only
<project>/.kompile/test-milestones/Immutable harness-captured and manual test milestone JSON recordsProtected — never deleted by /gc
<project>/.kompile/enforcer-archive/ & coordination/Archived turn diffs (/archive, /rollback) and multi-agent edit-lock/mailbox stateYes — aux-state sweeps entries older than 7 days (excluding *.lock)
<project>/.kompile/memory/Project-scoped MEMORY.md and typed memory filesOptional — /gc memory [apply] deduplicates and trims old snapshots (memoryBackupsKeep)
<project>/.kompile/javacpp/Project-local JavaCPP native extraction cacheCataloged in ManagedCacheCatalog and visible in Web /storage
<project>/.kompile/task-registry/Parent/child subagent task trees and transcripts for task_transcriptRetained for session/task inspection
<project>/.kompile/*.jsonProject overrides (chat-config.json, enforcer-config.json, resource-policy.json, hooks.json, lsp-check.json)Protected — never deleted by /gc
<project>/data/crawls/Local local-runtime knowledge bases, semantic-index.jsonl, and .kgraph archivesProtected — never deleted by /gc

See Projects for how project boundaries, .kompile/ overrides, and multi-project workspaces work.


Safety invariants & crash protection ​

  • File locks, writer leases & live-session PID checks: Archival and purge acquire file locks and verify live PIDs so an active chat or subprocess never loses files out from under it.
  • Verified archives: Packed chat archives bundle into files.tar.gz with a SHA-256 digest in their manifest; /gc restore <id> verifies, unpacks, and auto-pins the session.
  • Interactive ownership only: The MCP gc tool (action=report|run|purge|restore|pin|unpin) is denied to subagents — cleanup decisions belong strictly to the interactive session.

Configuration (~/.kompile/config/gc-config.json) ​

All retention defaults work out of the box. To adjust any threshold, ask the agent in chat (for example, "Archive idle chats after 14 days and cap total unpinned chat storage at 500 MB in gc-config.json"). Every field in ~/.kompile/config/gc-config.json is optional and defaults to the values below:

FieldDefaultMeaning
chatMaxAgeDays30Archive unpinned conversations idle longer than this many days (0 disables)
chatMaxTotalMb0 (off)Optional total size cap in MB for unpinned chats before oldest sessions archive
chatMaxPerSource0 (off)Optional max unpinned chats retained per source
trashGraceDays7Minimum days a retired archive stays in trash before purge trash can delete it (minimum 1)
sessionTmpMaxIdleDays7Idle days before per-session scratch (conversations/<id>/tmp) is swept (0 disables)
processOutputMaxIdleDays7Idle days before exited sessions' .kompile/process-output/ logs are swept (0 disables)
auxMaxAgeDays30Max age in days for auxiliary state (queues, breakdowns, web state, enforcer diff archive; 0 disables)
memoryBackupsKeep5Number of newest memory-compaction backup snapshots kept per scope (0 disables pruning)
libBackupsKeep2Number of newest deploy JAR backups kept per artifact in backups/lib/ (0 disables pruning)
autoArchiveAtStartupfalseOpt-in: when true, CLI startup runs a 24-hour rate-limited reversible archive+pack pass for idle unpinned chats

Released under the Apache-2.0 License.