interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / site / ledger.om

6248 lines · 115511 bytes Raw Blame History
1note Ledger surfaces: /now/, /dash/, /now.json, /now/feed.xml and the public ledger guard.
2note Port of crates/site-builder/src/{ledger_public.rs,components/now.rs,components/dash.rs} and
3note seo.rs now_feed at baseline 3d36bd7829d1. Compose after runtime/json; core supplies om2.
4note API (all write to the current sofd except the checks):
5note sp_now, sp_dash: main-body renderers for /now/ and /dash/ (people.om sp_page dispatches).
6note sp_now_json: /now.json bytes (serde_json to_string_pretty field order, no trailing LF).
7note sp_now_feed: /now/feed.xml bytes (Atom, settled lines newest first).
8note sp_ledger_stamp: RFC 3339 ledger-written stamp for SEO (build clock when none); computed
9note once per process (guarded load) and cached, no LF, leaves sofd untouched.
10note HTML text escapes ' as ' through sr_escape where maud kept it raw; same rendered text.
11note sp_ledger_check: refuse unless public/data/now.tsv is absent or equals its public projection.
12note sp_ledger_check_at PATH: same refusal for any path (verifier: dist/data/now.tsv).
13note Every surface re-runs the guard before reading a ledger byte; rows are never skipped: a row
14note the guard would reject stops the build, so the page, JSON and feed carry every source line.
15note Optional inputs (now-pulse, models, claude-usage, accounts, routing TSVs) that are absent or
16note not UTF-8 read as unpublished, as read_to_string(..).unwrap_or_default() did. Other read
17note errors refuse (stricter than Rust, never silent). The ledger itself must be UTF-8 if present.
18note Guard semantics: check_public(x) == (project(x) == x). Projection is idempotent and every
19note redaction rewrites its match, so equality holds iff no field holds a credential, email or
20note control character (project errors) and no path/root/uuid/host/ipv4/ipv6/port/pid rule matches.
21note Regex fidelity: patterns are matched over code points with Rust regex Unicode semantics:
22note (?i) folds A-Z plus U+212A->k and U+017F->s (the only simple folds into ASCII); \s is the
23note White_Space set; \d covers the Nd blocks listed in lk_nd; \b uses lk_word, which treats ASCII
24note alnum/_ and all non-ASCII as word except the punctuation/symbol/emoji ranges listed there.
25note Known divergence: a non-ASCII code point outside those tables that Unicode does not class as
26note \w (rare symbols) is treated as word; time fields above 99999999 read as unparsable (Rust
27note would overflow); percentages parse as exact decimals (Rust parses f64 then rounds).
28note Integration cases/instructions (NOT_RUN, no build here): compose with the site unit, run
29note sp_ledger_check_at on fixtures; expect exit 70 + named stderr for each negative control:
30note header id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc then a row
31note L001\tdate\tagent\topen\tVALUE\t\t\tdate with VALUE in: owner@example.org; password=hunter22;
32note --api-key shortvalue; ghp_abcdef123; secret is a4c618e50b7d92f3c4e1d690a5b7c8d9e0f1a2b3c4d5e6f7
33note 89ab01cd23ef4567; See /home/person/private; Check ~/notes at 127.0.0.1:18091; pid 12345;
34note 550e8400-e29b-41d4-a716-446655440000; brief/home/x; host.local; [::1]; worker pid2344210;
35note a row with 4 fields; a row with 9 fields; a blank line; CRLF endings; no final LF; bad header;
36note a raw 0x01 byte; invalid UTF-8. Positive controls (exit 0): the projected forms
37note "See [private path]", "RFC 8032 7.1 TEST 1 secret is 9d61b19deffd5a60ba844af492ec2cc44449c5697b
38note 326919703bac031cae7f60;" (one token), repo@abcdef1 evidence/run.log https://github.com/aien-dev/x,
39note the committed public/data/now.tsv. Page parity: diff /now/ /dash/ /now.json /now/feed.xml main
40note bodies against the retained Rust builder at the same frozen clock (export the realns stamp).
41note Negative control for the parity diff: flip one ledger status and require a diff.
42const LKCAP ulong 4194304
43const LKROWS ulong 4096
44const LKNOTES ulong 65536
45const LKTOK ulong 8192
46global lkraw uchar 4194304
47global lkrn ulong 1
48global lkcl uchar 4194304
49global lkcn ulong 1
50global lklast ulong 1
51global lkreg ulong 16
52global lkhas uchar 8
53global lkcp uint 65536
54global lkcpn ulong 1
55global lkdl ulong 1
56global lkat long 1
57global lkatv uchar 1
58global lkok uchar 1
59global lkt long 8
60global lkio ulong 32768
61global lkil ulong 32768
62global lkline ulong 4096
63global lkage long 4096
64global lkupd long 4096
65global lkupv uchar 4096
66global lkopd long 4096
67global lkopv uchar 4096
68global lkown uchar 4096
69global lkstrm uchar 4096
70global lkstat uchar 4096
71global lknf ulong 4096
72global lknc ulong 4096
73global lkn ulong 1
74global lkno ulong 65536
75global lknl ulong 65536
76global lknn ulong 1
77global lkperm ulong 4096
78global lkpk ulong 2048
79global lkpv ulong 2048
80global lkpn ulong 1
81global lkmc ulong 2
82global lkmcv uchar 1
83global lkmid ulong 2048
84global lkmidn ulong 1
85global lkuv uchar 1
86global lkuc ulong 2
87global lkup ulong 2
88global lkuk uchar 1024
89global lkus ulong 2048
90global lkur ulong 2048
91global lkupc ulong 1024
92global lkun ulong 1
93global lkwr long 1
94global lkwrv uchar 1
95global lkts ulong 8192
96global lkte ulong 8192
97global lktk uchar 8192
98global lktr uchar 8192
99global lktn ulong 1
100global lkfc ulong 4
101global lkdc ulong 2
102global lkdcv uchar 1
103global lkap uchar 1024
104global lkan ulong 1024
105global lkapl ulong 2048
106global lkaw uchar 1024
107global lkal ulong 2048
108global lkapc ulong 1024
109global lkar ulong 2048
110global lkax uchar 1024
111global lkann ulong 1
112global lkrk uchar 1024
113global lkrnm ulong 2048
114global lkrmd ulong 2048
115global lkrcnt ulong 1
116global lkseat uchar 1
117text lkp0 "public/data/now.tsv"
118text lkp1 "public/data/now-pulse.tsv"
119text lkp2 "public/data/models.tsv"
120text lkp3 "public/data/claude-usage.tsv"
121text lkp4 "public/data/accounts.tsv"
122text lkp5 "public/data/routing.tsv"
123text lkroster "crates/site-builder/data/models.json"
124text lkhead "id\topened_utc\towner\tstatus\titem\tdone_when\tevidence\tupdated_utc"
125text lkepre "site ledger: "
126text lkeline "line "
127text lkecol ": "
128text lkenl "\n"
129text lkemnl "ledger must be newline-terminated UTF-8 TSV"
130text lkemhd "unexpected ledger header"
131text lkem9 "ledger row has more than eight columns"
132text lkem4 "ledger row has fewer than five columns"
133text lkemsc "credential-shaped value in ledger"
134text lkemem "email-shaped value in ledger"
135text lkemct "control character in ledger field"
136text lkempj "ledger is not its public projection"
137text lkemrd "unreadable ledger"
138text lkemcap "LEDGER_CAPACITY"
139text lkemfld "LEDGER_FIELD_CAPACITY"
140text lkemrow "LEDGER_ROW_CAPACITY"
141text lkemrst "ledger row changed after the guard"
142text lkemrj "data/models.json must parse"
143text lkrfc "rfc 8032 7.1 test 1"
144text lkrfck "secret is 9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60;"
145
146fn lk_fail why view uchar * line ulong to void
147sr_flush
148sr_diag lkepre
149if ne line 0
150sr_diag lkeline
151lk_dnum line
152sr_diag lkecol
153end
154sr_diag why
155sr_diag lkenl
156exit 70
157end
158
159fn lk_dnum v ulong to void
160xbuf = new uchar 20 0
161xp = ulong 20
162while true bound 20
163xp = sub xp 1
164put xbuf xp uchar add rem v 10 48
165v = div v 10
166if eq v 0
167break
168end
169end
170sr_diag part xbuf xp sub ulong 20 xp
171end
172
173note ---------------------------------------------------------------- files
174
175fn lk_read path view uchar * slot ulong to void
176xo = get lkrn 0
177put lkreg mul slot 2 xo
178put lkreg add mul slot 2 1 0
179put lkhas slot 0
180xfd = fopen path 0 len path 0 0
181if eq xfd -2
182ret
183end
184if lt xfd 0
185lk_fail lkemrd 0
186end
187xn = xo
188xeof = false
189for xtry ulong 999998
190if ge xn LKCAP
191lk_fail lkemcap 0
192end
193xk = read int xfd lkraw xn sub LKCAP xn
194if lt xk 0
195lk_fail lkemrd 0
196end
197if eq xk 0
198xeof = true
199break
200end
201xn = add xn ulong xk
202end
203if not xeof
204lk_fail lkemcap 0
205end
206sr_fclose int xfd
207put lkrn 0 xn
208put lkreg add mul slot 2 1 sub xn xo
209put lkhas slot 1
210end
211
212fn lk_roff slot ulong to ulong
213ret get lkreg mul slot 2
214end
215
216fn lk_rlen slot ulong to ulong
217ret get lkreg add mul slot 2 1
218end
219
220fn lk_cont p ulong e ulong to bool
221if ge p e
222ret false
223end
224xc = get lkraw p
225ret and ge xc 128 lt xc 192
226end
227
228fn lk_u8len p ulong e ulong to ulong
229xc = get lkraw p
230if lt xc 128
231ret 1
232end
233if and ge xc 194 le xc 223
234if lk_cont add p 1 e
235ret 2
236end
237ret 0
238end
239if and ge xc 224 le xc 239
240ret lk_u83 p e
241end
242if and ge xc 240 le xc 244
243ret lk_u84 p e
244end
245ret 0
246end
247
248fn lk_u83 p ulong e ulong to ulong
249xc = get lkraw p
250if not and lk_cont add p 1 e lk_cont add p 2 e
251ret 0
252end
253xd = get lkraw add p 1
254if and eq xc 224 lt xd 160
255ret 0
256end
257if and eq xc 237 ge xd 160
258ret 0
259end
260ret 3
261end
262
263fn lk_u84 p ulong e ulong to ulong
264xc = get lkraw p
265if not and lk_cont add p 1 e and lk_cont add p 2 e lk_cont add p 3 e
266ret 0
267end
268xd = get lkraw add p 1
269if and eq xc 240 lt xd 144
270ret 0
271end
272if and eq xc 244 ge xd 144
273ret 0
274end
275ret 4
276end
277
278note lk_utf8: slot is well-formed UTF-8. A for loop traps (4) at 1000000 passes and a raw slot may
279note hold up to 4 MiB, so the scan is two-level: 64 x 262144 passes, each advancing at least 1 byte.
280fn lk_utf8 slot ulong to bool
281xp = lk_roff slot
282xe = add xp lk_rlen slot
283while lt xp xe bound 64
284for xi ulong 262144
285if ge xp xe
286ret true
287end
288xk = lk_u8len xp xe
289if eq xk 0
290ret false
291end
292xp = add xp xk
293end
294end
295ret true
296end
297
298fn lk_dcp p ulong to uint
299xc = uint get lkraw p
300if lt xc 128
301put lkdl 0 1
302ret xc
303end
304xb = uint get lkraw add p 1
305if lt xc 224
306put lkdl 0 2
307ret or shl and xc 31 6 and xb 63
308end
309xd = uint get lkraw add p 2
310if lt xc 240
311put lkdl 0 3
312ret or or shl and xc 15 12 shl and xb 63 6 and xd 63
313end
314xf = uint get lkraw add p 3
315put lkdl 0 4
316xc = or shl and xc 7 18 shl and xb 63 12
317ret or or xc shl and xd 63 6 and xf 63
318end
319
320note Fresh read, guard and parse of every input; each public surface calls this first.
321fn lk_load_all to void
322put lkrn 0 0
323put lkcn 0 0
324lk_read lkp0 0
325if ne get lkhas 0 0
326if not lk_utf8 0
327lk_fail lkemrd 0
328end
329lk_guard 0
330end
331lk_read lkp1 1
332lk_read lkp2 2
333lk_read lkp3 3
334lk_read lkp4 4
335lk_read lkp5 5
336for xs ulong 5
337if ne get lkhas add xs 1 0
338if not lk_utf8 add xs 1
339put lkhas add xs 1 0
340end
341end
342end
343lk_stamp
344lk_parse
345lk_pulse
346lk_mcheck
347lk_usage
348lk_accts
349lk_routes
350end
351
352note ---------------------------------------------------------------- arena
353
354fn lk_cput c uchar to void
355xn = get lkcn 0
356if ge xn LKCAP
357lk_fail lkemcap 0
358end
359put lkcl xn c
360put lkcn 0 add xn 1
361end
362
363fn lk_by sel uchar p ulong to uchar
364if eq sel 0
365ret get lkraw p
366end
367ret get lkcl p
368end
369
370note Length of a White_Space character at p (0 if none); bytes beyond e never read.
371fn lk_wsat sel uchar p ulong e ulong to ulong
372xc = lk_by sel p
373if or and ge xc 9 le xc 13 eq xc 32
374ret 1
375end
376if and eq xc 194 lt add p 1 e
377xd = lk_by sel add p 1
378if or eq xd 133 eq xd 160
379ret 2
380end
381ret 0
382end
383if gt add p 3 e
384ret 0
385end
386ret lk_ws3 sel p
387end
388
389fn lk_ws3 sel uchar p ulong to ulong
390xc = lk_by sel p
391xd = lk_by sel add p 1
392xf = lk_by sel add p 2
393if and eq xc 225 and eq xd 154 eq xf 128
394ret 3
395end
396if and eq xc 227 and eq xd 128 eq xf 128
397ret 3
398end
399if and eq xc 226 eq xd 128
400if or le xf 138 or eq xf 168 or eq xf 169 eq xf 175
401if ge xf 128
402ret 3
403end
404end
405end
406if and eq xc 226 and eq xd 129 eq xf 159
407ret 3
408end
409ret 0
410end
411
412note Trim White_Space from both ends of [p, e) in buffer sel; start in lkt 6, end in lkt 7.
413fn lk_trim sel uchar p ulong e ulong to void
414while lt p e bound 999999
415xk = lk_wsat sel p e
416if eq xk 0
417break
418end
419p = add p xk
420end
421while gt e p bound 999999
422xk = lk_wsb sel p e
423if eq xk 0
424break
425end
426e = sub e xk
427end
428put lkt 6 long p
429put lkt 7 long e
430end
431
432fn lk_wsb sel uchar p ulong e ulong to ulong
433for xl ulong 3
434xk = add xl 1
435if le add p xk e
436if eq lk_wsat sel sub e xk e xk
437ret xk
438end
439end
440end
441ret 0
442end
443
444note clean(): em/en dash to '-', then trim. Raw [p, e) to a new lkcl string; length in lklast.
445fn lk_clean p ulong e ulong to ulong
446lk_trim 0 p e
447xs = ulong get lkt 6
448xe = ulong get lkt 7
449xo = get lkcn 0
450while lt xs xe bound 999999
451xc = get lkraw xs
452if lk_dash xs xe
453lk_cput 45
454xs = add xs 3
455else
456lk_cput xc
457xs = add xs 1
458end
459end
460put lklast 0 sub get lkcn 0 xo
461ret xo
462end
463
464fn lk_dash p ulong e ulong to bool
465if gt add p 3 e
466ret false
467end
468if ne get lkraw p 226
469ret false
470end
471if ne get lkraw add p 1 128
472ret false
473end
474xc = get lkraw add p 2
475ret or eq xc 147 eq xc 148
476end
477
478note ---------------------------------------------------------------- time
479
480fn lk_fdiv a long b long to long
481xq = div a b
482if and lt a 0 ne mul xq b a
483xq = sub xq 1
484end
485ret xq
486end
487
488note Rust i64 parse of [p, e): optional sign, at least one ASCII digit. lkok 0 = None.
489fn lk_pint sel uchar p ulong e ulong to long
490put lkok 0 0
491if ge p e
492ret 0
493end
494xneg = false
495xc = lk_by sel p
496if or eq xc 43 eq xc 45
497xneg = eq xc 45
498p = add p 1
499end
500if ge p e
501ret 0
502end
503xv = long 0
504while lt p e bound 999999
505xc = lk_by sel p
506if or lt xc 48 gt xc 57
507ret 0
508end
509xv = add mul xv 10 long sub xc 48
510if gt xv 99999999
511ret 0
512end
513p = add p 1
514end
515put lkok 0 1
516if xneg
517ret neg xv
518end
519ret xv
520end
521
522note lk_find: first p in [p, e) holding byte c, else e. Two-level (64 x 262144 passes): a region
523note may span the whole 4 MiB raw buffer, past the 1000000-pass loop trap.
524fn lk_find sel uchar p ulong e ulong c uchar to ulong
525while lt p e bound 64
526xk = ulong 0
527while and lt p e lt xk 262144 bound 262144
528if eq lk_by sel p c
529ret p
530end
531p = add p 1
532xk = add xk 1
533end
534end
535ret e
536end
537
538note parse_utc: lkt 0..5 = y m d hh mm ss; returns seconds, lkok 1 on success.
539fn lk_utc sel uchar p ulong e ulong to long
540lk_trim sel p e
541xs = ulong get lkt 6
542xe = ulong get lkt 7
543while gt xe xs bound 999999
544if ne lk_by sel sub xe 1 90
545break
546end
547xe = sub xe 1
548end
549xt = lk_find sel xs xe 84
550if ge xt xe
551put lkok 0 0
552ret 0
553end
554if not lk_utcd sel xs xt
555put lkok 0 0
556ret 0
557end
558if not lk_utct sel add xt 1 xe
559put lkok 0 0
560ret 0
561end
562xd = lk_days get lkt 0 get lkt 1 get lkt 2
563put lkok 0 1
564xd = add mul xd 86400 mul get lkt 3 3600
565ret add add xd mul get lkt 4 60 get lkt 5
566end
567
568fn lk_utcd sel uchar p ulong e ulong to bool
569for xi ulong 3
570xq = lk_find sel p e 45
571put lkt xi lk_pint sel p xq
572if eq get lkok 0 0
573ret false
574end
575if ge xq e
576if lt xi 2
577ret false
578end
579end
580p = add xq 1
581end
582ret true
583end
584
585fn lk_utct sel uchar p ulong e ulong to bool
586xq = lk_find sel p e 58
587put lkt 3 lk_pint sel p xq
588if eq get lkok 0 0
589ret false
590end
591if ge xq e
592ret false
593end
594p = add xq 1
595xq = lk_find sel p e 58
596put lkt 4 lk_pint sel p xq
597if eq get lkok 0 0
598ret false
599end
600put lkt 5 0
601if lt xq e
602p = add xq 1
603xq = lk_find sel p e 58
604xv = lk_pint sel p xq
605if eq get lkok 0 1
606put lkt 5 xv
607end
608end
609ret true
610end
611
612fn lk_days y long m long d long to long
613xy = y
614xm = sub m 3
615if le m 2
616xy = sub y 1
617xm = add m 9
618end
619xera = lk_fdiv xy 400
620xyoe = sub xy mul xera 400
621xdoy = sub add div add mul 153 xm 2 5 d 1
622xdoe = add mul xyoe 365 div xyoe 4
623xdoe = sub xdoe div xyoe 100
624xdoe = add xdoe xdoy
625ret sub add mul xera 146097 xdoe 719468
626end
627
628note civil from days into lkt 0..5.
629fn lk_civil secs long to void
630xdays = lk_fdiv secs 86400
631put lkt 5 sub secs mul xdays 86400
632xz = add xdays 719468
633xera = lk_fdiv xz 146097
634xdoe = sub xz mul xera 146097
635xyoe = div sub add sub xdoe div xdoe 1460 div xdoe 36524 div xdoe 146096 365
636xdoy = sub xdoe sub add mul 365 xyoe div xyoe 4 div xyoe 100
637xmp = div add mul 5 xdoy 2 153
638xdd = div add mul 153 xmp 2 5
639put lkt 2 add sub xdoy xdd 1
640xm = sub xmp 9
641if lt xmp 10
642xm = add xmp 3
643end
644put lkt 1 xm
645xy = add xyoe mul xera 400
646if le xm 2
647xy = add xy 1
648end
649put lkt 0 xy
650end
651
652fn lk_cpad v long w ulong to void
653xbuf = new uchar 24 0
654if lt v 0
655lk_cput 45
656v = neg v
657if gt w 0
658w = sub w 1
659end
660end
661xp = ulong 24
662while true bound 24
663xp = sub xp 1
664put xbuf xp uchar add rem v 10 48
665v = div v 10
666if and eq v 0 ge sub 24 xp w
667break
668end
669end
670while lt xp 24 bound 24
671lk_cput get xbuf xp
672xp = add xp 1
673end
674end
675
676note fmt_utc (seconds false) or rfc3339 (seconds true) appended to lkcl; length in lklast.
677fn lk_fmt secs long full bool to ulong
678xo = get lkcn 0
679lk_civil secs
680xr = get lkt 5
681lk_cpad get lkt 0 4
682lk_cput 45
683lk_cpad get lkt 1 2
684lk_cput 45
685lk_cpad get lkt 2 2
686lk_cput 84
687lk_cpad div xr 3600 2
688lk_cput 58
689lk_cpad div rem xr 3600 60 2
690if full
691lk_cput 58
692lk_cpad rem xr 60 2
693end
694lk_cput 90
695put lklast 0 sub get lkcn 0 xo
696ret xo
697end
698
699note One build clock for every ledger surface, as the Rust builder read the clock once.
700fn lk_stamp to void
701if eq get lkatv 0 0
702xns = realns
703put lkat 0 div xns 1000000000
704put lkatv 0 1
705end
706end
707
708fn lk_now to long
709lk_stamp
710ret get lkat 0
711end
712
713note ---------------------------------------------------------------- privacy guard
714
715fn lk_c i ulong to uint
716if ge i get lkcpn 0
717ret 0
718end
719ret get lkcp i
720end
721
722fn lk_f i ulong to uint
723xc = lk_c i
724if and ge xc 65 le xc 90
725ret add xc 32
726end
727if eq xc 8490
728ret 107
729end
730if eq xc 383
731ret 115
732end
733ret xc
734end
735
736fn lk_inr c uint a uint b uint to bool
737ret and ge c a le c b
738end
739
740note Approximate Unicode \w: see the header note for the exact divergence.
741fn lk_word c uint to bool
742if lt c 128
743ret or or lk_inr c 48 57 lk_inr c 97 122 or lk_inr c 65 90 eq c 95
744end
745if lk_inr c 128 191
746ret or eq c 170 or eq c 181 eq c 186
747end
748if or eq c 215 eq c 247
749ret false
750end
751if lk_inr c 0x2000 0x2bff
752ret lk_word2 c
753end
754if lk_inr c 0x3000 0x303f
755ret or lk_inr c 0x3005 0x3007 or lk_inr c 0x3021 0x302f or lk_inr c 0x3031 0x3035 lk_inr c 0x3038 0x303c
756end
757if lk_inr c 0xfe10 0xfe6f
758ret or lk_inr c 0xfe20 0xfe2f or lk_inr c 0xfe33 0xfe34 lk_inr c 0xfe4d 0xfe4f
759end
760if lk_inr c 0xff00 0xff65
761ret lk_word3 c
762end
763if or lk_inr c 0xe000 0xf8ff lk_inr c 0x1f000 0x1faff
764ret false
765end
766ret true
767end
768
769fn lk_word2 c uint to bool
770if or lk_inr c 0x203f 0x2040 eq c 0x2054
771ret true
772end
773if or eq c 0x2071 or eq c 0x207f lk_inr c 0x2090 0x209c
774ret true
775end
776if lk_inr c 0x20d0 0x20f0
777ret true
778end
779if lk_inr c 0x2100 0x214f
780ret lk_word4 c
781end
782if or lk_inr c 0x2160 0x2188 lk_inr c 0x24b6 0x24e9
783ret true
784end
785ret false
786end
787
788fn lk_word4 c uint to bool
789if or eq c 0x2102 or eq c 0x2107 or lk_inr c 0x210a 0x2113 eq c 0x2115
790ret true
791end
792if or lk_inr c 0x2119 0x211d or eq c 0x2124 or eq c 0x2126 eq c 0x2128
793ret true
794end
795if or lk_inr c 0x212a 0x212d or lk_inr c 0x212f 0x2139 lk_inr c 0x213c 0x213f
796ret true
797end
798ret or lk_inr c 0x2145 0x2149 eq c 0x214e
799end
800
801fn lk_word3 c uint to bool
802if or lk_inr c 0xff10 0xff19 or lk_inr c 0xff21 0xff3a lk_inr c 0xff41 0xff5a
803ret true
804end
805ret eq c 0xff3f
806end
807
808fn lk_sp c uint to bool
809if or lk_inr c 9 13 or eq c 32 or eq c 133 eq c 160
810ret true
811end
812if or eq c 0x1680 or lk_inr c 0x2000 0x200a or eq c 0x2028 eq c 0x2029
813ret true
814end
815ret or eq c 0x202f or eq c 0x205f eq c 0x3000
816end
817
818fn lk_nd10 c uint a uint to bool
819ret and ge c a lt c add a 10
820end
821
822note Unicode Nd blocks (Unicode 15.1 DerivedNumericType Decimal), ten digits each except 1D7CE.
823fn lk_nd c uint to bool
824if lt c 0x660
825ret lk_nd10 c 48
826end
827if or lk_nd10 c 0x660 or lk_nd10 c 0x6f0 or lk_nd10 c 0x7c0 or lk_nd10 c 0x966 lk_nd10 c 0x9e6
828ret true
829end
830if or lk_nd10 c 0xa66 or lk_nd10 c 0xae6 or lk_nd10 c 0xb66 or lk_nd10 c 0xbe6 lk_nd10 c 0xc66
831ret true
832end
833if or lk_nd10 c 0xce6 or lk_nd10 c 0xd66 or lk_nd10 c 0xde6 or lk_nd10 c 0xe50 lk_nd10 c 0xed0
834ret true
835end
836if or lk_nd10 c 0xf20 or lk_nd10 c 0x1040 or lk_nd10 c 0x1090 or lk_nd10 c 0x17e0 lk_nd10 c 0x1810
837ret true
838end
839if or lk_nd10 c 0x1946 or lk_nd10 c 0x19d0 or lk_nd10 c 0x1a80 or lk_nd10 c 0x1a90 lk_nd10 c 0x1b50
840ret true
841end
842if or lk_nd10 c 0x1bb0 or lk_nd10 c 0x1c40 or lk_nd10 c 0x1c50 or lk_nd10 c 0xa620 lk_nd10 c 0xa8d0
843ret true
844end
845if or lk_nd10 c 0xa900 or lk_nd10 c 0xa9d0 or lk_nd10 c 0xa9f0 or lk_nd10 c 0xaa50 lk_nd10 c 0xabf0
846ret true
847end
848if lk_nd10 c 0xff10
849ret true
850end
851if lt c 0x10000
852ret false
853end
854ret lk_ndx c
855end
856
857fn lk_ndx c uint to bool
858if or lk_nd10 c 0x104a0 or lk_nd10 c 0x10d30 or lk_nd10 c 0x11066 or lk_nd10 c 0x110f0 lk_nd10 c 0x11136
859ret true
860end
861if or lk_nd10 c 0x111d0 or lk_nd10 c 0x112f0 or lk_nd10 c 0x11450 or lk_nd10 c 0x114d0 lk_nd10 c 0x11650
862ret true
863end
864if or lk_nd10 c 0x116c0 or lk_nd10 c 0x11730 or lk_nd10 c 0x118e0 or lk_nd10 c 0x11950 lk_nd10 c 0x11c50
865ret true
866end
867if or lk_nd10 c 0x11d50 or lk_nd10 c 0x11da0 or lk_nd10 c 0x11f50 or lk_nd10 c 0x16a60 lk_nd10 c 0x16ac0
868ret true
869end
870if or lk_nd10 c 0x16b50 or lk_nd10 c 0x1e140 or lk_nd10 c 0x1e2f0 or lk_nd10 c 0x1e4f0 lk_nd10 c 0x1e950
871ret true
872end
873ret or lk_inr c 0x1d7ce 0x1d7ff lk_nd10 c 0x1fbf0
874end
875
876fn lk_wb i ulong to bool
877xa = false
878if gt i 0
879xa = lk_word lk_c sub i 1
880end
881xb = false
882if lt i get lkcpn 0
883xb = lk_word lk_c i
884end
885ret ne xa xb
886end
887
888fn lk_isws i ulong to bool
889if ge i get lkcpn 0
890ret false
891end
892ret lk_sp lk_c i
893end
894
895fn lk_skws i ulong to ulong
896while lk_isws i bound 999999
897i = add i 1
898end
899ret i
900end
901
902fn lk_nsend i ulong to ulong
903while lt i get lkcpn 0 bound 999999
904if lk_isws i
905ret i
906end
907i = add i 1
908end
909ret i
910end
911
912note (?i) literal: s is lowercase ASCII.
913fn lk_lit i ulong s view uchar * to bool
914for xj ulong len s
915if ne lk_f add i xj uint get s xj
916ret false
917end
918end
919ret true
920end
921
922fn lk_litc i ulong s view uchar * to bool
923for xj ulong len s
924if ne lk_c add i xj uint get s xj
925ret false
926end
927end
928ret true
929end
930
931note to_ascii_lowercase comparison (no Unicode folding).
932fn lk_lita i ulong s view uchar * to bool
933for xj ulong len s
934xc = lk_c add i xj
935if lk_inr xc 65 90
936xc = add xc 32
937end
938if ne xc uint get s xj
939ret false
940end
941end
942ret true
943end
944
945fn lk_az c uint to bool
946ret lk_inr c 97 122
947end
948
949fn lk_an c uint to bool
950ret or lk_inr c 97 122 lk_inr c 48 57
951end
952
953fn lk_hx c uint to bool
954ret or lk_inr c 97 102 lk_inr c 48 57
955end
956
957fn lk_ad c uint to bool
958ret lk_inr c 48 57
959end
960
961text lkk0 "password"
962text lkk1 "passwd"
963text lkk2 "secret"
964text lkk3 "api"
965text lkk4 "key"
966text lkk5 "private"
967text lkk6 "access"
968text lkk7 "token"
969text lkk8 "authorization"
970text lkk9 "auth"
971text lkk10 "cookie"
972text lkk11 "session"
973text lkk12 "id"
974text lkkis "is"
975text lkkdd "--"
976text lkksk "sk-"
977text lkkghp "ghp_"
978text lkkgho "gho_"
979text lkkgpat "github_pat_"
980text lkkxox "xox"
981text lkkakia "akia"
982text lkkbeg "-----begin"
983text lkkbear "bearer"
984text lkkcss "://"
985text lkklh "localhost"
986text lkkloc "local"
987text lkkint "internal"
988text lkkts "ts.net"
989text lkk18 ":18"
990text lkkpid "pid"
991text lkrt0 "~/"
992text lkrt1 "~\\"
993text lkrn0 "home"
994text lkrn1 "root"
995text lkrn2 "tmp"
996text lkrn3 "var"
997text lkrn4 "etc"
998text lkrn5 "opt"
999text lkrn6 "srv"
1000text lkrn7 "run"
1001text lkrn8 "proc"
1002text lkrn9 "mnt"
1003text lkrn10 "media"
1004text lkrn11 "Users"
1005text lkrn12 "private"
1006
1007fn lk_sep i ulong to ulong
1008xc = lk_f i
1009if or eq xc 95 eq xc 45
1010ret add i 1
1011end
1012ret i
1013end
1014
1015note First keyword alternative that fits at i (end index), 0 when none.
1016fn lk_kw i ulong to ulong
1017if lk_lit i lkk0
1018ret add i 8
1019end
1020if lk_lit i lkk1
1021ret add i 6
1022end
1023if lk_lit i lkk2
1024ret add i 6
1025end
1026if lk_lit i lkk3
1027xq = lk_sep add i 3
1028if lk_lit xq lkk4
1029ret add xq 3
1030end
1031end
1032if lk_lit i lkk5
1033xq = lk_sep add i 7
1034if lk_lit xq lkk4
1035ret add xq 3
1036end
1037end
1038if lk_lit i lkk6
1039xq = lk_sep add i 6
1040if lk_lit xq lkk7
1041ret add xq 5
1042end
1043end
1044if lk_lit i lkk8
1045ret add i 13
1046end
1047if lk_lit i lkk9
1048ret add i 4
1049end
1050if lk_lit i lkk10
1051ret add i 6
1052end
1053if lk_lit i lkk11
1054ret lk_kwses add i 7
1055end
1056ret 0
1057end
1058
1059fn lk_kwses i ulong to ulong
1060xq = lk_sep i
1061if lk_lit xq lkk4
1062ret add xq 3
1063end
1064if lk_lit xq lkk7
1065ret add xq 5
1066end
1067if lk_lit xq lkk12
1068ret add xq 2
1069end
1070ret 0
1071end
1072
1073note auth(?:orization)? backtracks to the bare auth when the long form's tail fails.
1074fn lk_kw2 i ulong to ulong
1075if lk_lit i lkk8
1076ret add i 4
1077end
1078ret 0
1079end
1080
1081note \s*(?:=|:|\bis\b)\s*\S+ from q; returns match end, 0 if none.
1082fn lk_s1r q ulong to ulong
1083xr = lk_skws q
1084xc = lk_c xr
1085xt = ulong 0
1086if or eq xc 61 eq xc 58
1087xt = add xr 1
1088else
1089if not and lk_lit xr lkkis and lk_wb xr lk_wb add xr 2
1090ret 0
1091end
1092xt = add xr 2
1093end
1094xt = lk_skws xt
1095if ge xt get lkcpn 0
1096ret 0
1097end
1098ret lk_nsend xt
1099end
1100
1101fn lk_s1 i ulong to ulong
1102if not lk_wb i
1103ret 0
1104end
1105xk = lk_kw i
1106if eq xk 0
1107ret 0
1108end
1109xe = lk_s1r xk
1110if ne xe 0
1111ret xe
1112end
1113xk = lk_kw2 i
1114if eq xk 0
1115ret 0
1116end
1117ret lk_s1r xk
1118end
1119
1120fn lk_s2t k ulong to bool
1121if not lk_isws k
1122ret false
1123end
1124ret lt lk_skws k get lkcpn 0
1125end
1126
1127fn lk_s2k q ulong to bool
1128xk = lk_kw q
1129if ne xk 0
1130if lk_s2t xk
1131ret true
1132end
1133end
1134xk = lk_kw2 q
1135if ne xk 0
1136ret lk_s2t xk
1137end
1138ret false
1139end
1140
1141fn lk_s2 i ulong to bool
1142if not lk_lit i lkkdd
1143ret false
1144end
1145xq = add i 2
1146while lt xq get lkcpn 0 bound 999999
1147if lk_s2k xq
1148ret true
1149end
1150xr = xq
1151while lk_an lk_f xr bound 999999
1152xr = add xr 1
1153end
1154if eq xr xq
1155ret false
1156end
1157xc = lk_f xr
1158if not or eq xc 95 eq xc 45
1159ret false
1160end
1161xq = add xr 1
1162end
1163ret false
1164end
1165
1166fn lk_s3 i ulong to bool
1167if not lk_wb i
1168ret false
1169end
1170xp = ulong 0
1171if lk_lit i lkksk
1172xp = add i 3
1173end
1174if lk_lit i lkkghp
1175xp = add i 4
1176end
1177if lk_lit i lkkgho
1178xp = add i 4
1179end
1180if lk_lit i lkkgpat
1181xp = add i 11
1182end
1183if lk_lit i lkkakia
1184xp = add i 4
1185end
1186if lk_lit i lkkxox
1187xc = lk_f add i 3
1188if and or or eq xc 98 eq xc 97 or or eq xc 112 eq xc 114 eq xc 115 eq lk_f add i 4 45
1189xp = add i 5
1190end
1191end
1192if eq xp 0
1193ret false
1194end
1195xc = lk_f xp
1196ret or lk_an xc or eq xc 95 eq xc 45
1197end
1198
1199fn lk_s4p q ulong to bool
1200if not lk_lit q lkk5
1201ret false
1202end
1203if not lk_isws add q 7
1204ret false
1205end
1206ret lk_lit lk_skws add q 7 lkk4
1207end
1208
1209fn lk_s4 i ulong to bool
1210if not lk_lit i lkkbeg
1211ret false
1212end
1213xq = add i 10
1214if not lk_isws xq
1215ret false
1216end
1217xq = lk_skws xq
1218while lt xq get lkcpn 0 bound 999999
1219if lk_s4p xq
1220ret true
1221end
1222xr = xq
1223while lk_az lk_f xr bound 999999
1224xr = add xr 1
1225end
1226if eq xr xq
1227ret false
1228end
1229if not lk_isws xr
1230ret false
1231end
1232xq = lk_skws xr
1233end
1234ret false
1235end
1236
1237fn lk_s5 i ulong to bool
1238if not and lk_wb i lk_lit i lkkbear
1239ret false
1240end
1241xq = add i 6
1242if not lk_isws xq
1243ret false
1244end
1245xq = lk_skws xq
1246xk = ulong 0
1247while true bound 999999
1248xc = lk_f xq
1249if not or lk_an xc or or eq xc 46 eq xc 95 eq xc 45
1250break
1251end
1252xk = add xk 1
1253xq = add xq 1
1254end
1255ret ge xk 8
1256end
1257
1258fn lk_s6 i ulong to bool
1259if not lk_az lk_f i
1260ret false
1261end
1262xk = add i 1
1263while true bound 999999
1264xc = lk_f xk
1265if not or lk_an xc or or eq xc 43 eq xc 46 eq xc 45
1266break
1267end
1268xk = add xk 1
1269end
1270if not lk_litc xk lkkcss
1271ret false
1272end
1273ret lk_s6u add xk 3
1274end
1275
1276note [^\s/@]+:[^\s/@]+@ from u.
1277fn lk_s6u u ulong to bool
1278xr = u
1279xcol = false
1280while lt xr get lkcpn 0 bound 999999
1281xc = lk_c xr
1282if or lk_sp xc or eq xc 47 eq xc 64
1283break
1284end
1285if and eq xc 58 and gt xr u lt add xr 1 get lkcpn 0
1286if lk_s6y add xr 1
1287xcol = true
1288end
1289end
1290xr = add xr 1
1291end
1292ret and xcol eq lk_c xr 64
1293end
1294
1295fn lk_s6y p ulong to bool
1296xc = lk_c p
1297ret not or lk_sp xc or or eq xc 47 eq xc 64 ge p get lkcpn 0
1298end
1299
1300fn lk_exctx to bool
1301for xi ulong get lkcpn 0
1302if lk_lita xi lkrfc
1303ret true
1304end
1305end
1306ret false
1307end
1308
1309fn lk_exm i ulong e ulong to bool
1310if ne sub e i len lkrfck
1311ret false
1312end
1313ret lk_lita i lkrfck
1314end
1315
1316fn lk_secret to bool
1317xex = lk_exctx
1318for xi ulong get lkcpn 0
1319xe = lk_s1 xi
1320if ne xe 0
1321if not and xex lk_exm xi xe
1322ret true
1323end
1324else
1325if lk_secr2 xi
1326ret true
1327end
1328end
1329end
1330ret false
1331end
1332
1333fn lk_secr2 i ulong to bool
1334if or lk_s2 i or lk_s3 i lk_s4 i
1335ret true
1336end
1337ret or lk_s5 i lk_s6 i
1338end
1339
1340fn lk_eml c uint to bool
1341ret or lk_an c or or eq c 46 eq c 95 or or eq c 37 eq c 43 eq c 45
1342end
1343
1344fn lk_emd c uint to bool
1345ret or lk_an c or eq c 46 eq c 45
1346end
1347
1348fn lk_emr b ulong to bool
1349xe = b
1350while lk_emd lk_f xe bound 999999
1351xe = add xe 1
1352end
1353xj = add b 1
1354while lt xj xe bound 999999
1355if eq lk_c xj 46
1356xl = add xj 1
1357while lk_az lk_f xl bound 999999
1358xl = add xl 1
1359end
1360if and ge sub xl add xj 1 2 lk_wb xl
1361ret true
1362end
1363end
1364xj = add xj 1
1365end
1366ret false
1367end
1368
1369fn lk_ema a ulong to bool
1370xs = a
1371while gt xs 0 bound 999999
1372if not lk_eml lk_f sub xs 1
1373break
1374end
1375xs = sub xs 1
1376end
1377if eq xs a
1378ret false
1379end
1380xok = false
1381xj = xs
1382while lt xj a bound 999999
1383if lk_wb xj
1384xok = true
1385break
1386end
1387xj = add xj 1
1388end
1389if not xok
1390ret false
1391end
1392ret lk_emr add a 1
1393end
1394
1395fn lk_email to bool
1396for xi ulong get lkcpn 0
1397if eq lk_c xi 64
1398if lk_ema xi
1399ret true
1400end
1401end
1402end
1403ret false
1404end
1405
1406fn lk_ctrl to bool
1407for xi ulong get lkcpn 0
1408xc = lk_c xi
1409if or lt xc 32 lk_inr xc 127 159
1410ret true
1411end
1412end
1413ret false
1414end
1415
1416fn lk_pdel c uint to bool
1417if lk_sp c
1418ret true
1419end
1420if or or eq c 40 eq c 60 or eq c 96 eq c 34
1421ret true
1422end
1423ret or or eq c 39 eq c 91 or or eq c 61 eq c 58 eq c 44
1424end
1425
1426fn lk_seg c uint to bool
1427ret or lk_an c or or eq c 46 eq c 95 eq c 45
1428end
1429
1430fn lk_path i ulong to bool
1431if gt i 0
1432if not lk_pdel lk_c sub i 1
1433ret false
1434end
1435end
1436xc = lk_c i
1437if eq xc 126
1438xd = lk_c add i 1
1439ret or eq xd 47 eq xd 92
1440end
1441if ne xc 47
1442ret false
1443end
1444xr = add i 1
1445while lk_seg lk_f xr bound 999999
1446xr = add xr 1
1447end
1448ret and gt xr add i 1 eq lk_c xr 47
1449end
1450
1451fn lk_rootn q ulong s view uchar * to bool
1452if not lk_litc q s
1453ret false
1454end
1455ret eq lk_c add q len s 47
1456end
1457
1458fn lk_root i ulong to bool
1459if or lk_litc i lkrt0 lk_litc i lkrt1
1460ret true
1461end
1462if ne lk_c i 47
1463ret false
1464end
1465xq = add i 1
1466if or or lk_rootn xq lkrn0 lk_rootn xq lkrn1 or lk_rootn xq lkrn2 lk_rootn xq lkrn3
1467ret true
1468end
1469if or or lk_rootn xq lkrn4 lk_rootn xq lkrn5 or lk_rootn xq lkrn6 lk_rootn xq lkrn7
1470ret true
1471end
1472if or or lk_rootn xq lkrn8 lk_rootn xq lkrn9 or lk_rootn xq lkrn10 lk_rootn xq lkrn11
1473ret true
1474end
1475ret lk_rootn xq lkrn12
1476end
1477
1478fn lk_hexn q ulong k ulong to bool
1479for xj ulong k
1480if not lk_hx lk_f add q xj
1481ret false
1482end
1483end
1484ret true
1485end
1486
1487fn lk_uuid i ulong to bool
1488if not and lk_wb i lk_hexn i 8
1489ret false
1490end
1491if not and eq lk_c add i 8 45 lk_hexn add i 9 4
1492ret false
1493end
1494if not and eq lk_c add i 13 45 lk_hexn add i 14 4
1495ret false
1496end
1497if not and eq lk_c add i 18 45 lk_hexn add i 19 4
1498ret false
1499end
1500if not and eq lk_c add i 23 45 lk_hexn add i 24 12
1501ret false
1502end
1503ret lk_wb add i 36
1504end
1505
1506fn lk_hc c uint to bool
1507ret or lk_an c or eq c 95 eq c 45
1508end
1509
1510fn lk_hpre d ulong to bool
1511if eq d 0
1512ret false
1513end
1514if not lk_hc lk_f sub d 1
1515ret false
1516end
1517xs = sub d 1
1518while true bound 999999
1519xc = lk_f xs
1520if lk_hc xc
1521if lk_wb xs
1522ret true
1523end
1524else
1525if ne xc 46
1526ret false
1527end
1528if eq xs 0
1529ret false
1530end
1531if not lk_hc lk_f sub xs 1
1532ret false
1533end
1534end
1535if eq xs 0
1536ret false
1537end
1538xs = sub xs 1
1539end
1540ret false
1541end
1542
1543fn lk_hsuf d ulong s view uchar * to bool
1544if not lk_lit add d 1 s
1545ret false
1546end
1547if not lk_wb add add d 1 len s
1548ret false
1549end
1550ret lk_hpre d
1551end
1552
1553fn lk_host i ulong to bool
1554if and lk_wb i lk_lit i lkklh
1555if lk_wb add i 9
1556ret true
1557end
1558end
1559if ne lk_c i 46
1560ret false
1561end
1562ret or lk_hsuf i lkkloc or lk_hsuf i lkkint lk_hsuf i lkkts
1563end
1564
1565fn lk_drun q ulong to ulong
1566xk = ulong 0
1567while lk_nd lk_c add q xk bound 999999
1568if ge add q xk get lkcpn 0
1569break
1570end
1571xk = add xk 1
1572end
1573ret xk
1574end
1575
1576fn lk_ip4 i ulong to bool
1577if not lk_wb i
1578ret false
1579end
1580xq = i
1581for xo ulong 3
1582xk = lk_drun xq
1583if or eq xk 0 gt xk 3
1584ret false
1585end
1586xq = add xq xk
1587if ne lk_c xq 46
1588ret false
1589end
1590xq = add xq 1
1591end
1592xk = lk_drun xq
1593if or eq xk 0 gt xk 3
1594ret false
1595end
1596ret lk_wb add xq xk
1597end
1598
1599fn lk_ip6 i ulong to bool
1600if ne lk_c i 91
1601ret false
1602end
1603xr = add i 1
1604while true bound 999999
1605xc = lk_f xr
1606if not or lk_hx xc eq xc 58
1607break
1608end
1609xr = add xr 1
1610end
1611ret and ge sub xr add i 1 2 eq lk_c xr 93
1612end
1613
1614fn lk_port i ulong to bool
1615if not lk_litc i lkk18
1616ret false
1617end
1618if not and lk_ad lk_c add i 3 and lk_ad lk_c add i 4 lk_ad lk_c add i 5
1619ret false
1620end
1621ret lk_wb add i 6
1622end
1623
1624fn lk_pid i ulong to bool
1625if not and lk_wb i lk_lit i lkkpid
1626ret false
1627end
1628xq = lk_skws add i 3
1629xr = xq
1630while lk_ad lk_c xr bound 999999
1631xr = add xr 1
1632end
1633if eq xr xq
1634ret false
1635end
1636ret lk_wb xr
1637end
1638
1639fn lk_redact to bool
1640for xi ulong get lkcpn 0
1641if or or lk_path xi lk_root xi or lk_uuid xi lk_host xi
1642ret true
1643end
1644if or or lk_ip4 xi lk_ip6 xi or lk_port xi lk_pid xi
1645ret true
1646end
1647end
1648ret false
1649end
1650
1651note Decode raw [p, e) into lkcp (input already UTF-8 validated).
1652fn lk_decode p ulong e ulong to void
1653xn = ulong 0
1654while lt p e bound 999999
1655if ge xn len lkcp
1656lk_fail lkemfld 0
1657end
1658put lkcp xn lk_dcp p
1659p = add p get lkdl 0
1660xn = add xn 1
1661end
1662put lkcpn 0 xn
1663end
1664
1665note 0 public, 1 credential, 2 email, 3 control, 4 needs redaction.
1666fn lk_fchk p ulong e ulong to uchar
1667lk_decode p e
1668if lk_secret
1669ret 1
1670end
1671if lk_email
1672ret 2
1673end
1674if lk_ctrl
1675ret 3
1676end
1677if lk_redact
1678ret 4
1679end
1680ret 0
1681end
1682
1683fn lk_lineok p ulong e ulong line ulong to bool
1684xcnt = ulong 0
1685xred = false
1686xs = p
1687while true bound 999999
1688xf = lk_find 0 xs e 9
1689if eq xcnt 8
1690lk_fail lkem9 line
1691end
1692xr = lk_fchk xs xf
1693if eq xr 1
1694lk_fail lkemsc line
1695end
1696if eq xr 2
1697lk_fail lkemem line
1698end
1699if eq xr 3
1700lk_fail lkemct line
1701end
1702if eq xr 4
1703xred = true
1704end
1705xcnt = add xcnt 1
1706if ge xf e
1707break
1708end
1709xs = add xf 1
1710end
1711if lt xcnt 5
1712lk_fail lkem4 line
1713end
1714ret not xred
1715end
1716
1717note check_public over a loaded region; lkhas must be set and UTF-8 already proven.
1718fn lk_guard slot ulong to void
1719xp = lk_roff slot
1720xn = lk_rlen slot
1721xe = add xp xn
1722if eq xn 0
1723lk_fail lkemnl 0
1724end
1725if ne get lkraw sub xe 1 10
1726lk_fail lkemnl 0
1727end
1728note no CR anywhere in the region (lk_find scans the whole slot; a for loop traps at 1000000).
1729if lt lk_find 0 xp xe 13 xe
1730lk_fail lkemnl 0
1731end
1732xl = lk_find 0 xp xe 10
1733if not lk_rawis xp xl lkhead
1734lk_fail lkemhd 0
1735end
1736xpub = true
1737xline = ulong 2
1738xs = add xl 1
1739while lt xs xe bound 999999
1740xl = lk_find 0 xs xe 10
1741if not lk_lineok xs xl xline
1742xpub = false
1743end
1744xline = add xline 1
1745xs = add xl 1
1746end
1747if not xpub
1748lk_fail lkempj 0
1749end
1750end
1751
1752fn lk_rawis p ulong e ulong s view uchar * to bool
1753if ne sub e p len s
1754ret false
1755end
1756for xj ulong len s
1757if ne get lkraw add p xj get s xj
1758ret false
1759end
1760end
1761ret true
1762end
1763
1764fn sp_ledger_check to void
1765put lkrn 0 0
1766lk_read lkp0 0
1767if eq get lkhas 0 0
1768ret
1769end
1770if not lk_utf8 0
1771lk_fail lkemrd 0
1772end
1773lk_guard 0
1774end
1775
1776fn sp_ledger_check_at path view uchar * to void
1777put lkrn 0 0
1778lk_read path 0
1779if eq get lkhas 0 0
1780ret
1781end
1782if not lk_utf8 0
1783lk_fail lkemrd 0
1784end
1785lk_guard 0
1786end
1787
1788note ---------------------------------------------------------------- parse
1789
1790text lkow0 "drake"
1791text lkow1 "desk"
1792text lkow2 "coordinator"
1793text lkow3 "unassigned"
1794text lkc0 "research"
1795text lkc1 "symposium"
1796text lkc2 "#583"
1797text lkc3 "#584"
1798text lkc4 "inventory for site"
1799text lkc5 "agent:"
1800text lkc6 "cascade"
1801text lkc7 "decode"
1802text lkc8 "tok/s"
1803text lkc9 "flashnext"
1804text lkc10 "omega#"
1805text lkc11 "rig"
1806text lkc12 "aienos.com"
1807text lkc13 "org profile"
1808text lkc14 "readme"
1809text lkc15 "dashboard"
1810text lkc16 "alpha"
1811text lkc17 "install"
1812text lkc18 "serve-27b"
1813text lkc19 "27b server"
1814text lkc20 "imac"
1815text lkc21 "horizon"
1816text lkc22 "allen"
1817text lkc23 "aienos"
1818text lkc24 "bundle"
1819text lkc25 "merge"
1820text lkc26 "queue"
1821text lkc27 "label"
1822text lkc28 "squash"
1823text lkst0 "open"
1824text lkst1 "done"
1825text lkst2 "dropped"
1826text lknsep " | "
1827
1828fn lk_fo i ulong k ulong to ulong
1829ret get lkio add mul i 8 k
1830end
1831
1832fn lk_fl i ulong k ulong to ulong
1833ret get lkil add mul i 8 k
1834end
1835
1836note Exact byte equality of an lkcl string with a text.
1837fn lk_eqt o ulong l ulong s view uchar * to bool
1838if ne l len s
1839ret false
1840end
1841for xj ulong l
1842if ne get lkcl add o xj get s xj
1843ret false
1844end
1845end
1846ret true
1847end
1848
1849fn lk_lb c uchar to uchar
1850if and ge c 65 le c 90
1851ret add c 32
1852end
1853ret c
1854end
1855
1856note to_ascii_lowercase(lkcl[o..o+l]) starts with / contains s (s lowercase).
1857fn lk_lat o ulong l ulong p ulong s view uchar * to bool
1858if gt add p len s l
1859ret false
1860end
1861for xj ulong len s
1862if ne lk_lb get lkcl add add o p xj get s xj
1863ret false
1864end
1865end
1866ret true
1867end
1868
1869fn lk_lpre o ulong l ulong s view uchar * to bool
1870ret lk_lat o l 0 s
1871end
1872
1873fn lk_lhas o ulong l ulong s view uchar * to bool
1874for xp ulong l
1875if lk_lat o l xp s
1876ret true
1877end
1878end
1879ret eq len s 0
1880end
1881
1882fn lk_okind o ulong l ulong to uchar
1883if lk_eqt o l lkow0
1884ret 1
1885end
1886if lk_eqt o l lkow1
1887ret 2
1888end
1889if lk_eqt o l lkow2
1890ret 3
1891end
1892if lk_eqt o l lkow3
1893ret 4
1894end
1895ret 0
1896end
1897
1898note classify(item, owner): stream index into lk_sname order.
1899fn lk_class i ulong to uchar
1900xo = lk_fo i 4
1901xl = lk_fl i 4
1902if or or lk_lpre xo xl lkc0 lk_lhas xo xl lkc1 or or lk_lhas xo xl lkc2 lk_lhas xo xl lkc3 lk_lhas xo xl lkc4
1903ret 4
1904end
1905if or or lk_lpre xo xl lkc5 lk_lhas xo xl lkc6 or lk_lhas xo xl lkc7 lk_lhas xo xl lkc8
1906ret 0
1907end
1908if or lk_lhas xo xl lkc9 lk_lhas xo xl lkc10
1909ret 0
1910end
1911if lk_lpre xo xl lkc11
1912ret 2
1913end
1914if or or lk_lhas xo xl lkc12 lk_lhas xo xl lkc13 or lk_lhas xo xl lkc14 lk_lhas xo xl lkc15
1915ret 5
1916end
1917if or or lk_lhas xo xl lkc16 lk_lhas xo xl lkc17 or lk_lhas xo xl lkc18 lk_lhas xo xl lkc19
1918ret 1
1919end
1920if or or lk_lhas xo xl lkc20 lk_lhas xo xl lkc21 or lk_lhas xo xl lkc22 lk_lhas xo xl lkc23
1921ret 3
1922end
1923if lk_lhas xo xl lkc24
1924ret 3
1925end
1926if or eq get lkown i 2 or lk_lpre xo xl lkc25 lk_lpre xo xl lkc26
1927ret 6
1928end
1929if or lk_lhas xo xl lkc27 lk_lhas xo xl lkc28
1930ret 6
1931end
1932ret 7
1933end
1934
1935fn lk_lower o ulong l ulong to void
1936for xj ulong l
1937put lkcl add o xj lk_lb get lkcl add o xj
1938end
1939end
1940
1941note Status code: 1 open, 2 done, 3 dropped, 0 anything else (kept and shown as written).
1942fn lk_scode o ulong l ulong to uchar
1943if lk_eqt o l lkst0
1944ret 1
1945end
1946if lk_eqt o l lkst1
1947ret 2
1948end
1949if lk_eqt o l lkst2
1950ret 3
1951end
1952ret 0
1953end
1954
1955fn lk_notes i ulong to void
1956xo = lk_fo i 6
1957xe = add xo lk_fl i 6
1958put lknf i get lknn 0
1959put lknc i 0
1960xs = xo
1961while true bound 999999
1962xq = lk_nsep xs xe
1963lk_trim 1 xs xq
1964xa = ulong get lkt 6
1965xb = ulong get lkt 7
1966if gt xb xa
1967xn = get lknn 0
1968if ge xn LKNOTES
1969lk_fail lkemrow 0
1970end
1971put lkno xn xa
1972put lknl xn sub xb xa
1973put lknn 0 add xn 1
1974put lknc i add get lknc i 1
1975end
1976if ge xq xe
1977break
1978end
1979xs = add xq 3
1980end
1981end
1982
1983fn lk_nsep p ulong e ulong to ulong
1984while le add p 3 e bound 999999
1985if eq get lkcl p 32
1986if eq get lkcl add p 1 124
1987if eq get lkcl add p 2 32
1988ret p
1989end
1990end
1991end
1992p = add p 1
1993end
1994ret e
1995end
1996
1997fn lk_row p ulong e ulong line ulong to void
1998xi = get lkn 0
1999if ge xi LKROWS
2000lk_fail lkemrow line
2001end
2002xs = p
2003xk = ulong 0
2004while lt xk 8 bound 9
2005xf = lk_find 0 xs e 9
2006put lkio add mul xi 8 xk lk_clean xs xf
2007put lkil add mul xi 8 xk get lklast 0
2008xk = add xk 1
2009if ge xf e
2010break
2011end
2012xs = add xf 1
2013end
2014if lt xk 5
2015lk_fail lkemrst line
2016end
2017while lt xk 8 bound 9
2018put lkio add mul xi 8 xk get lkcn 0
2019put lkil add mul xi 8 xk 0
2020xk = add xk 1
2021end
2022put lkline xi line
2023lk_lower lk_fo xi 3 lk_fl xi 3
2024put lkstat xi lk_scode lk_fo xi 3 lk_fl xi 3
2025put lkown xi lk_okind lk_fo xi 2 lk_fl xi 2
2026put lkstrm xi lk_class xi
2027lk_notes xi
2028lk_rowtime xi
2029put lkn 0 add xi 1
2030end
2031
2032fn lk_rowtime i ulong to void
2033xo = lk_fo i 7
2034xv = lk_utc 1 xo add xo lk_fl i 7
2035put lkupd i xv
2036put lkupv i get lkok 0
2037xo = lk_fo i 1
2038xv = lk_utc 1 xo add xo lk_fl i 1
2039put lkopd i xv
2040put lkopv i get lkok 0
2041xat = lk_now
2042put lkage i -1
2043if ne get lkupv i 0
2044put lkage i sub xat get lkupd i
2045else
2046if ne get lkopv i 0
2047put lkage i sub xat get lkopd i
2048end
2049end
2050end
2051
2052note parse_ledger over the guarded projection: header line skipped, every other line a row.
2053fn lk_parse to void
2054put lkn 0 0
2055put lknn 0 0
2056if eq get lkhas 0 0
2057ret
2058end
2059xp = lk_roff 0
2060xe = add xp lk_rlen 0
2061xl = lk_find 0 xp xe 10
2062xs = add xl 1
2063xline = ulong 2
2064while lt xs xe bound 999999
2065xl = lk_find 0 xs xe 10
2066lk_row xs xl xline
2067xline = add xline 1
2068xs = add xl 1
2069end
2070end
2071
2072note Rust str::lines: split at LF, drop one CR before it; no empty trailing line.
2073fn lk_lend p ulong e ulong to ulong
2074xl = lk_find 0 p e 10
2075if gt xl p
2076if eq get lkraw sub xl 1 13
2077ret sub xl 1
2078end
2079end
2080ret xl
2081end
2082
2083fn lk_pulse to void
2084put lkpn 0 0
2085if eq get lkhas 1 0
2086ret
2087end
2088xp = lk_roff 1
2089xe = add xp lk_rlen 1
2090while lt xp xe bound 999999
2091xl = lk_lend xp xe
2092xt = lk_find 0 xp xl 9
2093if lt xt xl
2094lk_pair xp xt xl
2095end
2096xp = add lk_find 0 xp xe 10 1
2097end
2098end
2099
2100fn lk_pair p ulong t ulong e ulong to void
2101xn = get lkpn 0
2102if ge xn 1024
2103lk_fail lkemrow 0
2104end
2105put lkpk mul xn 2 lk_clean p t
2106put lkpk add mul xn 2 1 get lklast 0
2107put lkpv mul xn 2 lk_clean add t 1 e
2108put lkpv add mul xn 2 1 get lklast 0
2109put lkpn 0 add xn 1
2110end
2111
2112text lkmk0 "checked"
2113text lkmk1 "model"
2114text lkmk2 "plan"
2115text lkmk3 "limit"
2116
2117note Copy raw [p, e) into lkcl unchanged (trimmed by the caller); length in lklast.
2118fn lk_copy p ulong e ulong to ulong
2119xo = get lkcn 0
2120while lt p e bound 999999
2121lk_cput get lkraw p
2122p = add p 1
2123end
2124put lklast 0 sub get lkcn 0 xo
2125ret xo
2126end
2127
2128fn lk_rawt p ulong e ulong s view uchar * to bool
2129lk_trim 0 p e
2130ret lk_rawis ulong get lkt 6 ulong get lkt 7 s
2131end
2132
2133note parse_models_check: last valid checked line wins; model ids in order.
2134fn lk_mcheck to void
2135put lkmcv 0 0
2136put lkmidn 0 0
2137if eq get lkhas 2 0
2138ret
2139end
2140xp = lk_roff 2
2141xe = add xp lk_rlen 2
2142while lt xp xe bound 999999
2143xl = lk_lend xp xe
2144xt = lk_find 0 xp xl 9
2145if lt xt xl
2146lk_mline xp xt xl
2147end
2148xp = add lk_find 0 xp xe 10 1
2149end
2150end
2151
2152fn lk_mline p ulong t ulong e ulong to void
2153if lk_rawt p t lkmk0
2154xv = lk_utc 0 add t 1 e
2155if eq get lkok 0 1
2156lk_trim 0 add t 1 e
2157put lkmc 0 lk_copy ulong get lkt 6 ulong get lkt 7
2158put lkmc 1 get lklast 0
2159put lkmcv 0 1
2160end
2161ret
2162end
2163if lk_rawt p t lkmk1
2164lk_trim 0 add t 1 e
2165if gt get lkt 7 get lkt 6
2166xn = get lkmidn 0
2167if ge xn 1024
2168lk_fail lkemrow 0
2169end
2170put lkmid mul xn 2 lk_clean add t 1 e
2171put lkmid add mul xn 2 1 get lklast 0
2172put lkmidn 0 add xn 1
2173end
2174end
2175end
2176
2177note Split [p, e) at tabs into lkt-free scratch: field starts/ends in the caller's arrays.
2178fn lk_fields p ulong e ulong fs edit ulong 16 fe edit ulong 16 to ulong
2179xk = ulong 0
2180xs = p
2181while lt xk 16 bound 17
2182xf = lk_find 0 xs e 9
2183put fs xk xs
2184put fe xk xf
2185xk = add xk 1
2186if ge xf e
2187break
2188end
2189xs = add xf 1
2190end
2191ret xk
2192end
2193
2194note parse_utc(..).map(fmt_utc) into lkcl; 0 length when None.
2195fn lk_utcfmt p ulong e ulong to ulong
2196xv = lk_utc 0 p e
2197if eq get lkok 0 0
2198put lklast 0 0
2199ret get lkcn 0
2200end
2201ret lk_fmt xv false
2202end
2203
2204note usage_words (dash false, 40) and dash word() filtering (true, 48); then trim.
2205fn lk_words p ulong e ulong dash bool to ulong
2206xo = get lkcn 0
2207xk = ulong 0
2208xmax = ulong 40
2209if dash
2210xmax = 48
2211end
2212while lt p e bound 999999
2213if ge xk xmax
2214break
2215end
2216xc = get lkraw p
2217xn = lk_u8len p e
2218if eq xn 1
2219if lk_wkeep xc dash
2220lk_cput xc
2221xk = add xk 1
2222end
2223end
2224if eq xn 0
2225xn = 1
2226end
2227p = add p xn
2228end
2229lk_trim 1 xo get lkcn 0
2230xa = ulong get lkt 6
2231xb = ulong get lkt 7
2232put lklast 0 sub xb xa
2233ret xa
2234end
2235
2236fn lk_wkeep c uchar dash bool to bool
2237if or or and ge c 48 le c 57 and ge c 65 le c 90 or and ge c 97 le c 122 eq c 32
2238ret true
2239end
2240if eq c 46
2241ret true
2242end
2243if not dash
2244ret false
2245end
2246if or or eq c 58 eq c 95 or eq c 47 eq c 38
2247ret true
2248end
2249ret or or eq c 40 eq c 41 or eq c 43 eq c 45
2250end
2251
2252note f64 parse, round half away from zero, clamp 0..100 (NaN 0); lkok 0 when it does not parse.
2253fn lk_pct p ulong e ulong to ulong
2254lk_trim 0 p e
2255xs = ulong get lkt 6
2256xe = ulong get lkt 7
2257put lkok 0 0
2258if ge xs xe
2259ret 0
2260end
2261xneg = false
2262xc = get lkraw xs
2263if or eq xc 43 eq xc 45
2264xneg = eq xc 45
2265xs = add xs 1
2266end
2267if lk_pinf xs xe
2268put lkok 0 1
2269if xneg
2270ret 0
2271end
2272ret 100
2273end
2274if lk_pnan xs xe
2275put lkok 0 1
2276ret 0
2277end
2278xv = lk_pdec xs xe
2279if xneg
2280ret 0
2281end
2282ret xv
2283end
2284
2285text lkfinf "inf"
2286text lkfinfy "infinity"
2287text lkfnan "nan"
2288
2289fn lk_rawci p ulong e ulong s view uchar * to bool
2290if ne sub e p len s
2291ret false
2292end
2293for xj ulong len s
2294if ne lk_lb get lkraw add p xj get s xj
2295ret false
2296end
2297end
2298ret true
2299end
2300
2301fn lk_pinf p ulong e ulong to bool
2302ret or lk_rawci p e lkfinf lk_rawci p e lkfinfy
2303end
2304
2305fn lk_pnan p ulong e ulong to bool
2306ret lk_rawci p e lkfnan
2307end
2308
2309note Decimal digits[.digits][(e|E)[+-]digits]; value from the integer part and first fraction digit.
2310fn lk_pdec p ulong e ulong to ulong
2311xdg = new uchar 512 0
2312xnd = ulong 0
2313xip = long 0
2314xdot = false
2315while lt p e bound 999999
2316xc = get lkraw p
2317if and ge xc 48 le xc 57
2318if lt xnd 512
2319put xdg xnd sub xc 48
2320xnd = add xnd 1
2321end
2322if not xdot
2323xip = add xip 1
2324end
2325else
2326if and eq xc 46 not xdot
2327xdot = true
2328else
2329break
2330end
2331end
2332p = add p 1
2333end
2334if eq xnd 0
2335ret 0
2336end
2337if lt p e
2338xc = get lkraw p
2339if not or eq xc 101 eq xc 69
2340ret 0
2341end
2342xx = lk_pint 0 add p 1 e
2343if eq get lkok 0 0
2344ret 0
2345end
2346xip = add xip xx
2347end
2348put lkok 0 1
2349ret lk_round view xdg xnd xip
2350end
2351
2352fn lk_rinp ip long nd ulong to bool
2353if lt ip 0
2354ret false
2355end
2356ret lt ulong ip nd
2357end
2358
2359fn lk_round dg view uchar 512 nd ulong ip long to ulong
2360xv = ulong 0
2361xi = long 0
2362while lt xi ip bound 999999
2363if lt ulong xi nd
2364xv = add mul xv 10 ulong get dg ulong xi
2365else
2366xv = mul xv 10
2367end
2368if gt xv 100
2369ret 100
2370end
2371xi = add xi 1
2372end
2373if lk_rinp ip nd
2374if ge get dg ulong ip 5
2375xv = add xv 1
2376end
2377end
2378if gt xv 100
2379ret 100
2380end
2381ret xv
2382end
2383
2384note claude-usage.tsv: checked/plan/limit rows; limits capped at 1024 (refusal beyond).
2385fn lk_usage to void
2386put lkun 0 0
2387put lkuv 0 0
2388put lkuc 1 0
2389put lkup 1 0
2390if eq get lkhas 3 0
2391ret
2392end
2393xp = lk_roff 3
2394xe = add xp lk_rlen 3
2395xfs = new ulong 16 0
2396xfe = new ulong 16 0
2397while lt xp xe bound 999999
2398xl = lk_lend xp xe
2399xn = lk_fields xp xl xfs xfe
2400lk_uline xn xfs xfe
2401xp = add lk_find 0 xp xe 10 1
2402end
2403if and ne get lkuc 1 0 gt get lkun 0 0
2404put lkuv 0 1
2405end
2406end
2407
2408text lkuk0 "session"
2409text lkuk1 "weekly_all"
2410text lkuk2 "weekly_scoped"
2411
2412fn lk_uline n ulong fs view ulong 16 fe view ulong 16 to void
2413if lt n 2
2414ret
2415end
2416if lk_rawis get fs 0 get fe 0 lkmk0
2417put lkuc 0 lk_utcfmt get fs 1 get fe 1
2418put lkuc 1 get lklast 0
2419ret
2420end
2421if lk_rawis get fs 0 get fe 0 lkmk2
2422put lkup 0 lk_words get fs 1 get fe 1 false
2423put lkup 1 get lklast 0
2424ret
2425end
2426if lt n 4
2427ret
2428end
2429if lk_rawis get fs 0 get fe 0 lkmk3
2430lk_ulimit n fs fe
2431end
2432end
2433
2434fn lk_ulimit n ulong fs view ulong 16 fe view ulong 16 to void
2435xpc = lk_pct get fs 2 get fe 2
2436if eq get lkok 0 0
2437ret
2438end
2439xso = get lkcn 0
2440xsl = ulong 0
2441if gt n 4
2442xso = lk_words get fs 4 get fe 4 false
2443xsl = get lklast 0
2444end
2445xk = uchar 255
2446if lk_rawis get fs 1 get fe 1 lkuk0
2447xk = 0
2448end
2449if lk_rawis get fs 1 get fe 1 lkuk1
2450xk = 1
2451end
2452if and lk_rawis get fs 1 get fe 1 lkuk2 gt xsl 0
2453xk = 2
2454end
2455if eq xk 255
2456ret
2457end
2458xi = get lkun 0
2459if ge xi 1024
2460lk_fail lkemrow 0
2461end
2462put lkuk xi xk
2463put lkus mul xi 2 xso
2464put lkus add mul xi 2 1 xsl
2465put lkupc xi xpc
2466put lkur mul xi 2 lk_utcfmt get fs 3 get fe 3
2467put lkur add mul xi 2 1 get lklast 0
2468put lkun 0 add xi 1
2469end
2470
2471note ---------------------------------------------------------------- dash inputs
2472
2473text lkpv0 "Anthropic"
2474text lkpv1 "OpenAI Codex"
2475text lkpv2 "Google Antigravity"
2476text lkpv3 "xAI Grok"
2477text lkwin0 "5h"
2478text lkwin1 "week"
2479text lkexh "exhausted"
2480text lkrk0 "role"
2481text lkrk1 "agent"
2482text lkrk2 "seat"
2483text lkadv "advisor"
2484
2485fn lk_hexb c uchar to bool
2486ret or and ge c 48 le c 57 or and ge c 97 le c 102 and ge c 65 le c 70
2487end
2488
2489note looks_private: '@', an 8hex-4hex run, or a token ending in a mail domain with a letter host.
2490fn lk_priv p ulong e ulong to bool
2491for xi ulong sub e p
2492if eq get lkraw add p xi 64
2493ret true
2494end
2495end
2496if gt sub e p 12
2497for xj ulong sub sub e p 12
2498if lk_uuidish add p xj
2499ret true
2500end
2501end
2502end
2503ret lk_dom p e
2504end
2505
2506fn lk_uuidish p ulong to bool
2507for xj ulong 8
2508if not lk_hexb get lkraw add p xj
2509ret false
2510end
2511end
2512if ne get lkraw add p 8 45
2513ret false
2514end
2515for xk ulong 4
2516if not lk_hexb get lkraw add add p 9 xk
2517ret false
2518end
2519end
2520ret true
2521end
2522
2523fn lk_dtok c uchar to bool
2524ret or or and ge c 48 le c 57 and ge c 65 le c 90 or and ge c 97 le c 122 or eq c 46 eq c 45
2525end
2526
2527fn lk_dom p ulong e ulong to bool
2528xs = p
2529while lt xs e bound 999999
2530xt = xs
2531while lt xt e bound 999999
2532if not lk_dtok get lkraw xt
2533break
2534end
2535xt = add xt 1
2536end
2537if lk_domt xs xt
2538ret true
2539end
2540xt = add xt lk_skip1 xt e
2541xs = xt
2542end
2543ret false
2544end
2545
2546fn lk_skip1 p ulong e ulong to ulong
2547if ge p e
2548ret 1
2549end
2550xn = lk_u8len p e
2551if eq xn 0
2552ret 1
2553end
2554ret xn
2555end
2556
2557text lktld0 "com"
2558text lktld1 "org"
2559text lktld2 "net"
2560text lktld3 "io"
2561text lktld4 "ai"
2562text lktld5 "dev"
2563text lktld6 "co"
2564text lktld7 "us"
2565
2566fn lk_domt p ulong e ulong to bool
2567if or or lk_tld p e lktld0 lk_tld p e lktld1 or lk_tld p e lktld2 lk_tld p e lktld3
2568ret true
2569end
2570ret or or lk_tld p e lktld4 lk_tld p e lktld5 or lk_tld p e lktld6 lk_tld p e lktld7
2571end
2572
2573note token ends ".tld" (ASCII case-insensitive) and the host before it has an ASCII letter.
2574fn lk_tld p ulong e ulong s view uchar * to bool
2575xn = add len s 1
2576if gt xn sub e p
2577ret false
2578end
2579xd = sub e xn
2580if ne get lkraw xd 46
2581ret false
2582end
2583if not lk_rawci add xd 1 e s
2584ret false
2585end
2586while lt p xd bound 999999
2587xc = lk_lb get lkraw p
2588if and ge xc 97 le xc 122
2589ret true
2590end
2591p = add p 1
2592end
2593ret false
2594end
2595
2596note dash word(): None when private; the kept string otherwise. lkok 0 for None.
2597fn lk_dword p ulong e ulong to ulong
2598if lk_priv p e
2599put lkok 0 0
2600put lklast 0 0
2601ret 0
2602end
2603xo = lk_words p e true
2604put lkok 0 1
2605ret xo
2606end
2607
2608fn lk_pvidx p ulong e ulong to uchar
2609if lk_rawis p e lkpv0
2610ret 0
2611end
2612if lk_rawis p e lkpv1
2613ret 1
2614end
2615if lk_rawis p e lkpv2
2616ret 2
2617end
2618if lk_rawis p e lkpv3
2619ret 3
2620end
2621ret 255
2622end
2623
2624note u32 parse after trim: optional '+', digits, at most 4294967295.
2625fn lk_pu32 p ulong e ulong to ulong
2626lk_trim 0 p e
2627xs = ulong get lkt 6
2628xe = ulong get lkt 7
2629put lkok 0 0
2630if and lt xs xe eq get lkraw xs 43
2631xs = add xs 1
2632end
2633if ge xs xe
2634ret 0
2635end
2636xv = ulong 0
2637while lt xs xe bound 999999
2638xc = get lkraw xs
2639if or lt xc 48 gt xc 57
2640ret 0
2641end
2642xv = add mul xv 10 ulong sub xc 48
2643if gt xv 4294967295
2644ret 0
2645end
2646xs = add xs 1
2647end
2648put lkok 0 1
2649ret xv
2650end
2651
2652fn lk_accts to void
2653put lkann 0 0
2654put lkdcv 0 0
2655if eq get lkhas 4 0
2656ret
2657end
2658xp = lk_roff 4
2659xe = add xp lk_rlen 4
2660xfs = new ulong 16 0
2661xfe = new ulong 16 0
2662while lt xp xe bound 999999
2663xl = lk_lend xp xe
2664xn = lk_fields xp xl xfs xfe
2665lk_aline xn xfs xfe
2666xp = add lk_find 0 xp xe 10 1
2667end
2668end
2669
2670fn lk_aline n ulong fs view ulong 16 fe view ulong 16 to void
2671if and ge n 2 lk_rawis get fs 0 get fe 0 lkmk0
2672put lkdc 0 lk_utcfmt get fs 1 get fe 1
2673put lkdc 1 get lklast 0
2674put lkdcv 0 0
2675if gt get lklast 0 0
2676put lkdcv 0 1
2677end
2678ret
2679end
2680if lt n 9
2681ret
2682end
2683if not lk_rawis get fs 0 get fe 0 lkmk3
2684ret
2685end
2686xpv = lk_pvidx get fs 1 get fe 1
2687if eq xpv 255
2688ret
2689end
2690xan = lk_pu32 get fs 2 get fe 2
2691if eq get lkok 0 0
2692ret
2693end
2694lk_alimit n fs fe xpv xan
2695end
2696
2697fn lk_alimit n ulong fs view ulong 16 fe view ulong 16 pv uchar an ulong to void
2698xpc = lk_pct get fs 6 get fe 6
2699if eq get lkok 0 0
2700ret
2701end
2702xw = uchar 255
2703if lk_rawis get fs 4 get fe 4 lkwin0
2704xw = 0
2705end
2706if lk_rawis get fs 4 get fe 4 lkwin1
2707xw = 1
2708end
2709if eq xw 255
2710ret
2711end
2712xlo = lk_dword get fs 5 get fe 5
2713if eq get lkok 0 0
2714ret
2715end
2716xll = get lklast 0
2717xpo = lk_dword get fs 3 get fe 3
2718if eq get lkok 0 0
2719ret
2720end
2721xi = get lkann 0
2722if ge xi 1024
2723lk_fail lkemrow 0
2724end
2725lk_apput xi xpo xlo xll
2726lk_alast xi fs fe pv an
2727put lkaw xi xw
2728put lkapc xi xpc
2729put lkann 0 add xi 1
2730end
2731
2732note lk_apput: the four lkapl/lkal cells of limit row i (split out of lk_alimit for registers).
2733fn lk_apput i ulong po ulong lo ulong ll ulong to void
2734put lkapl mul i 2 po
2735put lkapl add mul i 2 1 get lklast 0
2736put lkal mul i 2 lo
2737put lkal add mul i 2 1 ll
2738end
2739
2740fn lk_alast i ulong fs view ulong 16 fe view ulong 16 pv uchar an ulong to void
2741put lkap i pv
2742put lkan i an
2743put lkar mul i 2 lk_utcfmt get fs 7 get fe 7
2744put lkar add mul i 2 1 get lklast 0
2745put lkax i 0
2746if lk_rawis get fs 8 get fe 8 lkexh
2747put lkax i 1
2748end
2749end
2750
2751fn lk_routes to void
2752put lkrcnt 0 0
2753put lkseat 0 0
2754if eq get lkhas 5 0
2755ret
2756end
2757xp = lk_roff 5
2758xe = add xp lk_rlen 5
2759xfs = new ulong 16 0
2760xfe = new ulong 16 0
2761while lt xp xe bound 999999
2762xl = lk_lend xp xe
2763xn = lk_fields xp xl xfs xfe
2764if ge xn 3
2765lk_rline xfs xfe
2766end
2767xp = add lk_find 0 xp xe 10 1
2768end
2769end
2770
2771fn lk_rline fs view ulong 16 fe view ulong 16 to void
2772xno = lk_dword get fs 1 get fe 1
2773if eq get lkok 0 0
2774ret
2775end
2776xnl = get lklast 0
2777xmo = lk_dword get fs 2 get fe 2
2778if eq get lkok 0 0
2779ret
2780end
2781xml = get lklast 0
2782if or eq xnl 0 eq xml 0
2783ret
2784end
2785xk = uchar 255
2786if lk_rawis get fs 0 get fe 0 lkrk0
2787xk = 0
2788end
2789if lk_rawis get fs 0 get fe 0 lkrk1
2790xk = 1
2791end
2792if lk_rawis get fs 0 get fe 0 lkrk2
2793xk = 2
2794put lkseat 0 1
2795end
2796if eq xk 255
2797ret
2798end
2799xi = get lkrcnt 0
2800if ge xi 1024
2801lk_fail lkemrow 0
2802end
2803put lkrk xi xk
2804put lkrnm mul xi 2 xno
2805put lkrnm add mul xi 2 1 xnl
2806put lkrmd mul xi 2 xmo
2807put lkrmd add mul xi 2 1 xml
2808put lkrcnt 0 add xi 1
2809end
2810
2811note ---------------------------------------------------------------- emit
2812
2813fn lk_e o ulong l ulong to void
2814for xj ulong l
2815xc8 = get lkcl add o xj
2816xd8 = xc8
2817if lt add xj 1 l
2818xd8 = get lkcl add add o xj 1
2819end
2820sr_escref xc8 xd8
2821end
2822end
2823
2824fn lk_r o ulong l ulong to void
2825for xj ulong l
2826sr_byte get lkcl add o xj
2827end
2828end
2829
2830fn lk_un v ulong to void
2831sr_num v
2832end
2833
2834fn lk_ln v long to void
2835if lt v 0
2836sr_byte 45
2837sr_num ulong neg v
2838ret
2839end
2840sr_num ulong v
2841end
2842
2843fn lk_ef i ulong k ulong to void
2844lk_e lk_fo i k lk_fl i k
2845end
2846
2847note keeper_name(): Renda to Keeper in prose, identifiers untouched; output HTML-escaped.
2848fn lk_k o ulong l ulong to void
2849xi = ulong 0
2850while lt xi l bound 999999
2851xw = lk_khit o l xi
2852if eq xw 0
2853xc8 = get lkcl add o xi
2854xd8 = xc8
2855if lt add xi 1 l
2856xd8 = get lkcl add add o xi 1
2857end
2858sr_escref xc8 xd8
2859xi = add xi 1
2860else
2861lk_kout xw
2862xi = add xi 5
2863end
2864end
2865end
2866
2867text lkkw0 "KEEPER"
2868text lkkw1 "Keeper"
2869text lkkw2 "keeper"
2870text lkkrn "renda"
2871text lkkRN "RENDA"
2872
2873fn lk_kout w uchar to void
2874if eq w 1
2875sr_raw lkkw0
2876ret
2877end
2878if eq w 2
2879sr_raw lkkw1
2880ret
2881end
2882sr_raw lkkw2
2883end
2884
2885fn lk_up c uchar to bool
2886ret and ge c 65 le c 90
2887end
2888
2889fn lk_lo c uchar to bool
2890ret and ge c 97 le c 122
2891end
2892
2893fn lk_dg c uchar to bool
2894ret and ge c 48 le c 57
2895end
2896
2897note 0 no rename at i; 1 KEEPER, 2 Keeper, 3 keeper.
2898fn lk_khit o ulong l ulong i ulong to uchar
2899if gt add i 5 l
2900ret 0
2901end
2902if not lk_lat o l i lkkrn
2903ret 0
2904end
2905xcap = eq get lkcl add o i 82
2906if gt i 0
2907if not lk_kbef get lkcl sub add o i 1 xcap
2908ret 0
2909end
2910end
2911if lt add i 5 l
2912if not lk_kaft o l add i 5 xcap
2913ret 0
2914end
2915end
2916if lk_eqat o i lkkRN
2917ret 1
2918end
2919if xcap
2920ret 2
2921end
2922ret 3
2923end
2924
2925fn lk_eqat o ulong i ulong s view uchar * to bool
2926for xj ulong len s
2927if ne get lkcl add add o i xj get s xj
2928ret false
2929end
2930end
2931ret true
2932end
2933
2934fn lk_kbef p uchar cap bool to bool
2935if or or lk_up p lk_dg p or or eq p 47 eq p 46 or or eq p 95 eq p 126 eq p 45
2936ret false
2937end
2938ret or not lk_lo p cap
2939end
2940
2941fn lk_kaft o ulong l ulong j ulong cap bool to bool
2942xn = get lkcl add o j
2943if or eq xn 47 eq xn 95
2944ret false
2945end
2946if eq xn 46
2947if lt add j 1 l
2948xt = get lkcl add add o j 1
2949ret not or or lk_up xt lk_lo xt lk_dg xt
2950end
2951ret true
2952end
2953if lk_lo xn
2954ret false
2955end
2956if lk_up xn
2957ret cap
2958end
2959ret true
2960end
2961
2962note Box footer: forge link stretched over its box (boxlink::foot_labelled).
2963text lkfa0 "<a class=\"box-link\" href=\""
2964text lkfa1 "<a class=\"box-link box-link-source\" href=\""
2965text lkfa2 "\" target=\"_blank\" rel=\"noopener noreferrer\">"
2966text lkfa3 " <span class=\"box-arrow\" aria-hidden=\"true\">↗</span></a>"
2967text lkledu "https://interplane.io/drakestapleton/aienos.com/blob/data/now/now.tsv"
2968text lkusgu "https://interplane.io/drakestapleton/aienos.com/blob/data/now/claude-usage.tsv"
2969text lkhl "#L"
2970text lkfl0 "Ledger line "
2971text lkfl1 " on the forge"
2972text lkfl2 "Plan: ledger "
2973text lksrc "Source on the forge"
2974
2975fn lk_lfoot i ulong to void
2976sr_raw lkfa0
2977sr_raw lkledu
2978sr_raw lkhl
2979lk_un get lkline i
2980sr_raw lkfa2
2981sr_raw lkfl0
2982lk_un get lkline i
2983sr_raw lkfl1
2984sr_raw lkfa3
2985end
2986
2987fn lk_sfoot href view uchar * to void
2988sr_raw lkfa1
2989sr_raw href
2990sr_raw lkfa2
2991sr_raw lksrc
2992sr_raw lkfa3
2993end
2994
2995fn lk_tfoot href view uchar * label view uchar * to void
2996sr_raw lkfa0
2997sr_raw href
2998sr_raw lkfa2
2999sr_raw label
3000sr_raw lkfa3
3001end
3002
3003note ---------------------------------------------------------------- words
3004
3005text lkag0 "age unknown"
3006text lkag1 "just now"
3007text lkag2 " min ago"
3008text lkag3 "1 hour ago"
3009text lkag4 " hours ago"
3010text lkag5 "1 day ago"
3011text lkag6 " days ago"
3012text lkwm0 "hot"
3013text lkwm1 "warm"
3014text lkwm2 "cool"
3015text lkwm3 "cold"
3016
3017fn lk_age a long to void
3018if lt a 0
3019sr_raw lkag0
3020ret
3021end
3022xm = div a 60
3023if lt xm 1
3024sr_raw lkag1
3025ret
3026end
3027if lt xm 60
3028lk_ln xm
3029sr_raw lkag2
3030ret
3031end
3032if lt xm 2160
3033xh = div xm 60
3034if eq xh 1
3035sr_raw lkag3
3036ret
3037end
3038lk_ln xh
3039sr_raw lkag4
3040ret
3041end
3042xd = div xm 1440
3043if eq xd 1
3044sr_raw lkag5
3045ret
3046end
3047lk_ln xd
3048sr_raw lkag6
3049end
3050
3051fn lk_warm a long to void
3052if lt a 0
3053sr_raw lkwm3
3054ret
3055end
3056if lt a 1800
3057sr_raw lkwm0
3058ret
3059end
3060if lt a 7200
3061sr_raw lkwm1
3062ret
3063end
3064if lt a 86400
3065sr_raw lkwm2
3066ret
3067end
3068sr_raw lkwm3
3069end
3070
3071text lkkd0 "agent"
3072text lkkd1 "operator"
3073text lkkd2 "desk"
3074text lkkd3 "coordinator"
3075text lkkd4 "unassigned"
3076
3077fn lk_kind k uchar to void
3078if eq k 1
3079sr_raw lkkd1
3080ret
3081end
3082if eq k 2
3083sr_raw lkkd2
3084ret
3085end
3086if eq k 3
3087sr_raw lkkd3
3088ret
3089end
3090if eq k 4
3091sr_raw lkkd4
3092ret
3093end
3094sr_raw lkkd0
3095end
3096
3097text lksn0 "Engine speed"
3098text lksn1 "Alpha release"
3099text lksn2 "AIEN Rig"
3100text lksn3 "AienOS on the iMac"
3101text lksn4 "Research"
3102text lksn5 "Public record"
3103text lksn6 "PR desk"
3104text lksn7 "Infrastructure"
3105text lksl0 "engine-speed"
3106text lksl1 "alpha-release"
3107text lksl2 "aien-rig"
3108text lksl3 "aienos-on-the-imac"
3109text lksl4 "research"
3110text lksl5 "public-record"
3111text lksl6 "pr-desk"
3112text lksl7 "infrastructure"
3113
3114fn lk_sname s uchar to void
3115if eq s 0
3116sr_raw lksn0
3117end
3118if eq s 1
3119sr_raw lksn1
3120end
3121if eq s 2
3122sr_raw lksn2
3123end
3124if eq s 3
3125sr_raw lksn3
3126end
3127if eq s 4
3128sr_raw lksn4
3129end
3130if eq s 5
3131sr_raw lksn5
3132end
3133if eq s 6
3134sr_raw lksn6
3135end
3136if eq s 7
3137sr_raw lksn7
3138end
3139end
3140
3141fn lk_sslug s uchar to void
3142if eq s 0
3143sr_raw lksl0
3144end
3145if eq s 1
3146sr_raw lksl1
3147end
3148if eq s 2
3149sr_raw lksl2
3150end
3151if eq s 3
3152sr_raw lksl3
3153end
3154if eq s 4
3155sr_raw lksl4
3156end
3157if eq s 5
3158sr_raw lksl5
3159end
3160if eq s 6
3161sr_raw lksl6
3162end
3163if eq s 7
3164sr_raw lksl7
3165end
3166end
3167
3168note ---------------------------------------------------------------- owner chip
3169
3170text lkol0 "Drake"
3171text lkol1 "PR desk"
3172text lkol2 "Coordinator"
3173text lkol3 "Unassigned"
3174text lkol4 "Keeper"
3175text lkol5 "Keeper "
3176text lkol6 "agent "
3177text lkokp "keeper"
3178text lksa "sa"
3179
3180note Length of the keeper/renda prefix when the rest is all digits, else 0.
3181fn lk_keepn i ulong to ulong
3182xo = lk_fo i 2
3183xl = lk_fl i 2
3184xp = ulong 0
3185if lk_eqpre xo xl lkokp
3186xp = 6
3187else
3188if lk_eqpre xo xl lkkrn
3189xp = 5
3190end
3191end
3192if eq xp 0
3193ret 0
3194end
3195for xj ulong sub xl xp
3196if not lk_dg get lkcl add add xo xp xj
3197ret 0
3198end
3199end
3200ret xp
3201end
3202
3203fn lk_eqpre o ulong l ulong s view uchar * to bool
3204if lt l len s
3205ret false
3206end
3207ret lk_eqat o 0 s
3208end
3209
3210fn lk_iskeep i ulong to bool
3211if ne get lkown i 0
3212ret false
3213end
3214ret ne lk_keepn i 0
3215end
3216
3217fn lk_olabel i ulong to void
3218xk = get lkown i
3219if eq xk 1
3220sr_raw lkol0
3221ret
3222end
3223if eq xk 2
3224sr_raw lkol1
3225ret
3226end
3227if eq xk 3
3228sr_raw lkol2
3229ret
3230end
3231if eq xk 4
3232sr_raw lkol3
3233ret
3234end
3235xp = lk_keepn i
3236if ne xp 0
3237lk_okeeper i xp
3238ret
3239end
3240sr_raw lkol6
3241lk_oagent i
3242end
3243
3244fn lk_okeeper i ulong p ulong to void
3245xo = lk_fo i 2
3246xl = lk_fl i 2
3247if eq xl p
3248sr_raw lkol4
3249ret
3250end
3251sr_raw lkol5
3252lk_e add xo p sub xl p
3253end
3254
3255note sa-3-dfa217d1 reads "dfa217"; any other owner stays as written.
3256fn lk_oagent i ulong to void
3257xo = lk_fo i 2
3258xl = lk_fl i 2
3259xe = add xo xl
3260xa = lk_find 1 xo xe 45
3261if and lt xa xe lk_eqt xo sub xa xo lksa
3262xb = lk_find 1 add xa 1 xe 45
3263if lt xb xe
3264xc = lk_find 1 add xb 1 xe 45
3265xs = add xb 1
3266xn = sub xc xs
3267if gt xn 6
3268xn = 6
3269end
3270lk_e xs xn
3271ret
3272end
3273end
3274lk_e xo xl
3275end
3276
3277text lkch0 "<span class=\"now-owner now-owner-"
3278text lkch1 "\">"
3279text lkch2 "<img class=\"now-owner-dog\" src=\"/assets/keeper.svg\" alt=\"\" width=\"42\" height=\"14\">"
3280text lkspc "</span>"
3281
3282fn lk_chip i ulong to void
3283sr_raw lkch0
3284lk_kind get lkown i
3285sr_raw lkch1
3286if lk_iskeep i
3287sr_raw lkch2
3288end
3289lk_olabel i
3290sr_raw lkspc
3291end
3292
3293note ---------------------------------------------------------------- linkify
3294
3295text lkrf0 "omega-mv"
3296text lkrf1 "aien-sovereign-core-mv"
3297text lkrf2 "aienux"
3298text lkrf3 "aien-architecture-mv"
3299text lkrf4 "physics-mv"
3300text lkrf5 "aien-protocols-mv"
3301text lkrf6 "benchmarks-mv"
3302text lkrf7 "aien-rig"
3303text lkrf8 "aienos.com"
3304text lkrf9 ".github"
3305text lkrs0 "omega"
3306text lkrs1 "sc"
3307text lkrs2 "aien-sovereign-core"
3308text lkrs3 "aienos"
3309text lkrs4 "aienos-mv"
3310text lkrs5 "arch"
3311text lkrs6 "aien-architecture"
3312text lkrs7 "physics"
3313text lkrs8 "aien-protocols"
3314text lkrs9 "benchmarks"
3315text lkadv0 "aien-dev/"
3316text lkevp "evidence/"
3317text lkhttps "https://"
3318text lkhttp "http://"
3319text lkdots ".."
3320text lkgc "/commit/"
3321text lkgt "/tree/"
3322text lkgb "/blob/"
3323text lkslash "/"
3324text lkref0 "<a class=\"now-ref\" href=\""
3325text lkref1 "</a>"
3326
3327fn lk_rfull r uchar to void
3328if eq r 0
3329sr_raw lkrf0
3330end
3331if eq r 1
3332sr_raw lkrf1
3333end
3334if eq r 2
3335sr_raw lkrf2
3336end
3337if eq r 3
3338sr_raw lkrf3
3339end
3340if eq r 4
3341sr_raw lkrf4
3342end
3343if eq r 5
3344sr_raw lkrf5
3345end
3346if eq r 6
3347sr_raw lkrf6
3348end
3349if eq r 7
3350sr_raw lkrf7
3351end
3352if eq r 8
3353sr_raw lkrf8
3354end
3355if eq r 9
3356sr_raw lkrf9
3357end
3358end
3359
3360note The rdallow row of a full repository name (every lkrf name is published on the forge).
3361fn lk_rrow r ulong to ulong
3362if eq r 0
3363ret rd_rowt lkrf0
3364end
3365if eq r 1
3366ret rd_rowt lkrf1
3367end
3368if eq r 2
3369ret rd_rowt lkrf2
3370end
3371if eq r 3
3372ret rd_rowt lkrf3
3373end
3374if eq r 4
3375ret rd_rowt lkrf4
3376end
3377if eq r 5
3378ret rd_rowt lkrf5
3379end
3380if eq r 6
3381ret rd_rowt lkrf6
3382end
3383if eq r 7
3384ret rd_rowt lkrf7
3385end
3386if eq r 8
3387ret rd_rowt lkrf8
3388end
3389if eq r 9
3390ret rd_rowt lkrf9
3391end
3392ret 0
3393end
3394
3395note now::linkify: an issue has no forge page and a URL naming github.com is never linked,
3396note so both stay plain text; any other URL is linked as written.
3397text lkghd "github.com"
3398fn lk_hasgh s ulong e ulong to bool
3399while lt s e bound 999999
3400if lk_starts s e lkghd
3401ret true
3402end
3403s = add s 1
3404end
3405ret false
3406end
3407
3408fn lk_tlink k ulong to bool
3409xt = get lktk k
3410if eq xt 1
3411ret false
3412end
3413if eq xt 3
3414ret not lk_hasgh get lkts k get lkte k
3415end
3416ret true
3417end
3418
3419note lk_rowb: rd_row for a repository name held in lkcl [o, e).
3420fn lk_rowb o ulong e ulong to ulong
3421t = len rdallow
3422n = sub e o
3423i = ulong 0
3424while lt i t bound 128
3425ok = and gt n 0 le add add i n 1 t
3426if ok
3427for j ulong n
3428if ne get rdallow add i j get lkcl add o j
3429ok = false
3430end
3431end
3432end
3433if ok
3434ok = eq get rdallow add i n 32
3435end
3436if ok
3437ret add add i n 1
3438end
3439i = rd_skip i
3440end
3441ret 0
3442end
3443
3444note lk_urad: forge::receipt_code for a URL in lkcl [s, e): FORGE/<repo>/(commit|blob|tree)/<7-40 hex>
3445note ending the URL or followed by /, # or ?.
3446fn lk_urad s ulong e ulong to void
3447if not lk_starts s e rdfgb
3448ret
3449end
3450p = add s len rdfgb
3451q = lk_find 1 p e 47
3452if ge q e
3453ret
3454end
3455row = lk_rowb p q
3456if eq row 0
3457ret
3458end
3459k = add q 1
3460h = ulong 0
3461if lk_starts k e rdcm
3462h = add k len rdcm
3463end
3464if lk_starts k e rdbl
3465h = add k len rdbl
3466end
3467if lk_starts k e rdtr
3468h = add k len rdtr
3469end
3470if eq h 0
3471ret
3472end
3473k = h
3474go = true
3475while go bound 64
3476if ge h e
3477go = false
3478else
3479if rd_hex get lkcl h
3480h = add h 1
3481else
3482go = false
3483end
3484end
3485end
3486hn = sub h k
3487if or lt hn 7 gt hn 40
3488ret
3489end
3490if lt h e
3491c = get lkcl h
3492if not or eq c 47 or eq c 35 eq c 63
3493ret
3494end
3495end
3496sr_raw rdk0
3497rd_repout row
3498sr_byte 32
3499lk_e k hn
3500sr_raw rdk1
3501end
3502
3503note The receipt text after a commit or forge URL anchor: rad:<RID> <sha>, so it survives either host.
3504fn lk_trad k ulong to void
3505if eq get lktk k 3
3506lk_urad get lkts k get lkte k
3507ret
3508end
3509if ne get lktk k 2
3510ret
3511end
3512xrow = lk_rrow ulong get lktr k
3513if eq xrow 0
3514ret
3515end
3516xs = get lkts k
3517xe = get lkte k
3518xa = lk_find 1 xs xe 64
3519sr_raw rdk0
3520rd_repout xrow
3521sr_byte 32
3522lk_e add xa 1 sub sub xe xa 1
3523sr_raw rdk1
3524end
3525
3526note repo_name(short) over lkcl [a, b): full-name index, 255 when unknown.
3527fn lk_repo a ulong b ulong to uchar
3528xl = sub b a
3529if or lk_eqt a xl lkrs0 lk_eqt a xl lkrf0
3530ret 0
3531end
3532if or or lk_eqt a xl lkrs1 lk_eqt a xl lkrs2 lk_eqt a xl lkrf1
3533ret 1
3534end
3535if or or lk_eqt a xl lkrf2 lk_eqt a xl lkrs3 lk_eqt a xl lkrs4
3536ret 2
3537end
3538if or or lk_eqt a xl lkrs5 lk_eqt a xl lkrs6 lk_eqt a xl lkrf3
3539ret 3
3540end
3541if or lk_eqt a xl lkrs7 lk_eqt a xl lkrf4
3542ret 4
3543end
3544if or lk_eqt a xl lkrs8 lk_eqt a xl lkrf5
3545ret 5
3546end
3547if or lk_eqt a xl lkrs9 lk_eqt a xl lkrf6
3548ret 6
3549end
3550if lk_eqt a xl lkrf7
3551ret 7
3552end
3553if lk_eqt a xl lkrf8
3554ret 8
3555end
3556if lk_eqt a xl lkrf9
3557ret 9
3558end
3559ret 255
3560end
3561
3562fn lk_drepo s uchar to uchar
3563if or eq s 0 eq s 4
3564ret 0
3565end
3566if eq s 1
3567ret 1
3568end
3569if eq s 2
3570ret 7
3571end
3572if eq s 3
3573ret 2
3574end
3575if eq s 5
3576ret 8
3577end
3578ret 255
3579end
3580
3581fn lk_tokc c uchar to bool
3582if or or lk_up c lk_lo c lk_dg c
3583ret true
3584end
3585ret or or eq c 46 eq c 95 or or eq c 47 eq c 64 or eq c 35 eq c 45
3586end
3587
3588fn lk_tpush s ulong e ulong to void
3589xn = get lktn 0
3590if ge xn LKTOK
3591lk_fail lkemfld 0
3592end
3593put lkts xn s
3594put lkte xn e
3595put lktn 0 add xn 1
3596end
3597
3598fn lk_tokens o ulong l ulong to void
3599put lktn 0 0
3600xs = ulong 0
3601xin = false
3602for xi ulong l
3603xc = get lkcl add o xi
3604if lk_tokc xc
3605if not xin
3606xs = add o xi
3607xin = true
3608end
3609else
3610if xin
3611lk_tpush xs add o xi
3612xin = false
3613end
3614end
3615end
3616if xin
3617lk_tpush xs add o l
3618end
3619end
3620
3621fn lk_starts s ulong e ulong t view uchar * to bool
3622if lt sub e s len t
3623ret false
3624end
3625ret lk_eqat s 0 t
3626end
3627
3628note A URL runs to the next White_Space, ')', '"' or '>'.
3629fn lk_urlend s ulong e ulong to ulong
3630while lt s e bound 999999
3631xc = get lkcl s
3632if or eq xc 41 or eq xc 34 eq xc 62
3633ret s
3634end
3635if ne lk_wsat 1 s e 0
3636ret s
3637end
3638s = add s 1
3639end
3640ret e
3641end
3642
3643fn lk_punct c uchar to bool
3644ret or or eq c 46 eq c 44 or eq c 59 eq c 58
3645end
3646
3647note Tokens: URL extension, then trailing .,;: stripped, empties dropped; in place.
3648fn lk_tfix o ulong l ulong to void
3649xe = add o l
3650xw = ulong 0
3651xskip = o
3652for xr ulong get lktn 0
3653xs = get lkts xr
3654xt = get lkte xr
3655if ge xs xskip
3656if or lk_starts xs xe lkhttps lk_starts xs xe lkhttp
3657xt = lk_urlend xs xe
3658xskip = xt
3659end
3660while gt xt xs bound 999999
3661if not lk_punct get lkcl sub xt 1
3662break
3663end
3664xt = sub xt 1
3665end
3666if gt xt xs
3667put lkts xw xs
3668put lkte xw xt
3669xw = add xw 1
3670end
3671end
3672end
3673put lktn 0 xw
3674end
3675
3676fn lk_last s ulong e ulong c uchar to ulong
3677xp = e
3678while gt xp s bound 999999
3679xp = sub xp 1
3680if eq get lkcl xp c
3681ret xp
3682end
3683end
3684ret e
3685end
3686
3687fn lk_alldg s ulong e ulong to bool
3688if ge s e
3689ret false
3690end
3691while lt s e bound 999999
3692if not lk_dg get lkcl s
3693ret false
3694end
3695s = add s 1
3696end
3697ret true
3698end
3699
3700fn lk_issha s ulong e ulong to bool
3701xn = sub e s
3702if or lt xn 7 gt xn 40
3703ret false
3704end
3705while lt s e bound 64
3706xc = get lkcl s
3707if not or lk_dg xc and ge xc 97 le xc 102
3708ret false
3709end
3710s = add s 1
3711end
3712ret true
3713end
3714
3715fn lk_isbr s ulong e ulong to bool
3716if ge s e
3717ret false
3718end
3719if or eq get lkcl s 47 eq get lkcl sub e 1 47
3720ret false
3721end
3722while lt s e bound 999999
3723xc = get lkcl s
3724if not or or lk_lo xc lk_dg xc or or eq xc 47 eq xc 46 or eq xc 95 eq xc 45
3725ret false
3726end
3727s = add s 1
3728end
3729ret true
3730end
3731
3732fn lk_hasdd s ulong e ulong to bool
3733while lt add s 1 e bound 999999
3734if and eq get lkcl s 46 eq get lkcl add s 1 46
3735ret true
3736end
3737s = add s 1
3738end
3739ret false
3740end
3741
3742note Kind: 0 none, 1 issue, 2 commit, 3 url, 4 evidence, 5 repository name (sets the repo).
3743fn lk_tclass k ulong to void
3744xs = get lkts k
3745xe = get lkte k
3746put lktk k 0
3747put lktr k 255
3748if or lk_starts xs xe lkhttps lk_starts xs xe lkhttp
3749put lktk k 3
3750ret
3751end
3752xh = lk_last xs xe 35
3753if lt xh xe
3754lk_tissue k xs xh xe
3755ret
3756end
3757xa = lk_find 1 xs xe 64
3758if lt xa xe
3759if and lk_isbr xs xa lk_issha add xa 1 xe
3760put lktk k 2
3761end
3762ret
3763end
3764if lk_starts xs xe lkevp
3765if and gt sub xe xs 9 not lk_hasdd add xs 9 xe
3766put lktk k 4
3767end
3768ret
3769end
3770xr = lk_repo xs xe
3771if ne xr 255
3772put lktk k 5
3773put lktr k xr
3774end
3775end
3776
3777fn lk_tissue k ulong s ulong h ulong e ulong to void
3778xs = s
3779if lk_starts s h lkadv0
3780xs = add s 9
3781end
3782if not lk_alldg add h 1 e
3783ret
3784end
3785xr = lk_repo xs h
3786if ne xr 255
3787put lktk k 1
3788put lktr k xr
3789end
3790end
3791
3792note Resolve commit repositories left to right and evidence paths against the first commit.
3793note A repository named in a note holds until its clause ends at a semicolon; after that no repository
3794note holds (255) until one is named again. A clause that names none keeps the stream's home.
3795fn lk_tresolve s uchar to void
3796xlast = lk_drepo s
3797put lkfc 0 0
3798for xk ulong get lktn 0
3799if gt xk 0
3800if lt lk_find 1 get lkte sub xk 1 get lkts xk 59 get lkts xk
3801if not eq xlast lk_drepo s
3802xlast = 255
3803end
3804end
3805end
3806lk_tclass xk
3807xt = get lktk xk
3808if eq xt 5
3809xlast = get lktr xk
3810put lktk xk 0
3811end
3812if eq xt 2
3813if eq xlast 255
3814put lktk xk 0
3815else
3816put lktr xk xlast
3817lk_tfirst xk xlast
3818end
3819end
3820end
3821for xj ulong get lktn 0
3822if eq get lktk xj 4
3823if eq get lkfc 0 0
3824put lktk xj 0
3825end
3826end
3827end
3828end
3829
3830fn lk_tfirst k ulong r uchar to void
3831if ne get lkfc 0 0
3832ret
3833end
3834xs = get lkts k
3835put lkfc 0 1
3836put lkfc 1 ulong r
3837put lkfc 2 xs
3838put lkfc 3 lk_find 1 xs get lkte k 64
3839end
3840
3841fn lk_thref k ulong to void
3842xt = get lktk k
3843xs = get lkts k
3844xe = get lkte k
3845if eq xt 3
3846lk_e xs sub xe xs
3847ret
3848end
3849sr_raw ghforge
3850if eq xt 4
3851lk_evhref xs xe
3852ret
3853end
3854lk_rfull get lktr k
3855sr_raw lkgc
3856xa = lk_find 1 xs xe 64
3857lk_e add xa 1 sub sub xe xa 1
3858end
3859
3860note now::linkify: a folder (trailing / or no dot in its last segment) opens as tree, a file as blob.
3861fn lk_evdir s ulong e ulong to bool
3862q = e
3863while gt q s bound 999999
3864c = get lkcl sub q 1
3865if eq c 47
3866ret true
3867end
3868if eq c 46
3869ret false
3870end
3871q = sub q 1
3872end
3873ret true
3874end
3875
3876fn lk_evhref s ulong e ulong to void
3877lk_rfull uchar get lkfc 1
3878if lk_evdir s e
3879sr_raw lkgt
3880else
3881sr_raw lkgb
3882end
3883xb = get lkfc 2
3884lk_e xb sub get lkfc 3 xb
3885sr_raw lkslash
3886while gt e s bound 999999
3887if ne get lkcl sub e 1 47
3888break
3889end
3890e = sub e 1
3891end
3892lk_e s sub e s
3893end
3894
3895note A note with its references linked; plain runs pass through keeper_name.
3896fn lk_note o ulong l ulong s uchar to void
3897lk_tokens o l
3898lk_tfix o l
3899lk_tresolve s
3900xcur = o
3901for xk ulong get lktn 0
3902if ne get lktk xk 0
3903xs = get lkts xk
3904xe = get lkte xk
3905if gt xs xcur
3906lk_k xcur sub xs xcur
3907end
3908if lk_tlink xk
3909sr_raw lkref0
3910lk_thref xk
3911sr_raw lkfa2
3912lk_e xs sub xe xs
3913sr_raw lkref1
3914lk_trad xk
3915else
3916lk_e xs sub xe xs
3917end
3918xcur = xe
3919end
3920end
3921if lt xcur add o l
3922lk_k xcur sub add o l xcur
3923end
3924end
3925
3926fn lk_lastnote i ulong to void
3927xn = add get lknf i sub get lknc i 1
3928lk_note get lkno xn get lknl xn get lkstrm i
3929end
3930
3931note ---------------------------------------------------------------- item sets
3932
3933fn lk_cur i ulong to bool
3934xa = get lkage i
3935ret and ge xa 0 lt xa 86400
3936end
3937
3938note 1 operator, 2 queued, 3 moving, 4 moving now, 5 moving quiet, 6 queued now,
3939note 7 queued quiet, 8 settled, 9 settled now, 10 open.
3940fn lk_in i ulong set uchar to bool
3941xs = get lkstat i
3942if eq set 8
3943ret or eq xs 2 eq xs 3
3944end
3945if eq set 9
3946ret and or eq xs 2 eq xs 3 lk_cur i
3947end
3948if ne xs 1
3949ret false
3950end
3951if eq set 10
3952ret true
3953end
3954xo = eq get lkown i 1
3955if eq set 1
3956ret xo
3957end
3958if xo
3959ret false
3960end
3961xq = or eq get lkown i 4 eq get lknc i 0
3962if eq set 2
3963ret xq
3964end
3965if eq set 3
3966ret not xq
3967end
3968if eq set 4
3969ret and not xq lk_cur i
3970end
3971if eq set 5
3972ret and not xq not lk_cur i
3973end
3974if eq set 6
3975ret and xq lk_cur i
3976end
3977ret and xq not lk_cur i
3978end
3979
3980fn lk_count set uchar to ulong
3981xn = ulong 0
3982for xi ulong get lkn 0
3983if lk_in xi set
3984xn = add xn 1
3985end
3986end
3987ret xn
3988end
3989
3990fn lk_scount set uchar s uchar to ulong
3991xn = ulong 0
3992for xi ulong get lkn 0
3993if and lk_in xi set eq get lkstrm xi s
3994xn = add xn 1
3995end
3996end
3997ret xn
3998end
3999
4000fn lk_akey i ulong to long
4001xa = get lkage i
4002if lt xa 0
4003ret 9223372036854775807
4004end
4005ret xa
4006end
4007
4008note Stable sort of all rows by age (unknown last) into lkperm.
4009fn lk_sort to void
4010xn = get lkn 0
4011for xi ulong xn
4012put lkperm xi xi
4013end
4014for xj ulong xn
4015if gt xj 0
4016xv = get lkperm xj
4017xk = xj
4018while gt xk 0 bound 999999
4019if le lk_akey get lkperm sub xk 1 lk_akey xv
4020break
4021end
4022put lkperm xk get lkperm sub xk 1
4023xk = sub xk 1
4024end
4025put lkperm xk xv
4026end
4027end
4028end
4029
4030fn lk_hands to ulong
4031xn = ulong 0
4032for xi ulong get lkn 0
4033if lk_hand xi
4034if not lk_seen xi
4035xn = add xn 1
4036end
4037end
4038end
4039ret xn
4040end
4041
4042fn lk_hand i ulong to bool
4043if or ne get lkstat i 1 ne get lkown i 0
4044ret false
4045end
4046xa = get lkage i
4047ret and ge xa 0 lt xa 7200
4048end
4049
4050fn lk_seen i ulong to bool
4051for xj ulong i
4052if lk_hand xj
4053if lk_sameo xj i
4054ret true
4055end
4056end
4057end
4058ret false
4059end
4060
4061fn lk_sameo a ulong b ulong to bool
4062xl = lk_fl a 2
4063if ne xl lk_fl b 2
4064ret false
4065end
4066xo = lk_fo a 2
4067xp = lk_fo b 2
4068for xj ulong xl
4069if ne get lkcl add xo xj get lkcl add xp xj
4070ret false
4071end
4072end
4073ret true
4074end
4075
4076note ---------------------------------------------------------------- boxes
4077
4078note Phrases withdrawn from the public record on 2026-11-07 (now.rs WITHDRAWN_PHRASES).
4079note Ledger rows stay byte-identical; a row that still carries one is shown with a note.
4080text lkwd0 "drop-in"
4081text lkwd1 "first ever"
4082text lkwd2 "replaced cuda"
4083text lkwd3 "faster than cuda"
4084text lkwd4 "no nvidia software"
4085text lkwd5 "works on any nvidia gpu"
4086text lkwdp "<p class=\"now-withdrawn\">Wording withdrawn 2026-11-07: this phrase is not a supported claim; see the hardware scope.</p>"
4087text lkwds "<span class=\"now-withdrawn\">Wording withdrawn 2026-11-07: this phrase is not a supported claim; see the hardware scope.</span>"
4088text lh25r "<span class=\"now-row-meta\">"
4089
4090fn lk_wdt o ulong l ulong to bool
4091if eq l 0
4092ret false
4093end
4094ret or or or lk_lhas o l lkwd0 lk_lhas o l lkwd1 or lk_lhas o l lkwd2 lk_lhas o l lkwd3 or lk_lhas o l lkwd4 lk_lhas o l lkwd5
4095end
4096
4097note withdrawn(): item, latest note or done-when holds a withdrawn phrase.
4098fn lk_wd i ulong to bool
4099if or lk_wdt lk_fo i 4 lk_fl i 4 lk_wdt lk_fo i 5 lk_fl i 5
4100ret true
4101end
4102if gt get lknc i 0
4103xn = add get lknf i sub get lknc i 1
4104ret lk_wdt get lkno xn get lknl xn
4105end
4106ret false
4107end
4108
4109text lh0 "<article class=\"now-card now-"
4110text lh1 " now-k-"
4111text lh2 "\" id=\""
4112text lh3 "\"><header class=\"now-card-top\"><span class=\"now-id\">"
4113text lh4 "<span class=\"now-age\" title=\""
4114text lh5 "\"><span class=\"now-dot\" aria-hidden=\"true\"></span>"
4115text lh6 "</span></header><h3 class=\"now-item\">"
4116text lh7 "</h3>"
4117text lh8 "<p class=\"now-note\">"
4118text lh9 "</p>"
4119text lh10 "<p class=\"now-done\"><span class=\"now-done-k\">done when</span> "
4120text lh11 "</article>"
4121text lhq "\">"
4122
4123fn lk_card i ulong to void
4124sr_raw lh0
4125lk_warm get lkage i
4126sr_raw lh1
4127lk_kind get lkown i
4128sr_raw lh2
4129lk_ef i 0
4130sr_raw lh3
4131lk_ef i 0
4132sr_raw lkspc
4133lk_chip i
4134sr_raw lh4
4135lk_ef i 7
4136sr_raw lh5
4137lk_age get lkage i
4138sr_raw lh6
4139lk_k lk_fo i 4 lk_fl i 4
4140sr_raw lh7
4141if gt get lknc i 0
4142sr_raw lh8
4143lk_lastnote i
4144sr_raw lh9
4145end
4146if gt lk_fl i 5 0
4147sr_raw lh10
4148lk_k lk_fo i 5 lk_fl i 5
4149sr_raw lh9
4150end
4151if lk_wd i
4152sr_raw lkwdp
4153end
4154lk_lfoot i
4155sr_raw lh11
4156end
4157
4158text lh20 "<li class=\"now-queue-row now-row\" id=\""
4159text lh21 "\"><span class=\"now-id\">"
4160text lh22 "</span><span class=\"now-queue-item\">"
4161text lh23 "<span class=\"now-row-note\">"
4162text lh24 "<span class=\"now-row-done\">done when "
4163text lh25 "</span><span class=\"now-row-meta\">"
4164text lh26 "<span class=\"now-row-age\" title=\""
4165text lh27 "</span></span>"
4166text lh28 "</li>"
4167
4168fn lk_row1 i ulong to void
4169sr_raw lh20
4170lk_ef i 0
4171sr_raw lh21
4172lk_ef i 0
4173sr_raw lh22
4174lk_k lk_fo i 4 lk_fl i 4
4175if gt get lknc i 0
4176sr_raw lh23
4177lk_lastnote i
4178sr_raw lkspc
4179end
4180if gt lk_fl i 5 0
4181sr_raw lh24
4182lk_k lk_fo i 5 lk_fl i 5
4183sr_raw lkspc
4184end
4185if lk_wd i
4186sr_raw lkspc
4187sr_raw lkwds
4188sr_raw lh25r
4189else
4190sr_raw lh25
4191end
4192lk_chip i
4193sr_raw lh26
4194lk_ef i 7
4195sr_raw lhq
4196lk_age get lkage i
4197sr_raw lh27
4198lk_lfoot i
4199sr_raw lh28
4200end
4201
4202text lh30 "<li class=\"now-tl now-tl-"
4203text lh31 "\"><span class=\"now-tl-when mono\" title=\""
4204text lh32 "</span><div class=\"now-tl-body\"><span class=\"now-verdict now-verdict-"
4205text lh33 "</span><span class=\"now-id\">"
4206text lh34 "</span><p class=\"now-tl-item\">"
4207text lh35 "<p class=\"now-tl-evidence\">"
4208text lh36 "</div></li>"
4209
4210fn lk_tl i ulong to void
4211sr_raw lh30
4212lk_ef i 3
4213sr_raw lh2
4214lk_ef i 0
4215sr_raw lh31
4216lk_ef i 7
4217sr_raw lhq
4218lk_age get lkage i
4219sr_raw lh32
4220lk_ef i 3
4221sr_raw lhq
4222lk_ef i 3
4223sr_raw lh33
4224lk_ef i 0
4225sr_raw lh34
4226lk_k lk_fo i 4 lk_fl i 4
4227sr_raw lh9
4228if gt get lknc i 0
4229sr_raw lh35
4230lk_lastnote i
4231sr_raw lh9
4232end
4233if lk_wd i
4234sr_raw lkwdp
4235end
4236lk_lfoot i
4237sr_raw lh36
4238end
4239
4240text lh40 "<details class=\"now-fold\" id=\""
4241text lh41 "\"><summary class=\"now-fold-sum\"><span class=\"now-fold-name\">"
4242text lh42 "</span><span class=\"now-fold-n\">"
4243text lh43 " line"
4244text lh44 " lines"
4245text lh45 "<span class=\"now-fold-age\">last written "
4246text lh46 "</summary><ol class=\"now-queue now-fold-rows\">"
4247text lh47 "</ol></details>"
4248text lhqt "quiet-"
4249text lhqo "queued-older"
4250text lhqn "Queued, not written in the last day"
4251
4252fn lk_lines n ulong to void
4253lk_un n
4254if eq n 1
4255sr_raw lh43
4256ret
4257end
4258sr_raw lh44
4259end
4260
4261note A fold over set (stream s, or 255 for all); id/title written by the caller's mode.
4262fn lk_fold set uchar s uchar to void
4263xn = ulong 0
4264xmin = long -1
4265for xi ulong get lkn 0
4266if lk_fin xi set s
4267xn = add xn 1
4268xa = get lkage xi
4269if ge xa 0
4270if or lt xmin 0 lt xa xmin
4271xmin = xa
4272end
4273end
4274end
4275end
4276sr_raw lh40
4277if eq s 255
4278sr_raw lhqo
4279else
4280sr_raw lhqt
4281lk_sslug s
4282end
4283sr_raw lh41
4284if eq s 255
4285sr_raw lhqn
4286else
4287lk_sname s
4288end
4289sr_raw lh42
4290lk_lines xn
4291sr_raw lkspc
4292if ge xmin 0
4293sr_raw lh45
4294lk_age xmin
4295sr_raw lkspc
4296end
4297sr_raw lh46
4298for xj ulong get lkn 0
4299if lk_fin xj set s
4300lk_row1 xj
4301end
4302end
4303sr_raw lh47
4304end
4305
4306fn lk_fin i ulong set uchar s uchar to bool
4307if not lk_in i set
4308ret false
4309end
4310ret or eq s 255 eq get lkstrm i s
4311end
4312
4313text lh50 "<div class=\"now-river\" aria-hidden=\"true\">"
4314text lh51 "<span class=\"now-seg now-"
4315text lh52 "\" title=\""
4316text lh53 "\"></span>"
4317text lh54 "</div>"
4318text lhsp " "
4319
4320fn lk_river s uchar to void
4321sr_raw lh50
4322for xj ulong get lkn 0
4323xi = get lkperm xj
4324if and lk_in xi 4 eq get lkstrm xi s
4325sr_raw lh51
4326lk_warm get lkage xi
4327sr_raw lh52
4328lk_ef xi 0
4329sr_raw lhsp
4330lk_age get lkage xi
4331sr_raw lh53
4332end
4333end
4334sr_raw lh54
4335end
4336
4337text lh60 "<div class=\"now-stat"
4338text lh61 "\"><span class=\"now-stat-n\">"
4339text lh62 "</span><span class=\"now-stat-l\">"
4340text lh63 "</span></div>"
4341
4342fn lk_stat n ulong label view uchar * cls view uchar * to void
4343sr_raw lh60
4344sr_raw cls
4345sr_raw lh61
4346lk_un n
4347sr_raw lh62
4348sr_raw label
4349sr_raw lh63
4350end
4351
4352note ---------------------------------------------------------------- models
4353
4354text lkmj0 "plan"
4355text lkmj1 "models"
4356text lkmj2 "key"
4357text lkmj3 "name"
4358text lkmj4 "served_match"
4359text lkmj5 "absent"
4360text lkmj6 "track"
4361text lkmj7 "role"
4362text lkmj8 "plan_ledger"
4363text lkmj9 "source"
4364text lkmj10 "figures"
4365text lkmj11 "label"
4366text lkmj12 "url"
4367text lkmj13 "value"
4368text lkmj14 "receipt"
4369text lkms0 "answering"
4370text lkms1 "unknown"
4371text lkms2 "not-answering"
4372text lkms3 "planned"
4373text lkms4 "not-trained"
4374text lkms5 "retired"
4375
4376fn lk_roster to ulong
4377xr = sj_load lkroster
4378if ne sj_kind xr 1
4379lk_fail lkemrj 0
4380end
4381if ne sj_kind sj_find xr lkmj1 2
4382lk_fail lkemrj 0
4383end
4384if ne sj_kind sj_find xr lkmj0 1
4385lk_fail lkemrj 0
4386end
4387ret xr
4388end
4389
4390note Served id index for model m (first id whose ASCII lowercase contains served_match), or 9999.
4391fn lk_served m ulong to ulong
4392xp = sj_find m lkmj4
4393if ne sj_kind xp 3
4394ret 9999
4395end
4396for xj ulong get lkmidn 0
4397if lk_hasn get lkmid mul xj 2 get lkmid add mul xj 2 1 xp
4398ret xj
4399end
4400end
4401ret 9999
4402end
4403
4404fn lk_hasn o ulong l ulong p ulong to bool
4405xn = sj_size p
4406if gt xn l
4407ret false
4408end
4409for xs ulong add sub l xn 1
4410if lk_hasat add o xs p xn
4411ret true
4412end
4413end
4414ret false
4415end
4416
4417fn lk_hasat o ulong p ulong n ulong to bool
4418for xj ulong n
4419if ne lk_lb get lkcl add o xj sj_byte p xj
4420ret false
4421end
4422end
4423ret true
4424end
4425
4426note 0 answering, 1 unknown, 2 absent string as written.
4427fn lk_mstate m ulong to uchar
4428if ne lk_served m 9999
4429ret 0
4430end
4431if and eq sj_kind sj_find m lkmj4 3 eq get lkmcv 0 0
4432if sj_eq sj_find m lkmj5 lkms2
4433ret 1
4434end
4435end
4436ret 2
4437end
4438
4439fn lk_mstx m ulong st uchar to void
4440if eq st 0
4441sr_raw lkms0
4442ret
4443end
4444if eq st 1
4445sr_raw lkms1
4446ret
4447end
4448sj_emit sj_find m lkmj5
4449end
4450
4451text lhw0 "Answering"
4452text lhw1 "Not answering"
4453text lhw2 "Planned"
4454text lhw3 "Not trained yet"
4455text lhw4 "Status unknown"
4456text lhw5 "Retired"
4457
4458fn lk_mwords m ulong st uchar to void
4459if eq st 0
4460sr_raw lhw0
4461ret
4462end
4463if eq st 2
4464xa = sj_find m lkmj5
4465if sj_eq xa lkms2
4466sr_raw lhw1
4467ret
4468end
4469if sj_eq xa lkms3
4470sr_raw lhw2
4471ret
4472end
4473if sj_eq xa lkms4
4474sr_raw lhw3
4475ret
4476end
4477if sj_eq xa lkms5
4478sr_raw lhw5
4479ret
4480end
4481end
4482sr_raw lhw4
4483end
4484
4485fn lk_itemid n ulong to ulong
4486if ne sj_kind n 3
4487ret 9999
4488end
4489for xi ulong get lkn 0
4490if lk_eqsj lk_fo xi 0 lk_fl xi 0 n
4491ret xi
4492end
4493end
4494ret 9999
4495end
4496
4497fn lk_eqsj o ulong l ulong n ulong to bool
4498if ne sj_size n l
4499ret false
4500end
4501for xj ulong l
4502if ne get lkcl add o xj sj_byte n xj
4503ret false
4504end
4505end
4506ret true
4507end
4508
4509text lkfg0 "https://interplane.io/drakestapleton/"
4510
4511note Roster links are forge pages; a receipt anchor is followed by its rad:<RID> <sha> text.
4512fn lk_url n ulong to void
4513if not sj_prefix n lkfg0
4514lk_fail lkemrj 0
4515end
4516sj_href n
4517end
4518
4519
4520fn lk_mfoot root ulong m ulong to void
4521xi = lk_itemid sj_find m lkmj8
4522if ne xi 9999
4523sr_raw lkfa0
4524sr_raw lkledu
4525sr_raw lkhl
4526lk_un get lkline xi
4527sr_raw lkfa2
4528sr_raw lkfl2
4529lk_ef xi 0
4530sr_raw lkfl1
4531sr_raw lkfa3
4532ret
4533end
4534xs = sj_find m lkmj9
4535if ne sj_kind xs 1
4536xs = sj_find root lkmj0
4537end
4538sr_raw lkfa1
4539lk_url sj_find xs lkmj12
4540sr_raw lkfa2
4541sj_emit sj_find xs lkmj11
4542sr_raw lkfa3
4543rd_rcpt sj_find xs lkmj12
4544end
4545
4546text lh70 "<article class=\"now-card now-model now-model-"
4547text lh71 "\"><header class=\"now-card-top\"><span class=\"now-model-track\">"
4548text lh72 "</span><span class=\"now-model-state now-model-state-"
4549text lh73 "</span></header><h3 class=\"now-item\">"
4550text lh74 "</h3><p class=\"now-note now-model-role\">"
4551text lh75 "<p class=\"now-done\"><span class=\"now-done-k\">serving</span> <span class=\"mono\">"
4552text lh76 "</span>, answered the Spark's check at <span class=\"mono\">"
4553text lh77 "</span></p>"
4554text lh78 "<p class=\"now-done\">Did not answer the Spark's check at <span class=\"mono\">"
4555text lh79 "</span>.</p>"
4556text lh80 "<p class=\"now-done\">The Spark has not published a model check yet.</p>"
4557text lh81 "<dl class=\"now-model-figs\">"
4558text lh82 "<dt>"
4559text lh83 "</dt><dd>"
4560text lh84 " <a class=\"now-ref\" href=\""
4561text lh85 "\" target=\"_blank\" rel=\"noopener noreferrer\">receipt</a>"
4562text lh85b "</dd>"
4563text lh86 "</dl>"
4564text lhnev "never"
4565
4566fn lk_mchk to void
4567if eq get lkmcv 0 0
4568sr_raw lhnev
4569ret
4570end
4571lk_e get lkmc 0 get lkmc 1
4572end
4573
4574fn lk_mcard root ulong m ulong to void
4575xst = lk_mstate m
4576sr_raw lh70
4577lk_mstx m xst
4578sr_raw lh2
4579sj_emit sj_find m lkmj2
4580sr_raw lh71
4581sj_emit sj_find m lkmj6
4582sr_raw lh72
4583lk_mstx m xst
4584sr_raw lhq
4585lk_mwords m xst
4586sr_raw lh73
4587sj_emit sj_find m lkmj3
4588sr_raw lh74
4589sj_emit sj_find m lkmj7
4590sr_raw lh9
4591lk_mbody m xst
4592lk_figs sj_find m lkmj10
4593lk_mfoot root m
4594sr_raw lh11
4595end
4596
4597fn lk_mbody m ulong st uchar to void
4598if eq st 0
4599xj = lk_served m
4600sr_raw lh75
4601lk_e get lkmid mul xj 2 get lkmid add mul xj 2 1
4602sr_raw lh76
4603lk_mchk
4604sr_raw lh77
4605ret
4606end
4607if eq st 1
4608sr_raw lh80
4609ret
4610end
4611if sj_eq sj_find m lkmj5 lkms2
4612sr_raw lh78
4613lk_mchk
4614sr_raw lh79
4615end
4616end
4617
4618fn lk_figs a ulong to void
4619if eq sj_len a 0
4620ret
4621end
4622sr_raw lh81
4623xf = sj_first a
4624while ne xf 0 bound 65536
4625sr_raw lh82
4626sj_emit sj_find xf lkmj11
4627sr_raw lh83
4628sj_emit sj_find xf lkmj13
4629sr_raw lh84
4630lk_url sj_find xf lkmj14
4631sr_raw lh85
4632rd_rcpt sj_find xf lkmj14
4633sr_raw lh85b
4634xf = sj_next xf
4635end
4636sr_raw lh86
4637end
4638
4639text lh90 "<section class=\"now-section\" id=\"models\" aria-labelledby=\"now-models-h\"><div class=\"container\"><p class=\"kicker\">On the Spark</p><h2 id=\"now-models-h\" class=\"now-h2\">Models doing the work</h2><p class=\"now-sub\">The models the plan names, what each one is for, and whether it answered the Spark's own check of its model servers. The Spark checks every five minutes; this page shows the check from its last build"
4640text lh91 " (<span class=\"mono\">"
4641text lh92 "</span>)"
4642text lh93 ". Every speed links to its receipt. A token is a word or a piece of one. The plan: <a class=\"prose-link\" href=\""
4643text lh94 "</a>"
4644text lh94b ".</p><div class=\"now-grid\">"
4645text lh95 "</div></div></section>"
4646
4647fn lk_models to void
4648xr = lk_roster
4649sr_raw lh90
4650if ne get lkmcv 0 0
4651sr_raw lh91
4652lk_mchk
4653sr_raw lh92
4654end
4655sr_raw lh93
4656xp = sj_find xr lkmj0
4657lk_url sj_find xp lkmj12
4658sr_raw lhq
4659sj_emit sj_find xp lkmj11
4660sr_raw lh94
4661rd_rcpt sj_find xp lkmj12
4662sr_raw lh94b
4663xm = sj_first sj_find xr lkmj1
4664while ne xm 0 bound 65536
4665lk_mcard xr xm
4666xm = sj_next xm
4667end
4668sr_raw lh95
4669end
4670
4671fn lk_nmodels to ulong
4672xr = lk_roster
4673ret sj_len sj_find xr lkmj1
4674end
4675
4676note ---------------------------------------------------------------- usage
4677
4678text lku0 "This five-hour session"
4679text lku1 "This week, all models"
4680text lku2 "This week, "
4681text lku3 " only"
4682text lkuclau "Claude"
4683
4684fn lk_ulabel i ulong to void
4685xk = get lkuk i
4686if eq xk 0
4687sr_raw lku0
4688ret
4689end
4690if eq xk 1
4691sr_raw lku1
4692ret
4693end
4694sr_raw lku2
4695lk_e get lkus mul i 2 get lkus add mul i 2 1
4696sr_raw lku3
4697end
4698
4699text lh100 "<div class=\"now-usage-row\"><span class=\"now-usage-k\">"
4700text lh101 "</span><meter class=\"now-usage-meter\" min=\"0\" max=\"100\" low=\"70\" high=\"90\" optimum=\"0\" value=\""
4701text lh102 "% used</meter><span class=\"now-usage-v\"><strong>"
4702text lh103 "% left</strong> <span class=\"now-usage-used\">("
4703text lh104 "% used)</span></span>"
4704text lh105 "<span class=\"now-usage-reset\">resets <span class=\"mono\">"
4705text lh106 "</span></span>"
4706
4707fn lk_urow i ulong to void
4708xu = get lkupc i
4709sr_raw lh100
4710lk_ulabel i
4711sr_raw lh101
4712lk_un xu
4713sr_raw lhq
4714lk_un xu
4715sr_raw lh102
4716lk_un sub 100 xu
4717sr_raw lh103
4718lk_un xu
4719sr_raw lh104
4720if gt get lkur add mul i 2 1 0
4721sr_raw lh105
4722lk_e get lkur mul i 2 get lkur add mul i 2 1
4723sr_raw lh106
4724end
4725sr_raw lh54
4726end
4727
4728text lh110 "<section class=\"now-section\" id=\"claude\" aria-labelledby=\"now-claude-h\"><div class=\"container\"><p class=\"kicker\">Paying for the work</p><h2 id=\"now-claude-h\" class=\"now-h2\">How much Claude is left</h2><p class=\"now-sub\">Many of the agents on this page are Claude models made by Anthropic (Opus, Fable, Sonnet and Haiku), running on Drake's own three Claude subscriptions. The plans allow a set amount of use in each five-hour session and in each week. The Spark reads the plan's own usage meter every five minutes and publishes the percentages, never the login.</p><p class=\"now-sub\">The same work also runs on subscriptions Drake pays for himself: OpenAI Codex, Google Gemini and xAI Grok. Those plans publish no usage meter here, so this page shows no percentage for them. The Claude meter is the only one the Spark can read.</p><div class=\"now-usage-wrap\"><article class=\"now-usage\">"
4729text lh111 "<header class=\"now-card-top\"><span class=\"now-usage-plan\">Claude "
4730text lh112 " plan</span><span class=\"now-age mono\">read "
4731text lh113 "</span></header>"
4732text lh114 "<p class=\"now-done\">This is the last reading the Spark published; it has not read a newer one since.</p>"
4733text lh115 "<div class=\"now-usage-menu\">"
4734text lh116 "<input type=\"radio\" name=\"now-usage\" id=\"now-usage-"
4735text lh117 "\" class=\"now-usage-radio\""
4736text lh118 " checked"
4737text lh119 ">"
4738text lh120 "<div class=\"now-usage-tabs\" role=\"tablist\" aria-label=\"Usage limits: choose one to read\">"
4739text lh121 "<label class=\"now-usage-tab\" for=\"now-usage-"
4740text lh122 "\"><span class=\"now-usage-tab-k\">"
4741text lh123 "</span><span class=\"now-usage-tab-v\">"
4742text lh124 "% left</span></label>"
4743text lh125 "</div><div class=\"now-usage-panels\">"
4744text lh126 "<div class=\"now-usage-panel now-usage-panel-"
4745text lh127 "</div></div>"
4746text lh128 "<p class=\"now-done\">The Spark has not published a reading of the plan yet.</p>"
4747text lh129 "Usage reading on GitHub"
4748text lh130 "</article><aside class=\"now-give\" aria-labelledby=\"now-give-h\"><h3 id=\"now-give-h\" class=\"now-give-h\">Give compute, not money</h3><p>The work runs on plans and on one Spark. Both can come from you, and Drake takes no payment for either.</p><ul class=\"now-give-steps\"><li><strong>Your agent, your plan. </strong>Pick any repository on <a class=\"prose-link\" href=\"/agents/\">Agents</a> and give your agent its instructions: the rules mine follow and that repository's own AGENTS.md. It claims an open issue and opens a pull request that leads with its evidence, like mine do. Its own subscription pays for it (Claude, Codex, Gemini or Grok); nothing of yours is sent to the Spark.</li><li><strong>Your Spark. </strong>A second GB10 can qualify the same gates and publish its own receipt. The GPU gates are written to run on any Spark, and a PASS from your machine is evidence, not a claim.</li></ul><p class=\"now-give-note\">No keys are collected. Your agent runs on your account, your Spark on your network, and only merged evidence reaches this page.</p><p class=\"now-give-btn\">Join in Open Humanity: <code>open-humanity</code></p></aside></div></div></section>"
4749
4750fn lk_uplan to void
4751if eq get lkup 1 0
4752sr_raw lkuclau
4753ret
4754end
4755lk_e get lkup 0 get lkup 1
4756end
4757
4758fn lk_ustale to bool
4759xc = lk_utc 1 get lkuc 0 add get lkuc 0 get lkuc 1
4760if eq get lkok 0 0
4761ret false
4762end
4763ret gt sub lk_now xc 7200
4764end
4765
4766fn lk_usage1 to void
4767sr_raw lh110
4768if eq get lkuv 0 0
4769sr_raw lh128
4770else
4771sr_raw lh111
4772lk_uplan
4773sr_raw lh112
4774lk_e get lkuc 0 get lkuc 1
4775sr_raw lh113
4776if lk_ustale
4777sr_raw lh114
4778end
4779lk_umenu
4780end
4781lk_sfoot lkusgu
4782sr_raw lh130
4783end
4784
4785fn lk_umenu to void
4786xn = get lkun 0
4787if le xn 1
4788for xj ulong xn
4789lk_urow xj
4790end
4791ret
4792end
4793sr_raw lh115
4794for xi ulong xn
4795sr_raw lh116
4796lk_un xi
4797sr_raw lh117
4798if eq xi 0
4799sr_raw lh118
4800end
4801sr_raw lh119
4802end
4803sr_raw lh120
4804for xk ulong xn
4805sr_raw lh121
4806lk_un xk
4807sr_raw lh122
4808lk_ulabel xk
4809sr_raw lh123
4810lk_un sub 100 get lkupc xk
4811sr_raw lh124
4812end
4813sr_raw lh125
4814for xm ulong xn
4815sr_raw lh126
4816lk_un xm
4817sr_raw lhq
4818lk_urow xm
4819sr_raw lh54
4820end
4821sr_raw lh127
4822end
4823
4824note ---------------------------------------------------------------- written stamp
4825
4826note Latest parsable updated_utc in seconds; lkok 0 when none.
4827fn lk_written to long
4828xb = long 0
4829xh = false
4830for xi ulong get lkn 0
4831if ne get lkupv xi 0
4832if or not xh gt get lkupd xi xb
4833xb = get lkupd xi
4834xh = true
4835end
4836end
4837end
4838put lkok 0 0
4839if xh
4840put lkok 0 1
4841end
4842ret xb
4843end
4844
4845fn lk_wfmt to void
4846xs = lk_written
4847if eq get lkok 0 0
4848sr_raw lhnev
4849ret
4850end
4851xc = get lkcn 0
4852xo = lk_fmt xs false
4853lk_r xo get lklast 0
4854put lkcn 0 xc
4855end
4856
4857fn lk_bfmt full bool to void
4858xc = get lkcn 0
4859xo = lk_fmt lk_now full
4860lk_r xo get lklast 0
4861put lkcn 0 xc
4862end
4863
4864note RFC 3339 ledger-written stamp (build time when none); cached for the build.
4865fn sp_ledger_stamp to void
4866if eq get lkwrv 0 0
4867lk_load_all
4868xs = lk_written
4869if eq get lkok 0 0
4870xs = lk_now
4871end
4872put lkwr 0 xs
4873put lkwrv 0 1
4874end
4875xc = get lkcn 0
4876xo = lk_fmt get lkwr 0 true
4877lk_r xo get lklast 0
4878put lkcn 0 xc
4879end
4880
4881note ---------------------------------------------------------------- /now/
4882
4883text lhn0 "<section class=\"now-hero\" aria-labelledby=\"now-title\"><div class=\"container\"><div class=\"now-hero-top\"><div class=\"now-hero-text\"><p class=\"kicker\">Now</p><h1 id=\"now-title\" class=\"now-title\">What is being done, right now.</h1><p class=\"now-lead\">This is the working ledger of Aien, published as it is written. Every line is a promise with an owner and an observable finish. Agents write their progress here; the operator writes decisions here. Nothing on this page is composed by hand. Lines written in the last day are shown open; older lines are folded below, each one click away.</p><p class=\"now-lead\"><a href=\"/hive/\"><strong>Hive</strong></a> / Watch the agents work, see their exact models, and follow Drake's instructions and corrections live. <a href=\"/learn/\">Learn to structure your own work with AI.</a></p></div><figure class=\"now-keeper\"><img src=\"/assets/keeper.svg\" width=\"600\" height=\"200\" alt=\"Keeper, the merge desk that lands finished changes: a big cartoon dachshund, long and low, wearing a gold key on its red collar.\"><figcaption>Keeper, the merge desk</figcaption></figure></div>"
4884text lhn1 "<p class=\"now-empty\">No ledger has been published yet. The page will fill itself the moment one arrives.</p>"
4885text lhn2 "<div class=\"now-stats\">"
4886text lhs0 "agents writing in the last two hours"
4887text lhs1 "lines in motion, written in the last day"
4888text lhs2 "open lines quiet for over a day, quiet and queued"
4889text lhs3 "settled in the last day"
4890text lhs4 "waiting on the operator"
4891text lhc0 " now-stat-hot"
4892text lhc1 " "
4893text lhc2 " now-stat-done"
4894text lhc3 " now-stat-op"
4895text lhn3 "</div><nav class=\"now-jump\" aria-label=\"On this page\"><a href=\"#claude\">Paying for the work</a>"
4896text lhj0 "<a href=\"#operator\">Operator <span>"
4897text lhj1 "<a href=\"#streams\">In motion <span>"
4898text lhj2 "<a href=\"#models\">Models <span>"
4899text lhj3 "<a href=\"#quiet\">Quiet <span>"
4900text lhj4 "<a href=\"#next\">Queued <span>"
4901text lhj5 "<a href=\"#settled\">Settled <span>"
4902text lhje "</span></a>"
4903text lhn4 "<a href=\"#how\">How it is made</a></nav><p class=\"now-stamp\">Ledger last written <span class=\"mono\">"
4904text lhn5 "</span>. Page built <span class=\"mono\">"
4905text lhn6 "</span>. It is rebuilt only when a reviewed release is published, not on a timer.</p>"
4906text lhn7 "<ul class=\"now-pulse\">"
4907text lhn8 "<li><span class=\"now-pulse-k\">"
4908text lhn9 "</span><span class=\"now-pulse-v mono\">"
4909text lhn10 "</span></li>"
4910text lhn11 "</ul>"
4911text lhn12 "</div></section>"
4912
4913fn lk_hero to void
4914sr_raw lhn0
4915if eq get lkn 0 0
4916sr_raw lhn1
4917sr_raw lhn12
4918ret
4919end
4920sr_raw lhn2
4921lk_stat lk_hands lhs0 lhc0
4922lk_stat lk_count 4 lhs1 lhc1
4923lk_stat add lk_count 5 lk_count 7 lhs2 lhc1
4924lk_stat lk_count 9 lhs3 lhc2
4925lk_stat lk_count 1 lhs4 lhc3
4926sr_raw lhn3
4927lk_jump
4928sr_raw lhn4
4929lk_wfmt
4930sr_raw lhn5
4931lk_bfmt false
4932sr_raw lhn6
4933if gt get lkpn 0 0
4934sr_raw lhn7
4935for xi ulong get lkpn 0
4936sr_raw lhn8
4937lk_e get lkpk mul xi 2 get lkpk add mul xi 2 1
4938sr_raw lhn9
4939lk_e get lkpv mul xi 2 get lkpv add mul xi 2 1
4940sr_raw lhn10
4941end
4942sr_raw lhn11
4943end
4944sr_raw lhn12
4945end
4946
4947fn lk_jumpn t view uchar * n ulong to void
4948sr_raw t
4949lk_un n
4950sr_raw lhje
4951end
4952
4953fn lk_jump to void
4954xo = lk_count 1
4955if gt xo 0
4956lk_jumpn lhj0 xo
4957end
4958lk_jumpn lhj1 lk_count 4
4959lk_jumpn lhj2 lk_nmodels
4960xq = lk_count 5
4961if gt xq 0
4962lk_jumpn lhj3 xq
4963end
4964xn = lk_count 2
4965if gt xn 0
4966lk_jumpn lhj4 xn
4967end
4968xs = lk_count 8
4969if gt xs 0
4970lk_jumpn lhj5 xs
4971end
4972end
4973
4974text lho0 "<section class=\"now-section now-op-section\" id=\"operator\" aria-labelledby=\"now-op-h\"><div class=\"container\"><p class=\"kicker\">On the operator's desk</p><h2 id=\"now-op-h\" class=\"now-h2\">Decisions Drake is making</h2><p class=\"now-sub\">Work that cannot move until a human answers. Each line names the answer it needs.</p><div class=\"now-grid\">"
4975text lhm0 "<section class=\"now-section\" id=\"streams\" aria-labelledby=\"now-streams-h\"><div class=\"container\"><p class=\"kicker\">In motion</p><h2 id=\"now-streams-h\" class=\"now-h2\">What the agents are doing</h2><p class=\"now-sub\">Lines written in the last day, grouped by stream. The bar under each name is the stream's pulse: one segment per line, bright when written in the last half hour, fading as it cools.</p>"
4976text lhm1 "<p class=\"now-empty\">No line in motion was written in the last day.</p>"
4977text lhm2 "<div class=\"now-stream\" id=\"stream-"
4978text lhm3 "\"><header class=\"now-stream-head\"><h3 class=\"now-stream-name\">"
4979text lhm4 "</h3><span class=\"now-stream-n\">"
4980text lhm5 "</span></header>"
4981text lhm6 "<div class=\"now-grid\">"
4982text lhm7 "</div></div>"
4983text lhm8 "</div></section>"
4984
4985fn lk_opsec to void
4986if eq lk_count 1 0
4987ret
4988end
4989sr_raw lho0
4990for xi ulong get lkn 0
4991if lk_in xi 1
4992lk_card xi
4993end
4994end
4995sr_raw lh95
4996end
4997
4998fn lk_streams to void
4999sr_raw lhm0
5000if eq lk_count 4 0
5001sr_raw lhm1
5002end
5003for xs uchar 8
5004xn = lk_scount 4 xs
5005if gt xn 0
5006sr_raw lhm2
5007lk_sslug xs
5008sr_raw lhm3
5009lk_sname xs
5010sr_raw lhm4
5011lk_lines xn
5012sr_raw lhm5
5013lk_river xs
5014sr_raw lhm6
5015for xi ulong get lkn 0
5016if and lk_in xi 4 eq get lkstrm xi xs
5017lk_card xi
5018end
5019end
5020sr_raw lhm7
5021end
5022end
5023sr_raw lhm8
5024end
5025
5026text lhqs0 "<section class=\"now-section\" id=\"quiet\" aria-labelledby=\"now-quiet-h\"><div class=\"container\"><p class=\"kicker\">Quiet</p><h2 id=\"now-quiet-h\" class=\"now-h2\">Open, not written in the last day</h2><p class=\"now-sub\">Still open, with an owner and notes, but nobody has written to them for over a day. Folded by stream; open a stream to read every line and its latest note.</p><div class=\"now-folds\">"
5027text lhqs1 "<section class=\"now-section\" id=\"next\" aria-labelledby=\"now-next-h\"><div class=\"container\"><p class=\"kicker\">Next</p><h2 id=\"now-next-h\" class=\"now-h2\">What is queued</h2><p class=\"now-sub\">Promised, with a finish line, not yet picked up or not yet reported on.</p>"
5028text lhqs2 "<ol class=\"now-queue\">"
5029text lhqs3 "</ol>"
5030text lhqs4 "<div class=\"now-folds\">"
5031
5032fn lk_quiet to void
5033if eq lk_count 5 0
5034ret
5035end
5036sr_raw lhqs0
5037for xs uchar 8
5038if gt lk_scount 5 xs 0
5039lk_fold 5 xs
5040end
5041end
5042sr_raw lh95
5043end
5044
5045fn lk_next to void
5046if eq lk_count 2 0
5047ret
5048end
5049sr_raw lhqs1
5050if gt lk_count 6 0
5051sr_raw lhqs2
5052for xi ulong get lkn 0
5053if lk_in xi 6
5054lk_row1 xi
5055end
5056end
5057sr_raw lhqs3
5058end
5059if gt lk_count 7 0
5060sr_raw lhqs4
5061lk_fold 7 255
5062sr_raw lh54
5063end
5064sr_raw lhm8
5065end
5066
5067text lhst0 "<section class=\"now-section\" id=\"settled\" aria-labelledby=\"now-settled-h\"><div class=\"container\"><p class=\"kicker\">Settled</p><h2 id=\"now-settled-h\" class=\"now-h2\">Decisions made, with their evidence</h2><p class=\"now-sub\">A line closes on evidence (a commit, a receipt, a file) or is dropped for a stated reason. The last day is shown open, newest first; earlier days are folded by date (UTC).</p>"
5068text lhst1 "<p class=\"now-empty\">Nothing settled in the last day.</p>"
5069text lhst2 "<ol class=\"now-timeline\">"
5070text lhst3 "settled-"
5071text lhst4 "Settled "
5072text lhst5 "</span></summary><ol class=\"now-timeline now-fold-rows\">"
5073text lhdu "date unknown"
5074
5075note day_of: the first ten bytes of updated (else opened) when it parses, else "date unknown".
5076fn lk_dayo i ulong to ulong
5077xk = ulong 7
5078if eq lk_fl i 7 0
5079xk = 1
5080end
5081xo = lk_fo i xk
5082xv = lk_utc 1 xo add xo lk_fl i xk
5083if eq get lkok 0 0
5084ret 0
5085end
5086ret add mul xk 8 1
5087end
5088
5089fn lk_dayout i ulong to void
5090xd = lk_dayo i
5091if eq xd 0
5092sr_raw lhdu
5093ret
5094end
5095xk = div sub xd 1 8
5096lk_e lk_fo i xk 10
5097end
5098
5099fn lk_dayeq a ulong b ulong to bool
5100xa = lk_dayo a
5101xb = lk_dayo b
5102if or eq xa 0 eq xb 0
5103ret eq xa xb
5104end
5105xp = lk_fo a div sub xa 1 8
5106xq = lk_fo b div sub xb 1 8
5107for xj ulong 10
5108if ne get lkcl add xp xj get lkcl add xq xj
5109ret false
5110end
5111end
5112ret true
5113end
5114
5115fn lk_old j ulong to bool
5116xi = get lkperm j
5117ret and lk_in xi 8 not lk_cur xi
5118end
5119
5120fn lk_settled to void
5121if eq lk_count 8 0
5122ret
5123end
5124sr_raw lhst0
5125if eq lk_count 9 0
5126sr_raw lhst1
5127else
5128sr_raw lhst2
5129for xj ulong get lkn 0
5130if lk_in get lkperm xj 9
5131lk_tl get lkperm xj
5132end
5133end
5134sr_raw lhqs3
5135end
5136sr_raw lhqs4
5137lk_days1
5138sr_raw lh95
5139end
5140
5141note One fold per run of equal days in the age-sorted old settled lines.
5142fn lk_days1 to void
5143xn = get lkn 0
5144xj = ulong 0
5145while lt xj xn bound 999999
5146if lk_old xj
5147xe = lk_dayend xj
5148lk_dayfold xj xe
5149xj = xe
5150else
5151xj = add xj 1
5152end
5153end
5154end
5155
5156fn lk_dayend j ulong to ulong
5157xa = get lkperm j
5158xk = add j 1
5159while lt xk get lkn 0 bound 999999
5160if lk_old xk
5161if not lk_dayeq xa get lkperm xk
5162ret xk
5163end
5164end
5165xk = add xk 1
5166end
5167ret xk
5168end
5169
5170fn lk_dayfold j ulong e ulong to void
5171xa = get lkperm j
5172xc = ulong 0
5173for xk ulong sub e j
5174if lk_old add j xk
5175xc = add xc 1
5176end
5177end
5178sr_raw lh40
5179sr_raw lhst3
5180lk_dayout xa
5181sr_raw lh41
5182sr_raw lhst4
5183lk_dayout xa
5184sr_raw lh42
5185lk_lines xc
5186sr_raw lhst5
5187for xm ulong sub e j
5188if lk_old add j xm
5189lk_tl get lkperm add j xm
5190end
5191end
5192sr_raw lh47
5193end
5194
5195text lhhow "<section class=\"now-section now-how\" id=\"how\" aria-labelledby=\"now-how-h\"><div class=\"container\"><p class=\"kicker\">How this page is made</p><h2 id=\"now-how-h\" class=\"now-h2\">One file, no hands</h2><p class=\"now-sub\">The coordinator and every agent append to one tab separated file on the Spark. A publisher pushed that file to the <a class=\"prose-link\" href=\"https://interplane.io/drakestapleton/aienos.com/tree/data/now\">data/now branch</a> whenever it changed; that push has been paused since 7 November 2026, so this page shows the last copy pushed, dated in the stamp at the top of this page. The site builder reads it at build time and writes this page and <a class=\"prose-link\" href=\"/now.json\">/now.json</a>. A line that is not in the file is not here. Every card, queue row and settled entry links to its own line of that file, and the commits, pull requests and evidence folders named in a note link to GitHub. Owners shown as &quot;agent&quot; are autonomous coding agents; the operator is one person. Keeper, the merge desk that lands finished changes, was called Renda until 24 October 2026: this page shows the new name, and the ledger on GitHub keeps each line as it was written. Keeper is the dachshund at the top of this page; a small one marks every line Keeper owns.</p></div></section>"
5196
5197fn sp_now to void
5198lk_load_all
5199lk_sort
5200lk_hero
5201lk_usage1
5202lk_opsec
5203lk_streams
5204lk_models
5205lk_quiet
5206lk_next
5207lk_settled
5208sr_raw lhhow
5209end
5210
5211note ---------------------------------------------------------------- /dash/
5212
5213text ldm0 "Jan"
5214text ldm1 "Feb"
5215text ldm2 "Mar"
5216text ldm3 "Apr"
5217text ldm4 "May"
5218text ldm5 "Jun"
5219text ldm6 "Jul"
5220text ldm7 "Aug"
5221text ldm8 "Sep"
5222text ldm9 "Oct"
5223text ldm10 "Nov"
5224text ldm11 "Dec"
5225
5226fn lk_mon m long to void
5227if eq m 1
5228sr_raw ldm0
5229end
5230if eq m 2
5231sr_raw ldm1
5232end
5233if eq m 3
5234sr_raw ldm2
5235end
5236if eq m 4
5237sr_raw ldm3
5238end
5239if eq m 5
5240sr_raw ldm4
5241end
5242if eq m 6
5243sr_raw ldm5
5244end
5245if eq m 7
5246sr_raw ldm6
5247end
5248if eq m 8
5249sr_raw ldm7
5250end
5251if eq m 9
5252sr_raw ldm8
5253end
5254if eq m 10
5255sr_raw ldm9
5256end
5257if eq m 11
5258sr_raw ldm10
5259end
5260if eq m 12
5261sr_raw ldm11
5262end
5263end
5264
5265note short_utc over an lkcl string; escaped output.
5266fn lk_endz o ulong e ulong to bool
5267if le e o
5268ret false
5269end
5270ret eq get lkcl sub e 1 90
5271end
5272
5273fn lk_short o ulong l ulong to void
5274xe = add o l
5275if lk_endz o xe
5276while gt xe o bound 999999
5277if ne get lkcl sub xe 1 90
5278break
5279end
5280xe = sub xe 1
5281end
5282end
5283xt = lk_find 1 o xe 84
5284if ge xt xe
5285lk_e o l
5286ret
5287end
5288xa = lk_find 1 o xt 45
5289if ge xa xt
5290lk_e o l
5291ret
5292end
5293xb = lk_find 1 add xa 1 xt 45
5294xm = lk_pint 1 add xa 1 xb
5295if or eq get lkok 0 0 or lt xm 1 gt xm 12
5296lk_e o l
5297ret
5298end
5299if ge xb xt
5300lk_e o l
5301ret
5302end
5303xc = lk_find 1 add xb 1 xt 45
5304lk_mon xm
5305sr_raw lhsp
5306xd = add xb 1
5307while lt xd xc bound 999999
5308if ne get lkcl xd 48
5309break
5310end
5311xd = add xd 1
5312end
5313lk_e xd sub xc xd
5314sr_raw lhsp
5315lk_e add xt 1 sub sub xe xt 1
5316end
5317
5318fn lk_shbuilt to void
5319xc = get lkcn 0
5320xo = lk_fmt lk_now false
5321lk_short xo get lklast 0
5322put lkcn 0 xc
5323end
5324
5325fn lk_shwr to void
5326xs = lk_written
5327if eq get lkok 0 0
5328sr_raw lhnev
5329ret
5330end
5331xc = get lkcn 0
5332xo = lk_fmt xs false
5333lk_short xo get lklast 0
5334put lkcn 0 xc
5335end
5336
5337text ldacu "https://interplane.io/drakestapleton/aienos.com/blob/data/now/accounts.tsv"
5338text ldrou "https://interplane.io/drakestapleton/aienos.com/blob/data/now/routing.tsv"
5339text ldpuu "https://interplane.io/drakestapleton/aienos.com/blob/data/now/now-pulse.tsv"
5340text ldf0 "Reading on GitHub"
5341text ldf1 "Pulse on GitHub"
5342text ldf2 "Ledger on GitHub"
5343text ldf3 "Routing on GitHub"
5344text ldcl "Claude "
5345
5346text ld0 "<div class=\"dash-limit"
5347text ld1 " dash-out"
5348text ld2 "\"><span class=\"dash-limit-k\">"
5349text ld3 "</span><meter class=\"dash-meter\" min=\"0\" max=\"100\" low=\"30\" high=\"70\" optimum=\"100\" value=\""
5350text ld4 "% left</meter><span class=\"dash-limit-v mono\">"
5351text ld5 "%</span><span class=\"dash-limit-r mono\">"
5352text ld6 "</span></div>"
5353
5354fn lk_dlimit i ulong to void
5355xu = get lkapc i
5356xlf = sub 100 xu
5357sr_raw ld0
5358if or ne get lkax i 0 eq xlf 0
5359sr_raw ld1
5360end
5361sr_raw ld2
5362xo = get lkal mul i 2
5363xl = get lkal add mul i 2 1
5364if and eq get lkap i 0 lk_eqpre xo xl ldcl
5365xo = add xo 7
5366xl = sub xl 7
5367end
5368lk_e xo xl
5369sr_raw ld3
5370lk_un xlf
5371sr_raw lhq
5372lk_un xlf
5373sr_raw ld4
5374lk_un xlf
5375sr_raw ld5
5376xr = get lkar add mul i 2 1
5377if gt xr 0
5378xc = get lkcn 0
5379lk_short get lkar mul i 2 xr
5380put lkcn 0 xc
5381end
5382sr_raw ld6
5383end
5384
5385text ld10 "<article class=\"dash-card\"><h2 class=\"dash-h\">"
5386text ld11 " <span class=\"dash-h-note\">% left</span></h2>"
5387text ld12 "<div class=\"dash-acct\"><div class=\"dash-acct-h\">Account "
5388text ld13 "<span class=\"dash-plan\">"
5389text ld14 "</div>"
5390
5391fn lk_pvname p uchar to void
5392if eq p 0
5393sr_raw lkpv0
5394end
5395if eq p 1
5396sr_raw lkpv1
5397end
5398if eq p 2
5399sr_raw lkpv2
5400end
5401if eq p 3
5402sr_raw lkpv3
5403end
5404end
5405
5406note Smallest account number above prev (or any when first) for provider p; 0 flag in lkok.
5407fn lk_nexta p uchar prev ulong first bool to ulong
5408xb = ulong 0
5409put lkok 0 0
5410for xi ulong get lkann 0
5411if eq get lkap xi p
5412xn = get lkan xi
5413if or first gt xn prev
5414if or eq get lkok 0 0 lt xn xb
5415xb = xn
5416put lkok 0 1
5417end
5418end
5419end
5420end
5421ret xb
5422end
5423
5424fn lk_acct p uchar n ulong to void
5425sr_raw ld12
5426lk_un n
5427xf = lk_afirst p n
5428xl = get lkapl add mul xf 2 1
5429if gt xl 0
5430sr_raw ld13
5431lk_e get lkapl mul xf 2 xl
5432sr_raw lkspc
5433end
5434sr_raw ld14
5435for xw uchar 2
5436for xi ulong get lkann 0
5437if eq get lkap xi p
5438if eq get lkan xi n
5439if eq get lkaw xi xw
5440lk_dlimit xi
5441end
5442end
5443end
5444end
5445end
5446sr_raw ld14
5447end
5448
5449fn lk_afirst p uchar n ulong to ulong
5450for xi ulong get lkann 0
5451if and eq get lkap xi p eq get lkan xi n
5452ret xi
5453end
5454end
5455ret 0
5456end
5457
5458fn lk_pcard p uchar to void
5459xn = lk_nexta p 0 true
5460if eq get lkok 0 0
5461ret
5462end
5463sr_raw ld10
5464lk_pvname p
5465sr_raw ld11
5466while true bound 1025
5467lk_acct p xn
5468xn = lk_nexta p xn false
5469if eq get lkok 0 0
5470break
5471end
5472end
5473lk_tfoot ldacu ldf0
5474sr_raw lh11
5475end
5476
5477text ld20 "<article class=\"dash container\"><header class=\"dash-top\"><h1 class=\"dash-title\">Dashboard</h1><p class=\"dash-meta mono\">quota read "
5478text ld21 " · built "
5479text ld22 " UTC</p></header>"
5480text ld23 "<p class=\"dash-warn\">This is the last quota reading the Spark published; nothing newer has arrived since.</p>"
5481text ld24 "<div class=\"dash-flow\">"
5482text ld25 "<article class=\"dash-card\"><h2 class=\"dash-h\">Quota</h2><p class=\"dash-none\">No quota reading has been published yet.</p>"
5483text ld26 "<article class=\"dash-card\"><h2 class=\"dash-h\">Spark</h2><dl class=\"dash-kv\"><dt>Serving</dt><dd>"
5484text ld27 "nothing answered"
5485text ld28 ", "
5486text ld29 "</dd>"
5487text ld30 "</dl>"
5488text ld31 "<article class=\"dash-card\"><h2 class=\"dash-h\"><a href=\"/now/\">Work</a></h2><dl class=\"dash-kv\"><dt>Open</dt><dd>"
5489text ld32 "</dd><dt>Waiting on Drake</dt><dd>"
5490text ld33 "</dd><dt>Settled, last day</dt><dd>"
5491text ld34 "</dd><dt>Ledger written</dt><dd>"
5492text ld35 "<article class=\"dash-card\"><h2 class=\"dash-h\">Which model does what</h2>"
5493text ld36 "</div></article>"
5494text ld37 "<dt>"
5495text ld38 "</dt><dd>"
5496text ldpk0 "memory free"
5497text ldpk1 "disk free"
5498text ldpk2 "wall power"
5499text ldr0 "Roles"
5500text ldr1 "Subagents"
5501text ldr2 "Advisor seats"
5502text ld40 "<div class=\"dash-pairs\"><h3 class=\"dash-pairs-h\">"
5503text ld41 "</h3>"
5504text ld42 "<p class=\"dash-none\">Not published.</p>"
5505text ld43 "<dl>"
5506text ld44 "</dt><dd class=\"mono\">"
5507
5508fn lk_dstale to bool
5509if eq get lkdcv 0 0
5510ret false
5511end
5512xc = lk_utc 1 get lkdc 0 add get lkdc 0 get lkdc 1
5513if eq get lkok 0 0
5514ret false
5515end
5516ret gt sub lk_now xc 7200
5517end
5518
5519fn lk_pulsekv k view uchar * to void
5520for xi ulong get lkpn 0
5521if lk_eqt get lkpk mul xi 2 get lkpk add mul xi 2 1 k
5522sr_raw ld37
5523sr_raw k
5524sr_raw ld38
5525lk_e get lkpv mul xi 2 get lkpv add mul xi 2 1
5526sr_raw ld29
5527ret
5528end
5529end
5530end
5531
5532fn lk_serving to void
5533xr = lk_roster
5534xn = ulong 0
5535xm = sj_first sj_find xr lkmj1
5536while ne xm 0 bound 65536
5537if eq lk_mstate xm 0
5538if gt xn 0
5539sr_raw ld28
5540end
5541sj_emit sj_find xm lkmj3
5542xn = add xn 1
5543end
5544xm = sj_next xm
5545end
5546if eq xn 0
5547sr_raw ld27
5548end
5549end
5550
5551fn lk_rskip k uchar i ulong to bool
5552if ne get lkrk i k
5553ret true
5554end
5555if and eq k 0 ne get lkseat 0 0
5556ret lk_eqt get lkrnm mul i 2 get lkrnm add mul i 2 1 lkadv
5557end
5558ret false
5559end
5560
5561note lk_pairv: one route pair's name and mode cells (split out of lk_pairs for registers).
5562fn lk_pairv j ulong to void
5563lk_e get lkrnm mul j 2 get lkrnm add mul j 2 1
5564sr_raw ld44
5565lk_e get lkrmd mul j 2 get lkrmd add mul j 2 1
5566end
5567
5568fn lk_pairs k uchar title view uchar * to void
5569sr_raw ld40
5570sr_raw title
5571sr_raw ld41
5572xn = ulong 0
5573for xi ulong get lkrcnt 0
5574if not lk_rskip k xi
5575xn = add xn 1
5576end
5577end
5578if eq xn 0
5579sr_raw ld42
5580else
5581sr_raw ld43
5582for xj ulong get lkrcnt 0
5583if not lk_rskip k xj
5584sr_raw ld37
5585lk_pairv xj
5586sr_raw ld29
5587end
5588end
5589sr_raw ld30
5590end
5591sr_raw lh54
5592end
5593
5594fn sp_dash to void
5595lk_load_all
5596sr_raw ld20
5597if ne get lkdcv 0 0
5598lk_short get lkdc 0 get lkdc 1
5599else
5600sr_raw lhnev
5601end
5602sr_raw ld21
5603lk_shbuilt
5604sr_raw ld22
5605if lk_dstale
5606sr_raw ld23
5607end
5608sr_raw ld24
5609if eq get lkann 0 0
5610sr_raw ld25
5611lk_tfoot ldacu ldf0
5612sr_raw lh11
5613end
5614for xp uchar 4
5615lk_pcard xp
5616end
5617sr_raw ld26
5618lk_serving
5619sr_raw ld29
5620lk_pulsekv ldpk0
5621lk_pulsekv ldpk1
5622lk_pulsekv ldpk2
5623sr_raw ld30
5624lk_tfoot ldpuu ldf1
5625sr_raw lh11
5626sr_raw ld31
5627lk_un lk_count 10
5628sr_raw ld32
5629lk_un lk_count 1
5630sr_raw ld33
5631lk_un lk_count 9
5632sr_raw ld34
5633lk_shwr
5634sr_raw ld29
5635sr_raw ld30
5636lk_tfoot lkledu ldf2
5637sr_raw lh11
5638sr_raw ld35
5639lk_pairs 0 ldr0
5640lk_pairs 1 ldr1
5641lk_pairs 2 ldr2
5642lk_tfoot ldrou ldf3
5643sr_raw lh11
5644sr_raw ld36
5645end
5646
5647note ---------------------------------------------------------------- /now.json
5648
5649text ljhex "0123456789abcdef"
5650text ljq "\""
5651text ljbs "\\\\"
5652text ljbq "\\\""
5653text ljb "\\b"
5654text ljf "\\f"
5655text ljn "\\n"
5656text ljr "\\r"
5657text ljt "\\t"
5658text lju "\\u00"
5659text ljnull "null"
5660text ljind " "
5661text ljkc ": "
5662text ljcm ","
5663text ljnl "\n"
5664text ljob "{"
5665text ljoe "}"
5666text ljab "["
5667text ljae "]"
5668text ljempty "[]"
5669
5670fn lk_jc c uchar to void
5671if eq c 34
5672sr_raw ljbq
5673ret
5674end
5675if eq c 92
5676sr_raw ljbs
5677ret
5678end
5679if ge c 32
5680sr_byte c
5681ret
5682end
5683if eq c 8
5684sr_raw ljb
5685ret
5686end
5687if eq c 12
5688sr_raw ljf
5689ret
5690end
5691if eq c 10
5692sr_raw ljn
5693ret
5694end
5695if eq c 13
5696sr_raw ljr
5697ret
5698end
5699if eq c 9
5700sr_raw ljt
5701ret
5702end
5703sr_raw lju
5704sr_byte get ljhex ulong shr c 4
5705sr_byte get ljhex ulong and c 15
5706end
5707
5708fn lk_js o ulong l ulong to void
5709sr_raw ljq
5710for xj ulong l
5711lk_jc get lkcl add o xj
5712end
5713sr_raw ljq
5714end
5715
5716fn lk_jt s view uchar * to void
5717sr_raw ljq
5718for xj ulong len s
5719lk_jc get s xj
5720end
5721sr_raw ljq
5722end
5723
5724fn lk_jn n ulong to void
5725sr_raw ljq
5726for xj ulong sj_size n
5727lk_jc sj_byte n xj
5728end
5729sr_raw ljq
5730end
5731
5732note Newline, indent d levels, "key": .
5733fn lk_jk d ulong k view uchar * first bool to void
5734if not first
5735sr_raw ljcm
5736end
5737sr_raw ljnl
5738for xj ulong d
5739sr_raw ljind
5740end
5741lk_jt k
5742sr_raw ljkc
5743end
5744
5745fn lk_jnl d ulong first bool to void
5746if not first
5747sr_raw ljcm
5748end
5749sr_raw ljnl
5750for xj ulong d
5751sr_raw ljind
5752end
5753end
5754
5755fn lk_jclose d ulong c view uchar * to void
5756sr_raw ljnl
5757for xj ulong d
5758sr_raw ljind
5759end
5760sr_raw c
5761end
5762
5763text ljk0 "built_utc"
5764text ljk1 "ledger_written_utc"
5765text ljk2 "items"
5766text ljk3 "pulse"
5767text ljk4 "models_checked_utc"
5768text ljk5 "claude"
5769text lji0 "id"
5770text lji1 "line"
5771text lji2 "opened_utc"
5772text lji3 "owner"
5773text lji4 "owner_kind"
5774text lji5 "status"
5775text lji6 "item"
5776text lji7 "done_when"
5777text lji8 "notes"
5778text lji9 "updated_utc"
5779text lji10 "stream"
5780text lji11 "age_s"
5781text ljm0 "state"
5782text ljm1 "served_as"
5783text ljc0 "checked_utc"
5784text ljc1 "limits"
5785text ljc2 "used_pct"
5786text ljc3 "resets_utc"
5787
5788fn lk_jitem i ulong first bool to void
5789lk_jnl 2 first
5790sr_raw ljob
5791lk_jk 3 lji0 true
5792lk_js lk_fo i 0 lk_fl i 0
5793lk_jk 3 lji1 false
5794lk_un get lkline i
5795lk_jk 3 lji2 false
5796lk_js lk_fo i 1 lk_fl i 1
5797lk_jk 3 lji3 false
5798lk_js lk_fo i 2 lk_fl i 2
5799lk_jk 3 lji4 false
5800sr_raw ljq
5801lk_kind get lkown i
5802sr_raw ljq
5803lk_jk 3 lji5 false
5804lk_js lk_fo i 3 lk_fl i 3
5805lk_jk 3 lji6 false
5806lk_js lk_fo i 4 lk_fl i 4
5807lk_jk 3 lji7 false
5808lk_js lk_fo i 5 lk_fl i 5
5809lk_jk 3 lji8 false
5810lk_jnotes i
5811lk_jk 3 lji9 false
5812lk_js lk_fo i 7 lk_fl i 7
5813lk_jk 3 lji10 false
5814sr_raw ljq
5815lk_sname get lkstrm i
5816sr_raw ljq
5817lk_jk 3 lji11 false
5818lk_ln get lkage i
5819lk_jclose 2 ljoe
5820end
5821
5822fn lk_jnotes i ulong to void
5823xc = get lknc i
5824if eq xc 0
5825sr_raw ljempty
5826ret
5827end
5828sr_raw ljab
5829xf = get lknf i
5830for xj ulong xc
5831lk_jnl 4 eq xj 0
5832lk_js get lkno add xf xj get lknl add xf xj
5833end
5834lk_jclose 3 ljae
5835end
5836
5837fn lk_jlink d ulong n ulong to void
5838if ne sj_kind n 1
5839sr_raw ljnull
5840ret
5841end
5842sr_raw ljob
5843lk_jk add d 1 lkmj11 true
5844lk_jn sj_find n lkmj11
5845lk_jk add d 1 lkmj12 false
5846lk_jn sj_find n lkmj12
5847lk_jclose d ljoe
5848end
5849
5850fn lk_jopt n ulong to void
5851if ne sj_kind n 3
5852sr_raw ljnull
5853ret
5854end
5855lk_jn n
5856end
5857
5858fn lk_jmodel m ulong first bool to void
5859xst = lk_mstate m
5860lk_jnl 2 first
5861sr_raw ljob
5862lk_jk 3 lkmj2 true
5863lk_jn sj_find m lkmj2
5864lk_jk 3 lkmj3 false
5865lk_jn sj_find m lkmj3
5866lk_jk 3 ljm0 false
5867if eq xst 0
5868lk_jt lkms0
5869else
5870if eq xst 1
5871lk_jt lkms1
5872else
5873lk_jn sj_find m lkmj5
5874end
5875end
5876lk_jk 3 ljm1 false
5877xj = lk_served m
5878if eq xj 9999
5879sr_raw ljnull
5880else
5881lk_js get lkmid mul xj 2 get lkmid add mul xj 2 1
5882end
5883lk_jmrest m
5884lk_jclose 2 ljoe
5885end
5886
5887fn lk_jmrest m ulong to void
5888lk_jk 3 lkmj6 false
5889lk_jn sj_find m lkmj6
5890lk_jk 3 lkmj7 false
5891lk_jn sj_find m lkmj7
5892lk_jk 3 lkmj8 false
5893lk_jopt sj_find m lkmj8
5894lk_jk 3 lkmj9 false
5895lk_jlink 3 sj_find m lkmj9
5896lk_jk 3 lkmj10 false
5897xa = sj_find m lkmj10
5898if eq sj_len xa 0
5899sr_raw ljempty
5900ret
5901end
5902sr_raw ljab
5903xf = sj_first xa
5904xfirst = true
5905while ne xf 0 bound 65536
5906lk_jnl 4 xfirst
5907xfirst = false
5908sr_raw ljob
5909lk_jk 5 lkmj11 true
5910lk_jn sj_find xf lkmj11
5911lk_jk 5 lkmj13 false
5912lk_jn sj_find xf lkmj13
5913lk_jk 5 lkmj14 false
5914lk_jn sj_find xf lkmj14
5915lk_jclose 4 ljoe
5916xf = sj_next xf
5917end
5918lk_jclose 3 ljae
5919end
5920
5921fn lk_jusage to void
5922if eq get lkuv 0 0
5923sr_raw ljnull
5924ret
5925end
5926sr_raw ljob
5927lk_jk 2 ljc0 true
5928lk_js get lkuc 0 get lkuc 1
5929lk_jk 2 lkmj0 false
5930if eq get lkup 1 0
5931lk_jt lkuclau
5932else
5933lk_js get lkup 0 get lkup 1
5934end
5935lk_jk 2 ljc1 false
5936sr_raw ljab
5937for xi ulong get lkun 0
5938lk_jnl 3 eq xi 0
5939sr_raw ljob
5940lk_jk 4 lkmj11 true
5941sr_raw ljq
5942lk_julabel xi
5943sr_raw ljq
5944lk_jk 4 ljc2 false
5945lk_un get lkupc xi
5946lk_jk 4 ljc3 false
5947lk_js get lkur mul xi 2 get lkur add mul xi 2 1
5948lk_jclose 3 ljoe
5949end
5950lk_jclose 2 ljae
5951lk_jclose 1 ljoe
5952end
5953
5954note Labels are fixed ASCII plus usage_words output, so no JSON escapes are needed.
5955fn lk_julabel i ulong to void
5956xk = get lkuk i
5957if eq xk 0
5958sr_raw lku0
5959ret
5960end
5961if eq xk 1
5962sr_raw lku1
5963ret
5964end
5965sr_raw lku2
5966lk_r get lkus mul i 2 get lkus add mul i 2 1
5967sr_raw lku3
5968end
5969
5970fn lk_jwr to void
5971xs = lk_written
5972if eq get lkok 0 0
5973lk_jt lhnev
5974ret
5975end
5976xc = get lkcn 0
5977xo = lk_fmt xs false
5978lk_js xo get lklast 0
5979put lkcn 0 xc
5980end
5981
5982fn lk_jmc to void
5983if eq get lkmcv 0 0
5984lk_jt lhnev
5985ret
5986end
5987lk_js get lkmc 0 get lkmc 1
5988end
5989
5990fn sp_now_json to void
5991lk_load_all
5992sr_raw ljob
5993lk_jk 1 ljk0 true
5994xc = get lkcn 0
5995xo = lk_fmt lk_now false
5996lk_js xo get lklast 0
5997put lkcn 0 xc
5998lk_jk 1 ljk1 false
5999lk_jwr
6000lk_jk 1 ljk2 false
6001if eq get lkn 0 0
6002sr_raw ljempty
6003else
6004sr_raw ljab
6005for xi ulong get lkn 0
6006lk_jitem xi eq xi 0
6007end
6008lk_jclose 1 ljae
6009end
6010lk_jk 1 ljk3 false
6011lk_jpulse
6012lk_jk 1 ljk4 false
6013lk_jmc
6014lk_jmods
6015lk_jk 1 ljk5 false
6016lk_jusage
6017lk_jclose 0 ljoe
6018end
6019
6020fn lk_jpulse to void
6021if eq get lkpn 0 0
6022sr_raw ljempty
6023ret
6024end
6025sr_raw ljab
6026for xi ulong get lkpn 0
6027lk_jnl 2 eq xi 0
6028sr_raw ljob
6029lk_jk 3 lkmj2 true
6030lk_js get lkpk mul xi 2 get lkpk add mul xi 2 1
6031lk_jk 3 lkmj13 false
6032lk_js get lkpv mul xi 2 get lkpv add mul xi 2 1
6033lk_jclose 2 ljoe
6034end
6035lk_jclose 1 ljae
6036end
6037
6038fn lk_jmods to void
6039xr = lk_roster
6040lk_jk 1 lkmj0 false
6041lk_jlink 1 sj_find xr lkmj0
6042lk_jk 1 lkmj1 false
6043xa = sj_find xr lkmj1
6044if eq sj_len xa 0
6045sr_raw ljempty
6046ret
6047end
6048sr_raw ljab
6049xm = sj_first xa
6050xfirst = true
6051while ne xm 0 bound 65536
6052lk_jmodel xm xfirst
6053xfirst = false
6054xm = sj_next xm
6055end
6056lk_jclose 1 ljae
6057end
6058
6059note ---------------------------------------------------------------- /now/feed.xml
6060
6061text lfx0 "&amp;"
6062text lfx1 "&lt;"
6063text lfx2 "&gt;"
6064text lfx3 "&quot;"
6065text lfhead0 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<feed xmlns=\"http://www.w3.org/2005/Atom\">\n <title>AienOS: settled work from the live ledger</title>\n <subtitle>Every coordination ledger line that reached done or dropped, with the evidence that settled it.</subtitle>\n <link href=\"https://www.aienos.com/now/feed.xml\" rel=\"self\" type=\"application/atom+xml\"/>\n <link href=\"https://www.aienos.com/\" rel=\"alternate\" type=\"text/html\"/>\n <id>https://www.aienos.com/now/feed.xml</id>\n <updated>"
6066text lfhead1 "</updated>\n <author><name>M. Drake Stapleton</name><uri>https://www.drakestapleton.com</uri></author>\n <rights>Apache-2.0 WITH LLVM-exception</rights>\n <icon>https://www.aienos.com/logo.png</icon>\n <logo>https://www.aienos.com/og.png</logo>\n"
6067text lfe0 " <entry>\n <title>"
6068text lfe1 ": "
6069text lfe2 " ("
6070text lfe3 ")</title>\n <link href=\"https://www.aienos.com/now/#"
6071text lfe4 "\" rel=\"alternate\" type=\"text/html\"/>\n <id>https://www.aienos.com/now/#"
6072text lfe5 "</id>\n <published>"
6073text lfe6 "</published>\n <updated>"
6074text lfe7 "</updated>\n <content type=\"text\">"
6075text lfe8 "</content>\n <category term=\""
6076text lfe9 "\"/>\n </entry>\n"
6077text lfend "</feed>\n"
6078text lfb0 "Status: "
6079text lfb1 ". Owner: "
6080text lfb2 ". Stream: "
6081text lfb3 "."
6082text lfb4 "\nDone when: "
6083text lfb5 "\nEvidence:"
6084text lfb6 "\n- "
6085
6086fn lk_xc c uchar to void
6087if eq c 38
6088sr_raw lfx0
6089ret
6090end
6091if eq c 60
6092sr_raw lfx1
6093ret
6094end
6095if eq c 62
6096sr_raw lfx2
6097ret
6098end
6099if eq c 34
6100sr_raw lfx3
6101ret
6102end
6103sr_byte c
6104end
6105
6106fn lk_x o ulong l ulong to void
6107for xj ulong l
6108lk_xc get lkcl add o xj
6109end
6110end
6111
6112fn lk_xf i ulong k ulong to void
6113lk_x lk_fo i k lk_fl i k
6114end
6115
6116note Feed order: updated descending (unparsable last), then id descending, bytewise.
6117fn lk_fbefore a ulong b ulong to bool
6118xa = get lkupv a
6119xb = get lkupv b
6120if ne xa xb
6121ret gt xa xb
6122end
6123if and ne xa 0 ne get lkupd a get lkupd b
6124ret gt get lkupd a get lkupd b
6125end
6126ret lk_idgt a b
6127end
6128
6129fn lk_idgt a ulong b ulong to bool
6130xo = lk_fo a 0
6131xl = lk_fl a 0
6132xp = lk_fo b 0
6133xm = lk_fl b 0
6134for xj ulong xl
6135if ge xj xm
6136ret true
6137end
6138xc = get lkcl add xo xj
6139xd = get lkcl add xp xj
6140if ne xc xd
6141ret gt xc xd
6142end
6143end
6144ret false
6145end
6146
6147fn lk_fsort to ulong
6148xn = ulong 0
6149for xi ulong get lkn 0
6150if lk_in xi 8
6151xk = xn
6152while gt xk 0 bound 999999
6153if not lk_fbefore xi get lkperm sub xk 1
6154break
6155end
6156put lkperm xk get lkperm sub xk 1
6157xk = sub xk 1
6158end
6159put lkperm xk xi
6160xn = add xn 1
6161end
6162end
6163ret xn
6164end
6165
6166fn lk_rfc s long to void
6167xc = get lkcn 0
6168xo = lk_fmt s true
6169lk_r xo get lklast 0
6170put lkcn 0 xc
6171end
6172
6173fn lk_fwr to void
6174xs = lk_written
6175if eq get lkok 0 0
6176xs = lk_now
6177end
6178lk_rfc xs
6179end
6180
6181fn lk_fentry i ulong to void
6182sr_raw lfe0
6183lk_xf i 0
6184sr_raw lfe1
6185lk_xf i 4
6186sr_raw lfe2
6187lk_xf i 3
6188sr_raw lfe3
6189lk_xf i 0
6190sr_raw lfe4
6191lk_xf i 0
6192sr_raw lfe5
6193if ne get lkopv i 0
6194lk_rfc get lkopd i
6195else
6196lk_fupd i
6197end
6198sr_raw lfe6
6199lk_fupd i
6200sr_raw lfe7
6201lk_fbody i
6202sr_raw lfe8
6203lk_xf i 3
6204sr_raw lfe9
6205end
6206
6207fn lk_fupd i ulong to void
6208if ne get lkupv i 0
6209lk_rfc get lkupd i
6210ret
6211end
6212lk_fwr
6213end
6214
6215fn lk_fbody i ulong to void
6216sr_raw lfb0
6217lk_xf i 3
6218sr_raw lfb1
6219lk_xf i 2
6220sr_raw lfb2
6221lk_sname get lkstrm i
6222sr_raw lfb3
6223if gt lk_fl i 5 0
6224sr_raw lfb4
6225lk_xf i 5
6226end
6227xc = get lknc i
6228if gt xc 0
6229sr_raw lfb5
6230xf = get lknf i
6231for xj ulong xc
6232sr_raw lfb6
6233lk_x get lkno add xf xj get lknl add xf xj
6234end
6235end
6236end
6237
6238fn sp_now_feed to void
6239lk_load_all
6240xn = lk_fsort
6241sr_raw lfhead0
6242lk_fwr
6243sr_raw lfhead1
6244for xj ulong xn
6245lk_fentry get lkperm xj
6246end
6247sr_raw lfend
6248end