Skip to main content
Glama

๐ŸŒ OMNISTATE

Planning before implementation

Prompted transactions must record the original requirement in a memo, decompose it into checklist items and dependency-aware subtasks, and attach evidence before audit/finish. Use memo, checklist, and subtask after begin; the planning gate rejects unfinished or unlinked work. After the first plan is complete, use plan-review to activate an independent subagent that checks alignment with the user request, omissions, conflicts, and better approaches. Audit requires the review to be APPROVED or RESOLVED.

Universal State Governance, Transaction Guardrails & Anti-Bypass Framework for AI Agents, MCP & CLI
Zero Context Loss โ€ข Scope Enclosure โ€ข Anti-Laziness Diff Defense โ€ข Git Pre-commit Warden

License: MIT Python: 3.8+ Model Context Protocol Zero External Dependencies


Related MCP server: Harness Engineering MCP

๐ŸŽฏ The Problem

When Large Language Models (LLMs) and autonomous AI coding agents (Claude, Cursor, Copilot, ChatGPT, Cline, Antigravity) develop software, they inevitably run into four critical failure modes:

  1. Context Loss & Amnesia Across Sessions: When a chat restarts or compacts, the AI forgets what was changed, what decisions were made, or what step it was on.

  2. Scope Creep & Accidental Regression: The AI modifies files far outside its intended scope, breaking unrelated features or deleting essential comments and functions.

  3. Lazy AI Placeholders: The AI generates truncated code snippets such as // ... rest of implementation unchanged, # TODO: implement this, or silently deletes production logic.

  4. Unverified Commits: The AI hallucinates that "all tests pass" and commits directly to git without empirical proof or verified evidence.

OMNISTATE solves this by bringing deterministic ACID transaction semantics, multi-gate automated auditing, and a tamper-proof Git Warden to any software project.


๐Ÿ—๏ธ Architecture & Transaction Lifecycle

flowchart TD
    subgraph Human_or_AI ["AI Agent or Developer"]
        Init["omnistate init<br>(Mounts pre-commit hook)"] --> Begin
        Begin["omnistate begin<br>(Declare Intent & Scope)"]
        Begin --> Step["omnistate step<br>(Record Milestones)"]
        Step --> CodeEdit["Perform Code Edits"]
        CodeEdit --> Audit["omnistate audit<br>(Deterministic Gates)"]
    end

    subgraph Gates ["Quality & Security Gates"]
        Audit --> G1["Gate 1: Scope Enclosure Check"]
        Audit --> G2["Gate 2: Anti-Laziness Critic (Diff Scan)"]
        Audit --> G3["Gate 3: Anti-Bloat Ratio Check"]
        Audit --> G4["Gate 4: Automated Test Runner"]
        Audit --> G5["Gate 5: Empirical Evidence Verification"]
    end

    subgraph State_Engine ["OMNISTATE Engine"]
        G1 & G2 & G3 & G4 & G5 -->|All Passed| AuditPassed["Status: AUDITED<br>(Freezes SHA-256 Fingerprints)"]
        AuditPassed --> Finish["omnistate finish"]
        Finish --> TamperCheck{"Anti-Tamper Check:<br>Files changed since audit?"}
        TamperCheck -->|No| Clearance["Issue Commit Clearance Token<br>OMNI_CLEAR_XXXXXXXX<br>Archive rev_XXXX.json"]
        TamperCheck -->|Yes| TamperFail["๐Ÿšจ Tamper Violation<br>Require Re-Audit"]
    end

    subgraph Git_Warden ["Git Pre-Commit Warden Hook"]
        Clearance --> GitCommit["git commit -m '...'"]
        GitCommit --> PreCommitHook[".git/hooks/pre-commit"]
        PreCommitHook --> WardenScan{"Warden Verification:<br>1. Active session completed?<br>2. Valid clearance token?<br>3. Staged hashes == Audited hashes?"}
        WardenScan -->|Yes| CommitAllowed["โœ… Commit Permitted"]
        WardenScan -->|No| CommitBlocked["โŒ COMMIT BLOCKED"]
    end

โœจ Key Features

  • ๐Ÿ›ก๏ธ ACID Transactions for AI Edits: begin $\rightarrow$ step $\rightarrow$ audit $\rightarrow$ finish $\rightarrow$ commit.

  • ๐Ÿ”Œ Dual-Mode Adapters:

    • CLI Mode: Full-featured terminal interface with rich dashboards.

    • MCP Server Mode (Model Context Protocol): Exposes state tools directly to Claude Desktop, Cursor, Antigravity, OpenCode, Windsurf, and any MCP client over stdio.

  • ๐Ÿ”’ Anti-Tamper & Anti-Laziness Guardrail:

    • Scans unified diffs for lazy ellipsis comments (// ..., # TODO: implement).

    • Cryptographically locks audited files via SHA-256. Any modification made after audit invalidates the clearance token.

  • ๐Ÿ‘ฎ Git Warden Pre-Commit Hook:

    • Blocks any git commit or git push if code was not properly audited and cleared by OMNISTATE.

  • ๐Ÿ“ฆ Zero External Dependencies:

    • Pure Python standard library (compatible with Python 3.8+). No heavy dependencies, no version conflicts.

  • ๐Ÿ“œ Immutable History Snapshots:

    • Automatically records full state history in .omnistate/snapshots/rev_0001.json with revision deltas.


๐Ÿš€ Quick Start

1. Installation

git clone https://github.com/cwen0224/omnistate.git
cd omnistate
pip install -e .

Or install directly via pip (once published):

pip install omnistate

2. Initialize in Your Project

In any git repository:

cd /path/to/your/project
omnistate init

This will:

  1. Create the .omnistate/ directory with omnistate.json configuration.

  2. Install the automated pre-commit hook in .git/hooks/pre-commit.


๐Ÿค– Using with AI via MCP (Model Context Protocol)

OMNISTATE includes a built-in, zero-dependency MCP server that enables AI models to govern their own changes safely.

Claude Desktop Configuration

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "omnistate": {
      "command": "omnistate-mcp",
      "args": ["--workspace", "/path/to/your/project"]
    }
  }
}

Cursor / Windsurf / Antigravity / OpenCode Configuration

Add to your project's MCP settings:

{
  "name": "omnistate",
  "command": "python",
  "args": ["-m", "omnistate.mcp", "--workspace", "."]
}

Tools Exposed to the AI

MCP Tool Name

Description

omnistate_init

Initialize state governance and pre-commit hook in workspace

omnistate_begin

Start a transactional state change with declared intent and scope boundaries

omnistate_step

Record an incremental milestone or progress step

omnistate_audit

Deterministically verify modified code against scope, anti-laziness, and test gates

omnistate_finish

Verify anti-tamper fingerprints, archive immutable snapshot, and issue commit clearance

omnistate_abort

Abort active transaction and optionally roll back uncommitted changes

omnistate_status

Return active transaction status, git state, and clearance token

omnistate_inspect_diff

Scan working tree diff for anti-laziness violations

omnistate_explain_rules

Return state governance and guardrail rules for the AI context


๐Ÿ’ป CLI Usage Guide

1. Begin a Task

omnistate begin --intent "Implement OAuth login" --scope "auth/,tests/" --risk standard

2. Record Progress

omnistate step --action "Implemented JWT token parser" --details "Added unit test in test_auth.py"

3. Check Governance Dashboard

omnistate status

Output:

==================================================================
  ๐ŸŒ OMNISTATE STATE GOVERNANCE DASHBOARD (v1.0.0)
==================================================================
  Project Root     : /home/dev/my-project
  State Directory  : /home/dev/my-project/.omnistate
  Current Revision : #0012
  Git HEAD Commit  : a4b91ef201
------------------------------------------------------------------
  Transaction ID   : sess_3f1a92b810de
  Transaction State: ๐ŸŸก [ IN_PROGRESS ]
  Intent Summary   : Implement OAuth login
  Scope Boundary   : ['auth/', 'tests/']
  Risk Tier        : STANDARD
  Steps Recorded   : 3
  Audit Status     : โณ PENDING (Run 'omnistate audit' when edits complete)
------------------------------------------------------------------
  Working Tree Mod : 2 files modified
    โ€ข auth/oauth.py
    โ€ข tests/test_oauth.py
==================================================================

4. Audit Modifications

omnistate audit

Output:

================ OMNISTATE AUDIT RESULTS ================
  โœ… PASS | ScopeEnclosureGate
  โœ… PASS | AntiLazinessCritic
  โœ… PASS | AntiBloatCritic
  โœ… PASS | TestRunnerGate
=========================================================
๐ŸŽ‰ All quality gates PASSED! Ready to execute 'omnistate finish'.

5. Finalize & Unlock Git Commit

omnistate finish --evidence "tests/report.txt" --note "All tests green"

Output:

๐ŸŽ‰ [OMNISTATE] Transaction COMPLETED: sess_3f1a92b810de
๐Ÿ›ก๏ธ  Commit Clearance Token: OMNI_CLEAR_8A90F1BC24D7A19E
๐Ÿ“ฆ Archived Revision     : #0013
๐Ÿš€ You are now cleared to commit your changes with git!

6. Commit to Git

git commit -m "feat(auth): implement OAuth login"
# Output:
# ๐Ÿ›ก๏ธ  [OMNISTATE WARDEN PASSED] Clearance Token verified: OMNI_CLEAR_8A90F1BC24D7A19E

โš™๏ธ Configuration (omnistate.json)

Created automatically inside .omnistate/omnistate.json:

{
  "state_dir": ".omnistate",
  "ignored_paths": [
    ".git",
    ".venv",
    "node_modules",
    "__pycache__",
    "dist",
    "build"
  ],
  "gates": {
    "scope_enforcement": true,
    "anti_laziness": true,
    "anti_bloat": true,
    "max_file_growth_ratio": 2.0,
    "max_line_growth": 600,
    "test_command": "pytest -q",
    "evidence_required": false
  },
  "warden": {
    "enforce_pre_commit": true,
    "block_unclear_commits": true
  }
}

๐Ÿ Python SDK API

You can also embed OMNISTATE directly into your Python scripts or custom agent loops:

from pathlib import Path
from omnistate import OmniStateCoordinator

coord = OmniStateCoordinator(Path("."))

# 1. Begin
session = coord.begin(
    intent_summary="Refactor database models",
    scope_paths=["models/", "migrations/"],
    risk_tier="standard"
)

# 2. Record step
coord.record_step("Generated Alembic migration")

# 3. Audit
passed, gate_results = coord.audit(run_tests=True)
if passed:
    # 4. Finish
    finished_session = coord.finish(note="Migrations verified")
    print("Clearance Token:", finished_session.commit_clearance)
else:
    print("Audit failed! Gate errors:", [g.errors for g in gate_results if not g.passed])

๐Ÿงช Running Tests

python -m unittest discover -s tests

๐Ÿ“„ License

MIT License. Copyright (c) 2026 cwen0224.

Available Tools

9 tools
omnistate_abortB

Abort active transaction and optionally roll back uncommitted changes in scope.

Inputs: note, rollback.

omnistate_auditB

Audit current modifications against scope boundaries, anti-laziness gates, and test suites.

Inputs: files, run_tests.

omnistate_beginB

Begin a safe, transactional state change. Declares intent, scope boundaries, and risk tier.

Inputs: intent (required), scope, prompt, non_goals, +1 more.

omnistate_explain_rulesA

Explain the OMNISTATE transaction lifecycle rules and guardrails for AI coding assistants.

Inputs: no named parameters.

omnistate_finishA

Finalize transaction, verify anti-tamper fingerprints, archive immutable snapshot, and issue commit clearance.

Inputs: note, evidence.

omnistate_initC

Initialize OMNISTATE state governance and pre-commit guardrail in the current workspace.

Inputs: overwrite.

omnistate_inspect_diffB

Run anti-laziness and scope inspection on the working tree diff without altering state.

Inputs: no named parameters.

omnistate_statusA

Get current OMNISTATE status, active transaction details, git head, and commit clearance state.

Inputs: no named parameters.

omnistate_stepA

Record an intermediate progress milestone or action within the active transaction.

Inputs: action (required), details.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelogโ€ฆ

    TDQS

    A3.5/5.0

    Scored across 9 tools

    Disambiguation4/5

    Tools map cleanly to a transaction lifecycle (init, begin, step, audit, finish, abort) with status and inspect_diff as read-only helpers. The main possible confusion is audit vs inspect_diff, both involving scope/anti-laziness checks, and init vs begin, but descriptions distinguish state-changing versus read-only and setup versus transaction start.

    Naming Consistency4/5

    All tools share the omnistate_ prefix and snake_case formatting, making the set highly predictable. Minor deviations exist: status is a noun while most names are verbs, init is abbreviated, and step is less action-specific, but the convention remains readable.

    Tool Count5/5

    Nine tools fit comfortably within the ideal 3-15 range for a transaction-governance server. Each tool corresponds to a distinct lifecycle stage or helper, with no obvious filler.

    Completeness4/5

    The surface covers setup, transaction start, progress recording, auditing, commit clearance, abort/rollback, status, diff inspection, and rule explanation. A minor gap is that archived immutable snapshots are created but no tool lists or retrieves transaction history or past snapshots.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents and hosts to enforce deterministic repository boundaries via MCP, providing structured reads, supervised edits, snapshots, audits, and recovery with machine-readable evidence.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Commit-time audit engine for AI coding agents. Scans git diffs with 24 audit rules, writes HMAC-signed tamper-evident audit history, and ships MCP tools for governance aggregation.
      104
      55
      MIT