Skip to main content

Module stdlib

Module stdlib 

Source
Expand description

ETDL Standard Library resolution and library expansion.

A library is a reusable component catalog written in ordinary ETDL (see etdl_parser::ast::LibraryDocument). A document declares which libraries it uses in libraries: (see LibraryImport) and references their contents by qualified id: <library-name>.<short-name>, e.g. std.events.NetworkTimeout used as a gate input exactly like any other basic-event id.

expand_libraries is the only new compiler primitive this requires: given a parsed document, it resolves every declared library (transitively, with cycle detection) and returns a new document with each referenced qualified id spliced into the fault tree that references it, as an ordinary BasicEvent. Everything downstream — type checking, fault-tree evaluation, code generation — is completely unaware libraries exist; a qualified id is just another map key to them. This is deliberate: the standard library is a source-expansion concern, not a collection of compiler special cases.

§Layers

ETDL Core               language, compiler, runtime primitives
   |
ETDL Standard Library   built-in, embedded, `std.*` (this module's BuiltIn kind)
   |
ETDL Domain Libraries   e.g. the reliability supplement (a *separate*,
   |                    already-existing mechanism: compiled-in Rust via
   |                    `supplements:` + `extension::EtdlExtension` — not
   |                    reimplemented or replaced by this module)
ETDL Optional Libraries installed separately, resolved from a search path
   |                    (this module's Optional kind)
User Libraries          project-local, resolved relative to the document
                        (this module's User kind)

§What resolves where

  • Names starting with std. only resolve from the embedded built-in registry. This is the whole of the anti-shadowing rule: it is not a precedence order that optional/user libraries could win by being listed first, it is a hard partition. See LibraryError::Shadowing.
  • Everything else is searched, in order: LibraryResolver::search_paths (optional libraries), then <base_dir>/lib/<name>/lib.etdl (a user library local to the importing document, mirroring how asyncapi_imports resolves relative paths against base_dir).

§Reliability compatibility

This module does not depend on etdl-reliability-core, and nothing in the existing reliability pipeline (evidence, estimation, artifacts, calibration, observation, dependency/CCF analysis) depends on this module either. expand_libraries runs as an independent step alongside (not instead of) reliability::resolve_reliability; a future domain library MAY depend on std.* without requiring any reliability change.

Structs§

LibraryProvenance
Identity of one resolved library, for build-manifest provenance.
LibraryResolver
Resolves declared libraries to parsed LibraryDocuments.
ResolvedLibrary
One resolved library: its identity plus the basic-event definitions it provides, keyed by short (unqualified) name.

Enums§

LibraryError
A problem resolving a declared library. Never silently substitutes absence or a different library; every failure is reported.
LibraryKind
Where a resolved library’s definitions came from.

Constants§

STDLIB_SCHEMA
Schema identity for the built-in standard library package (distinct from doc.etdl, from crate versions, and from ARTIFACT_SCHEMA — see docs/reference/standard-library.md for the full versioning-axis table).
STD_NAMESPACE
The reserved namespace prefix for the built-in standard library.

Functions§

expand_libraries
Resolve every library doc declares (transitively, with cycle detection) and return a new document with library-provided basic events spliced into whichever fault trees reference them by qualified id. doc itself is never mutated. required: true (the default) means resolution failure is reported here as an error the caller should treat as fatal; required: false failures are also returned (the caller decides whether to downgrade them to a warning — see validate::validate_libraries, which applies exactly that policy).
list_builtin
Every built-in standard library module, resolved. For introspection (etdl library list) — the compile path resolves lazily and only resolves what a document actually declares.