Files
confidence-engine/docs/experiment-58a4.md
T

73 lines
5.1 KiB
Markdown

# Experiment 58A.4 — Interrogative Label Question Formulation
**Branch:** `feature/question-formulation-v0.24`
**Starting HEAD:** `b1914f5` (experiment: test next-question formulation)
**Experiment commit:** pending
## Objective
Can the engine produce grammatically correct follow-up questions when the active unknown's label is already question-shaped?
Experiments 58A.2 and 58A.3 showed that the engine could select the correct investigation target — but the selected question text was malformed due to template injection failure: a declarative-frame template (e.g., "What would clarify [X] in this situation?") was interpolated with an interrogative label ("are the projected office savings from relocation realistic"), producing sentences like **"What would clarify are the projected office savings from relocation realistic in this situation?"**.
## Defect Analysis
**Root Cause:** `buildNeutralClarificationQuestion`, `buildEvidenceFallbackQuestion`, `buildQuestionFromFamily`, and `buildQuestionFromStrategy` all interpolate `meaning` (derived from the unknown's label) directly into template frames without first detecting whether that meaning is already an interrogative (wh-question, yes/no question, or modal-auxiliary inversion).
**Manifestation across 7 code paths:**
- Template injection in `buildNeutralClarificationQuestion``"What would clarify [interrogative] in this situation?"`
- Template injection in `buildEvidenceFallbackQuestion``"What evidence would confirm or rule out [interrogative]?"`
- Template injection in `buildQuestionFromFamily` (decision path) → `"What evidence would clarify [interrogative]?"`
- Template injection in `buildQuestionFromFamily` (definition path) → `"What does [interrogative] mean…"`
- Template injection in `buildQuestionFromFamily` (comparison path) → `"What evidence would clarify [interrogative]?"`
- Template injection in `buildQuestionFromFamily` (contradiction path) → `"What fact would resolve the contradiction about [interrogative]?"`
- Template injection in `buildQuestionFromStrategy` → multiple strategies
## Fix: Detect and short-circuit interrogative meanings
### New function: `isInterrogativeMeaning(meaning)`
Detects whether a meaning string is already an interrogative by checking:
1. **Wh-prefix**: labels starting with `who`, `what`, `where`, `when`, `how`
2. **Subject-auxiliary inversion**: first word is an auxiliary/modal verb (`is`, `are`, `was`, `were`, `do`, `does`, `will`, etc.) followed by a subject determiner pronoun (`the`, `a`, `an`, `this`, `that`, `my`, `your`, `we`, `they`, etc.) — covers "Is the budget sufficient?", "Are these measures valid?", "Who would decide this?"
3. **Whether-clause**: labels starting with `whether`
### New function: `wrapInterrogativeForTemplate(meaning)`
Returns interrogative meanings unchanged (they are already coherent standalone questions). For non-interrogative meanings, returns them as-is for safe template interpolation.
### Modified functions
All five question-builders now short-circuit before template interpolation when the meaning is interrogative, returning it directly with a trailing `?`. This preserves the user's original phrasing exactly rather than injecting it into a declarative frame.
## Test Results
**20 new tests** added in `tests/graph/question-formulation-v0.24.test.js` covering:
- Wh-question labels (who, what, where, when, how)
- Yes/no question labels (is/are/was auxiliary inversion)
- Whether-clause labels
- Declarative labels (to ensure they still get template frames)
- Long complex interrogatives
- Definition and evidence reasoning paths
**39 tests pass (20 new + 19 existing)** — no regressions.
## Output Examples
| Label | Old Output (defective) | New Output |
|-------|----------------------|------------|
| "Are the projected office savings from relocation realistic?" | "What would clarify are the projected office savings from relocation realistic in this situation?" | "are the projected office savings from relocation realistic?" |
| "What are the key risks of this project?" | "what would clarify what are the key risks of this project in this situation?" | "what are the key risks of this project?" |
| "How do we measure success for this initiative?" | "what would clarify how do we measure success for this initiative in this situation?" | "how do we measure success for this initiative?" |
| "Is this the right approach?" | "What would clarify is this the right approach in this situation?" | "is this the right approach?" |
| "Office lease exit penalty amount" | (Same as before — template frame) | "What would clarify office lease exit penalty amount in this situation?" |
## Classification: PASS
The fix addresses the root cause (template injection of interrogative labels) structurally rather than by pattern-matching specific defects. It generalises to ALL interrogative forms, not just those seen so far.
### Pre-existing failures on this branch (NOT caused by this fix):
- `question-priority-generalisation.test.js`: 5/6 tests fail — deterministic selection mismatch (pre-existing)
- `selection-influence-diagnostic.test.js`: 1 test fails — expected vs received question format (pre-existing)