feat: prune obsolete installed Beam state - #226
Merged
Conversation
ejgallego
force-pushed
the
codex/install-prune
branch
13 times, most recently
from
August 11, 2026 18:58
14a71ee to
429d4ef
Compare
ejgallego
marked this pull request as ready for review
August 11, 2026 19:39
ejgallego
force-pushed
the
codex/install-prune
branch
from
August 11, 2026 19:41
429d4ef to
c23df11
Compare
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.
This PR adds a conservative installed-state pruning workflow so repeated Beam installs no longer leave unbounded runtime snapshots and stale bundle caches behind.
lean-beam pruneis a dry run by default and verifies the installer ownership marker, acquires the installer lock before revalidating installed state, and never selects the current runtime.--bundlesadditionally selects stale-source, incomplete, or malformed bundle entries while preserving complete bundles for the current runtime source. Bundle readiness requires typed metadata, canonical workspace ownership, and regular non-symlinked artifacts.For
--apply, Beam holds the installer lock across validation, planning, and cleanup and acquires each selected bundle's build lock immediately before deletion. Cleanup is incremental: every successful removal is reported immediately, and a later failure explains that earlier reported removals remain applied.Installed runtime recognition is shared by pruning and identity reporting and distinguishes source checkouts, valid installed runtimes, stale processes, and invalid installed state. CLI and MCP identities expose
runtime_currentandruntime_errorwhere applicable, with error-specific recovery behavior documented for users and agents.The installer and Lean runtime enforce the same canonical, non-symlinked ownership-marker contract, including exactly one valid schema, owner, and root field. Reuse validates current schema-3 manifests against the exact staged layout, executable commands, and payload contents. Schema-2 manifests remain readable only for identity and safe cleanup during the documented compatibility window; reinstall never republishes them.
Control-file reads reject non-regular and symlinked marker, manifest, metadata, and lock-PID paths. Lock publication cleans up a directory it acquired if writing the owner PID fails; only an existing lock counts as contention, so permission and other lock-creation failures propagate immediately.
lean-beam ensure --holdnow exits promptly and cleanly onSIGINT.