interplane.Get Omega
Read in your language

interplane-forge

INTERPLANE Forge

Brought by drakestapleton

branch main Branches Tags History

interplane-forge / tools / doi / README.md

204 lines · 13870 bytes Raw Blame History Rendered
1# Reserve a DOI for a paper
2
3A **local author tool**, not an Interplane endpoint. It creates a Zenodo draft, reserves a DOI,
4uploads the paper, and puts the DOI into the author's `.zenodo.json`. It publishes only after the
5author types **exactly `yes`** at `/dev/tty`. No, `Yes`, `yes `, EOF and no terminal keep the draft
6unpublished. It does not publish the repository to Radicle or send a token to Interplane.
7
8The default is **sandbox.zenodo.org**: test records, not registered DOIs. Production requires
9`--production`. A production publication is permanent: inspect the metadata and files first.
10
11## Build and use
12
13Linux AArch64, seeded Omega. From this repository's root:
14
15```sh
16sh tools/doi/build.sh
17# Or name the compiler and an output directory:
18sh tools/doi/build.sh /path/to/omega-mv/seed/out/omc /path/to/output
19```
20
21The compiler must have SHA-256
22`3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194`
23(omega-mv `f4df82394e35893dcf1354dda69a2fe028d94bc1`). Any other binary is refused. The default
24output is `.build/doi/doi`; set `DOI_ENGINE=/path/to/output/doi` when using another directory.
25Keep `doi.sh`, `fixture-curl.sh` and the engine together with this checkout; no system install or
26server change is needed.
27
28Create a **personal access token on the selected Zenodo site**, with `deposit:write` and
29`deposit:actions` scopes. Sandbox and production tokens are separate. Enter it without shell history
30or a credentials file (these two lines are for Bash):
31
32```bash
33read -rsp 'Zenodo token: ' ZENODO_TOKEN; printf '\n'
34export ZENODO_TOKEN
35```
36
37Then run:
38
39```sh
40sh tools/doi/doi.sh /path/to/paper-repo
41# Optional: also upload a source archive you have already prepared and inspected.
42sh tools/doi/doi.sh /path/to/paper-repo --source /path/to/source.tar.gz
43# A real registered DOI, only when the author deliberately chooses production:
44sh tools/doi/doi.sh /path/to/paper-repo --production
45unset ZENODO_TOKEN
46```
47
48The tool checks everything locally before its first request. It then creates a draft, validates all
49returned links, prints the draft URL and reserved DOI, and inserts `"doi"` as the first metadata
50member. All original metadata bytes are retained. It uploads **every top-level `*.pdf` (case insensitive),
51including untracked PDFs**, and the optional source file **before publish consent**. Git tracking is
52not consulted. Inspect this selection before running the tool: declining publication does not undo
53these uploads to the private draft. The tool prints the selected names and checks each acknowledged
54file name and size. The publish prompt names
55the selected site and DOI. Type `yes` there only after deciding to publish; any other answer exits
56successfully with “Draft kept, not published.”
57
58A reservation is saved **before uploads** so an upload failure does not lose its DOI. There are no
59automatic retries: a lost create response could otherwise create a second draft. On interruption,
60HTTP error, upload mismatch or declined consent, inspect the draft on the selected Zenodo site and
61finish or delete it there. A second run refuses metadata that already contains `doi`. Remove that
62field only when you deliberately want a new deposit, not as a retry. No replace/update/new-version
63API is used. `.zenodo.json.doi-new` is reserved exclusively before the first request. If it already
64exists, the tool makes zero requests. Inspect it after an interrupted or refused run; it may hold an
65empty reservation, a DOI candidate, or the displaced original following a sync failure. The tool
66does not overwrite or automatically delete a pre-existing temp. After a successful transaction it
67removes its own displaced original only after verifying its bytes and syncing the directory.
68
69One Omega keeper retains the opened repository directory and its exclusive advisory directory lock
70through snapshot and metadata write-back. Changing the original repository pathname cannot redirect
71the write: if the directory is renamed, the write remains in that original directory. A competing
72instance fails before any request. All path components are opened without following symlinks; paths
73with empty, `.` or `..` components are refused (use an absolute non-symlink path).
74
75The submitted metadata bytes must still match before write-back. An atomic `RENAME_EXCHANGE` then
76preserves the displaced metadata, which is compared again to catch an edit immediately before the
77exchange. The candidate stays mode 0600 while written; after the exchange the keeper checks that
78the installed `.zenodo.json` is the same inode (device and inode number) as its retained candidate
79descriptor, and only then restores the original permission bits. If the candidate name was replaced
80by another file, the exchange is reversed: the original metadata is restored and the substituted
81file is left at `.zenodo.json.doi-new` for inspection. On metadata mismatch the exchange is reversed and the edit preserved; the printed draft URL and
82DOI remain available for manual reconciliation, and no upload or publication follows. Successful
83write-back fsyncs the candidate and retained repository directory before the shell proceeds.
84A sync failure is an error, not a saved/published result; inspect both local files and the draft.
85
86## Paper repository format
87
88At the repository root, provide a nonempty `LICENSE` (also accepted: `LICENSE.md`, `LICENSE.txt`,
89`LICENCE`, `COPYING`), at least one nonempty PDF, and `.zenodo.json`. This is Zenodo **metadata itself**,
90not a `{"metadata": ...}` wrapper:
91
92```json
93{
94 "title": "My paper",
95 "creators": [{"name": "Family, Given", "orcid": "0000-0000-0000-0000"}],
96 "description": "The abstract or description of the paper.",
97 "license": "cc-by-4.0",
98 "upload_type": "publication",
99 "publication_type": "article",
100 "keywords": ["research"]
101}
102```
103
104Required: nonempty strings `title`, `description`, `license` (or `{"id":"cc-by-4.0"}`),
105`upload_type`; a nonempty `creators` array, each element an object with a nonempty string `name`.
106`publication_type` is required for `upload_type: publication`; `image_type` for `image`. Other
107upload types are `poster`, `presentation`, `dataset`, `video`, `software`, `lesson`, `physicalobject`,
108`other`. Zenodo itself checks its controlled vocabularies and any optional metadata. Its field errors
109are displayed, not suppressed. Unknown metadata is retained verbatim. Top-level keys must be written
110plainly without JSON backslash escapes. Do not supply `doi` or `prereserve_doi`: this tool manages the
111reservation. There is no CFF parser.
112
113Upload base names may contain only `A-Z a-z 0-9 - . _` and cannot start with a dot. Duplicate base
114names, empty files, nonregular files and symlink inputs (including metadata, licenses, PDFs and source) are refused. Source is an explicit file: the tool never
115archives the repository or reads `.git`. Untracked PDFs are deliberately included: a matching
116PDF can contain private material, and the optional source is uploaded exactly as supplied.
117
118## Token and transport boundary
119
120- `ZENODO_TOKEN` stays in environment/memory. The shell's builtin `printf` pipes a quoted header to
121 `curl --config -`; it never occurs in curl argv, a config file, a URL or a request log. Invalid token
122 bytes are refused without printing the token. Neither tool script enables xtrace.
123- Curl's user config is disabled (`-q` first), proxies and URL globbing are disabled, only HTTPS is
124 permitted, and redirects are not followed. Returned upload/publish links must match the selected
125 Zenodo origin and expected API path; lookalike hosts, HTTP, credentials, query strings, ports and
126 control bytes are refused before any upload. No arbitrary API-base flag exists.
127- Before any request, the long-lived Omega keeper walks ancestors using `O_NOFOLLOW | O_DIRECTORY`
128 descriptors and `fchdir`. It checks regular leaf descriptors opened with `O_NOFOLLOW | O_NONBLOCK`.
129 PDF enumeration happens in the retained repository, not a shell glob of its mutable pathname.
130 Curl and size checks use private snapshots. A source-directory symlink is refused as well as a
131 leaf symlink. A PDF replaced after snapshotting cannot change the uploaded bytes.
132- Temporary request/response files are private (`umask 077`) and removed on exit. They contain paper
133 metadata and Zenodo responses, **not the bearer**. An input FIFO carries the DOI; anonymous output pipes carry READY/SAVED/DONE.
134 Omega creates the keeper response pipe before forking, supervises keeper exit and consumer
135 liveness, and emits DONE only after successful keeper wait. The shell opens its input FIFO
136 read/write (no rendezvous wait), and requires READY then SAVED then DONE before uploading.
137 Keeper startup death closes the response stream; consumer failure kills and reaps the keeper.
138 The keeper retains its descriptors without exporting a path-string identity.
139- Upload URLs accept one alphanumeric/hyphen bucket component. Publish URLs accept exactly
140 `/api/deposit/depositions/<decimal-create-id>/actions/publish`; the numeric ID must equal the
141 create response's `id`. HTML links accept `/deposit/<id>` or `/records/<id>` at the same origin.
142 Dot segments, percent escapes, extra components and differing IDs are refused.
143- The launcher sets both soft and hard `RLIMIT_CORE` to zero (`ulimit -c 0`) and unsets
144 `SSLKEYLOGFILE` before launching children. This is not universal dump prevention: Linux does
145 not enforce this limit for piped core collectors. Piped/system crash collectors (including
146 apport/systemd-coredump) are excluded unless their retention policy is independently verified.
147 No collector policy is changed or qualified by this tool; do not use a real token where the
148 local crash-storage policy is unacceptable. These are precautions, not proof of credential secrecy.
149- This is not protection against a compromised local account, memory inspection, swap, an external
150 shell tracing the token-entry commands, or a malicious Zenodo server echoing credentials. Do not
151 put real credentials in tests or fixture data. Advisory locks serialize this tool's writers, not
152 arbitrary editors. The exchange check preserves a completed edit racing immediately before it;
153 it is not an atomic compare-and-swap against a hostile same-UID process continually editing or
154 renaming files during comparison/rollback. Readers may briefly observe the candidate during an
155 exchange that is rolled back. Hard links and deliberately copied private data are not provenance
156 checks. Do not run against an actively adversarial same-account checkout.
157
158JSON parsing, validation, URL/DOI checks, rewrite and terminal consent are seeded Omega (`doi.om`).
159The shell performs transport/file IO and sequences curl with the Omega keeper protocol. Repository
160custody, enumeration, snapshot comparison, exclusive reservation and exchange are Omega, not shell. The parser
161is independently implemented using the recursive-descent pattern inspected in omega-harness
162`tools/jflat.om` at Radicle commit `92eba82c`; no third-party parser is vendored. The pinned compiler
163has no runtime array growth: an input JSON file of 16777216 bytes or more is explicitly refused (its
164largest global array); excessive nesting stops at its 8 MiB stack limit. These are compiler storage
165boundaries, not claims of unlimited input support.
166
167Transport dependency observed on the development host: curl **8.5.0**, libcurl **8.5.0**, OpenSSL
168**3.0.13**. It supplies HTTPS/TLS and file transfer only. The Omega successor is a Zenodo HTTP adapter
169on omega-mv's `om/tls` primitives; it is not implemented or claimed by this slice. Shell/coreutils
170supply file IO (`mktemp`, `mkfifo`, `dirname`, `wc`, `tr`, cleanup); no Python, jq, Rust, C or JS product logic.
171
172## Offline fixtures and full check
173
174```sh
175bash tools/doi/tests/run.sh "$HOME/work/flux/omega-mv/seed/out/omc"
176```
177
178The suite builds the pinned engine and uses a fixed **fake token**. It runs every request through
179`fixture-curl.sh`, a stand-in that copies static response files and records method/URL/argv and
180uploaded bytes; it never runs curl or makes any connection. A pseudo-terminal simulates exact `yes`
181only for fixtures. Dependencies for the suite: Bash, coreutils, util-linux `script`/`setsid`, and
182`strace` (actual `execve` argv audit). It checks request JSON and rewritten metadata against independent
183byte fixtures, sandbox default, explicit production, source/PDF bytes, required metadata/LICENSE/PDF,
184existing DOI, declined/wrong-case/extra-space/no-tty consent, wrong origin/scheme/lookalike URLs,
185HTTP failures, upload mismatches, input symlinks (metadata/LICENSE/PDF/source, including dangling),
186post-snapshot replacement, ancestor/root swaps, two metadata-drift timings, exclusive writer/temp
187refusals with specific diagnoses, actual directory-fsync traces and injected sync failure,
188actual keeper protocol writes (including an erroneous-SAVED/nonzero-exit negative control),
189deterministic keeper death before input and output setup, identical stopped/continued startup
190controls, no remaining keeper/supervisor PIDs, a swallowed-death timeout negative control,
191inherited zero core limits, exact endpoint grammar, and token absence from every file and actual argv.
192The test timeout is an alarm, not a product startup timeout. The short Omega polling interval
193only schedules liveness checks; readiness and child status, never elapsed time, decide success.
194
195Manual offline flow (copy the fixture directory first: the stand-in writes request logs there):
196
197```sh
198cp -R tools/doi/tests/fixtures /path/to/offline-responses
199ZENODO_TOKEN=fixture-only sh tools/doi/doi.sh /path/to/test-paper --fixture /path/to/offline-responses
200```
201
202`--fixture` never falls back to a real request; omit it only for a deliberate author operation.
203The full fixture module is host-only verification. No real Zenodo operation or credential is part
204of development verification.