build(agent): molt-b#d1f4fd iteration
This commit is contained in:
parent
77100afcec
commit
f7304dfbd1
44
README.md
44
README.md
|
|
@ -1,37 +1,17 @@
|
||||||
Open-EnergyMesh: Offline-First Distributed Microgrid Orchestration (MVP)
|
# Open-EnergyMesh Offline-First Microgrid Platform (MVP)
|
||||||
|
|
||||||
Overview
|
This repository provides a minimal in-memory MVP for offline-first distributed microgrid orchestration.
|
||||||
- A minimal, open MVP for offline-first distributed microgrid orchestration.
|
Core concepts:
|
||||||
- Core concepts implemented in this MVP:
|
- EnergyMesh orchestrates devices such as Inverters and Meters and computes energy flow.
|
||||||
- Simple in-memory data model for devices, DERs, forecasts, and price quotes.
|
- ADMM-like scaffold is included as a forward-looking compositional optimization hook.
|
||||||
- This repository provides a scaffold for rapid iteration toward a larger ecosystem, with a testable, self-contained surface that can be extended by future agents.
|
- Data contracts and adapters allow plugging in additional devices (DERs, storage, etc.).
|
||||||
|
|
||||||
How it maps to the Open-EnergyMesh vision
|
Usage
|
||||||
- Data model and APIs: A lightweight in-code model (Device, Inverter, Meter, DER, Forecast, PriceQuote) with a simple EnergyMesh orchestrator. The current tests exercise a basic energy-flow calculation.
|
|
||||||
- Offline-first mesh: The MVP is intentionally in-memory and offline-friendly; future work can layer on delta-sync and reconnection logic.
|
|
||||||
- Forecasting and pricing: Placeholders exist (Forecast, PriceQuote) to plug in forecasting and pricing engines as plug-ins.
|
|
||||||
- Governance and trading: Scaffolding is planned; this MVP focuses on core energy-flow calculation to enable early testing of edge behavior.
|
|
||||||
- Security and privacy: The MVP is a foundation; security models (DIDs, DTLS/TLS) and privacy controls can be added in subsequent iterations.
|
|
||||||
|
|
||||||
Getting started
|
|
||||||
- Install dependencies: npm install
|
- Install dependencies: npm install
|
||||||
- Run tests: npm test (or ./test.sh)
|
- Run tests: npm test
|
||||||
- Source: src/mesh.js defines the in-memory data model and EnergyMesh orchestration.
|
|
||||||
- Tests: test/test.js exercises a basic energy-flow calculation using Inverter and Meter components.
|
|
||||||
|
|
||||||
Extending the MVP
|
Notes
|
||||||
- Add more detailed data models (Event, Trade, Forecast, PriceQuote) and richer flow logic.
|
- This MVP emphasizes offline resilience and a clean path toward modular optimization layers.
|
||||||
- Implement a small open API surface (JSON/Protobuf) and a schema registry for versioned contracts.
|
- See src/mesh.js and src/solver_admm.js for the basic in-memory implementation and the ADMM scaffold.
|
||||||
- Introduce a pluggable forecasting and pricing engine (local and federated options).
|
|
||||||
- Build a delta-sync protocol for offline periods and reconnection.
|
|
||||||
- Implement governance scaffolding for lightweight peer-to-peer trading and community rules.
|
|
||||||
|
|
||||||
Development and contribution
|
License: MIT
|
||||||
- This project adheres to the Open-EnergyMesh vision of interoperability and resilience.
|
|
||||||
- see AGENTS.md for the architectural guidance and testing commands.
|
|
||||||
|
|
||||||
License
|
|
||||||
- MIT
|
|
||||||
|
|
||||||
Ready-to-publish marker
|
|
||||||
- A ready-to-publish marker will be placed at the repository root when the project is fully production-ready.
|
|
||||||
|
|
|
||||||
26
src/mesh.js
26
src/mesh.js
|
|
@ -49,6 +49,16 @@ class Forecast {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { AdmmSolver } = (() => {
|
||||||
|
try {
|
||||||
|
// Lazy require to avoid circular/optional dependency issues in tests
|
||||||
|
// eslint-disable-next-line global-require
|
||||||
|
return require('./solver_admm');
|
||||||
|
} catch (e) {
|
||||||
|
return { AdmmSolver: class {} };
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
class EnergyMesh {
|
class EnergyMesh {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.devices = new Map(); // id -> Device
|
this.devices = new Map(); // id -> Device
|
||||||
|
|
@ -57,6 +67,8 @@ class EnergyMesh {
|
||||||
this.ders = new Map(); // id -> DER
|
this.ders = new Map(); // id -> DER
|
||||||
this.quotes = [];
|
this.quotes = [];
|
||||||
this.forecasts = [];
|
this.forecasts = [];
|
||||||
|
// Lightweight ADMM-like solver placeholder
|
||||||
|
this.admm = new (AdmmSolver || class {})();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device helpers
|
// Device helpers
|
||||||
|
|
@ -126,6 +138,20 @@ class EnergyMesh {
|
||||||
netFlowW: generation - consumption
|
netFlowW: generation - consumption
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Placeholder ADMM-like flow computation that delegates to the solver.
|
||||||
|
// For now, it mirrors computeFlow() to preserve current behavior.
|
||||||
|
computeFlowADMM() {
|
||||||
|
// In a future iteration, local problems would be posted to admm.step(...) and
|
||||||
|
// the returned primal/dual would influence generation decisions.
|
||||||
|
const base = this.computeFlow();
|
||||||
|
// No-op: return the same result to preserve legacy behavior during MVP
|
||||||
|
return {
|
||||||
|
generationW: base.generationW,
|
||||||
|
consumptionW: base.consumptionW,
|
||||||
|
netFlowW: base.netFlowW
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Minimal ADMM-like scaffold for Open-EnergyMesh
|
||||||
|
// This is a plug-in abstraction that represents the compositional optimization layer
|
||||||
|
// described in the MVP roadmap. It currently provides a no-op step implementation
|
||||||
|
// so the runtime can evolve without breaking existing behavior.
|
||||||
|
|
||||||
|
class AdmmSolver {
|
||||||
|
constructor() {
|
||||||
|
// In a full implementation, this would hold state for primal/dual variables
|
||||||
|
this.version = '0.1-admm-skeleton';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Accept a local problem payload and return a short step result
|
||||||
|
// localData shape is application-defined; here we keep a permissive contract
|
||||||
|
step(localData) {
|
||||||
|
// No real computation yet; return a conservative delta that could be used
|
||||||
|
// by a real solver in future iterations. We mirror the input as the 'primal'.
|
||||||
|
return {
|
||||||
|
primal: localData,
|
||||||
|
dual: {},
|
||||||
|
delta: 0,
|
||||||
|
converged: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
AdmmSolver
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue