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_world.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Pure seeded OM-2 Visor lane 6: read-only World view |
| 3 | note (replaces src/visor/visor_world.c and src/visor/rx/visor_world_rx.c). |
| 4 | note Depends on visor.om. |
| 5 | |
| 6 | text vwld_t_unatt "world: unattached (V1 omega binary does not link the runtime; holds no authority)\n" |
| 7 | text vwld_t_att "world: attached (read-only snapshot; holds no authority)\n" |
| 8 | text vwld_t_gen " generation: (not observable)\n" |
| 9 | text vwld_t_st " staged_effects: (not visible)\n" |
| 10 | text vwld_t_objs " resident_objects: " |
| 11 | text vwld_t_rxn "\n reactions: " |
| 12 | text vwld_t_pub "\n publication_tail: " |
| 13 | text vwld_t_dig "\n digest: sha256:" |
| 14 | text vwld_t_gap "\n gap_note: " |
| 15 | text vwld_t_obj_pfx " rx:" |
| 16 | text vwld_t_at "@" |
| 17 | text vwld_t_sp " " |
| 18 | text vwld_k_res "RESIDENT" |
| 19 | text vwld_k_eph "EPHEMERAL" |
| 20 | text vwld_k_dur "DURABLE" |
| 21 | text vwld_s_live "live" |
| 22 | text vwld_s_placed "live,placed" |
| 23 | text vwld_g_unatt "V1 omega binary does not link the runtime; holds no authority" |
| 24 | text vwld_g_null "NULL world: fail closed" |
| 25 | text vwld_g_att "generation not observable; published results not observable; staged effects not visible; coherent only when quiescent" |
| 26 | text vwld_g_trunc "; object list truncated at 32" |
| 27 | text vwld_j_unatt "{\"attached\":false,\"authority\":false,\"staged_effects_visible\":false,\"generation_observable\":false,\"resident_object_count\":0,\"object_count\":0,\"gap_note\":\"V1 omega binary does not link the runtime; holds no authority\"}" |
| 28 | text vwld_j_a1 "{\"attached\":true,\"authority\":false,\"staged_effects_visible\":false,\"generation_observable\":false,\"resident_object_count\":" |
| 29 | text vwld_j_a2 ",\"object_count\":" |
| 30 | text vwld_j_a3 ",\"reaction_count\":" |
| 31 | text vwld_j_a4 ",\"publication_tail\":" |
| 32 | text vwld_j_a5 ",\"digest\":\"sha256:" |
| 33 | text vwld_j_a6 "\"}" |
| 34 | |
| 35 | global vwld_attached ulong 1 |
| 36 | global vwld_res_cnt ulong 1 |
| 37 | global vwld_obj_cnt ulong 1 |
| 38 | global vwld_rxn_cnt ulong 1 |
| 39 | global vwld_act_cnt ulong 1 |
| 40 | global vwld_pub_tail ulong 1 |
| 41 | global vwld_digest uchar 32 |
| 42 | global vwld_oid ulong 32 |
| 43 | global vwld_ogen ulong 32 |
| 44 | global vwld_opers ulong 32 |
| 45 | global vwld_oplaced ulong 32 |
| 46 | global vwld_gap uchar 256 |
| 47 | global vwld_glen ulong 1 |
| 48 | |
| 49 | fn vwld_set_gap s view uchar * to void |
| 50 | n = len s |
| 51 | if gt n 255 |
| 52 | n = 255 |
| 53 | end |
| 54 | for i ulong n bound 256 |
| 55 | put vwld_gap i get s i |
| 56 | end |
| 57 | put vwld_glen 0 n |
| 58 | end |
| 59 | |
| 60 | fn vwld_append_gap s view uchar * to void |
| 61 | cur = get vwld_glen 0 |
| 62 | n = len s |
| 63 | for i ulong n bound 256 |
| 64 | if lt add cur i 255 |
| 65 | put vwld_gap add cur i get s i |
| 66 | end |
| 67 | end |
| 68 | nn = add cur n |
| 69 | if gt nn 255 |
| 70 | nn = 255 |
| 71 | end |
| 72 | put vwld_glen 0 nn |
| 73 | end |
| 74 | |
| 75 | fn vwld_unattached to void |
| 76 | put vwld_attached 0 0 |
| 77 | put vwld_res_cnt 0 0 |
| 78 | put vwld_obj_cnt 0 0 |
| 79 | put vwld_rxn_cnt 0 0 |
| 80 | put vwld_act_cnt 0 0 |
| 81 | put vwld_pub_tail 0 0 |
| 82 | vwld_set_gap vwld_g_unatt |
| 83 | end |
| 84 | |
| 85 | fn vwld_fail_closed to void |
| 86 | put vwld_attached 0 0 |
| 87 | put vwld_res_cnt 0 0 |
| 88 | put vwld_obj_cnt 0 0 |
| 89 | put vwld_rxn_cnt 0 0 |
| 90 | put vwld_act_cnt 0 0 |
| 91 | put vwld_pub_tail 0 0 |
| 92 | vwld_set_gap vwld_g_null |
| 93 | end |
| 94 | |
| 95 | fn vwld_format_text cap ulong to long |
| 96 | ob_reset cap |
| 97 | if eq get vwld_attached 0 0 |
| 98 | ob_puts vwld_t_unatt |
| 99 | else |
| 100 | ob_puts vwld_t_att |
| 101 | ob_puts vwld_t_gen |
| 102 | ob_puts vwld_t_st |
| 103 | ob_puts vwld_t_objs |
| 104 | ob_put_u64 get vwld_res_cnt 0 |
| 105 | ob_puts vwld_t_rxn |
| 106 | ob_put_u64 get vwld_rxn_cnt 0 |
| 107 | ob_puts vwld_t_pub |
| 108 | ob_put_u64 get vwld_pub_tail 0 |
| 109 | ob_puts vwld_t_dig |
| 110 | for i ulong 32 |
| 111 | ob_put_hex_byte ulong get vwld_digest i |
| 112 | end |
| 113 | ob_puts vwld_t_gap |
| 114 | gl = get vwld_glen 0 |
| 115 | for i ulong gl bound 256 |
| 116 | ob_putc get vwld_gap i |
| 117 | end |
| 118 | ob_putc uchar 10 |
| 119 | oc = get vwld_obj_cnt 0 |
| 120 | for i ulong oc bound 32 |
| 121 | ob_puts vwld_t_obj_pfx |
| 122 | ob_put_u64 get vwld_oid i |
| 123 | ob_puts vwld_t_at |
| 124 | ob_put_u64 get vwld_ogen i |
| 125 | ob_puts vwld_t_sp |
| 126 | ps = get vwld_opers i |
| 127 | if eq ps 0 |
| 128 | ob_puts vwld_k_res |
| 129 | else |
| 130 | if eq ps 1 |
| 131 | ob_puts vwld_k_eph |
| 132 | else |
| 133 | ob_puts vwld_k_dur |
| 134 | end |
| 135 | end |
| 136 | ob_puts vwld_t_sp |
| 137 | if ne get vwld_oplaced i 0 |
| 138 | ob_puts vwld_s_placed |
| 139 | else |
| 140 | ob_puts vwld_s_live |
| 141 | end |
| 142 | ob_putc uchar 10 |
| 143 | end |
| 144 | end |
| 145 | if ne get v_ob_ovf 0 0 |
| 146 | ret -1 |
| 147 | end |
| 148 | ret long get v_ob_len 0 |
| 149 | end |
| 150 | |
| 151 | fn vwld_format_json cap ulong to long |
| 152 | ob_reset cap |
| 153 | if eq get vwld_attached 0 0 |
| 154 | ob_puts vwld_j_unatt |
| 155 | else |
| 156 | ob_puts vwld_j_a1 |
| 157 | ob_put_u64 get vwld_res_cnt 0 |
| 158 | ob_puts vwld_j_a2 |
| 159 | ob_put_u64 get vwld_obj_cnt 0 |
| 160 | ob_puts vwld_j_a3 |
| 161 | ob_put_u64 get vwld_rxn_cnt 0 |
| 162 | ob_puts vwld_j_a4 |
| 163 | ob_put_u64 get vwld_pub_tail 0 |
| 164 | ob_puts vwld_j_a5 |
| 165 | for i ulong 32 |
| 166 | ob_put_hex_byte ulong get vwld_digest i |
| 167 | end |
| 168 | ob_puts vwld_j_a6 |
| 169 | end |
| 170 | if ne get v_ob_ovf 0 0 |
| 171 | ret -1 |
| 172 | end |
| 173 | ret long get v_ob_len 0 |
| 174 | end |