memtrace 0.7.25 → 0.8.1
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.
- package/README.md +209 -287
- package/install.js +9 -6
- package/installer/package.json +1 -1
- package/installer/skills/commands/memtrace-api-topology.md +31 -34
- package/installer/skills/commands/memtrace-cochange.md +64 -33
- package/installer/skills/commands/memtrace-daily.md +73 -0
- package/installer/skills/commands/memtrace-decision-recall.md +91 -0
- package/installer/skills/commands/memtrace-evolution.md +121 -88
- package/installer/skills/commands/memtrace-fleet-publish-intent.md +18 -2
- package/installer/skills/commands/memtrace-fleet-record-episode.md +23 -2
- package/installer/skills/commands/memtrace-fleet-resolve.md +24 -1
- package/installer/skills/commands/memtrace-graph.md +59 -41
- package/installer/skills/commands/memtrace-impact.md +67 -19
- package/installer/skills/commands/memtrace-index.md +20 -3
- package/installer/skills/commands/memtrace-intent-verification.md +81 -0
- package/installer/skills/commands/memtrace-preflight.md +85 -0
- package/installer/skills/commands/memtrace-provenance.md +90 -0
- package/installer/skills/commands/memtrace-quality.md +49 -32
- package/installer/skills/commands/memtrace-relationships.md +73 -30
- package/installer/skills/commands/memtrace-search.md +86 -61
- package/installer/skills/workflows/memtrace-change-impact-analysis.md +32 -12
- package/installer/skills/workflows/memtrace-code-review.md +17 -11
- package/installer/skills/workflows/memtrace-codebase-exploration.md +41 -5
- package/installer/skills/workflows/memtrace-continuous-memory.md +54 -56
- package/installer/skills/workflows/memtrace-decision-memory.md +139 -0
- package/installer/skills/workflows/memtrace-episode-replay.md +87 -63
- package/installer/skills/workflows/memtrace-first.md +63 -7
- package/installer/skills/workflows/memtrace-fleet-coordination.md +21 -1
- package/installer/skills/workflows/memtrace-fleet-first.md +35 -5
- package/installer/skills/workflows/memtrace-incident-investigation.md +113 -55
- package/installer/skills/workflows/memtrace-refactoring-guide.md +31 -11
- package/installer/skills/workflows/memtrace-session-continuity.md +63 -49
- package/installer/skills/workflows/memtrace-style-fingerprint.md +27 -4
- package/package.json +7 -7
- package/skills/commands/memtrace-api-topology.md +31 -34
- package/skills/commands/memtrace-cochange.md +64 -33
- package/skills/commands/memtrace-daily.md +73 -0
- package/skills/commands/memtrace-decision-recall.md +91 -0
- package/skills/commands/memtrace-evolution.md +121 -88
- package/skills/commands/memtrace-fleet-publish-intent.md +18 -2
- package/skills/commands/memtrace-fleet-record-episode.md +23 -2
- package/skills/commands/memtrace-fleet-resolve.md +24 -1
- package/skills/commands/memtrace-graph.md +59 -41
- package/skills/commands/memtrace-impact.md +67 -19
- package/skills/commands/memtrace-index.md +20 -3
- package/skills/commands/memtrace-intent-verification.md +81 -0
- package/skills/commands/memtrace-preflight.md +85 -0
- package/skills/commands/memtrace-provenance.md +90 -0
- package/skills/commands/memtrace-quality.md +49 -32
- package/skills/commands/memtrace-relationships.md +73 -30
- package/skills/commands/memtrace-search.md +86 -61
- package/skills/workflows/memtrace-change-impact-analysis.md +32 -12
- package/skills/workflows/memtrace-code-review.md +17 -11
- package/skills/workflows/memtrace-codebase-exploration.md +41 -5
- package/skills/workflows/memtrace-continuous-memory.md +54 -56
- package/skills/workflows/memtrace-decision-memory.md +139 -0
- package/skills/workflows/memtrace-episode-replay.md +87 -63
- package/skills/workflows/memtrace-first.md +63 -7
- package/skills/workflows/memtrace-fleet-coordination.md +21 -1
- package/skills/workflows/memtrace-fleet-first.md +35 -5
- package/skills/workflows/memtrace-incident-investigation.md +113 -55
- package/skills/workflows/memtrace-refactoring-guide.md +31 -11
- package/skills/workflows/memtrace-session-continuity.md +63 -49
- package/skills/workflows/memtrace-style-fingerprint.md +27 -4
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-impact
|
|
3
|
-
description: "
|
|
3
|
+
description: "Compute the blast radius of modifying a symbol through transitive graph impact. Use when the user asks about blast radius, impact, what breaks, risk, upstream callers, downstream dependencies, or consequences of modifying a symbol, before or during source-code changes. Do not use Grep or manual reference search; Memtrace computes transitive graph impact. For a full risk-rated plan covering a multi-part change, use memtrace-change-impact-analysis."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__get_impact
|
|
6
6
|
- mcp__memtrace__detect_changes
|
|
7
7
|
- mcp__memtrace__find_symbol
|
|
8
8
|
- mcp__memtrace__find_code
|
|
9
|
+
metadata:
|
|
10
|
+
author: "Syncable <support@syncable.dev>"
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
category: development
|
|
9
13
|
user-invocable: true
|
|
10
14
|
---
|
|
11
15
|
|
|
@@ -17,26 +21,47 @@ Compute the blast radius of changing a specific symbol. Traces upstream (what de
|
|
|
17
21
|
|
|
18
22
|
| Tool | Purpose |
|
|
19
23
|
|------|---------|
|
|
20
|
-
| `get_impact` | Blast radius from a
|
|
24
|
+
| `get_impact` | Blast radius from a symbol **name** (`target`) |
|
|
21
25
|
| `detect_changes` | Scope symbols affected by a diff/patch |
|
|
22
26
|
|
|
23
|
-
> **Parameter types:** MCP parameters are strictly typed. Numbers (`
|
|
27
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`depth`, `limit`, etc.) must be JSON numbers — not strings.
|
|
24
28
|
|
|
29
|
+
## Required parameters — `get_impact`
|
|
30
|
+
|
|
31
|
+
| Parameter | Required | Default | Notes |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| `repo_id` | yes | — | |
|
|
34
|
+
| `target` | yes | — | Symbol name (e.g. `"validateToken"`) — **not** `symbol_id` |
|
|
35
|
+
| `direction` | no | `"both"` | `"upstream"` \| `"downstream"` \| `"both"` |
|
|
36
|
+
| `depth` | no | `5` | BFS depth (max 15) |
|
|
37
|
+
| `as_of` | no | now | ISO-8601 for time-travel |
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{ "repo_id": "memdb", "target": "validateToken", "direction": "both", "depth": 5 }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
25
44
|
|
|
26
45
|
## Steps
|
|
27
46
|
|
|
28
|
-
### 1. Identify the symbol
|
|
47
|
+
### 1. Identify the symbol name
|
|
29
48
|
|
|
30
|
-
If you
|
|
31
|
-
-
|
|
32
|
-
-
|
|
49
|
+
If you don't know the exact name:
|
|
50
|
+
- `find_symbol(name="...")` for exact identifiers
|
|
51
|
+
- `find_code(query="...")` for natural-language queries
|
|
52
|
+
|
|
53
|
+
Use the returned **`name`** (and optional `file_path` hint) — graph tools resolve by name, not internal IDs.
|
|
33
54
|
|
|
34
55
|
### 2. Run impact analysis
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"repo_id": "memdb",
|
|
60
|
+
"target": "validateToken",
|
|
61
|
+
"direction": "upstream",
|
|
62
|
+
"depth": 5
|
|
63
|
+
}
|
|
64
|
+
```
|
|
40
65
|
|
|
41
66
|
### 3. Interpret the risk rating
|
|
42
67
|
|
|
@@ -45,20 +70,43 @@ Use the `get_impact` MCP tool:
|
|
|
45
70
|
| **Low** | Few dependents, leaf node | Safe to modify; minimal testing needed |
|
|
46
71
|
| **Medium** | Moderate dependents | Test direct callers; review interface contracts |
|
|
47
72
|
| **High** | Many dependents across modules | Coordinate changes; comprehensive test coverage |
|
|
48
|
-
| **Critical** | Core infrastructure, many transitive dependents | Plan migration strategy;
|
|
73
|
+
| **Critical** | Core infrastructure, many transitive dependents | Plan migration strategy; backward-compatible changes |
|
|
49
74
|
|
|
50
75
|
### 4. For diff-based analysis
|
|
51
76
|
|
|
52
|
-
When you have an actual code diff
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
When you have an actual code diff, use `detect_changes`:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{ "repo_id": "memdb", "diff": "<unified git diff text>" }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or pass `changed_files: ["path/a.rs", "path/b.ts"]` when no diff text is available.
|
|
56
84
|
|
|
57
85
|
## Decision Points
|
|
58
86
|
|
|
59
87
|
| Situation | Action |
|
|
60
88
|
|-----------|--------|
|
|
61
|
-
| Changing a single function | `get_impact` with `direction: both` |
|
|
89
|
+
| Changing a single function | `get_impact` with `direction: "both"` |
|
|
62
90
|
| Reviewing a PR or diff | `detect_changes` with the diff content |
|
|
63
|
-
| Renaming/removing a public API | `get_impact` with `direction: upstream`,
|
|
64
|
-
| Refactoring internals | `get_impact` with `direction: downstream`
|
|
91
|
+
| Renaming/removing a public API | `get_impact` with `direction: "upstream"`, higher `depth` |
|
|
92
|
+
| Refactoring internals | `get_impact` with `direction: "downstream"` |
|
|
93
|
+
|
|
94
|
+
## Output
|
|
95
|
+
|
|
96
|
+
`get_impact` returns the blast radius for the target symbol:
|
|
97
|
+
|
|
98
|
+
| Field | Example / meaning |
|
|
99
|
+
|---|---|
|
|
100
|
+
| Risk rating | `High` — one of `Low` / `Medium` / `High` / `Critical` (interpret via step 3) |
|
|
101
|
+
| Upstream | Transitive dependents (callers/importers) within `depth` hops — what breaks if the target changes |
|
|
102
|
+
| Downstream | Transitive dependencies — what the target relies on |
|
|
103
|
+
|
|
104
|
+
`detect_changes` returns the set of symbols affected by the supplied `diff` / `changed_files`, plus the affected processes (execution flows).
|
|
105
|
+
|
|
106
|
+
## Common Mistakes
|
|
107
|
+
|
|
108
|
+
| Mistake | Reality |
|
|
109
|
+
|---------|---------|
|
|
110
|
+
| Passing `symbol_id` or `name` | Required param is **`target`** |
|
|
111
|
+
| Omitting `repo_id` | Both `repo_id` and `target` are required |
|
|
112
|
+
| Defaulting `depth` to 3 | API default is **5** |
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-index
|
|
3
|
-
description: "
|
|
3
|
+
description: "Index a source-code repo into the Memtrace knowledge graph and poll the job to completion. Use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, when code exploration needs an index, or when searches return 0/partial results for source paths under an indexed root. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed. For ongoing watch mode / live re-indexing after the initial index, use memtrace-continuous-memory."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__index_directory
|
|
6
6
|
- mcp__memtrace__check_job_status
|
|
7
7
|
- mcp__memtrace__list_jobs
|
|
8
8
|
- mcp__memtrace__list_indexed_repositories
|
|
9
|
+
metadata:
|
|
10
|
+
author: "Syncable <support@syncable.dev>"
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
category: development
|
|
9
13
|
user-invocable: true
|
|
10
14
|
---
|
|
11
15
|
|
|
@@ -23,6 +27,8 @@ Index a local codebase into the persistent code knowledge graph. This is always
|
|
|
23
27
|
|
|
24
28
|
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `depth`, `min_size`, `last_n`, etc.) must be JSON numbers — not strings. Use `limit: 20`, never `limit: "20"`. Passing a string yields `MCP error -32602: invalid type: string, expected usize`.
|
|
25
29
|
|
|
30
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
31
|
+
|
|
26
32
|
|
|
27
33
|
## Steps
|
|
28
34
|
|
|
@@ -49,7 +55,7 @@ Use the `index_directory` MCP tool:
|
|
|
49
55
|
|
|
50
56
|
### 3. Poll for completion
|
|
51
57
|
|
|
52
|
-
Use `check_job_status` with the `job_id` every 2–3 seconds.
|
|
58
|
+
Use `check_job_status` with the `job_id` every 2–3 seconds. **The loop must never run unbounded** — hard cap at ~100 polls (~5 minutes). On hitting the cap: stop polling, report the `job_id` and last observed status to the user, and tell them the job keeps running server-side — they (or you, later) can resume with `check_job_status` on that `job_id` or find it via `list_jobs`.
|
|
53
59
|
|
|
54
60
|
Pipeline stages in order: **scan → parse → resolve → communities → processes → persist → embeddings → api_detect → done**
|
|
55
61
|
|
|
@@ -67,5 +73,16 @@ After indexing completes, call `list_indexed_repositories` to confirm the repo a
|
|
|
67
73
|
|-------|--------|
|
|
68
74
|
| Path does not exist | Ask user to verify the absolute path |
|
|
69
75
|
| Job status "failed" | Report the error message; suggest `clear_existing: true` for a fresh rebuild |
|
|
70
|
-
| Timeout (job running > 5 min) | Large repos are normal
|
|
76
|
+
| Timeout (job running > 5 min) | Large repos are normal, but respect the poll cap: stop, report `job_id` + last status, resume later via `check_job_status` / `list_jobs`. For monorepos, index subdirectories separately |
|
|
71
77
|
| Already indexed | Use `incremental: true` to update, or skip indexing entirely |
|
|
78
|
+
|
|
79
|
+
## Output
|
|
80
|
+
|
|
81
|
+
`index_directory` returns a job handle immediately; `check_job_status` tracks it to a terminal state:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{ "job_id": "6f9a2c1e-...-uuid" }
|
|
85
|
+
{ "status": "completed" }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
While running, the job advances through the pipeline stages listed in step 3; `status = "failed"` carries an error message. The final user-facing report (confirmed via `list_indexed_repositories`) covers: `repo_id`, languages detected, total symbols, total relationships (node/edge counts).
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-intent-verification
|
|
3
|
+
description: "Verify whether a past decision actually held or was violated, and surface the arc of episodes that implemented that specific decision. Returns a Held | ViolatedAt | CannotProve verdict and the implementing arc from Cortex decision memory. Use when the user asks whether a decision held, was followed, or drifted, or before relying on a decision or reporting drift. Requires a decision_id (from memtrace-decision-recall); do NOT use for free-text decision lookup — use memtrace-decision-recall first. Do not assume a decision was followed; verify it."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__verify_intent
|
|
6
|
+
- mcp__memtrace__get_arc
|
|
7
|
+
- mcp__memtrace__recall_decision
|
|
8
|
+
- mcp__memtrace__why_is_this_here
|
|
9
|
+
metadata:
|
|
10
|
+
author: "Syncable <support@syncable.dev>"
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
category: development
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
A decision being *recorded* doesn't mean it was *followed*. `verify_intent` checks
|
|
18
|
+
whether a decision held across its arc; `get_arc` returns the episodes that implemented
|
|
19
|
+
it. Use these to confirm a rationale is still in force before relying on it, and to
|
|
20
|
+
detect drift where the code quietly diverged from what was decided.
|
|
21
|
+
|
|
22
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
23
|
+
|
|
24
|
+
## Quick Reference
|
|
25
|
+
|
|
26
|
+
| Tool | Purpose | Returns / FactStatus |
|
|
27
|
+
|------|---------|----------------------|
|
|
28
|
+
| `verify_intent` | Did the decision hold across its arc? | `Held` \| `ViolatedAt` \| `CannotProve` |
|
|
29
|
+
| `get_arc` | Arc of episodes implementing the decision | DeterministicallyDerived \| CannotProve |
|
|
30
|
+
|
|
31
|
+
> **Both take a `decision_id` (uint64), not free text.** Get it from `recall_decision`
|
|
32
|
+
> (see `memtrace-decision-recall`) or from `why_is_this_here` (see `memtrace-provenance`).
|
|
33
|
+
> Do not invent ids.
|
|
34
|
+
|
|
35
|
+
> **Honesty contract:** verdicts are deterministically defended. `CannotProve` means the
|
|
36
|
+
> decision is invisible or has no implementing episode — *unknown*, not "fine."
|
|
37
|
+
|
|
38
|
+
## Steps
|
|
39
|
+
|
|
40
|
+
### 1. Get the decision_id
|
|
41
|
+
|
|
42
|
+
Run `recall_decision(...)` and take a `decision_id` from a hit, or get one from
|
|
43
|
+
`why_is_this_here(symbol_id)`. These tools do not accept names.
|
|
44
|
+
|
|
45
|
+
### 2. Verify it held
|
|
46
|
+
|
|
47
|
+
`verify_intent(decision_id)`:
|
|
48
|
+
|
|
49
|
+
| Verdict | Meaning | Action |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| **Held** | The decision held across its arc | Safe to rely on; honor it |
|
|
52
|
+
| **ViolatedAt** | The code drifted from the decision at a point | Surface the drift — it's either a bug or an unrecorded reversal; ask which |
|
|
53
|
+
| **CannotProve** | Decision invisible or no implementing episode | Treat as unknown; don't claim it held |
|
|
54
|
+
|
|
55
|
+
### 3. Inspect what implemented it
|
|
56
|
+
|
|
57
|
+
`get_arc(decision_id)` → the episodes reachable by Produced/DerivedFrom edges. This is
|
|
58
|
+
the implementation trail: where the decision actually landed (or where it should have).
|
|
59
|
+
|
|
60
|
+
### 4. Cross to the code graph for the "what"
|
|
61
|
+
|
|
62
|
+
The arc names episodes/symbols; to see the current code or its blast radius, hand those
|
|
63
|
+
over to `memtrace-first` / `memtrace-impact`. Decision memory proves *whether it held*;
|
|
64
|
+
the code graph shows *the current state*.
|
|
65
|
+
|
|
66
|
+
## Decision Points
|
|
67
|
+
|
|
68
|
+
| Situation | Action |
|
|
69
|
+
|-----------|--------|
|
|
70
|
+
| Relying on a recalled decision for a choice | `verify_intent` first — only trust a `Held` verdict |
|
|
71
|
+
| Auditing whether the codebase follows its own decisions | `verify_intent` per decision; report every `ViolatedAt` |
|
|
72
|
+
| "Where/when was decision D implemented?" | `get_arc(decision_id)` |
|
|
73
|
+
| `verify_intent` returns `ViolatedAt` | Don't silently 'fix' it — it may be a deliberate (unrecorded) reversal; confirm with the user |
|
|
74
|
+
| `verify_intent` returns `CannotProve` | Treat as unknown; fall back to `recall_decision` + the code graph |
|
|
75
|
+
|
|
76
|
+
## Output
|
|
77
|
+
|
|
78
|
+
| Call | Returns |
|
|
79
|
+
|------|---------|
|
|
80
|
+
| `verify_intent(decision_id)` | Verdict: `Held` \| `ViolatedAt` (the point where code drifted from the decision) \| `CannotProve` (decision invisible or no implementing episode — unknown, not "fine") |
|
|
81
|
+
| `get_arc(decision_id)` | FactStatus `DeterministicallyDerived` \| `CannotProve`, plus the implementing arc: the episodes reachable by Produced/DerivedFrom edges |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-preflight
|
|
3
|
+
description: "Run a one-call pre-flight check on a single existing symbol before editing it: blast radius (who depends on it), co-change partners (files that historically change with it), complexity, 30-day churn, and a generated verification checklist. Use before modifying any existing function or symbol you did not just write. Do not start editing a non-trivial existing function without a pre-flight check; Memtrace knows the dependency graph and change history. For a full multi-symbol change plan or what-will-break analysis, use memtrace-change-impact-analysis."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__preflight_check
|
|
6
|
+
- mcp__memtrace__get_impact
|
|
7
|
+
- mcp__memtrace__get_cochange_context
|
|
8
|
+
metadata:
|
|
9
|
+
author: "Syncable <support@syncable.dev>"
|
|
10
|
+
version: "1.0.0"
|
|
11
|
+
category: development
|
|
12
|
+
user-invocable: true
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
Pre-flight check: the two minutes before an edit that prevent the bug. One
|
|
18
|
+
`preflight_check` call composes the dependency graph, the bi-temporal change
|
|
19
|
+
history, and the complexity metrics into an actionable radar for a single
|
|
20
|
+
symbol.
|
|
21
|
+
|
|
22
|
+
## Quick Reference
|
|
23
|
+
|
|
24
|
+
| Tool | Purpose |
|
|
25
|
+
|------|---------|
|
|
26
|
+
| `preflight_check` | Full radar for one symbol: blast radius + co-change + churn + checklist |
|
|
27
|
+
| `get_impact` | Deeper blast-radius walk when the radar flags HIGH/CRITICAL |
|
|
28
|
+
| `get_cochange_context` | Wider co-change window when partners look surprising |
|
|
29
|
+
|
|
30
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers must be
|
|
31
|
+
|
|
32
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
33
|
+
> JSON numbers — not strings.
|
|
34
|
+
|
|
35
|
+
## Steps
|
|
36
|
+
|
|
37
|
+
### 1. Run the pre-flight check before touching the symbol
|
|
38
|
+
|
|
39
|
+
`preflight_check` with:
|
|
40
|
+
- `repo_id` — required
|
|
41
|
+
- `symbol` — the function/method name you are about to modify
|
|
42
|
+
|
|
43
|
+
### 2. Read the checklist — it is generated from the graph, not boilerplate
|
|
44
|
+
|
|
45
|
+
Each line names something concrete to verify:
|
|
46
|
+
- *"N symbols depend on this"* → run `get_impact` again after your edit and
|
|
47
|
+
compare `total_affected`; new dependents mean your change leaked wider
|
|
48
|
+
than intended.
|
|
49
|
+
- *"hotspot: N changes in 30 days"* → keep the edit small and reviewable;
|
|
50
|
+
hot code punishes large diffs.
|
|
51
|
+
- *"sits in N process flow(s)"* → check the process steps still order
|
|
52
|
+
correctly after the change.
|
|
53
|
+
- *"last touched by agent session …"* → read the latest episode before
|
|
54
|
+
assuming the current shape is intentional.
|
|
55
|
+
|
|
56
|
+
### 3. Treat co-change partners as part of the change
|
|
57
|
+
|
|
58
|
+
Files that historically changed together with the target usually need
|
|
59
|
+
updating in the same change. If you finish the edit without touching a
|
|
60
|
+
frequent partner, say so explicitly and why.
|
|
61
|
+
|
|
62
|
+
### 4. After the edit, close the loop
|
|
63
|
+
|
|
64
|
+
- Re-run `preflight_check` (or `get_impact`) on the symbol.
|
|
65
|
+
- The complexity number should not have grown without a stated reason;
|
|
66
|
+
if it did, simplify before declaring the work done.
|
|
67
|
+
|
|
68
|
+
## Verdict guidance
|
|
69
|
+
|
|
70
|
+
- `risk: CRITICAL/HIGH` — propose the change plan before editing; consider
|
|
71
|
+
a feature flag or staged rollout.
|
|
72
|
+
- `dependents: 0` — edit freely; note the symbol may be newly added or an
|
|
73
|
+
entry point.
|
|
74
|
+
|
|
75
|
+
## Output
|
|
76
|
+
|
|
77
|
+
`preflight_check` returns one radar for the symbol:
|
|
78
|
+
|
|
79
|
+
| Field | Meaning |
|
|
80
|
+
|-------|---------|
|
|
81
|
+
| `risk` | verdict, e.g. `HIGH` / `CRITICAL` (see Verdict guidance) |
|
|
82
|
+
| `dependents` | blast radius — count of symbols that depend on the target |
|
|
83
|
+
| co-change partners | files that historically change with it (step 3) |
|
|
84
|
+
| complexity + 30-day churn | current complexity score and recent change count |
|
|
85
|
+
| checklist | generated verification lines, e.g. `"hotspot: 6 changes in 30 days"`, `"sits in 2 process flow(s)"` |
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-provenance
|
|
3
|
+
description: "Retrieve the governing decision lineage (why is this here) and the contracts that bind a symbol, from Cortex decision memory. Use before deleting, rewriting, or 'cleaning up' code that looks unused, odd, or redundant, and when the user asks why a symbol exists or what rules constrain it. Symbol-scoped; for free-text decision search use memtrace-decision-recall. Do not infer intent from the diff or assume unfamiliar code is safe to remove."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__why_is_this_here
|
|
6
|
+
- mcp__memtrace__governing_contracts
|
|
7
|
+
- mcp__memtrace__verify_intent
|
|
8
|
+
- mcp__memtrace__recall_decision
|
|
9
|
+
metadata:
|
|
10
|
+
author: "Syncable <support@syncable.dev>"
|
|
11
|
+
version: "1.0.0"
|
|
12
|
+
category: development
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
Provenance answers **"why is this code here, and what binds it?"** before you change
|
|
18
|
+
it. `why_is_this_here` returns the decision/conversation lineage that governs a symbol
|
|
19
|
+
(its Governs/Produced provenance); `governing_contracts` returns the contract nodes
|
|
20
|
+
that constrain it. Together they stop you from deleting code that closes a past issue
|
|
21
|
+
or violating an invariant nothing in the AST advertises.
|
|
22
|
+
|
|
23
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
24
|
+
|
|
25
|
+
## Quick Reference
|
|
26
|
+
|
|
27
|
+
| Tool | Purpose | Returns / FactStatus |
|
|
28
|
+
|------|---------|----------------------|
|
|
29
|
+
| `why_is_this_here` | The governing decision/conversation lineage of a symbol | DeterministicallyDerived \| CannotProve |
|
|
30
|
+
| `governing_contracts` | The contract nodes that constrain a symbol | Contract nodes \| CannotProve |
|
|
31
|
+
| `verify_intent` | Given a returned governing `decision_id` — is that rationale still valid? | Held \| ViolatedAt \| CannotProve |
|
|
32
|
+
|
|
33
|
+
> **`why_is_this_here` and `governing_contracts` each take a `symbol_id` (uint64 node
|
|
34
|
+
> id), not a name. `verify_intent` takes a `decision_id` (uint64), not a `symbol_id`.**
|
|
35
|
+
> If you only have a name or a question, start with `recall_decision` (free text) — see
|
|
36
|
+
> `memtrace-decision-recall`. ids come from a prior recall/arc result or the Cortex
|
|
37
|
+
> view. Do not invent ids.
|
|
38
|
+
|
|
39
|
+
> **Honesty contract:** for a symbol no decision produced, `why_is_this_here` returns an
|
|
40
|
+
> honest **CannotProve**; `governing_contracts` returns CannotProve rather than a false
|
|
41
|
+
> "no contracts" verdict. **CannotProve ≠ safe to delete / unconstrained** — it means
|
|
42
|
+
> *unknown*, so fall back to blast-radius and the user.
|
|
43
|
+
|
|
44
|
+
## Steps
|
|
45
|
+
|
|
46
|
+
### 1. Get the symbol_id
|
|
47
|
+
|
|
48
|
+
If you have a name or a "why" question, run `recall_decision(...)` first and take the
|
|
49
|
+
`symbol_id` from the result (or the Cortex view). The id-based tools need a numeric id.
|
|
50
|
+
|
|
51
|
+
### 2. Ask why it's here
|
|
52
|
+
|
|
53
|
+
`why_is_this_here(symbol_id)` → the governing decision lineage. This is the *rationale*
|
|
54
|
+
the git blame won't give you: the decision that produced this code and, often, the
|
|
55
|
+
problem it was put there to solve.
|
|
56
|
+
|
|
57
|
+
### 3. Ask what constrains it
|
|
58
|
+
|
|
59
|
+
`governing_contracts(symbol_id)` → contracts that must survive any rewrite (invariants,
|
|
60
|
+
interface promises, "must always …" rules). A refactor that breaks one of these is a
|
|
61
|
+
regression even if every test passes.
|
|
62
|
+
|
|
63
|
+
### 4. Check the rationale still holds
|
|
64
|
+
|
|
65
|
+
If `why_is_this_here` returns a governing `decision_id`, run `verify_intent(decision_id)`
|
|
66
|
+
(see `memtrace-intent-verification`) — a `ViolatedAt` verdict (or a decision you can see
|
|
67
|
+
was superseded via `recall_decision`) changes whether the code should still look this way.
|
|
68
|
+
|
|
69
|
+
## Decision Points
|
|
70
|
+
|
|
71
|
+
| Situation | Action |
|
|
72
|
+
|-----------|--------|
|
|
73
|
+
| Code looks unused/dead and you want to delete it | `why_is_this_here` + `governing_contracts` BEFORE deleting; CannotProve is not a green light |
|
|
74
|
+
| Code is written in a strange/non-obvious way | `why_is_this_here` — there's likely a decision explaining the oddity |
|
|
75
|
+
| About to refactor a symbol's internals | `governing_contracts` — preserve every constraint, not just the test surface |
|
|
76
|
+
| User asks "why is this here?" | `why_is_this_here(symbol_id)`; if you only have a name, `recall_decision` first |
|
|
77
|
+
| All provenance returns CannotProve | Treat as unknown; combine with `memtrace-impact` (blast radius) and ask the user before removing |
|
|
78
|
+
|
|
79
|
+
## Output
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
why_is_this_here(symbol_id: 4821)
|
|
83
|
+
→ DeterministicallyDerived — governing lineage:
|
|
84
|
+
decision_id 913 (Governs): "Keep retry shim until legacy clients migrate"
|
|
85
|
+
governing_contracts(symbol_id: 4821)
|
|
86
|
+
→ contract node: "writes must always be debounced" (must survive any rewrite)
|
|
87
|
+
— no decision produced the symbol → CannotProve (unknown, NOT unconstrained)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`verify_intent(decision_id)` on a returned lineage id yields Held | ViolatedAt | CannotProve.
|
|
@@ -1,69 +1,86 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-quality
|
|
3
|
-
description: "
|
|
3
|
+
description: "Find dead code, complexity hotspots, and refactoring candidates in indexed source code. Use when the user asks about source-code quality, dead code, unused functions, zero callers, complexity, cyclomatic complexity, hotspots, refactoring candidates, or code smell questions. Do not use Grep, Glob, rg, or manual reference search for unused code; Memtrace uses graph reachability and complexity metrics."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__find_dead_code
|
|
6
6
|
- mcp__memtrace__calculate_cyclomatic_complexity
|
|
7
7
|
- mcp__memtrace__find_most_complex_functions
|
|
8
8
|
- mcp__memtrace__get_repository_stats
|
|
9
|
+
- mcp__memtrace__get_evolution
|
|
10
|
+
metadata:
|
|
11
|
+
author: "Syncable <support@syncable.dev>"
|
|
12
|
+
version: "1.0.0"
|
|
13
|
+
category: development
|
|
9
14
|
user-invocable: true
|
|
10
15
|
---
|
|
11
16
|
|
|
12
17
|
## Overview
|
|
13
18
|
|
|
14
|
-
|
|
19
|
+
Code quality via graph analysis — dead code, complexity hotspots, repository stats.
|
|
15
20
|
|
|
16
21
|
## Quick Reference
|
|
17
22
|
|
|
18
|
-
| Tool | Purpose |
|
|
19
|
-
|
|
20
|
-
| `find_dead_code` |
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `get_repository_stats` |
|
|
23
|
+
| Tool | Purpose | Required | Key optional |
|
|
24
|
+
|------|---------|----------|--------------|
|
|
25
|
+
| `find_dead_code` | Zero-caller symbols | `repo_id` | `include_tests`, `limit`, `kinds[]` |
|
|
26
|
+
| `find_most_complex_functions` | Ranked complexity hotspots | `repo_id` | **`top_n`** (def 20) — not `limit` |
|
|
27
|
+
| `calculate_cyclomatic_complexity` | Score one symbol | `repo_id`, **`target`** | — |
|
|
28
|
+
| `get_repository_stats` | Repository overview | `repo_id` | `branch` |
|
|
24
29
|
|
|
25
|
-
> **Parameter types:**
|
|
30
|
+
> **Parameter types:** numbers must be JSON numbers — `limit: 20`, never `"20"` (MCP error -32602).
|
|
26
31
|
|
|
32
|
+
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
27
33
|
|
|
28
34
|
## Steps
|
|
29
35
|
|
|
30
|
-
### 1.
|
|
36
|
+
### 1. Repository overview
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
- Community and process counts
|
|
38
|
+
```json
|
|
39
|
+
{ "repo_id": "memdb" }
|
|
40
|
+
```
|
|
36
41
|
|
|
37
|
-
### 2.
|
|
42
|
+
### 2. Dead code
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
```json
|
|
45
|
+
{ "repo_id": "memdb", "include_tests": false, "limit": 50 }
|
|
46
|
+
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
Exported symbols and entry points excluded by default. Results are candidates, not proof — callers via dynamic dispatch or reflection are invisible to the graph; verify before deleting.
|
|
44
49
|
|
|
45
|
-
### 3.
|
|
50
|
+
### 3. Complexity hotspots
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
```json
|
|
53
|
+
{ "repo_id": "memdb", "top_n": 10 }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Ordered by call-graph out-degree.
|
|
50
57
|
|
|
51
|
-
Complexity scoring (based on out-degree — number of callees):
|
|
52
58
|
| Score | Rating | Action |
|
|
53
59
|
|-------|--------|--------|
|
|
54
|
-
| <
|
|
55
|
-
| 5
|
|
56
|
-
| 10
|
|
57
|
-
| >
|
|
60
|
+
| <5 | Low | Fine |
|
|
61
|
+
| 5-10 | Medium | Consider simplifying |
|
|
62
|
+
| 10-20 | High | Refactor candidate |
|
|
63
|
+
| >20 | Critical | Refactor priority |
|
|
64
|
+
|
|
65
|
+
### 4. Single symbol complexity
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{ "repo_id": "memdb", "target": "processOrder" }
|
|
69
|
+
```
|
|
58
70
|
|
|
59
|
-
|
|
71
|
+
## Output
|
|
60
72
|
|
|
61
|
-
|
|
73
|
+
| Result | Carries |
|
|
74
|
+
|--------|---------|
|
|
75
|
+
| Dead-code entry (`find_dead_code`) | Symbol name + kind with zero graph callers — e.g. `format_legacy` (Function) |
|
|
76
|
+
| Complexity row (`find_most_complex_functions`) | Symbol, complexity score, risk level — e.g. `processOrder` — 27, Critical |
|
|
77
|
+
| Single score (`calculate_cyclomatic_complexity`) | Cyclomatic complexity for `target` |
|
|
78
|
+
| Stats (`get_repository_stats`) | Node counts by kind, edge counts, community and process counts for `repo_id`/`branch` |
|
|
62
79
|
|
|
63
80
|
## Common Mistakes
|
|
64
81
|
|
|
65
82
|
| Mistake | Reality |
|
|
66
83
|
|---------|---------|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
84
|
+
| `find_most_complex_functions(limit: 10)` | Param is **`top_n`** |
|
|
85
|
+
| `calculate_cyclomatic_complexity(symbol_id=...)` | Required param is **`target`** |
|
|
69
86
|
| Only looking at the highest complexity | Medium-complexity functions that are growing (check `get_evolution`) are often more urgent |
|