interplane.Get Omega
Read in your language

hop

Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.

Brought by drakestapleton

branch main Branches Tags History

hop / Omega / hopfact.om

485 lines · 7794 bytes Raw Blame History
1note hopfact: Hop factory command-center core, native ABI v1 (OM-1). Contract: Omega/README.md.
2note One call validates a bounded snapshot (256 ulong words in), categorizes every row, orders the
3note attention view and derives totals (256 ulong words out). Any malformed input fails closed as
4note verdict 1 INVALID with a reason and the first faulting word; nothing is guessed or defaulted.
5note Unknown states, rows the host could not decode and unrecognized groups are never IDLE or CLEAR.
6
7note code: reason r at input word i, packed as r*256+i (never 0 for r >= 1)
8fn code r ulong i ulong to ulong
9ret add mul r 256 i
10end
11
12fn bitset m ulong b ulong to bool
13ret ne and m shl ulong 1 b 0
14end
15
16note highest state code each kind defines (0 is always "unknown")
17fn maxst k ulong to ulong
18if eq k 1
19ret 5
20end
21if eq k 13
22ret 7
23end
24if eq k 14
25ret 5
26end
27ret 1
28end
29
30note largest count each kind accepts: quota permille 1000, agent idle seconds 4e9, others 1e6
31fn capof k ulong to ulong
32if eq k 12
33ret 1000
34end
35if eq k 11
36ret 4000000000
37end
38ret 1000000
39end
40
41note source bit a kind's rows come from: floor stream 0, usage 1, settings 2, chat 3
42fn needbit k ulong to ulong
43if le k 11
44ret 0
45end
46if eq k 15
47ret 0
48end
49if eq k 12
50ret 1
51end
52if eq k 13
53ret 2
54end
55ret 3
56end
57
58note station status: 1 idle 2 waiting 3 queued 4 running 5 bottleneck
59fn catstn s ulong to ulong
60if eq s 5
61ret 5
62end
63if ge s 3
64ret 8
65end
66if eq s 2
67ret 9
68end
69ret 12
70end
71
72note review/merge groups 2..10 and 15; an empty group is idle
73fn catgrp k ulong c ulong to ulong
74if eq c 0
75ret 12
76end
77if eq k 15
78ret 5
79end
80if eq k 2
81ret 8
82end
83if eq k 3
84ret 4
85end
86if eq k 5
87ret 6
88end
89if eq k 6
90ret 7
91end
92if eq k 10
93ret 10
94end
95if ge k 8
96ret 11
97end
98ret 2
99end
100
101note account: 1 OK 2 MISSING 3 EXPIRED 4 RELOGIN 5 BLOCKED 6 RUNNING 7 SAVED
102fn catacc s ulong to ulong
103if le s 4
104if ge s 2
105ret 3
106end
107end
108if eq s 5
109ret 4
110end
111ret 12
112end
113
114note chat item: 1 thinking 2 sending 3 ask 4 delivered 5 error
115fn catchat s ulong to ulong
116if le s 2
117ret 8
118end
119if eq s 3
120ret 2
121end
122if eq s 5
123ret 5
124end
125ret 12
126end
127
128note category 1 UNKNOWN 2 DECISION 3 ACCESS 4 QUOTA 5 TRIAGE 6 READY 7 OWNER 8 WORK 9 BACKLOG
129note 10 OTHER 11 NEUTRAL 12 IDLE; called only on rows that passed chkrow
130fn catof k ulong s ulong c ulong v ulong to ulong
131if eq v 0
132ret 1
133end
134if eq s 0
135ret 1
136end
137if eq k 1
138ret catstn s
139end
140if le k 10
141ret catgrp k c
142end
143if eq k 15
144ret catgrp k c
145end
146if eq k 11
147if lt c 90
148ret 8
149end
150ret 12
151end
152if eq k 12
153if lt c 100
154ret 4
155end
156ret 12
157end
158if eq k 13
159ret catacc s
160end
161ret catchat s
162end
163
164note one row: id, kind, state, count, valid at words 8+5r .. 12+5r
165fn chkrow inp view ulong 256 r ulong msk ulong to ulong
166b = add 8 mul r 5
167k = get inp add b 1
168if eq k 0
169ret code 6 add b 1
170end
171if gt k 15
172ret code 6 add b 1
173end
174if gt get inp b 65535
175ret code 15 b
176end
177if gt get inp add b 2 maxst k
178ret code 14 add b 2
179end
180if gt get inp add b 3 capof k
181ret code 5 add b 3
182end
183if gt get inp add b 4 1
184ret code 7 add b 4
185end
186if not bitset msk needbit k
187ret code 9 add b 1
188end
189ret 0
190end
191
192fn dupid inp view ulong 256 n ulong to ulong
193for r ulong n
194a = get inp add 8 mul r 5
195for q ulong r
196if eq a get inp add 8 mul q 5
197ret code 8 add 8 mul r 5
198end
199end
200end
201ret 0
202end
203
204fn chkhead inp view ulong 256 to ulong
205for i ulong 256
206if gt get inp i 9223372036854775807
207ret code 4 i
208end
209end
210if ne get inp 0 1213157446
211ret code 1 0
212end
213if ne get inp 1 1
214ret code 2 1
215end
216if gt get inp 2 48
217ret code 3 2
218end
219if gt get inp 5 3
220ret code 11 5
221end
222if gt get inp 6 15
223ret code 12 6
224end
225if ne get inp 7 0
226ret code 13 7
227end
228n = get inp 2
229p = add 8 mul n 5
230while lt p 256 bound 256
231if ne get inp p 0
232ret code 10 p
233end
234p = add p 1
235end
236msk = get inp 6
237for r ulong n
238e = chkrow inp r msk
239if ne e 0
240ret e
241end
242end
243ret dupid inp n
244end
245
246fn zero res edit ulong 256 to void
247for i ulong 256
248put res i 0
249end
250end
251
252fn invalid res edit ulong 256 e ulong to ulong
253zero res
254put res 0 1213157446
255put res 1 1
256put res 2 1
257put res 3 div e 256
258put res 4 rem e 256
259ret 1
260end
261
262note snapshot-level reason: 20 health failed, 21 link unknown, 22 stream unavailable, 23 generated
263note absent, 24 older than 60000 ms, 25 generated over 30000 ms ahead, 26 floor stream missing;
264note 0 when the snapshot is current (coverage of station and group kinds is checked by cover)
265fn snapr inp view ulong 256 to ulong
266l = get inp 5
267if eq l 2
268ret 20
269end
270if eq l 0
271ret 21
272end
273if eq l 3
274ret 22
275end
276gen = get inp 4
277now = get inp 3
278if eq gen 0
279ret 23
280end
281if gt gen add now 30000
282ret 25
283end
284if gt now gen
285if gt sub now gen 60000
286ret 24
287end
288end
289if not bitset get inp 6 0
290ret 26
291end
292ret 0
293end
294
295fn agems inp view ulong 256 to ulong
296gen = get inp 4
297now = get inp 3
298if eq gen 0
299ret 18446744073709551615
300end
301if gt gen now
302if gt sub gen now 30000
303ret 18446744073709551615
304end
305ret 0
306end
307ret sub now gen
308end
309
310note per-row categories at 96+r and per-category counts at 8+c
311fn classify inp view ulong 256 res edit ulong 256 n ulong to void
312for r ulong n
313b = add 8 mul r 5
314c = catof get inp add b 1 get inp add b 2 get inp add b 3 get inp add b 4
315put res add 96 r c
316put res add 8 c add get res add 8 c 1
317end
318end
319
320note kind presence mask at 7, per-kind count sums at 24+k (absent kind: -1)
321fn tally inp view ulong 256 res edit ulong 256 n ulong to void
322m = ulong 0
323for r ulong n
324b = add 8 mul r 5
325k = get inp add b 1
326m = or m shl ulong 1 k
327put res add 24 k add get res add 24 k get inp add b 3
328end
329put res 7 m
330for k ulong 16
331if gt k 0
332if not bitset m k
333put res add 24 k 18446744073709551615
334end
335end
336end
337end
338
339note agents working (idle under 90 s) and total at 40, 41 (-1 when no agent rows were sent);
340note minimum quota permille at 42 (-1 when none)
341fn derive inp view ulong 256 res edit ulong 256 n ulong to void
342w = ulong 0
343t = ulong 0
344mq = ulong 18446744073709551615
345for r ulong n
346b = add 8 mul r 5
347k = get inp add b 1
348c = get inp add b 3
349if eq k 11
350t = add t 1
351if lt c 90
352w = add w 1
353end
354end
355if eq k 12
356if lt c mq
357mq = c
358end
359end
360end
361if gt t 0
362put res 40 w
363put res 41 t
364else
365put res 40 18446744073709551615
366put res 41 18446744073709551615
367end
368put res 42 mq
369end
370
371note attention order at 48+i: row ids by category ascending, then input order
372fn order inp view ulong 256 res edit ulong 256 n ulong to void
373p = ulong 48
374for c ulong 13
375for r ulong n
376if eq get res add 96 r c
377put res p get inp add 8 mul r 5
378p = add p 1
379end
380end
381end
382end
383
384note attention rows: categories 1..7 and 10
385fn attn res view ulong 256 to ulong
386a = get res 18
387for c ulong 8
388if gt c 0
389a = add a get res add 8 c
390end
391end
392ret a
393end
394
395fn firstat res view ulong 256 to ulong
396for c ulong 11
397if gt c 0
398if le c 7
399if gt get res add 8 c 0
400ret c
401end
402end
403end
404end
405ret 10
406end
407
408note first kind the floor must report but did not: station 1, review 2..4, merge 5..7; 0 = covered
409fn cover m ulong to ulong
410for k ulong 8
411if gt k 0
412if not bitset m k
413ret k
414end
415end
416end
417ret 0
418end
419
420fn verdof r ulong to ulong
421if eq r 20
422ret 2
423end
424if le r 22
425ret 3
426end
427if le r 25
428ret 4
429end
430ret 5
431end
432
433note entry. Word 45 is read-freshness admission: 1 only when the snapshot is valid, the link is up,
434note generated is current and the floor stream is present (group coverage not required). It never
435note authorizes an action; the host still needs a live selection, explicit confirmation and the server.
436fn hopfact inp view ulong 256 res edit ulong 256 to ulong
437e = chkhead inp
438if ne e 0
439ret invalid res e
440end
441zero res
442n = get inp 2
443put res 0 1213157446
444put res 1 1
445put res 5 n
446put res 6 agems inp
447classify inp res n
448tally inp res n
449derive inp res n
450order inp res n
451a = attn res
452put res 43 a
453r = snapr inp
454if eq r 0
455put res 45 1
456k = cover get res 7
457if ne k 0
458put res 4 k
459r = ulong 31
460if le k 4
461r = ulong 30
462end
463if eq k 1
464r = ulong 29
465end
466end
467end
468v = ulong 8
469if ne r 0
470v = verdof r
471else
472if gt a 0
473v = ulong 6
474r = add 40 firstat res
475else
476if gt add get res 16 get res 17 0
477v = ulong 7
478r = ulong 60
479end
480end
481end
482put res 2 v
483put res 3 r
484ret v
485end