openclaw/scripts/lib/plugin-contract-test-plan.mts
Peter Steinberger e95e11c679
perf(sessions): serve per-turn session projections and entry reads from workers (#164779)
* perf(sessions): read per-turn metadata through existing workers

Move model, sandbox, completion and Gateway metadata preparation off the calling thread while retaining live source authority and audited worker patch settlement. Preserve native incognito and opaque callback contracts; leave the entry-store write kernel unchanged.

* fix(sessions): clear run context when model preparation fails

* perf(sessions): prepare dispatch and injection entries in workers

Preserve exact-row validation and canonical-key error identity. Keep storage-backed source checks outside worker grants and retain acknowledged writer settlement.

* refactor(sessions): keep prepared sandbox check within line budget

* test(sessions): use current agent entry config in injection fixtures

* refactor(sessions): make worker request and test await shapes explicit

* test(sessions): repair worker read fixture integration

Route worker-backed callers through the existing broker test lane, preserve contract command coverage, align synthetic entry readers, and await fixture shutdown. Synchronize provider cancellation on execution and terminal failure instead of a timer flush.

* test(sessions): prune repaired mock export baseline

* test(gateway): settle publication before durability probe
2026-10-04 02:41:14 -07:00

56 lines
1.8 KiB
TypeScript

// Builds balanced Vitest shard plans for plugin contract tests.
import { isDatabaseWorkerCoreTestFile } from "../../test/vitest/vitest.database-worker-core-paths.mjs";
import { listTrackedTestFiles } from "./list-test-files.mts";
import { assignWeightedTestFiles } from "./weighted-test-shards.mts";
const CONTRACT_FILE_WEIGHTS = new Map([
["plugin-sdk-subpaths.test.ts", 80],
["tts.contract.test.ts", 70],
["boundary-invariants.test.ts", 36],
["extension-package-project-boundaries.test.ts", 34],
["plugin-sdk-package-contract-guardrails.test.ts", 46],
["providers.contract.test.ts", 30],
["registry.contract.test.ts", 30],
["core-extension-facade-boundary.test.ts", 28],
["loader.contract.test.ts", 28],
["runtime-import-side-effects.contract.test.ts", 24],
["extension-runtime-dependencies.contract.test.ts", 22],
]);
function resolveContractFileWeight(file: string) {
const name = file.replaceAll("\\", "/").split("/").pop() ?? "";
if (name.startsWith("plugin-registration.")) {
return 14;
}
if (name.startsWith("wizard.")) {
return 12;
}
return CONTRACT_FILE_WEIGHTS.get(name) ?? 10;
}
/** Create balanced plugin contract test shards for CI check planning. */
export function createPluginContractTestShards() {
const suffixes = ["a", "b"];
const groups = suffixes.map((suffix) => ({
checkName: `checks-fast-contracts-plugins-${suffix}`,
includePatterns: new Array<string>(),
weight: 0,
}));
assignWeightedTestFiles(
groups,
listTrackedTestFiles("src/plugins/contracts").filter(
(file) => !isDatabaseWorkerCoreTestFile(file),
),
resolveContractFileWeight,
);
return groups
.map(({ checkName, includePatterns }) => ({
checkName,
includePatterns,
runtime: "node",
task: "contracts-plugins",
}))
.filter((shard) => shard.includePatterns.length > 0);
}