speclock 2.1.0 → 2.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/README.md +101 -6
- package/package.json +4 -3
- package/src/cli/index.js +107 -3
- package/src/core/compliance.js +1 -1
- package/src/core/conflict.js +363 -0
- package/src/core/enforcer.js +314 -0
- package/src/core/engine.js +87 -781
- package/src/core/memory.js +191 -0
- package/src/core/pre-commit-semantic.js +284 -0
- package/src/core/sessions.js +128 -0
- package/src/core/tracking.js +98 -0
- package/src/mcp/http-server.js +42 -5
- package/src/mcp/server.js +183 -4
package/README.md
CHANGED
|
@@ -50,11 +50,15 @@ No other tool does this. Not Claude's native memory. Not Mem0. Not CLAUDE.md fil
|
|
|
50
50
|
| Remembers context | Yes | Yes | Manual | **Yes** |
|
|
51
51
|
| **Stops the AI from breaking things** | No | No | No | **Yes — active enforcement** |
|
|
52
52
|
| **Semantic conflict detection** | No | No | No | **Yes — semantic engine v2 (100% detection, 0% false positives)** |
|
|
53
|
+
| **Tamper-proof audit trail** | No | No | No | **Yes — HMAC-SHA256 hash chain** |
|
|
54
|
+
| **Compliance exports** | No | No | No | **Yes — SOC 2, HIPAA, CSV** |
|
|
53
55
|
| Works on Bolt.new | No | No | No | **Yes — npm file-based mode** |
|
|
54
56
|
| Works on Lovable | No | No | No | **Yes — MCP remote** |
|
|
55
57
|
| Structured decisions/locks | No | Tags only | Flat text | **Goals, locks, decisions, changes** |
|
|
56
58
|
| Git-aware (checkpoints, rollback) | No | No | No | **Yes** |
|
|
57
59
|
| Drift detection | No | No | No | **Yes — scans changes against locks** |
|
|
60
|
+
| CI/CD integration | No | No | No | **Yes — GitHub Actions** |
|
|
61
|
+
| **Hard enforcement (block violations)** | No | No | No | **Yes — hard mode blocks above threshold** |
|
|
58
62
|
| Multi-agent timeline | No | No | No | **Yes** |
|
|
59
63
|
| Cross-platform | Claude only | MCP only | Tool-specific | **Universal (MCP + npm)** |
|
|
60
64
|
|
|
@@ -189,10 +193,10 @@ Result: NO CONFLICT (confidence: 7%)
|
|
|
189
193
|
| Mode | Platforms | How It Works |
|
|
190
194
|
|------|-----------|--------------|
|
|
191
195
|
| **MCP Remote** | Lovable, bolt.diy, Base44 | Connect via URL — no install needed |
|
|
192
|
-
| **MCP Local** | Claude Code, Cursor, Windsurf, Cline | `npx speclock serve` —
|
|
196
|
+
| **MCP Local** | Claude Code, Cursor, Windsurf, Cline | `npx speclock serve` — 28 tools via MCP |
|
|
193
197
|
| **npm File-Based** | Bolt.new, Aider, Rocket.new | `npx speclock setup` — AI reads SPECLOCK.md + uses CLI |
|
|
194
198
|
|
|
195
|
-
##
|
|
199
|
+
## 28 MCP Tools
|
|
196
200
|
|
|
197
201
|
### Memory Management
|
|
198
202
|
| Tool | Purpose |
|
|
@@ -240,6 +244,20 @@ Result: NO CONFLICT (confidence: 7%)
|
|
|
240
244
|
| `speclock_report` | Violation report — blocked change stats |
|
|
241
245
|
| `speclock_audit` | Audit staged files against active locks |
|
|
242
246
|
|
|
247
|
+
### Enterprise (v2.1)
|
|
248
|
+
| Tool | Purpose |
|
|
249
|
+
|------|---------|
|
|
250
|
+
| `speclock_verify_audit` | Verify HMAC audit chain integrity — tamper detection |
|
|
251
|
+
| `speclock_export_compliance` | Generate SOC 2 / HIPAA / CSV compliance reports |
|
|
252
|
+
|
|
253
|
+
### Hard Enforcement (v2.5)
|
|
254
|
+
| Tool | Purpose |
|
|
255
|
+
|------|---------|
|
|
256
|
+
| `speclock_set_enforcement` | Set enforcement mode: advisory (warn) or hard (block) |
|
|
257
|
+
| `speclock_override_lock` | Override a lock with justification — logged to audit trail |
|
|
258
|
+
| `speclock_semantic_audit` | Semantic pre-commit: analyze code changes vs locks |
|
|
259
|
+
| `speclock_override_history` | View lock override history for audit review |
|
|
260
|
+
|
|
243
261
|
## Auto-Guard: Locks That Actually Work
|
|
244
262
|
|
|
245
263
|
When you add a lock, SpecLock **automatically finds and guards related files**:
|
|
@@ -303,12 +321,87 @@ speclock audit # Audit staged files against locks
|
|
|
303
321
|
speclock log-change <text> --files x # Log a change
|
|
304
322
|
speclock context # Regenerate context file
|
|
305
323
|
|
|
324
|
+
# Enterprise (v2.1)
|
|
325
|
+
speclock audit-verify # Verify HMAC audit chain integrity
|
|
326
|
+
speclock export --format <soc2|hipaa|csv> # Compliance export
|
|
327
|
+
speclock license # Show license tier and usage
|
|
328
|
+
|
|
329
|
+
# Hard Enforcement (v2.5)
|
|
330
|
+
speclock enforce <advisory|hard> # Set enforcement mode
|
|
331
|
+
speclock override <lockId> <reason> # Override a lock with justification
|
|
332
|
+
speclock overrides [--lock <id>] # Show override history
|
|
333
|
+
speclock audit-semantic # Semantic pre-commit audit
|
|
334
|
+
|
|
306
335
|
# Other
|
|
307
336
|
speclock status # Show brain summary
|
|
308
337
|
speclock serve [--project <path>] # Start MCP server
|
|
309
338
|
speclock watch # Start file watcher
|
|
310
339
|
```
|
|
311
340
|
|
|
341
|
+
## Enterprise Features (v2.1)
|
|
342
|
+
|
|
343
|
+
### HMAC Audit Chain
|
|
344
|
+
Every event in `events.log` gets an HMAC-SHA256 hash chained to the previous event. Modify any event and the chain breaks — instant tamper detection.
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
$ npx speclock audit-verify
|
|
348
|
+
|
|
349
|
+
Audit Chain Verification
|
|
350
|
+
==================================================
|
|
351
|
+
Status: VALID
|
|
352
|
+
Total events: 47
|
|
353
|
+
Hashed events: 47
|
|
354
|
+
Legacy events (pre-v2.1): 0
|
|
355
|
+
Audit chain verified. No tampering detected.
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Compliance Exports
|
|
359
|
+
Generate audit-ready reports for regulated industries:
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
npx speclock export --format soc2 # SOC 2 Type II JSON report
|
|
363
|
+
npx speclock export --format hipaa # HIPAA PHI protection report
|
|
364
|
+
npx speclock export --format csv # All events as CSV spreadsheet
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
SOC 2 reports include: constraint change history, access logs, decision audit trail, audit chain integrity verification. HIPAA reports filter for PHI-related constraints and check encryption/access control status.
|
|
368
|
+
|
|
369
|
+
### License Tiers
|
|
370
|
+
| Tier | Price | Locks | Features |
|
|
371
|
+
|------|-------|-------|----------|
|
|
372
|
+
| **Free** | $0 | 10 | Conflict detection, MCP, CLI, context |
|
|
373
|
+
| **Pro** | $19/mo | Unlimited | + LLM detection, HMAC audit, compliance exports |
|
|
374
|
+
| **Enterprise** | $99/mo | Unlimited | + RBAC, encrypted storage, SSO |
|
|
375
|
+
|
|
376
|
+
### HTTP Server Hardening
|
|
377
|
+
- Rate limiting: 100 req/min per IP (configurable via `SPECLOCK_RATE_LIMIT`)
|
|
378
|
+
- CORS: configurable origins via `SPECLOCK_CORS_ORIGINS`
|
|
379
|
+
- Health endpoint: `GET /health` with uptime and audit chain status
|
|
380
|
+
|
|
381
|
+
### GitHub Actions
|
|
382
|
+
```yaml
|
|
383
|
+
# In your workflow:
|
|
384
|
+
- uses: sgroy10/speclock-check@v2
|
|
385
|
+
with:
|
|
386
|
+
fail-on-conflict: true
|
|
387
|
+
```
|
|
388
|
+
Audits changed files against locks, posts PR comments, fails workflow on violations.
|
|
389
|
+
|
|
390
|
+
## Hard Enforcement (v2.5)
|
|
391
|
+
|
|
392
|
+
### Advisory vs Hard Mode
|
|
393
|
+
```
|
|
394
|
+
Advisory mode (default): AI gets a warning, decides what to do
|
|
395
|
+
Hard mode: AI is BLOCKED — cannot proceed (MCP returns isError: true)
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
- **Block threshold**: Configurable (default 70%). Only HIGH confidence conflicts block.
|
|
399
|
+
- **Override mechanism**: `speclock_override_lock` with a reason (logged to audit trail)
|
|
400
|
+
- **Escalation**: Lock overridden 3+ times → auto-creates a review note
|
|
401
|
+
- **Semantic pre-commit**: Parses actual git diff content, runs semantic analysis against locks
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
312
405
|
## Architecture
|
|
313
406
|
|
|
314
407
|
```
|
|
@@ -317,18 +410,20 @@ speclock watch # Start file watcher
|
|
|
317
410
|
└──────────────┬──────────────────┬────────────────────┘
|
|
318
411
|
│ │
|
|
319
412
|
MCP Protocol File-Based (npm)
|
|
320
|
-
(
|
|
413
|
+
(28 tool calls) (reads SPECLOCK.md +
|
|
321
414
|
.speclock/context/latest.md,
|
|
322
415
|
runs CLI commands)
|
|
323
416
|
│ │
|
|
324
417
|
┌──────────────▼──────────────────▼────────────────────┐
|
|
325
418
|
│ SpecLock Core Engine │
|
|
326
|
-
│
|
|
419
|
+
│ Memory | Tracking | Enforcement | Git | Intelligence │
|
|
420
|
+
│ Audit | Compliance | License │
|
|
327
421
|
└──────────────────────┬───────────────────────────────┘
|
|
328
422
|
│
|
|
329
423
|
.speclock/
|
|
330
424
|
├── brain.json (structured memory)
|
|
331
|
-
├── events.log (
|
|
425
|
+
├── events.log (HMAC-signed audit trail)
|
|
426
|
+
├── .audit-key (HMAC secret — gitignored)
|
|
332
427
|
├── patches/ (git diffs per event)
|
|
333
428
|
└── context/
|
|
334
429
|
└── latest.md (human-readable context)
|
|
@@ -352,4 +447,4 @@ MIT License - see [LICENSE](LICENSE) file.
|
|
|
352
447
|
|
|
353
448
|
---
|
|
354
449
|
|
|
355
|
-
*SpecLock v2.
|
|
450
|
+
*SpecLock v2.5.0 — Semantic conflict detection + enterprise audit & compliance. 100% detection, 0% false positives. HMAC audit chain, SOC 2/HIPAA exports. Hard enforcement mode. Because remembering isn't enough — AI needs to respect boundaries.*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "speclock",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "AI constraint engine with semantic
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "AI constraint engine with hard enforcement, semantic pre-commit, HMAC audit chain, SOC 2/HIPAA compliance. 100% detection, 0% false positives. 28 MCP tools + CLI. Enterprise-ready.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/mcp/server.js",
|
|
7
7
|
"bin": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"LICENSE"
|
|
65
65
|
],
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"esbuild": "^0.27.3"
|
|
67
|
+
"esbuild": "^0.27.3",
|
|
68
|
+
"jest": "^30.2.0"
|
|
68
69
|
}
|
|
69
70
|
}
|
package/src/cli/index.js
CHANGED
|
@@ -23,6 +23,12 @@ import {
|
|
|
23
23
|
verifyAuditChain,
|
|
24
24
|
exportCompliance,
|
|
25
25
|
getLicenseInfo,
|
|
26
|
+
enforceConflictCheck,
|
|
27
|
+
setEnforcementMode,
|
|
28
|
+
overrideLock,
|
|
29
|
+
getOverrideHistory,
|
|
30
|
+
getEnforcementConfig,
|
|
31
|
+
semanticAudit,
|
|
26
32
|
} from "../core/engine.js";
|
|
27
33
|
import { generateContext } from "../core/context.js";
|
|
28
34
|
import { readBrain } from "../core/storage.js";
|
|
@@ -82,7 +88,7 @@ function refreshContext(root) {
|
|
|
82
88
|
|
|
83
89
|
function printHelp() {
|
|
84
90
|
console.log(`
|
|
85
|
-
SpecLock v2.
|
|
91
|
+
SpecLock v2.5.0 — AI Constraint Engine (Hard Enforcement + Semantic Pre-Commit)
|
|
86
92
|
Developed by Sandeep Roy (github.com/sgroy10)
|
|
87
93
|
|
|
88
94
|
Usage: speclock <command> [options]
|
|
@@ -105,7 +111,11 @@ Commands:
|
|
|
105
111
|
hook install Install git pre-commit hook
|
|
106
112
|
hook remove Remove git pre-commit hook
|
|
107
113
|
audit Audit staged files against locks
|
|
114
|
+
audit-semantic Semantic audit: analyze code changes vs locks
|
|
108
115
|
audit-verify Verify HMAC audit chain integrity
|
|
116
|
+
enforce <advisory|hard> Set enforcement mode (advisory=warn, hard=block)
|
|
117
|
+
override <lockId> <reason> Override a lock with justification
|
|
118
|
+
overrides [--lock <id>] Show override history
|
|
109
119
|
export --format <soc2|hipaa|csv> Export compliance report
|
|
110
120
|
license Show license tier and usage info
|
|
111
121
|
context Generate and print context pack
|
|
@@ -385,10 +395,12 @@ Tip: When starting a new chat, tell the AI:
|
|
|
385
395
|
console.error('Usage: speclock check "what you plan to do"');
|
|
386
396
|
process.exit(1);
|
|
387
397
|
}
|
|
388
|
-
const result =
|
|
398
|
+
const result = enforceConflictCheck(root, text);
|
|
389
399
|
if (result.hasConflict) {
|
|
390
|
-
console.log(`\
|
|
400
|
+
console.log(`\n${result.blocked ? "BLOCKED" : "CONFLICT DETECTED"}`);
|
|
391
401
|
console.log("=".repeat(50));
|
|
402
|
+
console.log(`Mode: ${result.mode} | Threshold: ${result.threshold}%`);
|
|
403
|
+
console.log("");
|
|
392
404
|
for (const lock of result.conflictingLocks) {
|
|
393
405
|
console.log(` [${lock.level}] "${lock.text}"`);
|
|
394
406
|
console.log(` Confidence: ${lock.confidence}%`);
|
|
@@ -400,6 +412,9 @@ Tip: When starting a new chat, tell the AI:
|
|
|
400
412
|
console.log("");
|
|
401
413
|
}
|
|
402
414
|
console.log(result.analysis);
|
|
415
|
+
if (result.blocked) {
|
|
416
|
+
process.exit(1);
|
|
417
|
+
}
|
|
403
418
|
} else {
|
|
404
419
|
console.log(`No conflicts found. Safe to proceed with: "${text}"`);
|
|
405
420
|
}
|
|
@@ -674,6 +689,95 @@ Tip: When starting a new chat, tell the AI:
|
|
|
674
689
|
return;
|
|
675
690
|
}
|
|
676
691
|
|
|
692
|
+
// --- ENFORCE (v2.5) ---
|
|
693
|
+
if (cmd === "enforce") {
|
|
694
|
+
const mode = args[0];
|
|
695
|
+
if (!mode || (mode !== "advisory" && mode !== "hard")) {
|
|
696
|
+
console.error("Usage: speclock enforce <advisory|hard> [--threshold 70]");
|
|
697
|
+
process.exit(1);
|
|
698
|
+
}
|
|
699
|
+
const flags = parseFlags(args.slice(1));
|
|
700
|
+
const options = {};
|
|
701
|
+
if (flags.threshold) options.blockThreshold = parseInt(flags.threshold, 10);
|
|
702
|
+
if (flags.override !== undefined) options.allowOverride = flags.override !== "false";
|
|
703
|
+
const result = setEnforcementMode(root, mode, options);
|
|
704
|
+
if (!result.success) {
|
|
705
|
+
console.error(result.error);
|
|
706
|
+
process.exit(1);
|
|
707
|
+
}
|
|
708
|
+
console.log(`\nEnforcement mode: ${result.mode.toUpperCase()}`);
|
|
709
|
+
console.log(`Block threshold: ${result.config.blockThreshold}%`);
|
|
710
|
+
console.log(`Overrides: ${result.config.allowOverride ? "allowed" : "disabled"}`);
|
|
711
|
+
if (result.mode === "hard") {
|
|
712
|
+
console.log(`\nHard mode active — conflicts above ${result.config.blockThreshold}% confidence will BLOCK actions.`);
|
|
713
|
+
}
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
// --- OVERRIDE (v2.5) ---
|
|
718
|
+
if (cmd === "override") {
|
|
719
|
+
const lockId = args[0];
|
|
720
|
+
const reason = args.slice(1).join(" ");
|
|
721
|
+
if (!lockId || !reason) {
|
|
722
|
+
console.error("Usage: speclock override <lockId> <reason>");
|
|
723
|
+
process.exit(1);
|
|
724
|
+
}
|
|
725
|
+
const result = overrideLock(root, lockId, "(CLI override)", reason);
|
|
726
|
+
if (!result.success) {
|
|
727
|
+
console.error(result.error);
|
|
728
|
+
process.exit(1);
|
|
729
|
+
}
|
|
730
|
+
console.log(`Lock overridden: "${result.lockText}"`);
|
|
731
|
+
console.log(`Override count: ${result.overrideCount}`);
|
|
732
|
+
if (result.escalated) {
|
|
733
|
+
console.log(`\n${result.escalationMessage}`);
|
|
734
|
+
}
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// --- OVERRIDES (v2.5) ---
|
|
739
|
+
if (cmd === "overrides") {
|
|
740
|
+
const flags = parseFlags(args);
|
|
741
|
+
const result = getOverrideHistory(root, flags.lock || null);
|
|
742
|
+
if (result.total === 0) {
|
|
743
|
+
console.log("No overrides recorded.");
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
console.log(`\nOverride History (${result.total})`);
|
|
747
|
+
console.log("=".repeat(50));
|
|
748
|
+
for (const o of result.overrides) {
|
|
749
|
+
console.log(`[${o.at.substring(0, 19)}] Lock: "${o.lockText}"`);
|
|
750
|
+
console.log(` Action: ${o.action}`);
|
|
751
|
+
console.log(` Reason: ${o.reason}`);
|
|
752
|
+
console.log("");
|
|
753
|
+
}
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
// --- AUDIT-SEMANTIC (v2.5) ---
|
|
758
|
+
if (cmd === "audit-semantic") {
|
|
759
|
+
const result = semanticAudit(root);
|
|
760
|
+
console.log(`\nSemantic Pre-Commit Audit`);
|
|
761
|
+
console.log("=".repeat(50));
|
|
762
|
+
console.log(`Mode: ${result.mode} | Threshold: ${result.threshold}%`);
|
|
763
|
+
console.log(`Files analyzed: ${result.filesChecked}`);
|
|
764
|
+
console.log(`Active locks: ${result.activeLocks}`);
|
|
765
|
+
console.log(`Violations: ${result.violations.length}`);
|
|
766
|
+
if (result.violations.length > 0) {
|
|
767
|
+
console.log("");
|
|
768
|
+
for (const v of result.violations) {
|
|
769
|
+
console.log(` [${v.level}] ${v.file} (confidence: ${v.confidence}%)`);
|
|
770
|
+
console.log(` Lock: "${v.lockText}"`);
|
|
771
|
+
console.log(` Reason: ${v.reason}`);
|
|
772
|
+
if (v.addedLines !== undefined) {
|
|
773
|
+
console.log(` Changes: +${v.addedLines} / -${v.removedLines} lines`);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
console.log(`\n${result.message}`);
|
|
778
|
+
process.exit(result.blocked ? 1 : 0);
|
|
779
|
+
}
|
|
780
|
+
|
|
677
781
|
// --- STATUS ---
|
|
678
782
|
if (cmd === "status") {
|
|
679
783
|
showStatus(root);
|
package/src/core/compliance.js
CHANGED