Skip to main content
Glama
README.md
<div align="center">

# distRA

**A spatial, non-recursive OS kernel, filesystem interface, and MCP server for humans and AI agents.**

*No folders inside folders. Real-world spatial ontology (`Country → Land → Hegemony → Palace/Building → Floor → Room → Desk/Cabinet → Binder → File → Document`) with strict type-containment rules.*

[![CI](https://github.com/gitmuhammedalbayrak/distRA/actions/workflows/ci.yml/badge.svg)](https://github.com/gitmuhammedalbayrak/distRA/actions/workflows/ci.yml)
[![License: MIT](https://github.com/gitmuhammedalbayrak/distRA/blob/main/LICENSE)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![MCP Compatible](https://img.shields.io/badge/MCP-stdio%20JSON--RPC-purple.svg)](distra/mcp_server.py)

[English](README.md) | [Türkçe](README.tr.md)

</div>

---

## Why distRA?

Traditional operating systems force everything into a single recursive abstraction: **infinite nested directories**. That blurs ownership, separates *sessions* from *workspaces*, and turns human + AI agent collaboration into folder chaos.

**distRA** replaces nested directories with a **typed, non-recursive spatial hierarchy** modeled after physical reality:

- **Nothing can ever contain itself** — no folder inside a folder, no file inside a file, no room inside a room, no desk inside a desk.
- **Every session is a Room (`oda`)** — humans and AI agents enter a room, drop their own **Desk (`masa`)**, collaborate on a shared room board, and leave **Documents (`evrak`)** on desks or inside binders.
- **Flat physical storage** — underneath, `evrak_store/` is completely flat (`<id>.dat` blobs + SQLite WAL registry). Zero nested directories exist on disk.
- **OS-level right-click contract** — `allowed_children_for` tells any shell or future desktop UI exactly what can be created in each space (inside a `saray` → only `kat`; inside an `oda` → `masa` or `dolap`; on a `masa` → `klasor`, `dosya`, or `evrak`).

---

## Spatial Ontology

```mermaid
flowchart TD
    U["ulke (Country / Network Sovereignty)"] --> A["arazi (Land / Disk)"]
    A --> B["beylik (Hegemony / OS Root)"]
    B --> S["saray (Palace / Root User - max 1)"]
    B --> BN["bina (Building / Normal User - 0..N)"]
    S --> K["kat (Floor / Workarea)"]
    BN --> K
    K --> O["oda (Room / Session)"]
    O --> M["masa (Desk / Desktop Surface)"]
    O --> D["dolap (Cabinet / Archive)"]
    M --> KL["klasor (Binder)"]
    D --> KL
    M --> DS["dosya (File)"]
    D --> DS
    KL --> DS
    M --> EV["evrak (Document Blob)"]
    DS --> EV
```

For the full specification (sovereignty, visitor permissions, crown transfer, desk/cabinet ownership vs. room ownership, and Debian OS roadmap), see **[docs/ARCHITECTURE.md](docs/ARCHITECTURE.md)** ([Türkçe](docs/ARCHITECTURE.tr.md)).

---

## Quick Start

```bash
git clone https://github.com/gitmuhammedalbayrak/distRA.git
cd distRA

# 1. Bootstrap a starter world (Country -> Land -> Hegemony -> Palace -> Floor -> Room)
./bin/distra --root ./distra_world init

# 2. Launch the interactive spatial shell
./bin/distra --root ./distra_world shell
```

Inside the interactive shell:
```text
harita                                              # Inspect the spatial tree
gir disk0/ana-beylik/saray/kat-1/ana-oda            # Enter the Room (Session)
yeni                                                # Query allowed types (masa, dolap)
kimlik ajan-1 agent                                 # Switch identity to an AI agent
oturum_katil ajan-masasi                            # Drop a desk and join the room
gir ajan-masasi                                     # Sit at the desk
evrak_yaz . plan.txt "Ship distRA v0.2"             # Write a document directly on the desk
gir ..                                              # Step back to the room
kimler                                              # List active humans & AI agents in the room
```

---

## AI Agent Integration (CLI & MCP Server)

### JSON CLI
Every command supports `--json` for scripts and autonomous agents:
```bash
./bin/distra --root ./distra_world --actor ajan-1 --kind agent --json \
  join /turkiye/disk0/ana-beylik/saray/kat-1/ana-oda --masa ajan-1-masasi --create-masa
```

### Model Context Protocol (MCP)
Connect any MCP-compatible AI agent (Antigravity, Claude, Cursor, Codex) directly to `distRA` via `stdio`:

```json
{
  "mcpServers": {
    "distra": {
      "command": "/path/to/distRA/bin/distra-mcp",
      "env": {
        "DISTRA_ROOT": "/path/to/distRA/distra_world",
        "DISTRA_STRICT_ACL": "0"
      }
    }
  }
}
```

Exposed MCP tools: `distra_ls`, `distra_allowed`, `distra_join_room`, `distra_who`, `distra_create`, `distra_write_evrak`, `distra_read_evrak`, `distra_post_board`, `distra_read_board`, `distra_grant`, `distra_audit`.

---

## Running Tests

```bash
python3 -m unittest discover -s tests -v
```

---

## Roadmap

- [x] Spatial ontology & strict non-nesting invariants across all 12 types
- [x] Flat disk storage (`evrak_store/` + SQLite WAL)
- [x] Interactive shell & JSON CLI
- [x] Role grants (`egemen`, `sahip`, `esya_sahibi`, `ziyaretci`), crown transfer, room board & audit log
- [x] Standard `stdio` MCP server for AI agents
- [ ] Inter-land network protocol (`ulke` / `arazi` federation)
- [ ] Desktop compositor / GUI driven by `allowed_children_for`
- [ ] Bootable minimal Debian/QEMU image

---

## Contributing & License

Contributions are welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md) and our [Code of Conduct](CODE_OF_CONDUCT.md).
Licensed under the [MIT License](LICENSE).