Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- Skill reads: a missing stored skill file is a client error for the readme, skill card, file text, and publish preview text. The message stays "File missing in storage".

- Plugin Inspector: stop storing the `package-json-missing` and `package-openclaw-entry-missing` findings for bundle plugins. A configuration-only Codex, Claude or Cursor bundle has no native package metadata, so a scan no longer shows it a warning that cannot apply (#4754). Nightly findings already stored for a release clear when that release is next scanned; a finding stored at publish time stays.

- Catalog: keep package search versions aligned with the current release when editing metadata on packages with stale version summaries. Package mutations now rely on the shared trigger to refresh search projections.

- Skill publish: a bad upload ticket is a client error. The messages stay "Skill upload ticket is missing, used, or expired", "Uploaded file does not match its skill upload ticket", and "Skill upload ticket does not match this publish".
Expand Down
20 changes: 20 additions & 0 deletions convex/lib/packageInspectorFinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,23 @@ export type PackageInspectorFinding = Infer<typeof packageInspectorIssueInputVal
export type PackageInspectorAuthorRemediation = NonNullable<
PackageInspectorFinding["authorRemediation"]
>;

// Plugin Inspector checks every upload as a native code plugin. These two
// checks ask for npm package metadata, which a configuration-only bundle
// (Codex, Claude or Cursor marker plus MCP config and skills) does not ship.
const NATIVE_ONLY_PACKAGE_FINDING_CODES = new Set([
"package-json-missing",
"package-openclaw-entry-missing",
]);

/**
* Drops findings that only apply to native code plugins when the package is a
* bundle plugin. Code plugins and every other finding code pass through.
*/
export function filterPackageInspectorFindingsForFamily<T extends { code: string }>(
family: string,
findings: T[],
): T[] {
if (family !== "bundle-plugin") return findings;
return findings.filter((finding) => !NATIVE_ONLY_PACKAGE_FINDING_CODES.has(finding.code));
}
115 changes: 115 additions & 0 deletions convex/packageInspectorFamilyFindings.runtime.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/// <reference types="vite/client" />
/* @vitest-environment edge-runtime */

import { register as registerRateLimiter } from "@convex-dev/rate-limiter/test";
import { convexTest } from "convex-test";
import { afterEach, describe, expect, it, vi } from "vitest";
import { createPackageSeedDefaults } from "../src/__tests__/helpers/packageSeed";
import schema from "./schema";

const modules = import.meta.glob("./**/*.ts");
vi.mock("./lib/verifiedClientIp", () => ({ getVerifiedClientIp: async () => "203.0.113.1" }));

const nativeFindings = [
{
id: "demo:package-json-missing",
code: "package-json-missing",
level: "warning",
message: "fixture has no package.json to describe install and plugin entrypoint metadata",
authorRemediation: { summary: "Add a package.json to the plugin package." },
},
{
id: "demo:package-openclaw-entry-missing",
code: "package-openclaw-entry-missing",
level: "warning",
message: "package openclaw metadata does not declare plugin entrypoints",
authorRemediation: { summary: "Declare OpenClaw package entrypoints." },
},
];

// Posts a worker result to the shipped results route and reads back what was stored.
async function scanThroughResultsRoute(
family: "bundle-plugin" | "code-plugin",
findings: unknown[],
) {
vi.stubEnv("CLAWHUB_PLUGIN_INSPECTOR_WORKER_TOKEN", "family-findings-test-worker");
const t = convexTest(schema, modules);
registerRateLimiter(t, "rateLimiterV2");
const ids = await t.run(async (ctx) => {
const ownerUserId = await ctx.db.insert("users", { handle: "demo-owner", role: "user" });
const packageId = await ctx.db.insert("packages", {
...createPackageSeedDefaults(),
name: "demo-plugin",
normalizedName: "demo-plugin",
displayName: "Demo plugin",
family,
ownerUserId,
scanStatus: "clean",
stats: { downloads: 0, installs: 0, stars: 0, versions: 1 },
});
const releaseId = await ctx.db.insert("packageReleases", {
packageId,
version: "1.0.0",
changelog: "",
distTags: [],
files: [],
integritySha256: "a".repeat(64),
createdAt: 1,
createdBy: ownerUserId,
publicationStatus: "published",
verification: { tier: "source-linked", scope: "artifact-only", scanStatus: "clean" },
});
await ctx.db.patch(packageId, { latestReleaseId: releaseId, tags: { latest: releaseId } });
return { packageId, releaseId };
});
const response = await t.fetch("/api/v1/package-inspector/results", {
method: "POST",
headers: {
authorization: "Bearer family-findings-test-worker",
"content-type": "application/json",
},
body: JSON.stringify({
...ids,
inspectorVersion: "0.4.6",
targetOpenClawVersion: "2026.10.14",
notifyOwners: false,
findings,
}),
});
const stored = await t.run(async (ctx) => ({
warnings: (
await ctx.db
.query("packageInspectorWarnings")
.withIndex("by_release", (q) => q.eq("releaseId", ids.releaseId))
.collect()
)
.map((warning) => warning.code)
.sort(),
outcomes: (await ctx.db.query("packageInspectorScanStates").collect()).map(
(state) => state.outcome,
),
}));
return { status: response.status, ...stored };
}

describe("package inspector results route and package family", () => {
afterEach(() => {
vi.unstubAllEnvs();
});

it("stores a configuration-only bundle scan as clean when only native findings fired", async () => {
await expect(scanThroughResultsRoute("bundle-plugin", nativeFindings)).resolves.toEqual({
status: 200,
warnings: [],
outcomes: ["clean"],
});
});

it("keeps the native findings for a code plugin", async () => {
await expect(scanThroughResultsRoute("code-plugin", nativeFindings)).resolves.toEqual({
status: 200,
warnings: ["package-json-missing", "package-openclaw-entry-missing"],
outcomes: ["findings"],
});
});
});
134 changes: 134 additions & 0 deletions convex/packages.public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14404,6 +14404,140 @@ describe("packages public queries", () => {
});
});

describe("native-only package findings", () => {
const nativeOnlyFindings = [
{
id: "totem:package-json-missing",
code: "package-json-missing",
level: "warning",
message: "fixture has no package.json to describe install and plugin entrypoint metadata",
authorRemediation: { summary: "Add a package.json to the plugin package." },
},
{
id: "totem:package-openclaw-entry-missing",
code: "package-openclaw-entry-missing",
level: "warning",
message: "package openclaw metadata does not declare plugin entrypoints",
authorRemediation: { summary: "Declare OpenClaw package entrypoints." },
},
{
id: "totem:deprecated-api",
code: "deprecated-api",
level: "warning",
message: "The API is deprecated but still available.",
authorRemediation: { summary: "Migrate before a future release." },
},
];

async function ingestFindingsFor(family: "bundle-plugin" | "code-plugin") {
const insert = vi.fn().mockResolvedValue("packageInspectorScanStates:demo");
const ctx = {
db: {
get: vi.fn(async (id: string) => {
if (id === "packages:demo") {
return {
_id: "packages:demo",
name: "demo-plugin",
family,
ownerUserId: "users:owner",
};
}
if (id === "packageReleases:demo-1") {
return {
_id: "packageReleases:demo-1",
packageId: "packages:demo",
version: "1.0.0",
};
}
return null;
}),
query: vi.fn(() => ({
withIndex: vi.fn(() => ({
collect: vi.fn().mockResolvedValue([]),
unique: vi.fn().mockResolvedValue(null),
})),
})),
insert,
patch: vi.fn(),
replace: vi.fn(),
delete: vi.fn(),
normalizeId: vi.fn((tableName: string, id: string) =>
id.startsWith(`${tableName}:`) ? id : null,
),
},
};
await ingestPackageInspectorScanResultsInternalHandler(ctx as never, {
packageId: "packages:demo",
releaseId: "packageReleases:demo-1",
inspectorVersion: "0.4.6",
targetOpenClawVersion: "2026.8.0",
findings: nativeOnlyFindings,
});
return insert.mock.calls
.filter(([table]) => table === "packageInspectorWarnings")
.map(([, doc]) => (doc as { code: string }).code);
}

it("does not store native package findings for a bundle plugin", async () => {
await expect(ingestFindingsFor("bundle-plugin")).resolves.toEqual(["deprecated-api"]);
});

it("records a configuration-only bundle scan as clean when only native findings fired", async () => {
const insert = vi.fn().mockResolvedValue("packageInspectorScanStates:demo");
const ctx = {
db: {
get: vi.fn(async (id: string) =>
id === "packages:demo"
? {
_id: "packages:demo",
name: "totem",
family: "bundle-plugin",
ownerUserId: "users:o",
}
: { _id: "packageReleases:demo-1", packageId: "packages:demo", version: "0.3.2" },
),
query: vi.fn(() => ({
withIndex: vi.fn(() => ({
collect: vi.fn().mockResolvedValue([]),
unique: vi.fn().mockResolvedValue(null),
})),
})),
insert,
patch: vi.fn(),
replace: vi.fn(),
delete: vi.fn(),
normalizeId: vi.fn((tableName: string, id: string) =>
id.startsWith(`${tableName}:`) ? id : null,
),
},
};

await expect(
ingestPackageInspectorScanResultsInternalHandler(ctx as never, {
packageId: "packages:demo",
releaseId: "packageReleases:demo-1",
inspectorVersion: "0.4.6",
targetOpenClawVersion: "2026.8.0",
findings: nativeOnlyFindings.slice(0, 2),
}),
).resolves.toEqual({ ok: true, inserted: 0, shouldEmailOwner: false });

expect(insert).not.toHaveBeenCalledWith("packageInspectorWarnings", expect.anything());
expect(insert).toHaveBeenCalledWith(
"packageInspectorScanStates",
expect.objectContaining({ outcome: "clean" }),
);
});

it("keeps native package findings for a code plugin", async () => {
await expect(ingestFindingsFor("code-plugin")).resolves.toEqual([
"package-json-missing",
"package-openclaw-entry-missing",
"deprecated-api",
]);
});
});

it("stores nightly errors and does not reuse an earlier target's email dedupe", async () => {
const insert = vi.fn();
const ctx = {
Expand Down
9 changes: 7 additions & 2 deletions convex/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ import {
import { verifyPublishFileStorageMetadata } from "./lib/packageFileVerification";
import { resolvePackageIcon } from "./lib/packageIcons";
import {
filterPackageInspectorFindingsForFamily,
packageInspectorIssueInputValidator,
type PackageInspectorFinding,
type PackageInspectorAuthorRemediation,
Expand Down Expand Up @@ -10591,6 +10592,10 @@ export const ingestPackageInspectorScanResultsInternal = internalMutation({
) {
throw new ConvexError("Package release not found");
}
// Inspector runs native-plugin package checks on every upload. Bundle
// plugins have no package.json by design, so drop those findings here,
// before they are stored or decide the scan outcome.
const findings = filterPackageInspectorFindingsForFamily(pkg.family, args.findings);
const result = args.inspectionFailed
? { ok: true as const, inserted: 0, shouldEmailOwner: false }
: await insertPackageInspectorFindings(ctx, {
Expand All @@ -10604,15 +10609,15 @@ export const ingestPackageInspectorScanResultsInternal = internalMutation({
inspectorVersion: args.inspectorVersion,
targetOpenClawVersion: args.targetOpenClawVersion,
notifyOwners: args.notifyOwners,
findings: args.findings,
findings,
});
const { inspectorVersion, targetOpenClawVersion } = args;
if (inspectorVersion && targetOpenClawVersion) {
const outcome: PackageInspectorOutcome = args.inspectionFailed
? args.failure?.reason === "timeout"
? "timeout"
: "tool_failure"
: args.findings.length > 0
: findings.length > 0
? "findings"
: "clean";
const sdkUsage = await recordPackageInspectorScan(ctx, {
Expand Down
46 changes: 46 additions & 0 deletions scripts/package-inspector-nightly-scan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { access, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promise
import { tmpdir } from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { filterPackageInspectorFindingsForFamily } from "../convex/lib/packageInspectorFinding";
import {
acknowledgeBatch,
downloadPackageArtifactForScan,
Expand Down Expand Up @@ -552,6 +553,51 @@ describe("package-inspector-nightly-scan", () => {
).toBe("manual-run");
});

it("keeps native package findings off a configuration-only bundle that the real Inspector flags", async () => {
const bundleRoot = await mkdtemp(path.join(tmpdir(), "clawhub-inspector-bundle-"));
temporaryRoots.push(bundleRoot);
await mkdir(path.join(bundleRoot, ".codex-plugin"), { recursive: true });
await mkdir(path.join(bundleRoot, "skills", "demo"), { recursive: true });
await writeFile(
path.join(bundleRoot, ".codex-plugin", "plugin.json"),
'{"name":"totem","version":"0.3.2","skills":"./skills"}\n',
);
await writeFile(path.join(bundleRoot, ".mcp.json"), '{"mcpServers":{}}\n');
await writeFile(
path.join(bundleRoot, "skills", "demo", "SKILL.md"),
"---\nname: demo\ndescription: demo\n---\nDemo skill.\n",
);
const scanRoot = await prepareExtractedPluginRoot(bundleRoot, "legacy-zip", "totem");
const inspector = (await import("@openclaw/plugin-inspector")) as unknown as {
pluginRoot: {
runCheck: (
options: Record<string, unknown>,
) => Promise<{ report: Record<string, unknown> }>;
};
};

const { report } = await inspector.pluginRoot.runCheck({
allowExecution: false,
authorFacing: true,
capture: false,
configPath: path.join(scanRoot, ".plugin-inspector.json"),
mockSdk: true,
outDir: path.join(bundleRoot, "report"),
pluginRoot: scanRoot,
});
const findings = normalizeFindings(report);

// The pinned Inspector treats every upload as a native plugin. Drop the
// filter once Inspector accepts the package family itself.
expect(findings.map((finding) => finding.code)).toContain("package-json-missing");
expect(
filterPackageInspectorFindingsForFamily("bundle-plugin", findings).map(
(finding) => finding.code,
),
).not.toContain("package-json-missing");
expect(filterPackageInspectorFindingsForFamily("code-plugin", findings)).toEqual(findings);
}, 60_000);

it("acknowledges a processed batch before the runner advances its cursor", async () => {
const fetchMock = vi.fn().mockResolvedValue(
new Response(JSON.stringify({ ok: true, cursor: "page-2", completed: false }), {
Expand Down
Loading