Metadata-Version: 2.4
Name: commitgov
Version: 1.0.0
Summary: MOSES Constitutional Governance Framework — sovereign governance for AI agents
Author-email: Deric McHenry <deric.mchenry@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/SunrisesIllNeverSee/commitgov
Project-URL: Repository, https://github.com/SunrisesIllNeverSee/commitgov
Project-URL: Documentation, https://github.com/SunrisesIllNeverSee/commitgov#readme
Project-URL: Bug Tracker, https://github.com/SunrisesIllNeverSee/commitgov/issues
Keywords: governance,ai,constitutional,audit,lineage,commitment,agent,sovereignty,provenance,mcp
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: enterprise
Requires-Dist: pyyaml>=6.0; extra == "enterprise"
Requires-Dist: opentelemetry-sdk>=1.20; extra == "enterprise"
Requires-Dist: opentelemetry-exporter-otlp>=1.20; extra == "enterprise"
Requires-Dist: httpx>=0.24; extra == "enterprise"
Requires-Dist: requests>=2.31; extra == "enterprise"
Provides-Extra: mcp
Requires-Dist: mcp>=1.0; extra == "mcp"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Provides-Extra: all
Requires-Dist: pyyaml>=6.0; extra == "all"
Requires-Dist: opentelemetry-sdk>=1.20; extra == "all"
Requires-Dist: opentelemetry-exporter-otlp>=1.20; extra == "all"
Requires-Dist: httpx>=0.24; extra == "all"
Requires-Dist: requests>=2.31; extra == "all"
Requires-Dist: mcp>=1.0; extra == "all"
Dynamic: license-file

# MOSES Constitutional Governance Framework

**Sovereign governance for AI agents — modes, postures, roles, SHA-256 audit chain, commitment conservation, lineage custody, and enterprise hardening.**

© 2026 Ello Cello LLC. All rights reserved.
Patent Pending: Serial No. 63/877,177

## Overview

MOSES (Modular Open System for Executive Sovereignty) is a constitutional governance framework for AI agents. It provides real-time execution-path enforcement through blocking constitutional gates, cryptographic provenance, and semantic commitment conservation.

### Three Interfaces, One Core

```python
# Library
from commitgov import governed_step, GovernanceState, AuditLedger

# CLI
python -m commitgov.cli status
python -m commitgov.cli run-task "deploy app" "read config|build|deploy"

# MCP Server
python server.py  # FastMCP stdio — 40 tools
```

## Architecture

### Core Library (Phase 1-3A)

| Module | Purpose | Tests |
|--------|---------|-------|
| `engine.py` | Modes, postures, roles, GovernanceState, action checking | 80 |
| `audit.py` | SHA-256 chained audit ledger with Isnad provenance | 32 |
| `commitment.py` | Commitment kernel extraction, Jaccard similarity, ghost tokens | 44 |
| `lineage.py` | 3-layer custody chain, archival chain, instance hash | 31 |
| `loop.py` | 6-gate ReAct loop, resilience monitoring | 19 |
| `signing.py` | Governance-gated HMAC signing (no bypass path) | 23 |
| `witness.py` | Moltbook external witness (blind envelopes) | 14 |
| `oracle.py` | Grok API external verification (fail-safe) | 11 |
| `swarm.py` | Primary→Secondary→Observer coordination | 16 |
| `meta.py` | Constitution amendments, rollback, proposals | 18 |
| `review.py` | Adversarial blind peer review + external referee | 10 |
| `model_swap.py` | Cross-model kernel comparison | 10 |
| `presence.py` | Nonce challenge/response liveness | 11 |
| `handshake.py` | Inter-agent envelope pack/unpack/verify | 11 |
| `progress.py` | Task tracking + recovery flags | 10 |
| `patterns.py` | Ghost pattern registry + fingerprinting | 14 |

### Enterprise Modules (Phase 3B — 21 Grok Upgrades)

| Module | Component | Dependencies |
|--------|-----------|-------------|
| `otel_tracing.py` | OTel Auto-Tracing | opentelemetry-sdk (optional) |
| `sinks.py` | Salesforce + Splunk + ConstitutionalCognitiveSink | requests (optional) |
| `envelope.py` | MissionEnvelope YAML | PyYAML (optional) |
| `gates.py` | ScriptedGates declarative checks | — |
| `obo.py` | OBO Claims (OAuth2 token exchange) | requests (optional) |
| `policy_bundle.py` | PII guard, rate limit, approval workflow | — |
| `flame_gateway.py` | DynamicFlameGateway (adaptive posture) | — |
| `trace.py` | SelfPayingConstitutionalTrace (Atomic Game Changer #1) | — |
| `royalty.py` | RoyaltyObligation webhook | requests (optional) |
| `omni_gateway.py` | IntentConservingOmniGateway (Atomic Game Changer #2) | — |
| `control_plane.py` | SovereignControlPlane | — |
| `passport.py` | ConstitutionalCognitivePassport | — |
| `playback.py` | ProvenanceAwareSessionPlayback | — |
| `config.py` | Enterprise YAML config | PyYAML (optional) |

### MCP Server (Phase 4)

40 tools exposed via FastMCP:
- Governance (6): set_mode, set_posture, set_role, check_action, get_status, assemble_context
- Vault (3): load, list, clear
- Audit (4): log, verify, recent, hash_session
- Commitment (2): check_commitment, check_ghost_tokens
- Lineage (2): verify, get_status
- Loop (2): run_step, run_task
- Signing (1): sign
- Witness (1): witness_event
- Oracle (1): oracle_verify
- Swarm (1): run_swarm_round
- Review (1): adversarial_review
- Model Swap (1): model_swap_test
- Presence (1): presence_challenge
- Handshake (1): handshake
- Progress (1): get_progress
- Meta (6): list_amendments, propose, ratify, rollback, constitution_status, list_modes
- Enterprise (5): load_envelope, check_gates, get_playback, emit_passport, control_plane
- Resilience (1): resilience_report

### CLI (Phase 5)

22 commands wrapping the core library for terminal usage.

## Installation

```bash
# No external dependencies required (stdlib only)
pip install -e .

# Optional dependencies for enterprise features
pip install requests pyyaml opentelemetry-sdk
```

## Quick Start

```python
from commitgov import GovernanceState, governed_step, AuditLedger

# Set up governance
gs = GovernanceState(mode="High Security", posture="DEFENSE", role="Primary")

# Run a governed step through the 6-gate ReAct loop
result = governed_step(
    task="deploy application",
    action="write config file",
    step_num=1,
    total_steps=3,
    governance=gs,
    ledger_path="audit.jsonl",
    lineage_path="lineage.json",
    progress_path="progress.json",
)

print(f"Success: {result.success}")
print(f"Reason: {result.reason}")
```

## Testing

```bash
# Run all 469 tests
python -m pytest tests/ -q

# Run specific module tests
python -m pytest tests/test_engine.py -q

# Run stress tests
python -m pytest tests/test_stress.py -q
```

## Key Concepts

### Six Fold Flame
Every action must pass all six constitutional gates before execution:
1. **Sovereignty** — Traceable to a registered agent
2. **Compression** — Substantive, high-signal (no filler)
3. **Purpose** — Serves a constitutional function
4. **Modularity** — Compatible with existing structure
5. **Verifiability** — Outcome can be tested/verified
6. **Reciprocal Resonance** — Produces value when mirrored

### Conservation Law of Commitment
C(T(S)) ≈ C(S) — commitment is conserved under transformation. The Jaccard similarity between commitment kernels before and after transformation must stay above threshold.

### Ghost Tokens
When commitment tokens leak, the pattern of leaked tokens is fingerprinted. If two agents produce the same fingerprint, it's a structural flaw, not extraction variance.

### 6-Gate ReAct Loop
1. Lineage verify (anchor chain)
2. Status load (governance state)
3. Ghost token gate (cascade risk)
4. Posture gate (SCOUT blocks, DEFENSE requires confirm, OFFENSE permits)
5. Audit log (with Isnad)
6. Progress write (continuity across context windows)

## License

© 2026 Ello Cello LLC. All rights reserved.
Patent Pending: Serial No. 63/877,177
