@cleocode/core 2026.6.3 → 2026.6.4

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 (66) hide show
  1. package/dist/docs/export-document.js +626 -310
  2. package/dist/docs/export-document.js.map +3 -3
  3. package/dist/llm/catalog-cache.d.ts +3 -0
  4. package/dist/llm/catalog-cache.d.ts.map +1 -1
  5. package/dist/llm/catalog-cache.js.map +1 -1
  6. package/dist/llm/catalog-model-resolver.d.ts +89 -0
  7. package/dist/llm/catalog-model-resolver.d.ts.map +1 -0
  8. package/dist/llm/catalog-model-resolver.js +158 -0
  9. package/dist/llm/catalog-model-resolver.js.map +1 -0
  10. package/dist/llm/cli-ops.d.ts +14 -0
  11. package/dist/llm/cli-ops.d.ts.map +1 -1
  12. package/dist/llm/cli-ops.js +35 -0
  13. package/dist/llm/cli-ops.js.map +1 -1
  14. package/dist/llm/index.d.ts +3 -0
  15. package/dist/llm/index.d.ts.map +1 -1
  16. package/dist/llm/index.js +3 -0
  17. package/dist/llm/index.js.map +1 -1
  18. package/dist/llm/oauth/pkce.js +27 -5
  19. package/dist/llm/oauth/pkce.js.map +1 -1
  20. package/dist/llm/plugin-facade.js +613 -325
  21. package/dist/llm/plugin-facade.js.map +3 -3
  22. package/dist/llm/provider-registry/builtin/openai.d.ts +11 -2
  23. package/dist/llm/provider-registry/builtin/openai.d.ts.map +1 -1
  24. package/dist/llm/provider-registry/builtin/openai.js +15 -3
  25. package/dist/llm/provider-registry/builtin/openai.js.map +1 -1
  26. package/dist/llm/system-resolver.d.ts +94 -0
  27. package/dist/llm/system-resolver.d.ts.map +1 -0
  28. package/dist/llm/system-resolver.js +165 -0
  29. package/dist/llm/system-resolver.js.map +1 -0
  30. package/dist/store/dual-scope-db.d.ts +20 -2
  31. package/dist/store/dual-scope-db.d.ts.map +1 -1
  32. package/dist/store/dual-scope-db.js +74 -7
  33. package/dist/store/dual-scope-db.js.map +1 -1
  34. package/dist/store/exodus/archive.d.ts +216 -0
  35. package/dist/store/exodus/archive.d.ts.map +1 -0
  36. package/dist/store/exodus/archive.js +314 -0
  37. package/dist/store/exodus/archive.js.map +1 -0
  38. package/dist/store/exodus/index.d.ts +1 -0
  39. package/dist/store/exodus/index.d.ts.map +1 -1
  40. package/dist/store/exodus/index.js +1 -0
  41. package/dist/store/exodus/index.js.map +1 -1
  42. package/dist/store/exodus/migrate.d.ts.map +1 -1
  43. package/dist/store/exodus/migrate.js +118 -24
  44. package/dist/store/exodus/migrate.js.map +1 -1
  45. package/dist/store/exodus/on-open.d.ts.map +1 -1
  46. package/dist/store/exodus/on-open.js +95 -34
  47. package/dist/store/exodus/on-open.js.map +1 -1
  48. package/dist/store/exodus/types.d.ts +10 -1
  49. package/dist/store/exodus/types.d.ts.map +1 -1
  50. package/dist/store/exodus/types.js.map +1 -1
  51. package/dist/store/exodus/verify-migration.d.ts.map +1 -1
  52. package/dist/store/exodus/verify-migration.js +12 -1
  53. package/dist/store/exodus/verify-migration.js.map +1 -1
  54. package/dist/store/sqlite.d.ts +16 -0
  55. package/dist/store/sqlite.d.ts.map +1 -1
  56. package/dist/store/sqlite.js +160 -39
  57. package/dist/store/sqlite.js.map +1 -1
  58. package/dist/validation/doctor/checks.d.ts +22 -0
  59. package/dist/validation/doctor/checks.d.ts.map +1 -1
  60. package/dist/validation/doctor/checks.js +67 -0
  61. package/dist/validation/doctor/checks.js.map +1 -1
  62. package/dist/validation/doctor/index.d.ts +1 -1
  63. package/dist/validation/doctor/index.d.ts.map +1 -1
  64. package/dist/validation/doctor/index.js +1 -1
  65. package/dist/validation/doctor/index.js.map +1 -1
  66. package/package.json +12 -12
@@ -28,8 +28,17 @@ export declare const OPENAI_CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hran
28
28
  /**
29
29
  * OpenAI / Codex provider profile.
30
30
  *
31
- * `defaultModel` is the Codex coding model; override per-credential with
32
- * `cleo llm use openai --model <m>` or `cleo llm profile <role> openai --model <m>`.
31
+ * `defaultModel` is a static FALLBACK used when no live catalog snapshot is
32
+ * available (i.e. before `cleo llm refresh-catalog` has been run). At runtime,
33
+ * `cleo llm use openai` / `cleo llm profile <role> openai` derive the default
34
+ * from the live catalog via `resolveProviderDefaultModel` and validate any
35
+ * explicit `--model` against `validateModelForProvider` (T11773 · E8).
36
+ *
37
+ * Override per-credential:
38
+ * `cleo llm use openai --model <m>`
39
+ * `cleo llm profile <role> openai --model <m>`
40
+ *
41
+ * @task T11773
33
42
  */
34
43
  export declare const openaiProfile: ProviderProfile;
35
44
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA6B3E;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,eAQ3B,CAAC"}
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AA6B3E;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,EAAE,eAW3B,CAAC"}
@@ -52,15 +52,27 @@ const OPENAI_CODEX_OAUTH = {
52
52
  /**
53
53
  * OpenAI / Codex provider profile.
54
54
  *
55
- * `defaultModel` is the Codex coding model; override per-credential with
56
- * `cleo llm use openai --model <m>` or `cleo llm profile <role> openai --model <m>`.
55
+ * `defaultModel` is a static FALLBACK used when no live catalog snapshot is
56
+ * available (i.e. before `cleo llm refresh-catalog` has been run). At runtime,
57
+ * `cleo llm use openai` / `cleo llm profile <role> openai` derive the default
58
+ * from the live catalog via `resolveProviderDefaultModel` and validate any
59
+ * explicit `--model` against `validateModelForProvider` (T11773 · E8).
60
+ *
61
+ * Override per-credential:
62
+ * `cleo llm use openai --model <m>`
63
+ * `cleo llm profile <role> openai --model <m>`
64
+ *
65
+ * @task T11773
57
66
  */
58
67
  export const openaiProfile = {
59
68
  name: 'openai',
60
69
  displayName: 'OpenAI Codex (ChatGPT)',
61
70
  authTypes: ['api_key', 'oauth'],
62
71
  baseUrl: 'https://api.openai.com/v1',
63
- defaultModel: 'gpt-5-codex',
72
+ // Static fallback — catalog-driven resolver replaces this at runtime when a
73
+ // disk snapshot is available (T11773 · E8). Updated from stale 'gpt-5-codex'
74
+ // to the confirmed latest OpenAI model (catalog release_date 2026-04-23).
75
+ defaultModel: 'gpt-5.5',
64
76
  aliases: ['codex', 'chatgpt', 'openai-codex'],
65
77
  oauth: OPENAI_CODEX_OAUTH,
66
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../../src/llm/provider-registry/builtin/openai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,8BAA8B,CAAC;AAE3E,6EAA6E;AAC7E,SAAS,qBAAqB;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,IAAI,4BAA4B,CAAC;AACpF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAwB;IAC9C,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,qBAAqB,EAAE;IACjC,qBAAqB,EAAE,yCAAyC;IAChE,aAAa,EAAE,qCAAqC;IACpD,KAAK,EAAE,qCAAqC;IAC5C,WAAW,EAAE,qCAAqC;IAClD,eAAe,EAAE;QACf,0BAA0B,EAAE,MAAM;QAClC,yBAAyB,EAAE,MAAM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Y,EAAE,SAAS;IACvB,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,cAAc,CAAC;IAC7C,KAAK,EAAE,kBAAkB;CAC1B,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `resolveLLMForSystem` — the single DRY chokepoint for all LLM resolution (E9).
3
+ *
4
+ * ## Purpose
5
+ *
6
+ * CLEO previously had a 4-resolver / 3-picker sprawl: `resolveLLMForRole`,
7
+ * `resolveAnthropicForRole`, `resolveCredentials`, and several inline `pickX`
8
+ * helpers each duplicated the implicit fallback model literal or called different
9
+ * tiers of the resolution chain independently.
10
+ *
11
+ * `resolveLLMForSystem` is the ONE chokepoint that:
12
+ *
13
+ * 1. Accepts a semantic "system of use" label (e.g. `'sentient'`, `'memory'`)
14
+ * instead of raw role names — insulating call-sites from config vocabulary.
15
+ * 2. Maps the system label to the canonical {@link RoleName} via
16
+ * {@link SYSTEM_ROLE_MAP} (overridable by `opts.roleOverride`).
17
+ * 3. Delegates to `resolveLLMForRole` for the full 5-tier config +
18
+ * CredentialPool resolution chain — no duplication.
19
+ * 4. When resolution lands on `implicit-fallback`, replaces the hardcoded
20
+ * haiku literal with the SSoT default model from the provider registry
21
+ * (`getProviderProfile(provider).defaultModel`) — satisfying the
22
+ * "not hardcoded" acceptance criterion.
23
+ *
24
+ * ## What this is NOT
25
+ *
26
+ * - A replacement for `resolveLLMForRole`. Existing callers of
27
+ * `resolveLLMForRole` continue to work unchanged; T11757 will migrate them
28
+ * to this chokepoint incrementally.
29
+ * - A new credential store or provider registry. All credential I/O goes
30
+ * through the existing CredentialPool (E3 pool) inside `resolveLLMForRole`.
31
+ *
32
+ * @module llm/system-resolver
33
+ * @task T11749
34
+ * @epic T11745
35
+ */
36
+ import type { ResolveLLMForSystemOptions, RoleName, SystemOfUse } from '@cleocode/contracts';
37
+ import { type ResolvedLLM } from './role-resolver.js';
38
+ /**
39
+ * Result of {@link resolveLLMForSystem}.
40
+ *
41
+ * Extends {@link ResolvedLLM} with the resolved `system` label so callers
42
+ * can log/audit which system triggered the resolution without passing it
43
+ * separately.
44
+ *
45
+ * @task T11749
46
+ */
47
+ export interface ResolvedLLMForSystem extends ResolvedLLM {
48
+ /**
49
+ * The {@link SystemOfUse} label that initiated this resolution.
50
+ *
51
+ * Preserved verbatim from the call argument — not normalised or remapped.
52
+ */
53
+ system: SystemOfUse;
54
+ /**
55
+ * The {@link RoleName} that was actually used for config lookup.
56
+ *
57
+ * `null` when `system === 'default'` and no role override was supplied
58
+ * (the global LLM default path was used instead of a per-role entry).
59
+ */
60
+ resolvedRole: RoleName | null;
61
+ }
62
+ /**
63
+ * Resolve the LLM client + credential for a semantic system-of-use label.
64
+ *
65
+ * This is the single DRY chokepoint for all LLM resolution in CLEO (E9 ·
66
+ * T11745). It wraps `resolveLLMForRole` with:
67
+ *
68
+ * - System label → role mapping (via {@link SYSTEM_ROLE_MAP}).
69
+ * - SSoT default model from the provider registry when `implicit-fallback`
70
+ * is reached (the hardcoded haiku literal is NOT used as the final model).
71
+ * - Full CredentialPool (E3) binding via `resolveLLMForRole` delegation.
72
+ *
73
+ * Like `resolveLLMForRole`, this function **never throws**: when no credential
74
+ * is reachable the caller receives `{ credential: null, client: null, … }` and
75
+ * is responsible for its own graceful-degradation path.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const resolved = await resolveLLMForSystem('sentient', { projectRoot });
80
+ * if (!resolved.credential?.apiKey || !resolved.client) {
81
+ * return null; // graceful no-op — no credential available
82
+ * }
83
+ * // Use resolved.model, resolved.client, resolved.credential
84
+ * ```
85
+ *
86
+ * @param system - Semantic label for the subsystem requesting an LLM client.
87
+ * @param opts - Optional overrides (project root, role override, skipCatalogDefault).
88
+ * @returns A {@link ResolvedLLMForSystem} envelope; never throws.
89
+ *
90
+ * @task T11749
91
+ * @epic T11745
92
+ */
93
+ export declare function resolveLLMForSystem(system: SystemOfUse, opts?: ResolveLLMForSystemOptions): Promise<ResolvedLLMForSystem>;
94
+ //# sourceMappingURL=system-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-resolver.d.ts","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAI5B;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;;;OAIG;IACH,MAAM,EAAE,WAAW,CAAC;IAEpB;;;;;OAKG;IACH,YAAY,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC/B;AAqED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,IAAI,CAAC,EAAE,0BAA0B,GAChC,OAAO,CAAC,oBAAoB,CAAC,CAyC/B"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * `resolveLLMForSystem` — the single DRY chokepoint for all LLM resolution (E9).
3
+ *
4
+ * ## Purpose
5
+ *
6
+ * CLEO previously had a 4-resolver / 3-picker sprawl: `resolveLLMForRole`,
7
+ * `resolveAnthropicForRole`, `resolveCredentials`, and several inline `pickX`
8
+ * helpers each duplicated the implicit fallback model literal or called different
9
+ * tiers of the resolution chain independently.
10
+ *
11
+ * `resolveLLMForSystem` is the ONE chokepoint that:
12
+ *
13
+ * 1. Accepts a semantic "system of use" label (e.g. `'sentient'`, `'memory'`)
14
+ * instead of raw role names — insulating call-sites from config vocabulary.
15
+ * 2. Maps the system label to the canonical {@link RoleName} via
16
+ * {@link SYSTEM_ROLE_MAP} (overridable by `opts.roleOverride`).
17
+ * 3. Delegates to `resolveLLMForRole` for the full 5-tier config +
18
+ * CredentialPool resolution chain — no duplication.
19
+ * 4. When resolution lands on `implicit-fallback`, replaces the hardcoded
20
+ * haiku literal with the SSoT default model from the provider registry
21
+ * (`getProviderProfile(provider).defaultModel`) — satisfying the
22
+ * "not hardcoded" acceptance criterion.
23
+ *
24
+ * ## What this is NOT
25
+ *
26
+ * - A replacement for `resolveLLMForRole`. Existing callers of
27
+ * `resolveLLMForRole` continue to work unchanged; T11757 will migrate them
28
+ * to this chokepoint incrementally.
29
+ * - A new credential store or provider registry. All credential I/O goes
30
+ * through the existing CredentialPool (E3 pool) inside `resolveLLMForRole`.
31
+ *
32
+ * @module llm/system-resolver
33
+ * @task T11749
34
+ * @epic T11745
35
+ */
36
+ import { SYSTEM_ROLE_MAP } from '@cleocode/contracts';
37
+ import { getLogger } from '../logger.js';
38
+ import { IMPLICIT_FALLBACK_PROVIDER, resolveLLMForRole, } from './role-resolver.js';
39
+ const logger = getLogger('llm-system-resolver');
40
+ // ---------------------------------------------------------------------------
41
+ // Internal helpers
42
+ // ---------------------------------------------------------------------------
43
+ /**
44
+ * Map a {@link SystemOfUse} to the {@link RoleName} that `resolveLLMForRole`
45
+ * will use for config lookup.
46
+ *
47
+ * Priority:
48
+ * 1. `opts.roleOverride` — explicit caller override.
49
+ * 2. {@link SYSTEM_ROLE_MAP} — static default for the system label.
50
+ *
51
+ * Returns `null` when the system maps to the global default (no role entry).
52
+ */
53
+ function deriveRole(system, opts) {
54
+ if (opts?.roleOverride)
55
+ return opts.roleOverride;
56
+ return SYSTEM_ROLE_MAP[system] ?? null;
57
+ }
58
+ /**
59
+ * When `resolveLLMForRole` returns `source === 'implicit-fallback'`, the
60
+ * model is the hardcoded `IMPLICIT_FALLBACK_MODEL` literal. This function
61
+ * replaces it with the SSoT `defaultModel` from the provider registry so
62
+ * the resolved model tracks catalog updates rather than a frozen constant.
63
+ *
64
+ * On any lookup error the original `resolved` envelope is returned unchanged
65
+ * so the caller is never blocked — graceful degradation is preserved.
66
+ *
67
+ * @param resolved - The envelope returned by `resolveLLMForRole`.
68
+ * @returns The same envelope, possibly with `model` replaced from the registry.
69
+ */
70
+ async function upgradeCatalogDefault(resolved) {
71
+ if (resolved.source !== 'implicit-fallback') {
72
+ // Not a fallback — the user explicitly configured a model; respect it.
73
+ return resolved;
74
+ }
75
+ try {
76
+ // Lazy import to avoid pulling the full registry chain at module-init time.
77
+ const { getProviderProfile } = await import('./provider-registry/index.js');
78
+ const profile = await getProviderProfile(resolved.provider);
79
+ if (!profile?.defaultModel) {
80
+ // Registry has no default for this provider — fall back to the existing model.
81
+ return resolved;
82
+ }
83
+ if (profile.defaultModel === resolved.model) {
84
+ // Already the same — no mutation needed.
85
+ return resolved;
86
+ }
87
+ logger.debug({ provider: resolved.provider, from: resolved.model, to: profile.defaultModel }, 'system-resolver: upgrading implicit-fallback model to catalog default');
88
+ return { ...resolved, model: profile.defaultModel };
89
+ }
90
+ catch (err) {
91
+ logger.warn({ err: err instanceof Error ? err.message : String(err) }, 'system-resolver: catalog default lookup failed; keeping existing fallback model');
92
+ return resolved;
93
+ }
94
+ }
95
+ // ---------------------------------------------------------------------------
96
+ // Public API
97
+ // ---------------------------------------------------------------------------
98
+ /**
99
+ * Resolve the LLM client + credential for a semantic system-of-use label.
100
+ *
101
+ * This is the single DRY chokepoint for all LLM resolution in CLEO (E9 ·
102
+ * T11745). It wraps `resolveLLMForRole` with:
103
+ *
104
+ * - System label → role mapping (via {@link SYSTEM_ROLE_MAP}).
105
+ * - SSoT default model from the provider registry when `implicit-fallback`
106
+ * is reached (the hardcoded haiku literal is NOT used as the final model).
107
+ * - Full CredentialPool (E3) binding via `resolveLLMForRole` delegation.
108
+ *
109
+ * Like `resolveLLMForRole`, this function **never throws**: when no credential
110
+ * is reachable the caller receives `{ credential: null, client: null, … }` and
111
+ * is responsible for its own graceful-degradation path.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * const resolved = await resolveLLMForSystem('sentient', { projectRoot });
116
+ * if (!resolved.credential?.apiKey || !resolved.client) {
117
+ * return null; // graceful no-op — no credential available
118
+ * }
119
+ * // Use resolved.model, resolved.client, resolved.credential
120
+ * ```
121
+ *
122
+ * @param system - Semantic label for the subsystem requesting an LLM client.
123
+ * @param opts - Optional overrides (project root, role override, skipCatalogDefault).
124
+ * @returns A {@link ResolvedLLMForSystem} envelope; never throws.
125
+ *
126
+ * @task T11749
127
+ * @epic T11745
128
+ */
129
+ export async function resolveLLMForSystem(system, opts) {
130
+ const resolvedRole = deriveRole(system, opts);
131
+ // When the role is null (system === 'default'), fall back to treating it as
132
+ // the 'consolidation' role — this exercises the same config tiers as all
133
+ // other roles (roles[role] → default → defaultProfile → implicit-fallback)
134
+ // and avoids a special code path. If `config.llm.roles['consolidation']` is
135
+ // not set, resolution cascades to `config.llm.default` and then the catalog
136
+ // default exactly as desired.
137
+ const roleForResolution = resolvedRole ?? 'consolidation';
138
+ let base;
139
+ try {
140
+ base = await resolveLLMForRole(roleForResolution, {
141
+ projectRoot: opts?.projectRoot,
142
+ });
143
+ }
144
+ catch (err) {
145
+ // Mirror role-resolver's never-throw contract: return a null-credential
146
+ // envelope on unexpected failure.
147
+ logger.warn({ err: err instanceof Error ? err.message : String(err), system, role: roleForResolution }, 'system-resolver: resolveLLMForRole threw unexpectedly; returning null-credential envelope');
148
+ base = {
149
+ provider: IMPLICIT_FALLBACK_PROVIDER,
150
+ model: 'unknown',
151
+ client: null,
152
+ credential: null,
153
+ source: 'implicit-fallback',
154
+ };
155
+ }
156
+ // Upgrade the implicit-fallback model to the SSoT catalog default unless
157
+ // the caller asked to skip the catalog lookup (e.g., in tests).
158
+ const upgraded = opts?.skipCatalogDefault ? base : await upgradeCatalogDefault(base);
159
+ return {
160
+ ...upgraded,
161
+ system,
162
+ resolvedRole,
163
+ };
164
+ }
165
+ //# sourceMappingURL=system-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-resolver.js","sourceRoot":"","sources":["../../src/llm/system-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,e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AChB,MAAM,EAAE,mBAAmB;SAC5B,CAAC;IACJ,CAAC;IAED,yEAAyE;IACzE,gEAAgE;IAChE,MAAM,QAAQ,GAAG,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAErF,OAAO;QACL,GAAG,QAAQ;QACX,MAAM;QACN,YAAY;KACb,CAAC;AACJ,CAAC"}
@@ -83,6 +83,24 @@ export interface DualScopeDbHandle<TScope extends DualScope = DualScope> {
83
83
  */
84
84
  close(): void;
85
85
  }
86
+ /**
87
+ * Options for {@link openDualScopeDbAtPath}.
88
+ *
89
+ * @task T11782 (FIX D — dedicated migrate connection)
90
+ */
91
+ export interface OpenDualScopeAtPathOptions {
92
+ /**
93
+ * When `true`, open a DEDICATED, NON-cached connection — a second SQLite
94
+ * handle to the same file, independent of the singleton `_cache`. Used by the
95
+ * exodus migrate engine so its copy + rollback transactions are isolated from
96
+ * the caller's cached handle (and any concurrent task INSERTs sharing it). The
97
+ * returned handle's `close()` closes only the native connection and never
98
+ * mutates the cache; the caller MUST close it to avoid a descriptor leak.
99
+ *
100
+ * @default false
101
+ */
102
+ readonly dedicated?: boolean;
103
+ }
86
104
  /**
87
105
  * Resolve the absolute path to the dual-scope `cleo.db` for the given scope.
88
106
  *
@@ -140,8 +158,8 @@ export declare function openDualScopeDb(scope: 'global', cwd?: string): Promise<
140
158
  * @epic T11249 (E6)
141
159
  * @saga T11242
142
160
  */
143
- export declare function openDualScopeDbAtPath(scope: 'project', dbPath: string, exodusCwd?: string): Promise<DualScopeDbHandle<'project'>>;
144
- export declare function openDualScopeDbAtPath(scope: 'global', dbPath: string, exodusCwd?: string): Promise<DualScopeDbHandle<'global'>>;
161
+ export declare function openDualScopeDbAtPath(scope: 'project', dbPath: string, exodusCwd?: string, options?: OpenDualScopeAtPathOptions): Promise<DualScopeDbHandle<'project'>>;
162
+ export declare function openDualScopeDbAtPath(scope: 'global', dbPath: string, exodusCwd?: string, options?: OpenDualScopeAtPathOptions): Promise<DualScopeDbHandle<'global'>>;
145
163
  /**
146
164
  * Reset cached dual-scope handles. Primarily for use in tests between test
147
165
  * cases and by domain `closeDb()`/`resetDbState()` paths. Closes the targeted
@@ -1 +1 @@
1
- {"version":3,"file":"dual-scope-db.d.ts","sourceRoot":"","sources":["../../src/store/dual-scope-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAMH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAKlE,OAAO,KAAK,KAAK,qBAAqB,MAAM,+BAA+B,CAAC;AAC5E,OAAO,KAAK,KAAK,sBAAsB,MAAM,gCAAgC,CAAC;AAK9E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7C,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE9E,2DAA2D;AAC3D,MAAM,MAAM,YAAY,GAAG,kBAAkB,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACrE,gFAAgF;IAChF,QAAQ,CAAC,EAAE,EAAE,MAAM,SAAS,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;IACrE,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAyBD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAK7E;AAsFD;;;;;;;;;;;;;;;;;;;;GAoBG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C,MAAM,SAAS,sBAAsB,CAAC,WAAW,CAAC,EAEvF,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAE7B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,SAAS,sBAAsB,CAAC,WAAW,CAAC,EAEvF,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAC3B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAC7B,wEAAwE;AACxE,UAAU,EAAE,MAAM,EAElB,cAAc,EAAE,GAAG,EACnB,GAAG,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GACtC,OAAO,CAAC,MAAM,CAAC,CAYjB"}
@@ -149,6 +149,58 @@ export async function openDualScopeDb(scope, cwd) {
149
149
  ? openDualScopeDbAtPath('project', dbPath, cwd)
150
150
  : openDualScopeDbAtPath('global', dbPath, cwd);
151
151
  }
152
+ /**
153
+ * Open a DEDICATED, NON-cached consolidated dual-scope `cleo.db` connection
154
+ * (T11782 · FIX D).
155
+ *
156
+ * This opens a fresh `DatabaseSync` to `dbPath`, applies the canonical pragmas,
157
+ * wraps it in Drizzle, reconciles + runs migrations, and returns a handle whose
158
+ * `close()` ONLY closes the native connection — it never reads or mutates the
159
+ * singleton `_cache`. WAL mode permits this second connection to coexist with
160
+ * the cached caller handle on the same file. The exodus migrate engine uses this
161
+ * so its bulk-copy + parity-abort rollback transactions are physically isolated
162
+ * from the caller's connection (and any concurrent task INSERTs sharing it).
163
+ *
164
+ * @param scope - The consolidated schema scope.
165
+ * @param dbPath - Absolute path to the consolidated `cleo.db` file.
166
+ * @param log - The module logger.
167
+ * @returns A typed {@link DualScopeDbHandle} backed by a dedicated connection.
168
+ *
169
+ * @task T11782 (FIX D — rollback connection isolation)
170
+ */
171
+ async function openDedicatedDualScopeDb(scope, dbPath, log) {
172
+ log.debug({ scope, dbPath }, 'opening DEDICATED (non-cached) dual-scope cleo.db (T11782 FIX D)');
173
+ // Ensure the directory exists before opening.
174
+ const dir = dirname(dbPath);
175
+ if (!existsSync(dir)) {
176
+ mkdirSync(dir, { recursive: true });
177
+ }
178
+ const DatabaseSyncCtor = getDatabaseSyncCtor();
179
+ const nativeDb = new DatabaseSyncCtor(dbPath, { allowExtension: true });
180
+ applyPerfPragmas(nativeDb);
181
+ const schema = scope === 'project' ? await loadProjectSchema() : await loadGlobalSchema();
182
+ const drizzle = getDrizzle();
183
+ // biome-ignore lint/suspicious/noExplicitAny: schema type is scope-specific; typed via DualScopeDbHandle<TScope>
184
+ const db = drizzle({ client: nativeDb, schema });
185
+ const migrationsFolder = resolveCorePackageMigrationsFolder(migrationsSetName(scope));
186
+ reconcileJournal(nativeDb, migrationsFolder, existenceTable(scope), `dual-scope-db[${scope}]`);
187
+ migrateWithRetry(db, migrationsFolder, nativeDb, existenceTable(scope), `dual-scope-db[${scope}]`);
188
+ log.debug({ scope, dbPath }, 'DEDICATED dual-scope cleo.db ready (T11782 FIX D)');
189
+ return {
190
+ db,
191
+ scope,
192
+ dbPath,
193
+ close() {
194
+ // Dedicated handles are never cached — close only the native connection.
195
+ try {
196
+ nativeDb.close();
197
+ }
198
+ catch {
199
+ // Idempotent — ignore double-close errors.
200
+ }
201
+ },
202
+ };
203
+ }
152
204
  export async function openDualScopeDbAtPath(scope, dbPath,
153
205
  /**
154
206
  * Internal: the resolved `cwd` from the canonical {@link openDualScopeDb}
@@ -157,17 +209,32 @@ export async function openDualScopeDbAtPath(scope, dbPath,
157
209
  * the public explicit-path callers (tests / legacy-path domains), which must
158
210
  * never auto-migrate an isolated fixture DB.
159
211
  */
160
- exodusCwd) {
212
+ exodusCwd, options) {
213
+ const dedicated = options?.dedicated === true;
161
214
  const key = cacheKey(scope, dbPath);
162
- // Return cached handle if available and not mid-init.
163
- const existing = _cache.get(key);
164
- if (existing) {
165
- if (existing.initPromise) {
166
- return existing.initPromise;
215
+ // A DEDICATED open (T11782 · FIX D) bypasses the singleton cache entirely: it
216
+ // opens a SECOND SQLite connection to the same file (WAL allows concurrent
217
+ // connections) so the exodus migrate engine can copy + (on abort) truncate on
218
+ // an ISOLATED handle. The caller's cached handle — shared by concurrent task
219
+ // INSERTs — is a physically distinct connection, so the migration's rollback
220
+ // can only ever truncate its OWN connection's transaction, never the caller's
221
+ // concurrent writes. The returned handle's `close()` only closes the native
222
+ // connection; it never touches `_cache`. Callers MUST close it after use to
223
+ // avoid a file-descriptor leak.
224
+ if (!dedicated) {
225
+ // Return cached handle if available and not mid-init.
226
+ const existing = _cache.get(key);
227
+ if (existing) {
228
+ if (existing.initPromise) {
229
+ return existing.initPromise;
230
+ }
231
+ return existing.handle;
167
232
  }
168
- return existing.handle;
169
233
  }
170
234
  const log = getLogger('dual-scope-db');
235
+ if (dedicated) {
236
+ return openDedicatedDualScopeDb(scope, dbPath, log);
237
+ }
171
238
  // Create a placeholder entry so concurrent callers wait for the same init.
172
239
  const initPromise = (async () => {
173
240
  log.debug({ scope, dbPath }, 'opening dual-scope cleo.db');
@@ -1 +1 @@
1
- {"version":3,"file":"dual-scope-db.js","sourceRoot":"","sources":["../../src/store/dual-scope-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC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