mirror of
https://github.com/block/buzz.git
synced 2026-11-01 06:51:17 +00:00
Rebased onto origin/main (5bf78671f4).
Conflict resolved in crates/buzz-agent/src/config.rs: kept our generated
anthropic_thinking_config_generated as the sole authority; absorbed main's
thinking shapes, ThinkingSummary enum + parse_thinking_summary, and the
thinking_summary field in Config wired through from_env / for_discovery.
Fixed CI job (model-capabilities): actions/checkout comment v6 → v6.0.3,
Swatinem/rust-cache SHA bumped to tagged v2.9.1 (c1937114) to resolve
zizmor ref-version-mismatch finding (r3730151005).
62ebc9431 fix(model-capabilities): collapse empty segments in Rust gpt-version-segment matcher
817b88790 test(file-size): fix fileOverrides integration test under GITHUB_ACTIONS
1e9df5568 fix(manifest): enforce registry_label exclusion on family rules; test fileOverrides boundary
0e6aacfd2 fix(buzz-agent): curate display name in configured_model_fallback
77c24ef32 chore(manifest): remove dead registry_labels key
Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
115 lines
4.0 KiB
JavaScript
115 lines
4.0 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Normative corpus runner — validates the generated TS interpreter against
|
|
* scripts/normative-corpus.json.
|
|
*
|
|
* This is the JS side of the two-interpreter corpus check. The runner imports
|
|
* resolveModelCapabilities() directly from the generated TypeScript module via
|
|
* Node's --experimental-strip-types flag. The Rust side lives in
|
|
* crates/buzz-agent/src/generated_model_capabilities.rs (shared corpus harness).
|
|
*
|
|
* Usage: node --experimental-strip-types scripts/run-corpus.mjs [--verbose]
|
|
* Exits 0 on all pass, 1 on any failure.
|
|
*/
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import { join, dirname } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const repoRoot = join(__dirname, "..");
|
|
const VERBOSE = process.argv.includes("--verbose");
|
|
|
|
// Import the generated TypeScript interpreter directly.
|
|
// Node 22+ --experimental-strip-types strips type annotations at load time; no build step needed.
|
|
const { resolveModelCapabilities } = await import(
|
|
join(repoRoot, "desktop", "src", "features", "agents", "ui", "modelCapabilities.ts")
|
|
);
|
|
|
|
const corpus = JSON.parse(
|
|
readFileSync(join(repoRoot, "scripts", "normative-corpus.json"), "utf8"),
|
|
);
|
|
|
|
// ----- Provider alias canonicalization -----
|
|
// Mirrors production canonicalizeProvider() in desktop/src/features/agents/lib/formatAgentModelLabel.ts.
|
|
// Applied before every generated lookup so alias vectors (e.g. "openai-compat") pass both interpreters.
|
|
const PROVIDER_ALIASES = new Map([
|
|
["databricks-v2", "databricks_v2"],
|
|
["openai-compat", "openai"],
|
|
]);
|
|
|
|
function canonicalizeProvider(provider) {
|
|
const normalized = (provider ?? "").trim().toLowerCase();
|
|
return PROVIDER_ALIASES.get(normalized) ?? normalized;
|
|
}
|
|
|
|
// ----- Run corpus -----
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
const REQUIRED_AXES = [
|
|
"thinking_mode",
|
|
"supported_efforts",
|
|
"default_effort",
|
|
"databricks_v2_wire_route",
|
|
"normalization_policy",
|
|
"registry_label",
|
|
];
|
|
|
|
for (const entry of corpus) {
|
|
// Skip group header entries
|
|
if (entry._group) continue;
|
|
if (!entry.expect) continue;
|
|
|
|
// Require all 6 axes on every executable vector — sparse vectors hide divergences.
|
|
const missingAxes = REQUIRED_AXES.filter((ax) => !(ax in entry.expect));
|
|
if (missingAxes.length > 0) {
|
|
failed++;
|
|
console.error(` FAIL ${entry.id}: sparse vector — missing axes: ${missingAxes.join(", ")}`);
|
|
console.error(` All six axes are required: ${REQUIRED_AXES.join(", ")}`);
|
|
continue;
|
|
}
|
|
|
|
// resolveModelCapabilities returns camelCase keys (registryLabel, thinkingMode, etc.)
|
|
const result = resolveModelCapabilities(canonicalizeProvider(entry.provider), entry.raw_model_id);
|
|
const expect = entry.expect;
|
|
|
|
const failures = [];
|
|
|
|
for (const [key, expectedVal] of Object.entries(expect)) {
|
|
// Corpus uses snake_case; generated TS uses camelCase — convert for lookup.
|
|
const camelKey = key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
const actualVal = camelKey in result ? result[camelKey] : result[key];
|
|
|
|
if (Array.isArray(expectedVal)) {
|
|
// Order-sensitive comparison for effort arrays
|
|
const actualArr = Array.isArray(actualVal) ? actualVal : [];
|
|
if (JSON.stringify(actualArr) !== JSON.stringify(expectedVal)) {
|
|
failures.push(
|
|
` ${key}: expected [${expectedVal.join(", ")}] got [${actualArr.join(", ")}]`,
|
|
);
|
|
}
|
|
} else {
|
|
if (actualVal !== expectedVal) {
|
|
failures.push(` ${key}: expected ${JSON.stringify(expectedVal)} got ${JSON.stringify(actualVal)}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (failures.length === 0) {
|
|
passed++;
|
|
if (VERBOSE) {
|
|
console.log(` PASS ${entry.id}`);
|
|
}
|
|
} else {
|
|
failed++;
|
|
console.error(` FAIL ${entry.id} (${entry.provider} / "${entry.raw_model_id}")`);
|
|
for (const f of failures) console.error(f);
|
|
if (entry._note) console.error(` note: ${entry._note}`);
|
|
}
|
|
}
|
|
|
|
console.log(`\nCorpus: ${passed} passed, ${failed} failed`);
|
|
process.exit(failed > 0 ? 1 : 0);
|