Upload scripts/build-daily-index.mjs with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465#!/usr/bin/env node/** * build-daily-index.mjs — X402-TRUST-INDEX daily publisher (RunPod-cron-able, zero deps) * Pulls the public census surfaces, computes deltas vs yesterday's snapshot, writes: * snapshots/YYYY-MM-DD.json (schema csoai.x402-trust-index/0.1, trimmed) * snapshots/YYYY-MM-DD.md (steering-committee one-pager) * Cron (RunPod): 0 8 * * * node /workspace/councilof-ai/scripts/build-daily-index.mjs --out /workspace/snapshots */import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';
const OUT = (process.argv[process.argv.indexOf('--out') + 1] || './snapshots');const SOURCES = { x402: 'https://councilof.ai/interop/x402-trust/latest.json', mcp: 'https://councilof.ai/interop/mcp-trust/latest.json', board: 'https://councilof.ai/api/gspc', capsules: 'https://councilof.ai/measurement-capsules/v0.2/index.json', root: 'https://councilof.ai/root.json',};const get = async u => (await fetch(u)).json();
function pick(o) { const x = o.counts ? { ...o.counts } : null; return { as_of: o.as_of?.date || o.as_of || null, raw_state: o.state, counts: x };}
const today = new Date().toISOString().slice(0, 10);const [x402, mcp, board, caps, root] = await Promise.all(Object.values(SOURCES).map(u => get(u).catch(() => null)));const snap = { schema: 'csoai.x402-trust-index/0.1', date: today, x402: pick(x402), mcp: pick(mcp), board: { fetched_at: board?.as_of?.fetched_at, slots: board?.counts?.[0]?.value, measured: board?.counts?.[1]?.value, unmeasured: board?.counts?.[2]?.value, separation: board?.separation?.public_count }, capsules: { as_of: caps?.as_of, n: caps?.n_capsules_total, signature: caps?.signature?.state, xrpl: caps?.anchors?.xrpl?.state }, root: { as_of: root?.as_of, leaves: root?.card_count, merkle: root?.merkle_root, state: root?.state },};snap.snapshot_sha256 = crypto.createHash('sha256').update(JSON.stringify(snap)).digest('hex');
// delta vs most recent prior snapshotconst prev = fs.readdirSync(OUT).filter(f => f.endsWith('.json') && f !== `${today}.json`).sort().pop();let deltas = {};if (prev) { const p = JSON.parse(fs.readFileSync(path.join(OUT, prev), 'utf8')); const pair = (a, b) => (a === b ? '=' : `${b} (was ${a}) ▲`); deltas = { board_measured: pair(p.board?.measured, snap.board?.measured), cards_leaves: pair(p.root?.leaves, snap.root?.leaves), capsules: pair(p.capsules?.n, snap.capsules?.n), };}
fs.mkdirSync(OUT, { recursive: true });fs.writeFileSync(path.join(OUT, `${today}.json`), JSON.stringify(snap, null, 2));fs.writeFileSync(path.join(OUT, `${today}.md`), `# DAILY TRUST REPORT — ${today}*Measurement, not endorsement. Verification free: https://councilof.ai/gspc-verify*
- x402 census (as_of ${snap.x402.as_of}): ${snap.x402.counts?.challenge_402}/${snap.x402.counts?.total} correct 402 · ${snap.x402.counts?.dead_404_or_unreachable} phantom/unreachable- MCP census (as_of ${snap.mcp.as_of}): ${snap.mcp.counts?.initialize_ok_open + snap.mcp.counts?.initialize_ok_tools_listed} answered · ${snap.mcp.counts?.auth_challenged_401_403} auth · ${snap.mcp.counts?.x402_challenged_402} x402 (cap ${snap.mcp.counts?.total ?? 500})- Board (fetched ${snap.board.fetched_at}): ${snap.board.slots} axes · ${snap.board.measured} measured · ${snap.board.unmeasured} declared-unmeasured · ${snap.board.separation}- Corpus: ${snap.capsules.n} capsules (sig ${snap.capsules.signature}) · root ${String(snap.root.merkle).slice(0, 8)}… ${snap.root.leaves} leaves · XRPL ${snap.capsules.xrpl}- Deltas vs ${prev || 'baseline'}: ${JSON.stringify(deltas)}
⏳ Dec-2 Article-50 countdown: ${Math.max(0, Math.ceil((new Date('2026-12-02') - new Date(today)) / 86400000))} days`);console.log(`[daily-index] wrote ${today}.json + ${today}.md prev=${prev || 'none'} deltas=${JSON.stringify(deltas)}`);scripts/build-daily-index.mjsAdded+65