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
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:
@@ -136,6 +136,59 @@ async def test_build_session_context_includes_project_when_scoped():
|
||||
assert "Reflex:" not in out["context"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("repo_project_id, says", [(43, True), (38, False), (0, False)])
|
||||
async def test_a_marker_that_disagrees_with_the_repo_binding_is_named(repo_project_id, says):
|
||||
"""A `.grimoire` marker names project 38 while the repo's remote is bound
|
||||
to 43: the marker wins, and the session is told which project each names
|
||||
and how to fix the file. Agreeing, or no binding to compare, says nothing."""
|
||||
projects = {38: MagicMock(id=38, title="Cartographer", goal="", design_system_id=None),
|
||||
43: MagicMock(id=43, title="Throne", goal="", design_system_id=None)}
|
||||
|
||||
async def get_project(_uid, pid):
|
||||
return projects.get(pid)
|
||||
|
||||
with patch("grimoire.services.plugin_context.projects_svc.get_project", get_project), \
|
||||
patch("grimoire.services.plugin_context.notes_svc.list_notes",
|
||||
AsyncMock(return_value=([], 0))):
|
||||
from grimoire.services.plugin_context import build_session_context
|
||||
out = await build_session_context(user_id=7, project_id=38, repo_project_id=repo_project_id)
|
||||
|
||||
assert out["project"] == {"id": 38, "title": "Cartographer"}
|
||||
ctx = out["context"]
|
||||
assert ("overrides its repo binding" in ctx) is says
|
||||
if says:
|
||||
assert "names Cartographer (id 38)" in ctx and "bound to Throne (id 43)" in ctx
|
||||
assert "delete the file" in ctx
|
||||
|
||||
|
||||
@pytest.mark.parametrize("query, resolves, passed", [
|
||||
({"project_id": "38", "repo": "https://git.example.com/o/r.git"}, 43, 43),
|
||||
({"project_id": "38"}, 43, 0),
|
||||
({"repo": "https://git.example.com/o/r.git"}, 43, 0),
|
||||
])
|
||||
async def test_the_route_looks_up_the_remote_beside_a_marker(query, resolves, passed):
|
||||
"""With a marker's project_id AND the remote, the route resolves the
|
||||
remote's binding too and hands it on; the project stays the marker's.
|
||||
With only one key there is nothing to compare."""
|
||||
import inspect
|
||||
from types import SimpleNamespace
|
||||
|
||||
from quart import Quart, g
|
||||
|
||||
from grimoire.routes import plugin as routes
|
||||
|
||||
build = AsyncMock(return_value={"context": "", "project": None})
|
||||
app = Quart(__name__)
|
||||
async with app.test_request_context("/api/plugin/context", query_string=query):
|
||||
g.user = SimpleNamespace(id=7)
|
||||
with patch.object(routes.repo_bindings_svc, "resolve_project", AsyncMock(return_value=resolves)), \
|
||||
patch.object(routes.plugin_ctx_svc, "build_session_context", build):
|
||||
await inspect.unwrap(routes.session_context)()
|
||||
args, kwargs = build.await_args
|
||||
assert args[1] == (38 if "project_id" in query else resolves)
|
||||
assert kwargs["repo_project_id"] == passed
|
||||
|
||||
|
||||
def test_a_short_goal_is_shown_whole():
|
||||
from grimoire.services.plugin_context import _goal_line
|
||||
assert _goal_line("ship it", 2) == "Goal: ship it"
|
||||
|
||||
Reference in New Issue
Block a user