fix: override the shipped standard preset in the compaction overlay
Release / release (push) Successful in 9s

`presets/standard-compaction.patch.yml` inserted a second `preset-standard`
declaration. It happened to take effect because it applied last, but which of
the two declarations mounted was decided by the loader's duplicate-id handling,
and the composed tree carried two rows with the same id.

The file now overrides the shipped row by id, so the intent is explicit and only
one declaration exists. `test/presets.test.js` composes the shipped declaration
and the overlay through the harness's own patch engine and asserts one row, no
skipped patch, and the compaction budget applied — which the old insert form no
longer satisfies.
This commit is contained in:
NotExpectedYet committed 2026-11-09 08:30:11 +00:00
1 parent 40574505f2
commit 387f7c3510
2 files changed
+164 -124

No files matched your search

+37 -2
View File
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
import { fileURLToPath, pathToFileURL } from 'node:url'
import yaml from 'js-yaml'
@@ -86,6 +86,9 @@ const HARNESS_SCOPES = harnessScopes()
const STANDARD_PRESET = HARNESS_SCOPES
.map((scope) => join(scope, '@deepseek-ai', 'dsh-web-app', 'presets', 'standard.patch.yml'))
.find((file) => existsSync(file))
const APP_BOOT = HARNESS_SCOPES
.map((scope) => join(scope, '@deepseek-ai', 'dsh-app-boot', 'lib', 'index.js'))
.find((file) => existsSync(file))
const SKIP_DRIFT =
HARNESS_SCOPES.length === 0
@@ -102,7 +105,10 @@ const PRESET_SCHEMA = yaml.DEFAULT_SCHEMA.extend([
/** The plugin rows of a single-preset patch file, as written. */
function presetPlugins(file) {
const [patch] = yaml.load(readFileSync(file, 'utf8'), { schema: PRESET_SCHEMA })
return patch.insert[0].config.plugins
// The facet preset is an insert; the optional overlay overrides the shipped
// row by id and carries the full config instead.
const declaration = patch.insert === undefined ? patch : patch.insert[0]
return declaration.config.plugins
}
/** Drop absent keys, so a missing field and an undefined field compare the same. */
@@ -181,6 +187,35 @@ test('the standard-compaction overlay is the shipped standard composition plus t
)
})
test(
'the standard-compaction overlay replaces the shipped preset instead of adding a second declaration',
{ skip: SKIP_DRIFT },
async (t) => {
if (APP_BOOT === undefined) return t.skip('the harness app-boot package was not found in any scope')
// Compose the way the launcher does: the shipped declaration first, then the
// overlay. A second declaration carrying the same preset id would register
// in the wrong order and lose — which is how this overlay used to do nothing.
const { composeEntries } = await import(pathToFileURL(APP_BOOT).href)
const standardPatch = yaml.load(readFileSync(STANDARD_PRESET, 'utf8'), { schema: PRESET_SCHEMA })
const overlayPatch = yaml.load(readFileSync(COMPACTION_PRESET, 'utf8'), { schema: PRESET_SCHEMA })
const warnings = []
const entries = composeEntries([standardPatch, overlayPatch], (message) => warnings.push(message))
assert.deepEqual(warnings, [], 'the overlay applies without a skipped patch')
const declarations = entries.filter((entry) => entry.id === 'preset-standard')
assert.equal(
declarations.length,
1,
'the overlay overrides the row; a second declaration would be ignored by the registry',
)
assert.deepEqual(
rowById(declarations[0].config.plugins, 'compaction-basic')?.config,
COMPACTION_BUDGET,
'the applied overlay carries the compaction budget',
)
},
)
/** Every row's id and module specifier, groups included. */
function namedRows(rows) {
return rows.flatMap((row) => [