Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/interplane-forge/compare/a64d48239e0204bf7585620b2bc9b7078550d1ab...3df50b9554ac999c45c6eaea50884e11e257bc45 # interplane-forge INTERPLANE Forge Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## Comparing `a64d48239e0204bf7585620b2bc9b7078550d1ab` ... `3df50b9554ac999c45c6eaea50884e11e257bc45` - Let slow first connections finish the Interplane TLS handshake `3df50b9` · Drake Stapleton · 2026-11-18 18:49 · Browse - Keep public Git limits in the existing deployable edge snippet `3521e81` · Drake Stapleton · 2026-11-18 18:41 · Browse - Queue repository page bursts and give Git transfers independent capacity `c7bca69` · Drake Stapleton · 2026-11-18 18:39 · Browse - Keep repository browsing on the same public Git source as downloads `f61fb80` · Drake Stapleton · 2026-11-18 17:57 · Browse - Offer a full clone and matching branch ZIP in every repository header `2e2666a` · Drake Stapleton · 2026-11-18 17:16 · Browse - Serve Omega clones and main archives from the same public Git source `eb4d734` · Drake Stapleton · 2026-11-18 17:03 · Browse - Exercise JSON media negotiation and reject unsafe Markdown links `c225838` · Drake Stapleton · 2026-11-18 16:11 · Browse - Support machine issue forms and preserve unpaged JSON clients `e5f46b0` · Drake Stapleton · 2026-11-18 16:10 · Browse - Compose shared form fields before both callers `0594b5a` · Drake Stapleton · 2026-11-18 16:03 · Browse - Keep edge cache control in the HTTP response layer `43e7c86` · Drake Stapleton · 2026-11-18 16:02 · Browse - Verify thread persistence across a server restart `74f7124` · Drake Stapleton · 2026-11-18 16:01 · Browse - Bound issue list rendering and keep older threads reachable `77aa644` · Drake Stapleton · 2026-11-18 16:00 · Browse - Keep issue reads fresh and recover interrupted submissions `9e873a5` · Drake Stapleton · 2026-11-18 15:58 · Browse - Use verified AArch64 file flags for issue writes `efff964` · Drake Stapleton · 2026-11-18 15:57 · Browse - Point failed issue checks to their fixture `2b507c3` · Drake Stapleton · 2026-11-18 15:56 · Browse - Open and discuss issues directly in Interplane `f5143a6` · Drake Stapleton · 2026-11-18 15:56 · Browse - Count actual fault calls in the JSON-only control `be780af` · Drake Stapleton · 2026-11-18 15:25 · Browse - Remember JSON diff failures and enforce clean gate inputs `e61ee44` · Drake Stapleton · 2026-11-18 15:24 · Browse - Keep the old rate-limit control buildable with patch intake `0328961` · Drake Stapleton · 2026-11-18 15:19 · Browse - Use normalized mail as the single copy-header check `3e9397f` · Drake Stapleton · 2026-11-18 15:11 · Browse - Bind test binaries to source and exercise storage limits `656bf70` · Drake Stapleton · 2026-11-18 15:09 · Browse - Use unsigned monotonic time for bundle retry expiry `5efb09b` · Drake Stapleton · 2026-11-18 15:07 · Browse - Use a compiler-compatible storage refusal identifier `b829296` · Drake Stapleton · 2026-11-18 15:07 · Browse - Assert the escaped timestamp is visible `c0919b9` · Drake Stapleton · 2026-11-18 15:06 · Browse - Exercise normalized mail and malformed import controls `9b69a83` · Drake Stapleton · 2026-11-18 15:05 · Browse - Reserve filesystem capacity before accepting new patches `3265aea` · Drake Stapleton · 2026-11-18 15:04 · Browse - Bound bundle diff generation and confirm patch index writes `7fada1b` · Drake Stapleton · 2026-11-18 15:04 · Browse - Check Git-normalized patch mail before applying it `324955b` · Drake Stapleton · 2026-11-18 15:01 · Browse - Validate imported issue records before rendering `48c4e5e` · Drake Stapleton · 2026-11-18 15:00 · Browse - Serve the write token from settings in the CLI fixture `53cbf91` · Drake Stapleton · 2026-11-18 14:44 · Browse - Match the CLI and edge fixtures to the deployed store layout `21dc2fd` · Drake Stapleton · 2026-11-18 14:43 · Browse - Apply download limits to imported proposal bundles `9374dfb` · Drake Stapleton · 2026-11-18 14:42 · Browse - Use compiler-compatible locals in patch endpoint matching `153e201` · Drake Stapleton · 2026-11-18 14:40 · Browse - Verify copy refusal and cleanup in the bounded patch workspace `25f760f` · Drake Stapleton · 2026-11-18 14:39 · Browse - Scope the larger upload limit to the patch endpoint `e87d80a` · Drake Stapleton · 2026-11-18 14:38 · Browse - Exercise the bounded patch retry schedule `685b599` · Drake Stapleton · 2026-11-18 14:37 · Browse - Bound patch workspace usage and upload retries `a41c01a` · Drake Stapleton · 2026-11-18 14:37 · Browse - Run the independent proposal oracle against the signed-store fixture `8e65f74` · Drake Stapleton · 2026-11-18 14:20 · Browse - Verify patch routing leaves the native issue list available `f699b08` · Drake Stapleton · 2026-11-18 14:18 · Browse - Check imported proposal bases in the signed-store fixture `4ac62b2` · Drake Stapleton · 2026-11-18 14:18 · Browse - Exercise imported issue pages with the signed-store fixture `d05d60a` · Drake Stapleton · 2026-11-18 14:17 · Browse - Advertise the signed patch schema and preserve live clone aliases `2d40609` · Drake Stapleton · 2026-11-18 14:16 · Browse - Serve imported issue pages from the signed-store forge `c944625` · Drake Stapleton · 2026-11-18 14:14 · Browse - Replay downloaded patches from the signed-store fixture `0ff5c01` · Drake Stapleton · 2026-11-18 14:12 · Browse - Use published repositories and Browse rendering for proposals `6a0d215` · Drake Stapleton · 2026-11-18 14:11 · Browse - Preview current Git patch and imported proposal code on the signed store `1b9cbfc` · Drake Stapleton · 2026-11-18 14:10 · Browse - WIP, not gated, not reviewed: port of the git patch intake (patch/git-intake `a73251d`) to the store-reading build; stopped by the lead before docs, agents.tsv, e2e, sandbox and edge tests were adapted `e4bd5d9` · Drake Stapleton · 2026-11-17 22:01 · Browse - Merge branch 'published-store' into preview/reconcile-signed-history `786f0e9` · Drake Stapleton · 2026-11-18 14:08 · Browse - Merge the installed store line `891ae1b` (bazinga/live) into main `c62763b` `d5a01a6` · Drake Stapleton · 2026-11-18 08:08 · Browse - social tests: unit-list alarm holds no run.sh text; review fixes (DRA-809) `c62763b` · Drake Stapleton · 2026-11-17 00:36 · Browse - social tests: derive the unit list from run.sh (DRA-809) `465c48c` · Drake Stapleton · 2026-11-17 00:27 · Browse - Merge `64d69961` (infra/DEPLOY.md: /forge redirect apply record, bay 1 MERGE) onto main `bb6a631` · Drake Stapleton · 2026-11-16 23:58 · Browse - visits/tests/run.sh: header names the mutants at the end of the file, not a typed list of three `badf879` · Drake Stapleton · 2026-11-16 23:57 · Browse - visits: gates pin the newest Omega build; no typed counts or word list in the README `775e9c3` · Drake Stapleton · 2026-11-16 23:19 · Browse - Merge forge/visits-kinds `711c8489` (bay 1 MERGE) onto main `0fe6a58` · Drake Stapleton · 2026-11-16 23:04 · Browse - chain page: "prove one message" reads the line from the file; a page past its buffer is refused `2067bc9` · Drake Stapleton · 2026-11-16 22:57 · Browse - Merge forge/chain-page `0edebedb` (`6bd4b99b` + bay 1 page-guard fix) onto main `4ed98366` `47ddce3` · Drake Stapleton · 2026-11-16 22:42 · Browse - Bazinga git: read-only clone over HTTPS on interplane.io, old clone links redirected `891ae1b` · Drake Stapleton · 2026-11-15 01:36 · Browse - Sign in with one command and one box; the owner signs in with the owner key `dc55b27` · Drake Stapleton · 2026-11-15 01:35 · Browse - restore: R4 findings 1, 2, 5: reason row out of the key table; check.sh ratelim control composes fmvng; compare.sh leaves out projects landed after the Radicle freeze and counts namespaced tags `52b39fc` · Drake Stapleton · 2026-11-15 00:36 · Browse - restore: RestoreReview findings 1-7, serve the whole public catalog `ebe796a` · Drake Stapleton · 2026-11-14 22:33 · Browse - infra/test/count-snapshot.py: available() after the Radicle-text removal `866b31f` · Drake Stapleton · 2026-11-14 20:58 · Browse - store/tests: a Radicle-pattern crawl of the store build; compare.sh compares with the restore-rad-free merge `0554840` · Drake Stapleton · 2026-11-14 20:23 · Browse - counts tables follow FAMAX; store variants of the sandbox gate, smoke, jsonpages, sitechrome, bigrepo, cutdata `b72c260` · Drake Stapleton · 2026-11-14 19:45 · Browse - store build: node health pages are a seam; agentdoor-store checks every not_available address; title.sh store variant `4dcd0d3` · Drake Stapleton · 2026-11-14 18:21 · Browse - tests: dl reads the frozen Radicle storage; sitechrome accepts the lane ports 19990..19999 `2a37cee` · Drake Stapleton · 2026-11-14 17:58 · Browse - restore: the store build serves the native store with the agent door; served list, FAMAX tables `e6c80b4` · Drake Stapleton · 2026-11-14 17:52 · Browse - restore-rad-free: bare ids in the restore code paths too (radsrc fputid, door events rid); agentdoor.py expects the bare rid `9a4420a` · Drake Stapleton · 2026-11-14 18:18 · Browse - Merge branch 'rad-free-text' of ../interplane-forge into HEAD `0955a98` · Drake Stapleton · 2026-11-14 18:16 · Browse - server/tests/readmefirst.sh: allow the retired seed line and the cut description `c1f107d` · Drake Stapleton · 2026-11-14 17:59 · Browse - Merge branch 'rad-free-text' of ../interplane-forge into HEAD `4f1ecde` · Drake Stapleton · 2026-11-14 17:53 · Browse - merge rad-free-text `5b9dc875` into restore `92efe260`: no Radicle wording, links, rad: ids or commands; conflicts resolved for the store-reading build (radsrc.om, dlclone.om, store/repos.om tsdv3, agents.tsv status row) `7a87f32` · Drake Stapleton · 2026-11-14 17:53 · Browse - forge: show repository descriptions without retired-network sentences (cut at load, stored data unchanged) `6d72229` · Drake Stapleton · 2026-11-14 17:52 · Browse - forge: serve no Radicle wording, links, rad: ids or rad commands (WIP, tests pending) `5b9dc87` · Drake Stapleton · 2026-11-14 17:36 · Browse - merge agent-door `c12ca793`: agents.json, the event stream and the feed `92efe26` · Drake Stapleton · 2026-11-14 17:07 · Browse - merge native-route `e455626`: forged reads the native store (`babf170`..`e455626`) `c1a39cc` · Drake Stapleton · 2026-11-14 17:06 · Browse - agent door: not_available rows, ETag over the public list, docs, forge-row test `c12ca79` · Drake Stapleton · 2026-11-14 16:37 · Browse - agent door: agents.json, the public event stream and the feed `a37cb7b` · Drake Stapleton · 2026-11-14 15:02 · Browse - store/tests: compare.py radicle accepts only listed rewrite rules (review-b1 finding 1) `e455626` · Drake Stapleton · 2026-11-13 23:44 · Browse - forged reads the native store (interplane-native DESIGN.md step 2) `babf170` · Drake Stapleton · 2026-11-13 19:35 · Browse - infra/DEPLOY.md: record the /forge redirect apply on the Spark and the refused hub update `64d6996` · Drake Stapleton · 2026-11-11 00:09 · Browse - chain: page never replaces the ledger or fed file, never writes through a stale OUT.tmp, never leaves one `0edebed` · Drake Stapleton · 2026-11-09 23:38 · Browse - visits gate: every day row is checked grouped (bay 4 patch kept from `a3dec9d4`) `711c848` · Drake Stapleton · 2026-11-09 23:35 · Browse - visits: near-miss gate cases; phas stops at the first differing byte (bay 2 patch on `e8da2b4c`) `92c5249` · Drake Stapleton · 2026-11-09 23:35 · Browse - chain: page, the head as a page with the check by hand `6bd4b99` · Drake Stapleton · 2026-11-09 23:32 · Browse - visits: crawlers and tools by a list of 23 words; the other kind is browser `e8da2b4` · Drake Stapleton · 2026-11-09 23:25 · Browse 173 files changed, +24312 -1298 README.md +10 -1 SANDBOX-NEEDS.md +4 -2 browse/a_core.om +2 -2 browse/c1_page.om +7 -8 browse/c2_hist.om +9 -9 browse/c3_blame.om +2 -2 browse/e1_json.om +4 -4 browse/e2_json.om +7 -7 browse/tests/stubutil.om +3 -0 chain/README.md +40 -14 chain/chain.om +280 -3 chain/proof.css +14 -0 chain/tests/run.sh +78 -0 collab/co0form.om +205 -0 collab/co2cob.om +5 -0 collab/co3view.om +2 -2 collab/co9comp.om +0 -205 collab/co9form.om +3 -3 collab/co9page.om +8 -130 collab/native/helpers.om +256 -0 collab/native/issue.om +878 -0 collab/native/json.om +447 -0 collab/native/route.om +84 -0 collab/native/write.om +841 -0 collab/tests/compose.sh +20 -17 collab/tests/native-issues-store.sh +224 -0 community/30page.om +1 -1 dl/dl.om +11 -44 dl/dlclone.om +31 -0 dl/tests/check.sh +7 -3 dl/tests/fstub.om +3 -0 docs/AGENT-DOOR.md +164 -0 docs/ANNOYANCES.md +1 -0 docs/API.md +289 -41 docs/BRING.md +83 -6 docs/CONTRACT.md +68 -14 docs/FEATURES.md +12 -8 docs/social.md +8 -2 door/READY +1 -0 door/ev1decl.om +497 -0 door/ev2log.om +416 -0 door/ev3col.om +1029 -0 door/ev4json.om +565 -0 door/ev5feed.om +298 -0 galaxy/page.om +93 -5 galaxy/tests/run.sh +4 -1 growth/g1prep.om +14 -14 growth/g2page.om +4 -5 growth/tests/check.sh +2 -2 infra/DEPLOY.md +6 -0 infra/apache/omega-source.conf +13 -0 infra/bazinga/omega-read +43 -0 infra/bazinga/post-update +5 -0 infra/bazinga/sync.sh +53 -0 infra/nginx/conf.d/bazinga-rad-map.conf +109 -0 infra/nginx/conf.d/forge.conf +23 -6 infra/nginx/sites-enabled/interplane.io +30 -0 infra/nginx/snippets/aienos-rad-moved.conf +11 -0 infra/nginx/snippets/bazinga-git.conf +54 -0 infra/nginx/snippets/forge-archive.conf +1 -0 infra/nginx/snippets/forge-proxy.conf +5 -2 infra/smoke.sh +16 -4 infra/spark/forged-public.sh +38 -7 infra/spark/forged-sandbox.sh +84 -6 infra/spark/forged-service.sh +3 -0 infra/spark/interplane-chain.service +2 -2 infra/spark/nginx/sites-interplane.io +28 -0 infra/test/count-snapshot.py +23 -18 infra/test/edge-bundle-limit.sh +253 -0 infra/test/edge-patch-limit.sh +130 -0 infra/test/sandbox-integrated.py +2 -2 infra/test/sandbox-netns.sh +4 -1 infra/test/sandbox-patch.sh +162 -0 infra/test/sandbox.sh +135 -7 nodes/srch.om +1 -1 nodes/stat.om +5 -5 open/route.om +156 -45 open/tests/run.sh +8 -8 open/tests/up.sh +7 -7 patch/READY +0 -0 patch/p1decl.om +482 -0 patch/p2base.om +522 -0 patch/p2utf8.om +79 -0 patch/p3gate.om +401 -0 patch/p4take.om +1179 -0 patch/p5imp.om +1281 -0 patch/p5page.om +614 -0 patch/p6json.om +637 -0 patch/p7route.om +133 -0 patch/tests/e2e-import.sh +511 -0 patch/tests/e2e.sh +122 -0 patch/tests/lib.sh +305 -0 patch/tests/resilience.sh +56 -0 patch/tests/run.sh +1642 -0 research/build.om +14 -7 research/intake-route.om +3 -6 research/tests/authors.sh +5 -5 research/tests/intake.sh +2 -1 run.sh +255 -18 salvage/15bundle.om +1 -1 salvage/20web.om +1 -1 server/agents.om +195 -0 server/agents.tsv +61 -0 server/count-snapshot.om +17 -17 server/counts.om +36 -153 server/json.om +4 -14 server/jsonp.om +11 -7 server/main.om +85 -7 server/nodoor.om +22 -0 server/noissuewrite.om +17 -0 server/nopatch.om +12 -0 server/nostat.om +14 -0 server/pages.om +37 -53 server/radsrc.om +300 -0 server/repos.om +8 -151 server/route.om +25 -3 server/state.om +1 -1 server/tests/agentdoor.py +492 -0 server/tests/agentdoor.sh +320 -0 server/tests/bigrepo.sh +11 -0 server/tests/check.sh +36 -5 server/tests/counts.sh +29 -35 server/tests/cutdata.sh +21 -0 server/tests/jsonpages.sh +19 -3 server/tests/overflow.sh +12 -3 server/tests/readmefirst.sh +37 -16 server/tests/sitechrome.sh +22 -5 server/tests/title.sh +13 -2 server/tests/translate.sh +5 -6 server/tests/trial-real.sh +3 -3 server/util.om +226 -20 social/05decl.om +8 -5 social/30store.om +3 -1 social/40auth.om +54 -4 social/55pages.om +18 -7 social/60json.om +1 -1 social/signin.sh +43 -0 social/tests/lib.sh +26 -8 social/tests/onebox.sh +23 -0 social/tests/units-check.sh +158 -0 social/tests/units.sh +34 -0 store/clone.om +40 -0 store/evcol.om +863 -0 store/head.om +25 -0 store/moving.om +42 -0 store/mvcommunity.om +13 -0 store/mvgrowth.om +15 -0 store/mvopen.om +27 -0 store/mvsalvage.om +14 -0 store/repos.om +1112 -0 store/tests/agentdoor-store.sh +340 -0 store/tests/capacity.sh +106 -0 store/tests/compare-controls.sh +155 -0 store/tests/compare.py +488 -0 store/tests/compare.sh +588 -0 store/tests/crawl-store.sh +59 -0 store/tests/expect_served.py +58 -0 store/tests/fixstore.sh +46 -0 store/tests/mutant-scan.om +55 -0 store/tests/radcrawl.py +106 -0 store/tests/svlib.sh +20 -0 tools/bring/PLATFORMS.md +13 -2 tools/bring/build.sh +1 -1 tools/bring/src/10base.om +1 -1 tools/bring/src/40net.om +13 -2 tools/bring/src/50patch.om +760 -0 tools/bring/src/90main.om +5 -1 tools/bring/tests/run.sh +39 -0 tools/bring/tests/standin.om +47 -3 visits/README.md +17 -11 visits/tests/owner.sh +2 -2 visits/tests/run.sh +48 -9 visits/visits.om +46 -21 README.md @@ -31,12 +31,14 @@ How the pieces fit together: `docs/CONTRACT.md`. What replaces the GitHub annoya 31 31 | `social/` | ForgeSocial | sign-in, sessions, stars, favorites, watch, follows | 32 32 | `infra/` | ForgeInfra | service supervisor, tunnel, nginx, smoke tests | 33 33 | `quiet/` | simplify (L1008 D) | one digest per subscriber, patch evidence receipt | 34 +| `door/` | AgentDoor | the public event stream (`events.json`) and the feed page; `agents.json` is `server/agents.om` | 34 35 | `docs/` | shared | CONTRACT.md, FEATURES.md, ANNOYANCES.md | 35 36 36 37 ## Build and run (on spark) 37 38 38 39 ``` 39 40 ./run.sh units # list the units in compose order 41 +./run.sh seams # tests only: the same list with every slice as its seam server/no.om 40 42 ./run.sh build # compose and compile with the pinned omc -> server/forged (clean tree only) 41 43 ./run.sh deploy # build HEAD in a fresh git worktree, install server/forged, log it in infra/DEPLOY.md 42 44 ./run.sh start | stop | status | reload @@ -57,13 +59,18 @@ How the pieces fit together: `docs/CONTRACT.md`. What replaces the GitHub annoya 57 59 `127.0.0.1:18480` only. The supervisor restarts forged if it exits; systemd restarts the supervisor. 58 60 - `./run.sh reload` (or SIGHUP to the supervisor) touches `~/forge-data/reload`; forged then re-reads 59 61 the allow-list and the social log without a restart. 62 +- Store-reading build (interplane-native DESIGN.md step 2, not deployed): 63 + `FORGE_STORE= FORGED_OUT= ./run.sh build` (optionally 64 + `FORGE_CLONE_BASE=https:////`) reads the project list from the store's `catalog.tsv` 65 + and Git from `projects/NAME/repo.git` (`store/`, docs/CONTRACT.md section 1); `deploy` and 66 + `restart` refuse it. Acceptance: `bash store/tests/compare.sh STORE KEY IPL_DIR`. 60 67 61 68 ## Data 62 69 63 70 - Repositories: Radicle storage `~/.radicle/storage/`, read with `git` (argv exec, no shell). 64 71 Only the 28 rows of the public table in `~/handoffs/radicle/RIDS.md` exist; everything else is 404. 65 72 `server/repos.om` `fdeny` refuses the withdrawn private projects and their RIDs 66 - even if a table row lists them. 73 + even if a table row lists them (in the store-reading build, by name and by the old id in record 1). 67 74 - Forge data dir `~/forge-data/`: the social append-only log and key, `archives/` (archive cache, 68 75 512 MiB cap per file), `logs/forged.log` (access log and supervisor log), `counts.log` (append-only 69 76 journal of the counted clone and download events and the log positions, `server/counts.om`), @@ -75,6 +82,8 @@ How the pieces fit together: `docs/CONTRACT.md`. What replaces the GitHub annoya 75 82 same data as the HTML pages as JSON: schemas `forge/explore/1` and `forge/repo/1` in `docs/API.md`. 76 83 `trending` and `explore?order=trending|new` order the public list. 77 84 `//insights` is the per-repo numbers page. Schemas and sources: `docs/GROWTH.md`. 85 +`agents.json` lists every machine-readable address (from `server/agents.tsv`); `events.json` 86 +is the public activity stream and `feed` its page: `docs/AGENT-DOOR.md`. 78 87 79 88 ## Host dependencies (production path) 80 89 SANDBOX-NEEDS.md @@ -349,8 +349,10 @@ existing renderer uses it. Archives plus assets must not overflow. The file 349 349 contains only public project identifiers, aggregate figures and collection times. 350 350 It contains no client address, user agent, raw request line or key material. 351 351 352 -Limits: 16384 file bytes, 65 LF-terminated lines including the header, 256 bytes 353 -per line excluding LF, 11 row fields, 64 bytes per field, 64 project rows. 352 +Limits: 65536 file bytes, 257 LF-terminated lines including the header, 256 bytes 353 +per line excluding LF, 11 row fields, 64 bytes per field, 256 project rows (FAMAX, 354 +server/util.om; 16384 bytes, 65 lines and 64 rows before 2026-11-14, when the 355 +allow-list table grew for the native store). 354 356 Duplicate project identifiers, incomplete lines, wrong field counts, invalid 355 357 numbers, future collection time or source times after collection are rejected. 356 358 Files older than 3600 seconds are rejected. A missing, rejected or stale snapshot browse/a_core.om @@ -382,7 +382,7 @@ end 382 382 note brrevp: rev-parse gbfr^{commit} into gbsha; false when it does not name a commit 383 383 fn brrevp to bool 384 384 put gbshl 0 0 385 -fkgit 385 +fksource 386 386 fka tbrevp 387 387 fka tbverif 388 388 fka tbq @@ -419,7 +419,7 @@ put gbfrl 0 0 419 419 if eq get gbrl 0 0 420 420 ret false 421 421 end 422 -fkgit 422 +fksource 423 423 fka tbfer 424 424 fka tbfmtr 425 425 fka tbrh browse/c1_page.om @@ -319,7 +319,7 @@ fput tbae 319 319 end 320 320 note brlast: the newest commit touching gbp at gbsha, in a box 321 321 fn brlast to void 322 -fkgit 322 +fksource 323 323 fka tblog 324 324 fka tbn1 325 325 fka tbone @@ -358,7 +358,7 @@ fn brotype to ulong 358 358 if eq get gbpl 0 0 359 359 ret 1 360 360 end 361 -fkgit 361 +fksource 362 362 fka tbcatf 363 363 fka tbt 364 364 brkshp @@ -377,7 +377,7 @@ ret 0 377 377 end 378 378 note ---- tree listing 379 379 fn brlsx to bool 380 -fkgit 380 +fksource 381 381 fka tblstr 382 382 fka tbz 383 383 fka tbll @@ -565,7 +565,7 @@ n = get gbrml 0 565 565 if eq n 0 566 566 ret 567 567 end 568 -fkgit 568 +fksource 569 569 fka tbcatf 570 570 fka tbblob 571 571 fkopen @@ -686,7 +686,6 @@ end 686 686 end 687 687 fpjdev1 688 688 brrefbar 689 -dlclone 690 689 brlast 691 690 if rd 692 691 if not brlist @@ -842,7 +841,7 @@ end 842 841 ret false 843 842 end 844 843 fn brcatb to bool 845 -fkgit 844 +fksource 846 845 fka tbcatf 847 846 fka tbblob 848 847 brkshp @@ -1120,7 +1119,7 @@ end 1120 1119 note brbsz: gbbsz = the size of the blob : (git cat-file -s) 1121 1120 fn brbsz to bool 1122 1121 put gbbsz 0 0 1123 -fkgit 1122 +fksource 1124 1123 fka tbcatf 1125 1124 fka tbsz 1126 1125 brkshp @@ -1146,7 +1145,7 @@ ret true 1146 1145 end 1147 1146 note brboid: gbboid = the blob id of : (rev-parse, 40 lowercase hex checked) 1148 1147 fn brboid to bool 1149 -fkgit 1148 +fksource 1150 1149 fka tbrevp 1151 1150 fka tbverif 1152 1151 fka tbq browse/c2_hist.om @@ -240,7 +240,7 @@ ret brerr 404 240 240 end 241 241 p = brpgnum 242 242 put gbpg 0 p 243 -fkgit 243 +fksource 244 244 fka tblog 245 245 fka tbfmtc 246 246 fka tbn1 @@ -370,7 +370,7 @@ end 370 370 note brcmtargs: argv in fpk of git format-patch (mode 1) or git show -p (mode 2) of commit gbsha. 371 371 note brcmtraw runs it; output larger than the capture runs again, streamed by the server (kind 4) 372 372 fn brcmtargs mode ulong to void 373 -fkgit 373 +fksource 374 374 if eq mode 1 375 375 fka tbfmtp 376 376 fka tbstdo @@ -388,7 +388,7 @@ brksha 388 388 end 389 389 note brcmthd: the commit header box; false when git show fails 390 390 fn brcmthd to bool 391 -fkgit 391 +fksource 392 392 fka tbshow 393 393 fka tbsfmt 394 394 fka tbfmtk @@ -510,7 +510,7 @@ fputc get gbsha i 510 510 end 511 511 end 512 512 fn brcmtstat to void 513 -fkgit 513 +fksource 514 514 fka tbshow 515 515 fka tbfmt0 516 516 fka tbnums @@ -524,7 +524,7 @@ brstat 524 524 end 525 525 end 526 526 fn brcmtdiff to void 527 -fkgit 527 +fksource 528 528 fka tbshow 529 529 fka tbfmt0 530 530 fka tbpp @@ -863,7 +863,7 @@ end 863 863 fput tbpe 864 864 end 865 865 fn brkref tg bool to void 866 -fkgit 866 +fksource 867 867 fka tbfer 868 868 if tg 869 869 fka tbsortt @@ -1167,7 +1167,7 @@ end 1167 1167 ret eq get gbpl 0 0 1168 1168 end 1169 1169 fn brcmplog to void 1170 -fkgit 1170 +fksource 1171 1171 fka tblog 1172 1172 fka tbfmtc 1173 1173 fka tbn1 @@ -1186,7 +1186,7 @@ fput tbcpcut 1186 1186 end 1187 1187 end 1188 1188 fn brcmpdiff to void 1189 -fkgit 1189 +fksource 1190 1190 fka tbdiff 1191 1191 fka tbnums 1192 1192 fka tbmm @@ -1199,7 +1199,7 @@ if eq get fxol 0 0 1199 1199 ret 1200 1200 end 1201 1201 brstat 1202 -fkgit 1202 +fksource 1203 1203 fka tbdiff 1204 1204 brkdiff 1205 1205 brkcs tbdots browse/c3_blame.om @@ -66,7 +66,7 @@ if eq k 1 66 66 brloc tbtree 67 67 ret 302 68 68 end 69 -fkgit 69 +fksource 70 70 fka tbblame 71 71 fka tbporc 72 72 fkopen @@ -291,7 +291,7 @@ brrefesc 291 291 fput tbsf5 292 292 end 293 293 fn brsrun to void 294 -fkgit 294 +fksource 295 295 fka tbgrep 296 296 fka tbgz 297 297 fka tbgn browse/e1_json.om @@ -239,7 +239,7 @@ fputc 34 239 239 end 240 240 note brylast: the brlast box (newest commit touching gbp at gbsha) as a commit summary, or null 241 241 fn brylast to void 242 -fkgit 242 +fksource 243 243 fka tblog 244 244 fka tbn1 245 245 fka tbone @@ -452,7 +452,7 @@ fputc 34 452 452 end 453 453 note bryrdok: git cat-file -e :/ (brrdshow shows nothing when the blob is unreadable) 454 454 fn bryrdok to bool 455 -fkgit 455 +fksource 456 456 fka tbcatf 457 457 fka tbge 458 458 fkopen @@ -646,7 +646,7 @@ if eq k 1 646 646 brloc tbtree 647 647 ret 302 648 648 end 649 -fkgit 649 +fksource 650 650 fka tbblame 651 651 fka tbporc 652 652 fkopen @@ -809,7 +809,7 @@ ret 200 809 809 end 810 810 note brysrun: brsrun's git grep; the hits array; true when the BRHITS cap cut the list 811 811 fn brysrun to bool 812 -fkgit 812 +fksource 813 813 fka tbgrep 814 814 fka tbgz 815 815 fka tbgn browse/e2_json.om @@ -417,7 +417,7 @@ ret brerr 404 417 417 end 418 418 p = brpgnum 419 419 put gbpg 0 p 420 -fkgit 420 +fksource 421 421 fka tblog 422 422 fka tbfmtc 423 423 fka tbn1 @@ -491,7 +491,7 @@ end 491 491 if gt mode 0 492 492 ret brcmtraw mode 493 493 end 494 -fkgit 494 +fksource 495 495 fka tbshow 496 496 fka tbsfmt 497 497 fka tbfmtk @@ -509,7 +509,7 @@ end 509 509 fyrhead tbzsc 510 510 brzcmthd 511 511 brzlinks 512 -fkgit 512 +fksource 513 513 fka tbshow 514 514 fka tbfmt0 515 515 fka tbnums @@ -519,7 +519,7 @@ fkopen 519 519 brksha 520 520 st = fexec BRTMO 521 521 brzfiles st 522 -fkgit 522 +fksource 523 523 fka tbshow 524 524 fka tbfmt0 525 525 fka tbpp @@ -686,7 +686,7 @@ fputc 34 686 686 fputc 125 687 687 end 688 688 fn brzclog to void 689 -fkgit 689 +fksource 690 690 fka tblog 691 691 fka tbfmtc 692 692 fka tbn1 @@ -705,7 +705,7 @@ fyk tbzkctr 705 705 fybool gt c 250 706 706 end 707 707 fn brzcdiff to void 708 -fkgit 708 +fksource 709 709 fka tbdiff 710 710 fka tbnums 711 711 fka tbmm @@ -720,7 +720,7 @@ if eq get fxol 0 0 720 720 brzdnull 721 721 ret 722 722 end 723 -fkgit 723 +fksource 724 724 fka tbdiff 725 725 brkdiff 726 726 brkcs tbdots browse/tests/stubutil.om @@ -297,6 +297,9 @@ for i ulong len t 297 297 fkc get t i 298 298 end 299 299 end 300 +fn fksource to void 301 +fkgit 302 +end 300 303 fn fkgit to void 301 304 fkb 302 305 fka tfgit chain/README.md @@ -34,24 +34,36 @@ OMV=$HOME/work/flux/omega-mv # sha2.om sha256 `5cf0f981`…fdb3 34 34 ./chain-bin add LEDGER KIND ACTOR SUBJECT < payload # prints: OK 35 35 ./chain-bin verify LEDGER # prints: OK , or BAD line N code 36 36 ./chain-bin check LEDGER SEQ < payload # exit 0 only if this is the payload record SEQ committed to 37 -./chain-bin feed LEDGER FILE KIND ACTOR # one record per new complete line of FILE 37 +./chain-bin feed LEDGER FILE KIND ACTOR [PAGE] # one record per new complete line of FILE; then PAGE 38 +./chain-bin page LEDGER OUT # the head as a page with the check by hand 38 39 ``` 39 40 40 41 `add` takes an exclusive lock, verifies the whole ledger and refuses to append to one that does not 41 42 verify. `verify` enforces every rule in the table above, not only the chain. Commands are matched as 42 -whole words (`add`, `verify`, `check`, `feed`). Exit 0 done; 1 usage or a bad argument; 2 the ledger 43 +whole words (`add`, `verify`, `check`, `feed`, `page`). Exit 0 done; 1 usage or a bad argument; 2 the ledger 43 44 does not verify; 3 read or write failed; 4 `check`: no such record, or the payload is not the one 44 45 committed; 5 `feed`: the file has fewer complete lines than were already recorded from it. BAD 45 46 codes: 1 not seven fields, or a byte that is not a tab or printable ASCII; 2 seq; 3 utc; 4 payload 46 47 digest; 5 prev; 6 line longer than 1,023 bytes; 7 last line has no line feed; 8 kind, actor or 47 48 subject breaks its rule. 48 49 50 +`page` verifies the ledger and writes one HTML file: the record count, the time of the last 51 +record, the head, and the commands from "Checking it without this program" with the public 52 +address of the ledger. It writes nothing for a ledger that does not verify. The file has no script 53 +and no inline style; it links `/assets/tokens.css` and `/assets/proof.css` (`chain/proof.css`). 54 +It is written as `OUT.tmp` and renamed. `feed` with a fifth argument writes the same page after 55 +its last record, so one service keeps ledger and page together. A page name, or its `.tmp`, that is 56 +the ledger or (in `feed`) the fed file is refused with exit 1 before anything is written. A stale 57 +`OUT.tmp` is removed first (the name, never what a link points to), the new one is created 58 +exclusively, and it is removed again when writing or renaming fails. 59 + 49 60 `feed` is how a running log becomes a chain. It records line N of FILE with the subject 50 61 ` line N` and the SHA-256 of the line's bytes, without its line feed, as the payload. 51 62 It resumes after the highest N already recorded for that KIND and file name, so running it again 52 63 adds only new lines; a last line with no line feed yet is left for the next run. Only the digest 53 64 enters the ledger, so a private log can be chained in public: whoever holds a line can prove it was 54 -recorded (`printf %s "LINE" | chain check LEDGER SEQ`), and nobody can read it from the ledger. 65 +recorded (`printf %s "$(sed -n 'Np' FILE)" | chain check LEDGER SEQ`, with the line number for N, 66 +so the line needs no quoting), and nobody can read it from the ledger. 55 67 The file name is at most 100 bytes of printable ASCII. Two files with one base name share a resume 56 68 point under one KIND, so give each its own KIND. A record another writer adds with the same kind and 57 69 a subject of the same form moves the resume point; one ledger per trusted set of writers. FILE may @@ -65,7 +77,7 @@ first run over a long file costs one sync, not one per line; the gate counts the 65 77 ```sh 66 78 # every record's prev is the digest of the line above it 67 79 awk 'NR>1' ledger.tsv | cut -f7 > claimed 68 -head -n -1 ledger.tsv | while IFS= read -r line; do printf %s "$line" | sha256sum | cut -d' ' -f1; done > computed 80 +sed '$d' ledger.tsv | while IFS= read -r line; do printf %s "$line" | sha256sum | cut -d' ' -f1; done > computed 69 81 cmp claimed computed && echo chain intact 70 82 # a payload is the one a record committed to 71 83 sha256sum < payload # equals field 6 of that record @@ -79,21 +91,23 @@ sha256sum < payload # equals field 6 of that record 79 91 - Assumed, not proved: that nobody can find such a SHA-256 collision. 80 92 - Not proved by the chain alone: when a record was written, and who wrote the payload. A ledger 81 93 kept only on one machine can be rebuilt from scratch by whoever holds it. Time and authorship 82 - come from outside: publish each new head where the publisher cannot take it back (a signed commit 83 - on Radicle, replicated by seeds other people run), and the record existed no later than that. 94 + come from outside: publish each new head where the publisher cannot take it back (for example a 95 + signed commit copied to machines other people run), and the record existed no later than that. 84 96 A model vendor does not sign what its model says, so "this model wrote this text" needs a 85 97 witness of the vendor connection; that is a later unit, not claimed here. 86 98 87 99 ## Service (after merge) 88 100 89 101 `infra/spark/interplane-chain.service` chains the hive's message board, `~/handoffs/BOARD.md`, 90 -one record per line, into `~/forge-data/proof/board.tsv`. It runs when the folder changes (inotify 91 -through `aien-onchange`, at most once a minute), not on a clock. Only digests enter the ledger. 102 +one record per line, into `~/forge-data/proof/board.tsv`, and rewrites the page 103 +`~/forge-data/proof/index.html` after each run. It runs when the folder changes (inotify through 104 +`aien-onchange`, at most once a minute), not on a clock. Only digests enter the ledger. 92 105 93 106 ```sh 94 107 mkdir -p ~/.local/share/interplane-chain ~/forge-data/proof 95 108 { printf 'om2\n'; cat $OMV/om/tls/sha2.om chain/chain.om; } | $OMV/seed/out/omc > ~/.local/share/interplane-chain/chain 96 109 chmod 755 ~/.local/share/interplane-chain/chain 110 +cp chain/proof.css ~/forge-data/proof/ 97 111 cp infra/spark/interplane-chain.service ~/.config/systemd/user/ 98 112 systemctl --user daemon-reload && systemctl --user enable --now interplane-chain.service 99 113 ``` @@ -105,7 +119,7 @@ append-only by intent. On a copy of the board of 2026-11-09 (3,294 lines) the fi 105 119 ## Gate 106 120 107 121 ```sh 108 -sh chain/tests/run.sh # RESULT pass=122 fail=0 at this commit 122 +sh chain/tests/run.sh # prints RESULT pass= fail=0 when every case holds 109 123 ``` 110 124 111 125 The oracle is `sha256sum`, never the program under test: every `prev`, every payload digest @@ -123,14 +137,26 @@ writes nothing. A command that only starts like `add` or `verify`, or has a byte 123 137 line (an empty line, a line with a tab, a 200,000-byte line of arbitrary bytes), for leaving an 124 138 unfinished line, for adding nothing when run again, for resuming only on its own kind and exact file 125 139 name, for exit 5 with nothing written when the file lost lines, for refusing the ledger itself as 126 -the file (by its name and through a link), and for its argument rules. 140 +the file (by its name and through a link), and for its argument rules. `page` is checked on a 141 +ledger of 1,234 records: its head and count against `sha256sum` and `wc`, and then the commands 142 +are taken out of the page itself, entity-decoded and run: the head command gives the page's head, 143 +the link check prints `chain intact`, and on a copy with one edited record it does not; the 144 +"prove one message" command, run on a board line holding a quote, an apostrophe, parentheses and a 145 +dollar sign, gives that line's SHA-256; the page ends with `` and its line feed. (A page 146 +that would pass the 16,383-byte page buffer is refused with exit 3, never cut short; today's page 147 +is under 3,000 bytes, so the gate does not reach that case.) A damaged 148 +ledger gets exit 2 and no page; an empty one says so. A page named as the ledger, as the ledger's 149 +name plus `.tmp`, or (in `feed`) as the fed file is refused and leaves both unchanged; a stale 150 +`OUT.tmp` link is not written through; a failed rename leaves no `OUT.tmp`. 127 151 Negative controls: a mutant that skips the prev check accepts the edited ledger; a mutant that 128 -forgets what was recorded records lines twice; a mutant without the lost-lines rule exits 0. The 152 +forgets what was recorded records lines twice; a mutant without the lost-lines rule exits 0; a 153 +mutant without the verify rule writes a page for a damaged ledger; a mutant without the name guard 154 +replaces its own ledger with the page. The 129 155 gate refuses any compiler or `sha2.om` other than the pins (exit 2). 130 156 131 157 ## Not done 132 158 133 -- The ledger is not served from interplane.io yet: `feed` and its service exist, the forged route 134 - does not. 135 -- No outside time anchor yet beyond what publishing on Radicle will give. 159 +- The ledger and its page are not served from interplane.io yet: the files exist under 160 + `~/forge-data/proof/`, the forged routes (`/proof`, `/proof/board.tsv`, `/assets/proof.css`) do not. 161 +- No outside time anchor yet: publishing each head where it cannot be taken back is a later unit. 136 162 - A ledger line is at most 1,023 bytes. chain/chain.om @@ -2,7 +2,9 @@ note chain.om: the INTERPLANE ledger, a hash chain anyone can check. Composed af 2 2 note chain add LEDGER KIND ACTOR SUBJECT < payload append one record; prints "OK seq head" 3 3 note chain verify LEDGER prints "OK count head" or "BAD line N code" 4 4 note chain check LEDGER SEQ < payload the payload is the one record SEQ committed to 5 -note chain feed LEDGER FILE KIND ACTOR one record per new complete line of FILE 5 +note chain feed LEDGER FILE KIND ACTOR [PAGE] one record per new complete line of FILE; then 6 +note the page, when PAGE is given 7 +note chain page LEDGER OUT write OUT: the head as a page with the check by hand 6 8 note feed records line N of FILE with the subject " line N" and the SHA-256 of the line's 7 9 note bytes (without its line feed) as payload. It resumes after the highest N already recorded for 8 10 note that KIND and file name, so running it again adds only new lines. A last line without a line @@ -24,7 +26,10 @@ note BAD codes: 1 not seven fields, or a byte that is not a tab or printable ASC 24 26 note zero); 3 utc (a real date and time, never earlier than the record before); 4 payload digest; 25 27 note 5 prev; 6 line longer than 1,023 bytes; 7 last line has no line feed; 8 kind, actor or subject 26 28 note breaks its rule (kind 1..24 bytes of A-Z 0-9 _, actor 1..64 bytes, subject 1..128 bytes). 27 -note Commands are matched as whole words: add, verify, check, feed. 29 +note page verifies the ledger first and writes nothing when it does not verify (exit 2). OUT is 30 +note written as OUT.tmp (created exclusively) and renamed, so a reader never sees half a page. A 31 +note page name, or its .tmp, that is the ledger or the fed file is refused (exit 1). 32 +note Commands are matched as whole words: add, verify, check, feed, page. 28 33 global gl uchar 1024 29 34 global gll ulong 1 30 35 global gh uchar 64 @@ -47,6 +52,20 @@ text tver "verify" 47 52 text tchk "check" 48 53 text tfeed "feed" 49 54 text tline " line " 55 +text tpage "page" 56 +text ttmp ".tmp" 57 +text tnone "no records yet" 58 +text q01 "Check the record yourself - INTERPLANE
\n" 59 +text q02 "

Proof

Check the record yourself

\n

The agents that build INTERPLANE talk on one message board. Each line of that board is recorded here by its SHA-256 digest, and each record names the digest of the record before it. You do not need to trust this page, this site or its author. Download the ledger and check it with tools already on your machine.

\n
Records
" 60 +text q03 "
Last record (UTC)
" 61 +text q04 "
\n

The head

\n

The head is the SHA-256 of the ledger's last line. Change, remove, add or move any earlier record and the head changes.

\n
"

62 +text q05 "
\n

Check it by hand

\n

Get the ledger and compute its head. It must be the line above. Where there is no sha256sum (macOS), shasum -a 256 does the same.

\n
curl -s https://interplane.io/proof/board.tsv -o board.tsv\nprintf %s "$(tail -n 1 board.tsv)" | sha256sum
\n" 63 +text q06 "

Then check every link. Field 7 of each record must be the SHA-256 of the line above it.

\n
awk 'NR>1' board.tsv | cut -f7 > claimed\nsed '$d' board.tsv | while IFS= read -r line; do printf %s "$line" | sha256sum | cut -d' ' -f1; done > computed\ncmp claimed computed && echo chain intact
\n" 64 +text q07 "

Prove one message

\n

Only digests are public; the board itself is not. Whoever holds line N of the board, as it was when the line was recorded, can prove it is the line that was recorded: its SHA-256 is field 6 of the record whose subject is BOARD.md line N. Write the line number in place of N; the command reads the line from the file, so nothing in it needs quoting.

\n
printf %s "$(sed -n 'Np' BOARD.md)" | sha256sum
\n" 65 +text q08 "

What this proves, and what it does not

\n

Proved in Lean 4 with no axioms: two valid ledgers with the same head are the same ledger, unless SHA-256 gives one digest for two different lines. Nobody is known to be able to do that; it is assumed, not proved.

\n

Not proved by the chain alone: when a record was written, and who or what wrote a message. A ledger kept on one machine can be rebuilt by whoever holds it. Time comes from outside, from publishing each head where it cannot be taken back.

\n
\n" 66 +global gp uchar 16384 67 +global gpl ulong 1 68 +global go uchar 2100 50 69 note gs: 0 records accepted, 1 first BAD code, 2 its line number, 3 wanted seq, 4 wanted seq found, 51 70 note 5 feed mode, 6 highest source line already recorded for the fed kind and file name 52 71 note gx: the fed kind at 0 (length gxl 0), actor at 64 (gxl 1), file name at 192 (gxl 2) @@ -945,6 +964,12 @@ end 945 964 if not sarg 3 192 2 100 false 946 965 ret 1 947 966 end 967 +if eq argcnt 7 968 +pl = argread 6 ga 0 4095 969 +if or lt pl 1 gt pl 1000 970 +ret 1 971 +end 972 +end 948 973 m = argread 3 ga 0 4095 949 974 sf = int fopen ga 0 ulong m 0 0 950 975 if lt sf 0 @@ -961,6 +986,12 @@ r = fsame sf fd 961 986 if ne r 0 962 987 ret r 963 988 end 989 +if eq argcnt 7 990 +r = pprep 6 991 +if ne r 0 992 +ret r 993 +end 994 +end 964 995 put gs 5 1 965 996 put gs 6 0 966 997 if not vfy fd @@ -977,9 +1008,249 @@ end 977 1008 if ne r 0 978 1009 ret r 979 1010 end 1011 +if eq argcnt 7 1012 +pbuild 1013 +w = pfile 1014 +if ne w 0 1015 +ret w 1016 +end 1017 +end 980 1018 y = fclose fd 981 1019 ret say 982 1020 end 1021 +note ---- page 1022 +note pb: one byte into the page; a page that would pass 16,383 bytes is marked as over (gpl 16384) 1023 +note and pput refuses to write it, so it is never cut short in silence 1024 +fn pb c uchar to void 1025 +o = get gpl 0 1026 +if lt o 16383 1027 +put gp o c 1028 +put gpl 0 add o 1 1029 +else 1030 +put gpl 0 16384 1031 +end 1032 +end 1033 +note pt: a text of at most 4,096 bytes into the page 1034 +fn pt t view uchar * to void 1035 +n = len t 1036 +i = ulong 0 1037 +while lt i n bound 4096 1038 +pb get t i 1039 +i = add i 1 1040 +end 1041 +end 1042 +note pn: a count with its digits grouped in threes 1043 +fn pn v ulong to void 1044 +d = new uchar 20 0 1045 +n = ulong 0 1046 +x = v 1047 +if eq x 0 1048 +pb 48 1049 +end 1050 +while gt x 0 bound 20 1051 +put d n uchar add 48 rem x 10 1052 +x = div x 10 1053 +n = add n 1 1054 +end 1055 +while gt n 0 bound 20 1056 +n = sub n 1 1057 +pb get d n 1058 +if gt n 0 1059 +if eq rem n 3 0 1060 +pb 44 1061 +end 1062 +end 1063 +end 1064 +end 1065 +note pbuild: the page for the ledger just verified (gs 0 records, head in gh, last time in gu) 1066 +fn pbuild to void 1067 +put gpl 0 0 1068 +pt q01 1069 +pt q02 1070 +pn get gs 0 1071 +pt q03 1072 +if eq get gs 0 0 1073 +pt tnone 1074 +else 1075 +for i ulong 10 1076 +pb get gu i 1077 +end 1078 +pb 32 1079 +for j ulong 8 1080 +pb get gu add 11 j 1081 +end 1082 +end 1083 +pt q04 1084 +if eq get gs 0 0 1085 +pt tnone 1086 +else 1087 +for k ulong 64 1088 +pb get gh k 1089 +end 1090 +end 1091 +pt q05 1092 +pt q06 1093 +pt q07 1094 +pt q08 1095 +end 1096 +note pput: the page into the new file named go[0, n), mode 0644, created exclusively (O_WRONLY, 1097 +note O_CREAT, O_EXCL: never through a link, never into a file that is already there); true when all 1098 +note of it is written and synced 1099 +fn pput n ulong to bool 1100 +if gt get gpl 0 16383 1101 +ret false 1102 +end 1103 +fd = int fopen go 0 n 193 420 1104 +if lt fd 0 1105 +ret false 1106 +end 1107 +m = get gpl 0 1108 +o = ulong 0 1109 +good = true 1110 +while lt o m bound 16384 1111 +k = write fd gp o sub m o 1112 +if le k 0 1113 +good = false 1114 +o = m 1115 +else 1116 +o = add o ulong k 1117 +end 1118 +end 1119 +if ne fsync fd 0 1120 +good = false 1121 +end 1122 +r = fclose fd 1123 +ret good 1124 +end 1125 +note peq: the first 16 bytes of two stat records (st_dev, st_ino) are equal 1126 +fn peq a view uchar 128 b view uchar 128 to bool 1127 +for i ulong 16 1128 +if ne get a i get b i 1129 +ret false 1130 +end 1131 +end 1132 +ret true 1133 +end 1134 +note pid: s holds the lstat of a name; 1 when it is the entry or the file argument idx names (by 1135 +note lstat or by stat), 0 when not, 3 when argument idx cannot be read or does not exist 1136 +fn pid s view uchar 128 idx ulong to int 1137 +m = argread idx ga 0 4095 1138 +if lt m 1 1139 +ret 3 1140 +end 1141 +t = new uchar 128 0 1142 +if lt stat ga 0 ulong m t 0 128 0 1143 +ret 3 1144 +end 1145 +if peq s t 1146 +ret 1 1147 +end 1148 +if lt lstat ga 0 ulong m t 0 128 0 1149 +ret 3 1150 +end 1151 +if peq s t 1152 +ret 1 1153 +end 1154 +ret 0 1155 +end 1156 +note pguard: 0 when the name go[0, n) does not exist or is neither the ledger (argument 2) nor, in 1157 +note feed, the fed file (argument 3); otherwise the exit code. Renaming the page over the ledger, or 1158 +note removing a stale .tmp that is the ledger, would destroy it. 1159 +fn pguard n ulong to int 1160 +s = new uchar 128 0 1161 +if lt lstat go 0 n s 0 128 0 1162 +ret 0 1163 +end 1164 +r = pid s 2 1165 +if ne r 0 1166 +ret r 1167 +end 1168 +if eq argcnt 7 1169 +ret pid s 3 1170 +end 1171 +ret 0 1172 +end 1173 +note pprep: argument idx (1..1,000 bytes) into go as .tmp, its length in gs 7, and both names 1174 +note through pguard. Runs before anything is written. 0, or the exit code. 1175 +fn pprep idx ulong to int 1176 +n = argread idx ga 0 4095 1177 +if or lt n 1 gt n 1000 1178 +ret 1 1179 +end 1180 +l = ulong n 1181 +for i ulong l bound 1000 1182 +put go i get ga i 1183 +end 1184 +for j ulong 4 1185 +put go add l j get ttmp j 1186 +end 1187 +put gs 7 l 1188 +r = pguard l 1189 +if ne r 0 1190 +ret r 1191 +end 1192 +ret pguard add l 4 1193 +end 1194 +note pfile: the page built by pbuild into the name pprep prepared, written as .tmp and 1195 +note renamed. A stale .tmp is removed first (the name only, never what it points to); on any 1196 +note failure the .tmp is removed again. w holds the two names as the list renames takes: count 2, 1197 +note then each name as a 2-byte length and its bytes. 0, or the exit code. 1198 +fn pfile to int 1199 +l = get gs 7 1200 +t = add l 4 1201 +u = unlink go 0 t 1202 +if not pput t 1203 +u = unlink go 0 t 1204 +ret 3 1205 +end 1206 +w = new uchar 2100 0 1207 +put w 0 2 1208 +put w 1 0 1209 +put w 2 uchar rem t 256 1210 +put w 3 uchar div t 256 1211 +for a ulong t bound 1004 1212 +put w add 4 a get go a 1213 +end 1214 +b = add 4 t 1215 +put w b uchar rem l 256 1216 +put w add b 1 uchar div l 256 1217 +for c ulong l bound 1000 1218 +put w add add b 2 c get go c 1219 +end 1220 +if ne renames w 0 add add b 2 l 0 0 1221 +u = unlink go 0 t 1222 +ret 3 1223 +end 1224 +ret 0 1225 +end 1226 +fn cpage to int 1227 +fd = ropen 0 1228 +if lt fd 0 1229 +ret 3 1230 +end 1231 +note the same exclusive lock add and feed take: one page writer per ledger, and never mid-append 1232 +if ne flock fd 2 0 1233 +ret 3 1234 +end 1235 +p = pprep 3 1236 +if ne p 0 1237 +ret p 1238 +end 1239 +good = vfy fd 1240 +r = fclose fd 1241 +if not good 1242 +ret 3 1243 +end 1244 +if ne get gs 1 0 1245 +ret say 1246 +end 1247 +pbuild 1248 +w = pfile 1249 +if ne w 0 1250 +ret w 1251 +end 1252 +ret say 1253 +end 983 1254 fn main to int 984 1255 if lt argcnt 3 985 1256 ret 1 @@ -1003,10 +1274,16 @@ end 1003 1274 ret 1 1004 1275 end 1005 1276 if argis tfeed 1006 -if eq argcnt 6 1277 +if or eq argcnt 6 eq argcnt 7 1007 1278 ret cfeed 1008 1279 end 1009 1280 ret 1 1010 1281 end 1282 +if argis tpage 1283 +if eq argcnt 4 1284 +ret cpage 1285 +end 1286 +ret 1 1287 +end 1011 1288 ret 1 1012 1289 end chain/proof.css new file mode 100644 @@ -0,0 +1,14 @@ 1 +/* proof.css: the page `chain page` writes. Colours only through tokens.css. */ 2 +*{box-sizing:border-box} 3 +html,body{margin:0;background:var(--bg-primary);color:var(--text-primary);font:14px/20px var(--font-sans,Inter,system-ui,sans-serif)} 4 +main{max-width:880px;margin:0 auto;padding:32px 24px 56px} 5 +.eyebrow{margin:0 0 8px;font-size:12px;font-weight:600;letter-spacing:.2em;text-transform:uppercase;color:var(--accent)} 6 +h1{margin:0 0 12px;font-size:36px;line-height:40px;font-weight:700} 7 +h2{margin:32px 0 8px;font-size:18px;line-height:28px;font-weight:600} 8 +.sub{margin:0 0 16px;max-width:720px;color:var(--text-secondary)} 9 +.stats{display:grid;grid-template-columns:repeat(2,1fr);gap:16px;margin:0 0 16px} 10 +.stats div{padding:24px;border:1px solid var(--border);border-radius:16px;background:var(--bg-card)} 11 +.stats dt{font-size:12px;line-height:16px;color:var(--text-secondary)} 12 +.stats dd{margin:4px 0 0;font:600 24px/32px var(--font-mono,ui-monospace,monospace)} 13 +.cmd{margin:0 0 16px;padding:16px;border:1px solid var(--border);border-radius:16px;background:var(--bg-card);font:12px/20px var(--font-mono,ui-monospace,monospace);white-space:pre-wrap;overflow-wrap:anywhere} 14 +@media (max-width:720px){.stats{grid-template-columns:1fr}main{padding:24px 12px}h1{font-size:30px;line-height:36px}} chain/tests/run.sh @@ -245,6 +245,84 @@ if command -v strace >/dev/null 2>&1; then 245 245 else 246 246 no "strace is needed to count syncs" 247 247 fi 248 + 249 +# page: the head as a page anyone can check by hand; the check it prints must itself work 250 +awk 'BEGIN { for (i = 1; i <= 1234; i++) print "message " i }' >"$T/src/LONG.md" 251 +P=$T/page.tsv 252 +o=$("$T/chain" feed "$P" "$T/src/LONG.md" MSG hive-board "$T/page.html"); eq "feed with a page exit" "$?" 0 253 +HEADP=$(printf %s "$(tail -n 1 "$P")" | sha) 254 +eq "feed with a page prints the count and the head" "$o" "$(printf 'OK\t1234\t%s' "$HEADP")" 255 +eq "page shows the head sha256sum gives" "$(grep -c "
$HEADP
" "$T/page.html")" 1 256 +eq "page shows the count, digits grouped" "$(grep -c '
Records
1,234
' "$T/page.html")" 1 257 +eq "page shows the last record's time" "$(grep -c "
$(tail -n 1 "$P" | cut -f2 | tr 'T' ' ' | tr -d 'Z')
" "$T/page.html")" 1 258 +eq "page has no script and no inline style" "$(grep -ci '/dev/null; eq "page exit" "$?" 0 261 +if cmp -s "$T/page.html" "$T/page2.html"; then ok "page and feed write the same page"; else no "page and feed write the same page"; fi 262 +# the commands on the page, taken from the page: entity-decoded, the download replaced by a local copy 263 +cmds() { awk -v n="$1" 'BEGIN { RS = "
"; FS = "
" } NR == n + 1 { printf "%s\n", $1 }' "$T/page.html" | sed -e 's/"/"/g' -e 's/>/>/g' -e 's/</"$T/hand/head.sh" 268 +cmds 3 >"$T/hand/links.sh" 269 +eq "the page's head command gives the page's head" "$(cd "$T/hand" && sh head.sh | cut -d' ' -f1)" "$HEADP" 270 +eq "the page's link check passes on the ledger" "$(cd "$T/hand" && sh links.sh 2>/dev/null)" "chain intact" 271 +sed -i '600s/hive-board/hive-b0ard/' "$T/hand/board.tsv" 272 +eq "the page's link check fails on a ledger with one edited record" "$(cd "$T/hand" && sh links.sh 2>/dev/null | grep -c 'chain intact')" 0 273 +# the page's "prove one message" command, from the page, on a board line that typing it by hand 274 +# inside quotes would break: a quote, an apostrophe, parentheses, a dollar sign and a backquote 275 +BL='it'"'"'s "quoted" (a) $HOME `x` line' 276 +printf 'first line\n%s\nlast line\n' "$BL" >"$T/hand/BOARD.md" 277 +cmds 4 | sed 's/Np/2p/' >"$T/hand/one.sh" 278 +eq "the page's prove-one-message command gives the line's SHA-256" "$(cd "$T/hand" && sh one.sh 2>/dev/null | cut -d' ' -f1)" "$(printf %s "$BL" | sha256sum | cut -d' ' -f1)" 279 +eq "the page ends with and a line feed" "$(tail -c 8 "$T/page.html" | tr '\n' '|')" "|" 280 +"$T/chain" page "$T/d1" "$T/bad.html" >/dev/null; eq "page of a damaged ledger exits 2" "$?" 2 281 +eq "and writes no page" "$(ls "$T" | grep -c '^bad\.html')" 0 282 +: >"$T/empty.tsv" 283 +"$T/chain" page "$T/empty.tsv" "$T/empty.html" >/dev/null; eq "page of an empty ledger exit" "$?" 0 284 +eq "it says there are no records yet, twice" "$(grep -o 'no records yet' "$T/empty.html" | wc -l | tr -d ' ')" 2 285 +longp=$T/$(awk 'BEGIN { for (i = 0; i < 1001; i++) printf "p" }') 286 +cp "$P" "$T/page.before"; printf 'one more\n' >>"$T/src/LONG.md" 287 +"$T/chain" feed "$P" "$T/src/LONG.md" MSG hive-board "$longp" >/dev/null 2>&1; eq "feed with a page name over 1,000 bytes refused" "$?" 1 288 +if cmp -s "$P" "$T/page.before"; then ok "and it records nothing"; else no "and it records nothing"; fi 289 +"$T/chain" page "$P" >/dev/null 2>&1; eq "page without a name refused" "$?" 1 290 +"$T/chain" pagex "$P" "$T/x.html" >/dev/null 2>&1; eq "pagex refused" "$?" 1 291 +# the page never replaces the ledger or the fed file, never writes through a stale OUT.tmp, never leaves one 292 +cp "$P" "$T/same.tsv" 293 +"$T/chain" page "$T/same.tsv" "$T/same.tsv" >/dev/null 2>&1; eq "page named as its own ledger refused" "$?" 1 294 +if cmp -s "$P" "$T/same.tsv"; then ok "and the ledger is unchanged"; else no "and the ledger is unchanged"; fi 295 +cp "$P" "$T/sl.tmp" 296 +"$T/chain" page "$T/sl.tmp" "$T/sl" >/dev/null 2>&1; eq "page whose OUT.tmp is the ledger refused" "$?" 1 297 +if cmp -s "$P" "$T/sl.tmp"; then ok "and that ledger is unchanged"; else no "and that ledger is unchanged"; fi 298 +cp "$T/src/LONG.md" "$T/long.before" 299 +"$T/chain" feed "$P" "$T/src/LONG.md" MSG hive-board "$T/src/LONG.md" >/dev/null 2>&1; eq "feed with the fed file as the page refused" "$?" 1 300 +if cmp -s "$P" "$T/page.before" && cmp -s "$T/src/LONG.md" "$T/long.before"; then ok "and ledger and file are unchanged"; else no "and ledger and file are unchanged"; fi 301 +printf 'victim\n' >"$T/victim"; ln -s "$T/victim" "$T/lk.html.tmp" 302 +"$T/chain" page "$P" "$T/lk.html" >/dev/null 2>&1; eq "page over a stale OUT.tmp link exit" "$?" 0 303 +eq "it writes the page, not through the link" "$(cat "$T/victim")/$(cmp -s "$T/lk.html" "$T/page.html" && echo same)" "victim/same" 304 +mkdir "$T/dir.html" 305 +"$T/chain" page "$P" "$T/dir.html" >/dev/null 2>&1; eq "page onto a directory fails" "$?" 3 306 +eq "and leaves no OUT.tmp" "$(ls "$T" | grep -c '^dir\.html\.tmp$')" 0 307 +# negative control: without the name guard the page replaces its own ledger 308 +awk '{ if ($0 == "if lt lstat go 0 n s 0 128 0") print "if true"; else print }' "$C/chain.om" >"$T/gm.om" 309 +if cmp -s "$C/chain.om" "$T/gm.om"; then 310 + no "guard mutant differs from source" 311 +else 312 + build "$T/gm.om" "$T/gm" 313 + cp "$P" "$T/gm.tsv" 314 + "$T/gm" page "$T/gm.tsv" "$T/gm.tsv" >/dev/null 2>&1 315 + eq "mutant without the name guard replaces the ledger with the page" "$(grep -c '' "$T/gm.tsv")" 1 316 +fi 317 +# negative control: the page is written although the ledger does not verify 318 +awk '/^if ne get gs 1 0$/ { c++ } { l[NR] = $0 } END { for (i = 1; i <= NR; i++) { if (l[i] == "if ne get gs 1 0") { k++; if (k == c) { print "if false"; continue } } print l[i] } }' "$C/chain.om" >"$T/pm.om" 319 +if cmp -s "$C/chain.om" "$T/pm.om"; then 320 + no "page mutant differs from source" 321 +else 322 + build "$T/pm.om" "$T/pm" 323 + "$T/pm" page "$T/d1" "$T/pm.html" >/dev/null 2>&1 324 + eq "mutant without the verify rule writes a page for a damaged ledger" "$(ls "$T" | grep -c '^pm\.html$')" 1 325 +fi 248 326 LEAN=${LEAN:-$HOME/.elan/bin/lean} 249 327 if [ -x "$LEAN" ]; then 250 328 eq "Lean checks tamper_evident, no axioms" "$("$LEAN" "$C/Ledger.lean" 2>&1 | grep -c 'does not depend on any axioms')" 1 collab/co0form.om new file mode 100644 @@ -0,0 +1,205 @@ 1 +global gcfv uchar 65536 2 +global gcfvl ulong 1 3 +note Shared issue and preview form decoding and text validation. 4 +note cobfld t: decode field t into gcfv; its length, -1 when absent, -2 when over 65536 bytes 5 +fn cobfld t view uchar * to long 6 +n = get fbodyl 0 7 +i = ulong 0 8 +while lt i n bound 70000 9 +if cobfmat t i n 10 +ret cobfdec add add i len t 1 n 11 +end 12 +i = cobfnxt i n 13 +end 14 +ret -1 15 +end 16 +fn cobfmat t view uchar * i ulong n ulong to bool 17 +if gt add add i len t 1 n 18 +ret false 19 +end 20 +for k ulong len t bound 64 21 +if ne get fbody add i k get t k 22 +ret false 23 +end 24 +end 25 +ret eq get fbody add i len t 61 26 +end 27 +fn cobfnxt i ulong n ulong to ulong 28 +j = i 29 +while lt j n bound 70000 30 +if eq get fbody j 38 31 +ret add j 1 32 +end 33 +j = add j 1 34 +end 35 +ret n 36 +end 37 +fn cobfdec i ulong n ulong to long 38 +j = i 39 +o = ulong 0 40 +while lt j n bound 70000 41 +c = get fbody j 42 +if eq c 38 43 +break 44 +end 45 +if ge o 65536 46 +ret -2 47 +end 48 +j = add j 1 49 +if eq c 43 50 +c = uchar 32 51 +end 52 +if eq c 37 53 +c = cobpct j n 54 +if lt add j 1 n 55 +j = add j 2 56 +end 57 +end 58 +put gcfv o c 59 +o = add o 1 60 +end 61 +put gcfvl 0 o 62 +ret long o 63 +end 64 +fn cobpct j ulong n ulong to uchar 65 +if ge add j 1 n 66 +ret uchar 37 67 +end 68 +a = fhexv get fbody j 69 +b = fhexv get fbody add j 1 70 +if or lt a 0 lt b 0 71 +ret uchar 37 72 +end 73 +ret uchar add mul a 16 b 74 +end 75 +note ---- text checks on gcfv[0,n) 76 +note cotxtok n ml: CRLF and lone CR become LF; then the text must be UTF-8 without NUL or control 77 +note bytes (ml: tab and LF allowed; else none); trailing blanks and leading newlines are trimmed 78 +note (single line: leading blanks too). The cleaned length, or -1 when the text is refused. 79 +fn cotxtok n ulong ml bool to long 80 +m = cocrlf n 81 +if eq cowutf8 m ml false 82 +ret -1 83 +end 84 +e = m 85 +while gt e 0 bound 70000 86 +c = get gcfv sub e 1 87 +if and ne c 32 and ne c 9 ne c 10 88 +break 89 +end 90 +e = sub e 1 91 +end 92 +s = ulong 0 93 +while lt s e bound 70000 94 +c = get gcfv s 95 +if and ne c 10 or ml and ne c 32 ne c 9 96 +break 97 +end 98 +s = add s 1 99 +end 100 +if gt s 0 101 +for k ulong sub e s bound 70000 102 +put gcfv k get gcfv add s k 103 +end 104 +end 105 +ret long sub e s 106 +end 107 +fn cocrlf n ulong to ulong 108 +o = ulong 0 109 +for i ulong n bound 70000 110 +c = get gcfv i 111 +if eq c 13 112 +c = uchar 10 113 +if lt add i 1 n 114 +if eq get gcfv add i 1 10 115 +c = uchar 0 116 +end 117 +end 118 +end 119 +if ne c 0 120 +put gcfv o c 121 +o = add o 1 122 +else 123 +if ne get gcfv i 13 124 +put gcfv o c 125 +o = add o 1 126 +end 127 +end 128 +end 129 +ret o 130 +end 131 +note cowutf8 n ml: well-formed UTF-8 (no overlong forms, surrogates or code points over U+10FFFF), no 132 +note NUL, C0 control or DEL byte except tab and LF when ml 133 +fn cowutf8 n ulong ml bool to bool 134 +i = ulong 0 135 +while lt i n bound 70000 136 +c = get gcfv i 137 +if lt c 128 138 +if eq coctlok c ml false 139 +ret false 140 +end 141 +i = add i 1 142 +else 143 +k = coulen i n 144 +if eq k 0 145 +ret false 146 +end 147 +i = add i k 148 +end 149 +end 150 +ret true 151 +end 152 +fn coctlok c uchar ml bool to bool 153 +if eq c 127 154 +ret false 155 +end 156 +if ge c 32 157 +ret true 158 +end 159 +if and ml or eq c 9 eq c 10 160 +ret true 161 +end 162 +ret false 163 +end 164 +note coulen i n: byte length of the multi-byte sequence at gcfv[i], 0 when it is malformed 165 +fn coulen i ulong n ulong to ulong 166 +c = get gcfv i 167 +k = ulong 0 168 +lo = uchar 128 169 +hi = uchar 191 170 +if and ge c 194 le c 223 171 +k = ulong 2 172 +end 173 +if and ge c 224 le c 239 174 +k = ulong 3 175 +if eq c 224 176 +lo = uchar 160 177 +end 178 +if eq c 237 179 +hi = uchar 159 180 +end 181 +end 182 +if and ge c 240 le c 244 183 +k = ulong 4 184 +if eq c 240 185 +lo = uchar 144 186 +end 187 +if eq c 244 188 +hi = uchar 143 189 +end 190 +end 191 +if or eq k 0 gt add i k n 192 +ret ulong 0 193 +end 194 +d = get gcfv add i 1 195 +if or lt d lo gt d hi 196 +ret ulong 0 197 +end 198 +for j ulong sub k 2 bound 2 199 +d = get gcfv add add i 2 j 200 +if or lt d 128 gt d 191 201 +ret ulong 0 202 +end 203 +end 204 +ret k 205 +end collab/co2cob.om @@ -96,6 +96,8 @@ global gccn ulong 1 96 96 note model slots gcm: 0,1 title (pool off,len) 2 lifecycle (0 open 1 draft 2 archived/closed) 97 97 note 3,4 labels 5,6 assignees 7,8 close reason 9 kind (1 patch 2 issue) 10 actions not understood 98 98 global gcm ulong 16 99 +note gclfc: the change whose lifecycle action was applied last (the event stream, door/, names it) 100 +global gclfc ulong 1 99 101 note revisions: id, base, head oid, creating change, description (off,len), redacted, verdict line 100 102 global gcrv uchar 2560 101 103 global gcrb uchar 2560 @@ -623,6 +625,7 @@ end 623 625 note ---- load and replay 624 626 fn coreset to void 625 627 put gcov 0 0 628 +put gclfc 0 0 626 629 put gccn 0 0 627 630 put gcpl 0 0 628 631 put gcrn 0 0 @@ -851,6 +854,7 @@ coatitle a e 851 854 ret 852 855 end 853 856 if coseq t e tclife 857 +put gclfc 0 ci 854 858 coalife a e 855 859 ret 856 860 end @@ -897,6 +901,7 @@ coatitle a e 897 901 ret 898 902 end 899 903 if coseq t e tclife 904 +put gclfc 0 ci 900 905 coalife a e 901 906 ret 902 907 end collab/co3view.om @@ -334,8 +334,8 @@ text tclul "
    \n" 334 334 text tcluln "
\n" 335 335 text tclnone "

Nothing here in this state.

\n" 336 336 text tclcap "

Only the 200 most recently updated are listed.

\n" 337 -text tcpnote "

Patches are Radicle collaborative objects (xyz.radicle.patch), read from this repository's storage. Open one by pushing a branch with git push rad HEAD:refs/patches from a clone.

\n" 338 -text tcinote "

Issues are Radicle collaborative objects (xyz.radicle.issue), read from this repository's storage. Open one with rad issue open from a clone.

\n" 337 +text tcpnote "

Patches are stored in this repository and read from it. Opening a new patch from a clone is closed for now: Interplane does not accept pushes yet.

\n" 338 +text tcinote "

Issues are stored in this repository and read from it. Opening a new issue is closed for now: Interplane does not accept issues yet.

\n" 339 339 note cotab f s nm v: one filter link (kind in gcm 9); v is the query value 340 340 fn cotab f ulong s ulong nm view uchar * v view uchar * to void 341 341 kd = get gcm 9 collab/co9comp.om @@ -5,8 +5,6 @@ note session's CSRF token, the repo and a 128-bit random id (/dev/urandom); GET 5 5 note preview and the exact rad or git command the author runs in a clone, signing with their own key. 6 6 note Kinds: 1 issue comment, 2 patch comment, 3 patch review, 4 new issue, 5 new patch; 0 free slot. 7 7 text tcurnd "/dev/urandom" 8 -global gcfv uchar 65536 9 -global gcfvl ulong 1 10 8 global gczk ulong 32 11 9 global gczt ulong 32 12 10 global gczix ulong 32 @@ -25,209 +23,6 @@ global gcsti uchar 256 25 23 global gcstil ulong 1 26 24 global gcsf ulong 1 27 25 global gcsrv ulong 1 28 -note ---- form body fields (application/x-www-form-urlencoded, fbody up to 64 KiB) into gcfv 29 -note cobfld t: decode field t into gcfv; its length, -1 when absent, -2 when over 65536 bytes 30 -fn cobfld t view uchar * to long 31 -n = get fbodyl 0 32 -i = ulong 0 33 -while lt i n bound 70000 34 -if cobfmat t i n 35 -ret cobfdec add add i len t 1 n 36 -end 37 -i = cobfnxt i n 38 -end 39 -ret -1 40 -end 41 -fn cobfmat t view uchar * i ulong n ulong to bool 42 -if gt add add i len t 1 n 43 -ret false 44 -end 45 -for k ulong len t bound 64 46 -if ne get fbody add i k get t k 47 -ret false 48 -end 49 -end 50 -ret eq get fbody add i len t 61 51 -end 52 -fn cobfnxt i ulong n ulong to ulong 53 -j = i 54 -while lt j n bound 70000 55 -if eq get fbody j 38 56 -ret add j 1 57 -end 58 -j = add j 1 59 -end 60 -ret n 61 -end 62 -fn cobfdec i ulong n ulong to long 63 -j = i 64 -o = ulong 0 65 -while lt j n bound 70000 66 -c = get fbody j 67 -if eq c 38 68 -break 69 -end 70 -if ge o 65536 71 -ret -2 72 -end 73 -j = add j 1 74 -if eq c 43 75 -c = uchar 32 76 -end 77 -if eq c 37 78 -c = cobpct j n 79 -if lt add j 1 n 80 -j = add j 2 81 -end 82 -end 83 -put gcfv o c 84 -o = add o 1 85 -end 86 -put gcfvl 0 o 87 -ret long o 88 -end 89 -fn cobpct j ulong n ulong to uchar 90 -if ge add j 1 n 91 -ret uchar 37 92 -end 93 -a = fhexv get fbody j 94 -b = fhexv get fbody add j 1 95 -if or lt a 0 lt b 0 96 -ret uchar 37 97 -end 98 -ret uchar add mul a 16 b 99 -end 100 -note ---- text checks on gcfv[0,n) 101 -note cotxtok n ml: CRLF and lone CR become LF; then the text must be UTF-8 without NUL or control 102 -note bytes (ml: tab and LF allowed; else none); trailing blanks and leading newlines are trimmed 103 -note (single line: leading blanks too). The cleaned length, or -1 when the text is refused. 104 -fn cotxtok n ulong ml bool to long 105 -m = cocrlf n 106 -if eq cowutf8 m ml false 107 -ret -1 108 -end 109 -e = m 110 -while gt e 0 bound 70000 111 -c = get gcfv sub e 1 112 -if and ne c 32 and ne c 9 ne c 10 113 -break 114 -end 115 -e = sub e 1 116 -end 117 -s = ulong 0 118 -while lt s e bound 70000 119 -c = get gcfv s 120 -if and ne c 10 or ml and ne c 32 ne c 9 121 -break 122 -end 123 -s = add s 1 124 -end 125 -if gt s 0 126 -for k ulong sub e s bound 70000 127 -put gcfv k get gcfv add s k 128 -end 129 -end 130 -ret long sub e s 131 -end 132 -fn cocrlf n ulong to ulong 133 -o = ulong 0 134 -for i ulong n bound 70000 135 -c = get gcfv i 136 -if eq c 13 137 -c = uchar 10 138 -if lt add i 1 n 139 -if eq get gcfv add i 1 10 140 -c = uchar 0 141 -end 142 -end 143 -end 144 -if ne c 0 145 -put gcfv o c 146 -o = add o 1 147 -else 148 -if ne get gcfv i 13 149 -put gcfv o c 150 -o = add o 1 151 -end 152 -end 153 -end 154 -ret o 155 -end 156 -note cowutf8 n ml: well-formed UTF-8 (no overlong forms, surrogates or code points over U+10FFFF), no 157 -note NUL, C0 control or DEL byte except tab and LF when ml 158 -fn cowutf8 n ulong ml bool to bool 159 -i = ulong 0 160 -while lt i n bound 70000 161 -c = get gcfv i 162 -if lt c 128 163 -if eq coctlok c ml false 164 -ret false 165 -end 166 -i = add i 1 167 -else 168 -k = coulen i n 169 -if eq k 0 170 -ret false 171 -end 172 -i = add i k 173 -end 174 -end 175 -ret true 176 -end 177 -fn coctlok c uchar ml bool to bool 178 -if eq c 127 179 -ret false 180 -end 181 -if ge c 32 182 -ret true 183 -end 184 -if and ml or eq c 9 eq c 10 185 -ret true 186 -end 187 -ret false 188 -end 189 -note coulen i n: byte length of the multi-byte sequence at gcfv[i], 0 when it is malformed 190 -fn coulen i ulong n ulong to ulong 191 -c = get gcfv i 192 -k = ulong 0 193 -lo = uchar 128 194 -hi = uchar 191 195 -if and ge c 194 le c 223 196 -k = ulong 2 197 -end 198 -if and ge c 224 le c 239 199 -k = ulong 3 200 -if eq c 224 201 -lo = uchar 160 202 -end 203 -if eq c 237 204 -hi = uchar 159 205 -end 206 -end 207 -if and ge c 240 le c 244 208 -k = ulong 4 209 -if eq c 240 210 -lo = uchar 144 211 -end 212 -if eq c 244 213 -hi = uchar 143 214 -end 215 -end 216 -if or eq k 0 gt add i k n 217 -ret ulong 0 218 -end 219 -d = get gcfv add i 1 220 -if or lt d lo gt d hi 221 -ret ulong 0 222 -end 223 -for j ulong sub k 2 bound 2 224 -d = get gcfv add add i 2 j 225 -if or lt d 128 gt d 191 226 -ret ulong 0 227 -end 228 -end 229 -ret k 230 -end 231 26 note ---- slots 232 27 fn conow to ulong 233 28 ret div ulong realns `1000000000` collab/co9form.om @@ -33,7 +33,7 @@ text tcfsnp "New patch" 33 33 text tcfs2 "\n" 34 34 text tcfse "\n" 35 35 text tcsgn1 "

Sign in to prepare one. Sign in with your Radicle key

\n" 36 +text tcsgn2 "\">Sign in with your key

\n" 37 37 text tcfo1 "
\n\n" @@ -49,8 +49,8 @@ text tcfv1 "

\n" 50 50 text tcfdr "

\n" 51 51 text tcfsub "

\n
\n" 52 -text tcfexp "

The forge checks the text and gives you the command that publishes it, signed by your own Radicle key. It never writes to Radicle itself.

\n" 53 -text tcfexpp "

The forge never takes your commits. It checks the title and description and gives you the git push that opens the patch from your clone, signed by your own Radicle key.

\n" 52 +text tcfexp "

The forge checks the text and keeps a preview for this session. Publishing it is closed for now: Interplane does not accept comments, reviews or issues yet.

\n" 53 +text tcfexpp "

The forge never takes your commits. It checks the title and description and keeps a preview for this session. Opening a patch is closed for now: Interplane does not accept pushes yet.

\n" 54 54 text tcfnorev "

Every revision of this patch is redacted; there is nothing to comment on.

\n" 55 55 text tcnwl1 "

Prepare a new issue

\n" collab/co9page.om @@ -1,5 +1,5 @@ 1 1 note collab/co9page.om (ForgePatches): GET //compose/, the checked text with its preview and 2 -note the exact command, and GET compose//, the file that command reads. 2 +note the note that publishing is closed for now, and GET compose//, the checked text as a file. 3 3 text tcfnc "comment.md" 4 4 text tcfnr "review.md" 5 5 text tcfni "issue.md" @@ -16,39 +16,17 @@ text tcpkr ", revision " 16 16 text tcpkacc " (accept)" 17 17 text tcpkrej " (reject)" 18 18 text tcpkdr " (draft)" 19 -text tcpg2 "\n

The forge checked this text and keeps it for 15 minutes, for this session only. It wrote nothing: a Radicle change is signed by its author, so your own node signs and publishes it.

\n

Preview

\n" 19 +text tcpg2 "\n

The forge checked this text and keeps it for 15 minutes, for this session only. It wrote nothing to this repository.

\n

Preview

\n" 20 20 text tcpgt1 "

" 21 21 text tcpgt2 "

\n" 22 22 text tcpgnone "

No text.

\n" 23 23 text tcpg3 "

Publish it

\n
    \n" 24 24 text tcpgdl1 "
  1. Save " 26 -text tcpgdl3 " in a clone of this repository (rad clone rad:" 27 -text tcpgdl4 ").
  2. \n" 28 -text tcpgr1 "
  3. From that clone, in sh, bash or zsh, run:
    "
    
    29 -text tcpgr1p "
  4. From that clone, on the branch you propose, in sh, bash or zsh, run:
    "
    
    30 -text tcpgr2 "
  5. \n" 31 -text tcpge1 "
  6. Then set the full description, with the patch id that git push printed in place of PATCH_ID:
    "
    
    32 -text tcpgb1 "
  7. It shows here once this forge's node has fetched it from yours: back.
  8. \n
\n" 34 -text tccmrid " --repo rad:" 35 -text tccm1 "rad issue comment " 36 -text tccm2 "rad patch comment " 37 -text tccm3 "rad patch review " 38 -text tccm3r " --revision " 39 -text tccmacc " --accept" 40 -text tccmrej " --reject" 41 -text tccmmsg " --message=\"$(cat " 42 -text tccmend ")\"" 43 -text tccmnom " --no-message" 44 -text tccm4 "rad issue open" 45 -text tccm4t " --title=\"$(head -n 1 issue.md)\" --description=\"$(tail -n +3 issue.md)\"" 46 -text tccm5 "git push -o patch.message=\"$(head -n 1 patch.md)\"" 47 -text tccm5b " -o patch.message=\"$(tail -n +3 patch.md)\"" 48 -text tccm5d " -o patch.draft" 49 -text tccm5r " rad HEAD:refs/patches" 50 -text tccm6 "rad patch edit PATCH_ID" 51 -text tccm6m " --message=\"$(head -n 1 patch.md)\" --message=\"$(tail -n +3 patch.md)\"" 26 +text tcpgdl3 " to keep a copy.\n" 27 +text tcpgcl "
  • Publishing it is closed for now: Interplane does not accept comments, reviews, issues or patches yet.
  • \n" 28 +text tcpgb1 "
  • Back.
  • \n\n" 52 30 note cofneq kd a b: frest[a,b) is the file name of kind kd 53 31 fn cofneq kd ulong a ulong b ulong to bool 54 32 if or eq kd 1 eq kd 2 @@ -77,17 +55,7 @@ ret 77 55 end 78 56 fput tcfnp 79 57 end 80 -note cozbnl s: the body of slot s has a line break 81 -fn cozbnl s ulong to bool 82 -o = mul s 60000 83 -for k ulong get gczbl s bound 60000 84 -if eq get gczb add o k 10 85 -ret true 86 -end 87 -end 88 -ret false 89 -end 90 -note cocdlf s: the file the command reads: the body (comments, reviews), or the title, a blank line 58 +note cocdlf s: the downloaded file: the body (comments, reviews), or the title, a blank line 91 59 note and the description (new issues and patches) 92 60 fn cocdlf s ulong to long 93 61 kd = get gczk s @@ -162,7 +130,7 @@ end 162 130 comdz s 163 131 fput tcpg3 164 132 cocpdl s 165 -cocprun s 133 +fput tcpgcl 166 134 fput tcpgb1 167 135 cocpback s 168 136 fput tcpgb2 @@ -239,96 +207,6 @@ cofname get gczk s 239 207 fput tcpgdl2 240 208 cofname get gczk s 241 209 fput tcpgdl3 242 -fputrid get fridx 0 243 -fput tcpgdl4 244 -end 245 -fn cotg40 s ulong to void 246 -for k ulong 40 247 -fputc get gcztg add mul s 40 k 248 -end 249 -end 250 -fn corv40 s ulong to void 251 -for k ulong 40 252 -fputc get gczrv add mul s 40 k 253 -end 254 -end 255 -fn corepo to void 256 -fesc tccmrid 257 -fputrid get fridx 0 258 -end 259 -note cocprun s: the command step(s) 260 -fn cocprun s ulong to void 261 -kd = get gczk s 262 -if eq kd 5 263 -fput tcpgr1p 264 -else 265 -fput tcpgr1 266 -end 267 -if eq kd 1 268 -fesc tccm1 269 -cotg40 s 270 -corepo 271 -cocmsg s 272 -end 273 -if eq kd 2 274 -fesc tccm2 275 -corv40 s 276 -corepo 277 -cocmsg s 278 -end 279 -if eq kd 3 280 -cocrev s 281 -end 282 -if eq kd 4 283 -fesc tccm4 284 -corepo 285 -fesc tccm4t 286 -end 287 -if eq kd 5 288 -cocpush s 289 -end 290 -fput tcpgr2 291 -if and eq kd 5 cozbnl s 292 -fput tcpge1 293 -fesc tccm6 294 -corepo 295 -fesc tccm6m 296 -fput tcpgr2 297 -end 298 -end 299 -fn cocmsg s ulong to void 300 -fesc tccmmsg 301 -cofname get gczk s 302 -fesc tccmend 303 -end 304 -fn cocrev s ulong to void 305 -f = get gczf s 306 -fesc tccm3 307 -cotg40 s 308 -corepo 309 -fesc tccm3r 310 -corv40 s 311 -if eq f 1 312 -fesc tccmacc 313 -end 314 -if eq f 2 315 -fesc tccmrej 316 -end 317 -if eq get gczbl s 0 318 -fesc tccmnom 319 -else 320 -cocmsg s 321 -end 322 -end 323 -fn cocpush s ulong to void 324 -fesc tccm5 325 -if and gt get gczbl s 0 eq cozbnl s false 326 -fesc tccm5b 327 -end 328 -if eq and get gczf s 8 8 329 -fesc tccm5d 330 -end 331 -fesc tccm5r 332 210 end 333 211 note cocpback s: link back to the issue, the patch or the list 334 212 fn cocpback s ulong to void collab/native/helpers.om new file mode 100644 @@ -0,0 +1,256 @@ 1 +note HTML and JSON helpers shared by the imported issue views. 2 +global gcrq uchar 16 3 +global gcrql ulong 1 4 +text tcid "id" 5 +text tcdraft "draft" 6 +text tcarch "archived" 7 +text tcclosed "closed" 8 +global gcm ulong 16 9 +text tcah "" 11 +text tcae "" 12 +text tcissp "/issues/" 13 +text tcpats "/patches" 14 +text tcisss "/issues" 15 +text tcnot "(no title)" 16 +text tcmidd " · " 17 +text tcstq "?state=" 18 +text tcstn "state" 19 +text tcopen "open" 20 +text tcmerged "merged" 21 +text tcall "all" 22 +text tcsopen "Open" 23 +text tcsdraft "Draft" 24 +text tcsclos "Closed" 25 +text tcsmerg "Merged" 26 +text tcsarch "Archived" 27 +text tcsall "All" 28 +text tciss "Issues" 29 +text tcbon "" 30 +text tcboff "" 31 +text tcopar " (" 32 +text tccpar ")" 33 +global gcsn ulong 1 34 +global gccnt ulong 8 35 +text tcbok "" 36 +text tcbbad "" 37 +text tcbmut "" 38 +text tclh1 "

    " 39 +text tclh2 "

    \n

    " 40 +text tclh3 "

    \n" 41 +text tclul "
      \n" 42 +text tcluln "
    \n" 43 +text tclnone "

    Nothing here in this state.

    \n" 44 +text tcli1 "
  • " 46 +text tcli7 "

    " 47 +text tcli10 "
  • \n" 48 +text tcnwr "new" 49 +text tcjsis "forge/issues/1" 50 +text tcjsi "forge/issue/1" 51 +text tcjsts "states" 52 +text tcjcnt "count" 53 +text tcjpath "path" 54 +text tcjtr "truncated" 55 +text tcjisss "issues" 56 +text tcjtitl "title" 57 +text tcjauth "author" 58 +text tcjupd "updated" 59 +text tcjcoms "comments" 60 +text tcjverd "verdict" 61 +text tcjopen "opened" 62 +text tcjlabs "labels" 63 +text tcjasg "assignees" 64 +text tcjnum "number" 65 +text tcjred "redacted" 66 +text tcjtime "time" 67 +text tcjbody "body" 68 +text tcjreas "reason" 69 +text tcjtrvw "review" 70 +text tcjtcom "comment" 71 +fn cosp to void 72 +fputc 32 73 +end 74 +fn coqeq n long t view uchar * to bool 75 +if ne ulong n len t 76 +ret false 77 +end 78 +for i ulong len t 79 +if ne get fval i get t i 80 +ret false 81 +end 82 +end 83 +ret true 84 +end 85 +fn coqstate kd ulong to ulong 86 +n = fqget tcstn 87 +if lt n 0 88 +ret ulong 0 89 +end 90 +if coqeq n tcdraft 91 +ret ulong 1 92 +end 93 +if or coqeq n tcclosed coqeq n tcarch 94 +ret ulong 2 95 +end 96 +if coqeq n tcmerged 97 +ret ulong 3 98 +end 99 +if coqeq n tcall 100 +ret ulong 9 101 +end 102 +ret ulong 0 103 +end 104 +fn costname kd ulong s ulong to void 105 +if eq s 9 106 +fput tcsall 107 +ret 108 +end 109 +if eq s 0 110 +fput tcsopen 111 +ret 112 +end 113 +if eq s 1 114 +fput tcsdraft 115 +ret 116 +end 117 +if eq s 3 118 +fput tcsmerg 119 +ret 120 +end 121 +if eq kd 1 122 +fput tcsarch 123 +ret 124 +end 125 +fput tcsclos 126 +end 127 +fn costbadge kd ulong s ulong to void 128 +if or eq s 0 eq s 3 129 +fput tcbok 130 +else 131 +if eq s 1 132 +fput tcbmut 133 +else 134 +fput tcbbad 135 +end 136 +end 137 +costname kd s 138 +fput tcboff 139 +end 140 +fn cotab f ulong s ulong nm view uchar * v view uchar * to void 141 +kd = get gcm 9 142 +fput tcah 143 +fputrl 144 +if eq kd 1 145 +fput tcpats 146 +else 147 +fput tcisss 148 +end 149 +fput tcstq 150 +fput v 151 +fput tcqg 152 +if eq f s 153 +fput tcbon 154 +end 155 +fput nm 156 +fput tcopar 157 +cotabn kd s 158 +fput tccpar 159 +if eq f s 160 +fput tcboff 161 +end 162 +fput tcae 163 +cosp 164 +end 165 +fn cotabn kd ulong s ulong to void 166 +if eq s 9 167 +fnum get gcsn 0 168 +ret 169 +end 170 +fnum get gccnt s 171 +end 172 +fn cotabs kd ulong f ulong to void 173 +cotab f 0 tcsopen tcopen 174 +if eq kd 1 175 +cotab f 1 tcsdraft tcdraft 176 +cotab f 3 tcsmerg tcmerged 177 +cotab f 2 tcsarch tcarch 178 +else 179 +cotab f 2 tcsclos tcclosed 180 +end 181 +cotab f 9 tcsall tcall 182 +end 183 +fn codrefb to void 184 +i = get fridx 0 185 +o = get fabo i 186 +n = get fabl i 187 +for k ulong n bound 64 188 +put gbref k get fabr add o k 189 +end 190 +put gbrefl 0 n 191 +end 192 +fn cojq to void 193 +fputc 34 194 +end 195 +fn cojsn kd ulong s ulong to void 196 +cojq 197 +cojsv kd s 198 +cojq 199 +end 200 +fn cojsv kd ulong s ulong to void 201 +if eq s 9 202 +fput tcall 203 +end 204 +if eq s 0 205 +fput tcopen 206 +end 207 +if eq s 1 208 +fput tcdraft 209 +end 210 +if eq s 3 211 +fput tcmerged 212 +end 213 +if eq s 2 214 +if eq kd 1 215 +fput tcarch 216 +else 217 +fput tcclosed 218 +end 219 +end 220 +ret 221 +end 222 +fn cojtabs kd ulong to void 223 +fputc 91 224 +cojtab kd 0 false 225 +if eq kd 1 226 +cojtab kd 1 true 227 +cojtab kd 3 true 228 +cojtab kd 2 true 229 +else 230 +cojtab kd 2 true 231 +end 232 +cojtab kd 9 true 233 +fputc 93 234 +end 235 +fn cojtab kd ulong s ulong c bool to void 236 +if c 237 +fputc 44 238 +end 239 +fputc 123 240 +fyk0 tcstn 241 +cojsn kd s 242 +fyk tcjcnt 243 +cotabn kd s 244 +fyk tcjpath 245 +cojq 246 +fputrl 247 +if eq kd 1 248 +fput tcpats 249 +else 250 +fput tcisss 251 +end 252 +fput tcstq 253 +cojsv kd s 254 +cojq 255 +fputc 125 256 +end collab/native/issue.om new file mode 100644 @@ -0,0 +1,878 @@ 1 +note collab/co5iss.om: issues from the native issue store (GitHub import contract r1 G3; docs/API.md 2 +note forge/issues/1, forge/issue/1). The store is issues///: an index file of lines 3 +note "\n" (16 lowercase hex) and one folder per issue with title, description, status ("open\n" or 4 +note "closed\n"), labels (one per line), gh (number, login, opened, closed, reason lines), thread and 5 +note source.json for imports, or native metadata for web writes. Nothing here reads Radicle storage. 6 +note A native-comment record holds the author DID and form token before the length. 7 +note A thread is a run of records "

    " 42 +text tnph2 "

    \n" 43 +text tnclo " · closed " 44 +text tnreas " (reason " 45 +text tnlab "Labels: " 46 +text tnbox "

    " 47 +text tnwrote " wrote on " 48 +text tnrevd " reviewed (" 49 +text tnrevd2 ") on " 50 +text tnrcon " commented on " 51 +text tnline " line " 52 +text tnon " on " 53 +text tnsece "

    \n" 54 +text tnnocm "

    No comments.

    \n" 55 +text tnutc " UTC" 56 +text tntiss " - issue - " 57 +text tnmd1 "
    \n" 58 +text tnmd2 "
    \n" 59 +text tnpkey "page" 60 +text tnpp "per_page" 61 +text tnnext "next" 62 +text tnprev "prev" 63 +text tnpage "&page=" 64 +text tnpjson "&page=" 65 +text tnnava "\n" 67 +text tnpnext "Next" 68 +text tnpprev "Previous" 69 +const NIPAGE ulong 30 70 +const NIROWS ulong 262144 71 +const NILEG ulong 200 72 +global gnpage ulong 1 73 +global gnmatch ulong 1 74 +global gnpaged ulong 1 75 +note the index of the repository's store (17 bytes per id line) and its count 76 +global gnix uchar `4456448` 77 +global gnn ulong 1 78 +note one issue's thread file, a small file (title, gh, status, source.json) and its length 79 +global gnth uchar `16777216` 80 +global gnthl ulong 1 81 +global gnf uchar 65536 82 +global gnfl ulong 1 83 +global gngh uchar 65536 84 +global gnghl ulong 1 85 +global gnative ulong 1 86 +note a parsed thread record: kind (1 comment 2 review 3 review comment), time, login, state, line, 87 +note path and body as offsets and lengths into gnth 88 +global gnr ulong 16 89 + 90 +note ---- paths and reads 91 +fn nipath to void 92 +fpb 93 +fpt tfdata 94 +fpt tniss 95 +fpt tfowner 96 +fpc 47 97 +r = get fridx 0 98 +for i ulong get fanl r bound 128 99 +fpc frnbyte r i 100 +end 101 +fpc 47 102 +end 103 +fn nipf k ulong t view uchar * to void 104 +nipath 105 +for i ulong 16 106 +fpc get gnix add mul k 17 i 107 +end 108 +fpc 47 109 +fpt t 110 +end 111 +note niidx: the ids of the index into gnix (lines that are not 16 lowercase hex and a line feed are 112 +note left out); a missing index is an empty store. false when the index does not fit the table. 113 +fn niidx to bool 114 +put gnn 0 0 115 +nipath 116 +fpt tnindex 117 +r = frdall 118 +if lt r 0 119 +ret true 120 +end 121 +if ne get fxotr 0 0 122 +fincut 123 +ret false 124 +end 125 +n = div ulong r 17 126 +if gt n 262144 127 +fincut 128 +ret false 129 +end 130 +m = ulong 0 131 +for j ulong n bound 262144 132 +if niidok mul j 17 133 +nicp mul j 17 mul m 17 134 +m = add m 1 135 +end 136 +end 137 +put gnn 0 m 138 +ret true 139 +end 140 +fn nicp a ulong b ulong to void 141 +for i ulong 17 142 +put gnix add b i get fxo add a i 143 +end 144 +end 145 +fn niidok o ulong to bool 146 +for i ulong 16 147 +c = get fxo add o i 148 +if not or and ge c 48 le c 57 and ge c 97 le c 102 149 +ret false 150 +end 151 +end 152 +ret eq get fxo add o 16 10 153 +end 154 +note nismall k t: the file t of issue k into gnf (at most 65536 bytes are kept); its length 155 +fn nismall k ulong t view uchar * to ulong 156 +put gnfl 0 0 157 +nipf k t 158 +r = frdall 159 +if lt r 0 160 +ret 0 161 +end 162 +n = ulong r 163 +if gt n 65536 164 +n = ulong 65536 165 +end 166 +for i ulong n bound 65536 167 +put gnf i get fxo i 168 +end 169 +put gnfl 0 n 170 +ret n 171 +end 172 +note nistate k: 0 open, 2 closed (the states of costbadge 2) 173 +fn nistate k ulong to ulong 174 +n = nismall k tnfsts 175 +if and eq n 5 eq get gnf 0 111 176 +ret 0 177 +end 178 +ret 2 179 +end 180 +note nigh k: the gh file of issue k into gngh 181 +fn nigh k ulong to void 182 +n = nismall k tniwnat 183 +put gnative 0 0 184 +if eq n 0 185 +n = nismall k tnfgh 186 +else 187 +put gnative 0 1 188 +end 189 +for i ulong n bound 65536 190 +put gngh i get gnf i 191 +end 192 +put gnghl 0 n 193 +end 194 +note nighv t: the value of the gh line "\n": its offset in gngh; its length in gnr 15 195 +fn nighv t view uchar * to ulong 196 +n = get gnghl 0 197 +s = ulong 0 198 +for i ulong n bound 65536 199 +if eq get gngh i 10 200 +if nighat s i t 201 +put gnr 15 sub sub i s len t 202 +ret add s len t 203 +end 204 +s = add i 1 205 +end 206 +end 207 +put gnr 15 0 208 +ret 0 209 +end 210 +fn nighat s ulong e ulong t view uchar * to bool 211 +if lt sub e s len t 212 +ret false 213 +end 214 +for i ulong len t bound 16 215 +if ne get gngh add s i get t i 216 +ret false 217 +end 218 +end 219 +ret true 220 +end 221 +note nighp t: the gh value t, HTML-escaped 222 +fn nighp t view uchar * to void 223 +o = nighv t 224 +for i ulong get gnr 15 bound 65536 225 +fescc get gngh add o i 226 +end 227 +end 228 +note nijv t: in gnf (a source.json), the string value after t (plain names), HTML-escaped 229 +fn nijv t view uchar * to void 230 +n = get gnfl 0 231 +for s ulong n bound 65536 232 +if nijat s t 233 +p = add s len t 234 +while lt p n bound 65536 235 +c = get gnf p 236 +if eq c 34 237 +ret 238 +end 239 +fescc c 240 +p = add p 1 241 +end 242 +ret 243 +end 244 +end 245 +end 246 +fn nijat s ulong t view uchar * to bool 247 +if gt add s len t get gnfl 0 248 +ret false 249 +end 250 +for i ulong len t bound 16 251 +if ne get gnf add s i get t i 252 +ret false 253 +end 254 +end 255 +ret true 256 +end 257 +note nithr k: the thread of issue k into gnth; false when it does not fit 258 +fn nithr k ulong to bool 259 +put gnthl 0 0 260 +nipf k tnfthr 261 +r = frdall 262 +if lt r 0 263 +ret true 264 +end 265 +if ne get fxotr 0 0 266 +ret false 267 +end 268 +for i ulong ulong r bound `16777216` 269 +put gnth i get fxo i 270 +end 271 +put gnthl 0 ulong r 272 +ret true 273 +end 274 + 275 +note ---- thread records 276 +global gnbad ulong 1 277 +global gncur ulong 1 278 +fn niword a ulong to void 279 +put gnr add a 1 0 280 +if ne get gnbad 0 0 281 +ret 282 +end 283 +p = get gncur 0 284 +n = get gnthl 0 285 +q = p 286 +while lt q n bound 257 287 +if le get gnth q 32 288 +break 289 +end 290 +if ge sub q p 256 291 +put gnbad 0 1 292 +ret 293 +end 294 +q = add q 1 295 +end 296 +if or ge q n eq q p 297 +put gnbad 0 1 298 +ret 299 +end 300 +if ne get gnth q 32 301 +put gnbad 0 1 302 +ret 303 +end 304 +put gnr a p 305 +put gnr add a 1 sub q p 306 +put gncur 0 add q 1 307 +end 308 +note nidec t: the decimal at gncur (1..18 digits) ended by the byte t; gncur moves past t. gnbad is 309 +note set when it is not one. At most 19 passes: the pass that sees an 19th digit returns. 310 +fn nidec t uchar to ulong 311 +if ne get gnbad 0 0 312 +ret 0 313 +end 314 +p = get gncur 0 315 +n = get gnthl 0 316 +v = ulong 0 317 +k = ulong 0 318 +while lt p n bound 19 319 +c = get gnth p 320 +if not fisdig c 321 +break 322 +end 323 +if ge k 18 324 +put gnbad 0 1 325 +ret 0 326 +end 327 +v = add mul v 10 ulong sub c 48 328 +k = add k 1 329 +p = add p 1 330 +end 331 +if or eq k 0 ge p n 332 +put gnbad 0 1 333 +ret 0 334 +end 335 +if ne get gnth p t 336 +put gnbad 0 1 337 +ret 0 338 +end 339 +put gncur 0 add p 1 340 +ret v 341 +end 342 +note niwordis a t: the word of gnr a, a+1 is t 343 +fn niwordis a ulong t view uchar * to bool 344 +if ne get gnr add a 1 len t 345 +ret false 346 +end 347 +o = get gnr a 348 +for i ulong len t bound 16 349 +if ne get gnth add o i get t i 350 +ret false 351 +end 352 +end 353 +ret true 354 +end 355 +note nikind: the record kind of the word in gnr 12, 13: 1 comment, 2 review, 3 review-comment, else 0 356 +fn nikind to ulong 357 +if niwordis 12 tnrcom 358 +ret 1 359 +end 360 +if niwordis 12 tniwncom 361 +ret 4 362 +end 363 +if niwordis 12 tnrrev 364 +ret 2 365 +end 366 +if niwordis 12 tnrrc 367 +ret 3 368 +end 369 +ret 0 370 +end 371 +note nitok: the time word (gnr 1, 2) is 20 bytes or "-" 372 +fn nitok to bool 373 +k = get gnr 2 374 +if eq k 20 375 +ret true 376 +end 377 +if ne k 1 378 +ret false 379 +end 380 +ret eq get gnth get gnr 1 45 381 +end 382 +note nirec p: parse the record at p into gnr (0 kind, 1-2 time, 3-4 login, 5-6 state, 7 line, 8-9 383 +note path, 10-11 body); the index after it. A malformed record leaves kind 0 and returns the thread's 384 +note length, which stops the caller: every length is checked against the thread before the bytes it 385 +note names are read (a path is at most 4096 bytes). 386 +fn nirec p ulong to ulong 387 +n = get gnthl 0 388 +put gnr 0 0 389 +put gnr 6 0 390 +put gnr 7 0 391 +put gnr 9 0 392 +put gnbad 0 0 393 +put gncur 0 p 394 +niword 12 395 +k = nikind 396 +if eq k 0 397 +ret n 398 +end 399 +niword 1 400 +niword 3 401 +if or eq k 2 eq k 4 402 +niword 5 403 +end 404 +if eq k 3 405 +put gnr 7 nidec 32 406 +put gnr 9 nidec 32 407 +end 408 +b = nidec 10 409 +if ne get gnbad 0 0 410 +ret n 411 +end 412 +if not nitok 413 +ret n 414 +end 415 +q = get gncur 0 416 +if eq k 3 417 +m = get gnr 9 418 +if or gt m 4096 ge add q m n 419 +ret n 420 +end 421 +if ne get gnth add q m 10 422 +ret n 423 +end 424 +put gnr 8 q 425 +q = add add q m 1 426 +end 427 +if ge add q b n 428 +ret n 429 +end 430 +if ne get gnth add q b 10 431 +ret n 432 +end 433 +put gnr 10 q 434 +put gnr 11 b 435 +put gnr 0 k 436 +ret add add q b 1 437 +end 438 +note nicount: the records of the loaded thread 439 +fn nicount to ulong 440 +p = ulong 0 441 +c = ulong 0 442 +n = get gnthl 0 443 +while lt p n bound `16777216` 444 +p = nirec p 445 +if ne get gnr 0 0 446 +c = add c 1 447 +end 448 +end 449 +ret c 450 +end 451 +note nitime o: the ISO time gnth[o, o+20) as YYYY-MM-DD HH:MM UTC 452 +fn nitime o ulong to void 453 +for i ulong 10 454 +fescc get gnth add o i 455 +end 456 +fputc 32 457 +for i ulong 5 458 +fescc get gnth add add o 11 i 459 +end 460 +fput tnutc 461 +end 462 +note nighte t: the gh time value t as YYYY-MM-DD HH:MM UTC ("-" stays "-") 463 +fn nighte t view uchar * to void 464 +o = nighv t 465 +if ne get gnr 15 20 466 +fputc 45 467 +ret 468 +end 469 +for i ulong 10 470 +fescc get gngh add o i 471 +end 472 +fputc 32 473 +for i ulong 5 474 +fescc get gngh add add o 11 i 475 +end 476 +fput tnutc 477 +end 478 + 479 +note ---- the provenance line: Imported from GitHub /#, by (plain text) 480 +fn niprov k ulong to void 481 +x = nismall k tnfsrc 482 +fput tnimp1 483 +nijv tnjow 484 +fputc 47 485 +nijv tnjrp 486 +fputc 35 487 +nighp tnghn 488 +fput tnimp2 489 +nighp tnghl 490 +end 491 +fn niwho to void 492 +if eq get gnative 0 1 493 +nighp tniwdid 494 +else 495 +nighp tnghl 496 +end 497 +end 498 +fn niorigin k ulong to void 499 +if eq get gnative 0 1 500 +niwho 501 +else 502 +niprov k 503 +end 504 +end 505 +note niref: the request's id prefix (gcrq, 4..16 hex) names exactly one issue: its index, else gnn 506 +fn niref to ulong 507 +n = get gnn 0 508 +q = get gcrql 0 509 +if gt q 16 510 +ret n 511 +end 512 +w = n 513 +c = ulong 0 514 +for k ulong n bound 262144 515 +if nipre k q 516 +w = k 517 +c = add c 1 518 +end 519 +end 520 +if ne c 1 521 +ret n 522 +end 523 +ret w 524 +end 525 +fn nipre k ulong q ulong to bool 526 +for i ulong q bound 16 527 +if ne get gnix add mul k 17 i get gcrq i 528 +ret false 529 +end 530 +end 531 +ret true 532 +end 533 +fn nilink k ulong to void 534 +fputrl 535 +fput tcissp 536 +for i ulong 16 537 +fputc get gnix add mul k 17 i 538 +end 539 +end 540 + 541 +note ---- the list page 542 +note nifilt: the ?state= filter (0 open, 2 closed, 9 all; anything else open) and the tab counts in 543 +note gccnt and gcsn (cotabs reads them) 544 +fn nifilt to ulong 545 +f = coqstate 2 546 +if and ne f 2 ne f 9 547 +f = ulong 0 548 +end 549 +for s ulong 8 550 +put gccnt s 0 551 +end 552 +for k ulong get gnn 0 bound 262144 553 +s = nistate k 554 +put gccnt s add get gccnt s 1 555 +end 556 +put gcsn 0 get gnn 0 557 +put gcm 9 2 558 +ret f 559 +end 560 +note Keep list thread reads to one page. The status scan also supplies the filter counts. 561 +fn nipagen f ulong to void 562 +n = fqget tnpkey 563 +put gnpaged 0 0 564 +if ge n 0 565 +put gnpaged 0 1 566 +end 567 +v = ulong 0 568 +if and gt n 0 le n 6 569 +for i ulong ulong n bound 6 570 +c = get fval i 571 +if not fisdig c 572 +v = ulong 0 573 +break 574 +end 575 +v = add mul v 10 ulong sub c 48 576 +end 577 +end 578 +if eq v 0 579 +v = ulong 1 580 +end 581 +put gnpage 0 v 582 +put gnmatch 0 cotabnval f 583 +end 584 +fn cotabnval s ulong to ulong 585 +if eq s 9 586 +ret get gcsn 0 587 +end 588 +ret get gccnt s 589 +end 590 +fn nipageurl f ulong p ulong html bool to void 591 +fputrl 592 +fput tcisss 593 +fput tcstq 594 +cojsv 2 f 595 +if html 596 +fput tnpage 597 +else 598 +fput tnpjson 599 +end 600 +fnum p 601 +end 602 +fn nilnav f ulong to void 603 +p = get gnpage 0 604 +if and eq p 1 le get gnmatch 0 NIPAGE 605 +ret 606 +end 607 +fput tnnava 608 +if gt p 1 609 +fput tcah 610 +nipageurl f sub p 1 true 611 +fput tcqg 612 +fput tnpprev 613 +fput tcae 614 +cosp 615 +end 616 +if gt get gnmatch 0 mul p NIPAGE 617 +fput tcah 618 +nipageurl f add p 1 true 619 +fput tcqg 620 +fput tnpnext 621 +fput tcae 622 +end 623 +fput tnnavz 624 +end 625 +fn nilist to long 626 +if not niidx 627 +ret 500 628 +end 629 +f = nifilt 630 +nipagen f 631 +fsetti tciss 632 +frepohd 6 633 +ftic 32 634 +ftirepo 635 +fput tclh1 636 +costname 2 f 637 +fput tclh2 638 +cotabs 2 f 639 +fput tclh3 640 +niwlink 641 +m = ulong 0 642 +fput tclul 643 +skip = mul sub get gnpage 0 1 NIPAGE 644 +for j ulong get gnn 0 bound 262144 645 +k = sub sub get gnn 0 1 j 646 +s = nistate k 647 +if or eq f 9 eq f s 648 +if ge m skip 649 +if not nirow k s 650 +ret 500 651 +end 652 +end 653 +m = add m 1 654 +if eq m add skip NIPAGE 655 +break 656 +end 657 +end 658 +end 659 +fput tcluln 660 +if le m skip 661 +fput tclnone 662 +end 663 +nilnav f 664 +ret 200 665 +end 666 +fn nirow k ulong s ulong to bool 667 +fput tcli1 668 +nilink k 669 +fput tcqg 670 +n = nismall k tnfttl 671 +if eq n 0 672 +fput tcnot 673 +end 674 +for i ulong n bound 65536 675 +fescc get gnf i 676 +end 677 +fput tcli2 678 +costbadge 2 s 679 +nigh k 680 +if eq get gnative 0 0 681 +fput tnli3 682 +nighp tnghn 683 +fput tnli4 684 +nighte tnghop 685 +else 686 +fput tnmeta 687 +fput tcopen 688 +cosp 689 +nighte tnghop 690 +end 691 +fput tcmidd 692 +if not nithr k 693 +ret false 694 +end 695 +c = nicount 696 +fnum c 697 +fput tnli5 698 +if ne c 1 699 +fputc 115 700 +end 701 +fput tcli7 702 +fput tnmeta 703 +niorigin k 704 +fput tnmetae 705 +fput tcli10 706 +ret true 707 +end 708 + 709 +note ---- one issue page 710 +fn nipage to long 711 +if not niidx 712 +ret 500 713 +end 714 +k = niref 715 +if ge k get gnn 0 716 +ret 404 717 +end 718 +s = nistate k 719 +n = nismall k tnfttl 720 +put ftil 0 0 721 +for i ulong hmin n 256 bound 256 722 +ftic get gnf i 723 +end 724 +for i ulong len tntiss 725 +ftic get tntiss i 726 +end 727 +ftirepo 728 +frepohd 6 729 +fput tnph1 730 +if eq n 0 731 +fput tcnot 732 +end 733 +for i ulong n bound 65536 734 +fescc get gnf i 735 +end 736 +fput tnph2 737 +nigh k 738 +fput tnmeta 739 +costbadge 2 s 740 +fput tcmidd 741 +if eq get gnative 0 0 742 +fputc 35 743 +nighp tnghn 744 +fput tcmidd 745 +end 746 +fput tcopen 747 +cosp 748 +nighte tnghop 749 +if eq s 2 750 +fput tnclo 751 +nighte tnghcl 752 +x = nighv tnghre 753 +if gt get gnr 15 1 754 +fput tnreas 755 +nighp tnghre 756 +fputc 41 757 +end 758 +end 759 +fput tnmetae 760 +fput tnmeta 761 +niorigin k 762 +fput tnmetae 763 +nilabs k 764 +fput tnsece 765 +if not nibody k 766 +ret 500 767 +end 768 +if not nithr k 769 +ret 500 770 +end 771 +nicoms 772 +niwform k false 773 +ret 200 774 +end 775 +fn nilabs k ulong to void 776 +n = nismall k tnflab 777 +if eq n 0 778 +ret 779 +end 780 +fput tnmeta 781 +fput tnlab 782 +for i ulong n bound 65536 783 +c = get gnf i 784 +if eq c 10 785 +if lt add i 1 n 786 +fputc 44 787 +fputc 32 788 +end 789 +else 790 +fescc c 791 +end 792 +end 793 +fput tnmetae 794 +end 795 +note nibody k: the description as Markdown (the default branch for relative links) 796 +fn nibody k ulong to bool 797 +nipf k tnfdsc 798 +r = frdall 799 +if le r 0 800 +ret true 801 +end 802 +if ne get fxotr 0 0 803 +ret false 804 +end 805 +codrefb 806 +fput tnbox 807 +niwho 808 +fput tnwrote 809 +nighte tnghop 810 +fput tnmetae 811 +put gbmdl 0 0 812 +fput tnmd1 813 +brmd 0 ulong r 814 +fput tnmd2 815 +fput tnsece 816 +ret true 817 +end 818 +fn nicoms to void 819 +p = ulong 0 820 +c = ulong 0 821 +n = get gnthl 0 822 +while lt p n bound `16777216` 823 +p = nirec p 824 +if ne get gnr 0 0 825 +nicom 826 +c = add c 1 827 +end 828 +end 829 +if eq c 0 830 +fput tnnocm 831 +end 832 +end 833 +note nicom: the parsed record (gnr) as a comment box; the login is text, the body Markdown 834 +fn nicom to void 835 +k = get gnr 0 836 +fput tnbox 837 +niraw 3 838 +if or eq k 1 eq k 4 839 +fput tnwrote 840 +end 841 +if eq k 2 842 +fput tnrevd 843 +niraw 5 844 +fput tnrevd2 845 +end 846 +if eq k 3 847 +fput tnrcon 848 +niraw 8 849 +fput tnline 850 +fnum get gnr 7 851 +fput tnon 852 +end 853 +if eq get gnr 2 20 854 +nitime get gnr 1 855 +else 856 +fputc 45 857 +end 858 +fput tnmetae 859 +o = get gnr 10 860 +b = get gnr 11 861 +if gt b 0 862 +for i ulong b bound `16777216` 863 +put fxo i get gnth add o i 864 +end 865 +put gbmdl 0 0 866 +fput tnmd1 867 +brmd 0 b 868 +fput tnmd2 869 +end 870 +fput tnsece 871 +end 872 +note niraw a: the bytes gnth[gnr a, + gnr a+1), HTML-escaped 873 +fn niraw a ulong to void 874 +o = get gnr a 875 +for i ulong get gnr add a 1 bound `16777216` 876 +fescc get gnth add o i 877 +end 878 +end collab/native/json.om new file mode 100644 @@ -0,0 +1,447 @@ 1 +note ---- issues of the native store (collab/co5iss.om): forge/issues/1 and forge/issue/1. An imported 2 +note issue has "author": null and an "imported" object naming its GitHub source and login (plain data, 3 +note never an account or a DID of this forge); the first comment is the issue body, as on the page. 4 +text tnjimp "imported" 5 +text tnjdid "did" 6 +text tnjnm "name" 7 +text tnjfrom "from" 8 +text tnjgh "github" 9 +text tnjown "owner" 10 +text tnjrepo "repo" 11 +text tnjurl "url" 12 +text tnjlog "login" 13 +text tnjkind "kind" 14 +text tnjclos "closed" 15 +text tnjline "line" 16 +text tnjurlk "\"url\":\"" 17 +fn nijlist to long 18 +if not niidx 19 +ret 500 20 +end 21 +f = nifilt 22 +nipagen f 23 +fyrhead tcjsis 24 +fyk tcstn 25 +cojsn 2 f 26 +fyk tcjsts 27 +cojtabs 2 28 +fyk tcjtr 29 +paged = ne get gnpaged 0 0 30 +fybool and not paged gt get gnmatch 0 NILEG 31 +if paged 32 +fyk tnpkey 33 +fnum get gnpage 0 34 +fyk tnpp 35 +fnum NIPAGE 36 +nijnav f 37 +end 38 +fyk tcjisss 39 +fputc 91 40 +if not nijrows f paged 41 +ret 500 42 +end 43 +fputc 93 44 +fyk tcnwr 45 +niwnewjson 46 +fputc 10 47 +fyend 48 +ret 200 49 +end 50 +fn nijrows f ulong paged bool to bool 51 +m = ulong 0 52 +skip = ulong 0 53 +count = NILEG 54 +if paged 55 +skip = mul sub get gnpage 0 1 NIPAGE 56 +count = NIPAGE 57 +end 58 +n = get gnn 0 59 +for j ulong n bound NIROWS 60 +k = j 61 +if paged 62 +k = sub sub n 1 j 63 +end 64 +s = nistate k 65 +if or eq f 9 eq f s 66 +if ge m skip 67 +if gt m skip 68 +fputc 44 69 +end 70 +fputc 10 71 +if not nijrow k s 72 +ret false 73 +end 74 +end 75 +m = add m 1 76 +if eq m add skip count 77 +break 78 +end 79 +end 80 +end 81 +ret true 82 +end 83 +fn nijnav f ulong to void 84 +p = get gnpage 0 85 +fyk tnprev 86 +if gt p 1 87 +cojq 88 +nipageurl f sub p 1 false 89 +cojq 90 +else 91 +fynull 92 +end 93 +fyk tnnext 94 +if gt get gnmatch 0 mul p NIPAGE 95 +cojq 96 +nipageurl f add p 1 false 97 +cojq 98 +else 99 +fynull 100 +end 101 +end 102 +fn nijid k ulong to void 103 +cojq 104 +for i ulong 16 105 +fputc get gnix add mul k 17 i 106 +end 107 +cojq 108 +end 109 +fn nijtitle k ulong to void 110 +n = nismall k tnfttl 111 +fjtb 112 +for i ulong n bound 65536 113 +fjtc get gnf i 114 +end 115 +fjstr 116 +end 117 +fn nijrow k ulong s ulong to bool 118 +fputc 123 119 +fyk0 tcid 120 +nijid k 121 +fyk tcjtitl 122 +nijtitle k 123 +fyk tcstn 124 +cojsn 2 s 125 +nigh k 126 +fyk tcjauth 127 +nijauthor 128 +nijimp k 129 +if not nithr k 130 +ret false 131 +end 132 +fyk tcjupd 133 +nijupd 134 +fyk tcjcoms 135 +fnum nicount 136 +fyk tcjverd 137 +fynull 138 +fyk tcjpath 139 +cojq 140 +nilink k 141 +cojq 142 +fputc 125 143 +ret true 144 +end 145 +fn nijauthor to void 146 +if eq get gnative 0 0 147 +fynull 148 +ret 149 +end 150 +fputc 123 151 +fyk0 tnjdid 152 +nijgh tniwdid 153 +fyk tnjnm 154 +fynull 155 +fputc 125 156 +end 157 +note nijgh t: the gh value t as a JSON string (null when "-" or absent) 158 +fn nijgh t view uchar * to void 159 +o = nighv t 160 +n = get gnr 15 161 +if or eq n 0 and eq n 1 eq get gngh o 45 162 +fynull 163 +ret 164 +end 165 +fjtb 166 +for i ulong n bound 65536 167 +fjtc get gngh add o i 168 +end 169 +fjstr 170 +end 171 +note nijsv t: in gnf (a source.json), the string value after t as a JSON string 172 +fn nijsv t view uchar * to void 173 +fjtb 174 +n = get gnfl 0 175 +for s ulong n bound 65536 176 +if nijat s t 177 +p = add s len t 178 +while lt p n bound 65536 179 +c = get gnf p 180 +if eq c 34 181 +break 182 +end 183 +fjtc c 184 +p = add p 1 185 +end 186 +break 187 +end 188 +end 189 +fjstr 190 +end 191 +note nighnum: imported issue number as a bounded decimal; invalid or missing is zero 192 +fn nighnum to ulong 193 +o = nighv tnghn 194 +n = get gnr 15 195 +if gt n 18 196 +ret 0 197 +end 198 +v = ulong 0 199 +for i ulong n bound 18 200 +c = get gngh add o i 201 +if not fisdig c 202 +ret 0 203 +end 204 +v = add mul v 10 ulong sub c 48 205 +end 206 +ret v 207 +end 208 +note nijimp k: ,"imported":{"from":"github","owner","repo","number","url","login"} (gh must be loaded) 209 +fn nijimp k ulong to void 210 +x = nismall k tnfsrc 211 +fyk tnjimp 212 +if eq get gnative 0 1 213 +fynull 214 +ret 215 +end 216 +fputc 123 217 +fyk0 tnjfrom 218 +fysv tnjgh 219 +fyk tnjown 220 +nijsv tnjow 221 +fyk tnjrepo 222 +nijsv tnjrp 223 +fyk tcjnum 224 +fnum nighnum 225 +fyk tnjurl 226 +nijsv tnjurlk 227 +fyk tnjlog 228 +nijgh tnghl 229 +fputc 125 230 +end 231 +note nijupd: the newest of the opened and closed times and the loaded thread's record times 232 +fn nijupd to void 233 +o = nighv tnghop 234 +if ne get gnr 15 20 235 +fynull 236 +ret 237 +end 238 +for i ulong 20 239 +put gnf i get gngh add o i 240 +end 241 +c = nighv tnghcl 242 +if eq get gnr 15 20 243 +if nighlt 0 c 244 +for i ulong 20 245 +put gnf i get gngh add c i 246 +end 247 +end 248 +end 249 +p = ulong 0 250 +n = get gnthl 0 251 +while lt p n bound `16777216` 252 +p = nirec p 253 +if and ne get gnr 0 0 eq get gnr 2 20 254 +if nithlt get gnr 1 255 +for i ulong 20 256 +put gnf i get gnth add get gnr 1 i 257 +end 258 +end 259 +end 260 +end 261 +fjtb 262 +for i ulong 20 263 +fjtc get gnf i 264 +end 265 +fjstr 266 +end 267 +note nighlt a c: gnf[a, a+20) sorts before gngh[c, c+20) 268 +fn nighlt a ulong c ulong to bool 269 +for i ulong 20 270 +x = get gnf add a i 271 +y = get gngh add c i 272 +if ne x y 273 +ret lt x y 274 +end 275 +end 276 +ret false 277 +end 278 +fn nithlt c ulong to bool 279 +for i ulong 20 280 +x = get gnf i 281 +y = get gnth add c i 282 +if ne x y 283 +ret lt x y 284 +end 285 +end 286 +ret false 287 +end 288 +note nijraw a: gnth[gnr a, + gnr a+1) as a JSON string 289 +fn nijraw a ulong to void 290 +fjtb 291 +o = get gnr a 292 +for i ulong get gnr add a 1 bound `16777216` 293 +fjtc get gnth add o i 294 +end 295 +fjstr 296 +end 297 +fn nijone to long 298 +if not niidx 299 +ret 500 300 +end 301 +k = niref 302 +if ge k get gnn 0 303 +ret 404 304 +end 305 +s = nistate k 306 +fyrhead tcjsi 307 +fyk tcid 308 +nijid k 309 +fyk tcjtitl 310 +nijtitle k 311 +fyk tcstn 312 +cojsn 2 s 313 +nigh k 314 +fyk tcjauth 315 +nijauthor 316 +nijimp k 317 +fyk tcjopen 318 +nijgh tnghop 319 +fyk tnjclos 320 +nijgh tnghcl 321 +fyk tcjpath 322 +cojq 323 +nilink k 324 +cojq 325 +fyk tcjreas 326 +nijgh tnghre 327 +nijlabs k 328 +fyk tcjasg 329 +fputc 91 330 +fputc 93 331 +if not nithr k 332 +ret 500 333 +end 334 +if not nijcoms k 335 +ret 500 336 +end 337 +fyend 338 +ret 200 339 +end 340 +fn nijlabs k ulong to void 341 +fyk tcjlabs 342 +fputc 91 343 +n = nismall k tnflab 344 +s = ulong 0 345 +c = ulong 0 346 +for i ulong n bound 65536 347 +if eq get gnf i 10 348 +if gt c 0 349 +fputc 44 350 +end 351 +fjtb 352 +for j ulong sub i s bound 65536 353 +fjtc get gnf add s j 354 +end 355 +fjstr 356 +c = add c 1 357 +s = add i 1 358 +end 359 +end 360 +fputc 93 361 +end 362 +note nijcoms k: "comments": the body first (author null, the GitHub login, opened), then the thread 363 +fn nijcoms k ulong to bool 364 +fyk tcjcoms 365 +fputc 91 366 +fputc 10 367 +fputc 123 368 +fyk0 tcjauth 369 +nijauthor 370 +fyk tnjlog 371 +nijgh tnghl 372 +fyk tnjkind 373 +fysv tcjtcom 374 +fyk tcjtime 375 +nijgh tnghop 376 +fyk tcjbody 377 +nipf k tnfdsc 378 +r = frdall 379 +if lt r 0 380 +r = 0 381 +end 382 +if ne get fxotr 0 0 383 +ret false 384 +end 385 +fjfx 0 ulong r 386 +fyk tcjred 387 +fybool false 388 +fputc 125 389 +p = ulong 0 390 +n = get gnthl 0 391 +while lt p n bound `16777216` 392 +p = nirec p 393 +if ne get gnr 0 0 394 +fputc 44 395 +fputc 10 396 +nijcom 397 +end 398 +end 399 +fputc 93 400 +ret true 401 +end 402 +fn nijcom to void 403 +k = get gnr 0 404 +fputc 123 405 +fyk0 tcjauth 406 +if eq k 4 407 +fputc 123 408 +fyk0 tnjdid 409 +nijraw 3 410 +fyk tnjnm 411 +fynull 412 +fputc 125 413 +fyk tnjlog 414 +fynull 415 +else 416 +fynull 417 +fyk tnjlog 418 +nijraw 3 419 +end 420 +fyk tnjkind 421 +if or eq k 1 eq k 4 422 +fysv tcjtcom 423 +end 424 +if eq k 2 425 +fysv tcjtrvw 426 +fyk tcstn 427 +nijraw 5 428 +end 429 +if eq k 3 430 +fysv tnrrc 431 +fyk tcjpath 432 +nijraw 8 433 +fyk tnjline 434 +fnum get gnr 7 435 +end 436 +fyk tcjtime 437 +if eq get gnr 2 20 438 +nijraw 1 439 +else 440 +fynull 441 +end 442 +fyk tcjbody 443 +nijraw 10 444 +fyk tcjred 445 +fybool false 446 +fputc 125 447 +end collab/native/route.om new file mode 100644 @@ -0,0 +1,84 @@ 1 +note Native issue list, detail, creation and comments. Prefixes are accepted only on reads. 2 +text tnnew "new" 3 +text tncoms "/comments" 4 +fn niresat a ulong n ulong t view uchar * to bool 5 +if ne sub n a len t 6 +ret false 7 +end 8 +for i ulong len t bound 16 9 +if ne get frest add a i get t i 10 +ret false 11 +end 12 +end 13 +ret true 14 +end 15 +fn niresid a ulong size ulong to bool 16 +if or lt size 4 gt size 16 17 +ret false 18 +end 19 +for i ulong size bound 16 20 +c = get frest add a i 21 +if not or and ge c 48 le c 57 and ge c 97 le c 102 22 +ret false 23 +end 24 +put gcrq i c 25 +end 26 +put gcrql 0 size 27 +ret true 28 +end 29 +fn coroute to long 30 +if or ge get fridx 0 get fan 0 not frstpre tcisss 31 +ret 0 32 +end 33 +prefix = len tcisss 34 +n = get frestl 0 35 +if and gt n prefix ne get frest prefix 47 36 +ret 0 37 +end 38 +fsetepno 39 +m = get fmeth 0 40 +start = add prefix 1 41 +if le n start 42 +if ne m 1 43 +ret 405 44 +end 45 +if fjwant 46 +ret nijlist 47 +end 48 +fyalt 49 +ret nilist 50 +end 51 +if niresat start n tnnew 52 +if eq m 3 53 +ret niwpost true 54 +end 55 +if eq m 1 56 +ret niwnew 57 +end 58 +ret 405 59 +end 60 +stop = add start 16 61 +if and gt n stop niresat stop n tncoms 62 +if not niresid start 16 63 +ret 404 64 +end 65 +if eq m 3 66 +ret niwpost false 67 +end 68 +if eq m 1 69 +ret niwcform 70 +end 71 +ret 405 72 +end 73 +if not niresid start sub n start 74 +ret 404 75 +end 76 +if ne m 1 77 +ret 405 78 +end 79 +if fjwant 80 +ret nijone 81 +end 82 +fyalt 83 +ret nipage 84 +end collab/native/write.om new file mode 100644 @@ -0,0 +1,841 @@ 1 +note Native issue writes. The author comes from the session established by SSH key proof. The 2 +note repository lock serializes replacements of its index and threads, even across server processes. 3 +note fopen flags below use Linux AArch64 values (O_CLOEXEC 524288, O_NOFOLLOW 32768). 4 +text tniwnp "/issues/new" 5 +text tniwlog "login" 6 +text tniwlink "

    New issue

    \n" 8 +text tniwttl "New issue" 9 +text tniwform "
    " 10 +text tniwsign "

    Sign in to comment

    " 12 +text tniwsgn "\">Sign in to open an issue

    " 13 +text tniwfa "
    " 17 +text tniwtf "

    " 18 +text tniwdf "

    " 19 +text tniwcf "

    " 20 +text tniwbn "

    " 21 +text tniwbc "

    " 22 +text tniwfe "
    \n" 23 +text tniwrq "request" 24 +text tniwrql "request " 25 +text tniwmrq "Reload the form before sending it again." 26 +text tniwfs "issue store: directory sync failed after publication\n" 27 +text tniwfsch "forge/issue-form/1" 28 +text tniwwsch "forge/issue-write/1" 29 +text tniwact "action" 30 +text tniwcsrf "csrf" 31 +text tniwappl "applied" 32 +text tniwft "title" 33 +text tniwfb "body" 34 +text tniwbadt "Enter a single-line title of 1 to 256 UTF-8 bytes." 35 +text tniwbadb "Enter valid Markdown text of at most 16000 UTF-8 bytes. A comment cannot be empty." 36 +text tniwopa "open\n" 37 +text tniwlock ".write.lock" 38 +text tniwist ".index.tmp" 39 +text tniwtht ".thread.tmp" 40 +text tniwstg ".new-" 41 +text tniwdir "issues" 42 +text tniwemp "" 43 +global gniwid uchar 16 44 +global gniwtt uchar 256 45 +global gniwtl ulong 1 46 +global gniwrq uchar 32 47 + 48 +fn niwlink to void 49 +fput tniwlink 50 +fputrl 51 +fput tniwnp 52 +fput tniwnewa 53 +end 54 +fn niwnewjson to void 55 +fputc 34 56 +fputrl 57 +fput tniwnp 58 +fputc 34 59 +end 60 +fn niwform k ulong opening bool to void 61 +fput tniwform 62 +if eq get gscur 0 0 63 +fput tniwsign 64 +fputb 65 +fput tniwlog 66 +if opening 67 +fput tniwsgn 68 +else 69 +fput tniwsgc 70 +end 71 +fput tnsece 72 +ret 73 +end 74 +hex = new uchar 32 0 75 +if not niwtoken hex 76 +fput tniwmrq 77 +fput tnsece 78 +ret 79 +end 80 +fput tniwfa 81 +if opening 82 +fputrl 83 +fput tniwnp 84 +else 85 +nilink k 86 +fput tncoms 87 +end 88 +fput tniwcs 89 +for j ulong get fcsrfl 0 bound 64 90 +fputc get fcsrf j 91 +end 92 +fput tniwrh 93 +for j ulong 32 94 +fputc get hex j 95 +end 96 +fput tniwqt 97 +if opening 98 +fput tniwtf 99 +fput tniwdf 100 +fput tniwbn 101 +else 102 +fput tniwcf 103 +fput tniwbc 104 +end 105 +fput tniwfe 106 +end 107 +fn niwtoken hex edit uchar 32 to bool 108 +raw = new uchar 16 0 109 +if not sorand raw 110 +ret false 111 +end 112 +sohex raw hex 113 +ret true 114 +end 115 +fn niwlogin to long 116 +put fkind 0 2 117 +flocb 118 +floct tniwlog 119 +ret 303 120 +end 121 +fn niwjsform k ulong opening bool to long 122 +if eq get gscur 0 0 123 +ret niwlogin 124 +end 125 +hex = new uchar 32 0 126 +if not niwtoken hex 127 +ret 500 128 +end 129 +fyrhead tniwfsch 130 +fyk tniwact 131 +cojq 132 +if opening 133 +fputrl 134 +fput tniwnp 135 +else 136 +nilink k 137 +fput tncoms 138 +end 139 +cojq 140 +fyk tniwcsrf 141 +fjtb 142 +for i ulong get fcsrfl 0 bound 64 143 +fjtc get fcsrf i 144 +end 145 +fjstr 146 +fyk tniwrq 147 +fysv hex 148 +fyend 149 +ret 200 150 +end 151 +fn niwcform to long 152 +if not fjwant 153 +ret 405 154 +end 155 +if eq get gscur 0 0 156 +ret niwlogin 157 +end 158 +if not niidx 159 +ret 500 160 +end 161 +k = niref 162 +if ge k get gnn 0 163 +ret 404 164 +end 165 +ret niwjsform k false 166 +end 167 +fn niwresult applied bool to long 168 +if fjwant 169 +fyrhead tniwwsch 170 +fyk tcjpath 171 +cojq 172 +fputrl 173 +fput tcissp 174 +for i ulong 16 175 +fputc get gniwid i 176 +end 177 +cojq 178 +fyk tniwappl 179 +fybool applied 180 +fyend 181 +if applied 182 +ret 201 183 +end 184 +ret 200 185 +end 186 +put fkind 0 2 187 +flocrepo 188 +floct tcissp 189 +for i ulong 16 190 +flocc get gniwid i 191 +end 192 +ret 303 193 +end 194 +fn niwnew to long 195 +if fjwant 196 +ret niwjsform 0 true 197 +end 198 +fsetti tniwttl 199 +frepohd 6 200 +niwform 0 true 201 +ret 200 202 +end 203 +fn niwerr t view uchar * to long 204 +if fjwant 205 +fyerr 400 206 +note The common error envelope is used by all machine clients. 207 +else 208 +frepohd 6 209 +fput tnbox 210 +fput t 211 +fput tnmetae 212 +fput tnsece 213 +end 214 +ret 400 215 +end 216 +fn niwfields opening bool to long 217 +if ne cobfld tniwrq 32 218 +ret niwerr tniwmrq 219 +end 220 +for i ulong 32 221 +c = get gcfv i 222 +if lt sohexv c 0 223 +ret niwerr tniwmrq 224 +end 225 +put gniwrq i c 226 +end 227 +if opening 228 +n = cobfld tniwft 229 +if or lt n 1 gt n 256 230 +ret niwerr tniwbadt 231 +end 232 +n = cotxtok ulong n false 233 +if lt n 1 234 +ret niwerr tniwbadt 235 +end 236 +put gniwtl 0 ulong n 237 +for i ulong ulong n bound 256 238 +put gniwtt i get gcfv i 239 +end 240 +end 241 +b = cobfld tniwfb 242 +if eq b -1 243 +b = 0 244 +end 245 +if lt b 0 246 +ret niwerr tniwbadb 247 +end 248 +b = cotxtok ulong b true 249 +if or or lt b 0 gt b 16000 and not opening eq b 0 250 +ret niwerr tniwbadb 251 +end 252 +put gcfvl 0 ulong b 253 +ret 0 254 +end 255 +fn niwpost opening bool to long 256 +r = sowpre 257 +if ne r 0 258 +if and fjwant ne r 303 259 +put fobl 0 0 260 +put fkind 0 0 261 +end 262 +ret r 263 +end 264 +soratev get gscur 0 get gsnow 0 265 +r = niwfields opening 266 +if ne r 0 267 +ret r 268 +end 269 +fd = niwacq opening 270 +if lt fd 0 271 +if eq fd -2 272 +ret 404 273 +end 274 +if eq fd -11 275 +put fretry 0 1 276 +ret 503 277 +end 278 +ret 500 279 +end 280 +if opening 281 +r = niwcreate 282 +else 283 +r = niwcomment 284 +end 285 +x = fclose int fd 286 +if gt r 0 287 +ret r 288 +end 289 +ret niwresult eq r 0 290 +end 291 + 292 +note ---- Storage 293 +fn niwdirs to bool 294 +fpb 295 +fpt tfdata 296 +fpt tniwdir 297 +if not niwmkdir 298 +ret false 299 +end 300 +fpc 47 301 +fpt tfowner 302 +if not niwmkdir 303 +ret false 304 +end 305 +fpc 47 306 +i = get fridx 0 307 +for k ulong get fanl i bound 128 308 +fpc frnbyte i k 309 +end 310 +ret niwmkdir 311 +end 312 +fn niwmkdir to bool 313 +r = makedir fpth 0 get fpthl 0 448 314 +ret or eq r 0 eq r -17 315 +end 316 +fn niwacq opening bool to long 317 +if opening 318 +if not niwdirs 319 +ret -5 320 +end 321 +end 322 +nipath 323 +fpt tniwlock 324 +fd = fopen fpth 0 get fpthl 0 557121 384 325 +if lt fd 0 326 +ret fd 327 +end 328 +r = flock int fd 6 329 +if ne r 0 330 +x = fclose int fd 331 +ret r 332 +end 333 +ret fd 334 +end 335 +fn niwpath stage bool file view uchar * to void 336 +nipath 337 +if stage 338 +fpt tniwstg 339 +end 340 +for i ulong 16 341 +fpc get gniwid i 342 +end 343 +if ne len file 0 344 +fpc 47 345 +fpt file 346 +end 347 +end 348 +fn niwarg to void 349 +soavopen 350 +for i ulong get fpthl 0 bound 4096 351 +soavc get fpth i 352 +end 353 +end 354 +note Source selectors: response buffer (0), file read buffer (1), title (2), form body (3), open status (4). 355 +fn niwwrite fd int src ulong p ulong n ulong to long 356 +if eq src 0 357 +ret write fd fob p n 358 +end 359 +if eq src 1 360 +ret write fd fxo p n 361 +end 362 +if eq src 2 363 +ret write fd gniwtt p n 364 +end 365 +if eq src 3 366 +ret write fd gcfv p n 367 +end 368 +ret write fd tniwopa p n 369 +end 370 +fn niwout fd int src ulong size ulong to bool 371 +p = ulong 0 372 +for i ulong 100000 373 +if eq p size 374 +ret true 375 +end 376 +n = niwwrite fd src p sub size p 377 +if gt n 0 378 +p = add p ulong n 379 +else 380 +if ne n -4 381 +ret false 382 +end 383 +end 384 +end 385 +ret false 386 +end 387 +fn niwput src ulong size ulong tail ulong to bool 388 +fd = fopen fpth 0 get fpthl 0 557249 384 389 +if lt fd 0 390 +ret false 391 +end 392 +ok = niwout int fd src size 393 +if and ok gt tail 0 394 +ok = niwout int fd 0 tail 395 +end 396 +if ok 397 +ok = eq fsync int fd 0 398 +end 399 +r = fclose int fd 400 +if or not ok ne r 0 401 +x = unlink fpth 0 get fpthl 0 402 +ret false 403 +end 404 +ret true 405 +end 406 +note Read a whole file into fxo under the write lock. Distinguish missing from other I/O errors. 407 +fn niwread cap ulong to long 408 +fd = fopen fpth 0 get fpthl 0 559104 0 409 +if lt fd 0 410 +ret fd 411 +end 412 +n = niwreadfd int fd cap 413 +r = fclose int fd 414 +ret n 415 +end 416 +fn niwreadfd fd int cap ulong to long 417 +p = ulong 0 418 +for i ulong 100000 419 +if gt p cap 420 +ret -27 421 +end 422 +n = read fd fxo p sub add cap 1 p 423 +if eq n 0 424 +ret long p 425 +end 426 +if gt n 0 427 +p = add p ulong n 428 +else 429 +if ne n -4 430 +ret n 431 +end 432 +end 433 +end 434 +ret -5 435 +end 436 +fn niwremove file view uchar * stage bool to void 437 +niwpath stage file 438 +x = unlink fpth 0 get fpthl 0 439 +end 440 +fn niwdiscard stage bool to void 441 +niwremove tnfttl stage 442 +niwremove tnfdsc stage 443 +niwremove tnfsts stage 444 +niwremove tniwnat stage 445 +niwpath stage tniwemp 446 +x = rmdir fpth 0 get fpthl 0 447 +end 448 +note Use the authenticated DID and the form token as a stable issue ID across retries. 449 +fn niwnewid to void 450 +seed = new uchar 160 0 451 +hash = new uchar 32 0 452 +hex = new uchar 16 0 453 +for i ulong 32 454 +put seed i get gniwrq i 455 +end 456 +d = get gscur 0 457 +o = get gsso d 458 +n = get gssl d 459 +for i ulong n bound 128 460 +put seed add i 32 get gsstr add o i 461 +end 462 +x = sha2_digest 256 part seed 0 add 32 n hash 463 +sohex part hash 0 8 hex 464 +for i ulong 16 465 +put gniwid i get hex i 466 +end 467 +end 468 +fn niwreq to void 469 +for i ulong 32 470 +fputc get gniwrq i 471 +end 472 +end 473 +fn niwmeta to void 474 +put fobl 0 0 475 +fput tniwdid 476 +niwactor 477 +fputc 10 478 +fput tnghop 479 +fjisob get gsnow 0 480 +fputc 10 481 +fput tniwrql 482 +niwreq 483 +fputc 10 484 +end 485 +fn niwactor to void 486 +d = get gscur 0 487 +o = get gsso d 488 +for i ulong get gssl d bound 128 489 +fputc get gsstr add o i 490 +end 491 +end 492 +fn niwnewfiles to bool 493 +niwpath true tnfttl 494 +if not niwput 2 get gniwtl 0 0 495 +ret false 496 +end 497 +niwpath true tnfdsc 498 +if not niwput 3 get gcfvl 0 0 499 +ret false 500 +end 501 +niwpath true tnfsts 502 +if not niwput 4 len tniwopa 0 503 +ret false 504 +end 505 +niwmeta 506 +niwpath true tniwnat 507 +ok = niwput 0 get fobl 0 0 508 +put fobl 0 0 509 +if not ok 510 +ret false 511 +end 512 +ret niwsync true 513 +end 514 +fn niwsync stage bool to bool 515 +niwpath stage tniwemp 516 +ret niwsyncat 517 +end 518 +fn niwsyncat to bool 519 +fd = fopen fpth 0 get fpthl 0 573440 0 520 +if lt fd 0 521 +ret false 522 +end 523 +r = fsync int fd 524 +x = fclose int fd 525 +ret eq r 0 526 +end 527 +note Publish the complete issue before replacing its index. After a crash between the renames the 528 +note unindexed directory is unreachable. Retrying the same request repairs its index entry. 529 +fn niwcreate to long 530 +niwnewid 531 +nipath 532 +fpt tnindex 533 +n = niwread len gnix 534 +if eq n -2 535 +n = 0 536 +end 537 +if eq n -27 538 +ret 409 539 +end 540 +if or lt n 0 ne rem ulong n 17 0 541 +ret 500 542 +end 543 +for j ulong div ulong n 17 bound NIROWS 544 +p = mul j 17 545 +if not niidok p 546 +ret 500 547 +end 548 +if niwrow p 549 +if niwexisting 550 +ret -1 551 +end 552 +ret 409 553 +end 554 +end 555 +if eq n long len gnix 556 +ret 409 557 +end 558 +for i ulong 16 559 +put fob i get gniwid i 560 +end 561 +put fob 16 10 562 +nipath 563 +fpt tniwist 564 +x = unlink fpth 0 get fpthl 0 565 +if not niwput 1 ulong n 17 566 +ret 500 567 +end 568 +r = niwinst 569 +if gt r 0 570 +nipath 571 +fpt tniwist 572 +x = unlink fpth 0 get fpthl 0 573 +end 574 +ret r 575 +end 576 +fn niwrow p ulong to bool 577 +for i ulong 16 578 +if ne get fxo add p i get gniwid i 579 +ret false 580 +end 581 +end 582 +ret true 583 +end 584 +fn niwexisting to bool 585 +niwpath false tniwnat 586 +r = niwread 256 587 +if le r 0 588 +ret false 589 +end 590 +for i ulong ulong r bound 256 591 +put gngh i get fxo i 592 +end 593 +put gnghl 0 ulong r 594 +if not niwmetasame 595 +ret false 596 +end 597 +ret niwsame 598 +end 599 +fn niwmetasame to bool 600 +d = get gscur 0 601 +o = get gsso d 602 +a = nighv tniwdid 603 +if ne get gnr 15 get gssl d 604 +ret false 605 +end 606 +for i ulong get gssl d bound 128 607 +if ne get gngh add a i get gsstr add o i 608 +ret false 609 +end 610 +end 611 +b = nighv tniwrql 612 +if ne get gnr 15 32 613 +ret false 614 +end 615 +for i ulong 32 616 +if ne get gngh add b i get gniwrq i 617 +ret false 618 +end 619 +end 620 +ret true 621 +end 622 +fn niwsame to bool 623 +niwpath false tnfttl 624 +if ne niwread 256 long get gniwtl 0 625 +ret false 626 +end 627 +for i ulong get gniwtl 0 bound 256 628 +if ne get fxo i get gniwtt i 629 +ret false 630 +end 631 +end 632 +niwpath false tnfdsc 633 +if ne niwread 16000 long get gcfvl 0 634 +ret false 635 +end 636 +for i ulong get gcfvl 0 bound 16000 637 +if ne get fxo i get gcfv i 638 +ret false 639 +end 640 +end 641 +ret true 642 +end 643 +fn niwinst to long 644 +niwpath false tniwemp 645 +r = stat fpth 0 get fpthl 0 fstb 0 128 646 +if eq r -2 647 +if not niwstage 648 +ret 500 649 +end 650 +else 651 +if lt r 0 652 +ret 500 653 +end 654 +if not niwexisting 655 +ret 409 656 +end 657 +end 658 +nipath 659 +if not niwsyncat 660 +ret 500 661 +end 662 +soavb 663 +nipath 664 +fpt tniwist 665 +niwarg 666 +nipath 667 +fpt tnindex 668 +niwarg 669 +if ne renames gspk 0 get gspkl 0 0 0 670 +ret 500 671 +end 672 +nipath 673 +if not niwsyncat 674 +flog tniwfs 675 +end 676 +ret 0 677 +end 678 +fn niwstage to bool 679 +note Discard remnants of an interrupted attempt of this same unindexed action. 680 +niwdiscard true 681 +niwpath true tniwemp 682 +if ne makedir fpth 0 get fpthl 0 448 0 683 +ret false 684 +end 685 +if not niwnewfiles 686 +niwdiscard true 687 +ret false 688 +end 689 +soavb 690 +niwpath true tniwemp 691 +niwarg 692 +niwpath false tniwemp 693 +niwarg 694 +if ne renames gspk 0 get gspkl 0 1 0 695 +niwdiscard true 696 +ret false 697 +end 698 +ret true 699 +end 700 +fn niwrecord to void 701 +put fobl 0 0 702 +fput tniwncom 703 +cosp 704 +fjisob get gsnow 0 705 +cosp 706 +niwactor 707 +cosp 708 +niwreq 709 +cosp 710 +n = get gcfvl 0 711 +fnum n 712 +fputc 10 713 +for i ulong n bound 16000 714 +fputc get gcfv i 715 +end 716 +fputc 10 717 +end 718 +fn niwcomment to long 719 +for i ulong 16 720 +put gniwid i get gcrq i 721 +end 722 +r = niwindexed 723 +if ne r 0 724 +ret r 725 +end 726 +niwpath false tnfthr 727 +n = niwread `1048576` 728 +if eq n -2 729 +n = 0 730 +end 731 +if eq n -27 732 +ret 409 733 +end 734 +if lt n 0 735 +ret 500 736 +end 737 +r = niwthread ulong n 738 +if ne r 0 739 +ret r 740 +end 741 +niwrecord 742 +if gt add ulong n get fobl 0 `1048576` 743 +put fobl 0 0 744 +ret 409 745 +end 746 +niwpath false tniwtht 747 +x = unlink fpth 0 get fpthl 0 748 +ok = niwput 1 ulong n get fobl 0 749 +put fobl 0 0 750 +if not ok 751 +ret 500 752 +end 753 +soavb 754 +niwarg 755 +niwpath false tnfthr 756 +niwarg 757 +if ne renames gspk 0 get gspkl 0 0 0 758 +niwremove tniwtht false 759 +ret 500 760 +end 761 +if not niwsync false 762 +flog tniwfs 763 +end 764 +ret 0 765 +end 766 +fn niwindexed to long 767 +nipath 768 +fpt tnindex 769 +n = niwread len gnix 770 +if eq n -2 771 +ret 404 772 +end 773 +if or lt n 0 ne rem ulong n 17 0 774 +ret 500 775 +end 776 +for j ulong div ulong n 17 bound NIROWS 777 +p = mul j 17 778 +if and niidok p niwrow p 779 +ret 0 780 +end 781 +end 782 +ret 404 783 +end 784 +note Check the whole prefix before replacing it. An already-published form returns its prior result. 785 +fn niwthread n ulong to long 786 +for i ulong n bound `1048576` 787 +put gnth i get fxo i 788 +end 789 +put gnthl 0 n 790 +p = ulong 0 791 +while lt p n bound `1048576` 792 +p = nirec p 793 +k = get gnr 0 794 +if eq k 0 795 +ret 409 796 +end 797 +if eq k 4 798 +if niwcomreq 799 +if niwcombody 800 +ret -1 801 +end 802 +ret 409 803 +end 804 +end 805 +end 806 +ret 0 807 +end 808 +fn niwcomreq to bool 809 +d = get gscur 0 810 +n = get gssl d 811 +if or ne get gnr 4 n ne get gnr 6 32 812 +ret false 813 +end 814 +a = get gnr 3 815 +o = get gsso d 816 +for i ulong n bound 128 817 +if ne get gnth add a i get gsstr add o i 818 +ret false 819 +end 820 +end 821 +b = get gnr 5 822 +for i ulong 32 823 +if ne get gnth add b i get gniwrq i 824 +ret false 825 +end 826 +end 827 +ret true 828 +end 829 +fn niwcombody to bool 830 +n = get gcfvl 0 831 +if ne n get gnr 11 832 +ret false 833 +end 834 +a = get gnr 10 835 +for i ulong n bound 16000 836 +if ne get gnth add a i get gcfv i 837 +ret false 838 +end 839 +end 840 +ret true 841 +end collab/tests/compose.sh @@ -1,6 +1,7 @@ 1 1 #!/bin/bash 2 2 # collab/tests/compose.sh: end-to-end HOST test of Phase A (docs/collab-write.md): the web composes and 3 -# checks, the author runs the shown command, and the result shows on the forge. Everything is private 3 +# checks and says publishing is closed (no command shown); the author runs commands this test writes, 4 +# and the result shows on the forge. Everything is private 4 5 # to a temp dir: a throwaway Radicle profile (RAD_HOME) with a private repo, a test forged on PORT 5 6 # (default 18493) whose store and allow-list point at that profile, throwaway ssh keys for sign-in. 6 7 # Nothing touches ~/.radicle, the live forged or the network. Every gate has a negative control. @@ -55,6 +56,9 @@ for m in re.findall(r'
    (.*?)
    ', open(sys.argv[1]).read() 55 56 EOF 56 57 } 57 58 run_() { [ -n "$1" ] && (cd "$W" && sh -c "$1"); } 59 +# The compose page shows no command: publishing is closed for now. The author's own commands below 60 +# are written by this test (not read from the page) so the fixture repo still gets its COBs. 61 +closed() { has 'Publishing it is closed for now: Interplane does not accept comments, reviews, issues or patches yet.' && [ -z "$(cmds)" ] && ok "$1: publishing closed, no command shown" || bad "$1: closed note missing or a command shown"; } 58 62 dl() { curl -s -o "$2" -D "$T/hdr" -H "X-Forge-Base: $BASE" -H "$CK" "$U$1" -w '%{http_code}'; } 59 63 cidof() { hdr location | sed -n 's|.*/compose/\([0-9a-f]\{32\}\)$|\1|p'; } 60 64 @@ -88,7 +92,7 @@ CK="Cookie: $SES" 88 92 89 93 # ---- forms 90 94 c=$(code GET "$R/issues/new"); check "$c" 200 "GET issues/new signed out" 91 -has 'Sign in with your Radicle key' && ! has 'name="title"' && ok "NEG signed out: sign-in link, no form" || bad "signed-out new-issue page" 95 +has 'Sign in with your key' && ! has 'name="title"' && ok "NEG signed out: sign-in link, no form" || bad "signed-out new-issue page" 92 96 c=$(code GET "$R/issues/new" -H "$CK"); check "$c" 200 "GET issues/new signed in" 93 97 has "action=\"$R/issues/new\"" && has 'name="title"' && has "value=\"$TOK\"" && ok "new-issue form with this session's CSRF token" || bad "new-issue form" 94 98 c=$(code GET "$R/patches/new" -H "$CK"); has 'name="draft"' && ok "new-patch form has the draft box" || bad "new-patch form ($c)" @@ -128,7 +132,7 @@ c=$(code GET "$R/compose/$CID" -H "$CK"); check "$c" 200 "compose page" 128 132 has 'bold' && ok "preview renders Markdown" || bad "preview markdown" 129 133 ! has '\n\n[Unsafe](javascript:alert(1))' 82 +} 83 +test "$(openissue 'Native issue ')" = 303 84 +issue=$(hdr location) 85 +id=${issue##*/} 86 +test "${#id}" = 16 87 +test "$(openissue 'Native issue ')" = 303 88 +test "$(hdr location)" = "$issue" 89 +test "$(openissue 'Changed title')" = 409 90 +test "$(wc -l < "$store/index")" = 3 91 +test "$(code GET "$issue" -H "$issue_cookie")" = 200 92 +grep -q 'Native issue <proof>' "$T/body" 93 +grep -q 'native' "$T/body" 94 +if grep -qE ''], d['commits'] @@ -779,7 +779,7 @@ EOF 779 779 c=$(code GET /open.json); check "$c" 200 "GET /open.json" 780 780 python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["schema"]=="interplane/open-builds/1" and len(d["projects"])==3' "$T/body" && ok "/open.json is the shelf JSON without an Accept header" || bad "/open.json" 781 781 c=$(code GET "/open/$R1.json"); check "$c" 200 "GET /open/.json" 782 -python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["schema"]=="interplane/open-build/1" and d["rid"]=="rad:"+sys.argv[2] and len(d["commits"])==1' "$T/body" "$R1" && ok "/open/.json is the project JSON without an Accept header" || bad "/open/.json" 782 +python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["schema"]=="interplane/open-build/1" and d["rid"]==sys.argv[2] and len(d["commits"])==1' "$T/body" "$R1" && ok "/open/.json is the project JSON without an Accept header" || bad "/open/.json" 783 783 c=$(code GET "/open/$(rid H4).json"); check "$c" 404 "NEG the .json name of a refused project" 784 784 c=$(code GET "/open/${R1}.jsonx"); check "$c" 404 "NEG a near-miss suffix is not a rid" 785 785 c=$(code POST /open.json -H "$CK" --data-urlencode "csrf=$TOK"); [ "$c" != 200 ] && [ "$c" != 303 ] && ok "NEG POST to /open.json is refused ($c)" || bad "POST /open.json: $c" @@ -803,7 +803,7 @@ shelfck() { 803 803 python3 -I - "$1" "$2" <<'EOF' 804 804 import json, sys 805 805 want = [l.split('\t')[0] for l in open(sys.argv[1], encoding='utf-8') if l.split('\t')[1] in ('open', 'held', 'stored')] 806 -got = [p['rid'][4:] for p in json.load(open(sys.argv[2], encoding='utf-8'))['projects']] 806 +got = [p['rid'] for p in json.load(open(sys.argv[2], encoding='utf-8'))['projects']] 807 807 assert got == want, (len(got), len(want)) 808 808 print(len(got)) 809 809 EOF @@ -814,7 +814,7 @@ n=$(shelfck "$T/data/open/list.tsv" "$T/body" 2>&1) && ok "/open.json lists all 814 814 check "$n" "$BPUB" "and that is every open and held row planted" 815 815 c=$(code GET /open/); [ "$c" = 200 ] && grep -q "$BOPEN" "$T/body" && grep -q "$BLONG" "$T/body" && ok "/open/ shows the last open row and the 70,000-byte row" || bad "/open/ with a 1.2 MB list: $c" 816 816 c=$(code GET "/open/$BOPEN"); check "$c" 200 "the project page of the last row answers" 817 -c=$(code GET "/open/$BLONG.json"); [ "$c" = 200 ] && python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["rid"]=="rad:"+sys.argv[2] and len(d["description"])==400' "$T/body" "$BLONG" && ok "the 70,000-byte row has a page; its description is cut at the page's 400 as every row's is" || bad "long row page: $c $(head -c 200 "$T/body")" 817 +c=$(code GET "/open/$BLONG.json"); [ "$c" = 200 ] && python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["rid"]==sys.argv[2] and len(d["description"])==400' "$T/body" "$BLONG" && ok "the 70,000-byte row has a page; its description is cut at the page's 400 as every row's is" || bad "long row page: $c $(head -c 200 "$T/body")" 818 818 stop 819 819 if build "$T/forged-mtr" '/^fn ohlfill /,/^fn ohlnext /s/^k = pread int sub get gost 0 1 goc 0 65536 long pos$/w = ulong 0\nif lt pos 262143\nw = sub 262143 pos\nend\nif gt w 65536\nw = ulong 65536\nend\nk = long 0\nif gt w 0\nk = pread int sub get gost 0 1 goc 0 w long pos\nend/'; then 820 820 start "$T/forged-mtr"; c=$(code GET /open.json) open/tests/up.sh @@ -317,10 +317,10 @@ check "$(sed -n 6p "$T/bt")" "$(printf '%s\t17\tREADME.md' "$(printf '# demo, ha 317 317 printf 'p %s\n' "$(cut -d' ' -f1,2 "$T/k1.pub")" > "$T/as" 318 318 ssh-keygen -Y verify -f "$T/as" -I p -n interplane-bring -s "$T/bs" < "$T/bt5" > /dev/null 2>&1 && ok "anyone can verify brought.sig over the statement with ssh-keygen -Y verify" || bad "brought.sig does not verify" 319 319 code GET /open/ > /dev/null 320 -grep -q "Stored on Radicle by the Interplane hub: the hub's key signed the Radicle record. The person who brought it signed the list of files." "$T/body" && ok "the shelf row says who signed what" || bad "no who-signs-what sentence on the shelf" 321 -grep -q "rad clone rad:$GOOD" "$T/body" && ok "the shelf lists the stored project" || bad "stored project not on the shelf" 320 +grep -q "Stored by the Interplane hub: the hub's key signs the repository's history. The person who brought it signed the list of files." "$T/body" && ok "the shelf row says who signed what" || bad "no who-signs-what sentence on the shelf" 321 +grep -q "href=\"/open/$GOOD\"" "$T/body" && ok "the shelf lists the stored project" || bad "stored project not on the shelf" 322 322 code GET /open.json > /dev/null 323 -python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); p=[x for x in d["projects"] if x["rid"]=="rad:"+sys.argv[2]][0]; assert p["stored_by_hub"] is True and p["download"]=="/open/"+sys.argv[2]+".tar" and len(p["download_sha256"])==64; print(p["download_sha256"])' "$T/body" "$GOOD" > "$T/dsha" && ok "shelf JSON: stored_by_hub true, download, download_sha256" || bad "shelf JSON fields: $(head -c 400 "$T/body")" 323 +python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); p=[x for x in d["projects"] if x["rid"]==sys.argv[2]][0]; assert p["stored_by_hub"] is True and p["download"]=="/open/"+sys.argv[2]+".tar" and len(p["download_sha256"])==64; print(p["download_sha256"])' "$T/body" "$GOOD" > "$T/dsha" && ok "shelf JSON: stored_by_hub true, download, download_sha256" || bad "shelf JSON fields: $(head -c 400 "$T/body")" 324 324 code GET "/open/$GOOD.json" > /dev/null 325 325 python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); assert d["stored_by_hub"] is True and d["download"]=="/open/"+sys.argv[2]+".tar" and d["download_sha256"]==sys.argv[3] and "README.md" in d["files"]' "$T/body" "$GOOD" "$(cat "$T/dsha")" && ok "page JSON: the same fields and the snapshot" || bad "page JSON: $(head -c 400 "$T/body")" 326 326 c=$(code GET "/open/$GOOD.tar"); check "$c" 200 "GET /open/.tar" @@ -332,10 +332,10 @@ c=$(code GET "/open/`z2abcdefghijkmnopqrstuvwxyzAB`.tar"); check "$c" 404 "NEG no 332 332 # the project page of a stored project: no empty label, the developer section, all of it escaped 333 333 code GET "/open/$GOOD" > /dev/null; cp "$T/body" "$T/page.html" 334 334 grep -q '

    For developers

    ' "$T/page.html" && ok "the page of a stored project has the developer section (pj-dev, pj-terms)" || bad "no developer section" 335 -grep -q "
    Radicle ID
    rad:$GOOD
    Clone
    rad clone rad:$GOOD" "$T/page.html" && ok "it shows the Radicle ID and the clone line" || bad "developer section: id or clone line" 335 +grep -q '
    Download
    ' "$T/page.html" && ! grep -q -e 'Radicle ID' -e 'rad clone' -e "rad:$GOOD" "$T/page.html" && ok "it shows the download first, with no Radicle ID, clone line or rad: id" || bad "developer section: id or clone line" 336 336 grep -q "/open/$GOOD.tar\">$GOOD.tar, SHA-256 $(cat "$T/dsha")" "$T/page.html" && ok "it shows the download and its SHA-256" || bad "developer section: download" 337 337 grep -q "
    The hub's key
    did:key:z6MkHubStandInKeyabcdefghijkmnopqrstuvwxyzAB" "$T/page.html" && ok "the hub's key comes from the node (rad self --did, read by the intake)" || bad "hub key not shown" 338 -grep -q "Stored on Radicle by the Interplane hub. The hub's key (did:key:z6MkHubStandInKeyabcdefghijkmnopqrstuvwxyzAB) created this Radicle repository" "$T/page.html" && ok "the paragraph names the hub's key" || bad "paragraph without the hub key" 338 +grep -q "Stored by the Interplane hub. The hub's key (did:key:z6MkHubStandInKeyabcdefghijkmnopqrstuvwxyzAB) created this repository" "$T/page.html" && ok "the paragraph names the hub's key" || bad "paragraph without the hub key" 339 339 KEYLINE=$(sed -n 's|.*
    Their public key
    \(ssh-`ed25519` [A-Za-z0-9+/=]*\).*|\1|p' "$T/page.html") 340 340 check "$KEYLINE" "$(cut -d' ' -f1,2 "$T/k1.pub")" "the bringer's public key, encoded from the did:key, equals their ssh key" 341 341 printf '%s\n' "$KEYLINE" > "$T/their.pub" @@ -623,7 +623,7 @@ world a15; plantbig "$K3" `1048576`; cp "$W/work/list.tsv" "$T/a15.before"; up "$T 623 623 check "$(upst "$USHA")" stored "an upload into a 1 MiB list is stored" 624 624 n=$(stat -c %s "$T/a15.before"); cmp -s -n "$n" "$T/a15.before" "$W/work/list.tsv" && [ "$(( $(wc -l < "$W/work/list.tsv") - $(wc -l < "$T/a15.before") ))" = 1 ] && [ "$(tail -1 "$W/work/list.tsv" | cut -f2)" = stored ] && ok "every planted row kept byte for byte, the stored row last ($(stat -c %s "$W/work/list.tsv") bytes)" || bad "1 MiB list: rows lost or changed ($(wc -l < "$W/work/list.tsv") rows)" 625 625 cmp -s "$W/work/list.tsv" "$T/data/open/list.tsv" && ok "the published 1 MiB list is the private list, byte for byte" || bad "the published list differs" 626 -c=$(code GET /open.json); python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); n=int(sys.argv[2]); assert len(d["projects"])==n and d["projects"][-1]["rid"]=="rad:"+sys.argv[3], (len(d["projects"]), n)' "$T/body" "$(wc -l < "$W/work/list.tsv")" "$(tail -1 "$W/work/list.tsv" | cut -f1)" && ok "forged lists all $(wc -l < "$W/work/list.tsv") rows of the 1 MiB shelf, the stored one last ($c)" || bad "/open.json with a 1 MiB list: $c" 626 +c=$(code GET /open.json); python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); n=int(sys.argv[2]); assert len(d["projects"])==n and d["projects"][-1]["rid"]==sys.argv[3], (len(d["projects"]), n)' "$T/body" "$(wc -l < "$W/work/list.tsv")" "$(tail -1 "$W/work/list.tsv" | cut -f1)" && ok "forged lists all $(wc -l < "$W/work/list.tsv") rows of the 1 MiB shelf, the stored one last ($c)" || bad "/open.json with a 1 MiB list: $c" 627 627 # a 60 MiB project (no size limit): stored, and largest_project_kib names the key and the volume 628 628 world a16; mktar "$T/big60.tar" "random.bin=@rand:`62914560`" a=b; spoolup "$T/k1" "$K1" "$T/big60.tar" sixty; intake 629 629 check "$(ustate "$K1")" stored "a 60 MiB project is stored" @@ -699,7 +699,7 @@ c=$(code GET "/open/$BIGR.tar"); check "$c" 404 "GET it: 404" 699 699 [ -f "$T/data/open/a/$NEARR.tar" ] && [ "$(sha "$T/data/open/a/$NEARR.tar")" = "$(cat "$T/data/open/a/$NEARR.sha256")" ] && ok "a 10 MiB download within the room is written" || bad "no download within the room" 700 700 printf 'OPEN_RESERVE_STORAGE_BYTES=1\nOPEN_RESERVE_DATA_BYTES=1\n' > "$W/work/reserve"; intake 701 701 z=$(stat -c %s "$T/data/open/a/$BIGR.tar" 2>/dev/null || echo 0); [ "$z" -gt `52428800` ] && [ "$(sha "$T/data/open/a/$BIGR.tar")" = "$(cat "$T/data/open/a/$BIGR.sha256")" ] && ok "with room, a download past the former 50 MiB is written ($z bytes)" || bad "no big download with room: $z" 702 -code GET /open/ > /dev/null; grep -q "rad clone rad:$NEARR" "$T/body" && ! grep -q "Unfinished:" "$T/body" && ok "a shelf card with an empty note has no Unfinished label" || bad "empty Unfinished label on the shelf" 702 +code GET /open/ > /dev/null; grep -q "href=\"/open/$NEARR\"" "$T/body" && ! grep -q "Unfinished:" "$T/body" && ok "a shelf card with an empty note has no Unfinished label" || bad "empty Unfinished label on the shelf" 703 703 code GET "/open/$NEARR" > /dev/null; ! grep -q "Unfinished:" "$T/body" && ! grep -q "pj-dev" "$T/body" && ok "its page has no empty label and, not stored by the hub, no developer section" || bad "empty label or developer section on a fetched row's page" 704 704 code GET "/open/$NEARR.json" > /dev/null; grep -q '"unfinished":""' "$T/body" && ok "the JSON keeps \"unfinished\": \"\"" || bad "JSON unfinished" 705 705 # a hostile hub DID line in the snapshot is escaped patch/READY new file mode 100644 patch/p1decl.om new file mode 100644 @@ -0,0 +1,482 @@ 1 +note patch/p1decl.om: git patch intake (docs/API.md "Git patches"). Every text and global of the slice, 2 +note declared before any use. Prefixes: functions pa*, globals gp*, texts tp*. 3 +note A patch is a `git format-patch --stdout BASE..HEAD` mbox with a title and a description, uploaded 4 +note by the local command `interplane patch` (tools/bring) in one signed POST. The forge checks it, 5 +note applies it once on BASE in a throwaway work tree and keeps the bytes under 6 +note patches////. It never writes a repository and never signs for anyone. 7 +note Repositories are the bare git stores of the Interplane store this build reads, 8 +note projects//repo.git (store/repos.om, server/util.om fksdir); nothing here reads 9 +note Radicle storage. The slice is composed only in a store-reading build (run.sh). 10 +text tpsdir "patches/" 11 +text tpindex "index" 12 +text tptmp "patch-work/" 13 +text tppw "pw" 14 +text tpfmb "mbox" 15 +text tpfst "statement" 16 +text tpfsg "signature" 17 +text tpfhd "head" 18 +text tpfss "status" 19 +text tpftt "title" 20 +text tpfds "description" 21 +text tpfme "meta" 22 +text tpfdf "diff" 23 +text tpnewd ".new-" 24 +text tpopen "open\n" 25 +text tpwm "/m" 26 +text tpww "/w" 27 +text tpwalt "/w/.git/objects/info/alternates" 28 +text tpobj "/objects\n" 29 +text tpdot "." 30 +text tpdd ".." 31 +note ---- routes 32 +text tppats "/patches" 33 +text tppulls "/pulls" 34 +text tppull "/pull" 35 +text tppnew "/patches/new" 36 +text tpsfxp ".patch" 37 +text tpsfxd ".diff" 38 +text tpqpage "page" 39 +note ---- form fields of POST .../patches/new 40 +text tpfcsrf "csrf" 41 +text tpfrepo "repo" 42 +text tpfbase "base" 43 +text tpfttl "title" 44 +text tpfdsc "description" 45 +text tpfmbx "mbox" 46 +text tpfsig "sig" 47 +text tpcsrfe "csrf=" 48 +note ---- the signed statement and the signature check 49 +text tpst1 "interplane-patch 1\n" 50 +text tpns "interplane-patch" 51 +text tpfrom "From " 52 +text tpfrom2 " Mon Sep 17 00:00:00 2001" 53 +text tpdg "diff --git " 54 +text tpgbp "GIT binary patch" 55 +text tpbf "Binary files " 56 +text tprnf "rename from " 57 +text tprnt "rename to " 58 +text tpcpf "copy from " 59 +text tpcpt "copy to " 60 +text tpmcopy "patches with copy headers are not accepted" 61 +note ---- git argv words (the argv-only exec path of server/util.om: fkb, fka, fexec; no shell) 62 +text tpdC "-C" 63 +note the empty tree as git's attribute source: no .gitattributes a patch writes is read (git 2.43 --attr-source) 64 +text tpatsrc "--attr-source=`4b825dc642cb6eb9a060e54bf8d69288fbee4904`" 65 +text tpc "-c" 66 +text tpinit "init" 67 +text tpq "-q" 68 +text tpqq "--quiet" 69 +text tptpl "--template=" 70 +text tpcatf "cat-file" 71 +text tpde "-e" 72 +text tpcmt "^{commit}" 73 +text tpgmb "merge-base" 74 +text tpisa "--is-ancestor" 75 +text tprh "refs/heads/" 76 +text tprdt "read-tree" 77 +text tpupr "update-ref" 78 +text tpnod "--no-deref" 79 +text tphead "HEAD" 80 +text tpam "am" 81 +text tpamd "--committer-date-is-author-date" 82 +text tpamk "--keep-cr" 83 +text tpamn "--no-verify" 84 +text tpam3 "--no-3way" 85 +text tprevp "rev-parse" 86 +text tprevl "rev-list" 87 +text tpcnt "--count" 88 +text tpdots ".." 89 +text tpdiff "diff" 90 +text tpraw "--raw" 91 +text tpnumst "--numstat" 92 +text tpnorn "--no-renames" 93 +text tpfull "--full-index" 94 +text tpdM "-M" 95 +text tpnoext "--no-ext-diff" 96 +text tpnotc "--no-textconv" 97 +note the configuration every git run in the throwaway work tree carries: no hooks, no maintenance, 98 +note no network transport, no filter program, symbolic links written as plain files, a fixed committer 99 +text tpk1 "core.hooksPath=/dev/null" 100 +text tpk2 "gc.auto=0" 101 +text tpk3 "maintenance.auto=false" 102 +text tpk4 "protocol.allow=never" 103 +text tpk5 "core.fsmonitor=false" 104 +text tpk6 "core.symlinks=false" 105 +text tpk7 "core.autocrlf=false" 106 +text tpk8 "commit.gpgSign=false" 107 +text tpk9 "user.name=interplane-forge" 108 +text tpk10 "user.email=forge@interplane.io" 109 +text tpk11 "filter.lfs.clean=" 110 +text tpk12 "filter.lfs.smudge=" 111 +text tpk13 "filter.lfs.process=" 112 +text tpk14 "filter.lfs.required=false" 113 +text tpk15 "core.attributesFile=/dev/null" 114 +text tpk16 "submodule.recurse=false" 115 +text tpk17 "init.defaultBranch=main" 116 +note ---- text answers of the upload (plain text, one reason a refusal) 117 +text tpctxt "text/plain; charset=utf-8" 118 +text tprefu "refused: " 119 +text tpacc "accepted\n" 120 +text tpexi "exists\n" 121 +text tpaid "id " 122 +text tpapth "path " 123 +text tpm403 "sign in first: this request carries no session" 124 +text tpmcsrf "missing or wrong CSRF token" 125 +text tpmrate "too many writes from this address or key; wait a minute" 126 +text tpmoff "writes are switched off on this forge right now" 127 +text tpmform "the body is not the patch form: fields csrf, repo, base, title, description, mbox and sig, each once" 128 +text tpmnorp "no such public repository" 129 +text tpmrepo "the repo field does not name this repository" 130 +text tpmnogs "this repository has no git store on this forge" 131 +text tpmbase "base is not a commit id of 40 lowercase hex digits" 132 +text tpmunk "unknown base: the repository has no such commit" 133 +text tpmnotm "base is not reachable from the repository's main branch" 134 +text tpmttl "the title must be 1 to 256 bytes of UTF-8 text on one line" 135 +text tpmdsc "the description must be at most 60000 bytes of UTF-8 text without control bytes" 136 +text tpmbig "the mbox is larger than `2097152` bytes" 137 +text tpmb64 "the mbox field is not base64url without padding" 138 +text tpmnfp "the mbox is not git format-patch output" 139 +text tpmmany "the mbox holds more than 100 commits" 140 +text tpmsigf "the sig field is not an armored SSH signature" 141 +text tpmsig "the signature does not verify for this session's key and this patch" 142 +text tpmbin "binary patches are not accepted" 143 +text tpmpath "a patch names a path outside the repository" 144 +text tpmappl "the mbox does not apply cleanly on base" 145 +text tpmcnt "git applied a different number of commits than the mbox holds" 146 +text tpmsub "the patch adds a submodule" 147 +text tpmdbig "the combined diff of the patch is larger than 16 MiB" 148 +text tpmint "the forge could not check the patch (internal error)" 149 +text tpmwr "the forge could not store the patch" 150 +text tplrm "PATCH-TMP a work folder under patch-work/ (pw...) could not be removed\n" 151 +note ---- pages 152 +text tptlist "Patches" 153 +text tptnew "Open a patch" 154 +text tppor1 "https://interplane.io" 155 +text tppor2 "https://www.aienos.com" 156 +text tph1 "
    " 157 +text tph1a " patch " 158 +text tph1b " patches " 159 +text tph2 "How to open a patch
    \n" 161 +text tphul "
      \n" 162 +text tphule "
    \n" 163 +text tphli "
  • " 165 +text tphae "" 166 +text tphm1 "
    open " 167 +text tphm2 " opened " 168 +text tphby " by " 169 +text tphm3 " · " 170 +text tphc1 " commit" 171 +text tphc2 " commits" 172 +text tphf1 " file" 173 +text tphf2 " files" 174 +text tphm4 "
  • \n" 175 +text tphnone "

    No patches yet.

    \n" 176 +text tphpg1 "
    " 177 +text tphpgn "\">Newer" 178 +text tphpgo "\">Older" 179 +text tphpg2 "
    \n" 180 +text tphqp "/patches?page=" 181 +text tphcode "" 182 +text tphcodz "" 183 +text tphp1 "

    " 184 +text tphp2 "

    \n

    open " 185 +text tphp3 "

    \n

    " 186 +text tphp4 " bytes. Base . Applied head " 189 +text tphp6 ": the last commit this forge's own git am made on the base. It is in no repository; the owner applies the patch by hand.

    \n
    \n" 190 +text tphds1 "
    "
    
    191 +text tphpre "
    \n" 192 +text tphap1 "

    Apply it

    \n
    git checkout -b patch-"
    
    193 +text tphap2 "\ncurl -fsSL "
    
    194 +text tphap3 " | git am
    \n

    Raw patch (mbox) · Diff

    \n" 197 +text tphsg1 "

    Signature

    \n

    The author's key " 198 +text tphsg2 " signed this statement with ssh-keygen -Y sign -n interplane-patch; 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.

    \n
    "
    
    199 +text tphsg3 "
    "
    
    200 +text tphdv "
    \n" 201 +text tphdf1 "

    Changes

    \n
    "
    
    202 +text tphdfc "

    The diff is longer than this page shows; the raw diff has all of it.

    \n" 203 +text tphn1 "

    Open a patch

    \n

    A patch is a set of commits you propose for this project. You send it from your own clone with the interplane program; your key signs it on your computer and never leaves it. The owner applies a patch by hand.

    \n
    interplane patch "
    
    204 +text tphn2 "
    \n

    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 git format-patch output, no binary patches.

    \n
    \n" 205 +note ---- JSON (docs/API.md forge/patch-list/1 and forge/patch/1) 206 +text tpjl1 "{\"schema\":\"forge/patch-list/1\",\"base\":\"" 207 +text tpjp1 "{\"schema\":\"forge/patch/1\",\"base\":\"" 208 +text tpjown "\",\"owner\":\"" 209 +text tpjrep "\",\"repo\":\"" 210 +text tpjpage "\",\"page\":" 211 +text tpjper ",\"per_page\":30,\"count\":" 212 +text tpjpats ",\"patches\":[\n" 213 +text tpjnext "\n],\"next\":" 214 +text tpjprev ",\"prev\":" 215 +text tpjend "}\n" 216 +text tpjid "{\"id\":\"" 217 +text tpjid2 "\",\"id\":\"" 218 +text tpjttl "\",\"title\":" 219 +text tpjdsc ",\"description\":" 220 +text tpjnm ",\"name\":" 221 +note the keys of SPEC section 3 after title, in their order (fyk / fyk0 of server/jsonp.om) 222 +text tpkst "status" 223 +text tpksd "state_derived" 224 +text tpkau "author" 225 +text tpkdid "did" 226 +text tpkim "imported" 227 +text tpkbc "base_commit" 228 +text tpkhc "head_commit" 229 +text tpkcm "commits" 230 +text tpkfl "files" 231 +text tpkby "bytes" 232 +text tpkcd "code" 233 +text tpksha "mbox_sha256" 234 +text tpkop "opened" 235 +text tpkcl "closed" 236 +text tpkmg "merge" 237 +text tpklb "labels" 238 +text tpkco "comments" 239 +text tpkcr "created" 240 +text tpkcc "comments_count" 241 +text tpkpt "path" 242 +text tpkpa "patch" 243 +text tpkdf "diff" 244 +text tpkbn "bundle" 245 +text tpkst2 "states" 246 +text tpkdm "damaged" 247 +text tpkdu "diff_unavailable" 248 +text tpktt "thread_truncated" 249 +text tpktr "thread_reason" 250 +note the values of diff_unavailable (pajduw) and of thread_reason (pajtrw; "too-large" is in both) 251 +text tpun1 "no-code-file" 252 +text tpun2 "no-base" 253 +text tpun3 "base-not-in-store" 254 +text tpun4 "too-large" 255 +text tpun5 "bundle-too-large" 256 +text tpun6 "diff-failed" 257 +text tptr1 "malformed-record" 258 +text tptr3 "document-budget" 259 +text tpkfrm "from" 260 +text tpkow "owner" 261 +text tpkrp "repo" 262 +text tpknum "number" 263 +text tpkurl "url" 264 +text tpklog "login" 265 +text tpkknd "kind" 266 +text tpkstt "state" 267 +text tpkln "line" 268 +text tpktim "time" 269 +text tpkbdy "body" 270 +text tpkcmt "commit" 271 +text tpkrch "reach" 272 +text tpkmn "main" 273 +text tpkobs "observed" 274 +text tpkmb "mbox" 275 +text tpknone "none" 276 +text tpgith "github" 277 +text tpdash "-" 278 +text tpjnull "null" 279 +text tpjsep ",\n" 280 +note ---- request state 281 +note gpfv: one percent-decoded form field (padec), read by the field checks and patch/p2utf8.om 282 +global gpfv uchar 65536 283 +note gpfo / gpfn / gpfs: offset, length and presence of the seven form fields in fbig, by index: 284 +note 0 csrf, 1 repo, 2 base, 3 title, 4 description, 5 mbox, 6 sig 285 +global gpfo ulong 8 286 +global gpfn ulong 8 287 +global gpfs ulong 8 288 +note gpmb: the decoded mbox (F1: at most 2 MiB) 289 +global gpmb uchar `2097152` 290 +global gpmbl ulong 1 291 +note gpttl: the title; a signed patch's is at most 256 bytes (F2), an imported item's is cut to 1024 292 +global gpttl uchar 1024 293 +global gpttll ulong 1 294 +global gpdsc uchar 60000 295 +global gpdscl ulong 1 296 +global gpsig uchar 4096 297 +global gpsigl ulong 1 298 +global gpbase uchar 40 299 +global gphead uchar 40 300 +global gpid uchar 16 301 +global gpst uchar 512 302 +global gpstl ulong 1 303 +note gpncm: commits the mbox holds; gpnfl: files the applied patch changed; gpgrd: what the scan of 304 +note the mbox found (0 nothing, 2 a binary patch, 3 a path outside the repository) 305 +global gpncm ulong 1 306 +global gpnfl ulong 1 307 +global gpgrd ulong 1 308 +note gpp: path builder; gpstm: the 16 hex digits that name this request's work folder and staging 309 +note folder; gpde: one batch of directory entries (the work-folder remover) 310 +global gpp uchar 4096 311 +global gppl ulong 1 312 +global gpstm uchar 16 313 +global gpde uchar 32768 314 +note ---- a stored patch read back (paload): author DID, creation time, commit and file counts, mbox 315 +note bytes and its SHA-256 from the meta file; title, base and head in the globals above 316 +global gpmdid uchar 128 317 +global gpmdidl ulong 1 318 +global gpmts ulong 1 319 +global gpmcm ulong 1 320 +global gpmfl ulong 1 321 +global gpmby ulong 1 322 +global gpmsha uchar 64 323 +note gpix: the index file of one list request (paixld). The page loaders read every item through fxo, 324 +note so the index cannot stay there while the items of the list are counted. As large as fxo: an index 325 +note of `16777216` bytes or more (986896 lines) is the whole 500 of fincut, as before 326 +global gpix uchar `16777216` 327 +note gpids: the ids of one list page (30 rows of 16 hex digits); gpln: a small line buffer 328 +global gpids uchar 480 329 +global gpln uchar 256 330 +global gplnl ulong 1 331 +note gpcur / gpbad: read position and failure flag of the meta file parser 332 +global gpcur ulong 1 333 +global gpbad ulong 1 334 +note ---- imported proposals (SPEC prstore/r1 extension, patch/p5imp.om); files of an item folder 335 +text tpfsj "source.json" 336 +text tpfgh "gh" 337 +text tpfth "thread" 338 +text tpflb "labels" 339 +text tpfmg "merged" 340 +text tpfrc "reach" 341 +text tpfbn "head.bundle" 342 +text tpdpd "pdiff/" 343 +text tpsfxg ".big" 344 +text tpsw1 "closed\n" 345 +text tpsw2 "merged\n" 346 +text tpsjpre "{\"kind\":\"github-import\",\"owner\":\"" 347 +text tpsjow "\"owner\":\"" 348 +text tpsjrp "\"repo\":\"" 349 +text tpsjurl "\"url\":\"" 350 +text tpsjutc "\"imported_utc\":\"" 351 +text tpsjnum "\"number\":" 352 +text tpsjder "\"state_derived\":true" 353 +text tpghn "number " 354 +text tpghl "login " 355 +text tpgho "opened " 356 +text tpghc "closed " 357 +text tpghm "merged " 358 +text tprcom "comment" 359 +text tprrev "review" 360 +text tprrc "review-comment" 361 +text tprch1 "reachable" 362 +text tprch2 "not-reachable" 363 +text tprch3 "unknown" 364 +text tpwopn "open" 365 +text tpwclo "closed" 366 +text tpwmrg "merged" 367 +text tpsfxb ".bundle" 368 +text tpctbin "application/octet-stream" 369 +text tpbund "bundle" 370 +text tpunb "unbundle" 371 +text tpnocol "--no-color" 372 +text tpdots3 "..." 373 +text tpm409 "another item of this store holds this patch id" 374 +text tpmdint "the diff could not be made (internal error)\n" 375 +note ---- imported proposals: HTML 376 +text tputc " UTC" 377 +text tpimp1 "Imported from GitHub " 378 +text tpimp2 ", by " 379 +text tpimp3 " (code only)" 380 +text tpbok "" 381 +text tpbbad "" 382 +text tpbmut "" 383 +text tpboff "" 384 +text tpbder " derived" 385 +text tpnotl "(untitled)" 386 +text tpiwi " imported " 387 +text tpiwo " opened " 388 +text tpir1 "
    " 389 +text tpir2 " " 390 +text tpsth "" 391 +text tpsto " open · " 392 +text tpstc " closed · " 393 +text tpstm " merged " 394 +text tpdmg1 "" 395 +text tpdmg2 " damaged item is not shown " 396 +text tpdmg3 " damaged items are not shown " 397 +text tpip2 "\n

    " 398 +text tpipn " #" 399 +text tpito " · opened " 400 +text tpitc " · closed " 401 +text tpitm " · merged " 402 +text tpipm "

    " 403 +text tpipe "

    \n" 404 +text tpider "

    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).

    \n" 405 +text tpilab "Labels: " 406 +text tpisb "Base " 407 +text tpisb2 " · " 408 +text tpisnb "No base commit · " 409 +text tpish "Head " 410 +text tpimg1 "Merged on GitHub as " 411 +text tpimr1 "; reachable from main " 412 +text tpimr2 "; not reachable from main " 413 +text tpimr3 "; reachability from main unknown" 414 +text tpimro " (observed " 415 +text tpibox "

    " 416 +text tpiwr " wrote on " 417 +text tpidsc "Description" 418 +text tpidbig "

    The description is too large for this page.

    \n" 419 +text tpirv1 " reviewed (" 420 +text tpirv2 ") on " 421 +text tpirc1 " commented on " 422 +text tpirc2 " line " 423 +text tpion " on " 424 +text tpitbad "

    The thread stops here: its next record is malformed.

    \n" 425 +text tpitcut "

    The thread is too long for this page; the rest is not shown.

    \n" 426 +text tpitbig "

    The thread file is larger than this forge reads; the rest is not shown.

    \n" 427 +text tpibd1 "

    Fetch it

    \n

    A git bundle of the pull request's head, " 428 +text tpibd2 " bytes.

    \n
    curl -fsSL "
    
    429 +text tpibd3 " -o "
    
    430 +text tpibd4 "\ngit fetch "
    
    431 +text tpibd4b " refs/pull/"
    
    432 +text tpibd5 "/head
    \n

    Raw bundle" 434 +text tpibd7 " ·

    \n" 436 +text tpicn1 "\n" 438 +text tpipv1 "

    Provenance

    \n

    This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

    \n
    "
    
    439 +text tpich "

    Changes

    \n

    " 440 +text tpicg0 "There is no diff: the head commit is already on main." 441 +text tpicg7 "There is no diff: this item holds no code file." 442 +text tpicx "

    Code

    \n

    This item holds no code file.

    \n" 443 +text tpicg1 "There is no stored diff for this mbox." 444 +text tpicg2 "There is no diff: the bundle has no base commit." 445 +text tpicg3 "There is no diff: the base commit is not in this project's git store." 446 +text tpicg4 "The diff is larger than 16 MiB, too large to show: fetch the bundle instead." 447 +text tpicg5 "The diff could not be made (internal error)." 448 +text tpicg6 "The diff is empty." 449 +text tpicg8 "This bundle is larger than the display limit. Fetch the bundle to see the changes." 450 +note gpimp: the loaded item is imported (1) or signed (0); gpist: its status (0 open, 1 closed, 2 451 +note merged); gpider: its state is derived (code-only); gpicode: its code file (0 none, 1 mbox, 2 452 +note head.bundle; its size in gpmby); gpihb: it has a base (gpbase); gpnum: its GitHub number; gpbd: 453 +note the bundle diff (pabdiff's answer; 9 not asked); gpsc: the items a list page shows by state (list 454 +note head); gptr: why the comments of forge/patch/1 are not the whole thread (pajcoms: 0 they are, 1 a 455 +note malformed record, 2 the thread file is larger than gpth, 3 the document budget PAJMX) 456 +global gpimp ulong 1 457 +global gpist ulong 1 458 +global gpider ulong 1 459 +global gpicode ulong 1 460 +global gpihb ulong 1 461 +global gpnum ulong 1 462 +global gpbd ulong 1 463 +global gpsc ulong 3 464 +global gptr ulong 1 465 +note gpr: offsets and lengths of the parsers (thread record, gh line, source.json value, reach line) 466 +global gpr ulong 16 467 +note gpsrc: source.json (its first 4096 bytes); gpgh: the gh file (its first 2048 bytes); gpth: the 468 +note thread (as much as fxo reads; gpthc 1 when the file is larger) 469 +global gpsrc uchar 4096 470 +global gpsrcl ulong 1 471 +global gpgh uchar 2048 472 +global gpghl ulong 1 473 +global gpth uchar `16777216` 474 +global gpthl ulong 1 475 +global gpthc ulong 1 476 +note PAPGMX: the most an imported page's description and thread take of fob (8 MiB), so the 477 +note provenance box and a 400000-byte diff (6 bytes each at most, escaped) still fit after them 478 +const PAPGMX ulong `5000000` 479 +note PAJMX: the most forge/patch/1 takes of fob (`8388608` bytes) up to the end of its comments. The 480 +note 65536 bytes left hold the rest of the document: at most 24578 bytes of "created" (a source.json 481 +note value of up to 4096 bytes, 6 bytes each escaped), four links of under 250 bytes and the fixed keys 482 +const PAJMX ulong `8323072` patch/p2base.om new file mode 100644 @@ -0,0 +1,522 @@ 1 +note patch/p2base.om: the path builder, the byte sources and SHA-256 over them, file writes, the git 2 +note argument lists and the remover of a request's work folder. 3 +const PATMO long `20000000000` 4 +note ---- path builder gpp (host words take the global directly) 5 +fn papc c uchar to void 6 +n = get gppl 0 7 +if lt n 4095 8 +put gpp n c 9 +put gppl 0 add n 1 10 +end 11 +end 12 +fn papt t view uchar * to void 13 +for i ulong len t bound 4096 14 +papc get t i 15 +end 16 +end 17 +note papb: gpp = 18 +fn papb to void 19 +put gppl 0 0 20 +papt tfdata 21 +end 22 +note paprn: the repository's name (the public-list row fridx) appended to gpp 23 +fn paprn to void 24 +i = get fridx 0 25 +for k ulong get fanl i bound 128 26 +papc frnbyte i k 27 +end 28 +end 29 +note paprepo: gpp = patches/// 30 +fn paprepo to void 31 +papb 32 +papt tpsdir 33 +papt tfowner 34 +papc 47 35 +paprn 36 +papc 47 37 +end 38 +note papid t: gpp = patches//// 39 +fn papid t view uchar * to void 40 +paprepo 41 +for k ulong 16 42 +papc get gpid k 43 +end 44 +papc 47 45 +papt t 46 +end 47 +note papnew t: gpp = patches///.new-/, this request's staging folder 48 +fn papnew t view uchar * to void 49 +paprepo 50 +papt tpnewd 51 +for k ulong 16 52 +papc get gpstm k 53 +end 54 +papc 47 55 +papt t 56 +end 57 +note papw t: gpp = patch-work/pw, this request's work folder (t is empty or starts with /) 58 +fn papw t view uchar * to void 59 +papb 60 +papt tptmp 61 +papt tppw 62 +for k ulong 16 63 +papc get gpstm k 64 +end 65 +papt t 66 +end 67 +note papgs: gpp = projects//repo.git, the repository's bare git store, built by the 68 +note store's own path builder (store/repos.om xspproj, as xsfolders does) in fpth and copied 69 +fn papgs to void 70 +xspproj get fridx 0 71 +fpt tfsrg 72 +put gppl 0 0 73 +for i ulong get fpthl 0 bound 4096 74 +papc get fpth i 75 +end 76 +end 77 +note paexist: the path in gpp exists 78 +fn paexist to bool 79 +r = stat gpp 0 get gppl 0 fstb 0 128 80 +ret ge r 0 81 +end 82 +note pamkdir: make the folder gpp (0700); true when it exists afterwards 83 +fn pamkdir to bool 84 +r = makedir gpp 0 get gppl 0 448 85 +if ge r 0 86 +ret true 87 +end 88 +ret paexist 89 +end 90 +note ---- byte sources. pasb w i: byte i of source w: 0 the mbox, 1 the statement, 2 the signature, 91 +note 3 the title, 4 the description, 5 the line buffer, 6 fxo, 7 title + line feed + description 92 +fn pasb w ulong i ulong to uchar 93 +if eq w 0 94 +ret get gpmb i 95 +end 96 +if eq w 1 97 +ret get gpst i 98 +end 99 +if eq w 2 100 +ret get gpsig i 101 +end 102 +if eq w 3 103 +ret get gpttl i 104 +end 105 +if eq w 4 106 +ret get gpdsc i 107 +end 108 +if eq w 5 109 +ret get gpln i 110 +end 111 +if eq w 6 112 +ret get fxo i 113 +end 114 +ret patd i 115 +end 116 +fn patd i ulong to uchar 117 +n = get gpttll 0 118 +if lt i n 119 +ret get gpttl i 120 +end 121 +if eq i n 122 +ret uchar 10 123 +end 124 +ret get gpdsc sub sub i n 1 125 +end 126 +note pahs w n o: o = SHA-256 of the first n bytes of source w 127 +fn pahs w ulong n ulong o edit uchar 32 to void 128 +c = new ulong 40 0 129 +b = new uchar 4096 0 130 +sha256_init c 131 +p = ulong 0 132 +while lt p n bound `16777216` 133 +k = hmin sub n p 4096 134 +for i ulong k bound 4096 135 +put b i pasb w add p i 136 +end 137 +sha256_update c part b 0 k 138 +p = add p k 139 +end 140 +sha256_final c o 141 +end 142 +note ---- the line buffer gpln 143 +fn palb to void 144 +put gplnl 0 0 145 +end 146 +fn palc c uchar to void 147 +n = get gplnl 0 148 +if lt n 255 149 +put gpln n c 150 +put gplnl 0 add n 1 151 +end 152 +end 153 +fn paln v ulong to void 154 +d = new uchar 20 0 155 +k = sodec v d 156 +for i ulong k bound 20 157 +palc get d i 158 +end 159 +end 160 +note ---- files 161 +note pawall: all k bytes of b to fd 162 +fn pawall fd int b view uchar 4096 k ulong to bool 163 +q = ulong 0 164 +for it ulong 8192 165 +if ge q k 166 +ret true 167 +end 168 +r = write fd b q sub k q 169 +if le r 0 170 +if ne r -4 171 +ret false 172 +end 173 +else 174 +q = add q ulong r 175 +end 176 +end 177 +ret false 178 +end 179 +note pawf w n: create the file gpp (exclusive, 0600, no link followed) holding the first n bytes of 180 +note source w, written through to the disk before it is closed 181 +fn pawf w ulong n ulong to bool 182 +fd = fopen gpp 0 get gppl 0 557249 384 183 +if lt fd 0 184 +ret false 185 +end 186 +b = new uchar 4096 0 187 +p = ulong 0 188 +ok = true 189 +while lt p n bound `16777216` 190 +k = hmin sub n p 4096 191 +for i ulong k bound 4096 192 +put b i pasb w add p i 193 +end 194 +if not pawall int fd b k 195 +ok = false 196 +break 197 +end 198 +p = add p k 199 +end 200 +if ok 201 +s = fsync int fd 202 +if lt s 0 203 +ok = false 204 +end 205 +end 206 +x = fclose int fd 207 +ret ok 208 +end 209 +note pawtxt t: the file gpp holding the text t 210 +fn pawtxt t view uchar * to bool 211 +palb 212 +for i ulong len t bound 255 213 +palc get t i 214 +end 215 +ret pawf 5 get gplnl 0 216 +end 217 +note ---- git argument lists (server/util.om fkb / fka / fkopen / fkc, run by fexec: no shell, empty 218 +note environment, standard input and error /dev/null) 219 +fn pakp to void 220 +for i ulong get gppl 0 bound 4096 221 +fkc get gpp i 222 +end 223 +end 224 +fn pakbase to void 225 +for i ulong 40 226 +fkc get gpbase i 227 +end 228 +end 229 +note pakst: argv = git --git-dir=/projects//repo.git 230 +fn pakst to void 231 +fkb 232 +fka tfgit 233 +fkopen 234 +fkt tfgitdir 235 +papgs 236 +pakp 237 +end 238 +fn pakc1 t view uchar * to void 239 +fka tpc 240 +fka t 241 +end 242 +note pakwt: argv = git -C /w --attr-source= -c ... for every git run in 243 +note the throwaway work tree. The attribute source is the empty tree, so no .gitattributes file the 244 +note patch writes (nor the index's) changes what git reports or converts: binary tests, diff drivers, 245 +note textconv, filters and line endings all see no attributes. 246 +fn pakwt to void 247 +fkb 248 +fka tfgit 249 +fka tpdC 250 +fkopen 251 +papw tpww 252 +pakp 253 +fka tpatsrc 254 +pakc1 tpk1 255 +pakc1 tpk2 256 +pakc1 tpk3 257 +pakc1 tpk4 258 +pakc1 tpk5 259 +pakc1 tpk6 260 +pakc1 tpk7 261 +pakc1 tpk8 262 +pakc1 tpk9 263 +pakc1 tpk10 264 +pakc1 tpk11 265 +pakc1 tpk12 266 +pakc1 tpk13 267 +pakc1 tpk14 268 +pakc1 tpk15 269 +pakc1 tpk16 270 +end 271 +note ---- the work folder remover. git fills patch-work/pw/ with the files and folders a patch 272 +note names, so nothing about their names, depth or kind is assumed. A forked child changes into the 273 +note folder and removes by relative name from the inside: a file, link or other entry is unlinked, an 274 +note empty folder removed, and a folder that is not empty is entered through a descriptor opened with 275 +note no-follow (a link is never entered) and emptied first. No path is built, so no path length or 276 +note depth limits it, and it only ever steps back up as often as it stepped down. 277 +fn parmnl o ulong to ulong 278 +k = ulong 0 279 +while lt k 256 bound 256 280 +if eq get gpde add o k 0 281 +ret k 282 +end 283 +k = add k 1 284 +end 285 +ret k 286 +end 287 +note parmdot: the entry name at o is . or .. 288 +fn parmdot o ulong nl ulong to bool 289 +if eq nl 1 290 +ret eq get gpde o 46 291 +end 292 +if eq nl 2 293 +if eq get gpde o 46 294 +ret eq get gpde add o 1 46 295 +end 296 +end 297 +ret false 298 +end 299 +note parment: remove the entry at o (type ty, 4 a folder): 1 removed, 2 entered it, 3 cannot 300 +fn parment o ulong nl ulong ty uchar to ulong 301 +r = long 0 302 +if ne ty 4 303 +r = unlink gpde o nl 304 +if ge r 0 305 +ret 1 306 +end 307 +if ne r -21 308 +ret 3 309 +end 310 +end 311 +r = rmdir gpde o nl 312 +if ge r 0 313 +ret 1 314 +end 315 +fd = fopen gpde o nl 573440 0 316 +if lt fd 0 317 +ret 3 318 +end 319 +r = fchdir int fd 320 +x = fclose int fd 321 +if lt r 0 322 +ret 3 323 +end 324 +ret 2 325 +end 326 +note parmscan: one pass over the folder open as fd: 0 it is empty, 1 entries were removed (scan again), 327 +note 2 entered a folder, 3 an entry could not be removed 328 +fn parmscan fd int to ulong 329 +seen = ulong 0 330 +for it ulong `1000000` 331 +n = getdnts fd gpde 0 32768 332 +if le n 0 333 +break 334 +end 335 +p = ulong 0 336 +while lt p ulong n bound 32768 337 +rl = or ulong get gpde add p 16 shl ulong get gpde add p 17 8 338 +if eq rl 0 339 +ret 3 340 +end 341 +nl = parmnl add p 19 342 +if not parmdot add p 19 nl 343 +seen = add seen 1 344 +r = parment add p 19 nl get gpde add p 18 345 +if ge r 2 346 +ret r 347 +end 348 +end 349 +p = add p rl 350 +end 351 +end 352 +if gt seen 0 353 +ret 1 354 +end 355 +ret 0 356 +end 357 +note parmch: the child: empty the current folder and everything below it, then exit 0 358 +fn parmch to void 359 +dep = ulong 0 360 +for it ulong `4000000000` 361 +fd = fopen tpdot 0 1 540672 0 362 +if lt fd 0 363 +exit 3 364 +end 365 +st = parmscan int fd 366 +x = fclose int fd 367 +if eq st 3 368 +exit 4 369 +end 370 +if eq st 2 371 +dep = add dep 1 372 +end 373 +if eq st 0 374 +if eq dep 0 375 +exit 0 376 +end 377 +r = chdir tpdd 0 2 378 +if lt r 0 379 +exit 5 380 +end 381 +dep = sub dep 1 382 +end 383 +end 384 +exit 6 385 +end 386 +note parmtree: remove this request's work folder and all it holds (30 s, then the child is killed) 387 +fn parmtree to bool 388 +papw part tpdot 0 0 389 +pid = fork 390 +if lt pid 0 391 +ret false 392 +end 393 +if eq pid 0 394 +r = chdir gpp 0 get gppl 0 395 +if lt r 0 396 +exit 2 397 +end 398 +parmch 399 +exit 0 400 +end 401 +dl = add long monons `30000000000` 402 +st = freap int pid dl 403 +papw part tpdot 0 0 404 +q = rmdir gpp 0 get gppl 0 405 +ret and eq st 0 ge q 0 406 +end 407 +note ---- small files of an item (patch/p5imp.om): read without fxo, so a caller may keep a listing there 408 +note pards: the file gpp into gpln (its first 256 bytes); the bytes read (256: the file has at least 409 +note that many), or -errno 410 +fn pards to long 411 +put gplnl 0 0 412 +fd = fopen gpp 0 get gppl 0 524288 0 413 +if lt fd 0 414 +ret fd 415 +end 416 +for it ulong 64 417 +n = get gplnl 0 418 +if ge n 256 419 +break 420 +end 421 +r = read int fd gpln n sub 256 n 422 +if le r 0 423 +break 424 +end 425 +put gplnl 0 add n ulong r 426 +end 427 +x = fclose int fd 428 +ret long get gplnl 0 429 +end 430 +note pal40: gpln is 40 lowercase hex digits and a line feed 431 +fn pal40 to bool 432 +if ne get gplnl 0 41 433 +ret false 434 +end 435 +for i ulong 40 436 +if lt sohexv get gpln i 0 437 +ret false 438 +end 439 +end 440 +ret eq get gpln 40 10 441 +end 442 +note palnis t: gpln is exactly t 443 +fn palnis t view uchar * to bool 444 +if ne get gplnl 0 len t 445 +ret false 446 +end 447 +for i ulong len t bound 256 448 +if ne get gpln i get t i 449 +ret false 450 +end 451 +end 452 +ret true 453 +end 454 +note pastrd: the status file of item gpid: 0 "open\n", 1 "closed\n", 2 "merged\n", 9 anything else 455 +fn pastrd to ulong 456 +papid tpfss 457 +r = pards 458 +if palnis tpopen 459 +ret 0 460 +end 461 +if palnis tpsw1 462 +ret 1 463 +end 464 +if palnis tpsw2 465 +ret 2 466 +end 467 +ret 9 468 +end 469 +note pastsz: the size of the file paexist last found (st_size of struct stat, aarch64 offset 48) 470 +fn pastsz to ulong 471 +v = ulong 0 472 +for i ulong 8 473 +v = or v shl ulong get fstb add 48 i mul i 8 474 +end 475 +ret v 476 +end 477 +note ---- the bundle diff cache: pdiff/// (derived data, safe to delete) 478 +note papdr: gpp = pdiff/// 479 +fn papdr to void 480 +papb 481 +papt tpdpd 482 +papt tfowner 483 +papc 47 484 +paprn 485 +papc 47 486 +end 487 +note papdf: gpp = the cache file of item gpid 488 +fn papdf to void 489 +papdr 490 +for k ulong 16 491 +papc get gpid k 492 +end 493 +end 494 +note papdfg: gpp = the marker beside it, .big: an empty file that says the bundle diff of item gpid 495 +note was cut at 16 MiB (patch/p5imp.om pabbig) 496 +fn papdfg to void 497 +papdf 498 +papt tpsfxg 499 +end 500 +note papdfn: gpp = this request's staging file beside it, .new- 501 +fn papdfn to void 502 +papdr 503 +papt tpnewd 504 +for k ulong 16 505 +papc get gpstm k 506 +end 507 +end 508 +note pamkpd: make pdiff/// (0700 each); false when it is not there afterwards 509 +fn pamkpd to bool 510 +papb 511 +papt tpdpd 512 +if not pamkdir 513 +ret false 514 +end 515 +papt tfowner 516 +if not pamkdir 517 +ret false 518 +end 519 +papc 47 520 +paprn 521 +ret pamkdir 522 +end patch/p2utf8.om new file mode 100644 @@ -0,0 +1,79 @@ 1 +note patch/p2utf8.om: the text rules of a title and a description (docs/collab-write.md section 2), 2 +note over the decoded field gpfv. The same code as collab/co9comp.om cowutf8, coctlok and coulen under 3 +note this slice's names: the store-reading build composes collab out (server/nocollab.om), so the 4 +note patch intake carries its own copy and needs no collab unit. 5 +note pawutf8 n ml: well-formed UTF-8 (no overlong forms, surrogates or code points over U+10FFFF), no 6 +note NUL, C0 control or DEL byte except tab and LF when ml 7 +fn pawutf8 n ulong ml bool to bool 8 +i = ulong 0 9 +while lt i n bound 70000 10 +c = get gpfv i 11 +if lt c 128 12 +if eq pactlok c ml false 13 +ret false 14 +end 15 +i = add i 1 16 +else 17 +k = paulen i n 18 +if eq k 0 19 +ret false 20 +end 21 +i = add i k 22 +end 23 +end 24 +ret true 25 +end 26 +fn pactlok c uchar ml bool to bool 27 +if eq c 127 28 +ret false 29 +end 30 +if ge c 32 31 +ret true 32 +end 33 +if and ml or eq c 9 eq c 10 34 +ret true 35 +end 36 +ret false 37 +end 38 +note paulen i n: byte length of the multi-byte sequence at gpfv[i], 0 when it is malformed 39 +fn paulen i ulong n ulong to ulong 40 +c = get gpfv i 41 +k = ulong 0 42 +lo = uchar 128 43 +hi = uchar 191 44 +if and ge c 194 le c 223 45 +k = ulong 2 46 +end 47 +if and ge c 224 le c 239 48 +k = ulong 3 49 +if eq c 224 50 +lo = uchar 160 51 +end 52 +if eq c 237 53 +hi = uchar 159 54 +end 55 +end 56 +if and ge c 240 le c 244 57 +k = ulong 4 58 +if eq c 240 59 +lo = uchar 144 60 +end 61 +if eq c 244 62 +hi = uchar 143 63 +end 64 +end 65 +if or eq k 0 gt add i k n 66 +ret ulong 0 67 +end 68 +d = get gpfv add i 1 69 +if or lt d lo gt d hi 70 +ret ulong 0 71 +end 72 +for j ulong sub k 2 bound 2 73 +d = get gpfv add add i 2 j 74 +if or lt d 128 gt d 191 75 +ret ulong 0 76 +end 77 +end 78 +ret k 79 +end patch/p3gate.om new file mode 100644 @@ -0,0 +1,401 @@ 1 +note patch/p3gate.om: the upload form in fbig (server/main.om freqbig), the write gate, the text 2 +note answers, and the field decoders. 3 +note ---- text answers (kind 1, text/plain) 4 +fn patext to void 5 +put fobl 0 0 6 +put fkind 0 1 7 +fsetct tpctxt 8 +end 9 +note parefu: "refused: " with status st 10 +fn parefu st ulong t view uchar * to long 11 +patext 12 +fput tprefu 13 +fput t 14 +fputc 10 15 +ret long st 16 +end 17 +note ---- the form: name=value pairs joined by &, each of the seven names once, nothing else 18 +fn pafis s ulong e ulong t view uchar * to bool 19 +if ne sub e s len t 20 +ret false 21 +end 22 +for i ulong len t bound 16 23 +if ne get fbig add s i get t i 24 +ret false 25 +end 26 +end 27 +ret true 28 +end 29 +note pafidx: the index of the field name fbig[s, e), 9 when it is none of the seven 30 +fn pafidx s ulong e ulong to ulong 31 +if pafis s e tpfcsrf 32 +ret 0 33 +end 34 +if pafis s e tpfrepo 35 +ret 1 36 +end 37 +if pafis s e tpfbase 38 +ret 2 39 +end 40 +if pafis s e tpfttl 41 +ret 3 42 +end 43 +if pafis s e tpfdsc 44 +ret 4 45 +end 46 +if pafis s e tpfmbx 47 +ret 5 48 +end 49 +if pafis s e tpfsig 50 +ret 6 51 +end 52 +ret 9 53 +end 54 +note pafend s n c: the first index in [s, n) holding c or &, else n 55 +fn pafend s ulong n ulong c uchar to ulong 56 +j = s 57 +while lt j n bound `4194304` 58 +b = get fbig j 59 +if or eq b c eq b 38 60 +ret j 61 +end 62 +j = add j 1 63 +end 64 +ret n 65 +end 66 +note paparse: split fbig into the fields; false for a pair without =, an unknown name or a name twice 67 +fn paparse to bool 68 +for k ulong 8 69 +put gpfo k 0 70 +put gpfn k 0 71 +put gpfs k 0 72 +end 73 +n = get fbigl 0 74 +s = ulong 0 75 +for it ulong 16 76 +if ge s n 77 +ret true 78 +end 79 +e = pafend s n 61 80 +if ge e n 81 +ret false 82 +end 83 +if ne get fbig e 61 84 +ret false 85 +end 86 +a = pafend add e 1 n 38 87 +k = pafidx s e 88 +if eq k 9 89 +ret false 90 +end 91 +if ne get gpfs k 0 92 +ret false 93 +end 94 +put gpfo k add e 1 95 +put gpfn k sub a add e 1 96 +put gpfs k 1 97 +s = add a 1 98 +end 99 +ret false 100 +end 101 +note pafall: all seven fields are present 102 +fn pafall to bool 103 +for k ulong 7 104 +if eq get gpfs k 0 105 +ret false 106 +end 107 +end 108 +ret true 109 +end 110 +note padec k cap: field k percent-decoded (+ is a space) into gpfv (65536 bytes); 111 +note the length, or -1 when an escape is malformed or the value is longer than cap (cap <= 65536) 112 +fn padec k ulong cap ulong to long 113 +o = get gpfo k 114 +n = get gpfn k 115 +j = ulong 0 116 +m = ulong 0 117 +while lt j n bound `4194304` 118 +c = get fbig add o j 119 +j = add j 1 120 +if eq c 43 121 +c = uchar 32 122 +end 123 +if eq c 37 124 +if gt add j 2 n 125 +ret -1 126 +end 127 +h = fhexv get fbig add o j 128 +l = fhexv get fbig add add o j 1 129 +if or lt h 0 lt l 0 130 +ret -1 131 +end 132 +c = uchar add mul h 16 l 133 +j = add j 2 134 +end 135 +if ge m cap 136 +ret -1 137 +end 138 +put gpfv m c 139 +m = add m 1 140 +end 141 +ret long m 142 +end 143 +note ---- the write gate: the gate of every forge write (social/40auth.om sowpre: CSRF token 403, 144 +note store off 503, 30 writes a minute an address and a key 429), with two differences an uploading 145 +note program needs: signed out is 403 here, not a redirect to the sign-in page, and every answer is 146 +note one line of text. sowpre reads the token from the form body fbody, which is empty on this route 147 +note (the body is in fbig), so the csrf field is handed to it there. 148 +fn pacsrf to bool 149 +if eq get gpfs 0 0 150 +ret false 151 +end 152 +if ne get gpfn 0 32 153 +ret false 154 +end 155 +o = get gpfo 0 156 +for i ulong len tpcsrfe 157 +put fbody i get tpcsrfe i 158 +end 159 +for i ulong 32 160 +put fbody add len tpcsrfe i get fbig add o i 161 +end 162 +put fbodyl 0 add len tpcsrfe 32 163 +ret true 164 +end 165 +fn pagate to long 166 +if eq get gscur 0 0 167 +ret parefu 403 tpm403 168 +end 169 +if not paparse 170 +ret parefu 400 tpmform 171 +end 172 +if not pacsrf 173 +ret parefu 403 tpmcsrf 174 +end 175 +r = sowpre 176 +put fbodyl 0 0 177 +if eq r 0 178 +soratev get gscur 0 get gsnow 0 179 +ret 0 180 +end 181 +if eq r 429 182 +ret parefu 429 tpmrate 183 +end 184 +if eq r 503 185 +ret parefu 503 tpmoff 186 +end 187 +ret parefu 403 tpmcsrf 188 +end 189 +note paunl: POST ///patches/new where x is not a public repository (server/route.om asks 190 +note before its 404): the gate first, then 404 in text. 0 = not that request. 191 +fn paunl to long 192 +if ne get fmeth 0 3 193 +ret 0 194 +end 195 +if not frsteq tppnew 196 +ret 0 197 +end 198 +r = pagate 199 +if ne r 0 200 +ret r 201 +end 202 +ret parefu 404 tpmnorp 203 +end 204 +note ---- field checks (after the gate) 205 +note parepok: the repo field is exactly / of the request path 206 +fn parepok to bool 207 +n = padec 1 256 208 +if lt n 0 209 +ret false 210 +end 211 +i = get fridx 0 212 +l = get fanl i 213 +w = len tfowner 214 +if ne ulong n add add w 1 l 215 +ret false 216 +end 217 +for k ulong w bound 64 218 +if ne get gpfv k get tfowner k 219 +ret false 220 +end 221 +end 222 +if ne get gpfv w 47 223 +ret false 224 +end 225 +for k ulong l bound 128 226 +if ne get gpfv add add w 1 k frnbyte i k 227 +ret false 228 +end 229 +end 230 +ret true 231 +end 232 +note pabasef: the base field is 40 lowercase hex digits; copied into gpbase 233 +fn pabasef to bool 234 +if ne get gpfn 2 40 235 +ret false 236 +end 237 +o = get gpfo 2 238 +for i ulong 40 239 +c = get fbig add o i 240 +if lt sohexv c 0 241 +ret false 242 +end 243 +put gpbase i c 244 +end 245 +ret true 246 +end 247 +note patitle: 1..256 bytes, UTF-8, one line, no control byte (the text rules of docs/collab-write.md 248 +note section 2, checked and never rewritten: the bytes are what the author's key signed) 249 +fn patitle to bool 250 +n = padec 3 256 251 +if lt n 1 252 +ret false 253 +end 254 +if not pawutf8 ulong n false 255 +ret false 256 +end 257 +for i ulong ulong n bound 256 258 +put gpttl i get gpfv i 259 +end 260 +put gpttll 0 ulong n 261 +ret true 262 +end 263 +note padescr: 0..60000 bytes, UTF-8, tab and line feed the only control bytes 264 +fn padescr to bool 265 +n = padec 4 60000 266 +if lt n 0 267 +ret false 268 +end 269 +if not pawutf8 ulong n true 270 +ret false 271 +end 272 +for i ulong ulong n bound 60000 273 +put gpdsc i get gpfv i 274 +end 275 +put gpdscl 0 ulong n 276 +ret true 277 +end 278 +note ---- the mbox field: base64url without padding, canonical (unused bits zero) 279 +fn pab64v c uchar to long 280 +if and ge c 65 le c 90 281 +ret long sub c 65 282 +end 283 +if and ge c 97 le c 122 284 +ret long sub c 71 285 +end 286 +if and ge c 48 le c 57 287 +ret long add c 4 288 +end 289 +if eq c 45 290 +ret 62 291 +end 292 +if eq c 95 293 +ret 63 294 +end 295 +ret -1 296 +end 297 +note pabq p k: the k digits at fbig[p] as one number, -1 when one is not a base64url digit 298 +fn pabq p ulong k ulong to long 299 +v = long 0 300 +for i ulong k bound 4 301 +d = pab64v get fbig add p i 302 +if lt d 0 303 +ret -1 304 +end 305 +v = add mul v 64 d 306 +end 307 +ret v 308 +end 309 +note pambtail: the last 2 or 3 digits (1 or 2 bytes) at fbig[p], written at gpmb[q]; false when bad 310 +fn pambtail p ulong k ulong q ulong to bool 311 +v = pabq p k 312 +if lt v 0 313 +ret false 314 +end 315 +if eq k 2 316 +if ne and v 15 0 317 +ret false 318 +end 319 +put gpmb q uchar shr v 4 320 +ret true 321 +end 322 +if ne and v 3 0 323 +ret false 324 +end 325 +put gpmb q uchar shr v 10 326 +put gpmb add q 1 uchar and shr v 2 255 327 +ret true 328 +end 329 +note pambdec: decode the mbox field into gpmb: 0, 413 over 2 MiB, 400 not base64url 330 +fn pambdec to ulong 331 +o = get gpfo 5 332 +n = get gpfn 5 333 +put gpmbl 0 0 334 +if gt n `2796203` 335 +ret 413 336 +end 337 +k = rem n 4 338 +if eq k 1 339 +ret 400 340 +end 341 +q = ulong 0 342 +for t ulong div n 4 bound `1048576` 343 +v = pabq add o mul t 4 4 344 +if lt v 0 345 +ret 400 346 +end 347 +put gpmb q uchar shr v 16 348 +put gpmb add q 1 uchar and shr v 8 255 349 +put gpmb add q 2 uchar and v 255 350 +q = add q 3 351 +end 352 +if ne k 0 353 +if not pambtail add o sub n k k q 354 +ret 400 355 +end 356 +q = add q sub k 1 357 +end 358 +put gpmbl 0 q 359 +ret 0 360 +end 361 +note ---- the sig field: an armored SSH signature, at most 4000 bytes; kept with one final line feed 362 +fn pasigin to bool 363 +n = padec 6 4000 364 +if lt n 0 365 +ret false 366 +end 367 +s = new uchar 4096 0 368 +k = ulong 0 369 +for i ulong ulong n bound 4096 370 +c = get gpfv i 371 +if ne c 13 372 +if not sosigc c 373 +ret false 374 +end 375 +put s k c 376 +k = add k 1 377 +end 378 +end 379 +for it ulong 4096 380 +if eq k 0 381 +break 382 +end 383 +c = get s sub k 1 384 +if and ne c 10 ne c 32 385 +break 386 +end 387 +k = sub k 1 388 +end 389 +if lt k add len tssigb len tssige 390 +ret false 391 +end 392 +if not soarmok part s 0 k 393 +ret false 394 +end 395 +for i ulong k bound 4096 396 +put gpsig i get s i 397 +end 398 +put gpsig k 10 399 +put gpsigl 0 add k 1 400 +ret true 401 +end patch/p4take.om new file mode 100644 @@ -0,0 +1,1179 @@ 1 +note patch/p4take.om: POST ///patches/new. The checks in order, each refusal one line 2 +note of text with nothing kept: session and CSRF (pagate); the repo field and the repository's git 3 +note store; base a commit reachable from the default branch the public list names; sizes and shapes 4 +note of title, description, mbox and sig; the signature by the session's key over the statement; then 5 +note the mbox is applied once on base in a throwaway work tree and, only if that is clean (no file is 6 +note binary, by git's marks and by the bytes of the applied diff, and no submodule is added), stored. 7 +note ---- the mbox scan 8 +note pamln s e t: the line gpmb[s, e) starts with t 9 +fn pamln s ulong e ulong t view uchar * to bool 10 +if lt sub e s len t 11 +ret false 12 +end 13 +for i ulong len t bound 64 14 +if ne get gpmb add s i get t i 15 +ret false 16 +end 17 +end 18 +ret true 19 +end 20 +note pafrom: the line is "From <40 lowercase hex> Mon Sep 17 00:00:00 2001", format-patch's first 21 +note line of every commit 22 +fn pafrom s ulong e ulong to bool 23 +if ne sub e s 70 24 +ret false 25 +end 26 +if not pamln s e tpfrom 27 +ret false 28 +end 29 +for i ulong 40 30 +if lt sohexv get gpmb add add s 5 i 0 31 +ret false 32 +end 33 +end 34 +ret pamln add s 45 e tpfrom2 35 +end 36 +fn paeol s ulong n ulong to ulong 37 +j = s 38 +while lt j n bound `4194304` 39 +if eq get gpmb j 10 40 +ret j 41 +end 42 +j = add j 1 43 +end 44 +ret n 45 +end 46 +note padd: gpmb[j] and gpmb[j+1] are both a dot, inside [s, e) 47 +fn padd j ulong e ulong to bool 48 +if ge add j 1 e 49 +ret false 50 +end 51 +if ne get gpmb j 46 52 +ret false 53 +end 54 +ret eq get gpmb add j 1 46 55 +end 56 +note pasep: the byte bounds a path segment (/, space, quote) 57 +fn pasep c uchar to bool 58 +ret or or eq c 47 eq c 32 eq c 34 59 +end 60 +note paddseg j s e: the ".." at gpmb[j] is a whole segment of the path part gpmb[s, e): the byte 61 +note before it (when there is one) and the byte after it (when there is one) each bound a segment 62 +fn paddseg j ulong s ulong e ulong to bool 63 +if gt j s 64 +if not pasep get gpmb sub j 1 65 +ret false 66 +end 67 +end 68 +if lt add j 2 e 69 +ret pasep get gpmb add j 2 70 +end 71 +ret true 72 +end 73 +note paout s e: the path part gpmb[s, e) of a diff header names a way out of the repository: a ".." 74 +note segment, an empty segment (//) or a leading / 75 +fn paout s ulong e ulong to bool 76 +if ge s e 77 +ret false 78 +end 79 +if eq get gpmb s 47 80 +ret true 81 +end 82 +j = s 83 +while lt j e bound `4194304` 84 +if padd j e 85 +if paddseg j s e 86 +ret true 87 +end 88 +end 89 +if eq get gpmb j 47 90 +if lt add j 1 e 91 +if eq get gpmb add j 1 47 92 +ret true 93 +end 94 +end 95 +end 96 +j = add j 1 97 +end 98 +ret false 99 +end 100 +note padiffl: a line of a diff: 2 a binary patch, 3 a header naming a path outside, else 0 101 +fn padiffl s ulong e ulong to ulong 102 +if pamln s e tpgbp 103 +if eq sub e s len tpgbp 104 +ret 2 105 +end 106 +end 107 +if pamln s e tpbf 108 +ret 2 109 +end 110 +if pamln s e tprnf 111 +if paout add s len tprnf e 112 +ret 3 113 +end 114 +end 115 +if pamln s e tprnt 116 +if paout add s len tprnt e 117 +ret 3 118 +end 119 +end 120 +ret 0 121 +end 122 +note pascan: one pass over the lines of the mbox. gpncm = commits (From lines); gpgrd = 2 for a 123 +note binary patch or 3 for an outside path, otherwise 0. False when the first line 124 +note is not a From line: not format-patch output. 125 +fn pascan to bool 126 +n = get gpmbl 0 127 +put gpncm 0 0 128 +put gpgrd 0 0 129 +s = ulong 0 130 +ind = false 131 +for it ulong `4194304` 132 +if ge s n 133 +break 134 +end 135 +e = paeol s n 136 +if pafrom s e 137 +put gpncm 0 add get gpncm 0 1 138 +ind = false 139 +else 140 +if eq s 0 141 +ret false 142 +end 143 +g = ulong 0 144 +if pamln s e tpdg 145 +ind = true 146 +if paout add s len tpdg e 147 +g = 3 148 +end 149 +else 150 +if ind 151 +g = padiffl s e 152 +end 153 +end 154 +if and ne g 0 eq get gpgrd 0 0 155 +put gpgrd 0 g 156 +end 157 +end 158 +s = add e 1 159 +end 160 +ret gt get gpncm 0 0 161 +end 162 +note ---- base 163 +note pabasec: 0 base is a commit on the main branch; else the refusal's status with its text written 164 +fn pabasec to long 165 +fkgit 166 +fka tpcatf 167 +fka tpde 168 +fkopen 169 +pakbase 170 +fkt tpcmt 171 +r = fexec PATMO 172 +if lt r 0 173 +ret parefu 500 tpmint 174 +end 175 +if ne r 0 176 +ret parefu 422 tpmunk 177 +end 178 +fkgit 179 +fka tpgmb 180 +fka tpisa 181 +fkopen 182 +pakbase 183 +fkopen 184 +fkt tprh 185 +i = get fridx 0 186 +o = get fabo i 187 +for k ulong get fabl i bound 64 188 +fkc get fabr add o k 189 +end 190 +r = fexec PATMO 191 +if eq r 0 192 +ret 0 193 +end 194 +if eq r 1 195 +ret parefu 422 tpmnotm 196 +end 197 +ret parefu 500 tpmint 198 +end 199 +note ---- the statement and the id 200 +fn pastc c uchar to void 201 +n = get gpstl 0 202 +if lt n 511 203 +put gpst n c 204 +put gpstl 0 add n 1 205 +end 206 +end 207 +fn pasthex h view uchar 32 to void 208 +x = new uchar 64 0 209 +sohex h x 210 +for i ulong 64 211 +pastc get x i 212 +end 213 +pastc 10 214 +end 215 +note pastmt: gpst = "interplane-patch 1\n/\n\n\n\n", all hex lowercase; gpid = the first 16 hex of its SHA-256 217 +fn pastmt to void 218 +put gpstl 0 0 219 +for i ulong len tpst1 220 +pastc get tpst1 i 221 +end 222 +for i ulong len tfowner 223 +pastc get tfowner i 224 +end 225 +pastc 47 226 +r = get fridx 0 227 +for k ulong get fanl r bound 128 228 +pastc frnbyte r k 229 +end 230 +pastc 10 231 +for i ulong 40 232 +pastc get gpbase i 233 +end 234 +pastc 10 235 +h = new uchar 32 0 236 +pahs 0 get gpmbl 0 h 237 +pasthex h 238 +pahs 7 add add get gpttll 0 1 get gpdscl 0 h 239 +pasthex h 240 +pahs 1 get gpstl 0 h 241 +x = new uchar 64 0 242 +sohex h x 243 +for i ulong 16 244 +put gpid i get x i 245 +end 246 +end 247 +note ---- the signature: ssh-keygen -Y verify -f -I forge-user -n interplane-patch 248 +note -s with the statement on standard input (the argv exec and temp files of the 249 +note sign-in check, social/20crypt.om and 40auth.om). The one allowed signer is the session's key. 250 +note paspk: the `ed25519` key of the session's did:key into pk 251 +fn paspk pk edit uchar 32 to bool 252 +d = get gscur 0 253 +o = get gsso d 254 +l = get gssl d 255 +w = len tsdidp 256 +if or le l w gt sub l w 64 257 +ret false 258 +end 259 +z = new uchar 64 0 260 +for i ulong sub l w bound 64 261 +put z i get gsstr add add o w i 262 +end 263 +ret sodidpk part z 0 sub l w pk 264 +end 265 +note pasigw: the three temp files: a allowed signers, s signature, m statement 266 +fn pasigw pk view uchar 32 to bool 267 +al = new uchar 128 0 268 +k = sopkline pk al 269 +if not sotmpw 97 part al 0 k 270 +ret false 271 +end 272 +sg = new uchar 4096 0 273 +n = get gpsigl 0 274 +for i ulong n bound 4096 275 +put sg i get gpsig i 276 +end 277 +if not sotmpw 115 part sg 0 n 278 +ret false 279 +end 280 +m = new uchar 512 0 281 +n = get gpstl 0 282 +for i ulong n bound 512 283 +put m i get gpst i 284 +end 285 +ret sotmpw 109 part m 0 n 286 +end 287 +fn pasigrun to long 288 +sotmpp 109 289 +mfd = fopen gspth 0 get gspthl 0 524288 0 290 +if lt mfd 0 291 +ret -500 292 +end 293 +soavb 294 +soava tssshkg 295 +soava tsY 296 +soava tsverify 297 +soava tsdf 298 +sotmpp 97 299 +soavpth 300 +soava tsdI 301 +soava tsprinc 302 +soava tsdn 303 +soava tpns 304 +soava tsds 305 +sotmpp 115 306 +soavpth 307 +r = sorunv mfd 5000 308 +x = fclose int mfd 309 +if eq r -2 310 +ret -500 311 +end 312 +if eq r -1 313 +ret -500 314 +end 315 +ret r 316 +end 317 +note pasigck: 0 the signature verifies; else the refusal's status with its text written 318 +fn pasigck to long 319 +if not sovlim 320 +ret parefu 429 tpmrate 321 +end 322 +pk = new uchar 32 0 323 +if not paspk pk 324 +ret parefu 500 tpmint 325 +end 326 +st = new uchar 8 0 327 +if not sorand st 328 +ret parefu 500 tpmint 329 +end 330 +for i ulong 8 331 +put gsstem i get st i 332 +end 333 +r = long -500 334 +if pasigw pk 335 +r = pasigrun 336 +end 337 +sotmprm 97 338 +sotmprm 115 339 +sotmprm 109 340 +if eq r 0 341 +ret 0 342 +end 343 +if lt r 0 344 +ret parefu 500 tpmint 345 +end 346 +ret parefu 403 tpmsig 347 +end 348 +note ---- apply once on base in a throwaway work tree 349 +note pastem: gpstm = 16 random hex digits naming this request's work and staging folders 350 +fn pastem to bool 351 +r = new uchar 8 0 352 +if not sorand r 353 +ret false 354 +end 355 +x = new uchar 16 0 356 +sohex r x 357 +for i ulong 16 358 +put gpstm i get x i 359 +end 360 +ret true 361 +end 362 +note pawinit: make patch-work/pw/ with an empty git repository w whose objects are borrowed from 363 +note the repository's store (objects/info/alternates): the store is only read, and nothing the work 364 +note folder makes is ever written into it (the intake's pawork, and the bundle diff of patch/p5imp.om) 365 +fn pawinit to bool 366 +papb 367 +papt tptmp 368 +x = pamkdir 369 +papw part tpdot 0 0 370 +r = makedir gpp 0 get gppl 0 448 371 +if lt r 0 372 +ret false 373 +end 374 +fkb 375 +fka tfgit 376 +pakc1 tpk17 377 +fka tpinit 378 +fka tpq 379 +fka tptpl 380 +fkopen 381 +papw tpww 382 +pakp 383 +r = fexec PATMO 384 +if ne r 0 385 +ret false 386 +end 387 +palb 388 +papgs 389 +if gt get gppl 0 240 390 +ret false 391 +end 392 +for i ulong get gppl 0 bound 240 393 +palc get gpp i 394 +end 395 +for i ulong len tpobj 396 +palc get tpobj i 397 +end 398 +papw tpwalt 399 +ret pawf 5 get gplnl 0 400 +end 401 +note pawork: the work folder of pawinit with the mbox as m 402 +fn pawork to bool 403 +if not pawinit 404 +ret false 405 +end 406 +papw tpwm 407 +ret pawf 0 get gpmbl 0 408 +end 409 +note pasteq: the stored statement of item gpid is byte-equal to this request's gpst[0, gpstl) 410 +fn pasteq to bool 411 +pafp tpfst 412 +n = frdall 413 +if ne n long get gpstl 0 414 +ret false 415 +end 416 +for i ulong get gpstl 0 bound 512 417 +if ne get fxo i get gpst i 418 +ret false 419 +end 420 +end 421 +ret true 422 +end 423 +note pahex40: fxo[0, 40) is 40 lowercase hex digits followed by a line feed; copied into gphead 424 +fn pahex40 to bool 425 +if ne get fxol 0 41 426 +ret false 427 +end 428 +for i ulong 40 429 +c = get fxo i 430 +if lt sohexv c 0 431 +ret false 432 +end 433 +put gphead i c 434 +end 435 +ret eq get fxo 40 10 436 +end 437 +note panum: the decimal number in fxo[0, n) before its line feed, `999999999` when it is not one 438 +fn panum to ulong 439 +n = get fxol 0 440 +if or lt n 2 gt n 10 441 +ret `999999999` 442 +end 443 +v = ulong 0 444 +for i ulong sub n 1 bound 16 445 +c = get fxo i 446 +if not fisdig c 447 +ret `999999999` 448 +end 449 +v = add mul v 10 ulong sub c 48 450 +end 451 +ret v 452 +end 453 +note pabinat s: fxo[s, s+4) is "-\t-\t" (the caller keeps s+4 inside the output) 454 +fn pabinat s ulong to bool 455 +a = and eq get fxo s 45 eq get fxo add s 1 9 456 +b = and eq get fxo add s 2 45 eq get fxo add s 3 9 457 +ret and a b 458 +end 459 +note pabinns: fxo holds `git diff --numstat --no-renames`: a line starts with "-\t-\t", git's mark of 460 +note a binary file. The mbox scan (padiffl) sees only the bytes as sent; git am decodes a mail body 461 +note sent base64 or quoted-printable first, so only git's own view after the apply covers every way in. 462 +fn pabinns to bool 463 +n = get fxol 0 464 +s = ulong 0 465 +for it ulong `16777216` 466 +if ge s n 467 +break 468 +end 469 +if le add s 4 n 470 +if pabinat s 471 +ret true 472 +end 473 +end 474 +e = s 475 +while lt e n bound `16777216` 476 +if eq get fxo e 10 477 +break 478 +end 479 +e = add e 1 480 +end 481 +s = add e 1 482 +end 483 +ret false 484 +end 485 +note pafxln s e t: the line fxo[s, e) starts with t 486 +fn pafxln s ulong e ulong t view uchar * to bool 487 +if lt sub e s len t 488 +ret false 489 +end 490 +for i ulong len t bound 64 491 +if ne get fxo add s i get t i 492 +ret false 493 +end 494 +end 495 +ret true 496 +end 497 +note Read the same normalized diff as Git, before applying any of the mail messages. 498 +text tpmspl "mailsplit" 499 +text tpmio "mailinfo" 500 +text tpmd "/mails" 501 +text tpmslash "/mails/" 502 +text tpmsg "/mails/message" 503 +text tpmpt "/mails/patch" 504 +text tpmo "-o" 505 +text tpmdig "-d4" 506 +fn pamaid num ulong to void 507 +papw tpmslash 508 +d = ulong 1000 509 +for i ulong 4 510 +papc uchar add rem div num d 10 48 511 +d = div d 10 512 +end 513 +end 514 +fn pafxcpy to bool 515 +n = get fxol 0 516 +s = ulong 0 517 +header = false 518 +while lt s n bound `16777216` 519 +e = s 520 +while lt e n bound `16777216` 521 +if eq get fxo e 10 522 +break 523 +end 524 +e = add e 1 525 +end 526 +if pafxln s e tpdg 527 +header = true 528 +end 529 +if and header or pafxln s e tpcpf pafxln s e tpcpt 530 +ret true 531 +end 532 +s = add e 1 533 +end 534 +ret false 535 +end 536 +fn pamread idx ulong tmo long to long 537 +pamaid idx 538 +fd = fopen gpp 0 get gppl 0 524288 0 539 +if lt fd 0 540 +ret 500 541 +end 542 +pakwt 543 +fka tpmio 544 +fkopen 545 +papw tpmsg 546 +pakp 547 +fkopen 548 +papw tpmpt 549 +pakp 550 +r = fexecin tmo int fd 551 +x = fclose int fd 552 +if ne r 0 553 +ret 422 554 +end 555 +papw tpmpt 556 +fpb 557 +for i ulong get gppl 0 bound 4096 558 +fpc get gpp i 559 +end 560 +r = frdall 561 +if or lt r 0 ne get fxotr 0 0 562 +ret 422 563 +end 564 +put fxol 0 ulong r 565 +if pafxcpy 566 +ret 409 567 +end 568 +ret 0 569 +end 570 +fn pamail to long 571 +papw tpmd 572 +if not pamkdir 573 +ret parefu 500 tpmint 574 +end 575 +dl = add long monons PATMO 576 +pakwt 577 +fka tpmspl 578 +fka tpmdig 579 +fkopen 580 +fkt tpmo 581 +papw tpmd 582 +pakp 583 +fkopen 584 +papw tpwm 585 +pakp 586 +r = fexec PATMO 587 +if or ne r 0 ne get fxotr 0 0 588 +ret parefu 422 tpmappl 589 +end 590 +n = panum 591 +if or ne n get gpncm 0 gt n 100 592 +ret parefu 422 tpmcnt 593 +end 594 +for i ulong n bound 100 595 +left = sub dl long monons 596 +if le left 0 597 +ret parefu 422 tpmappl 598 +end 599 +r = pamread add i 1 left 600 +if eq r 409 601 +ret parefu 422 tpmcopy 602 +end 603 +if ne r 0 604 +ret parefu 422 tpmappl 605 +end 606 +end 607 +ret 0 608 +end 609 +note pabinfx: the bytes of the full diff fxo[0, fxol) (paapply3's last git run) hold a NUL byte, a line 610 +note that is exactly "GIT binary patch" or a line that starts "Binary files ". Every line of a diff's 611 +note body starts with a space, + or -, so those two at column 0 are git's own markers. The bytes decide: 612 +note git's own binary test reads only a file's first 8000 bytes (pabinns cannot see a later NUL). 613 +fn pabinfx to bool 614 +n = get fxol 0 615 +s = ulong 0 616 +for it ulong `16777216` 617 +if ge s n 618 +break 619 +end 620 +e = s 621 +while lt e n bound `16777216` 622 +c = get fxo e 623 +if eq c 0 624 +ret true 625 +end 626 +if eq c 10 627 +break 628 +end 629 +e = add e 1 630 +end 631 +if pafxln s e tpbf 632 +ret true 633 +end 634 +if eq sub e s len tpgbp 635 +if pafxln s e tpgbp 636 +ret true 637 +end 638 +end 639 +s = add e 1 640 +end 641 +ret false 642 +end 643 +note paraw: fxo holds `git diff --raw --no-renames`: gpnfl = its lines (files changed); false when a 644 +note line's new mode is 160000 (a submodule) or a line is not a raw line 645 +fn paraw to bool 646 +n = get fxol 0 647 +c = ulong 0 648 +s = ulong 0 649 +for it ulong `16777216` 650 +if ge s n 651 +break 652 +end 653 +if gt add s 14 n 654 +ret false 655 +end 656 +if ne get fxo s 58 657 +ret false 658 +end 659 +if pasubm add s 8 660 +ret false 661 +end 662 +c = add c 1 663 +e = s 664 +while lt e n bound `16777216` 665 +if eq get fxo e 10 666 +break 667 +end 668 +e = add e 1 669 +end 670 +s = add e 1 671 +end 672 +put gpnfl 0 c 673 +ret true 674 +end 675 +note pasubm: fxo[p, p+6) is the mode 160000 676 +fn pasubm p ulong to bool 677 +if ne get fxo p 49 678 +ret false 679 +end 680 +if ne get fxo add p 1 54 681 +ret false 682 +end 683 +for i ulong 4 684 +if ne get fxo add add p 2 i 48 685 +ret false 686 +end 687 +end 688 +ret true 689 +end 690 +note pakrange: one argument "..HEAD" 691 +fn pakrange to void 692 +fkopen 693 +pakbase 694 +fkt tpdots 695 +fkt tphead 696 +end 697 +note paapply2: the git runs in the work tree: read-tree base, HEAD at base, am, then head, commit 698 +note count, raw diff (files, submodules), numstat (binary files) and the full diff left in fxo, whose 699 +note bytes are checked too (pabinfx). 0, or the refusal's status. 700 +fn paapply2 to long 701 +pakwt 702 +fka tprdt 703 +fkopen 704 +pakbase 705 +r = fexec PATMO 706 +if ne r 0 707 +ret parefu 500 tpmint 708 +end 709 +pakwt 710 +fka tpupr 711 +fka tpnod 712 +fka tphead 713 +fkopen 714 +pakbase 715 +r = fexec PATMO 716 +if ne r 0 717 +ret parefu 500 tpmint 718 +end 719 +pakwt 720 +fka tpam 721 +fka tpqq 722 +fka tpamd 723 +fka tpamk 724 +fka tpamn 725 +fka tpam3 726 +fkopen 727 +papw tpwm 728 +pakp 729 +r = fexec PATMO 730 +if ne r 0 731 +ret parefu 422 tpmappl 732 +end 733 +pakwt 734 +fka tprevp 735 +fka tphead 736 +r = fexec PATMO 737 +if ne r 0 738 +ret parefu 500 tpmint 739 +end 740 +if not pahex40 741 +ret parefu 500 tpmint 742 +end 743 +pakwt 744 +fka tprevl 745 +fka tpcnt 746 +pakrange 747 +r = fexec PATMO 748 +if ne r 0 749 +ret parefu 500 tpmint 750 +end 751 +if ne panum get gpncm 0 752 +ret parefu 422 tpmcnt 753 +end 754 +ret paapply3 755 +end 756 +fn paapply3 to long 757 +pakwt 758 +fka tpdiff 759 +fka tpnoext 760 +fka tpnotc 761 +fka tpraw 762 +fka tpnorn 763 +fkopen 764 +pakbase 765 +fka tphead 766 +r = fexec PATMO 767 +if or ne r 0 ne get fxotr 0 0 768 +ret parefu 500 tpmint 769 +end 770 +if not paraw 771 +ret parefu 422 tpmsub 772 +end 773 +pakwt 774 +fka tpdiff 775 +fka tpnoext 776 +fka tpnotc 777 +fka tpnumst 778 +fka tpnorn 779 +fkopen 780 +pakbase 781 +fka tphead 782 +r = fexec PATMO 783 +if or ne r 0 ne get fxotr 0 0 784 +ret parefu 500 tpmint 785 +end 786 +if pabinns 787 +ret parefu 422 tpmbin 788 +end 789 +pakwt 790 +fka tpdiff 791 +fka tpnoext 792 +fka tpnotc 793 +fka tpfull 794 +fka tpdM 795 +fkopen 796 +pakbase 797 +fka tphead 798 +r = fexec PATMO 799 +if ne r 0 800 +ret parefu 500 tpmint 801 +end 802 +if ne get fxotr 0 0 803 +ret parefu 413 tpmdbig 804 +end 805 +if pabinfx 806 +ret parefu 422 tpmbin 807 +end 808 +ret 0 809 +end 810 +note ---- the store: patches//// with mbox, statement, signature, head, 811 +note status, title, description, meta and diff. Written into a staging folder beside it and renamed 812 +note into place, so an id folder is always whole and is never written again; the repository's index 813 +note file gets one line "\n" per patch, appended. 814 +fn pamkst to bool 815 +papb 816 +papt tpsdir 817 +if not pamkdir 818 +ret false 819 +end 820 +papt tfowner 821 +if not pamkdir 822 +ret false 823 +end 824 +papc 47 825 +paprn 826 +if not pamkdir 827 +ret false 828 +end 829 +papnew part tpdot 0 0 830 +r = makedir gpp 0 get gppl 0 448 831 +ret ge r 0 832 +end 833 +note pameta: the meta file's six lines: author DID, creation time (s), commits, files, mbox bytes, 834 +note mbox SHA-256 (the statement's fourth line) 835 +fn pameta to bool 836 +palb 837 +d = get gscur 0 838 +o = get gsso d 839 +for i ulong get gssl d bound 128 840 +palc get gsstr add o i 841 +end 842 +palc 10 843 +paln get gsnow 0 844 +palc 10 845 +paln get gpncm 0 846 +palc 10 847 +paln get gpnfl 0 848 +palc 10 849 +paln get gpmbl 0 850 +palc 10 851 +n = get gpstl 0 852 +for i ulong 64 853 +palc get gpst add sub n 130 i 854 +end 855 +palc 10 856 +papnew tpfme 857 +ret pawf 5 get gplnl 0 858 +end 859 +note pahdln: gpln = the head commit and a line feed 860 +fn pahdln to void 861 +palb 862 +for i ulong 40 863 +palc get gphead i 864 +end 865 +palc 10 866 +end 867 +note pawall9: the nine files into the staging folder; the diff is fxo[0, fxol) (paapply3 left it) 868 +fn pawall9 to bool 869 +papnew tpfdf 870 +if not pawf 6 get fxol 0 871 +ret false 872 +end 873 +papnew tpfmb 874 +if not pawf 0 get gpmbl 0 875 +ret false 876 +end 877 +papnew tpfst 878 +if not pawf 1 get gpstl 0 879 +ret false 880 +end 881 +papnew tpfsg 882 +if not pawf 2 get gpsigl 0 883 +ret false 884 +end 885 +papnew tpftt 886 +if not pawf 3 get gpttll 0 887 +ret false 888 +end 889 +papnew tpfds 890 +if not pawf 4 get gpdscl 0 891 +ret false 892 +end 893 +if not pameta 894 +ret false 895 +end 896 +pahdln 897 +papnew tpfhd 898 +if not pawf 5 get gplnl 0 899 +ret false 900 +end 901 +papnew tpfss 902 +ret pawtxt tpopen 903 +end 904 +note padrop: remove the staging folder and the files it may hold 905 +fn padrop1 t view uchar * to void 906 +papnew t 907 +x = unlink gpp 0 get gppl 0 908 +end 909 +fn padrop to void 910 +padrop1 tpfdf 911 +padrop1 tpfmb 912 +padrop1 tpfst 913 +padrop1 tpfsg 914 +padrop1 tpftt 915 +padrop1 tpfds 916 +padrop1 tpfme 917 +padrop1 tpfhd 918 +padrop1 tpfss 919 +papnew part tpdot 0 0 920 +x = rmdir gpp 0 get gppl 0 921 +end 922 +note paidxhas: the index (read into fxo) lists gpid 923 +fn paidxhas to bool 924 +paprepo 925 +papt tpindex 926 +fpb 927 +for i ulong get gppl 0 bound 4096 928 +fpc get gpp i 929 +end 930 +n = frdall 931 +if lt n 17 932 +ret false 933 +end 934 +for r ulong div ulong n 17 bound `1048576` 935 +if paidxeq mul r 17 936 +ret true 937 +end 938 +end 939 +ret false 940 +end 941 +fn paidxeq o ulong to bool 942 +for i ulong 16 943 +if ne get fxo add o i get gpid i 944 +ret false 945 +end 946 +end 947 +ret true 948 +end 949 +note paidxadd: append "\n" to the index (created 0600), written through 950 +fn paidxadd to bool 951 +paprepo 952 +papt tpindex 953 +fd = fopen gpp 0 get gppl 0 558145 384 954 +if lt fd 0 955 +ret false 956 +end 957 +b = new uchar 4096 0 958 +for i ulong 16 959 +put b i get gpid i 960 +end 961 +put b 16 10 962 +ok = pawall int fd b 17 963 +s = fsync int fd 964 +x = fclose int fd 965 +ret and ok ge s 0 966 +end 967 +note pakeep: staging folder -> / (rename), then the index line. false when nothing was kept. 968 +fn pakeep to bool 969 +if not pamkst 970 +ret false 971 +end 972 +if not pawall9 973 +padrop 974 +ret false 975 +end 976 +soavb 977 +papnew part tpdot 0 0 978 +paavp 979 +papid part tpdot 0 0 980 +paavp 981 +r = renames gspk 0 get gspkl 0 1 982 +if lt r 0 983 +padrop 984 +ret false 985 +end 986 +ret paidxadd 987 +end 988 +note paavp: one record of the packed list gspk (social/20crypt.om) holding gpp without a final / 989 +fn paavp to void 990 +soavopen 991 +n = get gppl 0 992 +if gt n 0 993 +if eq get gpp sub n 1 47 994 +n = sub n 1 995 +end 996 +end 997 +for i ulong n bound 4096 998 +soavc get gpp i 999 +end 1000 +end 1001 +note paok st w: the text answer of a kept (201, "accepted") or already known (200, "exists") patch: 1002 +note its id and the path of its page 1003 +fn paok st ulong w view uchar * to long 1004 +patext 1005 +fput w 1006 +fput tpaid 1007 +for i ulong 16 1008 +fputc get gpid i 1009 +end 1010 +fputc 10 1011 +fput tpapth 1012 +fputrl 1013 +fput tppats 1014 +fputc 47 1015 +for i ulong 16 1016 +fputc get gpid i 1017 +end 1018 +fputc 10 1019 +ret long st 1020 +end 1021 +note paapply: work folder, the git runs, the store; the work folder is removed whatever happened 1022 +text tpfsbin "/usr/bin/stat" 1023 +text tpfstype "-f" 1024 +text tpfsfmt "--format=%a %S" 1025 +text tpnosp "patch storage is temporarily unavailable" 1026 +const PAPRES ulong `1073741824` 1027 +note Keep a reserve for the rest of the forge. Compare blocks without multiplying arbitrary values. 1028 +fn pafree to bool 1029 +fkb 1030 +fka tpfsbin 1031 +fka tpfstype 1032 +fka tpfsfmt 1033 +fka tfdata 1034 +r = fexec `1000000000` 1035 +if or ne r 0 ne get fxotr 0 0 1036 +ret false 1037 +end 1038 +n = get fxol 0 1039 +a = ulong 0 1040 +size = ulong 0 1041 +p = ulong 0 1042 +for i ulong n bound 48 1043 +c = get fxo i 1044 +if eq c 32 1045 +p = add i 1 1046 +break 1047 +end 1048 +if or ge i 18 not fisdig c 1049 +ret false 1050 +end 1051 +a = add mul a 10 ulong sub c 48 1052 +end 1053 +if or le p 1 ge p n 1054 +ret false 1055 +end 1056 +for i ulong sub n p bound 48 1057 +c = get fxo add p i 1058 +if eq c 10 1059 +break 1060 +end 1061 +if or ge i 18 not fisdig c 1062 +ret false 1063 +end 1064 +size = add mul size 10 ulong sub c 48 1065 +end 1066 +if eq size 0 1067 +ret false 1068 +end 1069 +ret gt a div PAPRES size 1070 +end 1071 +fn paapply to long 1072 +if not pafree 1073 +ret parefu 503 tpnosp 1074 +end 1075 +if not pastem 1076 +ret parefu 500 tpmint 1077 +end 1078 +r = long 0 1079 +if pawork 1080 +r = pamail 1081 +if eq r 0 1082 +r = paapply2 1083 +end 1084 +else 1085 +r = parefu 500 tpmint 1086 +end 1087 +kept = false 1088 +if eq r 0 1089 +kept = pakeep 1090 +end 1091 +if not parmtree 1092 +flog tplrm 1093 +end 1094 +if ne r 0 1095 +ret r 1096 +end 1097 +if not kept 1098 +ret parefu 503 tpmwr 1099 +end 1100 +ret paok 201 tpacc 1101 +end 1102 +note pasizes: title, description, mbox and sig, each to its own global; 0 or the refusal 1103 +fn pasizes to long 1104 +if not patitle 1105 +ret parefu 400 tpmttl 1106 +end 1107 +if not padescr 1108 +ret parefu 400 tpmdsc 1109 +end 1110 +r = pambdec 1111 +if eq r 413 1112 +ret parefu 413 tpmbig 1113 +end 1114 +if ne r 0 1115 +ret parefu 400 tpmb64 1116 +end 1117 +if not pascan 1118 +ret parefu 400 tpmnfp 1119 +end 1120 +if gt get gpncm 0 100 1121 +ret parefu 413 tpmmany 1122 +end 1123 +if not pasigin 1124 +ret parefu 400 tpmsigf 1125 +end 1126 +ret 0 1127 +end 1128 +note patake: POST ///patches/new 1129 +fn patake to long 1130 +r = pagate 1131 +if ne r 0 1132 +ret r 1133 +end 1134 +if not pafall 1135 +ret parefu 400 tpmform 1136 +end 1137 +if not parepok 1138 +ret parefu 400 tpmrepo 1139 +end 1140 +papgs 1141 +if not paexist 1142 +ret parefu 404 tpmnogs 1143 +end 1144 +if not pabasef 1145 +ret parefu 400 tpmbase 1146 +end 1147 +r = pabasec 1148 +if ne r 0 1149 +ret r 1150 +end 1151 +r = pasizes 1152 +if ne r 0 1153 +ret r 1154 +end 1155 +pastmt 1156 +r = pasigck 1157 +if ne r 0 1158 +ret r 1159 +end 1160 +papid part tpdot 0 0 1161 +if paexist 1162 +if not pasteq 1163 +ret parefu 409 tpm409 1164 +end 1165 +if not paidxhas 1166 +if not paidxadd 1167 +ret parefu 503 tpmwr 1168 +end 1169 +end 1170 +ret paok 200 tpexi 1171 +end 1172 +if eq get gpgrd 0 2 1173 +ret parefu 422 tpmbin 1174 +end 1175 +if eq get gpgrd 0 3 1176 +ret parefu 422 tpmpath 1177 +end 1178 +ret paapply 1179 +end patch/p5imp.om new file mode 100644 @@ -0,0 +1,1281 @@ 1 +note patch/p5imp.om: imported proposals (SPEC prstore/r1 extension, written only by tools/ghimport): 2 +note reading an imported item back, its list row and page, and the diff of a bundle-backed item. 3 +note Every imported byte goes out through fescc (HTML) or fjtc (JSON); a GitHub login is text. Each 4 +note reader checks a length against its buffer before it reads, so a malformed or oversized file 5 +note ends in "not an item", a cut value or a sentence on the page, never in a trap. 6 +note ---- loading 7 +note pafrd t cap: the file of item gpid into fxo; its length cut to cap, 0 when it cannot be read 8 +fn pafrd t view uchar * cap ulong to ulong 9 +pafp t 10 +n = frdall 11 +if lt n 0 12 +ret 0 13 +end 14 +ret hmin ulong n cap 15 +end 16 +note pasjat s t: gpsrc holds t at s (the caller keeps s + len t inside gpsrc) 17 +fn pasjat s ulong t view uchar * to bool 18 +for i ulong len t bound 64 19 +if ne get gpsrc add s i get t i 20 +ret false 21 +end 22 +end 23 +ret true 24 +end 25 +note pasjf t: the offset in gpsrc of the first t, the length of gpsrc when it is not there 26 +fn pasjf t view uchar * to ulong 27 +n = get gpsrcl 0 28 +k = len t 29 +if gt k n 30 +ret n 31 +end 32 +for s ulong add sub n k 1 bound 4097 33 +if pasjat s t 34 +ret s 35 +end 36 +end 37 +ret n 38 +end 39 +note pasjv t: the string value after the key text t in gpsrc: its offset; its length in gpr 15, and gpr 40 +note 14 is 1 when the key is there (0 and length 0 when it is not). The value ends at its closing 41 +note quote; a backslash ends it too (the value is cut there, never decoded), and so does the end of 42 +note the buffer 43 +fn pasjv t view uchar * to ulong 44 +n = get gpsrcl 0 45 +s = pasjf t 46 +put gpr 15 0 47 +put gpr 14 0 48 +if ge s n 49 +ret 0 50 +end 51 +put gpr 14 1 52 +p = add s len t 53 +q = p 54 +while lt q n bound 4097 55 +c = get gpsrc q 56 +if or eq c 34 eq c 92 57 +break 58 +end 59 +q = add q 1 60 +end 61 +put gpr 15 sub q p 62 +ret p 63 +end 64 +note pasjnum: the number of source.json ("number":N, 1..18 digits), 0 when it has none 65 +fn pasjnum to ulong 66 +n = get gpsrcl 0 67 +s = pasjf tpsjnum 68 +if ge s n 69 +ret 0 70 +end 71 +p = add s len tpsjnum 72 +v = ulong 0 73 +k = ulong 0 74 +while lt p n bound 19 75 +c = get gpsrc p 76 +if not fisdig c 77 +break 78 +end 79 +if ge k 18 80 +ret 0 81 +end 82 +v = add mul v 10 ulong sub c 48 83 +k = add k 1 84 +p = add p 1 85 +end 86 +ret v 87 +end 88 +note paghat s e t: the gh line gpgh[s, e) starts with t 89 +fn paghat s ulong e ulong t view uchar * to bool 90 +if lt sub e s len t 91 +ret false 92 +end 93 +for i ulong len t bound 16 94 +if ne get gpgh add s i get t i 95 +ret false 96 +end 97 +end 98 +ret true 99 +end 100 +note paghv t: the value of the gh line "\n" in gpgh: its offset; its length in gpr 15 (0 101 +note when there is no such whole line) 102 +fn paghv t view uchar * to ulong 103 +n = get gpghl 0 104 +s = ulong 0 105 +for i ulong n bound 2048 106 +if eq get gpgh i 10 107 +if paghat s i t 108 +put gpr 15 sub sub i s len t 109 +ret add s len t 110 +end 111 +s = add i 1 112 +end 113 +end 114 +put gpr 15 0 115 +ret 0 116 +end 117 +note paghnum: the GitHub number of the gh file ("number N", 1..18 digits), 0 when it has none 118 +fn paghnum to ulong 119 +o = paghv tpghn 120 +k = get gpr 15 121 +if or eq k 0 gt k 18 122 +ret 0 123 +end 124 +v = ulong 0 125 +for i ulong k bound 18 126 +c = get gpgh add o i 127 +if not fisdig c 128 +ret 0 129 +end 130 +v = add mul v 10 ulong sub c 48 131 +end 132 +ret v 133 +end 134 +note paiload2: the optional files of the imported item: title (cut to 1024 bytes), base (40 hex and 135 +note a line feed, else the item has no base), gh (cut to 2048 bytes), and the code file: mbox, else 136 +note head.bundle, else none (its size in gpmby) 137 +fn paiload2 to bool 138 +n = pafrd tpftt 1024 139 +for i ulong n bound 1024 140 +put gpttl i get fxo i 141 +end 142 +put gpttll 0 n 143 +put gpihb 0 0 144 +papid tpfbase 145 +r = pards 146 +if pal40 147 +put gpihb 0 1 148 +for i ulong 40 149 +put gpbase i get gpln i 150 +end 151 +end 152 +n = pafrd tpfgh 2048 153 +for i ulong n bound 2048 154 +put gpgh i get fxo i 155 +end 156 +put gpghl 0 n 157 +put gpnum 0 paghnum 158 +if eq get gpnum 0 0 159 +put gpnum 0 pasjnum 160 +end 161 +put gpicode 0 0 162 +put gpmby 0 0 163 +papid tpfbn 164 +e = paexist 165 +if e 166 +put gpicode 0 2 167 +put gpmby 0 pastsz 168 +end 169 +papid tpfmb 170 +e = paexist 171 +if e 172 +put gpicode 0 1 173 +put gpmby 0 pastsz 174 +end 175 +put gpmcm 0 0 176 +put gpmfl 0 0 177 +put gpmdidl 0 0 178 +put gpmts 0 0 179 +ret true 180 +end 181 +note paiload: the imported item gpid into the globals (SPEC section 1): false unless source.json 182 +note starts with the import prefix, status is one of the three words and head is 40 hex and a line 183 +note feed. source.json is kept up to 4096 bytes. 184 +fn paiload to bool 185 +put gpimp 0 1 186 +n = pafrd tpfsj 4096 187 +if lt n len tpsjpre 188 +ret false 189 +end 190 +for i ulong len tpsjpre bound 64 191 +if ne get fxo i get tpsjpre i 192 +ret false 193 +end 194 +end 195 +for i ulong n bound 4096 196 +put gpsrc i get fxo i 197 +end 198 +put gpsrcl 0 n 199 +put gpider 0 0 200 +if lt pasjf tpsjder n 201 +put gpider 0 1 202 +end 203 +s = pastrd 204 +if gt s 2 205 +ret false 206 +end 207 +put gpist 0 s 208 +papid tpfhd 209 +r = pards 210 +if not pal40 211 +ret false 212 +end 213 +for i ulong 40 214 +put gphead i get gpln i 215 +end 216 +ret paiload2 217 +end 218 +note ---- the thread: records "comment