@opennodes/registry 0.1.52 → 0.1.54
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 +7 -6
- package/bin.js +10 -1
- package/package.json +2 -2
- package/src/corpus.js +166 -0
- package/src/data/proprietary-vendors.json +12 -0
- package/src/importers.js +3 -1
- package/src/location.js +168 -18
- package/src/locations.js +8 -4
- package/src/mcp.js +7 -3
- package/src/probes.js +27 -7
- package/src/schedule.js +178 -0
- package/src/search.js +52 -11
- package/src/server.js +309 -58
- package/src/stageb.js +155 -55
- package/src/stagec.js +222 -27
- package/src/store-pg.js +57 -0
- package/src/store.js +62 -0
- package/src/vendors.js +92 -0
- package/src/web/index.html +63 -29
package/src/probes.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
// Stage A admission probes (DS-ADM-01): card consistency, health, blind invocation, /models agreement.
|
|
2
2
|
// All outbound traffic goes through the SSRF-guarded fetcher (safefetch.js).
|
|
3
3
|
import { fetchJsonCapped } from './safefetch.js';
|
|
4
|
+
import { loadCorpus } from './corpus.js';
|
|
5
|
+
import { artifactClaimProblems, vendorTable } from './vendors.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Stage A checks whose failure is a property of the card, not of the moment: a listed node that
|
|
9
|
+
* fails one of these on a scheduled re-run loses its tier at once. `models-agreement` counts only
|
|
10
|
+
* when /models answered 200 without the card's models (a timeout is an outage, not a card fault).
|
|
11
|
+
* Health and blind-invocation failures are left to Stage C (liveness suspension, blind-failure
|
|
12
|
+
* demotion), so an outage of a few minutes does not cost a node its tier. Each Stage A result
|
|
13
|
+
* carries `structural: true` when it is such a failure.
|
|
14
|
+
*/
|
|
15
|
+
export const STRUCTURAL_KINDS = ['card-consistency', 'artifact-namespace', 'models-agreement', 'tested-offerings'];
|
|
16
|
+
const DEV_CORPUS = loadCorpus(null);
|
|
4
17
|
|
|
5
18
|
/**
|
|
6
19
|
* Binding profiles the admission tests can call (ONP-3 §4a). Verification covers only these: an
|
|
@@ -35,19 +48,25 @@ export function cardConsistency(card) {
|
|
|
35
48
|
return problems;
|
|
36
49
|
}
|
|
37
50
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Run Stage A against a card. Records results via store; returns { ok, results }.
|
|
53
|
+
* `corpus`: the probe corpus (corpus.js); `vendors`: the vendor-namespace table (vendors.js).
|
|
54
|
+
*/
|
|
55
|
+
export async function runStageA(store, nodeId, card, { safeFetch, corpus = DEV_CORPUS, vendors = vendorTable() } = {}) {
|
|
40
56
|
if (!safeFetch) safeFetch = (url, opts = {}, t = 10_000) => fetch(url, { ...opts, signal: AbortSignal.timeout(t) });
|
|
41
57
|
const fetchJson = (url, opts, timeoutMs = 10_000) => fetchJsonCapped(safeFetch, url, opts, timeoutMs);
|
|
42
58
|
const results = [];
|
|
43
|
-
const record = async (offeringId, kind, ok, detail, measured) => {
|
|
59
|
+
const record = async (offeringId, kind, ok, detail, measured, structural = STRUCTURAL_KINDS.includes(kind)) => {
|
|
44
60
|
await store.recordProbe(nodeId, offeringId, 'A', kind, ok, detail, measured);
|
|
45
|
-
results.push({ offeringId, kind, ok, detail });
|
|
61
|
+
results.push({ offeringId, kind, ok, detail, ...(ok ? {} : { structural }) });
|
|
46
62
|
};
|
|
47
63
|
|
|
48
64
|
// 0. Card consistency (no network)
|
|
49
65
|
const problems = cardConsistency(card);
|
|
50
66
|
await record(null, 'card-consistency', problems.length === 0, problems.length ? problems.join('; ') : null);
|
|
67
|
+
// 0b. Vendor-namespace rule (ONP-3 §6.3): a proprietary artefact only from the vendor's namespace.
|
|
68
|
+
const claims = artifactClaimProblems(card, vendors);
|
|
69
|
+
await record(null, 'artifact-namespace', claims.length === 0, claims.length ? claims.join('; ') : null);
|
|
51
70
|
|
|
52
71
|
// 1. Health endpoint
|
|
53
72
|
try {
|
|
@@ -68,9 +87,10 @@ export async function runStageA(store, nodeId, card, { safeFetch } = {}) {
|
|
|
68
87
|
const cardIds = card.offerings.filter((o) => o.binding.profile.startsWith('onp.openai.')).map((o) => o.binding.model_id);
|
|
69
88
|
const missing = cardIds.filter((id) => !modelIds.has(id));
|
|
70
89
|
await record(null, 'models-agreement', status === 200 && missing.length === 0,
|
|
71
|
-
missing.length ? `card offerings absent from /models: ${missing.join(', ')}` : null
|
|
90
|
+
status !== 200 ? `status ${status}` : missing.length ? `card offerings absent from /models: ${missing.join(', ')}` : null,
|
|
91
|
+
null, status === 200); // a card fault only if /models answered
|
|
72
92
|
} catch (err) {
|
|
73
|
-
await record(null, 'models-agreement', false, String(err.message ?? err));
|
|
93
|
+
await record(null, 'models-agreement', false, String(err.message ?? err), null, false);
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
// 3. Blind invocation per offering the tests can call. A node with none gives no functional
|
|
@@ -93,7 +113,7 @@ export async function runStageA(store, nodeId, card, { safeFetch } = {}) {
|
|
|
93
113
|
},
|
|
94
114
|
body: JSON.stringify({
|
|
95
115
|
model: offering.binding.model_id,
|
|
96
|
-
messages: [{ role: 'user', content:
|
|
116
|
+
messages: [{ role: 'user', content: corpus.chatPrompt() }],
|
|
97
117
|
max_tokens: 32,
|
|
98
118
|
}),
|
|
99
119
|
}, 90_000);
|
package/src/schedule.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// Re-verification on the registry's own timetable (ONP-3 §4a):
|
|
2
|
+
// - Stage A at least every 6 h and on every new card revision, for registered nodes from `indexed` up;
|
|
3
|
+
// - Stage B for a node that reaches `community`, at a random time within a day; again soon after any
|
|
4
|
+
// change to a tested offering's model, serving or hardware block, or after a confirmed mismatch in
|
|
5
|
+
// a blind identity check (stagec.js); and quarterly otherwise.
|
|
6
|
+
// The operator does not choose when Stage B runs, and no API says when it will: the next run time
|
|
7
|
+
// lives only in the private `schedule` table. The server supplies the stage runs (and their effect
|
|
8
|
+
// on the tier); this module only decides when they are due.
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import { stableStringify } from '@opennodes/core';
|
|
11
|
+
import { testable } from './probes.js';
|
|
12
|
+
|
|
13
|
+
const HOUR = 3_600_000, DAY = 24 * HOUR;
|
|
14
|
+
|
|
15
|
+
export const SCHEDULE_DEFAULTS = Object.freeze({
|
|
16
|
+
tickMs: 5 * 60_000, // how often the scheduler looks for due work
|
|
17
|
+
stageAIntervalMs: 6 * HOUR, // longest gap between Stage A runs; each gap is 75-100% of it
|
|
18
|
+
// After a pass the next Stage B falls anywhere between these two, uniformly: at least quarterly,
|
|
19
|
+
// and a node that passed cannot count on a quiet stretch in which to swap models.
|
|
20
|
+
stageBMinGapMs: DAY,
|
|
21
|
+
stageBIntervalMs: 91 * DAY,
|
|
22
|
+
stageBRetryMs: 7 * DAY, // after a Stage B that did not pass (and was not a dispute); 85-100% of it
|
|
23
|
+
stageBFirstMs: [HOUR, DAY], // a node that reaches community: first Stage B in this window
|
|
24
|
+
stageBChangeMs: [0, HOUR], // after a change to a tested offering's model, serving or hardware
|
|
25
|
+
// After a confirmed mismatch in a blind identity check (stagec.js). The upper end leaves room for
|
|
26
|
+
// the tick (at most 1.5 x tickMs late), so the run starts within the hour.
|
|
27
|
+
stageBIdentityMs: [0, 50 * 60_000],
|
|
28
|
+
stageBLegacyMs: [DAY, 7 * DAY], // nodes verified before the schedule existed: re-run in this window
|
|
29
|
+
// The card revision really moved during Stage B (an excused 409, stageb.js): run again at a random
|
|
30
|
+
// time within the hour (tick slack included). At most MAX_EXCUSED_409 in a row; the next run is judged.
|
|
31
|
+
staleRetryMs: [0, 50 * 60_000],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/** States whose nodes get Stage A on schedule, and the subset that gets Stage B. */
|
|
35
|
+
export const STAGE_A_STATES = ['indexed', 'community', 'verified', 'attested'];
|
|
36
|
+
export const STAGE_B_STATES = ['community', 'verified', 'attested'];
|
|
37
|
+
|
|
38
|
+
const iso = (ms) => new Date(ms).toISOString();
|
|
39
|
+
const sha256 = (s) => createHash('sha256').update(s).digest('hex');
|
|
40
|
+
|
|
41
|
+
/** A uniform random point in [lo, hi]. */
|
|
42
|
+
export const between = ([lo, hi], random = Math.random) => lo + random() * (hi - lo);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* What Stage B measured, as one hash: the tested offerings' model, serving, hardware and binding
|
|
46
|
+
* blocks, the node's hardware, and the API endpoint (another server is another deployment). A
|
|
47
|
+
* change to any of them makes Stage B due (ONP-3 §4a).
|
|
48
|
+
*/
|
|
49
|
+
export function servingDigest(card) {
|
|
50
|
+
const offerings = (card?.offerings ?? []).filter(testable)
|
|
51
|
+
.map((o) => ({ id: o.offering_id, model: o.model ?? null, serving: o.serving ?? null, hardware: o.hardware ?? null, binding: o.binding ?? null }))
|
|
52
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
53
|
+
return sha256(stableStringify({ offerings, hardware: card?.hardware ?? null, endpoint: card?.endpoints?.openai ?? null }));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Bookkeeping for the schedule table, used by every Stage A / B run whether or not the timer is on. */
|
|
57
|
+
export function makePlanner(store, options = {}) {
|
|
58
|
+
const o = { ...SCHEDULE_DEFAULTS, ...options };
|
|
59
|
+
const random = options.random ?? Math.random;
|
|
60
|
+
return {
|
|
61
|
+
options: o,
|
|
62
|
+
/** After any Stage A run: next one within the interval. */
|
|
63
|
+
async afterStageA(nodeId, card, ok) {
|
|
64
|
+
const prev = await store.getSchedule(nodeId, 'A');
|
|
65
|
+
await store.setSchedule(nodeId, 'A', {
|
|
66
|
+
last_at: iso(Date.now()), next_at: iso(Date.now() + o.stageAIntervalMs * between([0.75, 1], random)),
|
|
67
|
+
ok, revision: card?.revision ?? null, failures: ok ? 0 : (prev?.failures ?? 0) + 1,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* A first (or renewed) Stage B at a random time: `first` for a node that reached community,
|
|
72
|
+
* `legacy` for one verified before this schedule existed. A sooner run already planned stays.
|
|
73
|
+
*/
|
|
74
|
+
async firstStageB(nodeId, card, kind = 'first') {
|
|
75
|
+
const prev = await store.getSchedule(nodeId, 'B');
|
|
76
|
+
const planned = Date.now() + between(kind === 'legacy' ? o.stageBLegacyMs : o.stageBFirstMs, random);
|
|
77
|
+
const existing = prev?.next_at ? Date.parse(prev.next_at) : Infinity;
|
|
78
|
+
const row = {
|
|
79
|
+
last_at: prev?.last_at ?? null, next_at: iso(Math.min(planned, existing)), ok: prev?.ok ?? null,
|
|
80
|
+
revision: prev?.revision ?? null, digest: servingDigest(card), pending_digest: null, failures: 0,
|
|
81
|
+
};
|
|
82
|
+
await store.setSchedule(nodeId, 'B', row);
|
|
83
|
+
return row;
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* A blind identity check found a reply that is not the reference's, twice (stagec.js): Stage B
|
|
87
|
+
* is due at a random time within the hour, unless a sooner run is already planned. It changes
|
|
88
|
+
* nothing else: only Stage B can dispute. Returns the planned time (ISO).
|
|
89
|
+
*/
|
|
90
|
+
async stageBSoon(nodeId, card) {
|
|
91
|
+
const prev = await store.getSchedule(nodeId, 'B');
|
|
92
|
+
const at = Date.now() + between(o.stageBIdentityMs, random);
|
|
93
|
+
const next = iso(Math.min(prev?.next_at ? Date.parse(prev.next_at) : Infinity, at));
|
|
94
|
+
await store.setSchedule(nodeId, 'B', prev ? { ...prev, next_at: next } : {
|
|
95
|
+
last_at: null, next_at: next, ok: null, revision: null, digest: servingDigest(card), pending_digest: null, failures: 0,
|
|
96
|
+
});
|
|
97
|
+
return next;
|
|
98
|
+
},
|
|
99
|
+
/** After any Stage B run. A dispute leaves nothing scheduled: the node is out until a resolution. */
|
|
100
|
+
async afterStageB(nodeId, card, result) {
|
|
101
|
+
const prev = await store.getSchedule(nodeId, 'B') ?? {};
|
|
102
|
+
const now = Date.now();
|
|
103
|
+
if (result.stale) {
|
|
104
|
+
// Unjudged: last_at stays, so the excused 409s since the last judged run keep counting.
|
|
105
|
+
await store.setSchedule(nodeId, 'B', { ...prev, next_at: iso(now + between(o.staleRetryMs, random)), failures: (prev.failures ?? 0) + 1 });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const next = result.identityFailed ? null
|
|
109
|
+
: iso(now + (result.ok ? between([o.stageBMinGapMs, o.stageBIntervalMs], random) : o.stageBRetryMs * between([0.85, 1], random)));
|
|
110
|
+
await store.setSchedule(nodeId, 'B', {
|
|
111
|
+
last_at: iso(now), next_at: next, ok: result.ok, revision: card?.revision ?? null,
|
|
112
|
+
digest: servingDigest(card), pending_digest: null, failures: result.ok ? 0 : (prev.failures ?? 0) + 1,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Run due work every `tickMs` (jittered), one node at a time. `stageA(nodeId)` and `stageB(nodeId)`
|
|
120
|
+
* are the server's runs; each records its own schedule through the planner.
|
|
121
|
+
*/
|
|
122
|
+
export function startScheduler(store, planner, { stageA, stageB, random = Math.random } = {}) {
|
|
123
|
+
const o = planner.options;
|
|
124
|
+
let stopped = false, timer = null;
|
|
125
|
+
|
|
126
|
+
async function tick() {
|
|
127
|
+
for (const node of await store.allNodes()) {
|
|
128
|
+
if (stopped) return;
|
|
129
|
+
if (node.source === 'import' || !STAGE_A_STATES.includes(node.state)) continue;
|
|
130
|
+
const card = await store.latestCard(node.id);
|
|
131
|
+
if (!card) continue;
|
|
132
|
+
const now = Date.now();
|
|
133
|
+
|
|
134
|
+
const a = await store.getSchedule(node.id, 'A');
|
|
135
|
+
if (!a || !a.next_at || Date.parse(a.next_at) <= now || a.revision !== card.revision) {
|
|
136
|
+
await stageA(node.id).catch(() => {});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const current = await store.getNode(node.id);
|
|
140
|
+
if (!STAGE_B_STATES.includes(current?.state)) continue;
|
|
141
|
+
const fresh = await store.latestCard(node.id);
|
|
142
|
+
let b = await store.getSchedule(node.id, 'B');
|
|
143
|
+
if (!b) {
|
|
144
|
+
// Never scheduled: a node new at community, or one verified before the schedule existed.
|
|
145
|
+
await planner.firstStageB(node.id, fresh, current.state === 'community' ? 'first' : 'legacy');
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
let nextAt = b.next_at ? Date.parse(b.next_at) : Infinity;
|
|
149
|
+
if (current.state === 'community') {
|
|
150
|
+
// Back at community since its last Stage B (blind-probe demotion, an unsigned card,
|
|
151
|
+
// reinstatement): it gets a new chance within the first-run window.
|
|
152
|
+
const last = (await store.transitionsFor(node.id)).at(-1);
|
|
153
|
+
if (last?.to_state === 'community' && (!b.last_at || last.at > b.last_at) && nextAt > now + o.stageBFirstMs[1]) {
|
|
154
|
+
b = await planner.firstStageB(node.id, fresh, 'first');
|
|
155
|
+
nextAt = Date.parse(b.next_at);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const digest = servingDigest(fresh);
|
|
159
|
+
if (b.digest && digest !== b.digest && digest !== b.pending_digest) {
|
|
160
|
+
// A tested offering's model, serving or hardware changed since the last Stage B: run it soon.
|
|
161
|
+
nextAt = Math.min(nextAt, now + between(o.stageBChangeMs, random));
|
|
162
|
+
b = { ...b, pending_digest: digest, next_at: iso(nextAt) };
|
|
163
|
+
await store.setSchedule(node.id, 'B', b);
|
|
164
|
+
}
|
|
165
|
+
if (nextAt <= now) await stageB(node.id).catch(() => {});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const loop = async () => {
|
|
170
|
+
if (stopped) return;
|
|
171
|
+
await tick().catch(() => {});
|
|
172
|
+
if (!stopped) timer = setTimeout(loop, o.tickMs * between([0.5, 1.5], random));
|
|
173
|
+
timer?.unref?.();
|
|
174
|
+
};
|
|
175
|
+
timer = setTimeout(loop, o.tickMs * between([0.5, 1.5], random));
|
|
176
|
+
timer.unref?.();
|
|
177
|
+
return { stop: () => { stopped = true; clearTimeout(timer); }, tick };
|
|
178
|
+
}
|
package/src/search.js
CHANGED
|
@@ -3,8 +3,10 @@ import {
|
|
|
3
3
|
residencyWithin, residencyCodes, servingLocations, basisRank,
|
|
4
4
|
inJurisdiction, localSizes, pullsOf, specialtyOf, isEmbedder,
|
|
5
5
|
trustedView, poolOf, inTrustedPool, lineageAllowed, meetsDataPolicy, RETENTION_LEVELS,
|
|
6
|
+
serverCheckOf, serverCheckPassed, jurisdictionEvidence, SERVER_CHECK_FILTERS,
|
|
6
7
|
} from '@opennodes/core';
|
|
7
8
|
import { testable } from './probes.js';
|
|
9
|
+
import { declaredOrigins } from './location.js';
|
|
8
10
|
|
|
9
11
|
/** BCP 47 prefix match (ONP-3 §5): `fr` matches `fr` and `fr-CA`; `fr-CA` matches only itself. */
|
|
10
12
|
export const langMatches = (tag, wanted) => {
|
|
@@ -26,7 +28,8 @@ const catalogs = new WeakMap(); // store -> { items, at, stale, building }
|
|
|
26
28
|
const placements = new WeakMap(); // store -> Map
|
|
27
29
|
// A request to these hosts passes through a third-party router before it reaches the provider, so
|
|
28
30
|
// the provider's sites say nothing about where the prompt goes: no seed placement for them.
|
|
29
|
-
|
|
31
|
+
/** Third-party routers: their listings name model authors, not the host that serves them. */
|
|
32
|
+
export const ROUTER_HOSTS = new Set(['router.huggingface.co', 'openrouter.ai']);
|
|
30
33
|
const hostOf = (url) => { try { return new URL(url).hostname; } catch { return null; } };
|
|
31
34
|
|
|
32
35
|
/** Use these seed placements in search from now on (the server sets them at start and on seed import). */
|
|
@@ -53,7 +56,7 @@ export function markCatalogStale(store) {
|
|
|
53
56
|
|
|
54
57
|
/** Wrap the store's write methods so any change to nodes, cards, probes or observations marks the catalog stale. */
|
|
55
58
|
export function watchStoreWrites(store) {
|
|
56
|
-
for (const name of ['upsertNode', 'setState', 'setNodeFlag', 'saveRevision', 'recordProbe', 'addFingerprints', 'setObservation']) {
|
|
59
|
+
for (const name of ['upsertNode', 'setState', 'setNodeFlag', 'saveRevision', 'recordProbe', 'addFingerprints', 'clearFingerprints', 'setObservation']) {
|
|
57
60
|
const write = store[name];
|
|
58
61
|
if (typeof write !== 'function' || write.__marksCatalogStale) continue;
|
|
59
62
|
const wrapped = async function (...args) {
|
|
@@ -78,6 +81,41 @@ export async function collectOfferings(store) {
|
|
|
78
81
|
return entry.building;
|
|
79
82
|
}
|
|
80
83
|
|
|
84
|
+
/**
|
|
85
|
+
* The server-location check (location.js) as search results carry it, under `jurisdiction.location`
|
|
86
|
+
* (ONP-3 §6.4). A check applies only to the card it was made for: when the card now names another API
|
|
87
|
+
* host, or declares another operator country, it is reported as `unknown` until the next check, so an
|
|
88
|
+
* operator cannot pass on one host and then point its endpoint elsewhere.
|
|
89
|
+
*/
|
|
90
|
+
export function locationSummary(loc, card) {
|
|
91
|
+
if (!loc) return null;
|
|
92
|
+
const host = hostOf(card?.endpoints?.openai);
|
|
93
|
+
const declared = card?.node?.operator?.country ? String(card.node.operator.country).toUpperCase() : null;
|
|
94
|
+
const stale = (loc.host ?? null) !== host ? 'the API host changed since this check'
|
|
95
|
+
: (loc.declared ?? null) !== declared ? 'the declared operator country changed since this check' : null;
|
|
96
|
+
if (stale) return { verdict: 'unknown', server_country: null, network: null, cdn: false, latency: 'unknown', checked_at: loc.checked_at, reason: stale };
|
|
97
|
+
// Origin results count only for the origin addresses the card declares now.
|
|
98
|
+
const origins = declaredOrigins(card);
|
|
99
|
+
const originCurrent = loc.origin && JSON.stringify(loc.origin.declared ?? []) === JSON.stringify(origins);
|
|
100
|
+
const origin = !loc.origin || !origins.length ? null
|
|
101
|
+
: originCurrent ? loc.origin
|
|
102
|
+
: { verdict: 'unknown', reason: 'the declared origin addresses changed since this check', addresses: [] };
|
|
103
|
+
return {
|
|
104
|
+
verdict: loc.verdict, server_country: loc.server?.country ?? null, network: loc.server?.network ?? null,
|
|
105
|
+
cdn: Boolean(loc.server?.cdn), latency: loc.latency?.verdict ?? 'unknown', checked_at: loc.checked_at,
|
|
106
|
+
...(loc.reason ? { reason: loc.reason } : {}),
|
|
107
|
+
// Behind a CDN: the origin addresses the card declares, as the registry found them.
|
|
108
|
+
...(origin ? { origin: {
|
|
109
|
+
verdict: origin.verdict,
|
|
110
|
+
...(origin.reason ? { reason: origin.reason } : {}),
|
|
111
|
+
addresses: (origin.addresses ?? []).map((a) => ({
|
|
112
|
+
address: a.address, verdict: a.verdict, server_country: a.server_country ?? null,
|
|
113
|
+
network: a.server?.network ?? null, latency: a.latency?.verdict ?? 'unknown', ...(a.reason ? { reason: a.reason } : {}),
|
|
114
|
+
})),
|
|
115
|
+
} } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
81
119
|
/** Flatten indexed nodes into searchable offering summaries. */
|
|
82
120
|
async function buildOfferings(store) {
|
|
83
121
|
const out = [];
|
|
@@ -90,18 +128,15 @@ async function buildOfferings(store) {
|
|
|
90
128
|
// Pass rate over the recent window of conformance (A) and continuous (C) checks. Stage A
|
|
91
129
|
// alone runs every 6 h and is pushed out of the window by liveness checks within hours,
|
|
92
130
|
// which left healthy verified nodes showing 0 probes and a 0 pass rate.
|
|
93
|
-
|
|
131
|
+
// A blind probe excused for a 409 (the card revision moved; retried) is a record, not a check.
|
|
132
|
+
const checks = probes.filter((p) => (p.stage === 'A' || p.stage === 'C') && p.kind !== 'blind-409');
|
|
94
133
|
const probeSuccess = checks.length ? checks.filter((p) => p.ok).length / checks.length : 0;
|
|
95
134
|
const tier = node.state === 'indexed' ? 'unverified' : node.state;
|
|
96
135
|
const nodeObs = await store.getObservations(node.id, '_node');
|
|
97
136
|
const availability = nodeObs.availability ?? null;
|
|
98
|
-
const loc = nodeObs.location ?? null;
|
|
99
137
|
const placed = ROUTER_HOSTS.has(hostOf(card.endpoints?.openai)) ? null : placements.get(store)?.get(node.id);
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
verdict: loc.verdict, server_country: loc.server?.country ?? null, network: loc.server?.network ?? null,
|
|
103
|
-
cdn: Boolean(loc.server?.cdn), latency: loc.latency?.verdict ?? 'unknown', checked_at: loc.checked_at,
|
|
104
|
-
} : null;
|
|
138
|
+
const location = locationSummary(nodeObs.location ?? null, card);
|
|
139
|
+
const serverCheck = serverCheckOf({ jurisdiction: { location } });
|
|
105
140
|
for (const declared of card.offerings) {
|
|
106
141
|
// No location on the card: a curated seed may say where this node serves every model.
|
|
107
142
|
const offering = placed && !Array.isArray(declared.locations) && !(card.node?.locations ?? []).length
|
|
@@ -135,14 +170,16 @@ async function buildOfferings(store) {
|
|
|
135
170
|
pricing: offering.pricing,
|
|
136
171
|
data_policy: offering.data_policy ?? null,
|
|
137
172
|
node_regions: card.node?.regions ?? [],
|
|
138
|
-
// Where the operator is (ONP-2 node.operator.country, node.regions).
|
|
173
|
+
// Where the operator is (ONP-2 node.operator.country, node.regions): a declaration, not proof.
|
|
139
174
|
// Registered nodes declare it in their signed card; imports get it from the importer's list of
|
|
140
|
-
// known providers, labeled inferred. `location` is the registry's own server-location check
|
|
175
|
+
// known providers, labeled inferred. `location` is the registry's own server-location check and
|
|
176
|
+
// `server_check` its evidence level (core serverCheckOf); `evidence` says both in words.
|
|
141
177
|
jurisdiction: {
|
|
142
178
|
country: card.node?.operator?.country ?? null,
|
|
143
179
|
regions: card.node?.regions ?? [],
|
|
144
180
|
basis: card.node?.operator?.country ? (node.source === 'import' ? 'inferred' : 'declared') : null,
|
|
145
181
|
location,
|
|
182
|
+
server_check: serverCheck,
|
|
146
183
|
},
|
|
147
184
|
// Where requests are served: live sites with their evidence basis (ONP-2 §3a), and the
|
|
148
185
|
// codes a residency check must cover (pins + sites, else node regions).
|
|
@@ -166,6 +203,7 @@ async function buildOfferings(store) {
|
|
|
166
203
|
});
|
|
167
204
|
// Trusted or open pool (ONP-3 §5e), under this registry's trusted view.
|
|
168
205
|
out.at(-1).pool = poolOf(out.at(-1), view);
|
|
206
|
+
if (out.at(-1).jurisdiction.country) out.at(-1).jurisdiction.evidence = jurisdictionEvidence(out.at(-1));
|
|
169
207
|
}
|
|
170
208
|
}
|
|
171
209
|
return out;
|
|
@@ -196,7 +234,10 @@ export async function searchOfferingsPaged(store, query) {
|
|
|
196
234
|
}
|
|
197
235
|
if (q('max_input_price')) items = items.filter((o) => (o.pricing.input_per_mtok ?? Infinity) <= Number(q('max_input_price')));
|
|
198
236
|
if (q('scheme')) items = items.filter((o) => o.pricing.schemes.includes(q('scheme')));
|
|
237
|
+
// Operator jurisdiction: the declared (or, for imports, inferred) country, minus servers found outside.
|
|
199
238
|
if (q('jurisdiction')) items = items.filter((o) => inJurisdiction(o, q('jurisdiction')));
|
|
239
|
+
// Evidence: the registry's server-location check passed (front, or every declared origin behind a CDN).
|
|
240
|
+
if (oneOf('server_check', q('server_check'), SERVER_CHECK_FILTERS) === 'passed') items = items.filter((o) => o.local || serverCheckPassed(o));
|
|
200
241
|
if (q('region')) {
|
|
201
242
|
// Residency: every pinned region and live serving site (else the node's regions) inside.
|
|
202
243
|
items = items.filter((o) => residencyWithin(o.residency, q('region')));
|