build(agent): new-agents-2#7e3bbc iteration

This commit is contained in:
agent-7e3bbc424e07835b 2026-04-21 10:41:13 +02:00
parent 7ece74b55e
commit 887f28ed52
13 changed files with 173 additions and 27 deletions

55
delta_mesh/Registry.c Normal file
View File

@ -0,0 +1,55 @@
#include "Registry.h"
#include <stdlib.h>
#include <string.h>
// Internal helper to ensure capacity
static int registry_ensure_capacity(Registry* r) {
if (r->entries == NULL) {
size_t cap = 4;
r->entries = (RegistryEntry*)calloc(cap, sizeof(RegistryEntry));
if (!r->entries) return -1;
r->capacity = cap;
r->count = 0;
return 0;
}
if (r->count < r->capacity) return 0;
size_t newcap = r->capacity * 2;
RegistryEntry* tmp = (RegistryEntry*)realloc(r->entries, newcap * sizeof(RegistryEntry));
if (!tmp) return -1;
// Initialize new slots to zero
for (size_t i = r->capacity; i < newcap; ++i) {
tmp[i].key = NULL;
tmp[i].value = NULL;
tmp[i].version = 0;
}
r->entries = tmp;
r->capacity = newcap;
return 0;
}
void registry_init(Registry* r) {
r->entries = NULL;
r->count = 0;
r->capacity = 0;
// lazy initialization on first register
}
int registry_register(Registry* r, const char* key, const char* value, int version) {
if (registry_ensure_capacity(r) != 0) return -1;
RegistryEntry e;
e.key = key;
e.value = value;
e.version = version;
r->entries[r->count++] = e;
return 0;
}
const char* registry_lookup(Registry* r, const char* key) {
if (!r || !r->entries) return NULL;
for (size_t i = 0; i < r->count; ++i) {
if (r->entries[i].key && strcmp(r->entries[i].key, key) == 0) {
return r->entries[i].value;
}
}
return NULL;
}

23
delta_mesh/Registry.h Normal file
View File

@ -0,0 +1,23 @@
// Simple in-process registry to map canonical primitives to versions/handles
#ifndef REGISTRY_H
#define REGISTRY_H
#include <stddef.h>
typedef struct RegistryEntry {
const char* key;
const char* value;
int version;
} RegistryEntry;
typedef struct Registry {
RegistryEntry* entries;
size_t count;
size_t capacity;
} Registry;
void registry_init(Registry* r);
int registry_register(Registry* r, const char* key, const char* value, int version);
const char* registry_lookup(Registry* r, const char* key);
#endif

BIN
delta_mesh/Registry.o Normal file

Binary file not shown.

4
delta_mesh/delta_crdt.c Normal file
View File

@ -0,0 +1,4 @@
#include "delta_crdt.h"
// No heavy implementation needed for a toy MVP; this file exists to
// satisfy build expectations and to place future CRDT logic here.

20
delta_mesh/delta_crdt.h Normal file
View File

@ -0,0 +1,20 @@
// Lightweight CRDT-like delta structure and merge utility
#ifndef DELTA_CRDT_H
#define DELTA_CRDT_H
typedef struct DeltaCRDT {
unsigned long version;
double value_delta;
} DeltaCRDT;
// Merge two deltas by choosing the one with the higher version.
static inline void crdt_merge(const DeltaCRDT* a, const DeltaCRDT* b, DeltaCRDT* out) {
if (!a || !b || !out) return;
if (a->version >= b->version) {
*out = *a;
} else {
*out = *b;
}
}
#endif

BIN
delta_mesh/delta_crdt.o Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,16 +1,43 @@
#include <stdio.h>
#include "LocalMarket.h"
#include "admm_lite.h"
#include "Registry.h"
#include "dsl_seed.h"
#include "delta_crdt.h"
// A tiny demo that creates two LocalMarkets and demonstrates a simple ADMM-lite step.
int main(void) {
// 1) Demonstrate a simple registry usage (GoC-like bridge)
Registry reg;
registry_init(&reg);
registry_register(&reg, "LocalMarket", "v1.0", 1);
registry_register(&reg, "SharedSignals", "v1.0", 1);
const char* lm_ver = registry_lookup(&reg, "LocalMarket");
printf("DeltaMesh REG: LocalMarket -> %s\n", lm_ver ? lm_ver : "<missing>");
// 2) Demonstrate DSL seed usage (toy initialization)
LocalMarketSeed lm_seed;
dsl_localmarket_seed_init(&lm_seed, "VenueA", 100.0, 50.0);
SharedSignalsSeed ss_seed;
dsl_sharedsignals_seed_init(&ss_seed, 0.25, 0.18);
PlanDeltaSeed pd_seed;
dsl_plandelta_seed_init(&pd_seed, 0.5, 0.2, 12345);
printf("DeltaMesh DSL seeds: lm=%s, ivol=%.3f, quote=%.3f\n",
lm_seed.venue, ss_seed.implied_vol, pd_seed.quote);
// 3) Demonstrate a CRDT-like delta merge (toy)
DeltaCRDT d1 = { .version = 1, .value_delta = 0.2 };
DeltaCRDT d2 = { .version = 2, .value_delta = -0.1 };
DeltaCRDT merged = {0};
crdt_merge(&d1, &d2, &merged);
printf("DeltaMesh CRDT merge: ver=%lu delta=%.4f\n", merged.version, merged.value_delta);
// 4) Simple ADMM-lite step using existing demo helper for compatibility
LocalMarket v1 = {"VenueA", 100.0, 50.0};
LocalMarket v2 = {"VenueB", 150.0, 75.0};
double quotes[2] = { v1.inventory, v2.inventory };
double aggregate = 0.0;
admm_lite_step(quotes, 2, &aggregate);
printf("DeltaMesh DEMO: aggregated quote = %f\n", aggregate);
return 0;
}

Binary file not shown.

View File

@ -1,11 +1,21 @@
// Minimal DSL seed implementation for DeltaMesh MVP (toy).
#include "dsl_seed.h"
#include <stdio.h>
// Example entry point to exercise the seed artifacts without pulling external deps.
void dsl_seed_example_log(void) {
AuditLog log = { "delta_seed_initialized", 0 };
(void)log; // suppress unused warning in a tiny demo
// No-op print guarded by a macro in a real build; kept tiny to avoid side effects.
// printf("%s @ %lu\n", log.entry, log.timestamp);
void dsl_localmarket_seed_init(LocalMarketSeed* s, const char* venue, double inventory, double risk_budget) {
if (!s) return;
s->venue = venue;
s->inventory = inventory;
s->risk_budget = risk_budget;
}
void dsl_sharedsignals_seed_init(SharedSignalsSeed* s, double greeks, double ivol) {
if (!s) return;
s->aggregated_greeks = greeks;
s->implied_vol = ivol;
}
void dsl_plandelta_seed_init(PlanDeltaSeed* s, double quote, double hedge, unsigned long ts) {
if (!s) return;
s->quote = quote;
s->hedge = hedge;
s->timestamp = ts;
}

View File

@ -1,24 +1,28 @@
// Minimal DSL seed primitives for DeltaMesh MVP (toy).
// This header provides lightweight, forward-looking data structures that
// can be used by adapters and the coordination layer to agree on contract
// representations without leaking raw data.
// Lightweight seed structures for LocalMarket, SharedSignals, and PlanDelta
// to bootstrap interoperability in the DeltaMesh MVP.
#ifndef DSL_SEED_H
#define DSL_SEED_H
typedef struct LocalArbProblem {
double objective; // toy objective value for the arb problem
unsigned long timestamp; // monotonic timestamp for replay
} LocalArbProblem;
typedef struct LocalMarketSeed {
const char* venue;
double inventory;
double risk_budget;
} LocalMarketSeed;
typedef struct AuditLog {
const char* entry; // human-readable log entry or hash
unsigned long timestamp; // log timestamp for replay and audit
} AuditLog;
typedef struct SharedSignalsSeed {
double aggregated_greeks;
double implied_vol;
} SharedSignalsSeed;
typedef struct GovernanceBlock {
const char* policy; // description of governance constraint
unsigned long timestamp; // policy versioning / timestamp
} GovernanceBlock;
typedef struct PlanDeltaSeed {
double quote;
double hedge;
unsigned long timestamp;
} PlanDeltaSeed;
void dsl_localmarket_seed_init(LocalMarketSeed* s, const char* venue, double inventory, double risk_budget);
void dsl_sharedsignals_seed_init(SharedSignalsSeed* s, double greeks, double ivol);
void dsl_plandelta_seed_init(PlanDeltaSeed* s, double quote, double hedge, unsigned long ts);
#endif

BIN
delta_mesh/dsl_seed.o Normal file

Binary file not shown.

View File

@ -13,7 +13,10 @@ $cc $CCFLAGS -c delta_mesh/LocalMarket.c -o delta_mesh/LocalMarket.o || true
$cc $CCFLAGS -c delta_mesh/SharedSignals.c -o delta_mesh/SharedSignals.o || true
$cc $CCFLAGS -c delta_mesh/PlanDelta.c -o delta_mesh/PlanDelta.o || true
$cc $CCFLAGS -c delta_mesh/EnergiBridge.c -o delta_mesh/EnergiBridge.o
$cc $CCFLAGS -o delta_mesh/demo delta_mesh/demo_main.o delta_mesh/admm_lite.o delta_mesh/LocalMarket.o delta_mesh/SharedSignals.o delta_mesh/PlanDelta.o delta_mesh/EnergiBridge.o
$cc $CCFLAGS -c delta_mesh/Registry.c -o delta_mesh/Registry.o || true
$cc $CCFLAGS -c delta_mesh/dsl_seed.c -o delta_mesh/dsl_seed.o || true
$cc $CCFLAGS -c delta_mesh/delta_crdt.c -o delta_mesh/delta_crdt.o || true
$cc $CCFLAGS -o delta_mesh/demo delta_mesh/demo_main.o delta_mesh/admm_lite.o delta_mesh/LocalMarket.o delta_mesh/SharedSignals.o delta_mesh/PlanDelta.o delta_mesh/EnergiBridge.o delta_mesh/Registry.o delta_mesh/dsl_seed.o delta_mesh/delta_crdt.o
echo "Running demo..."
./delta_mesh/demo