@cleocode/brain 2026.11.16 → 2026.11.17

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 (43) hide show
  1. package/README.md +31 -21
  2. package/dist/src/adapters/agent-registry.d.ts +12 -9
  3. package/dist/src/adapters/agent-registry.d.ts.map +1 -1
  4. package/dist/src/adapters/agent-registry.js +40 -65
  5. package/dist/src/adapters/agent-registry.js.map +1 -1
  6. package/dist/src/adapters/brain.d.ts +3 -2
  7. package/dist/src/adapters/brain.d.ts.map +1 -1
  8. package/dist/src/adapters/brain.js +172 -172
  9. package/dist/src/adapters/brain.js.map +1 -1
  10. package/dist/src/adapters/conduit.d.ts +5 -4
  11. package/dist/src/adapters/conduit.d.ts.map +1 -1
  12. package/dist/src/adapters/conduit.js +53 -64
  13. package/dist/src/adapters/conduit.js.map +1 -1
  14. package/dist/src/adapters/index.d.ts +2 -2
  15. package/dist/src/adapters/index.d.ts.map +1 -1
  16. package/dist/src/adapters/index.js +11 -10
  17. package/dist/src/adapters/index.js.map +1 -1
  18. package/dist/src/adapters/nexus.d.ts +5 -3
  19. package/dist/src/adapters/nexus.d.ts.map +1 -1
  20. package/dist/src/adapters/nexus.js +47 -44
  21. package/dist/src/adapters/nexus.js.map +1 -1
  22. package/dist/src/adapters/tasks.d.ts +4 -2
  23. package/dist/src/adapters/tasks.d.ts.map +1 -1
  24. package/dist/src/adapters/tasks.js +93 -92
  25. package/dist/src/adapters/tasks.js.map +1 -1
  26. package/dist/src/cleo-home.d.ts +22 -12
  27. package/dist/src/cleo-home.d.ts.map +1 -1
  28. package/dist/src/cleo-home.js +24 -20
  29. package/dist/src/cleo-home.js.map +1 -1
  30. package/dist/src/db-connections.d.ts +23 -101
  31. package/dist/src/db-connections.d.ts.map +1 -1
  32. package/dist/src/db-connections.js +43 -169
  33. package/dist/src/db-connections.js.map +1 -1
  34. package/dist/src/index.d.ts +3 -3
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js +5 -5
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/project-context.d.ts +15 -7
  39. package/dist/src/project-context.d.ts.map +1 -1
  40. package/dist/src/project-context.js +10 -15
  41. package/dist/src/project-context.js.map +1 -1
  42. package/dist/tsconfig.build.tsbuildinfo +1 -1
  43. package/package.json +4 -4
@@ -2,8 +2,8 @@
2
2
  * CLEO home + project DB path resolution for `@cleocode/brain`.
3
3
  *
4
4
  * Path resolution delegates to the `@cleocode/paths` SSoT
5
- * ({@link getCleoHome}). Project data (tasks.db, brain.db, conduit.db) is
6
- * resolved via projectId → nexus.db registry lookup
5
+ * ({@link getCleoHome}). The project store (`.cleo/cleo.db`) is resolved via
6
+ * projectId → global registry lookup
7
7
  * ({@link resolveProjectByCwd} + {@link resolveCanonicalCleoDir}), with a
8
8
  * `CLEO_ROOT` / `process.cwd()` fallback for non-project contexts.
9
9
  *
@@ -16,6 +16,7 @@
16
16
  * @task T1874 (original Windows fix)
17
17
  * @task T1886 (migrated to @cleocode/paths SSoT)
18
18
  * @task T11040 (verified 2026-05-27: projectId-based resolution confirmed; 72/72 tests pass)
19
+ * @task T14583 (read the consolidated cleo.db, not the legacy per-domain files)
19
20
  */
20
21
  import { getCleoHome } from '@cleocode/paths';
21
22
  export { getCleoHome };
@@ -33,16 +34,25 @@ export { getCleoHome };
33
34
  * @task T11040 — migrate from CWD-walk-up to projectId-based resolution
34
35
  */
35
36
  export declare function getCleoProjectDir(): string;
36
- /** Returns the absolute path to the global nexus.db file. */
37
- export declare function getNexusDbPath(): string;
38
- /** Returns the absolute path to the project-scoped brain.db file. */
39
- export declare function getBrainDbPath(): string;
40
- /** Returns the absolute path to the project-scoped tasks.db file. */
41
- export declare function getTasksDbPath(): string;
42
- /** Returns the absolute path to the project-scoped conduit.db file. */
43
- export declare function getConduitDbPath(): string;
44
- /** Returns the absolute path to the global signaldock.db file. */
45
- export declare function getAgentRegistryDbPath(): string;
37
+ /**
38
+ * Returns the absolute path to the project-scope `cleo.db`.
39
+ *
40
+ * It holds the project's `tasks_*`, `brain_*`, `conduit_*` and `nexus_*`
41
+ * (code graph, ADR-090) tables. The legacy `tasks.db`, `brain.db` and
42
+ * `conduit.db` files are decoys and are never read (T12095, T14583).
43
+ *
44
+ * @returns `<project>/.cleo/cleo.db`.
45
+ */
46
+ export declare function getProjectStorePath(): string;
47
+ /**
48
+ * Returns the absolute path to the global-scope `cleo.db` under CLEO home.
49
+ *
50
+ * It holds the `agent_registry_*` tables; the retired `signaldock.db` and
51
+ * `nexus.db` files are never read (T14583).
52
+ *
53
+ * @returns `<cleoHome>/cleo.db`.
54
+ */
55
+ export declare function getGlobalStorePath(): string;
46
56
  /** Returns true when the given DB file exists on disk. */
47
57
  export declare function dbExists(dbPath: string): boolean;
48
58
  //# sourceMappingURL=cleo-home.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleo-home.d.ts","sourceRoot":"","sources":["../../src/cleo-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAEL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAkB1C;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,qEAAqE;AACrE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,qEAAqE;AACrE,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,uEAAuE;AACvE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,kEAAkE;AAClE,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD"}
1
+ {"version":3,"file":"cleo-home.d.ts","sourceRoot":"","sources":["../../src/cleo-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,EAEL,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAkB1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhD"}
@@ -2,8 +2,8 @@
2
2
  * CLEO home + project DB path resolution for `@cleocode/brain`.
3
3
  *
4
4
  * Path resolution delegates to the `@cleocode/paths` SSoT
5
- * ({@link getCleoHome}). Project data (tasks.db, brain.db, conduit.db) is
6
- * resolved via projectId → nexus.db registry lookup
5
+ * ({@link getCleoHome}). The project store (`.cleo/cleo.db`) is resolved via
6
+ * projectId → global registry lookup
7
7
  * ({@link resolveProjectByCwd} + {@link resolveCanonicalCleoDir}), with a
8
8
  * `CLEO_ROOT` / `process.cwd()` fallback for non-project contexts.
9
9
  *
@@ -16,6 +16,7 @@
16
16
  * @task T1874 (original Windows fix)
17
17
  * @task T1886 (migrated to @cleocode/paths SSoT)
18
18
  * @task T11040 (verified 2026-05-27: projectId-based resolution confirmed; 72/72 tests pass)
19
+ * @task T14583 (read the consolidated cleo.db, not the legacy per-domain files)
19
20
  */
20
21
  import { existsSync } from 'node:fs';
21
22
  import { join } from 'node:path';
@@ -53,25 +54,28 @@ export function getCleoProjectDir() {
53
54
  const root = process.env['CLEO_ROOT'] ?? process.cwd();
54
55
  return join(root, '.cleo');
55
56
  }
56
- /** Returns the absolute path to the global nexus.db file. */
57
- export function getNexusDbPath() {
58
- return join(getCleoHome(), 'nexus.db');
59
- }
60
- /** Returns the absolute path to the project-scoped brain.db file. */
61
- export function getBrainDbPath() {
62
- return join(getCleoProjectDir(), 'brain.db');
63
- }
64
- /** Returns the absolute path to the project-scoped tasks.db file. */
65
- export function getTasksDbPath() {
66
- return join(getCleoProjectDir(), 'tasks.db');
67
- }
68
- /** Returns the absolute path to the project-scoped conduit.db file. */
69
- export function getConduitDbPath() {
70
- return join(getCleoProjectDir(), 'conduit.db');
57
+ /**
58
+ * Returns the absolute path to the project-scope `cleo.db`.
59
+ *
60
+ * It holds the project's `tasks_*`, `brain_*`, `conduit_*` and `nexus_*`
61
+ * (code graph, ADR-090) tables. The legacy `tasks.db`, `brain.db` and
62
+ * `conduit.db` files are decoys and are never read (T12095, T14583).
63
+ *
64
+ * @returns `<project>/.cleo/cleo.db`.
65
+ */
66
+ export function getProjectStorePath() {
67
+ return join(getCleoProjectDir(), 'cleo.db');
71
68
  }
72
- /** Returns the absolute path to the global signaldock.db file. */
73
- export function getAgentRegistryDbPath() {
74
- return join(getCleoHome(), 'signaldock.db');
69
+ /**
70
+ * Returns the absolute path to the global-scope `cleo.db` under CLEO home.
71
+ *
72
+ * It holds the `agent_registry_*` tables; the retired `signaldock.db` and
73
+ * `nexus.db` files are never read (T14583).
74
+ *
75
+ * @returns `<cleoHome>/cleo.db`.
76
+ */
77
+ export function getGlobalStorePath() {
78
+ return join(getCleoHome(), 'cleo.db');
75
79
  }
76
80
  /** Returns true when the given DB file exists on disk. */
77
81
  export function dbExists(dbPath) {
@@ -1 +1 @@
1
- {"version":3,"file":"cleo-home.js","sourceRoot":"","sources":["../../src/cleo-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;;;;;;;;;;;GAYG;AACH,MAAM,U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I,CAAC,iBAAiB,EAAE,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AACxC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
@@ -1,49 +1,24 @@
1
1
  /**
2
- * Read-only SQLite connection helpers for the Living Brain substrate adapters.
2
+ * Read-only store access for the Living Brain substrate adapters.
3
3
  *
4
- * Uses node:sqlite (Node.js built-in).
4
+ * The adapters read the consolidated stores, never the legacy per-domain files
5
+ * (`brain.db`, `tasks.db`, `conduit.db`, `nexus.db`, `signaldock.db`), which are
6
+ * decoys or retired (T12095, T14583):
5
7
  *
6
- * Global databases (nexus.db, signaldock.db) are shared across all projects
7
- * and use module-level caches — their path is fixed per machine and never
8
- * changes between requests.
8
+ * - **Project `cleo.db`** (`<project>/.cleo/cleo.db`): `tasks_*`, `brain_*`,
9
+ * `conduit_*` and the `nexus_*` code graph (ADR-090).
10
+ * - **Global `cleo.db`** (`<cleoHome>/cleo.db`): `agent_registry_*`.
9
11
  *
10
- * Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
11
- * the active {@link ProjectContext} passed by the caller. No cross-request
12
- * caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
13
- * and caching across different ProjectContexts is the precise bug this
14
- * module's Studio counterpart was rewritten to avoid.
15
- *
16
- * This file is a trimmed mirror of
17
- * `packages/studio/src/lib/server/db/connections.ts`, containing only the
18
- * getters required by the substrate adapters.
19
- *
20
- * ## E4-T5 transition (T11516 · SG-DB-SUBSTRATE-V2)
21
- *
22
- * This module now depends on `@cleocode/core` and delegates to
23
- * {@link openDualScopeDb} for new consolidated `cleo.db` access. The legacy
24
- * per-domain DB getters ({@link getNexusDb}, {@link getBrainDb}, etc.) still
25
- * open the old per-domain files via per-line-allowed raw opens because the
26
- * substrate adapters in this package still target those legacy table schemas.
27
- * The full exodus to the consolidated `cleo.db` schema happens in E6 (T11249),
28
- * at which point the per-line `// db-open-allowed` markers and the legacy
29
- * getters are removed.
12
+ * Every read goes through the store chokepoint's snapshot opener
13
+ * ({@link openCleoDbSnapshot}): a read-only handle with no migrations and no
14
+ * singleton, opened for one read and closed after it. Opening is
15
+ * sub-millisecond, and no handle is cached across project contexts.
30
16
  *
31
17
  * @task T969
32
- * @task T11516 (E4-T5)
18
+ * @task T14583 (consolidated cleo.db through the store chokepoint)
33
19
  */
34
- import type { DatabaseSync as _DatabaseSyncType } from 'node:sqlite';
20
+ import type { DatabaseSync } from 'node:sqlite';
35
21
  import type { ProjectContext } from './project-context.js';
36
- /**
37
- * Re-export of the dual-scope `cleo.db` chokepoint.
38
- *
39
- * Callers that target the new consolidated schema (E4+) should use
40
- * `openDualScopeDb` directly rather than the legacy per-domain getters below.
41
- *
42
- * @see packages/core/src/store/dual-scope-db.ts
43
- */
44
- export { openDualScopeDb } from '@cleocode/core/db';
45
- type DatabaseSync = _DatabaseSyncType;
46
- declare const DatabaseSync: new (path: import("fs").PathLike, options?: import("node:sqlite").DatabaseSyncOptions | undefined) => DatabaseSync;
47
22
  /**
48
23
  * Minimal structural view of a `node:sqlite` prepared statement.
49
24
  *
@@ -72,72 +47,19 @@ interface PreparedStatementLike {
72
47
  */
73
48
  export declare function allTyped<T>(stmt: PreparedStatementLike, ...params: unknown[]): T[];
74
49
  /**
75
- * Returns a read-only connection to the global nexus.db.
76
- * Returns null when the file does not exist on disk.
77
- *
78
- * @remarks
79
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
80
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
81
- * adapters still target legacy nexus.db table names. Full exodus in E6 (T11249).
82
- */
83
- export declare function getNexusDb(): DatabaseSync | null;
84
- /**
85
- * Returns a read-only connection to the global signaldock.db.
86
- * Returns null when the file does not exist on disk.
50
+ * Runs `read` against the project-scope `cleo.db` named by `ctx`.
87
51
  *
88
- * @remarks
89
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
90
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
91
- * adapters still target legacy signaldock.db table names. Full exodus in E6 (T11249).
52
+ * @param ctx - The active project context; `tasksDbPath` names its `cleo.db`.
53
+ * @param read - Synchronous read against the project store.
54
+ * @returns The read's result, or null when the store is missing or unreadable.
92
55
  */
93
- export declare function getAgentRegistryDb(): DatabaseSync | null;
56
+ export declare function readProjectStore<T>(ctx: ProjectContext, read: (db: DatabaseSync) => T): T | null;
94
57
  /**
95
- * Opens a connection to brain.db for the given project context.
96
- *
97
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
98
- * Returns null when brain.db does not exist for the project OR when the
99
- * file is detected as malformed (T10303). Reader-side malformation is
100
- * handled by returning null — recovery is owned by the writer side in
101
- * `@cleocode/core/store/memory-sqlite.ts:getBrainDb`, which runs the
102
- * `recoverMalformedBrainDb()` pipeline before the next process re-opens.
103
- *
104
- * @param ctx - The active project context.
105
- *
106
- * @remarks
107
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
108
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
109
- * adapters still target legacy brain.db table names. Full exodus in E6 (T11249).
110
- */
111
- export declare function getBrainDb(ctx: ProjectContext): DatabaseSync | null;
112
- /**
113
- * Opens a connection to tasks.db for the given project context.
114
- *
115
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
116
- * Returns null when tasks.db does not exist for the project.
117
- *
118
- * @param ctx - The active project context.
119
- *
120
- * @remarks
121
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
122
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
123
- * adapters still target legacy tasks.db table names. Full exodus in E6 (T11249).
124
- */
125
- export declare function getTasksDb(ctx: ProjectContext): DatabaseSync | null;
126
- /**
127
- * Opens a connection to conduit.db for the given project context.
128
- *
129
- * conduit.db lives alongside brain.db in the project's `.cleo/` directory.
130
- * Its path is derived from the brain.db path since `ProjectContext` does not
131
- * carry a dedicated `conduitDbPath` field.
132
- *
133
- * Returns null when conduit.db does not exist for the project.
134
- *
135
- * @param ctx - The active project context.
58
+ * Runs `read` against the global-scope `cleo.db` under CLEO home.
136
59
  *
137
- * @remarks
138
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
139
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
140
- * adapters still target legacy conduit.db table names. Full exodus in E6 (T11249).
60
+ * @param read - Synchronous read against the global store.
61
+ * @returns The read's result, or null when the store is missing or unreadable.
141
62
  */
142
- export declare function getConduitDb(ctx: ProjectContext): DatabaseSync | null;
63
+ export declare function readGlobalStore<T>(read: (db: DatabaseSync) => T): T | null;
64
+ export {};
143
65
  //# sourceMappingURL=db-connections.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-connections.d.ts","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAKH,OAAO,KAAK,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,KAAK,YAAY,GAAG,iBAAiB,CAAC;AACtC,QAAA,MAAQ,YAAY,wGAC8D,YACjF,CAAC;AAMF;;;;;;;GAOG;AACH,UAAU,qBAAqB;IAC7B,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC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,IAAI,CAE1E"}
@@ -1,52 +1,25 @@
1
1
  /**
2
- * Read-only SQLite connection helpers for the Living Brain substrate adapters.
2
+ * Read-only store access for the Living Brain substrate adapters.
3
3
  *
4
- * Uses node:sqlite (Node.js built-in).
4
+ * The adapters read the consolidated stores, never the legacy per-domain files
5
+ * (`brain.db`, `tasks.db`, `conduit.db`, `nexus.db`, `signaldock.db`), which are
6
+ * decoys or retired (T12095, T14583):
5
7
  *
6
- * Global databases (nexus.db, signaldock.db) are shared across all projects
7
- * and use module-level caches — their path is fixed per machine and never
8
- * changes between requests.
8
+ * - **Project `cleo.db`** (`<project>/.cleo/cleo.db`): `tasks_*`, `brain_*`,
9
+ * `conduit_*` and the `nexus_*` code graph (ADR-090).
10
+ * - **Global `cleo.db`** (`<cleoHome>/cleo.db`): `agent_registry_*`.
9
11
  *
10
- * Per-project databases (brain.db, tasks.db, conduit.db) are resolved from
11
- * the active {@link ProjectContext} passed by the caller. No cross-request
12
- * caching is performed: opening SQLite with `node:sqlite` is sub-millisecond,
13
- * and caching across different ProjectContexts is the precise bug this
14
- * module's Studio counterpart was rewritten to avoid.
15
- *
16
- * This file is a trimmed mirror of
17
- * `packages/studio/src/lib/server/db/connections.ts`, containing only the
18
- * getters required by the substrate adapters.
19
- *
20
- * ## E4-T5 transition (T11516 · SG-DB-SUBSTRATE-V2)
21
- *
22
- * This module now depends on `@cleocode/core` and delegates to
23
- * {@link openDualScopeDb} for new consolidated `cleo.db` access. The legacy
24
- * per-domain DB getters ({@link getNexusDb}, {@link getBrainDb}, etc.) still
25
- * open the old per-domain files via per-line-allowed raw opens because the
26
- * substrate adapters in this package still target those legacy table schemas.
27
- * The full exodus to the consolidated `cleo.db` schema happens in E6 (T11249),
28
- * at which point the per-line `// db-open-allowed` markers and the legacy
29
- * getters are removed.
12
+ * Every read goes through the store chokepoint's snapshot opener
13
+ * ({@link openCleoDbSnapshot}): a read-only handle with no migrations and no
14
+ * singleton, opened for one read and closed after it. Opening is
15
+ * sub-millisecond, and no handle is cached across project contexts.
30
16
  *
31
17
  * @task T969
32
- * @task T11516 (E4-T5)
18
+ * @task T14583 (consolidated cleo.db through the store chokepoint)
33
19
  */
34
20
  import { existsSync } from 'node:fs';
35
- import { createRequire } from 'node:module';
36
- import { dirname, join } from 'node:path';
37
- import { applyPerfPragmas } from '@cleocode/core/store/sqlite-pragmas.js';
38
- import { dbExists, getAgentRegistryDbPath, getNexusDbPath } from './cleo-home.js';
39
- /**
40
- * Re-export of the dual-scope `cleo.db` chokepoint.
41
- *
42
- * Callers that target the new consolidated schema (E4+) should use
43
- * `openDualScopeDb` directly rather than the legacy per-domain getters below.
44
- *
45
- * @see packages/core/src/store/dual-scope-db.ts
46
- */
47
- export { openDualScopeDb } from '@cleocode/core/db';
48
- const _require = createRequire(import.meta.url);
49
- const { DatabaseSync } = _require('node:sqlite');
21
+ import { openCleoDbSnapshot } from '@cleocode/core/store/open-cleo-db.js';
22
+ import { getGlobalStorePath } from './cleo-home.js';
50
23
  /**
51
24
  * Executes a prepared statement and returns rows typed as `T[]`.
52
25
  *
@@ -66,150 +39,51 @@ export function allTyped(stmt, ...params) {
66
39
  return stmt.all(...params);
67
40
  }
68
41
  // ---------------------------------------------------------------------------
69
- // Global singleton caches (path never changes per process)
70
- // ---------------------------------------------------------------------------
71
- /** Cached nexus.db connection — global, path is machine-scoped. */
72
- let nexusDb = null;
73
- /** Cached signaldock.db connection — global, path is machine-scoped. */
74
- let signaldockDb = null;
75
- // ---------------------------------------------------------------------------
76
- // Global DB getters (cached per process)
77
- // ---------------------------------------------------------------------------
78
- /**
79
- * Returns a read-only connection to the global nexus.db.
80
- * Returns null when the file does not exist on disk.
81
- *
82
- * @remarks
83
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
84
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
85
- * adapters still target legacy nexus.db table names. Full exodus in E6 (T11249).
86
- */
87
- export function getNexusDb() {
88
- if (nexusDb)
89
- return nexusDb;
90
- const path = getNexusDbPath();
91
- if (!dbExists(path))
92
- return null;
93
- nexusDb = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence (schema-guard-exempt: legacy read adapters run no schema code) — adapters target legacy nexus.db schema; full exodus in E6 (T11249)
94
- applyPerfPragmas(nexusDb);
95
- return nexusDb;
96
- }
97
- /**
98
- * Returns a read-only connection to the global signaldock.db.
99
- * Returns null when the file does not exist on disk.
100
- *
101
- * @remarks
102
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
103
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
104
- * adapters still target legacy signaldock.db table names. Full exodus in E6 (T11249).
105
- */
106
- export function getAgentRegistryDb() {
107
- if (signaldockDb)
108
- return signaldockDb;
109
- const path = getAgentRegistryDbPath();
110
- if (!dbExists(path))
111
- return null;
112
- signaldockDb = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence (schema-guard-exempt: legacy read adapters run no schema code) — adapters target legacy signaldock.db schema; full exodus in E6 (T11249)
113
- applyPerfPragmas(signaldockDb);
114
- return signaldockDb;
115
- }
116
- // ---------------------------------------------------------------------------
117
- // Per-project DB getters (NOT cached — resolved from ProjectContext)
42
+ // Store readers
118
43
  // ---------------------------------------------------------------------------
119
44
  /**
120
- * Detect the brain.db malformation signature (T10303) without taking a
121
- * dependency on `@cleocode/core`. The reader side does NOT auto-recover —
122
- * recovery is owned by the writer side in `@cleocode/core/store/memory-sqlite.ts`.
123
- * Reader-side detection returns `null` so substrate adapters degrade
124
- * gracefully (matches the existing "DB doesn't exist" semantics).
125
- *
126
- * @internal — brain-package-local.
127
- * @task T10303
128
- */
129
- function isMalformationError(err) {
130
- if (!(err instanceof Error))
131
- return false;
132
- const code = err.code;
133
- const errcode = err.errcode;
134
- if (code === 'ERR_SQLITE_ERROR' && errcode === 11)
135
- return true;
136
- return /malformed/i.test(err.message ?? '');
137
- }
138
- /**
139
- * Opens a connection to brain.db for the given project context.
45
+ * Runs `read` against a read-only snapshot of the store at `path`.
140
46
  *
141
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
142
- * Returns null when brain.db does not exist for the project OR when the
143
- * file is detected as malformed (T10303). Reader-side malformation is
144
- * handled by returning null — recovery is owned by the writer side in
145
- * `@cleocode/core/store/memory-sqlite.ts:getBrainDb`, which runs the
146
- * `recoverMalformedBrainDb()` pipeline before the next process re-opens.
147
- *
148
- * @param ctx - The active project context.
149
- *
150
- * @remarks
151
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
152
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
153
- * adapters still target legacy brain.db table names. Full exodus in E6 (T11249).
47
+ * @param path - Absolute path to a consolidated `cleo.db`.
48
+ * @param read - Synchronous read; the handle is closed when it returns.
49
+ * @returns The read's result, or null when the store is missing or cannot be
50
+ * opened (a restore in progress, a malformed file), so the substrate degrades
51
+ * to no nodes.
154
52
  */
155
- export function getBrainDb(ctx) {
156
- const path = ctx.brainDbPath;
53
+ function readStore(path, read) {
157
54
  if (!existsSync(path))
158
55
  return null;
56
+ let snapshot;
57
+ try {
58
+ snapshot = openCleoDbSnapshot(path, { readOnly: true });
59
+ }
60
+ catch {
61
+ return null;
62
+ }
159
63
  try {
160
- const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence (schema-guard-exempt: legacy read adapters run no schema code) — adapters target legacy brain.db schema; full exodus in E6 (T11249)
161
- applyPerfPragmas(__db);
162
- return __db;
64
+ return read(snapshot.db);
163
65
  }
164
- catch (err) {
165
- if (isMalformationError(err))
166
- return null;
167
- throw err;
66
+ finally {
67
+ snapshot.close();
168
68
  }
169
69
  }
170
70
  /**
171
- * Opens a connection to tasks.db for the given project context.
172
- *
173
- * Each call opens a fresh DatabaseSync against the path stored in `ctx`.
174
- * Returns null when tasks.db does not exist for the project.
175
- *
176
- * @param ctx - The active project context.
71
+ * Runs `read` against the project-scope `cleo.db` named by `ctx`.
177
72
  *
178
- * @remarks
179
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
180
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
181
- * adapters still target legacy tasks.db table names. Full exodus in E6 (T11249).
73
+ * @param ctx - The active project context; `tasksDbPath` names its `cleo.db`.
74
+ * @param read - Synchronous read against the project store.
75
+ * @returns The read's result, or null when the store is missing or unreadable.
182
76
  */
183
- export function getTasksDb(ctx) {
184
- const path = ctx.tasksDbPath;
185
- if (!existsSync(path))
186
- return null;
187
- const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence (schema-guard-exempt: legacy read adapters run no schema code) — adapters target legacy tasks.db schema; full exodus in E6 (T11249)
188
- applyPerfPragmas(__db);
189
- return __db;
77
+ export function readProjectStore(ctx, read) {
78
+ return readStore(ctx.tasksDbPath, read);
190
79
  }
191
80
  /**
192
- * Opens a connection to conduit.db for the given project context.
81
+ * Runs `read` against the global-scope `cleo.db` under CLEO home.
193
82
  *
194
- * conduit.db lives alongside brain.db in the project's `.cleo/` directory.
195
- * Its path is derived from the brain.db path since `ProjectContext` does not
196
- * carry a dedicated `conduitDbPath` field.
197
- *
198
- * Returns null when conduit.db does not exist for the project.
199
- *
200
- * @param ctx - The active project context.
201
- *
202
- * @remarks
203
- * Uses `applyPerfPragmas` from `@cleocode/core` (SSoT, T9045).
204
- * The raw open is per-line-allowed during the E4 → E6 transition; substrate
205
- * adapters still target legacy conduit.db table names. Full exodus in E6 (T11249).
83
+ * @param read - Synchronous read against the global store.
84
+ * @returns The read's result, or null when the store is missing or unreadable.
206
85
  */
207
- export function getConduitDb(ctx) {
208
- const path = join(dirname(ctx.brainDbPath), 'conduit.db');
209
- if (!existsSync(path))
210
- return null;
211
- const __db = new DatabaseSync(path, { open: true }); // db-open-allowed: E4-T5 coexistence (schema-guard-exempt: legacy read adapters run no schema code) — adapters target legacy conduit.db schema; full exodus in E6 (T11249)
212
- applyPerfPragmas(__db);
213
- return __db;
86
+ export function readGlobalStore(read) {
87
+ return readStore(getGlobalStorePath(), read);
214
88
  }
215
89
  //# sourceMappingURL=db-connections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"db-connections.js","sourceRoot":"","sources":["../../src/db-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGlF;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,aAAa,CAE9C,CAAC;AAkBF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAI,IAA2B,EAAE,GAAG,MAAiB;IAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAQ,CAAC;AACpC,CAAC;AAED,8EAA8E;AAC9E,2DAA2D;AAC3D,8EAA8E;AAE9E,mEAAmE;AACnE,IAAI,OAAO,GAAwB,IAAI,CAAC;AAExC,wEAAwE;AACxE,IAAI,YAAY,GAAwB,IAAI,CAAC;AAE7C,8EAA8E;AAC9E,yCAAyC;AACzC,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU;IACxB,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,MAAM,IAAI,GAAG,cAAc,EAAE,CAAC;IAC9B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OA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S,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAmBpD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAI,IAA2B,EAAE,GAAG,MAAiB;IAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAQ,CAAC;AACpC,CAAC;AAED,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAI,IAAY,EAAE,IAA6B;IAC/D,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,QAA+C,CAAC;IACpD,IAAI,CAAC;QACH,QAAQ,GAAG,kBAAkB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,QAAQ,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAI,GAAmB,EAAE,IAA6B;IACpF,OAAO,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAI,IAA6B;IAC9D,OAAO,SAAS,CAAC,kBAAkB,EAAE,EAAE,IAAI,CAAC,CAAC;AAC/C,CAAC"}
@@ -6,7 +6,7 @@
6
6
  * - Unified query function (`getAllSubstrates`)
7
7
  * - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getAgentRegistrySubstrate`)
8
8
  * - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
9
- * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
9
+ * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getProjectStorePath`, `getGlobalStorePath`)
10
10
  *
11
11
  * @remarks
12
12
  * T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
@@ -18,8 +18,8 @@
18
18
  * @task T969 (original extraction) · T973 (LB* → Brain* rename)
19
19
  */
20
20
  export { getAgentRegistrySubstrate, getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getTasksSubstrate, } from './adapters/index.js';
21
- export { dbExists, getAgentRegistryDbPath, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getTasksDbPath, } from './cleo-home.js';
22
- export { getAgentRegistryDb, getBrainDb, getConduitDb, getNexusDb, getTasksDb, } from './db-connections.js';
21
+ export { dbExists, getCleoHome, getCleoProjectDir, getGlobalStorePath, getProjectStorePath, } from './cleo-home.js';
22
+ export { readGlobalStore, readProjectStore } from './db-connections.js';
23
23
  export type { ProjectContext } from './project-context.js';
24
24
  export { resolveDefaultProjectContext } from './project-context.js';
25
25
  export type { BrainConnectionStatus, BrainEdge, BrainGraph, BrainNode, BrainNodeKind, BrainProjectContext, BrainQueryOptions, BrainStreamEvent, BrainSubstrate, } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAExE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,YAAY,EACV,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/src/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * - Unified query function (`getAllSubstrates`)
7
7
  * - Individual substrate adapters (`getBrainSubstrate`, `getNexusSubstrate`, `getTasksSubstrate`, `getConduitSubstrate`, `getAgentRegistrySubstrate`)
8
8
  * - Project context helpers (`ProjectContext`, `resolveDefaultProjectContext`)
9
- * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getBrainDbPath`, etc.)
9
+ * - Path helpers (`getCleoHome`, `getCleoProjectDir`, `getProjectStorePath`, `getGlobalStorePath`)
10
10
  *
11
11
  * @remarks
12
12
  * T973 renamed the `LB*` prefix to `Brain*` to align the runtime naming with
@@ -21,9 +21,9 @@
21
21
  export { getAgentRegistrySubstrate, getAllSubstrates, getBrainSubstrate, getConduitSubstrate, getNexusSubstrate, getTasksSubstrate, } from './adapters/index.js';
22
22
  // Path helpers (re-exported for downstream consumers that need to resolve
23
23
  // DB paths without importing the connection helpers directly)
24
- export { dbExists, getAgentRegistryDbPath, getBrainDbPath, getCleoHome, getCleoProjectDir, getConduitDbPath, getNexusDbPath, getTasksDbPath, } from './cleo-home.js';
25
- // Low-level connection getters (for advanced consumers; studio typically uses
26
- // its own connection helpers and passes ProjectContext to the adapters instead)
27
- export { getAgentRegistryDb, getBrainDb, getConduitDb, getNexusDb, getTasksDb, } from './db-connections.js';
24
+ export { dbExists, getCleoHome, getCleoProjectDir, getGlobalStorePath, getProjectStorePath, } from './cleo-home.js';
25
+ // Read-only store readers (for advanced consumers; each opens a snapshot of
26
+ // the consolidated cleo.db through the core store chokepoint and closes it)
27
+ export { readGlobalStore, readProjectStore } from './db-connections.js';
28
28
  export { resolveDefaultProjectContext } from './project-context.js';
29
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uCAAuC;AACvC,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,8DAA8D;AAC9D,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,8EAA8E;AAC9E,gFAAgF;AAChF,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,UAAU,EACV,UAAU,GACX,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uCAAuC;AACvC,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,0EAA0E;AAC1E,8DAA8D;AAC9D,OAAO,EACL,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,4EAA4E;AAC5E,4EAA4E;AAC5E,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}