Skip to content

Commit bf317be

Browse files
author
Tehan
committed
fix(rebase): complete v0.26 resolution — SQL SET comma, dup pi import, two-phase promotion test, config-docs regen
- storage-meta-shared.ts: add missing comma after cached_m0_project_identity in the persistCachedM0 SET clause (TAKE-BOTH merge dropped the separator). - inject-compartments-pi.ts: drop duplicate renderExternalMemoryBlock import (026b856 added it standalone; 2a8cd71 added it to the consolidated block). - promotion.test.ts: migrate the 3 external-tee tests from the dropped promoteSessionFactsToMemory to upstream's two-phase promoteSessionFactsDurable + embedPromotedFacts (tee now lives post-commit). - configuration.md: regenerate to include memory.external.* rows. - lint:fix import ordering.
1 parent 0d743a6 commit bf317be

5 files changed

Lines changed: 37 additions & 20 deletions

File tree

packages/docs/src/content/docs/reference/configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ Durable project memory, semantic search, and recall features.
103103
| `memory.git_commit_indexing.enabled` | boolean | `false` | Index HEAD git commits for ctx_search (git_commit source). Graduated from experimental.git_commit_indexing; opt-in, default off. Independent of memory.enabled. |
104104
| `memory.git_commit_indexing.since_days` | number (7–3650) | `365` | Days of HEAD history to index (min: 7, max: 3650, default: 365) |
105105
| `memory.git_commit_indexing.max_commits` | number (100–20000) | `2000` | Max commits kept per project; oldest evicted (min: 100, max: 20000, default: 2000) |
106+
| `memory.external` | object || External long-term memory backend (tee). USER config only. |
107+
| `memory.external.provider` | `"hindsight"` \\| `"off"` | `"off"` | External memory backend. 'hindsight' tees memory creations to a Hindsight service; 'off' disables (default). SECURITY: this whole block only honors USER-level config. |
108+
| `memory.external.endpoint` | string || Backend base URL (e.g. http://10.0.0.1:8889). Required when provider is hindsight. |
109+
| `memory.external.api_key` | string || Bearer token for the backend (optional). |
110+
| `memory.external.project_bank` | string | `"mc-{name}-{id8}"` | Bank name template for project-scoped items. Placeholders: {name}=project basename, {id8}=first 8 chars of the project identity hash. |
111+
| `memory.external.main_bank` | string || Bank for user- and global-scoped items. Required when provider is hindsight. Assumed to pre-exist; never created or modified. |
112+
| `memory.external.retain_sources` | `"historian"` \\| `"agent"` \\| `"dreamer"`[] | `["historian","agent","dreamer"]` | Which creation points tee: historian promotion, agent ctx_memory writes, dreamer user-memory promotion. |
113+
| `memory.external.tags` | string[] | `[]` | Static tags attached to every retained item. |
114+
| `memory.external.recall` | object || Unified read path: session-start recall + ctx_search external source. |
115+
| `memory.external.recall.enabled` | boolean | `true` | Session-start recall from the external backend, merged into the context injection (default: true). |
116+
| `memory.external.recall.timeout_ms` | number (500–15000) | `3000` | Max wait for recall at the first render of a session (already cache-cold). Late results ride the m[1] delta. (default: 3000) |
117+
| `memory.external.recall.max_tokens` | number (256–8192) | `2048` | Token budget per recall slice (project / profile / global each). (default: 2048) |
118+
| `memory.external.recall.dedup_threshold` | number (0.5–0.99) | `0.85` | Cosine similarity above which a recalled item is dropped as a duplicate of a local memory. Hash-only fallback when embeddings are unavailable. (default: 0.85) |
119+
| `memory.external.recall.global_tags` | string[] | `[]` | Tag filter for the global (main-bank) recall slice, matched with tags_match 'any' (untagged content INCLUDED). Empty = no filter (full autoRecall replacement). |
120+
| `memory.external.recall.global_from_prompt` | boolean | `false` | Include an excerpt of the session's FIRST user prompt in the global-slice recall query (the project name is always included). The first prompt is fixed for the session, so the query — and the frozen recall snapshot — stays deterministic. Default false: pure template query. |
121+
| `memory.external.recall.search` | boolean | `true` | Expose the ctx_search 'external' source (project + main bank). (default: true) |
122+
| `memory.external.recall.mental_models` | boolean | `true` | Use Hindsight mental models as the fast path for the project/profile recall slices (single GET, server-refreshed), falling back to recall when absent/empty. (default: true) |
123+
| `memory.external.recall.profile_mental_models` | string[] | `["user-preferences"]` | Main-bank mental-model names (case-insensitive) used for the profile slice. The main bank is never modified by the plugin — create these manually. |
106124
| `embedding` | object || Embedding provider configuration |
107125
| `embedding.provider` | `"local"` \\| `"openai-compatible"` \\| `"off"` | `"local"` | Embedding provider. 'local' uses Xenova/all-MiniLM-L6-v2, 'openai-compatible' requires endpoint and model, 'off' disables embeddings. |
108126
| `embedding.model` | string || Embedding model name. Required for openai-compatible, ignored for local. |

packages/pi-plugin/src/inject-compartments-pi.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,19 @@
2525
* historyRefreshSessions signal.
2626
*/
2727

28+
import {
29+
computeRecallSnapshotHash,
30+
type ExternalRecallSnapshot,
31+
readExternalRecallHash,
32+
readExternalRecallSnapshot,
33+
} from "@magic-context/core/features/magic-context/memory/external-recall-read";
2834
import {
2935
getMaxMemoryIdForProjects,
3036
getMemoriesByProject,
3137
getMemoriesByProjects,
3238
readNewMemoriesForM1Union,
3339
} from "@magic-context/core/features/magic-context/memory/storage-memory";
3440
import type { Memory } from "@magic-context/core/features/magic-context/memory/types";
35-
import {
36-
computeRecallSnapshotHash,
37-
type ExternalRecallSnapshot,
38-
readExternalRecallHash,
39-
readExternalRecallSnapshot,
40-
} from "@magic-context/core/features/magic-context/memory/external-recall-read";
41-
import { renderExternalMemoryBlock } from "@magic-context/core/hooks/magic-context/inject-compartments";
4241
import {
4342
type ContextDatabase,
4443
clearCachedM0M1,

packages/pi-plugin/src/pi-historian-runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ import {
4747
appendCompartments,
4848
getCompartments,
4949
} from "@magic-context/core/features/magic-context/compartment-storage";
50+
import type { PromotedMemoryRef } from "@magic-context/core/features/magic-context/memory";
5051
import {
5152
embedPromotedFacts,
5253
promoteSessionFactsDurable,
5354
} from "@magic-context/core/features/magic-context/memory";
54-
import type { PromotedMemoryRef } from "@magic-context/core/features/magic-context/memory";
5555
import { resolveProjectIdentity } from "@magic-context/core/features/magic-context/memory/project-identity";
5656
import { getMemoriesByProject } from "@magic-context/core/features/magic-context/memory/storage-memory";
5757
import {

packages/plugin/src/features/magic-context/memory/promotion.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const {
3535
getMemoriesByProject,
3636
insertMemory,
3737
} = await import("./storage-memory");
38-
const { promoteSessionFactsDurable } = await import("./promotion");
38+
const { promoteSessionFactsDurable, embedPromotedFacts } = await import("./promotion");
3939

4040
let db: Database | null = null;
4141

@@ -440,13 +440,10 @@ describe("promotion", () => {
440440
db = makeMemoryDatabase();
441441
const calls = captureTee();
442442

443-
promoteSessionFactsToMemory(
444-
db,
445-
"ses_1",
446-
"git:rootsha",
447-
[{ category: "PROJECT_RULES", content: "tee me" }],
448-
{ projectName: "myproj" },
449-
);
443+
const refs = promoteSessionFactsDurable(db, "ses_1", "git:rootsha", [
444+
{ category: "PROJECT_RULES", content: "tee me" },
445+
]);
446+
await embedPromotedFacts(db, "ses_1", "git:rootsha", refs, { projectName: "myproj" });
450447
await Bun.sleep(10);
451448

452449
expect(calls.length).toBe(1);
@@ -465,13 +462,15 @@ describe("promotion", () => {
465462
db = makeMemoryDatabase();
466463
const calls = captureTee();
467464

468-
promoteSessionFactsToMemory(db, "ses_1", "git:rootsha", [
465+
const refs1 = promoteSessionFactsDurable(db, "ses_1", "git:rootsha", [
469466
{ category: "PROJECT_RULES", content: "dup fact" },
470467
]);
468+
await embedPromotedFacts(db, "ses_1", "git:rootsha", refs1);
471469
await Bun.sleep(10);
472-
promoteSessionFactsToMemory(db, "ses_2", "git:rootsha", [
470+
const refs2 = promoteSessionFactsDurable(db, "ses_2", "git:rootsha", [
473471
{ category: "PROJECT_RULES", content: "dup fact" },
474472
]);
473+
await embedPromotedFacts(db, "ses_2", "git:rootsha", refs2);
475474
await Bun.sleep(10);
476475

477476
expect(calls.length).toBe(1);
@@ -481,9 +480,10 @@ describe("promotion", () => {
481480
db = makeMemoryDatabase();
482481
const calls = captureTee();
483482

484-
promoteSessionFactsToMemory(db, "ses_1", "git:rootsha", [
483+
const refs = promoteSessionFactsDurable(db, "ses_1", "git:rootsha", [
485484
{ category: "NOT_A_CATEGORY", content: "skip me" },
486485
]);
486+
await embedPromotedFacts(db, "ses_1", "git:rootsha", refs);
487487
await Bun.sleep(10);
488488

489489
expect(calls.length).toBe(0);

packages/plugin/src/features/magic-context/storage-meta-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ export function persistCachedM0(
504504
cached_m0_upgrade_state = ?,
505505
cached_m0_system_hash = ?,
506506
cached_m0_model_key = ?,
507-
cached_m0_project_identity = ?
507+
cached_m0_project_identity = ?,
508508
cached_m0_external_recall_hash = ?
509509
WHERE session_id = ?`,
510510
).run(

0 commit comments

Comments
 (0)