@twinsearth/ai-prison-dsh-plugin 1.2.1 → 1.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.
@@ -1,11 +1,15 @@
1
1
  /**
2
- * Shared in-process state of the AI Prison watchdog. The watchdog loader row
3
- * writes it; the panel tool and the HTTP route read it. Same package, same Node
4
- * process, so one module instance is enough (no service plumbing needed).
2
+ * Shared in-process state of the AI Prison watchdog.
3
+ *
4
+ * P0 wrote it in observe mode; P1 keeps the same shape and adds the enforcement
5
+ * registries (quarantine, pause grace, hot-operation counters, budget table,
6
+ * baseline, crash plans). Nothing here touches the plugin manager by itself.
5
7
  */
6
8
  export const watchdogState = {
7
- mode: 'observe',
9
+ mode: 'enforce',
10
+ enforce: true,
8
11
  startedAt: null,
12
+ runId: null,
9
13
  dataDir: null,
10
14
  config: {},
11
15
  /** Latest metrics sample. */
@@ -14,8 +18,24 @@ export const watchdogState = {
14
18
  samples: [],
15
19
  thresholds: null,
16
20
  waterline: 'ok',
21
+ strongWarn: false,
22
+ pausedAt: null,
23
+ graceUntil: null,
24
+ frozenAt: null,
17
25
  /** target -> { count, estimateMB, lastAt, version, lastApplication } */
18
26
  operations: new Map(),
27
+ /** target -> { reason, level, at, evidence, release: 'restart'|'manual' } */
28
+ quarantine: new Map(),
29
+ /** target -> ms timestamp until which operation events are our own doing. */
30
+ suppressUntil: new Map(),
31
+ /** name@version -> measured/estimated startup MB (budget probe feeds this in P2). */
32
+ budgets: {},
33
+ /** Last clean baseline: { at, runId, bundles: [{name, version, enabled}], files } */
34
+ baseline: null,
35
+ /** Crash attribution plans (dry-run): { at, level, target, evidence, applied } */
36
+ plans: [],
37
+ /** Escalation counters: crash timestamps (ms) and applied level. */
38
+ escalation: { crashes: [], level: 'L0' },
19
39
  /** Recent incidents (newest last), capped. */
20
40
  incidents: [],
21
41
  /** Last crash-log scan marker (ms). */
@@ -28,15 +48,27 @@ export const MAX_SAMPLES = 120
28
48
  export const MAX_INCIDENTS = 200
29
49
 
30
50
  export function resetWatchdogState(overrides = {}) {
31
- watchdogState.mode = 'observe'
51
+ watchdogState.mode = 'enforce'
52
+ watchdogState.enforce = true
32
53
  watchdogState.startedAt = null
54
+ watchdogState.runId = null
33
55
  watchdogState.dataDir = null
34
56
  watchdogState.config = {}
35
57
  watchdogState.latest = null
36
58
  watchdogState.samples = []
37
59
  watchdogState.thresholds = null
38
60
  watchdogState.waterline = 'ok'
61
+ watchdogState.strongWarn = false
62
+ watchdogState.pausedAt = null
63
+ watchdogState.graceUntil = null
64
+ watchdogState.frozenAt = null
39
65
  watchdogState.operations = new Map()
66
+ watchdogState.quarantine = new Map()
67
+ watchdogState.suppressUntil = new Map()
68
+ watchdogState.budgets = {}
69
+ watchdogState.baseline = null
70
+ watchdogState.plans = []
71
+ watchdogState.escalation = { crashes: [], level: 'L0' }
40
72
  watchdogState.incidents = []
41
73
  watchdogState.lastCrashScan = 0
42
74
  watchdogState.degraded = null
package/locale/en.json CHANGED
@@ -3,5 +3,18 @@
3
3
  "title": "AI Prison",
4
4
  "description": "Wraps the aiprison CLI as six DSH tools (levels, status, demo, drill, inspect, verify, repair-tail) and adds a sidebar panel showing the L0–L5 grading matrix together with the durable ledger's audit-chain integrity and record count. Open it from the sidebar's shield entry; the panel is read-only and never writes to the ledger. Ledgers live in <session working directory>/.ai-prison unless a data directory is configured. Every capability-removal backend (GRAM, TLM, hardware binding, MicroVM isolation) stays simulated, so the tools audit and demonstrate governance instead of enforcing real isolation.",
5
5
  "detail": "docs/DETAIL.md"
6
- }
6
+ },
7
+ "watchdog.enforceTitle": "Enforcement",
8
+ "watchdog.enforceOn": "enforce",
9
+ "watchdog.observeOnly": "observe only",
10
+ "watchdog.freezeHint": "Heap is frozen at {level}: plugin operations are blocked except release actions. Close the biggest plugins below or restart DSH.",
11
+ "watchdog.confirmPause": "I understand: allow plugin operations for 10 minutes",
12
+ "watchdog.quarantine": "Plugin prison",
13
+ "watchdog.noQuarantine": "No quarantined plugins.",
14
+ "watchdog.release": "Release",
15
+ "watchdog.topFive": "Top {n} by estimated heap",
16
+ "watchdog.close": "Close now",
17
+ "watchdog.plans": "Crash plans (dry-run)",
18
+ "watchdog.noPlans": "No crash attribution plans.",
19
+ "watchdog.baseline": "Clean baseline: {at}"
7
20
  }
package/locale/zh.json CHANGED
@@ -3,5 +3,18 @@
3
3
  "title": "AI Prison · AI 监狱",
4
4
  "description": "把 aiprison CLI 封装为六个 DSH 工具(levels、status、demo、drill、inspect、verify、repair-tail),并在侧边栏增加一个面板:展示 L0–L5 分级矩阵,以及落盘账本的审计链完整性与记录数。从侧边栏的盾牌入口打开;面板只读,不会写入数据目录。账本默认写到 <会话工作目录>/.ai-prison,也可在配置里指定数据目录。GRAM、TLM、硬件绑定、MicroVM 隔离等能力摘除后端全部为内存模拟 —— 这些工具用于审计与演示治理流程,并不执行真实隔离。",
5
5
  "detail": "docs/DETAIL.zh.md"
6
- }
6
+ },
7
+ "watchdog.enforceTitle": "执行状态",
8
+ "watchdog.enforceOn": "enforce",
9
+ "watchdog.observeOnly": "仅观察",
10
+ "watchdog.freezeHint": "堆水位已冻结({level}):除释放类操作外,所有插件操作被禁止。请关闭下方内存最大的插件或重启 DSH。",
11
+ "watchdog.confirmPause": "我已知晓:允许插件操作 10 分钟",
12
+ "watchdog.quarantine": "插件监狱",
13
+ "watchdog.noQuarantine": "没有被隔离的插件。",
14
+ "watchdog.release": "假释",
15
+ "watchdog.topFive": "按估算内存排序的前 {n} 个插件",
16
+ "watchdog.close": "立即关闭",
17
+ "watchdog.plans": "崩溃降级计划(dry-run)",
18
+ "watchdog.noPlans": "暂无崩溃归因计划。",
19
+ "watchdog.baseline": "干净基线:{at}"
7
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/ai-prison-dsh-plugin",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
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",