stanford-openarch 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/check.js +467 -0
- package/cli/draft.js +75 -0
- package/cli/init.js +511 -0
- package/cli/mcp.js +302 -0
- package/cli/openarch.js +856 -0
- package/cli/pathCheck.js +114 -0
- package/cli/research.js +248 -0
- package/cli/safeFile.js +69 -0
- package/cli/ui.js +209 -0
- package/members/kit/README.md +215 -0
- package/members/kit/catalog.js +217 -0
- package/members/kit/csv.js +51 -0
- package/members/kit/index.js +286 -0
- package/members/kit/searchIndex.js +61 -0
- package/members/lib/fileSafety.js +35 -0
- package/members/lib/verifyQuote.js +210 -0
- package/package.json +22 -3
- package/protocol/MEMBERSHIP-AGREEMENT.md +105 -0
- package/protocol/OPENARCH-PROTOCOL.md +475 -0
- package/protocol/PARTNER-TERMS.md +43 -0
- package/server/lib/mcpTools.js +194 -0
- package/server/lib/readCapped.js +34 -0
- package/server/lib/vocabulary.js +177 -0
- package/README.md +0 -3
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
# openarch Protocol, version 0.1
|
|
2
|
+
|
|
3
|
+
openarch is a network for sharing archival research data between universities. Each
|
|
4
|
+
member keeps its own holdings and exposes them through the small set of HTTP calls
|
|
5
|
+
defined here. A registry at the hub lists the members, approves the partners who may
|
|
6
|
+
read, issues their keys, and offers one connection point (REST and MCP) that reaches
|
|
7
|
+
every member.
|
|
8
|
+
|
|
9
|
+
openarch never takes custody of a member's data. Every answer a partner receives is
|
|
10
|
+
produced by the member that holds the material and carries that member's provenance.
|
|
11
|
+
|
|
12
|
+
**Status.** Draft 0.1, 2026-10-19. The first member is INDRA
|
|
13
|
+
(indra.stanford.edu). Stanford operates the hub; the governance section says how that
|
|
14
|
+
can change.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 1. Roles
|
|
19
|
+
|
|
20
|
+
| Role | Who | What they can do |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| **Hub** | openarch.stanford.edu | Keeps the member registry, approves partners, issues and revokes keys, audits, routes requests. |
|
|
23
|
+
| **Member** | An institution's archive (INDRA, a university library, …) | Implements the Member API over its own holdings. Sets its own reuse terms and limits. May decline any request. |
|
|
24
|
+
| **Partner** | A researcher, a lab, a tool, an AI agent acting for one of them | Holds a key. Reads, searches, fetches, cites and verifies, within quotas. |
|
|
25
|
+
| **Operator** | A named person at the hub | Holds an admin key. Every admin action is attributable to one operator. |
|
|
26
|
+
|
|
27
|
+
A member's own staff may also hold partner keys for their own holdings; the protocol
|
|
28
|
+
does not special-case that.
|
|
29
|
+
|
|
30
|
+
## 2. Keys
|
|
31
|
+
|
|
32
|
+
- Keys are bearer tokens: `oa_<role>_<40 hex>`, roles `adm` (operator), `mem`
|
|
33
|
+
(a member's account key: its staff sign in at `/account`, manage the sharing grid, and
|
|
34
|
+
use the network as a partner does), `ro` (partner).
|
|
35
|
+
- The **hub credential** is not a key the hub looks up but the secret the hub presents to
|
|
36
|
+
a member's adapter on every call (§7). The hub mints it when it approves the member
|
|
37
|
+
(`oa_hub_<40 hex>`), keeps it sealed at rest, and the operator sends it to the member
|
|
38
|
+
once, with its account key. A member's adapter needs only its SHA-256 to check it.
|
|
39
|
+
Credentials set before this rule (some shaped `oa_mem_…`) stay valid.
|
|
40
|
+
- The hub stores only the SHA-256 of a key. Plaintext is shown once, at issuance.
|
|
41
|
+
- Every key is bound to one institution and one named holder, with a label, an
|
|
42
|
+
expiry (default 1 year), and quotas. Suspending the institution suspends its keys.
|
|
43
|
+
- Keys are presented as `Authorization: Bearer oa_…`. A key is never put in a URL.
|
|
44
|
+
- There are no shared keys. A tool that serves several people gets one key per person,
|
|
45
|
+
or a member-role key with its own accounting.
|
|
46
|
+
|
|
47
|
+
### 2.1 What a partner key can do
|
|
48
|
+
|
|
49
|
+
Read-only. Version 0.1 of the protocol has no write calls; publishing stays inside each
|
|
50
|
+
member's own systems. Writes are a later version, once members ask for them.
|
|
51
|
+
|
|
52
|
+
### 2.2 Quotas
|
|
53
|
+
|
|
54
|
+
Quotas are measured in what costs the member something, not in requests:
|
|
55
|
+
|
|
56
|
+
| Quota | Unit | Default for a new partner key |
|
|
57
|
+
|---|---|---|
|
|
58
|
+
| Documents | document texts fetched, and quotations checked, per rolling day | 2,000 |
|
|
59
|
+
| Bytes | bytes of document text per rolling day | 200 MB |
|
|
60
|
+
| Searches | search calls per minute | 30 |
|
|
61
|
+
| Concurrency | calls in flight at once | 4 |
|
|
62
|
+
| Semantic a minute | semantic passage calls (`GET /passages`) per minute | 1 |
|
|
63
|
+
| Semantic a day | semantic passage calls per rolling day | 100 |
|
|
64
|
+
| Semantic documents | distinct documents returned in passage hits per rolling day | 1,000 |
|
|
65
|
+
|
|
66
|
+
The hub enforces quotas for routed calls. A quotation check reads the whole document at
|
|
67
|
+
its member, so each one counts as a document; a `verify-quotes` batch needs as many
|
|
68
|
+
documents left in the day as it has items. Concurrency counts the key's calls that
|
|
69
|
+
reach a member, open at once; one more is refused at once (`429`, quota `in_flight`).
|
|
70
|
+
The hub also bounds how much of members' answers it holds at once, across keys and per
|
|
71
|
+
key; a large answer that would pass that bound is refused at once (`503`, `hub_busy`,
|
|
72
|
+
with `Retry-After`). A member may also enforce its own limits and
|
|
73
|
+
return `429` with a `Retry-After` header. Quotas are per key; a partner who needs more
|
|
74
|
+
asks the hub, and the increase is recorded in the audit log.
|
|
75
|
+
|
|
76
|
+
## 2.3 What flows through the network: text first, files where a member shares them
|
|
77
|
+
|
|
78
|
+
openarch shares **what an application needs to use the knowledge in an archive**:
|
|
79
|
+
the document's text (OCR, a born-digital text layer, a transcript, or a
|
|
80
|
+
spreadsheet rendered as text), its token count, its metadata, its page structure,
|
|
81
|
+
its citation and its reuse terms — and, for the kinds of material a member's sharing
|
|
82
|
+
grid marks `files` (§4.1), the files themselves: the image, the PDF, the video, served
|
|
83
|
+
through §4.6–4.7 under the member's declared terms and metered in bytes like text.
|
|
84
|
+
|
|
85
|
+
Two things follow:
|
|
86
|
+
|
|
87
|
+
- **Text is the floor, files are a choice.** A member is often a *research index* over
|
|
88
|
+
another institution's holdings, not the holding itself. INDRA mirrors text and metadata
|
|
89
|
+
for about 30 million documents but keeps no exhaustive store of the archives' files,
|
|
90
|
+
so it shares every kind as `text` and the permalink leads to the source. PETRA holds
|
|
91
|
+
the advertisements it indexes, so it shares images and video as `files`.
|
|
92
|
+
- **The hub never becomes a mirror.** A file flows through the hub's route, or by a
|
|
93
|
+
short-lived signed URL the member mints into its own storage; the hub stores nothing
|
|
94
|
+
and holds no member's storage credential.
|
|
95
|
+
|
|
96
|
+
## 3. Identifiers and permalinks
|
|
97
|
+
|
|
98
|
+
- **Member id.** A short lowercase slug: `indra`, `ucsf-idl`, … Unique across the
|
|
99
|
+
network and assigned by the hub.
|
|
100
|
+
- **Collection id.** `<member>/<collection>`, slug segments, e.g. `indra/toxicdocs`.
|
|
101
|
+
- **Document id.** `<member>/<local id>`, where the local id is whatever the member
|
|
102
|
+
uses and is stable for the life of the document, e.g. `indra/td-NG2mLp2DQmnqjZDBpyJ8maymR`.
|
|
103
|
+
A member must never reuse a local id for a different document.
|
|
104
|
+
- **Permalink.** Every document has `permalink`, a URL at the member that resolves to
|
|
105
|
+
the document for a human reader, and the hub resolves
|
|
106
|
+
`https://openarch.stanford.edu/d/<member>/<local id>` to the same place.
|
|
107
|
+
|
|
108
|
+
## 4. The Member API
|
|
109
|
+
|
|
110
|
+
A member serves these under a base URL it registers with the hub, over TLS at a public
|
|
111
|
+
address: the address before `/openarch/v1` (`https://archive.example.edu`, never
|
|
112
|
+
`…/openarch`). All responses are JSON, UTF-8. The member authenticates the hub by the hub
|
|
113
|
+
credential (§2, §7); the partner key hash the hub forwards is for the member's own
|
|
114
|
+
accounting. Each call lists what it MUST return; a member may add fields, and a partner
|
|
115
|
+
must ignore fields it does not know.
|
|
116
|
+
|
|
117
|
+
### 4.1 `GET /openarch/v1/manifest` (public)
|
|
118
|
+
|
|
119
|
+
Describes the member.
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"protocol": "0.1",
|
|
124
|
+
"member": "indra",
|
|
125
|
+
"name": "INDRA — Industry Documents Research and Analysis",
|
|
126
|
+
"institution": "Stanford University",
|
|
127
|
+
"contact": "indra@stanford.edu",
|
|
128
|
+
"capabilities": ["search", "documents", "citations", "verify_quote"],
|
|
129
|
+
"collections": [ { "id": "indra/ucsf-idl", "title": "UCSF Industry Documents Library",
|
|
130
|
+
"documents": 25804502, "terms": "ucsf-idl" } ],
|
|
131
|
+
"terms": { "ucsf-idl": { "label": "UCSF Industry Documents Library terms of use",
|
|
132
|
+
"url": "https://www.industrydocuments.ucsf.edu/…",
|
|
133
|
+
"reuse": "research-and-education" } },
|
|
134
|
+
"limits": { "search_results_max": 200, "document_bytes_max": 20000000 }
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
A terms entry's `reuse` is one of the grants in the vocabulary (`open`,
|
|
139
|
+
`research-and-education`, `non-commercial`, `excerpts-only`, `metadata-only`; `GET
|
|
140
|
+
/api/v1/vocabulary` on the hub); `url` points to the full text where there is one.
|
|
141
|
+
|
|
142
|
+
`capabilities` names which of the calls below the member implements; `search`,
|
|
143
|
+
`documents` and `citations` are required, `verify_quote` is optional.
|
|
144
|
+
|
|
145
|
+
Optional identity fields, rendered by the hub's directory and by clients:
|
|
146
|
+
|
|
147
|
+
- `home` — the member's public site.
|
|
148
|
+
- `logo` — `{ "light": "<url>", "dark": "<url>", "scale": 1 }`: an SVG or PNG for light and
|
|
149
|
+
for dark backgrounds (the version named `light` is the one drawn ON a light background).
|
|
150
|
+
`scale` is optional (default 1): the hub draws every logo at one standard height and
|
|
151
|
+
multiplies yours by `scale`, so a mark whose box carries padding can match the others'
|
|
152
|
+
capital height. Judge it by the capitals, not the box.
|
|
153
|
+
A logo is public: the hub fetches it without the member's hub credential, so it must
|
|
154
|
+
not sit behind the member's gate.
|
|
155
|
+
- `terms_statement` — the member's own position on reuse, stated beside, never in place
|
|
156
|
+
of, the per-collection `terms`: `{ "basis": "<one word>", "statement": "<sentence or
|
|
157
|
+
two>", "applies_to": "all collections" | ["<collection id>", …], "stated_by", "stated_on" }`.
|
|
158
|
+
A partner reads `terms` for what each source archive publishes and `terms_statement`
|
|
159
|
+
for what the member asserts about serving it.
|
|
160
|
+
|
|
161
|
+
A member also **declares**, in the fixed vocabulary of `server/lib/vocabulary.js`,
|
|
162
|
+
three things an agent can route on without reading prose. They are required for
|
|
163
|
+
membership (MEMBERSHIP-AGREEMENT.md) and checked by `openarch member check`:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
"rights": {
|
|
167
|
+
"basis": "owner | public-record | public-domain | licensed | fair-use-host | mixed",
|
|
168
|
+
"license": "CC-BY-4.0 (when basis is licensed or grant is open)",
|
|
169
|
+
"grant": "open | research-and-education | non-commercial | excerpts-only | metadata-only",
|
|
170
|
+
"attribution": "required | requested | none",
|
|
171
|
+
"automated_access": "allowed | via-openarch | forbidden",
|
|
172
|
+
"statement": "a sentence or two in the member's own words (optional)",
|
|
173
|
+
"declared_by": "a named person", "declared_on": "YYYY-MM-DD"
|
|
174
|
+
},
|
|
175
|
+
"permalinks": {
|
|
176
|
+
"pattern": "https://indra.stanford.edu/docs/{id}",
|
|
177
|
+
"stable": true, "legacy_resolve": true, "human_readable": true
|
|
178
|
+
},
|
|
179
|
+
"agreement": { "version": "0.1", "accepted_by": "a named person", "accepted_on": "YYYY-MM-DD" },
|
|
180
|
+
"sharing": {
|
|
181
|
+
"share": { "pdf": "text", "image": "files", "spreadsheet": "text" },
|
|
182
|
+
"withhold": { "email": "privileged", "video": "not-digitized" }
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
`sharing` is the member's grid: every kind of material it holds (`MATERIAL_KINDS`:
|
|
187
|
+
pdf, image, video, audio, spreadsheet, email, text, dataset) sorted into **share** —
|
|
188
|
+
with how far it is served: `metadata`, `text` (metadata and the document's text) or
|
|
189
|
+
`files` (metadata, text and the files themselves) — or **withhold**, with a reason
|
|
190
|
+
(`privileged`, `confidential`, `under-review`, `rights`, `personal-data`,
|
|
191
|
+
`not-digitized`). A kind in neither column is not held. The grid is the member's
|
|
192
|
+
POLICY, kept at the hub and changeable in the member's account; the manifest's
|
|
193
|
+
`capabilities` and each document's `kind` are the member's CAPABILITY; the hub enforces
|
|
194
|
+
the policy on every route, whatever the adapter would serve: a withheld kind is not
|
|
195
|
+
served at all, a kind shared as `metadata` is served without its text (no text, no
|
|
196
|
+
search snippet, no concordance line, no quotation check), and files only for kinds
|
|
197
|
+
shared as `files`. Kind by kind for every document whose adapter names its kind in
|
|
198
|
+
`material_kind` (one of `MATERIAL_KINDS`, on documents, search results, concordance
|
|
199
|
+
lines and verify answers); for a document it does not name, the most the grid shares
|
|
200
|
+
of any kind. A member with no grid on record is served not at all. `openarch member
|
|
201
|
+
check` reports where the policy and the capability disagree. A collection may
|
|
202
|
+
carry its own `sharing` block when its grid differs from the member's.
|
|
203
|
+
|
|
204
|
+
`rights` is the member's default; a collection whose rights differ carries its own
|
|
205
|
+
`rights` block of the same shape (basis `mixed` at the member level says so). The
|
|
206
|
+
three `permalinks` promises are the permalink standard: minted once and never reused;
|
|
207
|
+
every earlier form resolves forever; the permalink opens the document for a person.
|
|
208
|
+
|
|
209
|
+
`terms` is the generalisation of openarch's earlier per-record legal basis: for a
|
|
210
|
+
federated member, reuse terms attach to a collection (the upstream archive), and every
|
|
211
|
+
document returned names its terms id. A partner can always find out on what basis it
|
|
212
|
+
may reuse a document.
|
|
213
|
+
|
|
214
|
+
### 4.2 `GET /openarch/v1/search?q=…&collection=…&limit=…&cursor=…`
|
|
215
|
+
|
|
216
|
+
Searches the member's holdings. `q` is the member's native query syntax; the manifest
|
|
217
|
+
may document it under `search_syntax`. Returns:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{
|
|
221
|
+
"total": 1284, "total_is_estimate": false,
|
|
222
|
+
"results": [ { "id": "indra/jlid0123", "title": "…", "date": "1979-11-08",
|
|
223
|
+
"collection": "indra/ucsf-idl", "snippet": "…", "permalink": "https://…",
|
|
224
|
+
"tokens": 1830, "terms": "ucsf-idl" } ],
|
|
225
|
+
"cursor": "opaque-or-null"
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`total` is the member's count for the query. If the member caps results, it says so
|
|
230
|
+
with `total_is_estimate` or a `capped` field; it never silently truncates a count.
|
|
231
|
+
|
|
232
|
+
### 4.3 `GET /openarch/v1/documents/<local id>`
|
|
233
|
+
|
|
234
|
+
Returns metadata and, when the key's quota allows, the document's text:
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"id": "indra/jlid0123", "title": "…", "date": "…", "authors": ["…"], "type": "letter",
|
|
239
|
+
"collection": "indra/ucsf-idl", "permalink": "https://…", "source_url": "https://…",
|
|
240
|
+
"terms": "ucsf-idl", "tokens": 1830, "pages": 4,
|
|
241
|
+
"text": "…", "text_kind": "ocr", "text_quality": 0.82,
|
|
242
|
+
"pages_marked": true
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
- `text_kind` is one of `ocr`, `born-digital`, `transcript`, `spreadsheet`, `none`.
|
|
247
|
+
For `spreadsheet`, `text` is the member's text rendering of the workbook and the
|
|
248
|
+
response adds `sheet: { names: [...], rendering: "<member's rendering id>" }` so a
|
|
249
|
+
caller knows which sheets exist and how cells were laid out as text. Cell
|
|
250
|
+
citations use the member's own form (INDRA: `(sheet "Name", D14)`).
|
|
251
|
+
- `text_quality`, when present, is the member's 0–1 estimate for the text.
|
|
252
|
+
- `pages_marked: true` means the text carries `[[page N]]` markers at page starts.
|
|
253
|
+
- `tokens` is the member's token count for the text as served (INDRA: the count the
|
|
254
|
+
model would be billed).
|
|
255
|
+
|
|
256
|
+
`?text=false` returns metadata only and costs no document quota.
|
|
257
|
+
|
|
258
|
+
`?pages=3-5,8` (capability `page_ranges`, optional) returns only those pages, each with
|
|
259
|
+
its marker, and adds `pages_returned`, `pages_missing` and `pages_total`. A member
|
|
260
|
+
without the capability is sent the plain call and the hub cuts the pages from the
|
|
261
|
+
`[[page N]]` markers itself (§5), so a partner pays in bytes only for the pages it read;
|
|
262
|
+
a text without markers answers `422 no_page_markers`, a range past the end
|
|
263
|
+
`416 pages_out_of_range`. A member whose source marks pages another way (UCSF's
|
|
264
|
+
trailing `pgNbr=N`) rewrites them into `[[page N]]` before serving — only when the
|
|
265
|
+
numbering is a clean 1, 2, 3 …, and without dropping a word.
|
|
266
|
+
|
|
267
|
+
The files themselves, where a member shares them, come from §4.6–4.7. `source_url`
|
|
268
|
+
points a human to the original at the source archive; `permalink` points to the
|
|
269
|
+
member's own page for the document.
|
|
270
|
+
|
|
271
|
+
### 4.4 `GET /openarch/v1/documents/<local id>/citation?style=apa|chicago|mla|bibtex`
|
|
272
|
+
|
|
273
|
+
Returns `{ "style": "chicago", "citation": "…", "permalink": "https://…" }`. The
|
|
274
|
+
citation names the holding archive and the permalink.
|
|
275
|
+
|
|
276
|
+
### 4.5 `POST /openarch/v1/verify-quote` (capability `verify_quote`)
|
|
277
|
+
|
|
278
|
+
Body `{ "id": "indra/jlid0123", "quote": "…" }`. `id` is the document's full id
|
|
279
|
+
(`<member>/<local id>`, as every search result and document names it); a member MUST
|
|
280
|
+
also accept the bare local id. Returns the member's verdict on whether the quotation
|
|
281
|
+
appears in the document's text:
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{ "id": "indra/jlid0123", "status": "anchored", "confidence": 0.97,
|
|
285
|
+
"offset": 10234, "method": "indra-quote-anchor-v3" }
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
`status` is `anchored` (found, verbatim or within tolerance), `uncertain` (partly
|
|
289
|
+
found), or `fabricated` (not found). This is the call that lets an agent check a
|
|
290
|
+
quotation against the actual document before using it, and it is the reason to join
|
|
291
|
+
the network rather than scrape it.
|
|
292
|
+
|
|
293
|
+
An `uncertain` verdict SHOULD carry `matched_span`, the passage as the document has it,
|
|
294
|
+
when the parts that matched sit together: the difference is usually the document's OCR
|
|
295
|
+
("offorts" for "efforts"), and the reader can see it. A quotation with an ellipsis is
|
|
296
|
+
anchored when every fragment is found in order; its `matched_span` is the fragments as
|
|
297
|
+
found, joined by " … ", with `fragment_offsets`, and never the text the ellipsis leaves
|
|
298
|
+
out. A member bounds its own work: the reference adapters check at most 200 distinct
|
|
299
|
+
5-word runs of a quotation, and a check that sampled says `uncertain` at most, never
|
|
300
|
+
`anchored`.
|
|
301
|
+
|
|
302
|
+
**How it scales.** The unit of work is one document, never the corpus: the id names
|
|
303
|
+
the member and the document, the member reads that one text and matches the quotation
|
|
304
|
+
against it. A check costs what serving the document costs, needs no index, and lands
|
|
305
|
+
where the text already is; the hub only routes. Ten members or a thousand, each check
|
|
306
|
+
is one member reading one document, so capacity grows with membership. A quotation
|
|
307
|
+
whose document is unknown is located by `POST /find-quote` (§5), a bounded
|
|
308
|
+
search-then-verify; an answer with many quotations is checked in one
|
|
309
|
+
`POST /verify-quotes` call. A verdict says the words are, or are not, in the text the
|
|
310
|
+
member holds; it does not certify the OCR or the member — that is §4.8's job.
|
|
311
|
+
|
|
312
|
+
### 4.6 `GET /openarch/v1/documents/<local id>/files` (capability `files`)
|
|
313
|
+
|
|
314
|
+
Lists the files a document has and the member serves — the image, the PDF, the video,
|
|
315
|
+
page images, a thumbnail — never the files of a kind the member withholds:
|
|
316
|
+
|
|
317
|
+
```json
|
|
318
|
+
{ "id": "petra/747433173", "files": [
|
|
319
|
+
{ "file_id": "primary", "kind": "image", "role": "primary", "media_type": "image/png",
|
|
320
|
+
"bytes": 412330, "sha256": "9f2c…e41a", "width": 1600, "height": 2200,
|
|
321
|
+
"url": "https://…/openarch/v1/documents/747433173/files/primary" } ] }
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
`role` is one of `primary`, `page`, `thumbnail`, `keyframe`, `attachment`. `sha256`
|
|
325
|
+
(optional, hex) is the hash of the bytes the file call serves, so a partner can prove the
|
|
326
|
+
copy it holds is the member's; when present it must match (`member check` F4). `url` is where
|
|
327
|
+
the bytes are: the member's own file call (below), or a short-lived signed URL into the
|
|
328
|
+
member's storage (R2, S3) that the member mints — the hub and the partner never hold a
|
|
329
|
+
member's storage credential. `?text=false` on the document call is the cheap way to learn
|
|
330
|
+
whether files exist (`has_files`); the listing costs a metadata call.
|
|
331
|
+
|
|
332
|
+
### 4.7 `GET /openarch/v1/documents/<local id>/files/<file id>` (capability `files`)
|
|
333
|
+
|
|
334
|
+
Streams the file with its media type, or redirects (302) to a signed URL. A redirect's
|
|
335
|
+
`Location` must be an absolute `https` URL with no credentials in it; the hub relays nothing
|
|
336
|
+
else (it answers `502 member_bad_response`), and a partner fetches that URL **without** its
|
|
337
|
+
openarch key, which is only ever sent to the hub. Bytes count
|
|
338
|
+
against the partner's byte quota exactly as text does. A member that serves files
|
|
339
|
+
declares it in `capabilities` and in `sharing` (`files` for the kinds concerned).
|
|
340
|
+
|
|
341
|
+
### 4.7a `GET /openarch/v1/trends?terms=…` (capability `trends`) and `GET /openarch/v1/collections` (capability `collections`)
|
|
342
|
+
|
|
343
|
+
Counts only, never text or document ids. `trends` answers how many documents hold each term, year by year (a member may offer a federation-wide and an own-index scope, and co-occurrence of two terms); `collections` lists named collections and other groupings with their document counts. A member offering either **must compute it only over documents it would serve**: a count over withheld documents is an inference leak ("does this phrase appear in the withheld set, and when"). The hub serves neither for a member that shares no material through the network.
|
|
344
|
+
|
|
345
|
+
The same rule governs the counts the hub relays from search and concordance (§5). A member computes them only over what it shares, so the hub relays them as sent, unless they could cover something the hub withholds: when the hub's grid serves a kind less than the member's own declaration shares it, or once the member has returned a kind the hub withholds. Then the hub relays none of that member's counts, on every call alike. Three residuals are the member adapter's to close, because the hub cannot see them:
|
|
346
|
+
- a member that does not label `material_kind` has its counts relayed as it sent them;
|
|
347
|
+
- the first answer in which a member returns a withheld kind changes its counts from relayed to withheld, once;
|
|
348
|
+
- a page shorter than its limit that still carries a cursor can show that the hub removed something from it.
|
|
349
|
+
|
|
350
|
+
### 4.7b `GET /openarch/v1/passages?q=…&limit=…&collection=…` (capability `passages`)
|
|
351
|
+
|
|
352
|
+
Semantic passages, v1 INDRA only. `q` is 1–500 characters of plain words (no Boolean
|
|
353
|
+
syntax), `limit` 1–100 (default 20), `collection` one of the member's collection ids, applied
|
|
354
|
+
after retrieval. The member answers one ranked page, `{ results, end: true, index }`, one hit
|
|
355
|
+
per document: `id`, `score` (cosine similarity, comparable within one answer only), `text`
|
|
356
|
+
(at most 500 characters of the document's text, or `null` with `textOmitted: "too_large"`),
|
|
357
|
+
`anchor` (`passage`, `terms` or `start`), `collection`, `title`, `date`, and `offset` only when
|
|
358
|
+
the member has confirmed that the text occurs exactly once, there, in what it serves at
|
|
359
|
+
`/documents/<id>` (`text.slice(offset, offset + text.length)`, UTF-16 code units; a hint). A
|
|
360
|
+
member whose index is down answers `503 semantic_unavailable`, never a keyword answer in its
|
|
361
|
+
place, and the hub relays that. Hits are leads: a partner reads the document before quoting.
|
|
362
|
+
|
|
363
|
+
### 4.8 Accuracy
|
|
364
|
+
|
|
365
|
+
What a member serves is what it holds, unaltered. OCR is a verbatim rendition of the
|
|
366
|
+
page; a transcript is what was said; metadata is honest; nothing is fabricated,
|
|
367
|
+
doctored or invented, and absence is declared (`withhold`, `tiesUnsourced`, a `partial`
|
|
368
|
+
answer) rather than silently filled. The agreement (§9) makes this a term of membership
|
|
369
|
+
and says what follows when it is broken.
|
|
370
|
+
|
|
371
|
+
### 4.9 Errors
|
|
372
|
+
|
|
373
|
+
JSON `{ "error": "<code>", "message": "…" }` with the right status: `401` no or bad
|
|
374
|
+
key, `403` key lacks the right, `404` unknown id, `429` over quota with `Retry-After`,
|
|
375
|
+
`503` member unavailable, `413` a request body over the route's limit, `415` a
|
|
376
|
+
compressed request body. Request bodies are sent uncompressed, at most 64 KB, or 1 MB
|
|
377
|
+
for `POST /verify-quotes` and `/mcp`. A member that cannot answer part of a request says so in the
|
|
378
|
+
response (`"partial": true` with a `warnings` list) rather than returning less without
|
|
379
|
+
saying.
|
|
380
|
+
|
|
381
|
+
## 5. The Hub API
|
|
382
|
+
|
|
383
|
+
Served at `https://openarch.stanford.edu/api/v1`.
|
|
384
|
+
|
|
385
|
+
| Call | Who | Purpose |
|
|
386
|
+
|---|---|---|
|
|
387
|
+
| `GET /meta` | public | Protocol version, members, citation styles, key roles. |
|
|
388
|
+
| `GET /members` | public | The member directory with each manifest's public fields. |
|
|
389
|
+
| `POST /access-requests` | public | Apply for a partner key: institution, contact, purpose. `202` with a receipt; `429` while that contact address already has 3 applications waiting, or the hub has 1,000 waiting. An application no operator decides within 30 days is marked `expired`: it is kept, with its receipt, and no longer counts as waiting. |
|
|
390
|
+
| `GET /whoami` | key | The key's holder, institution, quotas and remaining allowance. |
|
|
391
|
+
| `GET /search?q=…&members=…` | partner | Fan out to the named members (default: all) and return their results, grouped by member, each group carrying its member's `total`. When a member's counts could cover something the hub withholds (the hub's grid serves a kind less than the member's own declaration shares it, or the member has returned a kind the hub withholds), every group of that member keeps only `results` and `cursor` and its `total` is `null`, on every call alike, so the null says nothing about a query (§4.7a). No withheld number is ever given. The same holds for a concordance's `total_matches`, `per_archive` (recounted from the lines served) and `collocates`. |
|
|
392
|
+
| `GET /documents/<member>/<id>` | partner | Routed to the member; quota charged at the hub. |
|
|
393
|
+
| `GET /documents/<member>/<id>/citation` | partner | Routed. |
|
|
394
|
+
| `POST /verify-quote` | partner | Routed to the member named by the id. |
|
|
395
|
+
| `GET /documents/<member>/<id>?pages=3-5` | partner | Only those pages; cut by the member (`page_ranges`) or by the hub from the markers; bytes charged for the pages served. |
|
|
396
|
+
| `GET /may?id=…\|member=…&collection=…&use=…` | partner | May I? For a document, a collection or a member, and one use or all (`read`, `quote`, `quote-at-length`, `reproduce-image`, `teach`, `text-mine`, `train-model`, `redistribute`, `commercial`): `yes`, `conditions` (yes, if), `ask` or `no`, the most restrictive of the partner terms, the member's grant, basis, automated-access and attribution declarations, and the source archive's terms for the document's collection. Every layer that spoke is listed with what it said; unverified source terms are disclosed. A reading of declarations, not legal advice. |
|
|
397
|
+
| `POST /verify-quotes` | partner | `{ items: [{ id, quote }] }`, 1–100: each routed to its member, several members in parallel; every item answers, in order, with a `summary`. A member that cannot check (no capability, unknown, down) gives `unverifiable`, a status only the hub uses. A call has 60 seconds: an item not started by then answers `unverifiable` with reason `budget`, is not charged, and is counted in `summary.budget`; send it again in another call. |
|
|
398
|
+
| `POST /find-quote` | partner | `{ quote, members?, limit? }`: where is this quotation from? Each member is searched with up to three probes at once — the two most distinctive six-word phrases, quoted, and the distinctive words — and its top `limit` (default 5, at most 10) candidates are verified. Returns `found` (anchored first; an `uncertain` counts only when a run of the words matched, since most words of any sentence occur somewhere in a long document) and `best`. Bounded: three searches and `limit` checks per member. |
|
|
399
|
+
| `GET /passages?q=…&members=indra&collection=…&limit=…` | partner | Semantic passages (§4.7b) from one member that offers them (`indra` in v1; any other `400 member_has_no_passages`). `q` 1–500 characters, `limit` 1–100 (default 20), `collection` checked against the member's manifest (`400 bad_query`). Answers `{ member, query, results, end: true, index }`, no cursor and no total. Each hit is checked at the hub (id, score, text of at most 500 characters or `null` with `textOmitted`, an integer `offset` ≥ 0, a collection in the manifest) and the sharing grid applied per hit; a hit that fails is dropped and never counted. One call is one search and one semantic call (`429 rate_limited`, with `Retry-After`, over a semantic quota); the documents returned count against semantic documents a day, and the text returned against the byte quota. `503 semantic_unavailable` when the member's index does not answer. The query is never logged. |
|
|
400
|
+
| `GET /d/<member>/<id>` | public | Redirects to the member's permalink. |
|
|
401
|
+
| `GET/POST /admin/…` | operator | Members (register, suspend), access requests (approve, deny), keys (issue, revoke, quota), audit log. |
|
|
402
|
+
|
|
403
|
+
The hub routes with the partner's key (§7), records every call in the audit log with
|
|
404
|
+
the key, member, call and byte count, and enforces quotas before routing.
|
|
405
|
+
|
|
406
|
+
## 6. MCP
|
|
407
|
+
|
|
408
|
+
The hub serves MCP over HTTP at `https://openarch.stanford.edu/mcp` (the network) and
|
|
409
|
+
`/mcp/m/<member>` (one member), authenticated by the same bearer key, one JSON-RPC
|
|
410
|
+
request per POST (a batch is refused, as MCP's 2025-06-18 revision dropped batching).
|
|
411
|
+
Tools, all read-only, mapping one-to-one onto the API:
|
|
412
|
+
|
|
413
|
+
- `list_members`, `get_member`
|
|
414
|
+
- `search` (`query`, optional `members`, `collection`, `limit`)
|
|
415
|
+
- `semantic_passages` (`query`, optional `collection`, `limit`): its hits are labeled untrusted
|
|
416
|
+
document text, and leads to read and verify
|
|
417
|
+
- `get_document` (`id`, optional `text: false`)
|
|
418
|
+
- `cite_document` (`id`, `style`)
|
|
419
|
+
- `verify_quote` (`id`, `quote`), `verify_quotes` (`items`, up to 100)
|
|
420
|
+
- `find_quote` (`quote`, optional `members`, `limit`)
|
|
421
|
+
- `may_i` (`id`, or `member` and `collection`; optional `use`)
|
|
422
|
+
- `get_document` takes `pages` too
|
|
423
|
+
- `list_files`, `get_file` (§4.6–4.7)
|
|
424
|
+
|
|
425
|
+
The MCP instructions sent to the client state the terms rule: when the client quotes a
|
|
426
|
+
document it must cite it (`cite_document`), and a member's `terms` govern reuse.
|
|
427
|
+
|
|
428
|
+
A member may additionally serve its own MCP endpoint; the hub's is the one a partner
|
|
429
|
+
configures once to reach everyone. The CLI serves the same tools over stdio
|
|
430
|
+
(`openarch mcp serve`), authenticated by the key stored on the partner's machine, so an
|
|
431
|
+
agent's own configuration never has to hold the key.
|
|
432
|
+
|
|
433
|
+
## 7. How the hub authenticates to a member
|
|
434
|
+
|
|
435
|
+
The hub forwards the partner's own key hash, never the key:
|
|
436
|
+
|
|
437
|
+
```
|
|
438
|
+
X-OpenArch-Hub: openarch.stanford.edu
|
|
439
|
+
X-OpenArch-Key: sha256:<hex of the partner key>
|
|
440
|
+
X-OpenArch-Partner: <institution slug>
|
|
441
|
+
Authorization: Bearer <member-scoped hub credential>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
The member verifies the hub credential (§2: minted by the hub when it approved the member,
|
|
445
|
+
`oa_hub_…`), answers nothing but the manifest without it, and may use the partner's key
|
|
446
|
+
hash for its own per-partner accounting or refusals. A member never sees a partner's
|
|
447
|
+
plaintext key.
|
|
448
|
+
|
|
449
|
+
## 8. Audit
|
|
450
|
+
|
|
451
|
+
The hub keeps an append-only log of key issuance, approvals, denials, revocations,
|
|
452
|
+
quota changes, and every routed call (key id, member, call, document id, bytes,
|
|
453
|
+
status). Operators can read it. Partners can read their own key's rows via `/whoami`.
|
|
454
|
+
|
|
455
|
+
## 9. Terms of reuse
|
|
456
|
+
|
|
457
|
+
Every document names a `terms` id resolved by its member's manifest. The protocol does
|
|
458
|
+
not adjudicate rights; it guarantees the partner is told the terms the holder states,
|
|
459
|
+
on every document, every time. A member that cannot state terms for a collection does
|
|
460
|
+
not expose that collection.
|
|
461
|
+
|
|
462
|
+
## 10. Governance
|
|
463
|
+
|
|
464
|
+
Stanford operates the hub and sets these rules in version 0.1 (the arch is Stanford's).
|
|
465
|
+
The design keeps the door open to shared governance: the admin role is already
|
|
466
|
+
per-operator, so moving to a quorum (2 of 3, 3 of 5) for member admission and key
|
|
467
|
+
policy is a change to who holds operator keys and an approval rule at the hub, not a
|
|
468
|
+
protocol change. Members can leave at any time by withdrawing their manifest; their
|
|
469
|
+
documents stop resolving and their keys stop routing.
|
|
470
|
+
|
|
471
|
+
## 11. Versioning
|
|
472
|
+
|
|
473
|
+
Paths carry the major version (`/openarch/v1/`). Within a major version fields are only
|
|
474
|
+
added, never removed or changed in meaning. The manifest's `protocol` field states the
|
|
475
|
+
exact version a member speaks.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# openarch partner terms, version 0.1
|
|
2
|
+
|
|
3
|
+
A partner is a person, at an institution, who holds a key to the network. By requesting
|
|
4
|
+
the key, the person named in the request agrees to the following.
|
|
5
|
+
|
|
6
|
+
## 1. The key is yours
|
|
7
|
+
|
|
8
|
+
The key is issued to you by name. You keep it, you do not share it, and you tell the
|
|
9
|
+
operator if it leaks. A key is revoked when you leave the institution it was issued for.
|
|
10
|
+
|
|
11
|
+
## 2. What you receive
|
|
12
|
+
|
|
13
|
+
The network relays what each member serves: text, metadata, citations and, where a
|
|
14
|
+
member offers them, files. openarch does not check, warrant or vouch for a member's data;
|
|
15
|
+
you receive it as the member served it, and a member answers for its own data (membership
|
|
16
|
+
agreement, §9). An answer that says `partial` or `withheld` is telling you something; read
|
|
17
|
+
it.
|
|
18
|
+
|
|
19
|
+
## 3. What you may do with it
|
|
20
|
+
|
|
21
|
+
Each member declares the reuse it grants, whether credit is required, and whether
|
|
22
|
+
automated access is allowed; every document names its terms. You use what you receive
|
|
23
|
+
within those terms. You cite what you quote, by the permalink the citation gives you, and
|
|
24
|
+
you check a quotation against the document (`verify_quote`) before you rely on it.
|
|
25
|
+
|
|
26
|
+
## 4. What you may not do
|
|
27
|
+
|
|
28
|
+
You do not re-host or redistribute a member's collection, in whole or in bulk; you do not
|
|
29
|
+
work around quotas, keys or the terms a member declared; you do not present the network's
|
|
30
|
+
answers as your own archive.
|
|
31
|
+
|
|
32
|
+
## 5. Records
|
|
33
|
+
|
|
34
|
+
Every call you make is logged (which member, which call, how much, when). You can read
|
|
35
|
+
your own ledger at any time; the operator can read everything. No reading of yours is
|
|
36
|
+
stored beyond that ledger.
|
|
37
|
+
|
|
38
|
+
## 6. Ending
|
|
39
|
+
|
|
40
|
+
You may stop at any time by telling the operator, who revokes the key. The operator may
|
|
41
|
+
revoke a key that breaks these terms, on notice to you.
|
|
42
|
+
|
|
43
|
+
Accepted by name and date in the key request.
|