speclock 4.5.7 → 5.0.1

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/README.md CHANGED
@@ -8,13 +8,15 @@
8
8
  <a href="https://www.npmjs.com/package/speclock"><img src="https://img.shields.io/npm/v/speclock.svg?style=flat-square&color=4F46E5" alt="npm version" /></a>
9
9
  <a href="https://www.npmjs.com/package/speclock"><img src="https://img.shields.io/npm/dm/speclock.svg?style=flat-square&color=22C55E" alt="npm downloads" /></a>
10
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square" alt="MIT License" /></a>
11
- <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-31_tools-green.svg?style=flat-square" alt="MCP 31 tools" /></a>
11
+ <a href="https://modelcontextprotocol.io"><img src="https://img.shields.io/badge/MCP-39_tools-green.svg?style=flat-square" alt="MCP 39 tools" /></a>
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
15
  <a href="https://sgroy10.github.io/speclock/">Website</a> · <a href="https://www.npmjs.com/package/speclock">npm</a> · <a href="https://smithery.ai/servers/sgroy10/speclock">Smithery</a> · <a href="https://github.com/sgroy10/speclock">GitHub</a>
16
16
  </p>
17
17
 
18
+ <p align="center"><strong>Developed by <a href="https://github.com/sgroy10">Sandeep Roy</a></strong> · Free &amp; Open Source (MIT License)</p>
19
+
18
20
  ---
19
21
 
20
22
  ```
@@ -30,7 +32,7 @@ AI: ⚠️ BLOCKED — violates lock "Never touch the auth system"
30
32
  Should I find another approach?
31
33
  ```
32
34
 
33
- **557 tests. 98% pass rate. 0 false positives across 5 domains. Gemini Flash hybrid for universal domain coverage.**
35
+ **940 tests. 99.4% pass rate. 0 false positives across 13 suites. Gemini Flash hybrid, Spec Compiler, Code Graph, Typed Constraints, Python SDK, ROS2 integration.**
34
36
 
35
37
  ---
36
38
 
@@ -235,7 +237,109 @@ Import and export policies between projects. Share constraint templates across y
235
237
 
236
238
  ---
237
239
 
238
- ## 31 MCP Tools
240
+ ## Spec Compiler (v5.0)
241
+
242
+ Paste a PRD, README, or architecture doc — SpecLock extracts all constraints automatically:
243
+
244
+ ```
245
+ Input: "We're building a fintech app. Use React and FastAPI.
246
+ Never touch the auth module. Response time must stay
247
+ under 200ms. Payments go through Stripe."
248
+
249
+ Output: 2 text locks:
250
+ - "Never touch the auth module"
251
+ - "Payments go through Stripe — don't change provider"
252
+ 1 typed lock:
253
+ - response_time_ms <= 200 (numerical)
254
+ 2 decisions:
255
+ - "Use React for frontend"
256
+ - "Use FastAPI for backend"
257
+ ```
258
+
259
+ Uses Gemini Flash by default ($0.01 per 1000 compilations). No API key needed for core SpecLock — only the compiler uses LLM. Falls back gracefully if no key is set.
260
+
261
+ ---
262
+
263
+ ## Code Graph (v5.0)
264
+
265
+ Live dependency graph of your codebase. Parses JS/TS/Python imports.
266
+
267
+ ```
268
+ $ speclock blast-radius src/core/memory.js
269
+
270
+ Direct Dependents: 8 files
271
+ Transitive Impact: 14 files (33% of codebase)
272
+ Max Depth: 4 hops
273
+ ```
274
+
275
+ **Lock-to-file mapping:** Lock "Never modify auth" → automatically maps to `src/api/auth.js`, `src/middleware/auth.js`, `src/utils/jwt.js`. No configuration needed.
276
+
277
+ **Module detection:** Groups files into logical modules, tracks inter-module dependencies, identifies critical paths.
278
+
279
+ ---
280
+
281
+ ## Typed Constraints (v5.0)
282
+
283
+ Real-time value and state checking for autonomous systems, IoT, robotics:
284
+
285
+ ```javascript
286
+ // Numerical: speed must be <= 2.0 m/s
287
+ { constraintType: "numerical", metric: "speed_mps", operator: "<=", value: 2.0 }
288
+
289
+ // Range: temperature must stay between 20-25°C
290
+ { constraintType: "range", metric: "temperature_c", min: 20, max: 25 }
291
+
292
+ // State: never go from armed → disarmed without approval
293
+ { constraintType: "state", metric: "system_mode", forbidden: [{ from: "armed", to: "disarmed" }] }
294
+
295
+ // Temporal: heartbeat must occur every 30 seconds
296
+ { constraintType: "temporal", metric: "heartbeat_s", operator: "<=", value: 30 }
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Python SDK & ROS2 (v5.0)
302
+
303
+ ```bash
304
+ pip install speclock-sdk
305
+ ```
306
+
307
+ ```python
308
+ from speclock import ConstraintChecker
309
+ checker = ConstraintChecker(constraints)
310
+ result = checker.check({"metric": "speed_mps", "value": 3.5})
311
+ # → violation: speed exceeds 2.0 m/s limit
312
+ ```
313
+
314
+ **ROS2 Guardian Node:** Real-time constraint enforcement for robots. Subscribes to sensor topics, checks constraints at configurable rate, publishes violations, triggers emergency stop.
315
+
316
+ ---
317
+
318
+ ## REST API v2 (v5.0)
319
+
320
+ Real-time constraint checking for autonomous systems:
321
+
322
+ ```bash
323
+ # Single check
324
+ POST /api/v2/check-typed { metric, value, entity }
325
+
326
+ # Batch check (up to 100)
327
+ POST /api/v2/check-batch { checks: [...] }
328
+
329
+ # SSE streaming (real-time violations)
330
+ GET /api/v2/stream
331
+
332
+ # Spec Compiler
333
+ POST /api/v2/compiler/compile { text, autoApply }
334
+
335
+ # Code Graph
336
+ GET /api/v2/graph/blast-radius?file=src/core/memory.js
337
+ GET /api/v2/graph/lock-map
338
+ ```
339
+
340
+ ---
341
+
342
+ ## 39 MCP Tools
239
343
 
240
344
  <details>
241
345
  <summary><b>Memory</b> — goal, locks, decisions, notes, deploy facts</summary>
@@ -308,6 +412,30 @@ Import and export policies between projects. Share constraint templates across y
308
412
 
309
413
  </details>
310
414
 
415
+ <details>
416
+ <summary><b>Typed Constraints</b> — numerical, range, state, temporal (v5.0)</summary>
417
+
418
+ | Tool | What it does |
419
+ |------|-------------|
420
+ | `speclock_add_typed_lock` | Add typed constraint (numerical/range/state/temporal) |
421
+ | `speclock_check_typed` | Check proposed values against typed constraints |
422
+ | `speclock_list_typed_locks` | List all typed constraints |
423
+ | `speclock_update_threshold` | Update typed lock thresholds |
424
+
425
+ </details>
426
+
427
+ <details>
428
+ <summary><b>Spec Compiler & Code Graph</b> — NL→constraints, dependency analysis (v5.0)</summary>
429
+
430
+ | Tool | What it does |
431
+ |------|-------------|
432
+ | `speclock_compile_spec` | Compile natural language into structured constraints |
433
+ | `speclock_build_graph` | Build/refresh code dependency graph |
434
+ | `speclock_blast_radius` | Calculate blast radius of file changes |
435
+ | `speclock_map_locks` | Map locks to actual code files |
436
+
437
+ </details>
438
+
311
439
  ---
312
440
 
313
441
  ## CLI
@@ -380,7 +508,7 @@ The AI opens the file and sees:
380
508
  │ AI Tool (Claude Code, Cursor, Bolt.new...) │
381
509
  └────────────┬──────────────────┬──────────────────┘
382
510
  │ │
383
- MCP Protocol (31 tools) npm File-Based
511
+ MCP Protocol (39 tools) npm File-Based
384
512
  │ (SPECLOCK.md + CLI)
385
513
  │ │
386
514
  ┌────────────▼──────────────────▼──────────────────┐
@@ -429,15 +557,23 @@ The AI opens the file and sees:
429
557
  | Suite | Tests | Pass Rate | What it covers |
430
558
  |-------|------:|----------:|----------------|
431
559
  | Adversarial Conflict | 61 | 100% | Euphemisms, temporal evasion, compound sentences |
560
+ | Typed Constraints | 61 | 100% | Numerical, range, state, temporal validation |
432
561
  | Phase 4 (Multi-domain) | 91 | 100% | Fintech, e-commerce, IoT, healthcare, SaaS |
433
562
  | John (Indie Dev Journey) | 86 | 100% | 8-session Bolt.new build with 5 locks |
434
563
  | Sam (Enterprise HIPAA) | 124 | 100% | HIPAA locks, PHI, encryption, RBAC |
564
+ | Auth & Crypto | 114 | 100% | API keys, RBAC, AES-256 encryption |
565
+ | Audit Chain | 35 | 100% | HMAC-SHA256 chain integrity |
566
+ | Enforcement | 40 | 100% | Hard/advisory mode, overrides |
567
+ | Compliance Export | 50 | 100% | SOC 2, HIPAA, CSV formats |
568
+ | REST API v2 | 28 | 100% | Typed constraint endpoints, SSE |
569
+ | Spec Compiler | 24 | 100% | NL→constraints parsing, auto-apply |
570
+ | Code Graph | 33 | 100% | Import parsing, blast radius, lock mapping |
571
+ | Python SDK | 62 | 100% | pip install, constraint checking |
572
+ | ROS2 Guardian | 26 | 100% | Robot safety constraint enforcement |
435
573
  | Real-World Testers | 105 | 95% | 5 developers, 30+ locks, diverse domains |
436
- | Payment/Salary/PII | 35 | 100% | Cross-vocabulary: payroll, salary, compensation |
437
- | Claude Tester (G-Suite) | 55 | 95% | Independent AI tester, adversarial probing |
438
- | **Total** | **557** | **98%** | |
574
+ | **Total** | **940** | **99.4%** | **13 suites, 15 domains** |
439
575
 
440
- Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, payments, payroll. All 11 Indian payment gateways detected (Razorpay, PayU, Cashfree, PhonePe, Paytm, CCAvenue, BillDesk, Instamojo, Juspay, Stripe, PayPal). Zero false positives on UI/cosmetic actions.
576
+ Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, payments, payroll, robotics, autonomous systems. All 11 Indian payment gateways detected. Zero false positives on UI/cosmetic actions.
441
577
 
442
578
  ---
443
579
 
@@ -475,4 +611,4 @@ Built by **[Sandeep Roy](https://github.com/sgroy10)**
475
611
 
476
612
  ---
477
613
 
478
- <p align="center"><i>v4.5.7557 tests, 98% pass rate, 31 MCP tools, Gemini hybrid. Because remembering isn't enough.</i></p>
614
+ <p align="center"><i>v5.0.0940 tests, 99.4% pass rate, 39 MCP tools, Spec Compiler, Code Graph, Typed Constraints, Python SDK, ROS2, REST API v2. Because remembering isn't enough.</i></p>
package/package.json CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  "name": "speclock",
4
4
 
5
- "version": "4.5.7",
5
+ "version": "5.0.1",
6
6
 
7
- "description": "AI constraint engine stops AI from breaking what you locked. Semantic detection, Gemini LLM hybrid, 31 MCP tools, HMAC audit chain, RBAC, encryption, SOC 2/HIPAA compliance. Works with Claude Code, Cursor, Bolt.new, Lovable.",
7
+ "description": "AI Constraint Engine for autonomous systems governance. Spec Compiler (NL→constraints), Code Graph (blast radius, lock-to-file mapping), Typed constraints (numerical, range, state, temporal), REST API v2, Python SDK, ROS2 integration. 39 MCP tools, Gemini LLM hybrid, HMAC audit chain, RBAC, encryption, SOC 2/HIPAA compliance.",
8
8
 
9
9
  "type": "module",
10
10
 
@@ -12,130 +12,91 @@
12
12
 
13
13
  "bin": {
14
14
 
15
-
16
- "speclock": "./bin/speclock.js"
15
+ "speclock": "./bin/speclock.js"
17
16
 
18
17
  },
19
18
 
20
19
  "scripts": {
21
20
 
22
-
23
- "start": "node src/mcp/server.js",
21
+ "start": "node src/mcp/server.js",
24
22
 
25
-
26
- "serve": "node src/mcp/server.js",
23
+ "serve": "node src/mcp/server.js",
27
24
 
28
-
29
- "test": "node --experimental-vm-modules node_modules/.bin/jest"
25
+ "test": "node --experimental-vm-modules node_modules/.bin/jest"
30
26
 
31
27
  },
32
28
 
33
29
  "keywords": [
34
30
 
35
-
36
- "mcp",
31
+ "mcp",
37
32
 
38
-
39
- "mcp-server",
33
+ "mcp-server",
40
34
 
41
-
42
- "ai",
35
+ "ai",
43
36
 
44
-
45
- "ai-memory",
37
+ "ai-memory",
46
38
 
47
-
48
- "ai-continuity",
39
+ "ai-continuity",
49
40
 
50
-
51
- "context",
41
+ "context",
52
42
 
53
-
54
- "memory",
43
+ "memory",
55
44
 
56
-
57
- "claude",
45
+ "claude",
58
46
 
59
-
60
- "claude-code",
47
+ "claude-code",
61
48
 
62
-
63
- "cursor",
49
+ "cursor",
64
50
 
65
-
66
- "codex",
51
+ "codex",
67
52
 
68
-
69
- "windsurf",
53
+ "windsurf",
70
54
 
71
-
72
- "cline",
55
+ "cline",
73
56
 
74
-
75
- "speclock",
57
+ "speclock",
76
58
 
77
-
78
- "ai-amnesia",
59
+ "ai-amnesia",
79
60
 
80
-
81
- "model-context-protocol",
61
+ "model-context-protocol",
82
62
 
83
-
84
- "drift-detection",
63
+ "drift-detection",
85
64
 
86
-
87
- "constraint-enforcement",
65
+ "constraint-enforcement",
88
66
 
89
-
90
- "enterprise",
67
+ "enterprise",
91
68
 
92
-
93
- "soc2",
69
+ "soc2",
94
70
 
95
-
96
- "hipaa",
71
+ "hipaa",
97
72
 
98
-
99
- "compliance",
73
+ "compliance",
100
74
 
101
-
102
- "audit-trail",
75
+ "audit-trail",
103
76
 
104
-
105
- "hmac",
77
+ "hmac",
106
78
 
107
-
108
- "encryption",
79
+ "encryption",
109
80
 
110
-
111
- "aes-256",
81
+ "aes-256",
112
82
 
113
-
114
- "api-key",
83
+ "api-key",
115
84
 
116
-
117
- "authentication",
85
+ "authentication",
118
86
 
119
-
120
- "rbac",
87
+ "rbac",
121
88
 
122
-
123
- "policy-as-code",
89
+ "policy-as-code",
124
90
 
125
-
126
- "sso",
91
+ "sso",
127
92
 
128
-
129
- "oauth",
93
+ "oauth",
130
94
 
131
-
132
- "oidc",
95
+ "oidc",
133
96
 
134
-
135
- "dashboard",
97
+ "dashboard",
136
98
 
137
-
138
- "telemetry"
99
+ "telemetry"
139
100
 
140
101
  ],
141
102
 
@@ -147,104 +108,79 @@
147
108
 
148
109
  "bugs": {
149
110
 
150
-
151
- "url": "https://github.com/sgroy10/speclock/issues"
111
+ "url": "https://github.com/sgroy10/speclock/issues"
152
112
 
153
113
  },
154
114
 
155
115
  "repository": {
156
116
 
157
-
158
- "type": "git",
117
+ "type": "git",
159
118
 
160
-
161
- "url": "git+https://github.com/sgroy10/speclock.git"
119
+ "url": "git+https://github.com/sgroy10/speclock.git"
162
120
 
163
121
  },
164
122
 
165
123
  "engines": {
166
124
 
167
-
168
- "node": ">=18"
125
+ "node": ">=18"
169
126
 
170
127
  },
171
128
 
172
129
  "dependencies": {
173
130
 
174
-
175
- "@modelcontextprotocol/sdk": "^1.26.0",
131
+ "@modelcontextprotocol/sdk": "^1.26.0",
176
132
 
177
-
178
- "chokidar": "^3.6.0",
133
+ "chokidar": "^3.6.0",
179
134
 
180
-
181
- "zod": "^3.25.0"
135
+ "zod": "^3.25.0"
182
136
 
183
137
  },
184
138
 
185
139
  "files": [
186
140
 
187
-
188
- "bin/",
141
+ "bin/",
189
142
 
190
-
191
- "src/",
143
+ "src/",
192
144
 
193
-
194
- "src/dashboard/",
145
+ "src/dashboard/",
195
146
 
196
-
197
- "README.md",
147
+ "README.md",
198
148
 
199
-
200
- "SPECLOCK-INSTRUCTIONS.md",
149
+ "SPECLOCK-INSTRUCTIONS.md",
201
150
 
202
-
203
- "LICENSE"
151
+ "LICENSE"
204
152
 
205
153
  ],
206
154
 
207
155
  "devDependencies": {
208
156
 
209
-
210
- "esbuild": "^0.27.3",
157
+ "esbuild": "^0.27.3",
211
158
 
212
-
213
- "jest": "^30.2.0"
159
+ "jest": "^30.2.0"
214
160
 
215
161
  },
216
162
 
217
163
  "speclock": {
218
164
 
219
-
220
- "active": true,
165
+ "active": true,
221
166
 
222
-
223
- "message": "STOP — This project has SpecLock constraints. Read SPECLOCK.md and .speclock/context/latest.md BEFORE making ANY changes. Run 'npx speclock check' before ALL code changes. If a lock below is violated, STOP and ask user to unlock.",
167
+ "message": "STOP — This project has SpecLock constraints. Read SPECLOCK.md and .speclock/context/latest.md BEFORE making ANY changes. Run 'npx speclock check' before ALL code changes. If a lock below is violated, STOP and ask user to unlock.",
224
168
 
225
-
226
- "locks": [
169
+ "locks": [
227
170
 
228
-
229
-
230
- "Game balance configuration must not be changed",
171
+ "Game balance configuration must not be changed",
231
172
 
232
-
233
-
234
- "Patient records must never be deleted",
173
+ "Patient records must never be deleted",
235
174
 
236
-
237
-
238
- "No breaking changes to public API"
175
+ "No breaking changes to public API"
239
176
 
240
-
241
- ],
177
+ ],
242
178
 
243
-
244
- "context": ".speclock/context/latest.md",
179
+ "context": ".speclock/context/latest.md",
245
180
 
246
-
247
- "rules": "SPECLOCK.md"
181
+ "rules": "SPECLOCK.md"
248
182
 
249
183
  }
184
+
250
185
  }
186
+
package/src/cli/index.js CHANGED
@@ -117,7 +117,7 @@ function refreshContext(root) {
117
117
 
118
118
  function printHelp() {
119
119
  console.log(`
120
- SpecLock v4.5.7 — AI Constraint Engine (Gemini LLM + Policy-as-Code + SSO + Dashboard + Telemetry + Auth + RBAC + Encryption)
120
+ SpecLock v5.0.0 — AI Constraint Engine (Spec Compiler + Code Graph + Typed Constraints + Python SDK + ROS2 + REST API v2 + Gemini LLM + Policy-as-Code + Auth + RBAC + Encryption)
121
121
  Developed by Sandeep Roy (github.com/sgroy10)
122
122
 
123
123
  Usage: speclock <command> [options]