interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / patch / p1decl.om

482 lines · 19584 bytes Raw Blame History
1note patch/p1decl.om: git patch intake (docs/API.md "Git patches"). Every text and global of the slice,
2note declared before any use. Prefixes: functions pa*, globals gp*, texts tp*.
3note A patch is a `git format-patch --stdout BASE..HEAD` mbox with a title and a description, uploaded
4note by the local command `interplane patch` (tools/bring) in one signed POST. The forge checks it,
5note applies it once on BASE in a throwaway work tree and keeps the bytes under
6note <data>patches/<owner>/<repo>/<id>/. It never writes a repository and never signs for anyone.
7note Repositories are the bare git stores of the Interplane store this build reads,
8note <store>projects/<name>/repo.git (store/repos.om, server/util.om fksdir); nothing here reads
9note Radicle storage. The slice is composed only in a store-reading build (run.sh).
10text tpsdir "patches/"
11text tpindex "index"
12text tptmp "patch-work/"
13text tppw "pw"
14text tpfmb "mbox"
15text tpfst "statement"
16text tpfsg "signature"
17text tpfhd "head"
18text tpfss "status"
19text tpftt "title"
20text tpfds "description"
21text tpfme "meta"
22text tpfdf "diff"
23text tpnewd ".new-"
24text tpopen "open\n"
25text tpwm "/m"
26text tpww "/w"
27text tpwalt "/w/.git/objects/info/alternates"
28text tpobj "/objects\n"
29text tpdot "."
30text tpdd ".."
31note ---- routes
32text tppats "/patches"
33text tppulls "/pulls"
34text tppull "/pull"
35text tppnew "/patches/new"
36text tpsfxp ".patch"
37text tpsfxd ".diff"
38text tpqpage "page"
39note ---- form fields of POST .../patches/new
40text tpfcsrf "csrf"
41text tpfrepo "repo"
42text tpfbase "base"
43text tpfttl "title"
44text tpfdsc "description"
45text tpfmbx "mbox"
46text tpfsig "sig"
47text tpcsrfe "csrf="
48note ---- the signed statement and the signature check
49text tpst1 "interplane-patch 1\n"
50text tpns "interplane-patch"
51text tpfrom "From "
52text tpfrom2 " Mon Sep 17 00:00:00 2001"
53text tpdg "diff --git "
54text tpgbp "GIT binary patch"
55text tpbf "Binary files "
56text tprnf "rename from "
57text tprnt "rename to "
58text tpcpf "copy from "
59text tpcpt "copy to "
60text tpmcopy "patches with copy headers are not accepted"
61note ---- git argv words (the argv-only exec path of server/util.om: fkb, fka, fexec; no shell)
62text tpdC "-C"
63note the empty tree as git's attribute source: no .gitattributes a patch writes is read (git 2.43 --attr-source)
64text tpatsrc "--attr-source=4b825dc642cb6eb9a060e54bf8d69288fbee4904"
65text tpc "-c"
66text tpinit "init"
67text tpq "-q"
68text tpqq "--quiet"
69text tptpl "--template="
70text tpcatf "cat-file"
71text tpde "-e"
72text tpcmt "^{commit}"
73text tpgmb "merge-base"
74text tpisa "--is-ancestor"
75text tprh "refs/heads/"
76text tprdt "read-tree"
77text tpupr "update-ref"
78text tpnod "--no-deref"
79text tphead "HEAD"
80text tpam "am"
81text tpamd "--committer-date-is-author-date"
82text tpamk "--keep-cr"
83text tpamn "--no-verify"
84text tpam3 "--no-3way"
85text tprevp "rev-parse"
86text tprevl "rev-list"
87text tpcnt "--count"
88text tpdots ".."
89text tpdiff "diff"
90text tpraw "--raw"
91text tpnumst "--numstat"
92text tpnorn "--no-renames"
93text tpfull "--full-index"
94text tpdM "-M"
95text tpnoext "--no-ext-diff"
96text tpnotc "--no-textconv"
97note the configuration every git run in the throwaway work tree carries: no hooks, no maintenance,
98note no network transport, no filter program, symbolic links written as plain files, a fixed committer
99text tpk1 "core.hooksPath=/dev/null"
100text tpk2 "gc.auto=0"
101text tpk3 "maintenance.auto=false"
102text tpk4 "protocol.allow=never"
103text tpk5 "core.fsmonitor=false"
104text tpk6 "core.symlinks=false"
105text tpk7 "core.autocrlf=false"
106text tpk8 "commit.gpgSign=false"
107text tpk9 "user.name=interplane-forge"
108text tpk10 "user.email=forge@interplane.io"
109text tpk11 "filter.lfs.clean="
110text tpk12 "filter.lfs.smudge="
111text tpk13 "filter.lfs.process="
112text tpk14 "filter.lfs.required=false"
113text tpk15 "core.attributesFile=/dev/null"
114text tpk16 "submodule.recurse=false"
115text tpk17 "init.defaultBranch=main"
116note ---- text answers of the upload (plain text, one reason a refusal)
117text tpctxt "text/plain; charset=utf-8"
118text tprefu "refused: "
119text tpacc "accepted\n"
120text tpexi "exists\n"
121text tpaid "id "
122text tpapth "path "
123text tpm403 "sign in first: this request carries no session"
124text tpmcsrf "missing or wrong CSRF token"
125text tpmrate "too many writes from this address or key; wait a minute"
126text tpmoff "writes are switched off on this forge right now"
127text tpmform "the body is not the patch form: fields csrf, repo, base, title, description, mbox and sig, each once"
128text tpmnorp "no such public repository"
129text tpmrepo "the repo field does not name this repository"
130text tpmnogs "this repository has no git store on this forge"
131text tpmbase "base is not a commit id of 40 lowercase hex digits"
132text tpmunk "unknown base: the repository has no such commit"
133text tpmnotm "base is not reachable from the repository's main branch"
134text tpmttl "the title must be 1 to 256 bytes of UTF-8 text on one line"
135text tpmdsc "the description must be at most 60000 bytes of UTF-8 text without control bytes"
136text tpmbig "the mbox is larger than 2097152 bytes"
137text tpmb64 "the mbox field is not base64url without padding"
138text tpmnfp "the mbox is not git format-patch output"
139text tpmmany "the mbox holds more than 100 commits"
140text tpmsigf "the sig field is not an armored SSH signature"
141text tpmsig "the signature does not verify for this session's key and this patch"
142text tpmbin "binary patches are not accepted"
143text tpmpath "a patch names a path outside the repository"
144text tpmappl "the mbox does not apply cleanly on base"
145text tpmcnt "git applied a different number of commits than the mbox holds"
146text tpmsub "the patch adds a submodule"
147text tpmdbig "the combined diff of the patch is larger than 16 MiB"
148text tpmint "the forge could not check the patch (internal error)"
149text tpmwr "the forge could not store the patch"
150text tplrm "PATCH-TMP a work folder under <data>patch-work/ (pw...) could not be removed\n"
151note ---- pages
152text tptlist "Patches"
153text tptnew "Open a patch"
154text tppor1 "https://interplane.io"
155text tppor2 "https://www.aienos.com"
156text tph1 "<div class=\"bar\"><b>"
157text tph1a " patch</b> "
158text tph1b " patches</b> "
159text tph2 "<a href=\""
160text tph2n "/patches/new\">How to open a patch</a></div>\n"
161text tphul "<ul class=\"commits\">\n"
162text tphule "</ul>\n"
163text tphli "<li><a class=\"subject\" href=\""
164text tphq "\">"
165text tphae "</a>"
166text tphm1 "<div class=\"meta\"><span class=\"label\">open</span> <code>"
167text tphm2 "</code> opened "
168text tphby " by "
169text tphm3 " &middot; "
170text tphc1 " commit"
171text tphc2 " commits"
172text tphf1 " file"
173text tphf2 " files"
174text tphm4 "</div></li>\n"
175text tphnone "<p class=\"empty\">No patches yet.</p>\n"
176text tphpg1 "<div class=\"pager\">"
177text tphpgn "\">Newer</a>"
178text tphpgo "\">Older</a>"
179text tphpg2 "</div>\n"
180text tphqp "/patches?page="
181text tphcode "<code>"
182text tphcodz "</code>"
183text tphp1 "<div class=\"box commit\"><h2>"
184text tphp2 "</h2>\n<p class=\"meta\"><span class=\"label\">open</span> <code>"
185text tphp3 "</p>\n<p class=\"meta\">"
186text tphp4 " bytes. Base <a href=\""
187text tphcm "/commit/"
188text tphp5 "</code></a>. Applied head <code>"
189text tphp6 "</code>: the last commit this forge's own <code>git am</code> made on the base. It is in no repository; the owner applies the patch by hand.</p>\n</div>\n"
190text tphds1 "<pre class=\"msg\">"
191text tphpre "</pre>\n"
192text tphap1 "<div class=\"box\"><h3>Apply it</h3>\n<pre class=\"so-cmd\">git checkout -b patch-"
193text tphap2 "\ncurl -fsSL "
194text tphap3 " | git am</pre>\n<p><a href=\""
195text tphap4 "\">Raw patch (mbox)</a> &middot; <a href=\""
196text tphap5 "\">Diff</a></p></div>\n"
197text tphsg1 "<div class=\"box\"><h3>Signature</h3>\n<p class=\"meta\">The author's key <code>"
198text tphsg2 "</code> signed this statement with <code>ssh-keygen -Y sign -n interplane-patch</code>; the forge checked the signature before it kept the patch. The lines are: format, repository, base, SHA-256 of the mbox, SHA-256 of the title, a line feed and the description.</p>\n<pre class=\"hit\">"
199text tphsg3 "<pre class=\"hit\">"
200text tphdv "</div>\n"
201text tphdf1 "<h3>Changes</h3>\n<pre class=\"hit\">"
202text tphdfc "<p class=\"meta\">The diff is longer than this page shows; the raw diff has all of it.</p>\n"
203text tphn1 "<div class=\"box\"><h2>Open a patch</h2>\n<p>A patch is a set of commits you propose for this project. You send it from your own clone with the <code>interplane</code> program; your key signs it on your computer and never leaves it. The owner applies a patch by hand.</p>\n<pre class=\"so-cmd\">interplane patch "
204text tphn2 "</pre>\n<p class=\"meta\">Run it inside a git work tree with your commits on top of this project's main branch. It shows what will be sent (base, commits, files, bytes, title) and sends only after you type yes. Limits: 100 commits, 2 MiB of <code>git format-patch</code> output, no binary patches.</p>\n</div>\n"
205note ---- JSON (docs/API.md forge/patch-list/1 and forge/patch/1)
206text tpjl1 "{\"schema\":\"forge/patch-list/1\",\"base\":\""
207text tpjp1 "{\"schema\":\"forge/patch/1\",\"base\":\""
208text tpjown "\",\"owner\":\""
209text tpjrep "\",\"repo\":\""
210text tpjpage "\",\"page\":"
211text tpjper ",\"per_page\":30,\"count\":"
212text tpjpats ",\"patches\":[\n"
213text tpjnext "\n],\"next\":"
214text tpjprev ",\"prev\":"
215text tpjend "}\n"
216text tpjid "{\"id\":\""
217text tpjid2 "\",\"id\":\""
218text tpjttl "\",\"title\":"
219text tpjdsc ",\"description\":"
220text tpjnm ",\"name\":"
221note the keys of SPEC section 3 after title, in their order (fyk / fyk0 of server/jsonp.om)
222text tpkst "status"
223text tpksd "state_derived"
224text tpkau "author"
225text tpkdid "did"
226text tpkim "imported"
227text tpkbc "base_commit"
228text tpkhc "head_commit"
229text tpkcm "commits"
230text tpkfl "files"
231text tpkby "bytes"
232text tpkcd "code"
233text tpksha "mbox_sha256"
234text tpkop "opened"
235text tpkcl "closed"
236text tpkmg "merge"
237text tpklb "labels"
238text tpkco "comments"
239text tpkcr "created"
240text tpkcc "comments_count"
241text tpkpt "path"
242text tpkpa "patch"
243text tpkdf "diff"
244text tpkbn "bundle"
245text tpkst2 "states"
246text tpkdm "damaged"
247text tpkdu "diff_unavailable"
248text tpktt "thread_truncated"
249text tpktr "thread_reason"
250note the values of diff_unavailable (pajduw) and of thread_reason (pajtrw; "too-large" is in both)
251text tpun1 "no-code-file"
252text tpun2 "no-base"
253text tpun3 "base-not-in-store"
254text tpun4 "too-large"
255text tpun5 "bundle-too-large"
256text tpun6 "diff-failed"
257text tptr1 "malformed-record"
258text tptr3 "document-budget"
259text tpkfrm "from"
260text tpkow "owner"
261text tpkrp "repo"
262text tpknum "number"
263text tpkurl "url"
264text tpklog "login"
265text tpkknd "kind"
266text tpkstt "state"
267text tpkln "line"
268text tpktim "time"
269text tpkbdy "body"
270text tpkcmt "commit"
271text tpkrch "reach"
272text tpkmn "main"
273text tpkobs "observed"
274text tpkmb "mbox"
275text tpknone "none"
276text tpgith "github"
277text tpdash "-"
278text tpjnull "null"
279text tpjsep ",\n"
280note ---- request state
281note gpfv: one percent-decoded form field (padec), read by the field checks and patch/p2utf8.om
282global gpfv uchar 65536
283note gpfo / gpfn / gpfs: offset, length and presence of the seven form fields in fbig, by index:
284note 0 csrf, 1 repo, 2 base, 3 title, 4 description, 5 mbox, 6 sig
285global gpfo ulong 8
286global gpfn ulong 8
287global gpfs ulong 8
288note gpmb: the decoded mbox (F1: at most 2 MiB)
289global gpmb uchar 2097152
290global gpmbl ulong 1
291note gpttl: the title; a signed patch's is at most 256 bytes (F2), an imported item's is cut to 1024
292global gpttl uchar 1024
293global gpttll ulong 1
294global gpdsc uchar 60000
295global gpdscl ulong 1
296global gpsig uchar 4096
297global gpsigl ulong 1
298global gpbase uchar 40
299global gphead uchar 40
300global gpid uchar 16
301global gpst uchar 512
302global gpstl ulong 1
303note gpncm: commits the mbox holds; gpnfl: files the applied patch changed; gpgrd: what the scan of
304note the mbox found (0 nothing, 2 a binary patch, 3 a path outside the repository)
305global gpncm ulong 1
306global gpnfl ulong 1
307global gpgrd ulong 1
308note gpp: path builder; gpstm: the 16 hex digits that name this request's work folder and staging
309note folder; gpde: one batch of directory entries (the work-folder remover)
310global gpp uchar 4096
311global gppl ulong 1
312global gpstm uchar 16
313global gpde uchar 32768
314note ---- a stored patch read back (paload): author DID, creation time, commit and file counts, mbox
315note bytes and its SHA-256 from the meta file; title, base and head in the globals above
316global gpmdid uchar 128
317global gpmdidl ulong 1
318global gpmts ulong 1
319global gpmcm ulong 1
320global gpmfl ulong 1
321global gpmby ulong 1
322global gpmsha uchar 64
323note gpix: the index file of one list request (paixld). The page loaders read every item through fxo,
324note so the index cannot stay there while the items of the list are counted. As large as fxo: an index
325note of 16777216 bytes or more (986896 lines) is the whole 500 of fincut, as before
326global gpix uchar 16777216
327note gpids: the ids of one list page (30 rows of 16 hex digits); gpln: a small line buffer
328global gpids uchar 480
329global gpln uchar 256
330global gplnl ulong 1
331note gpcur / gpbad: read position and failure flag of the meta file parser
332global gpcur ulong 1
333global gpbad ulong 1
334note ---- imported proposals (SPEC prstore/r1 extension, patch/p5imp.om); files of an item folder
335text tpfsj "source.json"
336text tpfgh "gh"
337text tpfth "thread"
338text tpflb "labels"
339text tpfmg "merged"
340text tpfrc "reach"
341text tpfbn "head.bundle"
342text tpdpd "pdiff/"
343text tpsfxg ".big"
344text tpsw1 "closed\n"
345text tpsw2 "merged\n"
346text tpsjpre "{\"kind\":\"github-import\",\"owner\":\""
347text tpsjow "\"owner\":\""
348text tpsjrp "\"repo\":\""
349text tpsjurl "\"url\":\""
350text tpsjutc "\"imported_utc\":\""
351text tpsjnum "\"number\":"
352text tpsjder "\"state_derived\":true"
353text tpghn "number "
354text tpghl "login "
355text tpgho "opened "
356text tpghc "closed "
357text tpghm "merged "
358text tprcom "comment"
359text tprrev "review"
360text tprrc "review-comment"
361text tprch1 "reachable"
362text tprch2 "not-reachable"
363text tprch3 "unknown"
364text tpwopn "open"
365text tpwclo "closed"
366text tpwmrg "merged"
367text tpsfxb ".bundle"
368text tpctbin "application/octet-stream"
369text tpbund "bundle"
370text tpunb "unbundle"
371text tpnocol "--no-color"
372text tpdots3 "..."
373text tpm409 "another item of this store holds this patch id"
374text tpmdint "the diff could not be made (internal error)\n"
375note ---- imported proposals: HTML
376text tputc " UTC"
377text tpimp1 "Imported from GitHub "
378text tpimp2 ", by "
379text tpimp3 " (code only)"
380text tpbok "<b class=\"ok\">"
381text tpbbad "<b class=\"bad\">"
382text tpbmut "<b class=\"muted\">"
383text tpboff "</b>"
384text tpbder " <b class=\"muted\">derived</b>"
385text tpnotl "(untitled)"
386text tpiwi " imported "
387text tpiwo " opened "
388text tpir1 "<div class=\"meta\">"
389text tpir2 " <code>"
390text tpsth "<span class=\"states\">"
391text tpsto " open &middot; "
392text tpstc " closed &middot; "
393text tpstm " merged</span> "
394text tpdmg1 "<span class=\"muted\">"
395text tpdmg2 " damaged item is not shown</span> "
396text tpdmg3 " damaged items are not shown</span> "
397text tpip2 "</h2>\n<p class=\"meta\">"
398text tpipn " #"
399text tpito " &middot; opened "
400text tpitc " &middot; closed "
401text tpitm " &middot; merged "
402text tpipm "<p class=\"meta\">"
403text tpipe "</p>\n"
404text tpider "<p class=\"meta\">GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).</p>\n"
405text tpilab "Labels: "
406text tpisb "Base <code>"
407text tpisb2 "</code> &middot; "
408text tpisnb "No base commit &middot; "
409text tpish "Head <code>"
410text tpimg1 "Merged on GitHub as <code>"
411text tpimr1 "; reachable from main <code>"
412text tpimr2 "; not reachable from main <code>"
413text tpimr3 "; reachability from main unknown"
414text tpimro " (observed "
415text tpibox "<div class=\"box\"><p class=\"meta\">"
416text tpiwr " wrote on "
417text tpidsc "Description"
418text tpidbig "<p class=\"meta\">The description is too large for this page.</p>\n"
419text tpirv1 " reviewed ("
420text tpirv2 ") on "
421text tpirc1 " commented on <code>"
422text tpirc2 "</code> line "
423text tpion " on "
424text tpitbad "<p class=\"meta\">The thread stops here: its next record is malformed.</p>\n"
425text tpitcut "<p class=\"meta\">The thread is too long for this page; the rest is not shown.</p>\n"
426text tpitbig "<p class=\"meta\">The thread file is larger than this forge reads; the rest is not shown.</p>\n"
427text tpibd1 "<div class=\"box\"><h3>Fetch it</h3>\n<p class=\"meta\">A git bundle of the pull request's head, "
428text tpibd2 " bytes.</p>\n<pre class=\"so-cmd\">curl -fsSL "
429text tpibd3 " -o "
430text tpibd4 "\ngit fetch "
431text tpibd4b " refs/pull/"
432text tpibd5 "/head</pre>\n<p><a href=\""
433text tpibd6 "\">Raw bundle</a>"
434text tpibd7 " &middot; <a href=\""
435text tpibd9 "</p></div>\n"
436text tpicn1 "<div class=\"box\"><h3>Code</h3>\n<p class=\"meta\">The head commit is on main: <a href=\""
437text tpicn2 "</code></a>.</p></div>\n"
438text tpipv1 "<div class=\"box\"><h3>Provenance</h3>\n<p class=\"meta\">This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:</p>\n<pre class=\"hit\">"
439text tpich "<h3>Changes</h3>\n<p class=\"meta\">"
440text tpicg0 "There is no diff: the head commit is already on main."
441text tpicg7 "There is no diff: this item holds no code file."
442text tpicx "<div class=\"box\"><h3>Code</h3>\n<p class=\"meta\">This item holds no code file.</p></div>\n"
443text tpicg1 "There is no stored diff for this mbox."
444text tpicg2 "There is no diff: the bundle has no base commit."
445text tpicg3 "There is no diff: the base commit is not in this project's git store."
446text tpicg4 "The diff is larger than 16 MiB, too large to show: fetch the bundle instead."
447text tpicg5 "The diff could not be made (internal error)."
448text tpicg6 "The diff is empty."
449text tpicg8 "This bundle is larger than the display limit. Fetch the bundle to see the changes."
450note gpimp: the loaded item is imported (1) or signed (0); gpist: its status (0 open, 1 closed, 2
451note merged); gpider: its state is derived (code-only); gpicode: its code file (0 none, 1 mbox, 2
452note head.bundle; its size in gpmby); gpihb: it has a base (gpbase); gpnum: its GitHub number; gpbd:
453note the bundle diff (pabdiff's answer; 9 not asked); gpsc: the items a list page shows by state (list
454note head); gptr: why the comments of forge/patch/1 are not the whole thread (pajcoms: 0 they are, 1 a
455note malformed record, 2 the thread file is larger than gpth, 3 the document budget PAJMX)
456global gpimp ulong 1
457global gpist ulong 1
458global gpider ulong 1
459global gpicode ulong 1
460global gpihb ulong 1
461global gpnum ulong 1
462global gpbd ulong 1
463global gpsc ulong 3
464global gptr ulong 1
465note gpr: offsets and lengths of the parsers (thread record, gh line, source.json value, reach line)
466global gpr ulong 16
467note gpsrc: source.json (its first 4096 bytes); gpgh: the gh file (its first 2048 bytes); gpth: the
468note thread (as much as fxo reads; gpthc 1 when the file is larger)
469global gpsrc uchar 4096
470global gpsrcl ulong 1
471global gpgh uchar 2048
472global gpghl ulong 1
473global gpth uchar 16777216
474global gpthl ulong 1
475global gpthc ulong 1
476note PAPGMX: the most an imported page's description and thread take of fob (8 MiB), so the
477note provenance box and a 400000-byte diff (6 bytes each at most, escaped) still fit after them
478const PAPGMX ulong 5000000
479note PAJMX: the most forge/patch/1 takes of fob (8388608 bytes) up to the end of its comments. The
480note 65536 bytes left hold the rest of the document: at most 24578 bytes of "created" (a source.json
481note value of up to 4096 bytes, 6 bytes each escaped), four links of under 250 bytes and the fixed keys
482const PAJMX ulong 8323072