tr-plugin-meta-harness 0.3.0 → 0.5.26
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/DESIGN.md +86 -0
- package/README.md +257 -11
- package/capability/BRICK.md +1 -1
- package/capability/index.mjs +154 -13
- package/cli.mjs +426 -41
- package/package.json +15 -3
- package/plugin.json +1457 -119
- package/skills/meta-harness/SKILL.md +63 -25
- package/src/adoption.mjs +102 -0
- package/src/agent-user.mjs +194 -0
- package/src/alerts.mjs +220 -14
- package/src/cascade.mjs +185 -0
- package/src/chat.mjs +80 -0
- package/src/codex-models.mjs +54 -0
- package/src/compat-harness.mjs +114 -0
- package/src/control.mjs +145 -0
- package/src/coordinator.mjs +267 -358
- package/src/dispatch-request.mjs +76 -0
- package/src/dispatch.mjs +119 -0
- package/src/documentation-authority.mjs +57 -0
- package/src/documentation.mjs +120 -32
- package/src/executor.mjs +101 -22
- package/src/gate-adapters/agy.mjs +155 -0
- package/src/gate-adapters/claude.mjs +303 -0
- package/src/gate-adapters/cline.mjs +111 -0
- package/src/gate-adapters/codex.mjs +164 -0
- package/src/gate-adapters/cursor.mjs +164 -0
- package/src/gate-adapters/devin.mjs +116 -0
- package/src/gate-adapters/dsh.mjs +284 -0
- package/src/gate-adapters/grok.mjs +112 -0
- package/src/gate-adapters/hermes.mjs +217 -0
- package/src/gate-adapters/hook-files.mjs +156 -0
- package/src/gate-adapters/index.mjs +131 -0
- package/src/gate-adapters/openclaw-plugin/gate-client.js +205 -0
- package/src/gate-adapters/openclaw-plugin/index.js +25 -0
- package/src/gate-adapters/openclaw-plugin/openclaw.plugin.json +9 -0
- package/src/gate-adapters/openclaw-plugin/package.json +15 -0
- package/src/gate-adapters/openclaw.mjs +288 -0
- package/src/gate-adapters/pi.mjs +146 -0
- package/src/gate.mjs +18 -0
- package/src/harness-updates.mjs +170 -0
- package/src/included-usage.mjs +344 -0
- package/src/jobs.mjs +135 -0
- package/src/json-reply.mjs +22 -0
- package/src/learner.mjs +97 -67
- package/src/maintenance.mjs +18 -0
- package/src/mcp-server.mjs +228 -0
- package/src/model-catalog.mjs +195 -0
- package/src/model-selection.mjs +67 -0
- package/src/paths.mjs +23 -0
- package/src/pool.mjs +69 -0
- package/src/process-manager.mjs +246 -0
- package/src/process-worker.mjs +18 -0
- package/src/reasoning.mjs +231 -0
- package/src/remote-operation.mjs +76 -0
- package/src/review.mjs +241 -0
- package/src/reviews.mjs +25 -0
- package/src/router-benchmark-corpus.mjs +16 -0
- package/src/router-benchmark.mjs +208 -0
- package/src/router.mjs +265 -346
- package/src/runtime.mjs +30 -8
- package/src/session/claude.mjs +358 -0
- package/src/session/codex.mjs +501 -0
- package/src/session/result.mjs +90 -0
- package/src/session/resume.mjs +393 -0
- package/src/session/run.mjs +258 -0
- package/src/session-jobs.mjs +77 -0
- package/src/setup.mjs +6 -3
- package/src/ssss-store.mjs +20 -0
- package/src/telemetry.mjs +267 -0
- package/src/termination.mjs +28 -0
- package/src/threads.mjs +150 -0
- package/src/usage-queue.mjs +137 -0
- package/src/verify-ssss.mjs +102 -0
- package/src/worker.mjs +955 -84
- package/src/worktree.mjs +244 -0
- package/ui/chunks/adapter-docs-freshness.md +16 -0
- package/ui/chunks/chat-handoff.md +26 -0
- package/ui/chunks/fleet-maintenance.md +21 -0
- package/ui/chunks/harness-inventory.md +21 -0
- package/ui/chunks/included-access.md +18 -0
- package/ui/chunks/included-usage-verification.md +15 -0
- package/ui/chunks/independent-review.md +17 -0
- package/ui/chunks/managed-execution.md +20 -0
- package/ui/chunks/official-documentation.md +18 -0
- package/ui/chunks/quota-recovery.md +21 -0
- package/ui/chunks/review-routing-decision.md +16 -0
- package/ui/chunks/route-work.md +18 -0
- package/ui/chunks/routing-evidence.md +18 -0
- package/ui/chunks/run-ledger.md +18 -0
- package/ui/chunks/session-controls.md +16 -0
- package/ui/home.js +198 -0
- package/ui/DESIGN.md +0 -32
- package/ui/card.js +0 -845
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** Measures existing routers. This module never dispatches an agent or executes a plugin operation. */
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
7
|
+
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { ROUTER_CORPUS } from './router-benchmark-corpus.mjs';
|
|
9
|
+
import { configDir } from './paths.mjs';
|
|
10
|
+
|
|
11
|
+
const hash = value => createHash('sha256').update(typeof value === 'string' ? value : JSON.stringify(value)).digest('hex');
|
|
12
|
+
const bytes = value => Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
13
|
+
const mean = values => values.length ? values.reduce((a, b) => a + b, 0) / values.length : null;
|
|
14
|
+
const percentile = (values, p) => values.length ? [...values].sort((a, b) => a - b)[Math.ceil(values.length * p) - 1] : null;
|
|
15
|
+
const timings = rows => ({ samples: rows.length, p50Ms: percentile(rows.map(r => r.durationMs), .5), p95Ms: percentile(rows.map(r => r.durationMs), .95) });
|
|
16
|
+
|
|
17
|
+
export function validateCorpus(corpus) {
|
|
18
|
+
if (corpus?.schemaVersion !== 1 || !corpus.id || !corpus.version || !Array.isArray(corpus.cases) || !corpus.cases.length) throw new Error('Invalid corpus schema/version/cases');
|
|
19
|
+
const ids = new Set();
|
|
20
|
+
for (const c of corpus.cases) {
|
|
21
|
+
if (!c.id || ids.has(c.id) || typeof c.intent !== 'string' || !c.intent.trim() || !c.provenance || !['capability', 'harness'].includes(c.layer) || !['cli', 'api', 'mcp', 'router'].includes(c.surface)) throw new Error(`Invalid corpus case ${c.id}`);
|
|
22
|
+
ids.add(c.id);
|
|
23
|
+
if (c.layer === 'capability' && (!Array.isArray(c.groups) || c.groups.some(g => !Array.isArray(g) || !g.length || g.some(id => typeof id !== 'string' || !id)))) throw new Error(`Invalid expected groups ${c.id}`);
|
|
24
|
+
if (c.layer === 'harness' && (!['ready', 'inactive', 'quota'].includes(c.scenario) || !Array.isArray(c.expected) || c.expected.some(id => !['codex', 'claude'].includes(id)))) throw new Error(`Invalid harness scenario ${c.id}`);
|
|
25
|
+
}
|
|
26
|
+
return corpus;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Bind only to a verified host's real retrieval implementation, never a benchmark replacement. */
|
|
30
|
+
export async function loadCapabilityRouter({ coreRoot } = {}) {
|
|
31
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
const roots = coreRoot ? [coreRoot] : [process.env.TR_PACKAGE_ROOT, path.resolve(here, '../node_modules/total-recall-brain')].filter(Boolean);
|
|
33
|
+
for (const candidate of roots) {
|
|
34
|
+
let root, pkg;
|
|
35
|
+
try { root = fs.realpathSync(candidate); pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); } catch { continue; }
|
|
36
|
+
if (pkg.name !== 'total-recall-brain') continue;
|
|
37
|
+
const predictor = path.join(root, 'src/core/action-predictor.mjs');
|
|
38
|
+
const index = path.join(root, 'src/core/cli-semantic-index.mjs');
|
|
39
|
+
if (!fs.existsSync(predictor) || !fs.existsSync(index) || !fs.existsSync(path.join(root, 'bin/total-recall.mjs'))) continue;
|
|
40
|
+
const [actions, retrieval] = await Promise.all([import(pathToFileURL(predictor).href), import(pathToFileURL(index).href)]);
|
|
41
|
+
const catalogModule = path.join(root, 'src/core/plugin-catalog.mjs');
|
|
42
|
+
const query = (intent, options, actionableOnly) => retrieval.queryCliSemanticIndex(intent, { ...options, minScore: 0, actionableOnly });
|
|
43
|
+
return { shortlist: (intent, options) => query(intent, options, true), query: (intent, options) => query(intent, options, false),
|
|
44
|
+
questions: actions.buildActionQuestions, harvest: retrieval.harvestAllCliVerbs,
|
|
45
|
+
source: { implementation: 'queryCliSemanticIndex', hostVersion: pkg.version, root,
|
|
46
|
+
predictorHash: hash(fs.readFileSync(predictor)), retrievalHash: hash(fs.readFileSync(index)),
|
|
47
|
+
catalogHash: fs.existsSync(catalogModule) ? hash(fs.readFileSync(catalogModule)) : null } };
|
|
48
|
+
}
|
|
49
|
+
throw new Error('Real capability router unavailable: invalid selected core root');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function readInstalledCatalog({ coreRoot, projectRoot = process.cwd() } = {}) {
|
|
53
|
+
if (!coreRoot) throw new Error('Installed catalog unavailable: verified coreRoot required');
|
|
54
|
+
let catalog;
|
|
55
|
+
try { catalog = JSON.parse(execFileSync(process.execPath, [path.join(coreRoot, 'bin/total-recall.mjs'), 'composable-cli', 'library', '--json'], {
|
|
56
|
+
cwd: projectRoot, env: { ...process.env, TR_PACKAGE_ROOT: coreRoot }, encoding: 'utf8', timeout: 30000, maxBuffer: 32 * 1024 * 1024 })); }
|
|
57
|
+
catch (error) { throw new Error(`Installed catalog unavailable: ${error.message}`); }
|
|
58
|
+
if (!Array.isArray(catalog?.plugins) || !catalog.plugins.length || !Array.isArray(catalog.commands) || !catalog.fingerprint) throw new Error('Installed catalog missing plugins, commands or fingerprint');
|
|
59
|
+
return catalog;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const capabilitySurface = c => ({ api: 'api', 'mcp-tool': 'mcp', 'mcp-server': 'mcp', 'api-router': 'router', cli: 'cli', core: 'cli', composed: 'cli' }[c.kind] || (c.id?.split(':').length === 3 ? 'cli' : null));
|
|
63
|
+
export function catalogCases(catalog, count) {
|
|
64
|
+
const records = catalog.capabilities || catalog.commands.map(c => ({ ...c, id: `plugin:${c.plugin}:${c.name}`, kind: 'cli' }));
|
|
65
|
+
const operations = records.filter(c => capabilitySurface(c) && c.id && c.description && !['on', 'off', 'root'].includes(c.name));
|
|
66
|
+
const owners = new Set();
|
|
67
|
+
const surfaces = new Set();
|
|
68
|
+
const ordered = [...operations.filter(c => { const surface = capabilitySurface(c); if (surfaces.has(surface)) return false; surfaces.add(surface); return true; }), ...operations.filter(c => { const key = `${c.plugin}:${capabilitySurface(c)}`; if (owners.has(key)) return false; owners.add(key); return true; }), ...operations];
|
|
69
|
+
const seen = new Set();
|
|
70
|
+
return ordered.filter(c => { if (seen.has(c.id)) return false; seen.add(c.id); return true; }).slice(0, count).map(c => ({
|
|
71
|
+
id: `catalog:${c.id}`, layer: 'capability', surface: capabilitySurface(c), kind: 'description-probe', provenance: `catalog:${catalog.fingerprint}:${c.id}`,
|
|
72
|
+
intent: c.description, groups: [[c.id]],
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Only a declared CLI identity can supply a legacy alias. No router response is used. */
|
|
77
|
+
export function resolveLabels(c, records) {
|
|
78
|
+
const aliases = new Map();
|
|
79
|
+
for (const r of records) {
|
|
80
|
+
aliases.set(r.id, r.id);
|
|
81
|
+
if (r.kind === 'cli' && r.plugin && r.name) aliases.set(`plugin:${r.plugin}:${r.name}`, r.id);
|
|
82
|
+
else if (r.id?.startsWith('plugin:') && r.id.split(':').length === 3) {
|
|
83
|
+
const [, owner, name] = r.id.split(':'); aliases.set(`plugin:${owner}:cli:${encodeURIComponent(name)}`, r.id);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { ...c, groups: c.groups.map(g => [...new Set(g.map(id => aliases.get(id) || id))]) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function scoreRetrieval(c, hits, universe) {
|
|
90
|
+
const ids = [...new Set(hits.map(h => h.id))];
|
|
91
|
+
const groups = c.groups;
|
|
92
|
+
const ranks = groups.map(g => ids.findIndex(id => universe.has(id) && g.includes(id)) + 1);
|
|
93
|
+
return { ids, labelCoverage: groups.length ? groups.filter(g => g.some(id => universe.has(id))).length / groups.length : null,
|
|
94
|
+
recallAtK: groups.length ? ranks.filter(Boolean).length / groups.length : null,
|
|
95
|
+
reciprocalRank: groups.length ? mean(ranks.map(r => r ? 1 / r : 0)) : null,
|
|
96
|
+
topOneCorrect: groups.length === 1 ? Number(universe.has(ids[0]) && groups[0].includes(ids[0])) : null,
|
|
97
|
+
allStepsCovered: groups.length > 1 ? ranks.every(Boolean) : null,
|
|
98
|
+
refusalCorrect: null, refusalReason: groups.length ? null : 'Retrieval ranks candidates; no abstention contract. Decision stage not evaluated.' };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function harnessScenario(c) {
|
|
102
|
+
const { routeTask } = await import('./router.mjs');
|
|
103
|
+
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'mh-benchmark-'));
|
|
104
|
+
const previous = process.env.TR_SECRETS_BRAIN;
|
|
105
|
+
process.env.TR_SECRETS_BRAIN = scratch;
|
|
106
|
+
try {
|
|
107
|
+
const agents = ['codex', 'claude'].map(id => ({ id, installed: true, versionVerified: true, version: 'scenario', authenticated: c.scenario !== 'inactive' }));
|
|
108
|
+
const receipts = c.scenario === 'quota' ? agents.map(a => ({ harness: a.id, success: false, failureKind: 'quota', timestamp: new Date().toISOString(), resetsAt: new Date(Date.now() + 3600000).toISOString() })) : [];
|
|
109
|
+
const result = await routeTask(c.intent, { inspect: async () => ({ agents }), receipts: async () => receipts,
|
|
110
|
+
fleet: () => ({ ok: true, nodes: [] }), openRouterKey: '', openRouterManagementKey: '', codexAllowance: async () => { throw new Error('Unexpected provider probe'); }, recordReceipt: async () => { throw new Error('Unexpected receipt mutation'); } });
|
|
111
|
+
const correct = c.expected.length ? c.expected.includes(result.selected) : !result.selected;
|
|
112
|
+
return { selected: result.selected, tier: result.tier, excluded: result.excluded, correct, refusalCorrect: c.expected.length ? null : correct,
|
|
113
|
+
candidates: result.candidates, evidence: 'Real routeTask with declared readiness/receipt scenario; not live provider readiness' };
|
|
114
|
+
} finally {
|
|
115
|
+
if (previous === undefined) delete process.env.TR_SECRETS_BRAIN; else process.env.TR_SECRETS_BRAIN = previous;
|
|
116
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function checkThresholds(report, { minRecall, minMrr, maxP95Ms, baseline, maxRecallDrop = 0, allowCatalogChange = false } = {}) {
|
|
121
|
+
const failures = [];
|
|
122
|
+
for (const [name, value, min, max] of [['minRecall', minRecall, 0, 1], ['minMrr', minMrr, 0, 1], ['maxP95Ms', maxP95Ms, 0, Infinity], ['maxRecallDrop', maxRecallDrop, 0, 1]]) {
|
|
123
|
+
if (value !== undefined && (!Number.isFinite(value) || value < min || value > max)) throw new Error(`Invalid ${name}`);
|
|
124
|
+
}
|
|
125
|
+
const measured = report.capability;
|
|
126
|
+
for (const [name, value, limit, lower] of [['recallAtK', measured.recallAtK, minRecall, true], ['mrr', measured.mrr, minMrr, true], ['p95Ms', measured.latency.p95Ms, maxP95Ms, false]]) {
|
|
127
|
+
if (limit !== undefined && (!Number.isFinite(value) || (lower ? value < limit : value > limit))) failures.push({ metric: name, actual: value, threshold: limit });
|
|
128
|
+
}
|
|
129
|
+
if (baseline) {
|
|
130
|
+
if (baseline.schemaVersion !== 1 || baseline.corpus?.hash !== report.corpus.hash || (!allowCatalogChange && baseline.catalog?.hash !== report.catalog.hash) || baseline.configuration?.k !== report.configuration.k || baseline.configuration?.repeats !== report.configuration.repeats || baseline.configuration?.retrieval?.split(':', 1)[0] !== report.configuration.retrieval) throw new Error('Incompatible baseline corpus/catalog/configuration');
|
|
131
|
+
if (allowCatalogChange && (baseline.corpus?.labelMapping !== report.corpus.labelMapping || baseline.corpus?.resolvedLabelsHash !== report.corpus.resolvedLabelsHash)) throw new Error('Incompatible baseline label mappings');
|
|
132
|
+
if (!Number.isFinite(baseline.capability.recallAtK) || measured.recallAtK === null) throw new Error('Baseline has no comparable recall');
|
|
133
|
+
if (baseline.capability.recallAtK - measured.recallAtK > maxRecallDrop) failures.push({ metric: 'recallDrop', actual: baseline.capability.recallAtK - measured.recallAtK, threshold: maxRecallDrop });
|
|
134
|
+
}
|
|
135
|
+
return failures;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function runRouterBenchmark(options = {}) {
|
|
139
|
+
const { k = 20, repeats = 3, catalogSamples = 24, projectRoot = process.cwd() } = options;
|
|
140
|
+
for (const [name, value, max] of [['k', k, 1000], ['repeats', repeats, 100], ['catalogSamples', catalogSamples, 10000]]) if (!Number.isInteger(value) || value < (name === 'catalogSamples' ? 0 : 1) || value > max) throw new Error(`Invalid ${name}`);
|
|
141
|
+
const startedAt = new Date().toISOString();
|
|
142
|
+
const adapter = options.adapter || await loadCapabilityRouter({ coreRoot: options.coreRoot });
|
|
143
|
+
if (options.coreRoot && adapter.source?.root !== fs.realpathSync(options.coreRoot)) throw new Error('Host-source identity mismatch');
|
|
144
|
+
const catalog = options.catalog || readInstalledCatalog({ coreRoot: adapter.source.root, projectRoot });
|
|
145
|
+
if (!Array.isArray(catalog.plugins) || !catalog.plugins.length || !Array.isArray(catalog.commands) || (!catalog.commands.length && !catalog.capabilities?.length) || !catalog.fingerprint) throw new Error('Installed catalog missing plugins, commands or fingerprint');
|
|
146
|
+
const base = validateCorpus(options.corpus || ROUTER_CORPUS);
|
|
147
|
+
const corpus = validateCorpus({ ...base, cases: [...base.cases, ...catalogCases(catalog, catalogSamples)] });
|
|
148
|
+
const harvested = adapter.harvest({ projectRoot });
|
|
149
|
+
if (!harvested.length) throw new Error('Router harvested no capabilities');
|
|
150
|
+
const universe = new Set(harvested.map(h => h.id));
|
|
151
|
+
if (catalog.capabilities?.some(c => !universe.has(c.id))) throw new Error('Host-source identity mismatch: catalog capability missing from harvest');
|
|
152
|
+
const resolved = corpus.cases.filter(c => c.layer === 'capability').map(c => resolveLabels(c, harvested));
|
|
153
|
+
const byCase = new Map(resolved.map(c => [c.id, c]));
|
|
154
|
+
const actionableUniverse = new Set(harvested.filter(c => c.callable !== false).map(c => c.id));
|
|
155
|
+
const samples = [], unsupported = [];
|
|
156
|
+
const lookup = { limit: k, projectRoot, queryEmbedding: null };
|
|
157
|
+
for (let pass = 0; pass < repeats; pass++) for (const c of corpus.cases) {
|
|
158
|
+
const start = performance.now();
|
|
159
|
+
if (c.layer === 'harness') {
|
|
160
|
+
const routed = await harnessScenario(c);
|
|
161
|
+
samples.push({ caseId: c.id, layer: c.layer, kind: c.kind, pass, ...routed, durationMs: performance.now() - start });
|
|
162
|
+
} else {
|
|
163
|
+
const hits = await (adapter.query || adapter.shortlist)(c.intent, lookup);
|
|
164
|
+
const durationMs = performance.now() - start;
|
|
165
|
+
samples.push({ caseId: c.id, layer: c.layer, kind: c.kind, pass, ...scoreRetrieval(byCase.get(c.id), hits, universe), durationMs,
|
|
166
|
+
candidates: hits.length, candidateReduction: 1 - hits.length / universe.size,
|
|
167
|
+
questionBytes: bytes(adapter.questions(hits, { intent: c.intent })), intentBytes: Buffer.byteLength(c.intent, 'utf8') });
|
|
168
|
+
const actionStart = performance.now();
|
|
169
|
+
const actions = await adapter.shortlist(c.intent, lookup);
|
|
170
|
+
samples.push({ caseId: c.id, layer: 'actionable', kind: c.kind, pass, ...scoreRetrieval(byCase.get(c.id), actions, actionableUniverse), durationMs: performance.now() - actionStart });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
for (const surface of ['api', 'mcp', 'router']) if (!harvested.some(c => capabilitySurface(c) === surface)) unsupported.push({ surface, reason: 'No installed declarations for this surface; live coverage missing' });
|
|
174
|
+
const capability = samples.filter(s => s.layer === 'capability'), harness = samples.filter(s => s.layer === 'harness');
|
|
175
|
+
const average = (rows, field) => mean(rows.map(s => s[field]).filter(Number.isFinite));
|
|
176
|
+
const summary = rows => ({ recallAtK: average(rows, 'recallAtK'), mrr: average(rows, 'reciprocalRank'), topOneAccuracy: average(rows, 'topOneCorrect'), labelCoverage: average(rows, 'labelCoverage'), samples: rows.length });
|
|
177
|
+
const sourceFiles = ['router-benchmark.mjs', 'router-benchmark-corpus.mjs', 'router.mjs', 'pool.mjs', '../capability/index.mjs'];
|
|
178
|
+
const report = { schemaVersion: 1, id: randomUUID(), owner: 'meta-harness', benchmark: 'router-efficiency', startedAt, finishedAt: new Date().toISOString(),
|
|
179
|
+
source: { capability: adapter.source, ownerVersion: JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url))).version,
|
|
180
|
+
hashes: Object.fromEntries(sourceFiles.map(f => [f, hash(fs.readFileSync(new URL(f, import.meta.url), 'utf8'))])) },
|
|
181
|
+
configuration: { k, repeats, catalogSamples, projectRoot, retrieval: 'lexical', providerMode: 'none', execution: false },
|
|
182
|
+
corpus: { id: corpus.id, version: corpus.version, hash: hash(corpus), labelMapping: 'declared-cli-identity-v1', resolvedLabelsHash: hash(resolved.map(c => ({ id: c.id, groups: c.groups.map(g => g.map(id => id.replace(/^(plugin:[^:]+):cli:([^:]+)$/, '$1:$2'))) }))), cases: corpus.cases.length, data: corpus },
|
|
183
|
+
catalog: { sourceRoot: adapter.source.root || null, changedFromBaseline: options.baseline ? options.baseline.catalog.hash !== hash(catalog) : null, schemaVersion: catalog.schemaVersion, fingerprint: catalog.fingerprint, hash: hash(catalog), plugins: catalog.plugins.length, commands: catalog.commands.length,
|
|
184
|
+
harvested: universe.size, harvestedHash: hash(harvested), declaredActivation: catalog.plugins.map(p => ({ id: p.id, activation: p.activation })) },
|
|
185
|
+
actionable: { ...summary(samples.filter(s => s.layer === 'actionable')), latency: timings(samples.filter(s => s.layer === 'actionable')), mode: 'actual-catalog-query:callable-only', decisionCorrectness: null },
|
|
186
|
+
capability: { mode: 'actual-catalog-query:all-declarations', ...summary(capability), independent: summary(capability.filter(s => s.kind !== 'description-probe')), descriptionProbes: summary(capability.filter(s => s.kind === 'description-probe')),
|
|
187
|
+
surfaces: Object.fromEntries(['cli', 'api', 'mcp', 'router'].map(surface => [surface, { declarations: harvested.filter(c => capabilitySurface(c) === surface).length, ...summary(capability.filter(s => corpus.cases.find(c => c.id === s.caseId)?.surface === surface)) }])),
|
|
188
|
+
latency: timings(capability), firstCall: timings(capability.slice(0, 1)), warm: timings(capability.filter(s => s.pass > 0)),
|
|
189
|
+
meanCandidateReduction: average(capability, 'candidateReduction'), meanQuestionBytes: average(capability, 'questionBytes'), meanIntentBytes: average(capability, 'intentBytes'),
|
|
190
|
+
fullCatalogQuestionBytes: bytes(adapter.questions(harvested)), refusalCorrectness: null },
|
|
191
|
+
harness: { samples: harness.length, correctness: harness.length ? mean(harness.map(s => Number(s.correct))) : null,
|
|
192
|
+
refusalCorrectness: mean(harness.filter(s => s.refusalCorrect !== null).map(s => Number(s.refusalCorrect))), latency: timings(harness), mode: 'readiness-scenarios' },
|
|
193
|
+
calls: { actionableRouter: samples.filter(s => s.layer === 'actionable').length, capabilityRouter: capability.length, harnessRouter: harness.length, provider: 0, dispatch: 0 },
|
|
194
|
+
dispatchAvoidance: { avoidedByBenchmark: samples.length, routerDecisionAvoidance: null, note: 'Read-only evaluator dispatches nothing; this is not measured router decision savings' },
|
|
195
|
+
missingMetrics: { tokens: null, costUSD: null, actualProviderPromptBytes: null, decisionCorrectness: null, liveHarnessReadiness: null, capabilityRefusalCorrectness: null, inactiveCapabilityFiltering: null,
|
|
196
|
+
reason: 'No provider/Decision/dispatch execution; retrieval has no refusal or activation enforcement contract. Harness scenarios are controlled inputs.' },
|
|
197
|
+
latencyNotes: 'First measured retrieval call, not fresh OS/module caches. Warm means repeated corpus passes. Harness includes disposable scenario setup. No embedding network calls.',
|
|
198
|
+
unsupported, samples };
|
|
199
|
+
report.thresholdFailures = checkThresholds(report, options);
|
|
200
|
+
report.ok = report.thresholdFailures.length === 0;
|
|
201
|
+
if (options.save) {
|
|
202
|
+
const { PluginStateStore } = await import('./ssss-store.mjs');
|
|
203
|
+
const store = new PluginStateStore(path.join(configDir(), 'router-benchmarks.jsonl'), 'meta-harness');
|
|
204
|
+
store.append(report);
|
|
205
|
+
report.persistence = { document: store.documentPath, owner: 'meta-harness', format: 'plugin-store:ledger' };
|
|
206
|
+
}
|
|
207
|
+
return report;
|
|
208
|
+
}
|