Govern task context and advance execution pointer
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-20 06:02:43 -04:00
parent 380cbed4ff
commit 10640aeb3c
984 changed files with 543475 additions and 327 deletions

View File

@@ -0,0 +1,47 @@
import test from "node:test";
import assert from "node:assert/strict";
import { buildTaskContext } from "../../../tools/web/task-context-lib.mjs";
import { validateContextBundle } from "../../../tools/web/context-governance.mjs";
test("current context satisfies document, task-card, and pointer budgets", () => {
const bundle = buildTaskContext();
const result = validateContextBundle(bundle);
assert.deepEqual(result.violations, []);
assert.ok(result.report.totalTokens <= 3500);
});
test("task cards cannot smuggle full plans or history into the default context", () => {
const bundle = buildTaskContext();
const taskSource = `${bundle.sources.taskSource}\nnext-task-plan.json\n`;
const result = validateContextBundle({
...bundle,
sources: { ...bundle.sources, taskSource },
});
assert.ok(result.violations.some(({ code }) => code === "FORBIDDEN_CONTEXT_REFERENCE"));
});
test("governance rejects forged selection totals and unaudited exclusions", () => {
const bundle = buildTaskContext();
const forged = {
...bundle,
context: {
...bundle.context,
inputPaths: ["tools/web/generated/M16-GAP-00022.py"],
inputSelection: {
...bundle.context.inputSelection,
selected: [{ path: "tools/web/generated/M16-GAP-00022.py", bytes: 9000, tokens: 1 }],
excluded: [
{ path: "tests/files/web/generated/M16-GAP-00022-datablock-Sound.blend", reason: "FORGED_REASON" },
{ path: "tests/golden/M16-GAP-00022/" },
],
totals: { files: 1, bytes: 9000, tokens: 2250 },
},
},
};
const result = validateContextBundle(forged);
assert.ok(result.violations.some(({ code }) => code === "EVIDENCE_BYTES_OVER_BUDGET"));
assert.ok(result.violations.some(({ code }) => code === "CONTEXT_REMAINING_BYTES_OVER_BUDGET"));
assert.ok(result.violations.some(({ code }) => code === "INPUT_EXCLUSION_REASON_MISSING"));
assert.ok(result.violations.some(({ code }) => code === "INPUT_EXCLUSION_REASON_UNKNOWN"));
assert.ok(result.violations.some(({ code }) => code === "INPUT_SELECTION_ENTRY_INVALID"));
});