Metadata-Version: 2.4
Name: grumo
Version: 2.0.0
Summary: The programmable runtime for adaptive applications and operational systems — from web and AI to distributed and physical systems.
Author-email: Helder Perez <contact@helderperez.com>
Maintainer-email: Helder Perez <contact@helderperez.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/helderperez-dev/grumo
Project-URL: Documentation, https://github.com/helderperez-dev/grumo#documentation
Project-URL: Repository, https://github.com/helderperez-dev/grumo
Project-URL: Changelog, https://github.com/helderperez-dev/grumo/blob/main/CHANGELOG.md
Project-URL: Roadmap, https://github.com/helderperez-dev/grumo/blob/main/ROADMAP.md
Project-URL: Issues, https://github.com/helderperez-dev/grumo/issues
Project-URL: Discussions, https://github.com/helderperez-dev/grumo/discussions
Keywords: python,runtime,application-runtime,distributed-systems,ai-agents,edge-computing,reactive-ui,durable-execution,operational-systems,local-first
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: starlette
Requires-Dist: uvicorn
Requires-Dist: pydantic
Requires-Dist: grumo-store<3.0.0,>=2.0.0
Requires-Dist: websockets
Requires-Dist: httpx
Requires-Dist: python-dotenv
Requires-Dist: pyyaml
Requires-Dist: typer
Requires-Dist: rich
Requires-Dist: aiofiles
Provides-Extra: ai
Requires-Dist: openai; extra == "ai"
Requires-Dist: anthropic; extra == "ai"
Requires-Dist: google-generativeai; extra == "ai"
Requires-Dist: ollama; extra == "ai"
Provides-Extra: mcp
Provides-Extra: browser
Requires-Dist: playwright; extra == "browser"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: types-PyYAML; extra == "dev"
Requires-Dist: cryptography>=42; extra == "dev"
Requires-Dist: pip-audit; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: aiosqlite; extra == "dev"
Provides-Extra: sqlite
Requires-Dist: aiosqlite; extra == "sqlite"
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.3.4; extra == "postgres"
Provides-Extra: s3
Requires-Dist: boto3>=1.34; extra == "s3"
Requires-Dist: botocore>=1.34; extra == "s3"
Provides-Extra: redis
Requires-Dist: redis>=5.0; extra == "redis"
Provides-Extra: edge
Requires-Dist: paho-mqtt>=2.0; extra == "edge"
Provides-Extra: secrets
Requires-Dist: cryptography>=42; extra == "secrets"
Dynamic: license-file

# Grumo

**The programmable runtime for adaptive applications and operational systems.**

[GitHub](https://github.com/helderperez-dev/grumo) · [Documentation](#documentation) · [Architecture](ARCHITECTURE.md) · [Roadmap](ROADMAP.md) · [Changelog](CHANGELOG.md)

[![CI](https://github.com/helderperez-dev/grumo/actions/workflows/ci.yml/badge.svg)](https://github.com/helderperez-dev/grumo/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/grumo)](https://pypi.org/project/grumo/)
[![Python](https://img.shields.io/pypi/pyversions/grumo)](https://pypi.org/project/grumo/)
[![License](https://img.shields.io/badge/license-MIT-informational)](LICENSE)

Grumo lets a Python application start small — a page, API, model, task or agent —
and grow into durable workflows, human approvals, adaptive goals, distributed
participants and physical-device systems **without replacing the execution model
underneath it**.

> Composition over configuration. Python over DSLs. Adapters over lock-in.
> Explicit capabilities over ambient authority.

## What Grumo is

Most application stacks accumulate separate execution models as they grow:
HTTP handlers, frontend state, database jobs, queues, schedulers, agent loops,
workflow engines, event buses, human approvals, distributed workers and device
control.

Grumo treats those as different manifestations of one programmable Runtime.

```text
Entity → State → Intent → Capability + Policy → Execution → Effect → State
```

For operational systems, the model becomes a closed loop:

```text
World
  ↓
Observation
  ↓
Goal / Intent
  ↓
Plan
  ↓
Capability + Policy
  ↓
Execution
  ↓
Effect
  ↓
Participant
  ↓
ACK / observed evidence
  └────────────────────→ World
```

Two rules are central:

- **AI is Compute, not authority.** Agents participate in the same Runtime and
  remain subject to capabilities and policy.
- **Effect != Observation.** What the system attempted is not automatically
  treated as evidence that the real world changed.

An `Execution` is not every function call. It is meaningful work worth
authorizing, observing, recovering, accounting for, waiting on, or reasoning
about.

## Quick start

Grumo requires Python 3.12 or newer. The canonical PyPI distribution is
`grumo`; Grumo Store is installed automatically.

### Install the standalone CLI (recommended)

```bash
uv tool install --python 3.12 grumo
grumo version
grumo new my_app
cd my_app
grumo dev
```

Upgrade with `uv tool upgrade grumo`, or run without a persistent tool
installation using `uvx --python 3.12 --from grumo grumo --help`.

### Add Grumo to an existing uv project

```bash
uv add grumo
uv run grumo --help
```

### Install with pip

Use an activated virtual environment with Python 3.12 or newer.

```bash
pip install grumo
grumo new my_app
cd my_app
grumo dev
```

The Homebrew tap is being validated in
[homebrew-grumo](https://github.com/helderperez-dev/homebrew-grumo).
Until the tap has been validated against the published release, use pip or uv.

Open `http://localhost:8000`. A fresh application requires no external
database, Redis, queue or object server. The 2.0 source uses the canonical Grumo namespace without legacy import aliases.

### Small application

```python
from grumo import App, page
from grumo.ui import Heading, Page, Stack, Text

app = App()


@page("/")
def home():
    return Page(
        Stack(
            Heading("Hello, Grumo", level=1),
            Text("One application. One runtime."),
            gap="md",
        )
    )


if __name__ == "__main__":
    app.run()
```

## Start simple, grow only when needed

Grumo is designed for progressive complexity. You do not need World Models,
Goals, AI or distributed execution to build a normal application.

| You need | Use |
|---|---|
| UI-local mutable value | `state()` |
| Persistent business data | `Model` |
| Indexed business queries | `field(index=True)` + `where/order_by` |
| Page / browser interaction | Grumo UI + Python-callable events |
| HTTP/API surface | routing / API primitives |
| Retryable background work | `@task` |
| Future or recurring work | Runtime scheduling |
| Decoupled notification | Mesh / event bus |
| Meaningful governed work | `Execution` |
| LLM reasoning and tool use | `Agent` + `@tool` |
| Authorization to produce effects | `Capability` + `Policy` |
| Human decision during work | HITL approval |
| Durable desired outcome | `Goal` + `GoalRuntime` |
| Operational reality | `Entity` + `Observation` + `WorldModel` |
| Physical/external participant | Edge / `DeviceGateway` |
| Governed node-to-node work | Runtime Fabric |

See [Choosing primitives](docs/choosing-primitives.md) for the semantic
boundaries between state, models, events, tools, tasks, capabilities and
executions.

## One Runtime, one durable substrate

Grumo Store is the default embedded infrastructure for a local application.

```text
Application
    │
    ▼
Grumo Runtime
    │
    ├── Model / Data
    ├── Jobs / Queue
    ├── Scheduler / Cron / Triggers
    ├── Events / Outbox
    ├── Objects
    ├── Execution / Workflow / Goal / HITL
    ├── Identity
    └── Edge / device state
    │
    ▼
RuntimeStore
    │
    ▼
.grumo/application.grumo
```

The default path is **local-first and single-writer**. PostgreSQL, SQLite,
Redis and S3-compatible object storage remain explicit adapters
or integrations for workloads that need them; they are not silent defaults.

Store owns durable mechanics. Runtime owns semantics, authority and
intelligence.

Models may declare native secondary indexes without changing the query API:

```python
from grumo import Model
from grumo.data import field


class Customer(Model):
    email: str = field(index=True)
    score: int = field(index=True)


customers = await Customer.where(email="ada@example.com")
top = await Customer.where().order_by("-score").limit(10)
```

Indexed equality and single-column ordering are pushed into Grumo Store;
queries without a matching declared index preserve the same API and fall back
to collection scans.

Models receive a Runtime-generated UUIDv7 identity by default. The UUID is
generated before persistence, stored as the 16-byte Collection primary key and
exposed as `uuid.UUID` in Python. Sequential business identifiers remain
ordinary explicit fields rather than the default technical identity.

Model typing carries schema semantics without duplicating them in storage
configuration: `T | None` expresses optionality, normal assignment or
`field(default=...)` expresses defaults, `field(default_factory=...)` handles
dynamic defaults, and `typing.Annotated` constraints express domain limits.
Relationships use `relation(...)` with explicit `Delete.RESTRICT`,
`Delete.CASCADE` or `Delete.SET_NULL` policies. Backend-specific `db_type`
metadata is deliberately not part of the default Model API.

## Runtime architecture

Grumo deliberately converges concepts under one semantic owner instead of
preserving duplicate historical namespaces.

```text
src/grumo/
├── core/          application facade, lifecycle, state and events
├── primitives/    foundational semantic concepts
├── runtime/       canonical Runtime semantics
│   ├── execution/
│   ├── scheduling/
│   ├── agency/
│   ├── distributed/
│   ├── reconciliation/
│   └── inspection/
├── world/         entities, relationships, observations, WorldModel
├── edge/          physical/external participant boundary
├── protocol/      language-neutral semantic contracts
├── ai/            native Agent/provider/tool semantics
├── integrations/  MCP and provider SDK integrations
├── observability/ traces, metrics and runtime inspection
├── data/          Store-first Model API
├── storage/       infrastructure contracts
├── adapters/      explicit infrastructure providers
├── ui/            reactive UI and design system
├── routing/       pages and APIs
├── mesh/          realtime/event transport surface
├── auth/          application authentication surfaces
├── security/      HTTP security and redaction
└── cli/           developer tooling
```

The package root stays intentionally small:

```python
from grumo import Agent, App, Model, page, state, task, tool
```

The canonical distribution and root imports are `grumo`. Advanced APIs live under `grumo.*`, with implementation in `src/grumo/`. Use `grumo.toml` and `.grumo/application.grumo` for new projects. Do not rename persisted data manually.

Advanced APIs come from the namespace that owns them:

```python
from grumo.ui import Button, Card, DataTable
from grumo.runtime import ExecutionEngine, Goal, GoalRuntime, Planner
from grumo.world import Entity, Observation, WorldModel
from grumo.edge import DeviceGateway, WorldAwareDeviceGateway
from grumo.protocol import RemoteExecutionRequest, WorldSnapshot
from grumo.integrations.mcp import mcp
```

See [Public API contract (inherited from Grumo 3.0)](docs/public-api-3.md) for the canonical import
model and the clean-break migration map from 2.x.

For contributor-facing ownership and package placement, see the [canonical
package navigation](docs/architecture/navigation.md).

## Adaptive applications

An adaptive application can observe facts, express desired outcomes and allow
the Runtime to reconcile the two without creating a second orchestration model.

```python
from grumo import App
from grumo.primitives import Intent

app = App()

conversion = app.observation("business", "conversion")


@app.goal(
    "grow",
    observes=(conversion,),
    target_entity_id="business",
    propose=lambda goal, world: Intent(name="conversion.adjust"),
)
def growth(world):
    return world is not None and world.entity.properties.get("conversion", 0) >= 0.10


@app.capability("conversion.adjust")
async def improve(ctx):
    return {"accepted": True}
```

The application declares observations, goals and executable capabilities.
Execution, scheduling, reconciliation and authority remain Runtime concerns.

## AI and tools

AI is optional. The core package does not install provider SDKs.

```bash
pip install "grumo[ai]"
```

A tool remains normal Python while also becoming introspectable Runtime
capability for agent/tool workflows:

```python
from grumo import Agent, tool


@tool
async def find_customer(email: str) -> dict:
    """Find a customer by email."""
    return {"email": email}


agent = Agent(
    model="mock:test",
    tools=[find_customer],
)
```

MCP is an interoperability boundary under `grumo.integrations.mcp`; it is
not a second tool registry or execution model.

## Operational systems and Edge

Grumo can connect software decisions to external or physical participants
without treating a sent command as reality.

```text
Device evidence
    ↓
Edge
    ↓
Observation
    ↓
World
    ↓
Goal / Intent
    ↓
Planner
    ↓
Capability + Policy
    ↓
Execution
    ↓
Effect
    ↓
Device
    ↓
ACK / measured evidence
    └──────────────→ Observation → World
```

Run the zero-infrastructure operational canary:

```bash
python examples/adaptive/operational_closed_loop/main.py
```

The example proves the important boundary: the World changes only after the
simulated device reports observed evidence, not merely because an Effect was
sent.

## Distributed Runtime

Grumo scales by adding Runtime nodes, not by letting multiple processes write
the same Store file.

```text
same application semantics
          │
          ▼
     Runtime Fabric
      /    |    \
   node-a node-b node-c
      |      |      |
   a.grumo b.grumo c.grumo
```

Each node owns its local Store. Remote work re-enters canonical
`Capability + Policy + Execution` at the destination.

The Runtime Fabric includes authenticated node identity, durable membership,
health/discovery, placement, lease generations, replay/idempotency boundaries
and bounded failover. Failover remains constrained by the semantics of the work:
ambiguous external or physical effects must not be blindly reissued.

## Major capabilities

| Domain | Capabilities |
|---|---|
| Application | pages, APIs, reactive Python UI, design system, SEO |
| Data | Store-first `Model`, explicit SQL adapters |
| Runtime | Execution, recovery, tasks, scheduling, workflows, transactions/outbox |
| Agency | Goals, planning, adaptive supervision, reconciliation |
| Authority | Identity, Capability, contextual Policy |
| Human | durable HITL waiting/approval |
| AI | Agents, tools, provider abstraction, persistent Memory |
| Interoperability | MCP integration, language-neutral Protocol |
| Distributed | remote execution, membership, placement, leases, bounded failover |
| World | Entity, Relationship, Observation, WorldModel |
| Edge | device identity/session/effects/ACK/evidence flows |
| Observability | execution lineage, traces, metrics and inspection |
| Infrastructure | PostgreSQL, SQLite, Redis and S3 adapters |

## Installation options

```bash
# Core Runtime + Grumo Store
pip install grumo

# AI providers
pip install "grumo[ai]"

# External infrastructure adapters
pip install "grumo[postgres,redis,s3]"

# Explicit SQLite adapter
pip install "grumo[sqlite]"

# Edge MQTT transport
pip install "grumo[edge]"

# Development dependencies
pip install "grumo[dev]"
```

You can also install the CLI with `uv tool install grumo` or
`pipx install grumo`.

## Configuration

A fresh application is zero-config. The effective defaults are equivalent to:

```toml
[store]
provider = "grumo"
path = ".grumo/application.grumo"

[database]
provider = "grumo"

[queue]
provider = "grumo"

[events]
provider = "grumo"

[objects]
provider = "grumo"
```

Override only the domain that actually needs external infrastructure:

```toml
[database]
provider = "postgres"
url = "postgresql://..."

[queue]
provider = "redis"
url = "redis://..."

[objects]
provider = "s3"
bucket = "my-bucket"
```

Grumo does not silently migrate or copy legacy external data into Grumo Store
at startup. Migration is an explicit operation.

## Examples

| Example | What it demonstrates |
|---|---|
| `examples/basics/hello_world/` | smallest application + native design system |
| `examples/web/dashboard/` | reactive UI/state |
| `examples/web/realtime/` | realtime communication |
| `examples/web/ui_magic/` | callable UI + current design-system acceptance app |
| `examples/ai/agent/` | Agent + Tool |
| `examples/ai/saas/` | UI + Agent + Tool + Mesh + Task + Model |
| `examples/adaptive/operational_closed_loop/` | Edge → World → Goal → Execution → Effect → evidence |

## Documentation

A useful reading order:

1. [Hello world](docs/hello_world.md)
2. [Choosing primitives](docs/choosing-primitives.md)
3. [Computational primitives](docs/primitives.md)
4. [Execution model](docs/execution-model.md)
5. [Runtime](docs/runtime.md)
6. [Agents](docs/agents.md) and [Tools](docs/tools.md)
7. [Human-in-the-loop](docs/hitl.md)
8. [MCP](docs/mcp.md)
9. [Protocol](docs/protocol.md)
10. [Public API contract (inherited from Grumo 3.0)](docs/public-api-3.md)
11. [Architecture](ARCHITECTURE.md)
12. [Roadmap](ROADMAP.md)

`SPRINT_PLAN.md` is the implementation tracker; it should not be treated as a
marketing promise for future capabilities.

## What Grumo deliberately does not claim

Grumo's architecture is broad, but its guarantees are intentionally explicit.

Grumo does **not** claim:

- automatic Store replication or synchronization between nodes;
- shared multi-writer `.grumo` files;
- distributed consensus;
- globally serializable cross-node transactions;
- global exactly-once execution;
- production PKI/OIDC/mTLS infrastructure;
- a managed Grumo Cloud control plane.

Grumo Store 1.x exposes native Collections/index
queries, Queues, Topics/Streams, Consumer Groups, Objects, RPC, CDC,
Workflow/HITL state, lifecycle operations and heterogeneous transactions to the
Runtime. Those primitives remain single-node/local Store semantics; they do not
imply replication, consensus or global exactly-once behavior.

## What Grumo is trying to preserve

As the project grows, these properties are architectural constraints:

- one Runtime and one canonical Execution lifecycle;
- local-first progressive complexity;
- Python application code instead of a mandatory workflow DSL;
- explicit authority for effects;
- AI as a participant, not an ambient superuser;
- replaceable infrastructure behind contracts;
- topology changes without rewriting business semantics;
- observable lineage from Intent → Execution → Effect → Observation;
- one semantic owner per concept.

## Project status

Grumo is **beta software**.

**v1.0.0** is the first published Grumo release, with Grumo Store 1.x.
The `main` branch now contains the 2.0 source targeting Grumo Store 2.x. A merge to `main` is not itself a package release; check PyPI for the latest published version.

The next numbered development sprint is intentionally selected from real
product/architecture pressure rather than by accumulating unrelated framework
features.

## Contributing

Read [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md) before
structural changes. Repository architecture is enforced by tests, including
rules that prevent removed legacy compatibility namespaces from returning.

Security issues should follow [SECURITY.md](SECURITY.md). Community behavior is
covered by [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).

## License

MIT. See [LICENSE](LICENSE).
