@twinsearth/ai-prison-dsh-plugin 1.4.6 → 1.4.7

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 CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to `@twinsearth/ai-prison-dsh-plugin` are recorded here.
4
4
 
5
+ ## [1.4.7] — 2026-11-18
6
+
7
+ ### Added — panel/remote operations roll back while paused or frozen
8
+
9
+ - The 5 GB freeze (and the 3.9 GB pause without a confirmation) now also covers
10
+ operations started from the panel or the web UI, not just the agent tool:
11
+ after an additive operation settles, the watchdog immediately disables that
12
+ bundle and records a `freeze-rollback` / `pause-rollback` incident. Release
13
+ operations (disable/remove) and a confirmed pause grace window stay allowed.
14
+ - The panel's "Measure plugin budgets now" button is disabled while frozen,
15
+ because each probe spawns a child process.
16
+
17
+ ### Fixed — tamper monitor no longer flags the manager's own writes
18
+
19
+ - The operation-window suppression was ±5 s around settle, but pnpm may write
20
+ package.json / pnpm-lock.yaml later than that, so installs of 1.4.5/1.4.6 were
21
+ repeatedly "restored" by the tamper monitor and some installs failed.
22
+ - Any drift within 120 s after the last plugin operation is now treated as a
23
+ manager write; the mtime window still applies to older operations. Real
24
+ out-of-window edits (manual scripts) are still detected and restored.
25
+
26
+ ### Tests
27
+ - New `test/watchdog-freeze.test.mjs`: freeze rollback, pause rollback with and
28
+ without grace, and release-class operations never rolled back.
29
+
30
+ ## [1.4.6] — 2026-11-18
5
31
  ## [1.4.6] — 2026-11-18
6
32
 
7
33
  ### Added — structured reason / impact / steps / release text
package/client.js CHANGED
@@ -475,7 +475,7 @@ window.__ModuleLoader__.load({
475
475
  watchdog.baseline ? h('p', { style: { ...C.muted, fontSize: 11.5, margin: '10px 0 0' } }, t('watchdog.baseline', { at: watchdog.baseline.at })) : null,
476
476
  watchdog.tamper ? h('p', { style: { ...C.muted, fontSize: 11.5, margin: '6px 0 0' } }, t('watchdog.tamper', { n: (watchdog.tamper.files || []).length, at: watchdog.tamper.lastCheckAt || '—' })) : null,
477
477
  h('div', { style: { marginTop: 10, display: 'flex', gap: 8, alignItems: 'center', flexWrap: 'wrap' } },
478
- h('button', { style: { ...button, padding: '5px 10px' }, onClick: () => act('probe') }, t('watchdog.measure')),
478
+ h('button', { style: { ...button, padding: '5px 10px', opacity: frozen ? 0.5 : 1 }, disabled: frozen, title: frozen ? t('watchdog.measureBlocked') : undefined, onClick: () => { if (!frozen) act('probe') } }, t('watchdog.measure')),
479
479
  watchdog.probeProgress ? h('span', { style: { ...C.mono, fontSize: 11.5 } }, `${watchdog.probeProgress.done || 0}/${watchdog.probeProgress.total || 0}`) : null,
480
480
  ),
481
481
  )
@@ -138,6 +138,7 @@ export function createWatchdog(ctx, config = {}, logger = {}) {
138
138
 
139
139
  let lastFlush = 0
140
140
  let operationWindowUntil = 0
141
+ let lastOperationAt = 0
141
142
  const operationWindows = []
142
143
  let tamperMigrationDone = false
143
144
  let tamper = null
@@ -157,7 +158,7 @@ export function createWatchdog(ctx, config = {}, logger = {}) {
157
158
  policy: config.tamperPolicy === 'alert' ? 'alert' : 'restore',
158
159
  graceMs: Number(config.tamperGraceMs) >= 0 ? Number(config.tamperGraceMs) : 15_000,
159
160
  intervalMs: Number(config.tamperIntervalMs) > 0 ? Number(config.tamperIntervalMs) : 30_000,
160
- shouldIgnore: () => Date.now() < operationWindowUntil,
161
+ shouldIgnore: () => Date.now() < operationWindowUntil || Date.now() - lastOperationAt < 120000,
161
162
  isWithinOperationWindow: (mtimeMs) => {
162
163
  const now = Date.now()
163
164
  return operationWindows.some((window) => mtimeMs >= window.startedAt - 5000 && mtimeMs <= (window.settledAt || now) + 5000)
@@ -396,6 +397,7 @@ export function createWatchdog(ctx, config = {}, logger = {}) {
396
397
  const entry = watchdogState.operations.get(target) || { count: 0, estimateMB: 0, lastAt: null, version: operation.version || null, lastApplication: null }
397
398
  if (operation.phase === 'started') {
398
399
  operationWindowUntil = Date.now() + 4000
400
+ lastOperationAt = Date.now()
399
401
  operationWindows.push({ startedAt: Date.now(), settledAt: null })
400
402
  if (operationWindows.length > 20) operationWindows.shift()
401
403
  inflight.set(operation.id, { target, heapBefore: watchdogState.latest ? watchdogState.latest.heapUsed : 0 })
@@ -405,6 +407,7 @@ export function createWatchdog(ctx, config = {}, logger = {}) {
405
407
  }
406
408
  if (operation.phase !== 'settled') return
407
409
  operationWindowUntil = Date.now() + 4000
410
+ lastOperationAt = Date.now()
408
411
  for (let i = operationWindows.length - 1; i >= 0; i -= 1) {
409
412
  if (operationWindows[i].settledAt === null) { operationWindows[i].settledAt = Date.now(); break }
410
413
  }
@@ -422,6 +425,24 @@ export function createWatchdog(ctx, config = {}, logger = {}) {
422
425
  entry.version = operation.version || entry.version
423
426
  entry.lastApplication = operation.application || null
424
427
  watchdogState.operations.set(target, entry)
428
+ const additive = operation.stage === 'install' || (operation.stage === 'enable' && operation.enabled !== false)
429
+ if (
430
+ watchdogState.enforce &&
431
+ additive &&
432
+ target &&
433
+ !EXEMPT_TARGETS.has(target) &&
434
+ (watchdogState.waterline === 'frost' || watchdogState.waterline === 'pause') &&
435
+ !(Number.isFinite(watchdogState.graceUntil) && Date.now() < watchdogState.graceUntil)
436
+ ) {
437
+ const level = watchdogState.waterline
438
+ appendIncident({
439
+ kind: level === 'frost' ? 'freeze-rollback' : 'pause-rollback',
440
+ target,
441
+ level,
442
+ detail: (level === 'frost' ? '冻结' : '暂停') + '期间检测到面板/网页发起的增内存操作,已立即回滚关闭 ' + target,
443
+ })
444
+ void disableTarget(target, level + '-rollback')
445
+ }
425
446
  if (operation.reason === 'remove' && operation.application === 'applied') {
426
447
  watchdogState.operations.delete(target)
427
448
  return
package/locale/en.json CHANGED
@@ -18,5 +18,6 @@
18
18
  "watchdog.noPlans": "No crash attribution plans.",
19
19
  "watchdog.baseline": "Clean baseline: {at}",
20
20
  "watchdog.tamper": "Profile watch: {n} critical file(s), last check {at}",
21
- "watchdog.measure": "Measure plugin budgets now"
21
+ "watchdog.measure": "Measure plugin budgets now",
22
+ "watchdog.measureBlocked": "Heap is frozen: measuring spawns child processes, so it stays disabled until the heap recovers."
22
23
  }
package/locale/zh.json CHANGED
@@ -18,5 +18,6 @@
18
18
  "watchdog.noPlans": "暂无崩溃归因计划。",
19
19
  "watchdog.baseline": "干净基线:{at}",
20
20
  "watchdog.tamper": "配置监控:{n} 个关键文件,最近检查 {at}",
21
- "watchdog.measure": "立即测量插件预算"
21
+ "watchdog.measure": "立即测量插件预算",
22
+ "watchdog.measureBlocked": "堆已冻结:测量会启动子进程,恢复前暂停测量。"
22
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/ai-prison-dsh-plugin",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "AI Prison for DSH: six governance tools wrapping the aiprison CLI (levels, demo, drill, inspect, verify, repair-tail) plus a panel for the L0–L5 matrix and the audit-chain state. The CLI ships bundled for Windows, macOS and Linux; every capability-removal backend stays simulated.",
5
5
  "type": "module",
6
6
  "main": "index.js",