feat: graph-level fanout — reuse flow UUID for same from_node+from_port

Edges that share the same source node and port now get the same MXL flow
UUID. One writer, multiple independent readers — each tracks its own
position in the ring buffer. Enables 1-to-N routing in graph.json without
any splitter node.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
JohannesItten
2026-07-03 10:43:41 +03:00
parent 2b0dfb10c6
commit a422cd832a
+12 -3
View File
@@ -6,8 +6,10 @@
#include <cstdlib>
#include <filesystem>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <fcntl.h>
#include <sys/wait.h>
@@ -62,11 +64,18 @@ static dmf::FlowGraph load_graph(const std::string& path) {
n.value("params", nlohmann::json::object())
});
}
// Edges sharing the same from_node+from_port reuse the same flow UUID,
// so one writer can be read by multiple consumers (MXL supports N readers per flow).
std::map<std::pair<std::string,std::string>, std::string> flow_ids;
for (const auto& e : j.at("edges")) {
auto from_node = e.at("from").get<std::string>();
auto from_port = e.at("from_port").get<std::string>();
auto key = std::make_pair(from_node, from_port);
if (!flow_ids.count(key)) flow_ids[key] = gen_uuid();
g.edges.push_back({
gen_uuid(),
e.at("from").get<std::string>(),
e.at("from_port").get<std::string>(),
flow_ids.at(key),
from_node,
from_port,
e.value("to", std::string{}),
e.value("to_port", std::string{}),
e.at("format")