✓
Passing This code compiles and runs correctly.
Code
// Cross-module phantom state unification (the ratified design,
// OUTSTANDING_DESIGN_DECISIONS.md "phantom state cross-module resolution").
//
// A USER module references a phantom state DECLARED in an imported library
// module, via the qualified form `<app/lib/store:!secret>`. The qualified state
// RESOLVES through the import map and UNIFIES with the `<secret!>` that
// make-secret issues — so this compiles, runs, and prints "ok".
//
// This is GREEN: phantom_semantic_checker.zig's lookupModule resolves the
// slash-qualified `app/lib/store` through module_map (tolerating slash<->dot),
// canonicalizing BOTH the issued `<secret!>` and the consumed `<!secret>` to
// `app.lib.store:secret`, which unify. (The obligation is issued by a
// cross-module bare-return event and bound via `: s`, then consumed by a
// user-module event whose param names the foreign module explicitly.)
//
// This is the scalar-phantom case (the obligation rides on `string`, a builtin
// with no home module) — the case that proves bare-is-not-enough and the state
// must name its own module. See also 330_088 (bare-outside rejection) and
// 330_089 (taint-tracking capability use case).
~import std/io
~import app/lib/store
// Consume app/lib/store's secret obligation cross-module.
~tor use-secret { s: string<app/lib/store:!secret> } -> string
~proc use-secret|zig {
return s;
}
~app/lib/store:make-secret(payload: "shh"): s |> use-secret(s): _ |> std/io:print.ln("ok")
Actual
ok
Must succeed:
Compile and run without errors.
Expected output
ok
Flows
flow ~make-secret click a branch to expand · @labels scroll to their anchor
make-secret (payload: "shh")
Imported Files
// A module that ISSUES a phantom-tagged scalar obligation, for the cross-module
// unification tests (330_087, 330_088, 330_089).
//
// `secret` is a compile-time taint tag: `make-secret` issues `<secret!>` (an
// obligation that the value must be `reveal`-ed before use); `reveal` consumes
// `<!secret>` and returns a plain value. This is the minimal taint-tracking
// vocabulary — a module that declares a phantom-state vocabulary carried on a
// builtin scalar (no home module of its own), which is exactly why the state
// must name its own module rather than being implied by the type.
const std = @import("std");
~pub tor make-secret { payload: string } -> string<secret!>
~proc make-secret|zig {
return payload;
}
// Consume the secret obligation: discharges <secret!> -> a plain value.
~pub tor reveal { s: string<!secret> } -> string
~proc reveal|zig {
return s;
}
Test Configuration
MUST_RUN