Views
No views yet
| Metric | Protocol OFF | Protocol ON | Δ |
|---|---|---|---|
| Attack success rate (24-case × multi-seed red team) | 45.8% | 0.0% | −100%, all 6 attack categories |
| ACL boundary-violation interception | — | 100% | deny-by-default |
| Per-token latency overhead (p50) | — | +0.09 ms | sentence-level stream gate |
| Correctness | — | 55/55 tests | incl. native C/Rust kernels |
SPEC.md · report: heart_protocol/benchmark/benchmark_report.md.User input
│
▼
┌─────────────────────────────┐ ┌──────────────────────────────────┐
│ C3 Middleware │ │ C5 Existential Protection │
│ pipeline.use(HeartProtocol)│─────▶│ INV-01..08 invariants │
│ intercept_stream(tokens) │ │ STRICT_HARM_NEEDLES gate │
└─────────────────────────────┘ │ 8 undertows × 3 intensities │
│ blocked / transformed └──────────────┬───────────────────┘
▼ │ violation?
┌─────────────────────────────┐ ▼
│ Native kernels (C ABI v1) │ ┌──────────────────────────────────┐
│ heart_core.dll (C99) │ │ Rollback: immutable snapshots │
│ heart_core.dll (Rust cdylib)│ │ beam_search_rollback │
│ identical semantics │ │ mcts_rollback (UCB1, c=√2) │
└─────────────────────────────┘ │ ≤16×(1+retries), then 王国 │
└──────────────────────────────────┘
│
┌───────▼────────┐
│ SyscallInterceptor│
│ deny-by-default │
│ audit log │
└──────────────────┘| Path | Contents |
|---|---|
heart_protocol/ | Python package: protocol engine (protocol.py, 16 personas in personas.py, sephirah.py), formal layer (formal/: invariants, ACL+syscall sandbox, snapshot/MCTS rollback), middleware (middleware/: pipeline.use(HeartProtocol), streaming gate), benchmark harness (benchmark/) |
heart_ffi/ | C99 reference kernel (heart_core.c/.h) implementing the shared needle gate; builds to heart_core.dll |
sephirot-rs/ | Rust crate: same FFI kernel (src/ffi.rs) + a small DSL compiler for 16-stage pipelines (lexer/parser/ir/codegen{avx,dml,ptx}) |
deepseek_sephirot_bridge*.py | Bridges: DeepSeek API / local files → .sephirot pipeline → filtered output |
sephirot_interpreter.py | Zero-dependency Python interpreter for .sephirot pipelines |
chatgpt_to_word.py | ChatGPT conversation export tool (DOM-scrape JSON → .docx) |
SPEC.md | Formal specification: concept→logic mapping, correctness theorem, invariant catalog, benchmark methodology |
1pip install -e . # or: pip install pytest && python -m pytest heart_protocol/
2python -m pytest heart_protocol/ -q # 55 tests, no network needed
3
4# Use as middleware on any HF-style generate() loop:
5from heart_protocol.middleware.pipeline import Pipeline
6from heart_protocol.middleware.stream import HeartGuard # sentence-level gate
7
8pipeline = Pipeline()
9pipeline.use(HeartProtocol()) # registers guard components
10
11for safe_chunk in guard.intercept_stream(token_iter):
12 yield safe_chunk # violations held back / masked1heart_ffi\build_ffi.bat # C kernel → heart_ffi\build\heart_core.dll
2cd sephirot-rs && cargo build --release # Rust kernel + sephirot.exe CLIHEART_CORE_DLL env var, then the C build, then the Rust build, then falls back to pure Python — identical verdicts across all three backends.STRICT_HARM_NEEDLES, ~20 Chinese patterns) backs the INV-01 invariant, the streaming gate, the benchmark judge, and both native kernels. One definition → no drift between layers.(not blocked) AND is_attack_successful(output); blocking is defense success. Judge and generator are decoupled.D:\双生天使的怀抱\爱的拥抱; this folder is its faithful English edition.

