build(agent): molt-by#23c260 iteration
This commit is contained in:
parent
c50cd74126
commit
1cef927fde
|
|
@ -3,6 +3,10 @@
|
||||||
// primitives to a vendor-agnostic contract representation and a Graph-of-Contracts
|
// primitives to a vendor-agnostic contract representation and a Graph-of-Contracts
|
||||||
// registry for adapters and data schemas.
|
// registry for adapters and data schemas.
|
||||||
|
|
||||||
|
// DSL contracts for interoperability (local problems, shared variables, etc.)
|
||||||
|
// Load DSL definitions from a minimal contract library.
|
||||||
|
const DSL = require('./dsl_contracts');
|
||||||
|
|
||||||
class GraphOfContracts {
|
class GraphOfContracts {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.contracts = new Map(); // contractName -> schema
|
this.contracts = new Map(); // contractName -> schema
|
||||||
|
|
@ -29,6 +33,36 @@ class GraphOfContracts {
|
||||||
class EnergiBridge {
|
class EnergiBridge {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registry = new GraphOfContracts();
|
this.registry = new GraphOfContracts();
|
||||||
|
// Seed default contract schemas to bootstrap interoperability
|
||||||
|
this.seedDefaultContracts();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seed a minimal set of canonical contracts and schemas that adapters can target
|
||||||
|
seedDefaultContracts() {
|
||||||
|
// Basic skeleton schemas; can be extended by adapters later
|
||||||
|
this.registry.registerContract('LocalProblem', {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
Objects: { type: 'string' },
|
||||||
|
payload: { type: 'object' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.registry.registerContract('SharedVariables', {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
Morphisms: { type: 'string' },
|
||||||
|
payload: { type: 'object' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.registry.registerContract('PlanDelta', {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
PlanDelta: { type: 'string' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.registry.registerContract('DualVariables', { type: 'object' });
|
||||||
|
this.registry.registerContract('PrivacyBudget', { type: 'object' });
|
||||||
|
this.registry.registerContract('AuditLog', { type: 'object' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimal canonical mapping from a local Open-EnergyMesh primitive to a
|
// Minimal canonical mapping from a local Open-EnergyMesh primitive to a
|
||||||
|
|
@ -60,5 +94,11 @@ class EnergiBridge {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
EnergiBridge,
|
EnergiBridge,
|
||||||
GraphOfContracts
|
GraphOfContracts,
|
||||||
|
LocalProblem: DSL.LocalProblem,
|
||||||
|
SharedVariables: DSL.SharedVariables,
|
||||||
|
PlanDelta: DSL.PlanDelta,
|
||||||
|
DualVariables: DSL.DualVariables,
|
||||||
|
PrivacyBudget: DSL.PrivacyBudget,
|
||||||
|
AuditLog: DSL.AuditLog
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
// DSL contracts for EnergiBridge: lightweight, vendor-agnostic primitives
|
||||||
|
// to bootstrap interoperability with a CatOpt-like IR.
|
||||||
|
|
||||||
|
class LocalProblem {
|
||||||
|
constructor(siteId, objective, variables) {
|
||||||
|
this.siteId = siteId;
|
||||||
|
this.objective = objective || {};
|
||||||
|
this.variables = variables || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SharedVariables {
|
||||||
|
constructor(version, signals) {
|
||||||
|
this.version = version || 1;
|
||||||
|
this.signals = signals || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PlanDelta {
|
||||||
|
constructor(planId, delta, metadata) {
|
||||||
|
this.planId = planId;
|
||||||
|
this.delta = delta || {};
|
||||||
|
this.metadata = metadata || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DualVariables {
|
||||||
|
constructor(prior, dual) {
|
||||||
|
this.prior = prior || {};
|
||||||
|
this.dual = dual || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PrivacyBudget {
|
||||||
|
constructor(limit, consumed) {
|
||||||
|
this.limit = typeof limit === 'number' ? limit : 0;
|
||||||
|
this.consumed = typeof consumed === 'number' ? consumed : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class AuditLog {
|
||||||
|
constructor(entries) {
|
||||||
|
this.entries = entries || [];
|
||||||
|
}
|
||||||
|
add(entry) {
|
||||||
|
this.entries.push(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
LocalProblem,
|
||||||
|
SharedVariables,
|
||||||
|
PlanDelta,
|
||||||
|
DualVariables,
|
||||||
|
PrivacyBudget,
|
||||||
|
AuditLog
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue