Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
5e25db3
Add local Docker MVP path: mock/real boundary, Corefile generation, w…
claude Jun 22, 2026
6e5f728
Fix CI: update poetry.lock, correct asyncpg version, clean up lint/ty…
claude Jun 22, 2026
7e2a84d
Fix test failures: guard Docker calls when docker_client is None
claude Jun 22, 2026
07d49e6
Fix test_cli: use attribute access on NetEngineSpec instead of dict s…
claude Jun 22, 2026
948c6a4
Add data/ to .gitignore (runtime-generated CoreDNS zone files)
claude Jun 22, 2026
719f1b4
Fix DNS verify: skip real SOA query when docker_client is None
claude Jun 22, 2026
2991ef3
feat: Implement DNS service deployment with CoreDNS and real verific…
aidankhogg Jun 22, 2026
209f013
feat(M8): implement operator API routes, reload engine, and CLI commands
claude Jun 22, 2026
041b575
Implement Tier 1 blockers: Keycloak platform setup and pgmq consumer …
claude Jun 22, 2026
01f5309
Fix CI failures: type annotations, formatting, and test mocking
claude Jun 22, 2026
79a4d87
Fix type annotations and formatting in errors.py
claude Jun 22, 2026
b64c7c8
Remove unused import from errors.py
claude Jun 22, 2026
dec981f
fix: Added ConsumerSupervisor for background task management
aidankhogg Jun 22, 2026
f313c6c
Merge branch 'dev/alpha' into claude/wonderful-gauss-6wn8u1
aidankhogg Jun 22, 2026
19d8fd8
fix: resolve all CI failures (black, mypy, test fixtures)
claude Jun 22, 2026
aaad1fd
fix: merge remote fixes and resolve remaining CI failures
claude Jun 22, 2026
fa025cb
fix: regenerate poetry.lock to match pyproject.toml after dev/alpha m…
claude Jun 22, 2026
7931d58
Complete Tier 3-5 remaining work items
claude Jun 22, 2026
bed6977
fix: re-run black after dev/alpha merge and fix minio cert dir permis…
claude Jun 22, 2026
b52ced0
fix: sort imports with isort across routes, cli, and test file
claude Jun 22, 2026
3a49e6f
fix: resolve flake8 errors in reload.py and errors.py
claude Jun 22, 2026
5f4c59d
feat: New operator API routes and a live-reload engine for world mana…
aidankhogg Jun 22, 2026
5e8a023
Merge branch 'dev/alpha' into claude/hopeful-hawking-6meekl
aidankhogg Jun 22, 2026
595e2a8
Fix CI: isort, mypy await, and minio tempdir
claude Jun 22, 2026
159de17
Clean up api/app.py: remove rebase-merged inline routes
claude Jun 22, 2026
c1c7620
feat: Implemented the teardown command and added Phase 9 org apps dep…
aidankhogg Jun 22, 2026
8c411d9
fix: address M0-M4 audit findings — bugs, gaps, and smells
claude Jun 22, 2026
05c009e
fix: resolve all three CI failures
claude Jun 22, 2026
2b9ac9a
fix: use correct type: ignore[import-untyped] for docker stubs
claude Jun 22, 2026
e993466
Merge branch 'dev/alpha' into claude/sharp-wozniak-d2fto1
aidankhogg Jun 22, 2026
757ed58
fix: DNS zone generation, PGMQ retry logic, and error handling
aidankhogg Jun 22, 2026
7229ae5
fix: address minor issues in PR #21 — conftest env var, pgmq dlq_reas…
claude Jun 22, 2026
009293e
fix: black formatting for dns.py
claude Jun 22, 2026
2033e1e
fix: remove unused omegaconf import from errors.py
claude Jun 22, 2026
827f7c2
fix: Refactor archive_to_dlq logic and fix minor issues
aidankhogg Jun 22, 2026
d676bfd
fix: resolve all six Tier-1 runtime blockers and four Tier-2 hardenin…
claude Jun 22, 2026
cbcf483
style: black formatting for phase_ands.py
claude Jun 22, 2026
a3ad561
fix: cascading cleanup — env var rename in cli, spec-sourced IPs, pha…
claude Jun 22, 2026
540fb55
feat: Refactored CLI, improve; as well as profile handling and enhanc…
aidankhogg Jun 22, 2026
73f62ff
Merge branch 'dev/alpha' into claude/zealous-ptolemy-cw1kid
aidankhogg Jun 22, 2026
2c1b9c8
fix: cascading cleanup — env var rename in cli, spec-sourced IPs, pha…
aidankhogg Jun 22, 2026
fb8b0b1
fix: pre-v1 cleanup — supervisor, gateway ABC, spec access, and profi…
claude Jun 22, 2026
740a321
fix: remove unused field import (F401) and mock minio cert writes in CI
claude Jun 22, 2026
34da85d
Resolve merge conflicts with dev/alpha
claude Jun 23, 2026
3934a57
style: black format cli/main.py
claude Jun 23, 2026
12c9145
style: isort gateway_handler.py imports
claude Jun 23, 2026
2a87722
feat: Expanded the CLI, added consumer supervisor, refactored AND+ p…
aidankhogg Jun 23, 2026
4df45d4
feat: switch DB backend to local Postgres by default, Supabase cloud …
claude Jun 23, 2026
bd6f300
fix: replace silent exception swallowing with debug/warning logging
claude Jun 23, 2026
1b38b08
Fix CI: black formatting + mypy type errors
claude Jun 23, 2026
35001bd
Activate pgmq event emission in substrate; fix GatewayError types
claude Jun 23, 2026
05b75f7
feat: local asyncpg database client with Supabase cloud fallback
aidankhogg Jun 23, 2026
3f2522a
Add spec-time cross-field validation (CIDR overlap, AND name uniqueness)
claude Jun 23, 2026
d63eace
Quality: fix pre-commit Python version, expand mypy coverage
claude Jun 23, 2026
d2c270a
Fix mypy CI: add docker ignore_missing_imports override in pyproject.…
claude Jun 23, 2026
dfe70d9
Add unit tests for GatewayHandler, WorldRegistryHandler, DomainRegist…
claude Jun 23, 2026
2e6f369
Fix linting: black-format test files
claude Jun 23, 2026
640bbe9
fix: isort import ordering in registry and gateway handler tests
claude Jun 23, 2026
2015969
docs: comprehensive README rewrite with quickstart, architecture, and…
claude Jun 23, 2026
5769cfd
docs: comprehensive README rewrite
aidankhogg Jun 23, 2026
f45603e
Merge branch 'dev/alpha' into claude/netengine-down
aidankhogg Jun 23, 2026
5fd0c31
feat: Activated pgmq event emissions in substrate; fixed GatewayErro…
aidankhogg Jun 23, 2026
aa946a6
docs: unit tests for GatewayHandler, WorldRegistryHandler, DomainReg…
aidankhogg Jun 23, 2026
2037601
fix: add missing return type annotations for mypy strict compliance
claude Jun 23, 2026
7c3cf4d
fix: spec-time cross-field validation (CIDR overlap, AND name unique…
aidankhogg Jun 23, 2026
a47bc3c
Quality: fix pre-commit Python version, expand mypy strict coverage
aidankhogg Jun 23, 2026
68f22d6
fix: complete netengine down command and fix registry handler tests
claude Jun 25, 2026
3c6d27c
fix: completed netengine down command + fixed registry handler tests
aidankhogg Jun 26, 2026
69857a6
Add netengine diagnose — Diagnostic Utility for world health checks
claude Jun 26, 2026
f396243
Fix linting issues in diagnostic probes
claude Jun 26, 2026
10dd8e6
Format code with black
claude Jun 26, 2026
5fea33f
Fix import ordering with isort
claude Jun 26, 2026
51fd421
feat: Added a diagnostic probes framework and health check CLI command
aidankhogg Jun 26, 2026
fe8e6c8
fix: replace broken Phase 4/5 placeholder tests with real test coverage
claude Jun 26, 2026
aa49f40
test: comprehensive integration tests for Phase 4 & 5 handlers
aidankhogg Jun 26, 2026
2300c10
Implement PKI certificate rotation scheduled worker
claude Jun 26, 2026
98a089a
Fix type hints and line length issues
claude Jun 26, 2026
425caa2
Fix PGMQ event emission in rotation worker
claude Jun 26, 2026
f06d829
Fix type hints for strict mypy compliance
claude Jun 26, 2026
3a20c08
Improve datetime deserialization in RuntimeState
claude Jun 26, 2026
66a9795
Fix line length issues in state.py
claude Jun 26, 2026
38dc81f
Fix long line in phase_pki.py logging
claude Jun 26, 2026
b7d937f
Fix line length in spec/models.py Field descriptions
claude Jun 26, 2026
fb9235b
feat: Add monitoring service with pgmq event publishing
claude Jun 26, 2026
8e8e6d6
Improve type annotations in RuntimeState.load()
claude Jun 26, 2026
72353bb
cleanup: Remove unused imports from monitoring service
claude Jun 26, 2026
b14d4fd
Add state controller with continuous drift detection and self-healing
claude Jun 26, 2026
5d15976
Integrate loguru logging system across all NetEngine modules
claude Jun 26, 2026
acaf6fc
fix: Resolve type checking and test failures
claude Jun 26, 2026
002b795
Fix linting and type checking issues
claude Jun 26, 2026
67c2f7d
fix: recentralised the logging configuration with custom get_logger …
aidankhogg Jun 26, 2026
81ce43a
Fix type checking and test failures for PKI cert rotation worker
claude Jun 26, 2026
d62094c
feat: always-running monitoring service for world health checks
aidankhogg Jun 26, 2026
42afef2
Fix type checking errors
claude Jun 26, 2026
c7ca8e7
Merge branch 'dev/alpha' into claude/pki-cert-rotation-worker-0f8bvj
aidankhogg Jun 26, 2026
90737e5
Fix import ordering in phase_pki.py per isort requirements
claude Jun 26, 2026
8a71042
Fix line length issues in test files
claude Jun 26, 2026
65b1ac8
Fix test mock for extract_cert_expiry in Phase 4 tests
claude Jun 26, 2026
8383efb
Brainstorm: Modular compose.yml collection for NetEngine workflows
claude Jun 26, 2026
3f12692
feat: automatic PKI certificate rotation worker
aidankhogg Jun 26, 2026
6e8cb56
Implement DNS zone record disk flushing, NTP sync, and gateway verifi…
claude Jun 26, 2026
5831d63
Expand compose brainstorm: 11 new specialized variants
claude Jun 26, 2026
2bcef83
feat: Supabase setup and configuration scripts
claude Jun 26, 2026
e164a08
Add 15 support files: scripts, configs, and templates
claude Jun 26, 2026
17c2041
chore: Supabase database setup scripts and documentation
aidankhogg Jun 26, 2026
33a5322
Add 13 in-world platform service compose variants
claude Jun 26, 2026
5ef871b
feat: real NTP and gateway connectivity checks
aidankhogg Jun 26, 2026
5990805
Merge branch 'dev/alpha' into claude/state-controller-drift-detection…
aidankhogg Jun 26, 2026
66284ba
feat: drift detection and self-healing controller
aidankhogg Jun 26, 2026
2c5006d
Add CLI spec composition flags
aidankhogg Jun 26, 2026
9176654
Expose netengine console script
aidankhogg Jun 26, 2026
5b0abab
Include phase 9 in CLI status
aidankhogg Jun 26, 2026
96be0e2
feat: Added `up --env` and repeatable `--set` support for spec compo…
aidankhogg Jun 26, 2026
9f7a6f8
Merge branch 'dev/alpha' into codex/update-cli-to-include-phase-9
aidankhogg Jun 26, 2026
a0d1ef6
fix: Included Phase 9 (Org applications) in CLI, docs, and tests
aidankhogg Jun 26, 2026
6092dd0
Expose phase 9 in API health labels
aidankhogg Jun 26, 2026
9f114ba
Merge pull request #43 from Forebase/codex/update-pyproject.toml-for-…
aidankhogg Jun 26, 2026
4be7b03
Harden operator auth TLS verification
aidankhogg Jun 26, 2026
f3a89f5
fix: Exposed phase 9 in API health labels
aidankhogg Jun 26, 2026
7eb90f1
feat: Hardening of operator auth TLS verification
aidankhogg Jun 26, 2026
6aeef5a
Secure export import operator endpoints
aidankhogg Jun 26, 2026
a1130f6
fix: Secure export admin-only access and secret sanitization
aidankhogg Jun 26, 2026
597f5cc
Improve runtime state Supabase sync
aidankhogg Jun 26, 2026
c2e2f2f
Compute default zone dir at context construction
aidankhogg Jun 26, 2026
0da776b
fix: Best-effort Supabase sync - return task in async context and lo…
aidankhogg Jun 26, 2026
b122c55
Improve runtime state atomic saves
aidankhogg Jun 26, 2026
2746faa
Merge branch 'dev/alpha' into codex/improve-runtimestate.save-impleme…
aidankhogg Jun 26, 2026
fef1f53
feat: RuntimeState atomic saves and preserve 0o600 permissions
aidankhogg Jun 26, 2026
c2537a9
fix: Compute default zone dir at PhaseContext construction
aidankhogg Jun 26, 2026
39a1042
Merge branch 'claude/compose-yml-brainstorm-mk9gva' into dev/alpha
aidankhogg Jun 27, 2026
855074a
Complete operator API CRUD, AND/domain management, e2e bootstrap test
claude Jun 27, 2026
c9b1c0e
Fix CI: black formatting and mypy type errors
claude Jun 27, 2026
ac53492
Fix isort: sort TYPE_CHECKING before other typing imports in state.py
claude Jun 27, 2026
d356d03
Fix loguru KeyError on JSON format and improve Docker subnet overlap …
claude Jun 27, 2026
3d537af
Fix flake8 E501: shorten subnet overlap error message lines
claude Jun 27, 2026
d25e5ba
Change default platform subnet from 172.20/16 to 172.28/16 to avoid c…
claude Jun 27, 2026
92130a4
Update tests to match new 172.28.0.0/16 platform subnet default
claude Jun 27, 2026
1c16015
Narrow default core network subnet from /8 to /24 to avoid conflicts
claude Jun 27, 2026
30eb2d2
Merge remote-tracking branch 'origin/claude/docker-network-subnet-con…
aidankhogg Jun 27, 2026
85506bc
feat: add `netengine init` command to scaffold a new world spec
claude Jun 27, 2026
69f55d0
feat: Implement 12 missing Docker Compose configurations for comprehe…
claude Jun 27, 2026
3b58e43
feat: expand `netengine init` into a full interactive wizard
claude Jun 27, 2026
87f3911
Merge remote-tracking branch 'origin/claude/getting-started-beji5b' i…
aidankhogg Jun 27, 2026
4389283
refactor: extract PhaseGraph, DockerFactory; add queue registry and s…
claude Jun 27, 2026
97ec561
style: apply black formatting to routes.py
claude Jun 27, 2026
b665316
style: fix isort import order in routes.py
claude Jun 27, 2026
acbf7fd
feat: complete architectural improvements (metrics, immutability, eve…
claude Jun 27, 2026
6e4dba6
fix: remove NETENGINE_MOCK from integration CI job
claude Jun 27, 2026
1b79db2
fix: replace deprecated datetime.utcnow() with datetime.now(UTC)
claude Jun 27, 2026
a0625aa
feat: implement declared-but-not-implemented PKI, gateway, and federa…
claude Jun 28, 2026
2bdca88
Fix CI failures: black formatting, mypy types, integration test mock
claude Jun 28, 2026
1b28a9c
Fix isort: sort inline imports (os before tempfile) in gateway_portal…
claude Jun 28, 2026
1451feb
Fix flake8 E501: shorten line 62 in gateway_portal_handler (129→89 ch…
claude Jun 28, 2026
d4dce97
feat: Gateway Portal and PKI feature handlers
aidankhogg Jun 28, 2026
ad921bb
chore: non-cascading repo tidy
claude Jun 28, 2026
c8cbda9
feat: complete alpha v1 — e2e tests, federation, and Docker fixes
claude Jun 28, 2026
d79c667
docs: comprehensive gap analysis of spec-implementation mismatches
claude Jun 28, 2026
1ecb370
fix: black formatting on e2e tests; configure Docker address pool in CI
claude Jun 28, 2026
d30352d
fix: isort import ordering in e2e test files
claude Jun 28, 2026
01f2a1f
fix: use 172.20.0.x e2e fixture spec to avoid CI subnet conflict
claude Jun 28, 2026
ef640dc
fix: dns.py reads listen_ip from spec not dns_output; fix substrate a…
claude Jun 28, 2026
570cf4b
fix: create CoreDNS container directly on core network at startup
claude Jun 28, 2026
32eb606
fix: black formatting on dns.py after Docker API refactor
claude Jun 28, 2026
af2bc22
fix: deprecated datetime.utcnow() with datetime.now(UTC)
aidankhogg Jun 28, 2026
a200663
fix: Removed flake8 config and consolidate test fixtures
aidankhogg Jun 28, 2026
7ee13be
docs: comprehensive gap analysis and feature inventory
aidankhogg Jun 28, 2026
13025fa
fix: retry CoreDNS SOA verification up to 6x and log container output…
claude Jun 28, 2026
e2e58b3
fix: remove unused docker import in _verify_dns_service (flake8 F401)
claude Jun 28, 2026
6485b7c
fix: add $TTL + explicit IN class to zone files so CoreDNS accepts SOA
claude Jun 28, 2026
f9583ae
fix: gracefully handle missing gateway container in GatewayPortalHandler
claude Jun 28, 2026
23aa6d0
fix: write Corefile patches via host-mounted path instead of sh exec
claude Jun 28, 2026
093ae1c
fix: use Docker daemon APIs instead of shell exec for CoreDNS SIGHUP …
claude Jun 28, 2026
6c13086
fix: comprehensive end-to-end integration tests with real Docker
aidankhogg Jun 28, 2026
443afc0
fix: register missing queues and replace string literals with Queue enum
claude Jun 28, 2026
9434c67
feat: warn on unsupported spec fields at load time
claude Jun 28, 2026
12af970
fix: apply black formatting to test_spec_parsing.py
claude Jun 28, 2026
13f4339
fix: apply isort to test_spec_parsing.py
claude Jun 28, 2026
f7a21f2
fix: add world_services_output prerequisite for Phase 9 (org_apps)
claude Jun 28, 2026
be1d33f
feat: make PKI rotation worker reload-aware via _resolve_configs
claude Jun 28, 2026
a80040b
feat: add PUT /ands/{name}/profile, /gateway, /services/{name}, /pki/…
claude Jun 28, 2026
6343eb6
fix: correct world_registry field name in mail_handler and remove fal…
claude Jun 28, 2026
8de092e
Implement intermediate CA support
claude Jun 28, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# ── Cloud Supabase (optional — used when NETENGINE_DB_URL is not set) ──
SUPABASE_URL=https://xxxxx.supabase.co
SUPABASE_SERVICE_KEY=eyJ...
SUPABASE_SERVICE_KEY=eyJ...

# ── Local Postgres (docker-compose.yml) ──
NETENGINE_DB_URL=postgresql://netengine:dev_password@localhost:5432/netengine
POSTGRES_PASSWORD=dev_password

# ── Keycloak admin credentials ──
KEYCLOAK_ADMIN_PASSWORD=admin_dev_password

# ── Runtime behaviour ──
# Set to true to skip all real Docker/DNS/PKI calls (unit-test mode)
NETENGINE_MOCK=false

# Where the DNS handler writes Corefile + zone files (CoreDNS bind-mounts this)
NETENGINE_ZONE_DIR=./data/coredns

# Where the RuntimeState JSON file is persisted
NETENGINE_STATE_FILE=netengine_state.json
69 changes: 69 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,75 @@ jobs:
- name: Lint with flake8
run: poetry run flake8 netengine tests

integration:
name: Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install

- name: Run integration tests
run: poetry run pytest tests/integration/ -v --tb=short

e2e:
name: E2E Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install

- name: Pull CoreDNS image (cache warm-up)
run: docker pull coredns/coredns:1.11.3

- name: Run e2e tests
run: poetry run pytest tests/integration/test_e2e_fullstack.py tests/integration/test_e2e_federation.py -v --tb=short --run-e2e -m "e2e and not slow"

typecheck:
name: Type Checking
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,4 @@ __marimo__/

# NetEngine local runtime state
netengines_state.json
data/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 24.1.1
hooks:
- id: black
language_version: python3.11
language_version: python3.13
args: ["--line-length=100"]

- repo: https://github.com/PyCQA/isort
Expand Down
207 changes: 206 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,210 @@
# NetEngine
# NetEngine
## Your internet, your control.

NetEngine is a declarative platform for bootstrapping self-contained, authority-autonomous digital worlds. Give it a YAML spec and it provisions authoritative DNS, a private PKI/ACME CA, OIDC identity (Keycloak), network isolation (nftables), domain and world registries, mail, storage, and org applications — all running in Docker on a single host.

---

## What it does

A *world* is a self-contained internet: its own TLD hierarchy, its own certificate authority, its own identity provider, and its own network policies. NetEngine turns a YAML spec into a live world in under ten minutes.

```
netengine up examples/minimal.yaml
```

That single command runs nine phases in sequence:

| Phase | What it provisions |
|---|---|
| 0 — Substrate | Docker networks, NTP, orchestrator init |
| 1–2 — DNS | CoreDNS root + platform zones, TLD hierarchy |
| 3 — PKI | step-ca root CA + ACME endpoint |
| 4 — Platform identity | Keycloak realm, admin user, platform OIDC client |
| 5 — Registries | World registry, domain registry, WHOIS server |
| 6 — In-world identity | Per-org Keycloak realms |
| 7 — ANDs | Administrative Network Domains (nftables isolation) |
| 8 — Services | Postfix, MinIO |
| 9 — Org applications | Org app deployments |

Each phase is idempotent — re-running `netengine up` skips already-completed phases.

---

## Prerequisites

- **Python 3.13+**
- **Docker** (Engine 24+, Compose optional)
- **PostgreSQL 15+** with the [pgmq](https://github.com/tembo-io/pgmq) extension — the easiest way is `docker compose up -d db` using the included `docker-compose.yml`
- **Poetry** (`pip install poetry`)

---

## Quickstart

```bash
# 1. Clone
git clone https://github.com/Forebase/NetEngine.git
cd NetEngine

# 2. Install dependencies
poetry install

# 3. Start local Postgres + pgmq (includes pgmq extension pre-installed)
docker compose up -d db

# 4. Apply migrations
poetry run python -m netengine.utils.run_migrations

# 5. Boot a minimal world
poetry run netengine up examples/minimal.yaml
```

Check status at any time:

```bash
poetry run netengine status
```

Tear down:

```bash
poetry run netengine down
```

---

## Configuration

Worlds are defined in YAML. See `examples/` for reference:

| File | Description |
|---|---|
| `examples/minimal.yaml` | Bare minimum — no orgs, no ANDs, services off |
| `examples/single-org.yaml` | One organisation with residential AND |
| `examples/dev-sandbox.yaml` | Full dev setup with orgs, ANDs, mail, storage |

### Spec composition

Large specs can be split across files:

```bash
# Base + environment overlay
poetry run netengine up examples/spec.base.yaml --env dev

# Inline override
poetry run netengine up spec.yaml --set metadata.name=my-world
```

### Environment variables

| Variable | Default | Description |
|---|---|---|
| `NETENGINE_DB_URL` | `postgresql://netengine:dev_password@localhost:5432/netengine` | Local Postgres connection string |
| `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | — | Set both to use Supabase cloud instead of local Postgres |
| `NETENGINE_STATE_FILE` | `netengines_state.json` | Path to runtime state JSON |
| `NETENGINE_MOCK` | `false` | Set `true` to skip real Docker/DNS/PKI calls (useful for CI) |
| `NETENGINE_ZONE_DIR` | `./data/coredns` | Directory for CoreDNS zone files |

---

## Architecture

```
┌─────────────────────────────────────────────────┐
│ netengine CLI (click) │
│ up / down / status / reload / migrate │
└────────────────┬────────────────────────────────┘
┌────────────────▼────────────────────────────────┐
│ Orchestrator (core/orchestrator.py) │
│ Sequential phase execution, state machine │
│ Skip logic (idempotent re-runs) │
└────────────────┬────────────────────────────────┘
┌────────┴─────────┐
│ Phase handlers │ phases/ + handlers/
│ 0–9, each with: │
│ execute() │
│ healthcheck() │
│ should_skip() │
└────────┬──────────┘
┌────────────────▼────────────────────────────────┐
│ Event bus (pgmq over Postgres) │
│ EventEnvelope with correlation_id │
│ ConsumerSupervisor for background workers │
└─────────────────────────────────────────────────┘
```

**Runtime state** is persisted to `netengines_state.json` after each phase so interrupted runs can resume where they left off.

**Events** flow phase-to-phase via pgmq queues: `dns_updates`, `oidc_provisioning`, `and_provisioning`, `inworld_admissions`, `services_admissions`. Each queue has a dead-letter queue (`*_dlq`) for failed messages.

---

## Development

```bash
# Run tests
poetry run pytest

# Type checking
poetry run mypy netengine

# Linting
poetry run black netengine tests
poetry run isort netengine tests
poetry run flake8 netengine

# Mock-mode test (no Docker needed)
NETENGINE_MOCK=true poetry run netengine up examples/minimal.yaml
```

### Project layout

```
netengine/
cli/ Click CLI (up, down, status, reload, migrate)
core/ Orchestrator, state, pgmq client, consumer supervisor
handlers/ Phase implementation handlers (DNS, PKI, gateway, …)
phases/ Phase handler wrappers (identity, registries, ANDs, services)
spec/ Pydantic v2 models + YAML loader with cross-field validation
events/ EventEnvelope schema (locked)
api/ FastAPI operator API
logging/ Structured logging (loguru)
errors.py Error hierarchy (SubstrateError, DNSError, PKIError, …)
migrations/ SQL schema + pgmq queue setup
examples/ Reference YAML specs
docs/ Architecture decisions, audit findings
```

---

## Operator API

When a world is running, the operator API is available at `https://api.platform.internal:8080`. Authentication uses the platform OIDC realm — include a bearer token from Keycloak.

```
GET /health Liveness check
GET /world Current world spec + phase status
GET /phases/{n} Individual phase status and output
```

---

## Roadmap to v1

The active development roadmap lives in the [GitHub project](https://github.com/Forebase/NetEngine). Key items:

- [x] End-to-end integration test (real Docker, live DNS query, cert issuance, OIDC login)
- [x] Complete operator API (org CRUD, AND management, domain management)
- [x] Cross-world federation
- [x] `persistent` lifecycle mode (import/export, lifecycle guards, teardown confirmation)
- [x] `netengine down --dry-run`

---

## License

See `LICENSE`.
Loading
Loading