@engramlabs/mcp 0.1.2-alpha → 0.1.4-alpha

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.
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: engram-implement
3
+ description: Execute a plan step-by-step with a self-review loop — implement, verify with the plan's own commands, review the diff against the plan's risks, then learn from the outcome. Trigger when a plan exists (from engram-plan or given directly) and it's time to execute.
4
+ ---
5
+
6
+ # engram-implement
7
+
8
+ Implement with discipline: **implement → verify → self-review**, per step.
9
+ Red tests are information, not failure. Flailing is forbidden.
10
+
11
+ ## Contract
12
+
13
+ 1. Work the plan's steps in order; verify each with its own command.
14
+ 2. Self-review every diff against the plan's Findings and Risks.
15
+ 3. Two consecutive failed verifications on one step → stop and report.
16
+ 4. The session ends with a learn pass (`engram-learn` core ideas).
17
+
18
+ ## Workflow
19
+
20
+ ### 0. Recall the plan
21
+
22
+ If the plan isn't in-context:
23
+
24
+ ```
25
+ recall({ "query": "PLAN <slug>" })
26
+ ```
27
+
28
+ No plan anywhere? Either draft one (engram-plan, even briefly) or state
29
+ plainly that this is plan-less execution and accept the label.
30
+
31
+ ### 1. Per step: implement
32
+
33
+ Make the change. Small diffs. Prefer the smallest edit that satisfies the
34
+ step — style sweeps and drive-by refactors belong in their own step
35
+ (usually: don't).
36
+
37
+ ### 2. Per step: verify
38
+
39
+ Run the step's verification command exactly as written in the plan. If
40
+ the plan's command was wrong, fix the plan's command (and note it —
41
+ that's a learning).
42
+
43
+ - **Green** → self-review (step 3).
44
+ - **Red** → read the failure; fix; re-verify. The red IS the signal.
45
+
46
+ ### 3. Per step: self-review
47
+
48
+ Before moving on, review your diff against the plan:
49
+
50
+ - Does the diff do what the step said — nothing more?
51
+ - Did it touch any Risk-listed symbol/area? If yes, is the mitigation applied?
52
+ - Did it break an invariant the plan's Findings flagged?
53
+ - New behavior covered by a test (or is one honestly not warranted)?
54
+
55
+ Any "no" → fix before proceeding. Skipping self-review to "come back
56
+ later" is how bridges get broken silently.
57
+
58
+ ### 4. Stop conditions
59
+
60
+ - All steps verified + self-reviewed → completion report → step 5.
61
+ - Two consecutive failed verifications on the SAME step → STOP. Report:
62
+ the step, what you tried (both attempts), the error, your read on the
63
+ blocker. Do not attempt three.
64
+ - Plan invalidated mid-flight (a finding proves wrong) → stop, report the
65
+ contradiction, propose the plan amendment. Don't improvise a new plan
66
+ silently.
67
+
68
+ ### 5. Completion + learn pass
69
+
70
+ Report: steps done, verification results, diff summary, plan amendments
71
+ made, risks re-checked. Then a quick learn pass — the durable bits only:
72
+
73
+ ```
74
+ write_memory({ "content": "Fixed <X>: root cause was <Y>. Plan step-N command was wrong: <what worked instead>." })
75
+ procedure_put({ "name": "<validated workflow, if one emerged>",
76
+ "trigger": "<when>", "steps": ["..."] })
77
+ ```
78
+
79
+ ## When it fails
80
+
81
+ - Verify command can't run (missing tool/deps) → report immediately; do
82
+ not substitute a weaker check silently.
83
+ - Scope creep detected mid-step → finish or revert the current step, then
84
+ raise the scope change explicitly.
85
+
86
+ ## Anti-patterns
87
+
88
+ - Implementing multiple steps before verifying any.
89
+ - "I'll add tests at the end."
90
+ - Third attempt after two failures (stop means stop).
91
+ - Editing the plan to match the code after the fact without saying so.
92
+
93
+ ## Final check
94
+
95
+ - Every step verified green, every diff self-reviewed?
96
+ - Risks from the plan re-checked against the final diff?
97
+ - Did the learn pass capture the root causes, not the play-by-play?
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: engram-index
3
+ description: Index a codebase AND memorize what matters about it — build the code graph, then write durable, evidence-labeled memories (stack, invariants, sharp edges, build/test procedures). Trigger on "index this repo", first session in a repository, or when the engram stale-index reminder fires.
4
+ ---
5
+
6
+ # engram-index
7
+
8
+ Index the code graph, then **memorize the codebase** — the graph alone is
9
+ structure; memory is understanding. Evidence-first, always.
10
+
11
+ Depth on demand: `references/rea-process.md` (the full evidence-first
12
+ process) · `references/memorization-catalog.md` (exact write formats).
13
+
14
+ ## Contract
15
+
16
+ 1. Structure comes from `scan_repo` — never from reading files by hand first.
17
+ 2. Every memorized claim carries an evidence label: `[proven]`, `[likely]`, or `[guessed]`.
18
+ 3. Every memory written is read back — **an index that cannot be recalled is not an index.**
19
+ 4. No claim without a tool call behind it. If you cannot prove it, label it `[guessed]` or omit it.
20
+ 5. Recurring workflows become procedures — an index without runbooks is only half an index.
21
+
22
+ ## Workflow
23
+
24
+ ### 0. Scope (skip if fresh)
25
+
26
+ Check staleness first. If the repo is already indexed and little changed,
27
+ skip to phase 2 (delta-memorize) — don't rescan for nothing.
28
+
29
+ ```
30
+ recall({ "query": "repo overview build test invariants" })
31
+ ```
32
+
33
+ If recalled memories describe this repo adequately, go to phase 2.
34
+ Otherwise continue.
35
+
36
+ ### 1. Surface map
37
+
38
+ ```
39
+ scan_repo({ "path": "/absolute/path/to/repo" })
40
+ architecture({ "limit": 20 })
41
+ graph_health({})
42
+ ```
43
+
44
+ Read the architecture output: central symbols (core abstractions), bridges
45
+ (critical paths), communities (modules). This is the structural truth —
46
+ do NOT open files to "get a feel".
47
+
48
+ ### 2. Memorize
49
+
50
+ Write memories — one concern per memory, title first. Exact formats:
51
+ `references/memorization-catalog.md`. In short:
52
+
53
+ ```
54
+ write_memory({ "content": "[proven] <claim> — evidence: <tool + what it showed>" })
55
+ ```
56
+
57
+ Memorize, in order of value:
58
+ - **Stack + layout** — languages, framework, key directories (`[proven]` from the graph's file entities)
59
+ - **Invariants** — naming rules, boundary rules, layering (e.g. "domain crates must not depend on adapters — check-contracts.sh enforces") (`[likely]` if from names alone, `[proven]` if a check/script enforces it)
60
+ - **Sharp edges** — bridge symbols ("change_impact shows X is a bridge; touching it ripples into N areas"), god modules, known-tricky paths (`[proven]` via `change_impact`)
61
+ - **Core abstractions** — the top 3-5 central symbols, one line each on their role
62
+
63
+ Memorize procedures — the commands that build/test/verify, AND the
64
+ recurring workflows this repo actually performs (indexing, triage,
65
+ release, dogfood — whatever the repo's rhythm is):
66
+
67
+ ```
68
+ procedure_put({ "name": "verify", "trigger": "before handoff", "steps": ["<exact command>"] })
69
+ ```
70
+
71
+ Only procedures you have seen work (from READMEs, CI configs, or this
72
+ session). Label untested steps in the trigger field ("untested").
73
+ Check what already exists first — `procedure_list({})` — and re-put to
74
+ update, don't duplicate.
75
+
76
+ Optionally, entities + relationships for the top abstractions:
77
+
78
+ ```
79
+ put_entity({ "name": "Scanner", "kind": "class" })
80
+ put_relationship({ "subject": "Scanner", "predicate": "describes", "object": "ingest pipeline" })
81
+ ```
82
+
83
+ ### 3. Verify (write → read-back)
84
+
85
+ Probe with three recall queries a future agent would actually ask:
86
+
87
+ ```
88
+ recall({ "query": "build command" })
89
+ recall({ "query": "<top central symbol name>" })
90
+ recall({ "query": "<one invariant you wrote>" })
91
+ ```
92
+
93
+ If a probe returns nothing (or garbage), the memory was written badly —
94
+ rewrite it with more distinctive wording, then re-probe. Do not skip this.
95
+
96
+ ### 4. Report
97
+
98
+ Concise, no file dumps: N symbols, M modules, core abstractions (top
99
+ PageRank), bridges to respect, what was memorized, confidence split
100
+ (proven/likely/guessed counts), unknowns worth investigating later.
101
+
102
+ ## When it fails
103
+
104
+ - `scan_repo` errors → report the error; do not fall back to reading files
105
+ as a "quick index" — that produces structure-free memory.
106
+ - Empty architecture → repo may be empty/non-code; say so, stop.
107
+ - Read-back probes fail after one rewrite → report which memories didn't
108
+ stick; do not silently continue.
109
+
110
+ ## Anti-patterns
111
+
112
+ - Reading source files to summarize the repo before scanning (the graph is the map).
113
+ - Writing unlabelled claims ("the auth is in middleware" — proven? guessed?).
114
+ - Memorizing trivia (file counts, boilerplate names).
115
+ - One giant memory blob instead of one-concern-per-memory.
116
+
117
+ ## Final check
118
+
119
+ - What am I missing in the overview?
120
+ - Is every claim labeled and evidenced?
121
+ - Would these memories survive a refactor of the code they describe?
122
+ - Did all three probes come back?
@@ -0,0 +1,81 @@
1
+ # Memorization catalog — what engram-index writes, exactly
2
+
3
+ The reference for phase 2 (memorize) of engram-index. One concern per
4
+ memory; every claim labeled; every procedure seen working.
5
+
6
+ ## Memory formats (write_memory)
7
+
8
+ ### Stack + layout
9
+ ```
10
+ write_memory({ "content": "[proven] Rust workspace, 30+ crates; core/
11
+ adapters/backends split enforced by scripts/ci/check-engine-neutrality.sh
12
+ — evidence: architecture tool showed core crates; CI script read via
13
+ fetch_content" })
14
+ ```
15
+
16
+ ### Invariants (the rules this repo lives by)
17
+ ```
18
+ write_memory({ "content": "[proven] engram-domain must not depend on SQL,
19
+ vector stores, or async runtimes — evidence: check-engine-neutrality.sh
20
+ gates CI; violation names engine types in core crates" })
21
+ ```
22
+ Label `[likely]` when inferred from structure alone ("naming suggests
23
+ layering" is not proof); upgrade to `[proven]` only when a check, test,
24
+ or doc enforces it.
25
+
26
+ ### Sharp edges (what bites)
27
+ ```
28
+ write_memory({ "content": "[proven] bridge symbol: resolve_symbol in
29
+ core/code — 14 dependents across 5 crates; change_impact shows ripple
30
+ into scanner, mcp tools, and tests. Touch last, test wide." })
31
+ ```
32
+ Sources of sharp edges: `architecture` bridge list, `change_impact`
33
+ output on symbols you expect to touch, temporal traps from
34
+ `whats_changed`.
35
+
36
+ ### Core abstractions (the "understand this = understand the system" set)
37
+ ```
38
+ write_memory({ "content": "[proven] MemoryService trait is the central
39
+ abstraction (top PageRank) — every write path flows through it;
40
+ adapters implement, orchestration composes. evidence: architecture
41
+ tool, symbol_context depth 2" })
42
+ ```
43
+
44
+ ## Procedure formats (procedure_put)
45
+
46
+ Only procedures whose steps were SEEN working (CI configs, READMEs,
47
+ this session). Untested steps must say so in `trigger`.
48
+
49
+ ```
50
+ procedure_put({ "name": "verify",
51
+ "trigger": "before handoff",
52
+ "steps": ["cargo fmt --all", "cargo check --workspace",
53
+ "pnpm run typecheck", "pnpm run test",
54
+ "scripts/ci/check-contracts.sh"] })
55
+
56
+ procedure_put({ "name": "scan-repo",
57
+ "trigger": "index refresh",
58
+ "steps": ["scan_repo {path: <repo>}", "architecture {limit: 20}",
59
+ "graph_health {}"] })
60
+ ```
61
+
62
+ ## Entity/relationship formats (put_entity / put_relationship)
63
+
64
+ Top abstractions only — the graph already knows every symbol; entities
65
+ are for the CONCEPTS the graph can't infer:
66
+
67
+ ```
68
+ put_entity({ "name": "Engine Neutrality", "kind": "concept" })
69
+ put_relationship({ "subject": "Engine Neutrality", "predicate":
70
+ "realized_by", "object": "check-engine-neutrality" })
71
+ ```
72
+
73
+ Bridge concepts to the code that realizes them; a concept linked to
74
+ nothing is an orphan in a disconnected subgraph.
75
+
76
+ ## What NOT to memorize
77
+
78
+ - File counts, line counts, dependency version trivia
79
+ - Boilerplate names, test fixture names
80
+ - Anything `architecture`/`symbol_context` answers on demand
81
+ - Session play-by-play (that's engram-learn's job, and only the durable parts)
@@ -0,0 +1,79 @@
1
+ # REA process for code indexing
2
+
3
+ The evidence-first discipline (adapted from the REA — Reverse Engineer
4
+ Anything — method) applied to understanding and memorizing a codebase.
5
+
6
+ ## The process, stage by stage
7
+
8
+ ### 1. Target scoping
9
+ Define what is being understood before touching anything:
10
+ - What kind of system is this? (service, library, app, agent tool)
11
+ - What will "understood" mean here? (can answer where/how questions,
12
+ can plan changes safely, can recall invariants)
13
+ - What is already known? (check staleness — if a fresh index exists,
14
+ only delta-memorize)
15
+
16
+ **Stop condition:** scope stated in one sentence before any tool call.
17
+
18
+ ### 2. Surface mapping
19
+ Map the terrain without reading files:
20
+ - `scan_repo` — the structural pass (symbols, edges, communities)
21
+ - `architecture {limit: 20}` — central symbols, bridges, stats
22
+ - `graph_health` — is the graph trustworthy?
23
+
24
+ Surface mapping answers: how big, how coupled, where does complexity
25
+ live? It does NOT answer how anything works — that's tracing.
26
+
27
+ ### 3. Feature tracing
28
+ Follow one behavior from trigger to outcome through the graph:
29
+ - Start from the entry point (top central symbol, or a named feature)
30
+ - `symbol_context` each hop: callers, callees, community
31
+ - `change_impact` on bridges to understand blast radius
32
+ - `fetch_content` the load-bearing files to verify the graph's story
33
+
34
+ Record every hop: file, symbol, what the edge means. A trace that
35
+ skips a hop is a guess, not a trace.
36
+
37
+ ### 4. Evidence collection
38
+ Every claim gets its evidence AT COLLECTION TIME, not later:
39
+
40
+ | Label | Meaning | Evidence standard |
41
+ |---|---|---|
42
+ | `[proven]` | Verified against source or graph | tool + query + what it showed |
43
+ | `[likely]` | Strong signal, unverified | naming, structure, docs memory |
44
+ | `[guessed]` | Hypothesis only | must say so explicitly |
45
+
46
+ Rules:
47
+ - Never claim how something works without graph/source evidence.
48
+ - Separate facts from interpretation — the label IS the separation.
49
+ - Start with the simplest trace that proves the behavior.
50
+ - Pseudocode-level summaries of files you haven't fetched are `[likely]`
51
+ at best.
52
+
53
+ ### 5. Reconstruction (memorization)
54
+ Turn findings into durable memory — one concern per memory, written so a
55
+ future agent in a fresh session can act on it:
56
+ - Stack + layout invariants
57
+ - Sharp edges (bridges, god modules, temporal traps)
58
+ - Core abstractions (top PageRank, one line each)
59
+ - Build/test/verify procedures (exact commands, only ones seen working)
60
+
61
+ An unmemorized finding is a finding you'll pay for twice.
62
+
63
+ ### 6. Verification (write → read-back)
64
+ - Recall 3 probe queries a future agent would actually ask.
65
+ - A probe that fails = a memory written badly = rewrite it.
66
+ - **An index that cannot be recalled is not an index.**
67
+
68
+ ### 7. Final report
69
+ - N symbols, M modules, core abstractions, bridges to respect
70
+ - What was memorized + confidence split (proven/likely/guessed counts)
71
+ - Unknowns worth investigating — honesty about holes
72
+
73
+ ## The final check (run before claiming done)
74
+
75
+ - What am I missing in the overview?
76
+ - Is each claim proven or just plausible?
77
+ - Did I mistake graph structure for verified behavior?
78
+ - Would these memories survive the next refactor?
79
+ - What evidence would change my mind?
@@ -0,0 +1,99 @@
1
+ ---
2
+ name: engram-learn
3
+ description: Distill durable learnings from a session, doc, or fix into engram — decisions with rationale, gotchas and resolutions, validated procedures, source-grounded facts, belief updates. Trigger on "remember this", "learn from this session", after a meaningful bug fix, or at the end of a substantive work session.
4
+ ---
5
+
6
+ # engram-learn
7
+
8
+ Turn what just happened into durable memory. The agent does the extraction
9
+ and judgment; engram stores and recalls. Learners capture **decisions,
10
+ gotchas, and procedures** — not transcripts.
11
+
12
+ ## Contract
13
+
14
+ 1. No trivia: if a future agent wouldn't act on it, don't write it.
15
+ 2. No duplicates: recall first; update or skip if it's already known.
16
+ 3. Decisions record the *why*, not just the *what*.
17
+ 4. Source-grounded facts cite their source (`store_knowledge`, not `write_memory`).
18
+
19
+ ## Workflow
20
+
21
+ ### 1. What kind of learning is this?
22
+
23
+ | Kind | Tool | Shape |
24
+ |---|---|---|
25
+ | Decision + rationale | `write_memory` | "Decided X over Y because Z" |
26
+ | Gotcha / resolution | `write_memory` | "X bites when Y; fix: Z" |
27
+ | Validated procedure | `procedure_put` | exact steps that worked |
28
+ | Fact from a source | `store_knowledge` | entities/facts with the doc path |
29
+ | Changed stance | `belief_get` → update or let contradiction stand | subject + new position |
30
+ | Replayable doc | `index_docs` | verbatim, chunked for recall |
31
+
32
+ ### 2. Recall before writing (dedup)
33
+
34
+ ```
35
+ recall({ "query": "<the learning's key terms>" })
36
+ ```
37
+
38
+ If it's already there: skip (nothing new), or write only the delta
39
+ ("update: also fails on Windows"), or bump the procedure's accuracy by
40
+ re-putting it.
41
+
42
+ ### 3. Write
43
+
44
+ ```
45
+ write_memory({ "content": "Decided to gate npm publish on the scan gate: a package is the most-attacked surface (lesson: OpenClaw). Context: RFC-0021." })
46
+ ```
47
+
48
+ ```
49
+ procedure_put({ "name": "re-tag-release", "trigger": "publish retry",
50
+ "steps": ["gh release delete vX --yes", "git tag -d vX",
51
+ "git push origin :refs/tags/vX", "git tag vX", "git push origin vX"] })
52
+ ```
53
+
54
+ For stance changes, check the belief state first:
55
+
56
+ ```
57
+ belief_get({ "subject": "engram-index auto-triggers" })
58
+ ```
59
+
60
+ If a belief contradicts the new learning, let the contradiction stand —
61
+ `contradiction_list` will surface the tension later. Never silently
62
+ overwrite a belief with history behind it.
63
+
64
+ For source material (RFCs, ADRs, design docs) the project should recall:
65
+
66
+ ```
67
+ store_knowledge({ "entities": [], "facts": [], "relationships": [], "idempotency_key": "<doc-id>" })
68
+ ```
69
+
70
+ Bridge concepts to code where you can — a concept not linked to what
71
+ realizes it is an orphan. Use `search({ "query": "<term>" })` to find
72
+ real symbol names before linking.
73
+
74
+ ### 4. Confirm
75
+
76
+ One read-back per critical write:
77
+
78
+ ```
79
+ recall({ "query": "<the decision's core terms>" })
80
+ ```
81
+
82
+ ## When it fails
83
+
84
+ - `write_memory` errors → report; never retry in a loop.
85
+ - Nothing worth learning → say "nothing durable here" and stop. Silence
86
+ is a valid outcome; forced learnings are noise.
87
+
88
+ ## Anti-patterns
89
+
90
+ - Session-transcript dumps ("we ran tests, then edited X, then…").
91
+ - Duplicating what `recall` already returns.
92
+ - Unvalidated procedures (steps never executed).
93
+ - Belief overwrites that erase history.
94
+
95
+ ## Final check
96
+
97
+ - Would a future agent in a fresh session act differently because of these writes?
98
+ - Every decision has its why?
99
+ - Procedures were actually run?
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: engram-plan
3
+ description: Plan a change by mining the engram index first — past issues, patterns, invariants, blast radius — using the right workflow for the job. Triage (classify + route), Bugfix (root cause + regression guard), or Story/Feature (precedents + per-layer steps). Trigger when asked to solve/plan/triage/implement anything non-trivial, before editing.
4
+ ---
5
+
6
+ # engram-plan
7
+
8
+ Plan from evidence, not vibes. The index already knows this repo's
9
+ structure, invariants, history, and past failures — mine it before
10
+ writing a line of the plan.
11
+
12
+ **Pick the workflow first** — they are different disciplines:
13
+
14
+ | The request smells like… | Workflow | Reference |
15
+ |---|---|---|
16
+ | "this is broken", unclear severity, red CI | **Triage** — classify + route, don't fix | `references/plan-triage.md` |
17
+ | Reproduced failure, regression, crash | **Bugfix** — root cause + regression guard | `references/plan-bugfix.md` |
18
+ | New capability, story, integration | **Story/Feature** — precedents + per-layer steps | `references/plan-story.md` |
19
+
20
+ All three share the moves below; the references carry each one's
21
+ specific discipline.
22
+
23
+ ## Contract
24
+
25
+ 1. Mine before writing: past work, past failures, invariants, blast radius, tensions.
26
+ 2. **Every plan starts with a past-pattern search** — a fix/feature that ignores how this repo solved it before is planning amnesia.
27
+ 3. Findings are evidence-labeled; risks are quantified from the graph.
28
+ 4. Every step is independently verifiable — it names the command that proves it.
29
+ 5. The plan is written to memory so `engram-implement` can recall it; recurring shapes become procedures.
30
+
31
+ ## Workflow (shared moves)
32
+
33
+ ### 1. Frame the change
34
+
35
+ One paragraph: what changes, for whom, what "done" means. Ambiguity →
36
+ list your interpretation in Open Questions; don't silently pick.
37
+
38
+ ### 2. Search the past (engram-search discipline)
39
+
40
+ ```
41
+ recall({ "query": "<domain terms> fix design decisions" })
42
+ search({ "query": "<likely touchpoint symbols>" })
43
+ procedure_list({})
44
+ contradiction_list({})
45
+ ```
46
+
47
+ Mine for: past fixes with the same symptom · precedents for the same
48
+ feature shape · indexed invariants the change must respect · existing
49
+ runbooks (if one covers this, following it beats planning) · open
50
+ tensions. **Record the search result either way** — "no past
51
+ occurrences" is a finding.
52
+
53
+ ### 3. Map the surface
54
+
55
+ ```
56
+ architecture({ "limit": 15 })
57
+ symbol_context({ "symbol": "<touchpoint>", "depth": 2 })
58
+ change_impact({ "target": "<touchpoint>" })
59
+ ```
60
+
61
+ Blast radius per touchpoint → Risks. Crossed layers → explicit
62
+ per-layer steps.
63
+
64
+ ### 4. Write the plan (fixed sections)
65
+
66
+ **Overview** (the repo's vocabulary) · **Findings** (labeled, including
67
+ the past-pattern search result) · **Risks** (blast radius + invariants
68
+ threatened + mitigations) · **Steps** (ordered, each with its verify
69
+ command) · **Open Questions** (what the index could NOT answer).
70
+
71
+ ### 5. Persist plan + workflow
72
+
73
+ ```
74
+ write_memory({ "content": "PLAN <slug>: <overview>. Precedents: <found|none>. Steps: <N>. Top risks: <top risks>." })
75
+ ```
76
+
77
+ When this shape recurs, capture the workflow that worked:
78
+
79
+ ```
80
+ procedure_put({ "name": "plan-<workflow-type>", "trigger": "<when this shape appears>", "steps": ["<the moves that worked, in order>"] })
81
+ ```
82
+
83
+ ## When it fails
84
+
85
+ - No index (recall/search empty) → plan against `scan_repo` + reads,
86
+ findings marked `[guessed]` where the graph would have proven them.
87
+ Suggest engram-index.
88
+ - A recalled past fix contradicts the request's assumptions → surface
89
+ it before planning; the past fix is evidence, not noise.
90
+
91
+ ## Anti-patterns
92
+
93
+ - Skipping the past-pattern search (the #1 planning failure).
94
+ - Triage that fixes, bugfix plans without a regression test, story
95
+ plans without a precedent search.
96
+ - Steps with no verification command.
97
+ - Risks without graph evidence ("might be tricky" is not a risk).
98
+ - Planning past an open contradiction without flagging it.
99
+
100
+ ## Final check
101
+
102
+ - Right workflow for the request?
103
+ - Did the past-pattern search run, and is its result in Findings?
104
+ - Could a fresh agent implement from Findings + Steps alone?
@@ -0,0 +1,66 @@
1
+ # Plan workflow: BUGFIX
2
+
3
+ Root cause first, minimal fix second, regression guard always.
4
+
5
+ ## When this workflow
6
+ - Reproduced failure, cause unknown or partially known
7
+ - Regression (something that used to work)
8
+ - Post-triage routing (fast lane if a past pattern was recalled)
9
+
10
+ ## Steps
11
+
12
+ ### 1. Search the past — every bugfix starts here
13
+ ```
14
+ recall({ "query": "<symptom terms> fix root cause" })
15
+ search({ "query": "<failing symbol}" })
16
+ procedure_list({})
17
+ ```
18
+ - A past fix for the same symptom = the pattern to check first
19
+ (was it fully fixed, or did the same class resurface elsewhere?)
20
+ - An indexed sharp edge near the failure = prime suspect
21
+ - **Record the search**: "no past occurrences found" is itself a
22
+ finding ([proven] by absence, worth saying)
23
+
24
+ ### 2. Localize with the graph
25
+ ```
26
+ symbol_context({ "symbol": "<failing symbol>", "depth": 2 })
27
+ change_impact({ "target": "<suspect symbol>" })
28
+ ```
29
+ - The failing symbol's neighborhood = the suspect pool
30
+ - `fetch_content` the load-bearing file(s) — never theorize about code
31
+ you haven't read this session
32
+ - If recently-changed code is in the neighborhood:
33
+ `whats_changed {}` to see what moved lately
34
+
35
+ ### 3. Root cause (the plan's Findings section)
36
+ State it as a testable claim: "X fails because Y, when Z."
37
+ Label it. `[proven]` requires either a repro trace or source evidence.
38
+ A root cause you can't state in one sentence isn't found yet.
39
+
40
+ ### 4. Minimal fix + regression guard (Steps section)
41
+ - Smallest change that removes the cause (not the symptom)
42
+ - A test that fails before the fix and passes after — the regression
43
+ guard is mandatory, not optional
44
+ - Blast radius from step 2 becomes the Risks section
45
+
46
+ ### 5. Persist the pattern (procedures for recurring classes)
47
+ If this is the second+ occurrence of a failure class:
48
+
49
+ ```
50
+ procedure_put({ "name": "fix-<failure-class>",
51
+ "trigger": "<symptom signature>",
52
+ "steps": ["<localization step>", "<root-cause check>",
53
+ "<the fix>", "<the regression test>"] })
54
+ ```
55
+ Next triage of this class should hit the runbook, not rediscover it.
56
+
57
+ ## Output (hand to engram-implement)
58
+ - **Findings**: symptom, root cause [labeled], past-occurrence search result
59
+ - **Risks**: blast radius, what the regression test must cover
60
+ - **Steps**: fix + test + verify command (exact)
61
+
62
+ ## Stop conditions
63
+ - Root cause unprovable after localization → plan the investigation
64
+ (instrument, log, bisect) — don't plan a fix on a guess.
65
+ - Fix would touch a bridge symbol → plan-wide test pass is a step, not
66
+ an afterthought.