fix: override the shipped standard preset in the compaction overlay
Release / release (push) Successful in 9s
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:
1 parent
40574505f2
commit
387f7c3510
2 files changed
+44
-4
No files matched your search
@@ -8,6 +8,12 @@
|
|||||||
#
|
#
|
||||||
# or add its path to `dsh.bundle.patch` in package.json.
|
# or add its path to `dsh.bundle.patch` in package.json.
|
||||||
#
|
#
|
||||||
|
# It overrides the shipped `preset-standard` row by id rather than inserting a
|
||||||
|
# second declaration. With two rows carrying the same preset id, which one mounts
|
||||||
|
# is decided by the loader's duplicate-id handling rather than by the patch — the
|
||||||
|
# insert form worked only as long as that ordering held. The override is explicit
|
||||||
|
# and must be applied after the web-app layer, which both ways above are.
|
||||||
|
#
|
||||||
# It is deliberately not applied for you, and the reason is a real hazard rather
|
# It is deliberately not applied for you, and the reason is a real hazard rather
|
||||||
# than caution: a preset declaration replaces the whole plugin list, never merges
|
# than caution: a preset declaration replaces the whole plugin list, never merges
|
||||||
# into it, so this file is a frozen copy of the shipped `standard` composition
|
# into it, so this file is a frozen copy of the shipped `standard` composition
|
||||||
@@ -21,8 +27,7 @@
|
|||||||
# The one change from the shipped file is the `compaction-basic` row's config.
|
# The one change from the shipped file is the `compaction-basic` row's config.
|
||||||
# `test/presets.test.js` compares this file against the installed `standard`
|
# `test/presets.test.js` compares this file against the installed `standard`
|
||||||
# and fails on any other difference.
|
# and fails on any other difference.
|
||||||
- insert:
|
- id: preset-standard
|
||||||
- id: preset-standard
|
|
||||||
name: '@deepseek-ai/dsh-agent-preset'
|
name: '@deepseek-ai/dsh-agent-preset'
|
||||||
config:
|
config:
|
||||||
id: standard
|
id: standard
|
||||||
|
|||||||
+37
-2
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|||||||
import { createRequire } from 'node:module'
|
import { createRequire } from 'node:module'
|
||||||
import { dirname, join } from 'node:path'
|
import { dirname, join } from 'node:path'
|
||||||
import { test } from 'node:test'
|
import { test } from 'node:test'
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||||
|
|
||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
|
|
||||||
@@ -86,6 +86,9 @@ const HARNESS_SCOPES = harnessScopes()
|
|||||||
const STANDARD_PRESET = HARNESS_SCOPES
|
const STANDARD_PRESET = HARNESS_SCOPES
|
||||||
.map((scope) => join(scope, '@deepseek-ai', 'dsh-web-app', 'presets', 'standard.patch.yml'))
|
.map((scope) => join(scope, '@deepseek-ai', 'dsh-web-app', 'presets', 'standard.patch.yml'))
|
||||||
.find((file) => existsSync(file))
|
.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 =
|
const SKIP_DRIFT =
|
||||||
HARNESS_SCOPES.length === 0
|
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. */
|
/** The plugin rows of a single-preset patch file, as written. */
|
||||||
function presetPlugins(file) {
|
function presetPlugins(file) {
|
||||||
const [patch] = yaml.load(readFileSync(file, 'utf8'), { schema: PRESET_SCHEMA })
|
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. */
|
/** 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. */
|
/** Every row's id and module specifier, groups included. */
|
||||||
function namedRows(rows) {
|
function namedRows(rows) {
|
||||||
return rows.flatMap((row) => [
|
return rows.flatMap((row) => [
|
||||||
|
|||||||
Reference in new issue
Block a user