From cb4407427f0e23180ccaeed179a125978ff47a5e Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 5 Oct 2026 17:43:38 +0800 Subject: [PATCH 1/2] test(llm): pin Loader IDs in inventory order fixtures The parameterized versioned/name-only inventory test reversed plugin arrival order but left Loader entry IDs random. EntryTree generates hexadecimal IDs and enumerates its object-backed store with Object.values(). Numeric-only IDs become JavaScript integer property keys and enumerate before other keys, so the fixture's declared arrival order did not determine the comparator's operand order. Both parameter cases could exercise the same orientation while retaining the correct sorted output, intermittently leaving the right version's nullish fallback uncovered by the per-file 100% CI gate. Use the typed root-group update API with fixed non-integer inventory-* IDs for this fixture. Both requested arrival orders now reach the inventory collector without integer-key reordering. Keep real Loader imports and activation, duplicate entries, and the existing output assertions. Explain the non-obvious identifier requirement locally in the test. Production sorting, package identity rules, and request fields are unchanged. A controlled negative uses numeric IDs for versioned entries: all 46 tests pass, but package source branch coverage is 73/74 (98.64%), with index.ts:186 uncovered exactly as in the observed node 24 coverage failure. The final non-integer IDs pass the same owning file with 74/74 branches (100%). No global Math.random interception, retry, timeout, or coverage exception is introduced. Validation: - pnpm install --frozen-lockfile --ignore-scripts installed the existing lockfile. - pnpm exec vitest run packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts --coverage --coverage.include='packages/llm/plugin-package-inventory-deepseek/src/**/*.ts' --coverage.reporter=text --coverage.reportsDirectory=/tmp/dsh-merge-5719/inventory-negative reproduced the controlled coverage failure with 46 passing tests. - The same command with reportsDirectory=/tmp/dsh-merge-5719/inventory-fixed passed 46 tests and 100% statements (80/80), branches (74/74), functions (15/15), and lines (68/68) for the package's executable source. - pnpm --silent run change-scope --base 70996a53b84212db9efafe21a4db3dddd46b47ec confirms the sole changed path is the owning inventory.spec.ts. - git diff --check passed. --- .../tests/inventory.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts b/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts index 6c3bb1f6db..0d3b0d6669 100644 --- a/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts +++ b/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts @@ -103,7 +103,12 @@ describe('DeepSeek plugin package inventory', () => { const versioned = await packagePlugin(root, 'versioned', { name: 'same', version: 'undefined' }) const unversioned = await packagePlugin(root, 'unversioned', { name: 'same' }) const entries = reversed ? [unversioned, versioned] : [versioned, unversioned] - for (const name of [...entries, ...entries]) await ctx.loader.create({ name }) + // Numeric generated IDs precede other keys in Loader's object-backed store. + // Named IDs preserve both requested arrival orders before inventory sorting. + await ctx.loader.root.update([...entries, ...entries].map((name, index) => ({ + id: `inventory-${String(index)}`, + name, + }))) const prepared = await ctx.deepseekLlmApiExtensions.prepare({ body: { messages: [] }, signal: SIGNAL }) expect(prepared.fields.dsh_plugin_packages?.packages).toStrictEqual([ { name: 'same' }, From 310a9e4de4deac7c98096795611314cd4b0b1a30 Mon Sep 17 00:00:00 2001 From: Tianyi Cui <53024+tianyicui@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:10:26 +0800 Subject: [PATCH 2/2] docs(test): clarify Loader integer-key enumeration JavaScript object enumeration moves canonical array-index property keys ahead of other string keys. Describing every numeric-looking Loader ID as reordered is too broad: leading-zero and other noncanonical numeric strings remain ordinary string properties. Name the exact key category in the inventory fixture's local comment. The inventory-* IDs exclude every canonical array-index key, and the real Loader activation, fixture order, output assertions, and production code are unchanged. This addresses the automatic review's nonblocking terminology clarification. Validation: - Type-aware Oxlint passed for the owning inventory.spec.ts. - git diff --check passed. - No behavior or test inputs changed, so the already observed 46-test and 74/74-branch evidence remains applicable. --- .../plugin-package-inventory-deepseek/tests/inventory.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts b/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts index 0d3b0d6669..8ffd85d6d6 100644 --- a/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts +++ b/packages/llm/plugin-package-inventory-deepseek/tests/inventory.spec.ts @@ -103,7 +103,7 @@ describe('DeepSeek plugin package inventory', () => { const versioned = await packagePlugin(root, 'versioned', { name: 'same', version: 'undefined' }) const unversioned = await packagePlugin(root, 'unversioned', { name: 'same' }) const entries = reversed ? [unversioned, versioned] : [versioned, unversioned] - // Numeric generated IDs precede other keys in Loader's object-backed store. + // Canonical array-index IDs precede other keys in Loader's object-backed store. // Named IDs preserve both requested arrival orders before inventory sorting. await ctx.loader.root.update([...entries, ...entries].map((name, index) => ({ id: `inventory-${String(index)}`,