FN-5893: require invariant-level bug regression coverage

Add invariant-first regression guidance to triage prompts and testing docs.

- add an AGENTS standing rule to cover bug-fix invariants across all known surfaces
- update standard, fast, and core triage prompt templates to require invariant-level regression tests
- add triage regression tests that lock the new wording into standard, fast, and core prompts
- link docs/testing guidance back to the new invariant-over-repro rule

Files changed:
 AGENTS.md                                    |  7 ++++++
 docs/testing.md                              |  1 +
 packages/core/src/agent-prompts.ts           |  3 ++-
 packages/engine/src/__tests__/triage.test.ts | 32 ++++++++++++++++++++++++++++
 packages/engine/src/triage.ts                |  6 ++++--
 5 files changed, 46 insertions(+), 3 deletions(-)

Fusion-Task-Id: FN-5893

Fusion-Task-Lineage: 31c082c6-2a0a-4619-a13b-94dad97eef62
This commit is contained in:
gsxdsm
2026-06-02 14:02:36 -07:00
parent bd3190ba19
commit 65ddb4d4f5
5 changed files with 46 additions and 3 deletions

View File

@@ -9,9 +9,11 @@ import {
computeUserCommentFingerprint,
} from "../triage.js";
import { join } from "node:path";
import { readFileSync } from "node:fs";
import { mkdir, writeFile, rm, mkdtemp } from "node:fs/promises";
import { tmpdir } from "node:os";
import { setTimeout as delay } from "node:timers/promises";
import { fileURLToPath } from "node:url";
import { planLog } from "../logger.js";
const { mockReviewStep, mockCreateFnAgent } = vi.hoisted(() => ({
@@ -645,6 +647,36 @@ describe("TRIAGE_SYSTEM_PROMPT", () => {
});
});
describe("FN-5893 invariant regression wording", () => {
it("requires invariant-level regression coverage in standard, fast, and core triage prompts", () => {
const corePromptSource = readFileSync(
fileURLToPath(new URL("../../../core/src/agent-prompts.ts", import.meta.url)),
"utf8",
);
for (const prompt of [
TRIAGE_SYSTEM_PROMPT,
FAST_TRIAGE_SYSTEM_PROMPT,
corePromptSource,
]) {
expect(prompt).toContain("invariant across all known surfaces");
expect(prompt).toContain("provider/bridge");
expect(prompt).toContain("desktop + mobile breakpoints");
expect(prompt).toContain("empty/undefined/populated data states");
expect(prompt).toContain("FN-5787/FN-5789/FN-5803");
expect(prompt).toContain("FN-5751");
}
});
it("requires implementation-step testing guidance to enumerate invariant surfaces in standard and fast prompts", () => {
for (const prompt of [TRIAGE_SYSTEM_PROMPT, FAST_TRIAGE_SYSTEM_PROMPT]) {
expect(prompt).toContain(
"Run targeted tests for changed files, asserting the invariant across all known surfaces",
);
}
});
});
describe("fast-mode triage", () => {
it("exports a lean FAST_TRIAGE_SYSTEM_PROMPT", () => {
expect(typeof FAST_TRIAGE_SYSTEM_PROMPT).toBe("string");