Metadata-Version: 2.4
Name: uni-native
Version: 0.1.0
Summary: UNI — Native Intent Language Runtime
Author: matj0
License: MIT
Project-URL: Repository, https://github.com/matj0/UNI
Keywords: language,runtime,deterministic,declarative
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Software Development :: Interpreters
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Provides-Extra: server
Requires-Dist: aiohttp>=3.9; extra == "server"
Provides-Extra: rts
Requires-Dist: numpy>=1.24; extra == "rts"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"

# UNI — Native Intent Language

A deterministic runtime where declarative Laws govern state transformations.

## Quick Start

```bash
pip install -e .

# Create a new app
uni init my-app

# Run it
uni run my-app --law MyApp.Initialize
uni run my-app --law MyApp.SetMessage --set text=hello
uni status my-app

# Serve over HTTP
uni serve my-app --port 8080
# GET  /state, GET /laws, POST /law/SetMessage
```

## Writing a .uni App

```uni
module Counter

state CounterState:
    fields:
        value: number

law Initialize:
    intent: "Reset counter"
    effects:
        - ReadState CounterState as s
        - WriteState CounterState
    logic:
        s.value = 0

law Increment:
    intent: "Add one"
    effects:
        - ReadState CounterState as s
        - WriteState CounterState
    logic:
        s.value = s.value + 1
```

## CLI Reference

| Command | Description |
|---------|-------------|
| `uni init <name>` | Scaffold a new app |
| `uni run <path> --law Name` | Execute a law |
| `uni run <path> --law Name --set k=v` | Execute with inputs |
| `uni serve <path> --port 8080` | HTTP server |
| `uni status [path]` | Show current state |
| `uni build <file> --emit-uir out.json` | Compile to UIR |
| `uni validate <path>` | Run compliance checks |

## Architecture Overview

```
┌─────────────────────────────────────────────────────────┐
│  .uni Source Files (Laws, States, Computes, Queries)    │
└───────────────┬─────────────────────────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  Compiler (Lexer → Parser → SA → UIR)│  src/uni/compiler/
└───────────────┬──────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  Kernel (RuntimeOrchestrator)        │  src/uni/kernel/
│  ├── BaseExecutor (UIR VM)           │
│  ├── LawSolver (Intent → Mutation)   │
│  ├── AuditBus (Event Broadcasting)   │
│  └── Timeline (State History)        │
└───────────────┬──────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  SemanticGraph (Single Source of     │  src/uni/ontology/
│  Truth — STRUCTURAL + CAUSAL +      │
│  EPISTEMIC nodes with Identity)      │
└───────────────┬──────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  Observers (89 files)                │  src/uni/observers/
│  ├── structural/ (Graph Analysis)    │
│  ├── causal/ (Ancestry, Validation)  │
│  └── epistemic/ (Repair, Learning)   │
└───────────────┬──────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  Evolution Engine                    │  src/uni/evolution/
│  ├── MetaValidator (Holy Invariants) │
│  ├── EntropyGate / CoherenceGate     │
│  ├── SimulationFork (Sandboxed Test) │
│  └── Explain-to-Repair Pipeline      │
└───────────────┬──────────────────────┘
                ▼
┌──────────────────────────────────────┐
│  Autonomous Sandbox                  │  src/uni/autonomous/
│  ├── 72h Campaign Harness            │
│  ├── Budget Governance               │
│  └── Checkpoint / Rollback / Quarantine│
└──────────────────────────────────────┘
```

## Quick Start

```bash
# Run the autonomous evolution campaign
$env:PYTHONPATH="src"; python src/uni/autonomous/run_harness.py

# Run the web app hub (Tic-Tac-Toe, Snake, Todo)
python src/uni/cli/main.py serve
# Visit: http://localhost:8080/

# Run integration tests
$env:PYTHONPATH="src"; python tests/test_reflex_arc.py
$env:PYTHONPATH="src"; python tests/test_lineage_integrity.py
```

## Key Modules

| Module | Path | Purpose |
|--------|------|---------|
| **Compiler** | `src/uni/compiler/` | Lexer → Parser → Static Analysis → UIR assembly |
| **Kernel** | `src/uni/kernel/` | RuntimeOrchestrator, BaseExecutor, LawSolver, AuditBus, Timeline |
| **Ontology** | `src/uni/ontology/` | SemanticGraph, CausalAtoms, SemanticIdentity, IdentityRegistry |
| **Observers** | `src/uni/observers/` | 89 files: structural, causal, epistemic observers + GraphProjector |
| **Evolution** | `src/uni/evolution/` | EvolutionEngine, MetaValidator, Gates, Fuzzer, ProofEngine |
| **Observatory** | `src/uni/observatory/` | BlackBoxRecorder, TelemetryServer, ObservatoryMonitor |
| **Autonomous** | `src/uni/autonomous/` | AutonomousSandbox, RunHarness (4-stage campaign) |
| **Vision** | `src/uni/vision/` | VisionCompiler (LLM → `.uni` source) |
| **Stdlib** | `src/uni/stdlib/` | Standard library: meta.uni, logic.uni, numeric.uni, identity.uni |
| **Packs** | `src/uni/packs/` | Application packs: Snake, Tic-Tac-Toe, Todo, Calculator |
| **Adapter** | `src/uni/adapter/` | HTTP server, REST API bridge |
| **UIR** | `src/uni/uir/` | Universal Intermediate Representation models |

## Documentation

1. **[Core System Contract](docs/CORE_SYSTEM.md)** — The 4+2 primitives and execution model
2. **[Architecture Doctrine](docs/arch/UNI_ARCHITECTURE_DOCTRINE.md)** — Layer separation and determinism rules
3. **[Writing Laws](docs/WRITING_LAWS.md)** — Guide to authoring `.uni` behaviors
4. **[Getting Started](docs/GETTING_STARTED.md)** — Quick setup guide
5. **[Evolution Roadmap](docs/EVOLUTION_ROADMAP_V2.md)** — Multi-epoch evolution strategy

## Current Phase: 14 (Semantic Identity & Explain-to-Repair)

UNI has completed 14 phases of development across 3 epochs:

- **Epoch 1:** Wiring (Graph ↔ Runtime, Reflex Arc, AuditBus)
- **Epoch 2:** Governance (Observatory, Budget, Jepsen Campaigns, Structural Purification)
- **Epoch 3:** Semantic Civilization (Identity Tracking, Explain-to-Repair, Meta-Ontology)

## ⚖️ License

Proprietary UNI License © 2026. All rights reserved.
