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 / server / repos.om

369 lines · 6546 bytes Raw Blame History
1note forged server/repos.om: the allow-list helpers and per-repo metadata (description from the identity
2note document, last commit) that both repository sources use: server/radsrc.om (RIDS.md and Radicle
3note storage, the default build) and store/repos.om (the native store, the store-reading build). A
4note source fills fan / fanm / faid / fabr with fnmput, fbrput and its own key, and calls fmeta.
5note ficut: stored data behind this response was longer than the buffer it was read into, and the code
6note that follows would have treated the cut copy as the whole (a list with entries missing, an empty
7note list, a 404 for something that exists). fincut sets it and fobtr, so fsend (server/main.om) throws
8note the response away and sends the whole 500 of fovfl with the words of tfmicut (server/pages.om).
9note Kinds 3 and 4 (a file, a command) do not read it: a handler returns before it starts one.
10global ficut ulong 1
11fn fincut to void
12put ficut 0 1
13put fobtr 0 1
14end
15text tfshow "show"
16text tfidref "refs/rad/id:embeds/radicle.json"
17text tfdkey "\"description\":\""
18text tflog "log"
19text tfm1 "-1"
20text tflcfmt "--format=%H %ct %cs %h %s"
21note falsh / falsl / falct: full sha (40 hex, or length 0) and committer time (epoch s) of the last
22note commit of repo i, for the JSON form (server/json.om); falc keeps "%cs %h %s" for the HTML pages.
23global falsh uchar 10240
24global falsl ulong 256
25global falct ulong 256
26text tfrh "refs/heads/"
27text tfrns "refs/namespaces/"
28text tfrnsh "/refs/heads/"
29fn fleol p ulong ln ulong to ulong
30j = p
31while lt j ln bound 16777216
32if eq get fxo j 10
33ret j
34end
35j = add j 1
36end
37ret ln
38end
39fn flnext p ulong ln ulong to ulong
40e = fleol p ln
41if lt e ln
42ret add e 1
43end
44ret ln
45end
46fn ftrs a ulong b ulong to ulong
47j = a
48while lt j b bound 16777216
49if ne get fxo j 32
50ret j
51end
52j = add j 1
53end
54ret b
55end
56fn ftre a ulong b ulong to ulong
57j = b
58while gt j a bound 16777216
59if ne get fxo sub j 1 32
60ret j
61end
62j = sub j 1
63end
64ret a
65end
66fn fnmok c uchar to bool
67if fisaln c
68ret true
69end
70ret or or eq c 46 eq c 45 eq c 95
71end
72fn fbrok c uchar to bool
73if fnmok c
74ret true
75end
76ret eq c 47
77end
78fn fnmcur k ulong to ulong
79if eq k 0
80ret 0
81end
82ret add get fano sub k 1 get fanl sub k 1
83end
84fn fidcur k ulong to ulong
85if eq k 0
86ret 0
87end
88ret add get faio sub k 1 get fail sub k 1
89end
90fn fbrcur k ulong to ulong
91if eq k 0
92ret 0
93end
94ret add get fabo sub k 1 get fabl sub k 1
95end
96fn fnmput k ulong a ulong b ulong to bool
97s = ftrs a b
98t = ftre s b
99n = sub t s
100if or eq n 0 gt n 100
101ret false
102end
103cur = fnmcur k
104if gt add cur n len fanm
105ret false
106end
107put fano k cur
108put fanl k n
109for i ulong n bound 128
110c = get fxo add s i
111if not fnmok c
112ret false
113end
114put fanm add cur i c
115end
116ret true
117end
118fn fbrput k ulong a ulong b ulong to bool
119s = ftrs a b
120t = ftre s b
121n = sub t s
122if or eq n 0 gt n 60
123ret false
124end
125cur = fbrcur k
126if gt add cur n len fabr
127ret false
128end
129put fabo k cur
130put fabl k n
131for i ulong n bound 64
132c = get fxo add s i
133if not fbrok c
134ret false
135end
136put fabr add cur i c
137end
138ret true
139end
140note fdeny: withdrawn or never-public repositories, refused even when a RIDS.md row lists them
141note (by RID without "rad:" or by name); checked before the storage test, independent of the table
142text tfdnr1 "z2ft64NFLsKzWttCXw6NWNbRQLggQ"
143text tfdnn1 "omega-pearl"
144text tfdnn2 "aien-crypto"
145fn fdideq k ulong t view uchar * to bool
146if ne get fail k len t
147ret false
148end
149for i ulong len t bound 64
150if ne fridbyte k i get t i
151ret false
152end
153end
154ret true
155end
156fn fdnmeq k ulong t view uchar * to bool
157if ne get fanl k len t
158ret false
159end
160for i ulong len t bound 64
161if ne frnbyte k i get t i
162ret false
163end
164end
165ret true
166end
167fn fdeny k ulong to bool
168if fdideq k tfdnr1
169ret true
170end
171if fdnmeq k tfdnn1
172ret true
173end
174ret fdnmeq k tfdnn2
175end
176fn fmove w ulong i ulong to void
177if eq w i
178ret
179end
180put fano w get fano i
181put fanl w get fanl i
182put faio w get faio i
183put fail w get fail i
184put fabo w get fabo i
185put fabl w get fabl i
186end
187note ---- per-repo metadata: description (identity doc) and last commit
188fn fdcur i ulong to ulong
189if eq i 0
190ret 0
191end
192ret add get fado sub i 1 get fadl sub i 1
193end
194fn flccur i ulong to ulong
195if eq i 0
196ret 0
197end
198ret add get falco sub i 1 get falcl sub i 1
199end
200fn fmeta i ulong to void
201put fado i fdcur i
202put fadl i 0
203put falco i flccur i
204put falcl i 0
205put falsl i 0
206put falct i 0
207fkgiti i
208fka tfshow
209fka tfidref
210st = fexec 5000000000
211if eq st 0
212fdescget i
213end
214flcget i
215end
216fn fdkey s ulong ln ulong to bool
217if gt add s len tfdkey ln
218ret false
219end
220for k ulong len tfdkey bound 32
221if ne get fxo add s k get tfdkey k
222ret false
223end
224end
225ret true
226end
227fn fdescget i ulong to void
228ln = get fxol 0
229s = ulong 0
230while lt s ln bound 16777216
231if fdkey s ln
232fdcopy i add s len tfdkey ln
233ret
234end
235s = add s 1
236end
237end
238fn fdcopy i ulong a ulong ln ulong to void
239o = get fado i
240n = ulong 0
241j = a
242while lt j ln bound 100000
243c = get fxo j
244if eq c 34
245break
246end
247if ge add o n len fadesc
248break
249end
250if ge n 1000
251break
252end
253if eq c 92
254j = add j 1
255if ge j ln
256break
257end
258c = fdunesc get fxo j
259end
260put fadesc add o n c
261n = add n 1
262j = add j 1
263end
264put fadl i n
265fdclean i
266end
267fn fdunesc c uchar to uchar
268if or eq c 110 eq c 116
269ret uchar 32
270end
271ret c
272end
273fn flcarg i ulong ns ulong to void
274fkgiti i
275fka tflog
276fka tfm1
277fka tflcfmt
278fkopen
279if eq ns 1
280fkt tfrns
281fkt tfnid
282fkt tfrnsh
283else
284fkt tfrh
285end
286o = get fabo i
287for k ulong get fabl i bound 64
288fkc get fabr add o k
289end
290end
291fn flcget i ulong to void
292flcarg i 0
293st = fexec 5000000000
294if ne st 0
295flcarg i 1
296st = fexec 5000000000
297end
298if ne st 0
299ret
300end
301a = flcsha i
302o = get falco i
303n = ulong 0
304m = hmin sub get fxol 0 a 1024
305for j ulong m bound 1024
306c = get fxo add a j
307if eq c 10
308break
309end
310if ge n 1000
311break
312end
313if ge add o n len falc
314break
315end
316put falc add o n c
317n = add n 1
318end
319put falcl i n
320end
321note flcsha: fxo starts "<40 hex sha> <epoch> %cs %h %s". Stores the sha in falsh / falsl and the
322note committer time in falct for repo i, and returns the offset of "%cs"; returns 0 (whole line kept,
323note falsl 0) when the prefix is not exactly that shape.
324fn flcishx c uchar to bool
325if fisdig c
326ret true
327end
328ret and ge c 97 le c 102
329end
330fn flcsha i ulong to ulong
331ln = get fxol 0
332if lt ln 43
333ret 0
334end
335for k ulong 40
336if not flcishx get fxo k
337ret 0
338end
339end
340if ne get fxo 40 32
341ret 0
342end
343t = ulong 0
344p = ulong 41
345for it ulong 20
346if ge p ln
347break
348end
349c = get fxo p
350if not fisdig c
351break
352end
353t = add mul t 10 ulong sub c 48
354p = add p 1
355end
356if or eq p 41 ge p ln
357ret 0
358end
359if ne get fxo p 32
360ret 0
361end
362o = mul i 40
363for k ulong 40
364put falsh add o k get fxo k
365end
366put falsl i 40
367put falct i t
368ret add p 1
369end