Skip to content

Latest commit

Β 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ztd (Zero Trust Data)

License CI Version

A model can ask, but it cannot directly act.

ztd is a zero-trust execution and evidence platform for AI agents, human operators, and distributed target systems. It sits between reasoning engines (frontier LLMs, MCP tools, local models, autonomous loops) and the infrastructure they touch.

An agent does not connect to your server, hold your ambient SSH keys, or run raw shell commands against production. Instead, intent is expressed as typed actions, gated through cryptographic policy checks, independently re-verified on the target machine, and executed under single-use capabilities with an immutable audit trail written to the host where the work actually happened.


Why this exists

Most modern AI agent stacks combine four completely different jobs into a single process:

  1. Reasoning: What the model thinks it should do based on prompt context.
  2. Authorization: What the system is permitted to do.
  3. Execution: The ambient credentials, tokens, and host sockets used to do it.
  4. Evidence: The logs explaining what happened after the dust settles.

When you collapse those into one process, an indirect prompt injection, a poisoned context window, or a hallucinated flag isn't just an AI quirkβ€”it's an instant remote code execution vulnerability.

During development, an evaluation assignment bug wiped the entire root of this repository. Not a directory in /tmpβ€”the repo root. Git brought it back thirty seconds later, but the lesson stuck: the evaluation harness had quietly bypassed the platform's own governance checks. The seatbelt was bolted to the floor next to the seat.

Safety fine-tuning and system prompts are not security boundaries. You cannot prompt-engineer your way to least privilege. If a system can mutate state, authority must be cryptographic, deterministic, and enforced at the host execution boundary.


How it works

ztd splits operations into two distinct protocol roles, packaged into a single static Go binary (ztd):

                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚          AI Model / MCP Client         β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚ 1. Proposes Typed Intent
                                         β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚        ztd Gateway (PDP)               β”‚
                     β”‚  - Validates L1 Doctrine (heuristics)   β”‚
                     β”‚  - Coordinates L2 Consensus (Ed25519)  β”‚
                     β”‚  - Enforces L3 Notary (WebAuthn)       β”‚
                     β”‚  - Issues signed GovernanceEnvelope    β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚ 2. Outbound-only mTLS
                                         β”‚    (no inbound ports)
                                         β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚        ztd Operator (PEP)              β”‚
                     β”‚  - L4 Warden: Re-verifies hash & root  β”‚
                     β”‚  - L5 Actuator: Mint ephemeral cap     β”‚
                     β”‚  - Executes locally on target host     β”‚
                     β”‚  - Appends signed ActionReceipt to     β”‚
                     β”‚    local SQLite ledger & Git history   β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The Policy Decision Point: Gateway (ztd gw)

The Gateway is the front door and protocol coordinator. It ingests intent via MCP (POST /mcp or stdio), Agent-to-Agent (A2A), HTTP dispatch, or CLI. It checks technical bedrock rules, coordinates multi-agent consensus or human passkey authorizations, and packages admitted intent into a canonical, signed GovernanceEnvelope. It also serves the embedded browser console and hosts an in-process Operator substrate strictly for Gateway-local operations.

The Policy Execution Point: Operator (ztdo)

The Operator is a lightweight daemon that lives on the target machine owning the data. It connects strictly outbound over mTLS to the Gateway and listens on zero inbound network ports. It pulls transactions from its dedicated session channel, independently re-evaluates the envelope at Layer 4, mints a short-lived capability, dispatches the action locally, and records cryptographic receipts in its own local SQLite audit database and git file ledger.

Even if the Gateway is compromised, an Operator refuses to execute any envelope whose canonical transaction hash, state Merkle root, or cryptographic proofs fail its independent verification. Delivery from the Gateway does not equal authorization.


The Five-Layer Governance Pipeline

Every mutation passing through ztd must clear five deterministic layers:

Layer Name Who runs it What it does
L1 Doctrine Gateway + Operator Decodes typed payloads and enforces technical hard gates, regex constraints, and MITRE ATT&CK threat heuristics. Always enforced across all postures.
L2 Consensus Gateway (coord.), Operator (verify) $K$-of-$N$ Ed25519 quorum signature check over <tx_hash>|<decision> by enrolled machine peers.
L3 Notary Gateway (coord.), Operator (verify) Cryptographic human approval gate. WebAuthn passkeys in the browser console, or signed Ed25519 CLI approval proofs for headless runtimes.
L4 Warden Executing Operator Pre-dispatch host gate. Reserves nonces, checks TTLs, recomputes the canonical transaction hash, checks the state Merkle root, and re-runs L1.
L5 Actuator Executing Operator Sole execution boundary. Signs EXECUTING receipt, rehydrates scrubbed credentials locally, mints a single-action just-in-time capability, executes the action, dissolves the capability, and signs the final COMPLETED or FAILED receipt.

Governance Postures

You choose a governance posture when the Gateway starts (via --posture). It is immutable for the lifetime of that process:

  • doctrine (default): L1 Doctrine, L4 Warden, and L5 Actuator are blocking gates. L2 and L3 proofs are recorded as audit evidence when present, but don't block dispatch.
  • consensus: Requires $K$-of-$N$ signed machine consensus before any mutation can execute.
  • ratify: Requires explicit cryptographic human authorization (L3 Notary) for every mutation. Read-only actions pass through.
  • notary: Maximum governance. Requires both machine consensus (L2) and human sign-off (L3) before any mutating envelope touches a host.

Universal integrity checks (L1, L4, and L5) are mandatory in every posture. Fail-closed is the only mode.


Local-First Audit Architecture (LFAA)

Most cloud-managed agent tools ship logs back to a vendor bucket. If the vendor goes down or credentials leak, your audit trail goes with it.

ztd uses a Local-First Audit Architecture:

  • Authoritative local store: Each Operator maintains its own encrypted SQLite database (audit.db) and a git-backed file history ledger under its runtime directory.
  • Projections, not truth: The Gateway mirrors receipts for the UI and CLI, but the local host remains the single authoritative root of truth for what ran.
  • Incremental Merkle commitment: State roots are computed incrementally across 65,536 buckets in a 16-ary tree. Proofs don't degrade into full-table scans as your audit history grows.
  • Local secret rehydration: Sensitive credentials and tokens never travel across the wire in plaintext. They are scrubbed to reversible placeholders ({{UEI_N}}) and rehydrated by the L5 Actuator inside the target host's memory immediately before execution.

Quickstart

ztd runs natively as a static binary on Linux, macOS, and Windows. No Docker daemon, no background hypervisor, no sudo required.

1. One-line install

On Linux or macOS:

curl -fsSL https://zerotrustdata.io/start.sh | sh

On Windows (PowerShell 7):

irm https://zerotrustdata.io/start.ps1 | iex

This downloads the checksum-verified binary to ~/ztd, starts a local Gateway on https://localhost:8443, creates a CLI identity, and runs your first governed action through an embedded Operator.

2. Build from source

If you want to inspect every line before running:

git clone https://github.com/zerotrustdata/ztd.git
cd ztd

# Check dependencies, generate .env, and build the binary
bash scripts/linux-setup.sh --build-only   # macOS: bash scripts/macos-setup.sh --build-only

# Spin up Gateway, enroll CLI, and fire the first action
make quickstart

On Windows:

git clone https://github.com/zerotrustdata/ztd.git; cd ztd
pwsh scripts/windows-setup.ps1 --build-only
make quickstart

Requirements for source builds: Go 1.27.2, Git, and GNU Make. Pre-built frontends are already embedded in the repository.


Interacting with the Stack

Once the Gateway is running, here is how you drive it:

# Watch the live transaction firehose in your terminal
./ztd tui

# Sign in to the Web Console with a WebAuthn passkey
./ztd login web
# Then open https://localhost:8443/console/

# List enrolled Operators and their health
./ztd operator list

# Run a governed command across all active Operators
./ztd operator run --all-active --cmd "uptime"

# Inspect the cryptographic audit receipts for a session
./ztd gw data audit list --operator-session-id <session_id>

# Shut down the stack (preserves all local audit ledgers in .ztd/)
make down

Governing AI Agents (MCP & Claude Code)

ztd integrates directly with Model Context Protocol (MCP) clients and coding assistants. Instead of granting an LLM raw bash execution:

# Connect Claude Code to governed ztd tools
./ztd mcp agent run claude

Mutations proposed by Claude flow through the Gateway's L1–L5 pipeline. If Claude asks to edit a file or invoke a shell command, the request is evaluated against security doctrine, bound to a canonical transaction hash, verified by the Operator on the machine, executed under a temporary capability, and committed to local git history.


Tested at Scale

We test ztd the way production infrastructure breaks.

In October 2026, we drove 2,000 native Operator processes against a single Gateway instance on a modest 12-core Linux machine:

  • 2,000 Operators enrolled in 54.82 seconds.
  • Governed command fan-out to 2,001 targets completed in 3.89 seconds with 0 failures.
  • Re-tested after bouncing the Gateway: all 2,000 resumed cleanly over mTLS without session rotation.
  • Gateway memory remained flat under continuous 30-second heartbeats over 6,000 concurrent TLS connections.

For the raw benchmarks, profiles, and the SQLite concurrency lessons learned during the test, read From 936 to 2,000 Operators on one Gateway.


Repository Map

cmd/ztd/              Static binary entrypoint (Gateway, Operator, CLI, TUI)
internal/
  cli/                Cobra CLI commands (gw, operator, auth, mcp, audit, eval, compliance)
  services/
    gateway/          PDP control plane, HTTP APIs, PKI CA, session routing
    governance/       The five-layer pipeline (L1 Doctrine, L2 Consensus, L3 Notary, L4 Warden, L5 Actuator)
    consensus/        Ed25519 quorum deliberation engine
    fs/               RuntimeFileService (strictly isolated .ztd/ filesystem access)
    vault/            AES-256-GCM encrypted local secret & key storage
    mcp/              Native MCP server and tool registry
protocol/             Canonical Protobuf schemas (proto/ztd/) and generated Go/TS bindings
console/              React + TypeScript (Vite) web console (embedded into the Go binary)
eval/                 Model evaluation fixtures, security gauntlets, and test datasets
docs/                 Complete platform architecture, developer invariants, and user guides

Testing & Quality

Always run test suites through ./ztd test <suite> or the root Makefile (they configure mandatory FIPS tags, race detectors, and environment isolation):

./ztd test unit          # Fast, in-memory, parallel-safe unit tests
./ztd test integration   # Real SQLite/PKI/mTLS integration tests (-race enabled)
./ztd test lint          # golangci-lint, vulnerability audit, and doctrine verification
./ztd test chaos         # Fault injection and network disruption tests

make console-test        # Vitest suite for the browser console
make proto-generate      # Regenerate Go and TypeScript protobuf bindings
make doctrines-validate  # Verify JSON doctrine rule definitions

Field Notes & Documentation

We document the architectural rationale, breaking changes, and operational scars in public:


License

ztd is licensed under the Business Source License 1.1 (LICENSE), by Lateralus Labs, LLC.

You are free to copy, modify, test, and run ztd for development, evaluation, and non-production use. Production deployments require a commercial license from Lateralus Labs. Each version automatically converts to Apache 2.0 four years after its release (and no later than 2030-08-18).

Third-party dependencies and notices are documented in THIRD_PARTY_NOTICES.md.