Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/visor/visor_realization.h # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / visor / visor_realization.h` 120 lines ยท 5588 bytes Raw Blame History 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_realization.h -- Omega Visor V1, lane 5: realization lab. 19 * 20 * Wraps the EXISTING realizers (omega_realize_pure_binary, omega_program_realize 21 * compiling the program body, omega_synthesize_realization) and the machine 22 * estimate. Costs live in four separate slots and are never merged: 23 * predicted (static), estimated (machine model), measured and qualified 24 * (both ALWAYS absent in V1: no receipts are ingested). 25 * The only execution path is visor_realization_run_pure. 26 */ 27 #ifndef OMEGA_VISOR_REALIZATION_H 28 #define OMEGA_VISOR_REALIZATION_H 29 30 #include 31 #include 32 #include 33 34 #include "visor.h" 35 #include "omega_machine.h" 36 #include "omega_program.h" 37 38 typedef enum { 39 VISOR_COST_PREDICTED = 0, /* static model: instruction count, 1 cycle each */ 40 VISOR_COST_ESTIMATED = 1, /* omega_machine_estimate_latency on a machine model */ 41 VISOR_COST_MEASURED = 2, /* from a receipt: NOT available in V1 */ 42 VISOR_COST_QUALIFIED = 3 /* from a qualified gate: NOT available in V1 */ 43 } VisorCostClass; 44 45 typedef struct { 46 bool present; 47 VisorCostClass cls; 48 const char *cls_name; 49 uint64_t cycles; 50 uint32_t insn_count; 51 uint32_t code_bytes; 52 char source[128]; 53 } VisorCostItem; 54 55 typedef struct { 56 VisorCostItem predicted, estimated, measured, qualified; 57 } VisorCostView; 58 59 #define VISOR_DISASM_MAX 64 60 61 typedef struct { 62 char label[48]; /* alternatives: "direct@dgx-spark", ...; else "" */ 63 char realization_id[72]; 64 char subject_id[72]; 65 char realized_id[72]; /* real.semantic_id */ 66 char machine_id[72]; /* machine model used for estimates (entry.machine_id) */ 67 char bound_machine_id[72]; /* real.machine_id if the realizer bound one, else "none" */ 68 char machine_name[64]; 69 char target[32]; 70 uint8_t profile; 71 uint32_t code_len; 72 uint32_t insn_count; 73 char disasm[VISOR_DISASM_MAX][48]; 74 size_t disasm_count; 75 bool compatible; 76 bool runnable; /* run_pure would accept this entry */ 77 char why[256]; 78 VisorCostView cost; 79 } VisorRealizationView; 80 81 /* Return codes: 0 ok, -1 bad args / internal, -2 unsupported (why set), -3 refused to run. */ 82 int visor_realize_apply(const OmegaGraph *g, const SemanticId *apply_id, const OmegaMachineGraph *mg, 83 VisorRealizationEntry *out_entry, VisorRealizationView *out_view); 84 int visor_realize_program(const OmegaProgram *p, const OmegaMachineGraph *mg, 85 VisorRealizationEntry *out_entry, VisorRealizationView *out_view); 86 int visor_realization_view(const VisorRealizationEntry *e, const OmegaMachineGraph *mg, 87 VisorRealizationView *out); 88 int visor_realization_cost(const VisorRealizationEntry *e, const OmegaMachineGraph *mg, 89 VisorCostView *out); 90 /* Deterministic order: [0] direct@, [1] direct@, 91 * [2] synth@, [3] synth@. direct = omega_program_realize (canonical); 92 * synth = omega_synthesize_realization for that machine (verified against the 93 * semantic evaluator), additionally differentially checked 94 * against the direct realization; mismatch => compatible=false, runnable=false. */ 95 int visor_realization_alternatives(const OmegaProgram *p, const OmegaMachineGraph *mg, 96 VisorRealizationView *out, size_t max, size_t *count); 97 /* Same, also returning the entries (entries may be NULL). */ 98 int visor_realization_alternatives_ex(const OmegaProgram *p, const OmegaMachineGraph *mg, 99 VisorRealizationEntry *entries, VisorRealizationView *out, 100 size_t max, size_t *count); 101 int visor_realization_compare(const VisorRealizationView *a, const VisorRealizationView *b, 102 char *out, size_t n); 103 int visor_realization_why(const VisorRealizationView *v, char *out, size_t n); 104 int visor_realization_format_text(const VisorRealizationView *v, char *out, size_t n); 105 int visor_realization_format_json(const VisorRealizationView *v, char *out, size_t n); 106 int visor_cost_format_text(const VisorCostView *c, char *out, size_t n); 107 int visor_cost_format_json(const VisorCostView *c, char *out, size_t n); 108 109 /* Execute a pure AArch64 realization natively: f(a,b,c), missing args = 0. 110 * Refuses (-3): Blackwell / unknown targets, non-V8A profile, code failing 111 * aarch64_validate_code_buffer, any instruction other than 112 * ADD/SUB/MUL/AND/ORR/EOR/MOVZ/MOVK/RET, no trailing RET, argc > 3, 113 * or a non-aarch64 host. */ 114 int visor_realization_run_pure(const VisorRealizationEntry *e, const uint64_t *args, size_t argc, 115 uint64_t *out); 116 117 /* Disassemble with aarch64_decoder (deterministic). Returns line count. */ 118 size_t visor_disasm(const uint8_t *code, size_t len, char lines[][48], size_t max); 119 120 #endif /* OMEGA_VISOR_REALIZATION_H */