Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ jobs:
CLAWHUB_CI_TEST_OBSERVATIONS: "1"
run: bun run ci:unit

- name: Offline dependency compatibility
run: bun run test:dependency-compat

- name: Upload test observations
if: ${{ always() }}
continue-on-error: true
Expand Down
76 changes: 38 additions & 38 deletions bun.lock

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"skills-sh:prove-trending": "bun scripts/skills-sh-catalog/prove-trending-test.ts",
"skills:install": "npx --yes skills@1.5.16 add openclaw/carapace --skill openclaw-design openclaw-brand openclaw-carapace openclaw-design-system openclaw-marketing-pages openclaw-design-audit --agent codex --copy --yes",
"test": "vitest run",
"test:dependency-compat": "bun install --cwd scripts/fixtures/dependency-baseline --frozen-lockfile && vitest run --config vitest.dependency.config.ts",
"test:e2e": "vitest run -c vitest.e2e.config.ts",
"test:e2e:local": "bash scripts/run-playwright-local.sh",
"test:e2e:prod-http": "vitest run -c vitest.e2e.config.ts e2e/prod-http-smoke.e2e.test.ts",
Expand All @@ -98,7 +99,7 @@
"@convex-dev/auth": "0.0.98",
"@convex-dev/migrations": "0.3.8",
"@convex-dev/rate-limiter": "0.4.3",
"@convex-dev/workpool": "0.4.15",
"@convex-dev/workpool": "0.4.16",
"@fontsource/bricolage-grotesque": "5.3.0",
"@fontsource/ibm-plex-mono": "5.3.0",
"@fontsource/noto-sans-sc": "5.3.1",
Expand All @@ -122,19 +123,19 @@
"@shikijs/rehype": "4.6.0",
"@tanstack/react-router": "1.170.46",
"@tanstack/react-start": "1.169.5",
"@vercel/oidc": "4.0.8",
"@vercel/oidc": "4.0.9",
"arktype": "2.2.9",
"class-variance-authority": "0.7.1",
"clawhub-schema": "workspace:0.0.2",
"clsx": "2.1.1",
"convex": "1.49.0",
"convex": "1.50.0",
"convex-helpers": "0.1.135",
"fflate": "0.8.3",
"franc-min": "6.2.0",
"h3": "2.0.8",
"ignore": "7.0.14",
"ignore": "7.0.16",
"jose": "6.2.17",
"lucide-react": "1.72.0",
"lucide-react": "1.74.0",
"mermaid": "^11.17.2",
"mime": "4.1.2",
"monaco-editor": "0.57.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/clawhub-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"arktype": "2.2.9",
"commander": "15.1.0",
"fflate": "0.8.3",
"ignore": "7.0.14",
"ignore": "7.0.16",
"json5": "2.2.3",
"mime": "4.1.2",
"ora": "10.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/clawhub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"@openclaw/plugin-inspector": "0.4.6",
"arktype": "2.2.9",
"commander": "15.1.0",
"croner": "11.0.0",
"croner": "11.0.1",
"fflate": "0.8.3",
"ignore": "7.0.14",
"ignore": "7.0.16",
"json5": "2.2.3",
"mime": "4.1.2",
"ora": "10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
},
"dependencies": {
"arktype": "2.2.9",
"croner": "11.0.0",
"croner": "11.0.1",
"json5": "2.2.3",
"unicode-case-folding": "1.1.2",
"yaml": "2.9.1"
Expand Down
86 changes: 86 additions & 0 deletions scripts/dependency-account-compat.proof.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* @vitest-environment node */
import { spawnSync } from "node:child_process";
import { randomBytes } from "node:crypto";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { resolve, join } from "node:path";
import { expect, it } from "vitest";

function runFixture(runtime: string, file: string, args: string[] = []) {
const home = mkdtempSync(join(tmpdir(), "dependency-compat-"));
const nonce = randomBytes(32).toString("hex");
writeFileSync(join(home, ".clawhub-dependency-fixture"), nonce, { mode: 0o600 });
try {
const result = spawnSync(runtime, [resolve("scripts/fixtures", file), ...args], {
cwd: home,
env: {
CLAWHUB_DEPENDENCY_FIXTURE_HOME: home,
CLAWHUB_DEPENDENCY_FIXTURE_NONCE: nonce,
HOME: home,
USERPROFILE: home,
PATH: process.env.PATH,
TMPDIR: tmpdir(),
NO_COLOR: "1",
},
encoding: "utf8",
timeout: 10_000,
});
expect(result.status, result.stderr || String(result.error ?? result.stdout)).toBe(0);
return JSON.parse(result.stdout.trim().split("\n").at(-1) ?? "null");
} finally {
rmSync(home, { force: true, recursive: true });
}
}

it("preserves legacy Convex credentials through account selection and permission changes", () => {
expect(runFixture(process.execPath, "convex-account-compat.mjs")).toEqual({
legacyReadable: true,
selection: true,
preserved: true,
permissions: true,
});
});

it.each(["xdg", "legacy", "precedence"])(
"preserves OIDC behavior with %s configuration",
(layout) => {
for (const packageName of ["baseline", "candidate"]) {
expect(
runFixture(process.execPath, "vercel-oidc-compat.mjs", [packageName, layout]),
).toMatchObject({
layout,
fresh: true,
request: true,
file: true,
refresh: true,
});
}
},
);

it.each([
["convex-account-compat.mjs", ".convex/config.json", []],
["vercel-oidc-compat.mjs", ".now/auth.json", ["candidate", "legacy"]],
] as const)(
"refuses an unowned direct invocation of %s before changing credentials",
(file, credential, args) => {
const home = mkdtempSync(join(tmpdir(), "dependency-compat-"));
const path = join(home, credential);
const original = '{"token":"fixture-preexisting-credential"}';
try {
mkdirSync(resolve(path, ".."), { recursive: true });
writeFileSync(path, original);
const result = spawnSync(process.execPath, [resolve("scripts/fixtures", file), ...args], {
cwd: home,
env: { HOME: home, USERPROFILE: home, PATH: process.env.PATH, NO_COLOR: "1" },
encoding: "utf8",
timeout: 10_000,
});
expect(result.status).not.toBe(0);
expect(result.stderr).toContain("Run through the dependency fixture runner.");
expect(readFileSync(path, "utf8")).toBe(original);
} finally {
rmSync(home, { force: true, recursive: true });
}
},
);
91 changes: 91 additions & 0 deletions scripts/fixtures/component-upgrade/app.ts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Workpool } from "@convex-dev/workpool";
import { makeFunctionReference } from "convex/server";
import { ConvexError, v } from "convex/values";
import { components } from "./_generated/api";
import { internalAction, internalMutation, internalQuery } from "./functions";

function localOnly() {
if (!/^http:\/\/127\.0\.0\.1:\d+$/.test(process.env.CONVEX_SITE_URL ?? ""))
throw new Error("Dependency fixtures require the owned local backend.");
}
const ref = (name: string) => makeFunctionReference(name);

export const seed = internalMutation({
args: {},
handler: async (ctx) => {
localOnly();
const userId = await ctx.db.insert("users", { role: "admin", handle: "dependency-fixture" });
await ctx.db.insert("dependencyUpgradeGate", { started: false, released: false });
return { userId };
},
});

export const gate = internalMutation({
args: { started: v.optional(v.boolean()), released: v.optional(v.boolean()) },
handler: async (ctx, args) => {
localOnly();
const row = await ctx.db.query("dependencyUpgradeGate").unique();
if (!row) throw new Error("Missing fixture gate.");
await ctx.db.patch(row._id, args);
},
});

export const observeGate = internalQuery({
args: {},
handler: async (ctx) => {
localOnly();
return await ctx.db.query("dependencyUpgradeGate").unique();
},
});

export const failAfterGate = internalAction({
args: {},
handler: async (ctx) => {
localOnly();
await ctx.runMutation(ref("dependencyUpgradeFixtures:gate"), { started: true });
const deadline = Date.now() + 180_000;
while (Date.now() < deadline) {
const state = await ctx.runQuery(ref("dependencyUpgradeFixtures:observeGate"), {});
if (state?.released) throw new ConvexError({ fixture: "retained-completion" });
await new Promise((resolve) => setTimeout(resolve, 50));
}
throw new Error("Fixture gate was not released before the deadline.");
},
});

export const startFailure = internalMutation({
args: {},
handler: async (ctx) => {
localOnly();
const pool = new Workpool(components.searchReports, { maxParallelism: 1 });
return await pool.enqueueAction(ctx, ref("dependencyUpgradeFixtures:failAfterGate"), {}, { retry: false });
},
});

export const enqueueReportAndPause = internalMutation({
args: {},
handler: async (ctx) => {
localOnly();
const report = await ctx.runMutation(ref("searchReports:start"), {
view: "recommendations", artifactKind: "plugin",
});
await ctx.runMutation(components.searchReports.config.update, { maxParallelism: 0 });
return report;
},
});

export const parallelism = internalMutation({
args: { value: v.union(v.literal(0), v.literal(1)) },
handler: async (ctx, { value }) => {
localOnly();
await ctx.runMutation(components.searchReports.config.update, { maxParallelism: value });
},
});

export const reportRow = internalQuery({
args: { reportId: v.id("searchReportRuns") },
handler: async (ctx, { reportId }) => {
localOnly();
return await ctx.db.get(reportId);
},
});
10 changes: 10 additions & 0 deletions scripts/fixtures/component-upgrade/schema.ts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";
import original from "./_dependencyUpgradeOriginalSchema";

export * from "./_dependencyUpgradeOriginalSchema";

export default defineSchema({
...original.tables,
dependencyUpgradeGate: defineTable({ started: v.boolean(), released: v.boolean() }),
});
111 changes: 111 additions & 0 deletions scripts/fixtures/convex-account-compat.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import assert from "node:assert/strict";
import { createHash } from "node:crypto";
import { chmodSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
import Module, { createRequire } from "node:module";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import { assertFixtureHome, rejectExternalIo } from "./dependency-network-guard.mjs";

assertFixtureHome();

const verifyIo = rejectExternalIo();
function helpers(baseline) {
const require = createRequire(
baseline ? new URL("./dependency-baseline/package.json", import.meta.url) : import.meta.url,
);
const root = dirname(require.resolve("convex/package.json"));
assert.equal(
JSON.parse(readFileSync(join(root, "package.json"))).version,
baseline ? "1.49.0" : "1.50.0",
);
const filename = join(root, "dist/cli.bundle.cjs");
const code = readFileSync(filename, "utf8");
const expectedHash = baseline
? "de7c7ded59ba4258c76cc308fc28e429f23fd3a31df419364183fe444d824621"
: "b27df8835a27baafc85611e1d11a655fb79f6ad860674a71a7679cb8a6035d43";
assert.equal(
createHash("sha256").update(code).digest("hex"),
expectedHash,
"Published CLI bundle changed; inspect the new entrypoint before qualifying it.",
);
const entry = "\nvoid main();";
assert.equal(code.split(entry).length, 2, "Pinned CLI entrypoint changed.");
const exports = baseline
? "readGlobalConfig, nodeFs"
: "readGlobalConfig, nodeFs, readAccountSettings, getAccountSelection, legacyAuthForFirstAccount, writeAccountCredentials, initializeDefaultAccount, writeAccountDirectory, readAccountAuth, loadAccountCredentials";
// Expose the published helper bodies without invoking the CLI, login or telemetry.
const loaded = new Module(filename);
loaded.filename = filename;
loaded.paths = Module._nodeModulePaths(root);
loaded._compile(code.replace(entry, `\nmodule.exports = { ${exports} };`), filename);
return loaded.exports;
}
const previous = helpers(true);
const current = helpers(false);
const cleanups = new Map();
const ctx = {
fs: current.nodeFs,
crash: async ({ printedMessage }) => {
throw new Error(printedMessage);
},
registerCleanup: (fn) => {
const id = String(cleanups.size);
cleanups.set(id, fn);
return id;
},
removeCleanup: (id) => cleanups.delete(id),
};
const configPath = join(homedir(), ".convex/config.json");
mkdirSync(dirname(configPath), { recursive: true });
const legacy = { accessToken: "fixture-legacy-token", preservedSetting: "keep" };
writeFileSync(configPath, JSON.stringify(legacy));
chmodSync(configPath, 0o644);
assert.deepEqual(previous.readGlobalConfig(ctx), { accessToken: legacy.accessToken });
assert.deepEqual(current.readGlobalConfig(ctx), { accessToken: legacy.accessToken });
if (process.platform !== "win32") assert.equal(statSync(configPath).mode & 0o777, 0o600);
assert.deepEqual(await current.readAccountSettings(ctx), legacy);
assert.equal(await current.getAccountSelection(ctx), null);
assert.equal(
(await current.legacyAuthForFirstAccount(ctx, { name: "work", source: "fixture" })).accessToken,
legacy.accessToken,
);
await current.writeAccountCredentials(ctx, "work", legacy.accessToken);
await current.initializeDefaultAccount(ctx, { name: "work", source: "fixture" }, true);
assert.equal((await current.getAccountSelection(ctx)).name, "work");
await current.writeAccountCredentials(ctx, "personal", "fixture-personal-token");
await current.writeAccountDirectory(ctx, "personal");
assert.equal((await current.getAccountSelection(ctx)).name, "personal");
mkdirSync("child");
const parent = process.cwd();
process.chdir("child");
assert.equal((await current.getAccountSelection(ctx)).name, "personal");
process.chdir(parent);
assert.equal(previous.readGlobalConfig(ctx).accessToken, legacy.accessToken);
assert.equal(JSON.parse(readFileSync(configPath, "utf8")).preservedSetting, "keep");
process.env.CONVEX_ACCOUNT = "work";
assert.equal((await current.getAccountSelection(ctx)).name, "work");
assert.equal((await current.getAccountSelection(ctx, { name: "personal" })).name, "personal");
delete process.env.CONVEX_ACCOUNT;
writeFileSync(".env.local", "CONVEX_ACCOUNT=work\n");
assert.equal((await current.getAccountSelection(ctx)).name, "work");
writeFileSync("custom.env", "CONVEX_ACCOUNT=personal\n");
assert.equal((await current.getAccountSelection(ctx, { envFile: "custom.env" })).name, "personal");
writeFileSync(".env.local", "CONVEX_ACCOUNT=\n");
assert.equal((await current.getAccountSelection(ctx)).name, "personal");
assert.equal(
(await current.readAccountAuth(ctx, { name: "work", source: "fixture" })).accessToken,
legacy.accessToken,
);
if (process.platform !== "win32") {
const directory = join(homedir(), ".convex/accounts");
chmodSync(directory, 0o755);
chmodSync(join(directory, "work.json"), 0o644);
current.loadAccountCredentials(ctx, "work");
assert.equal(statSync(directory).mode & 0o777, 0o700);
assert.equal(statSync(join(directory, "work.json")).mode & 0o777, 0o600);
}
assert.equal(cleanups.size, 0);
verifyIo();
console.log(
JSON.stringify({ legacyReadable: true, selection: true, preserved: true, permissions: true }),
);
Loading
Loading