dsh-tower 2.3.0 → 2.4.0
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 +34 -0
- package/COMPATIBILITY.md +1 -0
- package/CONTRIBUTING.md +17 -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 +25 -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/en.json +31 -11
- package/locale/zh.json +30 -10
- package/package.json +16 -3
- package/scripts/check-components.mjs +235 -0
- package/scripts/component-surface.json +395 -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 +17 -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,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
|
|
@@ -171,19 +180,24 @@ ports/vcs.js
|
|
|
171
180
|
reviewer.js
|
|
172
181
|
scripts/architecture-waivers.json
|
|
173
182
|
scripts/architecture.mjs
|
|
183
|
+
scripts/check-components.mjs
|
|
174
184
|
scripts/check-docs.mjs
|
|
175
185
|
scripts/check-pack.mjs
|
|
176
186
|
scripts/check-philosophy.mjs
|
|
187
|
+
scripts/component-surface.json
|
|
177
188
|
scripts/domain-metrics.mjs
|
|
178
189
|
scripts/enable-dev-hmr.mjs
|
|
190
|
+
scripts/generate-component-surface.mjs
|
|
179
191
|
scripts/generate-config-reference.mjs
|
|
180
192
|
scripts/generate-error-reference.mjs
|
|
181
193
|
scripts/generate-events-reference.mjs
|
|
182
194
|
scripts/generate-tools-reference.mjs
|
|
195
|
+
scripts/generate-types.mjs
|
|
183
196
|
scripts/issue-audit.mjs
|
|
184
197
|
scripts/lib/cli.mjs
|
|
185
198
|
scripts/lib/surface.mjs
|
|
186
199
|
scripts/lib/tmp.mjs
|
|
200
|
+
scripts/lib/tool-surface.mjs
|
|
187
201
|
scripts/mount-smoke.mjs
|
|
188
202
|
scripts/mount-smoke/fixtures.mjs
|
|
189
203
|
scripts/mount-smoke/host.json
|
|
@@ -194,6 +208,9 @@ scripts/regression-audit.mjs
|
|
|
194
208
|
scripts/release-check.mjs
|
|
195
209
|
scripts/surface-baseline.json
|
|
196
210
|
scripts/surface-baseline.mjs
|
|
211
|
+
scripts/types-coverage.mjs
|
|
212
|
+
scripts/types-strict-manifest.txt
|
|
213
|
+
scripts/types-strict.mjs
|
|
197
214
|
skills.js
|
|
198
215
|
skills/tower-recovery.md
|
|
199
216
|
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
|
}
|
|
@@ -2,16 +2,21 @@
|
|
|
2
2
|
// Concept-budget gate (#84): compare the live surface with the committed
|
|
3
3
|
// baseline and require evidence for growth.
|
|
4
4
|
//
|
|
5
|
-
// The surface is
|
|
5
|
+
// The surface is four counts the user has to hold at once:
|
|
6
6
|
// config keys leaf keys in domain/config/schema.js (one level deep)
|
|
7
7
|
// sections object groups in that schema
|
|
8
|
-
// tools tool
|
|
8
|
+
// tools every tool the Host entry registers, including the
|
|
9
|
+
// tower_mode/tower_control pair that index.js registers
|
|
10
|
+
// directly rather than through define() (#118)
|
|
11
|
+
// components user-visible rows in cordis.patch.yml (#120), so the 2.3.0
|
|
12
|
+
// 4 -> 1 contraction and any future move need a written decision
|
|
9
13
|
//
|
|
10
14
|
// `scripts/surface-baseline.json` freezes those counts. A PR that grows a count
|
|
11
15
|
// fails here until the baseline carries a decision with either an ADR under
|
|
12
|
-
// docs/adr
|
|
13
|
-
//
|
|
14
|
-
// reference headers, so growth
|
|
16
|
+
// docs/adr/, deletions that no longer exist in the live surface, or an explicit
|
|
17
|
+
// measurement-correction record (reason + date). The same file supplies the date
|
|
18
|
+
// and counts printed in the generated config/tools reference headers, so growth
|
|
19
|
+
// is visible in a diff.
|
|
15
20
|
//
|
|
16
21
|
// Usage:
|
|
17
22
|
// node scripts/surface-baseline.mjs [--root <dir>] [--json]
|
|
@@ -19,9 +24,9 @@ import fs from 'node:fs'
|
|
|
19
24
|
import path from 'node:path'
|
|
20
25
|
import { fileURLToPath } from 'node:url'
|
|
21
26
|
import { configSurface } from '../domain/config/schema.js'
|
|
27
|
+
import { parseCordisPatch } from '../domain/components.js'
|
|
22
28
|
import { SURFACE_CLASSIFICATION_FILE, SURFACE_BASELINE_FILE, surfaceLine } from '../domain/surface.js'
|
|
23
|
-
import {
|
|
24
|
-
import { definedToolNames } from '../host/tool-registry.js'
|
|
29
|
+
import { loadShippedToolSurface } from './lib/tool-surface.mjs'
|
|
25
30
|
import { checkSurfaceBudget } from './lib/surface.mjs'
|
|
26
31
|
import { parseArgs, runMain } from './lib/cli.mjs'
|
|
27
32
|
|
|
@@ -33,52 +38,44 @@ const USAGE = `usage: node scripts/surface-baseline.mjs [--root <dir>] [--json]
|
|
|
33
38
|
--help print this text
|
|
34
39
|
|
|
35
40
|
Growth is refused by default. To grow a count, update ${SURFACE_BASELINE_FILE}
|
|
36
|
-
with a decision that names an existing docs/adr/ ADR
|
|
37
|
-
longer in the live surface
|
|
38
|
-
|
|
41
|
+
with a decision that names an existing docs/adr/ ADR, deletions that are no
|
|
42
|
+
longer in the live surface, or a measurement-correction record with a reason and
|
|
43
|
+
date. The classification table in
|
|
44
|
+
${SURFACE_CLASSIFICATION_FILE} must cover every key and tool exactly once, and
|
|
45
|
+
the component count comes from the visible rows in cordis.patch.yml.`
|
|
39
46
|
|
|
40
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* The live tool names: apply the shipped Host entry so every registration path
|
|
49
|
+
* is included, then release the mock context's timers.
|
|
50
|
+
*/
|
|
41
51
|
function liveToolNames() {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const dispose = fn()
|
|
48
|
-
return typeof dispose === 'function' ? dispose : () => {}
|
|
49
|
-
},
|
|
50
|
-
systemPrompt: { section() {} },
|
|
51
|
-
tools: {
|
|
52
|
-
register() {
|
|
53
|
-
return () => {}
|
|
54
|
-
},
|
|
55
|
-
guard() {
|
|
56
|
-
return () => {}
|
|
57
|
-
},
|
|
58
|
-
restrict() {
|
|
59
|
-
return () => {}
|
|
60
|
-
},
|
|
61
|
-
},
|
|
52
|
+
const surface = loadShippedToolSurface()
|
|
53
|
+
try {
|
|
54
|
+
return surface.names
|
|
55
|
+
} finally {
|
|
56
|
+
surface.dispose()
|
|
62
57
|
}
|
|
63
|
-
registerTowerTools(ctx)
|
|
64
|
-
return definedToolNames()
|
|
65
58
|
}
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
61
|
* The live surface used by the gate. Exported so tests can compare the counts
|
|
69
62
|
* with the generated references without spawning the CLI.
|
|
63
|
+
* @param {string} [root] repository root (defaults to this package)
|
|
70
64
|
*/
|
|
71
|
-
export function liveSurface() {
|
|
65
|
+
export function liveSurface(root = PACKAGE_ROOT) {
|
|
72
66
|
const config = configSurface()
|
|
73
67
|
const tools = liveToolNames()
|
|
68
|
+
const patch = parseCordisPatch(fs.readFileSync(path.join(root, 'cordis.patch.yml'), 'utf8'))
|
|
74
69
|
return {
|
|
75
70
|
configKeys: config.count,
|
|
76
71
|
sections: config.sections.length,
|
|
77
72
|
tools: tools.length,
|
|
73
|
+
components: patch.visible.length,
|
|
78
74
|
liveNames: {
|
|
79
75
|
configKeys: config.keys,
|
|
80
76
|
sections: config.sections,
|
|
81
77
|
tools,
|
|
78
|
+
components: patch.visible,
|
|
82
79
|
},
|
|
83
80
|
}
|
|
84
81
|
}
|
|
@@ -105,6 +102,7 @@ function main(argv) {
|
|
|
105
102
|
return result.ok ? 0 : 1
|
|
106
103
|
}
|
|
107
104
|
console.log(`surface: ${surfaceLine(current)}`)
|
|
105
|
+
console.log(`surface: components: ${current.components} visible (${current.liveNames.components.join(', ')})`)
|
|
108
106
|
if (result.baseline) console.log(`surface: baseline ${result.baseline.date} (${SURFACE_BASELINE_FILE})`)
|
|
109
107
|
if (result.classification) {
|
|
110
108
|
const configRows = result.classification.entries.filter((entry) => entry.kind === 'config').length
|