@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.
Files changed (2) hide show
  1. package/bin/doctor.js +62 -39
  2. 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 pkg = require("../package.json");
6
+ const HOME = process.env.HOME;
7
+ const workspace = path.join(HOME, ".openclaw", "workspace");
8
8
 
9
- const OPENCLAW_DIR = path.join(os.homedir(), ".openclaw");
10
- const WORKSPACE_DIR = path.join(OPENCLAW_DIR, "workspace");
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
- function checkFile(filePath, label) {
13
- if (!fs.existsSync(filePath)) {
14
- console.log(`❌ Missing: ${label}`);
15
- return;
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
- const content = fs.readFileSync(filePath, "utf8");
30
+ function tokenEstimate(text) {
31
+ if (!text) return 0;
32
+ return Math.ceil(text.split(/\s+/).length * 1.3);
33
+ }
19
34
 
20
- if (!content.includes("Installed by openclaw-deterministic")) {
21
- console.log(`⚠️ ${label} exists but is not deterministic-managed.`);
22
- return;
23
- }
35
+ console.log("\nRunning deterministic doctor...\n");
24
36
 
25
- if (!content.includes(`v${pkg.version}`)) {
26
- console.log(`⚠️ ${label} version drift detected.`);
27
- return;
28
- }
37
+ // File checks
38
+ console.log(exists(files.operating)
39
+ ? "✅ OPERATING_RULES.md present."
40
+ : "❌ OPERATING_RULES.md missing.");
29
41
 
30
- console.log(`✅ ${label} OK (v${pkg.version})`);
31
- }
42
+ console.log(exists(files.deterministicSoul)
43
+ ? "✅ SOUL.deterministic.md present."
44
+ : "❌ SOUL.deterministic.md missing.");
32
45
 
33
- function runDoctor() {
34
- console.log("Running deterministic doctor...\n");
46
+ console.log(exists(files.skill)
47
+ ? " memory-compactor SKILL.md present."
48
+ : "❌ memory-compactor SKILL.md missing.");
35
49
 
36
- if (!fs.existsSync(OPENCLAW_DIR)) {
37
- console.log("❌ OpenClaw not installed.");
38
- process.exit(1);
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
- checkFile(
42
- path.join(WORKSPACE_DIR, "OPERATING_RULES.md"),
43
- "OPERATING_RULES.md"
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
- checkFile(
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
- console.log("\nDoctor complete.");
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
- runDoctor();
80
+ console.log("\nDoctor complete.\n");
81
+
82
+ process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdotwinter/openclaw-deterministic",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Deterministic governance and memory compaction layer for OpenClaw",
5
5
  "keywords": [
6
6
  "openclaw",