feat(instructions): fit the delivery fold — 2k server map, floor Systems reflex, write-time systems_hint
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 7s
CI & Build / integration (push) Successful in 18s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 47s
CI & Build / Build & push image (push) Successful in 28s
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 7s
CI & Build / integration (push) Successful in 18s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / Python tests (push) Successful in 47s
CI & Build / Build & push image (push) Successful in 28s
Claude Code injects only the first ~2,048 chars of an MCP server's instructions and silently cuts the rest mid-word (#2562, observed live): _INSTRUCTIONS was 20,002 chars, so ~90% — including all Systems tagging guidance — never reached any session. Rearchitect delivery around what each surface actually delivers: - _INSTRUCTIONS becomes a 1,997-char purpose-sorted map, with a header comment stating the budget and where detail belongs instead. - Tool docstrings keep the per-tool HOW (audit: nearly all displaced topics were already duplicated there); backfill the four gaps — enter_project session scoping + project bootstrap, create_rule entity-vs-rule test, create_design_system not-a-rulebook, create_system two-records test. - The plugin static context (the delivery floor) gains the tag-to-Systems reflex and a surfaces-layering statement; plugin 0.1.25 -> 0.1.26 so the executing cache refreshes (#2209). - create_task / create_note / create_snippet return a systems_hint when a record is created untagged in a project that has Systems — in-band at the exact write it applies to, fail-open like the dedup gate. - Guards: _INSTRUCTIONS length budget, floor-states-the-reflex, and a displaced-topics sweep asserting every cut topic still lives on a delivered surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,95 @@ def test_every_session_start_surface_states_the_pull():
|
||||
)
|
||||
|
||||
|
||||
def _instructions_text() -> str:
|
||||
"""The _INSTRUCTIONS literal from server.py, as the client would see it."""
|
||||
import re
|
||||
src = (ROOT / "src" / "scribe" / "mcp" / "server.py").read_text()
|
||||
match = re.search(r'_INSTRUCTIONS = """(.*?)"""', src, re.S)
|
||||
assert match, "server.py no longer defines _INSTRUCTIONS as a triple-quoted literal"
|
||||
return match.group(1).strip()
|
||||
|
||||
|
||||
# Claude Code injects only the first ~2,048 characters of an MCP server's
|
||||
# instructions and silently cuts the rest mid-word (#2562: observed live —
|
||||
# the previous 20k-char version delivered ~10% of itself, and none of the
|
||||
# Systems tagging guidance ever reached a session). 2,000 leaves margin.
|
||||
INSTRUCTIONS_BUDGET = 2000
|
||||
|
||||
|
||||
def test_instructions_fit_the_fold():
|
||||
text = _instructions_text()
|
||||
assert len(text) <= INSTRUCTIONS_BUDGET, (
|
||||
f"_INSTRUCTIONS is {len(text)} chars; the client injects only ~2,048 "
|
||||
f"and silently cuts the rest (#2562). This block is a MAP — move the "
|
||||
f"detail to the tool's docstring (delivered at reach-for time), the "
|
||||
f"plugin static context (always delivered), or a skill; see the "
|
||||
f"comment above _INSTRUCTIONS."
|
||||
)
|
||||
|
||||
|
||||
def test_floor_states_the_systems_reflex():
|
||||
"""Write-time tagging guidance must live on the surface that always arrives.
|
||||
|
||||
#2562's behavioral finding: with the guidance only in tool descriptions,
|
||||
sessions filed records untagged. The static context is the delivery floor,
|
||||
so the tag-as-you-write reflex has to be stated there.
|
||||
"""
|
||||
floor = (ROOT / "plugin" / "hooks" / "scribe_static_context.md").read_text()
|
||||
for needle in ("system_ids", "create_system"):
|
||||
assert needle in floor, (
|
||||
f"plugin/hooks/scribe_static_context.md no longer mentions "
|
||||
f"{needle} — the Systems tagging reflex must be stated on the "
|
||||
f"floor, not only in tool descriptions (#2562)."
|
||||
)
|
||||
|
||||
|
||||
# Topics displaced from _INSTRUCTIONS when it was cut to fit the fold. Each
|
||||
# must remain stated on at least one DELIVERED surface: a tool docstring
|
||||
# (arrives with the tool schema), the plugin static context (always arrives),
|
||||
# or a bundled skill (arrives on trigger match). Keyed by a phrase distinctive
|
||||
# enough that its disappearance means the guidance is gone, not reworded —
|
||||
# update the phrase alongside a deliberate rewording.
|
||||
DISPLACED_TOPICS = {
|
||||
"supersedes": "supersedes",
|
||||
"trash is recoverable": "deleted_batch_id",
|
||||
"duplicate gate": "duplicate",
|
||||
"systems tag-as-you-write": "system_ids",
|
||||
"reference note vs dev-log": "reference note",
|
||||
"work-logs over body rewrites": "add_task_log",
|
||||
"rule homes / altitude": "create_project_rule",
|
||||
"rules vs other entities": "standing instruction",
|
||||
"shared records are suggestions": "shared",
|
||||
"processes run verbatim": "verbatim",
|
||||
"snippet reuse reflex": "when_to_use",
|
||||
"compaction at seams": "compact",
|
||||
"plans are milestones": "start_planning",
|
||||
"scope to the entered project": "cross-project",
|
||||
"project bootstrap needs confirmation": "never guessing a project",
|
||||
}
|
||||
|
||||
|
||||
def test_displaced_topics_live_on_a_delivered_surface():
|
||||
corpus = ""
|
||||
for p in (ROOT / "src" / "scribe" / "mcp" / "tools").glob("*.py"):
|
||||
corpus += p.read_text()
|
||||
corpus += (ROOT / "plugin" / "hooks" / "scribe_static_context.md").read_text()
|
||||
for p in (ROOT / "plugin" / "skills").rglob("SKILL.md"):
|
||||
corpus += p.read_text()
|
||||
corpus = corpus.lower()
|
||||
missing = [
|
||||
f"{topic} (phrase: {phrase!r})"
|
||||
for topic, phrase in DISPLACED_TOPICS.items()
|
||||
if phrase.lower() not in corpus
|
||||
]
|
||||
assert not missing, (
|
||||
f"guidance displaced from _INSTRUCTIONS has fallen off every delivered "
|
||||
f"surface (tool docstrings / static context / skills): {missing}. It "
|
||||
f"was cut from _INSTRUCTIONS deliberately (#2562) on the premise it "
|
||||
f"lives elsewhere — restore it somewhere that delivers."
|
||||
)
|
||||
|
||||
|
||||
def test_no_surface_names_the_push_without_stating_the_pull():
|
||||
"""The exact shape #2497 took.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user