✓
Passing This code compiles and runs correctly.
Code
// PIN (design gap): A subflow that takes a *File<opened!> as input
// but silently ignores the obligation — never closes the file and
// never re-exports the obligation in its output signature.
//
// `process-file` is a void event (no output branches). It receives a file
// with an open obligation and the caller has no way to recover the file for
// closing. The phantom checker SHOULD reject because the input obligation
// <!opened> is not consumed inside the subflow body.
//
// This is the session-type delegation gap: once a value is handed to a
// callee, the callee OWNS the discharge responsibility. If the callee's
// body does not consume or re-export the obligation, the resource leaks.
//
// PREDICTION: RED PIN — the compiler likely accepts this today because
// phantom obligation tracking does not follow values into void-event bodies.
// The expected error below is what SHOULD fire when enforcement lands.
//
// Grounding:
// ~import syntax — 330_007/input.kz line 1
// *File<opened!> as param — 330_040_undisposed_nested_obligation/fs.kz line 20
// ~pub event open {...} — 330_007/fs.kz line 4
// | opened *File<opened!> — 330_007/fs.kz line 5
// ~event void (no branches) — 330_020/input.kz line 2 (~event log-done {})
// invocation chain |> — 330_007/input.kz line 3
~import app/fs
// BAD: accepts the opened file, declares no output branches, but never calls
// close and never discharges <!opened>. Obligation is silently lost.
~event process-file { file: *File<opened!> }
~proc process-file|zig {
std.debug.print("processing\n", .{});
}
const std = @import("std");
~app/fs:open(path: "data.txt")
| opened f |> process-file(file: f)
Must fail at runtime with:
CONTAINS obligationError Verification
Expected Error Pattern
Obligation lost at subflow boundary: process-file accepts *File<opened!>
but its output signature has no discharge (<!opened>) and no re-export
(*File<opened!>). The opened! obligation is silently dropped.Actual Compiler Output
error[KORU033]: Cannot issue obligation '<opened!>' on input parameter (event: process-file). Use '<!opened>' to consume an existing obligation, or remove the '!' suffix.
--> phantom_semantic_check:32:0
error[KORU030]: Phantom state mismatch: expected 'input:opened!' but got 'app.fs:opened!' for argument 'file'
--> phantom_semantic_check:39:0
❌ Compiler coordination error: Phantom semantic validation failed
error: CompilerCoordinationFailed
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_040_subflow_drops_obligation_on_input/backend.zig:94:13: 0x1011de3b3 in emit (backend)
return error.CompilerCoordinationFailed;
^
/Users/larsde/src/koru/tests/regression/300_ADVANCED_FEATURES/335_OBLIGATION_STRESS/335_040_subflow_drops_obligation_on_input/backend.zig:190:28: 0x1011df09f in main (backend)
const generated_code = try RuntimeEmitter.emit(compile_allocator, final_ast);
^Imported Files
// File-resource module reused verbatim from:
// tests/regression/300_ADVANCED_FEATURES/330_PHANTOM_TYPES/330_007_use_after_disposal/fs.kz
// — syntax is ground-truth from a passing test.
const std = @import("std");
const File = struct { handle: i32 };
~pub event open { path: []const u8 }
| opened *File<opened!>
~proc open|zig {
std.debug.print("Opening file: {s}\n", .{path});
const allocator = std.heap.page_allocator;
const f = allocator.create(File) catch unreachable;
f.* = File{ .handle = 42 };
return .{ .opened = f };
}
// Consumes the opened! obligation — grounded in 330_007/fs.kz line 13
~pub event close { file: *File<!opened> }
~proc close|zig {
std.debug.print("Closing file\n", .{});
}
Test Configuration
MUST_FAIL