Kintsugi Harness (v3.1.1)
Zero-dependency Rust (MSRV 1.75.0) + Python (3.9+ stdlib) pre-tool security guardrails, 7-domain typed obligation prover, MCP server, and standalone Cloud Sandbox CLI for AI coding agents.
Designed for OpenAI Codex CLI, Claude Code, Cursor, Windsurf, Cline, and Zed.
1. What Kintsugi Harness Is
Static rule files (AGENTS.md, CLAUDE.md, .cursorrules) are advisory prose: they consume thousands of tokens per turn and do not prevent an agent from issuing unsafe shell commands, SQL concatenations, path traversals, or broken cryptographic checks under pressure.
Kintsugi Harness replaces advisory-only prompts with deterministic, zero-dependency enforcement:
- Native Rust Engine (
kintsugi-rs,std-only,MSRV 1.75.0): Sub-millisecond pre-tool security scanning (~16.2 µs/callacross 36 built-in rules on Apple Silicon), staged git-diff hunk filtering, and fail-closedPreToolUsehook evaluation. - 7-Domain Typed Obligation Prover: Emits explicit 4-way static verdicts (
PROVEN|VIOLATED|UNKNOWN|UNSUPPORTED) with0falsePROVENverdicts on the repository's negative test corpus. - Built-In MCP Server (
kintsugi mcp): Zero-dependency JSON-RPC 2.0stdioserver exposing static scanning, context-aware file reading, pitfall lexicon lookup, delivery telemetry, and context compaction over standard MCP. - Standalone Cloud Sandbox Edition (
cloud-sandbox/·v3.1.1): Pure Python3.9+stdlib CLI for ephemeral or restricted cloud coding sandboxes with pinned SHA-256 GitHub self-update, 2-process OS subprocess IPC Truth Gate, fail-closed AST+regex scanning, exact rationalFractionfinancial checks, and read-only transaction policy guards. - Domain-Partitioned
KMI/1Context Compression: Compiles verbose security rules into compact<12-token symbolic headers expanded Just-In-Time only when a rule fires.
2. Quick Start & OpenAI Codex CLI / MCP Integration
Install
Option A: Prebuilt Native Binary (Linux x86_64 / ARM64, macOS Apple Silicon — No Rust Required)
Every tagged release ships zero-dependency kintsugi-rs binaries (~2.0 MiB) with SHA256SUMS.txt and GitHub SLSA Build Provenance attestations:
# Example for macOS Apple Silicon (replace target with x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu on Linux)
TAG="v3.1.1"
TARGET="aarch64-apple-darwin"
curl -fsSLO "https://github.com/tunguyen1993/kintsugi-harness/releases/download/${TAG}/kintsugi-rs-${TAG}-${TARGET}.tar.gz"
curl -fsSLO "https://github.com/tunguyen1993/kintsugi-harness/releases/download/${TAG}/SHA256SUMS.txt"
grep "kintsugi-rs-${TAG}-${TARGET}.tar.gz" SHA256SUMS.txt | shasum -a 256 -c -
tar -xzf "kintsugi-rs-${TAG}-${TARGET}.tar.gz" kintsugi-rs && ./kintsugi-rs --version
Option B: Install Python CLI + MCP Server (and Optional Local Rust Build)
git clone https://github.com/tunguyen1993/kintsugi-harness.git
cd kintsugi-harness
pip install -e .
# Optional: build the zero-dependency native Rust CLI (`kintsugi-rs`)
cargo build --release --all-features
Core CLI Commands
# Scan a repository or staged git diff (Python AST + regex scanner)
kintsugi scan . --staged --fail-on HIGH
# Run the native Rust 7-domain typed obligation prover
./target/release/kintsugi-rs s3-audit src/ --strict-proven --format json
# Generate a bounded JIT context envelope + low-tier pitfall brief for a file
./target/release/kintsugi-rs context src/app.py --low-tier --format json
./target/release/kintsugi-rs lexicon src/App.tsx --format compact
# Compile compact KMI/1 governance files (AGENTS.md, CLAUDE.md, Cursor, Copilot, Windsurf)
kintsugi compile --targets all --compact
OpenAI Codex CLI Integration (~/.codex/config.toml)
Register Kintsugi as a local stdio MCP server in ~/.codex/config.toml:
[mcp_servers.kintsugi]
command = "kintsugi"
args = ["mcp", "--profile", "v3", "--ledger", ".kintsugi/scars.json"]
Verify the MCP server starts cleanly over stdio:
kintsugi mcp --profile v3
Claude Code, Cursor, Windsurf, Cline & Zed MCP Configuration
Add the following to .mcp.json, .cursor/mcp.json, or claude_desktop_config.json:
{
"mcpServers": {
"kintsugi-harness": {
"command": "kintsugi",
"args": ["mcp", "--profile", "v3", "--ledger", ".kintsugi/scars.json"]
}
}
}
Claude Code PreToolUse Hook
Install hooks automatically (kintsugi install-hooks --git) or wire kintsugi-rs directly in .claude/settings.json:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit|MultiEdit|Bash",
"hooks": [
{
"type": "command",
"command": "kintsugi-rs hook claude-pre-tool --block-on HIGH"
}
]
}
]
}
}
Key MCP Tools (kintsugi mcp --profile v3)
The MCP server exposes 9 core tools under the default profile and 26 tools under --profile v3, alongside 2 resources (kintsugi://ledger/scars, kintsugi://posture/summary) and 2 prompts (kintsugi-audit-code, kintsugi-evolve-scar):
| Tool | Purpose |
|---|---|
kintsugi_scan_code |
Deterministic AST + regex scan of inline code or file paths before writing/committing. |
kintsugi_read_with_context |
POSIX dir_fd (O_NOFOLLOW) bounded file read with CRLF-verbatim digest parity and JIT context injection. |
kintsugi_low_tier_lexicon |
Symbol-scoped lookup into the 80-entry pitfall lexicon (LT-001..LT-080). |
kintsugi_delivery_telemetry |
Record and query DeliveryTelemetry/1 receipt stages and 2-strike auto-freeze state. |
kintsugi_list_scars |
List verified guardrails or emit a single domain-partitioned KMI/1 shard. |
kintsugi_record_failure |
Compile a runtime/test failure into a self-verified guardrail (scan(bad) >= 1, scan(good) == 0). |
kintsugi_verify_logic |
Run deterministic SAT/Datalog/difference-logic and auth state-machine verification. |
kintsugi_integrate_harness |
Discover, quarantine, conflict-check, mount, or eject third-party agent rule files cleanly. |
kintsugi_compact_context |
Strip verbose logs and superseded file reads while preserving user intents and hard anchors. |
GitHub Actions Integration
Kintsugi ships a composite action (action.yml) and can run directly in CI workflows:
- name: Run Kintsugi security scan
run: |
pip install -e .
kintsugi scan . --fail-on HIGH
3. Zero-Dependency Cloud Sandbox Edition (cloud-sandbox/ · v3.1.1)
For ephemeral or restricted cloud coding sandboxes with only Python 3.9+ stdlib (no Rust toolchain, no pip network access), cloud-sandbox/ provides a self-contained, hardened edition:
- Pinned SHA-256 GitHub Self-Updater (
bootstrap.py): Verifies explicit bootstrap and manifest digests (--require-pin,--require-full-sha,--expected-bootstrap-sha256,--expected-manifest-sha256), performsdir_fd(O_NOFOLLOW) safe extraction against symlink/path traversal, supports offline.tar.gz/.zipfallback (--source-archive), and runs a clean-environment boot smoke check before atomic directory swap. - 2-Process OS Subprocess IPC Truth Gate: Executes candidate tests in isolated Python and Node.js subprocesses communicating over OS IPC with runtime-counted assertions, verifying real
BROKEN -> FIXEDtransitions rather than trusting self-reported model output. - Fail-Closed AST + Regex Security Scanner: Multi-language scanner returning
INCOMPLETE_SCANfail-closed verdicts on parse errors, unreadable targets, symlink escapes, or oversized inputs. - Exact Rational
FractionFinancial Verification: Arbitrary-precisionfractions.Fractionconservation, FX conversion, and tick-rounding checks eliminating IEEE-754 floating-point drift. - Read-Only Transaction Policy Guard (
tx-guard): Pre-flight policy gate rejecting unauthorized outbound value transfers, token approvals, or advance-deposit requirements. - 5-Gate Closed-Loop Scar Evolution: Candidate synthesis -> 2-process IPC Truth Gate -> matcher-on-broken validation -> canary regression replay -> SHA-256 attested patch export/import.
# Pinned SHA-256 install in a restricted cloud sandbox (replace placeholders with release digests):
curl -fsSL "https://raw.githubusercontent.com/tunguyen1993/kintsugi-harness/<40-hex-commit-sha>/cloud-sandbox/bootstrap.py" -o /tmp/k_boot.py \
&& python3 /tmp/k_boot.py \
--ref "<40-hex-commit-sha>" \
--require-pin \
--require-full-sha \
--expected-bootstrap-sha256 "<64-hex-bootstrap-sha256>" \
--expected-manifest-sha256 "<64-hex-manifest-sha256>" \
--dest /tmp/kintsugi_sandbox
See cloud-sandbox/README.md, cloud-sandbox/TASKS.md, and cloud-sandbox/AGENT_INSTRUCTIONS.md for the full sandbox CLI reference (boot, self-test, brief, scan, tx-guard, truth-gate, ledger-check, verify-delivery, audit-deliverable, and evolve).
4. Architecture & Security Guarantees
flowchart LR
A["Agent Turn\n(KMI/1 Domain Shard: ~80.5 tok)"] --> B["Tool Call\n(Read / Write / Edit / Bash)"]
B --> C{"Rust / Python Guardrail\n(7-Domain Prover + AST/Regex)"}
C -- "PROVEN / Clean" --> D["Execute Tool\n(0 extra tokens)"]
C -- "VIOLATED / UNKNOWN" --> E["JIT Rule & Lexicon Expansion\n(Bounded ContextEnvelope/3)"]
E --> F["DeliveryTelemetry/1\n(2-Strike Auto-Freeze)"]
7-Domain Typed Obligation Prover (rust/src/audit/{obligation_prover,prover_extensions}.rs)
Every obligation is evaluated to one of four explicit verdicts—PROVEN, VIOLATED, UNKNOWN, or UNSUPPORTED—backed by a UTF-8 byte-aligned StatefulMasker and fail-closed NO_INPUT handling for missing, unreadable, symlink, or empty targets (0 false PROVEN verdicts on the repository's negative test corpus):
| Domain | Languages | Obligation Verified |
|---|---|---|
CMD_EXEC |
Python, TS/JS | Rejects shell execution (shell=True, dynamic shell= expressions, shell trampolines like sh -c, opaque options objects). |
SQL_EXEC |
Python, TS/JS | Requires parameterized queries; rejects string formatting/concatenation into SQL execution sinks. |
PATH_CONFINE |
Python, TS/JS, Rust | Requires canonical path containment against traversal outside an allowed root before filesystem reads/writes. |
CRYPTO_MAC_BIDI |
Python, TS/JS | Enforces constant-time MAC comparisons and rejects Trojan Source bidirectional Unicode overrides. |
TSX_XSS |
React .tsx/.jsx |
Flags unsafe HTML injection (dangerouslySetInnerHTML, unsanitized javascript: URLs). |
SOL_REENTRANCY_CEI |
Solidity .sol |
Checks Checks-Effects-Interactions ordering and reentrancy guards around external calls. |
SOL_SAFE_ERC20 |
Solidity .sol |
Requires exact SafeERC20.sol import, scoped using SafeERC20 for <ERC20Type>, and verified receiver typing. |
80-Entry Low-Tier Model Pitfall Lexicon (LT-001..LT-080)
Located in rust/src/audit/low_tier_lexicon.rs, the lexicon maps symbol-scoped, recurring coding-agent failure modes across Python, OWASP Security, TypeScript/React/Next/Vue, MySQL, Solidity 0.8.24/DeFi, Go, Rust, Docker, and GitHub Actions. Entries are injected Just-In-Time only when matching symbols/imports appear (0 matches / 0 tokens on the repository's benign fixture corpus).
9 Signature-Guarded Invariant Capsules (rust/src/audit/capsules.rs)
High-impact security and financial invariants (including ERC-4626 share bounds, replay-safe signature verification, and atomic locking) are packaged as signature-guarded capsules so injected reminders respect target function signatures (for example, never instructing a -> bool verifier to raise exceptions).
Delivery Telemetry (DeliveryTelemetry/1)
Implemented with cross-runtime Rust and Python parity (rust/src/audit/delivery_telemetry.rs, src/kintsugi/evolution/delivery_telemetry.py):
- Tracks 3 distinct receipt stages:
issued -> included_in_input -> patch_bound. - Protects efficacy accounting so unshown capsules (
included_before_first_patch == false) never pollute metrics. - Enforces cross-process file locking (
0600) and 2-Strike Auto-Freeze: if a capsule or lexicon entry correlates with repeated failing patches, it is automatically frozen out of subsequentContextEnvelope/3rankings.
Domain-Partitioned KMI/1 Context Compression (src/kintsugi/compressor.py)
Rules are partitioned across 6 engineering domains (security, backend, database, frontend, devops, ai_mcp) in docs/domains/. Measured with the deterministic estimate_tokens estimator:
- 16-Rule Starter Pack (
--starter-only):3,641verbose Markdown tokens ->226globalKMI/1tokens (93.8%reduction) or~80.5tokens/turn per domain shard (97.79%reduction). - Full Evolved Ledger (
.kintsugi/scars.json):414,267verbose tokens ->~175.7tokens/turn per domain shard (99.96%reduction).
5. Reproducible Benchmarks & Verification
All benchmark scripts and measured outputs are committed in benchmarks/ with pinned commit SHAs and explicit scoping caveats.
Real-World OSS Head-to-Head Benchmark (benchmarks/real_world_oss_benchmark_v3.json)
Measured end-to-end subprocess wall-clock latency (median of 5 runs after 1 warmup) and child Peak RSS (os.wait4) on Apple Silicon (arm64, macOS) comparing kintsugi-rs 3.1.1 (2.02 MiB static binary, 0 runtime deps) against ruff 0.17.6 (21.22 MiB, --select S --no-cache) and bandit 1.9.4 (52.77 MiB venv, -r -q -ll):
| Target Repo (Pinned Commit) | Files / LOC | kintsugi-rs scan (HIGH+) |
kintsugi-rs s3-audit |
ruff --select S |
bandit -ll |
Speedup vs Bandit |
|---|---|---|---|---|---|---|
psf/requests (src/requests, 3c7baaa0) |
19 .py / 6.4k |
27.9 ms · 4.5 MiB · 0 hits |
31.4 ms · PASS_S3_LOCKED (1/1 PROVEN) |
13.1 ms · 29.8 MiB · 16 hits (16 S101) |
291.3 ms · 39.4 MiB · 0 hits |
10.5× |
pallets/flask (src/flask, 49943b5a) |
24 .py / 9.6k |
54.9 ms · 4.7 MiB · 3 hits |
39.6 ms · 11 seams | 12.6 ms · 29.4 MiB · 10 hits (5 non-S101) |
332.1 ms · 40.7 MiB · 4 hits |
6.1× |
tiangolo/fastapi (fastapi/, 05e6df7e) |
54 .py / 23.8k |
183.2 ms · 6.3 MiB · 0 hits |
110.2 ms · PASS_S3_LOCKED |
16.2 ms · 35.3 MiB · 71 hits (71 S101) |
742.3 ms · 56.3 MiB · 0 hits |
4.1× |
tiangolo/fastapi (full repo, 05e6df7e) |
1,233 .py / 136k |
232.2 ms · 9.5 MiB · 3 hits (docs JS only; 0 Py FPs) |
1,387.8 ms · 59 seams | 49.8 ms · 57.7 MiB · 7,445 hits (7,341 S101) |
4,751.2 ms · 75.3 MiB · 3 hits |
20.5× |
adeyosemanputra/pygoat (OWASP vuln app, 2aa4cc14) |
116 .py / 8.1k |
13.7 ms · 5.0 MiB · 20 real vulns (KS-002/003/007/020/S3-01) |
86.7 ms · FAIL_S0_EXPOSED (6 unguarded) |
16.6 ms · 28.3 MiB · 100 hits |
429.3 ms · 39.0 MiB · 55 hits |
31.5× |
- Footprint & RAM:
kintsugi-rsis10.5×smaller on disk thanruff(2.02 MiBvs21.22 MiB) and uses5.7×–7.9×less Peak RSS thanruff/bandit(4.5–9.5 MiBvs28–75 MiB). - AI-Agent Threat Coverage: On OWASP PyGoat,
kintsugi-rscatches classic OWASP sinks (subprocess(..., shell=True),eval/pickle.loads, SQLi f-strings,yaml.load, weakrandom.randintOTP) plusKS-S3-01stealth prompt-injection instructions in repository docs (dependency_attack_lab/README.md) and Trojan Source Bidi overrides—classes outside Python-only AST linters. - Scope note:
ruff --select Scovers Python flake8-bandit rules (includingS101assertchecks) and is fastest on huge pure-Python trees (49.8 mson 1,233 files);kintsugi-rsadds multi-language pre-tool hook enforcement (8.14 µs/scanavg), prompt-injection/Bidi detection, and the 7-domains3-auditobligation prover in one zero-dependency binary.
Reproduce this exact benchmark locally:
python3 benchmarks/real_world_oss_benchmark.py --clone --bench-dir /tmp/kintsugi_real_bench --out /tmp/real_bench.json
Additional Verification Suites
- Low-Tier Pitfall Lexicon Blind A/B Evaluation (
benchmarks/low_tier_lexicon_ab_results_v3.json):- Scope: Synthetic/held-out blind zero-hint evaluation suite testing recurring budget-LLM failure modes (not an official SWE-bench leaderboard submission).
- 4-Round Aggregate (
56tasks ×3models =168runs acrossHeldOut12,HardCrucible16,DualStack16,OnlineOpsScars12): Baseline83/168(49.4%) -> With Lexicon161/168(95.8%,+46.4 pp). - Round 5 (
PolyglotInfra7, reported separately):7Go/Docker/GitHub Actions tasks improved from0/7(0.0%) to6/7(85.7%,+85.7 pp). - Zero-bloat check:
0matches /0tokens verified on the repository benign fixture corpus (Python, TypeScript, Rust, Go).
- 10-Arena Local Verification Suite (
benchmarks/verified_10_arena_pareto_certificate.json):- Reproducible local regression suite verifying
10/10arenas (98.28average score).
- Reproducible local regression suite verifying
Run Verification Locally
# 1. Full Python test suite (optional Z3 proof extra: pip install -e ".[proof]")
PYTHONPATH=src:tests pytest -q
# 2. Full Rust test suite across all targets + native release benchmark
cargo test --all-targets
cargo build --release --bins
./target/release/kintsugi-rs bench
# 3. Deterministic KMI/1 token compression report
PYTHONPATH=src python3 -m kintsugi.cli token-report --starter-only
# 4. 10-Arena local verification suite
python3 benchmarks/run_verifiable_arena_cert_suite.py --verify
6. BYOK Multi-Model Review (100% Apache-2.0, Optional)
Kintsugi Harness is 100% Apache-2.0 open source and runs completely offline with zero API keys for all static analysis, obligation proving, MCP server tools, PreToolUse hooks, and Cloud Sandbox workflows.
If you optionally want multi-model second-opinion code review (kintsugi swarm), Kintsugi supports Bring Your Own Key (BYOK) using standard official provider API keys:
OPENAI_API_KEYANTHROPIC_API_KEYGEMINI_API_KEYDEEPSEEK_API_KEY
User-supplied keys are stored strictly locally (e.g., .kintsugi/paid_council_pool.json with 0600 file permissions) and never sent to third-party proxies or external relays.
7. Security, Contributing & License
- Security Policy:
SECURITY.md— Vulnerability disclosure and supported versions - Contributing Guide:
CONTRIBUTING.md— Adding guardrails, running tests, and PR guidelines - Code of Conduct:
CODE_OF_CONDUCT.md - Changelog:
CHANGELOG.md - License: Apache License 2.0 (
Apache-2.0) - Maintainer: Tu Nguyen (
@tunguyen1993)
Metadata
Release files for kintsugi-harness 3.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kintsugi_harness-3.1.1.tar.gz | 1.0 MB | With provenance | Details for kintsugi_harness-3.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kintsugi_harness-3.1.1-py3-none-any.whl | Python 3 | none | any | Details for kintsugi_harness-3.1.1-py3-none-any.whl |
Total release size: 2.0 MB
Release files / kintsugi_harness-3.1.1.tar.gz
| Download URL | kintsugi_harness-3.1.1.tar.gz |
|---|---|
| Size | 1.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
227801b37a9171553fb84d0e6cd685da56d88bd3f88ec02d778adf895bd334ed
|
|
BLAKE2b-256 checksum How to use checksums |
792437154bff314c3f57e9024266fca24f00d75480a94a1f2d0cb3c8c440e0d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / kintsugi_harness-3.1.1-py3-none-any.whl
| Download URL | kintsugi_harness-3.1.1-py3-none-any.whl |
|---|---|
| Size | 935.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b012dbc8cce0d63f4ca9ac3b2029db7931ad60153cddf7eb1315070878514806
|
|
BLAKE2b-256 checksum How to use checksums |
db7679e7fb93a47e679b1ad81f9e6cc808597a5390b9eddc6e8ddf29a13cce96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for kintsugi-harness 3.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for kintsugi_harness-3.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.