memtrace-skills 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memtrace-first
3
- description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep; diagnose/reindex with Memtrace."
3
+ description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep: diagnose the miss first, then allow one targeted reformulation and bounded source verification or fallback, and reindex only on evidence of stale or incomplete coverage — never in a loop. A `repo_not_in_store` refusal means a different store holds the repository: route to that store, never grep and never re-index here."
4
4
  allowed-tools:
5
5
  - mcp__memtrace__list_indexed_repositories
6
6
  - mcp__memtrace__index_directory
@@ -35,56 +35,23 @@ metadata:
35
35
  version: "1.0.0"
36
36
  category: development
37
37
  ---
38
-
39
38
  # Memtrace First
40
39
 
41
- ## The Iron Law
42
-
43
- ```
44
- IF THE REPO IS INDEXED IN MEMTRACE → USE MEMTRACE TOOLS FIRST.
45
- After a search hit, route to GRAPH tools (get_symbol_context, get_impact,
46
- analyze_relationships) — that's what Memtrace uniquely provides. Read source
47
- ONLY when you're about to edit or quote, and read only the bounded span
48
- returned by Memtrace (start_line .. end_line + small context). Do not
49
- Grep/Glob/Find to "locate" anything already in the graph, and do not read
50
- the whole file when Memtrace has given you exact lines.
51
-
52
- BEFORE you edit/refactor/delete existing code or choose/re-pick a pattern,
53
- call Cortex decision memory: recall_decision for the symbol/subsystem/approach,
54
- and use provenance/contracts when a symbol_id is available. Use Memtrace's graph
55
- tools for structure and blast radius; use Cortex for rationale, bans, and
56
- contracts.
57
- ```
58
-
59
- Memtrace is the **memory layer** of the codebase, not a search engine that returns code. It has the full knowledge graph — every symbol, call, import, community, process, and API — with a time dimension. The point is to navigate that graph: who calls this, what's the blast radius, when did this change, what community is it part of. File tools are blind to all of that.
60
-
61
- **No exceptions for what's in the graph.**
62
-
63
- ## Value Tracking
64
-
65
- Do not print usage receipts in normal answers. Memtrace records tool usage, graph facts, file references, and estimated context avoided internally. Users can inspect that in the local UI's Value panel.
66
-
67
- ## What Memtrace actually indexes
68
-
69
- Memtrace's hybrid search = **BM25 over symbol metadata** (name, signature, file_path, kind) **+ semantic vector search over embedded code bodies** (first ~1500 chars of every Function / Method / Class / Struct / Interface body), fused via Reciprocal Rank Fusion.
70
-
71
- The semantic side means **string literals, error messages, magic constants, log strings, and any text inside an indexed symbol's body are findable through `find_code`**. The body got embedded; the embedding catches it. You do NOT need `Grep` to hunt for `STRIPE_KEY_FOO_BAR` if it lives inside a function in your indexed codebase.
72
-
73
- ## Zero results are not a grep license
40
+ Use Memtrace first for code discovery in indexed repositories. Use its graph to
41
+ understand relationships, processes and impact; verify source when exact behavior
42
+ matters. Retrieval is evidence, not a guarantee of complete coverage.
74
43
 
75
- If Memtrace returns 0 results, or repository stats look incomplete, do **not**
76
- infer that a source subdirectory is outside the index. Diagnose through
77
- Memtrace:
44
+ ## Establish scope
78
45
 
79
- 1. Call `list_indexed_repositories` and identify the repo root/repo_id.
80
- 2. If the path is under that indexed repo root, keep using Memtrace.
81
- 3. Retry with broader `find_code` terms and, when available, `file_path` filters
82
- such as `ui/`, `memtrace-ui/`, `src/`, or the framework directory.
83
- 4. If the language/path still appears missing, run `index_directory` on the repo
84
- root with `incremental: true` (or ask before `clear_existing: true`).
85
- 5. Report the indexing coverage problem instead of silently switching to grep.
46
+ Call `list_indexed_repositories` once per session. Select the actual repository
47
+ and branch; pass `repo_id` explicitly when possible. It lists this session's
48
+ store only, so a repository missing from it may still be indexed and live in
49
+ another store. Do not index a parent containing unrelated repositories. For a
50
+ deliberately shared workspace, verify its workspace marker and scope before
51
+ indexing. If tools are unavailable, state that limitation and use bounded source
52
+ inspection rather than blocking the task.
86
53
 
87
- ### Workspace Boundary Check
54
+ ### Workspace boundary check
88
55
 
89
56
  Before indexing or reindexing, make sure the target path is the repo the user
90
57
  asked about. If the current folder is only a parent that contains multiple
@@ -94,197 +61,206 @@ answer from stale repos.
94
61
 
95
62
  - For separate repos: use the actual git repo root as the `index_directory`
96
63
  path, or ask the user to open/run the agent from that repo root.
97
- - For an intentional shared workspace: the user should bless it explicitly with
98
- `memtrace start --bless-workspace`, then verify it with
64
+ - For an intentional shared workspace: a portable manifest is the durable
65
+ form — `memtrace start --workspace-file <manifest>` declares the members and
66
+ records the manifest as the owner of the store's membership. The Folder
67
+ Group flow still works and the CLI now calls it legacy: the user blesses the
68
+ parent with `memtrace start --bless-workspace`, then verifies it with
99
69
  `memtrace workspace status <path>`; the workspace marker should be present.
70
+ - A store whose membership is already owned by a manifest or a Named Workspace
71
+ cannot be widened by a plain `memtrace start` from a parent folder. That
72
+ start is refused with "a folder-walked start cannot widen it. Run
73
+ `<command>`", and the refusal names the exact command to run instead. Run
74
+ it. Do not route around the refusal by indexing elsewhere. A folder-sourced
75
+ store has no owning definition, so that refusal does not apply to it. A
76
+ `memtrace mcp` session can never widen an existing store under any flag,
77
+ including `--workspace-file`: adding a repository is always a `memtrace
78
+ start` for that store, carrying the manifest or the workspace name when one
79
+ owns its members.
100
80
  - If `list_indexed_repositories` returns empty or its metadata says the MCP
101
81
  child resolved a data dir from cwd because no workspace marker/git root was
102
82
  found, surface the workspace mismatch. Do not "fix" it by indexing the broad
103
83
  parent folder.
104
84
 
105
- **Never say "the index only covers X, so grep is right" when the target path is
106
- inside the indexed repository.** That is an indexing freshness/coverage issue,
107
- not permission to abandon Memtrace.
108
-
109
- ## The narrow exceptions where grep/glob are still right
110
-
111
- These are the ONLY cases where file tools beat memtrace:
112
-
113
- - **Files outside every indexed repo root.** Confirm this with
114
- `list_indexed_repositories`; 0 search results or missing language stats do not
115
- prove it. Vendored deps, system headers, and excluded dirs
116
- (`.git`, `node_modules`, `target`, `dist`) are examples Memtrace cannot see.
117
- - **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
118
- - **Pure file-inventory questions.** "How many `*.test.ts` files exist", "list every Markdown file in `docs/`". You're asking for a file count, not a symbol search.
119
- - **Reading at a known path outside Memtrace.** For configs, docs, or non-source artifacts that Memtrace cannot index, file `Read` is fine. For source-code spans returned by Memtrace, read the precise line range (your harness's `Read` with offset/limit, or `get_source_window` if your harness lacks bounded reads). Do not whole-file Read when you have a span.
120
-
121
- For everything else inside the indexed repo, memtrace is the right tool.
122
-
123
- ## The decision rule
124
-
125
- | Question Claude is asking | Right tool |
126
- |---|---|
127
- | "Where is symbol `foo` defined?" | `find_symbol(name="foo")` → then `get_symbol_context` for callers/callees/community, NOT a source read unless you're editing. |
128
- | "What calls `foo`?" | `get_symbol_context(repo_id, symbol="foo")` → callers with file:line. |
129
- | "How does authentication work?" | `find_code(query="authentication")` → `get_symbol_context` on the top hit, NOT a source read. |
130
- | "Find behavior X" with multi-word phrase (3+ words) | `find_code(verbatim)` first; if low confidence, fan out with identifier-shaped reshapes (camelCase / snake_case). |
131
- | "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
132
- | "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
133
- | "What breaks if I change `foo`?" | `get_impact(repo_id, target="foo")` → blast radius. |
134
- | "Should I change/delete/refactor `foo`?" | `find_symbol`/`get_symbol_context` → `recall_decision("foo / subsystem / approach")`; if a symbol id is available, `why_is_this_here` + `governing_contracts`; then `get_impact`. |
135
- | "Can I use/switch to pattern or library X?" | `recall_decision("X")` FIRST; bans and conventions are decisions. Verify a matching decision with `verify_intent(decision_id)` before relying on it. |
136
- | "What changed in `auth.ts` last week?" | `get_evolution(repo_id, from="7d ago", mode="recent", file_path="auth.ts")`. |
137
- | "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
138
- | "Find this string in my `.env`." | `Grep` (non-source artifact). |
139
- | "I'm about to edit `foo` — show me its source." | Bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`, or `get_source_window` if your harness lacks bounded reads. Never whole-file. |
140
- | "Read config/doc file I already have the path of." | `Read` (non-source artifact, path is known). |
141
-
142
- ## Parameter Types — Read This Before Calling Any Tool
143
-
144
- All memtrace MCP tools are **strictly typed**. Pass JSON numbers (not strings) for integer parameters.
145
-
146
- | Parameter | Correct | WRONG (fails with MCP error -32602) |
147
- |---|---|---|
148
- | `limit`, `min_size`, `depth`, `max_depth`, `last_n` | `limit: 20` | `limit: "20"` |
149
- | `repo_id`, `branch`, `name`, `symbol_name`, `query` | `repo_id: "my-repo"` | `repo_id: my-repo` (unquoted) |
150
- | `fuzzy`, `include_tests`, `invalidate` | `fuzzy: true` | `fuzzy: "true"` |
151
- | `get_evolution.from` | `from: "90d ago"` | `days: 90` (wrong param — use `from`, not `days`) |
152
- | `get_changes_since.since` | `since: "2026-04-13T10:43:00Z"` | `last_episode_id: "..."` (wrong param) |
153
- | `get_impact.target` / `get_symbol_context.symbol` | `target: "foo"` / `symbol: "foo"` | `symbol_id: "..."` (wrong — use name) |
154
- | `find_most_complex_functions` | `top_n: 10` | `limit: 10` (wrong param name) |
155
- | `get_cochange_context` | `target: "execute"` | `symbol: "execute"` (wrong param name) |
156
-
157
- If you see `failed to deserialize parameters: invalid type: string "N", expected usize`, remove the quotes from the number and retry.
158
-
159
- If you see `missing field 'from'`, you called `get_evolution` without `from` — pass e.g. `"90d ago"`, never `days`.
160
-
161
- Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
162
-
163
- ## Check Indexing First (Once Per Session)
164
-
165
- ```
166
- mcp__memtrace__list_indexed_repositories
167
- ```
168
-
169
- If the current repo appears → Memtrace is active. Follow this skill for ALL code tasks.
170
- If not indexed → offer to index with `mcp__memtrace__index_directory`, then follow this skill.
171
-
172
- ## Task → Tool Map
173
-
174
- | What you need | Use instead of Grep/Glob/Read |
175
- |---|---|
176
- | Find a function / class / symbol | `find_symbol` or `find_code` |
177
- | Understand how something works | `get_symbol_context` (the default next step) |
178
- | Find all callers of a function | `get_symbol_context` (callers field) |
179
- | Find all callees / dependencies | `get_symbol_context` (callees field) |
180
- | Trace a request / execution path | `get_process_flow` |
181
- | Understand module structure | `list_communities` |
182
- | Find the most important symbols | `find_central_symbols` |
183
- | Find API endpoints | `find_api_endpoints` |
184
- | Find where an API is called | `find_api_calls` |
185
- | Debug a problem | `get_symbol_context` → `get_impact` → `get_evolution` |
186
- | What changed recently? | `get_changes_since` or `get_evolution` |
187
- | What breaks if I change X? | `get_impact` |
188
- | Cross-service / cross-repo calls | `get_service_diagram` or `get_api_topology` |
189
- | Dependency between two symbols | `find_dependency_path` |
190
- | What files change together? | `get_cochange_context` |
191
- | Architecture overview | `list_communities` + `find_central_symbols` |
192
- | About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
193
- | About to edit/refactor/delete existing code | `recall_decision` for the intent + `why_is_this_here`/`governing_contracts` when a symbol id is available, then `get_impact` |
194
- | About to choose or replace a library/pattern/architecture | `recall_decision` first; use `verify_intent` on any matching decision before contradicting it |
195
- | About to choose between competing idioms (ternary vs if-else, arrow vs fn-decl, const vs let, await vs `.then`) | `get_style_fingerprint(repo_id, file_path)` — empirical codebase norm; see `memtrace-style-fingerprint` workflow |
196
-
197
- ## Standard Workflows
198
-
199
- ### "How does X work?" / "Explain X"
200
- 1. `find_symbol` or `find_code` → locate the symbol
201
- 2. `get_symbol_context` → callers, callees, community, processes (this usually answers "how it works")
202
- 3. `get_process_flow` (if it's a process/request path)
203
- 4. Only if you need to quote source: bounded `Read` at start_line..end_line, or `get_source_window`
204
-
205
- ### Debugging "X is broken"
206
- 1. `find_symbol` → locate the broken thing
207
- 2. `get_symbol_context` → understand its role
208
- 3. `get_impact` → blast radius (what else breaks)
209
- 4. `get_evolution(from=<lookback>, mode: recent)` → per-episode changelog near the incident
210
- 5. `get_changes_since(since=<anchor>)` → catch-up since last session (requires stored `since` timestamp)
211
-
212
- ### "Where is X defined / called?"
213
- 1. `find_symbol` with `fuzzy: true`
214
- 2. `get_symbol_context` for full caller/callee map
215
- 3. Only if you need source text: bounded `Read` at start_line..end_line, or `get_source_window`
216
-
217
- ### Before any code modification
218
- 1. `find_symbol` → confirm you have the right target
219
- 2. `get_symbol_context` → understand full context
220
- 3. `recall_decision("<symbol/subsystem/approach>")` → surface recorded choices, bans, and conventions before deciding what to do
221
- 4. If a `symbol_id` is available, `why_is_this_here(symbol_id)` + `governing_contracts(symbol_id)` before deleting, rewriting, or "cleaning up" odd code
222
- 5. `get_impact` → know blast radius before touching anything
223
- 6. `get_style_fingerprint(repo_id, file_path=<file>)` → match the codebase's empirical idiom (ternary vs if-else, arrow vs fn-decl, etc.) — see `memtrace-style-fingerprint` workflow for the full decision rule
224
-
225
- ## Red Flags — STOP, Use Memtrace Instead
226
-
227
- You are violating this skill if you think:
228
-
229
- | Thought | Reality |
230
- |---|---|
231
- | "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
232
- | "Let me glob for the file" | `find_symbol` returns exact location with context |
233
- | "Let me read the whole file" | `get_symbol_context` for the WHY (callers/callees/community); a bounded source read at start_line..end_line for the WHAT |
234
- | "I know why this is written this way" | Check Cortex first. Use `recall_decision`; use `why_is_this_here`/`governing_contracts` when you have a symbol id. |
235
- | "This looks unused/weird; I'll remove it" | `why_is_this_here` + `governing_contracts` first, then blast radius. CannotProve is unknown, not permission. |
236
- | "I'll just switch to library/pattern X" | `recall_decision("X")` first — you may be reintroducing a banned approach. |
237
- | "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
238
- | "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
239
- | "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
240
- | "Stats only show Rust, but I need `ui/` or `memtrace-ui/`" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
241
- | "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
242
- | "This is a simple question" | Simple questions benefit most — one `find_symbol` vs 20 file reads |
243
-
244
- ## When File Tools Are Still Correct
245
-
246
- Use Grep/Glob/Read ONLY for:
247
- - Non-source files or paths outside every indexed source repo
248
- - Files that are config, data, or docs (not source code symbols)
249
- - Repos or paths confirmed outside every Memtrace indexed root
250
- - **Official Memtrace product documentation** — use `memtrace-docs` (`ask_docs` / `search_docs` / `read_doc`), not file tools or web search
251
-
252
- For source-code spans already located by Memtrace, use a **bounded** read —
253
- your harness's `Read(file, offset, limit)` with the returned `start_line` /
254
- `end_line`, or `get_source_window` if your harness lacks bounded reads. Do
255
- not read the whole file.
256
-
257
- Never use file tools as a **discovery** mechanism when Memtrace is available.
258
-
259
- ## Skill Priority
260
-
261
- This skill is a **process skill** — it runs BEFORE any implementation or search skill.
262
-
263
- When this skill applies, it overrides default file-search behavior. Use the specific Memtrace sub-skills for deep detail on each tool:
264
-
265
- - Discovery → `memtrace-search`
266
- - Impact analysis → `memtrace-impact`
267
- - Temporal / change analysis → `memtrace-evolution`
268
- - Rationale / prior decisions / bans / contracts → `memtrace-decision-memory`
269
- - Incident investigation → `memtrace-incident-investigation`
270
- - Architecture overview → `memtrace-codebase-exploration`
271
- - Refactoring → `memtrace-refactoring-guide`
272
- - Memtrace **product docs** (install, CLI, MCP, enterprise) → `memtrace-docs`
273
-
274
- ## Output
275
-
276
- `find_symbol` / `find_code` return ranked symbol entries (`score` only with `include_diagnostics: true`):
277
-
278
- ```json
279
- { "name": "handleAuth", "kind": "Function", "file_path": "src/auth.ts",
280
- "start_line": 42, "end_line": 87 }
281
- ```
282
-
283
- `get_symbol_context` returns the graph neighborhood: `symbol`, `callers`, `callees`, `type_references`, `community`, `processes`, `api_callers_cross_repo`. Feed `start_line`/`end_line` into a bounded `Read` or `get_source_window` — never a whole-file read.
85
+ ## Search, then investigate
86
+
87
+ - Exact symbol: `find_symbol(name=..., repo_id=...)`.
88
+ - Behavior or concept: `find_code(query=..., repo_id=...)`.
89
+ - Relationships: `get_symbol_context` or `analyze_relationships` on the useful hit.
90
+ - Change impact: `get_impact`; confirm relevant callers against source.
91
+ - Execution path: `get_process_flow`; follow its `next_offset` for further steps.
92
+ - Architecture: `list_communities`, `find_central_symbols` and process tools.
93
+ - Historical coupling or changes: `get_cochange_context`, `get_evolution`,
94
+ `get_changes_since` or `get_episode_replay` as appropriate.
95
+
96
+ Inspect `find_code.context` first: concept queries include query-matched processes,
97
+ communities and selected callers/callees, referencing primary results by one-based
98
+ number. Set `include_context: true` for identifier searches or `false` for flat
99
+ results. Expand a graph tool only when this context does not answer the question.
100
+ Treat partial context, truncation and unavailable overlay context as incomplete
101
+ evidence; selected static flows are not complete runtime traces.
102
+
103
+ `context.next_calls` provides scoped follow-up arguments for the useful symbol
104
+ and process. Before changing shared behavior, inspect relevant callers and
105
+ callees to identify contracts the patch must preserve. Use process IDs for
106
+ flow navigation. No sampled flow is not proof that no call path exists.
107
+
108
+ Turn the requested behavior into observable tests, including failure and
109
+ boundary cases. Check that tests exercise the failure condition itself;
110
+ manual cleanup must not make a broken asynchronous operation appear correct.
111
+ Run related existing tests to detect regressions before claiming completion.
112
+
113
+ Read the bounded source span when verifying behavior, editing or quoting. Do not
114
+ fetch whole files or entire process traces when a local span answers the question.
115
+ `get_symbol_context` omits source bodies by default; use `include_content: true`
116
+ for explicit expansion, and `limit`/`offset` for relationship pages. An omitted
117
+ risk diagnostic means unknown, not zero callers or low risk. Check truncation and
118
+ pagination metadata before describing a neighborhood as complete.
119
+
120
+ ## Read the envelope before you diagnose anything
121
+
122
+ An empty-looking answer has three different causes and they need different
123
+ responses: the tool refused because another store holds the repository, the
124
+ tool never checked membership at all, or this store genuinely holds nothing
125
+ for the query. Before diagnosing, check which tool you called and what
126
+ `repo_in_store` and `error_code` say.
127
+
128
+ ### Only some tools check membership
129
+
130
+ Ten tools check the requested `repo_id` against this store's declared members
131
+ before they answer, and they are the only ones that set the top-level
132
+ `repo_in_store` key: `find_code`, `find_symbol`, `get_codebase_briefing`,
133
+ `find_central_symbols`, `find_dependency_path`, `find_bridge_symbols`,
134
+ `list_processes`, `get_process_flow`, `list_communities` and
135
+ `get_repository_stats`.
136
+
137
+ Every other tool that takes a `repo_id` — `get_symbol_context`, `get_impact`,
138
+ `analyze_relationships`, `get_evolution`, `get_timeline`, `get_source_window`,
139
+ `get_api_topology` and the rest — reads this session's store whatever id you
140
+ pass. Their answers carry no `repo_in_store` key at all, so a zero from one of
141
+ them is not evidence about membership and not evidence that the repository is
142
+ unindexed. When membership is in doubt, establish it with one of the ten above
143
+ before you conclude anything. `repo_in_store: null` is a third case:
144
+ membership was assumed rather than proven, because the session discovered no
145
+ workspace.
146
+
147
+ ### `repo_not_in_store` — wrong store, not a missing index
148
+
149
+ One of the ten, asked for a `repo_id` this session's store does not hold,
150
+ answers `repo_in_store: false` with `error_code: "repo_not_in_store"`. It
151
+ searched nothing. The `diagnostic` block names the store that answered, its
152
+ `members`, the `reason`, and — when a live runtime declares the repository —
153
+ `repo_lives_in` with that store, its path, `owner_pid`, `ui_port`,
154
+ `control_port` and `endpoint`.
155
+
156
+ 1. Read `diagnostic.reason` first. `ambiguous_repo_id` is not a routing
157
+ problem: the id matches more than one repository in *this* store, and the
158
+ message says to pass the exact id. Do that and stop here. Everything below
159
+ applies to the `not_in_store` reason.
160
+ 2. Do not fall back to file search. The refusal says so itself, in `_note`:
161
+ "Wrong store for this repo_id; do not fall back to filesystem search, ask
162
+ the session attached to the store named in diagnostic.repo_lives_in."
163
+ 3. Do not call `index_directory`. The repository is already indexed in the
164
+ store `repo_lives_in` names. Indexing it here would build a second copy in
165
+ the wrong store — writes are never routed to another store, so the call
166
+ lands locally.
167
+ 4. Tell the user which store holds it, and route the question to the session
168
+ or daemon attached to that store. A session cannot ask an owner to add a
169
+ repository: changing the members of a store that already has them means
170
+ running `memtrace start` for that store, with `--workspace-file <manifest>`
171
+ or `--workspace <name>` when a manifest or a Named Workspace owns its
172
+ scope.
173
+ 5. If `repo_lives_in` is absent, no live Memtrace runtime declares the
174
+ repository. Running `memtrace start` in its own workspace is the fix.
175
+
176
+ A refusal is not the only outcome. When the runtime whose store declares the
177
+ repository is live and publishes a reachable control port, the same read is
178
+ forwarded to it and you get the real answer, marked
179
+ `_meta.answered_by: "store_owner_daemon"` alongside `_meta.owner_pid`,
180
+ `_meta.owner_http` and `_meta.store`. That answer is authoritative; say which
181
+ store produced it.
182
+
183
+ A forwarded read can also come back as a bounded `busy` answer with
184
+ `"lane": "graph_materialization"` and `retryable: true`, naming what holds
185
+ the graph lane and for how long. That is a wait, not an absence — retry, or
186
+ narrow the call.
187
+
188
+ A `repo_not_in_store` refusal is also not evidence that a path lies outside
189
+ every indexed root: `list_indexed_repositories` covers this session's store
190
+ only, and the refusal's `diagnostic.repo_lives_in` names the store that does
191
+ hold the repository.
192
+
193
+ ## Handle misses without loops
194
+
195
+ This ladder applies to a genuine zero — an empty or irrelevant result from a
196
+ tool that reported `repo_in_store: true`. A refusal, or a zero from a tool
197
+ that sets no `repo_in_store` key, is handled in the section above, not here.
198
+
199
+ 1. Distinguish a tool error, a refusal (`repo_in_store: false`), a zero from a
200
+ tool that sets no `repo_in_store` key, missing scope, wrong branch, pending
201
+ index/embedding job, stale index and a valid empty result. Do not treat an
202
+ error as a clean miss, and do not treat a refusal or a keyless zero as one
203
+ either — re-ask through `find_code` or `find_symbol` before reading
204
+ anything into a keyless zero.
205
+ 2. For an ambiguous query, make at most one targeted reformulation, using an
206
+ identifier or path hint where available, and a `file_path` filter such as
207
+ `ui/`, `memtrace-ui/`, `src/` or the framework directory when one applies.
208
+ 3. If the result remains empty or irrelevant, use a bounded filesystem search
209
+ (`rg`, Grep or Glob) and verify the matching source. A returned hit that does
210
+ not answer the question is also a retrieval miss. Do **not** infer from a
211
+ zero that a source subdirectory is outside the index.
212
+ 4. Record the original miss and fallback in diagnostic/benchmark evidence. Do
213
+ not count filesystem recovery as successful Memtrace retrieval, and report
214
+ the indexing coverage problem rather than silently switching to grep.
215
+ 5. Reindex only when there is evidence of stale or incomplete coverage, at the
216
+ correct repository root, and only once steps 1 and 2 show the repository is
217
+ a member of this store. Prefer incremental repair (`index_directory` with
218
+ `incremental: true`; ask before `clear_existing: true`). Never repeat
219
+ indexing merely because a semantic query did not retrieve a target, and
220
+ never reindex in response to a `repo_not_in_store` refusal.
221
+
222
+ Memtrace combines full-text retrieval, vectors and graph expansion. Embedding
223
+ eligibility, language support, source limits and ranking affect recall. Literal
224
+ strings, short helpers and arbitrary body text are not guaranteed to appear in
225
+ semantic results. Use source search to establish exhaustive literal occurrences.
226
+ Configuration files, documentation, file inventories and excluded dependencies
227
+ are also appropriate uses of file tools.
228
+
229
+ ## Check rationale before changing code
230
+
231
+ BEFORE you edit/refactor/delete existing code or choose another pattern, call
232
+ Cortex `recall_decision("<symbol/subsystem/approach>")` when available. If a symbol
233
+ ID is available, consult `why_is_this_here(symbol_id)` and
234
+ `governing_contracts(symbol_id)`. Verify a
235
+ matching decision with `verify_intent` before relying on it. Unknown rationale
236
+ is not evidence that there is no contract. Use graph impact for structure and
237
+ Cortex for recorded choices, conventions and bans. Use `get_style_fingerprint`
238
+ when choosing among competing local idioms.
239
+
240
+ ## Tool arguments
241
+
242
+ Use JSON numbers for limits/depths and booleans for switches. Use symbol names
243
+ for `get_symbol_context.symbol`, `get_impact.target` and relationship targets;
244
+ use IDs only where the specific schema asks for one. Prefer the live schema over
245
+ remembered parameters. `find_code` has no `kind` filter; use `find_symbol` for it.
246
+ Search without an explicit repository uses safe scope inference, not an implicit
247
+ search of every repository. `get_evolution` uses `from`, not `days`.
248
+
249
+ For product setup or usage documentation, use `memtrace-docs`. Full tool parameter
250
+ references are bundled with the skills package. Do not print routine tool usage
251
+ receipts; preserve evidence internally and report meaningful findings and limits.
284
252
 
285
253
  ## Success criteria
286
254
 
287
- - The answer is grounded in Memtrace graph results (search hit → `get_symbol_context` / `get_impact`), not file-tool discovery.
288
- - Grep/Glob/Read appear only via the documented narrow exceptions (non-source artifacts, paths outside every indexed root, file inventory, bounded span reads).
289
- - Zero-result queries were diagnosed (`list_indexed_repositories` → broaden → reindex), not bypassed to grep.
255
+ - The right repository and branch were used.
256
+ - Graph claims are supported by retrieved edges, with missing/truncated data
257
+ made explicit, and exact behavioral claims are checked against source.
258
+ - A `repo_not_in_store` refusal was routed on `diagnostic.repo_lives_in`, not
259
+ answered by grep and not answered by indexing the repository into this store.
260
+ - A zero from a tool that sets no `repo_in_store` key was re-checked through a
261
+ membership-checking tool before it was called an absence.
262
+ - Failed retrieval on a genuine zero (`repo_in_store: true`) is diagnosed and
263
+ bounded; it does not trigger query or reindex loops, and fallbacks remain
264
+ distinguishable from retrieval successes.
290
265
  - Any source read was bounded to the span Memtrace returned.
266
+ - Existing rationale and contracts were checked when the tools were available.