mindforge-cc 2.3.5 → 3.0.0

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.
Files changed (82) hide show
  1. package/.agent/skills/mindforge-plan-phase/SKILL.md +1 -0
  2. package/.agent/skills/mindforge-system-architecture/SKILL.md +136 -0
  3. package/.agent/skills/mindforge-system-architecture/examples.md +120 -0
  4. package/.agent/skills/mindforge-system-architecture/scaling-checklist.md +76 -0
  5. package/.agent/skills/mindforge-tdd/SKILL.md +112 -0
  6. package/.agent/skills/mindforge-tdd/deep-modules.md +21 -0
  7. package/.agent/skills/mindforge-tdd/interface-design.md +22 -0
  8. package/.agent/skills/mindforge-tdd/mocking.md +24 -0
  9. package/.agent/skills/mindforge-tdd/refactoring.md +21 -0
  10. package/.agent/skills/mindforge-tdd/tests.md +28 -0
  11. package/.agent/workflows/mindforge-plan-phase.md +30 -1
  12. package/.agent/workflows/mindforge:architecture.md +40 -0
  13. package/.agent/workflows/mindforge:executor.md +18 -0
  14. package/.agent/workflows/mindforge:identity.md +18 -0
  15. package/.agent/workflows/mindforge:memory.md +18 -0
  16. package/.agent/workflows/mindforge:planner.md +18 -0
  17. package/.agent/workflows/mindforge:researcher.md +18 -0
  18. package/.agent/workflows/mindforge:reviewer.md +18 -0
  19. package/.agent/workflows/mindforge:tdd.md +41 -0
  20. package/.agent/workflows/mindforge:tool.md +18 -0
  21. package/.mindforge/engine/ads-protocol.md +54 -0
  22. package/.mindforge/engine/compaction-protocol.md +21 -36
  23. package/.mindforge/engine/context-injector.md +26 -0
  24. package/.mindforge/engine/knowledge-graph-protocol.md +125 -0
  25. package/.mindforge/engine/shard-controller.md +53 -0
  26. package/.mindforge/engine/temporal-protocol.md +40 -0
  27. package/.mindforge/personas/mf-executor.md +40 -0
  28. package/.mindforge/personas/mf-memory.md +33 -0
  29. package/.mindforge/personas/mf-planner.md +45 -0
  30. package/.mindforge/personas/mf-researcher.md +39 -0
  31. package/.mindforge/personas/mf-reviewer.md +35 -0
  32. package/.mindforge/personas/mf-tool.md +33 -0
  33. package/.planning/AUDIT.jsonl +1 -0
  34. package/.planning/TEMPORAL-TEST.md +1 -0
  35. package/.planning/history/36525e1d9da1b674/ARCHITECTURE.md +0 -0
  36. package/.planning/history/36525e1d9da1b674/HANDOFF.json +8 -0
  37. package/.planning/history/36525e1d9da1b674/PROJECT.md +33 -0
  38. package/.planning/history/36525e1d9da1b674/RELEASE-CHECKLIST.md +68 -0
  39. package/.planning/history/36525e1d9da1b674/REQUIREMENTS.md +0 -0
  40. package/.planning/history/36525e1d9da1b674/ROADMAP.md +12 -0
  41. package/.planning/history/36525e1d9da1b674/SNAPSHOT-META.json +18 -0
  42. package/.planning/history/36525e1d9da1b674/STATE.md +31 -0
  43. package/.planning/history/36525e1d9da1b674/TEMPORAL-TEST.md +1 -0
  44. package/.planning/history/36525e1d9da1b674/jira-sync.json +5 -0
  45. package/.planning/history/36525e1d9da1b674/slack-threads.json +3 -0
  46. package/.planning/history/test-audit-001/ARCHITECTURE.md +0 -0
  47. package/.planning/history/test-audit-001/HANDOFF.json +8 -0
  48. package/.planning/history/test-audit-001/PROJECT.md +33 -0
  49. package/.planning/history/test-audit-001/RELEASE-CHECKLIST.md +68 -0
  50. package/.planning/history/test-audit-001/REQUIREMENTS.md +0 -0
  51. package/.planning/history/test-audit-001/ROADMAP.md +12 -0
  52. package/.planning/history/test-audit-001/SNAPSHOT-META.json +17 -0
  53. package/.planning/history/test-audit-001/STATE.md +31 -0
  54. package/.planning/history/test-audit-001/TEMPORAL-TEST.md +1 -0
  55. package/.planning/history/test-audit-001/jira-sync.json +5 -0
  56. package/.planning/history/test-audit-001/slack-threads.json +3 -0
  57. package/CHANGELOG.md +101 -0
  58. package/README.md +57 -23
  59. package/bin/autonomous/auto-runner.js +23 -0
  60. package/bin/dashboard/server.js +2 -0
  61. package/bin/dashboard/temporal-api.js +82 -0
  62. package/bin/engine/temporal-cli.js +52 -0
  63. package/bin/engine/temporal-hub.js +138 -0
  64. package/bin/hindsight-injector.js +59 -0
  65. package/bin/memory/auto-shadow.js +274 -0
  66. package/bin/memory/embedding-engine.js +326 -0
  67. package/bin/memory/knowledge-capture.js +122 -5
  68. package/bin/memory/knowledge-graph.js +572 -0
  69. package/bin/memory/knowledge-store.js +15 -3
  70. package/bin/mindforge-cli.js +19 -0
  71. package/bin/models/model-router.js +1 -0
  72. package/bin/review/ads-engine.js +126 -0
  73. package/bin/review/ads-synthesizer.js +117 -0
  74. package/bin/shard-helper.js +134 -0
  75. package/bin/spawn-agent.js +61 -0
  76. package/docs/PERSONAS.md +71 -5
  77. package/docs/adr/ADR-042-ads-protocol.md +30 -0
  78. package/docs/architecture/README.md +55 -0
  79. package/docs/architecture/V3-CORE.md +52 -0
  80. package/docs/commands-reference.md +3 -2
  81. package/docs/usp-features.md +33 -15
  82. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the Implementation Pilot persona (mf-executor)
3
+ ---
4
+ # 🛠️ /mindforge:executor
5
+
6
+ ## Objective
7
+ Adopt the **Implementation Pilot** persona for high-fidelity plan execution and atomic commit discipline.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the executor essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-executor
16
+ ```
17
+
18
+ 2. The AI will adopt the **Self-Correction & Polish** pattern and await your execution tasks.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke a specialized agent identity from the /agents/ workspace
3
+ ---
4
+ # 🆔 /mindforge:identity
5
+
6
+ ## Objective
7
+ Directly load a specialized research identity (e.g., Planner, Executor) from the `/agents/` workspace.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to load the specialized identity:
14
+ ```bash
15
+ node bin/mindforge-cli.js identity [role]
16
+ ```
17
+
18
+ 2. The AI will adopt the deep, research-backed cognitive model defined in `agents/[role]/IDENTITY.md`.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the Semantic Clerk persona (mf-memory)
3
+ ---
4
+ # 📓 /mindforge:memory
5
+
6
+ ## Objective
7
+ Adopt the **Semantic Clerk** persona to manage long-term project memory and knowledge graph maintenance.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the memory essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-memory
16
+ ```
17
+
18
+ 2. The AI will adopt the **Memory Indexing & Pattern Recall** pattern and await your persistence tasks.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the Strategic Planner persona (mf-planner)
3
+ ---
4
+ # 🧠 /mindforge:planner
5
+
6
+ ## Objective
7
+ Adopt the **Strategic Planner** persona to decompose high-level goals into structured, executable plans.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the planner essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-planner
16
+ ```
17
+
18
+ 2. The AI will adopt the **Goal-Backward Decomposition** pattern and await your objective.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the Knowledge Detective persona (mf-researcher)
3
+ ---
4
+ # 🔍 /mindforge:researcher
5
+
6
+ ## Objective
7
+ Adopt the **Knowledge Detective** persona for grounded research and recursive browsing.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the researcher essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-researcher
16
+ ```
17
+
18
+ 2. The AI will adopt the **Deep Context Synthesis** pattern and await your research objective.
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the Quality Auditor persona (mf-reviewer)
3
+ ---
4
+ # 🛡️ /mindforge:reviewer
5
+
6
+ ## Objective
7
+ Adopt the **Quality Auditor** persona for adversarial review and 6-pillar logic auditing.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the reviewer essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-reviewer
16
+ ```
17
+
18
+ 2. The AI will adopt the **Adversarial Logic Verification** pattern and await your review target.
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: Strict TDD workflow (Red-Green-Refactor).
3
+ ---
4
+ # 🧪 /mindforge:tdd
5
+
6
+ <instruction>
7
+ Execute a strict Test-Driven Development (TDD) loop using the Red-Green-Refactor pattern with an emphasis on "Tracer Bullets" (vertical slices).
8
+ </instruction>
9
+
10
+ <context>
11
+ Follow the specialized MindForge TDD standards defined in [.agent/skills/mindforge-tdd/SKILL.md](.agent/skills/mindforge-tdd/SKILL.md).
12
+ </context>
13
+
14
+ <rules>
15
+ - **No Implementation without Test**: Do not write production code unless it is to make a failing test pass.
16
+ - **Minimalist Green**: Write the absolute minimum code required to satisfy the test.
17
+ - **Refactor Ruthlessly**: Clean up after every green state while keeping tests passing.
18
+ - **Vertical Slicing**: Prioritize end-to-end functionality over horizontal layers.
19
+ </rules>
20
+
21
+ <process>
22
+ 1. **RED**: Define a single behavioral requirement and write a failing test.
23
+ 2. **GREEN**: Implement the simplest code to fix the failure.
24
+ 3. **REFACTOR**: Optimize the code and tests for readability and maintainability.
25
+ 4. **VERIFY**: Ensure all tests in the suite pass before proceeding.
26
+ </process>
27
+
28
+ <supporting_documents>
29
+ - [Deep Modules](.agent/skills/mindforge-tdd/deep-modules.md)
30
+ - [Interface Design](.agent/skills/mindforge-tdd/interface-design.md)
31
+ - [Mocking Strategies](.agent/skills/mindforge-tdd/mocking.md)
32
+ - [Refactoring Guide](.agent/skills/mindforge-tdd/refactoring.md)
33
+ - [Test Infrastructure](.agent/skills/mindforge-tdd/tests.md)
34
+ </supporting_documents>
35
+
36
+ <output_format>
37
+ Summarize each TDD cycle with:
38
+ - `[RED]`: The test added.
39
+ - `[GREEN]`: The minimal change made.
40
+ - `[REFACTOR]`: Specific improvements made.
41
+ </output_format>
@@ -0,0 +1,18 @@
1
+ ---
2
+ description: Invoke the System Operator persona (mf-tool)
3
+ ---
4
+ # 🔌 /mindforge:tool
5
+
6
+ ## Objective
7
+ Adopt the **System Operator** persona for safe external system interaction and tool execution logic.
8
+
9
+ ---
10
+
11
+ ## Execution
12
+ // turbo
13
+ 1. Execute the MindForge CLI to spawn the tool essence:
14
+ ```bash
15
+ node bin/mindforge-cli.js spawn mf-tool
16
+ ```
17
+
18
+ 2. The AI will adopt the **Least-Privilege Gating** pattern and await your tool-use requests.
@@ -0,0 +1,54 @@
1
+ # MindForge Engine — Adversarial Decision Synthesis (ADS) Protocol
2
+
3
+ ## Purpose
4
+ Evolve the standard single-agent planning model into a high-fidelity Red-Team/Blue-Team architectural synthesis. This protocol ensures all major decisions are stress-tested for maintainability, security, and scalability before execution begins.
5
+
6
+ ## Core Roles
7
+
8
+ ### 1. The Architect (Blue Team — Performance & Complexity)
9
+ - **Persona**: `mindforge-architect` or `mf-planner`
10
+ - **Objective**: Propose the most technically superior, performant, and feature-complete solution.
11
+ - **Bias**: "We should build for scale and future-proof the system."
12
+
13
+ ### 2. The Auditor (Red Team — Simplicity & Maintainability)
14
+ - **Persona**: `mindforge-qa-engineer` or `mindforge-security-reviewer`
15
+ - **Objective**: Find logic gaps, security flaws, and architectural "over-engineering".
16
+ - **Bias**: "Do we really need this complexity? How will this break tomorrow?"
17
+
18
+ ### 3. The Synthesizer (Gold Team — Decision Merge)
19
+ - **Persona**: `mindforge-decision-architect`
20
+ - **Objective**: Mediate the debate, score proposals using `SOUL.md` metrics, and merge into a final `PLAN.md`.
21
+ - **Bias**: "Objective leverage. Minimal risk. Maximum impact."
22
+
23
+ ## Synthesis Loop — Execution Order
24
+
25
+ ### Step 1: Blue Proposal (Propose)
26
+ The **Architect** generates a detailed implementation plan (`PLAN-[P]-BLUE.md`).
27
+ - Focus on: Data flow, performance, and API design.
28
+
29
+ ### Step 2: Red Critique (Challenge)
30
+ The **Auditor** reviews the Blue plan and generates a critique (`PLAN-[P]-RED-CRITIQUE.md`).
31
+ - **Pressure Rule**: Red *must* identify at least 3 potential failure modes or "Complexity Traps."
32
+ - Red proposes a "Simpler Alternative" if the Blue plan is deemed over-engineered.
33
+
34
+ ### Step 3: Gold Verdict (Synthesize)
35
+ The **Synthesizer** ingest both plans and the critique.
36
+ 1. Calculates the **SOUL_SCORE** for each approach:
37
+ `Score = (Impact × Leverage × Reversibility) / (Effort × Risk × Cost)`
38
+ 2. Generates the final `PLAN.md` by adopting the best parts of both.
39
+ 3. Produces a `DECISION_ADS.md` (ADR) justifying the synthesis.
40
+
41
+ ## Synthesis Tossing (Iterative Loop)
42
+ If the **SOUL_SCORE** difference between approaches is < 0.2, the Synthesizer can trigger one round of "Tossing":
43
+ - Both teams are given the other's feedback and asked to refine their proposal.
44
+ - Total iterations capped at 2 to avoid scope-paralysis.
45
+
46
+ ## Output Structure
47
+ The final result must always move to the standard `.planning/` directory:
48
+ - `.planning/PLAN.md` (Validated & Hardened)
49
+ - `.planning/decisions/ADS-[UUID].md` (The Proof of Synthesis)
50
+
51
+ ## Trigger Conditions
52
+ - Any phase marked "Architectural" in `ROADMAP.md`
53
+ - Manual trigger via `/mindforge:plan-phase --ads`
54
+ - When a `security-reviewer` flags a high-risk change
@@ -63,55 +63,40 @@ workarounds discovered, gotchas found, things that seemed like they would
63
63
  work but did not]
64
64
  ```
65
65
 
66
- ### Step 4 — Write HANDOFF.json
67
- Overwrite `.planning/HANDOFF.json` with complete current state:
66
+ ### Step 4 — Write HANDOFF.json (Hot Context)
67
+ Overwrite `.planning/HANDOFF.json` with the current **Hot** state. This file should only contain high-SRD items required for immediate task resumption.
68
68
 
69
69
  ```json
70
70
  {
71
- "schema_version": "1.0.0",
72
- "project": "[project name from PROJECT.md]",
71
+ "schema_version": "2.1.0",
72
+ "project": "[project name]",
73
73
  "phase": [N],
74
74
  "plan": [M],
75
- "plan_step": "[exact step description — be precise enough to restart from here]",
76
- "last_completed_task": {
77
- "description": "[task description]",
78
- "commit_sha": "[git sha or 'wip-checkpoint']",
79
- "verified": true/false
80
- },
81
- "next_task": "[exact instruction for the next session to execute]",
82
- "in_progress": {
83
- "file": "[file being modified]",
84
- "intent": "[what the modification is trying to achieve]",
85
- "completed_steps": ["step 1", "step 2"],
86
- "remaining_steps": ["step 3", "step 4"]
75
+ "plan_step": "[exact step description]",
76
+ "next_task": "[exact instruction for next session]",
77
+ "hot_context": {
78
+ "active_decisions": [],
79
+ "recent_discoveries": [],
80
+ "file_offsets": {}
87
81
  },
88
82
  "blockers": [],
89
- "decisions_needed": [],
90
83
  "context_refs": [
91
- ".planning/PROJECT.md",
92
84
  ".planning/STATE.md",
93
- ".planning/REQUIREMENTS.md",
94
- ".planning/ARCHITECTURE.md",
95
- ".planning/phases/[N]/PLAN-[N]-[M].md",
96
- "[any other files critical for the next session]"
97
- ],
98
- "recent_commits": [
99
- "[sha1]: [message]",
100
- "[sha2]: [message]"
85
+ ".planning/HANDOFF.json",
86
+ ".planning/memories/WARM-SHARD-LATEST.jsonl"
101
87
  ],
102
- "recent_files": [
103
- "[most recently touched file 1]",
104
- "[most recently touched file 2]",
105
- "[most recently touched file 3]",
106
- "[most recently touched file 4]",
107
- "[most recently touched file 5]"
108
- ],
109
- "agent_notes": "[anything the agent knows that isn't captured elsewhere]",
110
- "_warning": "Never store secrets, tokens, or passwords in this file. It is tracked in git.",
111
- "updated_at": "[ISO-8601 timestamp]"
88
+ "shard_ref": ".planning/memories/WARM-SHARD-N.jsonl",
89
+ "updated_at": "[ISO-8601]"
112
90
  }
113
91
  ```
114
92
 
93
+ ### Step 4.5 — Semantic Sharding (Warm/Cold Context)
94
+ Invoke the [Shard Controller](shard-controller.md) to offload lower-SRD items:
95
+ 1. Identify items with SRD < 0.8 (Decisions from earlier in the phase, transient research).
96
+ 2. Append these to `.planning/memories/WARM-SHARD-N.jsonl`.
97
+ 3. If any item has matured into a Project-wide pattern (SRD > 0.9 + repeated usage), move it to `.mindforge/memory/`.
98
+ 4. Ensure `HANDOFF.json` remains under 10KB.
99
+
115
100
  ### Step 5 — Write compaction AUDIT entry
116
101
  ```json
117
102
  {
@@ -38,6 +38,25 @@ You are a MindForge agent executing a specific task. Read these instructions com
38
38
  [Contents of any ADR files referenced in the plan's <context> field]
39
39
  [Only the referenced ones]
40
40
 
41
+ ## Auto-Shadow Context (RAG 2.0)
42
+ [Generated by bin/memory/auto-shadow.js — DO NOT populate manually]
43
+
44
+ Before building the context package, the injector MUST:
45
+ 1. Read the <task> description from the current PLAN file.
46
+ 2. Call `auto-shadow.generateShadowContext({ taskDescription, excludeIds })`.
47
+ 3. Inject the returned `formatted` string here (if non-empty).
48
+ 4. The auto-shadow output is budget-capped at 2KB (~8000 chars).
49
+ 5. If the output is empty, omit this section entirely.
50
+ 6. Never include entries that are already in the "Relevant decisions" section above.
51
+
52
+ The Auto-Shadow engine queries:
53
+ - **Embedding similarity**: TF-IDF cosine similarity against the full knowledge base
54
+ - **Graph traversal**: 1-hop and 2-hop neighbors of top embedding matches
55
+ - **Hybrid scoring**: 60% embedding score + 40% graph proximity
56
+
57
+ Security: The engine automatically filters out entries containing secrets,
58
+ credentials, API keys, or PEM blocks. Deprecated entries are excluded.
59
+
41
60
  ## Active skills
42
61
  [Contents of any SKILL.md files listed in the plan's <context> field]
43
62
  [Only the listed ones]
@@ -108,6 +127,13 @@ Before injecting context to a subagent:
108
127
  c. If still > 30,000 after summarisation: warn the user and ask to proceed
109
128
  3. Never silently inject oversized context — the budget exists for a reason.
110
129
 
130
+ ## Semantic Warm Retrieval (New)
131
+ To maximize subagent fidelity without bloat, perform proactive retrieval from shards:
132
+ 1. **Query**: The `next_task` description.
133
+ 2. **Search**: Scan `.planning/memories/WARM-SHARD-N.jsonl` for semantic keywords (e.g., "auth", "database", "Kafka").
134
+ 3. **Inject**: Top 3 most relevant items into a new section: `## Sharded Context (Warm)`.
135
+ 4. **Scoring**: Use `bin/shard-helper.js --retrieve "[query]"` for automated matching.
136
+
111
137
  ## Subagent completion protocol
112
138
 
113
139
  After the subagent completes, the orchestrator must receive:
@@ -0,0 +1,125 @@
1
+ # MindForge Engine — Knowledge Graph Protocol (RAG 2.0)
2
+
3
+ ## Purpose
4
+
5
+ Govern the Local-First Knowledge Graph's integrity, security, and performance.
6
+ This protocol defines the rules for graph operations, auto-shadowing, and
7
+ life-cycle management of nodes and edges.
8
+
9
+ ## Graph Integrity Rules
10
+
11
+ ### Node Rules
12
+
13
+ - Every node MUST have a valid `id`, `type`, `topic`, and `content`.
14
+ - Deprecated nodes are excluded from all queries and traversals.
15
+ - Orphan nodes (no edges) are flagged in `graphStats()` but NOT auto-pruned.
16
+ - Orphan pruning only runs on `/mindforge:complete-milestone`.
17
+
18
+ ### Edge Rules
19
+
20
+ - Every edge MUST have a valid `sourceId`, `targetId`, and `type`.
21
+ - Self-referencing edges (sourceId === targetId) are rejected.
22
+ - Duplicate edges (same source, target, type) are prevented at creation time.
23
+ - All edge records include a SHA-256 integrity checksum.
24
+ - Edge writes are append-only — never mutate-in-place.
25
+
26
+ ### Cycle Prevention
27
+
28
+ - `CAUSED_BY` and `SUPERSEDES` edges form DAGs (Directed Acyclic Graphs).
29
+ - Cycle detection runs via DFS before any `CAUSED_BY` or `SUPERSEDES` edge creation.
30
+ - If a cycle is detected: the edge creation is rejected and logged.
31
+ - `RELATED_TO` and `INFORMS` edges are allowed to be cyclical (they are undirected semantics).
32
+
33
+ ## Edge Type Semantics
34
+
35
+ | Type | Direction | Meaning | Auto-Created |
36
+ |:---|:---|:---|:---|
37
+ | `RELATED_TO` | Bidirectional | Semantic similarity ≥ 0.65 | Yes |
38
+ | `CAUSED_BY` | Source → Target | Bug pattern caused by root cause | Yes (capture) |
39
+ | `SUPERSEDES` | New → Old | New decision replaces old decision | Manual only |
40
+ | `DEPENDS_ON` | Dependent → Dependency | Pattern requires another pattern | Manual only |
41
+ | `INFORMS` | Decision → Knowledge | Decision informed by domain knowledge | Yes (capture) |
42
+ | `CONTRADICTS` | Bidirectional | Conflicting knowledge entries | Manual only |
43
+
44
+ ## Auto-Shadow Protocol
45
+
46
+ ### Trigger Conditions
47
+
48
+ Auto-Shadow MUST be invoked:
49
+
50
+ 1. Before every subagent spawn (via context-injector)
51
+ 2. At session boot (via session-memory-loader, after hot context load)
52
+ 3. On explicit `/mindforge:remember --shadow` calls
53
+
54
+ ### Budget Constraints
55
+
56
+ - Maximum shadow section size: **2KB** (~8000 characters)
57
+ - Maximum shadow items: **5 entries**
58
+ - Minimum combined score: **0.35** (below this, entry is excluded)
59
+ - Entries already in Hot/Warm context are excluded (no duplication)
60
+
61
+ ### Security Guards
62
+
63
+ Auto-Shadow MUST NEVER include:
64
+
65
+ - Entries containing passwords, API keys, or credentials
66
+ - Entries matching patterns: `/[a-z0-9]{32,}/`, `/-----BEGIN/`, `/sk_[a-z]+_/`
67
+ - Entries with `type: 'secret'` or tags including `secret` or `credential`
68
+ - Deprecated entries
69
+
70
+ ### Contradiction Handling
71
+
72
+ - If two shadow items have a `CONTRADICTS` edge between them:
73
+ - Both items are included but flagged with ⚠️ prefix
74
+ - The higher-confidence entry is displayed first
75
+ - The agent is instructed: "These entries may conflict — verify with user"
76
+
77
+ ## Edge Weight Lifecycle
78
+
79
+ ### Reinforcement
80
+
81
+ - Traversal: +0.1 weight (capped at 2.0)
82
+ - Each reinforcement updates `last_traversed` and increments `traversal_count`
83
+ - When a node is reinforced (knowledge-store), its top 3 edges are also reinforced
84
+
85
+ ### Decay
86
+
87
+ - Edges not traversed in 30 days lose 10% weight per decay cycle
88
+ - Edges that decay to weight ≤ 0.1 are automatically deprecated
89
+ - Decay runs on `/mindforge:complete-milestone` or explicit `/mindforge:remember --gc`
90
+
91
+ ### Pruning
92
+
93
+ - Deprecated edges are retained in the JSONL for audit trail
94
+ - Graph compaction (removing deprecated entries from the file) runs only on explicit request
95
+ - Orphan nodes are reported but never auto-deleted
96
+
97
+ ## Embedding Cache
98
+
99
+ - Cache path: `.mindforge/memory/embeddings.json`
100
+ - Cache is rebuilt when knowledge-base.jsonl changes (detected by entry count mismatch)
101
+ - Cache format includes `schema_version` for forward compatibility
102
+ - Corrupted cache is silently rebuilt — never crash on cache errors
103
+
104
+ ## Performance Guarantees
105
+
106
+ | Operation | Target | Measured at |
107
+ |:---|:---|:---|
108
+ | Full embedding rebuild | < 200ms | 1K entries |
109
+ | Single cosine similarity | < 1ms | Any |
110
+ | Auto-edge inference | < 100ms | 1K entries |
111
+ | Graph traversal (2-hop) | < 50ms | 500 edges |
112
+ | Auto-shadow generation | < 500ms | 1K entries + 500 edges |
113
+
114
+ ## AUDIT Integration
115
+
116
+ All graph operations emit AUDIT entries:
117
+
118
+ ```json
119
+ {
120
+ "event": "knowledge_graph_operation",
121
+ "operation": "add_edge | deprecate_edge | auto_shadow | decay | cycle_detected",
122
+ "details": { ... },
123
+ "timestamp": "<ISO-8601>"
124
+ }
125
+ ```
@@ -0,0 +1,53 @@
1
+ # MindForge Engine — Semantic Shard Controller
2
+
3
+ ## Purpose
4
+ Manage the tiered storage of session context items to maintain high reasoning performance while minimizing token waste.
5
+
6
+ ## 1. The Tri-Tier Memory Model
7
+
8
+ | Tier | Storage Location | Retention Scope | Content Type |
9
+ | :--- | :--- | :--- | :--- |
10
+ | **Hot** | `HANDOFF.json` | 1-2 Sessions | Active tasks, current file offsets, uncommitted intent. |
11
+ | **Warm** | `.planning/memories/WARM-SHARD-N.jsonl` | Phase/Milestone | Decisions with rationale, discoveries, implicit quirks. |
12
+ | **Cold** | `.mindforge/memory/*.jsonl` | Project Life | Architecture patterns, global team preferences, recurring bugs. |
13
+
14
+ ## 2. Semantic Relevance Density (SRD) Scoring
15
+
16
+ Every context item (Decision, Discovery, Task Result) is scored before compaction using the following formula:
17
+
18
+ **SRD = (D * 0.6) + (F * 0.1) + (I * 0.3)**
19
+
20
+ - **D (Decisiveness)**: 1.0 for terminal decisions (ADRs), 0.5 for transient discoveries.
21
+ - **F (Frequency)**: Count of references in the last 10 tool calls (normalized 0-1).
22
+ - **I (Impact)**: 1.0 for security/core-logic, 0.5 for UI/Docs, 0.1 for housekeeping.
23
+
24
+ ### Tier Routing Gates
25
+ - **SRD > 0.8**: Tier 1 (Hot) -> Retain in `HANDOFF.json`.
26
+ - **0.4 <= SRD <= 0.8**: Tier 2 (Warm) -> Move to `WARM-SHARD-N.jsonl`.
27
+ - **SRD < 0.4**: Tier 3 (Cold/Drop) -> Archive to `.mindforge/memory` or drop if redundant.
28
+
29
+ ## 3. Shard Management Logic
30
+
31
+ ### On Compaction Trigger (70% Context)
32
+ 1. Invoke `bin/shard-helper.js --analyse` to generate SRD scores.
33
+ 2. Filter items by SRD.
34
+ 3. Append Warm items to `.planning/memories/WARM-SHARD-N.jsonl`.
35
+ 4. Update `HANDOFF.json` with only the Hot items.
36
+ 5. Record `sharding_completed` in `AUDIT.jsonl`.
37
+
38
+ ### On Session Restart
39
+ 1. Load `HANDOFF.json`.
40
+ 2. Locate `WARM-SHARD-N.jsonl` for the current phase.
41
+ 3. Perform **Semantic Retrieval**: Load top 5 most relevant Warm items based on the `next_task` description.
42
+ 4. Load top 3 most relevant Cold items from the Knowledge Graph.
43
+
44
+ ## 4. Governance & Constraints
45
+ - **Security First**: Never shard secrets or credentials (enforced by Gate 3).
46
+ - **Deduplication**: Before appending to a shard, check for identical `topic` or `id` to avoid context cycles.
47
+ - **Pruning**: Warm shards are archived to Cold storage upon Phase Completion.
48
+
49
+ ## 5. Beast Mode — Enterprise Hardening
50
+ - **Temporal Integrity**: Every shard entry must contain a `sha256` checksum. `bin/shard-helper.js --verify` ensures zero corruption.
51
+ - **Semantic Indexing**: Shards are tagged automatically during compaction for O(1) keyword retrieval.
52
+ - **Hindsight Injection**: If a "Warm" decision is corrected in a later session, the shard is updated with a `superseded_by` pointer.
53
+ - **Atomic Writes**: Shard appends are followed by a `fsync` to ensure durability.
@@ -0,0 +1,40 @@
1
+ # Temporal Vision & Hindsight Protocol (v3.0.0)
2
+
3
+ ## Overview
4
+ Temporal Vision enables high-fidelity "Time-Travel Debugging" by snapshotting the `.planning/` directory at every significant audit point. Hindsight Injection allows agents to learn from past failures by rolling back state and re-executing waves with injected corrections.
5
+
6
+ ## Snapshot Rules
7
+ 1. **Triggering**: Snapshots MUST be triggered on any `state-changing` audit event:
8
+ - `auto_mode_started`
9
+ - `phase_planned`
10
+ - `task_completed`
11
+ - `hindsight_injected`
12
+ 2. **Persistence**: Snapshots are stored in `.planning/history/[audit_id]/`.
13
+ 3. **Retention**: The system retains snapshots for the current milestone. Completed milestones should be archived or purged using `/mindforge:temporal --cleanup`.
14
+
15
+ ## Hindsight Injection Protocol
16
+ Hindsight Injection is a powerful tool and must be used according to these safety rules:
17
+
18
+ ### 1. Identify the Failure Coordinate ($T_n$)
19
+ - Use the Dashboard Temporal Slider to find the exact audit entry where the "architectural drift" or "logic failure" occurred.
20
+
21
+ ### 2. Inject the Correction
22
+ - The correction must be a concise "Steering Instruction" (e.g., "The database schema should use UUID instead of INT").
23
+ - The system will:
24
+ - Rollback `.planning/` to $T_n$.
25
+ - Append the `hindsight_injected` event.
26
+ - Set state to `awaiting_regeneration`.
27
+
28
+ ### 3. Verification
29
+ - After injection, the `AutoRunner` will re-trigger the wave.
30
+ - The agent must verify that the new execution path resolves the original failure.
31
+
32
+ ## Security Controls
33
+ - **Integrity**: Each snapshot includes a `SNAPSHOT-META.json` with a timestamp and file list.
34
+ - **Local-Only**: Rollback APIs are restricted to 127.0.0.1 ( localhost) to prevent remote state manipulation.
35
+ - **Atomic Operations**: History restoration uses synchronous file copies to prevent partial state corruption.
36
+
37
+ ## Common Operations
38
+ - `GET /api/temporal/history`: View the timeline.
39
+ - `POST /api/temporal/inject`: Perform hindsight repair.
40
+ - `/mindforge:temporal --status`: Check history size and snapshot count.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: mf-executor
3
+ description: Implementation specialist focused on high-fidelity execution of provided plans and code completion.
4
+ tools: Read, Write, Bash, multi_replace_file_content
5
+ color: orange
6
+ ---
7
+
8
+ <role>
9
+ You are the **MF-Executor**. You implement assigned tasks with precision, following the orchestrator's Source of Truth.
10
+ </role>
11
+
12
+ <responsibilities>
13
+ - Implement code changes accurately based on the planner's source
14
+ - Follow provided architectural patterns and constraints
15
+ - Provide detailed implementation notes and status reports
16
+ - Ensure all changes are verified and functional
17
+ </responsibilities>
18
+
19
+ <process>
20
+ 1. **Task Loading**: Internalize the specifics of the current plan.
21
+ 2. **Context Retrieval**: Read all relevant files and documentation.
22
+ 3. **High-Fidelity Implementation**: Apply changes exactly as planned.
23
+ </process>
24
+
25
+ <rules>
26
+ - Do not deviate from the plan without explicit approval.
27
+ - Do not make architectural decisions; follow existing patterns.
28
+ - Keep implementation clean, maintainable, and aligned with project standards.
29
+ </rules>
30
+
31
+ <output_format>
32
+ ```json
33
+ {
34
+ "task_id": "[ID]",
35
+ "status": "completed | failed",
36
+ "output": "[Success criteria or error message]",
37
+ "notes": "[What was implemented]"
38
+ }
39
+ ```
40
+ </output_format>
@@ -0,0 +1,33 @@
1
+ ---
2
+ name: mf-memory
3
+ description: Long-term memory management and knowledge graph synchronization for persistent context.
4
+ tools: Read, Write, commit_memory (Skill-based)
5
+ color: cyan
6
+ ---
7
+
8
+ <role>
9
+ You are the **MF-Memory**. You manage the framework's persistence layer, capturing decisions and learnings.
10
+ </role>
11
+
12
+ <responsibilities>
13
+ - Extract and store decisions and architectural choices
14
+ - Update the Knowledge Graph with new patterns and relationships
15
+ - Maintain structured handoffs between sessions
16
+ - Promote project-level patterns to global framework memory
17
+ </responsibilities>
18
+
19
+ <rules>
20
+ - Maintain strict structure; avoid data duplication.
21
+ - Prioritize clear, reusable insights over logs.
22
+ - Link related decisions to provide historical context.
23
+ </rules>
24
+
25
+ <output_format>
26
+ ```json
27
+ {
28
+ "memory_update": "[Description of new memory entry]",
29
+ "patterns": ["[Pattern1]", "[Pattern2]"],
30
+ "links": ["[RelatedDecisionID1]", "[RelatedNodeID2]"]
31
+ }
32
+ ```
33
+ </output_format>