feat(shell): NarrationBook wired to /dm/narrate with refire + fact-harvest

This commit is contained in:
2026-07-11 09:07:24 -05:00
parent bca04e3a2e
commit 5f1ebdf840
5 changed files with 151 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
extends "res://addons/gut/test.gd"
const SCENE := "res://scenes/shell/NarrationBook.tscn"
const FakeTransport = preload("res://tests/doubles/fake_transport.gd")
const DmResponse = preload("res://scripts/net/dm_response.gd")
func _book_with(response) -> NarrationBook:
var transport = FakeTransport.new()
transport.set_response(response)
var service := DmService.new(transport, FallbackLibrary.new())
var book = load(SCENE).instantiate()
add_child_autofree(book) # _ready() builds nodes + the considering indicator
book.setup(service, CanonLog.new(), ShellState.seed())
return book
func test_narrate_shows_prose_and_harvests_facts():
var book := _book_with(DmResponse.ok(200,
{"prose": "The rain runs black into the gutter. [FACT: the eastern bridge is out]"}))
var log := CanonLog.new()
var transport = FakeTransport.new()
transport.set_response(DmResponse.ok(200,
{"prose": "The rain runs black into the gutter. [FACT: the eastern bridge is out]"}))
book.setup(DmService.new(transport, FallbackLibrary.new()), log, ShellState.seed())
await book.narrate()
assert_string_contains(book._prose.text, "The rain runs black into the gutter.")
assert_false(book._prose.text.contains("[FACT"), "tags are stripped from displayed prose")
assert_true("the eastern bridge is out" in log.established_facts, "fact harvested to the log")
assert_false(book.last_degraded)
func test_degraded_response_shows_fallback_and_sets_flag():
var book := _book_with(DmResponse.failed("proxy down"))
await book.narrate()
assert_true(book.last_degraded, "a failed call degrades")
assert_ne(book._prose.text, "", "the fallback line is still shown (§13)")

View File

@@ -0,0 +1 @@
uid://dj6ly2ljf3ai4