From 1fd4743154704cff73f70e983af8c10a25ada218 Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Sat, 5 Sep 2026 17:13:07 +0800 Subject: [PATCH] test(boot): cover the inventory's runtime attribution of rows and recorded failures --- .../plugin-inventory/tests/inventory.spec.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/host/plugin-inventory/tests/inventory.spec.ts b/packages/host/plugin-inventory/tests/inventory.spec.ts index 6211f1eb33..500ea1cd7b 100644 --- a/packages/host/plugin-inventory/tests/inventory.spec.ts +++ b/packages/host/plugin-inventory/tests/inventory.spec.ts @@ -3,6 +3,7 @@ import { Context, FiberState, type Plugin } from '@deepseek-ai/cordis' import Loader from '@deepseek-ai/cordis-plugin-loader' import { remoteMethods } from '@deepseek-ai/dsh-typert-protocol' import type { AgentPresets } from '@deepseek-ai/dsh-agent-presets' +import { ensurePluginFailures, type ProfileRuntime, type RowOrigin } from '@deepseek-ai/dsh-app-boot' import PluginInventoryGateway from '../src/index.ts' const contexts: Context[] = [] @@ -96,6 +97,40 @@ describe('PluginInventoryGateway', () => { expect((await inventory.list()).entries.some(entry => entry.entryId === pendingId)).toBe(false) }) + it('attributes rows to their bundle through the profile runtime and lists recorded failures', async () => { + const { ctx, inventory } = await harness() + // A bare Loader assigns ids; without a root include they are also the tree-wide ids. + const versioned = await ctx.loader.create({ name: 'cordis:active' }) + const bare = await ctx.loader.create({ name: 'cordis:active' }) + const off = await ctx.loader.create({ name: 'cordis:active', disabled: true }) + const origins = new Map([ + [versioned, { trust: 'external', packageName: 'ext', version: '1.2.3' }], + [bare, { trust: 'external', packageName: 'ext' }], + [off, { trust: 'external', packageName: 'ext' }], + ['gone', { trust: 'external', packageName: 'ext' }], + ]) + ctx.provide('profileRuntime', { + originOf: (rowId: string) => origins.get(rowId), + userDisabledRowIds: () => new Set([off]), + } as Partial as never) + const registry = ensurePluginFailures(ctx) + registry.record({ entryId: 'gone', rowId: 'gone', moduleName: 'cordis:throws', groupId: 'bundle/ext', stage: 'apply', message: 'boom' }) + // A record of a row that later mounted rides on the live entry and is not listed twice. + registry.record({ entryId: bare, rowId: bare, moduleName: 'cordis:active', groupId: 'bundle/ext', stage: 'import', message: 'stale' }) + // A failure the runtime cannot attribute belongs to no package. + registry.record({ entryId: 'orphan', rowId: 'orphan', moduleName: 'cordis:throws', groupId: 'bundle/gone', stage: 'apply', message: 'lost' }) + + const { entries } = await inventory.list() + expect(entries).toEqual([ + { entryId: versioned, moduleName: 'cordis:active', enabled: true, fiberPhase: 'active', trust: 'external', package: { name: 'ext', version: '1.2.3' } }, + { entryId: bare, moduleName: 'cordis:active', enabled: true, fiberPhase: 'active', trust: 'external', package: { name: 'ext' }, failure: { stage: 'import', message: 'stale' } }, + { entryId: off, moduleName: 'cordis:active', enabled: false, fiberPhase: null, trust: 'external', package: { name: 'ext' }, disabledBy: 'user' }, + // A failed row the tree no longer holds is attributed through the runtime. + { entryId: 'gone', moduleName: 'cordis:throws', enabled: true, fiberPhase: 'failed', trust: 'external', package: { name: 'ext' }, failure: { stage: 'apply', message: 'boom' } }, + { entryId: 'orphan', moduleName: 'cordis:throws', enabled: true, fiberPhase: 'failed', trust: 'external', failure: { stage: 'apply', message: 'lost' } }, + ]) + }) + it('carries each composed preset with root-fiber states mapped to phases', async () => { const { ctx, inventory } = await harness() ctx.provide('agentPresets', {