@sdotwinter/openclaw-deterministic 0.10.0 → 0.11.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.
Files changed (2) hide show
  1. package/bin/doctor.js +36 -10
  2. package/package.json +1 -1
package/bin/doctor.js CHANGED
@@ -15,6 +15,14 @@ const workspace = path.join(openclawRoot, "workspace");
15
15
  const DEFAULT_HARD_LIMIT = 1200;
16
16
  const DEFAULT_RISK_THRESHOLD = 1020;
17
17
 
18
+ const episodicLogPath = path.join(
19
+ openclawRoot,
20
+ "workspace",
21
+ "memory",
22
+ "episodic",
23
+ "governance-log.md"
24
+ );
25
+
18
26
  const files = {
19
27
  operating: path.join(workspace, "OPERATING_RULES.md"),
20
28
  detSoul: path.join(workspace, "SOUL.deterministic.md"),
@@ -35,6 +43,18 @@ function read(p) {
35
43
  return fs.readFileSync(p, "utf8");
36
44
  }
37
45
 
46
+ function appendGovernanceEvent(event) {
47
+ try {
48
+ const timestamp = new Date().toISOString();
49
+ const entry = `\n---\nTime: ${timestamp}\nType: ${event.type}\nDetails: ${event.details}\n---\n`;
50
+
51
+ fs.mkdirSync(path.dirname(episodicLogPath), { recursive: true });
52
+ fs.appendFileSync(episodicLogPath, entry);
53
+ } catch {
54
+ // Logging must never crash doctor
55
+ }
56
+ }
57
+
38
58
  function versionFromFile(content) {
39
59
  const match = content.match(/Installed by openclaw-deterministic v([0-9.]+)/);
40
60
  return match ? match[1] : null;
@@ -82,24 +102,16 @@ function evaluateVersion(filePath) {
82
102
 
83
103
  function parseHardLimit() {
84
104
  if (!exists(files.compactor)) return null;
85
-
86
105
  const content = read(files.compactor);
87
-
88
106
  const match = content.match(/HARD_LIMIT[^0-9]*([0-9]+)/);
89
- if (!match) return null;
90
-
91
- return parseInt(match[1], 10);
107
+ return match ? parseInt(match[1], 10) : null;
92
108
  }
93
109
 
94
110
  function parseRiskThreshold() {
95
111
  if (!exists(files.compactor)) return null;
96
-
97
112
  const content = read(files.compactor);
98
-
99
113
  const match = content.match(/RISK_THRESHOLD[^0-9]*([0-9]+)/);
100
- if (!match) return null;
101
-
102
- return parseInt(match[1], 10);
114
+ return match ? parseInt(match[1], 10) : null;
103
115
  }
104
116
 
105
117
  function evaluate() {
@@ -184,12 +196,18 @@ function printHuman(result) {
184
196
 
185
197
  if (info.status === "missing") {
186
198
  console.log(`❌ ${label} missing.`);
199
+ appendGovernanceEvent({ type: "file-missing", details: label });
187
200
  } else if (info.status === "no-stamp") {
188
201
  console.log(`⚠ ${label} version stamp missing.`);
202
+ appendGovernanceEvent({ type: "no-version-stamp", details: label });
189
203
  } else if (info.status === "mismatch") {
190
204
  console.log(
191
205
  `⚠ ${label} version mismatch (installed ${info.version}, CLI ${pkg.version})`
192
206
  );
207
+ appendGovernanceEvent({
208
+ type: "version-mismatch",
209
+ details: `${label} installed ${info.version}, CLI ${pkg.version}`,
210
+ });
193
211
  } else {
194
212
  console.log(`✅ ${label} version matches CLI (${info.version})`);
195
213
  }
@@ -204,12 +222,20 @@ function printHuman(result) {
204
222
 
205
223
  if (!result.limits.coherent) {
206
224
  console.log("⚠ Threshold configuration drift detected in SKILL.md.");
225
+ appendGovernanceEvent({
226
+ type: "threshold-drift",
227
+ details: `HARD_LIMIT=${result.limits.hardLimitConfigured}, RISK_THRESHOLD=${result.limits.riskThresholdConfigured}`,
228
+ });
207
229
  }
208
230
 
209
231
  console.log(`\nSemantic memory tokens (est): ${result.semanticTokens}`);
210
232
 
211
233
  if (result.semanticStatus === "hard-limit-exceeded") {
212
234
  console.log("❌ Semantic memory exceeds HARD_LIMIT.");
235
+ appendGovernanceEvent({
236
+ type: "semantic-hard-limit-exceeded",
237
+ details: `Tokens=${result.semanticTokens}`,
238
+ });
213
239
  } else if (result.semanticStatus === "risk-threshold") {
214
240
  console.log("⚠ Semantic memory above risk threshold.");
215
241
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdotwinter/openclaw-deterministic",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Deterministic governance and memory compaction layer for OpenClaw",
5
5
  "keywords": [
6
6
  "openclaw",