A minimal, copy-paste template for a plugin-contributed Evrete rule pack: add or update
Komet rules — and the context-menu actions they generate — by dropping a jar into the Komet
image's plugins/ directory, without a komet release and without any runtime compiler.
See IKE-Network/ike-issues#626 for
the design decision and the rule-pack compatibility contract. For a full-featured real-world
example, see ZulipRuleProvider in komet-claude-plugin (#620).
EvreteRulesServiceconstructs the rule engine withDISABLE_LITERAL_DATA=trueand imports rules as precompiledJAVA-CLASS— so the in-JVM Java compiler is never invoked.- At startup it also calls
PluggableService.load(RuleProvider.class)and imports the classes from every discoveredRuleProvider, each in isolation (a bad pack loses its menu items; the engine keeps running). App.init()builds a JPMSModuleLayeroverplugins/, parented by the boot layer — so a pack canrequiresanything already in the image (dev.ikm.komet.rules,org.evrete.dsl.java, tinkar). This jar'sprovides … RuleProvideris then visible to step 2.
No literal/string rules, no javax.tools.JavaCompiler, no module-jars.
| File | Role |
|---|---|
ExampleRuleProvider |
The SPI entry point — returns the rule classes. |
ExampleRules |
One @Rule (extends RulesBase), fires on a focused concept, reusing RulesBase @RuleElement predicates as its @Where(methods = …). |
ExampleSuggestedAction |
The rule-generated menu action (extends AbstractActionSuggested). |
module-info.java |
provides RuleProvider, requires the author surface, opens the rule package unqualified. |
- Compile with
-parameters.@MethodPredicate(args = {"$observation"})binds facts to rule-method parameters by name; without parameter names in the bytecode the rule won't bind. (Set inpom.xml.) opensthe rule package UNQUALIFIED. Evrete reads the rule class viaMethodHandles. A qualifiedopens … to org.evrete.dsl.javais not sufficient — it throwsIllegalAccessExceptionwhen the engine unreflects the rule method. Use a bareopens <pkg>;(or anopen module).- Build against a compatible
komet-bom. The pack binds toRulesBase/AbstractAction*/ framework fact types at a specific version. Build against akomet-bommatching (same major) the komet image you deploy into — setkomet-bom.versioninpom.xml.
# from this directory, using the workspace's Maven 4 (or the wrapper)
mvn clean packageProduces target/komet-example-rules-plugin-1-SNAPSHOT.jar.
Drop the jar into the Komet runtime image's plugins/ directory (sibling of bin/), then start
Komet:
cp target/komet-example-rules-plugin-1-SNAPSHOT.jar \
/path/to/kometRuntimeImage/plugins/Focus a concept in Komet and open its context menu — "Example: log this concept" appears, contributed entirely by this plugin. Remove the jar (and restart) to remove the rule.
Plugins can be disabled at launch with
-Dike.plugins.disabled=true.
- Add
@RuleElement-annotated predicate methods toExampleRulesfor pack-specific conditions, and reference them by name in@MethodPredicate. - Return more rule classes from
ExampleRuleProvider.ruleClasses(). - Replace
ExampleSuggestedActionwith real work; useviewCalculator()to read the component, its STAMP, and version history.
New to IKE development? The Developer Environment guide covers IDE configuration, JDK 25 setup, and the tooling conventions every IKE workspace expects — start there before your first build.