This is a brilliant architectural leap. By using URIs to abstract the storage
and messaging layers, you are transforming the LPC engine from a
self-contained game server into a cloud-native, distributed microservice node.
The engine itself remains blissfully ignorant of databases or network
protocols. It simply passes a URI to a dispatcher, and the extensible plugins
handle the rest.
Here is how we can map this URI-driven architecture directly onto your
existing systems.
1. The Storage URIs: save_object() and restore_object()
Instead of hardcoding disk paths, the new system calls will parse the URI
scheme (file://, http://, kv://) and route the payload to the corresponding
plugin.
Because you already have a preemptive scheduler with a waitTable, we can make
HTTP REST saves appear synchronous to the LPC code while remaining completely
asynchronous to the Node.js host.
If a daemon calls save_object("[https://api.omega-mesh.fi/state/project-alpha](
https://api.omega-mesh.fi/state/project-alpha)"), the efun will:
* Serialize the object's stateArena using your existing vm.serialize_state(oid
) logic.
* Initiate a non-blocking fetch() POST request in Node.js.
* Immediately flag the context as WAITING_IO and suspend it to the wait
table, just like an empty read_mail() call.
* When the external HTTP promise resolves, the plugin pushes the context back
into the runQueue, waking the virtual CPU exactly where it left off.
2. The Pub/Sub URIs: broadcast_object() and subscribe_object()
You already have the foundation for this in your plugins/available/irc_mesh/ind
ex.js. Currently, it uses a hardcoded mesh_announce efun. We can replace this
with a dynamic URI dispatcher.
When an object calls subscribe_object("irc://hauki:16667/#genesis-planning"):
* The VM routes the URI scheme (irc://) to the IRC Plugin.
* The plugin joins the channel and maps the channel name to the requesting
OID.
* Whenever a message arrives in that IRC channel, the plugin wraps it in a
tagged array and calls your existing this.engine.deliverMail(oid,
taggedArray), waking the object to process the chat.
When it calls broadcast_object("irc://hauki:16667/#genesis-planning", "Let's
iterate on the AST."):
* The plugin intercepts the call and fires a PRIVMSG out to the channel.
The Collaborative Roundtable (LPC Implementation)
With these efuns in place, the 4-Tier Collaborative Hierarchy (Ideation,
Planning, Orchestration, Execution) becomes trivial to implement.
A "Chair" daemon managing a planning session would look like this in LPC:
string project_uri = "https://api.omega-mesh.fi/state/genesis-room-1";
string channel_uri = "irc://127.0.0.1:16667/#genesis-planning";
void start_roundtable() {
// 1. Load the current project state from the REST API
restore_object(project_uri);
// 2. Hook into the chat mesh
subscribe_object(channel_uri);
broadcast_object(channel_uri, "Roundtable initialized. Awaiting
input...");
while(1) {
// 3. Sleep at 0% CPU until a human or AI posts to the mesh
int *payload = read_mail();
if (payload != 0) {
string sender = payload[0];
string message = payload[1];
// 4. Process input (e.g., AI suggests a code change)
process_vote_or_idea(sender, message);
// 5. Instantly checkpoint the new consensus to the REST edge
save_object(project_uri);
}
}
}
Implementing the URI Dispatcher
To make this work, we need to build a URI Scheme Registry into your
PluginManager.
Currently, plugins manually register individual sys calls (this.engine.register
Syscall). We would expand the PluginManager to allow plugins to register URI
prefixes:
* pluginManager.registerScheme('http://', RestPlugin)
* pluginManager.registerScheme('file://', VfsPlugin)
* pluginManager.registerScheme('irc://', IrcMeshPlugin)
When sys_save_object (Efun ID 54) is invoked, it simply reads the prefix,
finds the registered plugin, and hands off the execution context.
Would you like to build the URI Dispatcher in the PluginManager first, or
should we upgrade the existing irc_mesh plugin to support dynamic
subscribe_object routing?