Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

HCF Runtime — Hivecore Framework

Runtime services for the KerML and SysML v2 metamodels defined in hcf-models: textual parser, writer, expression evaluator, behavior execution engine, parametric (Z3/SMT) analysis, indexing, and document generation. Built on HMF.

Package layout

org.openmbee.hivecore/
├── settings/                          # Runtime configuration / settings
├── kerml/
│   ├── parser/      visitors/base/    # ANTLR-driven KerML textual parser
│   ├── generator/   base/             # KerML textual writer
│   ├── eval/        lib/              # KerML expression evaluator + kernel
│   │                                  #   function libraries (Base, Data,
│   │                                  #   Control, Sequence, Numerical,
│   │                                  #   Boolean, String, Integer, Real,
│   │                                  #   Rational, Natural, Collection, Trig)
│   ├── exec/                          # Token-passing behavior execution
│   ├── analysis/                      # Z3/SMT parametric analysis
│   ├── index/                         # Element and name indexes
│   ├── io/                            # KerML file I/O helpers
│   └── docgen/                        # KerML-driven document generation
└── sysml/
    └── parser/      visitors/base/    # SysML v2 textual parser

Capabilities

KerML textual parser (kerml/parser)

ANTLR-based parser with the visitor pattern:

  • High-level KerMLModel API: parseString(...), parseFile(...).
  • Custom KerMLErrorListener collects parse errors with file/line/column.
  • ReferenceCollector + ReferenceResolver perform deferred resolution of forward references after a parse pass.
  • ~80 visitor classes grouped by metaclass domain over base visitors.
  • Deterministic UUIDs for library elements (UUID v5 from qualified names), so library cross-references remain stable across runs.

KerML writer (kerml/generator)

Generates KerML textual notation from HMFObject model graphs:

  • KerMLWriter top-level API: write(namespace), writeToFile(...).
  • GeneratorFactory routes each HMFObject to a type-specific generator.
  • Base generators for Element, Feature, Classifier, Type.

KerML expression evaluator (kerml/eval)

Native tree-walking evaluator over KerML Expression model elements (distinct from textual-OCL evaluation). Dispatches on metaclass:

  • LiteralExpression → Sequence{self}.
  • OperatorExpression → evaluate arguments, apply via KernelFunctionLibrary.
  • InvocationExpression → bind arguments to parameters, evaluate body.
  • FeatureReferenceExpression / FeatureChainExpression → navigate.
  • SelectExpression / CollectExpression / IndexExpression → collection ops.
  • NullExpression → empty sequence.

Function libraries under eval/lib mirror the KerML Kernel Function Library files: arithmetic and comparison, boolean (and, or, not, xor, implies), strings, sequences, numerics, trig, and control flow (if, ??, collect, select, reject, forAll, exists, reduce, …).

KerMLExpressionOperationHandler wires the evaluator into HMFEngine by replacing the corresponding metaclass operations with native handlers.

Behavior execution (kerml/exec)

Token-passing execution semantics for Behaviors composed of Steps connected by Successions, with data transfer via Flows:

  • Tokens: ControlToken, ObjectToken.
  • Step state machine: WAITING → READY → EXECUTING → COMPLETED.
  • ExecutionGraph builds topology from Steps + SuccessionEdges + FlowEdges.
  • ExecutionContext provides lexical scoping with parent chains for nested invocations.
  • BehaviorExecutionEngine.execute(behavior, inputs) runs to completion with a maxSteps cap; outgoing Successions evaluate guard conditions via the expression evaluator before propagation.

Parametric / SMT analysis (kerml/analysis)

KerML-aware wrapper over the Z3/SMT solver in hmf-runtime:

  • ParametricAnalysisService extracts constraints from Invariant elements, infers Z3 sorts from Feature types (Integer → INT, Real → REAL, Boolean → BOOL), and exposes:
    • solveConstraints — find satisfying assignments.
    • checkRequirementConsistency — detect conflicting requirements.
    • tradeStudy — optimize an objective subject to constraints.
  • Inherited-feature semantics: direct constraints on inherited features throw InheritedFeatureConstraintError; redefinitions must be created explicitly in the subtype.

Document generation (kerml/docgen)

Generates documents from a model using KerML view definitions.

Indexing (kerml/index)

Indexes elements by qualified name and other lookup keys to accelerate resolution.

SysML v2 parser (sysml/parser)

ANTLR-based parser for SysML v2 textual notation, structured analogously to the KerML parser.

Resources

Bundled standard libraries under src/main/resources/:

  • kerml-library/ — Kernel Semantic Library, Kernel Function Library, Kernel Data Type Library, DocGen Library, Views Library.
  • sysml-library/ — Quantities and Units, Systems Library, Analysis, Cause and Effect, Geometry, Metadata.

Building

./gradlew build --no-configuration-cache
./gradlew test --no-configuration-cache

# Regenerate ANTLR sources after grammar changes
./gradlew generateGrammarSource --no-configuration-cache

Requires JDK 21 and Gradle 9.x.

Related projects

  • hmf — base framework: HMFEngine, OCL, Z3 solver, mounts.
  • hcf-models — KerML / SysML metamodels and generated APIs.
  • hcf-server — REST API that wraps this runtime.
  • hcf-intellij — IntelliJ plugin that embeds this runtime.

License

See LICENSE and NOTICE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages