experiment: test assessor against unclear starting point
This commit is contained in:
+10
-2
@@ -46,6 +46,8 @@ Experiment 42 implemented Variant B's narrow Acknowledge exclusion gate in the p
|
||||
|
||||
Experiment 43 audited Clarify readiness across all 10 real assessment turns in existing fixtures. Zero turns produced Clarify-eligible states. Two findings: (1) the orienting-based Clarify rule is dead code because the assessor never produces phase=orienting, and (2) the too_broad trigger requires conditions no fixture exercises. Branch: `feature/user-workspace-ux-v0.7`.
|
||||
|
||||
Experiment 44 created one deliberately unclear starting scenario (five competing unknowns, zero resolved evidence, vague central statement) to test whether the assessor produces a Clarify-justifying signal. The assessor returned `too_broad` conversation health — confirming the previously untested too_broad path works correctly with real data. Clarify became eligible via Rule A. No production code changed. Remaining open: whether orienting phase is needed for earlier-stage clarification, and whether 2–3 competing threads (below the >3 threshold) can represent genuine scope confusion. Status pending Rob's review.
|
||||
|
||||
## 5. What Remains Open
|
||||
|
||||
- Whether the `too_broad` health trigger needs widening so Clarify fires in more typical investigations;
|
||||
@@ -57,6 +59,12 @@ Experiment 43 audited Clarify readiness across all 10 real assessment turns in e
|
||||
- Whether a dedicated fixture validating the `too_broad` trigger should be created before widening its threshold;
|
||||
- Whether Clarify's intent (genuinely unclear scope) maps better to an existing signal that could fire earlier.
|
||||
|
||||
### What Remains Open (continued from above)
|
||||
|
||||
- Experiment 44 confirmed the `too_broad` path fires for a genuinely unclear starting point, but only with >3 competing unknowns; scenarios with 2–3 threads may remain unflagged;
|
||||
- Whether a dedicated `orienting` phase is needed to catch earlier-stage clarification needs (the orienting-based Clarify rule remains dead code);
|
||||
- Whether Clarify's intent (genuinely unclear scope) maps better to an existing signal that could fire earlier.
|
||||
|
||||
### When This Knowledge-Management Phase Is Complete
|
||||
|
||||
Provisional criteria for review (all confirmed met by Experiment 38 cold-start test):
|
||||
@@ -103,6 +111,6 @@ Answer before continuing:
|
||||
|
||||
*Created by Experiment 34. Updated by Experiments 38, 39, 40, 41, 42, 43. Branch: `feature/user-workspace-ux-v0.7`.*
|
||||
|
||||
### Return-to-Work Note (Experiment 43)
|
||||
### Return-to-Work Note (Experiment 44)
|
||||
|
||||
Experiment 43 diagnosed Clarify's absence across all real scenarios: zero eligibility in 10 turns. The orienting-based rule is dead code (assessor never produces phase=orienting); the too_broad trigger needs a dedicated fixture. Open decision: fix the dead-code path, widen the threshold, or accept both and defer. Branch: `feature/user-workspace-ux-v0.7`. First file to inspect when resuming: `docs/current-handoff.md`, then `tests/behaviour-selection.clarify-readiness.test.js` for the full audit data, and `lib/behaviour-selection/behaviour-selector.js` lines 65-83 for the Clarify rules.
|
||||
Experiment 44 tested one genuinely unclear starting scenario (five competing unknowns, zero resolved evidence, no clear decision target). The assessor returned `too_broad` for conversation health and Clarify became eligible via the production rule. This confirms the previously untested `too_broad` health classifier path works correctly with real data. No production code changed. What remains unresolved: whether a dedicated `orienting` phase is needed to catch earlier-stage clarification needs, and whether fewer competing threads (2–3) can still represent a genuinely unclear situation that the assessor should flag. Branch: `feature/user-workspace-ux-v0.7`. First file to inspect when resuming: `tests/investigation-state-assessor.unclear-start.test.js` for the fixture, then `docs/design-evolution-log.md` lines 2721 onward for full experiment data, then `lib/assessment/investigation-state-assessor.js` line ~450 for the `too_broad` trigger logic.
|
||||
|
||||
@@ -2717,3 +2717,100 @@ All diagnostics confirm zero Clarify eligibility across the complete set of real
|
||||
|
||||
- `docs/design-evolution-log.md` — this entry
|
||||
- `docs/current-handoff.md` — return-to-work note replaced
|
||||
|
||||
## Experiment 44 — Assessor Against Unclear Starting Point (2026-08-06)
|
||||
|
||||
### Objective
|
||||
|
||||
Create one deliberately unclear investigation fixture and test whether the existing Investigation State Assessor produces any signal that justifies Clarify.
|
||||
|
||||
### Hypothesis
|
||||
|
||||
A deliberately unclear starting scenario may expose one of three outcomes:
|
||||
1. The assessor already produces `too_broad`.
|
||||
2. The assessor produces another existing signal that reasonably represents the need to clarify.
|
||||
3. The assessor has no suitable signal for unclear framing.
|
||||
|
||||
### Fixture Description
|
||||
|
||||
**File:** `tests/investigation-state-assessor.unclear-start.test.js` (test-only, not imported anywhere else)
|
||||
|
||||
The fixture represents:
|
||||
- A vague central statement that admits uncertainty: *"The business feels stuck. Sales are uneven, staff are frustrated, customers ask for different things, and I'm not sure what the real problem is."*
|
||||
- Five competing unknown threads (customer demand, staff capacity, product direction, pricing, operations) with no priority anchor
|
||||
- Only one observation (the only concrete data point)
|
||||
- Zero resolved evidence nodes
|
||||
- No selected question (no established direction)
|
||||
- All existing graph fields only (id, label, description, kind, status, confidence, evidenceIds, dependsOn, affects, childIds)
|
||||
- Five `kind: "unknown"` nodes and one `kind: "observation"` node
|
||||
|
||||
### Returned Assessment Signals
|
||||
|
||||
| Signal | Value | Confidence |
|
||||
|--------|-------|------------|
|
||||
| Phase | `cannot_determine` | low |
|
||||
| Phase signals | "Insufficient data for phase classification" | — |
|
||||
| Progress | `cannot_determine` | low |
|
||||
| Progress signals | "Insufficient data for progress assessment" | — |
|
||||
| Conversation health | **`too_broad`** | medium |
|
||||
| Health signals | "5 active unknowns with fewer than 2 resolved items"; "Investigation may be spreading too thin" | — |
|
||||
|
||||
Detailed evidence:
|
||||
- Phase evidence: resolvedNodeCount=0, activeUnknownCount=5, observationDensity=1, evidenceDepth="shallow"
|
||||
- Progress evidence: turnCount=0, recentResolutionsLastTurn=0
|
||||
- Health evidence: activeUnknownCount=5, resolvedNodeRatio=null, hasActiveQuestion=false
|
||||
|
||||
### Clarify Eligibility
|
||||
|
||||
**Clarify became eligible via Rule A.** The production `selectClarify` rule fires because `conversationHealth.value === "too_broad"`.
|
||||
|
||||
The production selector (`selectBehaviour`) returned:
|
||||
- behaviour: `"clarify"`
|
||||
- confidence: `"high"`
|
||||
- reason: "Conversation health is too broad — investigation may be spreading too thin. Narrow focus through a specific clarification question."
|
||||
|
||||
### Interpretation
|
||||
|
||||
**Classification: `assessor_recognises_unclear_start`**
|
||||
|
||||
The assessor produced `too_broad` from the unclear-start fixture, which directly maps to Clarify's intent (genuinely unclear scope requiring anchoring). The signal honestly reflects the starting situation: five competing unknowns with no resolved evidence and no established direction.
|
||||
|
||||
### What the Assessor Recognised
|
||||
|
||||
1. Multiple active unknowns without sufficient resolution triggered `too_broad` health classification.
|
||||
2. The assessor correctly recorded 5 active unknowns in both phase and health evidence sections.
|
||||
3. Observation density (1) was correctly reported as shallow.
|
||||
4. Phase confidence remained low due to insufficient data for any meaningful classification.
|
||||
|
||||
### What the Assessor Failed to Recognise
|
||||
|
||||
1. **`orienting` phase**: Still not produced by the assessor. The orienting-based Clarify rule remains dead code, unchanged from Experiment 43's finding.
|
||||
2. **Early-stage clarification need**: The `too_broad` trigger only fires after >3 unknowns accumulate — it does not catch a situation with fewer competing threads that is still genuinely unclear in framing.
|
||||
|
||||
### Limitations
|
||||
|
||||
- Only one fixture was tested. Different vague-scenario configurations may produce different results.
|
||||
- The `too_broad` trigger depends on having more than 3 active unknowns with fewer than 2 resolved — this specific threshold was exercised, but other boundary conditions (e.g., exactly 4 unknowns, or 5 unknowns with 1 resolved) were not tested.
|
||||
- The fixture uses the assessor's existing `too_broad` definition which conflates "many unknowns" with "unclear scope." A genuinely unclear scenario with only 2–3 competing threads may not trigger this signal.
|
||||
|
||||
### Status
|
||||
|
||||
Pending Rob's review. Experiment 43 remains closed — its conclusion that a deliberately unclear fixture was required is confirmed by this experiment, which successfully exercises the previously untested `too_broad` health path.
|
||||
|
||||
### Focused Test Results
|
||||
|
||||
| Test File | Tests | Result |
|
||||
|-----------|-------|--------|
|
||||
| `tests/investigation-state-assessor.unclear-start.test.js` | 23 | ✓ Pass |
|
||||
|
||||
### Regression / Validation Results
|
||||
|
||||
| Test File | Tests | Result | Notes |
|
||||
|-----------|-------|--------|-------|
|
||||
| `tests/behaviour-selection.clarify-readiness.test.js` | 31 | ✓ Pass | Zero regressions |
|
||||
| `tests/investigation-state-assessor.test.js` | 51 | ✓ Pass | Zero regressions |
|
||||
| `tests/behaviour-selection.test.js` | 51 | ✓ Pass | Zero regressions |
|
||||
|
||||
### Production Assessor Status
|
||||
|
||||
**Unchanged.** The assessor produced the expected `too_broad` signal from the unclear fixture, confirming the health classifier path works correctly. No code was modified.
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
/**
|
||||
* Experiment 44 — Assessor Against Unclear Starting Point
|
||||
*
|
||||
* One deliberately vague investigation with several competing unknowns,
|
||||
* no resolved evidence, and no clear decision target. Tests whether the
|
||||
* existing assessor produces any signal that justifies Clarify.
|
||||
*
|
||||
* No production code changes. No existing fixture modification.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import assessInvestigationState from "@/lib/assessment/investigation-state-assessor.js";
|
||||
import selectBehaviour from "@/lib/behaviour-selection/behaviour-selector.js";
|
||||
|
||||
/* ── Helpers ─────────────────────────────────────────────── */
|
||||
|
||||
function mkN(id, label, opts = {}) {
|
||||
const kind = opts.kind || "unknown";
|
||||
const status = opts.status || (kind === "unknown" ? "unknown" : "known");
|
||||
const confidence = opts.confidence || (kind === "unknown" ? "low" : "high");
|
||||
return {
|
||||
id, label, description: label, kind, status, confidence,
|
||||
evidenceIds: [], dependsOn: [], affects: [], childIds: []
|
||||
};
|
||||
}
|
||||
|
||||
function buildInput(nodes, resolvedNodeIds = [], activeUnknownNodeId = null) {
|
||||
return {
|
||||
situationGraph: {
|
||||
centralStatement: "The business feels stuck. Sales are uneven, staff are frustrated, customers ask for different things, and I'm not sure what the real problem is.",
|
||||
currentSummary: "",
|
||||
nodes: Array.isArray(nodes) ? nodes : [],
|
||||
edges: [],
|
||||
activeUnknownNodeId,
|
||||
resolvedNodeIds: resolvedNodeIds || []
|
||||
},
|
||||
selectedQuestion: null,
|
||||
noQuestionReason: "No clear decision target yet — too many competing threads.",
|
||||
diagnostics: {
|
||||
promptVersion: "v0.4",
|
||||
modelName: "mock-ollama",
|
||||
responseDurationMs: 0,
|
||||
validationStatus: "valid",
|
||||
nodeCount: Array.isArray(nodes) ? nodes.length : 0,
|
||||
edgeCount: 0,
|
||||
reasoningPattern: null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* ── Unclear-start fixture (test-only) ───────────────────── */
|
||||
|
||||
/**
|
||||
* Represents a genuinely vague starting situation:
|
||||
* - One central statement that is self-admittedly unclear
|
||||
* - Multiple competing unknown threads with no resolution
|
||||
* - Very few observations
|
||||
* - No clear decision target
|
||||
* - Early investigation state
|
||||
*/
|
||||
const unclearFixtureNodes = [
|
||||
// Single observation — the only concrete data point
|
||||
mkN("obs-1", "Sales figures are uneven across regions", { kind: "observation", status: "known", confidence: "medium" }),
|
||||
|
||||
// Competing unknown threads — no clear priority anchor
|
||||
mkN("u-customer", "Whether customers want different product features or better service"),
|
||||
mkN("u-staff", "Whether staff frustration stems from capacity, skills, or motivation"),
|
||||
mkN("u-product", "Whether the current product direction matches genuine market need"),
|
||||
mkN("u-pricing", "Whether pricing is the barrier or a symptom of deeper issues"),
|
||||
mkN("u-process", "Whether operational inefficiency drives customer dissatisfaction")
|
||||
];
|
||||
|
||||
const unclearResolvedIds = []; // intentionally no resolved evidence
|
||||
const unclearActiveUnknowns = ["u-customer", "u-staff", "u-product", "u-pricing", "u-process"];
|
||||
|
||||
/* ── Clarify eligibility check (mirrors production rule) ─── */
|
||||
|
||||
function isClarifyEligible(assessment) {
|
||||
if (assessment.conversationHealth.value === "too_broad") return true;
|
||||
if (assessment.phase.value === "orienting" && assessment.phase.evidence?.observationDensity < 3) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* ── Assessor result on unclear-start fixture ─────────────── */
|
||||
|
||||
describe("Experiment 44 — Unclear Starting Point", () => {
|
||||
|
||||
/* ═══ Fixture integrity checks ═══ */
|
||||
|
||||
describe("Fixture integrity", () => {
|
||||
it("uses only existing graph fields (id, label, description, kind, status, confidence, evidenceIds, dependsOn, affects, childIds)", () => {
|
||||
for (const node of unclearFixtureNodes) {
|
||||
const keys = Object.keys(node).sort();
|
||||
const allowed = ["affects", "childIds", "confidence", "dependsOn", "description", "evidenceIds", "id", "kind", "label", "status"];
|
||||
expect(keys).toEqual(allowed);
|
||||
}
|
||||
});
|
||||
|
||||
it("has multiple competing unknowns (at least 4) with no resolved evidence", () => {
|
||||
const unknownNodes = unclearFixtureNodes.filter(n => n.kind === "unknown");
|
||||
expect(unknownNodes.length).toBeGreaterThan(3);
|
||||
expect(unclearResolvedIds.length).toBe(0);
|
||||
});
|
||||
|
||||
it("has no selected question — represents no established direction", () => {
|
||||
const input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
expect(input.selectedQuestion).toBeNull();
|
||||
});
|
||||
|
||||
it("has a vague central statement that admits uncertainty", () => {
|
||||
expect(unclearFixtureNodes.some(n => n.id === "central")).toBe(false);
|
||||
// Central statement is in the graph object, not a node — verified below
|
||||
const input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
expect(input.situationGraph.centralStatement).toContain("not sure");
|
||||
});
|
||||
|
||||
it("has few observations relative to unknowns (early state)", () => {
|
||||
const obsCount = unclearFixtureNodes.filter(n => n.kind === "observation").length;
|
||||
const unkCount = unclearFixtureNodes.filter(n => n.kind === "unknown").length;
|
||||
expect(obsCount).toBeLessThan(unkCount);
|
||||
});
|
||||
});
|
||||
|
||||
/* ═══ Assessor acceptance and result ═══ */
|
||||
|
||||
describe("Assessor result on unclear-start fixture", () => {
|
||||
let assessment;
|
||||
let input;
|
||||
|
||||
beforeAll(() => {
|
||||
input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
assessment = assessInvestigationState(input);
|
||||
});
|
||||
|
||||
it("assessor accepts the fixture without error", () => {
|
||||
expect(assessment).toBeDefined();
|
||||
expect(assessment.version).toBe("v0.1");
|
||||
});
|
||||
|
||||
it("result contains all required contract fields", () => {
|
||||
for (const dim of ["phase", "progress", "conversationHealth"]) {
|
||||
expect(assessment[dim]).toHaveProperty("value");
|
||||
expect(assessment[dim]).toHaveProperty("confidence");
|
||||
expect(assessment[dim]).toHaveProperty("signals");
|
||||
expect(Array.isArray(assessment[dim].signals)).toBe(true);
|
||||
expect(assessment[dim]).toHaveProperty("evidence");
|
||||
}
|
||||
});
|
||||
|
||||
it("returns phase value and records relevant evidence", () => {
|
||||
console.log(`\n=== Experiment 44: Unclear-Start Phase ===`);
|
||||
console.log(` phase.value: ${assessment.phase.value}`);
|
||||
console.log(` phase.confidence: ${assessment.phase.confidence}`);
|
||||
console.log(` phase.signals:`, assessment.phase.signals);
|
||||
console.log(` phase.evidence:`, JSON.stringify(assessment.phase.evidence, null, 2));
|
||||
});
|
||||
|
||||
it("returns progress value and records relevant evidence", () => {
|
||||
console.log(`\n=== Experiment 44: Unclear-Start Progress ===`);
|
||||
console.log(` progress.value: ${assessment.progress.value}`);
|
||||
console.log(` progress.confidence: ${assessment.progress.confidence}`);
|
||||
console.log(` progress.signals:`, assessment.progress.signals);
|
||||
console.log(` progress.evidence:`, JSON.stringify(assessment.progress.evidence, null, 2));
|
||||
});
|
||||
|
||||
it("returns conversation health value and records relevant evidence", () => {
|
||||
console.log(`\n=== Experiment 44: Unclear-Start Conversation Health ===`);
|
||||
console.log(` conversationHealth.value: ${assessment.conversationHealth.value}`);
|
||||
console.log(` conversationHealth.confidence: ${assessment.conversationHealth.confidence}`);
|
||||
console.log(` conversationHealth.signals:`, assessment.conversationHealth.signals);
|
||||
console.log(` conversationHealth.evidence:`, JSON.stringify(assessment.conversationHealth.evidence, null, 2));
|
||||
});
|
||||
|
||||
it("overall confidence reflects dimension uncertainty", () => {
|
||||
// With many unknowns and no resolved data, confidence should be low or cannot_determine
|
||||
expect(["low", "medium", "high"]).toContain(assessment.confidence);
|
||||
});
|
||||
|
||||
/* Detailed signal recording */
|
||||
it("records phase observation density and active unknown count in evidence", () => {
|
||||
console.log(` [signal] observationDensity: ${assessment.phase.evidence?.observationDensity}`);
|
||||
console.log(` [signal] activeUnknownCount: ${assessment.phase.evidence?.activeUnknownCount ?? "N/A"}`);
|
||||
});
|
||||
|
||||
it("records resolved node count in progress evidence", () => {
|
||||
console.log(` [signal] resolvedNodeCount (progress): ${assessment.progress.evidence?.resolvedNodeCount ?? assessment.phase.evidence?.resolvedNodeCount}`);
|
||||
});
|
||||
});
|
||||
|
||||
/* ═══ Clarify eligibility ═══ */
|
||||
|
||||
describe("Clarify eligibility", () => {
|
||||
let assessment;
|
||||
|
||||
beforeAll(() => {
|
||||
const input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
assessment = assessInvestigationState(input);
|
||||
});
|
||||
|
||||
it("evaluates Clarify eligibility using the production rule", () => {
|
||||
const eligible = isClarifyEligible(assessment);
|
||||
console.log(`\n=== Experiment 44: Clarify Eligibility ===`);
|
||||
console.log(` conversationHealth.value: ${assessment.conversationHealth.value}`);
|
||||
console.log(` Phase value: ${assessment.phase.value}`);
|
||||
console.log(` Clarify eligible (production rule): ${eligible}`);
|
||||
|
||||
// Verify each individual condition
|
||||
const tooBroad = assessment.conversationHealth.value === "too_broad";
|
||||
const orientingLowObs = assessment.phase.value === "orienting" && (assessment.phase.evidence?.observationDensity ?? Infinity) < 3;
|
||||
console.log(` Rule A (too_broad health): ${tooBroad}`);
|
||||
console.log(` Rule B (orienting + obs<3): ${orientingLowObs}`);
|
||||
});
|
||||
|
||||
it("evaluates Clarify eligibility using the production selector", () => {
|
||||
const result = selectBehaviour(assessment);
|
||||
console.log(`\n=== Experiment 44: Behaviour Selector Result ===`);
|
||||
console.log(` Selected behaviour: ${result.behaviour}`);
|
||||
console.log(` Confidence: ${result.confidence}`);
|
||||
console.log(` Reason: ${result.reason}`);
|
||||
});
|
||||
});
|
||||
|
||||
/* ═══ Interpretation ═══ */
|
||||
|
||||
describe("Interpretation of results", () => {
|
||||
let assessment;
|
||||
|
||||
beforeAll(() => {
|
||||
const input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
assessment = assessInvestigationState(input);
|
||||
});
|
||||
|
||||
it("classifies whether the assessor recognises the unclear start", () => {
|
||||
const isTooBroad = assessment.conversationHealth.value === "too_broad";
|
||||
const hasOrienting = assessment.phase.value === "orienting";
|
||||
const clarEligible = isClarifyEligible(assessment);
|
||||
|
||||
let classification;
|
||||
if (clarEligible) {
|
||||
classification = "assessor_recognises_unclear_start";
|
||||
} else if (isTooBroad || hasOrienting) {
|
||||
classification = "assessor_partially_recognises_unclear_start";
|
||||
} else {
|
||||
// Check whether any signal meaningfully captures the unclear state
|
||||
const obsDensity = assessment.phase.evidence?.observationDensity ?? 0;
|
||||
const activeUnkCount = assessment.conversationHealth.evidence?.activeUnknownCount ?? 0;
|
||||
const hasManyUnknowns = activeUnkCount > 3 || (assessment.phase.evidence?.activeUnknownCount ?? 0) > 3;
|
||||
|
||||
// The assessor returns too_broad when activeUnknownCount > 3 && resolved < 2
|
||||
if (!isTooBroad && hasManyUnknowns) {
|
||||
// It saw the multiple unknowns but classified health differently — partial recognition
|
||||
classification = "assessor_partially_recognises_unclear_start";
|
||||
} else {
|
||||
classification = "assessor_does_not_recognise_unclear_start";
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n=== Experiment 44: Classification ===`);
|
||||
console.log(` Classification: ${classification}`);
|
||||
console.log(` Evidence: too_broad=${isTooBroad}, orienting=${hasOrienting}, clarifyEligible=${clarEligible}`);
|
||||
expect(classification).toBeDefined();
|
||||
});
|
||||
|
||||
it("reports what the closest existing signal is when Clarify does not fire", () => {
|
||||
const isTooBroad = assessment.conversationHealth.value === "too_broad";
|
||||
const isTooNarrow = assessment.conversationHealth.value === "too_narrow";
|
||||
const isCannotDetermine = assessment.phase.value === "cannot_determine";
|
||||
|
||||
if (!isTooBroad) {
|
||||
let closestSignal;
|
||||
if (isTooNarrow) closestSignal = "too_narrow health — insufficient context for question formulation";
|
||||
else if (isCannotDetermine) closestSignal = "cannot_determine phase — insufficient data for classification";
|
||||
else closestSignal = assessment.conversationHealth.value;
|
||||
console.log(` Closest existing signal: ${closestSignal}`);
|
||||
} else {
|
||||
console.log(` Too_broad fires directly — no proxy needed.`);
|
||||
}
|
||||
});
|
||||
|
||||
it("answers whether the result honestly reflects the unclear starting situation", () => {
|
||||
// The assessor should either produce too_broad (multiple unknowns, no resolution)
|
||||
// or a signal that meaningfully captures the ambiguity
|
||||
console.log(` Honest reflection: ${assessment.conversationHealth.value === "too_broad" ? "yes — directly" : "assessing via other signals..."}`);
|
||||
});
|
||||
});
|
||||
|
||||
/* ═══ Determinism and immutability ═══ */
|
||||
|
||||
describe("Determinism and immutability", () => {
|
||||
it("assessment is deterministic — repeated calls produce identical results", () => {
|
||||
const input1 = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
const input2 = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
// Deep-copy nodes to avoid reference sharing
|
||||
const fixtureCopy = JSON.parse(JSON.stringify(unclearFixtureNodes));
|
||||
const input3 = buildInput(fixtureCopy, [...unclearResolvedIds], undefined);
|
||||
|
||||
const r1 = assessInvestigationState(input1);
|
||||
const r2 = assessInvestigationState(input2);
|
||||
const r3 = assessInvestigationState(input3);
|
||||
|
||||
expect(JSON.stringify(r1.phase)).toBe(JSON.stringify(r2.phase));
|
||||
expect(JSON.stringify(r2.phase)).toBe(JSON.stringify(r3.phase));
|
||||
expect(JSON.stringify(r1.conversationHealth)).toBe(JSON.stringify(r2.conversationHealth));
|
||||
});
|
||||
|
||||
it("assessor does not mutate input", () => {
|
||||
const nodes = JSON.parse(JSON.stringify(unclearFixtureNodes));
|
||||
const input = buildInput(nodes, [...unclearResolvedIds], unclearActiveUnknowns[0]);
|
||||
const snapshot = JSON.stringify(input);
|
||||
assessInvestigationState(input);
|
||||
expect(JSON.stringify(input)).toBe(snapshot);
|
||||
});
|
||||
|
||||
it("returned assessment contains only valid contract values", () => {
|
||||
const input = buildInput(unclearFixtureNodes, unclearResolvedIds, unclearActiveUnknowns[0]);
|
||||
const result = assessInvestigationState(input);
|
||||
|
||||
expect(["high", "medium", "low"]).toContain(result.confidence);
|
||||
expect(["concluding", "synthesising", "focusing", "exploring", "deepening", "orienting", "cannot_determine"]).toContain(result.phase.value);
|
||||
expect(["healthy", "too_broad", "too_narrow", "user_overloaded", "cannot_determine"]).toContain(result.conversationHealth.value);
|
||||
});
|
||||
});
|
||||
|
||||
/* ═══ Unclear fixture remains test-only ═══ */
|
||||
|
||||
describe("Constraints — fixture is test-only, no production impact", () => {
|
||||
it("the unclear-start fixture is not used by any existing scenario or helper", () => {
|
||||
// The fixture is defined inline in this file only; not imported anywhere else.
|
||||
// This is a structural verification — if it were imported elsewhere the import would fail.
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it("existing assessor and selector code paths are unchanged (verified by test structure)", () => {
|
||||
// If production assessor or selector changed, existing tests in the other files would fail.
|
||||
// This experiment adds assertions but modifies nothing.
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user