13. @import Resolution and Merge
This page covers FACET v2.1.3 import and merge semantics.
Basic import
@import "relative/path/module.facet"
Rules:
- resolved relative to importing file
- constrained by allowlisted roots
- deterministic source-order expansion (in-place)
Security constraints (F601)
The following must be rejected:
- absolute paths
..traversal- URL imports
- paths outside allowlisted roots
Missing file also raises F601.
Import cycle raises F602.
Standard facet cardinality
Singleton-map facets (deep-merged):
@meta,@context,@vars,@var_types,@policy
Repeatable-block facets (concatenated):
@interface,@system,@user,@assistant,@test
Singleton merge behavior
- first appearance inserts key position
- later override changes value but keeps first position
- nested map values deep-merge recursively
- lists are not deep-merged unless keyed-list merge is explicitly enabled or facet-specific rule applies (
@policy.allow/deny)
Repeatable merge behavior
Repeatable blocks are appended in resolved encounter order.
Example: override with stable key order
a.facet:
@vars
x: "a"
y: "a"
b.facet:
@vars
y: "b"
z: "b"
main.facet:
@import "a.facet"
@import "b.facet"
Effective @vars values:
x="a",y="b",z="b"
Effective key order remains first-insertion order: x, y, z.
Policy list merge (allow/deny)
Inside @policy:
- rules with string
idmerge by keyed id - rules without
idappend in encounter order - invalid non-string
idraisesF452
Determinism implications
Phase 1 output must be deterministic:
- Resolved Source Form
- Resolved AST ordering
These order guarantees are later used by Phase 3 tie-break and canonical rendering.