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 / patch / p6json.om

637 lines · 9788 bytes Raw Blame History
1note patch/p6json.om: the JSON form of the patch pages (docs/API.md forge/patch-list/1, forge/patch/1).
2note The documents name the repository by owner and name only.
3note pajhead t: t (the schema and the base key up to its opening quote), then base, owner and repo
4fn pajhead t view uchar * to void
5fjstart
6fput t
7fputb
8fput tpjown
9fput tfowner
10fput tpjrep
11i = get fridx 0
12for k ulong get fanl i bound 128
13fputc frnbyte i k
14end
15end
16note pajname: the author's social name as a JSON string, null when the account has none
17fn pajname to void
18d = padid
19if eq d 0
20fput tpjnull
21ret
22end
23n = get gsnm d
24if eq n 0
25fput tpjnull
26ret
27end
28o = get gsso n
29fjtb
30for i ulong get gssl n bound 64
31fjtc get gsstr add o i
32end
33fjstr
34end
35note pajbody full: the keys of the loaded item (signed or imported) from its id's value on, in the order
36note of SPEC section 3, up to its closing brace (the caller writes it). full: forge/patch/1 (adds
37note description, mbox_sha256, opened, closed, merge, labels, comments, thread_truncated and
38note thread_reason); else a list row (adds comments_count). Both end with path, patch, diff,
39note diff_unavailable and bundle. The key set is the same for both kinds of item.
40fn pajbody full bool to void
41paputid
42fput tpjttl
43fjtb
44for i ulong get gpttll 0 bound 1024
45fjtc get gpttl i
46end
47fjstr
48if full
49fput tpjdsc
50n = pardf tpfds
51fjfx 0 n
52end
53imp = ne get gpimp 0 0
54fyk tpkst
55pajstw
56fyk tpksd
57fybool ne get gpider 0 0
58fyk tpkau
59if imp
60fynull
61else
62pajauth
63end
64fyk tpkim
65if imp
66pajimp
67else
68fynull
69end
70fyk tpkbc
71pajsha 0
72fyk tpkhc
73pajsha 1
74pajcnts imp
75fyk tpkcd
76pajcode
77if full
78pajfull imp
79end
80fyk tpkcr
81if imp
82pajsv tpsjutc
83else
84fjiso get gpmts 0
85end
86if not full
87fyk tpkcc
88if imp
89pathld
90fnum patcnt
91else
92fputc 48
93end
94end
95pajlinks
96end
97note pajstw: the status word as a JSON string
98fn pajstw to void
99fputc 34
100s = get gpist 0
101if eq s 0
102fput tpwopn
103end
104if eq s 1
105fput tpwclo
106end
107if eq s 2
108fput tpwmrg
109end
110fputc 34
111end
112note pajauth: {"did":...,"name":...} of a signed patch
113fn pajauth to void
114fputc 123
115fyk0 tpkdid
116fjtb
117for i ulong get gpmdidl 0 bound 128
118fjtc get gpmdid i
119end
120fjstr
121fput tpjnm
122pajname
123fputc 125
124end
125note pajsha w: the base (w 0; null when the item has none) or head commit as a JSON string
126fn pajsha w ulong to void
127if eq w 0
128if eq get gpihb 0 0
129fynull
130ret
131end
132end
133fputc 34
134paput40 w
135fputc 34
136end
137note pajcnts imp: commits and files (null for an imported item), bytes (of the code file)
138fn pajcnts imp bool to void
139fyk tpkcm
140if imp
141fynull
142else
143fnum get gpmcm 0
144end
145fyk tpkfl
146if imp
147fynull
148else
149fnum get gpmfl 0
150end
151fyk tpkby
152fnum get gpmby 0
153end
154fn pajcode to void
155k = get gpicode 0
156if eq k 1
157fysv tpkmb
158ret
159end
160if eq k 2
161fysv tpkbn
162ret
163end
164fysv tpknone
165end
166note pajfull imp: the keys only forge/patch/1 has, from mbox_sha256 to comments
167fn pajfull imp bool to void
168fyk tpksha
169if imp
170fynull
171else
172fputc 34
173for i ulong 64
174fputc get gpmsha i
175end
176fputc 34
177end
178fyk tpkop
179if imp
180pajgh tpgho
181else
182fynull
183end
184fyk tpkcl
185if imp
186pajgh tpghc
187else
188fynull
189end
190fyk tpkmg
191pajmrg
192fyk tpklb
193pajlabs
194fyk tpkco
195pajcoms
196t = get gptr 0
197fyk tpktt
198fybool ne t 0
199fyk tpktr
200pajtrw t
201end
202note pajtrw t: thread_reason: null for a whole thread (0), else why the comments stop
203fn pajtrw t ulong to void
204if eq t 1
205fysv tptr1
206ret
207end
208if eq t 2
209fysv tpun4
210ret
211end
212if eq t 3
213fysv tptr3
214ret
215end
216fynull
217end
218note pajdun: why the loaded bundle-backed item with a base has no diff, asked without making one: 0
219note it has or can have one (the cache file is there; or neither file is and the project's git store
220note holds the base commit, or git did not run), 3 the store does not hold the base commit (pabcat,
221note the check pabdiff makes), 4 the marker says its diff was cut at 16 MiB
222fn pajdun to ulong
223w = pabst
224if eq w 0
225ret 0
226end
227if eq w 2
228ret 4
229end
230if pabbcap
231ret 5
232end
233if pabbad
234ret 6
235end
236r = pabcat
237if lt r 0
238pabbset
239ret 6
240end
241if gt r 0
242ret 3
243end
244ret 0
245end
246note pajduw u: diff_unavailable: null when diff is a link (0), else the reason
247fn pajduw u ulong to void
248if eq u 1
249fysv tpun1
250ret
251end
252if eq u 2
253fysv tpun2
254ret
255end
256if eq u 3
257fysv tpun3
258ret
259end
260if eq u 4
261fysv tpun4
262ret
263end
264if eq u 5
265fysv tpun5
266ret
267end
268if eq u 6
269fysv tpun6
270ret
271end
272fynull
273end
274note pajlinks: path, patch (null without an mbox), diff (a link for an mbox, and for a bundle whose
275note diff exists or can be made; else null), diff_unavailable (null beside a link; else no-code-file,
276note no-base, base-not-in-store or too-large), bundle (null without head.bundle)
277fn pajlinks to void
278fyk tpkpt
279fputc 34
280papath
281fputc 34
282k = get gpicode 0
283fyk tpkpa
284if eq k 1
285fputc 34
286papath
287fput tpsfxp
288fputc 34
289else
290fynull
291end
292fyk tpkdf
293d = or eq k 1 and eq k 2 ne get gpihb 0 0
294u = ulong 0
295if d
296if eq k 2
297u = pajdun
298end
299else
300u = 2
301if eq k 0
302u = 1
303end
304end
305if eq u 0
306fputc 34
307papath
308fput tpsfxd
309fputc 34
310else
311fynull
312end
313fyk tpkdu
314pajduw u
315fyk tpkbn
316if eq k 2
317fputc 34
318papath
319fput tpsfxb
320fputc 34
321else
322fynull
323end
324end
325note pajgh t: the gh value t as a JSON string; null when the line is absent, empty or "-"
326fn pajgh t view uchar * to void
327o = paghv t
328n = get gpr 15
329if eq n 0
330fynull
331ret
332end
333if eq n 1
334if eq get gpgh o 45
335fynull
336ret
337end
338end
339fjtb
340for i ulong n bound 2048
341fjtc get gpgh add o i
342end
343fjstr
344end
345note pajsv t: the source.json string after the key text t as a JSON string; null without the key
346fn pajsv t view uchar * to void
347o = pasjv t
348if eq get gpr 14 0
349fynull
350ret
351end
352fjtb
353for i ulong get gpr 15 bound 4096
354fjtc get gpsrc add o i
355end
356fjstr
357end
358note pajimp: {"from":"github","owner","repo","number","url","login"} (login null for a code-only item)
359fn pajimp to void
360fputc 123
361fyk0 tpkfrm
362fysv tpgith
363fyk tpkow
364pajsv tpsjow
365fyk tpkrp
366pajsv tpsjrp
367fyk tpknum
368fnum get gpnum 0
369fyk tpkurl
370pajsv tpsjurl
371fyk tpklog
372if ne get gpider 0 0
373fynull
374else
375pajgh tpghl
376end
377fputc 125
378end
379note pajmrg: null, or for a merged imported item with a valid merged file {"commit","time","reach",
380note "main","observed"} (reach "unknown" with main and observed null when the reach file is not valid)
381fn pajmrg to void
382if eq get gpimp 0 0
383fynull
384ret
385end
386if ne get gpist 0 2
387fynull
388ret
389end
390papid tpfmg
391r = pards
392if not pal40
393fynull
394ret
395end
396fputc 123
397fyk0 tpkcmt
398fputc 34
399for i ulong 40
400fputc get gpln i
401end
402fputc 34
403fyk tpktim
404pajgh tpghm
405w = parchld
406fyk tpkrch
407if eq w 1
408fysv tprch1
409end
410if eq w 2
411fysv tprch2
412end
413if or eq w 0 eq w 3
414fysv tprch3
415end
416fyk tpkmn
417if and ne w 0 eq get gpr 13 40
418fjtb
419o = get gpr 12
420for i ulong 40
421fjtc get gpln add o i
422end
423fjstr
424else
425fynull
426end
427fyk tpkobs
428if ne w 0
429fjtb
430o = get gpr 14
431for i ulong get gpr 15 bound 32
432fjtc get gpln add o i
433end
434fjstr
435else
436fynull
437end
438fputc 125
439end
440note pajlabs: the labels file as an array of strings (one per line; empty lines are left out; its
441note first 65536 bytes)
442fn pajlabs to void
443fputc 91
444if eq get gpimp 0 0
445fputc 93
446ret
447end
448n = pafrd tpflb 65536
449s = ulong 0
450c = ulong 0
451for i ulong add n 1 bound 65537
452e = eq i n
453if not e
454e = eq get fxo i 10
455end
456if e
457if gt i s
458if gt c 0
459fputc 44
460end
461fjtb
462for j ulong sub i s bound 65536
463fjtc get fxo add s j
464end
465fjstr
466c = add c 1
467end
468s = add i 1
469end
470end
471fputc 93
472end
473note pajfit f0 t0: true while the document is at most PAJMX bytes and no byte was dropped; else the
474note output goes back to f0 (and the cut flag to t0): the comment just written is taken back whole
475fn pajfit f0 ulong t0 ulong to bool
476if and le get fobl 0 PAJMX eq get fobtr 0 t0
477ret true
478end
479put fobl 0 f0
480put fobtr 0 t0
481ret false
482end
483note pajcoms: the thread records (the description is not one of them) up to the first malformed one,
484note or up to the one that takes the document over PAJMX (taken back, so the document stays whole).
485note gptr says why they are not the whole thread: 3 the document budget; else 2 the thread file is
486note larger than gpth; else 1 a malformed record (when the page prints its sentence); 0 they are
487fn pajcoms to void
488put gptr 0 0
489fputc 91
490if eq get gpimp 0 0
491fputc 93
492ret
493end
494pathld
495p = ulong 0
496c = ulong 0
497n = get gpthl 0
498w = ulong 0
499while lt p n bound 16777216
500p = patrec p
501if eq get gpr 0 0
502w = 1
503break
504end
505f0 = get fobl 0
506t0 = get fobtr 0
507if gt c 0
508fputc 44
509end
510fputc 10
511pajcom
512if not pajfit f0 t0
513w = 3
514break
515end
516c = add c 1
517end
518fputc 93
519if ne w 3
520if ne get gpthc 0 0
521w = 2
522end
523end
524put gptr 0 w
525end
526note pajcom: the parsed record (gpr): {"author":null,"login","kind",["state"],["path","line"],"time",
527note "body"}; a review's state "-" is null
528fn pajcom to void
529k = get gpr 0
530fputc 123
531fyk0 tpkau
532fynull
533fyk tpklog
534pajtr 3
535fyk tpkknd
536if eq k 1
537fysv tprcom
538end
539if eq k 2
540fysv tprrev
541fyk tpkstt
542if patis 5 tpdash
543fynull
544else
545pajtr 5
546end
547end
548if eq k 3
549fysv tprrc
550fyk tpkpt
551pajtr 8
552fyk tpkln
553fnum get gpr 7
554end
555fyk tpktim
556if eq get gpr 2 20
557pajtr 1
558else
559fynull
560end
561fyk tpkbdy
562pajtr 10
563fputc 125
564end
565note pajtr a: gpth[gpr a, + gpr a+1) as a JSON string
566fn pajtr a ulong to void
567fjtb
568o = get gpr a
569for i ulong get gpr add a 1 bound 16777216
570fjtc get gpth add o i
571end
572fjstr
573end
574fn pajone to long
575pajhead tpjp1
576fput tpjid2
577pajbody true
578fput tpjend
579ret 200
580end
581note pajpg pg: the path of list page pg as a JSON string
582fn pajpg pg ulong to void
583fputc 34
584fputrl
585fput tphqp
586fnum pg
587fputc 34
588end
589note pajlist: forge/patch-list/1. count: the items the pages list (lst); states: the same items by
590note state (signed patches open); damaged: the index lines whose folder does not load as an item
591fn pajlist lst ulong dmg ulong pg ulong pages ulong cnt ulong to long
592pajhead tpjl1
593fput tpjpage
594fnum pg
595fput tpjper
596fnum lst
597fyk tpkst2
598fputc 123
599fyk0 tpwopn
600fnum get gpsc 0
601fyk tpwclo
602fnum get gpsc 1
603fyk tpwmrg
604fnum get gpsc 2
605fputc 125
606fyk tpkdm
607fnum dmg
608fput tpjpats
609first = true
610for j ulong cnt bound 30
611if paidset j
612if paany
613if not first
614fput tpjsep
615end
616first = false
617fput tpjid
618pajbody false
619fputc 125
620end
621end
622end
623fput tpjnext
624if lt pg pages
625pajpg add pg 1
626else
627fput tpjnull
628end
629fput tpjprev
630if gt pg 1
631pajpg sub pg 1
632else
633fput tpjnull
634end
635fput tpjend
636ret 200
637end