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/interplane-forge/server/counts.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 / interplane-forge / server / counts.om`
1043 lines ยท 20148 bytes Raw Blame History
1 note forged server/counts.om: real clone, download and seeding counts for the repo home (HTML header
2 note and the "counts" object of forge/repo/1). Every number comes from a log or table that exists:
3 note source 0 front-door nginx download log: git smart-HTTP info/refs?service=git-upload-pack (and
4 note /code/git/.git/info/refs) answered 200 = one git clone or fetch; our own
5 note addresses (loopback, LAN, tailnet, the home address of www.aienos.com) and user agents
6 note naming bot / crawl / spider are left out
7 note source 1 front-door nginx access log: POST /rad/.git/git-upload-pack answered 200, every
8 note client (that log has no client address); a clone is usually two of these
9 note source 2 forged's own access log: GET/HEAD of ///archive/... and /releases/download/...
10 note answered 200, our own addresses left out
11 note seeds this node's Radicle routing table (rad node routing --rid --json)
12 note Change-driven, no timer: on a repo home request each log is read only when its size or inode
13 note changed since the last read, from the saved position (after a rotation the rest of .1
14 note first). Counted events are appended to the journal ~/forge-data/counts.log as one write per
15 note batch ("e " lines, then "s " once, then the cursor "k
16 note "); forged replays it at start and on reload and ignores a torn last batch. Since = the
17 note time of the first line of the oldest log read for that source.
18 text tfzp0 "/var/log/nginx/aienos-dl.log"
19 text tfzp1 "/var/log/nginx/aienos.access.log"
20 text tfzlog "logs/forged.log"
21 text tfzjn "counts.log"
22 text tfzdot1 ".1"
23 text tfzrad5 "/rad/"
24 text tfzgit4 ".git"
25 text tfzinfo "/info/refs?service=git-upload-pack"
26 text tfzupk "/git-upload-pack"
27 text tfzz6 "/z6Mk"
28 text tfzcode "/code/git/"
29 text tfzdot "dot-"
30 text tfzpost "\"POST /rad/"
31 text tfzarch "/archive/"
32 text tfzrel "/releases/download/"
33 text tfzbot "bot"
34 text tfzcrl "crawl"
35 text tfzspi "spider"
36 text tfzmon "janfebmaraprmayjunjulaugsepoctnovdec"
37 text tfzo1 "127."
38 text tfzo2 "10."
39 text tfzo3 "192.168."
40 text tfzo4 "::1"
41 text tfzo5 "fe80:"
42 text tfzo6 "fd"
43 text tfzo7 "100."
44 text tfzkind "gpar"
45 note Owner-side snapshot mode supplies its isolated journal path; ordinary mode leaves it empty.
46 global fzjp uchar 4096
47 global fzjpl ulong 1
48 global fzbuf uchar `1048576`
49 global fzst uchar 128
50 global fzcin ulong 1
51 global fzcsz ulong 1
52 global fzino ulong 4
53 global fzoff ulong 4
54 global fzinit ulong 4
55 global fzsnc ulong 4
56 global fzsj ulong 4
57 global fzspen ulong 4
58 global fzz0 ulong 1
59 global fzfail ulong 1
60 note fzcnt / fzpnd: committed / pending counts, index k*FAMAX + repo, k 0 git fetch 1 upload-pack 2 archive 3 release asset
61 global fzcnt ulong 1024
62 global fzpnd ulong 1024
63 global fznev ulong 1
64 global fzjb uchar 131072
65 global fzjbl ulong 1
66 note fzjend: journal byte offset after the last committed cursor; any later bytes are abandoned.
67 global fzjend ulong 1
68 global fzhome uchar 64
69 global fzhomel ulong 1
70 global fzsd ulong 256
71 global fzsdk ulong 256
72 global fzsdm ulong 256
73 global fzsdt ulong 256
74 note ---- small readers over fzbuf
75 fn fzb i ulong to uchar
76 ret get fzbuf i
77 end
78 fn fzsp a ulong e ulong to ulong
79 j = a
80 for it ulong sub e a bound `1048576`
81 if eq fzb j 32
82 ret j
83 end
84 j = add j 1
85 end
86 ret e
87 end
88 fn fzch a ulong e ulong c uchar to ulong
89 j = a
90 for it ulong sub e a bound `1048576`
91 if eq fzb j c
92 ret j
93 end
94 j = add j 1
95 end
96 ret e
97 end
98 fn fznum a ulong e ulong to ulong
99 v = ulong 0
100 j = a
101 for it ulong 20
102 if ge j e
103 break
104 end
105 c = fzb j
106 if not fisdig c
107 break
108 end
109 v = add mul v 10 ulong sub c 48
110 j = add j 1
111 end
112 ret v
113 end
114 fn fzpre a ulong e ulong t view uchar * to bool
115 if gt add a len t e
116 ret false
117 end
118 for k ulong len t bound 64
119 if ne fzb add a k get t k
120 ret false
121 end
122 end
123 ret true
124 end
125 fn fzhasat a ulong t view uchar * to bool
126 for k ulong len t bound 64
127 if ne flow fzb add a k get t k
128 ret false
129 end
130 end
131 ret true
132 end
133 note fzhas: [a, e) contains t, ignoring ASCII case
134 fn fzhas a ulong e ulong t view uchar * to bool
135 if gt add a len t e
136 ret false
137 end
138 for s ulong add sub sub e a len t 1 bound `1048576`
139 if fzhasat add a s t
140 ret true
141 end
142 end
143 ret false
144 end
145 note ---- the repository an event belongs to (public allow-list only)
146 fn fzrideq i ulong a ulong n ulong to bool
147 if ne get fail i n
148 ret false
149 end
150 for k ulong n bound 64
151 if ne fridbyte i k fzb add a k
152 ret false
153 end
154 end
155 ret true
156 end
157 fn fzrix a ulong n ulong to ulong
158 for i ulong get fan 0 bound FAMAX
159 if fzrideq i a n
160 ret i
161 end
162 end
163 ret 9999
164 end
165 note fznmeq: the repo name of i equals [a, a+n); with dt 1 a leading "dot-" stands for "."
166 fn fznmeq i ulong a ulong n ulong dt ulong to bool
167 if and eq dt 1 fzpre a add a n tfzdot
168 if ne get fanl i sub n 3
169 ret false
170 end
171 if ne frnbyte i 0 46
172 ret false
173 end
174 for k ulong sub n 4 bound 128
175 if ne frnbyte i add k 1 fzb add add a 4 k
176 ret false
177 end
178 end
179 ret true
180 end
181 if ne get fanl i n
182 ret false
183 end
184 for k ulong n bound 128
185 if ne frnbyte i k fzb add a k
186 ret false
187 end
188 end
189 ret true
190 end
191 fn fznix a ulong n ulong dt ulong to ulong
192 for i ulong get fan 0 bound FAMAX
193 if fznmeq i a n dt
194 ret i
195 end
196 end
197 ret 9999
198 end
199 note ---- our own addresses: loopback, LAN, tailnet 100.64/10, IPv6 local, the home address
200 fn fzhomeq a ulong e ulong to bool
201 n = get fzhomel 0
202 if or eq n 0 ne sub e a n
203 ret false
204 end
205 for k ulong n bound 64
206 if ne fzb add a k get fzhome k
207 ret false
208 end
209 end
210 ret true
211 end
212 fn fzown a ulong e ulong to bool
213 if le sub e a 1
214 ret true
215 end
216 if or fzpre a e tfzo1 fzpre a e tfzo2
217 ret true
218 end
219 if or fzpre a e tfzo3 fzpre a e tfzo4
220 ret true
221 end
222 if or fzpre a e tfzo5 fzpre a e tfzo6
223 ret true
224 end
225 if fzpre a e tfzo7
226 v = fznum add a 4 e
227 if and ge v 64 le v 127
228 ret true
229 end
230 end
231 ret fzhomeq a e
232 end
233 note fzhomeip: the home address = what www.aienos.com resolves to here (getent, argv only)
234 text tfzgent "/usr/bin/getent"
235 text tfzhosts "hosts"
236 text tfzhost "www.aienos.com"
237 fn fzhomeip to bool
238 put fzhomel 0 0
239 fkb
240 fka tfzgent
241 fka tfzhosts
242 fka tfzhost
243 st = fexec `5000000000`
244 if ne st 0
245 ret false
246 end
247 n = ulong 0
248 for k ulong hmin get fxol 0 63 bound 64
249 c = get fxo k
250 if or or eq c 32 eq c 9 eq c 10
251 break
252 end
253 put fzhome k c
254 n = add n 1
255 end
256 put fzhomel 0 n
257 ret ge n 3
258 end
259 note ---- epochs from log times
260 fn fzdays y ulong m ulong d ulong to ulong
261 yy = y
262 if le m 2
263 yy = sub y 1
264 end
265 era = div yy 400
266 yoe = sub yy mul era 400
267 mm = add m 9
268 if gt m 2
269 mm = sub m 3
270 end
271 doy = add div add mul 153 mm 2 5 sub d 1
272 q = add mul yoe 365 div yoe 4
273 doe = sub add q doy div yoe 100
274 ret sub add mul era 146097 doe 719468
275 end
276 fn fzmon a ulong to ulong
277 for m ulong 12
278 if fzmoneq a m
279 ret add m 1
280 end
281 end
282 ret 0
283 end
284 fn fzmoneq a ulong m ulong to bool
285 for k ulong 3
286 if ne flow fzb add a k get tfzmon add mul m 3 k
287 ret false
288 end
289 end
290 ret true
291 end
292 note fzclf: "08/Nov/2026:05:57:35 -0600" at a -> epoch (0 when malformed)
293 fn fzn2 a ulong to ulong
294 ret add mul ulong sub fzb a 48 10 ulong sub fzb add a 1 48
295 end
296 fn fzdigs a ulong e ulong to bool
297 if or ge a e gt sub e a 19
298 ret false
299 end
300 for k ulong sub e a bound 19
301 if not fisdig fzb add a k
302 ret false
303 end
304 end
305 ret true
306 end
307 fn fzclf a ulong e ulong to ulong
308 if gt add a 26 e
309 ret 0
310 end
311 if not fzdigs add a 22 add a 26
312 ret 0
313 end
314 m = fzmon add a 3
315 if eq m 0
316 ret 0
317 end
318 dd = fzdays fznum add a 7 e m fznum a e
319 h = fznum add a 12 e
320 mi = fznum add a 15 e
321 s = add add mul h 3600 mul mi 60 fznum add a 18 e
322 t = add mul dd 86400 s
323 o = add mul fzn2 add a 22 3600 mul fzn2 add a 24 60
324 if eq fzb add a 21 45
325 ret add t o
326 end
327 ret sub t o
328 end
329 note ---- events: pending until the batch is in the journal
330 fn fzjc c uchar to void
331 n = get fzjbl 0
332 if lt n len fzjb
333 put fzjb n c
334 put fzjbl 0 add n 1
335 end
336 end
337 fn fzjn v ulong to void
338 d = new uchar 20 0
339 i = ulong 20
340 x = v
341 for it ulong 20
342 i = sub i 1
343 put d i uchar add rem x 10 48
344 x = div x 10
345 if eq x 0
346 break
347 end
348 end
349 for k ulong sub 20 i bound 20
350 fzjc get d add i k
351 end
352 end
353 fn fzev k ulong i ulong ep ulong to void
354 if ge i get fan 0
355 ret
356 end
357 j = add mul k FAMAX i
358 put fzpnd j add get fzpnd j 1
359 put fznev 0 add get fznev 0 1
360 fzjc 101
361 fzjc 32
362 fzjc get tfzkind k
363 fzjc 32
364 fzjn ep
365 fzjc 32
366 for q ulong get fail i bound 64
367 fzjc fridbyte i q
368 end
369 fzjc 10
370 end
371 fn fzsince s ulong ep ulong to void
372 if and eq get fzz0 0 1 eq get fzsnc s 0
373 if ge ep `1000000000`
374 put fzsnc s ep
375 end
376 end
377 end
378 note ---- source 0: " \"\" \"\""
379 fn fzl0 a ulong e ulong to void
380 p1 = fzsp a e
381 ep = fznum a p1
382 fzsince 0 ep
383 p2 = fzsp add p1 1 e
384 p3 = fzsp add p2 1 e
385 if ne fznum add p2 1 p3 200
386 ret
387 end
388 if ge add p3 2 e
389 ret
390 end
391 u = add p3 2
392 ue = fzch u e 34
393 if fzown add p1 1 p2
394 ret
395 end
396 if fzua ue e
397 ret
398 end
399 i = fzuri0 u ue
400 if lt i 9999
401 fzev 0 i ep
402 end
403 end
404 fn fzua a ulong e ulong to bool
405 if fzhas a e tfzbot
406 ret true
407 end
408 if fzhas a e tfzcrl
409 ret true
410 end
411 ret fzhas a e tfzspi
412 end
413 note fzuri0: /rad/.git[/z6Mk]/info/refs?service=git-upload-pack or /code/git/.git/info/refs...
414 fn fzuri0 u ulong ue ulong to ulong
415 if fzpre u ue tfzrad5
416 r = add u 5
417 g = fzch r ue 46
418 if not fzpre g ue tfzgit4
419 ret 9999
420 end
421 t = add g 4
422 if fzpre t ue tfzz6
423 t = fzch add t 1 ue 47
424 end
425 if not fzpre t ue tfzinfo
426 ret 9999
427 end
428 ret fzrix r sub g r
429 end
430 if fzpre u ue tfzcode
431 r = add u 10
432 g = fzch r ue 46
433 for it ulong 8
434 if fzpre g ue tfzgit4
435 break
436 end
437 g = fzch add g 1 ue 46
438 end
439 if not fzpre add g 4 ue tfzinfo
440 ret 9999
441 end
442 ret fznix r sub g r 1
443 end
444 ret 9999
445 end
446 note ---- source 1: combined format, "... [
\n"
958 text tfzh14 " (forged access log not read yet"
959 text tfzsn " since "
960 text tfznm "not measured"
961 text tfzb1 ""
962 text tfzb2 ""
963 fn fzhn v ulong s ulong to void
964 if eq get fzsnc s 0
965 fput tfznm
966 ret
967 end
968 fput tfzb1
969 fnum v
970 fput tfzb2
971 end
972 fn fzhs s ulong to void
973 if eq get fzsnc s 0
974 ret
975 end
976 fputc 59
977 fput tfzsn
978 fjday get fzsnc s
979 end
980 fn fzhtml i ulong to void
981 fput tfzh1
982 fzhn fzc 0 i 0
983 fput tfzh2
984 fzhs 0
985 fput tfzh3
986 fput tfznm
987 fput tfzh4
988 fput tfzh5
989 fzhdl i
990 if not fradsrc
991 fput tfzh9s
992 ret
993 end
994 fput tfzh9
995 end
996 fn fzhdl i ulong to void
997 if eq get fzsnc 2 0
998 fput tfznm
999 fput tfzh14
1000 ret
1001 end
1002 fzhn add fzc 2 i fzc 3 i 2
1003 fput tfzh6
1004 fnum fzc 2 i
1005 fput tfzh7
1006 fnum fzc 3 i
1007 fput tfzh8
1008 fzhs 2
1009 end
1010 text tfzj1 "{\n\"git_fetches\":{\"count\":"
1011 text tfzjs "\"since\":"
1012 text tfzj2 ",\"source\":\"front-door nginx download log\",\"counts\":\"git smart-HTTP info/refs?service=git-upload-pack requests answered 200 (one per clone or fetch), /code/git/.git and the retired clone path\",\"excludes\":\"our own addresses (loopback, LAN, tailnet, the home address of www.aienos.com) and user agents naming bot, crawl or spider\"},\n\"upload_pack_requests\":{\"count\":null,\"since\":null,\"source\":\"retired\",\"counts\":\"not measured: the source of this count is retired\",\"excludes\":null},\n\"downloads\":{\"count\":"
1013 text tfzj4 ",\"archives\":"
1014 text tfzj5 ",\"release_assets\":"
1015 text tfzj6 ",\"source\":\"forged access log\",\"counts\":\"GET or HEAD of ///archive/... and /releases/download/... answered 200\",\"excludes\":\"our own addresses (loopback, LAN, tailnet, the home address of www.aienos.com)\"},\n\"seeds\":{\"count\":null,\"as_of\":null,\"source\":\"retired\",\"counts\":\"not measured: the source of this count is retired\"}\n}"
1016 fn fzjv v ulong s ulong to void
1017 if eq get fzsnc s 0
1018 fput tfjnull
1019 else
1020 fnum v
1021 end
1022 fputc 44
1023 fput tfzjs
1024 fjiso get fzsnc s
1025 end
1026 fn fzjson i ulong to void
1027 fput tfzj1
1028 fzjv fzc 0 i 0
1029 fput tfzj2
1030 fzjv add fzc 2 i fzc 3 i 2
1031 fput tfzj4
1032 fzj0 fzc 2 i 2
1033 fput tfzj5
1034 fzj0 fzc 3 i 2
1035 fput tfzj6
1036 end
1037 fn fzj0 v ulong s ulong to void
1038 if eq get fzsnc s 0
1039 fput tfjnull
1040 ret
1041 end
1042 fnum v
1043 end