Skip to content

Commit 74b203a

Browse files
hyperpolymathclaude
andcommitted
docs(otpiser): bespoke OTP supervision tree content across all layers
Replace template placeholders and generic content with OTP-specific documentation, types, and FFI implementations: - README.adoc: supervision strategies, GenServer/GenStateMachine scaffolding, restart intensity, use cases, example manifest, quick start - ROADMAP.adoc: Phase 0-6 with OTP-specific milestones (tree generation, GenServer scaffolding, advanced OTP patterns, Elixir ecosystem integration) - TOPOLOGY.md: module map, data flow, supervision tree model, key interfaces - Idris2 ABI: SupervisorStrategy, ChildSpec, RestartIntensity, GenServerCallback, ProcessTree with well-formedness proofs - Zig FFI: tree construction (create_supervisor, create_worker, add_child), tree validation, OTP code emission stubs, serialisation - Rust ABI: mirrored OTP types with strategy/restart/shutdown enums - Manifest parser: OTP-aware validation (strategies, feature flags) - Machine-readable 6a2: bespoke STATE, META, ECOSYSTEM for OTP domain - 0-AI-MANIFEST: replaced [YOUR-REPO-NAME] with otpiser Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9e84496 commit 74b203a

18 files changed

Lines changed: 1765 additions & 494 deletions

File tree

.machine_readable/6a2/AGENTIC.a2ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[agent-permissions]
1212
can-edit-source = true

.machine_readable/6a2/ECOSYSTEM.a2ml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
(version "0.1.0")
77
(name "otpiser")
88
(type "tool")
9-
(purpose "Generate OTP supervision trees and fault-tolerance scaffolding")
9+
(purpose "Generate OTP supervision trees, GenServers, GenStateMachines, and fault-tolerance scaffolding from service descriptions")
1010

1111
(position-in-ecosystem
1212
(family "-iser acceleration frameworks")
1313
(meta-framework "iseriser")
1414
(relationship "sibling")
15+
(domain "Fault-tolerant distributed systems (Erlang/OTP/BEAM)")
1516
(top-3 ("typedqliser" "chapeliser" "verisimiser")))
1617

1718
(related-projects
@@ -23,16 +24,25 @@
2324
(description "Formal type safety for any query language"))
2425
(project "chapeliser"
2526
(relationship "sibling-priority-2")
26-
(description "Chapel distributed computing acceleration"))
27+
(description "Chapel distributed computing acceleration — otpiser can supervise Chapel workers"))
2728
(project "verisimiser"
2829
(relationship "sibling-priority-3")
29-
(description "VeriSimDB octad database augmentation"))
30+
(description "VeriSimDB octad database augmentation — otpiser can supervise DB connections"))
31+
(project "burble"
32+
(relationship "consumer")
33+
(description "Voice platform — uses OTP supervision for call handling, WebRTC, and media pipelines"))
3034
(project "squeakwell"
3135
(relationship "sibling")
3236
(description "Database recovery via constraint propagation"))
3337
(project "proven"
3438
(relationship "dependency")
35-
(description "Shared Idris2 verified library"))
39+
(description "Shared Idris2 verified library — provides foundational proofs"))
3640
(project "typell"
3741
(relationship "dependency")
38-
(description "Type theory engine"))))
42+
(description "Type theory engine — powers type-level supervision tree analysis"))
43+
(project "panll"
44+
(relationship "integration")
45+
(description "Panel framework — supervision tree visualisation panel"))
46+
(project "boj-server"
47+
(relationship "integration")
48+
(description "BoJ cartridge for OTP scaffolding generation"))))

.machine_readable/6a2/META.a2ml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,53 @@
44

55
(meta
66
(version "0.1.0")
7-
(last-updated "2026-03-20")
7+
(last-updated "2026-03-21")
88

99
(architecture-decisions
1010
(adr "001-iser-pattern"
1111
(status "accepted")
12-
(context "Need to make powerful languages accessible without steep learning curves")
13-
(decision "Use manifest-driven code generation: user describes WHAT, tool generates HOW")
14-
(consequences "Users write zero target language code; all complexity in the -iser"))
12+
(context "OTP supervision trees are powerful but hard to learn correctly")
13+
(decision "Manifest-driven code generation: user describes services, otpiser generates the supervision tree")
14+
(consequences "Users write zero Elixir code; all OTP complexity is handled by the -iser"))
1515

1616
(adr "002-abi-ffi-standard"
1717
(status "accepted")
18-
(context "Need verified interop between Rust CLI, target language, and user code")
19-
(decision "Idris2 ABI for formal proofs, Zig FFI for C-ABI bridge")
20-
(consequences "Compile-time correctness guarantees; zero runtime overhead from proofs"))
18+
(context "Need verified interop between Rust CLI, Elixir/BEAM runtime, and NIF bridge")
19+
(decision "Idris2 ABI for formal proofs of tree correctness, Zig FFI for C-ABI NIF bridge")
20+
(consequences "Compile-time guarantees that supervision trees are well-formed; zero runtime overhead"))
2121

22-
(adr "003-rsr-template"
22+
(adr "003-strategy-selection"
23+
(status "accepted")
24+
(context "Choosing the right supervision strategy is the hardest part of OTP design")
25+
(decision "Automatic strategy selection from service dependency analysis: independent → one_for_one, coupled → one_for_all, ordered → rest_for_one")
26+
(consequences "Users describe relationships; otpiser computes optimal strategies"))
27+
28+
(adr "004-restart-intensity"
29+
(status "accepted")
30+
(context "Incorrect max_restarts/max_seconds causes restart storms or premature shutdown")
31+
(decision "Compute restart intensity from SLA definitions: high-availability services get aggressive budgets, best-effort services get conservative ones")
32+
(consequences "Self-tuning fault tolerance without manual parameter guessing"))
33+
34+
(adr "005-rsr-template"
2335
(status "accepted")
2436
(context "Need consistent project structure across 29+ -iser repos")
2537
(decision "All repos cloned from rsr-template-repo with full CI/CD and governance")
2638
(consequences "17 workflows, SECURITY.md, CONTRIBUTING, bot directives from day one")))
2739

2840
(development-practices
29-
(language "Rust" (purpose "CLI and orchestration"))
30-
(language "Idris2" (purpose "ABI formal proofs"))
31-
(language "Zig" (purpose "FFI C-ABI bridge"))
41+
(language "Rust" (purpose "CLI orchestration and manifest parsing"))
42+
(language "Idris2" (purpose "ABI formal proofs for supervision tree invariants"))
43+
(language "Zig" (purpose "FFI C-ABI bridge for Erlang NIF generation"))
44+
(language "Elixir" (purpose "Target language — generated code"))
3245
(build-tool "cargo")
3346
(ci "GitHub Actions (17 workflows)"))
3447

3548
(design-rationale
3649
(principle "Manifest-driven"
37-
(explanation "User intent captured in TOML; all generation is deterministic and reproducible"))
50+
(explanation "User intent captured in otpiser.toml; supervision tree generation is deterministic and reproducible"))
3851
(principle "Formally verified bridges"
39-
(explanation "Idris2 dependent types prove interface correctness at compile time"))
52+
(explanation "Idris2 dependent types prove supervision tree well-formedness at compile time"))
4053
(principle "Zero target language exposure"
41-
(explanation "Users never write Chapel/Julia/Futhark/etc. — the -iser handles everything"))))
54+
(explanation "Users never write Elixir/Erlang — otpiser generates everything including Application, Supervisor, GenServer, tests, and mix.exs"))
55+
(principle "Let it crash, correctly"
56+
(explanation "OTP's 'let it crash' philosophy is correct but easy to misconfigure — otpiser ensures the crash recovery strategy matches service semantics"))))

.machine_readable/6a2/NEUROSYM.a2ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[hypatia-config]
1212
scan-enabled = true

.machine_readable/6a2/PLAYBOOK.a2ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[metadata]
88
version = "0.1.0"
9-
last-updated = "{{CURRENT_DATE}}"
9+
last-updated = "2026-03-21"
1010

1111
[deployment]
1212
# method = "gitops" # gitops | manual | ci-triggered

.machine_readable/6a2/STATE.a2ml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,38 @@
55
(state
66
(metadata
77
(version "0.1.0")
8-
(last-updated "2026-03-20")
8+
(last-updated "2026-03-21")
99
(author "Jonathan D.A. Jewell"))
1010

1111
(project-context
1212
(name "otpiser")
13-
(description "Generate OTP supervision trees and fault-tolerance scaffolding")
14-
(status "scaffold")
13+
(description "Generate OTP supervision trees, GenServers, GenStateMachines, and fault-tolerance scaffolding from service descriptions")
14+
(status "scaffold-documented")
1515
(priority "—")
1616
(ecosystem "-iser family (https://github.com/hyperpolymath/iseriser)"))
1717

1818
(current-position
19-
(phase "initial-scaffold")
20-
(completion-percentage 5)
21-
(milestone "Architecture defined, CLI scaffolded, RSR template complete"))
19+
(phase "scaffold-documented")
20+
(completion-percentage 10)
21+
(milestone "Architecture defined, CLI scaffolded, ABI/FFI bespoke for OTP, full documentation"))
2222

2323
(route-to-mvp
24-
(step 1 "Replace codegen stubs with target-language-specific generation")
25-
(step 2 "Implement Idris2 ABI proofs for core invariants")
26-
(step 3 "Build Zig FFI bridge")
27-
(step 4 "Integration tests with real-world examples")
28-
(step 5 "Documentation and examples"))
24+
(step 1 "Implement manifest parser for OTP-specific fields (services, strategies, SLAs)")
25+
(step 2 "Build dependency graph from service descriptions")
26+
(step 3 "Implement strategy selection engine (one_for_one, one_for_all, rest_for_one)")
27+
(step 4 "Implement restart intensity calculator from SLA definitions")
28+
(step 5 "Generate Elixir Application and Supervisor modules")
29+
(step 6 "Generate GenServer modules with typed callbacks")
30+
(step 7 "Generate DynamicSupervisor and Registry modules")
31+
(step 8 "Generate mix.exs, config, and ExUnit tests")
32+
(step 9 "First working end-to-end example (payment gateway)")
33+
(step 10 "Idris2 ABI proofs for tree correctness invariants")
34+
(step 11 "Zig FFI NIF bridge for performance-critical paths"))
2935

3036
(blockers-and-issues
31-
(none "Project is in scaffold phase — no blockers yet"))
37+
(none "Project is in documented scaffold phase — no blockers yet"))
3238

3339
(critical-next-actions
34-
(action "Implement codegen for primary use case")
35-
(action "Write first working example end-to-end")))
40+
(action "Expand otpiser.toml manifest schema with service/supervisor/SLA sections")
41+
(action "Implement supervision tree topology computation from dependency graph")
42+
(action "Write first working example: single-service one_for_one supervision")))

0-AI-MANIFEST.a2ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## WHAT IS THIS?
66

7-
This is the AI manifest for **[YOUR-REPO-NAME]**. It declares:
7+
This is the AI manifest for **otpiser**. It declares:
88
- Canonical file locations (where things MUST be, and nowhere else)
99
- Critical invariants (rules that must NEVER be violated)
1010
- Repository structure and organization
@@ -86,7 +86,7 @@ Policy enforcement contracts (k9, dust, lust, must, trust).
8686
This repo follows the **Dual-Track** architecture:
8787

8888
```
89-
[YOUR-REPO-NAME]/
89+
otpiser/
9090
├── 0-AI-MANIFEST.a2ml # THIS FILE (start here)
9191
├── README.adoc # High-level orientation (Rich Human)
9292
├── ROADMAP.adoc # Future direction

README.adoc

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,124 @@ Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
77

88
== What Is This?
99

10-
OTPiser generates **OTP supervision trees, GenServers, and fault-tolerance
11-
scaffolding** from service descriptions bringing Erlang/BEAM reliability
12-
to any service architecture.
10+
OTPiser generates **OTP supervision trees, GenServers, GenStateMachines, and
11+
fault-tolerance scaffolding** from service descriptions -- bringing Erlang/BEAM
12+
reliability to any service architecture.
1313

14-
The "let it crash" supervision tree model is genuinely superior for
15-
reliability, but OTP patterns are hard to learn. OTPiser eliminates the cliff.
14+
The "let it crash" supervision tree model is genuinely superior for reliability,
15+
but OTP patterns are notoriously hard to learn correctly. Supervision strategy
16+
selection, restart intensity tuning, child spec ordering, and process linking
17+
are all sources of subtle production bugs. OTPiser eliminates the cliff.
1618

1719
== How It Works
1820

1921
Describe your services in `otpiser.toml`. OTPiser:
2022

21-
1. Generates Elixir/Erlang supervision trees with correct restart strategies
22-
2. Creates GenServer modules for each service component
23-
3. Wires up health checks, circuit breakers, and backpressure
24-
4. Generates NIFs (via Zig FFI) for performance-critical paths
23+
1. Parses your service architecture into a dependency graph
24+
2. Generates an Elixir supervision tree with correct restart strategies
25+
(`one_for_one`, `one_for_all`, `rest_for_one`)
26+
3. Creates GenServer modules for stateful service components
27+
4. Creates GenStateMachine modules for state-machine workflows
28+
5. Wires up `max_restarts`, `max_seconds`, and child spec ordering
29+
6. Generates health checks, circuit breakers, and backpressure mechanisms
30+
7. Emits NIFs (via Zig FFI) for performance-critical hot paths
2531

26-
== Key Value
32+
== OTP Concepts Generated
2733

28-
* **9-nines reliability patterns** without learning OTP
29-
* **Supervision trees generated from service descriptions**
30-
* **"Let it crash" philosophy** — services self-heal automatically
34+
=== Supervision Strategies
35+
36+
[cols="1,3"]
37+
|===
38+
| Strategy | When OTPiser uses it
39+
40+
| `one_for_one`
41+
| Independent services -- restarting one does not affect siblings
42+
43+
| `one_for_all`
44+
| Tightly coupled service groups -- if one fails, restart the whole group
45+
46+
| `rest_for_one`
47+
| Ordered dependency chains -- restart the failed process and everything started after it
48+
|===
49+
50+
=== Generated Modules
51+
52+
* **Application** -- top-level OTP application with `start/2` callback
53+
* **Root Supervisor** -- entry supervisor with configurable strategy
54+
* **Service Supervisors** -- per-service-group supervisors (nested trees)
55+
* **GenServer workers** -- stateful services with `init/1`, `handle_call/3`, `handle_cast/2`, `handle_info/2`
56+
* **GenStateMachine workers** -- state-machine processes with typed state transitions
57+
* **DynamicSupervisor** -- for services that spawn workers on demand (connection pools, consumers)
58+
* **Registry** -- named process registry for service discovery
59+
* **Task.Supervisor** -- for fire-and-forget or awaited async work
60+
61+
=== Restart Intensity
62+
63+
OTPiser computes safe `max_restarts` / `max_seconds` values from your service
64+
SLA definitions. High-availability services get aggressive restart budgets;
65+
best-effort services get conservative ones to avoid restart storms.
66+
67+
== Use Cases
68+
69+
* **Microservice resilience** -- describe your service mesh, get a battle-tested supervision tree
70+
* **Message queue consumers** -- GenStage/Broadway pipelines with backpressure and consumer groups
71+
* **Connection pool management** -- DynamicSupervisor pools with health-checked workers
72+
* **Distributed system orchestration** -- multi-node process groups with `:pg` and `:net_kernel`
73+
* **IoT device management** -- per-device GenServers under a DynamicSupervisor
74+
* **WebSocket/long-lived connections** -- supervised connection handlers with clean shutdown
3175

3276
== Architecture
3377

3478
Follows the hyperpolymath -iser pattern (same as https://github.com/hyperpolymath/chapeliser[Chapeliser]):
3579

36-
* **Manifest** (`otpiser.toml`) describe WHAT you want
37-
* **Idris2 ABI** (`src/abi/`) formal proofs of interface correctness
38-
* **Zig FFI** (`ffi/zig/`) C-ABI bridge to target language runtime
39-
* **Codegen** (`src/codegen/`) generates target language wrapper code
40-
* **Rust CLI** parses manifest, validates, generates, builds, runs
80+
* **Manifest** (`otpiser.toml`) -- describe WHAT you want
81+
* **Idris2 ABI** (`src/interface/abi/`) -- formal proofs of supervision tree correctness
82+
* **Zig FFI** (`src/interface/ffi/`) -- C-ABI bridge for NIF generation
83+
* **Codegen** (`src/codegen/`) -- generates Elixir modules, mix.exs, config, and tests
84+
* **Rust CLI** -- parses manifest, validates, generates, builds, runs
4185

42-
User writes zero target language code. Otpiser generates everything.
86+
User writes zero Elixir code. OTPiser generates everything.
4387

4488
Part of the https://github.com/hyperpolymath/iseriser[-iser family] of acceleration frameworks.
4589

90+
== Quick Start
91+
92+
[source,bash]
93+
----
94+
# Initialise a new otpiser manifest
95+
otpiser init
96+
97+
# Edit otpiser.toml to describe your services
98+
# Then generate the supervision tree
99+
otpiser generate
100+
101+
# Validate the manifest before generation
102+
otpiser validate
103+
104+
# Build the generated Elixir project
105+
otpiser build
106+
107+
# Show manifest info
108+
otpiser info
109+
----
110+
111+
== Example Manifest
112+
113+
[source,toml]
114+
----
115+
[workload]
116+
name = "payment-gateway"
117+
entry = "PaymentGateway.Application"
118+
strategy = "one_for_one"
119+
120+
[data]
121+
input-type = "PaymentRequest"
122+
output-type = "PaymentResult"
123+
124+
[options]
125+
flags = ["distributed", "health-checks"]
126+
----
127+
46128
== Status
47129

48130
**Pre-alpha.** Architecture defined, scaffolding in place, codegen pending.

0 commit comments

Comments
 (0)