@opennodes/registry 0.1.59 → 0.1.60

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 CHANGED
@@ -3,9 +3,9 @@
3
3
  The OpenNodes Protocol (ONP) reference registry — an open, federatable discovery service for AI inference nodes.
4
4
 
5
5
  ```bash
6
- npx @opennodes/registry@0.1.59 # web app + API on http://127.0.0.1:4300
7
- ONP_DB=./registry.db npx @opennodes/registry@0.1.59 # persistent SQLite + persistent signing key
8
- ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.59
6
+ npx @opennodes/registry@0.1.60 # web app + API on http://127.0.0.1:4300
7
+ ONP_DB=./registry.db npx @opennodes/registry@0.1.60 # persistent SQLite + persistent signing key
8
+ ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.60
9
9
  ```
10
10
 
11
11
  What it does:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opennodes/registry",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
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, AI Horde), MCP surface, and the web app (catalog, chat, advisor, Node Builder)",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/schedule.js CHANGED
@@ -34,6 +34,9 @@ export const SCHEDULE_DEFAULTS = Object.freeze({
34
34
  // The card revision really moved during Stage B (an excused 409, stageb.js): run again at a random
35
35
  // time within the hour (tick slack included). At most MAX_EXCUSED_409 in a row; the next run is judged.
36
36
  staleRetryMs: [0, 50 * 60_000],
37
+ // Identity prompts got no reply even after retries (5xx, 429, timeouts: stageb.js), or the run could
38
+ // not finish: not judged, and run again at a random time in this window.
39
+ stageBFailedMs: [HOUR, DAY],
37
40
  });
38
41
 
39
42
  /** States whose nodes get Stage A on schedule, and the subset that gets Stage B. */
@@ -135,6 +138,13 @@ export function makePlanner(store, options = {}) {
135
138
  });
136
139
  return;
137
140
  }
141
+ if (result.endpointFailed || result.error) {
142
+ // Not judged: identity prompts got no reply even after retries, or the run could not finish
143
+ // (stageb.js endpointFailedOf). last_at stays, so the bound counts every such run since the
144
+ // last judged one; the next run comes within a day; the timer and any hold stay as they were.
145
+ await store.setSchedule(nodeId, 'B', { ...prev, next_at: iso(now + between(o.stageBFailedMs, random)), ok: false, failures: (prev.failures ?? 0) + 1 });
146
+ return;
147
+ }
138
148
  if (result.stale) {
139
149
  // Unjudged: last_at stays, so the excused 409s since the last judged run keep counting.
140
150
  await store.setSchedule(nodeId, 'B', { ...prev, next_at: iso(now + between(o.staleRetryMs, random)), failures: (prev.failures ?? 0) + 1 });
package/src/server.js CHANGED
@@ -49,6 +49,7 @@ export async function startRegistry({
49
49
  allowPrivateTargets = false, // SSRF guard off only for dev/e2e
50
50
  dnsResolveTxt = resolveTxt, // injectable for tests
51
51
  stageBCapacity = {}, // e.g. { durationMs, steps } — shortened in tests
52
+ stageBIdentityRetry = null, // {pausesMs, rateLimitPausesMs, retryAfterCapMs} for identity prompts after an endpoint failure (default stageb.js IDENTITY_RETRY)
52
53
  stageC = null, // { livenessIntervalMs, blindIntervalMs, failThreshold } to enable
53
54
  reimport = null, // { intervalMs, sources } to keep imported catalogs fresh
54
55
  adminToken = null, // bearer for admin routes; without it, loopback-only
@@ -317,9 +318,20 @@ export async function startRegistry({
317
318
  const now = await store.latestRevision(nodeId);
318
319
  return now && now.revision !== card.revision ? now.revision : null;
319
320
  };
320
- const stageB = await runStageB(store, nodeId, card, {
321
- safeFetch: await authFetch(nodeId, card), capacity: stageBCapacity, corpus, vendors: await vendors(), signed: Boolean(revision?.sig_ok), revisionMoved,
322
- });
321
+ let stageB;
322
+ try {
323
+ stageB = await runStageB(store, nodeId, card, {
324
+ safeFetch: await authFetch(nodeId, card), capacity: stageBCapacity, corpus, vendors: await vendors(), signed: Boolean(revision?.sig_ok), revisionMoved,
325
+ ...(stageBIdentityRetry ? { identityRetry: stageBIdentityRetry } : {}),
326
+ });
327
+ } catch (err) {
328
+ // The run could not finish: recorded, not judged (the tier stays), and run again within a day.
329
+ const reason = `Stage B could not finish: ${String(err?.message ?? err).slice(0, 200)}`;
330
+ await store.recordProbe(nodeId, null, 'B', 'error', false, reason);
331
+ const result = { ok: false, identityFailed: false, error: true, reason, verdicts: [], untested: [] };
332
+ await planner.afterStageB(nodeId, card, result);
333
+ return result;
334
+ }
323
335
  const node = await store.getNode(nodeId);
324
336
  let result = stageB;
325
337
  if (!stageB.stale && LISTED.includes(node.state)) {
package/src/stageb.js CHANGED
@@ -35,7 +35,7 @@ export const IDENTITY_MAX_TOKENS = 64;
35
35
  */
36
36
  export async function chatOnce(safeFetch, card, offering, content, maxTokens = IDENTITY_MAX_TOKENS, timeoutMs = 60_000) {
37
37
  const t0 = performance.now();
38
- const { status, body } = await fetchJsonCapped(safeFetch, `${card.endpoints.openai}/chat/completions`, {
38
+ const { status, body, headers } = await fetchJsonCapped(safeFetch, `${card.endpoints.openai}/chat/completions`, {
39
39
  method: 'POST',
40
40
  // A reference capture from an endpoint that is not a node (no card) sends no ONP headers.
41
41
  headers: card.node ? {
@@ -55,6 +55,8 @@ export async function chatOnce(safeFetch, card, offering, content, maxTokens = I
55
55
  text: body?.choices?.[0]?.message?.content ?? null,
56
56
  usage: body?.usage ?? null,
57
57
  latencyMs: performance.now() - t0,
58
+ // A 429's or 503's Retry-After (seconds, or an HTTP date), for the identity retries.
59
+ retryAfter: headers?.get?.('retry-after') ?? null,
58
60
  };
59
61
  }
60
62
 
@@ -81,15 +83,21 @@ export async function captureFingerprints(safeFetch, card, offering, prompts = D
81
83
  * inconclusive run per artefact and capture at most, and gets no `verified` from it. Disputes at
82
84
  * once: any non-matching prompt that went unanswered on either ask (a refusal or failed reply, so
83
85
  * M4's rule that a refusal counts as a non-match keeps its force). Card revisions do not reset the
84
- * count; only a new capture does.
86
+ * count; only a new capture does. A prompt that got no reply even after the retries (an endpoint
87
+ * failure) is neither: a run with only such prompts failing is not judged (endpointFailedOf), and
88
+ * with a confirmed mismatch beside them the mismatch is judged as usual.
85
89
  * Returns {dispute: true, why} or {dispute: false, inconclusive: [{offering_id, artifact, matches, total}]}.
86
90
  */
91
+ /** Whether a verdict's identity check failed on evidence: not unverified (nothing to compare) and not endpoint-failed. */
92
+ const identityMismatch = (v) => Boolean(v.identity) && !v.identity.ok && !v.identity.unverified && !v.identity.endpointFailed;
93
+
87
94
  export async function judgeMismatch(store, nodeId, stageB) {
88
- const failed = (stageB.verdicts ?? []).filter((v) => v.identity && !v.identity.ok && !v.identity.unverified);
95
+ const failed = (stageB.verdicts ?? []).filter(identityMismatch);
89
96
  const inconclusive = [];
90
97
  for (const v of failed) {
91
98
  const id = v.identity;
92
99
  const artifact = v.artifact;
100
+ if (id.failedAgain) return { dispute: true, why: IDENTITY_FAILED_AGAIN };
93
101
  if (!artifact) return { dispute: true, why: IDENTITY_MISMATCH };
94
102
  if (id.unanswered || id.moved) return { dispute: true, why: IDENTITY_MISMATCH };
95
103
  const since = await store.lastCaptureAt(artifact);
@@ -109,6 +117,35 @@ export const STAGE_B_INCONCLUSIVE = 'identity-inconclusive';
109
117
  /** Whether a reply's text is the reference's: the exact-output comparison of ONP-3 §4a.4. */
110
118
  export const matchesReference = (text, ref) => typeof text === 'string' && sha256(text) === ref.expected_hash;
111
119
 
120
+ /**
121
+ * Asking an identity prompt again after an endpoint failure (a 5xx, a 429, a 401, 403 or 408, a 200
122
+ * without a reply text, a timeout, a connection error): the pauses before each retry; for a 429 the
123
+ * pauses are `rateLimitPausesMs` (a per-minute quota needs the last one to reach the next minute),
124
+ * and a Retry-After header, up to `retryAfterCapMs`, sets the pause when it is longer.
125
+ */
126
+ export const IDENTITY_RETRY = Object.freeze({ pausesMs: [2_000, 8_000], rateLimitPausesMs: [5_000, 60_000], retryAfterCapMs: 120_000 });
127
+ /** Statuses that are endpoint failures, not refusals (with every 5xx). 401/403: a lapsed or revoked probe key looks the same as a refusal. */
128
+ const ENDPOINT_FAILURE_STATUSES = new Set([401, 403, 408, 429]);
129
+ /** A Retry-After header in ms (seconds or an HTTP date), or null. */
130
+ export function retryAfterMs(value, now = Date.now()) {
131
+ if (value == null || value === '') return null;
132
+ if (/^\d+$/.test(String(value).trim())) return Number(value) * 1000;
133
+ const at = Date.parse(value);
134
+ return Number.isFinite(at) ? Math.max(0, at - now) : null;
135
+ }
136
+ /**
137
+ * Probe record of a Stage B run that ended "endpoint failed" while the node answered other requests
138
+ * in it (selective). One is excused since the node's last judged run; with one already recorded, the
139
+ * next one's failed prompts count as unanswered, and the node is disputed (ONP-3 §4a.4).
140
+ */
141
+ export const STAGE_B_FAILED = 'identity-failed';
142
+ /** Probe record of a run that ended "endpoint failed" with nothing answered in it: the node was down. Never counts. */
143
+ export const STAGE_B_UNREACHABLE = 'identity-unreachable';
144
+ /** Selective endpoint-failed runs excused since the node's last judged Stage B. */
145
+ export const MAX_FAILED_RUNS = 1;
146
+ /** The transition reason of a dispute for identity prompts that failed again while other requests were answered. */
147
+ export const IDENTITY_FAILED_AGAIN = 'Stage B identity prompts failed in a second run while the node answered other requests';
148
+
112
149
  /** 409s to identity prompts excused (the run stops unjudged and is retried) since the node's last judged Stage B. */
113
150
  export const MAX_EXCUSED_409 = 3;
114
151
  /** The probe record of an excused one. */
@@ -164,41 +201,80 @@ const sameModelClaim = (a, b) => a.model?.artifact === b.model?.artifact
164
201
  * parallel slots can change a temperature-0 reply now and then). A 409 counts as a reply that does
165
202
  * not match unless `on409` excuses it (makeOn409).
166
203
  */
167
- async function probeIdentity(safeFetch, pin, offering, refs, on409) {
204
+ async function probeIdentity(safeFetch, pin, offering, refs, on409, retry = IDENTITY_RETRY, endpoint = { down: false }) {
168
205
  let matches = 0, retried = 0, refused = 0, refusedRepinned = 0, repinned = null, stop = null;
206
+ let answered = 0, failure = null;
169
207
  let current = offering;
208
+ // One request. An endpoint failure (a 5xx, a 401, 403, 408 or 429, a 200 without a reply text, a
209
+ // timeout, a connection error) is {failure}; any other status is {status}, for the refusal rule below.
210
+ const once = async (prompt) => {
211
+ try {
212
+ const { status, text, retryAfter } = await chatOnce(safeFetch, pin.card, current, prompt);
213
+ if (status === 200 && typeof text === 'string') return { text };
214
+ if (status === 200 || status >= 500 || ENDPOINT_FAILURE_STATUSES.has(status)) {
215
+ return { failure: status === 200 ? '200 without a reply text' : `status ${status}`, status429: status === 429, retryAfter: retryAfterMs(retryAfter) };
216
+ }
217
+ return { status };
218
+ } catch (err) {
219
+ return { failure: /abort|timeout/i.test(String(err?.name) + String(err?.message)) ? 'timeout' : 'connection error', thrown: true };
220
+ }
221
+ };
222
+ const pause = (ms) => (ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : null);
223
+ // {hash} | {refused: true} | {failed: true} | {} (the run stops: `stop`).
170
224
  const ask = async (prompt, again = true) => {
171
- const { status, text } = await chatOnce(safeFetch, pin.card, current, prompt);
172
- if (status !== 200) {
173
- // A 409, or another failure (a 404 for a model dropped since the card was fetched): only a
225
+ let r = await once(prompt);
226
+ // An endpoint failure is asked again, once per pause; once the run has found the endpoint
227
+ // unreachable (`endpoint.down`, shared by the run's offerings), not again until something answers.
228
+ for (let i = 0; r.failure && !endpoint.down && i < retry.pausesMs.length; i++) {
229
+ const base = (r.status429 ? retry.rateLimitPausesMs : retry.pausesMs)[i] ?? 0;
230
+ await pause(Math.max(base, Math.min(r.retryAfter ?? 0, retry.retryAfterCapMs)));
231
+ r = await once(prompt);
232
+ }
233
+ if (r.failure) { failure = r.failure; if (r.thrown) endpoint.down = true; return { failed: true }; }
234
+ endpoint.down = false;
235
+ if (r.status) {
236
+ // A 409, or another refusal (a 404 for a model dropped since the card was fetched): only a
174
237
  // revision that really moved excuses it; with the current revision pinned it does not match.
175
- const what = await on409(current, status);
238
+ const what = await on409(current, r.status);
176
239
  if (what.kind === 'repin') {
177
240
  // Beyond the bound: ask again with the revision just fetched pinned; a refusal then counts.
178
241
  current = what.offering;
179
242
  repinned = what.beyond;
180
243
  if (again) return ask(prompt, false);
181
244
  refusedRepinned++;
182
- return null;
245
+ return { refused: true };
183
246
  }
184
- if (what.kind !== 'refused') stop = what;
185
- else if (status === 409) refused++;
186
- return null;
247
+ if (what.kind !== 'refused') { stop = what; return {}; }
248
+ if (r.status === 409) refused++;
249
+ return { refused: true };
187
250
  }
188
- return text !== null ? sha256(text) : null;
251
+ answered++;
252
+ return { hash: sha256(r.text) };
189
253
  };
190
- // Non-matching prompts that got no text on either ask (a refusal or another failure): such a
191
- // mismatch is never "inconclusive" (judgeMismatch), so a refusal keeps counting against the node.
192
- let unanswered = 0;
254
+ // Per prompt that did not match: `unanswered` when an ask was refused (such a mismatch is never
255
+ // "inconclusive": judgeMismatch disputes at once, so M4's rule keeps its force); else `failed` when
256
+ // an ask got no reply even after the retries (not judged: endpointFailedOf); else `mismatched`, a
257
+ // reply on both asks that is not the reference's.
258
+ let unanswered = 0, failed = 0, mismatched = 0;
193
259
  for (const ref of refs) {
194
- let hash = await ask(ref.prompt);
195
- let noText = hash === null;
196
- if (hash !== ref.expected_hash && !stop) { retried++; hash = await ask(ref.prompt); noText ||= hash === null; }
197
- if (hash === ref.expected_hash) matches++;
198
- else if (noText && !stop) unanswered++;
260
+ let r = await ask(ref.prompt);
261
+ let refusedAny = Boolean(r.refused);
262
+ // A reply that does not match (or a refusal) is asked once more; a failed ask has had its retries.
263
+ if (!r.failed && r.hash !== ref.expected_hash && !stop) {
264
+ retried++;
265
+ r = await ask(ref.prompt);
266
+ refusedAny ||= Boolean(r.refused);
267
+ }
199
268
  if (stop) break;
269
+ if (r.hash === ref.expected_hash) matches++;
270
+ else if (refusedAny) unanswered++;
271
+ else if (r.failed) failed++;
272
+ else mismatched++;
200
273
  }
201
274
  const extra = { ...(retried ? { retried } : {}), ...(refused ? { refused } : {}), ...(unanswered ? { unanswered } : {}),
275
+ ...(failed ? { failed, failure } : {}), ...(mismatched ? { mismatched } : {}), answered,
276
+ // Nothing answered and the endpoint unreachable: the run sends this offering nothing more.
277
+ ...(failed && !answered && endpoint.down ? { unreachable: true } : {}),
202
278
  ...(repinned ? { repinned, refused_repinned: refusedRepinned } : {}) };
203
279
  if (stop?.kind === 'stale') return { ok: false, matches, total: refs.length, ...extra, stale: true };
204
280
  if (stop?.kind === 'moved') return { ok: false, matches, total: refs.length, ...extra, moved: true, reason: stop.reason };
@@ -247,17 +323,18 @@ async function probeContext(safeFetch, card, offering, corpus) {
247
323
  const body = Math.floor(tokens * charsPerToken) - fact.length - question.length - 40; // 40: chat template slack
248
324
  const before = Math.floor(body * 0.1);
249
325
  const prompt = corpus.haystack(before) + fact + corpus.haystack(body - before) + question;
250
- let found = false, why = null, promptTokens = null;
326
+ let found = false, why = null, promptTokens = null, answered = false;
251
327
  try {
252
328
  // Prefill on modest hardware is slow: allow ~30 ms per claimed token on top of the base timeout.
253
329
  const { status, text, usage } = await chatOnce(safeFetch, card, offering, prompt, 64, 60_000 + tokens * 30);
330
+ answered = status === 200 && typeof text === 'string'; // a reply, for the endpoint-failure bound
254
331
  promptTokens = usage?.prompt_tokens ?? null;
255
332
  if (status !== 200) why = `status ${status}`;
256
333
  else if (measured && promptTokens != null && promptTokens < tokens * 0.85) why = `prompt cut to ${promptTokens} tokens`;
257
334
  else if (!needleFound(text, digits)) why = 'number not in reply';
258
335
  else found = true;
259
336
  } catch (err) { why = /abort|timeout/i.test(String(err?.message)) ? 'timeout' : String(err?.message ?? err).slice(0, 80); }
260
- results.push({ fraction, tokens, found, ...(promptTokens != null ? { prompt_tokens: promptTokens } : {}), ...(why ? { why } : {}) });
337
+ results.push({ fraction, tokens, found, ...(answered ? { answered } : {}), ...(promptTokens != null ? { prompt_tokens: promptTokens } : {}), ...(why ? { why } : {}) });
261
338
  if (found && unbroken) cap = tokens; else unbroken = false;
262
339
  }
263
340
  const allPassed = results.every((r) => r.found);
@@ -267,7 +344,7 @@ async function probeContext(safeFetch, card, offering, corpus) {
267
344
  /** DS-ADM-04: stepped-concurrency ramp; measures TTFT p50/p95 and rough TPS. */
268
345
  async function probeCapacity(safeFetch, card, offering, corpus, { steps = CAPACITY_RAMP.steps, durationMs = CAPACITY_RAMP.durationMs } = {}) {
269
346
  const latencies = [];
270
- let completed = 0, failed = 0, outputTokens = 0;
347
+ let completed = 0, failed = 0, outputTokens = 0, answered = 0;
271
348
  const deadline = Date.now() + durationMs;
272
349
  for (const concurrency of steps) {
273
350
  while (Date.now() < deadline) {
@@ -280,6 +357,7 @@ async function probeCapacity(safeFetch, card, offering, corpus, { steps = CAPACI
280
357
  for (const r of batch) {
281
358
  if (!r) { failed++; continue; }
282
359
  completed++;
360
+ if (typeof r.text === 'string') answered++; // a reply with text, for the endpoint-failure bound
283
361
  latencies.push(r.latencyMs);
284
362
  outputTokens += r.usage?.completion_tokens ?? 0;
285
363
  }
@@ -291,7 +369,7 @@ async function probeCapacity(safeFetch, card, offering, corpus, { steps = CAPACI
291
369
  const totalSeconds = Math.max(0.001, durationMs / 1000);
292
370
  return {
293
371
  ok: completed > 0 && failed / Math.max(1, completed + failed) < 0.1,
294
- completed, failed,
372
+ completed, failed, answered,
295
373
  ttft_ms: { p50: pct(0.5), p95: pct(0.95) },
296
374
  tps: Math.round(outputTokens / totalSeconds),
297
375
  };
@@ -305,14 +383,57 @@ async function probeCapacity(safeFetch, card, offering, corpus, { steps = CAPACI
305
383
  * offering cannot be verified: no usable reference for the artefact, or a proprietary artefact
306
384
  * claimed outside the vendor's namespace.
307
385
  */
308
- async function identityOf(store, nodeId, safeFetch, pin, offering, { corpus, vendors, identitySample, on409 }) {
386
+ async function identityOf(store, nodeId, safeFetch, pin, offering, { corpus, vendors, identitySample, on409, identityRetry, endpoint }) {
309
387
  const artifact = offering.model?.artifact;
310
388
  const claim = vendorClaim(artifact, nodeId, vendors);
311
389
  if (!claim.ok) return { ok: false, unverified: true, reason: `${artifact} is not this node's to claim (vendor namespace)` };
312
390
  // References captured with public prompts prove nothing: a node could have recognised them.
313
391
  const refs = (await store.getFingerprints(artifact)).filter((r) => corpus.usableReference(r.prompt));
314
392
  if (!refs.length) return { ok: false, unverified: true, reason: NO_REFERENCE };
315
- return probeIdentity(safeFetch, pin, offering, sample(refs, identitySample), on409);
393
+ const asked = sample(refs, identitySample);
394
+ if (endpoint.down) {
395
+ // An earlier offering found the endpoint unreachable and nothing has answered since: not asked.
396
+ return { ok: false, matches: 0, total: asked.length, failed: asked.length, answered: 0, unreachable: true,
397
+ failure: 'not asked: the endpoint was unreachable for an earlier offering in this run' };
398
+ }
399
+ return probeIdentity(safeFetch, pin, offering, asked, on409, identityRetry, endpoint);
400
+ }
401
+
402
+ /**
403
+ * Whether the node answered any non-identity request of this offering's run: a 200 with a reply text
404
+ * (a context probe or a capacity request). A 200 without one, such as a proxy's error page, is no answer.
405
+ */
406
+ const answeredOtherwise = (verdict) => (verdict.capacity?.answered ?? 0) > 0
407
+ || (verdict.context?.results ?? []).some((r) => r.answered);
408
+
409
+ /**
410
+ * An identity check whose only non-matching prompts got no reply even after the retries (no refusal,
411
+ * no confirmed mismatch) is not judged: the run ends "not passed: endpoint failed", is recorded, and
412
+ * Stage B runs again soon. The bound: when the node answered other requests in the run (selective),
413
+ * one such run is excused since its last judged run; the next one's failed prompts count as
414
+ * unanswered, and the node is disputed. A node that answered nothing was down, and that never counts.
415
+ * Sets `endpointFailed` (with `reason`) or `failedAgain` on the identity verdict. `before`: selective
416
+ * endpoint-failed runs recorded since the last judged run, counted once at the start of this run, so
417
+ * that two offerings failing in one run are one run.
418
+ */
419
+ async function endpointFailedOf(store, nodeId, verdict, before) {
420
+ const id = verdict.identity;
421
+ if (id.ok || !id.failed || id.unanswered || id.mismatched || id.unverified || id.moved) return;
422
+ const selective = id.answered > 0 || answeredOtherwise(verdict);
423
+ const what = `${id.failed} of ${id.total} identity prompts got no reply, even after retries (last: ${id.failure})`;
424
+ if (selective && before >= MAX_FAILED_RUNS) {
425
+ id.failedAgain = true;
426
+ id.unanswered = id.failed;
427
+ await store.recordProbe(nodeId, verdict.offering_id, 'B', STAGE_B_FAILED, false,
428
+ `${what}, while the node answered other requests, again since its last judged run (${before} such run excused): counted as unanswered`);
429
+ return;
430
+ }
431
+ id.endpointFailed = true;
432
+ id.reason = `endpoint failed: ${what}`;
433
+ await store.recordProbe(nodeId, verdict.offering_id, 'B', selective ? STAGE_B_FAILED : STAGE_B_UNREACHABLE, false,
434
+ selective
435
+ ? `${what}, while the node answered other requests: not passed and not judged; Stage B runs again soon, and the next such run before a judged one counts them as unanswered`
436
+ : `${what}, and the node answered nothing in the run: not passed and not judged; Stage B runs again soon`);
316
437
  }
317
438
 
318
439
  /**
@@ -326,7 +447,7 @@ async function identityOf(store, nodeId, safeFetch, pin, offering, { corpus, ven
326
447
  */
327
448
  export async function runStageB(store, nodeId, card, {
328
449
  safeFetch, capacity = {}, corpus = DEV_CORPUS, vendors = vendorTable(), signed = true, identitySample = IDENTITY_SAMPLE,
329
- revisionMoved = null, maxExcused409 = MAX_EXCUSED_409,
450
+ revisionMoved = null, maxExcused409 = MAX_EXCUSED_409, identityRetry = IDENTITY_RETRY,
330
451
  } = {}) {
331
452
  // The card the run pins: the one held, until a refusal beyond the bound re-pins the fetched one.
332
453
  const pin = { card };
@@ -340,29 +461,48 @@ export async function runStageB(store, nodeId, card, {
340
461
  return { ok: false, identityFailed: false, reason: NO_TESTED_OFFERINGS, verdicts: [], untested };
341
462
  }
342
463
  const verdicts = [];
464
+ // Selective endpoint-failed runs since the last judged one, counted before this run records any.
465
+ const failedRunsBefore = await store.countProbes(nodeId, STAGE_B_FAILED, (await store.getSchedule(nodeId, 'B'))?.last_at ?? '');
343
466
  // The offering as the pinned card lists it now (a re-pin replaces the card mid-run).
344
467
  const pinned = (o) => pin.card.offerings.find((p) => p.offering_id === o.offering_id) ?? o;
468
+ // Shared by the run's offerings (one endpoint): set when an ask found it unreachable, cleared by any answer.
469
+ const endpoint = { down: false };
470
+
471
+ // First every offering's identity prompts, then the heavier probes: the run's own load (context
472
+ // probes, capacity ramps) must not rate-limit a later offering's identity asks.
345
473
  for (const listed of card.offerings) {
346
474
  if (!testable(listed)) continue;
347
- let offering = pinned(listed);
475
+ const offering = pinned(listed);
348
476
  const verdict = { offering_id: offering.offering_id, artifact: offering.model?.artifact ?? null, identity: null, context: null, capacity: null };
349
477
 
350
- verdict.identity = await identityOf(store, nodeId, safeFetch, pin, offering, { corpus, vendors, identitySample, on409 });
478
+ verdict.identity = await identityOf(store, nodeId, safeFetch, pin, offering, { corpus, vendors, identitySample, on409, identityRetry, endpoint });
351
479
  if (verdict.identity.stale) {
352
480
  // The card's revision really moved (an excused 409, recorded). Abort without judging: the caller retries.
353
481
  return { ok: false, identityFailed: false, stale: true, verdicts: [...verdicts, verdict], untested };
354
482
  }
355
- const { matches, total, refused, repinned, refused_repinned: refusedRepinned } = verdict.identity;
483
+ const { matches, total, refused, repinned, refused_repinned: refusedRepinned, failed, failure } = verdict.identity;
356
484
  await store.recordProbe(nodeId, offering.offering_id, 'B', 'identity', verdict.identity.ok,
357
485
  verdict.identity.unverified ? `identity unverified: ${verdict.identity.reason}`
358
486
  : verdict.identity.moved ? `not judged: ${verdict.identity.reason}`
359
487
  : `${matches}/${total} reference matches${refused ? `; ${refused} replies refused with 409, the current card revision pinned` : ''}`
488
+ + (failed ? `; ${failed} prompts got no reply, even after retries (last: ${failure})` : '')
360
489
  + (repinned ? `; ${repinned}${refusedRepinned ? `, then ${refusedRepinned} refusals with it pinned, counted as replies that do not match` : ''}` : ''));
361
490
  if (verdict.identity.moved) {
362
491
  // Beyond the bound, and the claimed model changed: not passed, and nothing more is sent.
363
492
  return { ok: false, identityFailed: false, reason: `${offering.offering_id}: ${verdict.identity.reason}`, verdicts: [...verdicts, verdict], untested };
364
493
  }
365
- offering = pinned(offering);
494
+ verdicts.push(verdict);
495
+ }
496
+
497
+ for (const verdict of verdicts) {
498
+ let offering = pinned({ offering_id: verdict.offering_id });
499
+ if (endpoint.down) {
500
+ // The endpoint was unreachable when last asked: nothing more is sent (a context probe can wait
501
+ // up to an hour on a large window), and the run ends with what it has.
502
+ verdict.skipped = 'endpoint unreachable';
503
+ await endpointFailedOf(store, nodeId, verdict, failedRunsBefore);
504
+ continue;
505
+ }
366
506
 
367
507
  verdict.context = await probeContext(safeFetch, pin.card, offering, corpus);
368
508
  await store.recordProbe(nodeId, offering.offering_id, 'B', 'context', verdict.context.ok,
@@ -377,8 +517,8 @@ export async function runStageB(store, nodeId, card, {
377
517
  // A failed ramp on a card that has since moved (the model dropped or changed during the run)
378
518
  // is not judged, by the same rule and bound as a 409.
379
519
  const what = await on409(offering, 'capacity failure');
380
- if (what.kind === 'stale') return { ok: false, identityFailed: false, stale: true, verdicts: [...verdicts, verdict], untested };
381
- if (what.kind === 'moved') return { ok: false, identityFailed: false, reason: `${offering.offering_id}: ${what.reason}`, verdicts: [...verdicts, verdict], untested };
520
+ if (what.kind === 'stale') return { ok: false, identityFailed: false, stale: true, verdicts, untested };
521
+ if (what.kind === 'moved') return { ok: false, identityFailed: false, reason: `${offering.offering_id}: ${what.reason}`, verdicts, untested };
382
522
  // Beyond the bound, same model: the ramp once more with the fetched card pinned, and that one counts.
383
523
  if (what.kind === 'repin') { offering = what.offering; verdict.capacity = await probeCapacity(safeFetch, pin.card, offering, corpus, capacity); }
384
524
  }
@@ -387,17 +527,21 @@ export async function runStageB(store, nodeId, card, {
387
527
  await store.setObservation(nodeId, offering.offering_id, 'ttft_ms', verdict.capacity.ttft_ms);
388
528
  await store.setObservation(nodeId, offering.offering_id, 'tps', verdict.capacity.tps);
389
529
  }
390
-
391
- verdicts.push(verdict);
530
+ // Only now: whether the node answered the run's other requests decides the endpoint-failure bound.
531
+ await endpointFailedOf(store, nodeId, verdict, failedRunsBefore);
392
532
  }
393
533
 
394
- const identityFailed = verdicts.some((v) => !v.identity.ok && !v.identity.unverified);
534
+ const identityFailed = verdicts.some(identityMismatch);
395
535
  const unverified = verdicts.filter((v) => v.identity.unverified);
396
- const capacityFailed = verdicts.filter((v) => !v.capacity?.ok);
536
+ const endpointFailed = verdicts.filter((v) => v.identity.endpointFailed);
537
+ const capacityFailed = verdicts.filter((v) => !v.skipped && !v.capacity?.ok);
397
538
  const reasons = [
398
539
  ...unverified.map((v) => `${v.offering_id}: identity unverified (${v.identity.reason})`),
540
+ ...endpointFailed.map((v) => `${v.offering_id}: identity not judged (${v.identity.reason})`),
399
541
  ...capacityFailed.map((v) => `${v.offering_id}: capacity ramp failed`),
400
542
  ];
401
543
  const ok = !identityFailed && reasons.length === 0;
402
- return { ok, identityFailed, ...(ok || identityFailed ? {} : { reason: reasons.join('; ') }), verdicts, untested };
544
+ // `endpointFailed`: not judged (the scheduler retries soon and keeps the last judged run's time).
545
+ return { ok, identityFailed, ...(!identityFailed && endpointFailed.length ? { endpointFailed: true } : {}),
546
+ ...(ok || identityFailed ? {} : { reason: reasons.join('; ') }), verdicts, untested };
403
547
  }
@@ -655,7 +655,7 @@
655
655
  <p class="sub">Listing is open; tiers are earned. The registry runs an automated admission battery against your live endpoints — no paperwork, no gatekeepers, no exceptions. Every verdict is recorded and visible in your node's listing history.</p>
656
656
  <div class="panel pad" style="max-width:56rem">
657
657
  <div class="stage"><span class="k">STAGE A</span><span><b>Conformance</b> — gate to <span class="chip t-community">COMMUNITY</span>, minutes. Health endpoint live; card valid; models list agrees with the card; one blind invocation returns proper usage accounting; a proprietary artefact (<code>urn:proprietary:{vendor}:…</code>) only from that vendor's own namespace, so name open-weight models by their public record (<code>hf:</code>, <code>ollama:</code>). Runs when you verify your registration, on every new card revision, and again at least every 6 hours on the registry's own timer.</span></div>
658
- <div class="stage"><span class="k">STAGE B</span><span><b>Substance</b> — gate to <span class="chip t-verified">VERIFIED</span>, hours. The registry chooses when it runs; nobody can ask for it. <b>Identity fingerprinting:</b> prompts from a private set, at temperature 0, compared with reference answers the registry captured from a deployment of the same weights it trusts. With no reference for your model's artefact, identity is unverified and the node stays at community. A confirmed mismatch marks the node <i>disputed</i> and delists it; registering again does not end a dispute, only a resolution the registry records after review. The exception is a first mismatch: when every prompt got a reply, the run ends <i>identity inconclusive</i> (not passed, not disputed, and a verified node returns to community), even if no reply matched, because exact replies can differ between processors and engine versions. Stage B then waits until the registry has captured the references again or reviewed the case, and a second mismatch disputes. A 409 to a fingerprint prompt stops the run only when your card's revision really changed (then it runs again within the hour, at most 3 times before a run is judged); with the current revision pinned, or beyond those 3, a 409 counts as a reply that does not match. <b>Signed card:</b> the verified tier needs a card whose signature verifies against your JWKS. <b>Card-only listings:</b> if you gave a probe key at registration, probes carrying it are easy to pick out, so the node stays at community until the registry has bought access to your API as an ordinary customer; from then on probes use that access, and the next Stage B can verify the node. <b>Context verification:</b> needle-in-haystack probes at 25/50/90% of the claimed window; overclaims are capped to the verified size, visibly. <b>Capacity ramp:</b> stepped concurrent load; measured TTFT/throughput overrides claims in search results.</span></div>
658
+ <div class="stage"><span class="k">STAGE B</span><span><b>Substance</b> — gate to <span class="chip t-verified">VERIFIED</span>, hours. The registry chooses when it runs; nobody can ask for it. <b>Identity fingerprinting:</b> prompts from a private set, at temperature 0, compared with reference answers the registry captured from a deployment of the same weights it trusts. With no reference for your model's artefact, identity is unverified and the node stays at community. A confirmed mismatch marks the node <i>disputed</i> and delists it; registering again does not end a dispute, only a resolution the registry records after review. The exception is a first mismatch: when every prompt got a reply, the run ends <i>identity inconclusive</i> (not passed, not disputed, and a verified node returns to community), even if no reply matched, because exact replies can differ between processors and engine versions. Stage B then waits until the registry has captured the references again or reviewed the case, and a second mismatch disputes. A 409 to a fingerprint prompt stops the run only when your card's revision really changed (then it runs again within the hour, at most 3 times before a run is judged); with the current revision pinned, or beyond those 3, a 409 counts as a reply that does not match. A 5xx, a 429 (after its Retry-After, or a minute), a 401, 403 or 408, a reply without text, a timeout or a dropped connection is asked again twice; a prompt that still gets nothing is not judged: the run is not passed (a verified node returns to community), nothing is disputed, and Stage B runs again within a day. If your endpoint answers other requests but fails the fingerprint prompts again in the next such run, they count as unanswered and the node is disputed. <b>Signed card:</b> the verified tier needs a card whose signature verifies against your JWKS. <b>Card-only listings:</b> if you gave a probe key at registration, probes carrying it are easy to pick out, so the node stays at community until the registry has bought access to your API as an ordinary customer; from then on probes use that access, and the next Stage B can verify the node. <b>Context verification:</b> needle-in-haystack probes at 25/50/90% of the claimed window; overclaims are capped to the verified size, visibly. <b>Capacity ramp:</b> stepped concurrent load; measured TTFT/throughput overrides claims in search results.</span></div>
659
659
  <div class="stage"><span class="k">STAGE C</span><span><b>Continuous</b> — keeps the tier honest. Liveness sweeps feed a rolling availability score; random blind invocations at unpredictable times, worded like ordinary requests, defeat "benchmark mode". On verified nodes some of them ask an identity prompt, and a reply that is not the reference's brings Stage B within the hour. Sustained liveness failures suspend the listing; blind invocations that keep failing while the node answers its health checks cost it a tier.</span></div>
660
660
  <div class="stage"><span class="k">COVERAGE</span><span><b>What is tested.</b> This registry has tests only for chat offerings (<code>onp.openai.chat/v1</code>). A tier covers only the offerings it could test: speech, embeddings, image or any other offering is listed as <span class="chip untested">UNTESTED</span>, and its tier is capped to <span class="chip t-unverified">UNVERIFIED</span> whatever the node's tier. A node with no chat offering stays unverified, because Stage A has nothing to call.</span></div>
661
661
  </div>
@@ -663,7 +663,7 @@
663
663
  <p class="sub">Everything this registry sends to your endpoints, as the code runs today: how much, how often and what starts it, so you can size your probe allowance. A <i>chat offering</i> is one bound to <code>onp.openai.chat/v1</code>; other offerings get only the health and models checks. Probe calls carry your probe key if you gave one at registration, or, once the registry has bought access to your API as a customer, that access instead; the registry does not pay for calls made with your probe key. Their wording comes from a private set of ordinary requests, the same kind your customers send; it is not published.</p>
664
664
  <div class="panel pad" style="max-width:56rem" id="probe-load-table">
665
665
  <div class="stage"><span class="k">STAGE A</span><span><b>When:</b> when you verify your registration, on each <code>PUT /v0/nodes/{id}/ping</code>, on every new card revision, and at least every 6&nbsp;hours (each gap is random, 4.5 to 6&nbsp;hours); a scheduled run uses the card the registry already holds.<br><b>Sends:</b> 1 GET to your health endpoint, 1 GET to <code>/models</code>, and 1 blind chat completion per chat offering (a short request, at most 32 output tokens): about 4 of each a day.</span></div>
666
- <div class="stage"><span class="k">STAGE B</span><span><b>When:</b> on the registry's schedule, never on request: between 1 and 24&nbsp;hours after your node reaches community; at a random time within 72&nbsp;hours of a change to a chat offering's model, serving, hardware or binding block, a new chat offering, or a change to your API endpoint; within 1&nbsp;hour of a confirmed identity mismatch in a blind call (below), at most once a day; within 1&nbsp;hour after a run stopped because your card's revision changed; again after 7&nbsp;days when a run did not pass; and after a pass at a random time from 1&nbsp;day on, and at most every 91&nbsp;days. That random run is set apart: a run that a change brings does not move it. The registry admin can also run it.<br><b>Sends, per chat offering</b> (up to 20 chat completions, plus one repeat for each identity reply that does not match):
666
+ <div class="stage"><span class="k">STAGE B</span><span><b>When:</b> on the registry's schedule, never on request: between 1 and 24&nbsp;hours after your node reaches community; at a random time within 72&nbsp;hours of a change to a chat offering's model, serving, hardware or binding block, a new chat offering, or a change to your API endpoint; within 1&nbsp;hour of a confirmed identity mismatch in a blind call (below), at most once a day; within 1&nbsp;hour after a run stopped because your card's revision changed; again after 7&nbsp;days when a run did not pass; and after a pass at a random time from 1&nbsp;day on, and at most every 91&nbsp;days. That random run is set apart: a run that a change brings does not move it. The registry admin can also run it.<br><b>Sends, per chat offering</b> (up to 20 chat completions, plus one repeat for each identity reply that does not match, and up to two more asks for each identity prompt that gets a 5xx, a 429, a 401, 403 or 408, no reply text, a timeout or a dropped connection; every offering's identity prompts come first, and an endpoint found unreachable gets nothing more in that run):
667
667
  <br>· <b>Fingerprint battery:</b> 3 prompts drawn at random from the 8 reference prompts the registry holds for your model's artefact, at temperature 0, at most 64 output tokens each. With no reference for the artefact nothing is asked, and the offering cannot be verified.
668
668
  <br>· <b>Calibration:</b> 1 call with about 4,000 characters of text, at most 4 output tokens, to measure your tokenizer.
669
669
  <br>· <b>Context:</b> 3 probes sized at 25, 50 and 90% of the claimed context window, at most 64 output tokens each: about 1.65 times the window in prompt tokens altogether (about 210k tokens for a 128k window).