Feature/product platform foundation v0.62 #1

Merged
robbond merged 683 commits from feature/product-platform-foundation-v0.62 into feature/emergent-unknowns-v0.5 2026-09-09 07:58:20 +01:00
2 changed files with 84 additions and 0 deletions
Showing only changes of commit 870d6caa05 - Show all commits
+12
View File
@@ -1707,3 +1707,15 @@ This satisfies 57J.77's boundary A recommendation: a committed update-only path
### Experiment 57J.86 — Smallest Recovery Contract for Null Semantic/Action with Good Mutation (Read-Only Design)
**Objective:** What is the smallest recovery contract that lets the engine preserve a good mutation while recovering missing semantic/action declarations, without regenerating or discarding the mutation? Read-only design evaluation of four options (deterministic action fill, declaration-only repair call, full regeneration, keep transition path). **Classification: B — DECLARATION-ONLY REPAIR CALL.** structuralActionRequired is PARTIALLY recoverable from structure via hasMeaningfulChange=true (but this changes field semantics from model declaration to engine inference). answerMeaning fields are NOT recoverable from mutation structure alone. Existing code has zero repair capability — validator only validates, orchestrator returns errors on rejection with no retry/repair path. Option B chosen: one bounded second-stage repair call that preserves mutation arrays exactly and recovers all missing declarations (answerMeaning + structuralActionRequired) through model declaration. Repair receives raw answer + original proposal as context; forbidden from changing any mutation arrays. Repair classified as SECOND-STAGE REPAIR, not RETRY or NORMAL SECOND CALL — existing call accounting cannot cleanly distinguish repair calls without tooling change. Non-negotiable invariants all met: original mutation preserved, no keyword logic, no regeneration, exactly 1 bounded additional call, provider-agnostic, 57J.84 information survives full recovery. No production code changed; no Ollama calls; documentation-only design.
### Experiment 58A.4 — Question-Like Label Formulation Fix
**Objective:** When an unknown's label is already interrogative (wh-question, yes/no question via subject-auxiliary inversion, or whether-clause), produce a grammatically correct follow-up question instead of interpolating the label raw into a declarative template frame.
**Defect reproduced by 58A.2 + 58A.3:** "What would clarify are the projected office savings from relocation realistic in this situation?" — malformed template injection.
**Fix summary:** Added `isInterrogativeMeaning()` (generic interrogative detection: wh-prefix, subject-auxiliary inversion, whether-clause) and `wrapInterrogativeForTemplate()`. All five question-builders now short-circuit before template interpolation when the meaning is already interrogative. Noun-phrase behaviour preserved. Target selection unchanged.
**Ownership location:** `lib/graph/question-formulator.js` — functions `isInterrogativeMeaning`, `wrapInterrogativeForTemplate`, and modified paths in `buildNeutralClarificationQuestion`, `buildEvidenceFallbackQuestion`, `buildQuestionFromFamily`, `buildQuestionFromStrategy`.
**Classification: PASS.** 20 new focused tests pass. No regressions. Two unrelated pre-existing failures explicitly out of scope: `question-priority-generalisation`, `selection-influence-diagnostic`.
+72
View File
@@ -0,0 +1,72 @@
# 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)