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-backedtrugs-storeadapter 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:
- The Noise Protocol Framework
noiseprotocol(BSD 3-Clause)trugs-store— optional, via the[trugs]extra
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| noise_chatbot-0.1.0.tar.gz | 37.1 kB | Without provenance | Details for noise_chatbot-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| noise_chatbot-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for noise_chatbot-0.1.0-py3-none-any.whl |
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
|
Security for noise-chatbot 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.