Skip to content

Commit 188d109

Browse files
authored
feat: show marketplace feed trust state (#98350)
1 parent a957843 commit 188d109

3 files changed

Lines changed: 170 additions & 0 deletions

File tree

‎src/cli/plugins-cli.marketplace-entries.test.ts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ describe("plugins marketplace entries", () => {
115115
},
116116
savedAt: "2026-06-23T01:02:03.000Z",
117117
},
118+
trust: {
119+
mode: "signed",
120+
signedBy: "acme-root-2026",
121+
signatureCount: 1,
122+
threshold: 1,
123+
verifiedAt: "2026-06-23T01:02:03.000Z",
124+
},
118125
error: "hosted catalog feed offline mode",
119126
});
120127

@@ -129,6 +136,13 @@ describe("plugins marketplace entries", () => {
129136
expect.objectContaining({
130137
source: "hosted-snapshot",
131138
entryCount: 1,
139+
trust: {
140+
mode: "signed",
141+
signedBy: "acme-root-2026",
142+
signatureCount: 1,
143+
threshold: 1,
144+
verifiedAt: "2026-06-23T01:02:03.000Z",
145+
},
132146
entries: [
133147
expect.objectContaining({
134148
id: "acme-calendar",
@@ -213,6 +227,53 @@ describe("plugins marketplace entries", () => {
213227
expect(mocks.defaultRuntime.exit).not.toHaveBeenCalled();
214228
});
215229

230+
it("prints bounded signed feed trust state in text output", async () => {
231+
mocks.getRuntimeConfig.mockReturnValue({});
232+
mocks.loadConfiguredHostedOfficialExternalPluginCatalogEntries.mockResolvedValue({
233+
source: "hosted-snapshot",
234+
entries: [],
235+
feed: {
236+
schemaVersion: 1,
237+
id: "acme-marketplace",
238+
generatedAt: "2026-06-23T00:00:00.000Z",
239+
sequence: 7,
240+
entries: [],
241+
},
242+
metadata: {
243+
url: "https://packages.acme.example/openclaw/feed",
244+
status: 200,
245+
checksum: "feed-sha",
246+
},
247+
snapshot: {
248+
body: "{}",
249+
metadata: {
250+
url: "https://packages.acme.example/openclaw/feed",
251+
status: 200,
252+
checksum: "feed-sha",
253+
},
254+
savedAt: "2026-06-23T01:02:03.000Z",
255+
},
256+
trust: {
257+
mode: "signed",
258+
signedBy: "acme-root-2026",
259+
signatureCount: 1,
260+
threshold: 1,
261+
verifiedAt: "2026-06-23T01:02:03.000Z",
262+
},
263+
error: "hosted catalog feed offline mode",
264+
});
265+
266+
const { runPluginMarketplaceEntriesCommand } = await import("./plugins-cli.runtime.js");
267+
await runPluginMarketplaceEntriesCommand({ offline: true });
268+
269+
const output = mocks.defaultRuntime.log.mock.calls.map(([value]) => String(value)).join("\n");
270+
expect(output).toContain("Trust:");
271+
expect(output).toContain("signed by acme-root-2026 (1/1)");
272+
expect(output).toContain("2026-06-23T01:02:03.000Z");
273+
expect(output).not.toContain("publicKey");
274+
expect(output).not.toContain("signature:");
275+
});
276+
216277
it("emits bounded diagnostics for feed entry listing", async () => {
217278
const timelinePath = await createTimelinePath();
218279
vi.stubEnv("OPENCLAW_DIAGNOSTICS", "1");
@@ -247,6 +308,13 @@ describe("plugins marketplace entries", () => {
247308
},
248309
savedAt: "2026-06-23T01:02:03.000Z",
249310
},
311+
trust: {
312+
mode: "signed",
313+
signedBy: "acme-root-2026",
314+
signatureCount: 1,
315+
threshold: 1,
316+
verifiedAt: "2026-06-23T01:02:03.000Z",
317+
},
250318
error: "hosted catalog feed offline mode",
251319
});
252320

@@ -263,6 +331,10 @@ describe("plugins marketplace entries", () => {
263331
feedIdPresent: true,
264332
feedProfileProvided: true,
265333
feedSequence: 7,
334+
feedTrustMode: "signed",
335+
feedTrustSignatureCount: 1,
336+
feedTrustThreshold: 1,
337+
feedTrustVerified: true,
266338
offline: true,
267339
payloadChecksumPresent: true,
268340
snapshotUsed: true,
@@ -271,6 +343,7 @@ describe("plugins marketplace entries", () => {
271343
expect(JSON.stringify(event)).not.toContain("packages.acme.example");
272344
expect(JSON.stringify(event)).not.toContain("acme-marketplace");
273345
expect(JSON.stringify(event)).not.toContain("feed-sha");
346+
expect(JSON.stringify(event)).not.toContain("acme-root-2026");
274347
expect(JSON.stringify(event)).not.toContain("secret");
275348
expect(JSON.stringify(event)).not.toContain("token=leak");
276349
});

‎src/cli/plugins-cli.marketplace-refresh.test.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ describe("plugins marketplace refresh", () => {
8787
checksum: "feed-sha",
8888
etag: '"abc"',
8989
},
90+
trust: {
91+
mode: "signed",
92+
signedBy: "acme-root-2026",
93+
signatureCount: 1,
94+
threshold: 1,
95+
verifiedAt: "2026-06-23T00:01:02.000Z",
96+
},
9097
});
9198

9299
const { runPluginMarketplaceRefreshCommand } = await import("./plugins-cli.runtime.js");
@@ -114,7 +121,51 @@ describe("plugins marketplace refresh", () => {
114121
checksum: "feed-sha",
115122
etag: '"abc"',
116123
},
124+
trust: {
125+
mode: "signed",
126+
signedBy: "acme-root-2026",
127+
signatureCount: 1,
128+
threshold: 1,
129+
verifiedAt: "2026-06-23T00:01:02.000Z",
130+
},
131+
});
132+
});
133+
134+
it("prints bounded signed feed trust state in text output", async () => {
135+
mocks.getRuntimeConfig.mockReturnValue({});
136+
mocks.loadConfiguredHostedOfficialExternalPluginCatalogEntries.mockResolvedValue({
137+
source: "hosted",
138+
entries: [{ name: "@acme/calendar" }],
139+
feed: {
140+
schemaVersion: 1,
141+
id: "acme-marketplace",
142+
generatedAt: "2026-06-23T00:00:00.000Z",
143+
sequence: 7,
144+
entries: [],
145+
},
146+
metadata: {
147+
url: "https://packages.acme.example/openclaw/feed",
148+
status: 200,
149+
checksum: "feed-sha",
150+
},
151+
trust: {
152+
mode: "signed",
153+
signedBy: "acme-root-2026",
154+
signatureCount: 1,
155+
threshold: 1,
156+
verifiedAt: "2026-06-23T00:01:02.000Z",
157+
},
117158
});
159+
160+
const { runPluginMarketplaceRefreshCommand } = await import("./plugins-cli.runtime.js");
161+
await runPluginMarketplaceRefreshCommand({});
162+
163+
const output = mocks.defaultRuntime.log.mock.calls.map(([value]) => String(value)).join("\n");
164+
expect(output).toContain("Trust:");
165+
expect(output).toContain("signed by acme-root-2026 (1/1)");
166+
expect(output).toContain("2026-06-23T00:01:02.000Z");
167+
expect(output).not.toContain("publicKey");
168+
expect(output).not.toContain("signature:");
118169
});
119170

120171
it("normalizes bare SHA-256 pins before refreshing", async () => {
@@ -288,6 +339,13 @@ describe("plugins marketplace refresh", () => {
288339
checksum: "feed-sha",
289340
etag: '"abc"',
290341
},
342+
trust: {
343+
mode: "signed",
344+
signedBy: "acme-root-2026",
345+
signatureCount: 1,
346+
threshold: 1,
347+
verifiedAt: "2026-06-23T00:01:02.000Z",
348+
},
291349
});
292350

293351
const { runPluginMarketplaceRefreshCommand } = await import("./plugins-cli.runtime.js");
@@ -313,6 +371,10 @@ describe("plugins marketplace refresh", () => {
313371
feedIdPresent: true,
314372
feedProfileProvided: true,
315373
feedSequence: 7,
374+
feedTrustMode: "signed",
375+
feedTrustSignatureCount: 1,
376+
feedTrustThreshold: 1,
377+
feedTrustVerified: true,
316378
feedUrlOverride: true,
317379
hasEtag: true,
318380
payloadChecksumPresent: true,
@@ -321,6 +383,7 @@ describe("plugins marketplace refresh", () => {
321383
expect(JSON.stringify(event)).not.toContain("packages.acme.example");
322384
expect(JSON.stringify(event)).not.toContain("acme-marketplace");
323385
expect(JSON.stringify(event)).not.toContain("feed-sha");
386+
expect(JSON.stringify(event)).not.toContain("acme-root-2026");
324387
expect(JSON.stringify(event)).not.toContain("secret");
325388
expect(JSON.stringify(event)).not.toContain("token=leak");
326389
expect(JSON.stringify(event)).not.toContain("override-leak");

‎src/cli/plugins-cli.runtime.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,18 @@ type MarketplaceRefreshPayload = {
467467
snapshot?: {
468468
savedAt: string;
469469
};
470+
trust?: MarketplaceFeedTrustPayload;
470471
error?: string;
471472
};
472473

474+
type MarketplaceFeedTrustPayload = {
475+
mode: "signed";
476+
signedBy: string;
477+
signatureCount: number;
478+
threshold: number;
479+
verifiedAt: string;
480+
};
481+
473482
type MarketplaceEntryPayload = {
474483
id?: string;
475484
label: string;
@@ -559,6 +568,12 @@ function emitMarketplaceFeedTelemetry(params: {
559568
if (params.payload.snapshot) {
560569
attributes.snapshotUsed = true;
561570
}
571+
if (params.payload.trust) {
572+
attributes.feedTrustVerified = true;
573+
attributes.feedTrustMode = params.payload.trust.mode;
574+
attributes.feedTrustSignatureCount = params.payload.trust.signatureCount;
575+
attributes.feedTrustThreshold = params.payload.trust.threshold;
576+
}
562577
const fallbackCategory = classifyMarketplaceFeedFallback(params.payload.error);
563578
if (fallbackCategory) {
564579
attributes.fallbackCategory = fallbackCategory;
@@ -597,6 +612,15 @@ function buildMarketplaceRefreshPayload(
597612
generatedAt: result.feed.generatedAt,
598613
sequence: result.feed.sequence,
599614
};
615+
if (result.trust) {
616+
payload.trust = {
617+
mode: result.trust.mode,
618+
signedBy: result.trust.signedBy,
619+
signatureCount: result.trust.signatureCount,
620+
threshold: result.trust.threshold,
621+
verifiedAt: result.trust.verifiedAt,
622+
};
623+
}
600624
}
601625
if (result.source === "hosted-snapshot") {
602626
payload.snapshot = { savedAt: result.snapshot.savedAt };
@@ -681,6 +705,10 @@ function formatMarketplaceRefreshSource(source: MarketplaceRefreshPayload["sourc
681705
return theme.warn("bundled fallback");
682706
}
683707

708+
function formatMarketplaceFeedTrust(trust: MarketplaceFeedTrustPayload): string {
709+
return `${trust.mode} by ${trust.signedBy} (${trust.signatureCount}/${trust.threshold}) verified ${trust.verifiedAt}`;
710+
}
711+
684712
function shouldFailPinnedMarketplaceRefresh(params: {
685713
expectedSha256?: string;
686714
source: MarketplaceRefreshPayload["source"];
@@ -778,6 +806,9 @@ export async function runPluginMarketplaceEntriesCommand(
778806
if (summary.snapshot?.savedAt) {
779807
lines.push(theme.muted("Snapshot:") + " " + summary.snapshot.savedAt);
780808
}
809+
if (summary.trust) {
810+
lines.push(theme.muted("Trust:") + " " + formatMarketplaceFeedTrust(summary.trust));
811+
}
781812
if (summary.error) {
782813
lines.push(theme.muted("Fallback reason:") + " " + summary.error);
783814
}
@@ -845,6 +876,9 @@ export async function runPluginMarketplaceRefreshCommand(
845876
if (payload.snapshot?.savedAt) {
846877
lines.push(`${theme.muted("Snapshot:")} ${payload.snapshot.savedAt}`);
847878
}
879+
if (payload.trust) {
880+
lines.push(`${theme.muted("Trust:")} ${formatMarketplaceFeedTrust(payload.trust)}`);
881+
}
848882
if (payload.error) {
849883
lines.push(`${theme.muted("Fallback reason:")} ${payload.error}`);
850884
}

0 commit comments

Comments
 (0)