@myrialabs/clopen 0.4.37 → 0.4.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/backend/auth/permissions.ts +39 -0
- package/backend/bootstrap.ts +16 -0
- package/backend/chat/stream-manager.ts +1 -1
- package/backend/database/crypto/envelope.test.ts +93 -0
- package/backend/database/crypto/envelope.ts +127 -0
- package/backend/database/crypto/index.ts +22 -0
- package/backend/database/crypto/master-key.ts +129 -0
- package/backend/database/crypto/secret-columns.ts +151 -0
- package/backend/database/migrations/071_create_notes_tables.ts +90 -0
- package/backend/database/migrations/072_encrypt_stored_secrets.ts +107 -0
- package/backend/database/migrations/073_create_integration_tables.ts +119 -0
- package/backend/database/migrations/074_create_work_tables.ts +94 -0
- package/backend/database/migrations/075_create_deploy_bindings.ts +54 -0
- package/backend/database/migrations/076_remove_memory_code_graph.ts +229 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +150 -0
- package/backend/database/migrations/index.ts +49 -0
- package/backend/database/queries/db-client-connection-queries.ts +42 -12
- package/backend/database/queries/deploy-queries.ts +124 -0
- package/backend/database/queries/engine-queries.ts +23 -10
- package/backend/database/queries/graph-queries.ts +291 -247
- package/backend/database/queries/index.ts +10 -1
- package/backend/database/queries/integration-db-link-queries.ts +168 -0
- package/backend/database/queries/integration-queries.ts +325 -0
- package/backend/database/queries/mcp-server-queries.ts +38 -11
- package/backend/database/queries/note-queries.test.ts +190 -0
- package/backend/database/queries/note-queries.ts +269 -0
- package/backend/database/queries/profile-queries.ts +1 -1
- package/backend/database/queries/ssh-connection-queries.ts +19 -8
- package/backend/database/queries/work-queries.ts +210 -0
- package/backend/db-client/integrations/index.ts +37 -0
- package/backend/db-client/integrations/links.ts +533 -0
- package/backend/db-client/integrations/projector.test.ts +280 -0
- package/backend/db-client/integrations/projector.ts +256 -0
- package/backend/db-client/integrations/supabase-service.ts +266 -0
- package/backend/db-client/providers/registry.ts +27 -0
- package/backend/db-client/providers/supabase/adapter.ts +500 -0
- package/backend/db-client/providers/supabase/api-types.ts +92 -0
- package/backend/db-client/providers/supabase/apply-migration.ts +104 -0
- package/backend/db-client/providers/supabase/client.ts +259 -0
- package/backend/db-client/providers/supabase/features.ts +502 -0
- package/backend/db-client/providers/supabase/local.test.ts +78 -0
- package/backend/db-client/providers/supabase/local.ts +137 -0
- package/backend/db-client/providers/types.ts +137 -0
- package/backend/deployments/bindings.test.ts +43 -0
- package/backend/deployments/bindings.ts +216 -0
- package/backend/deployments/index.ts +53 -0
- package/backend/deployments/log-streams.ts +214 -0
- package/backend/deployments/prompts.ts +70 -0
- package/backend/deployments/providers/vercel/adapter.ts +757 -0
- package/backend/deployments/providers/vercel/build-logs.test.ts +80 -0
- package/backend/deployments/providers/vercel/build-logs.ts +211 -0
- package/backend/deployments/providers/vercel/client.ts +203 -0
- package/backend/deployments/providers/vercel/list.test.ts +624 -0
- package/backend/deployments/providers/vercel/normalise.test.ts +115 -0
- package/backend/deployments/providers/vercel/normalise.ts +113 -0
- package/backend/deployments/providers/vercel/types.ts +104 -0
- package/backend/deployments/registry.ts +27 -0
- package/backend/deployments/service.ts +458 -0
- package/backend/deployments/types.ts +278 -0
- package/backend/engine/docs/artifacts.md +22 -9
- package/backend/files/os-clipboard.test.ts +209 -0
- package/backend/files/os-clipboard.ts +567 -0
- package/backend/http/integration-hooks.ts +42 -0
- package/backend/http/notes-images.test.ts +228 -0
- package/backend/http/notes-images.ts +196 -0
- package/backend/index.ts +13 -0
- package/backend/integrations/accounts.ts +229 -0
- package/backend/integrations/health.ts +146 -0
- package/backend/integrations/index.ts +36 -0
- package/backend/integrations/projections/index.ts +0 -0
- package/backend/integrations/projections/mcp-projector.test.ts +204 -0
- package/backend/integrations/projections/mcp-projector.ts +163 -0
- package/backend/integrations/projections/types.ts +63 -0
- package/backend/integrations/registry/define.ts +38 -0
- package/backend/integrations/registry/index.ts +60 -0
- package/backend/integrations/registry/providers/context7.ts +44 -0
- package/backend/integrations/registry/providers/firecrawl.ts +41 -0
- package/backend/integrations/registry/providers/github.ts +78 -0
- package/backend/integrations/registry/providers/supabase.ts +61 -0
- package/backend/integrations/registry/providers/vercel.ts +46 -0
- package/backend/integrations/registry/types.ts +96 -0
- package/backend/integrations/webhooks/gateway.ts +160 -0
- package/backend/integrations/webhooks/verify.ts +65 -0
- package/backend/mcp/README.md +25 -3
- package/backend/mcp/external/config.ts +35 -1
- package/backend/mcp/index.ts +1 -1
- package/backend/mcp/internal/config.ts +1 -1
- package/backend/mcp/internal/servers/memory-graph/description.ts +3 -3
- package/backend/mcp/internal/servers/memory-graph/runner.ts +4 -9
- package/backend/mcp/internal/servers/memory-graph/schema.ts +0 -4
- package/backend/memory/README.md +57 -34
- package/backend/memory/compose.test.ts +3 -3
- package/backend/memory/compose.ts +6 -9
- package/backend/memory/config.ts +0 -5
- package/backend/memory/consolidate.ts +1 -2
- package/backend/memory/context.test.ts +8 -54
- package/backend/memory/context.ts +19 -25
- package/backend/memory/extract/episodic.ts +10 -12
- package/backend/memory/extract/index.ts +23 -52
- package/backend/memory/extract/scheduler.ts +3 -6
- package/backend/memory/index.ts +6 -5
- package/backend/memory/invalidate.ts +36 -48
- package/backend/memory/layout.ts +319 -130
- package/backend/memory/retention.ts +12 -42
- package/backend/memory/retrieval.eval.test.ts +2 -2
- package/backend/memory/retrieval.test.ts +228 -183
- package/backend/memory/retrieval.ts +22 -21
- package/backend/memory/revise.test.ts +62 -116
- package/backend/memory/revise.ts +0 -1
- package/backend/memory/view.ts +8 -5
- package/backend/notes/access.test.ts +82 -0
- package/backend/notes/access.ts +27 -0
- package/backend/notes/storage.test.ts +77 -0
- package/backend/notes/storage.ts +114 -0
- package/backend/permissions/service.ts +2 -2
- package/backend/profiles/service.ts +1 -1
- package/backend/projects/project-cleanup.ts +6 -0
- package/backend/snapshot/helpers.ts +35 -41
- package/backend/snapshot/snapshot-service.ts +90 -0
- package/backend/snapshot/turn-changes.test.ts +163 -0
- package/backend/snapshot/turn-changes.ts +131 -0
- package/backend/work/bindings.ts +124 -0
- package/backend/work/index.ts +42 -0
- package/backend/work/prompts.ts +150 -0
- package/backend/work/providers/github/actions-logs.ts +180 -0
- package/backend/work/providers/github/adapter.test.ts +88 -0
- package/backend/work/providers/github/adapter.ts +1255 -0
- package/backend/work/providers/github/client.ts +280 -0
- package/backend/work/providers/github/list-range.test.ts +158 -0
- package/backend/work/providers/github/token-kind.test.ts +42 -0
- package/backend/work/pull-requests.ts +242 -0
- package/backend/work/registry.ts +27 -0
- package/backend/work/service.ts +436 -0
- package/backend/work/start-work.test.ts +71 -0
- package/backend/work/start-work.ts +232 -0
- package/backend/work/types.ts +180 -0
- package/backend/ws/db-client/accounts.ts +225 -0
- package/backend/ws/db-client/connections.ts +34 -3
- package/backend/ws/db-client/context.ts +37 -0
- package/backend/ws/db-client/index.ts +20 -1
- package/backend/ws/db-client/supabase.ts +188 -0
- package/backend/ws/deployments/actions.ts +360 -0
- package/backend/ws/deployments/context.ts +43 -0
- package/backend/ws/deployments/crud.ts +152 -0
- package/backend/ws/deployments/index.ts +15 -0
- package/backend/ws/deployments/schemas.ts +183 -0
- package/backend/ws/files/clipboard.ts +78 -0
- package/backend/ws/files/index.ts +5 -0
- package/backend/ws/git/diff-budget.ts +70 -11
- package/backend/ws/index.ts +16 -2
- package/backend/ws/integrations/crud.ts +219 -0
- package/backend/ws/integrations/index.ts +22 -0
- package/backend/ws/mcp/crud.ts +25 -1
- package/backend/ws/memory/crud.ts +4 -16
- package/backend/ws/notes/index.ts +278 -0
- package/backend/ws/profiles/crud.ts +1 -1
- package/backend/ws/snapshot/changes.ts +279 -0
- package/backend/ws/snapshot/index.ts +4 -3
- package/backend/ws/work/actions.ts +206 -0
- package/backend/ws/work/context.ts +51 -0
- package/backend/ws/work/crud.ts +347 -0
- package/backend/ws/work/index.ts +17 -0
- package/backend/ws/work/pull-requests.ts +177 -0
- package/backend/ws/work/schemas.ts +226 -0
- package/dist/assets/{index-sJmS_CCm.js → index-BrF6nqld.js} +1 -1
- package/dist/assets/{index-Bik9TCBi.js → index-C8Gi-b6U.js} +1 -1
- package/dist/assets/main-Bd3gb79F.css +1 -0
- package/dist/assets/main-Bo1hD7mt.js +1191 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/shared/constants/engine-tools.ts +1 -1
- package/shared/constants/tool-icons.ts +42 -0
- package/shared/types/database/schema.ts +41 -0
- package/shared/types/db-client/connection.ts +6 -0
- package/shared/types/db-client/index.ts +2 -0
- package/shared/types/db-client/integrations.ts +174 -0
- package/shared/types/db-client/supabase.ts +131 -0
- package/shared/types/deployments.ts +382 -0
- package/shared/types/integrations.ts +140 -0
- package/shared/types/memory.ts +34 -51
- package/shared/types/stores/settings.ts +8 -0
- package/shared/types/ui/components.ts +1 -1
- package/shared/types/work.ts +426 -0
- package/shared/utils/diff-calculator.test.ts +89 -0
- package/shared/utils/diff-calculator.ts +30 -65
- package/shared/utils/logger.ts +4 -0
- package/backend/memory/extract/languages.ts +0 -176
- package/backend/memory/extract/structural.test.ts +0 -215
- package/backend/memory/extract/structural.ts +0 -364
- package/backend/ws/snapshot/content.ts +0 -85
- package/dist/assets/main-DLqolBI2.css +0 -1
- package/dist/assets/main-Df1I3hnw.js +0 -1096
package/backend/mcp/README.md
CHANGED
|
@@ -6,7 +6,7 @@ disk and in their namespace keys:
|
|
|
6
6
|
| | **Internal** (`internal/`) | **External** (`external/`) |
|
|
7
7
|
|---|---|---|
|
|
8
8
|
| What | Custom tools defined in code via `defineServer()` | Servers the user installs from the official MCP registry |
|
|
9
|
-
| Managed | By developers (this README) | By users in **Settings →
|
|
9
|
+
| Managed | By developers (this README) | By users in **Settings → Integrations** |
|
|
10
10
|
| Stored | In code (`internal/servers/`) | In the DB (`mcp_servers` table) |
|
|
11
11
|
| Namespace | `clopen-mcp` bridge (non-Claude) / server name (Claude) | one bare `<slug>` per server (no prefix) |
|
|
12
12
|
| Execution | In-process (no subprocess) | Engine connects to Clopen's `/mcp/ext/<slug>` proxy; Clopen connects to the real upstream (stdio subprocess or remote HTTP) |
|
|
@@ -19,6 +19,27 @@ The rest of this document covers the **internal** custom-tool system. External
|
|
|
19
19
|
servers need no code — see `external/registry-client.ts`, `external/config.ts`,
|
|
20
20
|
and `external/proxy.ts` (the per-server `/mcp/ext/<slug>` proxy bridge).
|
|
21
21
|
|
|
22
|
+
### Where `backend/integrations/` fits
|
|
23
|
+
|
|
24
|
+
MCP is a **protocol**; an integration is a **credential with capabilities**.
|
|
25
|
+
They are separate modules on purpose, and `backend/integrations/` is the newer
|
|
26
|
+
of the two:
|
|
27
|
+
|
|
28
|
+
- `backend/mcp/` owns installing, proxying, per-engine tool exposure and
|
|
29
|
+
MCP-level OAuth. It knows nothing about accounts.
|
|
30
|
+
- `backend/integrations/` owns the account and its credential. One of the
|
|
31
|
+
capabilities an account can offer — `agent-tools` — **projects** a row into
|
|
32
|
+
`mcp_servers`, which is the only place the two meet.
|
|
33
|
+
|
|
34
|
+
That direction matters. A projected row is read by `resolveServerRow()` and by
|
|
35
|
+
every per-engine config builder exactly as a hand-installed one is, so nothing
|
|
36
|
+
in this subsystem has to know accounts exist. And most integrations project no
|
|
37
|
+
MCP server at all — a database provider projects a `db_client_connections` row,
|
|
38
|
+
a chat provider registers a notification channel.
|
|
39
|
+
|
|
40
|
+
Both appear under one UI, **Settings → Integrations**, which absorbed the old
|
|
41
|
+
Connectors section.
|
|
42
|
+
|
|
22
43
|
> **External servers are proxied, not direct.** Engines never connect straight
|
|
23
44
|
> to a third-party MCP server. Clopen connects to it (as an MCP client) and
|
|
24
45
|
> re-exposes its **sanitized** tools through a per-server endpoint on the same
|
|
@@ -199,7 +220,7 @@ backend/mcp/
|
|
|
199
220
|
│ ├── types.ts # CatalogServer / ResolvedExternalServer
|
|
200
221
|
│ ├── registry-client.ts # Fetch + normalise registry.modelcontextprotocol.io
|
|
201
222
|
│ ├── proxy.ts # `/mcp/ext/<slug>` proxy: Clopen ↔ upstream, schema sanitiser
|
|
202
|
-
│ ├── probe.ts # Connection health probe (Settings →
|
|
223
|
+
│ ├── probe.ts # Connection health probe (Settings → Integrations status)
|
|
203
224
|
│ ├── oauth.ts # Centralized OAuth (discovery + dynamic reg + PKCE)
|
|
204
225
|
│ └── config.ts # Per-engine builders (bridge URL, bare <slug>) + resolveExternalToolName
|
|
205
226
|
└── README.md # This file
|
|
@@ -1305,7 +1326,8 @@ checklist in `backend/engine/README.md` §10.12. The summary:
|
|
|
1305
1326
|
|
|
1306
1327
|
Everything above describes **internal** custom tools (the `clopen-mcp`
|
|
1307
1328
|
bridge). **External** servers are the ones a user installs from the official
|
|
1308
|
-
registry (Settings →
|
|
1329
|
+
registry (Settings → Integrations → Add → Browse the MCP registry), stored in
|
|
1330
|
+
the `mcp_servers` table.
|
|
1309
1331
|
|
|
1310
1332
|
### Proxied through the bridge (not direct)
|
|
1311
1333
|
|
|
@@ -110,7 +110,7 @@ export function getEnabledExternalServers(profileFilter?: Set<string>): Resolved
|
|
|
110
110
|
//
|
|
111
111
|
// When a Profile is active it is the source of truth for which connectors run:
|
|
112
112
|
// a connector it references is emitted even if globally disabled in the
|
|
113
|
-
//
|
|
113
|
+
// Integrations settings, and the global enable toggle is ignored. Without a
|
|
114
114
|
// profile filter, only enabled servers apply (unchanged).
|
|
115
115
|
const rows = profileFilter ? mcpServerQueries.getAll() : mcpServerQueries.getEnabled();
|
|
116
116
|
return rows
|
|
@@ -268,3 +268,37 @@ function logBuilt(engine: string, out: Record<string, unknown>): void {
|
|
|
268
268
|
const count = Object.keys(out).length;
|
|
269
269
|
if (count > 0) debug.log('mcp', `🧩 ${engine} external MCP: ${count} server(s)`);
|
|
270
270
|
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The config each engine is handed for ONE external server, keyed by engine.
|
|
274
|
+
*
|
|
275
|
+
* Surfaced in the Integrations detail view. It exists because "what does the
|
|
276
|
+
* engine actually receive" is otherwise unanswerable from the UI: every server,
|
|
277
|
+
* whatever its real transport, is emitted as a Streamable-HTTP remote pointing
|
|
278
|
+
* at the `/mcp/ext/<slug>` proxy, so the row a user configured and the config an
|
|
279
|
+
* engine sees do not look alike. Showing the row and calling it the engine's
|
|
280
|
+
* config would be a lie of omission.
|
|
281
|
+
*
|
|
282
|
+
* Returns `{}` for a server that is disabled or unknown — the honest answer,
|
|
283
|
+
* since a disabled server is handed to nobody.
|
|
284
|
+
*/
|
|
285
|
+
export function getEngineConfigsForServer(slug: string): Record<string, unknown> {
|
|
286
|
+
const namespace = externalNamespace(slug);
|
|
287
|
+
const pick = (config: Record<string, unknown>): unknown => config[namespace];
|
|
288
|
+
|
|
289
|
+
const out: Record<string, unknown> = {};
|
|
290
|
+
const builders: Record<string, () => Record<string, unknown>> = {
|
|
291
|
+
'claude-code': () => getClaudeExternalMcpConfig() as Record<string, unknown>,
|
|
292
|
+
opencode: () => getOpenCodeExternalMcpConfig() as Record<string, unknown>,
|
|
293
|
+
codex: () => getCodexExternalMcpConfig() as Record<string, unknown>,
|
|
294
|
+
copilot: () => getCopilotExternalMcpConfig() as Record<string, unknown>,
|
|
295
|
+
cursor: () => getCursorExternalMcpConfig() as Record<string, unknown>,
|
|
296
|
+
qwen: () => getQwenExternalMcpConfig() as Record<string, unknown>
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
for (const [engine, build] of Object.entries(builders)) {
|
|
300
|
+
const config = pick(build());
|
|
301
|
+
if (config !== undefined) out[engine] = config;
|
|
302
|
+
}
|
|
303
|
+
return out;
|
|
304
|
+
}
|
package/backend/mcp/index.ts
CHANGED
|
@@ -75,7 +75,7 @@ export {
|
|
|
75
75
|
|
|
76
76
|
// External catalog + types (used by the WS layer and Settings → MCP)
|
|
77
77
|
export { listRegistryServers, mapRegistryServer } from './external/registry-client';
|
|
78
|
-
export { getEnabledExternalServers, resolveServerRow, remoteNeedsOAuth } from './external/config';
|
|
78
|
+
export { getEnabledExternalServers, resolveServerRow, remoteNeedsOAuth, getEngineConfigsForServer } from './external/config';
|
|
79
79
|
export { listExternalServerTools, callExternalServerTool } from './external/proxy';
|
|
80
80
|
export { parseToolOverrides, resolveToolExposure, pruneToolOverrides, MCP_ENGINES } from './external/tools';
|
|
81
81
|
export type { ToolExposure } from './external/tools';
|
|
@@ -289,7 +289,7 @@ export function getEnabledServerNames(): string[] {
|
|
|
289
289
|
* Internal server names ACTIVE for a stream. When a Profile is active, its
|
|
290
290
|
* referenced connector set is the source of truth — a referenced internal server
|
|
291
291
|
* counts even if globally disabled, and one NOT referenced is excluded (built-in
|
|
292
|
-
* connectors appear in the profile's
|
|
292
|
+
* connectors appear in the profile's Integrations picker, so this is an explicit
|
|
293
293
|
* choice). Without a profile, every globally-enabled server is active (unchanged).
|
|
294
294
|
*/
|
|
295
295
|
export function activeInternalServerNames(profileFilter?: Set<string>): string[] {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* as importantly, that it does not have to write anything.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export const memoryToolDescription = `Query and curate Clopen's Memory Graph — a persistent store of what has been decided, tried and learned across past sessions of this workspace
|
|
7
|
+
export const memoryToolDescription = `Query and curate Clopen's Memory Graph — a persistent store of what has been decided, tried and learned across past sessions of this workspace. It is shared by every AI engine and survives session switches, so a memory written months ago by a different model is still here.
|
|
8
8
|
|
|
9
9
|
YOU DO NOT NEED TO RECORD ANYTHING. Memories are written automatically from each finished conversation turn, including anything the user asks you to remember — saying "remember that I prefer X" is enough on its own, and there is deliberately no action here that stores a new memory. That is one write path rather than two, so what ends up in the graph is predictable. This tool is for reading it and for correcting what is already there.
|
|
10
10
|
|
|
@@ -13,13 +13,13 @@ Reach for it when:
|
|
|
13
13
|
- something is failing in a way that feels like it has failed before
|
|
14
14
|
- you need to know why code looks the way it does, when the code itself does not say
|
|
15
15
|
- the user refers to a past discussion, decision or preference
|
|
16
|
-
- you
|
|
16
|
+
- you are about to change a file, and want to know what was decided about it
|
|
17
17
|
- a memory you were shown is wrong, out of date, or filed under the wrong kind
|
|
18
18
|
|
|
19
19
|
Relevant memories are already prepended to each turn automatically, so this tool is for going DEEPER than that: following up on something you have just discovered, asking about another project, or walking the graph. It is not a substitute for reading what you were given.
|
|
20
20
|
|
|
21
21
|
Actions:
|
|
22
|
-
- recall — natural-language search across memories
|
|
22
|
+
- recall — natural-language search across the memories. Runs keyword and semantic search together and expands into the graph, so it finds paraphrases as well as exact names. Use scope "all" to search every project, which is how you find that a problem was already solved in another repository.
|
|
23
23
|
- neighbours — walk outward from a node returned by recall. This is where the graph earns its keep: the memory you need is often adjacent to your match rather than being it.
|
|
24
24
|
- timeline — recent memories in order, for "what have we been doing here".
|
|
25
25
|
- update — correct a memory in place. Prefer this whenever an existing memory is nearly right: it keeps the node's connections and its history, where retiring it and letting a new one be written loses both.
|
|
@@ -69,10 +69,7 @@ function renderHit(hit: RetrievalHit, currentProjectId: string | null): string {
|
|
|
69
69
|
: node.projectId !== currentProjectId
|
|
70
70
|
? 'learned in another project'
|
|
71
71
|
: node.scope;
|
|
72
|
-
const detail =
|
|
73
|
-
node.kind === 'structural'
|
|
74
|
-
? (node.symbol ? `${node.symbol} — ${node.path}` : (node.path ?? ''))
|
|
75
|
-
: node.body.split('\n')[0].slice(0, 260);
|
|
72
|
+
const detail = node.body.split('\n')[0].slice(0, 260);
|
|
76
73
|
|
|
77
74
|
return [
|
|
78
75
|
`[${node.id}] (${node.subkind}, ${where}, confidence ${node.confidence.toFixed(2)}, found by ${found})`,
|
|
@@ -84,7 +81,7 @@ function renderHit(hit: RetrievalHit, currentProjectId: string | null): string {
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
function renderNode(node: GraphNode, prefix = ''): string {
|
|
87
|
-
const detail = node.
|
|
84
|
+
const detail = node.body.split('\n')[0].slice(0, 200);
|
|
88
85
|
return `${prefix}[${node.id}] (${node.subkind}) ${node.label}${detail ? `\n${prefix} ${detail}` : ''}`;
|
|
89
86
|
}
|
|
90
87
|
|
|
@@ -120,7 +117,6 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
|
|
|
120
117
|
// case memory exists to cover.
|
|
121
118
|
crossProject: true,
|
|
122
119
|
sessionId: ctx.sessionId ?? undefined,
|
|
123
|
-
kinds: op.kind && op.kind !== 'both' ? [op.kind] : undefined,
|
|
124
120
|
limit: op.limit ?? 10,
|
|
125
121
|
// An explicit lookup is answered with what MATCHES it, not with what
|
|
126
122
|
// matches it plus everything one edge away. Expansion belongs to
|
|
@@ -260,7 +256,7 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
|
|
|
260
256
|
...(op.subkind !== undefined && { subkind: op.subkind })
|
|
261
257
|
},
|
|
262
258
|
// An agent's correction is an agent's correction. Recording it as the
|
|
263
|
-
// user's would exempt the node from
|
|
259
|
+
// user's would exempt the node from staleness decay, from eviction and
|
|
264
260
|
// from consolidation, and would tell every future turn a person had
|
|
265
261
|
// stated it — authority the model did not earn by editing.
|
|
266
262
|
'agent'
|
|
@@ -291,8 +287,7 @@ async function runOne(op: Operation, ctx: Context): Promise<OperationReport> {
|
|
|
291
287
|
action: op.action,
|
|
292
288
|
ok: true,
|
|
293
289
|
text: [
|
|
294
|
-
`${stats.nodes}
|
|
295
|
-
` episodic: ${stats.episodic} structural: ${stats.structural}`,
|
|
290
|
+
`${stats.nodes} memories, ${stats.edges} connections`,
|
|
296
291
|
` scope — session ${stats.byScope.session}, project ${stats.byScope.project}, global ${stats.byScope.global}`,
|
|
297
292
|
` ${stats.vectors} node(s) have semantic vectors`,
|
|
298
293
|
` ${stats.entities} canonical entity/entities, ${stats.confirmedUseful} confirmed useful`,
|
|
@@ -42,10 +42,6 @@ const recall = z.object({
|
|
|
42
42
|
.describe(
|
|
43
43
|
'project (default): this project plus global memories. all: every project — use when the question is not about the current codebase, or to find how something was solved elsewhere.'
|
|
44
44
|
),
|
|
45
|
-
kind: z
|
|
46
|
-
.enum(['episodic', 'structural', 'both'])
|
|
47
|
-
.optional()
|
|
48
|
-
.describe('episodic = decisions/patterns/failures; structural = files/symbols/dependencies; both (default)'),
|
|
49
45
|
limit: z.number().int().min(1).max(40).optional().describe('Maximum results. Default 10.')
|
|
50
46
|
});
|
|
51
47
|
|
package/backend/memory/README.md
CHANGED
|
@@ -32,14 +32,15 @@ what was already settled, and switching engine loses it entirely.
|
|
|
32
32
|
```
|
|
33
33
|
a turn finishes
|
|
34
34
|
│
|
|
35
|
-
├── snapshot disk diff ──→
|
|
36
|
-
│
|
|
37
|
-
└── transcript ──→ episodic extraction (model)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
├── snapshot disk diff ──→ invalidation (ages what moved) ─┐
|
|
36
|
+
│ │
|
|
37
|
+
└── transcript ──→ episodic extraction (model) ────────────┤
|
|
38
|
+
▼
|
|
39
|
+
┌──────────────────┐
|
|
40
|
+
│ graph_nodes │
|
|
41
|
+
│ graph_edges │
|
|
42
|
+
│ graph_node_paths │
|
|
43
|
+
└────────┬─────────┘
|
|
43
44
|
│
|
|
44
45
|
┌──────────────────┴─────────┐
|
|
45
46
|
▼ ▼
|
|
@@ -58,24 +59,29 @@ Nothing on the read path calls a model or touches the network.
|
|
|
58
59
|
|
|
59
60
|
---
|
|
60
61
|
|
|
61
|
-
##
|
|
62
|
+
## One Store, Memories Only
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
Every node is a memory: a decision, a pattern, a failure, a preference, an
|
|
65
|
+
observation or an entity, written by a model reading each finished turn.
|
|
66
|
+
|
|
67
|
+
It used to hold the codebase alongside them — a node per file, per directory and
|
|
68
|
+
up to twenty-five per file's symbols. Measured on a real store that half was 81%
|
|
69
|
+
of the nodes and 88% of the edges, it never reached a prompt (an agent can read
|
|
70
|
+
the repository), and it won BM25 on any turn that mentioned a path. Migration 076
|
|
71
|
+
removed it.
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
What the half was genuinely for survives as an attribute. `graph_node_paths`
|
|
74
|
+
records the files each memory claims something about — shaped exactly like
|
|
75
|
+
`graph_node_entities`, which records the subjects it names. Those paths:
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
- are joined into the memory's indexed text, so a pasted path finds what is known
|
|
78
|
+
about it;
|
|
79
|
+
- are what `invalidate.ts` ages a memory against when the file changes;
|
|
80
|
+
- are what an anchored query seeds from when the turn's text says nothing.
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
The paths come from the **disk diff** and from extraction, not from tool calls, so
|
|
83
|
+
a file rewritten through Bash or a codemod counts as reliably as one edited with
|
|
84
|
+
an edit tool.
|
|
79
85
|
|
|
80
86
|
---
|
|
81
87
|
|
|
@@ -169,9 +175,9 @@ by then the secret is in a durable, re-injected, instance-wide store.
|
|
|
169
175
|
| --- | --- | --- |
|
|
170
176
|
| Belief revision | `revise.ts` | Records that two memories disagree (`contradicts`) |
|
|
171
177
|
| Read-time resolution | `context.ts` | Decides which is current, per turn |
|
|
172
|
-
| Structural invalidation | `invalidate.ts` | Sets `stale_at` when
|
|
178
|
+
| Structural invalidation | `invalidate.ts` | Sets `stale_at` when a file the memory names changes |
|
|
173
179
|
| Consolidation | `consolidate.ts` | Merges memories stating the same thing |
|
|
174
|
-
| Retention | `retention.ts` | Bounds growth
|
|
180
|
+
| Retention | `retention.ts` | Bounds growth: evicts, then purges, what earned nothing |
|
|
175
181
|
| Reach classification | `judge.ts` | Decides which memories travel between projects |
|
|
176
182
|
| Maintenance loop | `maintenance.ts` | Runs the above on a timer |
|
|
177
183
|
|
|
@@ -277,8 +283,8 @@ Split across two settings screens on purpose:
|
|
|
277
283
|
|
|
278
284
|
- **Settings → Model → Memory** — which model writes memories. The only place
|
|
279
285
|
memory uses a model at all.
|
|
280
|
-
- **Settings → Infrastructure → Memory** — what memory does: master switch,
|
|
281
|
-
memories, auto-recall.
|
|
286
|
+
- **Settings → Infrastructure → Memory** — what memory does: master switch,
|
|
287
|
+
record memories, auto-recall.
|
|
282
288
|
|
|
283
289
|
Stored in the `settings` table via `config.ts`. Mutations are admin-only
|
|
284
290
|
(`backend/auth/permissions.ts`), matching skills and MCP servers: memory is
|
|
@@ -292,17 +298,25 @@ member repositories they have no access to.
|
|
|
292
298
|
|
|
293
299
|
## Schema
|
|
294
300
|
|
|
295
|
-
Created by migration `066_create_memory_graph.ts
|
|
301
|
+
Created by migration `066_create_memory_graph.ts`, reshaped by
|
|
302
|
+
`076_remove_memory_code_graph.ts`.
|
|
296
303
|
|
|
297
304
|
```
|
|
298
|
-
graph_nodes the memories
|
|
305
|
+
graph_nodes the memories
|
|
299
306
|
graph_edges typed relations between them
|
|
300
307
|
graph_node_entities subjects a memory is about (an ATTRIBUTE, not nodes)
|
|
308
|
+
graph_node_paths files a memory is about (likewise)
|
|
301
309
|
graph_vectors one int8 vector per node, 260 bytes at 256 dims
|
|
302
310
|
graph_nodes_fts FTS5 mirror for BM25
|
|
311
|
+
graph_layout persisted positions and communities (migration 067)
|
|
303
312
|
memory_extraction_queue durable queue of turns awaiting summarisation
|
|
304
313
|
```
|
|
305
314
|
|
|
315
|
+
`graph_nodes.kind` survives 076 as the constant `'episodic'`: it is part of the
|
|
316
|
+
unique digest index and of the FTS mirror's schema, and rebuilding both across a
|
|
317
|
+
live memory store to reclaim one constant column would be risk without benefit.
|
|
318
|
+
Nothing above `graph-queries.ts` has the concept.
|
|
319
|
+
|
|
306
320
|
`graph_nodes` groups its columns four ways:
|
|
307
321
|
|
|
308
322
|
| Group | Columns | Answers |
|
|
@@ -320,12 +334,15 @@ both "where learned" and "where it applies" made cross-project recall impossible
|
|
|
320
334
|
### Relations
|
|
321
335
|
|
|
322
336
|
```
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
episodic → structural : about ← the bridge between both halves
|
|
326
|
-
any ↔ any : relates_to (user-drawn only)
|
|
337
|
+
memory ↔ memory : caused_by | supersedes | contradicts | generalizes
|
|
338
|
+
memory ↔ memory : relates_to (user-drawn only)
|
|
327
339
|
```
|
|
328
340
|
|
|
341
|
+
The code-shaped relations — `imports`, `defines`, `contains`, and `about`
|
|
342
|
+
pointing at a file node — went with the structural half in migration 076. What a
|
|
343
|
+
memory is about is a row in `graph_node_paths`, not an edge to a node standing in
|
|
344
|
+
for a file.
|
|
345
|
+
|
|
329
346
|
`relates_to` is **never** inferred. An automatic similarity linker used to write
|
|
330
347
|
it from vector neighbourhoods and fabricated most of the graph: against a corpus
|
|
331
348
|
of sentences all shaped "X is a project that does Y", every pair is similar in
|
|
@@ -352,8 +369,6 @@ view.ts graph serialization for the UI
|
|
|
352
369
|
extract/
|
|
353
370
|
scheduler.ts durable queue, retries, concurrency
|
|
354
371
|
episodic.ts model-driven summarisation of a finished turn
|
|
355
|
-
structural.ts file/symbol/dependency nodes from the disk diff
|
|
356
|
-
languages.ts per-language symbol extraction
|
|
357
372
|
|
|
358
373
|
embedding/
|
|
359
374
|
paths.ts version, pinned checksums, install location
|
|
@@ -410,6 +425,14 @@ could never be found semantically while still being offered to the model as
|
|
|
410
425
|
something to adjudicate against. Subjects are now rows in `graph_node_entities`,
|
|
411
426
|
folded into the FTS text.
|
|
412
427
|
|
|
428
|
+
**The same rule eventually removed the codebase.** Files, symbols and modules were
|
|
429
|
+
nodes for the same reason entities were — so a question about code could travel to
|
|
430
|
+
the decisions made around it. They were 81% of one real store and 88% of its
|
|
431
|
+
edges, they never reached a prompt, and 4,458 symbol nodes were never once the
|
|
432
|
+
reason a memory was found. The paths a memory names are rows in
|
|
433
|
+
`graph_node_paths` now (migration 076), and invalidation and anchoring got faster
|
|
434
|
+
for losing the hop through a node that stood in for a string.
|
|
435
|
+
|
|
413
436
|
**Revision resolves at read time.** See [Keeping the Graph Honest](#keeping-the-graph-honest).
|
|
414
437
|
|
|
415
438
|
**Retrieval never calls a model.** This is what makes injection on *every* turn
|
|
@@ -18,6 +18,7 @@ import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
|
18
18
|
import { Database } from 'bun:sqlite';
|
|
19
19
|
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
20
20
|
import * as migration066 from '$backend/database/migrations/066_create_memory_graph';
|
|
21
|
+
import * as migration076 from '$backend/database/migrations/076_remove_memory_code_graph';
|
|
21
22
|
|
|
22
23
|
let db: Database;
|
|
23
24
|
|
|
@@ -38,7 +39,6 @@ mock.module('$backend/database', () => ({
|
|
|
38
39
|
mock.module('./config', () => ({
|
|
39
40
|
getMemoryConfig: () => ({
|
|
40
41
|
enabled: true,
|
|
41
|
-
recordCode: true,
|
|
42
42
|
recordMemories: true,
|
|
43
43
|
autoRecall: true,
|
|
44
44
|
recallBudget: 2_400,
|
|
@@ -60,6 +60,7 @@ beforeEach(() => {
|
|
|
60
60
|
db = new Database(':memory:');
|
|
61
61
|
db.exec('PRAGMA foreign_keys = ON');
|
|
62
62
|
migration066.up(db as unknown as DatabaseConnection);
|
|
63
|
+
migration076.up(db as unknown as DatabaseConnection);
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
describe('drafting', () => {
|
|
@@ -156,7 +157,6 @@ describe('saving', () => {
|
|
|
156
157
|
// Agreeing with something already stored should make it stronger, not add a
|
|
157
158
|
// near-copy that competes with it for the same recall budget.
|
|
158
159
|
const existing = graphQueries.upsert({
|
|
159
|
-
kind: 'episodic',
|
|
160
160
|
subkind: 'preference',
|
|
161
161
|
projectId: PROJECT,
|
|
162
162
|
label: 'Prefers tabs',
|
|
@@ -174,7 +174,7 @@ describe('saving', () => {
|
|
|
174
174
|
|
|
175
175
|
expect(node.id).toBe(existing.id);
|
|
176
176
|
expect(node.confidence).toBe(0.95);
|
|
177
|
-
expect(graphQueries.count({ projectId: PROJECT
|
|
177
|
+
expect(graphQueries.count({ projectId: PROJECT })).toBe(1);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
it('makes it findable at once', () => {
|
|
@@ -172,7 +172,7 @@ export interface CreateInput {
|
|
|
172
172
|
* Store a reviewed draft.
|
|
173
173
|
*
|
|
174
174
|
* `source: 'user'`, which is not bookkeeping — it is what exempts the node from
|
|
175
|
-
*
|
|
175
|
+
* staleness decay, from eviction and from being archived into a consolidation,
|
|
176
176
|
* and what makes the injected block tell the agent a person said this rather
|
|
177
177
|
* than that a model inferred it.
|
|
178
178
|
*/
|
|
@@ -205,7 +205,6 @@ export function createMemory(input: CreateInput): GraphNode | null {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
const node = graphQueries.upsert({
|
|
208
|
-
kind: 'episodic',
|
|
209
208
|
subkind: input.subkind,
|
|
210
209
|
scope,
|
|
211
210
|
projectId,
|
|
@@ -226,13 +225,11 @@ export function createMemory(input: CreateInput): GraphNode | null {
|
|
|
226
225
|
});
|
|
227
226
|
|
|
228
227
|
linkEntities(node.id, input.entities ?? []);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
graphQueries.link({ srcId: node.id, dstId: target.id, rel: 'about', source: 'user' });
|
|
235
|
-
}
|
|
228
|
+
// Recorded whether or not those files have ever been seen — a path is a string
|
|
229
|
+
// on the memory now rather than a node that had to have been observed first.
|
|
230
|
+
// A hand-written memory naming a file the agent had not touched yet used to
|
|
231
|
+
// lose its attribution silently.
|
|
232
|
+
graphQueries.setPaths(node.id, input.relatedPaths ?? []);
|
|
236
233
|
|
|
237
234
|
scheduleVectorIndexing();
|
|
238
235
|
resetGraphEmptiness();
|
package/backend/memory/config.ts
CHANGED
|
@@ -28,8 +28,6 @@ export interface MemoryModelConfig {
|
|
|
28
28
|
export interface MemoryConfig {
|
|
29
29
|
/** Master switch: off means no recording, no retrieval, no injection. */
|
|
30
30
|
enabled: boolean;
|
|
31
|
-
/** Record the files and symbols each turn touches, read from the disk diff. */
|
|
32
|
-
recordCode: boolean;
|
|
33
31
|
/** Summarise finished turns into memories using `model`. */
|
|
34
32
|
recordMemories: boolean;
|
|
35
33
|
/** Hand relevant memories to the agent automatically at the start of a turn. */
|
|
@@ -56,7 +54,6 @@ export interface MemoryConfig {
|
|
|
56
54
|
*/
|
|
57
55
|
const KEYS = {
|
|
58
56
|
enabled: 'memory_enabled',
|
|
59
|
-
recordCode: 'memory_record_code',
|
|
60
57
|
recordMemories: 'memory_record_memories',
|
|
61
58
|
autoRecall: 'memory_auto_recall',
|
|
62
59
|
model: 'memory_model'
|
|
@@ -81,7 +78,6 @@ export function getMemoryConfig(): MemoryConfig {
|
|
|
81
78
|
|
|
82
79
|
return {
|
|
83
80
|
enabled: readBoolean(KEYS.enabled, true),
|
|
84
|
-
recordCode: readBoolean(KEYS.recordCode, true),
|
|
85
81
|
recordMemories: readBoolean(KEYS.recordMemories, true),
|
|
86
82
|
autoRecall: readBoolean(KEYS.autoRecall, true),
|
|
87
83
|
model
|
|
@@ -90,7 +86,6 @@ export function getMemoryConfig(): MemoryConfig {
|
|
|
90
86
|
|
|
91
87
|
export function setMemoryConfig(patch: Partial<MemoryConfig>): MemoryConfig {
|
|
92
88
|
if (patch.enabled !== undefined) settingsQueries.set(KEYS.enabled, String(patch.enabled));
|
|
93
|
-
if (patch.recordCode !== undefined) settingsQueries.set(KEYS.recordCode, String(patch.recordCode));
|
|
94
89
|
if (patch.recordMemories !== undefined) settingsQueries.set(KEYS.recordMemories, String(patch.recordMemories));
|
|
95
90
|
if (patch.autoRecall !== undefined) settingsQueries.set(KEYS.autoRecall, String(patch.autoRecall));
|
|
96
91
|
if (patch.model !== undefined) {
|
|
@@ -135,7 +135,6 @@ export async function consolidateMemories(projectId: string | null, projectPath:
|
|
|
135
135
|
if (covered.length < MIN_CLUSTER) continue;
|
|
136
136
|
|
|
137
137
|
const node = graphQueries.upsert({
|
|
138
|
-
kind: 'episodic',
|
|
139
138
|
subkind: summary.subkind,
|
|
140
139
|
scope: projectId ? 'project' : 'global',
|
|
141
140
|
projectId,
|
|
@@ -181,7 +180,7 @@ export async function consolidateMemories(projectId: string | null, projectPath:
|
|
|
181
180
|
*/
|
|
182
181
|
function findClusters(projectId: string | null): GraphNode[][] {
|
|
183
182
|
const nodes = graphQueries
|
|
184
|
-
.list({ projectId,
|
|
183
|
+
.list({ projectId, limit: 2_000 })
|
|
185
184
|
.filter(
|
|
186
185
|
node =>
|
|
187
186
|
node.source === 'agent' &&
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* turn that simply has no memory in it — which is indistinguishable from a graph
|
|
6
6
|
* that had nothing to say.
|
|
7
7
|
*
|
|
8
|
-
* THE BLOCK CAME OUT EMPTY ON THE TURNS WITH THE MOST TO OFFER. Retrieval
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
8
|
+
* THE BLOCK CAME OUT EMPTY ON THE TURNS WITH THE MOST TO OFFER. Retrieval used
|
|
9
|
+
* to rank the codebase alongside the memories while the block only ever showed
|
|
10
|
+
* memories, so a project's file and symbol nodes could take every slot. That half
|
|
11
|
+
* is gone (migration 076), and the test that guarded the filtering went with it;
|
|
12
|
+
* what remains worth pinning is that the block still fills from the memories the
|
|
13
|
+
* question earns.
|
|
14
14
|
*
|
|
15
15
|
* THE DIRECTIVE WAS SENT INTO AN EMPTY GRAPH. A few hundred characters on every
|
|
16
16
|
* turn of every session on every engine, telling an agent about a store with
|
|
@@ -21,6 +21,7 @@ import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
|
21
21
|
import { Database } from 'bun:sqlite';
|
|
22
22
|
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
23
23
|
import * as migration066 from '$backend/database/migrations/066_create_memory_graph';
|
|
24
|
+
import * as migration076 from '$backend/database/migrations/076_remove_memory_code_graph';
|
|
24
25
|
|
|
25
26
|
let db: Database;
|
|
26
27
|
|
|
@@ -40,7 +41,6 @@ mock.module('$backend/database', () => ({
|
|
|
40
41
|
mock.module('./config', () => ({
|
|
41
42
|
getMemoryConfig: () => ({
|
|
42
43
|
enabled: true,
|
|
43
|
-
recordCode: true,
|
|
44
44
|
recordMemories: true,
|
|
45
45
|
autoRecall: true,
|
|
46
46
|
model: null
|
|
@@ -81,7 +81,6 @@ const PROJECT = 'project-a';
|
|
|
81
81
|
|
|
82
82
|
function memory(label: string, body: string) {
|
|
83
83
|
return graphQueries.upsert({
|
|
84
|
-
kind: 'episodic',
|
|
85
84
|
subkind: 'decision',
|
|
86
85
|
projectId: PROJECT,
|
|
87
86
|
label,
|
|
@@ -90,24 +89,11 @@ function memory(label: string, body: string) {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
/** A project's structural half: the nodes that outnumber and outrank memories. */
|
|
94
|
-
function floodWithCode(count: number, token: string): void {
|
|
95
|
-
for (let i = 0; i < count; i++) {
|
|
96
|
-
graphQueries.upsert({
|
|
97
|
-
kind: 'structural',
|
|
98
|
-
subkind: 'file',
|
|
99
|
-
projectId: PROJECT,
|
|
100
|
-
label: `${token}-${i}.ts`,
|
|
101
|
-
body: `src/${token}/${token}-${i}.ts`,
|
|
102
|
-
path: `src/${token}/${token}-${i}.ts`
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
92
|
beforeEach(() => {
|
|
108
93
|
db = new Database(':memory:');
|
|
109
94
|
db.exec('PRAGMA foreign_keys = ON');
|
|
110
95
|
migration066.up(db as unknown as DatabaseConnection);
|
|
96
|
+
migration076.up(db as unknown as DatabaseConnection);
|
|
111
97
|
resetGraphEmptiness();
|
|
112
98
|
});
|
|
113
99
|
|
|
@@ -129,34 +115,6 @@ describe('the injected block', () => {
|
|
|
129
115
|
expect(block!.text).toContain('<clopen-memory>');
|
|
130
116
|
});
|
|
131
117
|
|
|
132
|
-
it('still finds the memory when the code half floods the ranking', () => {
|
|
133
|
-
// Forty file nodes all matching the query's tokens, which is what a real
|
|
134
|
-
// project looks like. With a limit of eighteen applied BEFORE the episodic
|
|
135
|
-
// filter, none of the one memory that matters survived.
|
|
136
|
-
const note = memory('Snapshot capture must not run mid-stream', 'It corrupts the working tree.');
|
|
137
|
-
floodWithCode(40, 'snapshot');
|
|
138
|
-
resetGraphEmptiness();
|
|
139
|
-
|
|
140
|
-
const block = buildMemoryContext({
|
|
141
|
-
query: 'snapshot capture',
|
|
142
|
-
projectId: PROJECT,
|
|
143
|
-
sessionId: 's'
|
|
144
|
-
})!;
|
|
145
|
-
|
|
146
|
-
expect(block.nodeIds).toContain(note.id);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('never lists a code entity — the agent can read the repository itself', () => {
|
|
150
|
-
memory('Snapshot capture must not run mid-stream', 'It corrupts the working tree.');
|
|
151
|
-
floodWithCode(10, 'snapshot');
|
|
152
|
-
resetGraphEmptiness();
|
|
153
|
-
|
|
154
|
-
const block = buildMemoryContext({ query: 'snapshot capture', projectId: PROJECT, sessionId: 's' })!;
|
|
155
|
-
const structural = graphQueries.list({ projectId: PROJECT, kinds: ['structural'] }).map(node => node.id);
|
|
156
|
-
|
|
157
|
-
expect(block.nodeIds.filter(id => structural.includes(id))).toHaveLength(0);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
118
|
it('carries as many memories as the question earns, never more than the ceiling', () => {
|
|
161
119
|
// There is no setting for this any more. A character budget did not bound what
|
|
162
120
|
// it claimed to, and a count could not be right for both "ok, continue" and a
|
|
@@ -230,7 +188,6 @@ describe('the injected block', () => {
|
|
|
230
188
|
// the name, a travelling memory reads as a claim about the project in front
|
|
231
189
|
// of it.
|
|
232
190
|
graphQueries.upsert({
|
|
233
|
-
kind: 'episodic',
|
|
234
191
|
subkind: 'pattern',
|
|
235
192
|
scope: 'project',
|
|
236
193
|
projectId: 'project-b',
|
|
@@ -257,7 +214,6 @@ describe('the injected block', () => {
|
|
|
257
214
|
// always rank it below whatever was actually asked — measured, human-stated
|
|
258
215
|
// rules reached the prompt on 3 of 20 opportunities.
|
|
259
216
|
graphQueries.upsert({
|
|
260
|
-
kind: 'episodic',
|
|
261
217
|
subkind: 'preference',
|
|
262
218
|
scope: 'global',
|
|
263
219
|
projectId: null,
|
|
@@ -277,7 +233,6 @@ describe('the injected block', () => {
|
|
|
277
233
|
|
|
278
234
|
it('does not repeat a standing instruction in the recalled section', () => {
|
|
279
235
|
graphQueries.upsert({
|
|
280
|
-
kind: 'episodic',
|
|
281
236
|
subkind: 'preference',
|
|
282
237
|
scope: 'global',
|
|
283
238
|
projectId: null,
|
|
@@ -303,7 +258,6 @@ describe('the injected block', () => {
|
|
|
303
258
|
// about how the user works is background, and promoting it would make the
|
|
304
259
|
// most privileged position in the prompt reachable by inference.
|
|
305
260
|
graphQueries.upsert({
|
|
306
|
-
kind: 'episodic',
|
|
307
261
|
subkind: 'preference',
|
|
308
262
|
scope: 'global',
|
|
309
263
|
projectId: null,
|