feat: introduce reasoning pattern selection

This commit is contained in:
2026-08-03 10:25:26 +01:00
parent 42d4da3496
commit b00928d6fb
7 changed files with 986 additions and 19 deletions
@@ -94,6 +94,95 @@ The engine now decomposes whenever either of these is true:
This prevents a broad container node from becoming the selected question target even when its wording looks grammatically singular.
## Reasoning Pattern
The next failure exposed a deeper issue: even after atomicity and answerability were added, the engine could still choose a question template from the wrong reasoning family.
The live failure was an explanation-style prompt appearing in a commercial validation scenario:
> What changed during the period that could help explain why ...
That was wrong not because of wording, but because the engine had selected an **explanation family** when the actual task was a **decision investigation**.
To correct that, the deterministic pipeline now explicitly inserts a reasoning-pattern stage:
```text
selected unknown
→ atomicity
→ answerability
→ reasoning pattern
→ investigation strategy
→ question family
→ question
```
This matters because each stage must constrain the next.
- **Reasoning Pattern** decides what kind of reasoning is happening
- **Investigation Strategy** decides how to reduce uncertainty within that pattern
- **Question Family** decides what template space is allowed
- **Question** is the final concrete wording
Without this stage separation, strategy and template selection can leak across domains and reuse relationship/explanation prompts too broadly.
## Deterministic reasoning-pattern vocabulary
The current deterministic pattern vocabulary is intentionally small:
- decision
- explanation
- contradiction
- definition
- diagnosis
- comparison
- prioritisation
Pattern selection uses graph structure rather than wording alone, including:
- node kind
- relationship / observation topology
- parent context
- reasoning state
- selected unknown role in the graph
## Question-family mapping
Patterns now constrain which question families are allowed.
- **decision**
- decision_foundation
- decision_evidence
- decision_threshold
- definition
- **explanation**
- explanation
- comparison
- **contradiction**
- contradiction
- comparison
- explanation
- **definition**
- definition
- **diagnosis**
- diagnosis
- comparison
- **comparison**
- comparison
- **prioritisation**
- prioritisation
- decision_threshold
Most importantly:
- explanation templates are only allowed for `explanation` or `contradiction`
- decision investigations cannot emit explanation-family questions
## Live correction
For the commercial-method scenario, the engine now classifies the reasoning as a **decision** pattern rather than an explanation pattern.
That means explanation-family templates are explicitly rejected, and the selected child unknown must be questioned using a decision-compatible family instead.
## UI result
The long compound question no longer survives as the first follow-up in the tested path.