fix(8564): a decision about a family idea lands in no project, so the fence stops asking when a session promotes another project's idea
CI & Build / TypeScript typecheck (push) Canceled after 0s
CI & Build / Plugin hooks (push) Canceled after 0s
CI & Build / Python lint (push) Canceled after 0s
CI & Build / Python tests (push) Canceled after 0s
CI & Build / integration (push) Canceled after 0s
CI & Build / Build & push image (push) Canceled after 0s

Promoting, proposing, revising, retiring, and setting references or topic
write only the family's own state, never the record that carries the idea.
The project fence located them at that record's project, so the usual path
(the trigger fires in the project that built the idea second) always asked
the operator about a change to a project that nothing touched. A project's
answer stays located: assessments, conflicts, and undoing an assessment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 14:36:40 -05:00
co-authored by Claude Opus 5.5
parent f55e263d7e
commit 0d9fe5d3c5
5 changed files with 71 additions and 18 deletions
+35 -2
View File
@@ -9,6 +9,7 @@ import pytest_asyncio
from sqlalchemy import select
from grimoire.models import async_session
from grimoire.models.family import FamilyDecision, FamilyIdea
from grimoire.models.milestone import Milestone
from grimoire.models.note import Note
from grimoire.models.project import Project
@@ -45,10 +46,21 @@ async def two_projects():
note_type="note", task_kind="work", status="todo")
trashed = Note(user_id=user.id, project_id=other.id, title="Trashed", body="",
note_type="note", deleted_batch_id=BATCH)
s.add_all([theirs, mine, trashed])
idea = Note(user_id=user.id, project_id=other.id, title="Their idea", body="",
note_type="snippet")
s.add_all([theirs, mine, trashed, idea])
await s.flush()
s.add(FamilyIdea(note_id=idea.id, status="candidate"))
await s.flush()
proposed = FamilyDecision(idea_id=idea.id, project_id=None, action="propose",
reason="repeated", decided_via="system", user_id=user.id)
answered = FamilyDecision(idea_id=idea.id, project_id=home.id, action="assess",
reason="exempt here", decided_via="agent", user_id=user.id)
s.add_all([proposed, answered])
await s.commit()
return {"user": user.id, "home": home.id, "other": other.id, "plan": plan.id,
"area": area.id, "theirs": theirs.id, "mine": mine.id}
"area": area.id, "theirs": theirs.id, "mine": mine.id, "idea": idea.id,
"proposed": proposed.id, "answered": answered.id}
async def test_each_locator_finds_the_project_of_the_row_it_names(two_projects):
@@ -67,6 +79,27 @@ async def test_each_locator_finds_the_project_of_the_row_it_names(two_projects):
assert await lands("create_rule", topic_id=1) == set()
async def test_a_decision_about_a_family_idea_lands_in_no_project_and_an_answer_in_its_own(two_projects):
# The idea's record lives in the other project, but deciding about the
# idea writes only the family's state; undoing a project's answer writes
# that project's ledger row.
ids = two_projects
uid, home = ids["user"], ids["home"]
async def lands(tool, **args):
return await write_scope.tool_targets(uid, tool, args)
for tool in ("propose_family_idea", "promote_family_idea", "revise_family_idea",
"retire_family_idea", "set_family_references", "set_family_topic"):
assert await lands(tool, note_id=ids["idea"]) == set(), tool
assert await lands("undo_family_decision", decision_id=ids["proposed"]) == set()
assert await lands("undo_family_decision", decision_id=ids["answered"]) == {home}
promote = await write_scope.check_act(uid, home, tool="promote_family_idea",
args={"note_id": ids["idea"]})
assert promote["allowed"] is True
async def test_a_session_in_one_project_is_asked_before_writing_in_the_other(two_projects):
ids = two_projects
uid, home, other = ids["user"], ids["home"], ids["other"]