refactor(8211): the MCP instructions carry only what no response or skill delivers
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Python tests (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 21s
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Python tests (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 21s
569 characters, from 1,600: what Grimoire is, enter_project first, ask what_might_apply before a consequential act, search before building, the force of each record kind, and that responses say what to do next. The rest is enforced in responses or stated in a skill. The budget drops to 800, and the guidance registry stops requiring index words for the topics that left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -87,9 +87,8 @@ def test_the_plugin_names_the_skill_it_ships():
|
||||
# --- the pointers ---------------------------------------------------------------------
|
||||
|
||||
def test_every_surface_that_meets_family_canon_points_at_the_skill():
|
||||
server = (ROOT / "src" / "grimoire" / "mcp" / "server.py").read_text()
|
||||
index = re.search(r'_INSTRUCTIONS = """(.*?)"""', server, re.S).group(1)
|
||||
assert "family-canon" in index and "`family`" in index
|
||||
# Not the MCP instructions: `enter_project` returns the `family` key with
|
||||
# its own text, which is where a session meets family canon.
|
||||
for module, tool in (("notes", "create_note"), ("snippets", "create_snippet"),
|
||||
("shapes", "classify_shapes")):
|
||||
assert "family-canon" in tool_doc(f"grimoire.mcp.tools.{module}", tool), tool
|
||||
|
||||
@@ -22,12 +22,15 @@ WHAT IT PINS
|
||||
(the index, the adapter's static text and commands, the live context, the
|
||||
other skills). A topic legitimately stated in two places at two different
|
||||
moments declares that in `shared_with`, with the reason beside it.
|
||||
3. THE INDEX NAMES THE SESSION-START REFLEXES. `_INSTRUCTIONS` is the one
|
||||
surface every MCP client receives, so each reflex it indexes keeps its
|
||||
`index` markers there — a one-line pointer, not a copy. Only session-start
|
||||
practices carry `index`: judging, reporting and the missed-rule route fire
|
||||
mid-work, so they stay out of the index (the skills and the in-band
|
||||
responses carry them at the moment they apply).
|
||||
3. THE INDEX NAMES WHAT NOTHING ELSE DELIVERS. `_INSTRUCTIONS` is the one
|
||||
surface every MCP client receives, so a topic it indexes keeps its `index`
|
||||
markers there — a one-line pointer, not a copy. Only the practices a client
|
||||
with no skills and no hooks would otherwise never meet carry `index`:
|
||||
entering the project, asking before a consequential act, searching before
|
||||
building, and the force of each record kind. A practice a response enforces
|
||||
(the duplicate gate, the unassigned-id refusal, `existing_milestone`,
|
||||
`systems_hint`, the design-system block) or that fires mid-work carries no
|
||||
`index`: the response or the skill delivers it at the moment it applies.
|
||||
|
||||
WHAT IT CANNOT SEE
|
||||
|
||||
@@ -133,7 +136,7 @@ TOPICS: tuple[Topic, ...] = (
|
||||
index=("enter_project",)),
|
||||
Topic("rules are retrieved; ask before a consequential act", U, ('content_type="rule"', "nothing matched"),
|
||||
"an empty session is not evidence of an empty rulebook",
|
||||
index=('content_type="rule"', "nothing matched")),
|
||||
index=("nothing matched",)),
|
||||
Topic("rules bind, preferences guide and are kept current", U, ("preference", "update_preference"),
|
||||
"updating one mid-work is the normal case rather than an interruption of it",
|
||||
index=("preferences guide",)),
|
||||
@@ -170,11 +173,11 @@ TOPICS: tuple[Topic, ...] = (
|
||||
Topic("stay inside the active project's scope", U, ("stay inside the active project", "cross-project"),
|
||||
"stay inside the active project's scope", index=("project_id",)),
|
||||
Topic("record as you go; honest status; fixes are issues", U, ("add_task_log", "in_progress", 'kind="issue"'),
|
||||
"fixes are issues, not work-logs", index=("add_task_log", 'kind="issue"')),
|
||||
"fixes are issues, not work-logs"),
|
||||
Topic("an id exists only once a create returns it", U, ("exists only once a create", "{{ref:"),
|
||||
"exists only once a create call returns it", index=("create_records", "{{ref:n}}")),
|
||||
"exists only once a create call returns it"),
|
||||
Topic("tag records to systems as you write", U, ("system_ids", "create_system"),
|
||||
"would someone investigating that subsystem want this record", index=("system_ids",)),
|
||||
"would someone investigating that subsystem want this record"),
|
||||
Topic("answer the systems_hint at the moment of work", U, ("systems_hint",),
|
||||
"treat it as the tagging question asked at the moment of work"),
|
||||
Topic("a retrieved rule outranks a default habit", U, ("outranks a default habit",),
|
||||
@@ -186,11 +189,11 @@ TOPICS: tuple[Topic, ...] = (
|
||||
("hand off", "claims it for this session"),
|
||||
"write down what the next session needs"),
|
||||
Topic("the project's design system binds ui", U, ("resolve_design_system",),
|
||||
"building ui: the project's design system binds", index=("resolve_design_system",)),
|
||||
"building ui: the project's design system binds"),
|
||||
Topic("name the record, never just its number", U, ("name the record",),
|
||||
"a bare id reads as complete to you and as homework to them"),
|
||||
Topic("project inception is a decision", U, ("decide_project_inception",),
|
||||
"starting a project: decide what it inherits", index=("decide_project_inception",)),
|
||||
"starting a project: decide what it inherits"),
|
||||
Topic("where a new rule goes, and its trigger", U, ("create_project_rule", "when_to_apply"),
|
||||
"whichever home it gets"),
|
||||
Topic("a rule vs the other entities", U, ("standing instruction",), "first ask whether it's a rule at all"),
|
||||
@@ -200,7 +203,7 @@ TOPICS: tuple[Topic, ...] = (
|
||||
Topic("rules mounted on a moment arrive by lookup; correct a misfire in-session", U,
|
||||
("list_moments", "map_action", "unmap_action", "judge_rule_moments"),
|
||||
"it belongs in the session that noticed, not on a settings page",
|
||||
index=("list_moments", "moment")),
|
||||
),
|
||||
Topic("a new rule about when gets its moments as it is written", U,
|
||||
("moments=[...]", "create_process(moments="),
|
||||
"then ask when it applies, as well as what it is about"),
|
||||
@@ -247,16 +250,16 @@ TOPICS: tuple[Topic, ...] = (
|
||||
"which files are which area is your call"),
|
||||
# ── process arcs — owned by their skills ──
|
||||
Topic("plan in a milestone, steps created together", "skill:writing-plans", ("start_planning", "{{ref:"),
|
||||
"a milestone earns its place when the work has an arc", index=("start_planning",)),
|
||||
"a milestone earns its place when the work has an arc"),
|
||||
# Without this, a session opens a second plan beside the roadmap milestone
|
||||
# that already covers the work.
|
||||
Topic("find the existing plan before making one", "skill:writing-plans",
|
||||
('content_type="milestone"', "unplanned_milestones", "existing_milestone"),
|
||||
"when an active milestone already covers the work, the plan is that milestone",
|
||||
index=('search(content_type="milestone")',)),
|
||||
),
|
||||
Topic("reuse recorded shapes; record at first build", "skill:reusing-code",
|
||||
("create_snippet", "when_to_use", "first build", "second copy"),
|
||||
"prior art offered beside a write is not noise", index=("create_snippet",)),
|
||||
"prior art offered beside a write is not noise"),
|
||||
# The writer judges what it wrote, at the end of the turn,
|
||||
# asked by the plugin's Stop hook — the moment the knowledge exists.
|
||||
Topic("judge what you wrote before the turn ends", "skill:reusing-code",
|
||||
@@ -304,7 +307,7 @@ TOPICS: tuple[Topic, ...] = (
|
||||
"skill:family-canon",
|
||||
("family_hint", "get_family_adoption", "resolve_family_conflict", "precedent"),
|
||||
"write the reason so a session in another project can tell whether the same fact holds there",
|
||||
index=("family-canon",)),
|
||||
),
|
||||
# ── per-tool contracts and in-band behaviour — owned by the server ──
|
||||
Topic("closing a task cues the report", "docstrings", ("report_back",), "reporting this to the operator?"),
|
||||
# The agent is the judge. Two topics, not one, because they fire
|
||||
@@ -329,9 +332,9 @@ TOPICS: tuple[Topic, ...] = (
|
||||
"it simply stops competing with this one"),
|
||||
Topic("deletes are recoverable from the trash", "docstrings", ("deleted_batch_id",), "deleted_batch_id"),
|
||||
Topic("creates are duplicate-gated", "docstrings", ("near-duplicate",), "bypass the near-duplicate gate",
|
||||
index=("duplicate-gated",)),
|
||||
),
|
||||
Topic("shared records are another user's suggestion", "docstrings", ("shared: true",),
|
||||
"belongs to another user", index=("shared:true",)),
|
||||
"belongs to another user"),
|
||||
Topic("stored processes are followed as written", "docstrings", ("get_process",), "follow the returned body"),
|
||||
Topic("a project is never guessed", "docstrings", ("never guessing a project",), "never guessing a project"),
|
||||
Topic("an unbound repo gets a bind hint", "live", ("bind_repo",), "isn't mapped to a grimoire project"),
|
||||
|
||||
@@ -51,11 +51,11 @@ def _instructions_text() -> str:
|
||||
|
||||
# Claude Code injects only the first ~2,048 characters of an MCP server's
|
||||
# instructions and silently cuts the rest mid-word, so guidance past the cap
|
||||
# never reaches a session. The budget is set below the cap, not at it: the
|
||||
# field runs ~600–1,600 characters, and
|
||||
# a block pressed against 2,048 is being used for depth that belongs in a
|
||||
# skill.
|
||||
INSTRUCTIONS_BUDGET = 1600
|
||||
# never reaches a session. The budget sits far below the cap: most servers
|
||||
# carry a few hundred characters or none, and the block holds only what no
|
||||
# response or skill delivers, so a block growing toward the cap is carrying
|
||||
# depth that belongs in a skill.
|
||||
INSTRUCTIONS_BUDGET = 800
|
||||
|
||||
|
||||
def test_instructions_fit_the_fold():
|
||||
|
||||
Reference in New Issue
Block a user