@opennodes/registry 0.1.55 → 0.1.57

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.55 # web app + API on http://127.0.0.1:4300
7
- ONP_DB=./registry.db npx @opennodes/registry@0.1.55 # persistent SQLite + persistent signing key
8
- ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.55
6
+ npx @opennodes/registry@0.1.57 # web app + API on http://127.0.0.1:4300
7
+ ONP_DB=./registry.db npx @opennodes/registry@0.1.57 # persistent SQLite + persistent signing key
8
+ ONP_DB=postgres://user:pass@host/db npx @opennodes/registry@0.1.57
9
9
  ```
10
10
 
11
11
  What it does:
@@ -29,14 +29,24 @@ What it does:
29
29
  - **Errors:** a misspelt `trust`, `lineage`, `retention` or `no_training` value gets `400 bad-query`, never a wider result.
30
30
  - **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.
31
31
  - **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`).
32
- - **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.
32
+ - **Catalog importers** — OpenRouter, Hugging Face Inference Providers, models.dev, the Ollama library, the AI Horde — so search is useful on day one, with imported listings labeled and claimable by their operators.
33
33
  - **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=`.
34
34
  - **Residency commitments** (`/v0/residency`, `?format=csv`): what each provider officially promises about where prompts, outputs and stored data stay (`processing`, `storage`, `none` or `unstated`; scope; `default`, `opt_in` or `enterprise`), with source and date (ONP-2 §3b, ONP-3 §5d). Each site in `/v0/locations` carries the commitments that cover it, and `residency=processing|storage` filters by them.
35
35
  - **MCP surface** at `/mcp` (including `find_locations` and `find_residency`) and a signed **export feed** for federation.
36
36
  - **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.
37
37
 
38
- Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_TRUSTED_JURISDICTIONS` (trusted pool operators, default `EU,CA`), `ONP_LOCATION=1` (server-location checks; the trusted pool needs them), `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.
38
+ Environment: `PORT`, `ONP_DB`, `ONP_REGISTRY_KEY`, `ONP_ADMIN_TOKEN`, `ONP_TRUSTED_JURISDICTIONS` (trusted pool operators, default `EU,CA`), `ONP_LOCATION=1` (server-location checks; the trusted pool needs them), `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`, `horde` (refreshed every `ONP_REIMPORT_HORDE_MS`, default one hour), 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.
39
39
 
40
40
  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`.
41
41
 
42
+ The AI Horde import (`horde`, or `POST /v0/import/horde` with an admin token) lists the [AI Horde](https://aihorde.net)'s text models as one node, `import.aihorde.text`. The Horde is a free network run by the non-profit Haidra: volunteers run the models on their own machines, and the queue is ordered by kudos, a non-monetary credit for contributed compute.
43
+ - **What the registry reads:** only the public model status (`/api/v2/status/models?type=text&chat=true`, sent with the `Client-Agent` header the Horde asks for) and Haidra's [text model reference](https://github.com/Haidra-Org/AI-Horde-text-model-reference). The reference is AGPL-3.0, so only its facts are used: model names and Hugging Face URLs, not its descriptions. The registry never sends a prompt, and imported listings are never probed. A ping on one answers 409 `imported-listing`.
44
+ - **What gets listed:** only models with online chat workers and a Hugging Face record in the reference. Workers declare the names themselves, and a name without a public record is skipped, not given a made-up artefact.
45
+ - **Pricing and data policy:** each offering is `free` with `retention: logged`. Volunteers can read and keep prompts and outputs, so there is no operator country, the listings stay in the open pool, and the trusted view and sensitive requests never include them.
46
+ - **Lineage:** declared only for a developer's own from-scratch release (`HORDE_FROM_SCRATCH` in `src/importers.js`).
47
+ - **Reported figures:** worker count, queue and ETA are what the Horde reports, shown as `observed.upstream` with `basis: "reported"`. With nothing to list, the node is delisted until workers return.
48
+ - **Calling a model:** people call the models at Haidra's OpenAI-compatible front (`https://oai.aihorde.net/v1`) with their own AI Horde key.
49
+
50
+ ONP has no field yet for two things this listing has to say: that the people running the hardware can read prompts (proposed: `data_policy.statement`), and that queue order follows a credit rather than a price, with a free output allowance (proposed: `free_tier.priority` and `free_tier.max_output_tokens`). The node description says both in words.
51
+
42
52
  Part of [OpenNodes](https://opennodes.io) · [specification](https://github.com/opennodes-io/opennodes/tree/main/spec) · Apache-2.0.
package/bin.js CHANGED
@@ -47,6 +47,9 @@ const registry = await startRegistry({
47
47
  reimport: process.env.ONP_REIMPORT === '1' ? {
48
48
  intervalMs: Number(process.env.ONP_REIMPORT_MS ?? 6 * 3600 * 1000),
49
49
  sources: (process.env.ONP_REIMPORT_SOURCES ?? 'openrouter,huggingface').split(','),
50
+ // `horde` (opt-in: add it to ONP_REIMPORT_SOURCES) refreshes hourly by default; workers come and go fast.
51
+ // Anything unset, unreadable or under a minute falls back to the hour: the Horde is never polled in a loop.
52
+ sourceIntervals: { horde: ((ms) => (Number.isFinite(ms) && ms >= 60_000 ? ms : 3600 * 1000))(Number(process.env.ONP_REIMPORT_HORDE_MS || NaN)) },
50
53
  } : null,
51
54
  });
52
55
  if (process.env.ONP_ALLOW_PRIVATE === '1') console.log('WARNING: SSRF guard disabled (ONP_ALLOW_PRIVATE=1) — dev only');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennodes/registry",
3
- "version": "0.1.55",
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)",
3
+ "version": "0.1.57",
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",
7
7
  "main": "src/server.js",
@@ -43,7 +43,7 @@
43
43
  "access": "public"
44
44
  },
45
45
  "dependencies": {
46
- "@opennodes/core": "0.1.25",
46
+ "@opennodes/core": "0.1.26",
47
47
  "pg": "^8.13.1"
48
48
  }
49
49
  }
package/src/importers.js CHANGED
@@ -1,9 +1,12 @@
1
1
  // DS-IMP-01: seed importers so search is useful before any real registration.
2
2
  // Imported records enter as unverified, unsigned, source='import', and are
3
3
  // excluded from verified tiers until claimed by their operator.
4
+ import { readFileSync } from 'node:fs';
4
5
  import { validateCard } from '@opennodes/core';
5
6
  import { ARTIFACT } from './vendors.js';
6
7
 
8
+ const { version: REGISTRY_VERSION } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
9
+
7
10
  const slug = (s) => String(s).toLowerCase().replace(/[^a-z0-9._-]+/g, '-').replace(/^[^a-z0-9]+/, '').slice(0, 100);
8
11
  const vendorSlug = (s) => slug(s).replace(/[._]/g, '-');
9
12
  /** The value as a string if it is a concrete http(s) URL, else undefined. Templated
@@ -409,6 +412,154 @@ export async function importOpenRouter(store, catalog) {
409
412
  return { providers: 1, offerings: offeringList.length, skipped: [] };
410
413
  }
411
414
 
415
+ /* ------------------------------------------------------------------ AI Horde */
416
+
417
+ // The AI Horde (aihorde.net, run by the non-profit Haidra) is a free network of volunteer GPUs: workers
418
+ // poll a coordinator and run whole models on their own machines, and queue priority follows kudos, a
419
+ // non-monetary credit earned by contributing compute. The registry only reads the public model status
420
+ // and Haidra's model reference; it never sends a prompt there (imports are never probed).
421
+
422
+ /** Text models with at least one online chat worker: the ones the OpenAI-compatible front can serve. */
423
+ export const HORDE_STATUS_URL = 'https://aihorde.net/api/v2/status/models?type=text&chat=true';
424
+ /** Haidra's text model reference (AGPL-3.0): Horde model name -> display name and Hugging Face record (`url`). */
425
+ export const HORDE_TEXT_REFERENCE_URL = 'https://raw.githubusercontent.com/Haidra-Org/AI-Horde-text-model-reference/main/db.json';
426
+ /** Haidra's own OpenAI-compatible front for the Horde (documented in the AI-Horde server README). */
427
+ export const HORDE_OPENAI_BASE = 'https://oai.aihorde.net/v1';
428
+ /** Horde asks every client for `Client-Agent: name:version:contact`. The contact is the project, never a person. */
429
+ export const HORDE_CLIENT_AGENT = `opennodes-registry:${REGISTRY_VERSION}:https://opennodes.io`;
430
+ /** The Horde FAQ (who can read prompts) and the date it and the privacy policy were read for this data policy. */
431
+ export const HORDE_POLICY_SOURCE = 'https://aihorde.net/faq';
432
+ export const HORDE_POLICY_CHECKED = '2026-11-20';
433
+ const HORDE_NODE_ID = 'import.aihorde.text';
434
+ const HORDE_EMPTY = 'AI Horde import: no text model with online chat workers and a public model record';
435
+
436
+ /**
437
+ * Lineage for Horde models, only where it is certain: a Hugging Face repo that is the developer's own
438
+ * from-scratch release (the developer trained the base itself, and any distillation teacher is its own
439
+ * model). A fine-tune, merge, quantization or re-upload under another account matches none of these and
440
+ * stays unknown: a list naming only the base developer would read as clean (ONP-2 §5). Distilled
441
+ * releases (`*-Distill-*`) are excluded even under a listed account.
442
+ */
443
+ export const HORDE_FROM_SCRATCH = Object.freeze([
444
+ [/^Qwen\/Qwen\d/, 'CN'], // Qwen/Qwen3-14B, Qwen/Qwen3.8-Flash-Next
445
+ [/^zai-org\/GLM-/, 'CN'],
446
+ [/^google\/gemma-/, 'US'],
447
+ [/^meta-llama\/(Meta-)?Llama-/, 'US'],
448
+ [/^mistralai\/(Mistral|Ministral|Magistral)-/, 'FR'],
449
+ ]);
450
+
451
+ /** `org/repo` of a Hugging Face model URL, or null. */
452
+ const hfRepo = (url) => {
453
+ const m = /^https:\/\/huggingface\.co\/([A-Za-z0-9][\w.-]*)\/([\w.-]+)\/?$/.exec(String(url ?? '').trim());
454
+ return m ? `${m[1]}/${m[2]}` : null;
455
+ };
456
+
457
+ /** The developer country for a from-scratch release, else null (unknown). */
458
+ export function hordeLineage(repo) {
459
+ if (!repo || /distill/i.test(repo)) return null;
460
+ return HORDE_FROM_SCRATCH.find(([re]) => re.test(repo))?.[1] ?? null;
461
+ }
462
+
463
+ /** Horde chat feature declarations -> ONP `serving.supports` (each declared by at least one worker). */
464
+ const HORDE_FEATURES = {
465
+ tools: 'tool_calls', json_object: 'json_mode', json_schema: 'structured_outputs',
466
+ vision: 'vision', reasoning_effort: 'reasoning',
467
+ };
468
+
469
+ /**
470
+ * Import the AI Horde's text models as one synthetic node (`import.aihorde.text`).
471
+ * `status` is GET /v2/status/models?type=text&chat=true; `reference` is Haidra's text model reference
472
+ * (db.json). An offering is made only for a model with online chat workers and a Hugging Face record in
473
+ * the reference: model names are declared by the workers, and an open-weight model is named by its public
474
+ * record (ONP-2 §5), so a name with no record is skipped, never given a made-up artifact. Worker count and
475
+ * queue go into the store as the `upstream` observation (reported by the Horde, not measured here).
476
+ * With nothing to list, the node is delisted rather than left showing workers that have gone.
477
+ */
478
+ export async function importHorde(store, status, reference = {}) {
479
+ if (!Array.isArray(status)) return { providers: 0, offerings: 0, skipped: ['status is not a list'] };
480
+ const reportedAt = new Date().toISOString();
481
+ const offeringList = [];
482
+ const upstream = new Map();
483
+ const skipped = [];
484
+ for (const m of status) {
485
+ const name = typeof m?.name === 'string' ? m.name : null;
486
+ const workers = Number(m?.chat?.workers ?? 0);
487
+ if (!name || m.type !== 'text' || !(workers >= 1)) continue;
488
+ const ref = reference?.[name];
489
+ const repo = hfRepo(ref?.url);
490
+ if (!repo || !ARTIFACT.test(`hf:${repo}`)) { skipped.push(`${name}: no public model record`); continue; }
491
+ const features = Array.isArray(m.chat.features) ? m.chat.features : [];
492
+ const vision = features.includes('vision');
493
+ const supports = ['streaming', ...new Set(features.map((f) => HORDE_FEATURES[f]).filter(Boolean))];
494
+ const lineage = hordeLineage(repo);
495
+ let offeringId = slug(name.replace(/\//g, '-')) || 'model';
496
+ if (offeringList.some((o) => o.offering_id === offeringId)) offeringId = slug(`${offeringId}-${offeringList.length}`);
497
+ offeringList.push({
498
+ offering_id: offeringId,
499
+ modality: vision ? 'multimodal' : 'text',
500
+ modalities: { input: vision ? ['text', 'image'] : ['text'], output: ['text'] },
501
+ model: {
502
+ name: ref.display_name || ref.model_name || name,
503
+ family: vendorSlug(repo.split('/')[0]),
504
+ artifact: `hf:${repo}`,
505
+ ...(lineage ? { lineage_origins: [lineage] } : {}),
506
+ // No `description`: the reference is AGPL-3.0, so only its facts (names, record URL) are used.
507
+ },
508
+ serving: {
509
+ supports,
510
+ ...(Number.isInteger(m.chat.max_context_length) && m.chat.max_context_length > 0 ? { context_window: m.chat.max_context_length } : {}),
511
+ ...(Number.isInteger(m.chat.max_length) && m.chat.max_length > 0 ? { max_output_tokens: m.chat.max_length } : {}),
512
+ },
513
+ binding: { profile: 'onp.openai.chat/v1', model_id: name },
514
+ // Free; queue order by kudos and the free output allowance have no ONP field yet (see the README).
515
+ pricing: { currency: 'USD', input_per_mtok: 0, output_per_mtok: 0, schemes: ['free'] },
516
+ // Volunteers run the models on their own machines and can read and keep prompts and outputs.
517
+ // Nobody can promise anything about training for them, so training_on_inputs stays unstated.
518
+ data_policy: { retention: 'logged', source: HORDE_POLICY_SOURCE, checked: HORDE_POLICY_CHECKED },
519
+ });
520
+ upstream.set(offeringId, {
521
+ source: 'aihorde', basis: 'reported', reported_at: reportedAt, workers,
522
+ queued_tokens: Number(m.queued ?? 0), jobs: Number(m.jobs ?? 0), eta_s: Number(m.eta ?? 0),
523
+ });
524
+ }
525
+
526
+ const node = await store.getNode(HORDE_NODE_ID);
527
+ if (!offeringList.length) {
528
+ if (node?.state === 'indexed') await store.setState(HORDE_NODE_ID, 'delisted', HORDE_EMPTY);
529
+ return { providers: 0, offerings: 0, skipped: [...skipped, 'nothing to list'] };
530
+ }
531
+ const card = {
532
+ onp: '0.1',
533
+ revision: reportedAt,
534
+ node: {
535
+ id: HORDE_NODE_ID,
536
+ name: 'AI Horde (volunteer GPUs)',
537
+ description: 'Imported from the AI Horde public model status (aihorde.net), run by the non-profit Haidra. '
538
+ + 'Free: volunteers run the models on their own machines, and the queue is ordered by kudos, so requests '
539
+ + 'with the anonymous key 0000000000 wait longest; a free registered key gets better priority. '
540
+ + 'Volunteer workers can technically read and keep prompts and outputs: never send personal data. '
541
+ + 'Worker counts and queues are a snapshot reported by the Horde. Call it with your own AI Horde key '
542
+ + 'at the OpenAI-compatible front. Terms: https://aihorde.net/terms. Privacy: https://aihorde.net/privacy. '
543
+ + 'FAQ: https://aihorde.net/faq. Metadata only, unclaimed by the operator.',
544
+ operator: { name: 'AI Horde (Haidra, volunteer workers)', url: 'https://aihorde.net' },
545
+ },
546
+ endpoints: { openai: HORDE_OPENAI_BASE, health: 'https://aihorde.net/api/v2/status/heartbeat', docs: 'https://oai.aihorde.net/docs' },
547
+ offerings: offeringList,
548
+ payment: { schemes: [{ scheme: 'free' }] },
549
+ };
550
+ const err = await saveImportedCard(store, HORDE_NODE_ID, 'https://aihorde.net', 'import:aihorde', card);
551
+ if (err) return { providers: 0, offerings: 0, skipped: [...skipped, err] };
552
+ // Back after an empty snapshot; a delisting by anyone else stays.
553
+ if (node?.state === 'delisted' && (await store.transitionsFor(HORDE_NODE_ID)).at(-1)?.reason === HORDE_EMPTY) {
554
+ await store.setState(HORDE_NODE_ID, 'indexed', 'AI Horde import: chat workers back online');
555
+ }
556
+ for (const [offeringId, value] of upstream) await store.setObservation(HORDE_NODE_ID, offeringId, 'upstream', value);
557
+ return {
558
+ providers: 1, offerings: offeringList.length, skipped,
559
+ workers: [...upstream.values()].reduce((n, u) => n + u.workers, 0),
560
+ };
561
+ }
562
+
412
563
  /* ------------------------------------------------------------------ locations (ONP-2 §3a) */
413
564
 
414
565
  /** Save a listing-only card: like saveImportedCard, but without invocation endpoints. */
package/src/reimport.js CHANGED
@@ -3,24 +3,51 @@
3
3
  import {
4
4
  importModelsDev, importHuggingFace, importOpenRouter,
5
5
  importOllamaLibrary, parseOllamaLibrary,
6
- importOpenRouterProviders, fetchOpenRouterEndpoints,
6
+ importOpenRouterProviders, fetchOpenRouterEndpoints, importHorde,
7
7
  HF_ROUTER_URL, HF_HUB_URL, OPENROUTER_URL, OPENROUTER_PROVIDERS_URL, OLLAMA_LIBRARY_URL,
8
+ HORDE_STATUS_URL, HORDE_TEXT_REFERENCE_URL, HORDE_CLIENT_AGENT,
8
9
  } from './importers.js';
9
10
 
10
11
  export const MODELS_DEV_URL = 'https://models.dev/api.json';
11
12
 
13
+ /**
14
+ * Sources that go stale faster than the catalog interval. AI Horde workers come and go within minutes,
15
+ * so its snapshot is refreshed hourly (one status read an hour is far inside the Horde's limits).
16
+ */
17
+ export const SOURCE_INTERVALS = Object.freeze({ horde: 3600 * 1000 });
18
+
19
+ /** A source's interval: its own when it is a number of at least a minute, never above `intervalMs`. */
20
+ const intervalOf = (s, intervalMs, sourceIntervals) => {
21
+ const own = sourceIntervals?.[s];
22
+ return Math.min(Number.isFinite(own) && own >= 60_000 ? own : intervalMs, intervalMs);
23
+ };
24
+
25
+ /** The sources due at `now`: never run, or last run at least their interval ago. */
26
+ export function dueSources(sources, lastRun, now, intervalMs, sourceIntervals = SOURCE_INTERVALS) {
27
+ return sources.filter((s) => !lastRun.has(s) || now - lastRun.get(s) >= intervalOf(s, intervalMs, sourceIntervals));
28
+ }
29
+
12
30
  export function startReimport(store, {
13
31
  safeFetch,
14
32
  intervalMs = 6 * 3600 * 1000, // the HF re-test cadence
15
33
  sources = ['openrouter', 'huggingface'],
34
+ sourceIntervals = SOURCE_INTERVALS,
16
35
  onCycle = null,
17
36
  } = {}) {
18
37
  let stopped = false;
38
+ const lastRun = new Map();
19
39
  const json = async (url, t = 120_000) => (await safeFetch(url, {}, t)).json();
40
+ // A refused or failed read must never look like an empty catalog: that would delist the Horde node.
41
+ const jsonOk = async (url, opts, t = 60_000) => {
42
+ const res = await safeFetch(url, opts, t);
43
+ if (!res.ok) throw new Error(`${new URL(url).host} answered ${res.status}`);
44
+ return res.json();
45
+ };
20
46
 
21
- async function cycle() {
47
+ async function cycle(only = sources) {
22
48
  const results = {};
23
- for (const source of sources) {
49
+ for (const source of only) {
50
+ lastRun.set(source, Date.now());
24
51
  try {
25
52
  if (source === 'openrouter') {
26
53
  results[source] = await importOpenRouter(store, await json(OPENROUTER_URL));
@@ -40,6 +67,14 @@ export function startReimport(store, {
40
67
  } else if (source === 'ollama') {
41
68
  const html = await (await safeFetch(OLLAMA_LIBRARY_URL, {}, 120_000)).text();
42
69
  results[source] = await importOllamaLibrary(store, parseOllamaLibrary(html));
70
+ } else if (source === 'horde') {
71
+ // Public status only (with the Client-Agent the Horde asks of every client); no prompt is sent.
72
+ const status = await jsonOk(HORDE_STATUS_URL, { headers: { 'client-agent': HORDE_CLIENT_AGENT } });
73
+ // The reference gives each model its public record. Without it nothing can be listed honestly,
74
+ // so a failed read keeps the previous snapshot instead of emptying it.
75
+ const reference = await jsonOk(HORDE_TEXT_REFERENCE_URL, {}, 120_000);
76
+ if (!reference || typeof reference !== 'object' || !Object.keys(reference).length) throw new Error('empty AI Horde model reference');
77
+ results[source] = await importHorde(store, status, reference);
43
78
  } else {
44
79
  results[source] = { error: `unknown source: ${source}` };
45
80
  }
@@ -51,10 +86,13 @@ export function startReimport(store, {
51
86
  return results;
52
87
  }
53
88
 
89
+ // Wake at the shortest interval among the sources and run only the ones that are due.
90
+ const tick = Math.min(intervalMs, ...sources.map((s) => intervalOf(s, intervalMs, sourceIntervals)));
54
91
  const loop = async () => {
55
92
  if (stopped) return;
56
- await cycle().catch(() => {});
57
- if (!stopped) setTimeout(loop, intervalMs).unref?.();
93
+ const due = dueSources(sources, lastRun, Date.now(), intervalMs, sourceIntervals);
94
+ if (due.length) await cycle(due).catch(() => {});
95
+ if (!stopped) setTimeout(loop, tick).unref?.();
58
96
  };
59
97
  setTimeout(loop, 2000).unref?.(); // first cycle shortly after boot
60
98
 
package/src/schedule.js CHANGED
@@ -1,8 +1,11 @@
1
1
  // Re-verification on the registry's own timetable (ONP-3 §4a):
2
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.
3
+ // - Stage B for a node that reaches `community`, at a random time within a day; again at a random time
4
+ // within 3 days of any change to a tested offering's model, serving, hardware or binding block (or a
5
+ // new tested offering), within the hour after a confirmed mismatch in a blind identity check
6
+ // (stagec.js), and on a random timer, 1 to 91 days after a pass, otherwise. That timer is its own
7
+ // row (TIMER) and only a run it set off draws it again: a run set off by a change does not, so an
8
+ // operator who changes the card every day cannot keep pushing the random run away.
6
9
  // The operator does not choose when Stage B runs, and no API says when it will: the next run time
7
10
  // lives only in the private `schedule` table. The server supplies the stage runs (and their effect
8
11
  // on the tier); this module only decides when they are due.
@@ -21,7 +24,9 @@ export const SCHEDULE_DEFAULTS = Object.freeze({
21
24
  stageBIntervalMs: 91 * DAY,
22
25
  stageBRetryMs: 7 * DAY, // after a Stage B that did not pass (and was not a dispute); 85-100% of it
23
26
  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
27
+ // After a change to a tested offering (or a new one): anywhere in three days, so that an operator who
28
+ // changes the card cannot know the hour of the run that follows (ONP-3 §4a, re-verification).
29
+ stageBChangeMs: [0, 72 * HOUR],
25
30
  // After a confirmed mismatch in a blind identity check (stagec.js). The upper end leaves room for
26
31
  // the tick (at most 1.5 x tickMs late), so the run starts within the hour.
27
32
  stageBIdentityMs: [0, 50 * 60_000],
@@ -34,6 +39,12 @@ export const SCHEDULE_DEFAULTS = Object.freeze({
34
39
  /** States whose nodes get Stage A on schedule, and the subset that gets Stage B. */
35
40
  export const STAGE_A_STATES = ['indexed', 'community', 'verified', 'attested'];
36
41
  export const STAGE_B_STATES = ['community', 'verified', 'attested'];
42
+ /**
43
+ * The private schedule row holding a node's random Stage B timer (drawn after a pass). Kept apart
44
+ * from row 'B', whose next_at is the soonest of everything due, so that runs set off by a change or
45
+ * a light-check mismatch never redraw it.
46
+ */
47
+ export const TIMER = 'B:timer';
37
48
 
38
49
  const iso = (ms) => new Date(ms).toISOString();
39
50
  const sha256 = (s) => createHash('sha256').update(s).digest('hex');
@@ -105,8 +116,17 @@ export function makePlanner(store, options = {}) {
105
116
  await store.setSchedule(nodeId, 'B', { ...prev, next_at: iso(now + between(o.staleRetryMs, random)), failures: (prev.failures ?? 0) + 1 });
106
117
  return;
107
118
  }
119
+ // The random timer is drawn again only when it is due or missing: a run that a change or a
120
+ // light-check mismatch set off leaves it where it was, so it still fires (ONP-3 §4a).
121
+ let timer = await store.getSchedule(nodeId, TIMER);
122
+ const timerAt = timer?.next_at ? Date.parse(timer.next_at) : null;
123
+ if (result.ok && !result.identityFailed && (timerAt === null || timerAt <= now)) {
124
+ timer = { last_at: iso(now), next_at: iso(now + between([o.stageBMinGapMs, o.stageBIntervalMs], random)) };
125
+ await store.setSchedule(nodeId, TIMER, timer);
126
+ }
127
+ const pending = timer?.next_at && Date.parse(timer.next_at) > now ? Date.parse(timer.next_at) : Infinity;
108
128
  const next = result.identityFailed ? null
109
- : iso(now + (result.ok ? between([o.stageBMinGapMs, o.stageBIntervalMs], random) : o.stageBRetryMs * between([0.85, 1], random)));
129
+ : iso(Math.min(pending, result.ok ? Infinity : now + o.stageBRetryMs * between([0.85, 1], random)));
110
130
  await store.setSchedule(nodeId, 'B', {
111
131
  last_at: iso(now), next_at: next, ok: result.ok, revision: card?.revision ?? null,
112
132
  digest: servingDigest(card), pending_digest: null, failures: result.ok ? 0 : (prev.failures ?? 0) + 1,
@@ -157,7 +177,8 @@ export function startScheduler(store, planner, { stageA, stageB, random = Math.r
157
177
  }
158
178
  const digest = servingDigest(fresh);
159
179
  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.
180
+ // A tested offering's model, serving, hardware or binding changed since the last Stage B, or a
181
+ // tested offering is new: run it at a random time in the change window.
161
182
  nextAt = Math.min(nextAt, now + between(o.stageBChangeMs, random));
162
183
  b = { ...b, pending_digest: digest, next_at: iso(nextAt) };
163
184
  await store.setSchedule(node.id, 'B', b);
package/src/search.js CHANGED
@@ -195,6 +195,9 @@ async function buildOfferings(store) {
195
195
  probes: checks.length,
196
196
  ttft_ms: obs.ttft_ms ?? null,
197
197
  tps: obs.tps ?? null,
198
+ // What an imported network reports about itself (AI Horde: workers, queue), basis `reported`:
199
+ // the upstream's own figures at `reported_at`, never measured by this registry.
200
+ ...(obs.upstream ? { upstream: obs.upstream } : {}),
198
201
  availability,
199
202
  },
200
203
  endpoints: card.endpoints,
package/src/server.js CHANGED
@@ -27,8 +27,9 @@ import { checkNodeLocation, declaredOrigins } from './location.js';
27
27
  import {
28
28
  importModelsDev, importHuggingFace, importOpenRouter,
29
29
  importOllamaLibrary, parseOllamaLibrary,
30
- importOpenRouterProviders, fetchOpenRouterEndpoints, importLocationSeed,
30
+ importOpenRouterProviders, fetchOpenRouterEndpoints, importLocationSeed, importHorde,
31
31
  HF_ROUTER_URL, HF_HUB_URL, OPENROUTER_URL, OPENROUTER_PROVIDERS_URL, OLLAMA_LIBRARY_URL,
32
+ HORDE_STATUS_URL, HORDE_TEXT_REFERENCE_URL, HORDE_CLIENT_AGENT,
32
33
  } from './importers.js';
33
34
  import { locationRoutes, loadLocationSeeds, seedPlacements, seedNodeSites, nodeServes } from './locations.js';
34
35
  import { makeRequestCounter, nodeIdsIn } from './counts.js';
@@ -294,11 +295,13 @@ export async function startRegistry({
294
295
  * card, capacity) keeps `community` or demotes `verified` to `community`. Returns null when a
295
296
  * run is already in progress for the node.
296
297
  */
297
- async function stageBFor(nodeId) {
298
+ async function stageBFor(nodeId, { refresh = false } = {}) {
298
299
  if (stageBRunning.has(nodeId)) return null;
299
300
  stageBRunning.add(nodeId);
300
301
  try {
301
- await refreshCard(nodeId);
302
+ // Scheduled runs go out on the card already held: a card fetch just before the battery would
303
+ // tell the operator that Stage B is starting (ONP-3 §4a.9). A 409 still re-fetches (below).
304
+ if (refresh) await refreshCard(nodeId);
302
305
  const card = await store.latestCard(nodeId);
303
306
  const revision = await store.latestRevision(nodeId);
304
307
  // Decided before anything is sent: what counts is the key this run's probes carry.
@@ -421,6 +424,9 @@ export async function startRegistry({
421
424
  if (!registerLimiter(clientOf(req))) return problem(res, 429, 'rate-limited', 'too many refresh requests from this address; try again later');
422
425
  const node = await store.getNode(params.id);
423
426
  if (!node) return problem(res, 404, 'unknown-node', params.id);
427
+ // A ping runs Stage A, which calls the endpoint. Imports are never probed: some upstreams (the AI
428
+ // Horde) answer requests without a key, so a public ping must not become traffic to them.
429
+ if (node.source === 'import') return problem(res, 409, 'imported-listing', `${node.id} is an imported catalog listing; the registry does not probe it`);
424
430
  try {
425
431
  const { card } = await indexCard(params.id, node.card_url);
426
432
  if (location) relocateIfStale(params.id, card).catch(() => {}); // background: a new API host is checked again now
@@ -442,7 +448,7 @@ export async function startRegistry({
442
448
  if (!LISTED.includes(node.state)) {
443
449
  return problem(res, 409, 'wrong-state', `Stage B requires community tier, node is ${node.state}`);
444
450
  }
445
- const stageB = await stageBFor(params.id);
451
+ const stageB = await stageBFor(params.id, { refresh: true }); // the admin's request: the latest card
446
452
  if (!stageB) return problem(res, 409, 'stage-b-running', `Stage B is already running for ${params.id}`);
447
453
  if (stageB.stale) {
448
454
  return problem(res, 409, 'stale-card', 'the node changed its card revision during the battery; retry');
@@ -778,6 +784,21 @@ export async function startRegistry({
778
784
  sendJson(res, 200, await importOpenRouter(store, catalog));
779
785
  }],
780
786
 
787
+ // AI Horde importer (admin): inline {status, reference}, or read the live public status (with the
788
+ // Client-Agent the Horde asks for) and Haidra's text model reference. Nothing is sent to a worker.
789
+ ['POST', '/v0/import/horde', async (req, res) => {
790
+ if (!adminOk(req, res)) return;
791
+ const body = await readJson(req, 20_000_000);
792
+ const read = async (url, opts) => {
793
+ const r = await safeFetch(url, opts, 60_000);
794
+ if (!r.ok) throw new Error(`${new URL(url).host} answered ${r.status}`);
795
+ return r.json();
796
+ };
797
+ const status = body.status ?? await read(HORDE_STATUS_URL, { headers: { 'client-agent': HORDE_CLIENT_AGENT } });
798
+ const reference = body.reference ?? await read(HORDE_TEXT_REFERENCE_URL, {});
799
+ sendJson(res, 200, await importHorde(store, status, reference));
800
+ }],
801
+
781
802
  // OpenRouter per-provider importer with declared locations (admin): inline
782
803
  // {providers, models, endpoints: {modelId: [...]}}, or fetch the live APIs (one call per model).
783
804
  ['POST', '/v0/import/openrouter-providers', async (req, res) => {
@@ -896,7 +917,9 @@ export async function startRegistry({
896
917
  // without one (ONP_SCHEDULE=0) Stage B runs only on admin request, so the mismatch is only recorded.
897
918
  const requestStageB = schedule ? (nodeId, card) => planner.stageBSoon(nodeId, card) : null;
898
919
  const stageCHandle = stageC ? startStageC(store, { safeFetch, fetchFor: authFetch, refreshCard, requestStageB, corpus, ...stageC }) : null;
899
- const scheduleHandle = schedule ? startScheduler(store, planner, { stageA: (id) => stageAFor(id, { refresh: true }), stageB: (id) => stageBFor(id) }) : null;
920
+ // Scheduled runs use the card already held when Stage C re-fetches cards on its own timer
921
+ // (stagec.js cardSweep), so no card fetch announces them; without Stage C, Stage A re-fetches.
922
+ const scheduleHandle = schedule ? startScheduler(store, planner, { stageA: (id) => stageAFor(id, { refresh: !stageCHandle }), stageB: (id) => stageBFor(id) }) : null;
900
923
  const reimportHandle = reimport ? startReimport(store, { safeFetch, ...reimport }) : null;
901
924
  const locationHandle = location ? startLocationSweep() : null;
902
925
  const actualPort = await listen(app, port, host);
@@ -909,6 +932,7 @@ export async function startRegistry({
909
932
  scheduleTick: scheduleHandle ? () => scheduleHandle.tick() : null,
910
933
  /** Run one Stage C blind sweep, or one look for due follow-ups, now (tests); null when Stage C is off. */
911
934
  blindSweep: stageCHandle ? () => stageCHandle.blindSweep() : null,
935
+ cardSweep: stageCHandle ? () => stageCHandle.cardSweep() : null,
912
936
  followUpTick: stageCHandle ? () => stageCHandle.followUpTick() : null,
913
937
  close: async () => {
914
938
  stageCHandle?.stop();
package/src/stageb.js CHANGED
@@ -89,7 +89,10 @@ export const STAGE_B_409 = 'identity-409';
89
89
  * (the card the run holds is stale now, so even an honest node refuses what follows).
90
90
  */
91
91
  function makeOn409(store, nodeId, card, { revisionMoved, maxExcused409 }) {
92
- return async (offering) => {
92
+ // `status`: the reply that sent the registry to the card. Since rev. 14 scheduled runs go out on
93
+ // the card already held, so a 404 for a model the node has just dropped gets the same rule as a
94
+ // 409: re-fetched after the reply, excused only if the revision really moved, within the bound.
95
+ return async (offering, status = 409) => {
93
96
  const fresh = revisionMoved ? await revisionMoved() : null;
94
97
  if (!fresh) return { kind: 'refused' };
95
98
  const since = (await store.getSchedule(nodeId, 'B'))?.last_at ?? '';
@@ -98,7 +101,7 @@ function makeOn409(store, nodeId, card, { revisionMoved, maxExcused409 }) {
98
101
  return { kind: 'moved', reason: `the card revision moved again during Stage B, after ${excused} such 409s since the last judged run (at most ${maxExcused409} are excused)` };
99
102
  }
100
103
  await store.recordProbe(nodeId, offering.offering_id, 'B', STAGE_B_409, false,
101
- `409 with revision ${card.revision} pinned; card re-indexed at ${fresh}; Stage B runs again later`);
104
+ `${status} with revision ${card.revision} pinned; card re-indexed at ${fresh}; Stage B runs again later`);
102
105
  return { kind: 'stale' };
103
106
  };
104
107
  }
@@ -113,9 +116,11 @@ async function probeIdentity(safeFetch, card, offering, refs, on409) {
113
116
  let matches = 0, retried = 0, refused = 0, stop = null;
114
117
  const ask = async (prompt) => {
115
118
  const { status, text } = await chatOnce(safeFetch, card, offering, prompt);
116
- if (status === 409) {
117
- const what = await on409(offering);
118
- if (what.kind === 'refused') refused++; else stop = what;
119
+ if (status !== 200) {
120
+ // A 409, or another failure (a 404 for a model dropped since the card was fetched): only a
121
+ // revision that really moved excuses it; with the current revision pinned it does not match.
122
+ const what = await on409(offering, status);
123
+ if (what.kind === 'refused') { if (status === 409) refused++; } else stop = what;
119
124
  return null;
120
125
  }
121
126
  return status === 200 && text !== null ? sha256(text) : null;
@@ -293,6 +298,13 @@ export async function runStageB(store, nodeId, card, {
293
298
  await store.setObservation(nodeId, offering.offering_id, 'context_cap', verdict.context.verified_cap);
294
299
 
295
300
  verdict.capacity = await probeCapacity(safeFetch, card, offering, corpus, capacity);
301
+ if (!verdict.capacity.ok) {
302
+ // A failed ramp on a card that has since moved (the model dropped or changed during the run)
303
+ // is not judged, by the same rule and bound as a 409.
304
+ const what = await on409(offering, 'capacity failure');
305
+ if (what.kind === 'stale') return { ok: false, identityFailed: false, stale: true, verdicts: [...verdicts, verdict], untested };
306
+ if (what.kind === 'moved') return { ok: false, identityFailed: false, reason: `${offering.offering_id}: ${what.reason}`, verdicts: [...verdicts, verdict], untested };
307
+ }
296
308
  await store.recordProbe(nodeId, offering.offering_id, 'B', 'capacity', verdict.capacity.ok, null, verdict.capacity);
297
309
  if (verdict.capacity.ttft_ms.p50 != null) {
298
310
  await store.setObservation(nodeId, offering.offering_id, 'ttft_ms', verdict.capacity.ttft_ms);
package/src/stagec.js CHANGED
@@ -4,6 +4,9 @@
4
4
  // - random blind invocations at unpredictable times (anti-"benchmark mode": a node cannot serve the
5
5
  // real model only when it detects a test window), worded from the registry's probe corpus like
6
6
  // any customer request; repeated failures cost the node its tier
7
+ // - blind invocations use the card the registry already holds: cards are re-fetched on their own
8
+ // jittered timer (cardSweep), never just before a probe, so the card origin's log does not announce
9
+ // the "blind" request that follows (a 409 still re-fetches and retries, below)
7
10
  // - an excused 409 is followed by a fresh blind invocation within the hour (ONP-3 §4a.9), so
8
11
  // publishing a new card revision to refuse a probe does not buy a quiet stretch
9
12
  // - on verified and attested nodes some blind invocations ask an identity prompt instead: a light
@@ -25,6 +28,11 @@ const MINUTE = 60_000, HOUR = 60 * MINUTE, DAY = 24 * HOUR;
25
28
  export const LIVENESS_INTERVAL_MS = 300_000;
26
29
  /** Mean gap between blind-invocation sweeps: one chat call per node per sweep, same jitter. */
27
30
  export const BLIND_INTERVAL_MS = 3_600_000;
31
+ /**
32
+ * Mean gap between card re-fetch sweeps, same jitter. Its own timer, independent of the blind sweeps:
33
+ * a card fetch must not tell a node that a blind invocation is coming.
34
+ */
35
+ export const CARD_REFRESH_INTERVAL_MS = 3_600_000;
28
36
  /** Each gap is the mean times a uniform random factor in this range. */
29
37
  export const JITTER = [0.5, 1.5];
30
38
  /** Consecutive failed blind invocations (since the node's last state change) that demote it one tier. */
@@ -70,6 +78,7 @@ export function startStageC(store, {
70
78
  corpus = loadCorpus(null), // probe prompts (corpus.js)
71
79
  livenessIntervalMs = LIVENESS_INTERVAL_MS, // tests shorten this
72
80
  blindIntervalMs = BLIND_INTERVAL_MS,
81
+ cardRefreshIntervalMs = CARD_REFRESH_INTERVAL_MS,
73
82
  followUpTickMs = FOLLOW_UP_TICK_MS,
74
83
  followUpMs = FOLLOW_UP_MS,
75
84
  failThreshold = 3,
@@ -139,7 +148,7 @@ export function startStageC(store, {
139
148
  for (const node of await store.allNodes()) {
140
149
  if (stopped) return;
141
150
  if (!OBSERVED_STATES.includes(node.state)) continue;
142
- await refreshCard?.(node.id);
151
+ // The card the registry holds, never one fetched just now (cardSweep has its own timer).
143
152
  const card = await store.latestCard(node.id);
144
153
  if (!card) continue;
145
154
  // Blind probes call only offerings the tests can call. A node with none is reported in the
@@ -160,6 +169,23 @@ export function startStageC(store, {
160
169
  }
161
170
  }
162
171
 
172
+ /**
173
+ * Re-fetch the cards of observed nodes, in random order, on a timer of its own. A revision the
174
+ * node moved to is picked up here (or on its ping, or by a 409's re-fetch), not just before a probe.
175
+ */
176
+ async function cardSweep() {
177
+ if (!refreshCard) return;
178
+ const nodes = (await store.allNodes()).filter((n) => OBSERVED_STATES.includes(n.state));
179
+ for (let i = nodes.length - 1; i > 0; i--) {
180
+ const j = Math.floor(random() * (i + 1));
181
+ [nodes[i], nodes[j]] = [nodes[j], nodes[i]];
182
+ }
183
+ for (const node of nodes) {
184
+ if (stopped) return;
185
+ await refreshCard(node.id);
186
+ }
187
+ }
188
+
163
189
  /**
164
190
  * The fresh blind invocations owed after excused 409s: each due one runs now, pinned to the card
165
191
  * the registry holds (the revision the node moved to), without fetching the card first. Its 409
@@ -184,6 +210,7 @@ export function startStageC(store, {
184
210
  const offering = callable[Math.floor(random() * callable.length)];
185
211
  const ref = await identityReference(node, offering);
186
212
  const result = await blindProbe(node, card, offering, ref);
213
+ if (result.skipped) return;
187
214
  // The record says only whether the reply conformed: never that it carried an identity prompt,
188
215
  // nor how that comparison went (node detail publishes the last probe records).
189
216
  await store.recordProbe(node.id, result.offeringId, 'C', 'blind', result.ok, result.detail, result.measured);
@@ -202,6 +229,26 @@ export function startStageC(store, {
202
229
  return refs.length ? refs[Math.floor(random() * refs.length)] : null;
203
230
  }
204
231
 
232
+ /**
233
+ * Blind probes go out on the card the registry holds, so one can reach an offering the node has
234
+ * since dropped from its card (it answers 404, say, not 409). After such a failure, and never
235
+ * before a probe, the card is re-fetched: when its revision moved and the offering is gone, the
236
+ * failure is not judged. It is excused like a 409, within the same daily bound and with a fresh
237
+ * probe owed within the hour. Null when it counts as a failure.
238
+ */
239
+ async function droppedOffering(node, card, offering, status) {
240
+ await refreshCard?.(node.id);
241
+ const fresh = await store.latestCard(node.id);
242
+ if (!fresh || fresh.revision === card.revision) return null;
243
+ if (fresh.offerings.some((o) => o.offering_id === offering.offering_id && testable(o))) return null;
244
+ const excused = await store.countProbes(node.id, 'blind-409', iso(Date.now() - DAY));
245
+ if (excused >= maxExcused409) return null;
246
+ await store.recordProbe(node.id, offering.offering_id, 'C', 'blind-409', false,
247
+ `status ${status} for ${offering.offering_id}, which revision ${fresh.revision} no longer offers; a fresh probe due within the hour`);
248
+ await oweFollowUp(node.id, fresh.revision);
249
+ return { skipped: true, offeringId: offering.offering_id };
250
+ }
251
+
205
252
  /**
206
253
  * One blind chat call, in the identity requests' shape (temperature 0, the same output cap). A fresh
207
254
  * 409 is excused within the daily bound: the card is re-indexed, the call retried once at once
@@ -221,6 +268,7 @@ export function startStageC(store, {
221
268
  let reply = await ask(card, offering, ref ? ref.prompt : corpus.chatPrompt());
222
269
  if (reply.status !== 409) {
223
270
  const result = judge(reply, offering);
271
+ if (!result.ok) return (await droppedOffering(node, card, offering, reply.status)) ?? result;
224
272
  if (ref && result.ok) result.identity = await lightCheck(reply, () => ask(card, offering, ref.prompt), ref);
225
273
  return result;
226
274
  }
@@ -238,7 +286,9 @@ export function startStageC(store, {
238
286
  await oweFollowUp(node.id, fresh.revision);
239
287
  const retryOffering = fresh.offerings.find((o) => o.offering_id === offering.offering_id && testable(o))
240
288
  ?? fresh.offerings.find(testable);
241
- if (!retryOffering) return { ok: false, offeringId: offering.offering_id, detail: `the new revision ${fresh.revision} has no tested offering`, measured: null };
289
+ // The node moved to a card with nothing to call (an excused 409, already recorded): nothing
290
+ // was judged, and the next sweep reports it as blind_skipped, as for any such card.
291
+ if (!retryOffering) return { skipped: true, offeringId: offering.offering_id };
242
292
  reply = await ask(fresh, retryOffering, corpus.chatPrompt());
243
293
  return judge(reply, retryOffering, reply.status === 409 ? 'on the retry with the re-indexed revision' : null);
244
294
  } catch (err) {
@@ -325,12 +375,14 @@ export function startStageC(store, {
325
375
  };
326
376
  loop(livenessSweep, livenessIntervalMs);
327
377
  loop(blindSweep, blindIntervalMs);
378
+ loop(cardSweep, cardRefreshIntervalMs);
328
379
  loop(followUpTick, followUpTickMs);
329
380
 
330
381
  return {
331
382
  stop: () => { stopped = true; },
332
383
  /** One blind sweep, or one look for due follow-ups, now (tests). */
333
384
  blindSweep,
385
+ cardSweep,
334
386
  followUpTick,
335
387
  };
336
388
  }
@@ -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), each time after a fetch of your card.<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; within 1&nbsp;hour of a change to a chat offering's model, serving or hardware block, or 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. 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):
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).
@@ -924,11 +924,19 @@ const invocable = (o) => o.invocable !== false && Boolean(o.endpoints?.openai);
924
924
  const runsLocally = (o) => Boolean(o.local) || /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/i.test(o.endpoints?.openai ?? '');
925
925
  /** endpoints.docs only when it is a plain web link (cards are third-party data). */
926
926
  const docsUrl = (endpoints) => /^https?:\/\//i.test(endpoints?.docs ?? '') ? endpoints.docs : null;
927
+ /** The AI Horde import: volunteers' machines, so a catalog listing in the open pool, never a claim to verify. */
928
+ const HORDE_NODE = 'import.aihorde.text';
927
929
  function provLine(o) {
928
930
  const obs = o.observed || {};
929
931
  const bits = [`revision ${esc((o.card_revision || '').slice(0, 10))}`];
930
932
  if (obs.probes > 0) bits.push(`probes ${Math.round((obs.probe_success ?? 0) * obs.probes)}/${obs.probes} pass`);
931
- if (o.source === 'import') bits.push('catalog import — operator can claim this listing to get verified');
933
+ if (o.source === 'import') bits.push(o.node_id === HORDE_NODE ? 'catalog import from the AI Horde\'s public status — never probed by this registry'
934
+ : 'catalog import — operator can claim this listing to get verified');
935
+ const up = obs.upstream;
936
+ if (up && Number.isFinite(up.workers)) {
937
+ bits.push(`${up.workers} volunteer worker${up.workers === 1 ? '' : 's'} online, queue ${Number(up.eta_s) > 0 ? `≈${Math.round(up.eta_s)} s` : 'empty'}`
938
+ + ` — reported by ${up.source === 'aihorde' ? 'the AI Horde' : 'the upstream'}${up.reported_at ? ` at ${esc(String(up.reported_at).slice(0, 16).replace('T', ' '))} UTC` : ''}, not measured here`);
939
+ }
932
940
  if (!invocable(o)) bits.push('listing only — no known API endpoint, so it cannot be called from here'
933
941
  + (docsUrl(o.endpoints) ? ` (<a href="${esc(docsUrl(o.endpoints))}" target="_blank" rel="noopener">provider docs ↗</a>)` : ''));
934
942
  return bits.join(' · ');
@@ -1709,7 +1717,9 @@ function importKeyHint(offering, base, key) {
1709
1717
  const host = new URL(base).host;
1710
1718
  if (offering.local || /^(localhost|127\.0\.0\.1|\[::1\])(:|$)/.test(host)) return null; // your own machine: no key
1711
1719
  const where = host.includes('huggingface') ? 'a Hugging Face token (huggingface.co/settings/tokens)'
1712
- : host.includes('openrouter') ? 'an OpenRouter API key (openrouter.ai/keys)' : `an API key for ${host}`;
1720
+ : host.includes('openrouter') ? 'an OpenRouter API key (openrouter.ai/keys)'
1721
+ : host === 'oai.aihorde.net' ? 'an AI Horde key (free at aihorde.net/register; the anonymous key 0000000000 works but waits longest; volunteers can read prompts, so no personal data)'
1722
+ : `an API key for ${host}`;
1713
1723
  return `This is an imported catalog listing served by ${host}: your browser calls it directly, which needs ${where} — paste it in the API key field (stored only in this browser). Or run it locally with BYOK: npx @opennodes/cli gateway --key ${host}=<key>. Registered OpenNodes nodes need no key.`;
1714
1724
  }
1715
1725
  async function callTarget(t, messages, maxTokens = 1024) {
@@ -2563,6 +2573,19 @@ async function loadFeed() {
2563
2573
  const CLAIM_GUIDE = 'https://github.com/opennodes-io/opennodes/tree/main/node-kit#card-only-listing-you-already-run-an-openai-compatible-api';
2564
2574
  function claimBanner(n, card) {
2565
2575
  if (n.source !== 'import' || ['delisted', 'claimed'].includes(n.state)) return '';
2576
+ if (n.id === HORDE_NODE) {
2577
+ return `<div class="panel pad" style="max-width:56rem; margin:0.4rem 0 0.8rem; border-left:3px solid var(--accent)">
2578
+ <p style="margin:0 0 0.35rem; font-weight:600">About this listing</p>
2579
+ <p style="margin:0 0 0.6rem; font-size:0.86rem; color:var(--muted); overflow-wrap:anywhere">The AI Horde is a free network run by the non-profit Haidra: volunteers run the models on their own machines, and the queue is ordered by kudos. This registry reads only the Horde's public model status and Haidra's model reference, about once an hour, and never sends a prompt. Volunteer workers can technically read prompts and outputs, so these listings stay in the open pool: never use them for personal data. To call a model, use your own AI Horde key (or the anonymous key <span class="mono">0000000000</span>, which waits longest) at the Horde's OpenAI-compatible front. Haidra: to change or remove this listing, write to us.</p>
2580
+ <span style="display:inline-flex; gap:0.6rem; flex-wrap:wrap; font-size:0.84rem">
2581
+ <a href="https://aihorde.net/terms" target="_blank" rel="noopener">Horde terms ↗</a>
2582
+ <a href="https://aihorde.net/privacy" target="_blank" rel="noopener">Privacy ↗</a>
2583
+ <a href="https://aihorde.net/faq" target="_blank" rel="noopener">FAQ ↗</a>
2584
+ <a href="https://aihorde.net/register" target="_blank" rel="noopener">Get a free key ↗</a>
2585
+ <a href="mailto:operators@opennodes.io?subject=${encodeURIComponent('AI Horde listing')}">operators@opennodes.io</a>
2586
+ </span>
2587
+ </div>`;
2588
+ }
2566
2589
  const name = card.node?.operator?.name || card.node?.name || n.id;
2567
2590
  let host = null;
2568
2591
  try { host = new URL(card.endpoints?.openai).hostname; } catch { /* listing without an API */ }
@@ -2625,8 +2648,9 @@ function dataPolicyLine(o) {
2625
2648
  }
2626
2649
 
2627
2650
  /** Server-location check (registry location.js) in plain words; `check` is the node's server_check for its current card. */
2628
- function locationRow(loc, imported, check) {
2651
+ function locationRow(loc, imported, check, country = null) {
2629
2652
  const claim = imported ? 'inferred for this unclaimed listing' : 'declared by the operator';
2653
+ if (!loc && imported && !country) return `<tr><td style="color:var(--muted)" class="mono">server</td><td style="font-size:0.8rem">not checked <span style="color:var(--muted)">· this listing names no operator country, so it has nothing to be checked against</span></td></tr>`;
2630
2654
  if (!loc) return `<tr><td style="color:var(--muted)" class="mono">server</td><td style="font-size:0.8rem">not checked yet <span style="color:var(--muted)">· the operator's country is ${claim}, not verified</span></td></tr>`;
2631
2655
  const srv = loc.server || {};
2632
2656
  const words = {
@@ -2703,7 +2727,7 @@ async function loadNode(id) {
2703
2727
  <div class="panel pad" style="max-width:56rem; margin-top:0.6rem"><table class="grid">
2704
2728
  <tr><td style="color:var(--muted); width:8rem" class="mono">endpoint</td><td class="mono" style="font-size:0.74rem">${card.endpoints?.openai ? esc(card.endpoints.openai) : '— <span style="font-family:inherit; color:var(--muted)">listing only: no known API endpoint, not callable from OpenNodes</span>'}</td></tr>
2705
2729
  ${docsUrl(card.endpoints) ? `<tr><td style="color:var(--muted)" class="mono">docs</td><td class="mono" style="font-size:0.74rem"><a href="${esc(docsUrl(card.endpoints))}" target="_blank" rel="noopener">${esc(docsUrl(card.endpoints))}</a></td></tr>` : ''}
2706
- ${locationRow(n.location, n.source === 'import', n.server_check)}
2730
+ ${locationRow(n.location, n.source === 'import', n.server_check, card.node?.operator?.country ?? null)}
2707
2731
  ${card.hardware ? `<tr><td style="color:var(--muted)" class="mono">hardware</td><td style="font-size:0.78rem">${hwStr({ hardware: card.hardware })}</td></tr>` : ''}
2708
2732
  ${returnedRow(n.request_counts, n.id)}
2709
2733
  ${testedRow(n, offers.length, untested.size)}