dsh-tower 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/COMPATIBILITY.md +2 -0
- package/CONTRIBUTING.md +20 -3
- package/PRINCIPLES.md +18 -0
- package/README.en.md +29 -16
- package/README.md +22 -15
- package/cordis.patch.yml +56 -28
- package/docs/README.md +2 -1
- package/docs/adr/0004-surface-budget.md +20 -0
- package/docs/adr/0005-component-surface.md +130 -0
- package/docs/adr/README.md +1 -0
- package/docs/agents/workflow.md +1 -1
- package/docs/architecture/overview.md +69 -7
- package/docs/guide/hot-reload.md +4 -4
- package/docs/guide/install-upgrade-migration.md +13 -0
- package/docs/operations/security.md +1 -1
- package/docs/reference/component-surface.md +135 -0
- package/docs/reference/config.generated.md +2 -10
- package/docs/reference/config.md +11 -9
- package/docs/reference/doctor.md +14 -9
- package/docs/reference/surface-budget.md +52 -23
- package/docs/reference/tools.generated.md +4 -2
- package/docs/reference/tools.md +6 -3
- package/docs/zh/README.md +1 -1
- package/docs/zh/guide/hot-reload.md +3 -3
- package/docs/zh/guide/install-upgrade-migration.md +10 -0
- package/docs/zh/operations/security.md +1 -1
- package/docs/zh/reference/config.md +9 -9
- package/docs/zh/reference/tools.md +6 -4
- package/domain/components.js +641 -0
- package/domain/config/schema.js +37 -27
- package/domain/contracts/outputs.js +10 -0
- package/domain/errors.js +11 -1
- package/domain/mission.js +12 -1
- package/domain/surface.js +154 -55
- package/host/capability-batch.js +15 -0
- package/host/capability-hmr.js +30 -0
- package/host/capability-import.js +11 -0
- package/host/capability-leases.js +11 -0
- package/host/capability-registry.js +149 -0
- package/host/capability-tests.js +16 -0
- package/host/doctor.js +41 -9
- package/host/hmr.js +2 -4
- package/host/presets.js +51 -9
- package/host/tool-registry.js +150 -34
- package/index.js +32 -20
- package/locale/batch/en.json +6 -0
- package/locale/batch/zh.json +6 -0
- package/locale/en.json +31 -11
- package/locale/hmr/en.json +6 -0
- package/locale/hmr/zh.json +6 -0
- package/locale/import/en.json +6 -0
- package/locale/import/zh.json +6 -0
- package/locale/leases/en.json +6 -0
- package/locale/leases/zh.json +6 -0
- package/locale/skills/en.json +6 -0
- package/locale/skills/zh.json +6 -0
- package/locale/tests/en.json +6 -0
- package/locale/tests/zh.json +6 -0
- package/locale/zh.json +30 -10
- package/package.json +25 -4
- package/scripts/check-components.mjs +235 -0
- package/scripts/check-pack.mjs +4 -0
- package/scripts/component-surface.json +395 -0
- package/scripts/generate-capability-locale.mjs +148 -0
- package/scripts/generate-component-surface.mjs +59 -0
- package/scripts/generate-tools-reference.mjs +7 -25
- package/scripts/generate-types.mjs +127 -0
- package/scripts/lib/tool-surface.mjs +85 -0
- package/scripts/mount-smoke/fixtures.mjs +3 -3
- package/scripts/mount-smoke/surface.mjs +96 -27
- package/scripts/mount-smoke.mjs +3 -1
- package/scripts/pack-manifest.txt +30 -0
- package/scripts/surface-baseline.json +35 -4
- package/scripts/surface-baseline.mjs +32 -34
- package/scripts/types-coverage.mjs +184 -0
- package/scripts/types-strict-manifest.txt +10 -0
- package/scripts/types-strict.mjs +141 -0
- package/skills.js +8 -1
- package/tools/index.js +2 -1
- package/tools/reload.js +34 -35
- package/tools/status.js +8 -1
- package/types/index.d.ts +28 -12
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Generate the published type vocabulary from the runtime constants (#115).
|
|
2
|
+
//
|
|
3
|
+
// `types/index.d.ts` is the shipped type surface (`package.json` `types`). Its
|
|
4
|
+
// status/type/role/error unions used to be a hand-copied second declaration of
|
|
5
|
+
// constants that live in domain/; this generator makes the runtime the single
|
|
6
|
+
// source: the marked block is rewritten from ERROR_CODES, MISSION_STATUSES,
|
|
7
|
+
// REVIEW_STATUSES, MERGE_VERDICTS, MISSION_KINDS, REVIEW_POLICIES, FINDING_*,
|
|
8
|
+
// ROLES and PAUSE_CAUSES. It is the type-surface sibling of the four
|
|
9
|
+
// `docs:generate:*` generators and shares their `--check` contract.
|
|
10
|
+
//
|
|
11
|
+
// Usage: node scripts/generate-types.mjs [--check]
|
|
12
|
+
//
|
|
13
|
+
// The block is delimited by `// generated:vocabulary:start` / `:end` in
|
|
14
|
+
// types/index.d.ts; the prose around it is hand-written. A missing marker is a
|
|
15
|
+
// configuration error, not a silent no-op.
|
|
16
|
+
import fs from 'node:fs'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
import { fileURLToPath } from 'node:url'
|
|
19
|
+
import { ERROR_CODES } from '../domain/errors.js'
|
|
20
|
+
import {
|
|
21
|
+
FINDING_SEVERITIES,
|
|
22
|
+
FINDING_STATUSES,
|
|
23
|
+
FINDING_TYPES,
|
|
24
|
+
MERGE_VERDICTS,
|
|
25
|
+
MISSION_STATUSES,
|
|
26
|
+
PAUSE_CAUSES,
|
|
27
|
+
REVIEW_STATUSES,
|
|
28
|
+
} from '../domain/mission.js'
|
|
29
|
+
import { MISSION_KINDS, REVIEW_POLICIES, ROLES } from '../domain/vocabulary.js'
|
|
30
|
+
|
|
31
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
32
|
+
const TARGET = path.join(root, 'types', 'index.d.ts')
|
|
33
|
+
export const START = '// generated:vocabulary:start'
|
|
34
|
+
export const END = '// generated:vocabulary:end'
|
|
35
|
+
|
|
36
|
+
/** One published alias per runtime constant family, in declaration order. */
|
|
37
|
+
const DECLARATIONS = [
|
|
38
|
+
{ key: 'missionStatuses', name: 'MissionStatus' },
|
|
39
|
+
{ key: 'missionKinds', name: 'MissionKind' },
|
|
40
|
+
{ key: 'reviewStatuses', name: 'ReviewStatus', multiline: true },
|
|
41
|
+
{ key: 'mergeVerdicts', name: 'MergeVerdict' },
|
|
42
|
+
{ key: 'reviewPolicies', name: 'ReviewPolicy' },
|
|
43
|
+
{ key: 'findingTypes', name: 'FindingType' },
|
|
44
|
+
{ key: 'findingSeverities', name: 'FindingSeverity' },
|
|
45
|
+
{ key: 'findingStatuses', name: 'FindingStatus' },
|
|
46
|
+
{ key: 'roles', name: 'Role' },
|
|
47
|
+
{ key: 'pauseCauses', name: 'PauseCause' },
|
|
48
|
+
{ key: 'errorCodes', name: 'ErrorCode', multiline: true },
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
/** The runtime data the block is generated from. `--check` compares this exact input. */
|
|
52
|
+
export function vocabularyData() {
|
|
53
|
+
return {
|
|
54
|
+
missionStatuses: [...MISSION_STATUSES],
|
|
55
|
+
missionKinds: [...MISSION_KINDS],
|
|
56
|
+
reviewStatuses: [...REVIEW_STATUSES],
|
|
57
|
+
mergeVerdicts: [...MERGE_VERDICTS],
|
|
58
|
+
reviewPolicies: [...REVIEW_POLICIES],
|
|
59
|
+
findingTypes: [...FINDING_TYPES],
|
|
60
|
+
findingSeverities: [...FINDING_SEVERITIES],
|
|
61
|
+
findingStatuses: [...FINDING_STATUSES],
|
|
62
|
+
roles: [...ROLES],
|
|
63
|
+
pauseCauses: [...PAUSE_CAUSES],
|
|
64
|
+
errorCodes: Object.keys(ERROR_CODES),
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function renderDeclaration({ name, values, multiline = false }) {
|
|
69
|
+
const quoted = values.map((value) => `'${String(value).replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`)
|
|
70
|
+
const inline = `export type ${name} = ${quoted.join(' | ')}`
|
|
71
|
+
if (!multiline && inline.length <= 120) return inline
|
|
72
|
+
return [`export type ${name} =`, ...quoted.map((value) => ` | ${value}`)].join('\n')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Render the marked block (markers excluded) for one vocabulary input.
|
|
77
|
+
* @param {Record<string, string[]>} data
|
|
78
|
+
* @returns {string}
|
|
79
|
+
*/
|
|
80
|
+
export function vocabularyBlock(data) {
|
|
81
|
+
return DECLARATIONS.map((declaration) =>
|
|
82
|
+
renderDeclaration({ ...declaration, values: data[declaration.key] }),
|
|
83
|
+
).join('\n')
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Replace the marked block in a declaration file. Removing or reordering the
|
|
88
|
+
* markers is a hard error: a generated block that cannot be found would
|
|
89
|
+
* otherwise pass every check while drifting.
|
|
90
|
+
* @param {string} source
|
|
91
|
+
* @param {string} block
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
export function injectVocabulary(source, block) {
|
|
95
|
+
const start = source.indexOf(START)
|
|
96
|
+
const end = source.indexOf(END)
|
|
97
|
+
if (start === -1 || end === -1 || end < start) {
|
|
98
|
+
throw new Error(`types/index.d.ts is missing the ${START} / ${END} markers`)
|
|
99
|
+
}
|
|
100
|
+
return `${source.slice(0, start + START.length)}\n${block}\n${source.slice(end)}`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function main() {
|
|
104
|
+
const source = fs.readFileSync(TARGET, 'utf8')
|
|
105
|
+
const expected = injectVocabulary(source, vocabularyBlock(vocabularyData()))
|
|
106
|
+
const codes = Object.keys(ERROR_CODES).length
|
|
107
|
+
if (process.argv.includes('--check')) {
|
|
108
|
+
if (source !== expected) {
|
|
109
|
+
console.error('published type vocabulary is stale; run npm run types:generate')
|
|
110
|
+
process.exit(1)
|
|
111
|
+
}
|
|
112
|
+
console.log(`type vocabulary: ${DECLARATIONS.length} aliases (${codes} error codes) in sync`)
|
|
113
|
+
} else {
|
|
114
|
+
fs.writeFileSync(TARGET, expected)
|
|
115
|
+
console.log(`wrote ${path.relative(root, TARGET)} (${DECLARATIONS.length} aliases, ${codes} error codes)`)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const isMain = process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
|
|
120
|
+
if (isMain) {
|
|
121
|
+
try {
|
|
122
|
+
main()
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(`type vocabulary: ${String(error?.message ?? error)}`)
|
|
125
|
+
process.exit(1)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The shipped tool surface, derived from the Host entry (#118).
|
|
2
|
+
//
|
|
3
|
+
// `scripts/surface-baseline.mjs` and `scripts/generate-tools-reference.mjs` must
|
|
4
|
+
// measure the tools the plugin actually registers — including `tower_mode` and
|
|
5
|
+
// `tower_control`, which `index.js` registers directly instead of through the
|
|
6
|
+
// `define()` path. Loading the real `apply()` with a minimal Cordis context
|
|
7
|
+
// means the measurement cannot drift from the shipped surface again.
|
|
8
|
+
import os from 'node:os'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { apply } from '../../index.js'
|
|
11
|
+
import { definedToolNames, registerAllCapabilities, __testResetToolSurface } from '../../host/tool-registry.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Apply the real Host entry against a recording mock context.
|
|
15
|
+
*
|
|
16
|
+
* @returns {{
|
|
17
|
+
* names: string[],
|
|
18
|
+
* definitions: Map<string, any>,
|
|
19
|
+
* dispose: () => void,
|
|
20
|
+
* }}
|
|
21
|
+
* `names` is the recorded surface (the same source `tower_doctor` reads);
|
|
22
|
+
* `definitions` is every tool the default profile actually registered.
|
|
23
|
+
*/
|
|
24
|
+
export function loadShippedToolSurface() {
|
|
25
|
+
const definitions = new Map()
|
|
26
|
+
const disposers = []
|
|
27
|
+
const ctx = {
|
|
28
|
+
effect(fn) {
|
|
29
|
+
const dispose = fn()
|
|
30
|
+
if (typeof dispose === 'function') disposers.push(dispose)
|
|
31
|
+
return () => {}
|
|
32
|
+
},
|
|
33
|
+
get() {
|
|
34
|
+
return undefined
|
|
35
|
+
},
|
|
36
|
+
provide() {},
|
|
37
|
+
inject(_deps, callback) {
|
|
38
|
+
callback(ctx)
|
|
39
|
+
},
|
|
40
|
+
on() {
|
|
41
|
+
return () => {}
|
|
42
|
+
},
|
|
43
|
+
logger: { warn() {} },
|
|
44
|
+
tools: {
|
|
45
|
+
register(definition) {
|
|
46
|
+
if (definition && typeof definition.name === 'string') definitions.set(definition.name, definition)
|
|
47
|
+
return () => {}
|
|
48
|
+
},
|
|
49
|
+
guard() {
|
|
50
|
+
return () => {}
|
|
51
|
+
},
|
|
52
|
+
restrict() {
|
|
53
|
+
return () => {}
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
systemPrompt: { section() {} },
|
|
57
|
+
commands: {
|
|
58
|
+
register() {
|
|
59
|
+
return () => {}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
// Keep the mode store out of the operator's real $DSH_HOME. The path is only
|
|
64
|
+
// read (a missing modes.json is an empty mode set); nothing is written.
|
|
65
|
+
// #121: the host entry registers only the mandatory surface; the shipped
|
|
66
|
+
// profile mounts the optional capability rows. The concept budget measures the
|
|
67
|
+
// *build* surface, so the all-capabilities aggregate is applied on top.
|
|
68
|
+
__testResetToolSurface()
|
|
69
|
+
apply(ctx, { mode: { storePath: path.join(os.tmpdir(), 'dsh-tower-surface-check') } })
|
|
70
|
+
registerAllCapabilities(ctx)
|
|
71
|
+
const names = definedToolNames()
|
|
72
|
+
return {
|
|
73
|
+
names,
|
|
74
|
+
definitions,
|
|
75
|
+
dispose() {
|
|
76
|
+
for (const dispose of disposers.reverse()) {
|
|
77
|
+
try {
|
|
78
|
+
dispose()
|
|
79
|
+
} catch {
|
|
80
|
+
// a recorder fixture must still exit when a disposer fails
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -67,19 +67,19 @@ const fixtures = [
|
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
name: 'dropped-skills-section',
|
|
70
|
-
what: 'the tower-skills row is removed from the bundle patch',
|
|
70
|
+
what: 'the optional tower-skills row is removed from the bundle patch',
|
|
71
71
|
seed(root) {
|
|
72
72
|
const file = path.join(root, 'cordis.patch.yml')
|
|
73
73
|
const text = fs.readFileSync(file, 'utf8')
|
|
74
74
|
const next = replaceOnce(
|
|
75
75
|
text,
|
|
76
|
-
/\n {
|
|
76
|
+
/\n {4}- id: tower-skills\n {6}name: 'dsh-tower\/skills'/,
|
|
77
77
|
'',
|
|
78
78
|
'cordis.patch.yml tower-skills row',
|
|
79
79
|
)
|
|
80
80
|
fs.writeFileSync(file, next)
|
|
81
81
|
},
|
|
82
|
-
expect: ['skill: missing tower-worker-protocol', 'bundle:
|
|
82
|
+
expect: ['skill: missing tower-worker-protocol', 'bundle: missing optional top-level row tower-skills'],
|
|
83
83
|
},
|
|
84
84
|
]
|
|
85
85
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The expected loaded surface of the dsh-tower bundle (#95).
|
|
1
|
+
// The expected loaded surface of the dsh-tower bundle (#95, #121).
|
|
2
2
|
//
|
|
3
3
|
// Pure derivation and comparison only: the mount smoke boots a throwaway
|
|
4
4
|
// profile, and these helpers turn the checked-in source of truth into the ids
|
|
@@ -7,17 +7,53 @@
|
|
|
7
7
|
//
|
|
8
8
|
// The oracle is deliberately source-derived where the source is unambiguous:
|
|
9
9
|
// one tool id per tool module, one skill id per bundled skill file. The bundle
|
|
10
|
-
//
|
|
11
|
-
// contract the
|
|
10
|
+
// rows and presets come from `cordis.patch.yml` and are stated here as the
|
|
11
|
+
// contract the component policy protects: one mandatory host group plus
|
|
12
|
+
// individually switchable optional top-level rows (#121). Tools owned by a row
|
|
13
|
+
// that ships off (today only `tower-hmr` -> `tower_reload`) are trimmed from the
|
|
14
|
+
// expected surface using the same ownership table the runtime reports, so the
|
|
15
|
+
// shipped default profile (28 tools) and the all-rows-on build surface (29)
|
|
16
|
+
// cannot be confused again.
|
|
17
|
+
|
|
18
|
+
import { COMPONENT_TOOLS } from '../../host/capability-registry.js'
|
|
12
19
|
|
|
13
20
|
/** Tools registered by index.js rather than by a handler module under tools/. */
|
|
14
21
|
export const INDEX_TOOL_IDS = ['tower_control', 'tower_mode']
|
|
15
22
|
|
|
16
|
-
/** The
|
|
17
|
-
export const BUNDLE_ID = 'tower
|
|
23
|
+
/** The mandatory host group row: off equals uninstalling. */
|
|
24
|
+
export const BUNDLE_ID = 'tower'
|
|
18
25
|
|
|
19
26
|
/** Rows that must stay nested inside {@link BUNDLE_ID}. */
|
|
20
|
-
export const BUNDLE_CHILD_IDS = ['preset-tower-
|
|
27
|
+
export const BUNDLE_CHILD_IDS = ['preset-tower-worker', 'tower-host']
|
|
28
|
+
|
|
29
|
+
/** The optional capability rows that sit at the top level beside the host. */
|
|
30
|
+
export const OPTIONAL_ROW_IDS = [
|
|
31
|
+
'preset-tower-reviewer',
|
|
32
|
+
'tower-batch',
|
|
33
|
+
'tower-hmr',
|
|
34
|
+
'tower-import',
|
|
35
|
+
'tower-leases',
|
|
36
|
+
'tower-skills',
|
|
37
|
+
'tower-tests',
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
/** Rows shipped off: the mount smoke must not expect them to be active. */
|
|
41
|
+
export const DEFAULT_OFF_ROW_IDS = ['tower-hmr']
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Tool ids owned by the rows in {@link DEFAULT_OFF_ROW_IDS}. The ownership table
|
|
45
|
+
* is the one `host/capability-registry.js` uses to report a disabled component,
|
|
46
|
+
* so the oracle cannot drift from the runtime: turning a row's default off in
|
|
47
|
+
* `cordis.patch.yml` automatically removes its tools from the expected surface.
|
|
48
|
+
* @returns {Set<string>} the tool ids a default profile does not register.
|
|
49
|
+
*/
|
|
50
|
+
export function defaultOffToolIds() {
|
|
51
|
+
const ids = new Set()
|
|
52
|
+
for (const rowId of DEFAULT_OFF_ROW_IDS) {
|
|
53
|
+
for (const toolId of COMPONENT_TOOLS[rowId] ?? []) ids.add(toolId)
|
|
54
|
+
}
|
|
55
|
+
return ids
|
|
56
|
+
}
|
|
21
57
|
|
|
22
58
|
/** Presets the bundle declares for its worker and reviewer roles. */
|
|
23
59
|
export const PRESET_IDS = ['tower-reviewer', 'tower-worker']
|
|
@@ -25,7 +61,7 @@ export const PRESET_IDS = ['tower-reviewer', 'tower-worker']
|
|
|
25
61
|
/** Cordis fiber state 2: mounted and active. */
|
|
26
62
|
const FIBER_ACTIVE = 2
|
|
27
63
|
|
|
28
|
-
const OWNED_ROW_IDS = new Set([BUNDLE_ID, ...BUNDLE_CHILD_IDS])
|
|
64
|
+
const OWNED_ROW_IDS = new Set([BUNDLE_ID, ...BUNDLE_CHILD_IDS, ...OPTIONAL_ROW_IDS])
|
|
29
65
|
|
|
30
66
|
/**
|
|
31
67
|
* Map one tools/ file name to the tool id its module must register.
|
|
@@ -42,14 +78,25 @@ export function toolIdForModule(fileName) {
|
|
|
42
78
|
|
|
43
79
|
/**
|
|
44
80
|
* @param {string[]} moduleFiles - file names under tools/.
|
|
81
|
+
* @param {{ enabledRows?: string[] }} [options] - rows enabled in the profile
|
|
82
|
+
* under test. Defaults to the shipped profile: every optional row except the
|
|
83
|
+
* ones in {@link DEFAULT_OFF_ROW_IDS}. Pass every row id to pin the full
|
|
84
|
+
* build surface (29 tools with the shipped sources).
|
|
45
85
|
* @returns {string[]} sorted tool ids the loaded profile must register.
|
|
46
86
|
*/
|
|
47
|
-
export function expectedToolIds(moduleFiles) {
|
|
87
|
+
export function expectedToolIds(moduleFiles, options = {}) {
|
|
88
|
+
const enabledRows = options.enabledRows === undefined ? null : new Set(options.enabledRows)
|
|
89
|
+
const skipped = new Set()
|
|
90
|
+
for (const rowId of DEFAULT_OFF_ROW_IDS) {
|
|
91
|
+
if (enabledRows !== null && enabledRows.has(rowId)) continue
|
|
92
|
+
for (const toolId of COMPONENT_TOOLS[rowId] ?? []) skipped.add(toolId)
|
|
93
|
+
}
|
|
48
94
|
const ids = new Set(INDEX_TOOL_IDS)
|
|
49
95
|
for (const file of moduleFiles) {
|
|
50
96
|
const id = toolIdForModule(file)
|
|
51
97
|
if (id !== null) ids.add(id)
|
|
52
98
|
}
|
|
99
|
+
for (const id of skipped) ids.delete(id)
|
|
53
100
|
return [...ids].sort()
|
|
54
101
|
}
|
|
55
102
|
|
|
@@ -81,46 +128,55 @@ export function compareIds(label, expectedIds, loadedIds) {
|
|
|
81
128
|
return failures
|
|
82
129
|
}
|
|
83
130
|
|
|
131
|
+
/** Effective loader id for a nested row (`group:child`), falling back to the raw id. */
|
|
132
|
+
function stateKey(id, entryStates) {
|
|
133
|
+
if (entryStates[id] !== undefined) return id
|
|
134
|
+
const nested = `${BUNDLE_ID}:${id}`
|
|
135
|
+
if (entryStates[nested] !== undefined) return nested
|
|
136
|
+
return id
|
|
137
|
+
}
|
|
138
|
+
|
|
84
139
|
/**
|
|
85
|
-
* Assert the bundle
|
|
86
|
-
* every
|
|
87
|
-
* @param {Array<{ id?: string, name?: string, group?: boolean, config?: unknown[] }>} topRows
|
|
88
|
-
* the composed rows at the root of the loaded profile tree.
|
|
140
|
+
* Assert the bundle ships one mandatory host group plus the optional rows and
|
|
141
|
+
* that every expected row actually mounted (the `tower-hmr` row is shipped off).
|
|
142
|
+
* @param {Array<{ id?: string, name?: string, group?: boolean, config?: unknown[], childIds?: unknown[] }>} topRows
|
|
89
143
|
* @param {Record<string, number | undefined>} [entryStates] - fiber state per entry id.
|
|
90
144
|
* @returns {string[]} one message per violated invariant.
|
|
91
145
|
*/
|
|
92
146
|
export function checkBundleRow(topRows, entryStates = {}) {
|
|
93
147
|
const rows = Array.isArray(topRows) ? topRows.filter(Boolean) : []
|
|
94
148
|
const failures = []
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
149
|
+
const hostRows = rows.filter((row) => row.id === BUNDLE_ID)
|
|
150
|
+
if (hostRows.length !== 1) {
|
|
97
151
|
failures.push(
|
|
98
|
-
|
|
99
|
-
? `bundle: no top-level ${BUNDLE_ID} row; the bundle did not compose`
|
|
100
|
-
: `bundle: found ${
|
|
152
|
+
hostRows.length === 0
|
|
153
|
+
? `bundle: no top-level ${BUNDLE_ID} host row; the bundle did not compose`
|
|
154
|
+
: `bundle: found ${hostRows.length} top-level ${BUNDLE_ID} rows, expected exactly 1`,
|
|
101
155
|
)
|
|
102
|
-
if (
|
|
156
|
+
if (hostRows.length === 0) return failures
|
|
103
157
|
}
|
|
104
158
|
|
|
105
|
-
const
|
|
159
|
+
const topIds = new Set(rows.map((row) => String(row.id)))
|
|
160
|
+
for (const id of OPTIONAL_ROW_IDS) {
|
|
161
|
+
if (!topIds.has(id)) failures.push(`bundle: missing optional top-level row ${id}`)
|
|
162
|
+
}
|
|
106
163
|
for (const row of rows) {
|
|
107
164
|
if (row.id === BUNDLE_ID) continue
|
|
108
165
|
const name = typeof row.name === 'string' ? row.name : ''
|
|
109
166
|
const ownedName = name === 'dsh-tower' || name.startsWith('dsh-tower/')
|
|
110
167
|
if (!OWNED_ROW_IDS.has(String(row.id)) && !ownedName) continue
|
|
111
|
-
if (
|
|
112
|
-
leaked.add(String(row.id))
|
|
168
|
+
if (OPTIONAL_ROW_IDS.includes(String(row.id))) continue
|
|
113
169
|
failures.push(`bundle: ${row.id} is a top-level row; it must stay nested in ${BUNDLE_ID}`)
|
|
114
170
|
}
|
|
115
171
|
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
172
|
+
const hostRow = hostRows[0]
|
|
173
|
+
if (hostRow.name !== 'cordis:group' || hostRow.group !== true) {
|
|
118
174
|
failures.push(
|
|
119
|
-
`bundle: ${BUNDLE_ID} is not a cordis:group row (name ${JSON.stringify(
|
|
175
|
+
`bundle: ${BUNDLE_ID} is not a cordis:group row (name ${JSON.stringify(hostRow.name)}, group ${JSON.stringify(hostRow.group)})`,
|
|
120
176
|
)
|
|
121
177
|
}
|
|
122
178
|
|
|
123
|
-
const rawChildren = Array.isArray(
|
|
179
|
+
const rawChildren = Array.isArray(hostRow.childIds) ? hostRow.childIds : Array.isArray(hostRow.config) ? hostRow.config : []
|
|
124
180
|
const children = rawChildren
|
|
125
181
|
.map((child) =>
|
|
126
182
|
child && typeof child === 'object' && child.id !== undefined ? String(child.id) : typeof child === 'string' ? child : null,
|
|
@@ -131,8 +187,21 @@ export function checkBundleRow(topRows, entryStates = {}) {
|
|
|
131
187
|
for (const id of children) if (!expectedChildren.includes(id)) failures.push(`bundle: ${BUNDLE_ID} has unexpected child ${id}`)
|
|
132
188
|
if (new Set(children).size !== children.length) failures.push(`bundle: ${BUNDLE_ID} has duplicate child rows`)
|
|
133
189
|
|
|
134
|
-
for (const id of [BUNDLE_ID, ...
|
|
135
|
-
|
|
190
|
+
for (const id of [BUNDLE_ID, ...OPTIONAL_ROW_IDS]) {
|
|
191
|
+
if (DEFAULT_OFF_ROW_IDS.includes(id)) {
|
|
192
|
+
const state = entryStates[id]
|
|
193
|
+
if (state === FIBER_ACTIVE) failures.push(`bundle: ${id} ships disabled but is active`)
|
|
194
|
+
continue
|
|
195
|
+
}
|
|
196
|
+
const key = stateKey(id, entryStates)
|
|
197
|
+
const state = entryStates[key]
|
|
198
|
+
if (state !== FIBER_ACTIVE) {
|
|
199
|
+
failures.push(`bundle: entry ${id} is not active (entry state ${state === undefined ? 'missing' : state})`)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
for (const id of BUNDLE_CHILD_IDS) {
|
|
203
|
+
const key = stateKey(id, entryStates)
|
|
204
|
+
const state = entryStates[key]
|
|
136
205
|
if (state !== FIBER_ACTIVE) {
|
|
137
206
|
failures.push(`bundle: entry ${id} is not active (entry state ${state === undefined ? 'missing' : state})`)
|
|
138
207
|
}
|
package/scripts/mount-smoke.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import path from 'node:path'
|
|
|
21
21
|
import { fileURLToPath } from 'node:url'
|
|
22
22
|
import {
|
|
23
23
|
BUNDLE_ID,
|
|
24
|
+
DEFAULT_OFF_ROW_IDS,
|
|
24
25
|
INDEX_TOOL_IDS,
|
|
25
26
|
PRESET_IDS,
|
|
26
27
|
checkBundleRow,
|
|
@@ -175,12 +176,13 @@ function verifySurface(surface, root) {
|
|
|
175
176
|
|
|
176
177
|
function summarize(surface, root) {
|
|
177
178
|
const modules = toolModuleNames(root).filter((name) => name !== 'index.js').length
|
|
179
|
+
const expected = expectedToolIds(toolModuleNames(root)).length
|
|
178
180
|
const tools = Array.isArray(surface?.tools?.value) ? surface.tools.value.filter((name) => name.startsWith('tower_')).length : '?'
|
|
179
181
|
const skills = Array.isArray(surface?.skills?.value?.tower) ? surface.skills.value.tower.length : '?'
|
|
180
182
|
const presets = Array.isArray(surface?.presets?.value) ? surface.presets.value.length : '?'
|
|
181
183
|
const commands = Array.isArray(surface?.commands?.value) ? surface.commands.value.filter((name) => name === 'tower').length : '?'
|
|
182
184
|
const rows = Array.isArray(surface?.tree?.value?.top) ? surface.tree.value.top.filter((row) => row.id === BUNDLE_ID).length : '?'
|
|
183
|
-
return `${tools} tower tools (${modules} modules + ${INDEX_TOOL_IDS.length} entry tools), ${skills} skills, ${presets} presets, /tower ${commands === 1 ? 'present' : 'missing'}, ${rows} top-level bundle row`
|
|
185
|
+
return `${tools} of ${expected} tower tools (${modules} modules + ${INDEX_TOOL_IDS.length} entry tools; ${DEFAULT_OFF_ROW_IDS.join(', ')} off), ${skills} skills, ${presets} presets, /tower ${commands === 1 ? 'present' : 'missing'}, ${rows} top-level bundle row`
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
function reportFailure(state, pin, options, error) {
|
|
@@ -51,6 +51,7 @@ docs/adr/0001-ports-adapters-as-data.md
|
|
|
51
51
|
docs/adr/0002-single-state-json.md
|
|
52
52
|
docs/adr/0003-allow-agent-control-default-true.md
|
|
53
53
|
docs/adr/0004-surface-budget.md
|
|
54
|
+
docs/adr/0005-component-surface.md
|
|
54
55
|
docs/adr/README.md
|
|
55
56
|
docs/agents/domain.md
|
|
56
57
|
docs/agents/issue-tracker.md
|
|
@@ -69,6 +70,7 @@ docs/operations/incident.md
|
|
|
69
70
|
docs/operations/runbook.md
|
|
70
71
|
docs/operations/security.md
|
|
71
72
|
docs/reference/blockers.md
|
|
73
|
+
docs/reference/component-surface.md
|
|
72
74
|
docs/reference/config.generated.md
|
|
73
75
|
docs/reference/config.md
|
|
74
76
|
docs/reference/doctor.md
|
|
@@ -100,6 +102,7 @@ domain/collab/batch.js
|
|
|
100
102
|
domain/collab/messages.js
|
|
101
103
|
domain/collab/roster.js
|
|
102
104
|
domain/collab/spawn.js
|
|
105
|
+
domain/components.js
|
|
103
106
|
domain/config/schema.js
|
|
104
107
|
domain/contracts/outputs.js
|
|
105
108
|
domain/contracts/tool-inputs/collaboration.js
|
|
@@ -142,6 +145,12 @@ domain/state/semantics.js
|
|
|
142
145
|
domain/summary.js
|
|
143
146
|
domain/surface.js
|
|
144
147
|
domain/vocabulary.js
|
|
148
|
+
host/capability-batch.js
|
|
149
|
+
host/capability-hmr.js
|
|
150
|
+
host/capability-import.js
|
|
151
|
+
host/capability-leases.js
|
|
152
|
+
host/capability-registry.js
|
|
153
|
+
host/capability-tests.js
|
|
145
154
|
host/compatibility.js
|
|
146
155
|
host/config.js
|
|
147
156
|
host/doctor.js
|
|
@@ -153,7 +162,19 @@ host/tool-registry.js
|
|
|
153
162
|
host/tower.js
|
|
154
163
|
icon.svg
|
|
155
164
|
index.js
|
|
165
|
+
locale/batch/en.json
|
|
166
|
+
locale/batch/zh.json
|
|
156
167
|
locale/en.json
|
|
168
|
+
locale/hmr/en.json
|
|
169
|
+
locale/hmr/zh.json
|
|
170
|
+
locale/import/en.json
|
|
171
|
+
locale/import/zh.json
|
|
172
|
+
locale/leases/en.json
|
|
173
|
+
locale/leases/zh.json
|
|
174
|
+
locale/skills/en.json
|
|
175
|
+
locale/skills/zh.json
|
|
176
|
+
locale/tests/en.json
|
|
177
|
+
locale/tests/zh.json
|
|
157
178
|
locale/zh.json
|
|
158
179
|
package.json
|
|
159
180
|
ports/archive.js
|
|
@@ -171,19 +192,25 @@ ports/vcs.js
|
|
|
171
192
|
reviewer.js
|
|
172
193
|
scripts/architecture-waivers.json
|
|
173
194
|
scripts/architecture.mjs
|
|
195
|
+
scripts/check-components.mjs
|
|
174
196
|
scripts/check-docs.mjs
|
|
175
197
|
scripts/check-pack.mjs
|
|
176
198
|
scripts/check-philosophy.mjs
|
|
199
|
+
scripts/component-surface.json
|
|
177
200
|
scripts/domain-metrics.mjs
|
|
178
201
|
scripts/enable-dev-hmr.mjs
|
|
202
|
+
scripts/generate-capability-locale.mjs
|
|
203
|
+
scripts/generate-component-surface.mjs
|
|
179
204
|
scripts/generate-config-reference.mjs
|
|
180
205
|
scripts/generate-error-reference.mjs
|
|
181
206
|
scripts/generate-events-reference.mjs
|
|
182
207
|
scripts/generate-tools-reference.mjs
|
|
208
|
+
scripts/generate-types.mjs
|
|
183
209
|
scripts/issue-audit.mjs
|
|
184
210
|
scripts/lib/cli.mjs
|
|
185
211
|
scripts/lib/surface.mjs
|
|
186
212
|
scripts/lib/tmp.mjs
|
|
213
|
+
scripts/lib/tool-surface.mjs
|
|
187
214
|
scripts/mount-smoke.mjs
|
|
188
215
|
scripts/mount-smoke/fixtures.mjs
|
|
189
216
|
scripts/mount-smoke/host.json
|
|
@@ -194,6 +221,9 @@ scripts/regression-audit.mjs
|
|
|
194
221
|
scripts/release-check.mjs
|
|
195
222
|
scripts/surface-baseline.json
|
|
196
223
|
scripts/surface-baseline.mjs
|
|
224
|
+
scripts/types-coverage.mjs
|
|
225
|
+
scripts/types-strict-manifest.txt
|
|
226
|
+
scripts/types-strict.mjs
|
|
197
227
|
skills.js
|
|
198
228
|
skills/tower-recovery.md
|
|
199
229
|
skills/tower-review.md
|
|
@@ -4,18 +4,49 @@
|
|
|
4
4
|
"surfaces": {
|
|
5
5
|
"configKeys": {
|
|
6
6
|
"seed": 64,
|
|
7
|
-
"value":
|
|
7
|
+
"value": 56,
|
|
8
8
|
"decisions": []
|
|
9
9
|
},
|
|
10
10
|
"sections": {
|
|
11
11
|
"seed": 15,
|
|
12
|
-
"value":
|
|
12
|
+
"value": 14,
|
|
13
13
|
"decisions": []
|
|
14
14
|
},
|
|
15
15
|
"tools": {
|
|
16
16
|
"seed": 27,
|
|
17
|
-
"value":
|
|
18
|
-
"decisions": [
|
|
17
|
+
"value": 29,
|
|
18
|
+
"decisions": [
|
|
19
|
+
{
|
|
20
|
+
"from": 27,
|
|
21
|
+
"to": 29,
|
|
22
|
+
"date": "2026-10-23",
|
|
23
|
+
"correction": {
|
|
24
|
+
"reason": "Measurement correction, not surface growth: the 2.3.0 baseline recorded only define()-registered tools. tower_mode and tower_control are registered directly by index.js, so the shipped surface was always 29 (#118). The recorder in host/tool-registry.js now covers both paths.",
|
|
25
|
+
"date": "2026-10-23",
|
|
26
|
+
"ref": "docs/adr/0004-surface-budget.md"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"components": {
|
|
32
|
+
"seed": 4,
|
|
33
|
+
"value": 8,
|
|
34
|
+
"decisions": [
|
|
35
|
+
{
|
|
36
|
+
"from": 4,
|
|
37
|
+
"to": 1,
|
|
38
|
+
"date": "2026-10-23",
|
|
39
|
+
"adr": "docs/adr/0005-component-surface.md",
|
|
40
|
+
"note": "The component surface joins the budget with its history. 2.0.4 shipped four top-level rows (tower, tower-skills, preset-tower-worker, preset-tower-reviewer); 2.3.0 replaced them with one tower-bundle group row that still mounts the same four sections. This is a recorded contraction, not a free ratchet: the seed stays at 4 so any further move -- including the #121 growth back to individually toggleable optional rows -- must extend this chain with a dated decision."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"from": 1,
|
|
44
|
+
"to": 8,
|
|
45
|
+
"date": "2026-10-23",
|
|
46
|
+
"adr": "docs/adr/0005-component-surface.md",
|
|
47
|
+
"note": "#121 restores the #65 policy from ADR 0005: the one tower-bundle group becomes a mandatory tower host anchor plus seven individually switchable optional rows (tower-skills, tower-batch, tower-import, tower-leases, tower-tests, tower-hmr shipped off, preset-tower-reviewer conditional). The host anchor and preset-tower-worker stay mandatory; tower_doctor and tower_recover stay mandatory with the host (#122), so they are not rows. configKeys and sections shrank in the same wave because the seven tools.expose* keys and dev.hotReload became rows."
|
|
48
|
+
}
|
|
49
|
+
]
|
|
19
50
|
}
|
|
20
51
|
}
|
|
21
52
|
}
|