API Reference
Every row below is extracted mechanically from #: comments in lib/api.nix and verified against yen.lib. Each symbol links to the line on GitHub where it is defined:
| Symbol | Description |
|---|---|
yen.types.str :: Type |
a string |
yen.types.int :: Type |
an integer |
yen.types.number :: Type |
an int or float |
yen.types.bool :: Type |
a boolean |
yen.types.port :: Type |
an integer TCP/UDP port (1..65535) |
yen.types.path :: Type |
a Nix path |
yen.types.attrs :: Type |
an attribute set |
yen.types.any :: Type |
any value |
yen.types.rawFunction :: Type |
a function passed verbatim without arg-filling |
yen.types.functionTo :: Type -> Type |
a function returning the given type |
yen.types.kind :: Type |
a declared kind reference |
yen.types.field :: Type |
a declared field reference |
yen.types.sink :: Type |
a declared sink reference |
yen.types.aspect :: Type |
a declared aspect reference |
yen.types.kit :: Type |
a declared kit reference |
yen.types.role :: Type |
a kit role or assembly role reference |
yen.types.selector :: Type |
an at selector or reference |
yen.types.is :: (a -> bool) -> str -> Type |
custom predicate type with description |
yen.types.opt :: Type -> a -> Type |
optional type with default value |
yen.types.maybe :: Type -> Type |
nullable type defaulting to null |
yen.types.listOf :: Type -> Type |
list whose elements all satisfy the inner type |
yen.types.attrsOf :: Type -> Type |
attrset whose values all satisfy the inner type |
yen.types.record :: Attrs -> Type |
structured typed record with field validation, defaults, and secret redaction |
yen.types.derive :: Type -> (inst -> a) -> Type |
field with derived default from instance |
yen.types.combine :: Reducer -> Type -> Type |
field override combine strategy for per-parent overrides |
yen.types.secret :: Type -> Type |
mark type sensitive for recursive SHA-256 redaction |
yen.types.checkWith :: attrs -> str -> [ str ] -> Type -> a -> [ Error ] |
check value against type |
yen.types.jsonSafe :: any -> any |
convert arbitrary Nix values (fns/drvs/refs) into JSON-safe structures |
yen.reduce.list :: [ Element ] -> { value; errors; } |
collect emitted values as a list |
yen.reduce.set :: [ Element ] -> { value; errors; } |
deduplicated list by ref/value identity |
yen.reduce.flat :: [ Element ] -> { value; errors; } |
concatenate emitted list values |
yen.reduce.one :: [ Element ] -> { value; errors; } |
require exactly one emitted element |
yen.reduce.maybe :: [ Element ] -> { value; errors; } |
require zero or one emitted element |
yen.reduce.last :: [ Element ] -> { value; errors; } |
keep the final element in deterministic order |
yen.reduce.merge :: [ Element ] -> { value; errors; } |
deep merge attrsets; error on leaf conflict |
yen.reduce.keyed :: (a -> str) -> [ Element ] -> { value; errors; } |
merge keyed entries; error on key clash |
yen.reduce.layers :: [ Element ] -> { value; errors; } |
ranked { rank; set; } merge; error on equal-rank conflict |
yen.reduce.elements :: [ Element ] -> { value; errors; } |
preserve full provenance records { from; aspect; origin; value; } |
yen.reduce.modules :: [ Element ] -> { value; errors; } |
wrap each module with deterministic provenance key for diamond-safe evalModules |
yen.at.any :: Selector |
matches every scope |
yen.at.none :: Selector |
matches no scope |
yen.at.all :: [ Selector ] -> Selector |
conjunction of selectors |
yen.at.anyOf :: [ Selector ] -> Selector |
disjunction of selectors |
yen.at.not :: Selector -> Selector |
negation of selector |
yen.at.kind :: KindRef -> Selector |
match scopes of kind (or sub-kind via extends) |
yen.at.where :: Attrs -> Selector |
schema-checked field matchers on target node |
yen.at.parent :: Selector -> Selector |
immediate parent satisfies selector |
yen.at.under :: Selector -> Selector |
some strict ancestor satisfies selector |
yen.at.nearest :: KindRef -> Selector -> Selector |
nearest ancestor-or-self of kind satisfies selector |
yen.at.child :: Selector -> Selector |
all immediate children satisfy selector |
yen.at.has :: Selector -> Selector |
some descendant satisfies selector |
yen.at.sibling :: Selector -> Selector |
some sibling satisfies selector |
yen.at.via :: FieldRef -> Selector -> Selector |
follow declared ref field and match target |
yen.at.targetOf :: FieldRef -> Selector -> Selector |
reverse-ref relational join via Datalog index |
yen.at.rule :: ({ S, ... } -> Rule) -> Selector |
pure-Nix Datalog rule selector with zero strings |
yen.at.pred :: str -> (scope -> bool) -> Selector |
labeled predicate escape hatch |
yen.at.self :: Matcher |
refers to root scope/instance under test across axes/hops |
yen.at.neq :: a -> Matcher |
field value != a |
yen.at.gt :: comparable -> Matcher |
field value > comparable |
yen.at.gte :: comparable -> Matcher |
field value >= comparable |
yen.at.lt :: comparable -> Matcher |
field value < comparable |
yen.at.lte :: comparable -> Matcher |
field value <= comparable |
yen.at.oneOf :: [ a ] -> Matcher |
field value matches one element |
yen.at.contains :: a -> Matcher |
list contains matching item or string contains substring |
yen.at.nonEmpty :: Matcher |
non-empty list, attrset, or string |
yen.at.exists :: Matcher |
non-null value |
yen.at.isNull :: Matcher |
value is null |
yen.at.matches :: str -> Matcher |
regex match on string field |
yen.cycle.wrap :: { before?; after?; afterWith?; boundary?; } -> Middleware |
create Cycle.js source/sink interceptor |
yen.cycle.compose :: [ Middleware ] -> Middleware |
compose Cycle middlewares outer-to-inner |
yen.cycle.apply :: Middleware -> Component -> Component |
apply middleware to a sources -> sinks component |
yen.cycle.interceptTree :: { onRequest?; onResponse?; } -> Middleware |
intercept Tree Driver requests and responses |
yen.cycle.isolateSource :: (SinkRef | str) -> (a -> b) -> Middleware |
transform an incoming source or sink source |
yen.cycle.isolateSink :: SinkRef -> (sources -> a -> b) -> Middleware |
transform outgoing emissions on a sink |
yen.cycle.redirect :: SinkRef -> SinkRef -> (sources -> a -> b) -> Middleware |
redirect emissions from one sink to another |
yen.cycle.filterSink :: SinkRef -> (sources -> a -> bool) -> Middleware |
keep only matching emissions on a sink |
yen.cycle.wall :: [ SinkRef ] -> Middleware |
kind-boundary interceptor allowing only listed sinks upward |
yen.cycle.onBoundary :: (ctx -> elem -> elem | null) -> Middleware |
custom upward sink boundary interceptor |
yen.eval :: ModuleSpec -> Result |
evaluate a Yen fleet ({ args ? {}; modules; } or bare module/list/path) |
yen.mkFlake :: Attrs -> ModuleSpec -> Attrs |
evaluate fleet and return fail-closed flake outputs plus .#yen inspection handle |
yen.at :: Attrs |
closed relational Datalog-backed selector algebra (where, under, parent, nearest, has, child, sibling, via, targetOf, rule, self) |
yen.cycle :: Attrs |
Cycle.js reactive middleware and source/sink/tree interception combinators |
yen.types :: Attrs |
unified schema and recursive secret redaction type system |
yen.reduce :: Attrs |
built-in sink and field reducers (list, set, flat, one, maybe, last, merge, keyed, layers, elements, modules) |
yen.graphs :: Attrs |
graph algorithms (fromEdges, nodesOf, reverseGraph, reachFrom, cycles, topo, sccs, waves) |
yen.graphs.fromEdges :: [ Edge ] -> Graph |
build adjacency map from edge list { from; to; } |
yen.graphs.nodesOf :: Graph -> [ str ] |
list all vertices in a graph |
yen.graphs.reverseGraph :: Graph -> Graph |
transpose all directed edges |
yen.graphs.reachFrom :: Graph -> str -> [ str ] |
all vertices reachable from a starting vertex |
yen.graphs.cycles :: Graph -> [ [ str ] ] |
list strongly connected cycles in a graph |
yen.graphs.topo :: Graph -> [ str ] |
deterministic topological order of an acyclic graph |
yen.graphs.sccs :: Graph -> [ [ str ] ] |
Kosaraju strongly connected components in reverse topological order |
yen.graphs.waves :: Graph -> [ [ str ] ] |
group DAG nodes into parallel dependency waves |
yen.datalog :: Attrs |
Tupu-inspired semi-naive stratified + WFS Datalog solver, aggregates, certificate verifier, and proof explorer |
yen.datalog.solveRules :: [ Rule ] -> [ Atom ] -> Result |
solve raw Datalog rules over ground facts |
yen.datalog.solveProgram :: Attrs -> [ Rule ] -> [ Atom ] -> Result |
plan, stratify, and solve a Datalog program with external relations ext |
yen.datalog.solveProgramWith :: Attrs -> [ Rule ] -> [ Atom ] -> Result |
solve a Datalog program with custom options (ext, budget) |
yen.datalog.verifyCertificate :: [ Rule ] -> Cert -> bool |
independently verify a WFS/stratified certificate |
yen.datalog.why :: [ Rule ] -> Model -> Atom -> [ Proof ] |
return derivation justifications for a true atom |
yen.datalog.proof :: [ Rule ] -> Model -> Cert -> Atom -> Proof |
return full proof tree for a derived atom |
yen.datalog.whyNot :: [ Rule ] -> Model -> Atom -> [ Reason ] |
explain why an atom was not derived |
yen.datalog.judge :: Model -> Atom -> Atom -> str |
classify two competing atoms (pos, neg, both, neither) |
yen.datalog.count :: AggSpec -> Agg |
Datalog count aggregate |
yen.datalog.sum :: AggSpec -> Agg |
Datalog sum aggregate |
yen.datalog.min :: AggSpec -> Agg |
Datalog minimum aggregate |
yen.datalog.max :: AggSpec -> Agg |
Datalog maximum aggregate |
yen.same :: a -> a -> bool |
structural ref identity comparison (never use raw string comparisons) |
yen.refKey :: Ref -> str |
deterministic canonical key string for any Yen ref |
yen.pointing :: FieldRef -> Attrs -> Scope -> Attrs |
filter instances whose fieldRef points to parent |
yen.matching :: FieldRef -> Attrs -> SpawnMatcher |
spawn instances whose selector field matches parent (checks spawn-stratification) |
yen.cascade :: FieldRef -> [ Scope ] -> a |
read first non-null field value across prioritized scopes |
yen.many :: [ a ] -> MultiEmit |
emit 0..N separate elements into a sink |
yen.lit :: a -> LitEmit |
emit a raw value (e.g. function) without Yen arg-filling |
yen.emit :: SinkRef -> a -> DynamicEmit |
emit an element to a sink identified by SinkRef |
yen.err :: str -> str -> Error |
create a fixable error record { from; error; code; } |
yen.errWith :: str -> str -> Attrs -> Error |
create a structured error record with { code; fix; near?; path?; } |
yen.near :: str -> [ str ] -> [ str ] |
Levenshtein top-3 suggestions |
yen.renderKind :: [ str ] -> str |
render canonical kind path list [ "host" "user" ] as "host.user" |
yen.isRef :: any -> bool |
true when value is any Yen reference |