✗
Failing This test is currently failing.
Failed: backend-exec
Error Details
install
Failure Output
Showing last 10 of 27 lines
error: the following command failed with 1 compilation errors:
/opt/homebrew/Cellar/zig/0.15.2_1/bin/zig build-exe -ODebug --dep koru_parser --dep koru_ast=ast --dep koru_errors=errors --dep ast --dep flow_parser --dep liquid -Mroot=/Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/410_BUDGETED_INTERPRETER/410_010_shape_contract/output_emitted.zig -ODebug --dep ast --dep lexer --dep errors --dep type_registry --dep expression_parser --dep union_collector --dep module_resolver --dep file_types -Mkoru_parser=/usr/local/lib/koru/src/parser.zig -ODebug --dep errors -Mast=/usr/local/lib/koru/src/ast.zig -ODebug -Merrors=/usr/local/lib/koru/src/errors.zig -ODebug --dep ast --dep lexer --dep errors --dep expression_parser -Mflow_parser=/usr/local/lib/koru/src/flow_parser.zig -ODebug -Mliquid=/usr/local/lib/koru/src/liquid.zig -ODebug -Mlexer=/usr/local/lib/koru/src/lexer.zig -ODebug --dep ast --dep log -Mtype_registry=/usr/local/lib/koru/src/type_registry.zig -ODebug --dep lexer --dep ast -Mexpression_parser=/usr/local/lib/koru/src/expression_parser.zig -ODebug --dep ast -Munion_collector=/usr/local/lib/koru/src/union_collector.zig -ODebug --dep config --dep log --dep file_types -Mmodule_resolver=/usr/local/lib/koru/src/module_resolver.zig -ODebug -Mfile_types=/usr/local/lib/koru/src/file_types.zig -ODebug -Mlog=/usr/local/lib/koru/src/log.zig -ODebug --dep log -Mconfig=/usr/local/lib/koru/src/config.zig --cache-dir .zig-cache --global-cache-dir /Users/larsde/.cache/zig --name output --zig-lib-dir /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig/ --listen=-
Build Summary: 0/3 steps succeeded; 1 failed
install transitive failure
+- install output transitive failure
+- compile exe output Debug native 1 errors
error: the following build command failed with exit code 1:
.zig-cache/o/4a2644f10c356997473182bd94b7aa06/build /opt/homebrew/Cellar/zig/0.15.2_1/bin/zig /opt/homebrew/Cellar/zig/0.15.2_1/lib/zig /Users/larsde/src/koru/tests/regression/400_RUNTIME_FEATURES/410_BUDGETED_INTERPRETER/410_010_shape_contract .zig-cache /Users/larsde/.cache/zig --seed 0x2861ede -Z86dea4ef5571ad34 Code
// Test: Shape contract validation for interpreted code
// Interpreted code can optionally be validated against an event signature
// This ensures responses conform to a known shape
~import "$std/runtime"
~import "$std/io"
const std = @import("std");
// =============================================================================
// The Handler Contract
// =============================================================================
// This defines what shape interpreted "handlers" must return.
// Think of it as a response schema for code sent over the wire.
~pub event handler { req: []const u8 }
| ok { status: i32, body: []const u8 }
| error []const u8
// =============================================================================
// Backend events the handler can call
// =============================================================================
~pub event db.user.get { id: i32 }
| found []const u8
~proc db.user.get|zig {
if (id == 1) {
return .{ .found = "Alice" };
}
}
// Register events with costs
~std.runtime:register(scope: "api") {
handler(0) // handler itself has no cost (it's the shape)
db.user.get(5) // database lookup costs 5 tokens
}
// =============================================================================
// TEST 1: Valid handler - should pass shape validation
// =============================================================================
const VALID_HANDLER =
\\~db.user.get(id: 1)
\\| found u |> ok { status: 200, body: u.name }
\\| unknown |> not_found {}
;
~std.runtime:run(source: VALID_HANDLER, scope: "api", budget: 100, shape: "handler")
| result _ |> std.io:println(text: "TEST 1 PASS: valid handler accepted")
| shape_error e |> std.io:print.ln("TEST 1 FAIL: unexpected shape error: {{ e.branch:s }}")
| exhausted _ |> std.io:println(text: "TEST 1 FAIL: exhausted")
| parse_error _ |> std.io:println(text: "TEST 1 FAIL: parse error")
| validation_error _ |> std.io:println(text: "TEST 1 FAIL: validation error")
| event_denied _ |> std.io:println(text: "TEST 1 FAIL: event denied")
| dispatch_error _ |> std.io:println(text: "TEST 1 FAIL: dispatch error")
| scope_not_found _ |> std.io:println(text: "TEST 1 FAIL: scope not found")
// =============================================================================
// TEST 2: Invalid branch name - should fail shape validation
// =============================================================================
const TYPO_HANDLER =
\\~db.user.get(id: 999)
\\| found u |> ok { status: 200, body: u.name }
\\| unknown |> not_foundy {}
;
// Note: "not_foundy" is a typo - should be "not_found"
// Using id: 999 which returns 'unknown' so the typo branch is executed
~std.runtime:run(source: TYPO_HANDLER, scope: "api", budget: 100, shape: "handler")
| result _ |> std.io:println(text: "TEST 2 FAIL: should have caught typo")
| shape_error e |> std.io:print.ln("TEST 2 PASS: caught invalid branch '{{ e.branch:s }}'")
| exhausted _ |> std.io:println(text: "TEST 2 FAIL: exhausted")
| parse_error _ |> std.io:println(text: "TEST 2 FAIL: parse error")
| validation_error _ |> std.io:println(text: "TEST 2 FAIL: validation error")
| event_denied _ |> std.io:println(text: "TEST 2 FAIL: event denied")
| dispatch_error _ |> std.io:println(text: "TEST 2 FAIL: dispatch error")
| scope_not_found _ |> std.io:println(text: "TEST 2 FAIL: scope not found")
// =============================================================================
// TEST 3: Missing required field - should fail shape validation
// =============================================================================
const MISSING_FIELD_HANDLER =
\\~db.user.get(id: 1)
\\| found u |> ok { status: 200 }
\\| unknown |> not_found {}
;
// Note: ok branch is missing required 'body' field
~std.runtime:run(source: MISSING_FIELD_HANDLER, scope: "api", budget: 100, shape: "handler")
| result _ |> std.io:println(text: "TEST 3 FAIL: should have caught missing field")
| shape_error e |> std.io:print.ln("TEST 3 PASS: caught missing field in '{{ e.branch:s }}'")
| exhausted _ |> std.io:println(text: "TEST 3 FAIL: exhausted")
| parse_error _ |> std.io:println(text: "TEST 3 FAIL: parse error")
| validation_error _ |> std.io:println(text: "TEST 3 FAIL: validation error")
| event_denied _ |> std.io:println(text: "TEST 3 FAIL: event denied")
| dispatch_error _ |> std.io:println(text: "TEST 3 FAIL: dispatch error")
| scope_not_found _ |> std.io:println(text: "TEST 3 FAIL: scope not found")
// =============================================================================
// TEST 4: Free-running mode (no shape) - typo allowed
// =============================================================================
~std.runtime:run(source: TYPO_HANDLER, scope: "api", budget: 100)
| result r |> std.io:print.ln("TEST 4 PASS: free-running mode allows any shape, got branch '{{ r.value.branch:s }}'")
| exhausted _ |> std.io:println(text: "TEST 4 FAIL: exhausted")
| parse_error _ |> std.io:println(text: "TEST 4 FAIL: parse error")
| validation_error _ |> std.io:println(text: "TEST 4 FAIL: validation error")
| shape_error _ |> std.io:println(text: "TEST 4 FAIL: shape error")
| event_denied _ |> std.io:println(text: "TEST 4 FAIL: event denied")
| dispatch_error _ |> std.io:println(text: "TEST 4 FAIL: dispatch error")
| scope_not_found _ |> std.io:println(text: "TEST 4 FAIL: scope not found")
Expected output
TEST 1 PASS: valid handler accepted
TEST 2 PASS: caught invalid branch 'not_foundy'
TEST 3 PASS: caught missing field in 'ok'
TEST 4 PASS: free-running mode allows any shape, got branch 'not_foundy'
Test Configuration
MUST_RUN