Skip to content

feat(betlang): wire-first toolchain pass + bet:Dist T on the unified runtime#65

Merged
hyperpolymath merged 1 commit into
mainfrom
chore/betlang-wiring-onto-reconciled
Jun 15, 2026
Merged

feat(betlang): wire-first toolchain pass + bet:Dist T on the unified runtime#65
hyperpolymath merged 1 commit into
mainfrom
chore/betlang-wiring-onto-reconciled

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

What this is

Brings the 2026-06-15 wire-first toolchain pass + bet : Dist T work onto the reconciled main (which already carries the parallel session's TP-5 intro/elim core and the checker's occurs-check + let-polymorphism). The parallel reconciliation merge resolved the TP-5/checker collisions but dropped this session's wiring; this PR re-applies it surgically on top.

Full rationale and the journey's design decisions: docs/decisions/2026-06-15-betlang-wiring-and-bet-dist-t.adoc (8 ADRs).

Highlights

bet : Dist T (option a) — checker + interpreter + codegen aligned with the Lean proof

  • check_bet/check_weighted_bet/check_conditional_bet return Dist T; bet { 1,2,3 } + 1 is now correctly rejected. echo(bet …) : Echo (Dist T).
  • Interpreter unified onto bet_rt::Value (one runtime): bet → Value::Dist, sample draws; AST lambdas closure-converted into native bet_rt closures. bet-rt and bet-rand are no longer orphaned.
  • JS codegen emits distribution objects so sample works end-to-end (verified under deno).

Wire-first pass

  • Justfile: was unparseable (// line 1) — fixed + Rust recipes (build-rust/test-rust/check/run/compile/repl-rust).
  • Workspace greened: bet-wasm (E0308), bet-viz (im dep + HistogramRectangle + textplots lifetimes), bet-chapel (rand_pcg); 3 real bet-rt bugs fixed (queue order, printf %s quoting, msgpack ListBytes).
  • cbindgen no longer strips the SPDX header from generated betlang.h (was an automated licence edit).
  • CLI bet compile … --target js|llvm|beam; LSP wired to the real parser + type checker (real parse/type diagnostics with spans; obsolete "LALR conflicts" deps re-enabled).
  • Interpreter surfaces unimplemented forms as errors, not silent Unit.
  • examples/dice.bet — first working .bet fixture.

Reconciliation choices (honoring owner adjudication)

  • TP-5 kept at origin's echoIntro/echoElim core. The richer comonad-law surface (this session's MultiStep shadow of EchoGradedComonad.agda) is TP-5b (deferred, P3) — preserved in local 964d106 + the ADR.
  • Origin's occurs-check + let-polymorphism kept (complementary; the audit had flagged both gaps).
  • docs/echo-types.adoc left at origin's baseline (owner-managed).

Verification

  • 317 workspace tests pass; lake build green; tools/proof-scan.sh clean (no banned escape hatches).
  • End-to-end: bet check/run/compile examples/dice.bet all work.

Deferred / for follow-up (ADR-8)

Racket→Rust authority declaration (left as-is); eager-vs-lazy runtime operational model; TP-5b; SEM-1/STAT-1/STAT-2 (Mathlib decision); ABI-1..5 (Idris2 recipe + CI).

🤖 Generated with Claude Code

…runtime

Brings the 2026-06-15 wiring work onto the reconciled origin/main (which
carries the parallel session's TP-5 intro/elim core + checker occurs-check
and let-polymorphism). Full rationale and the journey's encounters are in
docs/decisions/2026-06-15-betlang-wiring-and-bet-dist-t.adoc.

- bet : Dist T canonical in the checker (aligns with the Lean tBet rule);
  weighted/conditional bets are distributions too; sample : Dist 'a -> 'a.
- Interpreter unified onto bet_rt::Value (one runtime): bet -> Value::Dist,
  sample draws; AST lambdas closure-converted to native bet_rt closures.
  bet-rt and bet-rand are no longer orphaned.
- JS codegen emits distribution objects so sample works end-to-end.
- Interpreter surfaces unimplemented forms as errors (no silent Unit).
- Justfile parse fix + Rust recipes; workspace greened (bet-wasm/bet-viz/
  bet-chapel) + 3 bet-rt runtime bug fixes; cbindgen SPDX header preserved.
- CLI `bet compile`; LSP wired to the real parser + type checker.
- examples/dice.bet (first working .bet fixture).

TP-5 kept at origin's intro/elim core; the richer comonad-law surface is
TP-5b (deferred). 317 workspace tests pass; lake build + proof-scan green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hyperpolymath
hyperpolymath merged commit f925b52 into main Jun 15, 2026
19 checks passed
@hyperpolymath
hyperpolymath deleted the chore/betlang-wiring-onto-reconciled branch June 15, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant