feat: intern region entry content at the runtime boundary - #3
Open
a-programmers-programmer wants to merge 7 commits into
Open
feat: intern region entry content at the runtime boundary#3a-programmers-programmer wants to merge 7 commits into
a-programmers-programmer wants to merge 7 commits into
Conversation
The `lev run` error hint suggested `lev run agents/coder "task"`, wrong twice: the agents/ path form no longer resolves from a checkout, and the task is a -t flag, not positional. It now suggests `lev run coder -t "task"`. The launchd service label was ai.sunforge.leviath, the last user-visible string from the organization the project moved off of. It is now dev.leviath.daemon, and because a label rename would otherwise strand an already-supervised daemon under the old name, install and uninstall also boot out and delete any registration listed in LEGACY_SERVICE_LABELS. The cleanup actions are pure data in the tested daemon_service core; running them stays in the binary with the rest of the subprocess I/O. Linux is unaffected (its unit was always leviath.service). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Km9mfcU1ezK2HgB9SJa2R2
First version to ride the automated pipeline end to end: alpha builds it, beta and prod promote it, and prod's publish-crates job pushes all twelve crates to crates.io from the promoted commit. Carries the launch cleanup (service label migration, corrected run hint, refreshed crate pages) to the registry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Km9mfcU1ezK2HgB9SJa2R2
C-suite agents (CTO, TL, bottleneck-investigator) need to read files beyond their workdir — design docs, run archives, other agent blueprints. Without this, they fall back to shell (defeating the sandbox), or require workdir = filesystem root. Adds: - ReadPathsConfig ([read_paths].allow) in agent.leviath blueprints - ReadPathEntry enum: Exact, Glob (glob: prefix), Regex (regex: prefix) - resolve_within fallback to read_paths when workdir check fails - Only applies to read_file/read_files; writes stay sandboxed - Symlink validation against matched entry roots Fixes: # (to be filed)
Reworks the [read_paths] allowlist so it fits the repo's tighten-only invariant and cannot be used to widen an agent's reach past what the user granted. - Reads and writes no longer share one resolver. read_file/read_files/ list_dir get a new resolve_read() with the allowlist fallback; write_file and edit_file stay confined to the workdir. - glob/regex entries match the symlink-resolved canonical path (the previous resolves_within(p, p) check was a self-comparison, always true). Regexes are auto-anchored; Windows matching is case-insensitive with the \\?\ prefix stripped. Entry matching moves to a new leviath-core::read_paths module. - A blueprint's declarations are inert unless the user's config grants them: [security] read_paths, [agent_read_paths.<name>], or the allow_blueprint_read_paths override. Ungranted declarations warn at spawn with the exact stanza to add. - [read_paths] is now parsed by manifest.rs (it was never read before, so the feature was inert through `lev run`); invalid entries are hard errors. - ~/ expands via LEVIATH_HOME-aware home_dir(); bare relative entries resolve against the workdir; a new `lev run --workdir` sets that workdir. - Read tools are classified Private when a grant is active. Capabilities are surfaced in `lev add` and `lev validate`; docs updated in SECURITY.md and the security/agents/cli pages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`/..` is not absolute on Windows, so the workdir join reshaped it and the "cannot be resolved" bail in resolve_outside never fired there, leaving exec.rs:142 uncovered on windows-latest. Drive it with a leading `..` against an empty base, which yields a leading ParentDir on every platform. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…base The prior fix (`../x` against an empty base) still missed exec.rs:142 on windows-latest: an empty base is not absolute there and the join reshapes it so pop() never fails. Mirror resolve_rejects_excessive_parent_dir_traversal instead - a relative base "wd" gives exactly one leading Normal component with no platform-specific prefix, so the first `..` pops it and the second pops an empty accumulator, firing the bail on every OS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a-programmers-programmer
force-pushed
the
feature/intern-region-content-v3
branch
from
August 1, 2026 03:26
0166474 to
7537583
Compare
Domain Region APIs stay pure (no ContentInterner parameter). A World-scoped ContentInternerRes is cloned onto each ContextWindow at spawn; write and restore paths intern, then insert_entry. - RegionEntry stores private InternedString; callers see &str only - add_entry / upsert allocate uniquely; insert_entry is the runtime edge - No process-global table — distinct interners never share - Snapshots remain plain strings; restore re-interns through the window
a-programmers-programmer
force-pushed
the
feature/intern-region-content-v3
branch
from
August 1, 2026 03:28
7537583 to
de5d2eb
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.
Summary
Fleets of agents with identical pinned / system material currently pay N heap copies of the same text because
RegionEntry.contentis an ownedString. This PR makes entry text anInternedString(Arc<str>) and interns only at the runtime boundary, so identical strings share one allocation within a World.Commit:
de5d2ebon top of currentGEMISIS/leviathmain.Architecture
Separation of concerns
ContentInternerContentInternerResContextWindowRegionRegionEntryInternedString; public API is plain&strDesign details
Region::add_entry/upsert_by_keytakeimpl AsRef<str>and allocate uniquely. Domain tests never mention an interner.ContextWindowwrite paths callRegionEntry::internedthenRegion::insert_entry. Convenience writers delegate toinsert_entry/insert_tainted_entry(DRY).Out of scope
Test plan
cargo test -p leviath-core --lib(656 tests)cargo test -p leviath-runtime --lib(769 tests)cargo test -p leviath-runtime --test context_management(18 tests)cargo clippy -p leviath-core -p leviath-runtime --all-targets -- -D warningscargo fmt --all -- --checkshares_content_with; distinct interners do not share; domainadd_entryneeds no internerFiles (18, clean vs GEMISIS main)
crates/leviath-core/src/intern.rsContentInterner+InternedStringcrates/leviath-core/src/region.rsinsert_entrycrates/leviath-runtime/src/content_interner.rsContentInternerResResourcecrates/leviath-runtime/src/components.rscrates/leviath-runtime/src/{world,pipeline/transition,restore}.rscontent()/content_owned()accessorsUpstream PR not opened yet — waiting for go.