fix(8321): a .grimoire marker that disagrees with the repo's binding is named at session start
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Failing after 1m58s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Build & push image (push) Skipped

A marker copied along with a repo outlived the project it was written for:
the Throne folder's marker still named project 38 after the split, so every
hook held the session to Cartographer and writes to Throne stopped on the
project fence, with nothing saying why.

The SessionStart hook now sends the remote beside a marker's project_id. The
marker still decides the project; /context also resolves the remote's binding,
and when it names a different project the context says which project each
names and how to fix the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-02 13:22:50 -05:00
co-authored by Claude Opus 5.5
parent 9de0e80531
commit f4d6486255
6 changed files with 113 additions and 3 deletions
+26 -1
View File
@@ -2339,9 +2339,26 @@ def _goal_line(goal: str, project_id: int) -> str:
return f"Goal: {short} (full goal: `enter_project({project_id})`)"
async def _marker_conflict_lines(user_id: int, project, repo_project_id: int) -> list[str]:
"""The section saying a `.grimoire` marker and the repo's binding name
different projects, and that the marker is the one in force."""
bound = await projects_svc.get_project(user_id, repo_project_id)
bound_name = f"{bound.title} (id {bound.id})" if bound is not None else f"project {repo_project_id}"
return [
"",
"## ⚠️ This folder's `.grimoire` marker overrides its repo binding",
f"The marker file names {project.title} (id {project.id}), but this "
f"repo's remote is bound to {bound_name}. The marker wins, so every "
f"hook this session (rules, recall, the project fence) works as "
f"{project.title}, and writes to {bound_name} stop on a permission "
"prompt. If this folder belongs to the bound project, correct the "
"marker's `project_id` or delete the file so the binding decides.",
]
async def build_session_context(
user_id: int, project_id: int = 0, unbound_repo: str = "",
source: str = "", session_id: str = "",
source: str = "", session_id: str = "", repo_project_id: int = 0,
) -> dict:
"""Render the SessionStart context for a user, optionally project-scoped.
@@ -2360,6 +2377,12 @@ async def build_session_context(
claim section says (`task_claims.render_claims`): a compaction gets back the work it had claimed
with its latest logs; a new session hears about other sessions'
live and abandoned claims; a resume hears nothing.
repo_project_id: the project the working repo's remote is bound to,
when a `.grimoire` marker named `project_id` instead. The marker
wins, but when the two differ the session is told which project
each names: a marker copied along with a repo outlives the
project it was written for, and without this line a session is
held to the old project with nothing saying why.
Returns {"context": str, "project": dict | None}.
@@ -2389,6 +2412,8 @@ async def build_session_context(
_goal_line(goal, project.id),
f"Open todo tasks: {open_count}",
]
if repo_project_id and repo_project_id != project.id:
lines += await _marker_conflict_lines(user_id, project, repo_project_id)
# A design system binds the same way a rule does, and without this
# the standards would reach only an agent that already knew to look