memorix 1.2.1 → 1.2.2

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 (199) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +14 -2
  3. package/README.zh-CN.md +14 -2
  4. package/TEAM.md +86 -86
  5. package/dist/cli/index.js +15407 -13779
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/index.js +1321 -529
  8. package/dist/index.js.map +1 -1
  9. package/dist/maintenance-runner.d.ts +1 -1
  10. package/dist/maintenance-runner.js +8458 -8087
  11. package/dist/maintenance-runner.js.map +1 -1
  12. package/dist/memcode-runtime/CHANGELOG.md +16 -0
  13. package/dist/sdk.d.ts +7 -2
  14. package/dist/sdk.js +1349 -535
  15. package/dist/sdk.js.map +1 -1
  16. package/dist/types.d.ts +49 -1
  17. package/dist/types.js.map +1 -1
  18. package/docs/1.2.2-MEMORY-CONTROL-PLANE.md +434 -0
  19. package/docs/AGENT_OPERATOR_PLAYBOOK.md +4 -0
  20. package/docs/API_REFERENCE.md +24 -4
  21. package/docs/DESIGN_DECISIONS.md +357 -357
  22. package/docs/README.md +1 -1
  23. package/docs/dev-log/progress.txt +91 -11
  24. package/package.json +1 -1
  25. package/plugins/codex/memorix/.codex-plugin/plugin.json +1 -1
  26. package/src/audit/index.ts +156 -156
  27. package/src/cli/command-guide.ts +192 -0
  28. package/src/cli/commands/audit-list.ts +89 -89
  29. package/src/cli/commands/audit.ts +9 -4
  30. package/src/cli/commands/background.ts +659 -659
  31. package/src/cli/commands/cleanup.ts +5 -1
  32. package/src/cli/commands/codegraph.ts +15 -5
  33. package/src/cli/commands/context.ts +3 -2
  34. package/src/cli/commands/doctor.ts +4 -2
  35. package/src/cli/commands/explain.ts +9 -3
  36. package/src/cli/commands/formation.ts +48 -48
  37. package/src/cli/commands/git-hook-install.ts +111 -111
  38. package/src/cli/commands/handoff.ts +75 -61
  39. package/src/cli/commands/hooks-status.ts +63 -63
  40. package/src/cli/commands/identity.ts +116 -0
  41. package/src/cli/commands/ingest-commit.ts +153 -153
  42. package/src/cli/commands/ingest-image.ts +71 -69
  43. package/src/cli/commands/ingest-log.ts +180 -180
  44. package/src/cli/commands/ingest.ts +44 -44
  45. package/src/cli/commands/integrate-shared.ts +15 -15
  46. package/src/cli/commands/lock.ts +93 -92
  47. package/src/cli/commands/memory.ts +58 -21
  48. package/src/cli/commands/message.ts +123 -118
  49. package/src/cli/commands/operator-shared.ts +98 -3
  50. package/src/cli/commands/poll.ts +74 -64
  51. package/src/cli/commands/purge-all-memory.ts +85 -85
  52. package/src/cli/commands/purge-project-memory.ts +83 -83
  53. package/src/cli/commands/reasoning.ts +135 -121
  54. package/src/cli/commands/retention.ts +9 -4
  55. package/src/cli/commands/serve-http.ts +8 -2
  56. package/src/cli/commands/serve-shared.ts +118 -118
  57. package/src/cli/commands/session.ts +29 -3
  58. package/src/cli/commands/skills.ts +124 -119
  59. package/src/cli/commands/status.ts +4 -3
  60. package/src/cli/commands/task.ts +193 -184
  61. package/src/cli/commands/team.ts +14 -10
  62. package/src/cli/commands/transfer.ts +108 -55
  63. package/src/cli/commands/uninstall-project-artifacts.ts +85 -85
  64. package/src/cli/identity.ts +89 -0
  65. package/src/cli/index.ts +96 -19
  66. package/src/cli/invocation.ts +115 -0
  67. package/src/cli/tui/ChatView.tsx +234 -234
  68. package/src/cli/tui/CommandBar.tsx +312 -312
  69. package/src/cli/tui/ContextRail.tsx +118 -118
  70. package/src/cli/tui/HeaderBar.tsx +72 -72
  71. package/src/cli/tui/LogoBanner.tsx +51 -51
  72. package/src/cli/tui/Sidebar.tsx +179 -179
  73. package/src/cli/tui/chat-service.ts +41 -18
  74. package/src/cli/tui/data.ts +23 -44
  75. package/src/cli/tui/index.ts +41 -41
  76. package/src/cli/tui/markdown-render.tsx +371 -371
  77. package/src/cli/tui/operator-context.ts +60 -0
  78. package/src/cli/tui/use-mouse.ts +157 -157
  79. package/src/cli/tui/useNavigation.ts +56 -56
  80. package/src/cli/tui/views/MemoryView.tsx +10 -8
  81. package/src/cli/update-checker.ts +211 -211
  82. package/src/cli/version.ts +7 -7
  83. package/src/cli/workbench.ts +1 -1
  84. package/src/codegraph/auto-context.ts +31 -2
  85. package/src/codegraph/context-pack.ts +1 -0
  86. package/src/codegraph/project-context.ts +2 -0
  87. package/src/compact/engine.ts +26 -10
  88. package/src/compact/index-format.ts +25 -2
  89. package/src/compact/token-budget.ts +74 -74
  90. package/src/dashboard/project-classification.ts +64 -64
  91. package/src/dashboard/server.ts +46 -9
  92. package/src/embedding/fastembed-provider.ts +142 -142
  93. package/src/embedding/transformers-provider.ts +111 -111
  94. package/src/git/extractor.ts +209 -209
  95. package/src/git/hooks-path.ts +85 -85
  96. package/src/hooks/admission.ts +117 -0
  97. package/src/hooks/handler.ts +98 -91
  98. package/src/hooks/pattern-detector.ts +173 -173
  99. package/src/hooks/significance-filter.ts +250 -250
  100. package/src/knowledge/context-assembly.ts +97 -0
  101. package/src/knowledge/workset.ts +179 -10
  102. package/src/llm/memory-manager.ts +328 -328
  103. package/src/llm/provider.ts +885 -885
  104. package/src/llm/quality.ts +248 -248
  105. package/src/memory/admission.ts +57 -0
  106. package/src/memory/attribution-guard.ts +249 -249
  107. package/src/memory/consolidation.ts +13 -2
  108. package/src/memory/disclosure-policy.ts +140 -135
  109. package/src/memory/entity-extractor.ts +197 -197
  110. package/src/memory/export-import.ts +11 -3
  111. package/src/memory/formation/evaluate.ts +217 -217
  112. package/src/memory/formation/extract.ts +361 -361
  113. package/src/memory/formation/index.ts +417 -417
  114. package/src/memory/formation/resolve.ts +344 -344
  115. package/src/memory/formation/types.ts +315 -315
  116. package/src/memory/freshness.ts +122 -122
  117. package/src/memory/graph-context.ts +8 -2
  118. package/src/memory/graph.ts +197 -197
  119. package/src/memory/observations.ts +162 -4
  120. package/src/memory/quality-audit.ts +2 -0
  121. package/src/memory/refs.ts +94 -94
  122. package/src/memory/retention.ts +22 -2
  123. package/src/memory/secret-filter.ts +79 -79
  124. package/src/memory/session.ts +5 -2
  125. package/src/memory/visibility.ts +80 -0
  126. package/src/multimodal/image-loader.ts +143 -143
  127. package/src/orchestrate/adapters/claude-stream.ts +192 -192
  128. package/src/orchestrate/adapters/claude.ts +111 -111
  129. package/src/orchestrate/adapters/codex-stream.ts +134 -134
  130. package/src/orchestrate/adapters/codex.ts +41 -41
  131. package/src/orchestrate/adapters/gemini-stream.ts +166 -166
  132. package/src/orchestrate/adapters/gemini.ts +42 -42
  133. package/src/orchestrate/adapters/index.ts +73 -73
  134. package/src/orchestrate/adapters/opencode-stream.ts +143 -143
  135. package/src/orchestrate/adapters/opencode.ts +47 -47
  136. package/src/orchestrate/adapters/spawn-helper.ts +286 -286
  137. package/src/orchestrate/adapters/types.ts +77 -77
  138. package/src/orchestrate/capability-router.ts +284 -284
  139. package/src/orchestrate/context-compact.ts +188 -188
  140. package/src/orchestrate/cost-tracker.ts +219 -219
  141. package/src/orchestrate/error-recovery.ts +191 -191
  142. package/src/orchestrate/evidence.ts +140 -140
  143. package/src/orchestrate/ledger.ts +110 -110
  144. package/src/orchestrate/memorix-bridge.ts +378 -340
  145. package/src/orchestrate/output-budget.ts +80 -80
  146. package/src/orchestrate/permission.ts +152 -152
  147. package/src/orchestrate/pipeline-trace.ts +131 -131
  148. package/src/orchestrate/prompt-builder.ts +155 -155
  149. package/src/orchestrate/ring-buffer.ts +37 -37
  150. package/src/orchestrate/task-graph.ts +389 -389
  151. package/src/orchestrate/worktree.ts +232 -232
  152. package/src/project/aliases.ts +374 -374
  153. package/src/project/detector.ts +268 -268
  154. package/src/rules/adapters/claude-code.ts +99 -99
  155. package/src/rules/adapters/codex.ts +97 -97
  156. package/src/rules/adapters/copilot.ts +124 -124
  157. package/src/rules/adapters/cursor.ts +114 -114
  158. package/src/rules/adapters/kiro.ts +126 -126
  159. package/src/rules/adapters/trae.ts +56 -56
  160. package/src/rules/adapters/windsurf.ts +83 -83
  161. package/src/rules/syncer.ts +235 -235
  162. package/src/runtime/control-plane-maintenance.ts +1 -0
  163. package/src/runtime/isolated-maintenance.ts +1 -0
  164. package/src/runtime/lifecycle.ts +18 -0
  165. package/src/runtime/maintenance-jobs.ts +1 -0
  166. package/src/runtime/maintenance-runner.ts +2 -0
  167. package/src/runtime/project-maintenance.ts +89 -0
  168. package/src/sdk.ts +334 -304
  169. package/src/search/intent-detector.ts +289 -289
  170. package/src/search/query-expansion.ts +52 -52
  171. package/src/server/formation-timeout.ts +27 -27
  172. package/src/server.ts +260 -81
  173. package/src/skills/mini-skills.ts +386 -386
  174. package/src/store/chat-store.ts +119 -119
  175. package/src/store/graph-store.ts +249 -249
  176. package/src/store/mini-skill-store.ts +349 -349
  177. package/src/store/orama-store.ts +61 -6
  178. package/src/store/persistence-json.ts +212 -212
  179. package/src/store/persistence.ts +291 -291
  180. package/src/store/project-affinity.ts +195 -195
  181. package/src/store/sqlite-db.ts +23 -1
  182. package/src/store/sqlite-store.ts +12 -2
  183. package/src/team/event-bus.ts +76 -76
  184. package/src/team/file-locks.ts +173 -173
  185. package/src/team/handoff.ts +168 -161
  186. package/src/team/messages.ts +203 -203
  187. package/src/team/poll.ts +132 -132
  188. package/src/team/tasks.ts +211 -211
  189. package/src/types.ts +51 -0
  190. package/src/wiki/generator.ts +2 -0
  191. package/src/workspace/mcp-adapters/codex.ts +191 -191
  192. package/src/workspace/mcp-adapters/copilot.ts +105 -105
  193. package/src/workspace/mcp-adapters/cursor.ts +53 -53
  194. package/src/workspace/mcp-adapters/kiro.ts +64 -64
  195. package/src/workspace/mcp-adapters/opencode.ts +123 -123
  196. package/src/workspace/mcp-adapters/trae.ts +134 -134
  197. package/src/workspace/mcp-adapters/windsurf.ts +91 -91
  198. package/src/workspace/sanitizer.ts +60 -60
  199. package/src/workspace/workflow-sync.ts +131 -131
package/dist/types.d.ts CHANGED
@@ -47,6 +47,30 @@ type ObservationType = 'session-request' | 'gotcha' | 'problem-solution' | 'how-
47
47
  declare const OBSERVATION_ICONS: Record<ObservationType, string>;
48
48
  /** Observation lifecycle status */
49
49
  type ObservationStatus = 'active' | 'resolved' | 'archived';
50
+ /**
51
+ * Control-plane admission state for automatically captured observations.
52
+ * Candidate and ephemeral records remain inspectable, but only qualified
53
+ * records are eligible for automatic context delivery. Missing state preserves
54
+ * legacy behavior for observations written before this policy existed.
55
+ */
56
+ type ObservationAdmissionState = 'ephemeral' | 'candidate' | 'qualified';
57
+ /**
58
+ * Who may retrieve an observation through agent-facing memory surfaces.
59
+ * Missing visibility is a legacy record and resolves to `project`.
60
+ */
61
+ type ObservationVisibility = 'personal' | 'project' | 'team';
62
+ /**
63
+ * Identity available to an agent-facing retrieval call. Internal maintenance
64
+ * deliberately omits this and may inspect all project records for lifecycle work.
65
+ */
66
+ interface ObservationReader {
67
+ /** Bound project for a normal project-scoped call. Omit only for explicit global search. */
68
+ projectId?: string;
69
+ /** Stable coordination identity, available after an explicit team join. */
70
+ agentId?: string;
71
+ /** True only when agentId is an active member of the bound project team. */
72
+ isTeamMember?: boolean;
73
+ }
50
74
  /** Progress tracking for task/feature observations */
51
75
  interface ProgressInfo {
52
76
  feature: string;
@@ -93,6 +117,14 @@ interface Observation {
93
117
  sourceDetail?: 'explicit' | 'hook' | 'git-ingest';
94
118
  /** Value category from formation pipeline evaluation */
95
119
  valueCategory?: 'core' | 'contextual' | 'ephemeral';
120
+ /** Control-plane admission state for automatic capture and delivery. */
121
+ admissionState?: ObservationAdmissionState;
122
+ /** Short, sanitized explanation for the latest admission decision. */
123
+ admissionReason?: string;
124
+ /** Retrieval scope. Legacy records without a value remain project-visible. */
125
+ visibility?: ObservationVisibility;
126
+ /** Explicit additional readers for a personal record, used by targeted handoffs. */
127
+ sharedWithAgentIds?: string[];
96
128
  /** Phase 4a: Agent ID that created this observation (team attribution) */
97
129
  createdByAgentId?: string;
98
130
  /** Phase 4a: Monotonic write generation — snapshot of storage_generation at write time (watermark coherence) */
@@ -127,6 +159,10 @@ interface IndexEntry {
127
159
  sourceDetail?: 'explicit' | 'hook' | 'git-ingest';
128
160
  /** Value category for source-aware ranking */
129
161
  valueCategory?: 'core' | 'contextual' | 'ephemeral';
162
+ /** Control-plane admission state when known. */
163
+ admissionState?: ObservationAdmissionState;
164
+ /** Retrieval scope when known. */
165
+ visibility?: ObservationVisibility;
130
166
  /** Explainable recall: why this result matched. */
131
167
  matchedFields?: string[];
132
168
  /** Entity name — used for entity-affinity scoring and workstream deduplication. */
@@ -164,6 +200,8 @@ interface SearchOptions {
164
200
  source?: 'agent' | 'git' | 'manual';
165
201
  /** Internal observability probes can disable access tracking without affecting normal search behavior. */
166
202
  trackAccess?: boolean;
203
+ /** Internal reader context for agent-facing visibility filtering. */
204
+ reader?: ObservationReader;
167
205
  }
168
206
  /** Topic key family heuristics for suggesting stable topic keys */
169
207
  declare const TOPIC_KEY_FAMILIES: Record<string, string[]>;
@@ -193,6 +231,16 @@ interface MemorixDocument {
193
231
  sourceDetail?: string;
194
232
  /** Value category from formation evaluation */
195
233
  valueCategory?: string;
234
+ /** Control-plane admission state for automatic capture and delivery. */
235
+ admissionState?: string;
236
+ /** Short, sanitized explanation for the latest admission decision. */
237
+ admissionReason?: string;
238
+ /** Retrieval scope for agent-facing filtering. */
239
+ visibility?: string;
240
+ /** Agent that owns a personal record, or authored a shared record. */
241
+ createdByAgentId?: string;
242
+ /** Explicit readers for a targeted personal record. */
243
+ sharedWithAgentIds?: string;
196
244
  /** Optional vector embedding for semantic/hybrid retrieval */
197
245
  embedding?: number[];
198
246
  /** Document type: observation or mini-skill (Phase 3a) */
@@ -398,4 +446,4 @@ interface MCPConfigAdapter {
398
446
  getConfigPath(projectRoot?: string): string;
399
447
  }
400
448
 
401
- export { type AgentTarget, DEFAULT_CONFIG, type DetectionFailure, type DetectionFailureReason, type DetectionResult, type DocumentType, type Entity, type IndexEntry, type KnowledgeGraph, type KnowledgeLayer, type MCPConfigAdapter, type MCPServerEntry, type MemorixConfig, type MemorixDocument, type MemoryRef, type MiniSkill, OBSERVATION_ICONS, type Observation, type ObservationRef, type ObservationStatus, type ObservationType, type ProgressInfo, type ProjectInfo, type Relation, type RuleFormatAdapter, type RuleSource, type SearchOptions, type Session, type SkillConflict, type SkillEntry, type SnapshotObservation, type SourceSnapshot, TOPIC_KEY_FAMILIES, type TimelineContext, type UnifiedRule, type WorkflowEntry, type WorkspaceSyncResult };
449
+ export { type AgentTarget, DEFAULT_CONFIG, type DetectionFailure, type DetectionFailureReason, type DetectionResult, type DocumentType, type Entity, type IndexEntry, type KnowledgeGraph, type KnowledgeLayer, type MCPConfigAdapter, type MCPServerEntry, type MemorixConfig, type MemorixDocument, type MemoryRef, type MiniSkill, OBSERVATION_ICONS, type Observation, type ObservationAdmissionState, type ObservationReader, type ObservationRef, type ObservationStatus, type ObservationType, type ObservationVisibility, type ProgressInfo, type ProjectInfo, type Relation, type RuleFormatAdapter, type RuleSource, type SearchOptions, type Session, type SkillConflict, type SkillEntry, type SnapshotObservation, type SourceSnapshot, TOPIC_KEY_FAMILIES, type TimelineContext, type UnifiedRule, type WorkflowEntry, type WorkspaceSyncResult };
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Memorix Core Types\n *\n * Data model sources:\n * - Entity/Relation/KnowledgeGraph: MCP Official Memory Server (v0.6.3)\n * - Observation/ObservationType: claude-mem Progressive Disclosure\n * - UnifiedRule/RuleSource: Memorix original (rules sync)\n *\n * Designed for extensibility: new agent formats (Kiro, Copilot, Antigravity)\n * can be added by extending RuleSource and adding format adapters.\n */\n\n// ============================================================\n// Knowledge Graph (adopted from MCP Official Memory Server)\n// ============================================================\n\n/** A node in the knowledge graph representing a concept, component, or config */\nexport interface Entity {\n name: string;\n entityType: string;\n observations: string[];\n}\n\n/** A directed edge between two entities */\nexport interface Relation {\n from: string;\n to: string;\n relationType: string;\n}\n\n/** The complete knowledge graph */\nexport interface KnowledgeGraph {\n entities: Entity[];\n relations: Relation[];\n}\n\n// ============================================================\n// Observation (adopted from claude-mem Progressive Disclosure)\n// ============================================================\n\n/**\n * Observation type classification using claude-mem's icon-based legend system.\n *\n * Icon mapping:\n * [SESSION] session-request — User's original goal\n * [GOTCHA] gotcha — Critical pitfall / trap\n * [FIX] problem-solution — Bug fix or workaround\n * [INFO] how-it-works — Technical explanation\n * [CHANGE] what-changed — Code/architecture change\n * [DISCOVERY] discovery — New learning or insight\n * [WHY] why-it-exists — Design rationale\n * [DECISION] decision — Architecture decision\n * [TRADEOFF] trade-off — Deliberate compromise\n * [REASONING] reasoning — Why this approach was chosen (System 2 reasoning trace)\n * [PROBE] probe — Operational heartbeat / connectivity check (short-lived, excluded from default search)\n */\nexport type ObservationType =\n | 'session-request'\n | 'gotcha'\n | 'problem-solution'\n | 'how-it-works'\n | 'what-changed'\n | 'discovery'\n | 'why-it-exists'\n | 'decision'\n | 'trade-off'\n | 'reasoning'\n | 'probe';\n\n/** Map from ObservationType to display icon */\nexport const OBSERVATION_ICONS: Record<ObservationType, string> = {\n 'session-request': '[SESSION]',\n 'gotcha': '[GOTCHA]',\n 'problem-solution': '[FIX]',\n 'how-it-works': '[INFO]',\n 'what-changed': '[CHANGE]',\n 'discovery': '[DISCOVERY]',\n 'why-it-exists': '[WHY]',\n 'decision': '[DECISION]',\n 'trade-off': '[TRADEOFF]',\n 'reasoning': '[REASONING]',\n 'probe': '[PROBE]',\n};\n\n/** Observation lifecycle status */\nexport type ObservationStatus = 'active' | 'resolved' | 'archived';\n\n/** Progress tracking for task/feature observations */\nexport interface ProgressInfo {\n feature: string;\n status: 'in-progress' | 'completed' | 'blocked';\n completion?: number;\n}\n\n/** A rich observation record attached to an entity */\nexport interface Observation {\n id: number;\n entityName: string;\n type: ObservationType;\n title: string;\n narrative: string;\n facts: string[];\n filesModified: string[];\n concepts: string[];\n tokens: number;\n createdAt: string;\n updatedAt?: string;\n projectId: string;\n /** Whether the observation contains causal language (because, due to, etc.) */\n hasCausalLanguage?: boolean;\n /** Optional topic key for upsert — same project+topicKey updates existing observation */\n topicKey?: string;\n /** How many times this observation was revised via topic key upsert (starts at 1) */\n revisionCount?: number;\n /** Session ID this observation belongs to */\n sessionId?: string;\n /** Lifecycle status: active (default) → resolved → archived */\n status?: ObservationStatus;\n /** ID of the observation that superseded this one (set when auto-resolved by topicKey upsert) */\n supersededBy?: number;\n /** Progress tracking for task/feature observations */\n progress?: ProgressInfo;\n /** Origin of this observation: agent (IDE hooks/MCP), git (commit ingest), manual (CLI) */\n source?: 'agent' | 'git' | 'manual';\n /** Git commit hash if source is 'git' */\n commitHash?: string;\n /** Related commit hashes — links reasoning memories to the commits they explain */\n relatedCommits?: string[];\n /** Related entity names — explicit cross-references to other memory entities */\n relatedEntities?: string[];\n /** Provenance detail: how this observation entered the system */\n sourceDetail?: 'explicit' | 'hook' | 'git-ingest';\n /** Value category from formation pipeline evaluation */\n valueCategory?: 'core' | 'contextual' | 'ephemeral';\n /** Phase 4a: Agent ID that created this observation (team attribution) */\n createdByAgentId?: string;\n /** Phase 4a: Monotonic write generation — snapshot of storage_generation at write time (watermark coherence) */\n writeGeneration?: number;\n}\n\n// ============================================================\n// Session Lifecycle (inspired by Engram's session management)\n// ============================================================\n\n/** A coding session tracked by Memorix */\nexport interface Session {\n id: string;\n projectId: string;\n startedAt: string;\n endedAt?: string;\n summary?: string;\n status: 'active' | 'completed';\n /** Agent/IDE that started this session */\n agent?: string;\n}\n\n// ============================================================\n// Compact Engine (adopted from claude-mem 3-layer workflow)\n// ============================================================\n\n/** L1 index entry — lightweight, ~50-100 tokens per result */\nexport interface IndexEntry {\n id: number;\n time: string;\n type: ObservationType;\n icon: string;\n title: string;\n tokens: number;\n /** Relevance score from search (time-decayed). Used by compact engine. */\n score?: number;\n /** Project that owns this observation. Needed to disambiguate global results. */\n projectId?: string;\n /** Origin of the memory for source-aware retrieval and display. */\n source?: 'agent' | 'git' | 'manual';\n /** Provenance detail for source-aware display */\n sourceDetail?: 'explicit' | 'hook' | 'git-ingest';\n /** Value category for source-aware ranking */\n valueCategory?: 'core' | 'contextual' | 'ephemeral';\n /** Explainable recall: why this result matched. */\n matchedFields?: string[];\n /** Entity name — used for entity-affinity scoring and workstream deduplication. */\n entityName?: string;\n /** Document type: observation or mini-skill (Phase 3a) */\n documentType?: DocumentType;\n /** Knowledge layer for layer-aware ranking (Phase 3a) */\n knowledgeLayer?: KnowledgeLayer;\n}\n\n/** Explicit reference to an observation, optionally scoped to a project. */\nexport interface ObservationRef {\n id: number;\n projectId?: string;\n}\n\n/** L2 timeline context — observations around an anchor */\nexport interface TimelineContext {\n anchorId: number;\n anchorEntry: IndexEntry | null;\n before: IndexEntry[];\n after: IndexEntry[];\n}\n\n/** Search options for the compact engine */\nexport interface SearchOptions {\n query: string;\n limit?: number;\n type?: ObservationType;\n projectId?: string;\n since?: string;\n until?: string;\n /** Token budget — trim results to fit within this many tokens (0 = unlimited) */\n maxTokens?: number;\n /** Filter by observation status. Default: 'active' (only show active memories) */\n status?: ObservationStatus | 'all';\n /** Filter by observation source: 'agent', 'git', 'manual', or undefined for all */\n source?: 'agent' | 'git' | 'manual';\n /** Internal observability probes can disable access tracking without affecting normal search behavior. */\n trackAccess?: boolean;\n}\n\n/** Topic key family heuristics for suggesting stable topic keys */\nexport const TOPIC_KEY_FAMILIES: Record<string, string[]> = {\n 'architecture': ['architecture', 'design', 'adr', 'structure', 'pattern'],\n 'bug': ['bugfix', 'fix', 'error', 'regression', 'crash', 'problem-solution'],\n 'decision': ['decision', 'trade-off', 'choice', 'strategy'],\n 'config': ['config', 'setup', 'env', 'environment', 'deployment'],\n 'discovery': ['discovery', 'learning', 'insight', 'gotcha'],\n 'pattern': ['pattern', 'convention', 'standard', 'best-practice'],\n};\n\n// ============================================================\n// Orama Document Schema\n// ============================================================\n\n/** The document shape stored in Orama */\nexport interface MemorixDocument {\n id: string;\n observationId: number;\n entityName: string;\n type: string;\n title: string;\n narrative: string;\n facts: string;\n filesModified: string;\n concepts: string;\n tokens: number;\n createdAt: string;\n projectId: string;\n /** Number of times this observation was returned in search results */\n accessCount: number;\n /** ISO timestamp of last access via search/detail */\n lastAccessedAt: string;\n /** Lifecycle status: active, resolved, archived */\n status: string;\n /** Origin: agent, git, manual */\n source: string;\n /** Provenance detail: explicit, hook, or git-ingest */\n sourceDetail?: string;\n /** Value category from formation evaluation */\n valueCategory?: string;\n /** Optional vector embedding for semantic/hybrid retrieval */\n embedding?: number[];\n /** Document type: observation or mini-skill (Phase 3a) */\n documentType?: DocumentType;\n /** Knowledge layer for layer-aware ranking (Phase 3a) */\n knowledgeLayer?: KnowledgeLayer;\n}\n\n// ============================================================\n// Rules System (Memorix original — extensible for new agents)\n// ============================================================\n\n/**\n * Supported agent/IDE rule sources.\n * All 7 major AI IDEs are supported.\n */\nexport type RuleSource =\n | 'cursor'\n | 'claude-code'\n | 'codex'\n | 'windsurf'\n | 'antigravity'\n | 'gemini-cli'\n | 'copilot'\n | 'kiro'\n | 'trae'\n | 'memorix';\n\n/** A parsed rule in the unified intermediate representation */\nexport interface UnifiedRule {\n id: string;\n content: string;\n description?: string;\n source: RuleSource;\n scope: 'global' | 'project' | 'path-specific';\n paths?: string[];\n alwaysApply?: boolean;\n priority: number;\n hash: string;\n}\n\n/**\n * Format adapter interface — implement this for each agent/IDE.\n * Adding a new agent (e.g., Kiro) only requires implementing this interface.\n */\nexport interface RuleFormatAdapter {\n /** Unique identifier for this agent format */\n readonly source: RuleSource;\n\n /** File paths/globs this adapter can parse */\n readonly filePatterns: string[];\n\n /** Parse rule files into unified representation */\n parse(filePath: string, content: string): UnifiedRule[];\n\n /** Generate rule file content from unified representation */\n generate(rules: UnifiedRule[]): { filePath: string; content: string }[];\n}\n\n// ============================================================\n// Project Identity\n// ============================================================\n\nexport interface ProjectInfo {\n id: string;\n name: string;\n gitRemote?: string;\n rootPath: string;\n}\n\n/**\n * Diagnostic failure info from project detection.\n * Tells callers exactly WHY detection failed so they can report actionable errors.\n */\nexport type DetectionFailureReason =\n | 'path_not_found'\n | 'not_a_directory'\n | 'no_git'\n | 'git_worktree_error'\n | 'git_safe_directory'\n | 'remote_resolve_failed';\n\nexport interface DetectionFailure {\n reason: DetectionFailureReason;\n path: string;\n detail: string;\n}\n\nexport interface DetectionResult {\n project: ProjectInfo | null;\n failure: DetectionFailure | null;\n}\n\n// ============================================================\n// Memorix Server Configuration\n// ============================================================\n\nexport interface MemorixConfig {\n dataDir: string;\n projectId: string;\n projectName: string;\n enableEmbeddings: boolean;\n enableRulesSync: boolean;\n watchRuleFiles: boolean;\n}\n\nexport const DEFAULT_CONFIG: Partial<MemorixConfig> = {\n enableEmbeddings: false,\n enableRulesSync: false,\n watchRuleFiles: false,\n};\n\n// ============================================================\n// Workspace Sync — Cross-Agent workspace migration\n// ============================================================\n\n/** Supported agent targets for workspace sync */\nexport type AgentTarget =\n | 'windsurf'\n | 'cursor'\n | 'claude-code'\n | 'codex'\n | 'copilot'\n | 'antigravity'\n | 'gemini-cli'\n | 'openclaw'\n | 'hermes'\n | 'omp'\n | 'kiro'\n | 'opencode'\n | 'trae';\n\n/** A unified MCP server entry across all agent config formats */\nexport interface MCPServerEntry {\n name: string;\n /** Command for stdio transport */\n command: string;\n /** Args for stdio transport */\n args: string[];\n /** Environment variables */\n env?: Record<string, string> | null;\n /** URL for HTTP/SSE transport (Codex uses `url`, Windsurf uses `serverUrl`) */\n url?: string;\n /** HTTP headers (Windsurf uses `headers` for HTTP transport) */\n headers?: Record<string, string>;\n /** Whether this server is disabled */\n disabled?: boolean;\n /** Claude Code: force small core tool sets to load before the first prompt */\n alwaysLoad?: boolean;\n}\n\n/** Unified workflow entry */\nexport interface WorkflowEntry {\n name: string;\n description: string;\n content: string;\n source: AgentTarget;\n filePath: string;\n}\n\n/** A skill folder discovered from an agent's skills directory */\nexport interface SkillEntry {\n name: string;\n description: string;\n sourcePath: string;\n sourceAgent: AgentTarget;\n}\n\n/** Conflict when two agents have a skill with the same folder name */\nexport interface SkillConflict {\n name: string;\n kept: SkillEntry;\n skipped: SkillEntry;\n}\n\n/** Result of a workspace sync operation */\nexport interface WorkspaceSyncResult {\n mcpServers: {\n scanned: MCPServerEntry[];\n generated: { filePath: string; content: string }[];\n };\n workflows: {\n scanned: WorkflowEntry[];\n generated: { filePath: string; content: string }[];\n };\n rules: {\n scanned: number;\n generated: number;\n };\n skills: {\n scanned: SkillEntry[];\n conflicts: SkillConflict[];\n copied: string[];\n skipped: string[];\n };\n}\n\n// ============================================================\n// Mini-Skills — Promoted memories that never decay\n// ============================================================\n\n/** A mini-skill promoted from one or more observations */\nexport interface MiniSkill {\n id: number;\n /** Observation IDs this mini-skill was derived from (live refs, best-effort) */\n sourceObservationIds: number[];\n /** Entity the source observations belong to */\n sourceEntity: string;\n /** Short title for the skill */\n title: string;\n /** What the agent should do (imperative instruction) */\n instruction: string;\n /** When this skill should be applied (scenario description) */\n trigger: string;\n /** Key facts extracted from source observations */\n facts: string[];\n /** Project this skill belongs to */\n projectId: string;\n /** ISO timestamp */\n createdAt: string;\n /** How many times this skill was injected in session_start */\n usedCount: number;\n /** Classification tags */\n tags: string[];\n /** Frozen source observation content at promote time (JSON, immutable provenance proof) */\n sourceSnapshot?: string;\n /** ISO timestamp of last modification (Phase 3a: set once at creation) */\n updatedAt?: string;\n}\n\n// ============================================================\n// Source Snapshot — immutable provenance proof for promoted knowledge\n// ============================================================\n\n/** A single observation entry within a source snapshot */\nexport interface SnapshotObservation {\n id: number;\n title: string;\n type: string;\n narrative: string;\n facts: string[];\n entityName: string;\n projectId: string;\n createdAt: string;\n /** Frozen source detail for provenance (explicit / hook / git-ingest) */\n sourceDetail?: string;\n}\n\n/** Frozen source content captured at promote time */\nexport interface SourceSnapshot {\n observations: SnapshotObservation[];\n promotedAt: string;\n}\n\n// ============================================================\n// Knowledge Layer — Phase 3a retrieval classification\n// ============================================================\n\n/** Classification of knowledge for layer-aware ranking */\nexport type KnowledgeLayer = 'project-truth' | 'promoted' | 'evidence';\n\n/** Document type discriminator for Orama index */\nexport type DocumentType = 'observation' | 'mini-skill';\n\n// ============================================================\n// Typed Memory Reference — Phase 3a reference protocol\n// ============================================================\n\n/** A typed reference to a memory object (observation or mini-skill) */\nexport interface MemoryRef {\n kind: 'obs' | 'skill';\n id: number;\n projectId?: string;\n}\n\n/** MCP config format adapter interface */\nexport interface MCPConfigAdapter {\n readonly source: AgentTarget;\n /** Parse MCP server entries from a config file */\n parse(content: string): MCPServerEntry[];\n /** Generate config file content from MCP server entries */\n generate(servers: MCPServerEntry[]): string;\n /** Get the default config file path for this agent */\n getConfigPath(projectRoot?: string): string;\n}\n"],"mappings":";AAsEO,IAAM,oBAAqD;AAAA,EAChE,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AACX;AA2IO,IAAM,qBAA+C;AAAA,EAC1D,gBAAgB,CAAC,gBAAgB,UAAU,OAAO,aAAa,SAAS;AAAA,EACxE,OAAO,CAAC,UAAU,OAAO,SAAS,cAAc,SAAS,kBAAkB;AAAA,EAC3E,YAAY,CAAC,YAAY,aAAa,UAAU,UAAU;AAAA,EAC1D,UAAU,CAAC,UAAU,SAAS,OAAO,eAAe,YAAY;AAAA,EAChE,aAAa,CAAC,aAAa,YAAY,WAAW,QAAQ;AAAA,EAC1D,WAAW,CAAC,WAAW,cAAc,YAAY,eAAe;AAClE;AA0IO,IAAM,iBAAyC;AAAA,EACpD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * Memorix Core Types\n *\n * Data model sources:\n * - Entity/Relation/KnowledgeGraph: MCP Official Memory Server (v0.6.3)\n * - Observation/ObservationType: claude-mem Progressive Disclosure\n * - UnifiedRule/RuleSource: Memorix original (rules sync)\n *\n * Designed for extensibility: new agent formats (Kiro, Copilot, Antigravity)\n * can be added by extending RuleSource and adding format adapters.\n */\n\n// ============================================================\n// Knowledge Graph (adopted from MCP Official Memory Server)\n// ============================================================\n\n/** A node in the knowledge graph representing a concept, component, or config */\nexport interface Entity {\n name: string;\n entityType: string;\n observations: string[];\n}\n\n/** A directed edge between two entities */\nexport interface Relation {\n from: string;\n to: string;\n relationType: string;\n}\n\n/** The complete knowledge graph */\nexport interface KnowledgeGraph {\n entities: Entity[];\n relations: Relation[];\n}\n\n// ============================================================\n// Observation (adopted from claude-mem Progressive Disclosure)\n// ============================================================\n\n/**\n * Observation type classification using claude-mem's icon-based legend system.\n *\n * Icon mapping:\n * [SESSION] session-request — User's original goal\n * [GOTCHA] gotcha — Critical pitfall / trap\n * [FIX] problem-solution — Bug fix or workaround\n * [INFO] how-it-works — Technical explanation\n * [CHANGE] what-changed — Code/architecture change\n * [DISCOVERY] discovery — New learning or insight\n * [WHY] why-it-exists — Design rationale\n * [DECISION] decision — Architecture decision\n * [TRADEOFF] trade-off — Deliberate compromise\n * [REASONING] reasoning — Why this approach was chosen (System 2 reasoning trace)\n * [PROBE] probe — Operational heartbeat / connectivity check (short-lived, excluded from default search)\n */\nexport type ObservationType =\n | 'session-request'\n | 'gotcha'\n | 'problem-solution'\n | 'how-it-works'\n | 'what-changed'\n | 'discovery'\n | 'why-it-exists'\n | 'decision'\n | 'trade-off'\n | 'reasoning'\n | 'probe';\n\n/** Map from ObservationType to display icon */\nexport const OBSERVATION_ICONS: Record<ObservationType, string> = {\n 'session-request': '[SESSION]',\n 'gotcha': '[GOTCHA]',\n 'problem-solution': '[FIX]',\n 'how-it-works': '[INFO]',\n 'what-changed': '[CHANGE]',\n 'discovery': '[DISCOVERY]',\n 'why-it-exists': '[WHY]',\n 'decision': '[DECISION]',\n 'trade-off': '[TRADEOFF]',\n 'reasoning': '[REASONING]',\n 'probe': '[PROBE]',\n};\n\n/** Observation lifecycle status */\nexport type ObservationStatus = 'active' | 'resolved' | 'archived';\n\n/**\n * Control-plane admission state for automatically captured observations.\n * Candidate and ephemeral records remain inspectable, but only qualified\n * records are eligible for automatic context delivery. Missing state preserves\n * legacy behavior for observations written before this policy existed.\n */\nexport type ObservationAdmissionState = 'ephemeral' | 'candidate' | 'qualified';\n\n/**\n * Who may retrieve an observation through agent-facing memory surfaces.\n * Missing visibility is a legacy record and resolves to `project`.\n */\nexport type ObservationVisibility = 'personal' | 'project' | 'team';\n\n/**\n * Identity available to an agent-facing retrieval call. Internal maintenance\n * deliberately omits this and may inspect all project records for lifecycle work.\n */\nexport interface ObservationReader {\n /** Bound project for a normal project-scoped call. Omit only for explicit global search. */\n projectId?: string;\n /** Stable coordination identity, available after an explicit team join. */\n agentId?: string;\n /** True only when agentId is an active member of the bound project team. */\n isTeamMember?: boolean;\n}\n\n/** Progress tracking for task/feature observations */\nexport interface ProgressInfo {\n feature: string;\n status: 'in-progress' | 'completed' | 'blocked';\n completion?: number;\n}\n\n/** A rich observation record attached to an entity */\nexport interface Observation {\n id: number;\n entityName: string;\n type: ObservationType;\n title: string;\n narrative: string;\n facts: string[];\n filesModified: string[];\n concepts: string[];\n tokens: number;\n createdAt: string;\n updatedAt?: string;\n projectId: string;\n /** Whether the observation contains causal language (because, due to, etc.) */\n hasCausalLanguage?: boolean;\n /** Optional topic key for upsert — same project+topicKey updates existing observation */\n topicKey?: string;\n /** How many times this observation was revised via topic key upsert (starts at 1) */\n revisionCount?: number;\n /** Session ID this observation belongs to */\n sessionId?: string;\n /** Lifecycle status: active (default) → resolved → archived */\n status?: ObservationStatus;\n /** ID of the observation that superseded this one (set when auto-resolved by topicKey upsert) */\n supersededBy?: number;\n /** Progress tracking for task/feature observations */\n progress?: ProgressInfo;\n /** Origin of this observation: agent (IDE hooks/MCP), git (commit ingest), manual (CLI) */\n source?: 'agent' | 'git' | 'manual';\n /** Git commit hash if source is 'git' */\n commitHash?: string;\n /** Related commit hashes — links reasoning memories to the commits they explain */\n relatedCommits?: string[];\n /** Related entity names — explicit cross-references to other memory entities */\n relatedEntities?: string[];\n /** Provenance detail: how this observation entered the system */\n sourceDetail?: 'explicit' | 'hook' | 'git-ingest';\n /** Value category from formation pipeline evaluation */\n valueCategory?: 'core' | 'contextual' | 'ephemeral';\n /** Control-plane admission state for automatic capture and delivery. */\n admissionState?: ObservationAdmissionState;\n /** Short, sanitized explanation for the latest admission decision. */\n admissionReason?: string;\n /** Retrieval scope. Legacy records without a value remain project-visible. */\n visibility?: ObservationVisibility;\n /** Explicit additional readers for a personal record, used by targeted handoffs. */\n sharedWithAgentIds?: string[];\n /** Phase 4a: Agent ID that created this observation (team attribution) */\n createdByAgentId?: string;\n /** Phase 4a: Monotonic write generation — snapshot of storage_generation at write time (watermark coherence) */\n writeGeneration?: number;\n}\n\n// ============================================================\n// Session Lifecycle (inspired by Engram's session management)\n// ============================================================\n\n/** A coding session tracked by Memorix */\nexport interface Session {\n id: string;\n projectId: string;\n startedAt: string;\n endedAt?: string;\n summary?: string;\n status: 'active' | 'completed';\n /** Agent/IDE that started this session */\n agent?: string;\n}\n\n// ============================================================\n// Compact Engine (adopted from claude-mem 3-layer workflow)\n// ============================================================\n\n/** L1 index entry — lightweight, ~50-100 tokens per result */\nexport interface IndexEntry {\n id: number;\n time: string;\n type: ObservationType;\n icon: string;\n title: string;\n tokens: number;\n /** Relevance score from search (time-decayed). Used by compact engine. */\n score?: number;\n /** Project that owns this observation. Needed to disambiguate global results. */\n projectId?: string;\n /** Origin of the memory for source-aware retrieval and display. */\n source?: 'agent' | 'git' | 'manual';\n /** Provenance detail for source-aware display */\n sourceDetail?: 'explicit' | 'hook' | 'git-ingest';\n /** Value category for source-aware ranking */\n valueCategory?: 'core' | 'contextual' | 'ephemeral';\n /** Control-plane admission state when known. */\n admissionState?: ObservationAdmissionState;\n /** Retrieval scope when known. */\n visibility?: ObservationVisibility;\n /** Explainable recall: why this result matched. */\n matchedFields?: string[];\n /** Entity name — used for entity-affinity scoring and workstream deduplication. */\n entityName?: string;\n /** Document type: observation or mini-skill (Phase 3a) */\n documentType?: DocumentType;\n /** Knowledge layer for layer-aware ranking (Phase 3a) */\n knowledgeLayer?: KnowledgeLayer;\n}\n\n/** Explicit reference to an observation, optionally scoped to a project. */\nexport interface ObservationRef {\n id: number;\n projectId?: string;\n}\n\n/** L2 timeline context — observations around an anchor */\nexport interface TimelineContext {\n anchorId: number;\n anchorEntry: IndexEntry | null;\n before: IndexEntry[];\n after: IndexEntry[];\n}\n\n/** Search options for the compact engine */\nexport interface SearchOptions {\n query: string;\n limit?: number;\n type?: ObservationType;\n projectId?: string;\n since?: string;\n until?: string;\n /** Token budget — trim results to fit within this many tokens (0 = unlimited) */\n maxTokens?: number;\n /** Filter by observation status. Default: 'active' (only show active memories) */\n status?: ObservationStatus | 'all';\n /** Filter by observation source: 'agent', 'git', 'manual', or undefined for all */\n source?: 'agent' | 'git' | 'manual';\n /** Internal observability probes can disable access tracking without affecting normal search behavior. */\n trackAccess?: boolean;\n /** Internal reader context for agent-facing visibility filtering. */\n reader?: ObservationReader;\n}\n\n/** Topic key family heuristics for suggesting stable topic keys */\nexport const TOPIC_KEY_FAMILIES: Record<string, string[]> = {\n 'architecture': ['architecture', 'design', 'adr', 'structure', 'pattern'],\n 'bug': ['bugfix', 'fix', 'error', 'regression', 'crash', 'problem-solution'],\n 'decision': ['decision', 'trade-off', 'choice', 'strategy'],\n 'config': ['config', 'setup', 'env', 'environment', 'deployment'],\n 'discovery': ['discovery', 'learning', 'insight', 'gotcha'],\n 'pattern': ['pattern', 'convention', 'standard', 'best-practice'],\n};\n\n// ============================================================\n// Orama Document Schema\n// ============================================================\n\n/** The document shape stored in Orama */\nexport interface MemorixDocument {\n id: string;\n observationId: number;\n entityName: string;\n type: string;\n title: string;\n narrative: string;\n facts: string;\n filesModified: string;\n concepts: string;\n tokens: number;\n createdAt: string;\n projectId: string;\n /** Number of times this observation was returned in search results */\n accessCount: number;\n /** ISO timestamp of last access via search/detail */\n lastAccessedAt: string;\n /** Lifecycle status: active, resolved, archived */\n status: string;\n /** Origin: agent, git, manual */\n source: string;\n /** Provenance detail: explicit, hook, or git-ingest */\n sourceDetail?: string;\n /** Value category from formation evaluation */\n valueCategory?: string;\n /** Control-plane admission state for automatic capture and delivery. */\n admissionState?: string;\n /** Short, sanitized explanation for the latest admission decision. */\n admissionReason?: string;\n /** Retrieval scope for agent-facing filtering. */\n visibility?: string;\n /** Agent that owns a personal record, or authored a shared record. */\n createdByAgentId?: string;\n /** Explicit readers for a targeted personal record. */\n sharedWithAgentIds?: string;\n /** Optional vector embedding for semantic/hybrid retrieval */\n embedding?: number[];\n /** Document type: observation or mini-skill (Phase 3a) */\n documentType?: DocumentType;\n /** Knowledge layer for layer-aware ranking (Phase 3a) */\n knowledgeLayer?: KnowledgeLayer;\n}\n\n// ============================================================\n// Rules System (Memorix original — extensible for new agents)\n// ============================================================\n\n/**\n * Supported agent/IDE rule sources.\n * All 7 major AI IDEs are supported.\n */\nexport type RuleSource =\n | 'cursor'\n | 'claude-code'\n | 'codex'\n | 'windsurf'\n | 'antigravity'\n | 'gemini-cli'\n | 'copilot'\n | 'kiro'\n | 'trae'\n | 'memorix';\n\n/** A parsed rule in the unified intermediate representation */\nexport interface UnifiedRule {\n id: string;\n content: string;\n description?: string;\n source: RuleSource;\n scope: 'global' | 'project' | 'path-specific';\n paths?: string[];\n alwaysApply?: boolean;\n priority: number;\n hash: string;\n}\n\n/**\n * Format adapter interface — implement this for each agent/IDE.\n * Adding a new agent (e.g., Kiro) only requires implementing this interface.\n */\nexport interface RuleFormatAdapter {\n /** Unique identifier for this agent format */\n readonly source: RuleSource;\n\n /** File paths/globs this adapter can parse */\n readonly filePatterns: string[];\n\n /** Parse rule files into unified representation */\n parse(filePath: string, content: string): UnifiedRule[];\n\n /** Generate rule file content from unified representation */\n generate(rules: UnifiedRule[]): { filePath: string; content: string }[];\n}\n\n// ============================================================\n// Project Identity\n// ============================================================\n\nexport interface ProjectInfo {\n id: string;\n name: string;\n gitRemote?: string;\n rootPath: string;\n}\n\n/**\n * Diagnostic failure info from project detection.\n * Tells callers exactly WHY detection failed so they can report actionable errors.\n */\nexport type DetectionFailureReason =\n | 'path_not_found'\n | 'not_a_directory'\n | 'no_git'\n | 'git_worktree_error'\n | 'git_safe_directory'\n | 'remote_resolve_failed';\n\nexport interface DetectionFailure {\n reason: DetectionFailureReason;\n path: string;\n detail: string;\n}\n\nexport interface DetectionResult {\n project: ProjectInfo | null;\n failure: DetectionFailure | null;\n}\n\n// ============================================================\n// Memorix Server Configuration\n// ============================================================\n\nexport interface MemorixConfig {\n dataDir: string;\n projectId: string;\n projectName: string;\n enableEmbeddings: boolean;\n enableRulesSync: boolean;\n watchRuleFiles: boolean;\n}\n\nexport const DEFAULT_CONFIG: Partial<MemorixConfig> = {\n enableEmbeddings: false,\n enableRulesSync: false,\n watchRuleFiles: false,\n};\n\n// ============================================================\n// Workspace Sync — Cross-Agent workspace migration\n// ============================================================\n\n/** Supported agent targets for workspace sync */\nexport type AgentTarget =\n | 'windsurf'\n | 'cursor'\n | 'claude-code'\n | 'codex'\n | 'copilot'\n | 'antigravity'\n | 'gemini-cli'\n | 'openclaw'\n | 'hermes'\n | 'omp'\n | 'kiro'\n | 'opencode'\n | 'trae';\n\n/** A unified MCP server entry across all agent config formats */\nexport interface MCPServerEntry {\n name: string;\n /** Command for stdio transport */\n command: string;\n /** Args for stdio transport */\n args: string[];\n /** Environment variables */\n env?: Record<string, string> | null;\n /** URL for HTTP/SSE transport (Codex uses `url`, Windsurf uses `serverUrl`) */\n url?: string;\n /** HTTP headers (Windsurf uses `headers` for HTTP transport) */\n headers?: Record<string, string>;\n /** Whether this server is disabled */\n disabled?: boolean;\n /** Claude Code: force small core tool sets to load before the first prompt */\n alwaysLoad?: boolean;\n}\n\n/** Unified workflow entry */\nexport interface WorkflowEntry {\n name: string;\n description: string;\n content: string;\n source: AgentTarget;\n filePath: string;\n}\n\n/** A skill folder discovered from an agent's skills directory */\nexport interface SkillEntry {\n name: string;\n description: string;\n sourcePath: string;\n sourceAgent: AgentTarget;\n}\n\n/** Conflict when two agents have a skill with the same folder name */\nexport interface SkillConflict {\n name: string;\n kept: SkillEntry;\n skipped: SkillEntry;\n}\n\n/** Result of a workspace sync operation */\nexport interface WorkspaceSyncResult {\n mcpServers: {\n scanned: MCPServerEntry[];\n generated: { filePath: string; content: string }[];\n };\n workflows: {\n scanned: WorkflowEntry[];\n generated: { filePath: string; content: string }[];\n };\n rules: {\n scanned: number;\n generated: number;\n };\n skills: {\n scanned: SkillEntry[];\n conflicts: SkillConflict[];\n copied: string[];\n skipped: string[];\n };\n}\n\n// ============================================================\n// Mini-Skills — Promoted memories that never decay\n// ============================================================\n\n/** A mini-skill promoted from one or more observations */\nexport interface MiniSkill {\n id: number;\n /** Observation IDs this mini-skill was derived from (live refs, best-effort) */\n sourceObservationIds: number[];\n /** Entity the source observations belong to */\n sourceEntity: string;\n /** Short title for the skill */\n title: string;\n /** What the agent should do (imperative instruction) */\n instruction: string;\n /** When this skill should be applied (scenario description) */\n trigger: string;\n /** Key facts extracted from source observations */\n facts: string[];\n /** Project this skill belongs to */\n projectId: string;\n /** ISO timestamp */\n createdAt: string;\n /** How many times this skill was injected in session_start */\n usedCount: number;\n /** Classification tags */\n tags: string[];\n /** Frozen source observation content at promote time (JSON, immutable provenance proof) */\n sourceSnapshot?: string;\n /** ISO timestamp of last modification (Phase 3a: set once at creation) */\n updatedAt?: string;\n}\n\n// ============================================================\n// Source Snapshot — immutable provenance proof for promoted knowledge\n// ============================================================\n\n/** A single observation entry within a source snapshot */\nexport interface SnapshotObservation {\n id: number;\n title: string;\n type: string;\n narrative: string;\n facts: string[];\n entityName: string;\n projectId: string;\n createdAt: string;\n /** Frozen source detail for provenance (explicit / hook / git-ingest) */\n sourceDetail?: string;\n}\n\n/** Frozen source content captured at promote time */\nexport interface SourceSnapshot {\n observations: SnapshotObservation[];\n promotedAt: string;\n}\n\n// ============================================================\n// Knowledge Layer — Phase 3a retrieval classification\n// ============================================================\n\n/** Classification of knowledge for layer-aware ranking */\nexport type KnowledgeLayer = 'project-truth' | 'promoted' | 'evidence';\n\n/** Document type discriminator for Orama index */\nexport type DocumentType = 'observation' | 'mini-skill';\n\n// ============================================================\n// Typed Memory Reference — Phase 3a reference protocol\n// ============================================================\n\n/** A typed reference to a memory object (observation or mini-skill) */\nexport interface MemoryRef {\n kind: 'obs' | 'skill';\n id: number;\n projectId?: string;\n}\n\n/** MCP config format adapter interface */\nexport interface MCPConfigAdapter {\n readonly source: AgentTarget;\n /** Parse MCP server entries from a config file */\n parse(content: string): MCPServerEntry[];\n /** Generate config file content from MCP server entries */\n generate(servers: MCPServerEntry[]): string;\n /** Get the default config file path for this agent */\n getConfigPath(projectRoot?: string): string;\n}\n"],"mappings":";AAsEO,IAAM,oBAAqD;AAAA,EAChE,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AACX;AAoLO,IAAM,qBAA+C;AAAA,EAC1D,gBAAgB,CAAC,gBAAgB,UAAU,OAAO,aAAa,SAAS;AAAA,EACxE,OAAO,CAAC,UAAU,OAAO,SAAS,cAAc,SAAS,kBAAkB;AAAA,EAC3E,YAAY,CAAC,YAAY,aAAa,UAAU,UAAU;AAAA,EAC1D,UAAU,CAAC,UAAU,SAAS,OAAO,eAAe,YAAY;AAAA,EAChE,aAAa,CAAC,aAAa,YAAY,WAAW,QAAQ;AAAA,EAC1D,WAAW,CAAC,WAAW,cAAc,YAAY,eAAe;AAClE;AAoJO,IAAM,iBAAyC;AAAA,EACpD,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;","names":[]}
@@ -0,0 +1,434 @@
1
+ # Memorix 1.2.2 Memory Control Plane
2
+
3
+ Status: active development
4
+ Branch: `codex/1.2.2-memory-control-plane`
5
+ Baseline: `memorix@1.2.1`, tag `v1.2.1`
6
+ Start: 2026-07-24
7
+
8
+ ## Product Promise
9
+
10
+ Memorix 1.2.1 can already build a bounded task Workset from code state, Git
11
+ facts, durable memories, claims, wiki pages, workflows, and verification
12
+ hints. 1.2.2 makes that useful behavior consistent across the product.
13
+
14
+ For a normal agent request such as "continue the login timeout fix", the agent
15
+ should not need to remember a Memorix command or understand storage layers.
16
+ When Memorix has useful evidence, it should quietly deliver a short, current,
17
+ source-backed brief. When it does not, it should stay small and let the agent
18
+ read the code normally.
19
+
20
+ This is a control-plane release, not a new collection of memory types. Its job
21
+ is to make existing evidence flow through one controlled path:
22
+
23
+ ```text
24
+ capture -> qualify -> maintain -> assemble -> deliver -> receipt -> improve
25
+ ```
26
+
27
+ The result must be less prompt ballast, not more.
28
+
29
+ ## Why This Release Exists
30
+
31
+ The 1.2.1 foundation is real, but it has three seams that matter to users:
32
+
33
+ 1. `TaskWorkset` has a budget and provenance, while session handoff and legacy
34
+ graph-context paths can still form their own output outside the same
35
+ admission and receipt rules.
36
+ 2. A previous-session summary is valuable for a handoff, but a raw summary or
37
+ a scan of every active observation is unsafe to inject at SessionStart. It
38
+ can be slow, noisy, and consume the next agent's limited attention.
39
+ 3. Memory retention, consolidation, claims, workspace compilation, and
40
+ background jobs exist, but the product does not yet expose one answer to
41
+ "why was this included, why was this withheld, and what will be refreshed?"
42
+
43
+ The open embedding request also identifies a separate boundary: Memorix needs
44
+ a provider capability contract before it can honestly support query/document
45
+ intent or media inputs. Text-only OpenRouter embedding remains the supported
46
+ default until a capability is implemented end to end.
47
+
48
+ ## Existing Foundations To Reuse
49
+
50
+ - `TaskWorkset` and the bounded Workset renderer in `src/knowledge/workset.ts`.
51
+ - Auto Project Context and Context Pack adapters in `src/codegraph`.
52
+ - Code State snapshots, Claim Ledger, Knowledge Workspace, canonical workflows,
53
+ evaluation fixtures, and durable maintenance jobs from 1.2.1.
54
+ - Existing retention, deduplication, consolidation, and secret filtering.
55
+ - The `micro` MCP profile. It remains the normal coding-agent surface; 1.2.2
56
+ must not answer an internal architecture problem by adding more default tools.
57
+
58
+ ## What To Borrow From AgentMemory
59
+
60
+ AgentMemory is a useful reference implementation, not a template to copy. Its
61
+ [architecture guide](https://github.com/rohitg00/agentmemory/blob/main/plugin/skills/agentmemory-architecture/SKILL.md),
62
+ [context function](https://github.com/rohitg00/agentmemory/blob/main/src/functions/context.ts),
63
+ and [hybrid search](https://github.com/rohitg00/agentmemory/blob/main/src/state/hybrid-search.ts)
64
+ show a coherent capture, compression, lifecycle, and retrieval system.
65
+
66
+ The parts worth adopting are product disciplines:
67
+
68
+ | AgentMemory pattern | Memorix adoption | Important adaptation |
69
+ | --- | --- | --- |
70
+ | Automatic hook capture | Keep capture effortless, but record a small event/evidence record first. | Reading a file, repeated shell output, or agent chatter is not durable project knowledge by default. |
71
+ | Raw observation, compressed fact, session summary, lesson/profile layers | Make evidence stages explicit: ephemeral event -> candidate -> qualified durable memory/claim -> reviewable wiki/workflow artifact. | Do not create a second opaque transcript database. Existing observations and source refs remain the base. |
72
+ | Decay, access tracking, consolidation, forget | Apply lifecycle policy by evidence kind and source validity. | A code fact becomes suspect when its source changes; a release decision is superseded by evidence, not merely aged out. |
73
+ | BM25 + vector + graph RRF | Use multiple retrieval lanes and bounded fusion. | Code State is a currentness gate, not one more fuzzy graph score. Task lens and provenance must outrank generic recency. |
74
+ | Agent id and fail-closed isolated scope | Add uniform actor/source/visibility policy to every automatic write and delivery path. | Project facts can be shared deliberately; personal notes and private handoffs never leak because an agent id was absent. |
75
+
76
+ The resulting Memorix lifecycle is intentionally narrower than "remember
77
+ everything":
78
+
79
+ ```text
80
+ Ephemeral event/evidence
81
+ -> candidate (deduplicated, sanitized, not injected)
82
+ -> qualified durable memory or claim (source-backed, task-addressable)
83
+ -> approved knowledge/workflow artifact (reviewable)
84
+ -> temporary TaskWorkset or HandoffPacket (bounded delivery only)
85
+ ```
86
+
87
+ This is not a new storage stack. The first implementation adds lifecycle and
88
+ provenance semantics to existing observations, claims, sessions, and
89
+ maintenance jobs before considering any new table.
90
+
91
+ AgentMemory's retrieval and delivery paths are also deliberately separated in
92
+ its implementation: its hybrid search uses BM25, vector, and graph signals,
93
+ while its automatic context builder assembles profile/lesson/recent-session
94
+ blocks under a token budget. Memorix should keep that separation but improve
95
+ the final choice: task relevance, current code state, source confidence, and
96
+ workflow applicability must decide delivery. Recent text is a tie-breaker, not
97
+ the primary truth signal.
98
+
99
+ ## Non-Negotiable Invariants
100
+
101
+ - **Current source wins.** Historical text, handoffs, derived claims, and
102
+ external code intelligence are evidence, never executable instruction.
103
+ - **Every automatic delivery has a budget.** Context is selected as whole,
104
+ traceable items. It is not cut from an arbitrary raw corpus.
105
+ - **No foreground corpus work.** MCP initialize, tools/list, SessionStart, and
106
+ Project Context may schedule maintenance, but do not wait for a broad scan,
107
+ model call, or remote embedding request.
108
+ - **Silence is a valid result.** When evidence has no material advantage for
109
+ the task, Memorix returns a compact cold/fresh-project result instead of
110
+ manufacturing a narrative.
111
+ - **Historical content is untrusted.** Injected handoffs and stored text are
112
+ clearly delimited as historical evidence and cannot override host or project
113
+ instructions.
114
+ - **Source and recipient are explicit.** Every selected item carries source
115
+ references, freshness/trust state, selection reason, and a target surface.
116
+ - **One model/vector family is one index identity.** Changing provider, model,
117
+ dimensions, modality, or embedding intent never mixes incompatible vectors;
118
+ it requires an explicit reindex policy.
119
+ - **No automatic project writes.** Wiki/workflow proposals and agent adapters
120
+ remain reviewable. 1.2.2 does not mutate users' global agent configuration
121
+ to make an integration work.
122
+
123
+ ## Control-Plane Contract
124
+
125
+ `TaskWorkset` remains the public task-shaped result. 1.2.2 introduces a
126
+ shared internal assembly contract rather than a competing memory store:
127
+
128
+ ```text
129
+ ContextCandidate
130
+ id / kind handoff, current-fact, code-state, claim,
131
+ knowledge-page, workflow, verification, caution
132
+ sourceRefs / sourceHash
133
+ trust source-backed, derived, historical
134
+ freshness current, suspect, stale, unknown
135
+ relevance / importance
136
+ estimatedTokens
137
+ delivery task, hook-handoff, explicit-pull
138
+
139
+ ContextAssembly
140
+ task / target surface / budget
141
+ selected candidates / omitted candidates with reasons
142
+ cautions / refresh actions
143
+ receipt
144
+ ```
145
+
146
+ The Workset renderer, compact SessionStart handoff, Context Pack, and legacy
147
+ graph-summary compatibility path must become views of this contract. They may
148
+ have different budgets, but not different safety rules.
149
+
150
+ The receipt is privacy-safe metadata, not another prompt section. It records
151
+ at least selected source kinds and ids, reason, freshness, token counts,
152
+ omissions, truncation, scheduled refreshes, and elapsed assembly time. It must
153
+ not contain credentials, raw private source, or signed URLs.
154
+
155
+ ## Delivery Phases
156
+
157
+ ### Phase 0: Baseline And Failure Fixtures
158
+
159
+ Record the present behavior before changing it. Add deterministic fixtures for:
160
+
161
+ - a fresh project with no useful history;
162
+ - a mature project with many active observations;
163
+ - a long previous-session summary containing a secret-shaped value;
164
+ - a stale/dirty/incomplete Code State result;
165
+ - multiple workflows where generic words such as "verify" must not select the
166
+ release workflow;
167
+ - an unavailable embedding provider and a changed vector identity.
168
+
169
+ The fixtures measure output budget, selected evidence, omissions, and whether
170
+ the foreground path scheduled rather than awaited maintenance. No performance
171
+ number is claimed before it is measured on the supported Windows setup.
172
+
173
+ ### Phase 1: Shared Context Assembly
174
+
175
+ Build the small `ContextCandidate` and `ContextAssembly` core around the
176
+ existing Workset selector. Route Auto Project Context, Context Pack, and
177
+ hook-delivered context through it without changing the default MCP profile.
178
+
179
+ Acceptance gate:
180
+
181
+ - same evidence produces stable selected/omitted reasons across each surface;
182
+ - every rendered result remains inside its surface budget;
183
+ - legacy prompt and JSON compatibility remain intact where documented;
184
+ - an empty or irrelevant memory corpus produces a small answer;
185
+ - `memorix explain` and JSON consumers can inspect a receipt without reading
186
+ storage internals.
187
+
188
+ ### Phase 2: Compact, Safe Session Handoff
189
+
190
+ Introduce a dedicated `HandoffPacket`, not a call to the old broad
191
+ `getSessionContext()` formatter. It reads the most recent eligible completed
192
+ session and a bounded set of task-relevant durable evidence. Storage and
193
+ delivery both have explicit character/token limits, redaction, a truncation
194
+ marker, and a strict time budget.
195
+
196
+ Full session history remains an explicit pull through the existing session
197
+ surface. SessionStart only receives the small historical packet when the
198
+ project's behavior setting enables it and the packet earns delivery.
199
+
200
+ Acceptance gate:
201
+
202
+ - `minimal + handoff`, `full + handoff`, disabled, and `silent` behavior have
203
+ positive hook integration coverage;
204
+ - large summaries cannot block startup or exceed the injection budget;
205
+ - config resolves from the hook input project root, never accidental process
206
+ cwd;
207
+ - historical packet delimiters and redaction are visible in host output;
208
+ - users can inspect a receipt and explicitly pull the full context.
209
+
210
+ ### Phase 3: Admission, Lifecycle, And Refresh Discipline
211
+
212
+ Make the control loop decide what becomes durable evidence and what stays
213
+ ephemeral activity. Reuse existing retention and consolidation logic, but make
214
+ admission state, conflicts, requalification, maintenance actions, and reasons
215
+ visible to the assembly layer.
216
+
217
+ Start with a conservative automatic-write policy:
218
+
219
+ - explicit user/agent saves, Git facts, focused test outcomes, verified tool
220
+ failures, and source-linked decisions can become candidates;
221
+ - repeated reads, routine successful commands, raw conversation filler, and
222
+ unqualified tool output stay ephemeral or are dropped;
223
+ - background consolidation may summarize compatible candidates, but it never
224
+ promotes them into an approved claim without provenance and policy;
225
+ - every automatically captured record carries capture path, actor/session,
226
+ project, source reference, and visibility (`personal`, `project`, or `team`)
227
+ before it can be retrieved by another agent.
228
+
229
+ The initial multi-agent read policy is fail-closed for private scopes. A
230
+ missing actor id must not silently mean "read every agent's handoff". Project
231
+ shared evidence remains possible only through an explicit project visibility
232
+ rule and keeps the original actor in its receipt.
233
+
234
+ Acceptance gate:
235
+
236
+ - repeated low-value hook activity does not crowd out source-backed decisions;
237
+ - changed/deleted code downgrades related evidence deterministically;
238
+ - duplicate lifecycle signals enqueue one recoverable job;
239
+ - failed or deferred maintenance appears as a concise caution/receipt, not a
240
+ blocking foreground error;
241
+ - consolidation never destroys a source reference needed for drill-down;
242
+ - a private handoff cannot cross an agent boundary without an explicit shared
243
+ visibility rule, while project-level verified facts remain available to the
244
+ agents that need them.
245
+
246
+ ### Phase 3 Implementation Status: Admission And Qualification
247
+
248
+ The first Phase 3 slice is implemented. It adds a small admission state to the
249
+ existing observation record instead of creating a second transcript store:
250
+
251
+ | State | Meaning | Automatic delivery |
252
+ | --- | --- | --- |
253
+ | `ephemeral` | Routine automatic activity retained only as a short-lived trace. | Never selected. |
254
+ | `candidate` | Sanitized automatic evidence worth retaining, but not yet current/source-backed. | Never selected. |
255
+ | `qualified` | A candidate that a Code Memory scan completed after capture and linked to one or more current code references. | Eligible, subject to ordinary task relevance and budget. |
256
+
257
+ Automatic hooks and orchestration writes now use this policy. File mutations,
258
+ concrete failures, decisions, verified fixes, and pipeline summaries start as
259
+ `candidate`; routine command success and task-completion telemetry are
260
+ `ephemeral`; low-signal activity is dropped. Automatic capture is silent in
261
+ the host agent rather than adding a stream of "saved memory" status messages.
262
+
263
+ `observation-qualify` is a deduplicated maintenance job. It runs only after a
264
+ CodeGraph refresh, rejects a snapshot older than the capture, binds the
265
+ observation to the current scan, and upgrades only candidates with current
266
+ code references. It never creates a Claim; claim derivation remains limited to
267
+ explicit saves and Git evidence.
268
+
269
+ The real hook path persists a candidate before it schedules Code Memory work,
270
+ so a fast background worker cannot scan an earlier project state and strand a
271
+ new candidate. CLI, hook, and foreground-refresh paths register their local
272
+ project target before they enqueue isolated maintenance, letting the control
273
+ plane locate the correct project root without placing a path in an MCP job
274
+ payload.
275
+
276
+ Auto Project Context, automatic session L1 context, Wiki/Knowledge Graph
277
+ compilation, and graph-context packets exclude `candidate` and `ephemeral`
278
+ records. Explicit retrieval still permits inspection, while ordinary search
279
+ prefers qualified material and falls back only when no qualified result exists.
280
+
281
+ Pending candidates are deliberately excluded from automatic consolidation so
282
+ their evidence grain remains inspectable.
283
+
284
+ ### Phase 3 Implementation Status: Actor And Visibility Boundaries
285
+
286
+ The second Phase 3 slice gives the existing observation record a small,
287
+ uniform access policy instead of creating a parallel private-memory store:
288
+
289
+ | Visibility | Reader rule | Write rule |
290
+ | --- | --- | --- |
291
+ | `project` | Any caller bound to that project. This is also the legacy default. | A caller bound to that project. |
292
+ | `team` | An active coordination member of that project. | An active coordination member of that project. |
293
+ | `personal` | The creator or an explicit recipient in that project. | The creator only. |
294
+
295
+ SQLite and Orama retain the visibility, creator, and explicit recipient list.
296
+ Records created before this control-plane slice remain `project` visible so an
297
+ upgrade cannot hide existing project knowledge. Automatic hook and
298
+ orchestrator traces begin personal; only a later source-backed qualification
299
+ may promote a hook record to project evidence. A targeted handoff is personal
300
+ to its sender and recipient, while an untargeted handoff is team-visible.
301
+ Automatic orchestration lesson retrieval is an unbound project reader, so it
302
+ cannot inject personal or team-scoped records into another agent's prompt.
303
+
304
+ The same reader policy is applied to MCP search/detail/timeline/context,
305
+ automatic context, session packets, the regular CLI and TUI, both dashboards,
306
+ knowledge compilation, graph context, retention, consolidation, and scoped
307
+ maintenance. A recipient may read a targeted handoff but cannot mutate it.
308
+ Topic-key upserts check write scope before a write, so guessing a private key
309
+ does not disclose or modify the record. The project-attribution guard also
310
+ receives only records visible to the current reader.
311
+
312
+ The embedded SDK remains an unbound project-visible reader. The CLI and local
313
+ TUI also default to that reader, but an operator may explicitly select an
314
+ active local identity with `memorix identity join|use` or one command of
315
+ `--as <agent-id>`. That identity receives only its own personal/team access;
316
+ it does not turn the local database into ambient access to another agent's
317
+ records. Clearing the identity returns the terminal to project scope. CLI and
318
+ MCP transfer exports also use this reader, so an unbound backup cannot include
319
+ personal/team observations merely because they share a project database.
320
+
321
+ Explicit full-purge commands remain local operator maintenance commands behind
322
+ their existing confirmations; they are intentionally outside ordinary agent
323
+ delivery and mutation paths. Remaining Phase 3 work is limited to richer
324
+ qualified-evidence consolidation, deterministic source-change demotion for
325
+ non-code evidence, and receipt-level lifecycle cautions.
326
+
327
+ ### Phase 4: Embedding Capability Foundation
328
+
329
+ Define provider capabilities before extending the public input surface:
330
+
331
+ ```text
332
+ EmbeddingCapabilities
333
+ supportedModalities
334
+ supportedIntents
335
+ transport / endpoint family
336
+ maxInlineBytes / safe-reference policy
337
+ model / dimensions / vectorFamily
338
+ reindex requirement
339
+ ```
340
+
341
+ The existing OpenRouter `qwen/qwen3-embedding-8b` text path remains unchanged
342
+ and tested. Provider adapters must use their official protocol; a Google-native
343
+ embedding request is not treated as a generic OpenAI `/embeddings` request.
344
+
345
+ Media support only ships when an agent can safely complete the whole path:
346
+ validated input -> durable provenance -> supported embedding/extraction ->
347
+ index -> retrieval -> receipt. A typed internal foundation is allowed to land
348
+ on its own only if its docs and issue linkage say exactly that; it cannot claim
349
+ to close media retrieval before the end-to-end path exists.
350
+
351
+ Acceptance gate:
352
+
353
+ - capability and vector identity participate in cache/index identity;
354
+ - unsupported modality/intent degrades predictably to lexical search with a
355
+ receipt rather than silently fabricating a vector;
356
+ - reference validation rejects credentials in URLs and private, loopback,
357
+ link-local, and unsafe IPv6 targets, with DNS/rebinding policy documented;
358
+ - provider request-shape tests derive from official contracts, not mocked
359
+ generic paths;
360
+ - model/dimension/vector-family change requests or performs an explicit,
361
+ observable reindex.
362
+
363
+ ### Phase 5: Product Surface And Diagnostics
364
+
365
+ Keep the normal interaction simple: a supported agent uses the user's task and
366
+ gets Project Context when it helps. Operators can ask for a concise answer to
367
+ "what did Memorix use?" through existing context/explain/doctor paths.
368
+
369
+ Acceptance gate:
370
+
371
+ - default tool count stays at the current micro profile level;
372
+ - receipt explains inclusion, omission, freshness, and scheduled work in plain
373
+ language;
374
+ - dashboard/CLI empty, unavailable, stale, and refresh-queued states are
375
+ distinguishable;
376
+ - user-facing docs do not call a deterministic memory map a semantic graph or
377
+ describe a provider foundation as full multimodal retrieval.
378
+
379
+ ### Phase 6: Evaluation, Contribution Review, And Release
380
+
381
+ Run the existing Workset evaluation harness plus new control-plane fixtures,
382
+ full test/build/lint, package inspection, isolated Windows install, stdio MCP
383
+ smoke, and supported-agent integration smoke. Release evidence must include
384
+ the new budgets and no-foreground-wait behavior.
385
+
386
+ ## Open Contributions And Issue Boundaries
387
+
388
+ ### #135: Session Handoff
389
+
390
+ The contributor identified the right product gap. Their branch remains the
391
+ authoritative contribution and is invited to revise against Phase 2. It can be
392
+ merged with full contributor credit when it uses the bounded handoff contract,
393
+ target-project config resolution, explicit historical-data delimiters, and
394
+ positive E2E coverage. Memorix will not reimplement it privately and label it
395
+ as original work.
396
+
397
+ ### #133 / #134: Multimodal Embedding Inputs
398
+
399
+ The contributor's typed input and cache-identity direction is useful. The PR
400
+ cannot close #133 in its current form because its Google routing is not the
401
+ official native protocol, safe URL storage is incomplete, and no MCP media
402
+ input reaches index/retrieval. The contributor can either complete the
403
+ end-to-end path or narrow the PR to a validated capability foundation; both
404
+ remain eligible for review and credit. This phase deliberately separates that
405
+ work from an unsupported promise of "any media in, semantic memory out".
406
+
407
+ ### #136: MemorixBench-Transfer
408
+
409
+ The research artifact stays a draft research track. It is not bundled into a
410
+ product patch merely because its CI is green.
411
+
412
+ ## Explicit Non-Goals
413
+
414
+ - Capture every conversation, terminal output, or hook event by default.
415
+ - Invent a 53-tool management surface to expose internal machinery.
416
+ - Let a session handoff override project instructions or current code.
417
+ - Claim universal multimodal embedding through one OpenAI-compatible endpoint.
418
+ - Merge unrelated historical PRs or rewrite contributor work without credit.
419
+ - Turn Memorix into a cloud knowledge graph service; local-first evidence and
420
+ optional project artifacts remain the product boundary.
421
+
422
+ ## Definition Of Done
423
+
424
+ 1. All automatic context surfaces use the shared assembly/receipt policy.
425
+ 2. Session handoff is bounded, redacted, project-root-correct, and proven by
426
+ hook E2E tests.
427
+ 3. Lifecycle decisions can be explained and foreground requests do not await
428
+ corpus maintenance.
429
+ 4. Embedding capabilities make text behavior honest and leave no false media
430
+ retrieval claim.
431
+ 5. Existing MCP clients retain a compact default profile and documented
432
+ compatibility.
433
+ 6. Evaluation, clean-package smoke, supported-agent smoke, docs, changelog,
434
+ tag, npm package, and release evidence agree before publication.
@@ -54,6 +54,10 @@ For direct use, prefer `memorix ...` commands first. In the 1.2 line, the CLI co
54
54
 
55
55
  Do not ask memory-only users to join coordination state. A lightweight session is enough for memory, retrieval, reasoning, and continuation. Use `joinTeam` / `team_manage(join)` only for explicit task/message/lock coordination or for CLI-agent work managed by `memorix orchestrate`.
56
56
 
57
+ An unbound terminal is intentionally project-scoped: it reads and writes project-visible memory only. Use `memorix identity join --agent-type <agent>` or `memorix identity use --agent-id <id>` only when an operator explicitly needs personal/team memory or coordinated task actions. `memorix identity clear` removes that local selection; `--as <agent-id>` is the one-command script form and still requires an active member of the current project.
58
+
59
+ `--cwd <git-project>` is the canonical way to run direct CLI work from outside a repository. It changes the command's project anchor only; Git remains the source of truth for final project identity.
60
+
57
61
  Use MCP when:
58
62
 
59
63
  - an IDE or agent needs tool calls