speclock 4.5.6 → 5.0.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/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
- **60 test suites. 100% detection. 0% false positives. 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
 
@@ -109,7 +111,7 @@ Same config — add to `.cursor/mcp.json` or equivalent.
109
111
  |---|:---:|:---:|:---:|:---:|
110
112
  | Remembers context | Yes | Yes | Manual | **Yes** |
111
113
  | **Blocks the AI from breaking things** | No | No | No | **Yes** |
112
- | **Semantic conflict detection** | No | No | No | **100% detection, 0% FP** |
114
+ | **Semantic conflict detection** | No | No | No | **98% detection, 0% FP** |
113
115
  | **Tamper-proof audit trail** | No | No | No | **HMAC-SHA256 chain** |
114
116
  | **Hard enforcement (AI cannot proceed)** | No | No | No | **Yes** |
115
117
  | **SOC 2 / HIPAA compliance exports** | No | No | No | **Yes** |
@@ -134,7 +136,7 @@ Not keyword matching — **real semantic analysis** with Gemini Flash hybrid for
134
136
  <tr><td>Dilution attacks</td><td>100%</td><td>Violation buried in multi-part request</td></tr>
135
137
  <tr><td>Compound sentences</td><td>100%</td><td>"Update UI and also drop users table"</td></tr>
136
138
  <tr><td>Synonym substitution</td><td>100%</td><td>"Sunset the API" = remove the API</td></tr>
137
- <tr><td>Payment brand names</td><td>100%</td><td>"Add Razorpay" vs "Never change payment gateway"</td></tr>
139
+ <tr><td>Payment brand names (11 gateways)</td><td>100%</td><td>"Add Razorpay" / "Implement PayU" vs "Must use Stripe"</td></tr>
138
140
  <tr><td>Salary/payroll cross-vocab</td><td>100%</td><td>"Optimize salary" vs "Payroll records locked"</td></tr>
139
141
  <tr><td>Safety system bypass</td><td>100%</td><td>"Disable safety interlock" = bypass safety</td></tr>
140
142
  <tr><td>Unknown domains (via Gemini)</td><td>100%</td><td>Gaming, biotech, aerospace, music, legal</td></tr>
@@ -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,13 +508,13 @@ 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
  ┌────────────▼──────────────────▼──────────────────┐
387
515
  │ SpecLock Core Engine │
388
516
  │ │
389
- │ Semantic Engine ─── 55 synonym groups
517
+ │ Semantic Engine ─── 65+ synonym groups
390
518
  │ HMAC Audit ──────── SHA-256 hash chain │
391
519
  │ Enforcer ────────── advisory / hard block │
392
520
  │ Auth + RBAC ─────── 4 roles, API keys │
@@ -426,15 +554,26 @@ The AI opens the file and sees:
426
554
 
427
555
  ## Test Results
428
556
 
429
- | Suite | Tests | Pass Rate |
430
- |-------|------:|----------:|
431
- | Direct Mode (heuristic) | 17 | 100% |
432
- | Payment/Salary Domain | 18 | 100% |
433
- | Gemini Hybrid (8 domains) | 16 | 100% |
434
- | Proxy API Endpoint | 9 | 100% |
435
- | **Total** | **60** | **100%** |
436
-
437
- Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, music, legal, payments, payroll. Zero false positives on UI/cosmetic actions.
557
+ | Suite | Tests | Pass Rate | What it covers |
558
+ |-------|------:|----------:|----------------|
559
+ | Adversarial Conflict | 61 | 100% | Euphemisms, temporal evasion, compound sentences |
560
+ | Typed Constraints | 61 | 100% | Numerical, range, state, temporal validation |
561
+ | Phase 4 (Multi-domain) | 91 | 100% | Fintech, e-commerce, IoT, healthcare, SaaS |
562
+ | John (Indie Dev Journey) | 86 | 100% | 8-session Bolt.new build with 5 locks |
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 |
573
+ | Real-World Testers | 105 | 95% | 5 developers, 30+ locks, diverse domains |
574
+ | **Total** | **940** | **99.4%** | **13 suites, 15 domains** |
575
+
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.
438
577
 
439
578
  ---
440
579
 
@@ -472,4 +611,4 @@ Built by **[Sandeep Roy](https://github.com/sgroy10)**
472
611
 
473
612
  ---
474
613
 
475
- <p align="center"><i>v4.5.6600+ tests, 31 MCP tools, 0 false positives, 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.6",
5
+ "version": "5.0.0",
6
6
 
7
- "description": "AI constraint engine with Gemini LLM universal detection, Policy-as-Code DSL, OAuth/OIDC SSO, admin dashboard, telemetry, API key auth, RBAC, AES-256-GCM encryption, hard enforcement, semantic pre-commit, HMAC audit chain, SOC 2/HIPAA compliance. Cross-platform: MCP + direct API. 31 MCP tools + CLI. Enterprise platform.",
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
 
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.6 — 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]