Skip to content

Commit 5f1bbed

Browse files
fix(doctor): report missing managed local embedding setup (#123575)
* fix(gateway): expose startup blockers before cutover * fix(gateway): include session blockers in preflight * fix(gateway): keep preflight finding type private * fix(gateway): preflight startup auth blockers * fix(gateway): complete startup preflight readiness * fix(llama-cpp): keep preflight remediation private * fix(gateway): keep preflight passive and activation-aware * fix(gateway): apply startup guard in preflight * fix(gateway): align auth mode preflight * fix(gateway): keep preflight state reads isolated Share the read-only inspection snapshot scope across duplicated runtime chunks so blocked gateway preflight remains non-mutating when bundled provider artifacts read canonical state. * fix(gateway): keep startup preflight passive * fix(gateway): ignore inactive embedding owner shadows * fix(gateway): preserve startup preflight parity * fix(llama-cpp): keep cache inspection types private * fix(gateway): close startup preflight parity gaps * fix(gateway): handle uninitialized memory databases * test(gateway): observe shell fallback portably * fix(llama-cpp): normalize embedding model paths * refactor(gateway): drop broad startup preflight surface * fix(doctor): report missing managed local embedding setup * style(memory): simplify setup enablement check * fix(memory): keep diagnostic result type private * fix(memory): inspect local setup with remote secret refs * fix(memory): keep doctor index inspection immutable * fix(memory): make readiness inspection owner-aware * fix(doctor): mirror memory slot allowlist policy * test(doctor): use canonical memory slot id * fix(doctor): normalize memory provider ids * fix(doctor): resolve external embedding readiness owner * fix(plugins): keep embedding inspection result internal * fix(doctor): isolate plugin state during lint * fix(doctor): route lint metadata through snapshot * fix(cli): keep doctor lint startup source-only * fix(cli): keep doctor lint compile-cache free * fix(doctor): keep local embedding readiness opt-in * test(doctor): preserve plugin artifact roots during lint * fix(doctor): refresh memory readiness registration * test(doctor): type nullable provider policy mock * fix(doctor): scope lint state snapshot to provider check * fix(doctor): isolate selected plugin state checks * test(doctor): restore only scoped environment * fix(doctor): defer readiness state inspection * fix(doctor): keep deferred config reads isolated * fix(doctor): keep plugin state mode internal * fix(config): preserve default plugin validation
1 parent 635255f commit 5f1bbed

29 files changed

Lines changed: 2103 additions & 104 deletions

‎docs/cli/doctor.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,15 @@ openclaw doctor --lint --all
117117
openclaw doctor --lint --allow-exec
118118
openclaw doctor --lint --only core/doctor/gateway-config --json
119119
openclaw doctor --lint --only core/doctor/local-audio-acceleration --severity-min info
120+
openclaw doctor --lint --only memory-core/managed-local-embedding-setup --severity-min error --json
120121
```
121122

123+
The managed local embedding setup check is a scoped, non-mutating pre-cutover gate for existing
124+
semantic indexes. It is opt-in through `--only` or `--all`, so plain `doctor --lint` behavior stays
125+
unchanged. It reports missing llama.cpp setup and the interactive `models auth login` remediation
126+
without claiming full Gateway readiness, starting services, downloading models, or changing
127+
config.
128+
122129
Human output is compact:
123130

124131
```text

‎extensions/llama-cpp/doctor-contract-api.test.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
22
import { describe, expect, it } from "vitest";
33
import { legacyConfigRules, normalizeCompatibilityConfig } from "./doctor-contract-api.js";
4+
import { inspectEmbeddingProviderSetup } from "./provider-policy-api.js";
5+
import { buildLlamaCppProviderConfig } from "./src/defaults.js";
46

57
describe("llama.cpp doctor migration", () => {
68
it("moves the shipped local URL to an absolute managed service", () => {
@@ -49,4 +51,56 @@ describe("llama.cpp doctor migration", () => {
4951
expect(normalizeCompatibilityConfig({ cfg })).toEqual({ config: cfg, changes: [] });
5052
expect(legacyConfigRules[0]?.match?.("http://gpu-box.local:8080/v1")).toBe(false);
5153
});
54+
55+
it("reports the direct-start managed setup blocker with the supported CLI remediation", async () => {
56+
expect(
57+
inspectEmbeddingProviderSetup({
58+
config: {},
59+
env: {},
60+
agentId: "main",
61+
provider: "local",
62+
}),
63+
).toEqual({
64+
provider: "local",
65+
reason: expect.stringContaining("Local embeddings need the managed llama.cpp server config"),
66+
requirement: "managed-llama-cpp-setup",
67+
fixHint:
68+
"Run `openclaw models --agent main auth login --provider llama-cpp --method local` in an interactive terminal, then rerun this check.",
69+
});
70+
});
71+
72+
it("accepts managed config produced by the models auth CLI without mutating it", async () => {
73+
const provider = buildLlamaCppProviderConfig(undefined, {
74+
command: "/managed/llama-server",
75+
baseUrl: "http://127.0.0.1:19432/v1",
76+
healthUrl: "http://127.0.0.1:19432/health",
77+
args: ["--models-preset", "/managed/models.ini"],
78+
});
79+
const config: OpenClawConfig = {
80+
models: { providers: { "llama-cpp": provider } },
81+
};
82+
const configBefore = JSON.stringify(config);
83+
84+
expect(
85+
inspectEmbeddingProviderSetup({
86+
config,
87+
env: {},
88+
agentId: "main",
89+
provider: "local",
90+
}),
91+
).toBeNull();
92+
93+
expect(JSON.stringify(config)).toBe(configBefore);
94+
});
95+
96+
it("does not apply managed llama.cpp setup to a non-local memory provider", async () => {
97+
expect(
98+
inspectEmbeddingProviderSetup({
99+
config: {},
100+
env: {},
101+
agentId: "main",
102+
provider: "openai",
103+
}),
104+
).toBeNull();
105+
});
52106
});

‎extensions/llama-cpp/index.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,27 @@ describe("llama.cpp provider plugin", () => {
174174
});
175175
});
176176

177+
it("requires managed setup when local memory retains a remote SecretRef", async () => {
178+
await expect(
179+
llamaCppEmbeddingProviderAdapter.create({
180+
config: {
181+
memory: {
182+
search: {
183+
provider: "local",
184+
remote: {
185+
apiKey: { source: "env", provider: "default", id: "OPENAI_API_KEY" },
186+
},
187+
},
188+
},
189+
},
190+
provider: "local",
191+
model: DEFAULT_LLAMA_CPP_EMBEDDING_MODEL,
192+
}),
193+
).rejects.toThrow("Local embeddings need the managed llama.cpp server config");
194+
expect(mocks.ensureModel).not.toHaveBeenCalled();
195+
expect(mocks.prepareServer).not.toHaveBeenCalled();
196+
});
197+
177198
it("routes embeddings through the managed server and reports endpoint facts", async () => {
178199
const result = await llamaCppEmbeddingProviderAdapter.create(configuredOptions());
179200
const provider = expectDefined(result.provider, "local embedding provider");
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
2+
import {
3+
MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE,
4+
resolveManagedLlamaCppProviderConfig,
5+
} from "./src/managed-provider-config.js";
6+
7+
export function inspectEmbeddingProviderSetup(params: {
8+
config: OpenClawConfig;
9+
env: NodeJS.ProcessEnv;
10+
agentId: string;
11+
provider: string;
12+
}): {
13+
provider: string;
14+
reason: string;
15+
requirement: string;
16+
fixHint: string;
17+
} | null {
18+
if (params.provider !== "local") {
19+
return null;
20+
}
21+
const fixHint =
22+
`Run \`openclaw models --agent ${params.agentId} auth login --provider llama-cpp --method local\` ` +
23+
"in an interactive terminal, then rerun this check.";
24+
try {
25+
resolveManagedLlamaCppProviderConfig(params.config);
26+
} catch {
27+
return {
28+
provider: params.provider,
29+
reason: MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE,
30+
requirement: "managed-llama-cpp-setup",
31+
fixHint,
32+
};
33+
}
34+
return null;
35+
}

‎extensions/llama-cpp/src/embedding-provider.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
resolveLlamaCppModelSource,
1919
} from "./defaults.js";
2020
import { selectLlamaServerAsset } from "./llama-server-install.js";
21+
import { resolveManagedLlamaCppProviderConfig } from "./managed-provider-config.js";
2122
import {
2223
ensureLlamaCppModel,
2324
inspectLlamaServerRuntime,
@@ -98,13 +99,7 @@ function resolveModelIdentity(
9899
}
99100

100101
function resolveConfiguredProvider(options: EmbeddingProviderCreateOptions): ModelProviderConfig {
101-
const provider = options.config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
102-
if (!provider?.localService || !provider.baseUrl) {
103-
throw new Error(
104-
"Local embeddings need the managed llama.cpp server config. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.",
105-
);
106-
}
107-
return provider;
102+
return resolveManagedLlamaCppProviderConfig(options.config);
108103
}
109104

110105
function resolveProviderPort(provider: ModelProviderConfig): number {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
2+
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
3+
import { LLAMA_CPP_PROVIDER_ID } from "./defaults.js";
4+
5+
export const MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE =
6+
"Local embeddings need the managed llama.cpp server config. Run `openclaw configure`, choose llama.cpp once, then retry `openclaw memory status --deep`.";
7+
8+
export function resolveManagedLlamaCppProviderConfig(config: OpenClawConfig): ModelProviderConfig {
9+
const provider = config.models?.providers?.[LLAMA_CPP_PROVIDER_ID];
10+
if (!provider?.localService || !provider.baseUrl) {
11+
throw new Error(MANAGED_LLAMA_CPP_CONFIG_REQUIRED_MESSAGE);
12+
}
13+
return provider;
14+
}

‎extensions/memory-core/api.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ export { previewRemHarness } from "./src/rem-harness.js";
1616
export type { PreviewRemHarnessOptions, PreviewRemHarnessResult } from "./src/rem-harness.js";
1717
export { configureMemoryCoreDreamingState } from "./src/dreaming-state.js";
1818
export { filterMemorySearchHitsBySessionVisibility } from "./src/session-search-visibility.js";
19+
export {
20+
MEMORY_MANAGED_LOCAL_EMBEDDING_SETUP_CHECK_ID,
21+
pluginStateIsolatedDoctorCheckIds,
22+
registerMemoryCoreDoctorChecks,
23+
} from "./src/doctor-health.js";

0 commit comments

Comments
 (0)