refactor: split flat core into capability packages, layer the conversations service, English defaults for every model-facing text
This commit is contained in:
+13
-10
@@ -5,12 +5,15 @@ from pathlib import Path
|
||||
|
||||
from test_conversations import ScriptedClient, World, world
|
||||
|
||||
from beaver_gateway.core.conversations import UserSaid
|
||||
from beaver_gateway.core.envelope import HEADER, Envelope, RecallContext, render
|
||||
from beaver_gateway.core.watch import Change, VaultWatch, WatchRules
|
||||
from beaver_gateway.conversations.service import UserSaid
|
||||
from beaver_gateway.conversations.envelope import Envelope, RecallContext, render
|
||||
from beaver_gateway.conversations.texts import EnvelopeTexts
|
||||
from beaver_gateway.vault.watch import Change, VaultWatch, WatchRules
|
||||
|
||||
__all__ = ["world"]
|
||||
|
||||
HEADER = EnvelopeTexts().header
|
||||
|
||||
RULES = WatchRules(
|
||||
full=("дни/{today}.md",),
|
||||
names=("дни/*", "люди/*", "мета/бобер/*"),
|
||||
@@ -88,11 +91,11 @@ def test_envelope_respects_ceilings_and_names_only_window() -> None:
|
||||
lines = text.splitlines()
|
||||
assert lines[0] == HEADER
|
||||
assert "(Warsaw)" in lines[1]
|
||||
assert lines[2].startswith("vault, изменено со старта: ")
|
||||
assert lines[2].startswith("vault, changed since start: ")
|
||||
assert f"дни/{today}.md (+200)" in lines[2]
|
||||
assert "люди/Петя.md (+50)" in lines[2]
|
||||
assert sum(1 for line in lines if line.startswith("+ ")) == 31
|
||||
assert "+ … ещё 170" in lines
|
||||
assert "+ … 170 more" in lines
|
||||
assert len(lines) <= 120
|
||||
append(diary, "- ещё одна\n")
|
||||
watch.note(diary)
|
||||
@@ -122,8 +125,8 @@ def test_render_hits_total_ceiling() -> None:
|
||||
)
|
||||
lines = text.splitlines()
|
||||
assert len(lines) <= 120
|
||||
assert "… (потолок конверта)" in lines
|
||||
assert lines[1] == "время: 2026-08-26 13:04 (Warsaw)"
|
||||
assert "… (envelope cap)" in lines
|
||||
assert lines[1] == "time: 2026-08-26 13:04 (Warsaw)"
|
||||
|
||||
|
||||
async def test_master_turn_gets_envelope_after_text_and_before_injects(
|
||||
@@ -142,12 +145,12 @@ async def test_master_turn_gets_envelope_after_text_and_before_injects(
|
||||
assert head == "hello"
|
||||
assert rest.startswith(HEADER)
|
||||
assert "люди/Прохор.md (+1)" in rest
|
||||
assert rest.index("[инжекты") > rest.index(HEADER)
|
||||
assert rest.index("[injects") > rest.index(HEADER)
|
||||
branch = await world.conversations.spawn(
|
||||
kind="branch", parent=master, seed="brief", text="do X"
|
||||
)
|
||||
await world.settle(branch, 1)
|
||||
assert "[конверт" not in ScriptedClient.instances[-1].prompts[0]
|
||||
assert "[envelope" not in ScriptedClient.instances[-1].prompts[0]
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
@@ -187,7 +190,7 @@ async def test_recall_lines_follow_the_vault_block_and_reach_branches(
|
||||
branch_prompt = ScriptedClient.instances[-1].prompts[0]
|
||||
assert "про Прохор подробнее\n\n" + HEADER in branch_prompt
|
||||
assert branch_prompt.endswith(f"{HEADER}\n👤 Прохор - карточка `люди/Прохор.md`")
|
||||
assert "vault, изменено" not in branch_prompt
|
||||
assert "vault, changed" not in branch_prompt
|
||||
# the first branch turn carries the seed line above the text
|
||||
assert seen[-1][0] == "branch" and seen[-1][1].endswith("про Прохор подробнее")
|
||||
assert noted[-1].kind == "branch"
|
||||
|
||||
Reference in New Issue
Block a user