feat(moments): actions map onto moments, with in-session corrections (milestone 458 step 2, #4920)
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / integration (push) Successful in 1m23s
CI & Build / Python tests (push) Successful in 2m0s
CI & Build / Build & push image (push) Successful in 36s
CI & Build / Plugin hooks (push) Successful in 18s
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 55s
CI & Build / integration (push) Successful in 1m23s
CI & Build / Python tests (push) Successful in 2m0s
CI & Build / Build & push image (push) Successful in 36s
moment_actions.resolve(tool, input) names every moment a call reaches and the action that reached it. One call can reach several: kubectl apply is a run, a deliver and a reach outside the workspace. Command tools match by how each segment of the line starts, with a word boundary; other tools by field=value arguments. The MCP server prefix and case are ignored. 56 shipped defaults cover the harness tools, Scribe tools and common command shapes. moment_mappings (migration 0116) holds what an install adds and the defaults it switches off. A removal is a stored row, so an upgrade does not switch the default back on. Per the operator ruling, corrections happen in the session: map_action and unmap_action (write tools) return now_reaches so the fix can be confirmed in the same reply. list_moments now shows each moment's actions on this install. REST mirrors both doors, recorded as human. Backup v21 carries the mappings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+22
-7
@@ -93,27 +93,42 @@ def test_the_catalog_payload_carries_every_moment_and_the_family():
|
||||
assert data["families"][0]["prefix"] == moments.SKILL_PREFIX
|
||||
|
||||
|
||||
async def test_the_tool_returns_the_service_catalog():
|
||||
async def test_the_tool_returns_the_catalog_with_this_installs_actions():
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
from scribe.mcp.tools import moments as tool
|
||||
|
||||
assert await tool.list_moments() == moments.catalog()
|
||||
by_moment = {"actions": {"work.change": []}, "removed_defaults": []}
|
||||
with patch.object(tool, "current_user_id", lambda: 7), \
|
||||
patch.object(tool.actions_svc, "actions_by_moment",
|
||||
AsyncMock(return_value=by_moment)) as read:
|
||||
out = await tool.list_moments()
|
||||
read.assert_awaited_once_with(7)
|
||||
assert out["moments"] == moments.catalog()["moments"]
|
||||
assert out["actions"] == by_moment["actions"]
|
||||
assert out["removed_defaults"] == []
|
||||
|
||||
|
||||
def test_the_tool_is_registered_and_read_only():
|
||||
from scribe.mcp.server import _READ_ONLY_TOOLS
|
||||
def test_the_tools_are_registered_and_classified():
|
||||
from scribe.mcp.server import _READ_ONLY_TOOLS, _WRITE_TOOLS
|
||||
from scribe.mcp.tools import moments as tool
|
||||
|
||||
mcp = FakeMCP()
|
||||
tool.register(mcp)
|
||||
assert mcp.names == ["list_moments"]
|
||||
assert mcp.names == ["list_moments", "map_action", "unmap_action"]
|
||||
assert "list_moments" in _READ_ONLY_TOOLS
|
||||
assert {"map_action", "unmap_action"} <= _WRITE_TOOLS
|
||||
|
||||
|
||||
def test_both_doors_read_one_catalog():
|
||||
"""Rule 33 parity: the tool and the route call the same service, so the
|
||||
session and the Settings view cannot name different moments."""
|
||||
"""Rule 33 parity: the tool and the routes call the same services, so the
|
||||
session and the Settings view cannot name different moments or disagree
|
||||
about what a mapping does."""
|
||||
from scribe.mcp.tools import moments as tool
|
||||
from scribe.routes import retrieval as routes
|
||||
from scribe.services import moment_actions
|
||||
|
||||
assert tool.moments_svc is moments
|
||||
assert routes.moments_svc is moments
|
||||
assert tool.actions_svc is moment_actions
|
||||
assert routes.moment_actions_svc is moment_actions
|
||||
|
||||
Reference in New Issue
Block a user