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_verify.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 | /* Omega Visor V1 - lane 4: structured verification report. |
| 18 | * |
| 19 | * This is a VIEW over the existing verifier (src/omega_verify.c V0/V1/V2 and |
| 20 | * the same tiers omega_program_verify runs). It does not add a verifier: each |
| 21 | * row is one call into an existing check, reported with its own counts. |
| 22 | * |
| 23 | * Rows, fixed order: |
| 24 | * 0 STRUCTURAL omega_verify_v0_structural (graph for objects; realization for programs) |
| 25 | * 1 TYPE omega_validate_object on the queried object / omega_program_validate_contract |
| 26 | * 2 INVARIANTS omega_verify_v2_properties (reference-evaluator algebra; graph-independent) |
| 27 | * 3 REALIZATION omega_verify_v1_differential, only where its fixed reference |
| 28 | * model (a+b)-c applies: OP_ADD pure-binary realizations (c=0) and |
| 29 | * SUB(ADD(a,b),c) applies. Otherwise NOT_RUN with the reason. |
| 30 | * 4 AUTHORITY what the reachable graph REQUIRES (effects / capability refs). |
| 31 | * Reports REQUIRED or NONE. Never grants, mints or checks a grant. |
| 32 | * 5 MACHINE realization target profile (and machine id if bound) vs machine model. |
| 33 | * |
| 34 | * `passed` is true only when at least one row ran and no row FAILED. |
| 35 | * Fixed storage, no allocation, fail closed. */ |
| 36 | #ifndef VISOR_VERIFY_H |
| 37 | #define VISOR_VERIFY_H |
| 38 | |
| 39 | #include <stdbool.h> |
| 40 | #include <stddef.h> |
| 41 | #include <stdint.h> |
| 42 | |
| 43 | #include "omega_types.h" |
| 44 | #include "omega_realize.h" |
| 45 | #include "omega_machine.h" |
| 46 | #include "omega_program.h" |
| 47 | |
| 48 | typedef enum { VISOR_CHECK_PASS, VISOR_CHECK_FAIL, VISOR_CHECK_NOT_RUN } VisorCheckStatus; |
| 49 | |
| 50 | enum { |
| 51 | VISOR_ROW_STRUCTURAL = 0, |
| 52 | VISOR_ROW_TYPE = 1, |
| 53 | VISOR_ROW_INVARIANTS = 2, |
| 54 | VISOR_ROW_REALIZATION = 3, |
| 55 | VISOR_ROW_AUTHORITY = 4, |
| 56 | VISOR_ROW_MACHINE = 5, |
| 57 | VISOR_ROW_COUNT = 6 |
| 58 | }; |
| 59 | |
| 60 | typedef struct { |
| 61 | const char *name; |
| 62 | VisorCheckStatus status; |
| 63 | uint32_t checks; |
| 64 | uint32_t fails; |
| 65 | char detail[256]; |
| 66 | } VisorVerifyRow; |
| 67 | |
| 68 | typedef struct { |
| 69 | VisorVerifyRow rows[8]; |
| 70 | size_t row_count; |
| 71 | bool passed; |
| 72 | char first_violation[256]; |
| 73 | char object_involved[72]; /* "sha256:<hex>" only when the failure is on a known object */ |
| 74 | char expected[128]; |
| 75 | char observed[128]; |
| 76 | /* AUTHORITY row facts (requirements only, never a grant). */ |
| 77 | bool authority_required; |
| 78 | uint32_t effect_count; |
| 79 | uint32_t capability_ref_count; |
| 80 | } VisorVerifyReport; |
| 81 | |
| 82 | /* Returns 0 when the report was produced (read out->passed for the verdict), |
| 83 | * -1 on invalid arguments (out is zeroed with passed=false when out != NULL). */ |
| 84 | int visor_verify_object(const OmegaGraph *g, const SemanticId *id, |
| 85 | const RealizationObject *real_or_null, |
| 86 | const OmegaMachineGraph *mg_or_null, |
| 87 | VisorVerifyReport *out); |
| 88 | int visor_verify_program(const OmegaProgram *p, VisorVerifyReport *out); |
| 89 | |
| 90 | const char *visor_check_status_name(VisorCheckStatus s); /* "PASS" / "FAIL" / "NOT_RUN" */ |
| 91 | |
| 92 | /* Deterministic renderings. Return bytes written (excl. NUL) or -1 if truncated/invalid. */ |
| 93 | int visor_verify_format_text(const VisorVerifyReport *r, char *out, size_t n); |
| 94 | int visor_verify_format_json(const VisorVerifyReport *r, char *out, size_t n); |
| 95 | |
| 96 | #endif /* VISOR_VERIFY_H */ |