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/apps/readings-window/main.om # 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 / apps / readings-window / main.om` 125 lines ยท 2396 bytes Raw Blame History 1 note readings-window CLI: reads TSV telemetry samples from stdin, emits window stats JSON or text. 2 note Compose: si/directives/om2.om + apps/readings-window/lib.om + apps/readings-window/main.om 3 4 text rw_cli_flag_text "--text" 5 text rw_cli_err_parse "readings-window: malformed telemetry TSV line\n" 6 text rw_cli_err_ingest "readings-window: sample refused (monotonicity or bounds violation)\n" 7 text rw_cli_err_empty "readings-window: no telemetry samples provided\n" 8 9 fn rw_write_all fd int buf view uchar * n ulong to bool 10 done = ulong 0 11 while lt done n bound 65536 12 k = write fd buf done sub n done 13 if le k 0 14 ret false 15 end 16 done = add done ulong k 17 end 18 ret true 19 end 20 21 fn rw_read_stdin dst edit uchar * to long 22 got = ulong 0 23 cap = len dst 24 while lt got cap bound 65536 25 k = read 0 dst got sub cap got 26 if lt k 0 27 ret -1 28 end 29 if eq k 0 30 break 31 end 32 got = add got ulong k 33 end 34 ret long got 35 end 36 37 fn rw_want_text to bool 38 if lt argcnt 2 39 ret false 40 end 41 a1 = new uchar 64 0 42 n1 = argread 1 a1 0 64 43 if le n1 0 44 ret false 45 end 46 ret rw_eq_bytes part a1 0 ulong n1 rw_cli_flag_text 47 end 48 49 fn main to int 50 inbuf = new uchar 16384 0 51 nread = rw_read_stdin inbuf 52 if le nread 0 53 w = rw_write_all 2 rw_cli_err_empty len rw_cli_err_empty 54 if not w 55 ret 2 56 end 57 ret 1 58 end 59 ring = new RwRing 0 0 0 0 0 60 rbuf = new ulong 512 0 61 rw_ring_init ring 62 sample = new RwSample 0 0 0 0 0 0 0 63 cur = ulong 0 64 total = ulong nread 65 while lt cur total bound 16384 66 ls = cur 67 while lt cur total bound 16384 68 if eq get inbuf cur 10 69 cur = add cur 1 70 break 71 end 72 cur = add cur 1 73 end 74 ll = sub cur ls 75 if eq ll 0 76 continue 77 end 78 if eq get inbuf ls 10 79 continue 80 end 81 if eq get inbuf ls 35 82 continue 83 end 84 if not rw_parse_tsv_sample part inbuf ls ll sample 85 w = rw_write_all 2 rw_cli_err_parse len rw_cli_err_parse 86 if not w 87 ret 2 88 end 89 ret 1 90 end 91 rc = rw_ingest ring rbuf sample 92 if ne rc 0 93 w = rw_write_all 2 rw_cli_err_ingest len rw_cli_err_ingest 94 if not w 95 ret 2 96 end 97 ret 1 98 end 99 end 100 stats = new RwStats 0 0 0 0 0 0 0 101 if not rw_compute_stats ring rbuf RW_METRIC_GPU_TEMP 0 stats 102 w = rw_write_all 2 rw_cli_err_empty len rw_cli_err_empty 103 if not w 104 ret 2 105 end 106 ret 1 107 end 108 th = new RwThresh 85 250 90 98 115000 109 alarms = rw_check_alarms ring rbuf th 110 outbuf = new uchar 512 0 111 olen = long 0 112 if rw_want_text 113 olen = rw_format_stats_text outbuf stats alarms 114 else 115 olen = rw_format_stats_json outbuf stats alarms 116 end 117 if lt olen 0 118 ret 1 119 end 120 ok = rw_write_all 1 outbuf ulong olen 121 if not ok 122 ret 1 123 end 124 ret 0 125 end