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 / research / intake-route.om

292 lines · 6918 bytes Raw Blame History
1note Research intake adapter, composed only beside the open shelf. Its repository POST calls
2note ohpost unchanged: the shelf's sign-in, CSRF, permission, write limits, queue and refusal paths.
3note Research records only a request to index that repository after the shelf has accepted it.
4note Zenodo requests use the same write precheck, per-key rate counter and disk-space measure.
5text rqpath "/research/add/"
6text rqdir "research/add/"
7text rqqueue "queue"
8text rqlk "queue.lock"
9text rqtitle "Add your work"
10text rqorc "orcid"
11text rqdoi "doi"
12text rqsync "sync"
13text rqzpre "10.5281/zenodo."
14text rqmsg "Give a repository ID, an ORCID iD or a Zenodo DOI. Links and files are not accepted here."
15text rqwait "The request is queued. Public metadata will be listed with the key that asked. A repository appears only after the open shelf accepts it. Not verified."
16text rqh "<section class=\"sl\"><h1>Add your work</h1><p>Bring a paper repository, sync public Zenodo records, or <a href=\"/research/doi\">get a DOI for your work</a>. <a href=\"/research/add\">Read the steps</a>.</p><p>A listing is not proof that a key belongs to an author. Public metadata and repository text are not verified. The operator can take a listing down by key or repository.</p>"
17text rql "<p><a href=\"/login\">Sign in with your key</a> to add work.</p></section>"
18text rqf1 "<h2>Bring a repository</h2><p>Bringing new projects is closed until Interplane's own store accepts them.</p>"
19text rqf3 "<h2>Sync public records</h2><p>Give an ORCID iD, a Zenodo DOI, or both. A record is filed under an author only if that record carries the ORCID iD among its creators. This is a listing from public metadata by the key that asked, not an ORCID sign-in.</p><form method=\"post\" action=\"/research/add/\"><input type=\"hidden\" name=\"csrf\" value=\""
20text rqf4 "\"><input type=\"hidden\" name=\"action\" value=\"sync\"><label>ORCID iD <input name=\"orcid\" maxlength=\"19\" placeholder=\"0000-0000-0000-0000\"></label><label>Zenodo DOI <input name=\"doi\" maxlength=\"26\" placeholder=\"10.5281/zenodo.123456\"></label><button type=\"submit\">Sync records</button></form></section>"
21global rqo uchar 20
22global rqol ulong 1
23global rqd uchar 40
24global rqdl ulong 1
25fn rqform to long
26if not fget
27ret 405
28end
29put fkind 0 0
30fsetti rqtitle
31fput rqh
32if not ohdid
33fput rql
34ret 200
35end
36fput rqf1
37fput rqf3
38socsrfout
39fput rqf4
40ret 200
41end
42note rqappend: P or Z, did, rid or ORCID, ORCID(empty) or DOI. Failed append is rolled back.
43note Mutable intake state must not use rxfile, which pins immutable public generations.
44fn rqfile name view uchar * to void
45put ffilel 0 0
46for i ulong len tfdata bound 128
47ffilc get tfdata i
48end
49for i ulong len rqdir bound 64
50ffilc get rqdir i
51end
52for i ulong len name bound 16
53ffilc get name i
54end
55end
56fn rqlock to long
57rqfile rqlk
58fd = fopen ffile 0 get ffilel 0 558145 384
59if lt fd 0
60ret -1
61end
62r = flock int fd 6
63if ne r 0
64x = fclose int fd
65ret -1
66end
67ret fd
68end
69fn rqappend kind uchar to long
70rm = ohroom 400
71if or eq rm 1 eq rm 3
72ret soerr 503 tomroom
73end
74rqfile rqqueue
75put ffilel 0 sub get ffilel 0 len rqqueue
76r = makedir ffile 0 get ffilel 0 448
77lf = rqlock
78if lt lf 0
79ret soerr 503 tomsgq
80end
81rqfile rqqueue
82fd = fopen ffile 0 get ffilel 0 558145 384
83if lt fd 0
84x = fclose int lf
85ret soerr 503 tomsgq
86end
87sz = ohsize int fd
88if or lt sz 0 gt sz 4193904
89x = fclose int fd
90x = fclose int lf
91ret soerr 503 tomsgq
92end
93b = new uchar 400 0
94n = ulong 0
95put b n kind
96n = add n 1
97put b n 9
98n = add n 1
99for i ulong get godidl 0 bound 96
100put b n get godid i
101n = add n 1
102end
103put b n 9
104n = add n 1
105if eq kind 80
106for i ulong get goridl 0 bound 44
107put b n get gorid i
108n = add n 1
109end
110else
111for i ulong get rqol 0 bound 19
112put b n get rqo i
113n = add n 1
114end
115end
116put b n 9
117n = add n 1
118if eq kind 90
119for i ulong get rqdl 0 bound 40
120put b n get rqd i
121n = add n 1
122end
123end
124put b n 10
125n = add n 1
126w = write int fd b 0 n
127if ne w long n
128if ge sz 0
129x = ftrunc int fd sz
130end
131x = fclose int fd
132x = fclose int lf
133ret soerr 503 tomsgq
134end
135x = fclose int fd
136x = fclose int lf
137ohused n
138put fkind 0 0
139fsetti rqtitle
140fput rqh
141fput rqwait
142fput toend
143ret 200
144end
145note Preflight before a shelf mutation. A later IO fault is reported as partial acceptance, not
146note "nothing saved": the shelf retains the RID/key/note and the reply carries the retryable ID.
147fn rqpre to long
148rm = ohroom 400
149if or eq rm 1 eq rm 3
150ret soerr 503 tomroom
151end
152rqfile rqqueue
153put ffilel 0 sub get ffilel 0 len rqqueue
154r = makedir ffile 0 get ffilel 0 448
155lf = rqlock
156if lt lf 0
157ret soerr 503 tomsgq
158end
159rqfile rqqueue
160fd = fopen ffile 0 get ffilel 0 558145 384
161if lt fd 0
162x = fclose int lf
163ret soerr 503 tomsgq
164end
165sz = ohsize int fd
166x = fclose int fd
167x = fclose int lf
168if or lt sz 0 gt sz 4193904
169ret soerr 503 tomsgq
170end
171ret 0
172end
173text rqpart "<section class=\"sl\"><h1>Shelf request accepted</h1><p>The shelf accepted this repository. Research indexing was not queued because storage changed after admission. The shelf retains the repository ID, the requesting key and the paper note. Retry the ID below at <a href=\"/research/add/\">Add your work</a>.</p><pre>"
174text rqp2 "</pre><p>This is a partial acceptance, not a claim that nothing was saved. The shelf listing is not verified.</p></section>"
175fn rqpartial to long
176put fobl 0 0
177put fkind 0 0
178fsetti rqtitle
179fput rqpart
180for i ulong get goridl 0 bound 44
181fescc get gorid i
182end
183fput rqp2
184ret 202
185end
186fn rqpost to long
187if slffeq toact tobring
188if ne get gscur 0 0
189if not socsrfok
190ret soerr 403 tsmcsrf
191end
192p = rqpre
193if ne p 0
194ret p
195end
196end
197r = ohpost
198if ne r 303
199ret r
200end
201note A signed-out ohpost redirects to login, not to the shelf. Do not queue that as a request.
202if eq get gscur 0 0
203ret r
204end
205p = rqappend 80
206if ne p 200
207ret rqpartial
208end
209ret p
210end
211r = sowpre
212if ne r 0
213ret r
214end
215soratev get gscur 0 get gsnow 0
216if not slformvalid
217ret soerr 400 rqmsg
218end
219if ne slgetform tsfcsrf 32
220ret soerr 400 rqmsg
221end
222if not ohdid
223ret 403
224end
225if not slffeq toact rqsync
226ret soerr 400 rqmsg
227end
228n = slgetform rqorc
229if or lt n 0 gt n 19
230ret soerr 400 rqmsg
231end
232put rqol 0 ulong n
233if gt n 0
234if ne n 19
235ret soerr 400 rqmsg
236end
237for i ulong 19
238c = get gcfv i
239if or eq i 4 or eq i 9 eq i 14
240if ne c 45
241ret soerr 400 rqmsg
242end
243else
244ok = and ge c 48 le c 57
245if and eq i 18 eq c 88
246ok = true
247end
248if not ok
249ret soerr 400 rqmsg
250end
251end
252put rqo i c
253end
254end
255n = slgetform rqdoi
256if or lt n 0 gt n 26
257ret soerr 400 rqmsg
258end
259put rqdl 0 ulong n
260if gt n 0
261if le n long len rqzpre
262ret soerr 400 rqmsg
263end
264for i ulong len rqzpre
265if ne get gcfv i get rqzpre i
266ret soerr 400 rqmsg
267end
268end
269for i ulong sub ulong n len rqzpre bound 12
270c = get gcfv add len rqzpre i
271if or lt c 48 gt c 57
272ret soerr 400 rqmsg
273end
274end
275for i ulong ulong n bound 40
276put rqd i get gcfv i
277end
278end
279if eq add get rqol 0 get rqdl 0 0
280ret soerr 400 rqmsg
281end
282ret rqappend 90
283end
284fn rxint to long
285if not fpeq rqpath
286ret 0
287end
288if eq get fmeth 0 3
289ret rqpost
290end
291ret rqform
292end