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 / build.om

2476 lines · 52553 bytes Raw Blame History
1om2
2note build.om: the INTERPLANE research pages as one seeded Omega program. A filter: stdin is one mode
3note line, then the registry (research/registry/catalog.tsv); stdout is one document. No scripts are emitted.
4note Mode line: M <tab> mode [<tab> slug]. Modes: index css json bib txt slugs work wjson wbib.
5note Registry lines are tab-separated facts (README.md "Registry"). Every field is escaped for the
6note document it goes into (HTML, JSON, BibTeX, a URL query). Exit 0 on success, 1 when stdout fails,
7note 2 for an unknown mode, 3 when the slug names no work.
8global ib uchar 262144
9global ibl ulong 1
10global ob uchar 2097152
11global obl ulong 1
12note mgr: 1 when the mode is merge, whose raw catalog has no J line until merge writes it.
13global mgr ulong 1
14text tamp "&amp;"
15text tlt "&lt;"
16text tgt "&gt;"
17text tquo "&quot;"
18text tapo "&#39;"
19text thex "0123456789ABCDEF"
20text mindex "index"
21text mcss "css"
22text mjson "json"
23text mbib "bib"
24text mtxt "txt"
25text mslugs "slugs"
26text mwork "work"
27text mwjson "wjson"
28text mwbib "wbib"
29text korcid "orcid"
30text kname "name"
31text kbio "bio"
32text kalso "also-published-as"
33text kedu "education"
34text kcheck "checked"
35text kowork "orcid-works"
36text ksite "site"
37text rsup "isSupplementTo"
38text rref "references"
39text rder "isDerivedFrom"
40text psup "supplements"
41text pref "cites"
42text pder "is derived from"
43text rsby "isSupplementedBy"
44text psby "is supplemented by"
45text ridt "isIdenticalTo"
46text pidt "is identical to"
47text rpub "isPublishedIn"
48text ppub "is published in"
49text phttps "https://"
50text h1 "<!doctype html><html lang='en' data-theme='dark'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width,initial-scale=1'><title>"
51text h2 "</title><link rel='stylesheet' href='/assets/tokens.css'><link rel='stylesheet' href='/assets/research.css'><link rel='alternate' type='application/json' href='"
52text h3 "'></head><body>\n<header class='top'><a class='wm' href='/'>INTERPLANE</a><nav><a href='/galaxy'>Galaxy</a><a href='/explore'>Explore</a><a class='on' href='/research'>Research</a><a href='/open/'>Open builds</a><a href='/salvage/'>Bring your build</a></nav></header>\n<main>\n"
53text hfoot "</main>\n<footer class='foot'><p>DOIs are minted by Zenodo. Everything else here is built from the research registry in the Interplane forge repository by a seeded Omega program. No scripts run on this page.</p><p><a href='/research.json'>JSON</a><a href='/research.bib'>BibTeX</a><a href='/research.txt'>Guide for agents</a></p></footer></body></html>\n"
54text ititle "Research on INTERPLANE"
55text ijson "/research.json"
56text i01 "<section class='hero'><p class='eyebrow'>Research</p><h1>Ask the research.</h1><p class='sub'>"
57text i02 " works and "
58text i03 " versions by "
59text i04 ", each with its full text. Ask a question: an agent on my Spark answers from the papers and names the ones it used.</p>\n"
60text iform "<form class='ask' action='/research/ask' method='get'><input class='q' type='text' name='q' maxlength='300' required placeholder='What does the Turing measure?' aria-label='Your question'><button class='btn' type='submit'>Ask</button></form>\n"
61text itry "<p class='try'>Try <a href='/research/ask?q=What+is+a+Turing+and+how+is+it+measured%3F'>What is a Turing and how is it measured?</a><a href='/research/ask?q=How+does+the+Spark+run+a+model+with+no+CUDA+libraries%3F'>How does the Spark run a model with no CUDA libraries?</a><a href='/research/ask?q=What+separates+a+hive+from+a+swarm+of+agents%3F'>What separates a hive from a swarm of agents?</a></p></section>\n"
62text a01 "<section class='card who' id='author'><p class='eyebrow'>Author</p><h2>"
63text a02 "</h2><p class='orcid'><span class='idb'>ORCID iD</span><a href='https://orcid.org/"
64text a03 "'>https://orcid.org/"
65text a04 "</a></p><p class='sub'>"
66text a05 "</p><p class='meta'>Also published as "
67text a06 ". "
68text a07 ".</p><dl class='stats'><div><dt>Works</dt><dd>"
69text a08 "</dd></div><div><dt>Versions</dt><dd>"
70text a09 "</dd></div><div><dt>On the ORCID record</dt><dd>"
71text a10 " of "
72text a11 "</dd></div><div><dt>Checked</dt><dd>"
73text a12 "</dd></div></dl></section>\n"
74text t01 "<section class='thread' id='t-"
75text t02 "'><div class='th'><p class='eyebrow'>Thread</p><h2>"
76text t03 "</h2><p class='sub'>"
77text t04 "</p></div><ol class='works'>\n"
78text t05 "</ol></section>\n"
79text w01 "<li><a class='wt' href='/research/"
80text w02 "'>"
81text w03 "</a><p class='ws'>"
82text w04 "</p><p class='wmeta'><span>"
83text w05 "</span><span>"
84text w06 "</span><span>version "
85text w07 "</span><span>"
86text w08 " versions</span><a class='doi' href='https://doi.org/"
87text w08b "</span><a class='doi' href='https://doi.org/"
88text w09 "</a>"
89text wok "<span class='ok'>On the ORCID record</span>"
90text wno "<span class='warn'>Not on the ORCID record yet</span>"
91text w10 "</p></li>\n"
92text c01 "<section class='card' id='connections'><p class='eyebrow'>Lineage</p><h2>How the work connects</h2><p class='sub'>Each line is a relation recorded in the published metadata of the first work.</p><ul class='edges'>\n"
93text c02 "<li><a href='/research/"
94text c03 "</a><span class='rel'>"
95text c04 "</span><a href='/research/"
96text c05 "</a></li>\n"
97text c06 "</ul></section>\n"
98text p01 "<article class='work'><p class='eyebrow'><a href='/research#t-"
99text p02 "</a></p><h1>"
100text p03 "</h1><p class='by'>"
101text p04 "</p><p class='lead'>"
102text p05 "</p><p class='acts'><a class='btn' href='https://doi.org/"
103text p06 "'>Read at the DOI</a><a class='btn ghost' href='/research/"
104text p07 ".bib'>BibTeX</a><a class='btn ghost' href='/research/"
105text p08 ".json'>JSON</a></p>\n"
106text p09 "<section class='card'><h2>Ask about this work</h2><form class='ask' action='/research/ask' method='get'><input class='q' type='text' name='q' maxlength='300' required aria-label='Your question' value='"
107text p10 "'><button class='btn' type='submit'>Ask</button></form><p class='try'>Or <a href='/research/ask?q=What+evidence+supports+"
108text p11 "%3F'>what evidence supports it?</a><a href='/research/ask?q=What+are+the+stated+limits+of+"
109text p12 "%3F'>what are its stated limits?</a></p></section>\n"
110text pq1 "What does "
111text pq2 " claim?"
112text p13 "<section class='card'><h2>Abstract</h2><p class='abs'>"
113text p14 "</p></section>\n<section class='card'><h2>Cite</h2><p class='cite'>"
114text p15 "</p><dl class='ids'><div><dt>DOI, all versions</dt><dd><a href='https://doi.org/"
115text p16 "</a></dd></div><div><dt>DOI, this version</dt><dd><a href='https://doi.org/"
116text p17 "</a></dd></div><div><dt>License</dt><dd>"
117text p18 "</dd></div><div><dt>ORCID record</dt><dd>"
118text p19 "</dd></div></dl></section>\n"
119text pyes "listed"
120text pnot "not listed yet"
121text v01 "<section class='card'><h2>Versions</h2><ol class='vers'>\n"
122text v02 "<li><span class='vn'>"
123text v03 "</span><span>"
124text v04 "</span><a class='doi' href='https://doi.org/"
125text v05 "</a></li>\n"
126text v06 "</ol></section>\n"
127text e01 "<section class='card'><h2>Connected work</h2><ul class='edges'>\n"
128text e02 "<li><span class='rel'>This work "
129text e03 "<li><a href='/research/"
130text e04 "</a><span class='rel'>"
131text e05 " this work</span></li>\n"
132text e06 "<li><span class='rel'>"
133text e07 "</span><a href='"
134text f01 "<section class='card'><h2>Files</h2><ul class='files'>\n"
135text f02 "<li><a href='"
136text f03 "</a><span>"
137text f04 " bytes</span></li>\n"
138text k01 "<section class='card'><h2>Keywords</h2><p class='kw'>"
139text k02 "<span>"
140text k03 "</span>"
141text k04 "</p></section>\n"
142text tsend "</ul></section>\n"
143text pend "</article>\n"
144text tspan "</span>"
145text tdot ". "
146text tsp " "
147text tcomma ", "
148text tparo " ("
149text tparc "). "
150text tdoiu "https://doi.org/"
151text tresu "https://interplane.io/research/"
152note ---- JSON texts
153text j01 "{\"schema\":\"interplane/research/1\",\"author\":{\"name\":\""
154text j02 "\",\"orcid\":\"https://orcid.org/"
155text j03 "\",\"also_published_as\":\""
156text j04 "\"},\"checked\":\""
157text j05 "\",\"ask\":\"https://interplane.io/research/ask?q=\",\"works\":["
158text j06 "],\"threads\":["
159text j07 "],\"relations\":["
160text j08 "]}\n"
161text jw1 "{\"slug\":\""
162text jw2 "\",\"title\":\""
163text jw3 "\",\"thread\":\""
164text jw4 "\",\"date\":\""
165text jw5 "\",\"kind\":\""
166text jw6 "\",\"venue\":\""
167text jw7 "\",\"doi\":\""
168text jw8 "\",\"doi_this_version\":\""
169text jw9 "\",\"version\":\""
170text jw10 "\",\"versions\":"
171text jw11 ",\"on_orcid\":"
172text jw12 ",\"license\":\""
173text jw13 "\",\"summary\":\""
174text jw14 "\",\"url\":\"https://interplane.io/research/"
175text jw15 "\"}"
176text jt1 "{\"id\":\""
177text jt2 "\",\"description\":\""
178text je1 "{\"from\":\""
179text je2 "\",\"relation\":\""
180text je3 "\",\"to\":\""
181text jx1 "{\"schema\":\"interplane/research-work/1\",\"work\":"
182text jx2 ",\"authors\":\""
183text jx3 "\",\"abstract\":\""
184text jx4 "\",\"keywords\":["
185text jx5 "],\"version_history\":["
186text jx6 "],\"files\":["
187text jx7 "],\"links\":["
188text jx8 "],\"relations\":["
189text jq "\""
190text jv1 "{\"doi\":\""
191text jv2 "\",\"date\":\""
192text jv3 "\",\"version\":\""
193text jf1 "{\"name\":\""
194text jf2 "\",\"bytes\":"
195text jf3 ",\"url\":\""
196text jl1 "{\"relation\":\""
197text jl2 "\",\"url\":\""
198text jtrue "true"
199text jfalse "false"
200text ju00 "\\u00"
201note ---- BibTeX and plain text
202text b01 "@misc{"
203text b01a "@article{"
204text b02 ",\n author = {"
205text b03 "},\n title = {"
206text b04 "},\n year = {"
207text b05 "},\n howpublished = {"
208text b06 "},\n version = {"
209text b07 "},\n doi = {"
210text b08 "},\n url = {https://doi.org/"
211text b09 "}\n}\n\n"
212text kart "journal-article"
213text x01 "# Research on INTERPLANE: a guide for agents\n\nAuthor: "
214text x02 "\nORCID: https://orcid.org/"
215text x03 "\n\nEvery page has a JSON twin. Start at https://interplane.io/research.json (schema interplane/research/1).\nOne work: https://interplane.io/research/<slug>.json. BibTeX: https://interplane.io/research.bib or /research/<slug>.bib.\nAsk a question: GET https://interplane.io/research/ask?q=<your question, at most 300 bytes>. The answer is written by a\nmodel on the author's Spark from the full text of these works; follow the redirect and poll the answer URL (append .json).\nAn answer names the works it used. Check a claim against the work itself before relying on it.\n\nWorks:\n"
216text x04 "\n- "
217text x05 "\n "
218text x06 " | "
219text x07 " | https://doi.org/"
220text x08 "\n https://interplane.io/research/"
221note ---- stylesheet (colours only through the Sovereign Intelligence tokens)
222text q01 "*{box-sizing:border-box}html,body{margin:0;background:var(--bg-primary);color:var(--text-primary);font:16px/24px var(--font-sans,Inter,system-ui,sans-serif)}\n"
223text q02 "a{color:var(--accent);text-decoration:none;transition:color .15s}a:hover{color:var(--accent-hover)}a:focus-visible,input:focus-visible,button:focus-visible{outline:2px solid var(--focus-ring);outline-offset:2px}\n"
224text q03 ".top{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:24px;padding:12px 32px;background:var(--bg-header);border-bottom:1px solid var(--border)}\n"
225text q04 ".wm{font-weight:700;letter-spacing:.3em;color:var(--text-primary)}.top nav{display:flex;gap:20px;font-size:14px}.top .on{color:var(--text-primary)}\n"
226text q05 "main{max-width:1024px;margin:0 auto;padding:40px 24px 56px;display:flex;flex-direction:column;gap:16px}\n"
227text q06 ".eyebrow{margin:0 0 8px;font-size:12px;line-height:16px;font-weight:600;letter-spacing:.2em;text-transform:uppercase;color:var(--accent)}\n"
228text q07 "h1{margin:0 0 12px;font-size:36px;line-height:40px;font-weight:700}h2{margin:0 0 8px;font-size:18px;line-height:28px;font-weight:600}\n"
229text q08 ".sub{margin:0 0 12px;color:var(--text-secondary)}.meta{margin:0 0 16px;font-size:12px;line-height:16px;color:var(--text-secondary)}\n"
230text q09 ".hero{padding:24px 0 8px}.hero h1{font-size:48px;line-height:52px}\n"
231text q10 ".ask{display:flex;gap:8px;margin:16px 0 12px}.q{flex:1;min-width:0;padding:12px 16px;border:1px solid var(--border-strong);border-radius:8px;background:var(--fill-input);color:var(--text-primary);font:16px/24px var(--font-sans,Inter,system-ui,sans-serif)}\n"
232text q11 ".btn{display:inline-block;padding:12px 20px;border:0;border-radius:8px;background:var(--accent-fill);color:var(--on-accent-fill);font:600 16px/24px var(--font-sans,Inter,system-ui,sans-serif);cursor:pointer;transition:background-color .15s}\n"
233text q12 ".btn:hover{background:var(--accent-fill-hover);color:var(--on-accent-fill)}.ghost,.ghost:hover{background:none;border:1px solid var(--border-strong);color:var(--text-primary)}\n"
234text q13 ".try{margin:0;font-size:14px;line-height:20px;color:var(--text-secondary);display:flex;flex-wrap:wrap;gap:4px 16px}\n"
235text q14 ".card,.thread{background:var(--bg-card);border:1px solid var(--border);border-radius:16px;padding:24px}\n"
236text q15 ".orcid{margin:0 0 12px;display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;font:14px/20px var(--font-mono,ui-monospace,monospace)}\n"
237text q16 ".idb{padding:2px 10px;border:1px solid var(--success-line);border-radius:9999px;background:var(--success-tint);color:var(--success);font:600 12px/16px var(--font-sans,Inter,system-ui,sans-serif)}\n"
238text q17 ".stats{display:grid;grid-template-columns:repeat(4,auto);gap:12px;margin:0}.stats dt{font-size:12px;line-height:16px;color:var(--text-secondary)}.stats dd{margin:0;font:600 20px/28px var(--font-mono,ui-monospace,monospace)}\n"
239text q18 ".works,.vers,.edges,.files{list-style:none;margin:0;padding:0}.works li{padding:16px 0;border-top:1px solid var(--border-faint)}.works li:last-child{padding-bottom:0}\n"
240text q19 ".wt{font-size:16px;line-height:24px;font-weight:600;color:var(--text-primary)}.wt:hover{color:var(--accent)}.ws{margin:4px 0 8px;color:var(--text-secondary);font-size:14px;line-height:20px}\n"
241text q20 ".wmeta,.by{margin:0;display:flex;flex-wrap:wrap;gap:4px 16px;font:12px/16px var(--font-mono,ui-monospace,monospace);color:var(--text-secondary)}.by{margin:0 0 16px;font-size:14px;line-height:20px}\n"
242text q21 ".ok{color:var(--success)}.warn{color:var(--warning)}.doi{overflow-wrap:anywhere}\n"
243text q22 ".edges li,.vers li,.files li{display:flex;flex-wrap:wrap;gap:4px 12px;padding:8px 0;border-top:1px solid var(--border-faint);font-size:14px;line-height:20px}\n"
244text q23 ".rel{color:var(--text-secondary)}.vn{font-weight:600}.vers li,.files li{font-family:var(--font-mono,ui-monospace,monospace);font-size:12px;line-height:16px}\n"
245text q24 ".work h1{font-size:36px;line-height:40px}.lead{margin:0 0 16px;font-size:18px;line-height:28px}.acts{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 8px}\n"
246text q25 ".work{display:flex;flex-direction:column;gap:16px}.work>.eyebrow,.work>h1,.work>.by,.work>.lead,.work>.acts{margin-bottom:0}\n"
247text q26 ".abs{margin:0;color:var(--text-secondary);overflow-wrap:anywhere}.cite{margin:0 0 16px;padding:12px;border:1px solid var(--border);border-radius:8px;background:var(--fill-input);font:12px/16px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}\n"
248text q27 ".ids{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:0}.ids dt{font-size:12px;line-height:16px;color:var(--text-secondary)}.ids dd{margin:0;font:12px/16px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}\n"
249text q28 ".kw{margin:0;display:flex;flex-wrap:wrap;gap:8px}.kw span{padding:2px 10px;border:1px solid var(--border);border-radius:9999px;font-size:12px;line-height:16px;color:var(--text-secondary)}\n"
250text q29 ".foot{max-width:1024px;margin:0 auto;padding:0 24px 40px;font-size:12px;line-height:16px;color:var(--text-secondary)}.foot p{margin:0 0 8px}.foot a{margin-right:16px}\n"
251text q30 ".answer{white-space:pre-wrap;margin:0 0 16px;overflow-wrap:anywhere}.wait{color:var(--text-secondary)}\n"
252text q31 "@media (max-width:700px){.top{gap:8px 12px;padding:12px 16px;flex-wrap:wrap}.top nav{flex-wrap:wrap;gap:6px 16px}main{padding:24px 16px 40px}.hero h1{font-size:36px;line-height:40px}.ask{flex-direction:column}.stats{grid-template-columns:repeat(2,auto)}.ids{grid-template-columns:1fr}.card,.thread{padding:16px}}\n"
253note ---- output buffer: a byte past the end is dropped, never written
254fn emb c uchar to void
255o = get obl 0
256if lt o 2097152
257put ob o c
258put obl 0 add o 1
259else
260exit 4
261end
262end
263fn em t view uchar * to void
264n = len t
265i = ulong 0
266while lt i n bound 65536
267emb get t i
268i = add i 1
269end
270end
271fn emn v ulong to void
272d = new uchar 20 0
273n = ulong 0
274x = v
275if eq x 0
276emb 48
277end
278while gt x 0 bound 20
279put d n uchar add 48 rem x 10
280x = div x 10
281n = add n 1
282end
283while gt n 0 bound 20
284n = sub n 1
285emb get d n
286end
287end
288note cut: the end of a..b after at most cap bytes, never inside a UTF-8 character
289fn cut a ulong b ulong cap ulong to ulong
290if le b a
291ret a
292end
293if le sub b a cap
294ret b
295end
296e = add a cap
297k = ulong 0
298while lt k 3 bound 3
299if gt e a
300u = get ib e
301if ge u 128
302if lt u 192
303e = sub e 1
304end
305end
306end
307k = add k 1
308end
309ret e
310end
311note emh: a..b of the input, HTML-escaped, at most cap input bytes
312fn emh a ulong b ulong cap ulong to void
313e = cut a b cap
314i = a
315while lt i e bound 262144
316c = get ib i
317if eq c 38
318em tamp
319else
320if eq c 60
321em tlt
322else
323if eq c 62
324em tgt
325else
326if eq c 34
327em tquo
328else
329if eq c 39
330em tapo
331else
332if ge c 32
333emb c
334end
335end
336end
337end
338end
339end
340i = add i 1
341end
342end
343note emj: a..b as the inside of a JSON string
344fn emj a ulong b ulong cap ulong to void
345e = cut a b cap
346i = a
347while lt i e bound 262144
348c = get ib i
349if or eq c 34 eq c 92
350emb 92
351emb c
352else
353if lt c 32
354em ju00
355emb get thex ulong shr c 4
356emb get thex ulong and c 15
357else
358emb c
359end
360end
361i = add i 1
362end
363end
364note emq: a..b as part of a URL query: letters, digits and -._~ stay, a space is +, the rest %XX
365fn emq a ulong b ulong cap ulong to void
366e = cut a b cap
367i = a
368while lt i e bound 262144
369c = get ib i
370ok = false
371if and ge c 48 le c 57
372ok = true
373end
374if and ge c 65 le c 90
375ok = true
376end
377if and ge c 97 le c 122
378ok = true
379end
380if or or eq c 45 eq c 46 or eq c 95 eq c 126
381ok = true
382end
383if ok
384emb c
385else
386if eq c 32
387emb 43
388else
389emb 37
390emb get thex ulong shr c 4
391emb get thex ulong and c 15
392end
393end
394i = add i 1
395end
396end
397note emx: a..b for a BibTeX value: braces/backslashes/carets/tildes neutralized, & % # _ $ escaped
398fn emx a ulong b ulong cap ulong to void
399e = cut a b cap
400i = a
401while lt i e bound 262144
402c = get ib i
403if or or or eq c 123 eq c 125 eq c 92 or eq c 94 eq c 126
404c = uchar 32
405end
406if or or eq c 38 eq c 37 or or eq c 35 eq c 95 eq c 36
407emb 92
408end
409if ge c 32
410emb c
411end
412i = add i 1
413end
414end
415note emr: a..b as plain text (control bytes dropped)
416fn emr a ulong b ulong cap ulong to void
417e = cut a b cap
418i = a
419while lt i e bound 262144
420c = get ib i
421if ge c 32
422emb c
423end
424i = add i 1
425end
426end
427note ---- input scanning: every index stays inside 0..ibl
428fn find a ulong e ulong c uchar to ulong
429i = a
430while lt i e bound 262144
431if eq get ib i c
432ret i
433end
434i = add i 1
435end
436ret e
437end
438fn eol a ulong to ulong
439ret find a get ibl 0 10
440end
441note nextl: start of the first line at or after p that is "ty <tab> ...", or ibl
442fn nextl p ulong ty uchar to ulong
443lim = get ibl 0
444s = p
445while lt s lim bound 262144
446if eq get ib s ty
447if lt add s 1 lim
448if eq get ib add s 1 9
449ret s
450end
451end
452end
453s = add eol s 1
454end
455ret lim
456end
457note fld: start of field k (0 based) of the line s..e; e when the line has fewer fields
458fn fld s ulong e ulong k ulong to ulong
459p = s
460j = ulong 0
461while lt j k bound 16
462p = find p e 9
463if lt p e
464p = add p 1
465end
466j = add j 1
467end
468ret p
469end
470note fe: end of the field that starts at a in the line ending at e
471fn fe a ulong e ulong to ulong
472ret find a e 9
473end
474fn feqt a ulong b ulong t view uchar * to bool
475n = len t
476if lt b a
477ret false
478end
479if ne sub b a n
480ret false
481end
482i = ulong 0
483while lt i n bound 256
484if ne get ib add a i get t i
485ret false
486end
487i = add i 1
488end
489ret true
490end
491fn feqr a ulong b ulong c ulong d ulong to bool
492if or lt b a lt d c
493ret false
494end
495n = sub b a
496if ne n sub d c
497ret false
498end
499i = ulong 0
500while lt i n bound 262144
501if ne get ib add a i get ib add c i
502ret false
503end
504i = add i 1
505end
506ret true
507end
508fn pnum a ulong b ulong to ulong
509v = ulong 0
510i = a
511while lt i b bound 262144
512c = get ib i
513if and ge c 48 le c 57
514v = add mul v 10 ulong sub c 48
515end
516i = add i 1
517end
518ret v
519end
520fn cnt ty uchar to ulong
521lim = get ibl 0
522n = ulong 0
523s = nextl 0 ty
524while lt s lim bound 262144
525n = add n 1
526s = nextl add eol s 1 ty
527end
528ret n
529end
530note slugok: a..b is 1 to 64 bytes of a-z, 0-9 and -
531fn slugok a ulong b ulong to bool
532if or le b a gt sub b a 64
533ret false
534end
535i = a
536while lt i b bound 64
537c = get ib i
538ok = false
539if and ge c 97 le c 122
540ok = true
541end
542if and ge c 48 le c 57
543ok = true
544end
545if eq c 45
546ok = true
547end
548if not ok
549ret false
550end
551i = add i 1
552end
553ret true
554end
555note wline: start of the W line whose slug is a..b, or ibl
556fn wline a ulong b ulong to ulong
557lim = get ibl 0
558s = nextl 0 87
559while lt s lim bound 262144
560e = eol s
561f = fld s e 1
562if feqr f fe f e a b
563ret s
564end
565s = nextl add e 1 87
566end
567ret lim
568end
569note sline: start of the first line of type ty whose field 1 is a..b, at or after p; or ibl
570fn sline p ulong ty uchar a ulong b ulong to ulong
571lim = get ibl 0
572s = nextl p ty
573while lt s lim bound 262144
574e = eol s
575f = fld s e 1
576if feqr f fe f e a b
577ret s
578end
579s = nextl add e 1 ty
580end
581ret lim
582end
583note oval: start of the value of author fact t (an O line), or ibl
584fn oval t view uchar * to ulong
585lim = get ibl 0
586s = nextl 0 79
587while lt s lim bound 262144
588e = eol s
589f = fld s e 1
590if feqt f fe f e t
591ret fld s e 2
592end
593s = nextl add e 1 79
594end
595ret lim
596end
597note emo: the value of author fact t, HTML-escaped; nothing when the fact is absent
598fn emo t view uchar * cap ulong to void
599v = oval t
600if lt v get ibl 0
601emh v eol v cap
602end
603end
604fn emoj t view uchar * cap ulong to void
605v = oval t
606if lt v get ibl 0
607emj v eol v cap
608end
609end
610fn emor t view uchar * cap ulong to void
611v = oval t
612if lt v get ibl 0
613emr v eol v cap
614end
615end
616note wf: field k of the W line s, as start; its end is fe of that start
617fn wf s ulong k ulong to ulong
618ret fld s eol s k
619end
620note emwh / emwj: field k of the W line s, escaped for HTML or JSON
621fn emwh s ulong k ulong cap ulong to void
622a = wf s k
623emh a fe a eol s cap
624end
625fn emwj s ulong k ulong cap ulong to void
626a = wf s k
627emj a fe a eol s cap
628end
629note emsub: field 2 of the first line of type ty for the work of W line s (its summary, authors, abstract)
630fn subv s ulong ty uchar to ulong
631a = wf s 1
632l = sline 0 ty a fe a eol s
633if ge l get ibl 0
634ret get ibl 0
635end
636ret fld l eol l 2
637end
638fn emsubh s ulong ty uchar cap ulong to void
639v = subv s ty
640if lt v get ibl 0
641emh v eol v cap
642end
643end
644fn emsubj s ulong ty uchar cap ulong to void
645v = subv s ty
646if lt v get ibl 0
647emj v eol v cap
648end
649end
650note norcid: works whose W line says the ORCID record lists them
651fn norcid to ulong
652lim = get ibl 0
653n = ulong 0
654s = nextl 0 87
655while lt s lim bound 262144
656a = wf s 10
657if lt a eol s
658if eq get ib a 49
659n = add n 1
660end
661end
662s = nextl add eol s 1 87
663end
664ret n
665end
666note relword: the relation a..b as a plain phrase
667fn relword a ulong b ulong to void
668if feqt a b rsup
669em psup
670ret
671end
672if feqt a b rref
673em pref
674ret
675end
676if feqt a b rder
677em pder
678ret
679end
680if feqt a b rsby
681em psby
682ret
683end
684if feqt a b ridt
685em pidt
686ret
687end
688if feqt a b rpub
689em ppub
690ret
691end
692emh a b 64
693end
694note ishttps: a..b starts with https://
695fn ishttps a ulong b ulong to bool
696n = len phttps
697if lt sub b a n
698ret false
699end
700ret feqt a add a n phttps
701end
702text mjsfx ".json"
703text tresp "/research/"
704note head: the page head. ta..tb is the work title (empty for the hub), ja..jb its slug.
705fn head ta ulong tb ulong ja ulong jb ulong to void
706em h1
707if gt tb ta
708emh ta tb 200
709else
710em ititle
711end
712em h2
713if gt jb ja
714em tresp
715emh ja jb 64
716em mjsfx
717else
718em ijson
719end
720em h3
721end
722note ---- the hub
723fn workli s ulong to void
724if lt majline s get ibl 0
725mawli s
726ret
727end
728e = eol s
729em w01
730emwh s 1 64
731em w02
732emwh s 12 400
733em w03
734emsubh s 83 600
735em w04
736emwh s 3 16
737em w05
738emwh s 4 32
739em w06
740emwh s 8 48
741nv = wf s 9
742if gt pnum nv fe nv e 1
743em w07
744emwh s 9 8
745em w08
746else
747em w08b
748end
749emwh s 7 96
750em w02
751emwh s 7 96
752em w09
753oa = wf s 10
754on = false
755if lt oa e
756if eq get ib oa 49
757on = true
758end
759end
760if on
761em wok
762else
763em wno
764end
765em w10
766end
767fn threads to void
768lim = get ibl 0
769h = nextl 0 72
770while lt h lim bound 64
771he = eol h
772ia = fld h he 1
773ib2 = fe ia he
774em t01
775emh ia ib2 32
776em t02
777ta = fld h he 2
778emh ta fe ta he 120
779em t03
780ba = fld h he 3
781emh ba fe ba he 300
782em t04
783s = nextl 0 87
784while lt s lim bound 4096
785ws = wf s 2
786if feqr ws fe ws eol s ia ib2
787workli s
788end
789s = nextl add eol s 1 87
790end
791em t05
792h = nextl add he 1 72
793end
794end
795fn edgeli s ulong to void
796e = eol s
797fa = fld s e 1
798fb = fe fa e
799ra = fld s e 2
800ta = fld s e 3
801tb = fe ta e
802wa = wline fa fb
803wb = wline ta tb
804if or ge wa get ibl 0 ge wb get ibl 0
805ret
806end
807em c02
808emh fa fb 64
809em w02
810emwh wa 12 400
811em c03
812relword ra fe ra e
813em c04
814emh ta tb 64
815em w02
816emwh wb 12 400
817em c05
818end
819fn edges to void
820lim = get ibl 0
821if ge nextl 0 69 lim
822ret
823end
824em c01
825s = nextl 0 69
826while lt s lim bound 4096
827edgeli s
828s = nextl add eol s 1 69
829end
830em c06
831end
832fn index to void
833maindex
834end
835note ---- one work
836fn cite s ulong to void
837e = eol s
838emsubh s 67 400
839em tparo
840da = wf s 3
841emh da cut da fe da e 4 4
842em tparc
843emwh s 12 400
844em tdot
845emwh s 5 200
846em tdot
847em tdoiu
848emwh s 6 96
849end
850fn wvers s ulong to void
851lim = get ibl 0
852a = wf s 1
853b = fe a eol s
854em v01
855l = sline 0 86 a b
856while lt l lim bound 4096
857ln = eol l
858em v02
859va = fld l ln 4
860emh va fe va ln 64
861em v03
862da = fld l ln 3
863emh da fe da ln 16
864em v04
865ua = fld l ln 2
866emh ua fe ua ln 96
867em w02
868emh ua fe ua ln 96
869em v05
870l = sline add ln 1 86 a b
871end
872em v06
873end
874note wedge1: relation line l, when it names the work a..b on either side. first: the section is not
875note open yet. 1 when a row was written.
876fn wedge1 l ulong a ulong b ulong first bool to ulong
877lim = get ibl 0
878ln = eol l
879fa = fld l ln 1
880fb = fe fa ln
881ra = fld l ln 2
882ta = fld l ln 3
883tb = fe ta ln
884if feqr fa fb a b
885o = wline ta tb
886if ge o lim
887ret 0
888end
889if first
890em e01
891end
892em e02
893relword ra fe ra ln
894em c04
895emh ta tb 64
896em w02
897emwh o 12 400
898em c05
899ret 1
900end
901if feqr ta tb a b
902o = wline fa fb
903if ge o lim
904ret 0
905end
906if first
907em e01
908end
909em e03
910emh fa fb 64
911em w02
912emwh o 12 400
913em e04
914relword ra fe ra ln
915em e05
916ret 1
917end
918ret 0
919end
920note wlink1: outside link line l (https only). 1 when a row was written.
921fn wlink1 l ulong first bool to ulong
922ln = eol l
923ra = fld l ln 2
924ua = fld l ln 3
925ub = fe ua ln
926if not ishttps ua ub
927ret 0
928end
929if first
930em e01
931end
932em e06
933relword ra fe ra ln
934em e07
935emh ua ub 400
936em w02
937emh ua ub 400
938em c05
939ret 1
940end
941fn wedges s ulong to void
942lim = get ibl 0
943a = wf s 1
944b = fe a eol s
945n = ulong 0
946l = nextl 0 69
947while lt l lim bound 4096
948n = add n wedge1 l a b eq n 0
949l = nextl add eol l 1 69
950end
951l = sline 0 76 a b
952while lt l lim bound 4096
953n = add n wlink1 l eq n 0
954l = sline add eol l 1 76 a b
955end
956if gt n 0
957em tsend
958end
959end
960fn wfiles s ulong to void
961lim = get ibl 0
962a = wf s 1
963b = fe a eol s
964l = sline 0 70 a b
965if ge l lim
966ret
967end
968em f01
969while lt l lim bound 4096
970ln = eol l
971na = fld l ln 2
972ba = fld l ln 3
973ua = fld l ln 4
974ub = fe ua ln
975if ishttps ua ub
976em f02
977emh ua ub 400
978em w02
979emh na fe na ln 200
980em f03
981emn pnum ba fe ba ln
982em f04
983end
984l = sline add ln 1 70 a b
985end
986em tsend
987end
988fn wkeys s ulong to void
989lim = get ibl 0
990a = wf s 1
991b = fe a eol s
992l = sline 0 75 a b
993if ge l lim
994ret
995end
996em k01
997while lt l lim bound 4096
998ln = eol l
999ka = fld l ln 2
1000em k02
1001emh ka fe ka ln 80
1002em k03
1003l = sline add ln 1 75 a b
1004end
1005em k04
1006end
1007note thtitle: the title of thread id a..b
1008fn thtitle a ulong b ulong to void
1009lim = get ibl 0
1010h = sline 0 72 a b
1011if lt h lim
1012ta = fld h eol h 2
1013emh ta fe ta eol h 120
1014end
1015end
1016fn work s ulong to void
1017if lt majline s get ibl 0
1018mawork s
1019ret
1020end
1021e = eol s
1022sa = wf s 1
1023sb = fe sa e
1024ta = wf s 12
1025tb = fe ta e
1026head ta tb sa sb
1027em p01
1028ha = wf s 2
1029emh ha fe ha e 32
1030em w02
1031thtitle ha fe ha e
1032em p02
1033emh ta tb 400
1034em p03
1035em k02
1036emsubh s 67 400
1037em w05
1038emwh s 3 16
1039em w05
1040emwh s 4 32
1041em w05
1042emwh s 5 200
1043em tspan
1044em p04
1045emsubh s 83 600
1046em p05
1047emwh s 7 96
1048em p06
1049emh sa sb 64
1050em p07
1051emh sa sb 64
1052em p08
1053em p09
1054em pq1
1055emh ta cut ta tb 140 140
1056em pq2
1057em p10
1058emq ta cut ta tb 140 140
1059em p11
1060emq ta cut ta tb 140 140
1061em p12
1062em p13
1063emsubh s 65 12000
1064em p14
1065cite s
1066em p15
1067emwh s 6 96
1068em w02
1069emwh s 6 96
1070em p16
1071emwh s 7 96
1072em w02
1073emwh s 7 96
1074em p17
1075emwh s 11 32
1076em p18
1077oa = wf s 10
1078on = false
1079if lt oa e
1080if eq get ib oa 49
1081on = true
1082end
1083end
1084if on
1085em pyes
1086else
1087em pnot
1088end
1089em p19
1090wvers s
1091wedges s
1092wfiles s
1093wkeys s
1094em pend
1095em hfoot
1096end
1097note ---- JSON
1098fn jwork s ulong to void
1099e = eol s
1100em jw1
1101emwj s 1 64
1102em jw2
1103emwj s 12 400
1104em jw3
1105emwj s 2 32
1106em jw4
1107emwj s 3 16
1108em jw5
1109emwj s 4 32
1110em jw6
1111emwj s 5 200
1112em jw7
1113emwj s 6 96
1114em jw8
1115emwj s 7 96
1116em jw9
1117emwj s 8 48
1118em jw10
1119nv = wf s 9
1120emn pnum nv fe nv e
1121em jw11
1122oa = wf s 10
1123on = false
1124if lt oa e
1125if eq get ib oa 49
1126on = true
1127end
1128end
1129if on
1130em jtrue
1131else
1132em jfalse
1133end
1134em jw12
1135emwj s 11 32
1136em jw13
1137emsubj s 83 600
1138em jw14
1139emwj s 1 64
1140em jw15
1141end
1142fn jedge l ulong to void
1143ln = eol l
1144fa = fld l ln 1
1145ra = fld l ln 2
1146ta = fld l ln 3
1147em je1
1148emj fa fe fa ln 64
1149em je2
1150emj ra fe ra ln 64
1151em je3
1152emj ta fe ta ln 64
1153em jw15
1154end
1155fn json to void
1156lim = get ibl 0
1157em j01
1158emoj kname 120
1159em j02
1160emoj korcid 32
1161em j03
1162emoj kalso 200
1163em j04
1164emoj kcheck 16
1165em j05
1166n = ulong 0
1167s = nextl 0 87
1168while lt s lim bound 4096
1169if gt n 0
1170emb 44
1171end
1172jwork s
1173n = add n 1
1174s = nextl add eol s 1 87
1175end
1176em j06
1177n = ulong 0
1178h = nextl 0 72
1179while lt h lim bound 64
1180he = eol h
1181if gt n 0
1182emb 44
1183end
1184em jt1
1185a = fld h he 1
1186emj a fe a he 32
1187em jw2
1188a = fld h he 2
1189emj a fe a he 120
1190em jt2
1191a = fld h he 3
1192emj a fe a he 300
1193em jw15
1194n = add n 1
1195h = nextl add he 1 72
1196end
1197em j07
1198n = ulong 0
1199l = nextl 0 69
1200while lt l lim bound 4096
1201if gt n 0
1202emb 44
1203end
1204jedge l
1205n = add n 1
1206l = nextl add eol l 1 69
1207end
1208majextra
1209em j08
1210end
1211fn wjson s ulong to void
1212lim = get ibl 0
1213a = wf s 1
1214b = fe a eol s
1215em jx1
1216jwork s
1217em jx2
1218emsubj s 67 400
1219em jx3
1220emsubj s 65 12000
1221em jx4
1222n = ulong 0
1223l = sline 0 75 a b
1224while lt l lim bound 4096
1225ln = eol l
1226if gt n 0
1227emb 44
1228end
1229em jq
1230k = fld l ln 2
1231emj k fe k ln 80
1232em jq
1233n = add n 1
1234l = sline add ln 1 75 a b
1235end
1236em jx5
1237n = ulong 0
1238l = sline 0 86 a b
1239while lt l lim bound 4096
1240ln = eol l
1241if gt n 0
1242emb 44
1243end
1244em jv1
1245k = fld l ln 2
1246emj k fe k ln 96
1247em jv2
1248k = fld l ln 3
1249emj k fe k ln 16
1250em jv3
1251k = fld l ln 4
1252emj k fe k ln 64
1253em jw15
1254n = add n 1
1255l = sline add ln 1 86 a b
1256end
1257em jx6
1258n = ulong 0
1259l = sline 0 70 a b
1260while lt l lim bound 4096
1261ln = eol l
1262u = wf l 4
1263if ishttps u fe u ln
1264if gt n 0
1265emb 44
1266end
1267em jf1
1268k = fld l ln 2
1269emj k fe k ln 200
1270em jf2
1271k = fld l ln 3
1272emn pnum k fe k ln
1273em jf3
1274k = fld l ln 4
1275emj k fe k ln 400
1276em jw15
1277n = add n 1
1278end
1279l = sline add ln 1 70 a b
1280end
1281em jx7
1282n = ulong 0
1283l = sline 0 76 a b
1284while lt l lim bound 4096
1285ln = eol l
1286u = wf l 3
1287if ishttps u fe u ln
1288if gt n 0
1289emb 44
1290end
1291em jl1
1292k = fld l ln 2
1293emj k fe k ln 64
1294em jl2
1295k = fld l ln 3
1296emj k fe k ln 400
1297em jw15
1298n = add n 1
1299end
1300l = sline add ln 1 76 a b
1301end
1302em jx8
1303n = ulong 0
1304l = nextl 0 69
1305while lt l lim bound 4096
1306ln = eol l
1307fa = fld l ln 1
1308ta = fld l ln 3
1309if or feqr fa fe fa ln a b feqr ta fe ta ln a b
1310if gt n 0
1311emb 44
1312end
1313jedge l
1314n = add n 1
1315end
1316l = nextl add ln 1 69
1317end
1318if lt majline s lim
1319majwext s
1320end
1321em j08
1322end
1323note ---- BibTeX, the agent guide, the slug list
1324fn bibone s ulong to void
1325e = eol s
1326ka = wf s 4
1327if feqt ka fe ka e kart
1328em b01a
1329else
1330em b01
1331end
1332emwh s 1 64
1333em b02
1334v = subv s 66
1335if lt v get ibl 0
1336emx v eol v 400
1337else
1338v = subv s 67
1339if lt v get ibl 0
1340emx v eol v 400
1341end
1342end
1343em b03
1344ta = wf s 12
1345emx ta fe ta e 400
1346em b04
1347da = wf s 3
1348emn pnum da cut da fe da e 4
1349em b05
1350va = wf s 5
1351emx va fe va e 200
1352em b06
1353va = wf s 8
1354emx va fe va e 48
1355em b07
1356va = wf s 6
1357emx va fe va e 96
1358em b08
1359emx va fe va e 96
1360em b09
1361end
1362fn bib to void
1363lim = get ibl 0
1364s = nextl 0 87
1365while lt s lim bound 4096
1366bibone s
1367s = nextl add eol s 1 87
1368end
1369end
1370fn txt to void
1371lim = get ibl 0
1372em x01
1373emor kname 120
1374em x02
1375emor korcid 32
1376em x03
1377s = nextl 0 87
1378while lt s lim bound 4096
1379e = eol s
1380em x04
1381a = wf s 12
1382emr a fe a e 400
1383em x05
1384a = wf s 3
1385emr a fe a e 16
1386em x06
1387a = wf s 4
1388emr a fe a e 32
1389em x07
1390a = wf s 6
1391emr a fe a e 96
1392em x08
1393a = wf s 1
1394emr a fe a e 64
1395em x05
1396v = subv s 83
1397if lt v lim
1398emr v eol v 600
1399end
1400s = nextl add e 1 87
1401end
1402emb 10
1403end
1404fn slugs to void
1405lim = get ibl 0
1406s = nextl 0 87
1407while lt s lim bound 4096
1408e = eol s
1409a = wf s 1
1410if slugok a fe a e
1411emr a fe a e 64
1412emb 10
1413end
1414s = nextl add e 1 87
1415end
1416end
1417fn css to void
1418em q01
1419em q02
1420em q03
1421em q04
1422em q05
1423em q06
1424em q07
1425em q08
1426em q09
1427em q10
1428em q11
1429em q12
1430em q13
1431em q14
1432em q15
1433em q16
1434em q17
1435em q18
1436em q19
1437em q20
1438em q21
1439em q22
1440em q23
1441em q24
1442em q25
1443em q26
1444em q27
1445em q28
1446em q29
1447em q30
1448em q31
1449end
1450note ---- the filter
1451fn rdin to void
1452one = new uchar 1 0
1453n = ulong 0
1454k = long 1
1455while gt k 0 bound 262144
1456if eq n 262143
1457k = read 0 one 0 1
1458if ne k 0
1459exit 4
1460end
1461break
1462end
1463k = read 0 ib n sub 262143 n
1464if gt k 0
1465n = add n ulong k
1466end
1467end
1468if lt k 0
1469exit 4
1470end
1471put ibl 0 n
1472end
1473fn flush to int
1474n = get obl 0
1475o = ulong 0
1476while lt o n bound 2097152
1477k = write 1 ob o sub n o
1478if le k 0
1479ret 1
1480end
1481o = add o ulong k
1482end
1483ret 0
1484end
1485fn main to int
1486if gt argcnt 1
1487ret maargs
1488end
1489rdin
1490mamraw
1491if not maok
1492ret 4
1493end
1494lim = get ibl 0
1495m = nextl 0 77
1496if ne m 0
1497ret 2
1498end
1499me = eol m
1500a = fld m me 1
1501b = fe a me
1502sa = fld m me 2
1503sb = fe sa me
1504if true
1505r = mamode a b sa sb
1506if ne r 99
1507ret r
1508end
1509end
1510if feqt a b mcss
1511css
1512ret flush
1513end
1514if feqt a b mindex
1515index
1516ret flush
1517end
1518if feqt a b mjson
1519json
1520ret flush
1521end
1522if feqt a b mbib
1523bib
1524ret flush
1525end
1526if feqt a b mtxt
1527txt
1528ret flush
1529end
1530if feqt a b mslugs
1531slugs
1532ret flush
1533end
1534if not or or feqt a b mwork feqt a b mwjson feqt a b mwbib
1535ret 2
1536end
1537if not slugok sa sb
1538ret 3
1539end
1540s = wline sa sb
1541if ge s lim
1542ret 3
1543end
1544if feqt a b mwork
1545work s
1546ret flush
1547end
1548if feqt a b mwjson
1549wjson s
1550ret flush
1551end
1552if feqt a b mwbib
1553bibone s
1554ret flush
1555end
1556ret 2
1557end
1558note ---- multi-author registry. O remains the legacy author; U is id,name,orcid,DID,via,date.
1559note The U and P DID is the requester: the key asked for public Zenodo metadata or brought a repository.
1560note A requester gains no ownership; pages and JSON never present that key as an author.
1561note J joins work to U; P is slug,how,DID,date,source,open-text. Missing P denies foreign text.
1562note Modes: merge converts one foreign catalog; authors lists ids; author renders an id.
1563note add and doi render information pages; foreign lists foreign slugs; corpus lists slug<TAB>title<TAB>selected-text-sha (foreign only).
1564note quote reads foreign extracted text and prefixes its lines so they cannot become corpus headers.
1565note Exit 4 refuses malformed/ambiguous registry data or a full input/output buffer.
1566text mamrg "merge"
1567text maal "authors"
1568text maau "author"
1569text maad "add"
1570text mado "doi"
1571text mafo "foreign"
1572text maco "corpus"
1573text maqu "quote"
1574text maid "id"
1575text maby "added-by"
1576text mavia "via"
1577text maz "zenodo"
1578text mar "radicle"
1579text madid "did:key:z"
1580text marad "rad:z"
1581text mazen "https://zenodo.org/records/"
1582text maself "drakestapleton"
1583text mafoot "</main><footer class='foot'><p>DOIs are minted by Zenodo. The research registry records the source and the key that requested or brought each record; that key gains no ownership and is not shown to be an author. No scripts run on this page.</p><p><a href='/research.json'>JSON</a><a href='/research.bib'>BibTeX</a><a href='/research.txt'>Guide for agents</a></p></footer></body></html>\n"
1584text mahero "<section class='hero'><p class='eyebrow'>Research</p><h1>Ask the research.</h1><p class='sub'>Published work, connected by its sources. The agent answers from the open full text in this collection and names the papers it used. Some records contain metadata only.</p><p class='acts'><a class='btn' href='/research/add'>Add your work</a><a class='btn ghost' href='/research/doi'>Get a DOI</a></p>"
1585text maas "<section class='card'><h2>Authors</h2><ul class='edges'>"
1586text maalink "<li><a href='/research/authors/"
1587text mawsec "<section class='card'><h2>Works</h2><ol class='works'>"
1588text maend "</ol></section>\n"
1589text mauhead "<section class='card'><p class='eyebrow'>Author</p><h1>"
1590text mauid "</h1><p class='meta'>Author ID: "
1591text maun "</p><p class='meta'>Added by "
1592text maureq "</p><p class='meta'>Requester: key "
1593text mauvia ". Source: "
1594text maucheck ". Checked: "
1595text mauclose "</p></section>\n"
1596text mabyline "<p class='by'><a href='/research/authors/"
1597text maprov "<section class='card'><h2>Source</h2><p>Added through "
1598text mapkey " by key "
1599note mashelf: records whose source is the retired network (field "radicle") came through the shelf
1600text mashelf "the shelf"
1601text maprovz "<section class='card'><h2>Source</h2><p>Public metadata from "
1602text mapreq ". Requester: key "
1603text mapdate ". Checked "
1604text mapsrc ". Source: "
1605text maptext "</p><p>Open full text may be included in the agent corpus.</p></section>\n"
1606text mapmeta "<section class='card'><p>Metadata only. The agent does not use this work as full-text evidence.</p></section>\n"
1607text mazdisc "<section class='card'><h2>Zenodo records</h2><p>Zenodo records listed here are public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to the person named on this page.</p></section>\n"
1608text mazwork "<section class='card'><h2>Zenodo record</h2><p>This Zenodo record is public metadata, requested by a key. Requesting a record gives that key no ownership of the record or the work, and the registry makes no claim that the key belongs to a person named on this page.</p></section>\n"
1609text mapttl "<article class='work'><p class='eyebrow'><a href='/research'>Research</a></p><h1>"
1610text mapacts "</p><p class='acts'><a class='btn ghost' href='/research/"
1611text mapdoi "<p class='acts'><a class='btn' href='https://doi.org/"
1612text mapdoi2 "'>Read at the DOI</a></p>"
1613text mapclose "</a></p>"
1614text maplead "<p class='lead'>"
1615text mapp "</p>"
1616text maquote "> "
1617text maadd "<section class='hero'><p class='eyebrow'>Research</p><h1>Add your work</h1><p class='sub'>Sign in with your key, then add an ORCID iD or a repository you brought to the shelf.</p><p><a class='btn' href='/research/add/'>Open the submission form</a></p></section><section class='card'><h2>From Zenodo</h2><p>Give an ORCID iD. The sync worker checks public Zenodo records whose creators name that iD. The records are public metadata, and the page labels the key that asked for them as the requester. Requesting gives that key no ownership, and an ORCID match is not proof that the key belongs to that person.</p></section><section class='card'><h2>From a repository</h2><p>Bringing a repository to the shelf is closed until Interplane's own store accepts it. Include .zenodo.json, a license file, and paper.md, paper.txt or paper.pdf at its root. The worker checks the shelf entry and metadata before listing the work.</p></section><section class='card'><h2>What is shown</h2><p>The registry keeps the source, the key that requested or brought it and the check date. Requesting a record gives the key no ownership of it. Full text joins the question corpus only when its recorded license permits it. Metadata-only records can still have pages. The operator can remove a record, author or key, and a withdrawn shelf entry is removed on the next sync.</p></section>"
1618text madoi "<section class='hero'><p class='eyebrow'>Research</p><h1>Get a DOI</h1><p class='sub'>Zenodo mints the DOI. The local tool prepares a draft; you decide whether to publish.</p></section><section class='card'><h2>Prepare a repository</h2><p>At its root, include a nonempty LICENSE file, a PDF, and .zenodo.json with title, creators (name for each), description, license, upload_type and publication_type. Check those fields and the paper before uploading. A repository that already has a DOI is refused to avoid a duplicate deposit.</p></section><section class='card'><h2>Run on your own machine</h2><p>From the Interplane forge repository root, run <code>sh tools/doi/build.sh</code>. Keep ZENODO_TOKEN in your local shell environment, outside the repository. Do not send it to Interplane.</p><p>Try the sandbox: <code>sh tools/doi/doi.sh /path/to/paper-repo</code>. To make a real deposit, use <code>sh tools/doi/doi.sh /path/to/paper-repo --production</code>. An optional <code>--source /path/to/source.tar.gz</code> uploads a source archive with the PDF.</p></section><section class='card'><h2>Review before publishing</h2><p>The tool creates a draft, prints the reserved DOI, adds it to .zenodo.json while preserving the other metadata, and uploads the files. Review the draft on <a href='https://zenodo.org/uploads'>Zenodo</a>. Only an exact <code>yes</code> at the local terminal publishes it. Another answer, or no terminal, leaves an unpublished draft. A reserved DOI is not a published record.</p></section><section class='card'><h2>Link the published work</h2><p>After publication, commit the updated metadata and <a href='/research/add'>add your work</a>. Interplane links the published record; it does not mint a second DOI.</p></section>"
1619text majas "],\"authors\":[{\"id\":\"drakestapleton\",\"name\":\""
1620text maju "{\"id\":\""
1621text majname "\",\"name\":\""
1622text majorc "\",\"orcid\":\""
1623text majd "\",\"added_by\":\""
1624text majvia "\",\"via\":\""
1625text majdate "\",\"checked\":\""
1626text majreq "\",\"requester\":\""
1627text majrz "\",\"requester_role\":\"requested public Zenodo metadata; no ownership or identity claim"
1628text majrr "\",\"requester_role\":\"brought the repository to the shelf; not verified"
1629text majlinks "],\"work_authors\":["
1630text majwork "{\"slug\":\""
1631text majids "\",\"author_ids\":[\""
1632text majend "\"]}"
1633fn maprefix a ulong b ulong t view uchar * to bool
1634if lt sub b a len t
1635ret false
1636end
1637ret feqt a add a len t t
1638end
1639fn madate a ulong b ulong to bool
1640if ne sub b a 10
1641ret false
1642end
1643for i ulong 10
1644c = get ib add a i
1645if or eq i 4 eq i 7
1646if ne c 45
1647ret false
1648end
1649else
1650if not and ge c 48 le c 57
1651ret false
1652end
1653end
1654end
1655ret true
1656end
1657fn matype s ulong k ulong to bool
1658a = wf s k
1659b = fe a eol s
1660ret or feqt a b maz feqt a b mar
1661end
1662fn maval s ulong to bool
1663if not matype s 5
1664ret false
1665end
1666a = wf s 1
1667b = fe a eol s
1668if not slugok a b
1669ret false
1670end
1671if feqt a b maself
1672ret false
1673end
1674a = wf s 4
1675if not maprefix a fe a eol s madid
1676ret false
1677end
1678a = wf s 6
1679ret madate a fe a eol s
1680end
1681fn majline s ulong to ulong
1682a = wf s 1
1683ret sline 0 74 a fe a eol s
1684end
1685fn mauline s ulong to ulong
1686j = majline s
1687if ge j get ibl 0
1688ret get ibl 0
1689end
1690a = wf j 2
1691ret sline 0 85 a fe a eol j
1692end
1693fn mapline s ulong to ulong
1694a = wf s 1
1695ret sline 0 80 a fe a eol s
1696end
1697fn matext s ulong to bool
1698p = mapline s
1699if ge p get ibl 0
1700ret false
1701end
1702a = wf p 6
1703b = fe a eol p
1704if ne sub b a 1
1705ret false
1706end
1707ret eq get ib a 49
1708end
1709note maok rejects ambiguous ids/slugs and broken joins before a document or path list is emitted.
1710fn maok to bool
1711lim = get ibl 0
1712s = nextl 0 87
1713while lt s lim bound 4096
1714a = wf s 1
1715b = fe a eol s
1716if not slugok a b
1717ret false
1718end
1719if ne wline a b s
1720ret false
1721end
1722s = nextl add eol s 1 87
1723end
1724s = nextl 0 85
1725while lt s lim bound 4096
1726if not maval s
1727ret false
1728end
1729a = wf s 1
1730b = fe a eol s
1731if ne sline 0 85 a b s
1732ret false
1733end
1734s = nextl add eol s 1 85
1735end
1736s = nextl 0 74
1737while lt s lim bound 4096
1738a = wf s 1
1739b = fe a eol s
1740if ge wline a b lim
1741ret false
1742end
1743if ne sline 0 74 a b s
1744ret false
1745end
1746a = wf s 2
1747if ge sline 0 85 a fe a eol s lim
1748ret false
1749end
1750s = nextl add eol s 1 74
1751end
1752s = nextl 0 71
1753while lt s lim bound 4096
1754if not magvalid s
1755ret false
1756end
1757s = nextl add eol s 1 71
1758end
1759s = nextl 0 84
1760while lt s lim bound 4096
1761if not matvalid s
1762ret false
1763end
1764s = nextl add eol s 1 84
1765end
1766s = nextl 0 80
1767while lt s lim bound 4096
1768if not mapvalid s
1769ret false
1770end
1771s = nextl add eol s 1 80
1772end
1773ret true
1774end
1775fn mapvalid s ulong to bool
1776e = eol s
1777a = wf s 1
1778b = fe a e
1779if ge wline a b get ibl 0
1780ret false
1781end
1782if ne sline 0 80 a b s
1783ret false
1784end
1785if not matype s 2
1786ret false
1787end
1788a = wf s 3
1789if not maprefix a fe a e madid
1790ret false
1791end
1792a = wf s 4
1793if not madate a fe a e
1794ret false
1795end
1796a = wf s 5
1797b = fe a e
1798if not or maprefix a b marad maprefix a b mazen
1799ret false
1800end
1801a = wf s 6
1802if ne sub fe a e a 1
1803ret false
1804end
1805ret or eq get ib a 48 eq get ib a 49
1806end
1807fn maraw a ulong b ulong to void
1808i = a
1809while lt i b bound 262144
1810emb get ib i
1811i = add i 1
1812end
1813end
1814fn maoval t view uchar * cap ulong to void
1815a = oval t
1816if lt a get ibl 0
1817emr a eol a cap
1818end
1819end
1820fn mamerge to int
1821if not maovok
1822ret 4
1823end
1824lim = get ibl 0
1825a = oval maid
1826b = eol a
1827if not slugok a b
1828ret 4
1829end
1830if feqt a b maself
1831ret 4
1832end
1833if or lt nextl 0 85 lim lt nextl 0 74 lim
1834ret 4
1835end
1836emb 85
1837emb 9
1838emr a b 64
1839emb 9
1840maoval kname 120
1841emb 9
1842maoval korcid 32
1843emb 9
1844maoval maby 128
1845emb 9
1846maoval mavia 16
1847emb 9
1848maoval kcheck 10
1849emb 10
1850s = add eol 0 1
1851while lt s lim bound 262144
1852e = eol s
1853ty = get ib s
1854if and ne ty 79 ne ty 77
1855maraw s e
1856emb 10
1857if eq ty 87
1858emb 74
1859emb 9
1860v = wf s 1
1861emr v fe v e 64
1862emb 9
1863emr a b 64
1864emb 10
1865end
1866end
1867s = add e 1
1868end
1869ret flush
1870end
1871fn mauthors to void
1872em maself
1873emb 10
1874s = nextl 0 85
1875while lt s get ibl 0 bound 4096
1876emwh s 1 64
1877emb 10
1878s = nextl add eol s 1 85
1879end
1880end
1881fn malink s ulong to void
1882em maalink
1883if ge s get ibl 0
1884em maself
1885em w02
1886emo kname 120
1887else
1888emwh s 1 64
1889em w02
1890emwh s 2 120
1891end
1892em c05
1893end
1894fn maindex to void
1895head 0 0 0 0
1896em mahero
1897em iform
1898em itry
1899em maas
1900malink get ibl 0
1901s = nextl 0 85
1902while lt s get ibl 0 bound 4096
1903malink s
1904s = nextl add eol s 1 85
1905end
1906em tsend
1907threads
1908em mawsec
1909s = nextl 0 87
1910while lt s get ibl 0 bound 4096
1911if lt majline s get ibl 0
1912workli s
1913end
1914s = nextl add eol s 1 87
1915end
1916em maend
1917edges
1918em mafoot
1919end
1920fn maauthor a ulong b ulong to int
1921u = sline 0 85 a b
1922legacy = feqt a b maself
1923if and not legacy ge u get ibl 0
1924ret 3
1925end
1926head 0 0 0 0
1927em mauhead
1928if legacy
1929emo kname 120
1930else
1931emwh u 2 120
1932end
1933em mauid
1934emh a b 64
1935zen = false
1936if legacy
1937em maucheck
1938emo kcheck 16
1939else
1940vz = wf u 5
1941zen = feqt vz fe vz eol u maz
1942if zen
1943em maureq
1944else
1945em maun
1946end
1947emwh u 4 128
1948em mauvia
1949emwh u 5 16
1950em maucheck
1951emwh u 6 10
1952end
1953em mauclose
1954maorcid u legacy
1955em mawsec
1956s = nextl 0 87
1957while lt s get ibl 0 bound 4096
1958j = majline s
1959same = and legacy ge j get ibl 0
1960if lt j get ibl 0
1961v = wf j 2
1962same = feqr v fe v eol j a b
1963end
1964if same
1965workli s
1966if mazrec s
1967zen = true
1968end
1969end
1970s = nextl add eol s 1 87
1971end
1972em maend
1973if zen
1974em mazdisc
1975end
1976em mafoot
1977ret flush
1978end
1979fn mazrec s ulong to bool
1980p = mapline s
1981if ge p get ibl 0
1982ret false
1983end
1984a = wf p 2
1985ret feqt a fe a eol p maz
1986end
1987fn maproven s ulong to void
1988p = mapline s
1989if ge p get ibl 0
1990em mapmeta
1991ret
1992end
1993zen = mazrec s
1994if zen
1995em maprovz
1996emwh p 2 16
1997em mapreq
1998else
1999em maprov
2000a = wf p 2
2001if feqt a fe a eol p mar
2002em mashelf
2003else
2004emwh p 2 16
2005end
2006em mapkey
2007end
2008emwh p 3 128
2009em mapdate
2010emwh p 4 10
2011em mapsrc
2012emwh p 5 400
2013if matext s
2014em maptext
2015else
2016em mauclose
2017em mapmeta
2018end
2019if zen
2020em mazwork
2021end
2022end
2023fn mawork s ulong to void
2024ta = wf s 12
2025sa = wf s 1
2026head ta fe ta eol s sa fe sa eol s
2027em mapttl
2028emwh s 12 400
2029em p03
2030emsubh s 67 400
2031em mapacts
2032emwh s 1 64
2033em p07
2034emwh s 1 64
2035em p08
2036u = mauline s
2037em mabyline
2038emwh u 1 64
2039em w02
2040emwh u 2 120
2041em mapclose
2042em maplead
2043emsubh s 83 600
2044em mapp
2045em p13
2046emsubh s 65 12000
2047em p14
2048cite s
2049em mauclose
2050v = wf s 7
2051if gt fe v eol s v
2052em mapdoi
2053emwh s 7 96
2054em mapdoi2
2055end
2056maproven s
2057magsnap s
2058wvers s
2059wedges s
2060wfiles s
2061wkeys s
2062em pend
2063em mafoot
2064end
2065fn majextra to void
2066em majas
2067emoj kname 120
2068em majorc
2069emoj korcid 32
2070em jw15
2071s = nextl 0 85
2072while lt s get ibl 0 bound 4096
2073emb 44
2074em maju
2075emwj s 1 64
2076em majname
2077emwj s 2 120
2078em majorc
2079emwj s 3 32
2080em majd
2081emwj s 4 128
2082em majvia
2083emwj s 5 16
2084em majdate
2085emwj s 6 10
2086em majreq
2087emwj s 4 128
2088vz = wf s 5
2089if feqt vz fe vz eol s maz
2090em majrz
2091else
2092em majrr
2093end
2094em jw15
2095s = nextl add eol s 1 85
2096end
2097em majlinks
2098s = nextl 0 87
2099n = ulong 0
2100while lt s get ibl 0 bound 4096
2101if gt n 0
2102emb 44
2103end
2104em majwork
2105emwj s 1 64
2106em majids
2107u = mauline s
2108if lt u get ibl 0
2109emwj u 1 64
2110else
2111em maself
2112end
2113em majend
2114n = add n 1
2115s = nextl add eol s 1 87
2116end
2117end
2118fn malists corpus bool to void
2119s = nextl 0 87
2120while lt s get ibl 0 bound 4096
2121foreign = lt majline s get ibl 0
2122show = foreign
2123if corpus
2124show = or not foreign matext s
2125end
2126if show
2127emwh s 1 64
2128if corpus
2129emb 9
2130a = wf s 12
2131emr a fe a eol s 400
2132if foreign
2133emb 9
2134t = matline s
2135if lt t get ibl 0
2136emwh t 2 64
2137else
2138emb 45
2139end
2140end
2141end
2142emb 10
2143end
2144s = nextl add eol s 1 87
2145end
2146end
2147fn mamode a ulong b ulong sa ulong sb ulong to int
2148if feqt a b mamrg
2149ret mamerge
2150end
2151if feqt a b maal
2152mauthors
2153ret flush
2154end
2155if feqt a b maau
2156if not slugok sa sb
2157ret 3
2158end
2159ret maauthor sa sb
2160end
2161if or feqt a b maad feqt a b mado
2162head 0 0 0 0
2163if feqt a b maad
2164em maadd
2165else
2166em madoi
2167end
2168em mafoot
2169ret flush
2170end
2171if feqt a b mafo
2172malists false
2173ret flush
2174end
2175if feqt a b maco
2176malists true
2177ret flush
2178end
2179ret 99
2180end
2181fn maqtext to int
2182bol = true
2183while true bound 2097152
2184k = read 0 ib 0 4096
2185if lt k 0
2186ret 1
2187end
2188if eq k 0
2189ret 0
2190end
2191i = ulong 0
2192while lt i ulong k bound 4096
2193c = get ib i
2194if bol
2195em maquote
2196bol = false
2197end
2198emb c
2199if eq c 10
2200bol = true
2201end
2202i = add i 1
2203end
2204r = flush
2205if ne r 0
2206ret r
2207end
2208put obl 0 0
2209end
2210ret 1
2211end
2212fn maargs to int
2213av = new uchar 16 0
2214if ne argcnt 2
2215ret 2
2216end
2217z = argread 1 av 0 16
2218if ne z 5
2219ret 2
2220end
2221for i ulong 5
2222if ne get av i get maqu i
2223ret 2
2224end
2225end
2226ret maqtext
2227end
2228note Foreign O values are checked before the U record is emitted; the merged parser repeats checks.
2229fn maovok to bool
2230a = oval maby
2231if not maprefix a eol a madid
2232ret false
2233end
2234a = oval mavia
2235b = eol a
2236if not or feqt a b maz feqt a b mar
2237ret false
2238end
2239a = oval kcheck
2240if not madate a eol a
2241ret false
2242end
2243a = oval kname
2244ret and lt a get ibl 0 gt eol a a
2245end
2246text maorc1 "<p class='orcid'><span class='idb'>ORCID iD</span><a href='https://orcid.org/"
2247fn maorcid u ulong legacy bool to void
2248a = get ibl 0
2249b = a
2250if legacy
2251a = oval korcid
2252b = eol a
2253else
2254a = wf u 3
2255b = fe a eol u
2256end
2257if ne sub b a 19
2258ret
2259end
2260for i ulong 19
2261c = get ib add a i
2262if or or eq i 4 eq i 9 eq i 14
2263if ne c 45
2264ret
2265end
2266else
2267ok = and ge c 48 le c 57
2268if and eq i 18 eq c 88
2269ok = true
2270end
2271if not ok
2272ret
2273end
2274end
2275end
2276em maorc1
2277emh a b 19
2278em w02
2279emh a b 19
2280em mapclose
2281end
2282text mawby "</span><a href='/research/authors/"
2283text mawdoi "<a class='doi' href='https://doi.org/"
2284fn mawli s ulong to void
2285em w01
2286emwh s 1 64
2287em w02
2288emwh s 12 400
2289em w03
2290emsubh s 83 600
2291em w04
2292emwh s 3 16
2293em w05
2294emwh s 4 32
2295em mawby
2296u = mauline s
2297emwh u 1 64
2298em w02
2299emwh u 2 120
2300em w09
2301v = wf s 7
2302if gt fe v eol s v
2303em mawdoi
2304emwh s 7 96
2305em w02
2306emwh s 7 96
2307em w09
2308end
2309em w10
2310end
2311text majp1 "],\"provenance\":{\"how\":\""
2312text majp2 "\",\"source\":\""
2313text majp3 "\",\"open_text\":"
2314text majp4 "},\"author_ids\":[\""
2315text majp5 "],\"author_ids\":[\""
2316fn majwext s ulong to void
2317p = mapline s
2318if lt p get ibl 0
2319em majp1
2320emwj p 2 16
2321em majd
2322emwj p 3 128
2323em majreq
2324emwj p 3 128
2325if mazrec s
2326em majrz
2327else
2328em majrr
2329end
2330em majdate
2331emwj p 4 10
2332em majp2
2333emwj p 5 400
2334em majp3
2335if matext s
2336em jtrue
2337else
2338em jfalse
2339end
2340magjson s
2341em majp4
2342else
2343em majp5
2344end
2345u = mauline s
2346emwj u 1 64
2347em jq
2348end
2349note ---- G: slug, repository commit (40 lowercase hex), paper SHA-256 (64 lowercase hex).
2350note Only a foreign work (W with J and P) may carry one G line; legacy documents never show it.
2351text magh1 "<section class='card'><h2>Source snapshot</h2><p>Repository commit: <code>"
2352text magh2 "</code>. Paper SHA-256: <code>"
2353text magh3 "</code>.</p></section>\n"
2354text magj1 ",\"source_commit\":\""
2355text magj2 "\",\"paper_sha256\":\""
2356fn mahex a ulong b ulong n ulong to bool
2357if ne sub b a n
2358ret false
2359end
2360i = a
2361while lt i b bound 64
2362c = get ib i
2363ok = false
2364if and ge c 48 le c 57
2365ok = true
2366end
2367if and ge c 97 le c 102
2368ok = true
2369end
2370if not ok
2371ret false
2372end
2373i = add i 1
2374end
2375ret true
2376end
2377fn magline s ulong to ulong
2378a = wf s 1
2379ret sline 0 71 a fe a eol s
2380end
2381fn magvalid s ulong to bool
2382lim = get ibl 0
2383e = eol s
2384a = wf s 1
2385b = fe a e
2386if ne sline 0 71 a b s
2387ret false
2388end
2389w = wline a b
2390if ge w lim
2391ret false
2392end
2393if eq get mgr 0 0
2394if ge majline w lim
2395ret false
2396end
2397end
2398if ge mapline w lim
2399ret false
2400end
2401a = wf s 2
2402if not mahex a fe a e 40
2403ret false
2404end
2405a = wf s 3
2406b = fe a e
2407if ne b e
2408ret false
2409end
2410ret mahex a b 64
2411end
2412fn magsnap s ulong to void
2413g = magline s
2414if ge g get ibl 0
2415ret
2416end
2417em magh1
2418emwh g 2 40
2419em magh2
2420emwh g 3 64
2421em magh3
2422end
2423fn magjson s ulong to void
2424g = magline s
2425if ge g get ibl 0
2426ret
2427end
2428em magj1
2429emwj g 2 40
2430em magj2
2431emwj g 3 64
2432em jq
2433end
2434note mamraw: set mgr when the mode line (first line) names merge
2435fn mamraw to void
2436m = nextl 0 77
2437if ne m 0
2438ret
2439end
2440a = fld m eol m 1
2441if feqt a fe a eol m mamrg
2442put mgr 0 1
2443end
2444end
2445
2446note T binds a foreign work to the selected immutable cache, or '-' when there is no text.
2447fn matline s ulong to ulong
2448a = wf s 1
2449ret sline 0 84 a fe a eol s
2450end
2451fn matvalid s ulong to bool
2452e = eol s
2453a = wf s 1
2454b = fe a e
2455if ne sline 0 84 a b s
2456ret false
2457end
2458w = wline a b
2459if ge w get ibl 0
2460ret false
2461end
2462if eq get mgr 0 0
2463if ge majline w get ibl 0
2464ret false
2465end
2466end
2467a = wf s 2
2468b = fe a e
2469if ne b e
2470ret false
2471end
2472if eq sub b a 1
2473ret eq get ib a 45
2474end
2475ret mahex a b 64
2476end