From cfd463d8b37f1dcdbb412427a69450c970b2728f Mon Sep 17 00:00:00 2001 From: robbond Date: Wed, 26 Aug 2026 12:10:07 +0100 Subject: [PATCH] test(confidence-engine): capture structural frontier priority regression --- .../focused-deconstruct-regression-cases.mjs | 110 ++++++++++++++++++ .../focused-investigation-boundaries.test.js | 38 ++++++ 2 files changed, 148 insertions(+) diff --git a/tests/graph/focused-deconstruct-regression-cases.mjs b/tests/graph/focused-deconstruct-regression-cases.mjs index 94a81b9..728c4bb 100644 --- a/tests/graph/focused-deconstruct-regression-cases.mjs +++ b/tests/graph/focused-deconstruct-regression-cases.mjs @@ -149,4 +149,114 @@ whether token access itself is the actual blocker or whether another requirement Exactly one uncertainty. Exactly one next question.`, }, + { + id: "structural-frontier-over-working-example-detail", + centralStatement: + "I want to reduce how dependent the business is on me for routine operational work, but I am not sure how much responsibility I can realistically hand over to my team yet. I want to understand what is genuinely preventing more delegation rather than just assuming I need to stay involved.", + targetLabel: + "Concrete capability gaps, process maturity levels, or approval authority restrictions limiting delegation", + targetDescription: + "What is actually stopping further delegation right now — not hypothetical constraints but the real bottleneck in the current evidence.", + question: + "What evidence would confirm or rule out concrete capability gaps, process maturity levels, or approval authority restrictions limiting delegation?", + answer: + "One member of the team already handles the weekly supplier payments herself. She has done that for the last six months without me checking the routine payments. She hasn't had any formal training in this area. If a payment fails or there is anything unusual, she brings it to me. I still handle other routine operational work myself, but I haven't yet broken all of that down into a complete list.", + manualReviewCriteria: + `Observation fidelity — the reasoning must preserve the stated facts without weakening them: + +- weekly supplier payments are already handled independently by one team member +- those routine payments have operated for six months without routine review +- no formal training exists for that specific task +- failures or unusual cases are escalated back to the owner +- other routine work remains with the owner +- remaining routine work has not yet been fully identified / broken down + +Frontier priority (the key invariant): + +A local unresolved detail inside an already-working delegation example must NOT outrank a structural information gap required to progress the actual investigation. + +Specifically: + exception mechanics: "Can she also handle failed/unusual payments?" +is SAME-BRANCH-DETAIL / VALID-LATER + +while: + remaining-work inventory: "What other routine work is still being retained / not yet identified?" +is IMMEDIATE-FRONTIER + +The expected reasoning should remain anchored to the missing remaining-work inventory (or an equivalent structural prerequisite) rather than promoting exception-mechanics detail. + +Do not require exact wording such as "make a complete list". The semantic requirement is: identify what remaining routine work is actually being retained before reasoning about which capability/process/authority constraints prevent delegation. + +Assumption restraint — the following must be rejected (OVERREACH): + +- Hands-on experience with one task proves competence for similar work. +- Formal training is generally unnecessary for delegation readiness. +- Success on supplier payments establishes transferability to other routine work. + +The user did not state or rely upon those propositions. assumptions: [] is acceptable if no genuinely user-held assumption exists. + +Relationship restraint — a relationship equivalent to +"independent routine supplier-payment execution occurred despite lack of formal training" +may be acceptable if represented purely as a relationship between the two stated facts. + +It must NOT be strengthened into: + +- lack of formal training does not prevent delegation generally +- exception escalation makes delegation safe +- payment success proves readiness for other work`, + }, ]; + +// ── Deterministic fixture-integrity assertions (zero live calls) ───────── + +export const FOCUSED_DECONSTRUCT_REGRESSION_CASE_IDS = [ + "nearest-frontier-wins", + "no-genuine-assumption", + "genuine-evidence-sufficiency-assumption", + "juxtaposition-must-not-create-link", + "tentative-observation-fidelity", + "genuine-dependency-frontier", + "structural-frontier-over-working-example-detail", +]; + +export function validateRegressionFixtureIntegrity() { + const errors = []; + + if (FOCUSED_DECONSTRUCT_REGRESSION_CASES.length !== 7) { + errors.push( + `Expected exactly 7 regression cases; got ${FOCUSED_DECONSTRUCT_REGRESSION_CASES.length}`, + ); + } + + const ids = FOCUSED_DECONSTRUCT_REGRESSION_CASES.map((c) => c.id); + const uniqueIds = new Set(ids); + if (uniqueIds.size !== ids.length) { + errors.push(`Duplicate IDs found: ${ids.filter((id, i) => ids.indexOf(id) !== i).join(", ")}`); + } + + for (const expectedId of FOCUSED_DECONSTRUCT_REGRESSION_CASE_IDS) { + if (!ids.includes(expectedId)) { + errors.push(`Missing expected case ID: ${expectedId}`); + } + } + + // Verify no unknown IDs + for (const id of ids) { + if (!FOCUSED_DECONSTRUCT_REGRESSION_CASE_IDS.includes(id)) { + errors.push(`Unexpected case ID: ${id}`); + } + } + + // Verify each case has required fields + const requiredFields = ["id", "centralStatement", "targetLabel", "targetDescription", "question", "answer", "manualReviewCriteria"]; + for (const i in FOCUSED_DECONSTRUCT_REGRESSION_CASES) { + const case_ = FOCUSED_DECONSTRUCT_REGRESSION_CASES[i]; + for (const field of requiredFields) { + if (!(field in case_) || typeof case_[field] !== "string" || !case_[field].trim()) { + errors.push(`Case ${i} (${case_.id}): missing or invalid field "${field}"`); + } + } + } + + return errors; +} diff --git a/tests/graph/focused-investigation-boundaries.test.js b/tests/graph/focused-investigation-boundaries.test.js index 0b57701..c617ca3 100644 --- a/tests/graph/focused-investigation-boundaries.test.js +++ b/tests/graph/focused-investigation-boundaries.test.js @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { makeNode, makeGraph } from "@/lib/graph/schema.js"; import { formulateQuestionForTarget, buildFocusedDeconstructPrompt, validateFocusedDeconstructSchema } from "@/lib/graph/focused-investigation.js"; +import { FOCUSED_DECONSTRUCT_REGRESSION_CASES, validateRegressionFixtureIntegrity } from "./focused-deconstruct-regression-cases.mjs"; // ── helpers ────────────────────────────────────────────────────────────── @@ -230,3 +231,40 @@ describe("validateFocusedDeconstructSchema", () => { } }); }); + +// ── Regression fixture integrity (zero live calls) ────────────────────────── + +describe("FOCUSED_DECONSTRUCT_REGRESSION_CASES fixture integrity", () => { + it("has exactly 7 cases", () => { + expect(FOCUSED_DECONSTRUCT_REGRESSION_CASES.length).toBe(7); + }); + + it("all IDs are unique", () => { + const ids = FOCUSED_DECONSTRUCT_REGRESSION_CASES.map((c) => c.id); + expect(new Set(ids).size).toBe(ids.length); + }); + + it("contains the new structural-frontier case ID", () => { + const ids = FOCUSED_DECONSTRUCT_REGRESSION_CASES.map((c) => c.id); + expect(ids).toContain("structural-frontier-over-working-example-detail"); + }); + + it("preserves all six original case IDs", () => { + const ids = FOCUSED_DECONSTRUCT_REGRESSION_CASES.map((c) => c.id); + for (const origId of [ + "nearest-frontier-wins", + "no-genuine-assumption", + "genuine-evidence-sufficiency-assumption", + "juxtaposition-must-not-create-link", + "tentative-observation-fidelity", + "genuine-dependency-frontier", + ]) { + expect(ids).toContain(origId); + } + }); + + it("validateRegressionFixtureIntegrity reports zero errors", () => { + const errors = validateRegressionFixtureIntegrity(); + expect(errors).toEqual([]); + }); +});