fix(apes-sidebar): inject 改空数组(修 DSH entry pending → 恢复模式)

根因:inject: ['logger'] 声明了 logger 为硬依赖 service,但 DSH host
没有 provider 注册 logger service → entry 永远 pending →
'1 entry did not activate' → 插件树加载失败 → 恢复模式循环。

对比 dsh-better-sidebar:其 inject 是 host 实际提供的 service
(webServer/sessions/webRuntime/tools)。apes-sidebar host half 只用
ctx.logger 做可选链调用(log?.info?.() 在 try/catch 里),logger 是
软便利不是硬依赖——不该出现在 inject 列表里。

修正:inject 改空数组 [],host half 不声明任何硬依赖 service。
同步更新 smoke.spec.ts 断言(inject toEqual([]))+
verify-mount.cjs 检查(inject === [])。

门禁:typecheck rc=0 · build rc=0 · test 29/29
This commit is contained in:
figmar
2026-09-04 21:21:56 +08:00
parent cfc9d3c884
commit 0b79269b2c
3 changed files with 18 additions and 4 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ try {
check('host entry 加载成功', true)
check('导出 name (string)', typeof host.name === 'string', 'got ' + typeof host.name)
check('导出 inject (string[])', Array.isArray(host.inject), 'got ' + typeof host.inject)
check('inject === [logger]', JSON.stringify(host.inject) === '["logger"]', JSON.stringify(host.inject))
check('inject === [] (无硬依赖 service)', JSON.stringify(host.inject) === '[]', JSON.stringify(host.inject))
check('导出 apply (function)', typeof host.apply === 'function')
check('无 default export(namespace 规则)', !('default' in host))
console.log(' name =', JSON.stringify(host.name))
+12 -2
View File
@@ -22,8 +22,18 @@
*/
export const name = 'apes-sidebar'
/** The cordis services the host half injects (Phase 0 minimal set). */
export const inject = ['logger'] as const
/**
* The cordis services the host half injects.
*
* MUST stay empty: the host half uses `ctx.logger` only via optional-chaining
* (`log?.info?.()` inside try/catch) — it is a soft convenience, not a hard
* dependency. Declaring it in `inject` would make the entry wait on a
* `logger` service that no DSH host provider registers, leaving the entry
* `pending` forever and failing the plugin tree load (recovery mode).
* Compare dsh-better-sidebar, whose inject list is services the host
* actually provides (`webServer`/`sessions`/`webRuntime`/`tools`).
*/
export const inject = [] as const
/**
* The cordis effect entry: runs once per activation on the Node half.
+5 -1
View File
@@ -29,7 +29,11 @@ describe('apes-sidebar host plugin shape', () => {
expect('default' in host).toBe(false)
expect(typeof host.apply).toBe('function')
expect(host.name).toBe('apes-sidebar')
expect(host.inject).toEqual(['logger'])
// inject MUST be empty: `logger` is used only via optional-chaining in
// apply(ctx) — declaring it as an injected service would make the entry
// wait on a provider DSH host does not register, blocking activation
// (recovery mode). See src/index.ts comment.
expect(host.inject).toEqual([])
})
it('apply mounts a logger line through the effect (Phase 0 minimal)', () => {