interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / apps / interplane-forge / store / repos.om

1112 lines · 22955 bytes Raw Blame History
1note store/repos.om: the native-store source of the store-reading build. run.sh composes it in place
2note of server/repos.om when FORGE_STORE is set, after .build/store.om (tfsroot, the store root with a
3note final "/", and FSCB / tfcbase, the HTTPS clone base). It defines the words server/repos.om
4note defines (fload, fsrcchg, fkgit, fkgiti, fputid, fhasal, fradsrc, fpjterms, fjclone, tfsf4) from
5note the store that interplane-native CONTRACT.md v0 describes:
6note ROOT/catalog.tsv name TAB id TAB default-branch TAB head TAB visibility LF
7note ROOT/projects/NAME/repo.git the project's bare Git repository
8note ROOT/projects/NAME/records/1 record 1: name, branch, visibility, owner key, alias, nonce
9note The project list is the catalog and nothing else: no folder is scanned, and RIDS.md and
10note ~/.radicle are never read on this path. Fail closed: a catalog that cannot be read or is a link,
11note is longer than fxo, has a line without exactly five tab-separated fields or without its final
12note line feed, holds a control byte, a name, id, branch, head or visibility outside the rules of
13note om/landrec.om in interplane-native, two names that differ only in case or two equal ids: then
14note fan is 0 (every repository URL is 404) and one "forged: catalog refused" line on stderr gives
15note the reason and the line. Private lines are skipped. Every public line is served (Drake's
16note decision: the store build serves the whole public catalog, minus the deny list), except one the
17note allow-list table cannot hold (FAMAX rows, server/util.om; store/tests/capacity.sh alarms long
18note before), left out with one line each. A public line is served only when (xsok):
19note ROOT/projects, the project folder, its repo.git and records are folders, not links (lstat);
20note records/1 (opened without following a link) hashes to the line's id with SHA-256, and is the
21note PROJECT record of the same name, branch and visibility public;
22note the deny list (server/repos.om fdeny) names neither the name nor the old Radicle id;
23note no project already served has the same old Radicle id;
24note refs/heads/<branch> in repo.git is exactly the line's head (or is absent when the head is none);
25note the name fits the table (100 bytes, fnmput) and the branch too (60 bytes, fbrput).
26note Otherwise that project alone is left out with one "forged: project NAME left out" line on stderr.
27note The key of a project (faid: social targets, counts, receipts, the archive cache folder, /rad:
28note links) is its old Radicle id from record 1 (alias) without "rad:", or its 64-hex id when it has
29note none. New identifiers in pages and machine forms are git:<id> (fputid).
30global xsgid uchar 16384
31global xshead uchar 10240
32global xshn ulong 256
33global xsown uchar 16384
34global xsownl ulong 256
35global xsal ulong 256
36global xskeep ulong 256
37global xsck ulong 4
38global xsmsg uchar 8192
39global xsml ulong 1
40text tfsprjd "projects"
41text tfsrec "/records"
42text tfsrec1 "/records/1"
43text tfscat "catalog.tsv"
44text tfsgitp "git:"
45text tfradp "rad:"
46text tfsnone "none"
47text tfspub "public"
48text tfspriv "private"
49text tfsrevp "rev-parse"
50text tfsq "-q"
51text tfsvfy "--verify"
52text tfscmt "^{commit}"
53text tfsr1a "interplane-project 1\nproject "
54text tfsr1b "branch "
55text tfsr1c "visibility public\nowner "
56text tfsr1d "alias "
57text tfsr1e "nonce "
58text tfsfp "SHA256:"
59text tfsm1 "forged: catalog refused ("
60text tfsm2 " at line "
61text tfsm3 "); no repositories are served\n"
62text tfsm4 "forged: project "
63text tfsm5 " left out ("
64text tfsm6 ")\n"
65text tfsrd "cannot be read or is a link"
66text tfsbig "longer than the read buffer"
67text tfsnolf "no final line feed"
68text tfsctl "control byte"
69text tfsnf "not five tab-separated fields"
70text tfsbn "name outside the name rule"
71text tfsbi "id is not 64 lowercase hex digits"
72text tfsbb "branch outside the branch rule"
73text tfsbh "head is not 40 lowercase hex digits or none"
74text tfsbv "visibility is not public or private"
75text tfsdn "two names that differ only in case"
76text tfsdn2 "two equal names"
77text tfsdi "two equal ids"
78text tfsful "the allow-list table is full (FAMAX rows, server/util.om)"
79text tfsplk "ROOT/projects is a link or not a folder"
80text tfslnm "name longer than 100 bytes (server/repos.om fnmput)"
81text tfslbr "branch longer than 60 bytes (server/repos.om fbrput)"
82text tfslpf "project folder is a link or not a folder"
83text tfslrg "repo.git is a link or not a folder"
84text tfslrc "records is a link or not a folder"
85text tfslr1 "records/1 cannot be read or is a link"
86text tfslhs "records/1 does not hash to the catalog id"
87text tfslpr "records/1 is not the PROJECT record of this name, branch and visibility public"
88text tfsldn "on the deny list"
89text tfsldl "old Radicle id already used by a project listed before it"
90text tfslhd "refs/heads/<branch> in repo.git is not the catalog head"
91text tfslpl "path longer than the system allows"
92note ---- stderr lines
93fn xsmb to void
94put xsml 0 0
95end
96fn xsmc c uchar to void
97n = get xsml 0
98if lt n len xsmsg
99put xsmsg n c
100put xsml 0 add n 1
101end
102end
103fn xsmt t view uchar * to void
104for i ulong len t bound 8192
105xsmc get t i
106end
107end
108fn xsmn v ulong to void
109d = new uchar 20 0
110i = ulong 20
111x = v
112for it ulong 20
113i = sub i 1
114put d i uchar add rem x 10 48
115x = div x 10
116if eq x 0
117break
118end
119end
120for k ulong sub 20 i bound 20
121xsmc get d add i k
122end
123end
124fn xsmw to void
125w = write 2 xsmsg 0 get xsml 0
126end
127note xsrefuse: the whole catalog is refused (line 0: no line)
128fn xsrefuse t view uchar * ln ulong to long
129put fan 0 0
130xsmb
131xsmt tfsm1
132xsmt t
133if gt ln 0
134xsmt tfsm2
135xsmn ln
136end
137xsmt tfsm3
138xsmw
139ret -1
140end
141note xsleave: project k is left out
142fn xsleave k ulong t view uchar * to void
143put xskeep k 0
144xsmb
145xsmt tfsm4
146for i ulong get fanl k bound 128
147xsmc frnbyte k i
148end
149xsmt tfsm5
150xsmt t
151xsmt tfsm6
152xsmw
153end
154note ---- byte rules (om/landrec.om of interplane-native: isname, isref, hex)
155fn xsaln c uchar to bool
156ret fisaln c
157end
158fn xsnamec c uchar to bool
159ret or xsaln c or eq c 46 or eq c 95 eq c 45
160end
161fn xshexc c uchar to bool
162ret or fisdig c and ge c 97 le c 102
163end
164fn xsisname a ulong b ulong to bool
165if ge a b
166ret false
167end
168if not xsaln get fxo a
169ret false
170end
171if eq get fxo sub b 1 46
172ret false
173end
174j = a
175while lt j b bound 16777216
176if not xsnamec get fxo j
177ret false
178end
179j = add j 1
180end
181ret true
182end
183fn xsishex a ulong b ulong n ulong to bool
184if ne sub b a n
185ret false
186end
187j = a
188while lt j b bound 16777216
189if not xshexc get fxo j
190ret false
191end
192j = add j 1
193end
194ret true
195end
196fn xsrefc c uchar to bool
197ret or xsnamec c eq c 47
198end
199note xslock: fxo[e-5, e) is ".lock" and starts at or after a
200fn xslock a ulong e ulong to bool
201if lt sub e a 5
202ret false
203end
204s = sub e 5
205if ne get fxo s 46
206ret false
207end
208if ne get fxo add s 1 108
209ret false
210end
211if ne get fxo add s 2 111
212ret false
213end
214if ne get fxo add s 3 99
215ret false
216end
217ret eq get fxo add s 4 107
218end
219fn xsisref a ulong b ulong to bool
220if ge a b
221ret false
222end
223f = get fxo a
224if or eq f 45 or eq f 46 eq f 47
225ret false
226end
227l = get fxo sub b 1
228if or eq l 46 eq l 47
229ret false
230end
231p = uchar 0
232j = a
233while lt j b bound 16777216
234c = get fxo j
235if not xsrefc c
236ret false
237end
238if and eq c 46 or eq p 46 eq p 47
239ret false
240end
241if and eq c 47 eq p 47
242ret false
243end
244if eq c 47
245if xslock a j
246ret false
247end
248end
249p = c
250j = add j 1
251end
252ret not xslock a b
253end
254fn xstxeq a ulong b ulong t view uchar * to bool
255if ne sub b a len t
256ret false
257end
258for k ulong len t bound 64
259if ne get fxo add a k get t k
260ret false
261end
262end
263ret true
264end
265note ---- catalog lines: fxo[p, e) is one line without its line feed
266fn xstab p ulong e ulong k ulong to ulong
267note start of field k (0..4); fields are known to exist
268j = p
269n = ulong 0
270while lt j e bound 16777216
271if eq n k
272ret j
273end
274if eq get fxo j 9
275n = add n 1
276end
277j = add j 1
278end
279ret e
280end
281fn xsfend s ulong e ulong to ulong
282j = s
283while lt j e bound 16777216
284if eq get fxo j 9
285ret j
286end
287j = add j 1
288end
289ret e
290end
291note xsline: the reason line p..e breaks a rule, or 0 when it is well formed
292fn xsline p ulong e ulong to ulong
293t = ulong 0
294j = p
295while lt j e bound 16777216
296c = get fxo j
297if eq c 9
298t = add t 1
299else
300if or lt c 32 eq c 127
301ret 1
302end
303end
304j = add j 1
305end
306if ne t 4
307ret 2
308end
309ret xsfields p e
310end
311note xsfields: the five fields of a line with four tabs and no control byte
312fn xsfields p ulong e ulong to ulong
313s = p
314f = xsfend s e
315if not xsisname s f
316ret 3
317end
318s = add f 1
319f = xsfend s e
320if not xsishex s f 64
321ret 4
322end
323s = add f 1
324f = xsfend s e
325if not xsisref s f
326ret 5
327end
328s = add f 1
329f = xsfend s e
330if not xshdok s f
331ret 6
332end
333s = add f 1
334if not xsvisok s e
335ret 7
336end
337ret 0
338end
339fn xshdok s ulong f ulong to bool
340if xsishex s f 40
341ret true
342end
343ret xstxeq s f tfsnone
344end
345fn xsvisok s ulong e ulong to bool
346if xstxeq s e tfspub
347ret true
348end
349ret xstxeq s e tfspriv
350end
351fn xsreason r ulong ln ulong to long
352if eq r 1
353ret xsrefuse tfsctl ln
354end
355if eq r 2
356ret xsrefuse tfsnf ln
357end
358if eq r 3
359ret xsrefuse tfsbn ln
360end
361if eq r 4
362ret xsrefuse tfsbi ln
363end
364if eq r 5
365ret xsrefuse tfsbb ln
366end
367if eq r 6
368ret xsrefuse tfsbh ln
369end
370if eq r 7
371ret xsrefuse tfsbv ln
372end
373if eq r 8
374ret xsrefuse tfsdn ln
375end
376if eq r 10
377ret xsrefuse tfsdn2 ln
378end
379ret xsrefuse tfsdi ln
380end
381fn xsfold c uchar to uchar
382if and ge c 65 le c 90
383ret add c 32
384end
385ret c
386end
387note xsdupat: line [p, e) repeats the name (10 the same bytes, 8 apart from case) or the id (9) of
388note line [q, f); 0 if neither
389fn xsdupat p ulong e ulong q ulong f ulong to ulong
390b = xsfend p e
391d = xsfend q f
392if xsfoldeq p b q d
393if xsexeq p b q
394ret 10
395end
396ret 8
397end
398if xsideq add b 1 add d 1
399ret 9
400end
401ret 0
402end
403note xsexeq: fxo[a, b) equals the same number of bytes at c
404fn xsexeq a ulong b ulong c ulong to bool
405for k ulong sub b a bound 16777216
406if ne get fxo add a k get fxo add c k
407ret false
408end
409end
410ret true
411end
412note xsfoldeq: fxo[a, b) and fxo[c, d) are equal apart from the case of A-Z
413fn xsfoldeq a ulong b ulong c ulong d ulong to bool
414if ne sub b a sub d c
415ret false
416end
417for k ulong sub b a bound 16777216
418x = xsfold get fxo add a k
419y = xsfold get fxo add c k
420if ne x y
421ret false
422end
423end
424ret true
425end
426fn xsideq a ulong c ulong to bool
427for k ulong 64
428if ne get fxo add a k get fxo add c k
429ret false
430end
431end
432ret true
433end
434note xsdup: line [p, e) repeats a line before it (8 or 9), or 0
435fn xsdup p ulong e ulong to ulong
436q = ulong 0
437while lt q p bound 16777216
438f = fleol q p
439r = xsdupat p e q f
440if ne r 0
441ret r
442end
443q = add f 1
444end
445ret 0
446end
447fn xsispub p ulong e ulong to bool
448s4 = xstab p e 4
449ret xstxeq s4 e tfspub
450end
451note ---- paths
452fn xspfold to void
453fpb
454fpt tfsroot
455fpt tfsprj
456end
457note xspdir: ROOT/projects without the final "/", so that lstat sees a link as a link
458fn xspdir to void
459fpb
460fpt tfsroot
461fpt tfsprjd
462end
463fn xspproj k ulong to void
464xspfold
465for i ulong get fanl k bound 128
466fpc frnbyte k i
467end
468end
469fn xspfull to bool
470ret ge get fpthl 0 4095
471end
472note xsisdir: lstat of fpth is a folder (a link is not)
473fn xsisdir to bool
474if xspfull
475ret false
476end
477r = lstat fpth 0 get fpthl 0 fstb 0 128
478if lt r 0
479ret false
480end
481m = or ulong get fstb 16 shl ulong get fstb 17 8
482ret eq and m 61440 16384
483end
484note xsrdnf: read the file at fpth into fxo without following a link (O_NOFOLLOW | O_CLOEXEC);
485note the length, or -1 when it cannot be opened or is longer than fxo
486fn xsrdnf to long
487b = new uchar 1 0
488put fxol 0 0
489put fxotr 0 0
490if xspfull
491ret -1
492end
493fd = fopen fpth 0 get fpthl 0 557056 0
494if lt fd 0
495ret -1
496end
497ok = true
498for it ulong 16777217
499n = get fxol 0
500if ge n len fxo
501q = read int fd b 0 1
502if ne q 0
503put fxotr 0 1
504ok = false
505end
506break
507end
508r = read int fd fxo n sub len fxo n
509if lt r 0
510ok = false
511break
512end
513if eq r 0
514break
515end
516put fxol 0 add n ulong r
517end
518x = fclose int fd
519if not ok
520ret -1
521end
522ret long get fxol 0
523end
524note xsstat: the change key of the catalog (inode, size, mtime s, mtime ns), all 0 when missing
525fn xsstat k edit ulong 4 to void
526fpb
527fpt tfsroot
528fpt tfscat
529for i ulong 4
530put k i 0
531end
532r = stat fpth 0 get fpthl 0 fstb 0 128
533if lt r 0
534ret
535end
536put k 0 xsle8 8
537put k 1 xsle8 48
538put k 2 xsle8 88
539put k 3 xsle8 96
540end
541fn xsle8 o ulong to ulong
542v = ulong 0
543for i ulong 8
544v = or v shl ulong get fstb add o i mul i 8
545end
546ret v
547end
548fn fsrcchg to bool
549k = new ulong 4 0
550xsstat k
551for i ulong 4
552if ne get k i get xsck i
553ret true
554end
555end
556ret false
557end
558note ---- the catalog
559fn fload to long
560put fan 0 0
561put fsrcst 0 1
562fd = fopen tfpubgit 0 len tfpubgit 0 0
563put fpubgit 0 0
564if ge fd 0
565put fpubgit 0 1
566x = fclose int fd
567end
568put fsrtl 0 0
569for i ulong len tfsroot bound 4096
570put fsrt i get tfsroot i
571put fsrtl 0 add i 1
572end
573k = new ulong 4 0
574xsstat k
575for i ulong 4
576put xsck i get k i
577end
578xspdir
579if not xsisdir
580ret xsrefuse tfsplk 0
581end
582n = xscatrd
583if lt n 0
584if ne get fxotr 0 0
585ret xsrefuse tfsbig 0
586end
587ret xsrefuse tfsrd 0
588end
589ln = ulong n
590if and gt ln 0 ne get fxo sub ln 1 10
591ret xsrefuse tfsnolf 0
592end
593p = ulong 0
594li = ulong 0
595while lt p ln bound 16777216
596e = fleol p ln
597li = add li 1
598r = xsline p e
599if ne r 0
600ret xsreason r li
601end
602r = xsdup p e
603if ne r 0
604ret xsreason r li
605end
606p = add e 1
607end
608m = xsfill ln
609put fan 0 m
610for i ulong m bound FAMAX
611xscheck i
612end
613w = ulong 0
614for i ulong m bound FAMAX
615if eq get xskeep i 1
616xsmove w i
617w = add w 1
618end
619end
620put fan 0 w
621for i ulong w bound FAMAX
622fmeta i
623end
624ret long w
625end
626note xscatrd: ROOT/catalog.tsv into fxo, opened without following a link. The project list is this
627note file and nothing else (store/tests/compare.sh mutant "scan" replaces this word with a reader
628note of the project folders and must be caught).
629fn xscatrd to long
630fpb
631fpt tfsroot
632fpt tfscat
633ret xsrdnf
634end
635note xsfill: every public line of the catalog in fxo[0, ln) into the table, in catalog order; the
636note number of rows. A name or branch the table cannot hold, or a line past FAMAX rows, leaves that
637note project out here.
638fn xsfill ln ulong to ulong
639k = ulong 0
640p = ulong 0
641while lt p ln bound 16777216
642e = fleol p ln
643if xsispub p e
644e0 = xsfend p e
645if ge k FAMAX
646xsleavr p e0 tfsful
647else
648if xsrow k p e
649k = add k 1
650end
651end
652end
653p = add e 1
654end
655ret k
656end
657fn xsrow k ulong p ulong e ulong to bool
658e0 = xsfend p e
659if not fnmput k p e0
660xsleavr p e0 tfslnm
661ret false
662end
663s = xstab p e 2
664if not fbrput k s xsfend s e
665xsleavr p e0 tfslbr
666ret false
667end
668xsrowid k xstab p e 1
669xsrowhd k xstab p e 3 e
670put faio k mul k 64
671put fail k 0
672put xsal k 0
673put xsownl k 0
674put xskeep k 1
675ret true
676end
677fn xsrowid k ulong s ulong to void
678g = mul k 64
679for j ulong 64
680put xsgid add g j get fxo add s j
681end
682end
683fn xsrowhd k ulong s ulong e ulong to void
684if xstxeq s xsfend s e tfsnone
685put xshn k 0
686ret
687end
688put xshn k 1
689g = mul k 40
690for j ulong 40
691put xshead add g j get fxo add s j
692end
693end
694note xsleavr: a project left out while its name is still in fxo[a, b)
695fn xsleavr a ulong b ulong t view uchar * to void
696xsmb
697xsmt tfsm4
698for j ulong sub b a bound 16777216
699xsmc get fxo add a j
700end
701xsmt tfsm5
702xsmt t
703xsmt tfsm6
704xsmw
705end
706note ---- one project (xscheck sets xskeep k to 1 when it is served)
707fn xscheck k ulong to void
708put xskeep k 0
709if not xsfolders k
710ret
711end
712if not xsrec1 k
713ret
714end
715if fdeny k
716xsleave k tfsldn
717ret
718end
719if xsaldup k
720xsleave k tfsldl
721ret
722end
723if not xsheadok k
724xsleave k tfslhd
725ret
726end
727put xskeep k 1
728end
729fn xsfolders k ulong to bool
730xspproj k
731if xspfull
732xsleave k tfslpl
733ret false
734end
735if not xsisdir
736xsleave k tfslpf
737ret false
738end
739xspproj k
740fpt tfsrg
741if not xsisdir
742xsleave k tfslrg
743ret false
744end
745xspproj k
746fpt tfsrec
747if not xsisdir
748xsleave k tfslrc
749ret false
750end
751ret true
752end
753note xsrec1: records/1 of project k hashes to its id and is its PROJECT record; sets the key, the
754note owner and xsal
755fn xsrec1 k ulong to bool
756xspproj k
757fpt tfsrec1
758n = xsrdnf
759if lt n 0
760xsleave k tfslr1
761ret false
762end
763if not xshashok k ulong n
764xsleave k tfslhs
765ret false
766end
767if not xsparse k ulong n
768xsleave k tfslpr
769ret false
770end
771ret true
772end
773fn xshashok k ulong n ulong to bool
774c = new ulong 40 0
775b = new uchar 4096 0
776h = new uchar 32 0
777sha256_init c
778o = ulong 0
779while lt o n bound 16777216
780m = hmin sub n o 4096
781for j ulong m bound 4096
782put b j get fxo add o j
783end
784sha256_update c part b 0 m
785o = add o m
786end
787sha256_final c h
788ret xsdgeq k h
789end
790note xsdgeq: the 64-hex id of row k spells the digest h
791fn xsdgeq k ulong h view uchar 32 to bool
792g = mul k 64
793for j ulong 32
794v = get h j
795a = add g mul j 2
796if ne get xsgid a xshexd shr v 4
797ret false
798end
799if ne get xsgid add a 1 xshexd and v 15
800ret false
801end
802end
803ret true
804end
805fn xshexd v uchar to uchar
806if lt v 10
807ret add v 48
808end
809ret add v 87
810end
811note xsat: fxo[p, ...) starts with text t (within n)
812fn xsat p ulong n ulong t view uchar * to bool
813if gt add p len t n
814ret false
815end
816for j ulong len t bound 64
817if ne get fxo add p j get t j
818ret false
819end
820end
821ret true
822end
823note xsparse: fxo[0, n) is exactly "interplane-project 1\nproject NAME\nbranch BRANCH\nvisibility
824note public\nowner SHA256:<43 base64>\nalias <rad:z... or ->\nnonce <32 hex>\n" for project k
825fn xsparse k ulong n ulong to bool
826if not xsat 0 n tfsr1a
827ret false
828end
829p = len tfsr1a
830e = fleol p n
831if not xsnmeq k p e
832ret false
833end
834p = add e 1
835if not xsat p n tfsr1b
836ret false
837end
838p = add p len tfsr1b
839e = fleol p n
840if not xsbreq k p e
841ret false
842end
843p = add e 1
844if not xsat p n tfsr1c
845ret false
846end
847p = add p len tfsr1c
848e = fleol p n
849if not xsowner k p e
850ret false
851end
852p = add e 1
853if not xsat p n tfsr1d
854ret false
855end
856p = add p len tfsr1d
857e = fleol p n
858if not xsalias k p e
859ret false
860end
861p = add e 1
862if not xsat p n tfsr1e
863ret false
864end
865p = add p len tfsr1e
866e = fleol p n
867if not xsishex p e 32
868ret false
869end
870ret eq add e 1 n
871end
872fn xsnmeq k ulong a ulong b ulong to bool
873if ne sub b a get fanl k
874ret false
875end
876for j ulong sub b a bound 128
877if ne get fxo add a j frnbyte k j
878ret false
879end
880end
881ret true
882end
883fn xsbreq k ulong a ulong b ulong to bool
884if ne sub b a get fabl k
885ret false
886end
887o = get fabo k
888for j ulong sub b a bound 64
889if ne get fxo add a j get fabr add o j
890ret false
891end
892end
893ret true
894end
895fn xsb64c c uchar to bool
896ret or xsaln c or eq c 43 eq c 47
897end
898fn xsowner k ulong a ulong b ulong to bool
899if ne sub b a 50
900ret false
901end
902if not xsat a b tfsfp
903ret false
904end
905for j ulong 43
906if not xsb64c get fxo add add a 7 j
907ret false
908end
909end
910for j ulong 50
911put xsown add mul k 64 j get fxo add a j
912end
913put xsownl k 50
914ret true
915end
916note xsalias: "-" (no old id: the key is the 64-hex id) or "rad:z" and 20..60 letters and digits in
917note all after "rad:" (the key is that RID)
918fn xsalias k ulong a ulong b ulong to bool
919g = mul k 64
920if and eq sub b a 1 eq get fxo a 45
921for j ulong 64
922put faid add g j get xsgid add g j
923end
924put fail k 64
925put xsal k 0
926ret true
927end
928if lt sub b a 5
929ret false
930end
931if not xsat a b tfradp
932ret false
933end
934s = add a 4
935l = sub b s
936if or lt l 21 gt l 61
937ret false
938end
939if ne get fxo s 122
940ret false
941end
942for j ulong l bound 64
943if not xsaln get fxo add s j
944ret false
945end
946end
947for j ulong l bound 64
948put faid add g j get fxo add s j
949end
950put fail k l
951put xsal k 1
952ret true
953end
954note xsaldup: an earlier project still served has the same old Radicle id
955fn xsaldup k ulong to bool
956if eq get xsal k 0
957ret false
958end
959for j ulong k bound FAMAX
960if and eq get xskeep j 1 eq get xsal j 1
961if xskeyeq j k
962ret true
963end
964end
965end
966ret false
967end
968fn xskeyeq a ulong b ulong to bool
969if ne get fail a get fail b
970ret false
971end
972for j ulong get fail a bound 64
973if ne fridbyte a j fridbyte b j
974ret false
975end
976end
977ret true
978end
979note xsheadok: refs/heads/<branch> of repo.git is the catalog head, or is absent when the head is none
980fn xsheadok k ulong to bool
981fkgiti k
982fka tfsrevp
983fka tfsq
984fka tfsvfy
985fkopen
986fkt tfrh
987o = get fabo k
988for j ulong get fabl k bound 64
989fkc get fabr add o j
990end
991fkt tfscmt
992st = fexec 5000000000
993if eq get xshn k 0
994ret ne st 0
995end
996if ne st 0
997ret false
998end
999if ne get fxol 0 41
1000ret false
1001end
1002if ne get fxo 40 10
1003ret false
1004end
1005g = mul k 40
1006for j ulong 40
1007if ne get fxo j get xshead add g j
1008ret false
1009end
1010end
1011ret true
1012end
1013note xsmove: row i to row w (w < i), with the store's own columns
1014fn xsmove w ulong i ulong to void
1015if eq w i
1016ret
1017end
1018fmove w i
1019put xshn w get xshn i
1020put xsal w get xsal i
1021put xsownl w get xsownl i
1022put xskeep w get xskeep i
1023for j ulong 64
1024put xsgid add mul w 64 j get xsgid add mul i 64 j
1025put xsown add mul w 64 j get xsown add mul i 64 j
1026end
1027for j ulong 40
1028put xshead add mul w 40 j get xshead add mul i 40 j
1029end
1030end
1031note ---- git on a project: server/util.om fkgit / fkgiti name <fsrt>projects/NAME/repo.git once
1032note fsrcst is 1 (fload sets it and fsrt before it runs any git)
1033note ---- identity in pages and machine forms
1034fn fputid i ulong to void
1035fput tfsgitp
1036for k ulong 64
1037fputc get xsgid add mul i 64 k
1038end
1039end
1040fn fhasal i ulong to bool
1041ret eq get xsal i 1
1042end
1043fn fradsrc to bool
1044ret false
1045end
1046note fradwalk / fradseeds: the store has no routing table; server/counts.om fzseeds never calls them
1047note here (fradsrc is false), they exist so that counts.om composes unchanged
1048fn fradwalk to ulong
1049ret 0
1050end
1051fn fradseeds i ulong to long
1052ret -1
1053end
1054text tfsf4 "<p class=\"foot-fine\">INTERPLANE Forge: agents express intent; the forge retains authority. Repositories are plain Git kept in Interplane's own signed store, served by forged, a seeded-Omega web server, with no JavaScript.</p>\n<p class=\"foot-fine\"><a href=\""
1055note ---- the identity words of the "For developers" section (server/pages.om fpjdev1): ID, Owner,
1056note Refs and HEAD, and Patch up to its link. The Seed word is gone: this build reads no routing table.
1057text tsdv1 "<dt>ID</dt><dd>The project's permanent id on Interplane: the SHA-256 of its first signed record. This one is <code>git:"
1058text tsdv2 "</code>."
1059text tsdv3 " Its old id, kept only so that old links still work: <code>"
1060text tsdv4 "</dd>\n<dt>Owner</dt><dd>The key that signs every record of the project. This forge lists the project under "
1061text tsdv5 "; its key is <code>"
1062text tsdv6 "</code>.</dd>\n<dt>Refs and HEAD</dt><dd>Refs are the names that point at versions: branches and tags. HEAD is the version a fresh copy starts from, the newest commit of the default branch.</dd>\n<dt>Patch</dt><dd>A proposed change, reviewed before it is merged. This forge does not show proposed changes from its own store yet. The list is under <a href=\""
1063fn fpjterms to void
1064i = get fridx 0
1065if ge i get fan 0
1066ret
1067end
1068fput tsdv1
1069fputid4 i
1070fput tsdv2
1071if fhasal i
1072fput tsdv3
1073for k ulong get fail i bound 64
1074fescc fridbyte i k
1075end
1076fput tsdv2
1077end
1078fput tsdv4
1079fputown
1080fput tsdv5
1081for k ulong get xsownl i bound 64
1082fescc get xsown add mul i 64 k
1083end
1084fput tsdv6
1085end
1086fn fputid4 i ulong to void
1087for k ulong 64
1088fputc get xsgid add mul i 64 k
1089end
1090end
1091note ---- the clone object of the JSON repo form. Its keys stay those of forge/repo/1 (docs/API.md: keys
1092note are never removed): rad and rad_clone are null (no Radicle copy is served), git_https is the
1093note HTTPS address when the build has a clone base (FSCB 1), else null.
1094text tsjcl1 ",\n\"clone\":{\"rad\":null,\"rad_clone\":null,\"git_https\":"
1095text tsjcl2 "\""
1096text tsjcl3 "\"}"
1097text tsjcl4 "null}"
1098fn fjclone i ulong to void
1099fput tsjcl1
1100if eq FSCB 1
1101fput tsjcl2
1102fput tfcbase
1103fput tfsprj
1104for k ulong get fanl i bound 128
1105fputc frnbyte i k
1106end
1107fput tfsrg
1108fput tsjcl3
1109ret
1110end
1111fput tsjcl4
1112end