✓
Passing This code compiles and runs correctly.
Code
// Test 168: Import Registers Taps Automatically
//
// Tests that importing a module automatically registers any taps defined in it.
// This is the mechanism that makes `~[profile]import "std/profiler"` work -
// the import adds the module's universal taps to the tap registry, enabling
// full-program instrumentation with a single line.
//
// Structure:
// test_lib/
// logger.kz → Defines a universal tap ~tap(* -> *) that logs all events
//
// Expected: The logger's tap fires for ALL events, even though we didn't
// explicitly write the tap pattern in this file.
//
// This demonstrates "ambient" behavior - importing makes taps active.
const std = @import("std");
// Import the logger module (which defines universal taps)
~import app/test_lib/logger
// Define some events to test with
~tor compute { x: i32 } -> i32
~tor format { value: i32 } -> string
~tor display { text: string }
~proc compute|zig {
std.debug.print("compute({d})\n", .{x});
return x * 2;
}
~proc format|zig {
std.debug.print("format({d})\n", .{value});
// Allocate temporary string for testing
const text = "formatted";
return text;
}
~proc display|zig {
std.debug.print("Final: {s}\n", .{text});
}
// Call events - the logger's universal tap should intercept them!
~compute(x: 42): r |> format(value: r): f |> display(text: f)
Actual
compute(42)
[TAP] Intercepted event: compute
format(84)
[TAP] Intercepted event: format
Final: formatted
Expected output
compute(42)
[TAP] Intercepted event: compute
format(84)
[TAP] Intercepted event: format
Final: formatted
Flows
flow ~compute click a branch to expand · @labels scroll to their anchor
compute (x: 42)
Imported Files
// Logger module with event-specific taps
// When imported, these taps automatically register and intercept matching events
const std = @import("std");
~import std/taps
// Define a logging event
~pub tor log { event_name: string }
~proc log|zig {
std.debug.print("[TAP] Intercepted event: {s}\n", .{event_name});
}
// Tap: Intercept transitions from compute (any destination). compute/format are
// bare-return `-> T` events, so the tap binds the produced value with `: v` (the
// call-site bind rule) — a branch tap (`| result |>`) has no named branch to match
// on a bare-return event. Lars-ruled 2026-06-25; see 508_tap_on_bare_return.
~tap(input:compute -> input:format): r |> log(event_name: "compute")
// Tap: Intercept transitions from format (any destination).
~tap(input:format -> input:display): f |> log(event_name: "format")
Test Configuration
MUST_RUN