fix(capsule): make component→root capability merge exhaustive (#1232) - #1381
Open
jvsteiner wants to merge 1 commit into
Open
fix(capsule): make component→root capability merge exhaustive (#1232)#1381jvsteiner wants to merge 1 commit into
jvsteiner wants to merge 1 commit into
Conversation
…d-runtime#1232) discovery.rs folded each [[component]].capabilities into the root manifest.capabilities field-by-field by hand-enumeration, silently dropping any field not listed: net_connect, uplink, kv, identity, allow_persistent, allow_prompt_injection (and bind_workers once the run-loop concurrency work lands). The security gate reads only the root, so a component-only declaration granted nothing -- no error, even though `astrid capsule show` displayed it. Replace the enumerated merge with an exhaustive CapabilitiesDef::merge_from (allowlists concatenated, flags OR-ed). It destructures the source struct with no `..` rest pattern, so adding a field fails to compile until it is handled -- this class of silent-drop bug can't recur. Adds merge_from_unions_every_field (exhaustiveness guard) and component_level_capabilities_merge_into_root (discovery-seam regression). Closes astrid-runtime#1232. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jvsteiner
marked this pull request as ready for review
July 26, 2026 12:27
Author
|
@joshuajbouw ready for review — exhaustive |
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.
Closes #1232.
Problem
discovery.rsfolds each[[component]].capabilitiesinto the rootmanifest.capabilitiesfield-by-field, by hand-enumeration — so any fieldnot explicitly listed is silently dropped. The security gate reads only the
root, so a component-only declaration of a forgotten field grants nothing, with
no error or warning (it still shows up in
astrid capsule show).Fields the old merge dropped:
net_connect,uplink,kv,identity,allow_persistent,allow_prompt_injection(andbind_workersonce therun-loop concurrency work lands). Concretely: a capsule declaring
net_connectat the component level couldn't open the outbound connections it asked for —
easy to lose an hour to.
Fix
Replace the enumerated merge with an exhaustive
CapabilitiesDef::merge_from(&mut self, other)(allowlists concatenated, flagsOR-ed). It destructures the source struct with no
..rest pattern, soadding a field to
CapabilitiesDeffails to compile there until it's handled —this class of silent-drop bug can't recur.
discovery.rsnow just callsmanifest.capabilities.merge_from(caps).Tests
merge_from_unions_every_field— two fully-populated (no..Default) structs;asserts every field unions, and the literals are themselves a compile-time
reminder when a field is added.
component_level_capabilities_merge_into_root— the discovery-seam regression:a component-only
net_connect(the field the old merge dropped) surfaces inthe root manifest.
cargo test -p astrid-capsule-types -p astrid-capsulegreen; clippy clean; rustfmt applied.🤖 Generated with Claude Code