-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Implementation Plan - Humans-in-the-Loop, NuSMV & Clojure Integration
This plan outlines the steps to "implement humans-in-the-loop", integrate NuSMV formal verification, and introduce Clojure tooling into the MEMS pipeline.
User Review Required
Important
NuSMV Installation: The plan assumes NuSMV can be installed via apt-get or downloaded as a binary in the CI environment.
Clojure Runtime: To run Clojure code in OpenEMS (OSGi), we need the org.clojure/clojure generic OSGi bundle (or wrap it). I propose adding it as a bundle dependency.
Note
Human-in-the-Loop: Formalized as a Pull Request Review phase.
Clojure Strategy: We will use a deps.edn based approach for development ease (VSCode/Calva), but hook into Gradle for the build process to ensure "minimal interference".
Proposed Changes
1. System Design & Documentation (Humans-in-the-Loop)
[MODIFY] mems/JOURNAL.md
- Update Pipeline Stages diagram to explicitly show "Human Verification".
- Add "Human-in-the-Loop Protocol" section.
- Add NuSMV and Clojure to the tooling list.
2. NuSMV Integration
[NEW] mems/tools/verify-nusmv.js
- Script to convert XState JSON to SMV format and run
NuSMV.
[MODIFY] mems/tools/package.json
- Add
"verify:nusmv": "node verify-nusmv.js".
3. Clojure Integration
We will create a specific Clojure sub-project within mems/ that can be built into an OSGi bundle or library.
[NEW] mems/clojure/deps.edn
- Dependencies:
org.clojure/clojure,org.clojure/tools.logging(for SLF4J),clj-osgi. - Aliases:
:test:lambdaisland/kaochafor testing.:lint:clj-kondo/clj-kondofor linting.:build:tools.buildconfiguration (if needed) or simple AOT.
[NEW] mems/clojure/src/mems/core.clj
- Example namespace with
(:gen-class)to demonstrate Java interop. - Integration with standard Java concurrency keys.
[NEW] mems/clojure/test/mems/core_test.clj
- Example
clojure.testsuite.
[NEW] mems/clojure/.clj-kondo/config.edn
- Configuration for linting.
[NEW] mems/clojure/.vscode/settings.json
- VSCode settings to enable Jack-in/Calva support (e.g.,
"calva.connect.nReplPortFile"setup).
4. Build System (Gradle Updates)
[MODIFY] build.gradle
- Tasks:
memsVerify: Add dependency onverify:nusmv.tasks.register('clojureBuild'): A task to invokeclojure -M:buildor compile the Clojure code to classes/jar.tasks.register('clojureTest'): A task to invokeclojure -M:test(Kaocha).tasks.register('clojureLint'): A task to invokeclj-kondo.
5. CI Workflow
[MODIFY] .github/workflows/mems-pipeline.yml
- Install NuSMV step.
- Install Clojure step:
actions/setup-clojure. - Run Clojure Tests: Execute
clojure -M:test(via Gradle or direct). - Run NuSMV Verification.
Verification Plan
Automated
- Clojure: Run
clj -M:testvia Gradle. Verify tests pass. Checkclj-kondooutput. - NuSMV: Run
npm run verify:nusmv. Check for pass/fail. - Pipeline: Trigger GitHub workflow and check all steps (Java build, Clojure test, NuSMV verify).
Manual
- IDE Support: Open
mems/clojurein VSCode with Calva, try "Jack-in". Verify REPL works. - Human Review: Create a PR and simulate the "Human-in-the-Loop" approval.