skillhub/cli/test/fixtures/toggle-crash-child.ts
XiaoSeS 6c276d38fc
Some checks are pending
Security / Dependency Review (push) Waiting to run
Security / CodeQL (java-kotlin) (push) Waiting to run
Security / CodeQL (javascript-typescript) (push) Waiting to run
Security / CodeQL (python) (push) Waiting to run
fix(dsh): preserve legacy compatibility and Windows lifecycle safety (#1033)
保持共享库存 v2 与旧版可读普通日志,从真实入口派生启停;隔离扩展日志并保护恢复时的合法后续写入。修复 Windows 库存/日志原子替换及目标锁的短时共享冲突,不删除原数据、不抢占活锁、不重放事务。

补充安全探针诊断与仅公共下载内容的 CI 缓存,Profile 和安装状态仍逐次隔离。准备 CLI 0.3.0 / DSH 0.6.0,npm 发布另行执行。

最终提交的 CLI 三平台、DSH 14 项矩阵及 12 份启停场景摘要均通过。Windows 新 RC 依赖准备仍接近限额,作为 CI 准备稳定性风险保留。

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-29 21:08:14 +08:00

26 lines
1.6 KiB
TypeScript

import { writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import { InventoryStore } from '../../src/stores/inventory-store'
import { OperationStore } from '../../src/integrations/operation-store'
import { inspectToggle, executeNativeToggle } from '../../src/integrations/native-toggle'
const [home, operationId, boundary, readyFile] = process.argv.slice(2)
if (!home || !operationId || !readyFile || !['intent', 'linked', 'moved', 'restore-linked', 'committed'].includes(boundary!)) throw new Error('Invalid fixture arguments')
const inventory = new InventoryStore(home)
const operations = await OperationStore.open(join(home, 'operations'))
const baseline = await inspectToggle(inventory, { registry: 'https://registry.example', namespace: 'demo', slug: 'writer', version: '1.0.0' },
{ root: join(home, 'skills'), scope: 'user' }, 'disabled')
if (baseline.status !== 'ready') throw new Error('Fixture baseline unavailable')
const append = operations.recordToggle.bind(operations)
operations.recordToggle = async (...args) => {
if (boundary === 'restore-linked' && args[3].stage === 'committed') throw new Error('Injected commit rejection')
const saved = await append(...args)
if (args[3].stage === boundary) {
await writeFile(readyFile!, boundary, { flag: 'wx' })
// The parent force-terminates this owned process using the native platform API.
await new Promise(() => { setInterval(() => {}, 1000) })
}
return saved
}
await executeNativeToggle(operations, inventory, { operationId, ownerId: 'owner', baseline, authorize: async () => {} })
throw new Error('Crash boundary was not reached')