Repository navigation
Description
What happened
Every State Root ever opened leaves a permanent directory under the Runtime Host control namespace — ~/.cache/maka/runtime-hosts/<rootId>/ on Linux (see resolveRootControlNamespace in packages/storage/src/root-authority.ts) — containing only a 0-byte owner.lock. There is no reaping path anywhere in the codebase: the namespace is created with mkdir and locked, but never cleaned up.
On one long-lived machine this has accumulated to 91,026 directories (first seen 2026-07-20, still growing as of 2026-09-04). The bytes are negligible (~908 KB total), but the accumulation is unbounded and the directory itself becomes hostile to tooling — a plain glob over it fails with Argument list too long, and backup/indexing tools scan 91k dentries. Normal (non-development) usage accumulates one entry per State Root ever opened, forever.
Expected: stale control directories are reaped. The design already makes this safe — the durable State Root owner lock lives separately under state-root-owners/, and the code comment states the cache directory is disposable ("deleting a cache directory while a Host is running must never make the same State Root acquirable again", preserved by the durable lock). A reaper can e.g. attempt to acquire a directory's owner.lock on Host startup: if acquirable, no live Host holds it, and the directory can be removed after a grace period.
How to reproduce
- Run Maka (or its test suites) for some time; each new State Root mints one entry.
ls ~/.cache/maka/runtime-hosts | wc -l— count grows monotonically.- Inspect any entry: it contains only an empty
owner.lock.
Environment
- Maka version or commit: source checkout
b39e8d36ef; observed installation tracks recent main - OS and version: Ubuntu 26.04 LTS, x86_64
- Surface: Runtime Host
- Node.js version, if running from source: v26.3.0
Logs, screenshots, or additional context
$ ls -f ~/.cache/maka/runtime-hosts | wc -l
91026
$ du -sh ~/.cache/maka/runtime-hosts
908K
$ ls ~/.cache/maka/runtime-hosts/<any-entry>
owner.lock # 0 bytes
Note: development machines mint State Roots much faster (every test run / temporary workspace creates one), so the slope there is steeper than for typical users — but there is no cleanup for either.
Activity
Yx01-me commentedon Sep 4, 2026
take
Yx01-me commentedon Sep 13, 2026
Proposed Solution: Runtime Host Control Directory Reaping
I have completed a working implementation for reclaiming stale Runtime Host control directories.
Design
The cleanup process consists of three stages:
Lock validation
A directory is eligible for reclamation only when both
owner.lockand.maka-artifact-writer.lockcan be acquired exclusively.This protects active Runtime Hosts, Root Readers, and Artifact Writers from accidental deletion.
Atomic quarantine
Instead of deleting
runtime-hosts/<rootId>directly, the directory is atomically renamed to:Cleanup only operates on this quarantined path. If another Runtime Host concurrently recreates the original
<rootId>path, the newly created directory cannot be deleted by the previous cleanup operation.Background reaping
A normal Runtime Host shutdown attempts immediate cleanup.
Directories left behind by crashes are reclaimed by a later Runtime Host after that Host has already reached the ready state. The scan is streaming and bounded to 1,024 entries or 500 ms per batch, whichever comes first.
Safety Guarantees
<rootId>directory behind when cleanup is supported.<rootId>path is never recursively deleted.renameand deletion are reclaimed by a later sweep.state-root-owners/<rootId>.locklifecycle and leader-election model remain unchanged.Readiness and Scale
The reaper starts asynchronously only after the Runtime Host has reached the ready state. Therefore, a large number of stale directories does not delay Host startup.
In a WSL/ext4 test containing 100,000 directories:
Validation
The Linux/WSL implementation has been validated for:
SIGKILLfollowing quarantine<rootId>pathWindows Behavior
Native Windows may reject renaming a directory while lock-file handles inside it remain open. In that situation, the implementation safely skips reclamation instead of falling back to a close-then-delete sequence that could introduce a race.
The original issue targets Ubuntu, so the Linux/WSL implementation satisfies its current platform scope. Full native Windows reclamation would require a separate external GC gate and should be handled as a follow-up design.
Scope
This change only reclaims disposable control-plane data under
runtime-hosts/<rootId>. It does not delete State Root data or user session data.me2seeks commentedon Sep 14, 2026
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Looks good. Do you have a PR for this implementation yet?
Yx01-me commentedon Sep 14, 2026
#5268 @me2seeks this
Astro-Han commentedon Sep 18, 2026
Working on this issue, there is other half of the problem.