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 / train / omega-llm / tools / controller / policy.om
| 1 | note Seeded Omega supervised controller for initial tool choice and retry decisions. |
| 2 | note Model rows are five decision contexts by eight feature groups plus one pooled group. |
| 3 | text cpmagic "OCP1" |
| 4 | text ctarray " view " |
| 5 | text ctleft " left " |
| 6 | text ctdata " data " |
| 7 | text ctthen "then " |
| 8 | text cthalf "half " |
| 9 | text ctsquare "square " |
| 10 | text cttwice "twice " |
| 11 | text ctthree "three plus" |
| 12 | global cpvotes ulong 90 |
| 13 | fn hastext p view uchar * needle view uchar * to bool |
| 14 | if lt len p len needle |
| 15 | ret false |
| 16 | end |
| 17 | for i ulong add 1 sub len p len needle |
| 18 | ok = true |
| 19 | for j ulong len needle |
| 20 | if ne get p add i j get needle j |
| 21 | ok = false |
| 22 | break |
| 23 | end |
| 24 | end |
| 25 | if ok |
| 26 | ret true |
| 27 | end |
| 28 | end |
| 29 | ret false |
| 30 | end |
| 31 | fn cpfeatures p view uchar * to ulong |
| 32 | group = ulong 0 |
| 33 | if hastext p ctarray |
| 34 | group = 1 |
| 35 | end |
| 36 | if or hastext p ctleft hastext p ctdata |
| 37 | group = add group 2 |
| 38 | end |
| 39 | if or hastext p ctthen or hastext p cthalf or hastext p ctsquare or hastext p cttwice hastext p ctthree |
| 40 | group = add group 4 |
| 41 | end |
| 42 | ret group |
| 43 | end |
| 44 | fn cell stage ulong group ulong to ulong |
| 45 | ret mul 2 add group mul 9 stage |
| 46 | end |
| 47 | fn addvote stage ulong group ulong choice ulong to void |
| 48 | i = add cell stage group choice |
| 49 | put cpvotes i add 1 get cpvotes i |
| 50 | j = add cell stage 8 choice |
| 51 | put cpvotes j add 1 get cpvotes j |
| 52 | end |
| 53 | fn retryctx route ulong status ulong to ulong |
| 54 | ret add add 1 mul 2 route status |
| 55 | end |
| 56 | fn cpbit b bool to ulong |
| 57 | if b |
| 58 | ret 1 |
| 59 | end |
| 60 | ret 0 |
| 61 | end |
| 62 | fn cptrain j ulong to void |
| 63 | group = ulong get wdsrc j |
| 64 | dp = ulong get wdsrc add j 1 |
| 65 | ap = ulong get wdsrc add j 2 |
| 66 | dh = ulong get wdsrc add j 3 |
| 67 | ah = ulong get wdsrc add j 4 |
| 68 | d = and eq dp 2 eq dh 2 |
| 69 | a = and eq ap 2 eq ah 2 |
| 70 | if ne d a |
| 71 | if a |
| 72 | addvote 0 group 1 |
| 73 | else |
| 74 | addvote 0 group 0 |
| 75 | end |
| 76 | end |
| 77 | if lt dp 2 |
| 78 | addvote retryctx 0 dp group cpbit a |
| 79 | end |
| 80 | if lt ap 2 |
| 81 | addvote retryctx 1 ap group cpbit d |
| 82 | end |
| 83 | end |
| 84 | fn cppredict stage ulong group ulong to ulong |
| 85 | i = cell stage group |
| 86 | if lt add get cpvotes i get cpvotes add i 1 4 |
| 87 | i = cell stage 8 |
| 88 | end |
| 89 | other = get cpvotes add i 1 |
| 90 | if ne stage 0 |
| 91 | other = mul 4 other |
| 92 | end |
| 93 | ret cpbit gt other get cpvotes i |
| 94 | end |
| 95 | fn cpdump to void |
| 96 | wdot cpmagic |
| 97 | for i ulong len cpvotes |
| 98 | v = get cpvotes i |
| 99 | if gt v 65535 |
| 100 | exit 72 |
| 101 | end |
| 102 | wdoc and v 255 |
| 103 | wdoc shr v 8 |
| 104 | end |
| 105 | wdoflush 1 |
| 106 | end |
| 107 | fn cprestore arg ulong to void |
| 108 | wdpclr |
| 109 | wdpa arg |
| 110 | n = wdload |
| 111 | if ne n 184 |
| 112 | exit 72 |
| 113 | end |
| 114 | for j ulong len cpmagic |
| 115 | if ne get wdsrc j get cpmagic j |
| 116 | exit 72 |
| 117 | end |
| 118 | end |
| 119 | for i ulong len cpvotes |
| 120 | k = add 4 mul 2 i |
| 121 | put cpvotes i add ulong get wdsrc k shl ulong get wdsrc add k 1 8 |
| 122 | end |
| 123 | end |