Skip to main content

The directory tree IS the process state. A tiny library for filesystem-shaped agent processes.

Project description

pmstate

The directory tree IS the process state.

A tiny Python library for agent-driven processes that live on the filesystem. Each node in your process tree owns a slice of state on disk — an append-only event log or a JSON table. The agent navigates, reads, spawns, and prunes the same way a human navigates a project folder.

No DSL. No decorators. No compile step. Plain attrs-shaped values, plain JSON on disk, and a four-tool surface any LLM harness can drive.

Why

Most agent frameworks treat process state as opaque blobs in a vector store or workflow engine. pmstate flips it: the tree of folders and files is the state. That means:

  • An agent can ls-style introspect what's happening at any depth.
  • Branches spawn and die at runtime — no recompile.
  • Every event is a CloudEvents-shaped JSON line. Replayable, auditable, human-readable.
  • A human can cat a log file and see exactly what the agent saw.

Install

pip install pmstate              # core
pip install pmstate[claude-sdk]  # with the Claude Agent SDK harness

Example: a procurement flow in 28 lines

from pmstate import Node, Log, Table, Tree
from pmstate import ClaudeHarness

def quote_view(events):
    """Vendor quotes received and pending approval."""
    pending = [e for e in events if e["type"] == "quote.received"
               and not any(a["data"]["quote_id"] == e["id"]
                           for a in events if a["type"] == "quote.approved")]
    return {"pending_count": len(pending), "latest": pending[-1] if pending else None}

def procurement_rollup(children):
    return {
        "open_quotes": children["quotes"]["pending_count"],
        "open_lpos":   children["lpos"]["count"],
        "blocked":     children["quotes"]["pending_count"] > 5,
    }

procurement = Node(
    "procurement",
    description="Vendor quotes, LPOs, approvals.",
    reducer=procurement_rollup,
    children=[
        Node("quotes", state=Log("state/quotes.jsonl"), view=quote_view),
        Node("lpos",   state=Log("state/lpos.jsonl")),
        Node("vendors", state=Table("state/vendors.json")),
    ],
)

tree = Tree("project_alpha", root=Node("active", children=[procurement]))
ClaudeHarness(tree).run()

That is the full procurement flow. One custom view, one reducer, three leaves. The agent gets four tools (list_tree, get_state, find_state, read_log), discovers the structure on its own, and answers questions like "what's blocking us?" by reading the rolled-up state.

Concepts

  • Node — a named position in the tree. May own state (a Log or Table), a view (function: events → dict), a reducer (function: children's views → dict), and children.
  • Log — append-only JSONL of CloudEvents-shaped events.
  • Table — JSON document for slowly-changing reference data.
  • Tree — the wrapper that gives you spawn(parent, child) and prune(path) for runtime mutation.
  • Harness — adapter that wires the four agent tools into an LLM runtime. v0.1 ships ClaudeHarness; the surface is harness-agnostic.

Status

v0.1 alpha. Open but not supported. One user (Laterite). API will break without warning. PRs not yet accepted. Stars welcome.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmstate-0.0.1.tar.gz (169.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pmstate-0.0.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pmstate-0.0.1.tar.gz.

File metadata

  • Download URL: pmstate-0.0.1.tar.gz
  • Upload date:
  • Size: 169.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmstate-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1877c7da2a68689f8472707e5ce7c4b789ecf25bc087eb09398a47c884ce60b5
MD5 2a42ab751ef25911613547e648d8c669
BLAKE2b-256 8bfbdf2a67dff6645fad120c09cf242653f160976d9b3de8dc372b6fbca351da

See more details on using hashes here.

File details

Details for the file pmstate-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pmstate-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pmstate-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9d773b6be6f9636305e6a3cfe4669e142fe5386f52a68fb265dacf68dd297069
MD5 918fdad423aacb9c8231c27c363c64d1
BLAKE2b-256 3bc5db0cf70190a548ba965c40bbe1e7de6b346e48d1af2854f159c84c404f76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page