Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(fleet-console): say why a snapshot covers less than the whole fleet

nirholas3fc106e91f87
diff --git a/services/fleet-console/README.md b/services/fleet-console/README.md
index 246c090d8..64c953e1b 100644
--- a/services/fleet-console/README.md
+++ b/services/fleet-console/README.md
@@ -47,7 +47,7 @@ npm start --prefix services/fleet-console # http://localhost:8080
## What it measures
-Each repository is graded on eight weighted checks. The weights are deliberate:
+Each repository is graded on ten weighted checks. The weights are deliberate:
a broken deployment is worth more than a missing description, because a dead
link costs a visitor their trust and a missing description costs them a second.
@@ -56,11 +56,16 @@ link costs a visitor their trust and a missing description costs them a second.
| Claimed deployments respond | 20 | Every URL the repo presents as live actually answers |
| Advertised packages exist on npm | 15 | Every package name the repo advertises resolves on the registry |
| README links resolve | 12 | External links in the README are not dead |
-| Has a real README | 8 | Present, and more than a title |
-| Ships documentation beyond the README | 8 | A `docs/` directory, a site, or equivalent |
-| Declares a license | 6 | A license file or SPDX declaration |
+| Has a real README | 8 | Present, and at least 600 bytes (under that is a stub, which warns) |
+| Ships documentation beyond the README | 8 | A `docs/`, `doc/`, `documentation/`, `website/` or `site/` directory |
+| Recently touched | 8 | Pushed within 120 days (within 400 days warns) |
+| Declares a license | 6 | GitHub can classify it, so `NOASSERTION` does not count |
+| npm matches the committed version | 6 | The registry `latest` tag equals the manifest version |
| Has a description | 4 | The GitHub description field is set |
-| Recent activity | varies | Pushed within a recency window |
+| Discoverable by topic | 3 | Three or more topics are set (one or two warns) |
+
+`/docs` on the running console renders this same table from the code, so it can
+never drift from what the scorer does.
Every check returns `pass`, `warn`, `fail`, or `skip`. A `skip` is dropped from
both the numerator and the denominator, so a repository is never punished for a
@@ -84,20 +89,27 @@ something is wrong.
## HTTP surface
```
-GET / dashboard, or the scanning state before the first snapshot
-GET /r/:repo one repository, every measurement behind its score
-GET /docs how the score is computed, and how to embed a badge
-GET /api/fleet the whole snapshot
-GET /api/repo/:repo one repository
-GET /api/status scan progress, safe to poll
-GET /api/attention only what is broken, ranked, for automation
-POST /api/scan trigger a scan (requires FLEET_SCAN_TOKEN)
-GET /badge/fleet.svg fleet median badge
+GET / dashboard, or the scanning state before the first snapshot
+GET /r/:repo one repository, every measurement behind its score
+GET /docs how the score is computed, and how to embed a badge
+GET /healthz liveness, plus whether a snapshot exists yet
+GET /api/fleet the snapshot, slimmed; add ?full=1 for every measurement
+GET /api/repo/:repo one repository, with its score history
+GET /api/status scan progress, safe to poll
+GET /api/attention only what is broken, ranked, for automation
+POST /api/scan trigger a scan (requires FLEET_SCAN_TOKEN)
+GET /badge/fleet.svg fleet median badge
+GET /badge/:repo.svg one repository's health badge
+GET /badge/:repo/deployment.svg how many of that repository's claimed URLs respond
```
`/api/attention` is the one to automate against: it returns only failing checks,
worst first, already carrying the fix strings.
+Before the first scan finishes, `/api/fleet` and `/api/attention` answer `503`
+with the current progress rather than an empty fleet, because an empty fleet
+reads as "everything is fine" instead of "there is nothing to read yet".
+
---
## As an MCP server
@@ -132,8 +144,8 @@ Every option is an environment variable with a working default.
| Variable | Default | Meaning |
| --- | --- | --- |
| `FLEET_OWNER` | `nirholas` | GitHub user or organisation to scan |
-| `GITHUB_TOKEN` | none | Read-only token. Without one, GitHub allows 60 requests/hour |
-| `FLEET_DATA_DIR` | `/tmp/fleet-console` | Where snapshots are written. Ephemeral on Cloud Run unless a volume is mounted |
+| `GITHUB_TOKEN` | none | Read-only token, or `GH_TOKEN`. Without one, GitHub allows 60 requests/hour |
+| `FLEET_DATA_DIR` | `/tmp/fleet-console` | Where snapshots are written. Ephemeral unless the path is a mounted volume |
| `PORT` | `8080` | HTTP port |
| `FLEET_MAX_REPOS` | `400` | Repositories per scan, highest star count first |
| `FLEET_INCLUDE_FORKS` | `false` | Forks are someone else's code and score meaninglessly |
@@ -142,7 +154,16 @@ Every option is an environment variable with a working default.
| `FLEET_PROBE_CONCURRENCY` | `12` | Concurrent outbound probes against third-party hosts |
| `FLEET_PROBE_TIMEOUT_MS` | `10000` | Per-probe timeout |
| `FLEET_MAX_LINKS_PER_REPO` | `12` | READMEs occasionally carry hundreds of links |
-| `FLEET_SCAN_TOKEN` | none | Required as a bearer token to `POST /api/scan` |
+| `FLEET_SCAN_INTERVAL_MS` | `21600000` (6h) | Automatic rescan cadence. `0` disables it and leaves scans to `POST /api/scan` |
+| `FLEET_SCAN_ON_BOOT` | `true` | Scan as soon as the server starts, when no snapshot was restored from disk |
+| `FLEET_HISTORY_LIMIT` | `60` | Past snapshots retained for the trend lines |
+| `FLEET_SCAN_TOKEN` | none | Required as a bearer token to `POST /api/scan`. Unset means the endpoint answers `403` |
+
+A scan that covers less than the whole fleet is flagged `partial`, and
+`partialReason` says which of the two causes applied: `repo_cap` (the scan hit
+`FLEET_MAX_REPOS`) or `rate_limit` (the GitHub request budget ran out). They
+look identical in the data and need opposite fixes, so the dashboard and the
+CLI always name the one that actually happened.
---
@@ -150,6 +171,7 @@ Every option is an environment variable with a working default.
| File | Role |
| --- | --- |
+| `src/config.js` | Every tunable, read from the environment at import time |
| `src/scan.js` | The engine: orchestrates a full fleet scan |
| `src/github.js` | GitHub API client (repository list, README, metadata) |
| `src/extract-urls.js` | Pulls claimed URLs and package names out of a README |
@@ -166,7 +188,41 @@ Every option is an environment variable with a working default.
---
+## Where it runs
+
+Nothing about this service is deployed. It has no `Dockerfile` and no Cloud Run
+service, by design: it reads public GitHub and npm data and writes a JSON file,
+so the useful shapes are a terminal, a cron job, and an MCP server next to an
+agent. A snapshot survives a restart because `FLEET_DATA_DIR` is written
+atomically, and `FLEET_SCAN_INTERVAL_MS` keeps a long-lived process current.
+
+The gate that matters for cron use is `scan --attention`, which exits `1` when
+anything in the fleet is measurably broken:
+
+```bash
+GITHUB_TOKEN=ghp_... node services/fleet-console/src/cli.js scan --attention
+```
+
+---
+
+## Tests
+
+```bash
+npx vitest run tests/fleet-console.test.js tests/fleet-console-server.test.js
+```
+
+[tests/fleet-console.test.js](../../tests/fleet-console.test.js) covers the pure
+engine (URL extraction, probe classification, the scoring model, registry
+parsing, badges, the attention ranking).
+[tests/fleet-console-server.test.js](../../tests/fleet-console-server.test.js)
+is the core-path smoke test: it boots the real HTTP handler on a real socket
+over a real on-disk snapshot and walks every route, in both the
+before-first-scan and the populated state.
+
+---
+
## Related
- [STRUCTURE.md](../../STRUCTURE.md) maps every surface in this repository
+- [services/README.md](../README.md) covers the other long-running services
- [docs/mcp.md](../../docs/mcp.md) covers the wider three.ws MCP surface
diff --git a/services/fleet-console/src/cli.js b/services/fleet-console/src/cli.js
index 3fe947113..7668d8632 100644
--- a/services/fleet-console/src/cli.js
+++ b/services/fleet-console/src/cli.js
@@ -9,7 +9,7 @@
*/
import { config } from './config.js';
-import { runScan } from './scan.js';
+import { runScan, partialReasons } from './scan.js';
import * as store from './store.js';
import { attention } from './server.js';
@@ -35,7 +35,9 @@ const colorFor = (score) => (score >= 75 ? GREEN : score >= 55 ? YELLOW : RED);
function printReport(snapshot) {
const { summary } = snapshot;
process.stdout.write(`\n${BOLD}${snapshot.owner}${RESET} ${summary.repos} repositories, ${summary.stars.toLocaleString()} stars\n`);
- process.stdout.write(`${DIM}scanned in ${(snapshot.durationMs / 1000).toFixed(1)}s${snapshot.partial ? ', partial (rate limit)' : ''}${RESET}\n\n`);
+ process.stdout.write(`${DIM}scanned in ${(snapshot.durationMs / 1000).toFixed(1)}s${snapshot.partial ? ', partial' : ''}${RESET}\n`);
+ for (const reason of partialReasons(snapshot)) process.stdout.write(`${YELLOW} ${reason}${RESET}\n`);
+ process.stdout.write('\n');
process.stdout.write(` median health ${colorFor(summary.medianScore)}${summary.medianScore}/100${RESET}\n`);
process.stdout.write(` live deployments ${summary.deployments.healthy}/${summary.deployments.total}\n`);
process.stdout.write(` dead README links ${summary.links.dead}/${summary.links.total}\n`);
diff --git a/services/fleet-console/src/mcp.js b/services/fleet-console/src/mcp.js
index 6be9af2e3..09c54d956 100644
--- a/services/fleet-console/src/mcp.js
+++ b/services/fleet-console/src/mcp.js
@@ -19,6 +19,7 @@ import { createInterface } from 'node:readline';
import { config } from './config.js';
import * as store from './store.js';
import { attention } from './server.js';
+import { partialReasons } from './scan.js';
const PROTOCOL_VERSION = '2024-11-05';
const consoleUrl = (process.env.FLEET_CONSOLE_URL || '').replace(/\/+$/, '');
@@ -109,6 +110,11 @@ async function callTool(name, args = {}) {
owner: snapshot.owner,
generatedAt: snapshot.generatedAt,
partial: snapshot.partial,
+ // An agent acting on this needs to know whether it is looking at the
+ // whole fleet, and if not, why not: a capped scan is a configuration
+ // choice, an exhausted budget means the numbers themselves are shaky.
+ partialReason: snapshot.partialReason || '',
+ partialDetail: partialReasons(snapshot),
...snapshot.summary
});
}
diff --git a/services/fleet-console/src/scan.js b/services/fleet-console/src/scan.js
index 0417da125..9e1a2f9c4 100644
--- a/services/fleet-console/src/scan.js
+++ b/services/fleet-console/src/scan.js
@@ -31,6 +31,37 @@ export const progress = {
const DOC_DIRS = new Set(['docs', 'doc', 'documentation', 'website', 'site']);
+/**
+ * Why a snapshot covers less than the whole fleet, in plain sentences.
+ *
+ * Shared by the CLI and the dashboard so the two can never disagree about the
+ * cause. Both reasons can hold at once, in which case both are reported: an
+ * operator who raises FLEET_MAX_REPOS without also raising the request budget
+ * would otherwise fix half the problem and see no change.
+ *
+ * @param {object|null} snapshot
+ * @returns {string[]} one sentence per reason, empty when the scan was complete
+ */
+export function partialReasons(snapshot) {
+ if (!snapshot?.partial) return [];
+ const out = [];
+ const scanned = snapshot.summary?.repos ?? 0;
+ const owned = snapshot.totalOwned ?? scanned;
+
+ if (snapshot.partialReason === 'rate_limit') {
+ const resets = snapshot.rateLimit?.resetAt ? `, which resets at ${snapshot.rateLimit.resetAt}` : '';
+ const raise = snapshot.authenticated ? 'Some measurements are incomplete.' : 'Set GITHUB_TOKEN to raise the budget from 60 to 5000 requests an hour.';
+ out.push(`The GitHub request budget ran out during this scan${resets}. ${raise}`);
+ }
+ if (scanned < owned) {
+ out.push(`Only the ${scanned} most-starred of ${owned} repositories were scanned. Raise FLEET_MAX_REPOS to cover the whole fleet.`);
+ }
+ // A snapshot written before partialReason existed still reloads from disk and
+ // still renders, so it gets an honest sentence rather than an empty banner.
+ if (out.length === 0) out.push(`${scanned} of ${owned} repositories were scanned.`);
+ return out;
+}
+
async function gatherRepo(repo) {
const [readme, manifest, entries, pagesUrl] = await Promise.all([
fetchReadme(repo.fullName),
@@ -112,11 +143,19 @@ export async function runScan({ owner = config.owner, limit = config.maxRepos }
}
});
+ // A capped scan and an exhausted rate-limit budget are both "partial" and
+ // look identical in the data, but they are different problems with
+ // different fixes. Record which one happened so the console never blames
+ // GitHub for a limit this service set itself.
+ const rateLimited = Boolean(rateLimit.exhausted);
+ const capped = selected.length < all.length;
+
const snapshot = {
owner,
generatedAt: new Date().toISOString(),
durationMs: Date.now() - startedAt,
- partial: Boolean(rateLimit.exhausted) || selected.length < all.length,
+ partial: rateLimited || capped,
+ partialReason: rateLimited ? 'rate_limit' : capped ? 'repo_cap' : '',
totalOwned: all.length,
authenticated: Boolean(config.githubToken),
rateLimit: { limit: rateLimit.limit, remaining: rateLimit.remaining, resetAt: rateLimit.resetAt },
diff --git a/services/fleet-console/src/views/dashboard.js b/services/fleet-console/src/views/dashboard.js
index 42e20e7e3..f9005a72b 100644
--- a/services/fleet-console/src/views/dashboard.js
+++ b/services/fleet-console/src/views/dashboard.js
@@ -7,6 +7,7 @@
import { esc, attr, ago, page, ring, sparkline } from './html.js';
import { PROBE_STATES } from '../probe.js';
+import { partialReasons } from '../scan.js';
const tone = (value, good, warn) => (value >= good ? 'good' : value >= warn ? 'warn' : 'bad');
@@ -186,7 +187,7 @@ export function dashboardPage({ snapshot, history }) {
npm registry. A repository scores on the promises it makes, so a library with nothing deployed is never marked down for it.</p>
</section>
${statTiles(summary, history)}
-${snapshot.partial ? `<div class="note"><strong>Partial scan.</strong> ${esc(snapshot.summary.repos)} of ${esc(snapshot.totalOwned)} repositories were reachable within the GitHub rate-limit budget${snapshot.rateLimit.resetAt ? `, which resets at ${esc(snapshot.rateLimit.resetAt)}` : ''}.</div>` : ''}
+${snapshot.partial ? `<div class="note"><strong>Partial scan.</strong> ${partialReasons(snapshot).map((reason) => esc(reason)).join(' ')}</div>` : ''}
${attentionPanel(snapshot)}
<div class="toolbar" role="search">