Files
fusion/scripts/__tests__/agents-md-invariants.test.mjs
gsxdsm 53acaf96c3 FN-9123: Repair script test contract drift
Repair script-test contracts to match the current repository policies and live workflow coverage.

- Align static-gate and pretest mirrors with authoritative validator chains.
- Update the merger-rule floor and parameterized flake registration.
- Repoint workflow reliability evidence to the surviving dispatch test.

Files changed:
 .../test-failures/suite-only-flakes-observed-register.md       |  4 +++-
 scripts/__tests__/agents-md-invariants.test.mjs                | 10 ++++++++--
 scripts/__tests__/engine-vitest-gate-policy.test.mjs           |  6 ++++++
 scripts/__tests__/run-static-gate-checks.test.mjs              |  7 +++++++
 scripts/__tests__/verify-fast.test.mjs                         |  6 ++++++
 scripts/lib/workflow-reliability-release-check.json            |  4 ++--
 6 files changed, 32 insertions(+), 5 deletions(-)

Fusion-Task-Id: FN-9123

Fusion-Task-Lineage: 1a3dad24-69e3-423e-a159-56fd3f1085a3

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-08-16 04:05:45 -07:00

60 lines
2.1 KiB
JavaScript

import assert from "node:assert/strict";
import { existsSync, readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import test from "node:test";
const __dirname = dirname(fileURLToPath(import.meta.url));
const rootDir = resolve(__dirname, "../..");
const agentsPath = resolve(rootDir, "AGENTS.md");
const agents = readFileSync(agentsPath, "utf8");
const requiredAnchors = [
"Port 4040",
"pnpm release",
"@runfusion/fusion",
'engineModule = "@fusion/engine"',
"superviseSpawn",
"Fusion-Task-Id",
"Merging Branches Into Main",
"autoMerge: false",
"File-Scope invariant",
"git add -f",
];
test("AGENTS.md keeps non-negotiable invariant anchors", () => {
for (const anchor of requiredAnchors) {
assert.ok(agents.includes(anchor), `Missing required anchor: ${anchor}`);
}
});
/*
FNXC:TestInfrastructure 2026-08-16-10:52:
Commit 87e673baf7 deliberately removed the pre-commit diff-volume gate and its
former merging rule 7, renumbering the list from 10 to 9. The floor follows the
actual AGENTS.md contract; it must not pressure authors to invent a tenth rule.
*/
test("Merging section retains at least 9 numbered rules", () => {
const heading = "### Merging Branches Into Main";
const start = agents.indexOf(heading);
assert.notEqual(start, -1, "Merging section heading missing");
const afterStart = agents.slice(start + heading.length);
const nextSection = afterStart.indexOf("\n### ");
const section = nextSection === -1 ? afterStart : afterStart.slice(0, nextSection);
const rules = section.match(/^\d+\.\s+/gm) ?? [];
assert.ok(rules.length >= 9, `Expected >= 9 numbered rules, found ${rules.length}`);
});
test("All ./docs/*.md links in AGENTS.md resolve", () => {
const matches = [...agents.matchAll(/\.\/docs\/[A-Za-z0-9._-]+\.md/g)].map((m) => m[0]);
const links = [...new Set(matches)];
assert.ok(links.length > 0, "No ./docs/*.md links found");
for (const link of links) {
const target = resolve(rootDir, link);
assert.ok(existsSync(target), `Broken docs link in AGENTS.md: ${link}`);
}
});