Preserve context across conversation intents (V-542)

Owner explicitly requested direct commits to master; bypass the branch-only hook.
This commit is contained in:
2026-08-13 02:14:46 +04:00
parent a0e6643465
commit da9114b623
15 changed files with 499 additions and 56 deletions
@@ -0,0 +1,48 @@
# Five turns retain one referent across fact, query and chat routes
Measured 2026-08-13 on homesrv from `master` at `a0e6643` plus the V-542
working tree. Task: V-542. The run uses the deterministic simulator phraser;
no resident model is needed.
## Setup
`conversation_anaphora.json` replays the five Russian turns that exposed the
defect. Their scripted router decisions remain the observed
fact/query/query/chat/query sequence. Each of the four contextual replies is
accepted only if the chat phraser receives history containing the original
`купил новый монитор` turn; this prevents a canned response from hiding a
missing transcript.
Commands:
```sh
make t PKG=./cmd/mavend RUN='TestExplicitConversationOpenerKeepsCrossIntentSessionAlive|TestConversationOpenerDoesNotMatchAnotherDavaiCommand|TestFollowUpMerge|TestSimulatorScenarios/conversation_anaphora' V=1 RACE=1
make t PKG=./internal/dialogue RUN=TestSessionSurvivesRestart V=1 RACE=1
make t PKG=./internal/router RUN=TestAnaphoraResolverUsesTokenBoundariesAcrossPunctuation V=1 RACE=1
MAVEN_DIALOGUE_NO_SKIP=1 make t PKG=./cmd/mavend RUN=TestDialogueTraces V=1 RACE=0
```
## Result
| Gate | before | after |
| --- | ---: | ---: |
| contextual replies that name the monitor | 0/4 | **4/4** |
| replies proven to receive the original turn in history | 0/4 | **4/4** |
| original grounded fact still written | 1/1 | **1/1** |
| unsolicited sends in five turns plus one tick | 0/6 | **0/6** |
| focused race-tested packages | — | **3/3 pass** |
The forced dialogue suite passed 18/22 rows. Its four failures are the existing,
unrelated offline-floor cases for a mid-flow note, a correction while a question
is parked, a whole-day reminder, and a short correction that does not park a
clarification. None exercises V-542; the continuity scenario and all focused
race gates pass.
## What this rules out
The fix does not rewrite pronouns into guessed nouns or add a phrase regex.
Exact utterances form a persisted, chronological transcript independently of
intent slots. An anaphoric query with live dialogue context moves to chat and
clears query-source provenance; non-anaphoric queries retain their source path,
and acts are never widened. An explicit conversation opener extends session
lifetime without suppressing the fact side effect in its substantive clause.