aien-architecture-mv
Canonical architecture for the AIEN ecosystem: flows, boundaries, ADRs, and the map from design to implementation repositories.
Brought by drakestapleton
aien-architecture-mv / formal / invariants / capability-attenuation-v1.toml
| 1 | schema_version = 0 |
| 2 | id = "AIEN.INV.CAP.ATTENUATION.V1" |
| 3 | version = 1 |
| 4 | status = "SEEDED" |
| 5 | |
| 6 | statement = """ |
| 7 | A valid delegated child capability never possesses authority that its valid parent does not possess. \ |
| 8 | Concretely: the child's scope is contained in the parent's scope; the child's expiry is no later than \ |
| 9 | the parent's expiry; the child's remaining delegation depth is strictly less than the parent's; and a \ |
| 10 | capability with zero remaining delegation depth cannot delegate. Delegation from an invalid parent \ |
| 11 | (expired or revoked) is refused.""" |
| 12 | |
| 13 | assumptions = [ |
| 14 | "Cryptographic identity: the signature or MAC binding a capability to its fields is sound and the signing secret is not leaked. Crypto correctness is not proven here.", |
| 15 | "The capability graph has no cycles (parents are created before children).", |
| 16 | "A scope containment relation exists per scope kind and is the single definition of 'authority subset'.", |
| 17 | ] |
| 18 | |
| 19 | semantic_types = ["Capability", "Scope", "Expiry", "DelegationDepth", "Holder", "CapabilityGraph"] |
| 20 | |
| 21 | oracle_models = ["lean"] |
| 22 | |
| 23 | evidence_requirements = [ |
| 24 | "positive corpus of accepted delegations", |
| 25 | "negative corpus of refused delegations", |
| 26 | "deliberate privilege-expansion mutant that must not survive", |
| 27 | "differential agreement between Rust and C implementations on the shared corpus where their models overlap", |
| 28 | "existing implementation unit tests keep passing", |
| 29 | ] |
| 30 | |
| 31 | required_counterexamples = ["scope_expansion", "expiration_extension", "delegation_depth_increase"] |
| 32 | |
| 33 | omega_takeover_condition = """ |
| 34 | Omega expresses the containment, expiry, and depth relations as native propositions, accepts the positive \ |
| 35 | corpus, rejects the negative corpus, kills the required counterexample mutants, and emits a canonical \ |
| 36 | proof/evidence identity that the gates consume, with Lean absent.""" |
| 37 | |
| 38 | [[positive_examples]] |
| 39 | name = "narrower_filesystem_prefix" |
| 40 | description = "Parent holds a filesystem scope for /a; child asks for /a/b with depth one lower and the same expiry. Accepted." |
| 41 | |
| 42 | [[positive_examples]] |
| 43 | name = "read_only_from_read_write" |
| 44 | description = "Parent holds read-write filesystem scope; child asks for read-only on the same prefix. Accepted." |
| 45 | |
| 46 | [[positive_examples]] |
| 47 | name = "equal_scope" |
| 48 | description = "Child scope equals parent scope. Accepted (containment is non-strict)." |
| 49 | |
| 50 | [[negative_examples]] |
| 51 | name = "write_from_read_only" |
| 52 | description = "Parent filesystem scope is read-only; child asks for read-write. Refused." |
| 53 | |
| 54 | [[negative_examples]] |
| 55 | name = "delegate_at_depth_zero" |
| 56 | description = "Parent has delegation depth zero. Any child derivation is refused." |
| 57 | |
| 58 | [[negative_examples]] |
| 59 | name = "different_scope_kind" |
| 60 | description = "Parent is a Network scope, child asks for a Filesystem scope. Refused (only a system-admin parent contains every kind)." |
| 61 | |
| 62 | [[counterexamples]] |
| 63 | name = "scope_expansion" |
| 64 | description = "A child whose scope is not contained in the parent's is accepted (wider path, wider host, higher token or depth limit, write from read-only)." |
| 65 | |
| 66 | [[counterexamples]] |
| 67 | name = "expiration_extension" |
| 68 | description = "A child that outlives its parent is accepted." |
| 69 | |
| 70 | [[counterexamples]] |
| 71 | name = "delegation_depth_increase" |
| 72 | description = "A child with remaining delegation depth greater than or equal to the parent's is accepted, or a depth-zero parent delegates." |
| 73 | |
| 74 | [[counterexamples]] |
| 75 | name = "invalid_parent_delegates" |
| 76 | description = "An expired or revoked parent successfully derives a child." |
| 77 | |
| 78 | [[implementation_surfaces]] |
| 79 | repo = "aien-dev/aienux" |
| 80 | path = "crates/aienos-aegis/src/capability.rs" |
| 81 | kind = "production" |
| 82 | observed_at = "2ee61b4b158a385c5fcf2c925a625ac043babb21" |
| 83 | note = "Rust AEGIS capability graph: CapabilityScope::contains, CapabilityGraph::derive_child_token." |
| 84 | |
| 85 | [[implementation_surfaces]] |
| 86 | repo = "aien-dev/aienux" |
| 87 | path = "native/capability/aienos_capability.c" |
| 88 | kind = "reference" |
| 89 | observed_at = "2ee61b4b158a385c5fcf2c925a625ac043babb21" |
| 90 | note = "C capability authority (rights bitmask, generation slots). A different model from the Rust one; read only by grep for this manifest, not audited. Needs its own review before FORMAL-3." |
| 91 | |
| 92 | [[observations]] |
| 93 | surface = "crates/aienos-aegis/src/capability.rs" |
| 94 | text = """ |
| 95 | CapabilityToken fields: id, parent_id (optional), issuer, holder, scope, delegation_depth (u32), \ |
| 96 | valid_until_utc (u64), signature (32 bytes, HMAC-SHA256 over the other fields under a graph master secret).""" |
| 97 | |
| 98 | [[observations]] |
| 99 | surface = "crates/aienos-aegis/src/capability.rs" |
| 100 | text = """ |
| 101 | derive_child_token takes no expiry or depth argument. The child always gets valid_until_utc equal to the \ |
| 102 | parent's and delegation_depth equal to parent depth minus one. So 'child expiry <= parent expiry' holds by \ |
| 103 | construction as equality, and 'child depth < parent depth' holds by construction as exactly one less.""" |
| 104 | |
| 105 | [[observations]] |
| 106 | surface = "crates/aienos-aegis/src/capability.rs" |
| 107 | text = """ |
| 108 | derive_child_token order: look up parent (TokenNotFound), validate parent (revoked, ancestor revoked, \ |
| 109 | expired, bad signature), refuse if parent depth is 0 (DelegationDepthExceeded), refuse if \ |
| 110 | parent.scope.contains(child_scope) is false (ScopeExceeded). The holder argument is not checked against \ |
| 111 | the parent's holder; AegisError::UnauthorizedAgent exists but derive_child_token does not return it.""" |
| 112 | |
| 113 | [[observations]] |
| 114 | surface = "crates/aienos-aegis/src/capability.rs" |
| 115 | text = """ |
| 116 | CapabilityScope::contains (the subset relation), per kind: SystemAdmin contains everything. Filesystem: \ |
| 117 | child path_within parent prefix (lexical, absolute, no '..' components) and (read_only equal, or child is \ |
| 118 | read_only). Network: host equal or parent '*', and port equal or parent port 0. Model: model_name equal or \ |
| 119 | parent '*', and child max_tokens <= parent. World: child max_depth <= parent. StandingFetch: host equal or \ |
| 120 | parent '*'. Custom: namespace equal and (action equal or parent '*'). Any other pair is false. In particular \ |
| 121 | Device scope has no arm, so a Device parent contains no Device child (only a SystemAdmin parent does), and \ |
| 122 | a SystemAdmin child is contained only by a SystemAdmin parent.""" |
| 123 | |
| 124 | [[observations]] |
| 125 | surface = "crates/aienos-aegis/src/capability.rs" |
| 126 | text = """ |
| 127 | Expiry is inclusive of the boundary: a token is expired when now_utc > valid_until_utc, so now == valid_until_utc is still valid.""" |
| 128 | |
| 129 | [[observations]] |
| 130 | surface = "crates/aienos-aegis/src/capability.rs" |
| 131 | text = """ |
| 132 | derive_child_token does not reject a child_id that already exists; the new token replaces the old one in the \ |
| 133 | tokens map and the child id is appended to the parent's child list again. Whether this matters for the invariant \ |
| 134 | is open (it affects identity uniqueness, not attenuation).""" |
| 135 | |
| 136 | [[observations]] |
| 137 | surface = "native/capability/aienos_capability.c" |
| 138 | text = """ |
| 139 | Grep-level only. The C authority uses a rights bitmask (a child may not set rights its authority lacks: AIENOS_CAP_ERR_AMPLIFY), \ |
| 140 | a fixed maximum chain depth AIENOS_CAP_MAX_DEPTH = 8 counted from the root (not a per-token decreasing counter), \ |
| 141 | and lease_expiry where 0 means no expiry; a child lease may not exceed the authority's lease. Expiry is '>=' there \ |
| 142 | (clock >= lease_expiry is expired), unlike the Rust '>' boundary.""" |
| 143 | |
| 144 | [[observations]] |
| 145 | surface = "PLAN.md section 9 versus code" |
| 146 | text = """ |
| 147 | divergence: the plan states 'child expiration <= parent expiration' and 'child delegation depth < parent delegation depth' as properties to prove. \ |
| 148 | The Rust code satisfies them by construction (equality, and parent minus one). The C code has a different depth model (absolute cap) \ |
| 149 | and a different expiry boundary. The neutral statement therefore says 'no later' and 'strictly less remaining depth' and lists the C model's \ |
| 150 | difference as an open reconciliation item; it is not assumed to be the same rule.""" |