In this section
- Build storage · spiders / species/estate-activity/tools/build.mjs lines 1–292
- Build Test test · spiders / species/estate-activity/tools/build.test.mjs lines 1–168
- Genome Proof ingest · spiders / species/genome-spider/genome.proof.mjs lines 1–160
Build
A JavaScript module in the tools folder of Spiders that reads activity, using SHA-256 from GitHub API and the ventus-grid-engine repository.
storagespiders / species/estate-activity/tools/build.mjs · lines 1–292 of 292 · Entry point · pattern facts (shared by 5 files)
- What it does
- It loads activity. Defines 18 functions or classes, including isoDay, dayLabels, summarizeCommits, parseStanding, comparePinned. Uses libraries node:fs/promises, node:crypto, node:path, node:url. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'spiders'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). README: "For a manual live crawl, set a read-only GITHUB_TOKEN and run the build.mjs script."
- Inputs & outputs
- In: data source: ventus-grid-engine data; data source: GitHub API; JSON file source.json; JSON file config.json; JSON file activity.json; command-line arguments.
- Downstream impact
- Used directly by 2 files: Build Test (spiders); Estate Activity Workflow (spiders).
- What it achieves
- It summarizes commits (`summarizeCommits`), parses standing (`parseStanding`) and compares pinned (`comparePinned`). Estate Activity Spider: read-only observation of GitHub; no external repository writes.
- Why it matters
- Run by Estate Activity Workflow. Checked by Build Test.
- Application
- spiders · species/estate-activity/tools · JavaScript module
- Uses
- node:fs/promises, node:crypto, node:path, node:url
- Used by
- imported by Build Test (import), run by Estate Activity Workflow (workflow run)
- Produces
- isoDay, dayLabels, summarizeCommits, parseStanding, comparePinned, deriveRegistry, crawlRepo, assessCvaaAudit, verifyVaccineLock, collect, main
- Defines here
- isoDay, dayLabels, summarizeCommits, parseStanding, comparePinned, deriveRegistry, githubHeaders, request, api, raw, crawlRepo, assessCvaaAudit, verifyVaccineLock, isoMax, collect, pinnedSha, main, facts
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/estate-activity/tools/build.mjs:1-292 · blob 7669d2b93cc1df8688036df29831a5254ad2b38e · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: agent_infra · users: ai_agent · canonical: supporting_data
// Estate Activity Spider: read-only observation of GitHub; no external repository writes.
// No model classification, inferred code dependencies or invented releases.
import {readFile, mkdir, writeFile} from 'node:fs/promises';
import {createHash} from 'node:crypto';
import path from 'node:path';
import {fileURLToPath, pathToFileURL} from 'node:url';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(HERE, '..');
const OWNER = 'Ventusltd';
export function isoDay(value) {
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}T/.test(value)) return null;
const d = new Date(value);
return Number.isFinite(d.getTime()) ? d.toISOString().slice(0, 10) : null;
}
export function dayLabels(now, count = 7) {
const d = new Date(now);
if (!Number.isFinite(d.getTime())) throw Error('invalid scan time');
d.setUTCHours(0, 0, 0, 0);
return Array.from({length: count}, (_, i) => {
const day = new Date(d);
day.setUTCDate(d.getUTCDate() - (count - i - 1));
return day.toISOString().slice(0, 10);
});
}
export function summarizeCommits(name, commits, days, capReached = false) {
if (!Array.isArray(commits)) throw Error('commit response is not an array for ' + name);
const unique = new Map();
for (const c of commits) {
if (!/^[a-f0-9]{40}$/i.test(c?.sha ?? '')) continue;
if (!unique.has(c.sha)) unique.set(c.sha, c);
}
const rows = [...unique.values()];
const latest = rows[0] ?? null; // API returns the current branch first; this is HEAD, not 'most recent by author date'.
const hist = Object.fromEntries(days.map(d => [d, 0]));
const first = days[0];
let inWindow = 0;
for (const c of rows) {
const d = isoDay(c.commit?.committer?.date ?? c.commit?.author?.date);
if (d && d >= first && d in hist) {hist[d]++; inWindow++;}
}
return {
repo: OWNER + '/' + name,
url: 'https://github.com/' + OWNER + '/' + name,
head_sha: latest?.sha ?? null,
head_commit_url: latest?.html_url ?? null,
head_commit_utc: latest?.commit?.committer?.date ?? null,
sample_count: inWindow,
count_is_lower_bound: !!capReached,
day_counts: days.map(day => ({day, count: hist[day]})),
recent: rows.slice(0, 5).map(c => ({
sha: c.sha, url: c.html_url,
utc: c.commit?.committer?.date ?? null,
message: String(c.commit?.message ?? '').split('\n')[0].slice(0, 160)
}))
};
}
export function parseStanding(tsv) {
if (typeof tsv !== 'string') throw Error('Kuiper standing TSV missing');
const result = new Map();
for (const line of tsv.split(/\r?\n/)) {
if (!line || line.startsWith('#')) continue;
const cells = line.split('\t');
if (cells.length < 3 || !/^[a-f0-9]{12,40}$/i.test(cells[1])) continue;
result.set(cells[0], {sha_prefix: cells[1], timestamp_unix: Number(cells[2]) || null});
}
if (!result.size) throw Error('Kuiper standing has no valid measured rows');
return result;
}
export function comparePinned(repos, pins) {
if (!Array.isArray(repos) || !Array.isArray(pins)) throw Error('invalid pin comparison');
const live = new Map(repos.map(r => [r.repo, r.head_sha]));
return pins.map(p => {
const observed = live.get(p.repo) ?? null;
const pinned = p.sha ?? p.sha_prefix ?? null;
const status = !observed || !pinned ? 'unavailable' : observed.startsWith(pinned) ? 'aligned' : 'lagging';
return {repo: p.repo, pinned_sha: pinned, observed_sha: observed, status};
});
}
export function deriveRegistry(manifest) {
if (!Array.isArray(manifest?.graphs)) throw Error('Spider receiver manifest missing graphs');
const targets = ['periodic-table', 'modular', 'proof-of-work', 'genome-spider'];
return targets.map(id => {
const entry = manifest.graphs.find(g => g.id === id);
const path = entry?.path ?? null;
const expected = id === 'genome-spider' ? '/spiders/' : '/stars/';
return {id, registered: typeof path === 'string' && path.includes(expected),
source_path: path, receiver: 'https://ventusltd.github.io/ventus-grid-engine/?graph=' + id,
served_bytes_checked: false};
});
}
function githubHeaders(token) {
return {'Accept':'application/vnd.github+json', 'Authorization':'Bearer ' + token,
'X-GitHub-Api-Version':'2022-11-28', 'User-Agent':'Ventus-Activity-Spider'};
}
async function request(url, token, fetcher = fetch) {
const response = await fetcher(url, {headers: githubHeaders(token), signal: AbortSignal.timeout(20000)});
if (!response.ok) throw Error('GitHub/source request HTTP ' + response.status + ': ' + url);
return response;
}
async function api(route, token, fetcher = fetch) {
return (await request('https://api.github.com' + route, token, fetcher)).json();
}
async function raw(name, commit, file, token, fetcher = fetch) {
if (!/^[a-f0-9]{40}$/i.test(commit ?? '')) throw Error('unverified source head for ' + name);
return (await request('https://raw.githubusercontent.com/' + OWNER + '/' + name + '/' + commit + '/' + file, token, fetcher)).text();
}
export async function crawlRepo(name, labels, pages, token, fetcher = fetch) {
const since = labels[0] + 'T00:00:00Z';
let commits = [], capped = false;
for (let page = 1; page <= pages; page++) {
const rows = await api('/repos/' + OWNER + '/' + name + '/commits?since=' + encodeURIComponent(since) +
'&per_page=100&page=' + page, token, fetcher);
if (!Array.isArray(rows)) throw Error('invalid commits response for ' + name);
commits.push(...rows);
if (rows.length < 100) break;
if (page === pages) capped = true;
}
// Preserve exact default-branch HEAD even for quiet repos without commits in the last seven days.
if (!commits.length) {
const head = await api('/repos/' + OWNER + '/' + name + '/commits?per_page=1', token, fetcher);
if (!Array.isArray(head) || !head[0]) throw Error('repository HEAD unavailable for ' + name);
commits = head;
}
return summarizeCommits(name, commits, labels, capped);
}
export function assessCvaaAudit(pr, runs) {
if (!/^[a-f0-9]{40}$/i.test(pr?.head?.sha ?? '')) throw Error('CVAA audit PR lacks exact HEAD');
if (!Array.isArray(runs)) throw Error('CVAA Actions run list missing');
const sameHead = runs.filter(r => r.head_sha === pr.head.sha &&
r.name === '202608301447 Self-test and full-history fleet audit')
.sort((a, b) => String(b.created_at).localeCompare(String(a.created_at)));
const latest = sameHead[0] ?? null;
return {
type:'cvaa-full-history-audit', pr: pr.number,
pr_url: pr.html_url, pr_head_sha: pr.head.sha, pr_state: pr.state,
status: !latest ? 'NOT_OBSERVED' : latest.status !== 'completed' ? 'RUNNING' :
latest.conclusion === 'success' ? 'PASSED_AT_HEAD' : latest.conclusion === 'failure' ? 'FAILED_AT_HEAD' : 'INCOMPLETE',
run_id:latest?.id ?? null, run_url:latest?.html_url ?? null,
workflow_name:latest?.name ?? null, workflow_head_sha:latest?.head_sha ?? null,
workflow_conclusion:latest?.conclusion ?? null, run_updated_utc:latest?.updated_at ?? null,
coverage:'exact PR head; workflow job conclusion, not historical full estate certification',
consumer_inoculation:'NOT_OBSERVED'
};
}
export function verifyVaccineLock(lock, fileName, bytes) {
const expected = lock?.[fileName];
if (!/^[a-f0-9]{64}$/i.test(expected ?? '')) throw Error('CVAA lock missing pinned vaccine SHA256');
const actual = createHash('sha256').update(bytes,'utf8').digest('hex');
return {name:fileName, expected_sha256:expected, actual_sha256:actual,
status:actual === expected ? 'LOCK_MATCH' : 'PROVENANCE_CONFLICT'};
}
function isoMax(values) {
const valid = values.filter(s => typeof s === 'string' && Number.isFinite(Date.parse(s)));
return valid.length ? valid.sort((a, b) => Date.parse(b) - Date.parse(a))[0] : null;
}
export async function collect(config, token, now = new Date(), fetcher = fetch) {
if (config.schema !== 'estate-activity.config.v1' || config.owner !== OWNER ||
!Array.isArray(config.repos) || !config.repos.length ||
!Number.isInteger(config.max_commit_pages) || config.max_commit_pages < 1 || config.max_commit_pages > 5)
throw Error('invalid bounded config');
const days = dayLabels(now, config.lookback_days);
const repos = [];
// Serial reads keep GitHub API usage predictable, avoiding burst rate limiting.
for (const name of config.repos) {
if (!/^[A-Za-z0-9._-]+$/.test(name)) throw Error('invalid repository name');
repos.push(await crawlRepo(name, days, config.max_commit_pages, token, fetcher));
}
const byName = new Map(repos.map(r => [r.repo.split('/')[1], r]));
const pinnedSha = name => byName.get(name)?.head_sha;
for (const name of ['stars','kuiper-belt','ventus-grid-engine']) {
if (!pinnedSha(name)) throw Error('cannot pin essential ' + name + ' main head');
}
const registry = deriveRegistry(JSON.parse(await raw('ventus-grid-engine', pinnedSha('ventus-grid-engine'),
'spider/manifest.json', token, fetcher)));
const standing = parseStanding(await raw('kuiper-belt', pinnedSha('kuiper-belt'),
'cosmos/standing.tsv', token, fetcher));
const starsSource = JSON.parse(await raw('stars', pinnedSha('stars'),
'modular/source.json', token, fetcher));
if (!Array.isArray(starsSource.repositories)) throw Error('Stars catalogue missing pinned repositories');
const cvaaSha=pinnedSha('cvaa');
if (!cvaaSha) throw Error('CVAA HEAD unobserved; do not infer vaccine coverage');
const vaccineName='202609261425-observed-before-asserted.md';
const cvaaLock=JSON.parse(await raw('cvaa',cvaaSha,'vaccines.lock',token,fetcher));
const vaccineText=await raw('cvaa',cvaaSha,'vaccines/'+vaccineName,token,fetcher);
const vaccine=verifyVaccineLock(cvaaLock,vaccineName,vaccineText);
if (vaccine.status !== 'LOCK_MATCH') throw Error('CVAA vaccine bytes do not match pinned lock; refusing publication');
const cvaaPr=await api('/repos/'+OWNER+'/cvaa/pulls/2',token,fetcher);
const runResponse=await api('/repos/'+OWNER+'/cvaa/actions/runs?per_page=35',token,fetcher);
const cvaaAudit=assessCvaaAudit(cvaaPr,runResponse.workflow_runs);
const kuiperPins = [...standing].map(([name, row]) => ({repo: OWNER + '/' + name, sha_prefix: row.sha_prefix}));
const starsPins = starsSource.repositories.map(p => ({repo: p.repo, sha: p.commit}));
const inspected = new Set(repos.map(r => r.repo));
const joins = {
spider_receiver: {manifest_commit: pinnedSha('ventus-grid-engine'), registrations: registry},
kuiper: {source_commit: pinnedSha('kuiper-belt'), file: 'cosmos/standing.tsv',
pinned_rows: standing.size, comparisons: comparePinned(repos, kuiperPins.filter(p => inspected.has(p.repo)))},
stars: {source_commit: pinnedSha('stars'), file: 'modular/source.json',
source_generated_utc: starsSource.generated_utc ?? null, pinned_rows: starsPins.length,
comparisons: comparePinned(repos, starsPins.filter(p => inspected.has(p.repo)))},
cvaa:{source_commit:cvaaSha, vaccine_registry:'vaccines.lock', vaccine,
vaccine_url:'https://github.com/'+OWNER+'/cvaa/blob/'+cvaaSha+'/vaccines/'+vaccineName,
registry_url:'https://github.com/'+OWNER+'/cvaa/blob/'+cvaaSha+'/vaccines.lock',
relationship:'POLICY_REFERENCE_ONLY', audit:cvaaAudit}
};
const pulls = [];
for (const name of config.pr_repos) {
if (!config.repos.includes(name)) throw Error('PR repository not in measured set: ' + name);
const ps = await api('/repos/' + OWNER + '/' + name + '/pulls?state=open&sort=updated&direction=desc&per_page=60', token, fetcher);
if (!Array.isArray(ps)) throw Error('invalid PR response for ' + name);
for (const p of ps) {
if (!/^[a-f0-9]{40}$/i.test(p.head?.sha ?? '')) continue;
pulls.push({repo: OWNER + '/' + name, number: p.number, title: String(p.title ?? '').slice(0, 140),
url: p.html_url, draft: !!p.draft, head_sha: p.head.sha, updated_utc: p.updated_at});
}
}
pulls.sort((a, b) => String(b.updated_utc).localeCompare(String(a.updated_utc)));
const comments = await api('/repos/' + OWNER + '/neural-link-between-agents/issues/comments?sort=created&direction=desc&per_page=100', token, fetcher);
if (!Array.isArray(comments)) throw Error('invalid agent comment response');
const messages = comments.filter(x => isoDay(x.created_at) >= days[0]).slice(0, 35).map(c => {
const tag = /^\s*\[([^\]\n]{3,100})\]/.exec(c.body ?? '');
const safeTag=/^(?:CHATGPT\s+)?AGENT\s+[A-Za-z0-9-]{1,8}\b/i.exec(tag?.[1] ?? '');
return {id:c.id,url:c.html_url,issue_url:c.issue_url,utc:c.created_at,
declared_tag:safeTag ? safeTag[0] : null,
record_type:'MESSAGE_RECORDED', agent_runtime_status:'UNKNOWN'};
// Do not republish public comment bodies: they may contain inadvertently disclosed private details.
});
const events = repos.flatMap(r => r.recent.map(c => c.utc))
.concat(pulls.map(x => x.updated_utc), messages.map(x => x.utc));
return {schema:'estate-activity-spider.v1', owner: OWNER,
observation: 'public GitHub default-branch commits, open PR head snapshots and public issue comments; not individual agent process telemetry',
observed_at_utc:new Date(now).toISOString(),
coverage:{repos_requested:config.repos.length,repos_scanned:repos.length,repo_errors:0},
window_start_utc: days[0] + 'T00:00:00Z', day_labels: days,
latest_event_utc: isoMax(events),
count_rule: '7 UTC calendar days; commit counts may be lower bounds if the API page cap is reached',
repos, pulls: pulls.slice(0, 80), messages, joins, links: config.links,
sources: {github:'GitHub REST API, public repos, exact commits and comment URLs',
stars:'stars/modular/source.json at pinned stars HEAD',
kuiper:'kuiper-belt/cosmos/standing.tsv at pinned Kuiper HEAD',
spider:'ventus-grid-engine/spider/manifest.json at pinned receiver HEAD',
cvaa:'CVAA vaccines.lock and observed-before-asserted vaccine at pinned CVAA HEAD; exact PR #2 audit run'},
qualifications: ['Navigation links are not measured code dependencies.',
'GitHub account comments and their self-declared agent tags do not establish live agent status.',
'Registered graph URLs are not independently verified served HTTP bytes.',
'A pinned CVAA vaccine is policy reference; it does not mean Spider executed the inoculation.',
'CVAA failing audit at an exact PR head remains failed, even if other individual tests passed.',
'Public agent comment bodies are intentionally not copied into the activity snapshot.',
'A Kuiper or Stars pin behind a newer commit is expected between independent scans, not proof of a defect.']};
}
export async function main() {
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
if (!token) throw Error('GITHUB_TOKEN or GH_TOKEN required; do not publish an unauthenticated partial snapshot');
const config = JSON.parse(await readFile(path.join(ROOT, 'config.json'), 'utf8'));
const snapshot = await collect(config, token);
const output = path.join(ROOT, 'data', 'activity.json');
// A rerun with identical observed facts should not create a new Git commit solely
// because the clock advanced. The latest successful check still has an Actions run.
let previous = null;
try { previous = JSON.parse(await readFile(output,'utf8')); }
catch (error) { if (error.code !== 'ENOENT') throw error; }
const facts = value => {
const copy = {...value}; delete copy.observed_at_utc;
return JSON.stringify(copy);
};
if (previous && facts(previous) === facts(snapshot)) {
console.log('No material GitHub activity change; retaining last successful snapshot.');
return;
}
const serialised = JSON.stringify(snapshot, null, 2) + '\n';
await mkdir(path.dirname(output), {recursive: true});
await writeFile(output, serialised, 'utf8');
console.log('activity snapshot: ' + snapshot.repos.length + ' repos, ' + snapshot.pulls.length +
' open PRs, ' + snapshot.messages.length + ' comment references, date window starts ' + snapshot.window_start_utc);
}
if (process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href === import.meta.url) {
main().catch(e => {console.error('ACTIVITY SPIDER HOLD: ' + e.message); process.exitCode = 1;});
}Build Test
A test in the tools folder of Spiders that checks Build using data from GitHub API and the stars repository. It is built from the fake fetch helper (`fakeFetch`).
testspiders / species/estate-activity/tools/build.test.mjs · lines 1–168 of 168 · Entry point · pattern fakeFetch (shared by 2 files)
- What it does
- It tests its inputs. Defines fakeFetch. Uses libraries node:test, node:assert/strict.
- Why it exists in the grid workflow
- Domain stage agent_infra (repository name word 'spiders'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief).
- Inputs & outputs
- In: JSON file graph.json; JSON file nodes.json; JSON file source.json.
- Downstream impact
- Used directly by 1 file: Estate Activity Workflow (spiders).
- What it achieves
- Its name says it builds test. Defines `fakeFetch`.
- Why it matters
- Run by Estate Activity Workflow.
- Application
- spiders · species/estate-activity/tools · test
- Uses
- Build (import), node:test, node:assert/strict
- Used by
- run by Estate Activity Workflow (workflow run)
- Produces
- fakeFetch
- Defines here
- fakeFetch
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/estate-activity/tools/build.test.mjs:1-168 · blob ba14d5c6d01d81ee312dd3f802d6d0025551f800 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: transform · effects: none found · domain stage: agent_infra · users: ai_agent · canonical: unknown
import test from 'node:test';
import assert from 'node:assert/strict';
import {dayLabels, isoDay, summarizeCommits, parseStanding, comparePinned, deriveRegistry, assessCvaaAudit, verifyVaccineLock, collect} from './build.mjs';
const SHA_A = 'a'.repeat(40);
const SHA_B = 'b'.repeat(40);
const SHA_C = 'c'.repeat(40);
const SHA_D = 'd'.repeat(40);
const when = '2026-11-15T12:00:00Z';
const days = dayLabels(when);
test('UTC calendar dates include exactly the current UTC day and previous six days', () => {
assert.deepEqual(days, ['2026-11-09','2026-11-10','2026-11-11','2026-11-12',
'2026-11-13','2026-11-14','2026-11-15']);
assert.equal(isoDay('2026-11-15T00:30:00+02:00'), '2026-11-14');
assert.equal(isoDay('not a date'), null);
});
test('commits are keyed by SHA, never double-counted; a capped response is a lower bound', () => {
const one = {sha:SHA_A,html_url:'https://github.com/Ventusltd/stars/commit/' + SHA_A,
commit:{committer:{date:'2026-11-15T11:00:00Z'},message:'Modular star'}};
const old = {sha:SHA_B,html_url:'https://github.com/Ventusltd/stars/commit/' + SHA_B,
commit:{committer:{date:'2026-11-01T10:00:00Z'},message:'Prior'}};
const a = summarizeCommits('stars',[one,one,old],days,true);
assert.equal(a.head_sha,SHA_A);
assert.equal(a.sample_count,1);
assert.equal(a.count_is_lower_bound,true);
assert.equal(a.day_counts[6].count,1);
assert.equal(a.recent.length,2);
});
test('pinned comparisons distinguish aligned, lagging and unavailable; they never claim failure', () => {
const got = comparePinned([{repo:'Ventusltd/stars',head_sha:SHA_A}],
[{repo:'Ventusltd/stars',sha:SHA_A.slice(0,12)},
{repo:'Ventusltd/stars',sha:SHA_B},
{repo:'Ventusltd/missing',sha:SHA_C}]);
assert.deepEqual(got.map(x=>x.status),['aligned','lagging','unavailable']);
});
test('Kuiper measured rows and Spider manifest links require actual evidence', () => {
const standing = parseStanding('# repo\thead\thead_unix\nstars\t' + SHA_A.slice(0,12) + '\t1794745000\n');
assert.equal(standing.get('stars').sha_prefix,SHA_A.slice(0,12));
assert.throws(()=>parseStanding('# no rows'),/no valid/);
const links = deriveRegistry({graphs:[
{id:'periodic-table',path:'https://ventusltd.github.io/stars/blocks/graph.json'},
{id:'modular',path:'https://ventusltd.github.io/stars/modular/graph.json'},
{id:'proof-of-work',path:'https://ventusltd.github.io/stars/proof/graph.json'},
{id:'genome-spider',path:'https://ventusltd.github.io/spiders/species/genome-spider/data/nodes.json'}
]});
assert.equal(links.filter(x=>x.registered).length,4);
assert.ok(links.every(x=>x.served_bytes_checked===false));
assert.equal(deriveRegistry({graphs:[]}).filter(x=>x.registered).length,0);
assert.throws(()=>deriveRegistry({}),/missing graphs/);
});
test('full mocked crawl links exact repo SHA, Stars source and Kuiper measurements, not agent status', async () => {
const commits = {
stars:SHA_A, 'kuiper-belt':SHA_B, 'ventus-grid-engine':SHA_C,
'neural-link-between-agents':SHA_D, cvaa:'e'.repeat(40)
};
const config={schema:'estate-activity.config.v1', owner:'Ventusltd', lookback_days:7,
max_commit_pages:1, repos:Object.keys(commits),pr_repos:['neural-link-between-agents'],links:[]};
const calls=[];
async function fakeFetch(url) {
calls.push(url);
let payload;
if (url.includes('/commits?since=')) {
const repo=url.split('/repos/Ventusltd/')[1].split('/')[0];
payload=[{sha:commits[repo],html_url:'https://github.com/Ventusltd/'+repo+'/commit/'+commits[repo],
commit:{committer:{date:'2026-11-15T10:00:00Z'},message:'Verified public commit'}}];
} else if(url.includes('/cvaa/pulls/2')) {
payload={number:2,state:'open',html_url:'https://github.com/Ventusltd/cvaa/pull/2',head:{sha:'f'.repeat(40)}};
} else if(url.includes('/cvaa/actions/runs?')) {
payload={workflow_runs:[{id:42,name:'202608301447 Self-test and full-history fleet audit',
head_sha:'f'.repeat(40),created_at:'2026-11-15T10:00:00Z',updated_at:'2026-11-15T10:10:00Z',
status:'completed',conclusion:'failure',html_url:'https://github.com/Ventusltd/cvaa/actions/runs/42'}]};
} else if(url.includes('/pulls?')) {
payload=[{number:35,title:'Research',draft:true,html_url:'https://github.com/Ventusltd/neural-link-between-agents/pull/35',
head:{sha:SHA_D},updated_at:'2026-11-15T11:00:00Z'}];
} else if(url.includes('/issues/comments?')) {
payload=[{id:123,created_at:'2026-11-15T11:20:00Z',
html_url:'https://github.com/Ventusltd/neural-link-between-agents/issues/30#issuecomment-123',
issue_url:'https://api.github.com/repos/Ventusltd/neural-link-between-agents/issues/30',
body:'[AGENT 7] A comment, not proof of a running process'}];
} else if(url.includes('/spider/manifest.json')) {
payload={graphs:[{id:'periodic-table',path:'https://ventusltd.github.io/stars/blocks/graph.json'}]};
} else if(url.includes('/vaccines.lock')) {
payload={['202609261425-observed-before-asserted.md']:'19010486c40033079d62599947777e50993f0da01b2792f48ad512765e7ce9a7'};
} else if(url.includes('/vaccines/202609261425-observed-before-asserted.md')) {
payload='test CVAA vaccine fixture';
} else if(url.includes('/cosmos/standing.tsv')) {
payload='# repo\thead\thead_unix\nstars\t'+SHA_A.slice(0,12)+'\t1794745000\n';
} else if(url.includes('/modular/source.json')) {
payload={generated_utc:'2026-11-15T09:00:00Z',repositories:[
{repo:'Ventusltd/stars',commit:SHA_A},{repo:'Ventusltd/kuiper-belt',commit:SHA_A}
]};
} else throw Error('unrecognised mocked URL: '+url);
return {ok:true,status:200,json:async()=>payload,
text:async()=>typeof payload==='string'?payload:JSON.stringify(payload)};
}
const result=await collect(config,'mock-token',new Date(when),fakeFetch);
assert.equal(result.repos.length,5);
assert.equal(result.pulls.length,1);
assert.equal(result.messages[0].declared_tag,'AGENT 7');
assert.match(result.observation,/not individual agent process telemetry/);
assert.equal(result.joins.kuiper.comparisons[0].status,'aligned');
assert.equal(result.joins.stars.comparisons[1].status,'lagging');
assert.equal(result.joins.spider_receiver.registrations[0].registered,true);
assert.equal(result.joins.cvaa.audit.status,'FAILED_AT_HEAD');
assert.equal(result.joins.cvaa.relationship,'POLICY_REFERENCE_ONLY');
assert.equal(result.joins.cvaa.vaccine.status,'LOCK_MATCH');
assert.ok(!('excerpt' in result.messages[0]));
assert.equal(result.messages[0].agent_runtime_status,'UNKNOWN');
assert.equal(result.coverage.repos_requested,5);
assert.ok(calls.length>=12);
});
test('upstream HTTP failure aborts rather than publishing a fictitious empty graph', async () => {
const config={schema:'estate-activity.config.v1',owner:'Ventusltd',lookback_days:7,
max_commit_pages:1,repos:['stars'],pr_repos:[],links:[]};
await assert.rejects(collect(config,'mock',new Date(when),
async()=>({ok:false,status:403})),/HTTP 403/);
});
test('E2-CVAA-01: green workflow on SHA-A does not certify changed SHA-B', () => {
const pr={number:2,state:'open',head:{sha:SHA_B},html_url:'https://github.com/Ventusltd/cvaa/pull/2'};
const prior=[{name:'202608301447 Self-test and full-history fleet audit',head_sha:SHA_A,
created_at:'2026-11-15T10:00:00Z',status:'completed',conclusion:'success',id:8}];
const result=assessCvaaAudit(pr,prior);
assert.equal(result.status,'NOT_OBSERVED');
assert.equal(result.run_id,null);
assert.equal(result.consumer_inoculation,'NOT_OBSERVED');
});
test('E2-CVAA-02: a vaccine policy without valid pinned digest is rejected', () => {
const name='202609261425-observed-before-asserted.md';
assert.throws(()=>verifyVaccineLock({},name,'contents'),/missing pinned vaccine/);
const bad=verifyVaccineLock({[name]:'a'.repeat(64)},name,'contents');
assert.equal(bad.status,'PROVENANCE_CONFLICT');
});
test('E2-CVAA-03: newest exact-head full audit failure overrides a green subset or older pass', () => {
const pr={number:2,state:'open',head:{sha:SHA_A},html_url:'https://github.com/Ventusltd/cvaa/pull/2'};
const runs=[
{name:'202608301447 Self-test and full-history fleet audit',head_sha:SHA_A,
created_at:'2026-11-15T10:01:00Z',status:'completed',conclusion:'success',id:10},
{name:'202608301447 Self-test and full-history fleet audit',head_sha:SHA_A,
created_at:'2026-11-15T10:03:00Z',status:'completed',conclusion:'failure',id:12},
{name:'Selected tests passing',head_sha:SHA_A,created_at:'2026-11-15T10:04:00Z',
status:'completed',conclusion:'success',id:13}
];
const result=assessCvaaAudit(pr,runs);
assert.equal(result.status,'FAILED_AT_HEAD');
assert.equal(result.run_id,12);
});
test('E2-CVAA-08: public comment declaring an agent does not establish its live process', async () => {
const pr={number:2,state:'open',head:{sha:SHA_A},html_url:'https://github.com/Ventusltd/cvaa/pull/2'};
assert.equal(assessCvaaAudit(pr,[]).status,'NOT_OBSERVED');
assert.notEqual(assessCvaaAudit(pr,[{name:'irrelevant',head_sha:SHA_A,conclusion:'success'}]).status,'PASSED_AT_HEAD');
});
test('E2-CVAA-05: no repositories in configuration cannot be reported as fleet success', async () => {
await assert.rejects(collect({schema:'estate-activity.config.v1',owner:'Ventusltd',
lookback_days:7,max_commit_pages:1,repos:[],pr_repos:[]},'token',
new Date(when),async()=>({ok:true,json:async()=>[]})),/invalid bounded config/);
});Genome Proof
A JavaScript module in the genome spider folder of Spiders that reads GridAtlas lineage and substations, using SHA-256.
ingestspiders / species/genome-spider/genome.proof.mjs · lines 1–160 of 160 · Not reached from any entry point (candidate for review)
- What it does
- It loads GridAtlas lineage and substations. Defines ok, gt. Uses libraries node:fs, node:path, node:url. Side effects: reads or writes files; starts processes.
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'spider'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: substations. README: "`genome.proof.mjs` does not gate on this uncertainty — it's recorded in `dead_code[].reason` verbatim."
- Inputs & outputs
- In: JSON file genome.json; JSON file gridatlas-lineage.json; command-line arguments.
- What it achieves
- Reads a `genome.json` (default: `./data/genome.json`, the output of a real run against the estate) and checks plain-English sentences about it.
- Why it matters
- No other file in the estate was found to import it.
- Application
- spiders · species/genome-spider · JavaScript module
- Uses
- node:fs, node:path, node:url
- Used by
- none found
- Produces
- ok, gt
- Defines here
- ok, gt
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- spiders@78fc0f90bd5ca73f3d5d7c0e0b7b5712cfe781e5 species/genome-spider/genome.proof.mjs:1-160 · blob b01dc2d90371d24be513814e76ad4e5a0f045768 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem, process · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
/**
* genome-spider — proof.
*
* Reads a genome.json (default: ./data/genome.json, the output of a real
* run against the estate) and checks plain-English sentences about it.
* Every check accumulates; nothing short-circuits, so one failure doesn't
* hide the next. Exits non-zero on any failure.
*
* node genome.proof.mjs [path/to/genome.json]
*
* No dependencies.
*/
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const HERE = path.dirname(fileURLToPath(import.meta.url));
const genomePath = process.argv[2] ? path.resolve(process.cwd(), process.argv[2]) : path.join(HERE, 'data', 'genome.json');
const checks = [];
const ok = (name, pass, detail = '') => checks.push({ name, pass: Boolean(pass), detail });
if (!fs.existsSync(genomePath)) {
console.error(`genome.proof.mjs: no genome.json at ${genomePath}. Run spider.mjs first.`);
process.exit(2);
}
let genome;
try {
genome = JSON.parse(fs.readFileSync(genomePath, 'utf8'));
} catch (e) {
console.error(`genome.proof.mjs: ${genomePath} is not valid JSON: ${e.message}`);
process.exit(2);
}
const nodes = Array.isArray(genome.nodes) ? genome.nodes : [];
const edges = Array.isArray(genome.edges) ? genome.edges : [];
const nodeIds = new Set(nodes.map((n) => n.id));
/* ---- shape --------------------------------------------------------------- */
ok('genome.json declares its schema', genome.schema === 'genome-spider.genome.v1', String(genome.schema));
ok('genome.json names the generator that produced it', genome.generator === 'spiders/species/genome-spider/spider.mjs');
ok('at least one repository was actually walked', (genome.repos_walked || []).length > 0, `${(genome.repos_walked || []).length} repos`);
ok('every repository skipped carries a reason, not a silent drop',
(genome.repos_skipped || []).every((r) => typeof r.reason === 'string' && r.reason.length > 0));
/* ---- the rule that matters most: no edge without evidence ---------------- */
const edgesWithoutEvidence = edges.filter((e) => {
const ev = e.evidence;
if (!ev || typeof ev !== 'object') return true;
if (typeof ev.file !== 'string' || ev.file.length === 0) return true;
if (typeof ev.pattern !== 'string' || ev.pattern.length === 0) return true;
return false;
});
ok('every edge cites the file and pattern that detected it',
edgesWithoutEvidence.length === 0,
edgesWithoutEvidence.length ? `${edgesWithoutEvidence.length} edges with no usable evidence, e.g. ${JSON.stringify(edgesWithoutEvidence[0])}` : '');
const edgesWithDanglingEndpoints = edges.filter((e) => !nodeIds.has(e.from) || !nodeIds.has(e.to));
ok('every edge in genome.json points at a node genome.json also declares',
edgesWithDanglingEndpoints.length === 0,
edgesWithDanglingEndpoints.length ? `${edgesWithDanglingEndpoints.length} dangling, e.g. ${JSON.stringify(edgesWithDanglingEndpoints[0])}` : '');
/* ---- the other rule that matters: no node without commit history --------- */
const reposByName = new Set(nodes.filter((n) => !n.path).map((n) => n.repo));
const nodesWithoutHistory = nodes.filter((n) => n.kind !== 'external' && (!n.last_commit || !n.last_commit.sha || !n.last_commit.date));
ok('every non-external node carries a real last commit (sha + date)',
nodesWithoutHistory.length === 0,
nodesWithoutHistory.length ? `${nodesWithoutHistory.length} nodes with no last_commit, e.g. ${nodesWithoutHistory[0].id}` : '');
const nodesWithoutCount = nodes.filter((n) => n.kind !== 'external' && (n.commit_count === null || n.commit_count === undefined));
ok('every non-external node carries a commit_count',
nodesWithoutCount.length === 0,
nodesWithoutCount.length ? `${nodesWithoutCount.length} nodes, e.g. ${nodesWithoutCount[0].id}` : '');
/* ---- node ids are unique and every repo-unit node names a real repo ------ */
const dupIds = nodes.map((n) => n.id).filter((id, i, arr) => arr.indexOf(id) !== i);
ok('no two nodes share an id', dupIds.length === 0, dupIds.length ? dupIds.slice(0, 3).join(', ') : '');
const unitsWithBadRepo = nodes.filter((n) => n.path && !reposByName.has(n.repo));
ok('every unit node (one with a path) names a repository node genome.json also declares',
unitsWithBadRepo.length === 0,
unitsWithBadRepo.length ? `${unitsWithBadRepo.length}, e.g. ${unitsWithBadRepo[0].id}` : '');
/* ---- markers are internally consistent ------------------------------------ */
const markers = genome.markers || {};
const dup = markers.duplication || [];
ok('every duplication group actually has more than one copy',
dup.every((d) => Array.isArray(d.copies) && d.copies.length > 1),
`${dup.filter((d) => !(d.copies && d.copies.length > 1)).length} malformed`);
ok('every duplication group declares whether its copies agree',
dup.every((d) => typeof d.agree === 'boolean'));
const drift = markers.drift || [];
ok('every drift entry names the method that found it',
drift.every((d) => typeof d.method === 'string' && d.method.length > 0));
const dead = markers.dead_code || [];
ok('every dead-code finding names the node, repo and path it concerns',
dead.every((d) => d.node && d.repo && d.path));
ok('every dead-code finding names a node genome.json actually declares',
dead.every((d) => nodeIds.has(d.node)),
dead.filter((d) => !nodeIds.has(d.node)).map((d) => d.node).join(', '));
const uncomposed = markers.uncomposed || [];
ok('every uncomposed finding names the manifest it is stale against',
uncomposed.every((u) => typeof u.manifest === 'string' && u.manifest.length > 0));
ok('every uncomposed finding uses a declared method (sha256-mismatch or commit-date-after-last-composition)',
uncomposed.every((u) => u.method === 'sha256-mismatch' || u.method === 'commit-date-after-last-composition'));
const reDoing = markers.re_doing || [];
ok('every re-doing group was rebuilt more than once',
reDoing.every((g) => g.count > 1),
`${reDoing.filter((g) => !(g.count > 1)).length} malformed`);
/* ---- ground truth: the estate defects genome-spider was built to find ---- */
// These are informational, not hard failures — a fixed defect (see
// gridatlas commit b7a40d1, 2026-09-04) disappearing from a later run is
// success, not proof breakage. They are still printed so a human can see
// whether the detectors are exercised at all, which a silently-empty
// marker list would hide.
const groundTruth = [];
const gt = (name, pass, detail) => groundTruth.push({ name, pass, detail });
gt('gridatlas/atlas/modules/202609011950-substation-lookup.js is flagged dead code',
dead.some((d) => d.path === 'atlas/modules/202609011950-substation-lookup.js' && d.repo === 'gridatlas'));
gt('an earth-radius drift (6378.137 / 6371.0088 / 6384.7272) was detected somewhere in the estate',
drift.some((d) => d.method === 'known-family:earth-radius-km' && d.is_drift));
gt('ventus-grid-engine is present as a node',
nodes.some((n) => n.repo === 'ventus-grid-engine' && !n.path));
/* ---- gridatlas-lineage.json, if this run produced one -------------------- */
const lineagePath = path.join(path.dirname(genomePath), 'gridatlas-lineage.json');
if (fs.existsSync(lineagePath)) {
const lineage = JSON.parse(fs.readFileSync(lineagePath, 'utf8'));
const lNodeIds = new Set((lineage.nodes || []).map((n) => n.id));
ok('gridatlas-lineage.json declares its schema', lineage.schema === 'genome-spider.gridatlas-lineage.v1');
const lEdgesNoEvidence = (lineage.edges || []).filter((e) => !e.evidence || !e.evidence.file || !e.evidence.pattern);
ok('every lineage edge cites the file and pattern that detected it', lEdgesNoEvidence.length === 0,
lEdgesNoEvidence.length ? `${lEdgesNoEvidence.length} edges` : '');
const lDangling = (lineage.edges || []).filter((e) => !lNodeIds.has(e.from) || !lNodeIds.has(e.to));
ok('every lineage edge points at a node the lineage file also declares', lDangling.length === 0,
lDangling.length ? `${lDangling.length}, e.g. ${JSON.stringify(lDangling[0])}` : '');
ok('the lineage walk did not silently truncate — generations_walked and compositions_available_on_disk are both recorded',
typeof lineage.generations_walked === 'number' && typeof lineage.compositions_available_on_disk === 'number');
}
/* ---- report --------------------------------------------------------------- */
const failed = checks.filter((c) => !c.pass);
for (const c of checks) {
console.log(` [${c.pass ? 'PASS' : 'FAIL'}] ${c.name}${c.detail ? ' ' + c.detail : ''}`);
}
console.log(`\n${checks.length - failed.length}/${checks.length} checks passed`);
console.log('\nGround truth (informational — see comment above, not a pass/fail gate):');
for (const g of groundTruth) {
console.log(` [${g.pass ? 'FOUND' : 'not found this run'}] ${g.name}${g.detail ? ' ' + g.detail : ''}`);
}
process.exit(failed.length ? 1 : 0);