create-principles-disciple 1.147.4 → 1.147.6

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.
Files changed (177) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/package.json +1 -1
  3. package/console/dist/server/models/HealthCheckModel.d.ts +0 -1
  4. package/console/dist/server/models/HealthCheckModel.js +0 -54
  5. package/console/dist/server/routes/update.js +5 -8
  6. package/console/dist/server/types/index.d.ts +1 -9
  7. package/console/dist/web/assets/app.js +18 -18
  8. package/core/dist/index.d.ts +1 -1
  9. package/core/dist/index.d.ts.map +1 -1
  10. package/core/dist/index.js +1 -1
  11. package/core/dist/index.js.map +1 -1
  12. package/core/dist/prompt-builder/index.d.ts +0 -1
  13. package/core/dist/prompt-builder/index.d.ts.map +1 -1
  14. package/core/dist/prompt-builder/index.js +0 -1
  15. package/core/dist/prompt-builder/index.js.map +1 -1
  16. package/core/dist/runtime-v2/adapter/output-schema-registry.js +2 -2
  17. package/core/dist/runtime-v2/control-plane-triage.d.ts +1 -1
  18. package/core/dist/runtime-v2/control-plane-triage.d.ts.map +1 -1
  19. package/core/dist/runtime-v2/control-plane-triage.js +0 -15
  20. package/core/dist/runtime-v2/control-plane-triage.js.map +1 -1
  21. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts +3 -6
  22. package/core/dist/runtime-v2/evidence-triage/observation-resolver.d.ts.map +1 -1
  23. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js +5 -10
  24. package/core/dist/runtime-v2/evidence-triage/observation-resolver.js.map +1 -1
  25. package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts +2 -1
  26. package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts.map +1 -1
  27. package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +3 -8
  28. package/core/dist/runtime-v2/evidence-triage/source-descriptors.js.map +1 -1
  29. package/core/dist/runtime-v2/evidence-triage/types.d.ts +1 -1
  30. package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -1
  31. package/core/dist/runtime-v2/evidence-triage/types.js +0 -1
  32. package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -1
  33. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
  34. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +4 -1
  35. package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
  36. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  37. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js +3 -8
  38. package/core/dist/runtime-v2/feature-flags/feature-flag-lifecycle.js.map +1 -1
  39. package/core/dist/runtime-v2/golden-trace.d.ts.map +1 -1
  40. package/core/dist/runtime-v2/golden-trace.js +0 -1
  41. package/core/dist/runtime-v2/golden-trace.js.map +1 -1
  42. package/core/dist/runtime-v2/index.d.ts +5 -9
  43. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  44. package/core/dist/runtime-v2/index.js +4 -8
  45. package/core/dist/runtime-v2/index.js.map +1 -1
  46. package/core/dist/runtime-v2/internalization/rule-host-contracts.d.ts +0 -1
  47. package/core/dist/runtime-v2/internalization/rule-host-contracts.d.ts.map +1 -1
  48. package/core/dist/runtime-v2/operator-health-read-model.d.ts +0 -2
  49. package/core/dist/runtime-v2/operator-health-read-model.d.ts.map +1 -1
  50. package/core/dist/runtime-v2/operator-health-read-model.js +1 -55
  51. package/core/dist/runtime-v2/operator-health-read-model.js.map +1 -1
  52. package/core/dist/runtime-v2/signal-collector/confidence-gate.d.ts +1 -5
  53. package/core/dist/runtime-v2/signal-collector/confidence-gate.d.ts.map +1 -1
  54. package/core/dist/runtime-v2/signal-collector/confidence-gate.js +0 -9
  55. package/core/dist/runtime-v2/signal-collector/confidence-gate.js.map +1 -1
  56. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts +2 -2
  57. package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts.map +1 -1
  58. package/core/dist/runtime-v2/signal-collector/keyword-stage.js +6 -10
  59. package/core/dist/runtime-v2/signal-collector/keyword-stage.js.map +1 -1
  60. package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts +1 -1
  61. package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts.map +1 -1
  62. package/core/dist/runtime-v2/signal-collector/llm-stage.js +3 -4
  63. package/core/dist/runtime-v2/signal-collector/llm-stage.js.map +1 -1
  64. package/core/dist/runtime-v2/signal-collector/signal-collector.js +4 -4
  65. package/core/dist/runtime-v2/signal-collector/signal-collector.js.map +1 -1
  66. package/core/dist/runtime-v2/signal-collector/types.d.ts +6 -8
  67. package/core/dist/runtime-v2/signal-collector/types.d.ts.map +1 -1
  68. package/core/dist/runtime-v2/signal-collector/types.js +6 -6
  69. package/core/dist/runtime-v2/signal-collector/types.js.map +1 -1
  70. package/core/dist/runtime-v2/trajectory-schema.d.ts +24 -4
  71. package/core/dist/runtime-v2/trajectory-schema.d.ts.map +1 -1
  72. package/core/dist/runtime-v2/trajectory-schema.js +58 -2
  73. package/core/dist/runtime-v2/trajectory-schema.js.map +1 -1
  74. package/core/dist/runtime-v2/types/event-types.d.ts +0 -35
  75. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  76. package/core/dist/runtime-v2/types/event-types.js +0 -19
  77. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  78. package/core/dist/runtime-v2/types/index.d.ts +2 -2
  79. package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
  80. package/core/dist/runtime-v2/types/index.js +1 -1
  81. package/core/dist/runtime-v2/types/index.js.map +1 -1
  82. package/core/dist/trajectory-types.d.ts +0 -2
  83. package/core/dist/trajectory-types.d.ts.map +1 -1
  84. package/core/package.json +1 -1
  85. package/dist/i18n.d.ts.map +1 -1
  86. package/dist/i18n.js +6 -0
  87. package/dist/i18n.js.map +1 -1
  88. package/dist/installer.d.ts +21 -0
  89. package/dist/installer.d.ts.map +1 -1
  90. package/dist/installer.js +80 -3
  91. package/dist/installer.js.map +1 -1
  92. package/dist/mvp-config.d.ts +2 -2
  93. package/dist/mvp-config.d.ts.map +1 -1
  94. package/dist/mvp-config.js +4 -2
  95. package/dist/mvp-config.js.map +1 -1
  96. package/host-runtime/dist/governance-signal-admission.d.ts +0 -2
  97. package/host-runtime/dist/governance-signal-admission.js +14 -15
  98. package/host-runtime/dist/production-pain-evidence.d.ts +1 -1
  99. package/host-runtime/dist/production-pain-evidence.js +42 -7
  100. package/host-runtime/dist/production-rulehost-gate.d.ts +0 -1
  101. package/host-runtime/dist/production-rulehost-gate.js +3 -4
  102. package/host-runtime/dist/signal-classifier.d.ts +8 -0
  103. package/host-runtime/dist/signal-classifier.js +10 -2
  104. package/host-runtime/package.json +1 -1
  105. package/package.json +3 -3
  106. package/pd-cli/dist/commands/pain-evidence.d.ts +2 -4
  107. package/pd-cli/dist/commands/pain-evidence.d.ts.map +1 -1
  108. package/pd-cli/dist/commands/pain-evidence.js +2 -4
  109. package/pd-cli/dist/commands/pain-evidence.js.map +1 -1
  110. package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
  111. package/pd-cli/dist/commands/runtime-canary.js +2 -68
  112. package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
  113. package/pd-cli/dist/commands/runtime-diagnostics-export.d.ts.map +1 -1
  114. package/pd-cli/dist/commands/runtime-diagnostics-export.js +1 -25
  115. package/pd-cli/dist/commands/runtime-diagnostics-export.js.map +1 -1
  116. package/pd-cli/dist/commands/runtime-health-snapshot.d.ts.map +1 -1
  117. package/pd-cli/dist/commands/runtime-health-snapshot.js +0 -9
  118. package/pd-cli/dist/commands/runtime-health-snapshot.js.map +1 -1
  119. package/pd-cli/dist/index.js +0 -9
  120. package/pd-cli/dist/index.js.map +1 -1
  121. package/pd-mcp-server/dist/version.d.ts +1 -1
  122. package/pd-mcp-server/dist/version.js +1 -1
  123. package/pd-mcp-server/package.json +1 -1
  124. package/plugin/dist/bundle.js +492 -481
  125. package/plugin/dist/config/defaults/runtime.d.ts +0 -4
  126. package/plugin/dist/core/config.d.ts +0 -35
  127. package/plugin/dist/core/pain.d.ts +0 -1
  128. package/plugin/dist/core/session-tracker.d.ts +3 -51
  129. package/plugin/dist/core/signal-collector-host.d.ts +5 -13
  130. package/plugin/dist/core/signal-keyword-store.d.ts +2 -2
  131. package/plugin/dist/core/trajectory.d.ts +0 -2
  132. package/plugin/dist/governance-audit.js +2 -2
  133. package/plugin/dist/hooks/after-tool-call-helpers.d.ts +5 -12
  134. package/plugin/dist/hooks/after-tool-call-types.d.ts +0 -2
  135. package/plugin/dist/hooks/gate-block-helper.d.ts +1 -1
  136. package/plugin/dist/hooks/gate.d.ts +3 -4
  137. package/plugin/dist/hooks/pain.d.ts +4 -4
  138. package/plugin/dist/openclaw.plugin.json +1 -1
  139. package/plugin/dist/rulehost-evidence.js +45 -45
  140. package/plugin/dist/templates/pain_settings.json +0 -46
  141. package/plugin/dist/types/event-types.d.ts +1 -1
  142. package/plugin/openclaw.plugin.json +1 -1
  143. package/plugin/package.json +1 -1
  144. package/plugin/templates/pain_settings.json +0 -46
  145. package/release-manager/dist/i18n.js +6 -0
  146. package/release-manager/dist/installer.js +80 -3
  147. package/release-manager/dist/mvp-config.js +4 -2
  148. package/release-manager/package.json +1 -1
  149. package/workbuddy-adapter/package.json +1 -1
  150. package/core/dist/prompt-builder/attitude-directive.d.ts +0 -7
  151. package/core/dist/prompt-builder/attitude-directive.d.ts.map +0 -1
  152. package/core/dist/prompt-builder/attitude-directive.js +0 -39
  153. package/core/dist/prompt-builder/attitude-directive.js.map +0 -1
  154. package/core/dist/runtime-v2/gfi/gfi-kernel.d.ts +0 -12
  155. package/core/dist/runtime-v2/gfi/gfi-kernel.d.ts.map +0 -1
  156. package/core/dist/runtime-v2/gfi/gfi-kernel.js +0 -148
  157. package/core/dist/runtime-v2/gfi/gfi-kernel.js.map +0 -1
  158. package/core/dist/runtime-v2/gfi/gfi-policy.d.ts +0 -3
  159. package/core/dist/runtime-v2/gfi/gfi-policy.d.ts.map +0 -1
  160. package/core/dist/runtime-v2/gfi/gfi-policy.js +0 -23
  161. package/core/dist/runtime-v2/gfi/gfi-policy.js.map +0 -1
  162. package/core/dist/runtime-v2/gfi/gfi-read-model.d.ts +0 -78
  163. package/core/dist/runtime-v2/gfi/gfi-read-model.d.ts.map +0 -1
  164. package/core/dist/runtime-v2/gfi/gfi-read-model.js +0 -129
  165. package/core/dist/runtime-v2/gfi/gfi-read-model.js.map +0 -1
  166. package/core/dist/runtime-v2/gfi/gfi-types.d.ts +0 -70
  167. package/core/dist/runtime-v2/gfi/gfi-types.d.ts.map +0 -1
  168. package/core/dist/runtime-v2/gfi/gfi-types.js +0 -2
  169. package/core/dist/runtime-v2/gfi/gfi-types.js.map +0 -1
  170. package/core/dist/runtime-v2/gfi/index.d.ts +0 -6
  171. package/core/dist/runtime-v2/gfi/index.d.ts.map +0 -1
  172. package/core/dist/runtime-v2/gfi/index.js +0 -4
  173. package/core/dist/runtime-v2/gfi/index.js.map +0 -1
  174. package/pd-cli/dist/commands/runtime-gfi-snapshot.d.ts +0 -7
  175. package/pd-cli/dist/commands/runtime-gfi-snapshot.d.ts.map +0 -1
  176. package/pd-cli/dist/commands/runtime-gfi-snapshot.js +0 -101
  177. package/pd-cli/dist/commands/runtime-gfi-snapshot.js.map +0 -1
@@ -1,2 +1,2 @@
1
- export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RulePromotionEventData, GovernanceActionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimeV2PromptActivationsInjectedEventData, RuleHostUnhealthyEventData, RuleHostSkippedEventData, TrajectoryObservabilityFailureEventData, ToolCallStats, ErrorStats, EmpathyEventStats, GfiStats, HookStats, DailyStats, } from '@principles/core/runtime-v2';
1
+ export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RulePromotionEventData, GovernanceActionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimeV2PromptActivationsInjectedEventData, RuleHostUnhealthyEventData, RuleHostSkippedEventData, TrajectoryObservabilityFailureEventData, ToolCallStats, ErrorStats, EmpathyEventStats, HookStats, DailyStats, } from '@principles/core/runtime-v2';
2
2
  export { createEmptyDailyStats, } from '@principles/core/runtime-v2/types/event-types';
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
- "version": "2.5.0",
5
+ "version": "2.6.0",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "language": "zh",
3
3
  "thresholds": {
4
- "pain_trigger": 40,
5
4
  "cognitive_paralysis_input": 4000,
6
5
  "semantic_min_score": 0.7,
7
6
  "promotion_count_threshold": 3,
@@ -10,18 +9,12 @@
10
9
  "scores": {
11
10
  "default_confusion": 30,
12
11
  "default_loop": 40,
13
- "tool_failure_friction": 15,
14
12
  "exit_code_penalty": 50,
15
13
  "spiral_penalty": 30,
16
14
  "missing_test_command_penalty": 20,
17
15
  "subagent_error_penalty": 60,
18
16
  "subagent_timeout_penalty": 50
19
17
  },
20
- "severity_thresholds": {
21
- "high": 70,
22
- "medium": 40,
23
- "low": 20
24
- },
25
18
  "trust": {
26
19
  "stages": {
27
20
  "stage_1_observer": 30,
@@ -52,44 +45,5 @@
52
45
  "stage_2_max_lines": 50,
53
46
  "stage_3_max_lines": 300
54
47
  }
55
- },
56
- "empathy_engine": {
57
- "enabled": true,
58
- "dedupe_window_ms": 60000,
59
- "penalties": {
60
- "mild": 10,
61
- "moderate": 25,
62
- "severe": 40
63
- },
64
- "rate_limit": {
65
- "max_per_turn": 40,
66
- "max_per_hour": 120
67
- },
68
- "model_calibration": {}
69
- },
70
- "gfi_gate": {
71
- "enabled": true,
72
- "thresholds": {
73
- "low_risk_block": 70,
74
- "high_risk_block": 40,
75
- "large_change_block": 50
76
- },
77
- "large_change_lines": 50,
78
- "bash_safe_patterns": [
79
- "^(ls|dir|pwd|which|where|echo|env|cat|type|head|tail|less|more)\\b",
80
- "^git\\s+(status|log|diff|branch|show|remote)\\b",
81
- "^npm\\s+(run|test|build|start)\\b",
82
- "^(make|gradle|mvn)\\b"
83
- ],
84
- "bash_dangerous_patterns": [
85
- "rm\\s+(-[a-z]*r[a-z]*f|-rf)",
86
- "del\\s+/s",
87
- "rmdir\\s+/s",
88
- "git\\s+(push\\s+.*--force|reset\\s+--hard|clean\\s+-fd)",
89
- "npm\\s+publish",
90
- "pip\\s+upload",
91
- "docker\\s+push",
92
- "(curl|wget).*\\|\\s*(ba)?sh"
93
- ]
94
48
  }
95
49
  }
@@ -105,10 +105,14 @@ const translations = {
105
105
  // Install failure / rollback result strings (catch block). EP-11.
106
106
  rollback_no_changes: 'No changes were made — the existing install was not modified (no backup was created).',
107
107
  rollback_restored: 'Previous install has been restored.',
108
+ // PRI-1102: the rollback target itself can be incomplete — say so instead
109
+ // of reporting a restore that leaves the operator with a broken install.
110
+ rollback_restored_incomplete: 'Rolled back to the state that existed before this run, but that state is NOT usable — incomplete: {paths}.',
108
111
  rollback_failed: 'CRITICAL: Rollback also failed — installation state is uncertain. {restoreError} Resolve manually: check {extDir} and {backupDir}',
109
112
  next_no_changes_lock: 'A file lock blocked the backup (EPERM). Stop the OpenClaw gateway (openclaw gateway stop, or re-run with --stop-gateway) and retry.',
110
113
  next_no_changes_other: 'Fix the error above and re-run the installer. The existing install was not modified.',
111
114
  next_restored: 'Check the error above. Previous install has been restored. Fix the issue and re-run the installer.',
115
+ next_restored_incomplete: 'Check the error above. Rollback returned the pre-run state, but it is incomplete: {paths}. Re-run the installer so the missing components are rebuilt.',
112
116
  next_restore_failed: 'Installation and rollback both failed. Check {extDir} and {backupDir} manually. Error: {errorMsg}',
113
117
  // CP-6: fresh-install failure mid-deployment (no pre-existing install → no backup).
114
118
  rollback_fresh_cleaned: 'The install failed before activation — the partially deployed runtime files were removed. Nothing else was modified.',
@@ -225,10 +229,12 @@ const translations = {
225
229
  // 安装失败 / 回滚结果字符串(catch 块)。EP-11。
226
230
  rollback_no_changes: '未做任何改动 —— 现有安装未被修改(未创建备份)。',
227
231
  rollback_restored: '已恢复到之前的安装。',
232
+ rollback_restored_incomplete: '已回滚到本次运行之前的状态,但该状态本身不可用 —— 不完整:{paths}。',
228
233
  rollback_failed: '严重:回滚也失败了 —— 安装状态不确定。{restoreError} 请手动处理:检查 {extDir} 和 {backupDir}',
229
234
  next_no_changes_lock: '文件锁阻塞了备份 (EPERM)。请停止 OpenClaw gateway(openclaw gateway stop,或用 --stop-gateway 重新运行)后重试。',
230
235
  next_no_changes_other: '请修复上方错误后重新运行安装器。现有安装未被修改。',
231
236
  next_restored: '请检查上方错误。已恢复到之前的安装。修复问题后重新运行安装器。',
237
+ next_restored_incomplete: '请检查上方错误。回滚返回的是本次运行之前的状态,但该状态不完整:{paths}。请重新运行安装器,让它重建缺失的组件。',
232
238
  next_restore_failed: '安装与回滚均失败。请手动检查 {extDir} 和 {backupDir}。错误:{errorMsg}',
233
239
  // CP-6:全新安装部署中途失败(无既有安装 → 无备份)。
234
240
  rollback_fresh_cleaned: '安装未激活即失败 —— 已移除本次部署的部分运行时文件。其余内容未被修改。',
@@ -1553,10 +1553,79 @@ export async function checkBuiltPlugin(pluginDir) {
1553
1553
  }
1554
1554
  }
1555
1555
  }
1556
+ /**
1557
+ * PRI-1102: a target that exists as a DANGLING link (an interrupted install
1558
+ * left a reparse point whose target is gone) is not a directory the installer
1559
+ * can copy into. `existsSync` follows the link and reports "missing", so the
1560
+ * backup step never moves it, and `ensureDir` then treats it as present —
1561
+ * the follow-up mkdir fails with ENOENT and aborts the whole install.
1562
+ *
1563
+ * Absent targets are created. A dangling link is removed (the link itself only,
1564
+ * never a target), and the caller recreates the real directory. Everything
1565
+ * else — a real directory, or a link that still resolves — is left untouched,
1566
+ * so an existing install is never destroyed by this step.
1567
+ */
1568
+ export async function preparePluginInstallTarget(targetDir) {
1569
+ let stats;
1570
+ try {
1571
+ stats = lstatSync(targetDir, { throwIfNoEntry: false });
1572
+ }
1573
+ catch (error) {
1574
+ throw new Error(`Cannot inspect plugin install target ${targetDir}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
1575
+ }
1576
+ if (stats !== undefined && stats.isSymbolicLink()) {
1577
+ let resolves = true;
1578
+ try {
1579
+ realpathSync(targetDir);
1580
+ }
1581
+ catch {
1582
+ resolves = false;
1583
+ }
1584
+ if (!resolves) {
1585
+ // fs-extra's remove unlinks the reparse point instead of traversing it.
1586
+ await fse.remove(targetDir);
1587
+ logger.warn(`Removed dangling link at ${targetDir} (target missing) — rebuilding the plugin install directory.`);
1588
+ }
1589
+ }
1590
+ await fse.ensureDir(targetDir);
1591
+ }
1592
+ /**
1593
+ * PRI-1102: a rollback is only as good as the state it returns to. The
1594
+ * pre-run state can itself be incomplete (a component directory the previous
1595
+ * run never finished, a link whose target is gone), so "restored" must not be
1596
+ * reported as a healthy install without checking what the restored paths
1597
+ * actually resolve to.
1598
+ */
1599
+ export function describeRestoredStateGaps() {
1600
+ const gaps = [];
1601
+ for (const dir of [getPluginExtDir(), getPdRuntimeDir()]) {
1602
+ let stats;
1603
+ try {
1604
+ stats = lstatSync(dir, { throwIfNoEntry: false });
1605
+ }
1606
+ catch (error) {
1607
+ gaps.push(`${dir} (unreadable: ${error instanceof Error ? error.message : String(error)})`);
1608
+ continue;
1609
+ }
1610
+ if (stats === undefined) {
1611
+ gaps.push(`${dir} (missing)`);
1612
+ continue;
1613
+ }
1614
+ if (stats.isSymbolicLink()) {
1615
+ try {
1616
+ realpathSync(dir);
1617
+ }
1618
+ catch {
1619
+ gaps.push(`${dir} (dangling link)`);
1620
+ }
1621
+ }
1622
+ }
1623
+ return gaps;
1624
+ }
1556
1625
  export async function installPluginToStaging(pluginDir, language) {
1557
1626
  const builtPluginDir = path.join(pluginDir, 'plugin');
1558
1627
  for (const targetDir of pluginInstallDirs()) {
1559
- await fse.ensureDir(targetDir);
1628
+ await preparePluginInstallTarget(targetDir);
1560
1629
  // PRI-1037 payload fix: npm-era payloads carried a ~16k-file node_modules
1561
1630
  // (the whole pi-ai/openai/anthropic tree, dragged in through the plugin's
1562
1631
  // historical file:./core dependency) plus a `core` junction, in BOTH plugin
@@ -4355,6 +4424,10 @@ transaction) {
4355
4424
  // pre-date this run, so it is NOT wholesale-removed. Report its retention
4356
4425
  // honestly instead of claiming "nothing else was modified".
4357
4426
  const workspaceTouched = !hasBackup && mutationStarted && journal?.lastState !== 'planned';
4427
+ // PRI-1102: `restored` describes the rollback operation, not the health of
4428
+ // the state it returned to. Name the gaps so "restored" is never read as
4429
+ // "usable install".
4430
+ const restoredGaps = hasBackup && restoreResult.restored ? describeRestoredStateGaps() : [];
4358
4431
  const rollbackSuffix = !hasBackup
4359
4432
  ? freshCleanup
4360
4433
  ? freshCleanup.failed.length === 0
@@ -4362,7 +4435,9 @@ transaction) {
4362
4435
  : t('rollback_fresh_clean_failed').replace('{dirs}', freshCleanup.failed.map((f) => f.dir).join(', '))
4363
4436
  : t('rollback_no_changes')
4364
4437
  : restoreResult.restored
4365
- ? t('rollback_restored')
4438
+ ? restoredGaps.length === 0
4439
+ ? t('rollback_restored')
4440
+ : t('rollback_restored_incomplete').replace('{paths}', restoredGaps.join(', '))
4366
4441
  : t('rollback_failed')
4367
4442
  .replace('{restoreError}', restoreResult.error ?? '')
4368
4443
  .replace('{extDir}', extDir)
@@ -4379,7 +4454,9 @@ transaction) {
4379
4454
  ? t('next_no_changes_lock')
4380
4455
  : t('next_no_changes_other'))
4381
4456
  : restoreResult.restored
4382
- ? t('next_restored')
4457
+ ? restoredGaps.length === 0
4458
+ ? t('next_restored')
4459
+ : t('next_restored_incomplete').replace('{paths}', restoredGaps.join(', '))
4383
4460
  : t('next_restore_failed')
4384
4461
  .replace('{extDir}', extDir)
4385
4462
  .replace('{backupDir}', backupDir ?? runtimeBackupDir ?? '')
@@ -5,8 +5,10 @@ import { existsSync, readFileSync } from 'fs';
5
5
  import { execSync } from 'child_process';
6
6
  import { errnoCode } from './utils/config-file-io.js';
7
7
  export const MVP_CHANNELS = ['prompt', 'code_tool_hook', 'defer_archive'];
8
- export const MVP_QUIET_FLAGS = ['gfi'];
9
- export const MVP_GONE_FLAGS = ['nocturnal', 'idle_trigger'];
8
+ // GFI retired 2026-11-04 (GFI-COMPLETE-REMOVAL-001): its flag became a `gone`
9
+ // tombstone, so no quiet flag remains.
10
+ export const MVP_QUIET_FLAGS = [];
11
+ export const MVP_GONE_FLAGS = ['gfi', 'nocturnal', 'idle_trigger'];
10
12
  /**
11
13
  * Product-level feedback defaults (PRI-543). The PD 控制台的"意见反馈"收集的是
12
14
  * 使用者对 PD 产品的功能建议 / Bug,接收者是 PD 项目所有者,而非使用者自己。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.147.4",
3
+ "version": "1.147.6",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/workbuddy-adapter",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,7 +0,0 @@
1
- /**
2
- * Dynamic Attitude Matrix based on Global Friction Index (GFI).
3
- *
4
- * Phase: PRI-75 Prompt Injection SDK Migration Phase 1
5
- */
6
- export declare function buildAttitudeDirective(gfi: number): string;
7
- //# sourceMappingURL=attitude-directive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attitude-directive.d.ts","sourceRoot":"","sources":["../../src/prompt-builder/attitude-directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8B1D"}
@@ -1,39 +0,0 @@
1
- /**
2
- * Dynamic Attitude Matrix based on Global Friction Index (GFI).
3
- *
4
- * Phase: PRI-75 Prompt Injection SDK Migration Phase 1
5
- */
6
- export function buildAttitudeDirective(gfi) {
7
- if (gfi >= 70) {
8
- return `
9
- ### 【SYSTEM_MODE: HUMBLE_RECOVERY】
10
- **CURRENT STATUS**: Severe system friction / User frustration detected (GFI: ${gfi.toFixed(0)}).
11
- **BEHAVIORAL OVERRIDE**:
12
- - You have failed to meet expectations. Humility is your primary directive.
13
- - **STOP** aggressive file modifications.
14
- - **START** every response with a sincere, non-defensive apology.
15
- - **ACTION**: Explain why you failed, and propose a highly cautious recovery plan.
16
- `;
17
- }
18
- else if (gfi >= 40) {
19
- return `
20
- ### 【SYSTEM_MODE: CONCILIATORY】
21
- **CURRENT STATUS**: Moderate friction detected (GFI: ${gfi.toFixed(0)}).
22
- **BEHAVIORAL OVERRIDE**:
23
- - User is frustrated. Be more explanatory and cautious.
24
- - Before executing any tool, clearly state what you intend to do and **WAIT** for implicit or explicit user consent.
25
- - Avoid technical jargon; focus on the business/project value of your changes.
26
- `;
27
- }
28
- else {
29
- return `
30
- ### 【SYSTEM_MODE: EFFICIENT】
31
- **CURRENT STATUS**: System healthy (GFI: ${gfi.toFixed(0)}).
32
- **BEHAVIORAL OVERRIDE**:
33
- - Maintain peak efficiency.
34
- - Be concise. Prefer action over long explanations.
35
- - Follow the "Principles > Directives" rule strictly.
36
- `;
37
- }
38
- }
39
- //# sourceMappingURL=attitude-directive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attitude-directive.js","sourceRoot":"","sources":["../../src/prompt-builder/attitude-directive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;QACd,OAAO;;+EAEoE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;;CAM5F,CAAC;IACA,CAAC;SAAM,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;QACrB,OAAO;;uDAE4C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;CAKpE,CAAC;IACA,CAAC;SAAM,CAAC;QACN,OAAO;;2CAEgC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;;;;;CAKxD,CAAC;IACA,CAAC;AACH,CAAC"}
@@ -1,12 +0,0 @@
1
- import type { GfiState, GfiEvent, GfiPolicy, GfiStage, GfiSnapshot } from './gfi-types.js';
2
- import { DEFAULT_GFI_POLICY } from './gfi-policy.js';
3
- export { DEFAULT_GFI_POLICY };
4
- export declare function applyFriction(state: GfiState, event: GfiEvent, policy: GfiPolicy): GfiState;
5
- export declare function applyDecay(state: GfiState, elapsedMinutes: number, policy: GfiPolicy, stage: GfiStage, nowMs: number): GfiState;
6
- export declare function applyRelief(state: GfiState, opts: {
7
- source: string;
8
- amount?: number;
9
- }, nowMs: number, policy?: GfiPolicy): GfiState;
10
- export declare function classifyGfiStage(gfi: number, policy: GfiPolicy): GfiStage;
11
- export declare function createGfiSnapshot(state: GfiState, policy: GfiPolicy): GfiSnapshot;
12
- //# sourceMappingURL=gfi-kernel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gfi-kernel.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/gfi/gfi-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAa,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAE9B,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,GAChB,QAAQ,CA4BV;AAGD,wBAAgB,UAAU,CACxB,KAAK,EAAE,QAAQ,EACf,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,MAAM,GACZ,QAAQ,CA+BV;AAGD,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACzC,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,SAA8B,GACrC,QAAQ,CAoDV;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,CAKzE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAG,WAAW,CA0CjF"}
@@ -1,148 +0,0 @@
1
- import { DEFAULT_GFI_POLICY } from './gfi-policy.js';
2
- export { DEFAULT_GFI_POLICY };
3
- export function applyFriction(state, event, policy) {
4
- const isRepeated = state.lastErrorHash !== undefined && state.lastErrorHash === event.hash;
5
- const consecutiveErrors = isRepeated
6
- ? state.consecutiveErrors + 1
7
- : 1;
8
- const exponent = Math.max(0, consecutiveErrors - 1);
9
- const multiplier = Math.min(Math.pow(policy.repeatedFailureMultiplier.base, exponent), policy.repeatedFailureMultiplier.max);
10
- const score = event.baseScore * multiplier;
11
- const newCurrentGfi = state.currentGfi + score;
12
- const newGfiBySource = { ...state.gfiBySource };
13
- newGfiBySource[event.source] = (newGfiBySource[event.source] ?? 0) + score;
14
- return {
15
- ...state,
16
- currentGfi: newCurrentGfi,
17
- gfiBySource: newGfiBySource,
18
- consecutiveErrors,
19
- lastErrorHash: event.hash,
20
- lastErrorSource: event.source,
21
- dailyGfiPeak: Math.max(state.dailyGfiPeak ?? 0, newCurrentGfi),
22
- };
23
- }
24
- // eslint-disable-next-line @typescript-eslint/max-params
25
- export function applyDecay(state, elapsedMinutes, policy, stage, nowMs) {
26
- const rate = policy.decayRatesPerMinute[stage];
27
- // Decay each source slice individually, then prune those below minPruneBelow.
28
- // currentGfi is derived from the sum of remaining source slices when sources exist.
29
- // When no source ledger entries exist, decay currentGfi directly (e.g. session restart).
30
- const nextSources = {};
31
- for (const [src, value] of Object.entries(state.gfiBySource)) {
32
- const sourceDecayed = value - rate * elapsedMinutes;
33
- const sourceAfterDecay = Math.max(0, Math.round(sourceDecayed * 10) / 10);
34
- if (sourceAfterDecay >= policy.relief.minPruneBelow) {
35
- nextSources[src] = sourceAfterDecay;
36
- }
37
- }
38
- // Compute nextGfi:
39
- // - Has remaining sources: currentGfi = sum of remaining source slices (invariant)
40
- // - No remaining sources but had sources: currentGfi = 0 (all pruned → invariant)
41
- // - Had no source ledger at all: decay currentGfi directly (e.g. fresh session restart)
42
- const nextGfi = Object.keys(nextSources).length > 0
43
- ? Math.max(0, Math.round(Object.values(nextSources).reduce((a, b) => a + b, 0) * 10) / 10)
44
- : Object.keys(state.gfiBySource).length > 0
45
- ? 0
46
- : Math.max(0, Math.round((state.currentGfi - rate * elapsedMinutes) * 10) / 10);
47
- return {
48
- ...state,
49
- currentGfi: nextGfi,
50
- gfiBySource: nextSources,
51
- lastGfiDecayAt: nowMs,
52
- };
53
- }
54
- // eslint-disable-next-line @typescript-eslint/max-params
55
- export function applyRelief(state, opts, nowMs, policy = DEFAULT_GFI_POLICY) {
56
- const { source, amount = 0 } = opts;
57
- if (source === 'all' && amount >= 100) {
58
- return {
59
- currentGfi: 0,
60
- gfiBySource: {},
61
- consecutiveErrors: 0,
62
- lastErrorHash: undefined,
63
- lastErrorSource: undefined,
64
- lastGfiDecayAt: nowMs,
65
- dailyGfiPeak: state.dailyGfiPeak,
66
- };
67
- }
68
- const newSources = { ...state.gfiBySource };
69
- if (amount > 0) {
70
- // source-specific partial relief
71
- const key = source;
72
- if (newSources[key] !== undefined) {
73
- newSources[key] = Math.max(0, (newSources[key] ?? 0) - amount);
74
- if (newSources[key] === 0) {
75
- delete newSources[key];
76
- }
77
- }
78
- }
79
- else {
80
- // ratio-based relief (toolSuccessRatio)
81
- const ratio = policy.relief.toolSuccessRatio;
82
- for (const src of Object.keys(newSources)) {
83
- const key = src;
84
- newSources[key] = Math.max(0, Math.round(((newSources[key] ?? 0) * (1 - ratio)) * 10) / 10);
85
- if (newSources[key] === 0) {
86
- delete newSources[key];
87
- }
88
- }
89
- }
90
- const totalSources = Object.values(newSources).reduce((a, b) => a + b, 0);
91
- const isLastErrorSource = source === state.lastErrorSource && source !== 'all';
92
- const newConsecutiveErrors = isLastErrorSource ? 0 : state.consecutiveErrors;
93
- return {
94
- ...state,
95
- currentGfi: totalSources,
96
- gfiBySource: newSources,
97
- consecutiveErrors: newConsecutiveErrors,
98
- lastErrorHash: newConsecutiveErrors === 0 ? undefined : state.lastErrorHash,
99
- lastErrorSource: newConsecutiveErrors === 0 ? undefined : state.lastErrorSource,
100
- lastGfiDecayAt: nowMs,
101
- };
102
- }
103
- export function classifyGfiStage(gfi, policy) {
104
- if (gfi >= policy.stageThresholds.saturated)
105
- return 'saturated';
106
- if (gfi >= policy.stageThresholds.critical)
107
- return 'critical';
108
- if (gfi >= policy.stageThresholds.elevated)
109
- return 'elevated';
110
- return 'stable';
111
- }
112
- export function createGfiSnapshot(state, policy) {
113
- const stage = classifyGfiStage(state.currentGfi, policy);
114
- const sources = { ...state.gfiBySource };
115
- let dominantSource = null;
116
- let maxSourceValue = 0;
117
- for (const [src, val] of Object.entries(state.gfiBySource)) {
118
- if (val > maxSourceValue) {
119
- maxSourceValue = val;
120
- dominantSource = src;
121
- }
122
- }
123
- const attitudeMode = state.currentGfi < policy.stageThresholds.elevated
124
- ? 'efficient'
125
- : state.currentGfi < policy.stageThresholds.critical
126
- ? 'conciliatory'
127
- : 'humble_recovery';
128
- const painDiagnosticReason = state.currentGfi >= policy.stageThresholds.elevated ? 'high_gfi' : 'none';
129
- const consumers = { attitudeMode, painDiagnosticReason };
130
- return {
131
- currentGfi: state.currentGfi,
132
- stage,
133
- sources,
134
- dominantSource,
135
- consecutiveErrors: state.consecutiveErrors,
136
- lastErrorSource: state.lastErrorSource,
137
- lastDecayAt: state.lastGfiDecayAt ? new Date(state.lastGfiDecayAt).toISOString() : undefined,
138
- dailyGfiPeak: state.dailyGfiPeak,
139
- policy: {
140
- elevatedThreshold: policy.stageThresholds.elevated,
141
- criticalThreshold: policy.stageThresholds.critical,
142
- saturatedThreshold: policy.stageThresholds.saturated,
143
- repeatedFailureMultiplierMax: policy.repeatedFailureMultiplier.max,
144
- },
145
- consumers,
146
- };
147
- }
148
- //# sourceMappingURL=gfi-kernel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gfi-kernel.js","sourceRoot":"","sources":["../../../src/runtime-v2/gfi/gfi-kernel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,kBAAkB,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E,YAAY,EAAE,oBAAoB,EAAE,CAAC;IAEzD,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK;QACL,OAAO;QACP,cAAc;QACd,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS;QAC5F,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,MAAM,EAAE;YACN,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC,QAAQ;YAClD,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC,QAAQ;YAClD,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC,SAAS;YACpD,4BAA4B,EAAE,MAAM,CAAC,yBAAyB,CAAC,GAAG;SACnE;QACD,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { GfiPolicy } from './gfi-types.js';
2
- export declare const DEFAULT_GFI_POLICY: GfiPolicy;
3
- //# sourceMappingURL=gfi-policy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gfi-policy.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/gfi/gfi-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,eAAO,MAAM,kBAAkB,EAAE,SAqBhC,CAAC"}
@@ -1,23 +0,0 @@
1
- export const DEFAULT_GFI_POLICY = {
2
- stageThresholds: {
3
- elevated: 40,
4
- critical: 70,
5
- saturated: 100,
6
- },
7
- repeatedFailureMultiplier: {
8
- base: 1.5,
9
- max: 3.0,
10
- },
11
- decayRatesPerMinute: {
12
- stable: 0.5,
13
- elevated: 1.0,
14
- critical: 2.0,
15
- saturated: 4.0,
16
- },
17
- relief: {
18
- toolSuccessRatio: 0.25,
19
- minPruneBelow: 8,
20
- },
21
- sourceWeights: {},
22
- };
23
- //# sourceMappingURL=gfi-policy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gfi-policy.js","sourceRoot":"","sources":["../../../src/runtime-v2/gfi/gfi-policy.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAc;IAC3C,eAAe,EAAE;QACf,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE,GAAG;KACf;IACD,yBAAyB,EAAE;QACzB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,GAAG;KACT;IACD,mBAAmB,EAAE;QACnB,MAAM,EAAE,GAAG;QACX,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,GAAG;KACf;IACD,MAAM,EAAE;QACN,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,CAAC;KACjB;IACD,aAAa,EAAE,EAAE;CAClB,CAAC"}
@@ -1,78 +0,0 @@
1
- /**
2
- * GFI Observability Read Model
3
- *
4
- * Pure domain model for building workspace-level GFI snapshots.
5
- * Partitions sessions into active vs stale and produces an authoritative snapshot
6
- * for operator visibility.
7
- *
8
- * PRI-78: GFI Observability
9
- */
10
- import type { GfiPolicy, GfiSource, GfiSnapshot } from './gfi-types.js';
11
- export interface GfiReadModelInput {
12
- sessions: {
13
- sessionId: string;
14
- /** Defaults to 0 if omitted */
15
- currentGfi?: number;
16
- gfiBySource?: Partial<Record<GfiSource, number>>;
17
- lastErrorSource?: string;
18
- /** Defaults to 0 if omitted */
19
- consecutiveErrors?: number;
20
- lastGfiDecayAt?: number;
21
- dailyGfiPeak?: number;
22
- /** Defaults to 0 if omitted — session older than cutoff is classified stale */
23
- lastActivityAt?: number;
24
- }[];
25
- nowMs: number;
26
- /** Sessions with lastActivityAt < nowMs - staleCutoffMs are classified stale. Default: 2 hours */
27
- staleCutoffMs?: number;
28
- policy?: GfiPolicy;
29
- }
30
- /**
31
- * Workspace-level GFI snapshot — partitions sessions into active vs stale.
32
- *
33
- * Invariant: `active === null` iff `activeSessionCount === 0` (no active sessions exist).
34
- * Invariant: `staleGfiRange === null` iff `staleSessionCount === 0` (not an error state).
35
- */
36
- export interface GfiWorkspaceSnapshot {
37
- /**
38
- * Snapshot for the highest-GFI active session.
39
- * Null when there are no active sessions (all stale, or no sessions exist).
40
- */
41
- active: GfiSnapshot | null;
42
- staleSessionCount: number;
43
- /**
44
- * Min/max GFI across all stale sessions.
45
- * Null when staleSessionCount === 0 (no stale sessions — not an error state).
46
- */
47
- staleGfiRange: {
48
- min: number;
49
- max: number;
50
- } | null;
51
- totalSessionCount: number;
52
- activeSessionCount: number;
53
- generatedAt: string;
54
- }
55
- export interface GfiWorkspaceHealthAssessment {
56
- status: 'healthy' | 'degraded';
57
- reason: string;
58
- staleGfiDegradedThreshold: number;
59
- }
60
- export declare function classifyGfiWorkspaceHealth(snapshot: GfiWorkspaceSnapshot, options?: {
61
- staleGfiDegradedThreshold?: number;
62
- }): GfiWorkspaceHealthAssessment;
63
- /**
64
- * Build a workspace-level GFI snapshot from session data.
65
- *
66
- * Algorithm:
67
- * 1. Default stale cutoff to 2 hours if not provided
68
- * 2. Partition sessions into active (lastActivityAt >= nowMs - staleCutoffMs) and stale
69
- * 3. Select active session with highest currentGfi (tie-break: most recent lastActivityAt)
70
- * 4. Build GfiSnapshot for selected active session using createGfiSnapshot
71
- * 5. Compute staleGfiRange from stale sessions' currentGfi values
72
- * 6. Return GfiWorkspaceSnapshot
73
- *
74
- * Key invariant: stale sessions do NOT influence the active snapshot.
75
- * This prevents old UAT sessions with GFI=197.8 from making current health look critical.
76
- */
77
- export declare function buildGfiWorkspaceSnapshot(input: GfiReadModelInput): GfiWorkspaceSnapshot;
78
- //# sourceMappingURL=gfi-read-model.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gfi-read-model.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2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