Metadata-Version: 2.5
Name: plotroom
Version: 0.1.1
Summary: Orchestration control plane for multi-session coding work
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.14
Requires-Dist: aiosqlite==0.22.1
Requires-Dist: alembic==1.20.1
Requires-Dist: cryptography
Requires-Dist: httpx==0.28.1
Requires-Dist: mcp<3,>=2.3.0
Requires-Dist: pyyaml<7,>=6.0.2
Requires-Dist: sqlalchemy[asyncio]==2.1.9
Requires-Dist: sqlite-vec==0.1.9
Requires-Dist: uvicorn==0.54.0
Description-Content-Type: text/markdown

# Plotroom

**Run parallel coding sessions with shared project state.**

Plotroom is an MCP server for developers using Claude Code or Codex across
chats and worktrees. Assign work, catch overlapping file claims, and see what
still needs verification after a PR merges. Fresh sessions can pick up from
the same project ledger.

**[Try the local quickstart →](#try-it-in-a-minute)** · No accounts or API keys needed.

![Selected output from a local Plotroom run. Both the api and tests lanes claim tests/fixtures/user.json. The orchestrator's next call returns an open claim_overlap item.](docs/assets/claim-overlap.png)

## Why

Assign work before agents spread across worktrees. Deal with overlapping claims before
review. Pick up a lane after a chat restart and see which checks still need an owner.

The project ledger gives each session the tools to do that:

- **Lanes with owners.** The orchestrator gives each worker a lane (a branch and its work items)
  with `lane_start`. `snapshot()` summarizes the board and pages through lane details.
- **File claims that catch collisions early.** Workers `claim` the paths they plan to change, with
  a reason. Overlapping claims, and PRs that touch another lane's claims, become items for the
  orchestrator before the work collides.
- **One attention queue.** `next()` pages through ranked items visible to your role, including
  overlaps, lanes waiting on someone, PRs ready to merge, stale questions and missing action routes.
  `wait()` blocks until a visible change or a timeout. On timeout, `data.item` is `null`;
  pass `data.cursor` to the next `wait()` call to keep watching.
- **Merge readiness you can check.** `merge_gate(pr)` returns an advisory verdict for the exact PR
  head using checks, review threads, main's CI, base freshness and closing keywords. The controller
  separately routes actionable refusals to the owning worker or, for an unowned PR, the orchestrator.
  A person or a clerk session does the merge. Automatic controller merges and branch
  updates run only with injected test fixtures.
- **Post-merge steps that stay on the board.** `lane_ready` attaches a checklist to a PR and its
  head. After that head merges, the lane stays open until every step is recorded.
- **Briefs written from the ticket.** `brief` drafts a worker's handoff from the ticket's full text
  and the paths other lanes have claimed.
- **Your words, kept exactly.** `decide` records a decision word for word, with where you said it.
  `ask` tracks questions tied to an existing GitHub issue comment and flags stale ones. `goal`
  checks a rule such as "every open issue in milestone 1 has an owner" against projected GitHub data.
- **Triggers.** `trigger` can fire once or recur when a condition becomes true, such as a PR
  merging or main going green with its images built. It can message a worker, notify the
  orchestrator, mark a lane or propose archiving it.
- **Budget thresholds.** `budget_open` records a run's cap. With usage meter readings, Plotroom
  raises orchestrator items at 50%, 80%, and 100%. At 100% it queues a stop request for an active
  lane. Delivery depends on its route. Bridged lane-pinned stops surface as failed actions for
  operator attention. OpenRouter is the first live usage meter.
- **Search.** `search` covers messages, turn reports, decisions, asks, issue comments and PR bodies,
  with full-text search by default and search by meaning when you configure an embedding endpoint.

Local Claude Code and Codex clients reach Plotroom through `plotroom connect --stdio`. Hosted
instances serve MCP over HTTP. Workers on a Switchboard relay reach it through `plotroom bridge`.

## What it looks like

In the local run pictured above, an orchestrator started an `api` lane and a
`tests` lane. Each worker claimed `tests/fixtures/user.json`. The orchestrator's
`next()` call returned this item before either lane opened a PR.

```json
{
  "kind": "claim_overlap",
  "state": "open",
  "context": {
    "claims": [
      {"lane": "api", "glob": "tests/fixtures/user.json"},
      {"lane": "tests", "glob": "tests/fixtures/user.json"}
    ]
  }
}
```

These are selected fields from the MCP response.
The [claims test](tests/test_claims_e2e.py) also checks that the item clears
after the conflicting claims are released.

Reuse the same `request_id` to retry a command for the same role. The orchestrator can settle
who owns the fixture before either PR exists. If a chat is compacted or replaced,
`snapshot(lane="api")` recovers that lane and what it is waiting on, and
`claims(lane="api")` lists its path claims.

Every token is bound to one project and one role: `orchestrator`, `clerk`, `worker:<name>`,
`drain` or `bridge`. Each command declares which roles may call it, and anything undeclared is
refused. A worker that tries to start a lane, or to claim paths in another worker's lane, gets
`forbidden`.

## Status

Plotroom is usable from a checkout today. Start sessions in Claude Code or Codex,
then connect them to a local Plotroom daemon to assign lanes, record claims and
decisions, and track follow-up work. Start with the credential-free tour below, or
[connect your own sessions](#run-your-own).

- **Verified so far.** The GitHub poller was exercised against a dedicated live test
  repository ([#29](https://github.com/mgd43b/plotroom/issues/29)). A local daemon
  refreshed a GitHub App installation token using a mounted key
  ([#39](https://github.com/mgd43b/plotroom/issues/39)). The local daemon, isolated
  Docker Compose run, and available integrated CI checks passed
  ([#46](https://github.com/mgd43b/plotroom/issues/46)). CI also exercises the Helm
  chart on disposable kind clusters, where Claude Code and Codex connections
  have also been verified ([#123](https://github.com/mgd43b/plotroom/issues/123)).
- **Live acceptance still open.** Hosted GitHub App refresh, hosted Switchboard
  bridge delivery, and live deployment evidence remain in
  [Epic #2](https://github.com/mgd43b/plotroom/issues/2). The live pilot for
  coordinating Plotroom's own development is deferred
  ([#110](https://github.com/mgd43b/plotroom/issues/110)).
- **Public release.** Plotroom 0.1.0 is available as a [GitHub release],
  a [PyPI package], a [GHCR image] for `linux/amd64`, and a public
  [Helm OCI chart](https://github.com/users/mgd43b/packages/container/package/charts%2Fplotroom)
  that pins that image.

[GitHub release]: https://github.com/mgd43b/plotroom/releases/tag/v0.1.0
[PyPI package]: https://pypi.org/project/plotroom/0.1.0/
[GHCR image]: https://github.com/users/mgd43b/packages/container/plotroom/1655484067

## Try it in a minute

On macOS or Linux, with Git and uv 0.13.8 or newer. The tests play the orchestrator and the
workers against temporary local daemons, so no credentials, agents or live repository are needed.

```sh
git clone https://github.com/mgd43b/plotroom.git
cd plotroom
uv sync --locked --python 3.14
uv run --locked --python 3.14 python -m pytest -v \
  tests/test_lanes.py::test_local_lane_smoke \
  tests/test_claims_e2e.py::test_conflicting_claim_reported_when_made \
  tests/test_epic6_e2e.py
```

You should see **7 passed**:
- [The lane smoke test](tests/test_lanes.py): a worker marks its lane as waiting, and the
  orchestrator recovers that state after a daemon restart.
- [The claims test](tests/test_claims_e2e.py): an overlap opens, then clears as the workers change
  scope.
- [The brief and checklist tests](tests/test_epic6_e2e.py): a handoff that lists other lanes'
  claims, and a merge that keeps its lane open until the post-merge check is recorded.

## Run your own

Save this two-worker config as `plotroom.toml`:

```toml
data_dir = "plotroom-data"
port = 0

[projects.example.workers.agent]
[projects.example.workers.tester]
```

### Run the PyPI release

On macOS or Linux, use uv 0.13.8 or later. Run `uv python install 3.14 --upgrade`
to get the latest uv-managed Python 3.14 patch release with compatible SQLite.
Start the daemon in the directory containing `plotroom.toml`.

```sh
uvx --python 3.14 --from plotroom==0.1.0 --managed-python plotroom serve --config ./plotroom.toml
```

In a second terminal, issue an orchestrator token. Use the absolute path to
the daemon's config in both commands. Configure your MCP client to run the
proxy with the returned `token_id`. Keep the bearer `token` private.

```sh
uvx --python 3.14 --from plotroom==0.1.0 --managed-python plotroom token issue \
  --config /path/to/plotroom.toml --project example --role orchestrator
uvx --python 3.14 --from plotroom==0.1.0 --managed-python plotroom connect --stdio \
  --config /path/to/plotroom.toml --token-id YOUR_TOKEN_ID
```

### Run from a checkout

Put `plotroom.toml` next to the checkout, then start the daemon from the checkout directory.

```sh
uv run --locked plotroom serve --config ../plotroom.toml
```

In a second terminal, from the same checkout, issue a token for each role:

```sh
uv run --locked plotroom token issue --config ../plotroom.toml --project example --role orchestrator
uv run --locked plotroom token issue --config ../plotroom.toml --project example --role worker:agent
uv run --locked plotroom token issue --config ../plotroom.toml --project example --role worker:tester
```

Configure each MCP client to launch the stdio proxy. Set `--directory` to the absolute checkout
path so uv finds the project even when the client starts elsewhere. Set `--config` to the absolute
TOML path and replace `YOUR_TOKEN_ID` with the ID for that client's role.

```sh
uv --directory /path/to/plotroom run --locked plotroom connect --stdio \
  --config /path/to/plotroom.toml --token-id YOUR_TOKEN_ID
```

Call `snapshot()` in each connected MCP client. The response should show
`data.project` as `example`. The token commands generate the credentials locally. Use
the returned `token_id` in the client command and keep the bearer `token` private.

### Pull the container image or Helm chart

Pull the published `linux/amd64` image or the Helm chart that pins it.

```sh
docker pull --platform linux/amd64 ghcr.io/mgd43b/plotroom:0.1.0
helm pull oci://ghcr.io/mgd43b/charts/plotroom --version 0.1.0
```

See [Running Plotroom](docs/running.md) for Docker Compose and kind setup.

### Prepare and publish the Helm chart

The chart release workflow prepares version `0.1.0` for
`oci://ghcr.io/mgd43b/charts/plotroom`. The packaged chart defaults to the public
Plotroom `linux/amd64` image pinned by digest. The chart under `deploy/helm`
uses the local fixture image by default.

1. On the latest reviewed `main`, manually run **Chart release** in
   `candidate` mode with `reviewed_sha`, `reviewed_version` (`0.1.0`), and
   `ci_run` (the successful push CI run ID for that SHA). The read-only job
   verifies the release image and tag, packages the chart once, compares the
   bytes after a local OCI push and pull, and installs that OCI digest in a
   fresh Ubuntu amd64 kind cluster to check anonymous image pull and `/readyz`.
   It uploads the chart archive, `SHA256SUMS`, and `provenance.json` after
   those checks pass.
2. Download and review the candidate artifact. Independently compute the
   SHA-256 of `plotroom-0.1.0.tgz` and compare it with `SHA256SUMS` and the
   provenance. With explicit owner authorization, the repository owner
   can run **Chart release** in `promote` mode on the same current `main`.
   Reuse the three reviewed inputs and supply `candidate_run`,
   `candidate_attempt`, `candidate_artifact` (the artifact ID), and
   `package_sha256` (the lowercase archive checksum). Promotion verifies
   the candidate and current CI again. An existing version is accepted only
   if its chart layer matches the reviewed archive. Use this workflow as the
   sole publisher for this chart coordinate so another publisher cannot
   race the registry check and push.
3. After publication, the owner sets the chart package visibility to
   **Public**. Then verify the published OCI manifest digest matches the
   promotion receipt and install anonymously on a fresh, disposable
   `linux/amd64` kind cluster using Helm 4.3.2, kind 0.33.0, and kubectl 1.37.0.

Chart `0.1.0` is public. The recorded anonymous install passed readiness on a
native ARM64 kind control plane with Docker emulating the pinned amd64 image.
The earlier emulated amd64 control plane failed during bootstrap. See the
[verified publication and install evidence](_bmad-output/initiative-orchestration-control-plane/tickets/epic-helm-chart/tickets/story-publish-the-chart.md#public-oci-chart-acceptance-2026-11-29).
The procedure below is a separate verification path for a native amd64 host.
Use the manifest digest reported by promotion and an empty registry configuration.

```bash
set -euo pipefail
fixture=$(mktemp -d)
cluster="plotroom-oci-$(basename "$fixture" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')"
export KUBECONFIG="$fixture/kubeconfig"
export DOCKER_CONFIG="$fixture/docker"
export HELM_CONFIG_HOME="$fixture/helm"
mkdir "$DOCKER_CONFIG" "$HELM_CONFIG_HOME"
printf '{}\n' > "$DOCKER_CONFIG/config.json"
trap 'kind delete cluster --name "$cluster" --kubeconfig "$KUBECONFIG"; rm -rf -- "$fixture"' EXIT

# Set this to the reviewed promotion receipt.
manifest_digest='sha256:REPLACE_WITH_PROMOTION_MANIFEST_DIGEST'
chart='oci://ghcr.io/mgd43b/charts/plotroom'
receipt=$(helm pull "$chart" --version 0.1.0 --destination "$fixture" 2>&1)
tag_digest=$(sed -n 's/^Digest: //p' <<< "$receipt")
if [[ "$tag_digest" != "$manifest_digest" ]]; then
  printf 'Public chart tag resolves to %s, expected %s\n' "$tag_digest" "$manifest_digest" >&2
  exit 1
fi
kind create cluster --name "$cluster" --kubeconfig "$KUBECONFIG" --wait 120s
helm install plotroom "$chart@$manifest_digest" \
  --kubeconfig "$KUBECONFIG" --kube-context "kind-$cluster" \
  --namespace plotroom-oci --create-namespace --wait --timeout 4m
kubectl --kubeconfig "$KUBECONFIG" --context "kind-$cluster" -n plotroom-oci \
  exec deployment/plotroom -- python -c \
  "from urllib.request import urlopen; print(urlopen('http://localhost:8765/readyz').read().decode())"
```

The response should show `status: ready` and `projects.helm-fixture: ready`.

### Track OpenRouter spend

Add a binding for the exact run ID you will pass to `budget_open`. Use a dedicated inference
key with a positive, non-resetting OpenRouter USD cap and shared OpenRouter billing. Use a
new key per run and keep inference for that run on that key for its lifetime.

```toml
[projects.example.openrouter.trial]
key_file = "/run/secrets/openrouter-trial"
key_sha256 = "<SHA-256 of the trimmed mounted key>"
```

Compute the SHA-256 from the key text after trimming surrounding whitespace, without printing
the key. Keep the digest in private configuration and the key in an owner-controlled mounted
file. Relative paths are based on the configuration file. Keep the binding and key dedicated
to the same run across restarts. A replacement key requires a new run ID. A changed file
fails the configured digest check. Plotroom keeps an opaque reservation in the project ledger
to prevent reassigning an existing budget or reusing its key for a different run in the same
daemon data directory, including inactive projects. Across separate data directories, keep the
key dedicated to its original run.

Open a budget for `run="trial"` with `provider="openrouter"`, the active lane,
a `cap_usd` at least as high as the provider cap, and a `key_scope` of `staging`
or `production`. Budget registration checks the mounted key and provider cap before reserving
the key. The daemon reads lifetime `data.usage` in USD on the project tick.
`budget_status(run="trial")` shows accepted spend and when Plotroom saw it.
Provider accounting may lag. Equal, lower, incomplete, and BYOK readings preserve the previous
spend and as-of. The provider key cap supplies the spend boundary during reporting delay.
After a lane archives, its budgets can reconcile for two minutes. The key remains reserved
when polling stops.
[OpenRouter current-key API](https://openrouter.ai/docs/api/api-reference/api-keys/get-current-key)

- [Running Plotroom](docs/running.md): the local daemon, Docker Compose, the Helm chart on kind, and
  the Switchboard bridge.
- [Features and configuration](docs/features.md): GitHub reads, the merge gate, briefs, checklists,
  operator goals and search.

## How it's built

One daemon owns a data directory and holds a lock on it. Each project is its own SQLite file,
holding an append-only event log. Commands are checked against the writer-rule table, and every
retried call is idempotent. GitHub is read by polling, so no public webhook endpoint is needed. The
same build runs on a laptop over stdio and hosted in Docker or Kubernetes, with several projects
per instance.

- [Architecture](_bmad-output/initiative-orchestration-control-plane/architecture-orchestration-control-plane/architecture-orchestration-control-plane.md)
- [The plan: initiative and epics](_bmad-output/initiative-orchestration-control-plane/initiative-orchestration-control-plane.md)
- [How this repository coordinates its own development](coordination/README.md)

## License

[MIT](LICENSE)
