Skip to content

Commit 546fedb

Browse files
hyperpolymathclaude
andcommitted
docs: bespoke architecture, roadmap, topology, and ABI definitions for betlangiser
Replace all template placeholders with betlangiser-specific content. Architecture: deterministic code analysis -> ternary probabilistic wrapping engine. - README.adoc: full documentation with use cases, CLI commands, example manifest - ROADMAP.adoc: 7 bespoke phases (scaffold through ecosystem) - TOPOLOGY.md: structural map with data flow diagram - Types.idr: Distribution, TernaryBool (Kleene proofs), ProbabilityValue, ConfidenceInterval, SamplingStrategy, Kolmogorov axiom witnesses - Layout.idr: distribution struct (40B), sample buffer (56B), confidence interval (24B), ternary array (16B) layouts - Foreign.idr: distribution creation, sampling, combination, ternary logic, confidence interval FFI declarations - main.zig: distribution engine with sampling, ternary logic, analytical combination (Normal+Normal), parameter validation - build.zig, integration_test.zig: betlangiser-specific - 0-AI-MANIFEST.a2ml, CLADE.a2ml, ENSAID_CONFIG.a2ml: resolved placeholders - AGENTIC/NEUROSYM/PLAYBOOK: resolved date placeholders Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 672ad92 commit 546fedb

17 files changed

Lines changed: 1844 additions & 459 deletions

.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/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/CLADE.a2ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66
uuid = "a5ea1382-a34c-5334-8a46-a2ebe904c810"
77
primary-forge = "github"
88
primary-owner = "hyperpolymath"
9-
canonical-name = "rsr-template-repo"
10-
prefixed-name = "rm-rsr-template-repo"
9+
canonical-name = "betlangiser"
10+
prefixed-name = "ac-betlangiser"
1111

1212
[clade]
13-
primary = "rm"
13+
primary = "ac"
1414
secondary = ["gv"]
15-
assigned = "2026-03-16"
16-
rationale = ""
15+
assigned = "2026-03-20"
16+
rationale = "Acceleration tool — wraps deterministic code in ternary probabilistic distributions"
1717

1818
[forges]
19-
github = "hyperpolymath/rsr-template-repo"
20-
gitlab = "hyperpolymath/rsr-template-repo"
21-
bitbucket = "hyperpolymath/rsr-template-repo"
19+
github = "hyperpolymath/betlangiser"
20+
gitlab = "hyperpolymath/betlangiser"
21+
bitbucket = "hyperpolymath/betlangiser"
2222

2323
[lineage]
24-
type = "standalone"
25-
parent = "RSR template — scaffold for new repos"
26-
born = "2026-03-16"
24+
type = "member"
25+
parent = "-iser acceleration framework family (iseriser)"
26+
born = "2026-03-20"

.machine_readable/ENSAID_CONFIG.a2ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ version = "1.0.0"
8989

9090
# Example: a custom portfolio for this project
9191
# [[portfolios.custom]]
92-
# id = "{{project}}-dev"
93-
# name = "{{PROJECT_NAME}} Development"
94-
# description = "Panels for {{PROJECT_NAME}} development"
92+
# id = "betlangiser-dev"
93+
# name = "Betlangiser Development"
94+
# description = "Panels for betlangiser development"
9595
# panels = ["valence-shell", "editor-bridge", "build-dashboard"]
9696
# default-isolation = "native"

0-AI-MANIFEST.a2ml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
14
# ⚠️ STOP - CRITICAL READING REQUIRED
25

36
**THIS FILE MUST BE READ FIRST BY ALL AI AGENTS**
47

58
## WHAT IS THIS?
69

7-
This is the AI manifest for **[YOUR-REPO-NAME]**. It declares:
10+
This is the AI manifest for **betlangiser**. It declares:
811
- Canonical file locations (where things MUST be, and nowhere else)
912
- Critical invariants (rules that must NEVER be violated)
1013
- Repository structure and organization
1114

15+
Betlangiser adds ternary probabilistic modelling to deterministic code
16+
via Betlang. It analyses source code, identifies values that should be
17+
probabilistic, wraps them in distributions, and generates
18+
uncertainty-propagating code with ternary logic (true/false/unknown).
19+
1220
## CANONICAL LOCATIONS (UNIVERSAL RULE)
1321

1422
### Machine-Readable Metadata: `.machine_readable/` ONLY
@@ -80,34 +88,37 @@ Policy enforcement contracts (k9, dust, lust, must, trust).
8088
6. **Container images** - MUST use Chainguard base (`cgr.dev/chainguard/wolfi-base:latest` or `cgr.dev/chainguard/static:latest`)
8189
7. **Container runtime** - Podman, never Docker. Files are `Containerfile`, never `Dockerfile`
8290
8. **Container orchestration** - `selur-compose`, never `docker-compose`
91+
9. **Distribution parameters** - Must be validated at type level (Idris2 dependent types)
92+
10. **Ternary logic** - Kleene strong three-valued logic only, never Priest or Bochvar
8393

8494
## REPOSITORY STRUCTURE
8595

8696
This repo follows the **Dual-Track** architecture:
8797

8898
```
89-
[YOUR-REPO-NAME]/
99+
betlangiser/
90100
├── 0-AI-MANIFEST.a2ml # THIS FILE (start here)
91101
├── README.adoc # High-level orientation (Rich Human)
92-
├── ROADMAP.adoc # Future direction
93-
├── CONTRIBUTING.adoc # Human contribution guide
94-
├── GOVERNANCE.adoc # Decision-making model
95-
├── Justfile # Task runner
96-
├── Containerfile # OCI build
97-
├── LICENSE # Primary license
102+
├── ROADMAP.adoc # Future direction (6 phases)
103+
├── TOPOLOGY.md # Structural map
104+
├── Cargo.toml # Rust build configuration
105+
├── LICENSE # PMPL-1.0-or-later
98106
├── src/ # Source code
107+
│ ├── main.rs # Rust CLI (clap subcommands)
108+
│ ├── lib.rs # Library exports
109+
│ ├── manifest/ # betlangiser.toml parser
110+
│ ├── codegen/ # Betlang wrapper generation
111+
│ ├── core/ # Analysis logic
99112
│ └── interface/ # Verified Interface Seams
100-
│ ├── abi/ # Idris2 ABI (The Spec)
101-
│ ├── ffi/ # Zig FFI (The Bridge)
102-
│ └── generated/ # C Headers (The Result)
103-
├── container/ # Stapeln container ecosystem
104-
├── docs/ # Technical depths
105-
│ ├── attribution/ # Citations, owners, maintainers (adoc)
106-
│ ├── architecture/ # Topology, diagrams
107-
│ ├── theory/ # Domain theory
108-
│ └── practice/ # Manuals
109-
├── docs/legal/ # Legal exhibits and full texts
110-
└── .machine_readable/ # ALL machine-readable metadata
113+
│ ├── abi/ # Idris2 ABI (Distribution, TernaryBool proofs)
114+
│ ├── ffi/ # Zig FFI (sampling engine, ternary logic)
115+
│ └── generated/ # C Headers
116+
├── .machine_readable/ # ALL machine-readable metadata
117+
│ ├── 6a2/ # Core state files (STATE, META, ECOSYSTEM, etc.)
118+
│ ├── CLADE.a2ml # Clade taxonomy
119+
│ └── ENSAID_CONFIG.a2ml # PanLL environment config
120+
├── .claude/ # Claude Code instructions
121+
└── .github/ # Workflows and community metadata
111122
```
112123

113124
## SESSION STARTUP CHECKLIST

README.adoc

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

88
== What Is This?
99

10-
Betlangiser adds **ternary probabilistic uncertainty modelling** to deterministic
11-
code — expressing "maybe", "probably", and "unlikely" as first-class values.
10+
Betlangiser analyses deterministic code, identifies values that should be
11+
probabilistic, wraps them in **Betlang distributions**, and generates
12+
**uncertainty-propagating code**. Turn `price = 100` into
13+
`price = Normal(100, 5)` with automatic propagation through arithmetic
14+
and control flow -- without rewriting your codebase.
1215

13-
Betlang is a probabilistic programming language built on Racket where the
14-
core primitive is the ternary bet. Betlangiser wraps deterministic code
15-
in probabilistic semantics.
16+
Betlang is a ternary probabilistic programming language where every boolean
17+
becomes **true / false / unknown**, enabling reasoning under genuine
18+
uncertainty rather than forcing premature binary decisions.
1619

1720
== How It Works
1821

19-
Annotate uncertain values in `betlangiser.toml`. Betlangiser:
20-
21-
1. Identifies deterministic decisions that should be probabilistic
22-
2. Generates Betlang probabilistic wrappers with ternary bet semantics
23-
3. Provides 14 number systems for different precision needs
24-
4. Runs Monte Carlo simulation or analytical inference
25-
5. Returns probability distributions, not point estimates
22+
1. You write a `betlangiser.toml` manifest declaring which values are uncertain
23+
2. Betlangiser **analyses your deterministic source** to find numeric values,
24+
boolean conditions, and decision points
25+
3. The **Idris2 ABI layer** proves that distribution compositions are
26+
mathematically correct (Kolmogorov axioms, support bounds, parameter validity)
27+
4. The **Zig FFI bridge** provides zero-overhead C-ABI sampling and combination
28+
5. The **codegen engine** emits Betlang wrappers with ternary bet semantics
29+
6. You get **probability distributions**, not point estimates
2630

2731
== Key Value
2832

29-
* **Uncertainty as a first-class citizen** — not bolted on, built in
30-
* **Ternary bets** — richer than binary (true/false/uncertain)
31-
* **14 number systems** — from exact rationals to fuzzy intervals
32-
* **Decision under uncertainty** — Bayesian reasoning made accessible
33+
* **Retrofit uncertainty** -- add probabilistic modelling to existing code
34+
without a rewrite
35+
* **Ternary logic** -- every boolean becomes true/false/unknown, propagating
36+
uncertainty through conditionals and loops
37+
* **Distribution types** -- Normal, Uniform, Beta, Bernoulli, and custom
38+
distributions as first-class values
39+
* **Proven correctness** -- Idris2 dependent types prove distribution
40+
composition obeys Kolmogorov axioms at compile time
41+
* **14 number systems** -- from exact rationals to fuzzy intervals, matched
42+
to precision requirements
43+
* **Automatic propagation** -- uncertainty flows through arithmetic, comparisons,
44+
and control flow without manual instrumentation
45+
46+
== Use Cases
47+
48+
* **Financial modelling** -- model price uncertainty, risk distributions,
49+
portfolio Monte Carlo
50+
* **Sensor fusion** -- combine noisy readings with known error distributions
51+
* **Risk assessment** -- propagate uncertainty through decision trees
52+
* **Monte Carlo pipelines** -- generate full simulation harnesses from
53+
deterministic code
54+
* **Scientific computing** -- add measurement uncertainty to numerical models
3355

3456
== Architecture
3557

36-
Follows the hyperpolymath -iser pattern:
37-
manifest -> Idris2 ABI proof -> Zig FFI bridge -> target language codegen.
58+
Follows the hyperpolymath **-iser pattern**:
59+
60+
[source]
61+
----
62+
betlangiser.toml (manifest)
63+
-> Deterministic source analysis
64+
-> Idris2 ABI (proves distribution correctness)
65+
-> Zig FFI (C-ABI sampling bridge)
66+
-> Betlang codegen (uncertainty-propagating wrappers)
67+
----
68+
69+
=== Idris2 ABI Layer
70+
71+
* `Types.idr` -- Distribution, TernaryBool, ProbabilityValue,
72+
ConfidenceInterval, SamplingStrategy
73+
* `Layout.idr` -- Distribution struct memory layout, sample buffer layout
74+
* `Foreign.idr` -- Distribution creation, sampling, combination, ternary
75+
logic FFI declarations
76+
77+
=== Zig FFI Bridge
78+
79+
* `main.zig` -- Distribution allocation, sampling engine, combination
80+
operators, ternary logic evaluation
81+
* `build.zig` -- Shared/static library build, cross-compilation
82+
* `test/integration_test.zig` -- ABI compliance tests
83+
3884
Part of the https://github.com/hyperpolymath/iseriser[-iser family].
3985

86+
== CLI Commands
87+
88+
[source,bash]
89+
----
90+
# Initialise a new manifest
91+
betlangiser init
92+
93+
# Validate manifest
94+
betlangiser validate -m betlangiser.toml
95+
96+
# Generate Betlang wrappers and FFI bridge
97+
betlangiser generate -m betlangiser.toml -o generated/betlangiser
98+
99+
# Build generated artifacts
100+
betlangiser build -m betlangiser.toml --release
101+
102+
# Run the workload
103+
betlangiser run -m betlangiser.toml
104+
105+
# Show manifest info
106+
betlangiser info -m betlangiser.toml
107+
----
108+
109+
== Example Manifest
110+
111+
[source,toml]
112+
----
113+
[workload]
114+
name = "pricing-model"
115+
description = "Add uncertainty to deterministic pricing"
116+
117+
[sources]
118+
paths = ["src/pricing.rs"]
119+
120+
[distributions]
121+
# Wrap a deterministic value in a normal distribution
122+
[[distributions.wrap]]
123+
target = "base_price"
124+
distribution = "Normal"
125+
params = { mean = 100.0, stddev = 5.0 }
126+
127+
[[distributions.wrap]]
128+
target = "demand_factor"
129+
distribution = "Uniform"
130+
params = { low = 0.8, high = 1.2 }
131+
132+
[[distributions.wrap]]
133+
target = "is_peak_season"
134+
distribution = "Bernoulli"
135+
params = { p = 0.3 }
136+
137+
[propagation]
138+
strategy = "monte-carlo"
139+
samples = 10000
140+
confidence = 0.95
141+
142+
[output]
143+
format = "betlang"
144+
ternary-logic = true
145+
----
146+
147+
== Building
148+
149+
[source,bash]
150+
----
151+
cargo build --release
152+
cargo test
153+
----
154+
40155
== Status
41156

42-
**Pre-alpha.** Architecture defined, scaffolding in place, codegen pending.
157+
**Pre-alpha.** Architecture defined, CLI scaffolded, ABI definitions in progress.
158+
Codegen engine pending.
43159

44160
== License
45161

0 commit comments

Comments
 (0)