Add pipe operator, with-update, retry/fallback, reason, parallel, trace, contract, deploy

Implements 8 new language features:
- |> pipe operator: a |> f desugars to f(a), left-associative chains
- with record update: let b = a with { field: val } — non-destructive struct update
- retry/fallback: retry N times { ... } fallback { ... } with counter-based loop codegen
- reason: AI inference primitive calling soma /v1/chat/completions at runtime
- parallel: concurrent execution block returning a Map of named results via threads
- trace: zero-cost observability block emitting TraceBegin/TraceEnd with ms timing
- requires: precondition annotation on fn, emits ContractCheck bytecode at entry
- deploy: deployment-as-syntax posting to soma /v1/deploy at runtime

All features thread through lexer → parser/AST → codegen → runtime interpreter.
This commit is contained in:
Will Anderson
2026-04-28 12:04:45 -05:00
parent f2202e0e5e
commit afd99f5e0d
10 changed files with 868 additions and 59 deletions
+41
View File
@@ -248,6 +248,23 @@ fn extract_calls_from_expr(expr: &Expr, in_loop: bool, out: &mut Vec<CallInfo>)
extract_calls_from_expr(e, in_loop, out);
}
}
Expr::With { base, updates } => {
extract_calls_from_expr(base, in_loop, out);
for (_, e) in updates {
extract_calls_from_expr(e, in_loop, out);
}
}
Expr::Reason { .. } => {}
Expr::Parallel { entries } => {
for (_, e) in entries {
extract_calls_from_expr(e, in_loop, out);
}
}
Expr::Trace { body, .. } => {
for s in body {
extract_calls_from_stmt(s, in_loop, out);
}
}
}
}
@@ -352,6 +369,23 @@ fn extract_activate_types_expr(expr: &Expr, in_loop: bool, out: &mut Vec<String>
extract_activate_types_expr(e, in_loop, out);
}
}
Expr::With { base, updates } => {
extract_activate_types_expr(base, in_loop, out);
for (_, e) in updates {
extract_activate_types_expr(e, in_loop, out);
}
}
Expr::Reason { .. } => {}
Expr::Parallel { entries } => {
for (_, e) in entries {
extract_activate_types_expr(e, in_loop, out);
}
}
Expr::Trace { body, .. } => {
for s in body {
extract_activate_types_stmt(s, in_loop, out);
}
}
}
}
@@ -408,6 +442,13 @@ fn has_sealed_in_loop_expr(expr: &Expr, in_loop: bool) -> bool {
Expr::StructLit { fields, .. } => fields
.iter()
.any(|(_, e)| has_sealed_in_loop_expr(e, in_loop)),
Expr::With { base, updates } => {
has_sealed_in_loop_expr(base, in_loop)
|| updates.iter().any(|(_, e)| has_sealed_in_loop_expr(e, in_loop))
}
Expr::Reason { .. } => false,
Expr::Parallel { entries } => entries.iter().any(|(_, e)| has_sealed_in_loop_expr(e, in_loop)),
Expr::Trace { body, .. } => body.iter().any(|s| has_sealed_in_loop_stmt(s, in_loop)),
}
}