feat: recover evolving threads from freeform notes

This commit is contained in:
wuyang
2026-07-29 16:21:48 +08:00
parent af7bb68268
commit 953f69e092
7 changed files with 238 additions and 24 deletions
+60 -1
View File
@@ -25,7 +25,11 @@ def database(tmp_path: Path) -> Database:
return db
def assessment(idea_id: str | None = None, maturity: float = 38):
def assessment(
idea_id: str | None = None,
maturity: float = 38,
supporting_fragment_ids: list[str] | None = None,
):
return {
"idea_id": idea_id,
"title": "无分类的笔记入口",
@@ -38,6 +42,7 @@ def assessment(idea_id: str | None = None, maturity: float = 38):
"trajectory": "从输入摩擦的感受,收束成了产品边界。",
"possible_moves": ["做一个只保留原文的输入原型"],
"relevance": 1,
"supporting_fragment_ids": supporting_fragment_ids or [],
}
@@ -119,6 +124,60 @@ def test_curator_prompt_contains_recent_continuity_and_idea_catalog(
assert "我识别出了两个新的认知" in prompt
assert "无分类的笔记入口" in prompt
assert "不要要求用户显式建立会话" in prompt
assert "supporting_fragment_ids" in prompt
assert "是否形成新的未完成方向" in prompt
def test_later_fragment_can_recover_earlier_standalone_evidence(
tmp_path: Path,
):
db = database(tmp_path)
earlier = db.create_fragment(
ADMIN.id, "也许该重新设计小爱的架构,但现在还说不清。"
)
db.apply_assessments(ADMIN.id, earlier["id"], [])
current = db.create_fragment(
ADMIN.id, "这个新工作确定要做,我先熟悉 harness 5.0。"
)
db.apply_assessments(
ADMIN.id,
current["id"],
[assessment(supporting_fragment_ids=[earlier["id"]])],
)
idea = db.get_idea(ADMIN.id, db.list_ideas(ADMIN.id)[0]["id"])
assert [item["content"] for item in idea["fragments"]] == [
earlier["content"],
current["content"],
]
assert idea["snapshots"][-1]["fragment_ids"] == [
earlier["id"],
current["id"],
]
def test_recovered_evidence_cannot_cross_user_boundary(tmp_path: Path):
db = database(tmp_path)
member_fragment = db.create_fragment(MEMBER.id, "另一个人的记录")
current = db.create_fragment(ADMIN.id, "管理员的新方向")
try:
db.apply_assessments(
ADMIN.id,
current["id"],
[
assessment(
supporting_fragment_ids=[member_fragment["id"]]
)
],
)
except ValueError as exc:
assert str(exc) == "supporting fragment not found for user"
else:
raise AssertionError("cross-user supporting fragment was accepted")
assert db.list_ideas(ADMIN.id) == []
def test_delayed_reanalysis_keeps_later_input_out_of_prior_context(