Skip to content

Commit 3c67fcc

Browse files
authored
fix(release): stabilize beta validation and completion (#114396)
* test(release): fix rebased validation gates * test(migrate-hermes): use canonical auth store fixture * test(secrets): reset runtime state before migration isolation * test(secrets): reload singleton graph for migration isolation * test(secrets): isolate auth migration state * fix(release): return completed validation run * docs: refresh docs map after forward-port
1 parent d4ed57b commit 3c67fcc

6 files changed

Lines changed: 115 additions & 85 deletions

File tree

‎extensions/migrate-hermes/secrets.test.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -707,17 +707,24 @@ describe("Hermes migration secret items", () => {
707707
const stateDir = path.join(root, "state");
708708
const agentDir = path.join(stateDir, "agents", "main", "agent");
709709
await writeFile(path.join(source, ".env"), "OPENAI_API_KEY=sk-hermes\n");
710-
await writeFile(
711-
path.join(agentDir, "auth.json"),
712-
JSON.stringify({
713-
openai: { type: "api_key", provider: "openai", key: "legacy-main-key" },
714-
}),
715-
);
710+
const existingStore: AuthProfileStore = {
711+
version: 1,
712+
profiles: {
713+
"openai:existing": {
714+
type: "api_key",
715+
provider: "openai",
716+
key: "existing-main-key",
717+
},
718+
},
719+
};
720+
writeAuthProfileStore(agentDir, existingStore);
721+
const beforePlanStore = readAuthProfileStore(agentDir);
716722

717723
const provider = buildHermesMigrationProvider();
718724
await provider.plan(makeContext({ source, stateDir, workspaceDir, includeSecrets: true }));
719725

720-
await expect(fs.access(path.join(agentDir, "auth.json"))).resolves.toBeUndefined();
726+
expect(readAuthProfileStore(agentDir)).toEqual(beforePlanStore);
727+
// Canonical profiles stay in SQLite; planning must not recreate the retired JSON sidecar.
721728
await expectMissingPath(path.join(agentDir, "auth-profiles.json"));
722729
});
723730

‎extensions/openai/video-generation-provider.test.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
5+
import {
6+
clearRuntimeAuthProfileStoreSnapshots,
7+
saveAuthProfileStore,
8+
} from "openclaw/plugin-sdk/agent-runtime";
59
import {
610
getProviderHttpMocks,
711
installProviderHttpMockCleanup,
@@ -130,9 +134,8 @@ describe("openai video generation provider", () => {
130134
const previousOpenAIKey = process.env.OPENAI_API_KEY;
131135
delete process.env.OPENAI_API_KEY;
132136
try {
133-
fs.writeFileSync(
134-
path.join(agentDir, "auth-profiles.json"),
135-
JSON.stringify({
137+
saveAuthProfileStore(
138+
{
136139
version: 1,
137140
profiles: {
138141
"openai:chatgpt": {
@@ -143,11 +146,14 @@ describe("openai video generation provider", () => {
143146
expires: Date.now() + 60_000,
144147
},
145148
},
146-
}),
149+
},
150+
agentDir,
151+
{ filterExternalAuthProfiles: false, syncExternalCli: false },
147152
);
148153

149154
expect(buildOpenAIVideoGenerationProvider().isConfigured?.({ agentDir })).toBe(false);
150155
} finally {
156+
clearRuntimeAuthProfileStoreSnapshots();
151157
if (previousOpenAIKey === undefined) {
152158
delete process.env.OPENAI_API_KEY;
153159
} else {

‎extensions/xai/stream.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "./test-helpers.js";
1818
type XaiStreamApi = Extract<Api, "openai-completions" | "openai-responses">;
1919
type StreamEvent = Record<string, unknown> & { type?: string };
20+
const PAYLOAD_CAPTURE_TIMEOUT_MS = 5_000;
2021

2122
async function collectEvents(stream: ReturnType<StreamFn>): Promise<StreamEvent[]> {
2223
const events: StreamEvent[] = [];
@@ -124,7 +125,7 @@ async function captureXaiResponsesPayloadWithThinking(
124125
const payloadPromise = new Promise<Record<string, unknown>>((resolve, reject) => {
125126
const timeout = setTimeout(
126127
() => reject(new Error("provider payload callback was not invoked")),
127-
1_000,
128+
PAYLOAD_CAPTURE_TIMEOUT_MS,
128129
);
129130
const stream = streamSimple(
130131
model,
@@ -478,19 +479,19 @@ describe("xai stream wrappers", () => {
478479

479480
expect(payload.reasoning).toEqual({ effort: "low", summary: "auto" });
480481
expect(payload.include).toEqual(["reasoning.encrypted_content"]);
481-
});
482+
}, 10_000);
482483

483484
it("clamps unsupported Grok 4.5 off reasoning to low", async () => {
484485
const payload = await captureXaiResponsesPayloadWithThinking("off");
485486

486487
expect(payload.reasoning).toEqual({ effort: "low", summary: "auto" });
487-
});
488+
}, 10_000);
488489

489490
it("maps Grok 4.3 off reasoning to xAI none", async () => {
490491
const payload = await captureXaiResponsesPayloadWithThinking("off", "grok-4.3");
491492

492493
expect(payload.reasoning).toEqual({ effort: "none" });
493-
});
494+
}, 10_000);
494495

495496
it("moves image-bearing tool results out of function_call_output payloads", () => {
496497
const payload: Record<string, unknown> = {

‎scripts/full-release-validation-at-sha.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function waitForWorkflowRun(parentRunId, workflowSha) {
299299
}
300300
if (suite?.status === "completed") {
301301
if (suite.conclusion === "success") {
302-
return;
302+
return suite;
303303
}
304304
throw new Error(
305305
`Full Release Validation concluded ${String(suite.conclusion).toLowerCase()}: https://github.com/openclaw/openclaw/actions/runs/${parentRunId}`,
Lines changed: 84 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,100 @@
1-
import fs from "node:fs/promises";
2-
import os from "node:os";
3-
import path from "node:path";
4-
import { afterEach, describe, expect, it, vi } from "vitest";
5-
import { writePersistedAuthProfileStoreRaw } from "../agents/auth-profiles/sqlite.js";
6-
import { resolveApiKeyForProvider } from "../agents/model-auth.js";
7-
import { closeOpenClawAgentDatabasesForTest } from "../state/openclaw-agent-db.js";
8-
import {
9-
activateSecretsRuntimeSnapshot,
10-
clearSecretsRuntimeSnapshot,
11-
prepareSecretsRuntimeSnapshot,
12-
} from "./runtime.js";
1+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2+
3+
let resolveApiKeyForProvider: typeof import("../agents/model-auth.js").resolveApiKeyForProvider;
4+
let closeOpenClawAgentDatabasesForTest: typeof import("../state/openclaw-agent-db.js").closeOpenClawAgentDatabasesForTest;
5+
let withOpenClawTestState: typeof import("../test-utils/openclaw-test-state.js").withOpenClawTestState;
6+
let activateSecretsRuntimeSnapshot: typeof import("./runtime.js").activateSecretsRuntimeSnapshot;
7+
let clearSecretsRuntimeSnapshot: typeof import("./runtime.js").clearSecretsRuntimeSnapshot;
8+
let prepareSecretsRuntimeSnapshot: typeof import("./runtime.js").prepareSecretsRuntimeSnapshot;
139

1410
describe("auth profile migration isolation", () => {
15-
const roots: string[] = [];
11+
beforeEach(async () => {
12+
// This shard is non-isolated, so load the singleton-backed runtime and auth helpers
13+
// from one fresh graph after neighboring tests reset the module cache.
14+
vi.resetModules();
15+
({
16+
activateSecretsRuntimeSnapshot,
17+
clearSecretsRuntimeSnapshot,
18+
prepareSecretsRuntimeSnapshot,
19+
} = await import("./runtime.js"));
20+
({ resolveApiKeyForProvider } = await import("../agents/model-auth.js"));
21+
({ closeOpenClawAgentDatabasesForTest } = await import("../state/openclaw-agent-db.js"));
22+
({ withOpenClawTestState } = await import("../test-utils/openclaw-test-state.js"));
23+
clearSecretsRuntimeSnapshot();
24+
closeOpenClawAgentDatabasesForTest();
25+
vi.unstubAllEnvs();
26+
});
1627

17-
afterEach(async () => {
28+
afterEach(() => {
1829
clearSecretsRuntimeSnapshot();
1930
closeOpenClawAgentDatabasesForTest();
2031
vi.unstubAllEnvs();
21-
for (const root of roots.splice(0)) {
22-
await fs.rm(root, { recursive: true, force: true });
23-
}
2432
});
2533

2634
it("isolates one legacy owner and blocks env fallback without affecting a healthy agent", async () => {
27-
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-auth-migration-isolation-"));
28-
roots.push(root);
29-
const legacyAgentDir = path.join(root, "agents", "legacy", "agent");
30-
const healthyAgentDir = path.join(root, "agents", "healthy", "agent");
31-
await fs.mkdir(legacyAgentDir, { recursive: true });
32-
await fs.mkdir(healthyAgentDir, { recursive: true });
33-
await fs.writeFile(
34-
path.join(legacyAgentDir, "auth.json"),
35-
`${JSON.stringify({ openai: { type: "api_key", key: "fake-legacy-key" } })}\n`,
36-
);
37-
writePersistedAuthProfileStoreRaw(
35+
await withOpenClawTestState(
3836
{
39-
version: 1,
40-
profiles: {
41-
"openai:default": {
42-
type: "api_key",
43-
provider: "openai",
44-
key: "fake-healthy-key",
45-
},
37+
layout: "state-only",
38+
label: "auth-migration-isolation",
39+
env: {
40+
OPENAI_API_KEY: "fake-env-fallback-key",
4641
},
4742
},
48-
healthyAgentDir,
49-
);
50-
vi.stubEnv("OPENAI_API_KEY", "fake-env-fallback-key");
43+
async (state) => {
44+
const legacyAgentDir = state.agentDir("legacy");
45+
const healthyAgentDir = state.agentDir("healthy");
46+
await state.writeText(
47+
"agents/legacy/agent/auth.json",
48+
`${JSON.stringify({ openai: { type: "api_key", key: "fake-legacy-key" } })}\n`,
49+
);
50+
await state.writeAuthProfiles(
51+
{
52+
version: 1,
53+
profiles: {
54+
"openai:default": {
55+
type: "api_key",
56+
provider: "openai",
57+
key: "fake-healthy-key",
58+
},
59+
},
60+
},
61+
"healthy",
62+
);
5163

52-
const snapshot = await prepareSecretsRuntimeSnapshot({
53-
config: {},
54-
agentDirs: [legacyAgentDir, healthyAgentDir],
55-
includeConfigRefs: false,
56-
allowUnavailableSecretOwners: true,
57-
loadablePluginOrigins: new Map(),
58-
});
59-
expect(snapshot.degradedOwners).toEqual([
60-
expect.objectContaining({
61-
ownerKind: "route",
62-
reason: "auth profile migration required",
63-
paths: ["auth-profile-legacy:legacy-auth"],
64-
}),
65-
]);
66-
activateSecretsRuntimeSnapshot(snapshot);
64+
const snapshot = await prepareSecretsRuntimeSnapshot({
65+
config: {},
66+
env: state.env,
67+
agentDirs: [legacyAgentDir, healthyAgentDir],
68+
includeConfigRefs: false,
69+
allowUnavailableSecretOwners: true,
70+
loadablePluginOrigins: new Map(),
71+
});
72+
expect(snapshot.degradedOwners).toEqual([
73+
expect.objectContaining({
74+
ownerKind: "route",
75+
reason: "auth profile migration required",
76+
paths: ["auth-profile-legacy:legacy-auth"],
77+
}),
78+
]);
79+
activateSecretsRuntimeSnapshot(snapshot);
6780

68-
await expect(
69-
resolveApiKeyForProvider({ provider: "openai", agentDir: legacyAgentDir }),
70-
).rejects.toMatchObject({
71-
code: "AUTH_PROFILE_MIGRATION_REQUIRED",
72-
action: "openclaw doctor --fix",
73-
sourceKinds: ["legacy-auth"],
74-
});
75-
await expect(
76-
resolveApiKeyForProvider({
77-
provider: "openai",
78-
agentDir: healthyAgentDir,
79-
profileId: "openai:default",
80-
lockedProfile: true,
81-
store: snapshot.authStores.find((entry) => entry.agentDir === healthyAgentDir)?.store,
82-
}),
83-
).resolves.toMatchObject({ apiKey: "fake-healthy-key" });
81+
await expect(
82+
resolveApiKeyForProvider({ provider: "openai", agentDir: legacyAgentDir }),
83+
).rejects.toMatchObject({
84+
code: "AUTH_PROFILE_MIGRATION_REQUIRED",
85+
action: "openclaw doctor --fix",
86+
sourceKinds: ["legacy-auth"],
87+
});
88+
await expect(
89+
resolveApiKeyForProvider({
90+
provider: "openai",
91+
agentDir: healthyAgentDir,
92+
profileId: "openai:default",
93+
lockedProfile: true,
94+
store: snapshot.authStores.find((entry) => entry.agentDir === healthyAgentDir)?.store,
95+
}),
96+
).resolves.toMatchObject({ apiKey: "fake-healthy-key" });
97+
},
98+
);
8499
});
85100
});

‎test/scripts/full-release-validation-at-sha.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe("full-release-validation-at-sha", () => {
152152
const source = readFileSync("scripts/full-release-validation-at-sha.mjs", "utf8");
153153
expect(source).toContain("actions/runs/${parentRunId}");
154154
expect(source).toContain("workflowRun.head_sha !== workflowSha");
155+
expect(source).toContain("return suite;");
155156
expect(source).not.toContain('"graphql"');
156157
expect(source).not.toContain('["run", "watch"');
157158
});

0 commit comments

Comments
 (0)