omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / src / visor / visor_effect_request.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 |
| 2 | * Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
| 18 | * visor_effect_request.h -- Omega Visor V1, lane 7: effect requests. |
| 19 | * |
| 20 | * Invariant: THE VISOR CAN ASK. THE VISOR CANNOT GRANT. |
| 21 | * |
| 22 | * A VisorEffectRequest is a read-only description of an existing canonical |
| 23 | * KIND_EFFECT object, in the shape of an unauthorized EffectIntent. It is a |
| 24 | * question, never an answer: |
| 25 | * |
| 26 | * Visor -> EffectIntent -> AEGIS/PHYSICS authority -> bounded execution -> receipt |
| 27 | * |
| 28 | * Rules (spec/visor-authority.md): |
| 29 | * - `authorized` is always false. No function in the Visor sets it, and this |
| 30 | * header exports no setter. A consumer must never read `authorized == true` |
| 31 | * as permission: the only thing that may act on a request is the existing |
| 32 | * authority path OUTSIDE the Visor (rx_aegis_evaluate policy, the capability |
| 33 | * root validating the presented reference, the generation barrier's replay |
| 34 | * record, the World's publish checks). The Visor links none of them. |
| 35 | * - Building a request never mutates the graph. It recomputes the canonical |
| 36 | * digest and refuses (-1) an object whose stored SemanticId no longer |
| 37 | * matches its contents (edited after it was named/authorized). |
| 38 | * - The capability slot/generation/ref fields are copied as data. The Visor |
| 39 | * does not validate, mint, inspect or hold capabilities. |
| 40 | * |
| 41 | * This file is physics-free and runtime-free: it depends only on omega_types, |
| 42 | * omega_canonical, omega_validate, omega_core (lookup) and sha256. |
| 43 | */ |
| 44 | #ifndef OMEGA_VISOR_EFFECT_REQUEST_H |
| 45 | #define OMEGA_VISOR_EFFECT_REQUEST_H |
| 46 | |
| 47 | #include <stdbool.h> |
| 48 | #include <stddef.h> |
| 49 | #include <stdint.h> |
| 50 | |
| 51 | #include "omega_types.h" |
| 52 | |
| 53 | #define VISOR_EFFECT_PARAM_MAX OMEGA_EFFECT_PARAM_MAX |
| 54 | #define VISOR_EFFECT_STATUS_UNAUTHORIZED "UNAUTHORIZED_REQUEST" |
| 55 | #define VISOR_EFFECT_ROUTE \ |
| 56 | "Visor -> EffectIntent -> AEGIS/PHYSICS authority -> bounded execution -> receipt" |
| 57 | |
| 58 | typedef struct { |
| 59 | SemanticId effect_id; /* id of the KIND_EFFECT object asked about */ |
| 60 | uint16_t resource_class; |
| 61 | uint16_t operation_code; |
| 62 | uint32_t capability_slot; /* copied, never validated here */ |
| 63 | uint64_t capability_generation; /* full 64-bit AIENOS generation; copied, never validated here */ |
| 64 | SemanticId capability_ref; /* copied, never resolved here */ |
| 65 | uint16_t param_len; |
| 66 | uint8_t param_bytes[VISOR_EFFECT_PARAM_MAX]; |
| 67 | uint8_t request_digest[32]; /* sha256 over the canonical effect object encoding */ |
| 68 | bool authorized; /* ALWAYS false; there is no setter */ |
| 69 | char status[64]; /* "UNAUTHORIZED_REQUEST" */ |
| 70 | char route[128]; /* VISOR_EFFECT_ROUTE */ |
| 71 | } VisorEffectRequest; |
| 72 | |
| 73 | /* Build a request from an existing KIND_EFFECT object in `g`. |
| 74 | * Returns 0 on success; -1 (and *out zeroed, authorized=false) when the id is |
| 75 | * missing, the object is not KIND_EFFECT, omega_validate_object rejects it, |
| 76 | * the payload is not a valid 178-byte v2 effect payload (omega_effect_read: |
| 77 | * wrong length, legacy v1, resource 0, param_len > 128, non-zero padding), the object has no id, |
| 78 | * or the recomputed canonical digest differs from its stored SemanticId. |
| 79 | * Never mutates `g`. */ |
| 80 | int visor_effect_request_build(const OmegaGraph *g, const SemanticId *effect_object_id, |
| 81 | VisorEffectRequest *out); |
| 82 | |
| 83 | /* *requires_authority = true when the graph reachable from `id` (relations and |
| 84 | * payload references) contains a KIND_EFFECT object or a TYPE object tagged |
| 85 | * TYPE_CAPABILITY_REF / TYPE_EFFECT_INTENT_REF / TYPE_EFFECT_RECEIPT_REF. |
| 86 | * Returns 0, or -1 when `id` or any referenced non-zero id is missing from the |
| 87 | * graph (fail closed: callers must refuse to run on -1 as well as on true). */ |
| 88 | int visor_effect_request_classify(const OmegaGraph *g, const SemanticId *id, |
| 89 | bool *requires_authority); |
| 90 | |
| 91 | /* Deterministic rendering. Return 0, or -1 on bad args / truncation. */ |
| 92 | int visor_effect_request_format_text(const VisorEffectRequest *r, char *out, size_t n); |
| 93 | int visor_effect_request_format_json(const VisorEffectRequest *r, char *out, size_t n); |
| 94 | |
| 95 | #endif /* OMEGA_VISOR_EFFECT_REQUEST_H */ |