WireModel

object WireModel

Orchestrates model wireup: builds reference-name and ownership back-references across the entity registry of the current ModelScope maintained by MetamodelEntity.

Call reset at the start of each stigCheckModel invocation (to drop entities from a previous Gradle-daemon run), then wireAll once entities have been constructed (typically after class-loading) and before any rule that consults referenceName or owner* fields.

Both methods operate on whichever scope is current on the calling thread — usually the process-global default scope, but a live-source materializer (e.g. the IDEA plugin) can isolate its work in a per-file scope via ModelScope.with { … }.

Wireup proceeds in three phases:

  1. Kt-facade sweep. For each distinct declaring class observed in the registry, walks its static MetamodelEntity-typed fields and stamps entity.referenceName = field.name. This captures the Kotlin variable name for top-level vals (which compile to static fields on the file-facade class) and for Kotlin object members. Source-materialized entities have no captured declaring class and are skipped here — their referenceName must be set directly via MetamodelEntity.bindToSource before wireAll is called.

  2. Declared-child sweep. Walks model fields declared by consumer subclasses and binds their Kotlin property names and owning classes. This covers context/interface trees such as service members and method parameters in addition to the work-product containers. A follow-up pass then handles Port/TopicPort specifically: their inherited relation fields sit inside this package, so the generic walk does not discover serviceInterface/topic — the follow-up pass builds a compound reference from each port's own (by-then-resolved) name instead.

  3. Container sweep. Walks every registered container (Analysis, InterfacePointAnalysis, Requirements, Tests) and calls wireChildren(), which stamps both referenceName and the appropriate owner* back-reference on the container's declared children. Runs last so that a container's property name overrides the top-level binding name when an entity is aliased to both.

Functions

Link copied to clipboard

Infers the shared Viewpoint from a fully-qualified class name, based on package-name conventions used by STIG models: *.context.* / *.requirements.* / *.design.* / *.analysis.* / *.tests.*. Returns null for class names that don't match any convention (most library and JVM classes).

Link copied to clipboard
fun reset()

Clears the current ModelScope's entity registry. In the compiled / Gradle / CLI path this is the process-global default scope (ModelScope.global). The IDE plugin typically isolates its work with ModelScope.with(…) and lets the scope be GC'd rather than calling this directly.

Link copied to clipboard
fun wireAll()
Generated with STIG