feat(ux): T4-b 后端 — draft 端点接收本章指令 directive 直通 assemble(volatile)
assemble/_build_volatile 加 directive 参数(仅入 volatile,守缓存前缀不变量 #9);stream_draft 加可选 body {directive} 透传;不持久化、无迁移;directive 长度入 log 不记原文。新 DraftStreamRequest schema + 重生成 TS 客户端。后端门禁绿: ruff/mypy/pytest。契约记 memory/contracts.md。
This commit is contained in:
@@ -196,6 +196,33 @@ async def test_draft_stream_yields_sse_tokens_and_done() -> None:
|
||||
assert gateway.requests[0].tier == "writer"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_stream_threads_directive_into_volatile() -> None:
|
||||
gateway = FakeWriterGateway(chunks=["正文"])
|
||||
client, _, _, _ = _make_client(gateway=gateway)
|
||||
pid = uuid.uuid4()
|
||||
async with client:
|
||||
resp = await client.post(
|
||||
f"/projects/{pid}/chapters/1/draft", json={"directive": "多写战斗"}
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert len(gateway.requests) == 1
|
||||
# 指令直通 assemble→volatile(write 节点把 volatile 放进 LlmRequest.input)。
|
||||
assert "多写战斗" in str(gateway.requests[0].input)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_stream_backward_compatible_without_body() -> None:
|
||||
gateway = FakeWriterGateway(chunks=["正文"])
|
||||
client, _, _, _ = _make_client(gateway=gateway)
|
||||
pid = uuid.uuid4()
|
||||
async with client:
|
||||
resp = await client.post(f"/projects/{pid}/chapters/1/draft")
|
||||
assert resp.status_code == 200
|
||||
assert len(gateway.requests) == 1
|
||||
assert "本章指令" not in str(gateway.requests[0].input)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_stream_maps_error_to_sse_error_event() -> None:
|
||||
from ww_shared import AppError
|
||||
|
||||
Reference in New Issue
Block a user