@sdotwinter/openclaw-deterministic 0.4.1 → 0.5.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.
- package/bin/doctor.js +62 -39
- package/package.json +1 -1
package/bin/doctor.js
CHANGED
|
@@ -2,58 +2,81 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const os = require("os");
|
|
6
5
|
|
|
7
|
-
const
|
|
6
|
+
const HOME = process.env.HOME;
|
|
7
|
+
const workspace = path.join(HOME, ".openclaw", "workspace");
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const files = {
|
|
10
|
+
operating: path.join(workspace, "OPERATING_RULES.md"),
|
|
11
|
+
soul: path.join(workspace, "SOUL.md"),
|
|
12
|
+
deterministicSoul: path.join(workspace, "SOUL.deterministic.md"),
|
|
13
|
+
skill: path.join(workspace, "skills", "memory-compactor", "SKILL.md"),
|
|
14
|
+
semantic: path.join(workspace, "memory", "semantic", "openclaw.md"),
|
|
15
|
+
};
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
const MARKER = "## Deterministic Governance Overlay";
|
|
18
|
+
const HARD_LIMIT = 1200;
|
|
19
|
+
const RISK_THRESHOLD = 1020;
|
|
20
|
+
|
|
21
|
+
function exists(p) {
|
|
22
|
+
try {
|
|
23
|
+
fs.accessSync(p);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
16
27
|
}
|
|
28
|
+
}
|
|
17
29
|
|
|
18
|
-
|
|
30
|
+
function tokenEstimate(text) {
|
|
31
|
+
if (!text) return 0;
|
|
32
|
+
return Math.ceil(text.split(/\s+/).length * 1.3);
|
|
33
|
+
}
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
console.log(`⚠️ ${label} exists but is not deterministic-managed.`);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
35
|
+
console.log("\nRunning deterministic doctor...\n");
|
|
24
36
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
37
|
+
// File checks
|
|
38
|
+
console.log(exists(files.operating)
|
|
39
|
+
? "✅ OPERATING_RULES.md present."
|
|
40
|
+
: "❌ OPERATING_RULES.md missing.");
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
42
|
+
console.log(exists(files.deterministicSoul)
|
|
43
|
+
? "✅ SOUL.deterministic.md present."
|
|
44
|
+
: "❌ SOUL.deterministic.md missing.");
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
console.log(exists(files.skill)
|
|
47
|
+
? "✅ memory-compactor SKILL.md present."
|
|
48
|
+
: "❌ memory-compactor SKILL.md missing.");
|
|
35
49
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
50
|
+
// Activation check
|
|
51
|
+
if (exists(files.soul)) {
|
|
52
|
+
const soulContent = fs.readFileSync(files.soul, "utf8");
|
|
53
|
+
if (soulContent.includes(MARKER)) {
|
|
54
|
+
console.log("✅ Deterministic overlay ENABLED.");
|
|
55
|
+
} else {
|
|
56
|
+
console.log("⚠ Deterministic overlay installed but NOT enabled.");
|
|
39
57
|
}
|
|
58
|
+
} else {
|
|
59
|
+
console.log("❌ SOUL.md missing.");
|
|
60
|
+
}
|
|
40
61
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
checkFile(
|
|
47
|
-
path.join(WORKSPACE_DIR, "SOUL.deterministic.md"),
|
|
48
|
-
"SOUL.deterministic.md"
|
|
49
|
-
);
|
|
62
|
+
// Semantic memory health
|
|
63
|
+
if (exists(files.semantic)) {
|
|
64
|
+
const semanticContent = fs.readFileSync(files.semantic, "utf8");
|
|
65
|
+
const tokens = tokenEstimate(semanticContent);
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
path.join(WORKSPACE_DIR, "skills", "memory-compactor", "SKILL.md"),
|
|
53
|
-
"memory-compactor SKILL.md"
|
|
54
|
-
);
|
|
67
|
+
console.log(`\nSemantic memory tokens (est): ${tokens}`);
|
|
55
68
|
|
|
56
|
-
|
|
69
|
+
if (tokens > HARD_LIMIT) {
|
|
70
|
+
console.log("🚨 ABOVE HARD LIMIT (Tier C enforced).");
|
|
71
|
+
} else if (tokens > RISK_THRESHOLD) {
|
|
72
|
+
console.log("⚠ Near risk threshold (85%).");
|
|
73
|
+
} else {
|
|
74
|
+
console.log("✅ Semantic memory within safe bounds.");
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
console.log("\nℹ No semantic memory file detected.");
|
|
57
78
|
}
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
console.log("\nDoctor complete.\n");
|
|
81
|
+
|
|
82
|
+
process.exit(0);
|