Skip to main content

BTCU Harness

Balanced Ternary Cognitive Unit Harness — A cognitive architecture for LLM-based agents built on balanced ternary logic {-1, 0, +1}.

CI Python 3.10+ License: MIT PyPI Tests


What is BTCU?

BTCU Harness introduces a structured, interpretable, and evolvable cognitive layer between large language models (LLMs) and autonomous agents.

Instead of treating the agent's "mind" as an unstructured text buffer, BTCU provides:

  • 19,683 discrete cognitive states — completely enumerable, navigable, and comparable
  • Intrinsic transformation — the VOID state encodes change itself (-1+1=0)
  • Emergent semantics — state meanings arise from experience, never preset
  • Four-layer memory ecology — episodic, procedural, capability, and biographical
  • Third-choice synthesis — generates creative alternatives beyond binary conflicts
  • Growth model — school → internalize → graduate, progressively reducing LLM dependency

Installation

pip install btcu-harness

# With LLM providers
pip install "btcu-harness[openai]"      # OpenAI GPT
pip install "btcu-harness[anthropic]"   # Anthropic Claude
pip install "btcu-harness[gemini]"      # Google Gemini

# With REST API
pip install "btcu-harness[api]"

# With MongoDB
pip install "btcu-harness[mongo]"

# Everything
pip install "btcu-harness[all]"

Quick Example

from btcu_harness.agent import BTCUAgent
from btcu_harness.core.state import CognitiveState
from btcu_harness.llm.bridge import LLMBridge

# Create agent with callback (no API key needed for testing)
agent = BTCUAgent(growth_stage="school")
agent.init_project(
    domain="custom",
    dim_labels=["Speed", "Quality", "Cost", "Risk", "Innovation",
                "Team", "Deadline", "Scope", "Impact"],
)

# Process input
response = agent.process("Should we prioritize speed?")
print(f"State #{response.current_state.index}")
print(f"Polarity: {response.current_state.polarity}")
print(f"Self alignment: {response.self_alignment:.1%}")

Or run the quickstart script (no API key needed):

python examples/quickstart.py

REST API

pip install "btcu-harness[api]"
uvicorn btcu_harness.api:app --port 8000

Endpoints: POST /api/init, POST /api/project, GET /api/status, GET /api/explore, and more. Interactive OpenAPI docs at http://localhost:8000/docs.

Or with Docker:

docker compose up

Architecture

btcu_harness/
├── core/              # Trit, CognitiveState (19,683 states), CognitiveSpace
├── mapping/           # DimensionAdapter, InputProjector, PatternLearner
├── memory/            # StateMemory, TransitionMemory, Ecology, Trajectory, Climate
├── decision/          # Pathfinder, ThirdChoiceGenerator
├── self_layer/        # NLPSelfLayer (Dilts 8-level identity model)
├── llm/               # Multi-provider bridge (OpenAI/Claude/Gemini)
├── storage/           # PersistenceLayer (JSON), MongoPersistence (MongoDB)
├── api.py             # FastAPI REST interface
├── cli.py             # Command-line interface
└── agent.py           # BTCUAgent orchestrator

Documentation

Configuration

All via environment variables with BTCU_ prefix:

BTCU_LLM_PROVIDER=openai          # openai / anthropic / gemini
BTCU_LLM_API_KEY=sk-...
BTCU_LLM_MODEL=gpt-4o-mini
BTCU_MONGO_URI=mongodb://localhost:27017

Or use a .env file.

Testing

pip install "btcu-harness[dev]"
pytest tests/ -v

License

MIT License

Metadata

Release files for btcu-harness 1.3.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 btcu-harness 1.3.0
File Size Uploaded Provenance Actions
btcu_harness-1.3.0.tar.gz 157.7 kB Without provenance Details for btcu_harness-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for btcu-harness 1.3.0
File Interpreter ABI Platform Actions
btcu_harness-1.3.0-py3-none-any.whl Python 3 none any Details for btcu_harness-1.3.0-py3-none-any.whl

Total release size: 307.3 kB

Release files / btcu_harness-1.3.0.tar.gz

Download URL btcu_harness-1.3.0.tar.gz
Size 157.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ab6f00158345498359266dac262b73386ab4e2ffc2e4ee8030819d3f46073a19
BLAKE2b-256 checksum
How to use checksums
792cf50f3199ea7c07ccfcc8766b6428fb1b97368f3307009711a066352f0a73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Release files / btcu_harness-1.3.0-py3-none-any.whl

Download URL btcu_harness-1.3.0-py3-none-any.whl
Size 149.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
895a9d9eb922308e3fea977990f8808072c52fc2a73ccea15e38515dbc415a57
BLAKE2b-256 checksum
How to use checksums
1c861084c3f98fe4c31dfeb816b244cc7c71f13b3357e3ed0c3ed4625c152fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.8

Security for btcu-harness 1.3.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.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files No provenance

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