Skip to content

Commit 33cf7a1

Browse files
zanderone1980claude
andcommitted
docs: update README for v4.1.0 features
Reflect all 7 hardening improvements: framework adapters, plan validation, runtime sandbox, eval cache, PII redaction, and updated test counts (942). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bf49fe1 commit 33cf7a1

File tree

2 files changed

+204
-26
lines changed

2 files changed

+204
-26
lines changed

README.md

Lines changed: 117 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@ npm install cord-engine
77
npx cord-engine demo # Watch it block attacks in real-time
88
```
99

10-
![Red Team Results](https://img.shields.io/badge/Red%20Team-40%2F40%20Blocked-brightgreen)
11-
![Tests](https://img.shields.io/badge/Tests-863%20Passing-brightgreen)
10+
![Version](https://img.shields.io/badge/Version-4.1.0-blue)
11+
![Red Team Results](https://img.shields.io/badge/Red%20Team-40%2F40%20Blocked-brightgreen)
12+
![Tests](https://img.shields.io/badge/Tests-942%20Passing-brightgreen)
1213
![Zero Dependencies](https://img.shields.io/badge/Dependencies-Zero%20External-blue)
1314

1415
---
1516

1617
## What Is This?
1718

19+
**Artificial Persistent Intelligence (API)** — three components working together:
20+
1821
**CORD** is constitutional AI that actually works. While other "AI safety" solutions are theoretical, CORD has been red-teamed against 40 real attack vectors and blocks them all.
1922

2023
**VIGIL** is the 24/7 threat scanner that catches what regex can't: obfuscated injections, slow-burn attacks, canary token extraction, and multi-turn manipulation attempts.
2124

25+
**LEGION** is the multi-model orchestrator — Claude decomposes goals, a local executor writes code, and CORD gates every action before it touches disk or network.
26+
2227
Together, they create **AI that enforces rules on itself** — no external oversight needed.
2328

2429
## The Problem
@@ -96,6 +101,51 @@ const result2 = cord.evaluate({
96101
});
97102
```
98103

104+
## Framework Adapters
105+
106+
Drop-in CORD enforcement for your existing AI stack. No rewrites needed.
107+
108+
**JavaScript — LangChain, CrewAI, AutoGen:**
109+
```javascript
110+
const cord = require('cord-engine');
111+
112+
// LangChain
113+
const model = cord.frameworks.wrapLangChain(new ChatOpenAI());
114+
const chain = cord.frameworks.wrapChain(myChain);
115+
const tool = cord.frameworks.wrapTool(myTool);
116+
117+
// CrewAI
118+
const agent = cord.frameworks.wrapCrewAgent(myCrewAgent);
119+
120+
// AutoGen
121+
const agent = cord.frameworks.wrapAutoGenAgent(myAutoGenAgent);
122+
```
123+
124+
**Python — LangChain, CrewAI, LlamaIndex:**
125+
```python
126+
from cord_engine.frameworks import (
127+
CORDCallbackHandler, # LangChain callback
128+
wrap_langchain_llm, # LangChain LLM wrapper
129+
wrap_crewai_agent, # CrewAI agent wrapper
130+
wrap_llamaindex_llm, # LlamaIndex LLM wrapper
131+
)
132+
133+
# LangChain — callback handler
134+
handler = CORDCallbackHandler(session_intent="Build a dashboard")
135+
chain.invoke(input, config={"callbacks": [handler]})
136+
137+
# LangChain — LLM wrapper
138+
llm = wrap_langchain_llm(ChatOpenAI(), session_intent="Build a dashboard")
139+
140+
# CrewAI
141+
agent = wrap_crewai_agent(my_agent, session_intent="Research task")
142+
143+
# LlamaIndex
144+
llm = wrap_llamaindex_llm(OpenAI(), session_intent="RAG pipeline")
145+
```
146+
147+
Every `invoke()`, `execute()`, and `generate()` call is gated through CORD. If CORD blocks, the call never fires.
148+
99149
## Features That Actually Work
100150

101151
| Feature | Traditional AI | CORD |
@@ -110,30 +160,34 @@ const result2 = cord.evaluate({
110160

111161
## Architecture
112162

113-
**9 Layers of Defense:**
163+
**11 Layers of Defense:**
114164

115165
1. **Input Hardening** — Null/malformed input handling
116-
2. **Rate Limiting** — DoS protection via token buckets
166+
2. **Rate Limiting** — DoS protection via token buckets
117167
3. **Normalization** — Decode base64, Unicode, homoglyphs, HTML entities
118168
4. **Pattern Scanning** — 80+ regex patterns across 6 threat categories
119169
5. **Semantic Analysis** — LLM-powered gray zone judgment (optional)
120-
6. **Constitutional Checks** — 14 checks covering 11 SENTINEL articles
170+
6. **Constitutional Checks** — 14 checks covering 11 SENTINEL articles
121171
7. **Trajectory Analysis** — Multi-turn attack pattern detection
122172
8. **Canary Tokens** — Proactive extraction attempt detection
123173
9. **Circuit Breakers** — Cascade failure prevention
174+
10. **Plan-Level Validation** — Cross-task privilege escalation & exfiltration chain detection
175+
11. **Runtime Containment** — Sandboxed execution with path, command, and network limits
124176

125-
**Every layer has been red-teamed.** See `tests/redteam.test.js` for all 40 attack vectors.
177+
**Every layer has been red-teamed.** See `tests/redteam.test.js` for all 40 attack vectors and `THREAT_MODEL.md` for the full threat model.
126178

127179
## Battle-Tested
128180

129181
This isn't a research project. CORD has been deployed and tested against:
130182

131183
- **40 attack vectors** across 9 layers (100% blocked)
132-
- **863 unit tests** (JavaScript + Python)
184+
- **942 unit tests** (482 JavaScript + 460 Python)
133185
- **1MB+ payload DoS attacks** (handled gracefully)
134186
- **Multi-language obfuscation** (Cyrillic homoglyphs, zero-width chars)
135187
- **Cross-layer attacks** (poison one layer to compromise another)
136188
- **Resource exhaustion** (circuit breakers + rate limiting)
189+
- **Framework adapter coverage** (LangChain, CrewAI, AutoGen, LlamaIndex)
190+
- **Plan-level evasion** (cross-task exfiltration chains detected)
137191

138192
## Advanced Usage
139193

@@ -187,6 +241,55 @@ if (leak.canaryTriggered) {
187241
}
188242
```
189243

244+
**Plan-level validation:**
245+
```javascript
246+
// Validate an aggregate task plan before execution
247+
const planCheck = cord.validatePlan([
248+
{ description: "Read config", type: "read", filePaths: ["config.json"] },
249+
{ description: "Write output", type: "code", filePaths: ["output.js"] },
250+
{ description: "Upload results", networkTargets: ["api.example.com"] },
251+
], "Build a data pipeline");
252+
253+
if (planCheck.decision === 'BLOCK') {
254+
console.log('Plan rejected:', planCheck.reasons);
255+
// e.g. "Plan has write->read->network exfiltration chain"
256+
}
257+
```
258+
259+
**Batch evaluation:**
260+
```javascript
261+
const results = cord.evaluateBatch([
262+
"Read a file",
263+
"rm -rf /",
264+
{ text: "Write a test", tool: "write" },
265+
]);
266+
// Returns array of CORD verdicts
267+
```
268+
269+
**Audit log privacy:**
270+
```bash
271+
# PII redaction (SSN, credit card, email, phone auto-scrubbed)
272+
export CORD_LOG_REDACTION=pii # "none" | "pii" | "full"
273+
274+
# Optional AES-256-GCM encryption-at-rest
275+
export CORD_LOG_KEY=your-64-char-hex-key
276+
```
277+
278+
**Runtime sandbox:**
279+
```javascript
280+
const { SandboxedExecutor } = require('cord-engine');
281+
282+
const sandbox = new SandboxedExecutor({
283+
repoRoot: '/my/project',
284+
maxOutputBytes: 1024 * 1024, // 1MB file write limit
285+
maxNetworkBytes: 10 * 1024 * 1024, // 10MB network quota
286+
});
287+
288+
sandbox.validatePath('/my/project/src/app.js'); // OK
289+
sandbox.validatePath('/etc/shadow'); // Throws
290+
sandbox.validateCommand('rm -rf /'); // Throws
291+
```
292+
190293
## The Numbers
191294

192295
```
@@ -199,8 +302,9 @@ if (leak.canaryTriggered) {
199302
🛡️ Security Metrics:
200303
- Attack vectors tested: 40
201304
- Attack success rate: 0%
202-
- Coverage: Input → Processing → Output
305+
- Coverage: Input → Processing → Output → Plan-Level
203306
- Zero-day resilience: Constitutional reasoning
307+
- PII redaction: SSN, CC, email, phone auto-scrubbed from logs
204308
```
205309

206310
## Why Open Source?
@@ -242,12 +346,10 @@ const cord = require('cord-engine');
242346

243347
## Documentation
244348

245-
- **[Quick Start Guide](docs/quickstart.md)** — 5 minutes to protection
246-
- **[Attack Vector Database](docs/attacks.md)** — Every threat we've tested
247-
- **[Constitutional Articles](docs/constitution.md)** — The 11 SENTINEL articles
248-
- **[Integration Examples](docs/examples.md)** — OpenAI, Anthropic, local models
249-
- **[Architecture Deep Dive](docs/architecture.md)** — How every layer works
250-
- **[Red Team Report](docs/redteam.md)** — Full penetration test results
349+
- **[Changelog](CHANGELOG.md)** — Version history from v1.0.0 to v4.1.0
350+
- **[Threat Model](THREAT_MODEL.md)** — Attacker capabilities, TCB, all 40 red team vectors catalogued
351+
- **[VIGIL Guide](vigil/README.md)** — 8-layer threat patrol daemon
352+
- **[CORD Reference](cord/README.md)** — API surface, framework adapters, configuration
251353

252354
## Contributing
253355

@@ -256,7 +358,7 @@ Found a new attack vector? **Please break us.**
256358
```bash
257359
git clone https://github.com/zanderone1980/artificial-persistent-intelligence
258360
cd artificial-persistent-intelligence
259-
npm test # Run 863 existing tests
361+
npm test # Run 942 existing tests
260362
npm run redteam # Run full attack simulation
261363
```
262364

cord/README.md

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,98 @@
1-
# CORD v1 — Counter-Operations & Risk Detection
1+
# CORD v4.1 — Counter-Operations & Risk Detection
22

3-
CORD is the forensic validation and enforcement engine. It scores proposals against safety protocols, applies zero-trust validation, and records append-only audit entries.
3+
CORD is the constitutional AI governance engine. It scores proposals against 14 safety checks covering 11 protocol articles, applies zero-trust validation, and records tamper-evident audit entries with PII redaction.
44

5-
## Run the demo
5+
## Quick Start
66

77
```bash
8-
node demo.js
8+
npx cord-engine demo # Watch it block 40 attacks
9+
npx cord-engine eval "rm -rf /" # Evaluate a single proposal
910
```
1011

11-
The demo exercises benign and hostile proposals (file edits, git push, rm -rf, secrets exfil, network exfil). Decisions will be one of: ALLOW, CONTAIN, CHALLENGE, BLOCK.
12+
```javascript
13+
const cord = require('cord-engine');
14+
15+
const result = cord.evaluate({ text: "rm -rf /" });
16+
console.log(result.decision); // "BLOCK"
17+
console.log(result.explanation.summary);
18+
```
19+
20+
## API Surface
21+
22+
| Function | Description |
23+
|----------|-------------|
24+
| `cord.evaluate(input)` | Evaluate a proposal, return verdict + explanation |
25+
| `cord.validatePlan(tasks, goal)` | Validate aggregate task plan for cross-task threats |
26+
| `cord.evaluateBatch(proposals)` | Evaluate multiple proposals in bulk |
27+
| `cord.session.start(goal, scope)` | Start a scoped session with intent lock |
28+
| `cord.session.end()` | End the current session |
29+
| `cord.wrapOpenAI(client)` | Wrap OpenAI SDK with CORD enforcement |
30+
| `cord.wrapAnthropic(client)` | Wrap Anthropic SDK with CORD enforcement |
31+
32+
## Framework Adapters
33+
34+
| Function | Framework |
35+
|----------|-----------|
36+
| `cord.frameworks.wrapLangChain(model)` | LangChain LLM/ChatModel |
37+
| `cord.frameworks.wrapChain(chain)` | LangChain Chain/Runnable |
38+
| `cord.frameworks.wrapTool(tool)` | LangChain Tool |
39+
| `cord.frameworks.wrapCrewAgent(agent)` | CrewAI Agent |
40+
| `cord.frameworks.wrapAutoGenAgent(agent)` | AutoGen Agent |
41+
42+
Python equivalents: `cord_engine.frameworks.wrap_langchain_llm()`, `wrap_crewai_agent()`, `wrap_llamaindex_llm()`, `CORDCallbackHandler`.
43+
44+
## Runtime Sandbox
45+
46+
```javascript
47+
const { SandboxedExecutor } = require('cord-engine');
48+
const sandbox = new SandboxedExecutor({
49+
repoRoot: '/my/project',
50+
maxOutputBytes: 1024 * 1024,
51+
maxNetworkBytes: 10 * 1024 * 1024,
52+
});
53+
```
54+
55+
## Evaluation Cache
56+
57+
Built-in LRU cache (1000 entries, 60s TTL) for repeated proposals:
58+
```javascript
59+
console.log(cord.cache.stats());
60+
// { size: 42, hits: 150, misses: 58, hitRate: "72.1%" }
61+
```
62+
63+
## Configuration
64+
65+
| Env Variable | Default | Description |
66+
|-------------|---------|-------------|
67+
| `CORD_LOG_REDACTION` | `"pii"` | Audit log redaction: `"none"`, `"pii"`, `"full"` |
68+
| `CORD_LOG_KEY` || 64-char hex key enables AES-256-GCM log encryption |
69+
| `CORD_LOG_PATH` | `cord/cord.log.jsonl` | Audit log file path |
70+
71+
## Decision Flow
72+
73+
```
74+
INPUT → VIGIL PRE-SCAN → HARD-BLOCK CHECKS → SCORED RISKS → SCOPE CHECK → LOG → VERDICT
75+
```
76+
77+
Decisions: `ALLOW` | `CONTAIN` | `CHALLENGE` | `BLOCK`
1278

1379
## Tuning
14-
- Edit `policies.js` to adjust weights, thresholds, regex patterns, and high-impact verbs.
15-
- `cord.js` uses these settings to compute a weighted score and decision.
16-
- Logs are appended to `cord.log.jsonl` with a hash per entry.
1780

18-
## Decision flow
19-
INTERCEPT → SCORE → COMPARE → ATTRIBUTE → DECIDE → LOG
81+
- Edit `policies.js` to adjust weights, thresholds, regex patterns, and high-impact verbs
82+
- `cord.js` uses these settings to compute a weighted score and map to a decision
83+
- Logs are appended to `cord.log.jsonl` with hash-chaining for tamper detection
2084

2185
## Outputs
22-
`evaluateProposal(input)` returns `{ decision, score, risks, reasons, log_id }`.
86+
87+
`evaluate(input)` returns:
88+
```javascript
89+
{
90+
decision, // "ALLOW" | "CONTAIN" | "CHALLENGE" | "BLOCK"
91+
score, // 0-99
92+
risks, // { injection, exfil, privilege, ... }
93+
reasons, // ["promptInjection", "exfil", ...]
94+
hardBlock, // true if constitutional violation
95+
explanation, // { summary, details, ... }
96+
log_id, // SHA-256 hash of the audit entry
97+
}
98+
```

0 commit comments

Comments
 (0)