Skip to main content

noise-chatbot (Python)

Encrypted chatbot framework over Noise_IK (Curve25519 + ChaCha20-Poly1305 + BLAKE2b).

Python reimplementation of TRUGS-LLC/noise-chatbot (Go), generated from noise_chatbot.super.trug.json per the TRUG-driven rewrite methodology.

Status: Phase B scaffold. Function bodies are NotImplementedError stubs. Phase C fills them from the super-TRUG without reading Go source.

Quickstart (future — after Phase C)

from noise_chatbot.server import Server

s = Server(":9090")
s.on_chat(lambda text: "You said: " + text)
print("Public key:", s.public_key())
s.listen_and_serve()

Why Python

Same reasons as the Go original — encrypted end-to-end chatbot with no TLS certificates, no DNS, no MITM window — plus:

  • Drop-in replacement for Python teams already on the Python-AI ecosystem.
  • Pluggable stores. Guardrails, responses, banned keys, and the TRUG knowledge base each live behind a tiny Protocol. Ship with the zero-dependency in-memory / JSON-file defaults, or opt in to the graph-backed trugs-store adapter for persistent state. See Stores below.
  • Apache 2.0 (matching the Go original's license pre-#1550-relicense).

Install

pip install noise-chatbot          # standalone — in-memory + JSON-file stores
pip install noise-chatbot[trugs]   # + trugs-store graph adapter

From source during development:

git clone https://github.com/TRUGS-LLC/noise-chatbot
cd noise-chatbot
pip install -e ".[dev]"            # includes trugs-store for the full test suite

Stores

The Server holds four kinds of swappable persistent-state:

Protocol What it does In-memory default JSON-file [trugs] extra
GuardrailStore Pre-authored boundary responses compiled-in 15 nodes — TrugsGuardrailStore
ResponseStore Classifier match targets empty list JsonFileResponseStore(path) TrugsResponseStore
BannedKeyStore TTL-bounded bans (slowdown, not prevention) InMemoryBannedKeyStore(ttl=72h) JsonFileBannedKeyStore(path, ttl) TrugsBannedKeyStore
KnowledgeBaseStore TRUG context injection empty JsonFileKnowledgeBaseStore(path) TrugsKnowledgeBaseStore

Wire one in via the builder API:

from datetime import timedelta
from noise_chatbot.server import Server
from noise_chatbot.stores import JsonFileBannedKeyStore, JsonFileResponseStore

s = (
    Server(":9090")
    .with_response_store(JsonFileResponseStore("responses.trug.json"))
    .with_banned_keys(JsonFileBannedKeyStore("bans.json", ttl=timedelta(hours=72)))
)

Or the legacy path-based shortcuts (preserved — they now wrap the stores internally):

s = Server(":9090").with_responses_from_trug("responses.trug.json")

Opting in to trugs-store

# pip install noise-chatbot[trugs]
from trugs_store import JsonFilePersistence
from noise_chatbot.stores.trugs import TrugsBannedKeyStore

graph = JsonFilePersistence().load("chatbot.trug.json")
s = Server(":9090").with_banned_keys(TrugsBannedKeyStore(graph))
# The graph is mutated in place — caller is responsible for persisting via
# JsonFilePersistence.save() or the postgres backend before shutdown.

Every BannedKeyStore implementation is required (by the Protocol's type signature) to enforce ttl: timedelta expiry. No permanent-ban implementation is possible — bans are a slowdown mechanism, not prevention.

Architecture

noise_chatbot/
  noise/       Noise_IK transport (Curve25519 + ChaCha20-Poly1305)
  protocol/    Message type (JSON wire format)
  server/      Server, SafetyConfig, ResponseNode, DEFAULT_GUARDRAILS
  client/      Client, connect, chat, send, close
  helper/      noise-helper stdin/stdout bridge
  examples/    echo, faq, llm, graph

The Python API mirrors the Go API with idiomatic Python naming (snake_case instead of PascalCase for methods; Python dataclasses instead of Go structs). Behavioural parity is enforced by the parity corpus under tests/parity/.

Testing

pytest                    # unit + integration
pytest -m parity          # Go-golden parity corpus (needs Go binaries)
ruff check . && ruff format --check . && mypy src tests

Parity

Phase A of issue #1555 in TRUGS-DEVELOPMENT produced a 21-fixture YAML corpus that the Go implementation passes. This Python implementation is validated against the same corpus — Phase C is complete when all 17 runnable fixtures pass.

License

Apache License 2.0. See LICENSE and NOTICE.

Built on:

Metadata

Release files for noise-chatbot 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noise-chatbot 0.1.0
File Size Uploaded
noise_chatbot-0.1.0.tar.gz 37.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for noise-chatbot 0.1.0
File Interpreter ABI Platform
noise_chatbot-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 81.8 kB

Release files / noise_chatbot-0.1.0.tar.gz

Download URL noise_chatbot-0.1.0.tar.gz
Size 37.1 kB
Tags Source
SHA-256 checksum
How to use checksums
45ec16f85056484c844c598c1c549a43a14034c7fd622a20b496c95ae3f82aa7
BLAKE2b-256 checksum
How to use checksums
bc3dc46e9f6863cc672249b9c8283eddce5f9dcd95044aab0da07b2f04c0a708
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / noise_chatbot-0.1.0-py3-none-any.whl

Download URL noise_chatbot-0.1.0-py3-none-any.whl
Size 44.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b4b6ba247eeea07ba7c433f652f065e19af5086a13af45b4a8c6bcb336efb809
BLAKE2b-256 checksum
How to use checksums
77c2d6d142fde292caf6257385199adc030bf23886a4e962ecfbea1d496b9a86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page