Metadata-Version: 2.4
Name: hipson
Version: 1.2.1
Summary: Local-first control plane for AI coding agents: one lead, many workers, one ledger of who did what, with evidence.
Author: Hipson Contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Hipson47/Hipson
Project-URL: Repository, https://github.com/Hipson47/Hipson
Project-URL: Documentation, https://github.com/Hipson47/Hipson/blob/main/docs/README.md
Project-URL: Changelog, https://github.com/Hipson47/Hipson/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/Hipson47/Hipson/issues
Keywords: ai-agents,multi-agent,mcp,claude-code,codex,task-ledger,developer-tools,coordination
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: bandit>=1.9.4; extra == "dev"
Requires-Dist: mutmut>=3.8.0; extra == "dev"
Requires-Dist: mypy>=2.1.0; extra == "dev"
Requires-Dist: pip-audit>=2.10.0; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.8.0; extra == "dev"
Dynamic: license-file

<div align="center">

# Hipson

**One lead agent. Many workers. One ledger of who did what, with evidence.**

[![CI](https://github.com/Hipson47/Hipson/actions/workflows/ci.yml/badge.svg)](https://github.com/Hipson47/Hipson/actions/workflows/ci.yml)
![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-3776ab)
![Runtime dependencies: none](https://img.shields.io/badge/runtime%20deps-none-2ea043)
![Tests: 521, zero CI skips](https://img.shields.io/badge/tests-521%20%7C%200%20CI%20skips-2ea043)
![Bounded mutation score: 65.12%](https://img.shields.io/badge/bounded%20mutation-65.12%25-yellow)
[![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/Hipson47/Hipson/blob/main/LICENSE)

[Why](#why-it-exists) · [Built with itself](#built-with-itself) · [How it works](#how-it-works) · [Quick start](#quick-start) · [MCP](#use-it-from-a-lead-agent-mcp) · [Docs](https://github.com/Hipson47/Hipson/blob/main/docs/README.md)

</div>

<table>
<tr>
<td width="44%" align="center">
<img src="https://raw.githubusercontent.com/Hipson47/Hipson/main/.github/readme/demo.webp" width="320" alt="28-second demo: the real ledger prints line by line, an overlapping write claim is refused with exit 75, a dead run's claim is reaped, and the counters 7 tasks, 11 assignments, 48 events and 404 tests land">
</td>
<td width="56%">

**A control plane for the coordination layer, not another agent.**

A lead (for example Claude Code) opens tasks and hands bounded pieces to workers: Codex, Antigravity,
subagents. Every task, assignment, path claim and result lands in one transactional SQLite ledger on your
machine, next to a hash-chained evidence log linked by task id.

- **No silent overlap:** a second writer on the same paths is refused before it starts (`exit 75`).
- **No zombie locks:** a dead run's claims are reaped automatically.
- **Evidence, not confidence:** worker results are process results; only the lead says `done`.
- **Local-first:** no cloud service, zero runtime dependencies, Apache-2.0.

<sub>The film on the left was produced by an agent pipeline (Claude directing and animating, Codex reviewing
frames and running QA) from facts in this repository only. Silent excerpt, 28 s.</sub>

</td>
</tr>
</table>

<div align="center">

<img src="https://raw.githubusercontent.com/Hipson47/Hipson/main/.github/readme/ledger-events.svg" width="100%" alt="Real hipson task events output: a lead opens a task, a Codex builder and a separate reviewer run, the lead verifies and closes it">

<sub>Rendered from the real `hipson task events --json` record of building Hipson's own evidence hardening (task T-0003; long summaries shortened): builder → independent reviewer → builder with fixes → lead verification → done.</sub>

</div>

---

## Why it exists

Agents drift when each one keeps its own notes, its own plan and its own idea of "done". Two writers edit the
same files. A crashed run keeps a lock forever. A worker's "all tests pass" gets taken as proof.

Hipson fixes the coordination layer, not the agents:

- **One source of truth per task.** Status, assignments, path claims and an append-only event log in one SQLite store.
- **No silent overlap.** A writer must claim its paths; an overlapping live claim is refused before the worker starts.
- **No zombie locks.** Runs launched through the wrapper record their owner (process group, boot id, host); when
  that owner is gone, its claims are reaped. Assignments recorded by hand can carry a lease instead.
- **Evidence, not confidence.** Worker results are recorded as process results; only the lead moves a task to `done`.
- **Workers stay workers.** Agents launched by a lead switch to *worker mode*: no own orchestration, no own notes, no commits.

## Built with itself

The task ledger in this repository was built by Claude Code as lead with Codex as builder and reviewer and
Antigravity as a second reviewer; once the ledger existed, the rest of the work ran through it. Numbers from
branch `feat/task-ledger`, 2026-10-25:

| What | Result |
|---|---|
| Work recorded in the ledger | 7 tasks, 11 worker assignments (5 builder, 4 reviewer, 2 explorer), 48 events |
| Independent review rounds | Each code slice reviewed by a fresh read-only Codex run before commit (15 findings); a final whole-branch review by Codex and Antigravity (12 findings, 9 fixed, 3 judged non-issues); one more concurrency bug found by a stress test and fixed with a regression test |
| Test suite | 521 tests, 0 skipped on Linux CI (strict skip allowlist on macOS and Windows CI), run by both `pytest` and the dependency-free `scripts/run_tests.py` (1.2.0, 2026-10-26; 404 tests when the ledger landed) |
| Mutation gate | 65.12%: 1,331 / 2,044 mutants killed across four modules (1.2.0); the committed baseline (60.82% minimum, at most 727 survivors, 0 without tests, 0 timeouts) fails CI on regression |
| Agent e2e | A real Codex agent (gpt-6.1-sol) is given a natural-language mission and must reach it with Hipson alone; oracles check the resulting ledger, not the agent's report. 3 scenarios (lead flow, claim conflict, crash recovery). Latest live run 3/3; the first run found a real bug (claims reaped across PID namespaces), now fixed. Local and on demand: [docs/AGENT_E2E.md](https://github.com/Hipson47/Hipson/blob/main/docs/AGENT_E2E.md) |
| Static gates | `ruff`, `mypy`, `bandit`, `pip-audit`, `compileall`, wheel build (CI on Python 3.11 and 3.12) |
| Runtime dependencies | none (`dependencies = []`) |

Failure cases that are covered by tests, not just described: two processes racing for the same claim, a worker
whose runner is `SIGKILL`ed while the worker survives (claims stay), a dead process group (claims released),
a worker that ignores `SIGTERM` and its leftover child processes, readers racing writers, twelve concurrent
evidence writers keeping one hash chain, and secrets nested
inside evidence payloads.

## How it works

```mermaid
flowchart LR
  L([Lead<br/><sub>Claude Code</sub>]) -->|task open| T[(Task ledger<br/><sub>SQLite</sub>)]
  L -->|brief + task id| R[agent-run.sh<br/><sub>wrapper</sub>]
  R -->|assign + owner + claims| T
  R --> W[Worker<br/><sub>Codex · agy · subagent</sub>]
  W -->|report, diff| L
  R -->|finish: exit code, model, report path| T
  L -->|verify, then review → done| T
  T -.->|dead owner| X[reap<br/><sub>release claims</sub>]
```

| Who | Does |
|---|---|
| **Lead** | Plans, opens the task, briefs workers, verifies results itself, closes the task. The only one that sets `done`. |
| **Wrapper** (`examples/agent-run.sh`) | Records the assignment with owner and claims, runs the worker in its own process group, forwards signals, records the result. |
| **Worker** | Does the bounded job in worker mode and returns evidence. Never writes the ledger, never talks to other workers. |
| **Hipson** | Ledger, claims, reaping, evidence chain, MCP tools, and the existing local workflow (scan, packets, verify, audit). |

## Quick start

Requires Git and Python 3.11+; [uv](https://docs.astral.sh/uv/getting-started/installation/)
can install Python for you. Choose your OS below, then run the task example.

| OS | Support |
|---|---|
| Linux | Full CLI, ledger, MCP, evidence and worker wrapper |
| macOS | Full CLI, ledger, MCP, evidence and worker wrapper (Bash + `python3`) |
| Windows native | CLI, ledger, MCP and evidence; use leases and explicit finish for workers |
| Windows WSL2 | Full Linux support; recommended Windows route for running workers |

### Linux

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv tool install --python 3.12 git+https://github.com/Hipson47/Hipson
uv tool update-shell
hipson --help
hipson doctor
claude mcp add --transport stdio hipson -- hipson mcp serve --project "$PWD" --stdio
```

### macOS

Install Git first (`xcode-select --install` if missing). In Terminal:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
uv tool install --python 3.12 git+https://github.com/Hipson47/Hipson
uv tool update-shell
hipson --help
hipson doctor
claude mcp add --transport stdio hipson -- hipson mcp serve --project "$PWD" --stdio
```

The wrapper uses Python's `os.setsid()` when `setsid` is absent. No GNU utilities are required.

### Windows native (PowerShell)

Install Git for Windows, then install uv:

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

Reopen PowerShell, then:

```powershell
uv tool install --python 3.12 git+https://github.com/Hipson47/Hipson
uv tool update-shell
$env:Path = "$(uv tool dir --bin);$env:Path"
hipson --help
hipson doctor
claude mcp add --transport stdio hipson -- hipson mcp serve --project "$($PWD.Path)" --stdio
```

Use `--lease-seconds 3600` on `hipson task assign` and finish assignments explicitly.
`examples/agent-run.sh` and the agent e2e harness do not run natively on Windows.

### Windows WSL2

In an administrator PowerShell, install Ubuntu with `wsl --install -d Ubuntu` and restart if prompted.
Open Ubuntu and follow the **Linux** commands above, including MCP registration from the Linux
Claude Code installation. Keep projects in `~/code`, with Hipson and workers in that same WSL distro.

### Run from a clone instead

On any OS, after installing uv and Git:

```text
git clone https://github.com/Hipson47/Hipson.git
cd Hipson
uv sync --python 3.12 --no-dev
uv run --no-dev hipson --help
```

Use `uv run --no-dev hipson` in place of `hipson` below. For the wrapper, virtualenv activation,
MCP registration from a clone, PATH troubleshooting and verification commands, see
[docs/INSTALL.md](https://github.com/Hipson47/Hipson/blob/main/docs/INSTALL.md). The MCP commands follow
[Claude Code's stdio registration syntax](https://code.claude.com/docs/en/mcp#option-3-add-a-local-stdio-server).

Run a task by hand to see the model:

```bash
hipson task open --project . --title "Fix parser" --objective "Parser accepts trailing commas" --acceptance "tests pass"
hipson task assign --task T-0001 --actor codex --role builder --mode rw --scope src/parser
hipson task board
hipson task finish --assignment A-0001 --result passed --summary "worker exited 0" --ref runs/report.md
hipson task status --task T-0001 --to review --actor lead --summary "verified: tests pass"
hipson task status --task T-0001 --to done --actor lead
hipson task events --task T-0001
```

Wrap real workers so the ledger fills itself:

```bash
TASK=$(hipson task open --project . --title "Add rate limit" --objective "API returns 429 over quota" --json \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')
examples/agent-run.sh --task "$TASK" --actor codex --role builder --mode rw --scope src/api --rollout codex \
  -- codex exec -s workspace-write < brief.md
hipson task events --task "$TASK"
```

The wrapper exits with the worker's code, or 75 when a live writer already holds an overlapping scope.

The ledger lives at `$HIPSON_LEDGER` or `~/.config/hipson/ledger.sqlite`
(`$env:USERPROFILE\.config\hipson\ledger.sqlite` on native Windows).
`HIPSON_HOME` and `XDG_CONFIG_HOME` can change its config directory. Details, recovery rules and limits:
[docs/TASK_LEDGER.md](https://github.com/Hipson47/Hipson/blob/main/docs/TASK_LEDGER.md).

## Use it from a lead agent (MCP)

Hipson ships a stdio MCP server. Read tools: `task.show`, `task.brief`, `task.context`, `task.events`,
`task.list`, `task.board`, `task.findings`.
Write tools (each requires `approved=true`): `task.open`, `task.assign`, `task.finish`, `task.event`,
`task.status`, `task.reap`, `task.finding_add`, `task.finding_update`.

```bash
claude mcp add hipson -- hipson mcp serve --project . --stdio
```

The server only uses the configured ledger, never a caller-supplied database path, and read tools never create
or migrate the store.

## More than the ledger

The ledger sits on top of Hipson's existing local workflow layer:

| Area | Commands |
|---|---|
| Work planning | `hipson work`, `hipson route`, `hipson contract show` |
| Bounded packets for agents | `hipson packet review / exec`, `hipson packet preflight` |
| Local verification and evidence | `hipson verify run`, `hipson evidence append / show / verify`, `hipson audit show` |
| Run bundles and release gates | `hipson kit review`, `hipson autopilot`, `hipson run status / validate / handoff`, `hipson release claim` |
| Memory and sessions | `hipson memory`, `hipson session`, `hipson learn` (approval-gated) |
| Agent integration | `hipson install agents`, `hipson agent bootstrap`, `hipson mcp serve` |
| Optional AI second opinions | `hipson sidecar route / run`, `hipson quality report / eval` (explicit, advisory) |

Full command reference and workflows: [docs/USAGE.md](https://github.com/Hipson47/Hipson/blob/main/docs/USAGE.md). All docs: [docs/README.md](https://github.com/Hipson47/Hipson/blob/main/docs/README.md).

## Safety in short

- **Provider-free by default.** Core commands make no network calls; provider sidecars are explicit and advisory.
- **Repository content is data, not instructions.** Packets are bounded; sensitive files are skipped or summarized.
- **Redaction before persistence.** Evidence, work plans and release claims are redacted recursively, including
  any value under a credential-named key. Ledger text and MCP error messages get pattern-based redaction.
- **Write gates.** Every MCP write needs `approved=true`; invalid arguments are rejected before a database is opened.
- **Honest limits.** Actor names are recorded labels, not authenticated identities. Path claims coordinate
  cooperating agents; they are not filesystem permissions. Worker mode is an instruction, not a sandbox.

Hipson is a **beta coordination tool for cooperating agents**, not a security boundary or an enforced
release gate. A task reaching `done` checks ledger closure, not the truth of its evidence or release readiness.

Keep real provider keys in `~/.config/hipson/agents.env` or your shell, never in git.

## Development

```bash
uv sync --all-extras
uv run ruff check .
uv run mypy src/hipson
uv run bandit -q -r src -c pyproject.toml
uv run python scripts/run_tests.py
uv run python -m pytest -q
uv build
```

CI runs Linux on Python 3.11/3.12 and macOS/Windows on Python 3.12, including installed CLI ledger
commands and MCP initialize/tools-list over stdio. Mutation testing and `pip-audit` run on Linux.
On Linux with `CI` set, both test runners fail on any skip, including pytest collection skips.
The standalone runner reports passed, skipped and failed counts separately. Outside CI,
missing prerequisites produce explicit skips, including the pytest-policy probe when pytest is unavailable.
Wrapper tests resolve the installed CLI
through `HIPSON_BIN`, then `PATH`, then the checkout's `.venv/bin/hipson`
(`.venv\Scripts\hipson.exe` on Windows); missing prerequisites fail Linux CI.
The agent e2e harness stays Linux/WSL2-only; other platforms report explicit skips.
Artifact tests validate every keyword currently used in `schemas/`, including nested array items,
additional properties, references, nullable types, patterns and bounds. Unsupported schema keywords
fail even in unused branches.

Python 3.12 CI also enforces a bounded mutation baseline within a 20-minute step:

```bash
uv run mutmut run --max-children 2
uv run mutmut export-cicd-stats
uv run python scripts/mutation_gate.py
```

The fresh Linux baseline took 443.31 seconds (7m 23s) with Python 3.12.3 and mutmut 3.8.0 on 2026-10-25.

The mutated paths are `approvals.py`, `evidence.py`, `redaction.py` and `sandbox.py`; the test selection,
including `tests/test_evidence.py`, is in `pyproject.toml`. The score is **killed / total**, counting only
test-killed mutants as kills. The gate enforces the committed minimum score and population and caps
survivors, mutants without tests and timeouts. It rejects missing, malformed or incomplete results,
skipped mutants, suspicious outcomes, interruptions and segfaults.

To update `[tool.hipson.mutation-gate]` in `pyproject.toml`, start from a fresh checkout or move `mutants/`
aside, run the three commands above with the recorded mutmut/Python versions, inspect `uv run mutmut results`,
and review changed survivors before editing the baseline counts, minimum score (rounded down to two decimals), date,
versions and elapsed time. Baseline updates require a reviewed diff; the gate never learns a new threshold automatically.
Changes are listed in [CHANGELOG.md](https://github.com/Hipson47/Hipson/blob/main/CHANGELOG.md).

## Project layout

```text
src/hipson/      CLI, ledger, evidence, MCP server, runtime, packaged assets
schemas/         JSON schemas for every artifact kind
tests/           pytest suite (also runnable without pytest)
examples/        agent-run.sh worker wrapper
skills/          Hipson's own agent skills; third-party skills are fetched on demand into skills/external/
docs/            live documentation; docs/archive/ holds historical plans and audits
```

## License

Apache License 2.0. See [LICENSE](https://github.com/Hipson47/Hipson/blob/main/LICENSE).
