fix(runtime): isolate executable capsules by authority - #1487
Merged
Conversation
Signed-off-by: Joshua J. Bouw <jjb@unicity-labs.com>
joshuajbouw
marked this pull request as ready for review
August 13, 2026 20:40
Signed-off-by: Joshua J. Bouw <jjb@unicity-labs.com>
Signed-off-by: Joshua J. Bouw <jjb@unicity-labs.com>
5 tasks
joshuajbouw
added a commit
that referenced
this pull request
Aug 14, 2026
## Linked Issue Closes #1224. Refs #1197 and #1454. ## Summary Autonomous `#[astrid::run]` capsules entered their run export without an invocation principal, leaving owner KV, home/tmp, secrets, env, profile, budgets, log, and cancellation at the neutral floor. On the authority-scoped runtime architecture from #1487, this port installs the typed principal runtime owner's context before the run task is published. Explicit `SystemResident` runtimes remain neutral. ## Changes - Recognize autonomous owner context only from typed `RuntimeScope::Principal`; never infer authority from `default`, manifest shape, or first-loader state. - Require and resolve the owning principal profile for principal-resident run exports. - Derive owner home, environment, and log paths from the kernel-supplied capsule context. - Install the already UID-scoped KV, home/tmp, secrets, profile, env, budgets, log, and cancellation context before entering the guest run export. - Reject `SystemResident` and mismatched capsule RuntimeIds in the owner-context installer. - Preserve existing unstamped compatibility callers and recv-driven publisher context behavior. ## Verification - `cargo test -p astrid-capsule -- --quiet` — 633 passed - `cargo test -p astrid-kernel --lib -- --quiet` — 321 passed - `cargo clippy -p astrid-capsule --all-features -- -D warnings` - `cargo fmt --all -- --check` - `git diff --check` - Regressions prove Alice's run-loop KV survives replacement, default and Bob cannot observe or overwrite it, owner home/tmp/secrets/log/profile/env are installed, supplied-home env isolation holds, and system/wrong-capsule scopes fail closed. - Independent adversarial review: clean ## Scope This closes autonomous run-loop owner context. #1454 remains separate: the current recv ABI has no reliable handler-return boundary, so automatically restoring owner context after a publisher-scoped recv would be an approximation rather than a sound lifecycle edge. ## AI / Tool Assistance Assisted-by: Claude:Opus-4.8 Assisted-by: Codex:GPT-5 Jamie Steiner and Claude developed the original fix and tests. Codex ported and hardened the change against #1487's typed RuntimeId/RuntimeScope architecture, expanded isolation and replacement regressions, and performed adversarial review. Joshua reviewed the resulting changes and validation and authorized the signed commit, retaining responsibility for the design and merge decision. ## Checklist - [x] Linked to an issue - [x] CHANGELOG.md updated (entry under `[Unreleased]` — or `[Unreleased]` rolled into a version section for a release PR; not applicable to docs/CI-only changes) - [x] I understand every change in this PR and can explain its design, risks, and validation. - [x] I reviewed and tested any meaningful tool-generated output included in this PR. - [x] Every non-bot, non-merge commit has a matching `Signed-off-by` trailer. Signed-off-by: Joshua J. Bouw <jjb@unicity-labs.com> Co-authored-by: Joshua J. Bouw <jjb@unicity-labs.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
75 tasks
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.
Linked Issue
Closes #1486.
Prerequisite for #1380. This PR does not supersede Jamie's run-loop owner-context work: after this lands, #1380 can be rebased so its owner overlays are installed into a genuine immutable-UID principal runtime rather than a hash-shared/default-owned Store.
Summary
Astrid used the verified WASM content hash as both immutable artifact identity and mutable runtime identity. Content addressing is correct for deduplicating bytes and compilation, but sharing an executable Store, guest memory, subscriptions, processes, readiness, and cancellation across principals is not a valid authority boundary.
This separates compiled artifact reuse from live runtime ownership. Identical verified artifacts still compile once, while every principal receives a distinct executable runtime keyed by immutable
PrincipalUidand an incarnation generation. Explicit operator-owned system services remain intentional singletons.Changes
RuntimeScope,RuntimeKey, and generation-bearingRuntimeId; preserveWasmHashas artifact identity and existing wire/source UUID formats.Engine/Component/InstancePreartifacts while isolating mutable Stores, instances, pools, guest state, run tasks, resource tables, and authority overlays per principal.SystemResidentcreation and replacement to the operator/default install root and operator-owned[[uplinks]]policy; workspace config cannot widen that allowlist.Impact and sequencing
Existing capsule artifacts, manifests, WIT, and SDK contracts require no migration. On restart, executable capsules instantiate under corrected principal authority while compiled code remains deduplicated.
Once this PR lands:
main.Principal(owner_uid)runtime.Verification
cargo test -p astrid-capsule -p astrid-mcp --lib -- --quiet: 627 capsule tests passed; 124 MCP tests passed with one subprocess fixture intentionally ignored outside its driver.cargo test -p astrid-kernel --lib -- --quiet: 313 passed.cargo test -p astrid-events -p astrid-config --lib -- --quiet: 80 event and 113 config tests passed.stop().awaitreturned only after descendant absence while an unrelated peer remained available.cargo clippy -p astrid-mcp -p astrid-capsule -p astrid-events -p astrid-config -p astrid-kernel -p astrid-daemon --all-features --all-targets -- -D warningspassed.cargo check -p astrid-mcp --target aarch64-pc-windows-msvcpassed; Windows Job Object execution remains delegated to Windows CI.cargo fmt --all -- --check,git diff --check, commit signature, DCO trailer, and repository file-size limits passed.The broad workspace suite passed through the changed runtime/kernel/MCP surfaces; one unrelated pre-existing macOS seatbelt test stalled and was interrupted rather than treated as evidence for this change.
AI / Tool Assistance
Assisted-by: Codex: GPT-5
Codex assisted with the runtime-identity implementation, concurrency and teardown regressions, and adversarial review. Joshua reviewed the design and changes, directed the authority model and compatibility constraints, and validated the resulting implementation through the test, clippy, formatting, cross-compilation, and review passes listed above.
Checklist
[Unreleased]— or[Unreleased]rolled into a version section for a release PR; not applicable to docs/CI-only changes)Signed-off-bytrailer.