@opennodes/registry 0.1.50 → 0.1.52
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/README.md +18 -2
- package/bin.js +6 -2
- package/package.json +2 -2
- package/src/counts.js +135 -0
- package/src/data/locations-ua.json +93 -0
- package/src/export.js +6 -1
- package/src/locations.js +7 -5
- package/src/mcp.js +25 -8
- package/src/probes.js +24 -2
- package/src/search.js +43 -6
- package/src/server.js +67 -9
- package/src/stageb.js +18 -6
- package/src/stagec.js +25 -6
- package/src/store-pg.js +24 -1
- package/src/store.js +31 -1
- package/src/web/index.html +62 -11
package/README.md
CHANGED
|
@@ -10,7 +10,23 @@ ONP_DB=postgres://user:pass@host/db npx @opennodes/registry
|
|
|
10
10
|
|
|
11
11
|
What it does:
|
|
12
12
|
|
|
13
|
-
- **Registration with proof of resource** — namespace challenge (HTTP or DNS TXT), Stage A conformance probes, Stage B identity fingerprinting / context verification / capacity ramp, Stage C continuous liveness and blind probes. Trust tiers: `unverified → community → verified` (+ `disputed`, `suspended`). Claimed ≠ measured ≠ attested — always labeled, never blended.
|
|
13
|
+
- **Registration with proof of resource** — namespace challenge (HTTP or DNS TXT), Stage A conformance probes, Stage B identity fingerprinting / context verification / capacity ramp, Stage C continuous liveness and blind probes. Trust tiers: `unverified → community → verified` (+ `disputed`, `suspended`). Claimed ≠ measured ≠ attested — always labeled, never blended. The tests cover only chat offerings (`onp.openai.chat/v1`). Speech, embeddings and other offerings are shown with `tested: false` and capped to `unverified`, whatever the node's tier, and listed in node detail and the export feed as `verification.untested_offerings`. A node with no chat offering stays unverified. The web app's qualification page (`/#/qualification`) lists the probe load of each stage: Stage A sends 1 blind call per chat offering at verification and on each `PUT /v0/nodes/{id}/ping`; Stage B sends up to 20 per chat offering when the operator asks for admission; Stage C sends a health check every 5 min and 1 blind call per node every hour, both on average.
|
|
14
|
+
- **Operator marks** (ONP-3 §4b): `institutional` and `founding`, set by the registry admin on registered nodes and shown in `/v0/nodes`, node detail, search results and the web app. Labels only, never rank inputs:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
curl -X POST https://registry.example/v0/admin/nodes/io.example.ai/founding \
|
|
18
|
+
-H "authorization: Bearer $ONP_ADMIN_TOKEN" -H "content-type: application/json" -d '{"founding": true}'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The same request with `{"founding": false}` clears the mark; `/institutional` takes `{"institutional": true|false}`.
|
|
22
|
+
- **Trusted and open pools** (ONP-3 §5e):
|
|
23
|
+
- **Who lists:** any operator, from any country.
|
|
24
|
+
- **Search filters:** `trust=trusted` returns only offerings for personal data: declared model lineage without CN, tier verified or higher, an operator in the trusted jurisdictions, `retention: none` and no training on inputs. Each part is also a filter of its own: `lineage=declared`, `exclude_lineage=CN`, `retention=none|ephemeral|logged`, `no_training=true`, `jurisdiction=`, `tier=`.
|
|
25
|
+
- **Labels:** every result carries `pool: "trusted"` or `"open"`.
|
|
26
|
+
- **Recommend:** `policy.sensitive: true` uses the trusted pool, always under the registry's own view.
|
|
27
|
+
- **Configuration:** `ONP_TRUSTED_JURISDICTIONS` (default `EU,CA`) sets the trusted countries, and `/v0/health` publishes the view as `trust.trusted`.
|
|
28
|
+
- **Errors:** a misspelt `trust`, `lineage`, `retention` or `no_training` value gets `400 bad-query`, never a wider result.
|
|
29
|
+
- **Request counts** (ONP-3 §6.6): how often search, recommend and the MCP tools returned each node, per ISO week, in node detail (`request_counts`, 12 weeks) and at `GET /v0/stats/requests?weeks=4&node_id=…`. Only node ids and counts are stored, never the query, task or client.
|
|
14
30
|
- **Search and transparent ranking** (`/v0/offerings`, `sort=rank|price|ttft|tps`) with per-result `rank_explanation`; **enforceable estimates** (`POST /v0/estimate`) pinned to card revisions; the **advisor** (`POST /v0/recommend`).
|
|
15
31
|
- **Catalog importers** — OpenRouter, Hugging Face Inference Providers, models.dev, the Ollama library — so search is useful on day one, with imported listings labeled and claimable by their operators.
|
|
16
32
|
- **Where models run** (`/v0/locations`, `?format=csv` or `?format=geojson`): serving sites by country with their evidence (`claimed`, `documented`, `measured`, `attested`), a map point, and the models each serves (ONP-2 §3a, ONP-3 §5c). `near=lat,lon&within_km=` finds what runs close to a point. The GeoJSON opens directly in QGIS, ArcGIS, kepler.gl or any web map; the web app draws it on an interactive map. Built from card locations, the per-provider OpenRouter import (the headquarters, datacentres and region tags providers declare there) and curated seeds in [`src/data/`](src/data/) (Canada, Europe, and every registry provider worldwide). Search takes `region=`, `location_basis=` and `exclude_lineage=`.
|
|
@@ -18,7 +34,7 @@ What it does:
|
|
|
18
34
|
- **MCP surface** at `/mcp` (including `find_locations` and `find_residency`) and a signed **export feed** for federation.
|
|
19
35
|
- **Web app** at `/`: OpenRouter-style catalog with model and node pages, hardware and measured performance, playground, multi-model chat (compare / jury / pipeline / iterative), the advisor, the Node Builder, and the "Where models run" page.
|
|
20
36
|
|
|
21
|
-
Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_ALLOW_PRIVATE=1` (dev only: permit localhost nodes), `ONP_STAGE_C=0`, `ONP_REIMPORT=1`, `ONP_REIMPORT_SOURCES` (default `openrouter,huggingface`; also `models-dev`, `ollama`, and `openrouter-providers`, which makes one request per OpenRouter model, so give it a long `ONP_REIMPORT_MS`), `ONP_LOCATION_SEEDS=0` (skip the curated location seeds), `ONP_MAP_TILES` (basemap for the locations map: unset = OpenStreetMap, `off` = no map, or an XYZ URL template with `ONP_MAP_ATTRIBUTION`). The map loads Leaflet from cdnjs, pinned with subresource integrity, only on the "Where models run" page. Viewers' browsers then fetch tiles from the tile server. OpenStreetMap's tile policy asks for light use, so a busy registry should point `ONP_MAP_TILES` at its own or a commercial tile service.
|
|
37
|
+
Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_TRUSTED_JURISDICTIONS` (trusted pool operators, default `EU,CA`), `ONP_ALLOW_PRIVATE=1` (dev only: permit localhost nodes), `ONP_STAGE_C=0`, `ONP_REIMPORT=1`, `ONP_REIMPORT_SOURCES` (default `openrouter,huggingface`; also `models-dev`, `ollama`, and `openrouter-providers`, which makes one request per OpenRouter model, so give it a long `ONP_REIMPORT_MS`), `ONP_LOCATION_SEEDS=0` (skip the curated location seeds), `ONP_MAP_TILES` (basemap for the locations map: unset = OpenStreetMap, `off` = no map, or an XYZ URL template with `ONP_MAP_ATTRIBUTION`). The map loads Leaflet from cdnjs, pinned with subresource integrity, only on the "Where models run" page. Viewers' browsers then fetch tiles from the tile server. OpenStreetMap's tile policy asks for light use, so a busy registry should point `ONP_MAP_TILES` at its own or a commercial tile service.
|
|
22
38
|
|
|
23
39
|
Location seeds are dated JSON files (`locations-{seed}.json`): providers, their sites with `basis`, `source` and `checked`, and the models each site serves. A provider whose models are listed becomes a listing-only node `import.seed.{seed}.{id}`; one that publishes no model list is shown with a note. An entry with `nodes` describes existing registry nodes instead: its sites are shown under the first of them, with that node's models when `placement` is `all`. With `placement: "all"`, or `serves_from: "{seed}:{id}"` (the node's whole API runs at that entry's sites), search and recommend also use the live sites as the node's serving locations, marked `via: "seed"`, for offerings whose card declares none, except for listings reached through the Hugging Face router or OpenRouter. Providers carry `kind` and `residency`; `residency_of: "{seed}:{id}"` reuses another entry's commitments (the Canadian and European regions of a cloud share the cloud's). Corrections and new countries are welcome by pull request: cite the provider's own page for `documented`, anything else is `claimed`.
|
|
24
40
|
|
package/bin.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { startRegistry } from './src/server.js';
|
|
3
3
|
import { parseSite } from './src/location.js';
|
|
4
|
+
import { LIVENESS_INTERVAL_MS, BLIND_INTERVAL_MS } from './src/stagec.js';
|
|
5
|
+
import { trustedJurisdictionsFrom } from '@opennodes/core';
|
|
4
6
|
|
|
5
7
|
const dbPath = process.env.ONP_DB ?? ':memory:'; // sqlite path/:memory: or postgres:// URL
|
|
6
8
|
const persistent = dbPath !== ':memory:' && !dbPath.startsWith('postgres');
|
|
@@ -15,14 +17,16 @@ const registry = await startRegistry({
|
|
|
15
17
|
admitCooldownMs: Number(process.env.ONP_ADMIT_COOLDOWN_MS ?? 30 * 60_000), // Stage B per node
|
|
16
18
|
trustProxy: process.env.ONP_TRUST_PROXY === '1', // behind Caddy / a CDN
|
|
17
19
|
adminToken: process.env.ONP_ADMIN_TOKEN ?? null,
|
|
20
|
+
// Operator jurisdictions of the trusted pool (ONP-3 §5e): "EU,CA" unless set, e.g. "EU,CA,CH".
|
|
21
|
+
trustedJurisdictions: trustedJurisdictionsFrom(process.env),
|
|
18
22
|
locationSeeds: process.env.ONP_LOCATION_SEEDS !== '0', // curated "where models run" seeds
|
|
19
23
|
// Basemap for the locations map: unset = OpenStreetMap, "off" = no map, else an XYZ tile URL template.
|
|
20
24
|
...(process.env.ONP_MAP_TILES ? { mapTiles: process.env.ONP_MAP_TILES === 'off' ? null : {
|
|
21
25
|
tiles: process.env.ONP_MAP_TILES, attribution: process.env.ONP_MAP_ATTRIBUTION ?? '', max_zoom: 19,
|
|
22
26
|
} } : {}),
|
|
23
27
|
stageC: process.env.ONP_STAGE_C === '0' ? null : {
|
|
24
|
-
livenessIntervalMs: Number(process.env.ONP_LIVENESS_MS ??
|
|
25
|
-
blindIntervalMs: Number(process.env.ONP_BLIND_MS ??
|
|
28
|
+
livenessIntervalMs: Number(process.env.ONP_LIVENESS_MS ?? LIVENESS_INTERVAL_MS),
|
|
29
|
+
blindIntervalMs: Number(process.env.ONP_BLIND_MS ?? BLIND_INTERVAL_MS),
|
|
26
30
|
},
|
|
27
31
|
// Server-location checks: ONP_LOCATION=1, this registry's site, and optional remote probe agents
|
|
28
32
|
// ("FI Helsinki 60.17 24.93 https://host/onp-probe", comma-separated) sharing ONP_PROBE_AGENT_TOKEN.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opennodes/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.52",
|
|
4
4
|
"description": "OpenNodes (ONP) reference registry: node registration with proof-of-resource qualification (Stage A/B/C), transparent ranking, enforceable estimates, catalog importers (OpenRouter, Hugging Face, models.dev, Ollama), MCP surface, and the web app (catalog, chat, advisor, Node Builder)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@opennodes/core": "0.1.
|
|
46
|
+
"@opennodes/core": "0.1.23",
|
|
47
47
|
"pg": "^8.13.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/counts.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Request counts (ONP-3 §6.6): how often the registry returns each node to a client, per ISO week and
|
|
2
|
+
// surface. A response counts each node in it once. Only node ids, weeks and counts are kept: never the
|
|
3
|
+
// query, task, prompt or features, and nothing about the client.
|
|
4
|
+
|
|
5
|
+
/** Where a node can be returned: GET /v0/offerings, POST /v0/recommend, and MCP tools/call on /mcp. */
|
|
6
|
+
export const SURFACES = ['search', 'recommend', 'mcp'];
|
|
7
|
+
/** Row key for the number of responses on a surface, whichever nodes they held. */
|
|
8
|
+
const RESPONSES = '*';
|
|
9
|
+
const DAY_MS = 86_400_000;
|
|
10
|
+
|
|
11
|
+
/** ISO 8601 week of a date in UTC, e.g. "2026-W46". */
|
|
12
|
+
export function isoWeek(date = new Date()) {
|
|
13
|
+
const d = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
|
14
|
+
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7)); // the week's Thursday decides its year
|
|
15
|
+
const year = d.getUTCFullYear();
|
|
16
|
+
const week = Math.ceil(((d - Date.UTC(year, 0, 1)) / DAY_MS + 1) / 7);
|
|
17
|
+
return `${year}-W${String(week).padStart(2, '0')}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Monday (UTC) that starts an ISO week, as YYYY-MM-DD. */
|
|
21
|
+
export function weekStart(week) {
|
|
22
|
+
const [year, w] = week.split('-W').map(Number);
|
|
23
|
+
const jan4 = Date.UTC(year, 0, 4);
|
|
24
|
+
const monday1 = jan4 - ((new Date(jan4).getUTCDay() || 7) - 1) * DAY_MS;
|
|
25
|
+
return new Date(monday1 + (w - 1) * 7 * DAY_MS).toISOString().slice(0, 10);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The `n` ISO weeks ending with the one holding `date`, newest first. */
|
|
29
|
+
export function recentWeeks(n, date = new Date()) {
|
|
30
|
+
return Array.from({ length: n }, (_, i) => isoWeek(new Date(date.getTime() - i * 7 * DAY_MS)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Every node id anywhere in a response: `node_id` values (offerings, recommendations, scenario
|
|
35
|
+
* roles, sites) and `node_ids` lists (residency providers).
|
|
36
|
+
*/
|
|
37
|
+
export function nodeIdsIn(value, ids = new Set()) {
|
|
38
|
+
if (Array.isArray(value)) for (const v of value) nodeIdsIn(v, ids);
|
|
39
|
+
else if (value && typeof value === 'object') {
|
|
40
|
+
for (const [k, v] of Object.entries(value)) {
|
|
41
|
+
if (k === 'node_id' && typeof v === 'string') ids.add(v);
|
|
42
|
+
else if (k === 'node_ids' && Array.isArray(v)) for (const id of v) { if (typeof id === 'string') ids.add(id); }
|
|
43
|
+
else if (v && typeof v === 'object') nodeIdsIn(v, ids);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return ids;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const emptyWeek = (week) => ({ week, starts: weekStart(week), search: 0, recommend: 0, mcp: 0, total: 0 });
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Counts in memory, written to the store in batches (every `flushMs`, before every read, and on
|
|
53
|
+
* stop), so a search never waits on a database write.
|
|
54
|
+
*/
|
|
55
|
+
export function makeRequestCounter(store, { flushMs = 60_000, clock = () => new Date() } = {}) {
|
|
56
|
+
let pending = new Map(); // "node\tweek\tsurface" -> n
|
|
57
|
+
const add = (nodeId, week, surface, n) => {
|
|
58
|
+
const key = `${nodeId}\t${week}\t${surface}`;
|
|
59
|
+
pending.set(key, (pending.get(key) ?? 0) + n);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** One response on `surface` returned these nodes (duplicates count once). */
|
|
63
|
+
function count(surface, nodeIds) {
|
|
64
|
+
if (!SURFACES.includes(surface)) throw new Error(`unknown surface: ${surface}`);
|
|
65
|
+
const week = isoWeek(clock());
|
|
66
|
+
add(RESPONSES, week, surface, 1);
|
|
67
|
+
for (const id of new Set(nodeIds)) if (id && id !== RESPONSES) add(id, week, surface, 1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let chain = Promise.resolve();
|
|
71
|
+
function flush() {
|
|
72
|
+
chain = chain.then(async () => {
|
|
73
|
+
if (!pending.size) return;
|
|
74
|
+
const batch = pending;
|
|
75
|
+
pending = new Map();
|
|
76
|
+
const rows = [...batch].map(([key, n]) => {
|
|
77
|
+
const [node_id, week, surface] = key.split('\t');
|
|
78
|
+
return { node_id, week, surface, n };
|
|
79
|
+
});
|
|
80
|
+
try { await store.addRequestCounts(rows); }
|
|
81
|
+
catch { for (const r of rows) add(r.node_id, r.week, r.surface, r.n); } // retried on the next flush
|
|
82
|
+
});
|
|
83
|
+
return chain;
|
|
84
|
+
}
|
|
85
|
+
const timer = flushMs > 0 ? setInterval(() => { flush(); }, flushMs) : null;
|
|
86
|
+
timer?.unref?.();
|
|
87
|
+
|
|
88
|
+
/** Node detail: the last `weeks` ISO weeks for one node, newest first, zero weeks included. */
|
|
89
|
+
async function forNode(nodeId, weeks = 12) {
|
|
90
|
+
await flush();
|
|
91
|
+
const range = recentWeeks(weeks, clock());
|
|
92
|
+
const rows = await store.requestCounts({ nodeId, sinceWeek: range.at(-1) });
|
|
93
|
+
const byWeek = new Map(range.map((w) => [w, emptyWeek(w)]));
|
|
94
|
+
for (const r of rows) {
|
|
95
|
+
const w = byWeek.get(r.week);
|
|
96
|
+
if (!w || !SURFACES.includes(r.surface)) continue;
|
|
97
|
+
w[r.surface] += Number(r.n);
|
|
98
|
+
w.total += Number(r.n);
|
|
99
|
+
}
|
|
100
|
+
return [...byWeek.values()];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Stats endpoint: per week, the responses on each surface and the nodes they returned (most
|
|
105
|
+
* returned first, at most `limit`), optionally for one node only.
|
|
106
|
+
*/
|
|
107
|
+
async function stats({ weeks = 4, nodeId = null, limit = 50 } = {}) {
|
|
108
|
+
await flush();
|
|
109
|
+
const range = recentWeeks(weeks, clock());
|
|
110
|
+
const rows = await store.requestCounts({ sinceWeek: range.at(-1) });
|
|
111
|
+
const out = new Map(range.map((w) => [w, { week: w, starts: weekStart(w), responses: { search: 0, recommend: 0, mcp: 0 }, nodes: new Map() }]));
|
|
112
|
+
for (const r of rows) {
|
|
113
|
+
const w = out.get(r.week);
|
|
114
|
+
if (!w || !SURFACES.includes(r.surface)) continue;
|
|
115
|
+
const n = Number(r.n);
|
|
116
|
+
if (r.node_id === RESPONSES) { w.responses[r.surface] += n; continue; }
|
|
117
|
+
if (nodeId && r.node_id !== nodeId) continue;
|
|
118
|
+
const node = w.nodes.get(r.node_id) ?? { node_id: r.node_id, search: 0, recommend: 0, mcp: 0, total: 0 };
|
|
119
|
+
node[r.surface] += n;
|
|
120
|
+
node.total += n;
|
|
121
|
+
w.nodes.set(r.node_id, node);
|
|
122
|
+
}
|
|
123
|
+
return [...out.values()].map((w) => {
|
|
124
|
+
const nodes = [...w.nodes.values()].sort((a, b) => b.total - a.total || a.node_id.localeCompare(b.node_id));
|
|
125
|
+
return { week: w.week, starts: w.starts, responses: w.responses, nodes_returned: nodes.length, nodes: nodes.slice(0, limit) };
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function stop() {
|
|
130
|
+
if (timer) clearInterval(timer);
|
|
131
|
+
await flush();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return { count, flush, forNode, stats, stop };
|
|
135
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"seed": "ua",
|
|
3
|
+
"title": "Ukrainian data centres and GPU clouds",
|
|
4
|
+
"checked": "2026-11-10",
|
|
5
|
+
"note": "Curated by the OpenNodes project from public sources (ONP-2 §3a). Site-only entries: none of these operators serves models through a public API, so none becomes a node; providers that run models here can name them as facility_operator. During the war each site shows no more than the operator publishes itself (a city, or only the country), never an address. Sites outside Ukraine are not listed here. documented = the operator's own page; claimed = news or third-party pages. Corrections, or removal on request, by pull request or to operators@opennodes.io.",
|
|
6
|
+
"providers": [
|
|
7
|
+
{
|
|
8
|
+
"id": "denovo",
|
|
9
|
+
"name": "De Novo",
|
|
10
|
+
"kind": "cloud",
|
|
11
|
+
"residency": [
|
|
12
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "Colocation and GPU cloud; no statement on model data residency.", "source": "https://denovo.ua/en/data-center/colocation", "checked": "2026-11-10" }
|
|
13
|
+
],
|
|
14
|
+
"operator": { "name": "De Novo", "country": "UA", "url": "https://denovo.ua/en/" },
|
|
15
|
+
"sites": [
|
|
16
|
+
{ "id": "kyiv", "region": "UA-30", "site": "Kyiv", "status": "live", "basis": "documented", "source": "https://denovo.ua/en/data-center/colocation", "checked": "2026-11-10", "note": "Colocation (up to 15 kW a rack in the shielded module) and public cloud", "geo": { "lat": 50.4501, "lon": 30.5234, "precision": "city" } },
|
|
17
|
+
{ "id": "lviv", "region": "UA-46", "site": "Lviv", "status": "live", "basis": "documented", "source": "https://denovo.ua/en/data-center/colocation", "checked": "2026-11-10", "note": "Public cloud", "geo": { "lat": 49.8397, "lon": 24.0297, "precision": "city" } }
|
|
18
|
+
],
|
|
19
|
+
"models": [],
|
|
20
|
+
"models_note": "Colocation and GPU cloud (LLM Cloud with open models preinstalled for tenants); no public model API."
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "gigacloud",
|
|
24
|
+
"name": "GigaCloud",
|
|
25
|
+
"kind": "cloud",
|
|
26
|
+
"residency": [
|
|
27
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "GPU cloud; no statement on model data residency.", "source": "https://gigacloud.ua/en/", "checked": "2026-11-10" }
|
|
28
|
+
],
|
|
29
|
+
"operator": { "name": "GigaCloud", "country": "UA", "url": "https://gigacloud.ua/en/" },
|
|
30
|
+
"sites": [
|
|
31
|
+
{ "id": "ua", "region": "UA", "site": "Three data centres in Ukraine (cities not published)", "status": "live", "basis": "documented", "source": "https://gigacloud.ua/en/", "checked": "2026-11-10", "note": "Two more data centres in Poland" }
|
|
32
|
+
],
|
|
33
|
+
"models": [],
|
|
34
|
+
"models_note": "GPU cloud (H100, L40S); no public model API."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "ucloud",
|
|
38
|
+
"name": "Ucloud",
|
|
39
|
+
"kind": "cloud",
|
|
40
|
+
"residency": [
|
|
41
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "GPU cloud and colocation; no statement on model data residency.", "source": "https://ucloud.ua/", "checked": "2026-11-10" }
|
|
42
|
+
],
|
|
43
|
+
"operator": { "name": "Ucloud", "country": "UA", "url": "https://ucloud.ua/" },
|
|
44
|
+
"sites": [
|
|
45
|
+
{ "id": "ua", "region": "UA", "site": "Data centres in Ukraine (cities not published)", "status": "live", "basis": "documented", "source": "https://ucloud.ua/", "checked": "2026-11-10", "note": "Also in Poland (Warsaw) and Germany; colocation is offered at BE MOBILE Data Park" }
|
|
46
|
+
],
|
|
47
|
+
"models": [],
|
|
48
|
+
"models_note": "GPU cloud and colocation; no public model API."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "bemobile",
|
|
52
|
+
"name": "BE MOBILE Data Park",
|
|
53
|
+
"kind": "cloud",
|
|
54
|
+
"residency": [
|
|
55
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "Colocation provider; no statement on model data residency.", "source": "https://ucloud.ua/en/service/colocation/", "checked": "2026-11-10" }
|
|
56
|
+
],
|
|
57
|
+
"operator": { "name": "BE MOBILE", "country": "UA", "url": "https://bemobile.ua/" },
|
|
58
|
+
"sites": [
|
|
59
|
+
{ "id": "ua", "region": "UA", "site": "BE MOBILE Data Park", "status": "live", "basis": "claimed", "source": "https://ucloud.ua/en/service/colocation/", "checked": "2026-11-10", "note": "TIA-942 Tier III design and ISO 27001, per Ucloud" }
|
|
60
|
+
],
|
|
61
|
+
"models": [],
|
|
62
|
+
"models_note": "Colocation only; no model service."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": "colocall",
|
|
66
|
+
"name": "Colocall",
|
|
67
|
+
"kind": "cloud",
|
|
68
|
+
"residency": [
|
|
69
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "Colocation provider; no statement on model data residency.", "source": "https://www.colocall.net/en/colocation/colocation.html", "checked": "2026-11-10" }
|
|
70
|
+
],
|
|
71
|
+
"operator": { "name": "Colocall", "country": "UA", "url": "https://www.colocall.net/en/" },
|
|
72
|
+
"sites": [
|
|
73
|
+
{ "id": "ua", "region": "UA", "site": "Colocall data centre (city not published)", "status": "live", "basis": "claimed", "source": "https://www.colocall.net/en/colocation/colocation.html", "checked": "2026-11-10", "note": "Colocation and cloud" }
|
|
74
|
+
],
|
|
75
|
+
"models": [],
|
|
76
|
+
"models_note": "Colocation only; no model service."
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"id": "kyivstar-cloud",
|
|
80
|
+
"name": "Kyivstar Cloud",
|
|
81
|
+
"kind": "cloud",
|
|
82
|
+
"residency": [
|
|
83
|
+
{ "commitment": "unstated", "scope": [], "availability": "default", "statement": "Business cloud described as hosted in Ukraine; no statement on model data residency.", "source": "https://forbes.ua/news/kiivstar-zapustiv-vlasniy-khmarniy-servis-dlya-biznesu-24062025-30782", "checked": "2026-11-10" }
|
|
84
|
+
],
|
|
85
|
+
"operator": { "name": "Kyivstar", "country": "UA", "url": "https://kyivstar.ua/" },
|
|
86
|
+
"sites": [
|
|
87
|
+
{ "id": "ua", "region": "UA", "site": "Kyivstar Cloud (facilities not named)", "status": "live", "basis": "claimed", "source": "https://forbes.ua/news/kiivstar-zapustiv-vlasniy-khmarniy-servis-dlya-biznesu-24062025-30782", "checked": "2026-11-10", "note": "Business cloud launched June 2025 on HPE servers, hosted in Ukraine" }
|
|
88
|
+
],
|
|
89
|
+
"models": [],
|
|
90
|
+
"models_note": "Business cloud; no model service."
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
package/src/export.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// replicate without re-crawling. Each line = { payload, jws } signed by this registry,
|
|
3
3
|
// so provenance survives mirroring.
|
|
4
4
|
import { signJson } from '@opennodes/core';
|
|
5
|
+
import { verificationOf } from './probes.js';
|
|
5
6
|
|
|
6
7
|
export function exportRoutes(store, registryKeys) {
|
|
7
8
|
return [
|
|
@@ -11,11 +12,15 @@ export function exportRoutes(store, registryKeys) {
|
|
|
11
12
|
for (const node of await store.allNodes()) {
|
|
12
13
|
if (since && node.updated_at <= since) continue;
|
|
13
14
|
const card = await store.latestCard(node.id);
|
|
15
|
+
const observations = await store.observationsForNode(node.id);
|
|
16
|
+
const nodeObs = Object.fromEntries(observations.filter((o) => o.offering_id === '_node').map((o) => [o.key, o.value]));
|
|
14
17
|
const payload = {
|
|
15
18
|
type: 'node',
|
|
16
19
|
node: { id: node.id, origin: node.origin, state: node.state, source: node.source, updated_at: node.updated_at },
|
|
17
20
|
card,
|
|
18
|
-
observations
|
|
21
|
+
observations,
|
|
22
|
+
// The node's state covers only the offerings its tests could call (ONP-3 §4a).
|
|
23
|
+
verification: verificationOf(card, nodeObs),
|
|
19
24
|
};
|
|
20
25
|
const jws = signJson(payload, registryKeys.privateKey, 'registry-1');
|
|
21
26
|
res.write(JSON.stringify({ payload, jws }) + '\n');
|
package/src/locations.js
CHANGED
|
@@ -7,7 +7,7 @@ import { readFileSync, readdirSync } from 'node:fs';
|
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
8
|
import {
|
|
9
9
|
sendJson, problem, regionWithin, countryOf, basisRank, pointFor, distanceKm, parsePoint, precisionRank,
|
|
10
|
-
residencyAt, residencyMeets, commitmentRank, scopeCovers, RESIDENCY_COMMITMENTS,
|
|
10
|
+
residencyAt, residencyMeets, commitmentRank, scopeCovers, RESIDENCY_COMMITMENTS, lineageAllowed,
|
|
11
11
|
} from '@opennodes/core';
|
|
12
12
|
import { siteLocation } from './importers.js';
|
|
13
13
|
|
|
@@ -237,7 +237,7 @@ export async function collectSites(store, seeds = []) {
|
|
|
237
237
|
/**
|
|
238
238
|
* Filter and summarise. Query: country | region (containment), basis (minimum evidence),
|
|
239
239
|
* status (live | planned), model (substring of name or artifact), exclude_lineage (CSV of
|
|
240
|
-
* countries; drops those models, keeps undeclared lineage), near=lat,lon (adds distance_km,
|
|
240
|
+
* countries; drops those models, keeps undeclared lineage unless lineage=declared), near=lat,lon (adds distance_km,
|
|
241
241
|
* nearest first) with within_km (radius; country-level points never match), format=csv|geojson.
|
|
242
242
|
*/
|
|
243
243
|
export async function buildLocations(store, seeds, query) {
|
|
@@ -255,12 +255,14 @@ export async function buildLocations(store, seeds, query) {
|
|
|
255
255
|
if (!['processing', 'storage'].includes(q('residency'))) throw Object.assign(new Error('residency must be processing or storage'), { status: 400 });
|
|
256
256
|
sites = sites.filter((s) => residencyMeets(s.residency, q('residency'), q('availability') ?? 'enterprise'));
|
|
257
257
|
}
|
|
258
|
-
const banned = q('exclude_lineage')?.
|
|
258
|
+
const banned = q('exclude_lineage')?.split(',').filter(Boolean) ?? [];
|
|
259
|
+
if (q('lineage') && !['declared', 'any'].includes(q('lineage'))) throw Object.assign(new Error('lineage must be declared or any'), { status: 400 });
|
|
260
|
+
const declared = q('lineage') === 'declared'; // also drop models that declare no lineage
|
|
259
261
|
const needle = q('model')?.toLowerCase();
|
|
260
|
-
if (banned.length || needle) {
|
|
262
|
+
if (banned.length || declared || needle) {
|
|
261
263
|
sites = sites.map((s) => ({
|
|
262
264
|
...s,
|
|
263
|
-
models: s.models.filter((m) =>
|
|
265
|
+
models: s.models.filter((m) => lineageAllowed({ model: m }, { exclude: banned, declared })
|
|
264
266
|
&& (!needle || `${m.name} ${m.artifact}`.toLowerCase().includes(needle))),
|
|
265
267
|
}));
|
|
266
268
|
if (needle) sites = sites.filter((s) => s.models.length);
|
package/src/mcp.js
CHANGED
|
@@ -6,6 +6,8 @@ import { readFileSync } from 'node:fs';
|
|
|
6
6
|
import { readJson, sendJson, problem, estimateBounds, round6, extractFeatures, recommend, MCP_TOOLS, MCP_INSTRUCTIONS, summarizeNode } from '@opennodes/core';
|
|
7
7
|
import { searchOfferingsPaged, searchOfferings, collectOfferings, pricePublished } from './search.js';
|
|
8
8
|
import { buildLocations, buildResidency } from './locations.js';
|
|
9
|
+
import { nodeIdsIn } from './counts.js';
|
|
10
|
+
import { verificationOf } from './probes.js';
|
|
9
11
|
|
|
10
12
|
/** Tool arguments -> the query string the REST routes take (null/undefined dropped). */
|
|
11
13
|
const toQuery = (args = {}) => {
|
|
@@ -38,13 +40,14 @@ const TOOLS = MCP_TOOLS.map((tool) => {
|
|
|
38
40
|
};
|
|
39
41
|
});
|
|
40
42
|
|
|
41
|
-
async function runTool(store, seeds, name, args = {}) {
|
|
43
|
+
async function runTool(store, seeds, name, args = {}, trusted = undefined) {
|
|
42
44
|
switch (name) {
|
|
43
45
|
case 'recommend': {
|
|
44
46
|
const features = args.features ?? (args.task != null
|
|
45
47
|
? extractFeatures(String(args.task), { est_output_tokens: args.est_output_tokens ?? null }) : null);
|
|
46
48
|
if (!features) throw new Error('recommend needs "task" or "features"');
|
|
47
|
-
|
|
49
|
+
// policy.sensitive applies this registry's trusted view (the caller cannot pass its own)
|
|
50
|
+
return recommend((await collectOfferings(store)).filter((o) => o.invocable), features, { ...(args.policy ?? {}), ...(trusted ? { trusted } : {}) });
|
|
48
51
|
}
|
|
49
52
|
case 'search_offerings':
|
|
50
53
|
return searchOfferingsPaged(store, toQuery(args));
|
|
@@ -61,11 +64,13 @@ async function runTool(store, seeds, name, args = {}) {
|
|
|
61
64
|
case 'get_node': {
|
|
62
65
|
const node = await store.getNode(args.node_id);
|
|
63
66
|
if (!node) throw new Error(`unknown node: ${args.node_id} (node ids come from search_offerings or recommend results)`);
|
|
67
|
+
const card = await store.latestCard(node.id);
|
|
64
68
|
return summarizeNode({
|
|
65
69
|
...node,
|
|
66
|
-
card
|
|
70
|
+
card,
|
|
67
71
|
probes: (await store.probesFor(node.id)).slice(0, 20),
|
|
68
72
|
history: await store.transitionsFor(node.id),
|
|
73
|
+
verification: verificationOf(card, await store.getObservations(node.id, '_node')),
|
|
69
74
|
}, args.offering_limit ?? 25);
|
|
70
75
|
}
|
|
71
76
|
case 'estimate': {
|
|
@@ -102,7 +107,14 @@ async function runTool(store, seeds, name, args = {}) {
|
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
|
|
110
|
+
/** The nodes a tool result hands back to the client (for request counts). */
|
|
111
|
+
function nodesReturned(name, result) {
|
|
112
|
+
if (name === 'get_node') return [result.id];
|
|
113
|
+
if (name === 'estimate') return result.steps.map((s) => s.offering.split('/')[0]);
|
|
114
|
+
return nodeIdsIn(result);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function handleRpc(store, seeds, msg, onResult, trusted) {
|
|
106
118
|
const { id, method, params } = msg;
|
|
107
119
|
const reply = (result) => ({ jsonrpc: '2.0', id, result });
|
|
108
120
|
const rpcError = (code, message) => ({ jsonrpc: '2.0', id, error: { code, message } });
|
|
@@ -121,7 +133,8 @@ async function handleRpc(store, seeds, msg) {
|
|
|
121
133
|
return reply({ tools: TOOLS });
|
|
122
134
|
case 'tools/call':
|
|
123
135
|
try {
|
|
124
|
-
const result = await runTool(store, seeds, params?.name, params?.arguments);
|
|
136
|
+
const result = await runTool(store, seeds, params?.name, params?.arguments, trusted);
|
|
137
|
+
onResult?.(nodesReturned(params.name, result));
|
|
125
138
|
return reply({
|
|
126
139
|
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
127
140
|
structuredContent: result,
|
|
@@ -140,13 +153,17 @@ async function handleRpc(store, seeds, msg) {
|
|
|
140
153
|
}
|
|
141
154
|
}
|
|
142
155
|
|
|
143
|
-
/**
|
|
144
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Routes to mount into the registry app. `seeds` = the curated location seeds (find_locations).
|
|
158
|
+
* `onResult(nodeIds)` hears which nodes each successful tool call returned (request counts).
|
|
159
|
+
* `trusted` is the registry's trusted view, used by recommend's `policy.sensitive`.
|
|
160
|
+
*/
|
|
161
|
+
export function mcpRoutes(store, seeds = [], { onResult = null, trusted = undefined } = {}) {
|
|
145
162
|
return [
|
|
146
163
|
['POST', '/mcp', async (req, res) => {
|
|
147
164
|
const body = await readJson(req, 5_000_000);
|
|
148
165
|
const messages = Array.isArray(body) ? body : [body];
|
|
149
|
-
const replies = (await Promise.all(messages.map((m) => handleRpc(store, seeds, m)))).filter(Boolean);
|
|
166
|
+
const replies = (await Promise.all(messages.map((m) => handleRpc(store, seeds, m, onResult, trusted)))).filter(Boolean);
|
|
150
167
|
if (replies.length === 0) { res.writeHead(202); res.end(); return; }
|
|
151
168
|
sendJson(res, 200, Array.isArray(body) ? replies : replies[0]);
|
|
152
169
|
}],
|
package/src/probes.js
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
// All outbound traffic goes through the SSRF-guarded fetcher (safefetch.js).
|
|
3
3
|
import { fetchJsonCapped } from './safefetch.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Binding profiles the admission tests can call (ONP-3 §4a). Verification covers only these: an
|
|
7
|
+
* offering with another profile is never invoked, so a node's tier says nothing about it.
|
|
8
|
+
*/
|
|
9
|
+
export const TESTED_PROFILES = ['onp.openai.chat/v1'];
|
|
10
|
+
/** Whether the registry's tests can call this offering. */
|
|
11
|
+
export const testable = (offering) => TESTED_PROFILES.includes(offering?.binding?.profile);
|
|
12
|
+
/** Offering ids of a card that the tests cannot call. */
|
|
13
|
+
export const untestedOfferings = (card) => (card?.offerings ?? []).filter((o) => !testable(o)).map((o) => o.offering_id);
|
|
14
|
+
export const NO_TESTED_OFFERINGS = `no offerings with a tested profile (${TESTED_PROFILES.join(', ')})`;
|
|
15
|
+
/** The `verification` block of node detail and the export feed; nodeObs = the node's `_node` observations. */
|
|
16
|
+
export const verificationOf = (card, nodeObs = {}) => ({
|
|
17
|
+
tested_profiles: TESTED_PROFILES,
|
|
18
|
+
untested_offerings: untestedOfferings(card),
|
|
19
|
+
blind_skipped: nodeObs.blind_skipped ?? null,
|
|
20
|
+
});
|
|
21
|
+
|
|
5
22
|
/**
|
|
6
23
|
* Card rules a schema cannot express (ONP-2 §5): every offering declares a data_policy
|
|
7
24
|
* (required from `community` up), and offers only payment schemes the node declares.
|
|
@@ -56,9 +73,14 @@ export async function runStageA(store, nodeId, card, { safeFetch } = {}) {
|
|
|
56
73
|
await record(null, 'models-agreement', false, String(err.message ?? err));
|
|
57
74
|
}
|
|
58
75
|
|
|
59
|
-
// 3. Blind invocation per
|
|
76
|
+
// 3. Blind invocation per offering the tests can call. A node with none gives no functional
|
|
77
|
+
// evidence, so it fails Stage A and stays unverified (ONP-3 §4a item 2).
|
|
78
|
+
if (!card.offerings.some(testable)) {
|
|
79
|
+
const profiles = [...new Set(card.offerings.map((o) => o.binding?.profile))].join(', ');
|
|
80
|
+
await record(null, 'tested-offerings', false, `${NO_TESTED_OFFERINGS}; the card offers ${profiles || 'nothing'}`);
|
|
81
|
+
}
|
|
60
82
|
for (const offering of card.offerings) {
|
|
61
|
-
if (offering
|
|
83
|
+
if (!testable(offering)) continue;
|
|
62
84
|
try {
|
|
63
85
|
const t0 = performance.now();
|
|
64
86
|
// Generous timeout: CPU-backed nodes legitimately take tens of seconds per completion.
|
package/src/search.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
residencyWithin, residencyCodes, servingLocations, basisRank,
|
|
4
4
|
inJurisdiction, localSizes, pullsOf, specialtyOf, isEmbedder,
|
|
5
|
+
trustedView, poolOf, inTrustedPool, lineageAllowed, meetsDataPolicy, RETENTION_LEVELS,
|
|
5
6
|
} from '@opennodes/core';
|
|
7
|
+
import { testable } from './probes.js';
|
|
6
8
|
|
|
7
9
|
/** BCP 47 prefix match (ONP-3 §5): `fr` matches `fr` and `fr-CA`; `fr-CA` matches only itself. */
|
|
8
10
|
export const langMatches = (tag, wanted) => {
|
|
@@ -33,6 +35,16 @@ export function setSeedPlacements(store, map) {
|
|
|
33
35
|
markCatalogStale(store);
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
// The registry's trusted view (core trustedView: jurisdictions from ONP_TRUSTED_JURISDICTIONS).
|
|
39
|
+
const trustedViews = new WeakMap(); // store -> view
|
|
40
|
+
|
|
41
|
+
/** Use this trusted view for `pool` labels and `trust=trusted` from now on (the server sets it at start). */
|
|
42
|
+
export function setTrustedView(store, view) {
|
|
43
|
+
trustedViews.set(store, view);
|
|
44
|
+
markCatalogStale(store);
|
|
45
|
+
}
|
|
46
|
+
export const trustedViewOf = (store) => trustedViews.get(store) ?? trustedView();
|
|
47
|
+
|
|
36
48
|
/** Mark the cached catalog stale: the next read rebuilds it. */
|
|
37
49
|
export function markCatalogStale(store) {
|
|
38
50
|
const entry = catalogs.get(store);
|
|
@@ -41,7 +53,7 @@ export function markCatalogStale(store) {
|
|
|
41
53
|
|
|
42
54
|
/** Wrap the store's write methods so any change to nodes, cards, probes or observations marks the catalog stale. */
|
|
43
55
|
export function watchStoreWrites(store) {
|
|
44
|
-
for (const name of ['upsertNode', 'setState', 'saveRevision', 'recordProbe', 'addFingerprints', 'setObservation']) {
|
|
56
|
+
for (const name of ['upsertNode', 'setState', 'setNodeFlag', 'saveRevision', 'recordProbe', 'addFingerprints', 'setObservation']) {
|
|
45
57
|
const write = store[name];
|
|
46
58
|
if (typeof write !== 'function' || write.__marksCatalogStale) continue;
|
|
47
59
|
const wrapped = async function (...args) {
|
|
@@ -69,6 +81,7 @@ export async function collectOfferings(store) {
|
|
|
69
81
|
/** Flatten indexed nodes into searchable offering summaries. */
|
|
70
82
|
async function buildOfferings(store) {
|
|
71
83
|
const out = [];
|
|
84
|
+
const view = trustedViewOf(store);
|
|
72
85
|
for (const node of await store.allNodes()) {
|
|
73
86
|
if (['delisted', 'suspended', 'submitted', 'challenged', 'disputed', 'claimed'].includes(node.state)) continue;
|
|
74
87
|
const card = await store.latestCard(node.id);
|
|
@@ -101,12 +114,17 @@ async function buildOfferings(store) {
|
|
|
101
114
|
serving.context_window = obs.context_cap;
|
|
102
115
|
serving.context_capped_from = offering.serving.context_window;
|
|
103
116
|
}
|
|
117
|
+
// Verification covers only profiles the tests can call (ONP-3 §4a): another offering does
|
|
118
|
+
// not inherit the node's tier. Imported listings are never tested.
|
|
119
|
+
const covered = testable(offering);
|
|
104
120
|
out.push({
|
|
105
121
|
node_id: node.id,
|
|
106
122
|
offering_id: offering.offering_id,
|
|
107
|
-
tier,
|
|
123
|
+
tier: covered ? tier : 'unverified',
|
|
124
|
+
tested: covered && node.source !== 'import',
|
|
108
125
|
source: node.source ?? 'registration',
|
|
109
126
|
institutional: Boolean(node.institutional),
|
|
127
|
+
founding: Boolean(node.founding), // admin-set label (ONP-3 §4b), never a rank input
|
|
110
128
|
card_revision: card.revision,
|
|
111
129
|
modality: offering.modality,
|
|
112
130
|
modalities: offering.modalities ?? null,
|
|
@@ -146,11 +164,19 @@ async function buildOfferings(store) {
|
|
|
146
164
|
// false for listing-only imports (no known API endpoint): shown, never called
|
|
147
165
|
invocable: Boolean(card.endpoints?.openai),
|
|
148
166
|
});
|
|
167
|
+
// Trusted or open pool (ONP-3 §5e), under this registry's trusted view.
|
|
168
|
+
out.at(-1).pool = poolOf(out.at(-1), view);
|
|
149
169
|
}
|
|
150
170
|
}
|
|
151
171
|
return out;
|
|
152
172
|
}
|
|
153
173
|
|
|
174
|
+
const bad = (message) => Object.assign(new Error(message), { status: 400 });
|
|
175
|
+
const oneOf = (name, value, allowed) => {
|
|
176
|
+
if (value != null && !allowed.includes(value)) throw bad(`${name} must be ${allowed.join(' or ')}, not ${JSON.stringify(value)}`);
|
|
177
|
+
return value;
|
|
178
|
+
};
|
|
179
|
+
|
|
154
180
|
/** Whether an offering publishes a per-token price (imports with no known price leave it out). */
|
|
155
181
|
export const pricePublished = (pricing) => pricing?.input_per_mtok != null || pricing?.output_per_mtok != null;
|
|
156
182
|
|
|
@@ -180,10 +206,21 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
180
206
|
const min = basisRank(q('location_basis'));
|
|
181
207
|
items = items.filter((o) => o.locations.length && o.locations.every((l) => basisRank(l.basis) >= min));
|
|
182
208
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
209
|
+
// Origin policy on declared lineage: offerings that declare none are kept (unknown), unless
|
|
210
|
+
// lineage=declared asks for a declared lineage.
|
|
211
|
+
const declared = oneOf('lineage', q('lineage'), ['declared', 'any']) === 'declared';
|
|
212
|
+
if (q('exclude_lineage') || declared) {
|
|
213
|
+
const exclude = (q('exclude_lineage') ?? '').split(',').filter(Boolean);
|
|
214
|
+
items = items.filter((o) => lineageAllowed(o, { exclude, declared }));
|
|
215
|
+
}
|
|
216
|
+
// Data policy (ONP-2 §5): at most this retention, no training on inputs. No data_policy fails.
|
|
217
|
+
const retention = oneOf('retention', q('retention'), RETENTION_LEVELS);
|
|
218
|
+
const noTraining = oneOf('no_training', q('no_training'), ['true', 'false']) === 'true';
|
|
219
|
+
if (retention || noTraining) items = items.filter((o) => meetsDataPolicy(o, { retention, no_training: noTraining }));
|
|
220
|
+
// The trusted pool (ONP-3 §5e): every condition of the registry's trusted view at once.
|
|
221
|
+
if (oneOf('trust', q('trust'), ['trusted', 'open']) === 'trusted') {
|
|
222
|
+
const view = trustedViewOf(store);
|
|
223
|
+
items = items.filter((o) => inTrustedPool(o, view));
|
|
187
224
|
}
|
|
188
225
|
if (q('tier')) {
|
|
189
226
|
const order = ['unverified', 'community', 'verified', 'attested'];
|