LATEST RELEASE v0.3.4Released October 2026

Cohzen (`cz`) Documentation

Cohzen is a static architecture scanner, zero-egress runtime telemetry engine, and CI/CD governance suite for agentic workflows, built authoritatively for LangGraph (supporting 0.2.x through 1.2.x) under the Apache 2.0 license.

What's New in v0.3.4 & The v0.3 Release Series

The v0.3 series transforms Cohzen from an analysis tool into a complete zero-overhead local observability and CI governance engine:

  • Slim `cz init` Output (v0.3.4): Streamlined onboarding displays only the detected graph topology and routing edges table, eliminating terminal clutter.
  • Zero-Overhead `.pth` Startup Hook: Deprecated legacy sitecustomize.py injection in favor of virtualenv cohzen_startup.pth hooks for completely non-invasive execution interception.
  • Full Capture Lifecycle Management: New cz capture -- <cmd> for one-off runs, cz status, cz on, cz off, and cz deinit.
  • CI/CD Governance Gates: cz audit --min-coverage <pct> and --fail-on-empty with standardized exit codes (0, 1, 2) and PR comments via the composite GitHub Action.
  • Zero-Egress Local SQLite & Secret Redaction: High-performance asynchronous execution store (.cohzen/executions.db) with automatic pattern-based secret redaction and retention pruning.
  • Apache 2.0 License: Officially relicensed from MIT to Apache-2.0 with Contributor Covenant and DCO sign-offs.
cz scan [path]

Statically parses Python AST to reconstruct state graphs, nodes, conditional edge routes, model invocations, tools, and checkpointer persistence. Emits terminal dashboards, Mermaid flowcharts, or canonical CohzenManifest JSON with zero runtime code execution.

cz audit [path]

Consumes AST facts to audit observability coverage. Flags uninstrumented LLM caller nodes, missing tracing decorators (@traceable, @observe), and enforces CI quality gates with --min-coverage and --fail-on-empty.

Installation & Setup

Cohzen is written in Python (compatible with Python 3.10, 3.11, and 3.12). Install it via PyPI or install from source in editable mode:

Option A: Install via PyPI
$ pip install cohzen
Option B: Install from GitHub source
$ git clone https://github.com/cohzenai/cohzen.git
$ cd cohzen/cz
$ pip install -e .
Verify installation:$ cz version # Output: cz version 0.3.4

5-Minute Quickstart

You can scan architectures, record live executions, and debug individual graph nodes immediately. Navigate to your project directory and execute:

Step 1. Scan your agent architecture
$ cz scan .

Inspects Python files, builds ASTs, and renders an interactive Rich console report of graphs, nodes, conditional edges, tools, and LLM call sites.

Step 2. Audit observability coverage & telemetry gaps
$ cz audit .

Checks package manifests, .env files, and function decorators to detect nodes and tools lacking telemetry.

Step 3. Initialize zero-code runtime execution tracking
$ cz init

Enables transparent execution tracking in your directory. Run your workflow normally; executions and spans are stored in local SQLite (.cohzen/executions.db).

Step 4. View execution waterfall timeline
$ cz runs && cz waterfall <id>

Inspect recorded executions, overall latency, and Gantt waterfall timelines detailing exact microsecond offsets of node handlers and LLM calls.

Step 5. Debug any node in complete isolation
$ cz node run <node_name> --from-run <id>

Replays captured state or custom JSON to execute a single node directly without compiling or running the entire graph.

cz init — Slim Project Initialization & Startup Hook

v0.3.4 UPDATED

cz init initializes Cohzen in your agent repository with a single command. In v0.3.4, cz init features a slim topology output by default, rendering discovered graph routing edges without noisy terminal logs, and installs a clean virtual environment startup hook:

$ cz init
# Initialize a specific directory or skip confirmation:
$ cz init ./path/to/project --yes
# Target a specific Python environment:
$ cz init --python /path/to/venv/bin/python
Terminal Output: cz init (v0.3.4 Slim Output)Exit code: 0
Cohzen will:
  • create or modify .cohzen/config.toml
  • create or modify .cohzen/manifest.json
  • create or modify .cohzen/executions.db
  • create or modify .gitignore
  • create or modify .venv/lib/python3.11/site-packages/cohzen_startup.pth

Graph Topology & Routing Edges
┏━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃ Type        ┃ Source    ┃ Direction ┃ Target / Routing   ┃ Location          ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│ DIRECT      │ START     │    ──>    │ assistant          │ agent_tools.py:35 │
│ CONDITIONAL │ assistant │   ─?─>    │ fn: lambda state:  │ agent_tools.py:36 │
│             │           │           │ 'tools' | 'finish' │                   │
│ DIRECT      │ tools     │    ──>    │ assistant          │ agent_tools.py:41 │
└─────────────┴───────────┴───────────┴────────────────────┴───────────────────┘

✔ Cohzen initialized at ./
  • Manifest: .cohzen/manifest.json (1 graphs, 2 nodes, 2 tools)
  • Telemetry DB: .cohzen/executions.db
  • Startup hook: .venv/lib/python3.11/site-packages/cohzen_startup.pth
  • Added .cohzen/ to .gitignore

Capture is enabled for eligible local LangGraph runs. One-off capture remains available:
  cz capture -- python app.py

Then inspect recorded executions:
  cz runs
1. Pre-computes Architecture Manifest

Statically scans all Python files in the target directory and outputs .cohzen/manifest.json with exact node handlers, routing edges, tools, and LLM call locations.

2. Creates SQLite Telemetry Engine

Initializes .cohzen/executions.db, a local high-performance SQLite store capturing run metadata, states, and span trees with zero network egress.

3. Zero-Overhead .pth Startup Hook

Installs cohzen_startup.pth into the virtual environment site-packages. Completely non-invasive: leaves project source code untouched and cleanly migrates legacy hooks.

4. Project Configuration & Retention

Generates .cohzen/config.toml to govern capture toggles, retention pruning (max_runs, max_age_days), and regex secret redaction.

How the Virtualenv .pth Hook Works Under the Hood

Python's standard library executes .pth files discovered in site-packages during interpreter startup. Cohzen places a guarded one-line hook that calls cz._startup.start() wrapped in a safe try/except. It cleanly wraps compiled LangGraph invocations (Pregel, CompiledStateGraph) with zero runtime dependencies if Cohzen is uninstalled.

cz capture & Lifecycle Controls (on / off / status / deinit)

v0.3.0 NEW

Cohzen gives you total control over when and how runtime capture runs. Whether you prefer one-off execution capture or non-destructive toggling:

One-off Process Capture
$ cz capture -- python app.py

Executes the supplied command with runtime interception active only for that specific process. No persistent startup hooks are required.

Inspect Project Status & Retention
$ cz status

Displays whether capture is enabled, startup hook file paths, telemetry DB record counts, and active secret redaction filters.

Toggle Capture Non-Destructively
$ cz off && cz on

Switches the enabled flag in .cohzen/config.toml instantly without removing hooks or reinstalling packages.

Clean Teardown with cz deinit
$ cz deinit --keep-data

Safely unlinks the .pth hook, cleans legacy files, removes configuration, and optionally preserves executions.db.

cz scan — Architecture Discovery

COMMAND

cz scan [PATH] reconstructs LangGraph workflows statically from Python AST without executing any runtime code or importing dependencies.

Command Options & Flags

FlagTypeDescription
pathArgument (default: .)Target directory or Python file to scan.
--jsonFlagEmit the official CohzenManifest v0.1.0 JSON format.
--mermaidFlagTranslate graph topology into Mermaid flowchart markup.
-o, --outputOption [FILE]Write manifest or diagram output to specified file path.
--viewFlagLaunch dark-mode interactive HTML browser visualizer.

Terminal Output Walkthrough

Running cz scan . outputs high-signal Rich tables with exact file spans:

Terminal Output: cz scan .Exit code: 0
╭─────────────── Cohzen Architecture Scan (v0.1) ────────────────╮
│  Scanned Target: ./examples/langgraph-tools                    │
│  Frameworks:     ✓ langgraph                                  │
│  Files Examined: 2 total (1 Python files)                     │
│  Scan Duration:  1.69 ms                                      │
│  Graphs: 1  • Nodes: 2  • Edges: 3  • Tools: 2  • Models: 1   │
╰───────────────────────────────────────────────────────────────╯

Registered Nodes & Handlers:
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Node Name    ┃ Handler / Location ┃ LLM Calls & Models ┃ Tools Bound         ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩
│ 🤖 assistant │ assistant (app.py) │ langchain          │ bound: search_docs  │
│ 🤖 tools     │ tool_node (app.py) │ Tool Execution     │ ToolNode(search_docs│
│              │                    │                    │ calculate_metrics)  │
└──────────────┴────────────────────┴────────────────────┴─────────────────────┘

🛠️ Detected Tool Functions (@tool):
┏━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Tool Name            ┃ Location             ┃ Docstring / Purpose            ┃
┡━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 🔧 search_docs       │ agent_tools.py:8-10  │ Search internal documentation  │
│ 🔧 calculate_metrics │ agent_tools.py:13-15 │ Compute aggregate score        │
└──────────────────────┴──────────────────────┴────────────────────────────────┘

cz audit — Observability & CI/CD Governance Gates

v0.3.4 UPDATED

cz audit [PATH] evaluates observability instrumentation across your entire agentic codebase. It consumes the AST architectural model without executing user code and enforces strict CI/CD gate checks.

What `cz audit` Checks

1. Decorator Attribution

Verifies that agent nodes performing LLM calls or tool execution are decorated with @traceable, @observe, or span hooks.

2. Environment Flags

Cross-references .env files for critical flags like LANGCHAIN_TRACING_V2=true or LANGFUSE_PUBLIC_KEY.

3. Manifest Dependencies

Audits pyproject.toml and requirements.txt for telemetry packages (LangSmith, Langfuse, Phoenix, Traceloop, OTel).

CI/CD Quality Gate Options

FlagTypeDescription
--min-coverageOption [FLOAT]Minimum required agent/node instrumentation percentage (0-100). Exits with code 1 if not met. Skipped with an INFO line on empty repos unless --fail-on-empty is passed.
--fail-on-emptyFlagExit with code 1 when no agent nodes are found in the scanned directory. Ensures governance checks run only on repos containing active workflows.
--fail-on-missingFlagExit with code 1 if no telemetry packages or active environment configurations are detected.
--jsonFlagOutput machine-readable JSON. In v0.3.4, agent_instrumentation_pct returns null for empty repos rather than a misleading 0.0 or 100.0%.

Exit Code Specification

CodeStatusMeaning
0PASSED / SKIPPEDAll requested checks passed, or checks skipped on an empty repository without --fail-on-empty.
1GATE FAILEDA CI gate check failed (--min-coverage threshold unmet, --fail-on-missing triggered, or --fail-on-empty triggered on empty repo).
2USAGE ERRORInvalid CLI arguments or options.

Audit Findings & Gaps Example

Terminal Output: cz audit . --min-coverage 80CI Gate Alert
╭─────────────── Cohzen Observability & Telemetry Audit (v0.3) ────────────────╮
│  Scanned Target:    ./examples/langgraph-tools                               │
│  Observability:     LangSmith detected in package manifests                  │
│  Tracing Coverage:  Nodes: 1/2 (50.0%)  •  Tools: 1/2 (50.0%)                │
│  CI Gate Check:     Required 80.0% coverage  -->  FAILED (50.0%)             │
╰──────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────── Node Instrumentation Status ───────────────────────────╮
│ Node Name            │ Location           │ Tracing Status   │ Observability Tool │
│ 🤖 assistant         │ agent_tools.py:20  │ ✖ Uninstrumented │ None               │
│ 🤖 tools             │ agent_tools.py:29  │ ✔ Instrumented   │ LangSmith          │
╰───────────────────────────────────────────────────────────────────────────────────╯

╭─────────────────────────── Audit Findings & Gaps ─────────────────────────────────╮
│                                                                                   │
│  ⚠ LangSmith tracing detected, but 'LANGCHAIN_TRACING_V2=true' missing in .env   │
│  ⚠ Agent(s) 'assistant' perform LLM calls without @traceable or @observe          │
│  ✖ CI Gate Failure: Codebase coverage 50.0% does not meet --min-coverage 80.0%   │
│                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────╯
Export audit for CI/CD gates:$ cz audit . --json > audit.json

cz view — Interactive HTML Visualizer

Cohzen includes a standalone, zero-dependency browser visualizer that opens directly in your default web browser:

$ cz view .
# or equivalent shortcut:
$ cz scan . --view
Zero External Servers Required

Generates a clean HTML/JS visualization bundle that renders Mermaid diagrams, node inspector modals, docstrings, and checkpointer metadata offline.

v0.3.4 UPDATED

cz runs & cz run — Runtime Execution Telemetry

Inspect recorded runtime executions captured in SQLite. View completion statuses, overall duration, step-by-step node transitions, why reasoning tags, and granular token/tool metrics.

1. List Recorded Executions
$ cz runs

Displays all captured runs from .cohzen/executions.db, with execution IDs, graph names, status icons (✓ completed, ✗ failed, ● running), durations, and start times.

Terminal Output: cz runs
Cohzen Executions

ID          Graph                   Status     Duration  Started
─────────────────────────────────────────────────────────────────
7f3b89e2    support_assistant         ✓         1.18s    14:22:10
ce2e6db9    customer_onboarding       ✓         892ms    14:20:02
a82f9104    isolated_node:planner     ✓         127ms    14:15:18
2. Inspect Execution Details & Spans
$ cz run <execution_id> [-v, --verbose] [--json]

Renders the execution summary, goal/why reasons, the sequential transition flow from START to END, step durations, and aggregated LLM and tool call metrics. Pass --verbose to view untruncated payloads and error messages.

Terminal Output: cz run 7f3b89e2
Execution 7f3b89e2
────────────────────────────
Graph       support_assistant
Status      ✓ completed
Duration    1.18s
Goal / Why  Process user technical inquiry

START
  │
  ▼
collect_info                    310ms
      why: retrieve ticket history
  │
  ▼
ChatOpenAI.invoke               280ms
  │
  ▼
tools                           540ms
  │
  ▼
END

LLM calls     1
Tool calls    1
Nodes         2
SECURITY & PRIVACY

Privacy, Secret Redaction & Run Retention

Cohzen is architected from day one for zero-trust environments. All captured telemetry remains strictly on your local machine with zero external network egress.

1. Zero Network Egress

Both static scanning and runtime capture operate strictly offline. Rigorous privacy test suites continuously assert 0 socket calls and 0 egress bytes.

2. Pattern Secret Redaction

Built-in RedactionProcessor redacts OpenAI, Anthropic, Gemini, AWS, and GitHub tokens, Bearer headers, emails, and private keys before committing to disk.

3. Automated Run Pruning

Configurable in .cohzen/config.toml: automatically prunes excess runs (max_runs = 500) and expired runs (max_age_days = 30) to keep disk usage lean.

Mermaid Diagram Export

Generate native LangGraph-compatible Mermaid flowcharts directly from AST. Perfect for README documentation, architecture RFCs, and PR reviews:

$ cz scan . --mermaid -o architecture.mmd
Generated Mermaid Syntax Preview
flowchart TD
    __start__([● START]):::sentinelNode
    __end__([● END]):::sentinelNode
    assistant["🤖 assistant<br/>🧠 LLM: langchain<br/>🛠️ Tools: [search_docs]"]:::instrumentedAgent
    tools[["🛠️ tools (ToolNode)<br/>Tools: search_docs"]]:::toolNode
    __start__ --> assistant
    assistant -.->|route: tools| tools
    assistant -.->|route: finish| __end__
    tools --> assistant

CohzenManifest v0.1.0 Specification

SPECIFICATION

The CohzenManifest is the immutable, machine-readable contract produced by cz scan --json.

CohzenManifest v0.1.0 JSON Schema
{
  "version": "0.1.0",
  "metadata": {
    "target": ".",
    "files_scanned": 14,
    "files_skipped": 0,
    "parse_errors": 0,
    "unresolved_symbols": 0,
    "dynamic_constructions": 0,
    "scan_duration_ms": 1.82,
    "created_at": "2024-09-19T12:00:00Z",
    "warnings": []
  },
  "frameworks": ["langgraph"],
  "graphs": [
    {
      "id": "graph.workflow",
      "name": "workflow",
      "framework": "langgraph",
      "graph_class": "StateGraph",
      "state_schema": "AgentState",
      "source": { "file": "app.py", "line_start": 20, "line_end": 20 },
      "node_ids": ["planner", "tools"],
      "edges": [
        { "source": "START", "target": "planner", "edge_type": "direct" },
        { "source": "planner", "target": "tools", "edge_type": "conditional" }
      ],
      "compilation": {
        "compiled_var": "app",
        "checkpointer": "MemorySaver",
        "source": { "file": "app.py", "line_start": 35, "line_end": 35 }
      }
    }
  ],
  "nodes": [
    {
      "id": "planner",
      "name": "planner",
      "kind": "node",
      "handler": "planner_node",
      "source": { "file": "app.py", "line_start": 10, "line_end": 18 },
      "model_ids": ["model.openai.gpt-4o"],
      "tool_ids": ["tool.search_web"],
      "resolution": { "status": "resolved", "reason": null },
      "classification": { "role": "agent", "confidence": "high", "evidence": ["llm_invocation", "tool_binding"] }
    }
  ],
  "tools": [
    {
      "id": "tool.search_web",
      "name": "search_web",
      "source": { "file": "tools.py", "line_start": 5, "line_end": 8 },
      "docstring": "Searches the web",
      "resolution": { "status": "resolved", "reason": null }
    }
  ],
  "models": [
    {
      "id": "model.openai.gpt-4o",
      "provider": "openai",
      "name": "gpt-4o",
      "source": { "file": "app.py", "line_start": 12, "line_end": 12 }
    }
  ]
}

Supported Frameworks & Providers

Cohzen v0.1 features a comprehensive suite of static detectors across agent frameworks, LLM providers, and observability stacks:

1. Agent Framework: LangGraph (v0.1 Scope)

ConstructPatternDetection Status
Graph TypesStateGraph, MessageGraph, Graph✔ Full Static Support
Nodes & Handlersadd_node(name, fn), lambdas✔ Full Static Support
Direct & Conditional Edgesadd_edge, add_conditional_edges✔ Full Static Support
ToolNodeToolNode(tools), @tool functions✔ Full Static Support
Compilation & Persistence.compile(checkpointer=MemorySaver)✔ Full Static Support

2. LLM Providers & Invocations

✓OpenAI (chat.completions)
✓Anthropic (messages.create)
✓Google Gemini (genai.Client)
✓Groq (chat.completions)
✓xAI Grok (Client)
✓LiteLLM (completion)
✓LangChain (model.invoke)
✓Tool Bindings (.bind_tools)

3. Observability Audit Detectors

✓LangSmith (@traceable, env)
✓Langfuse (@observe, env)
✓OpenTelemetry (APIs, traces)
✓Arize Phoenix (openinference)
✓Traceloop (OpenLLMetry)
✓AgentOps (@track_agent)
✓W&B Weave (@weave.op)
✓Environment config (.env)

CI/CD & GitHub Actions Automation

Integrate cz scan and cz audit directly into GitHub Actions with our composite action to enforce architectural governance, verify minimum telemetry coverage, and post collapsible Mermaid diagrams on pull requests:

Option A: Official Composite GitHub Action (cohzenai/cohzen@v0.3.4)
name: Cohzen Architecture & Telemetry Gate
on: [push, pull_request]

jobs:
  cohzen-audit:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Run Cohzen Governance Action
        uses: cohzenai/cohzen@v0.3.4
        with:
          min-coverage: '80'
          fail-on-empty: 'true'
Option B: Direct CLI Integration
name: Cohzen Architecture & Telemetry Gate
on: [push, pull_request]

jobs:
  cohzen-audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install Cohzen
        run: pip install cohzen
      - name: Verify Architecture Graph
        run: cz scan . --json -o manifest.json
      - name: Audit Telemetry Gate (Min 80% coverage)
        run: cz audit . --min-coverage 80 --fail-on-empty

Troubleshooting & FAQ

Q: Why does Cohzen use 100% static analysis instead of runtime imports?

Runtime imports require all heavy dependencies installed, valid credentials in .env, and can trigger unwanted side-effects (database initialization, model pings). Static AST parsing works in milliseconds in any sandbox or CI runner without credentials.

Q: What license is Cohzen distributed under?

Cohzen is released as free and open-source software under the Apache 2.0 license (Apache-2.0) with an explicit NOTICE file. All contributions adhere to the Developer Certificate of Origin (DCO).

Q: Which LangGraph versions are supported?

Cohzen v0.3.4 contains a multi-version contract verification suite tested against LangGraph 0.2.76, 1.0.10, 1.1.10, and 1.2.16. Both pre-1.0 and 1.x Pregel compiled graphs are seamlessly intercepted without dropped runs.

Q: What happens if a node handler is imported from another package?

Cohzen uses graceful degradation. External library handlers are resolved as external_import with package attribution (e.g. package="external_agent_pkg") and highlighted in analysis limitations rather than failing as errors.

Q: How do I report a new pattern or framework?

Please open an issue or pull request on the official GitHub repository at github.com/cohzenai/cohzen.