Generate native core discovery from typed dispatch contracts

This commit is contained in:
Sausage
2026-11-02 00:10:34 +00:00
parent ee88adf6c6
commit facaf1d9b1
15 changed files with 702 additions and 98 deletions
+15 -1
View File
@@ -222,6 +222,7 @@ these areas fails.
/proc/
core/
PROTOCOL.md this file
discover.json generated core.rpc.discover document
graph.json plugins, imports, and the result of each check
graph.dot the same graph for Graphviz
locks.json held locks and waiting processes
@@ -389,6 +390,7 @@ At start, the core starts each service in `/config/boot.yaml`, in order:
| Method | Params | Result |
| --- | --- | --- |
| `core.rpc.discover` | none | generated OpenRPC 1.2 document for every native core method |
| `core.call` | `method`, `params`, `detach`? | the result of the method |
| `core.watch` | `path` | stays open; `armed`, then `changed` notifications (section 4) |
| `core.notify` | `name`, `params` | none (a notification) |
@@ -402,6 +404,17 @@ At start, the core starts each service in `/config/boot.yaml`, in order:
| `core.restart` | none | `{}`. With `SAUSAGE_LOOP=1`, schedule clean shutdown and exit code 75. |
| `core.exit` | none | Alias of `core.restart`: same supervisor gate, response, coalescing, and exit code 75. |
`core.rpc.discover` and `/proc/core/discover.json` expose the same document,
with unprefixed method names, just like a plugin's discovery document. The
core generates it from the parameter and result types used by its dispatch;
there is no separate JSON schema file to maintain. Copy the proc file to
`imports/core.json` and use `import!("core")` to get typed calls, including
`core::lock` and `core::log`. Dotted wire names become underscores in Rust
(`rpc.discover` becomes `rpc_discover`). Import checks recognize the native
core as a provider without requiring a `plugins/core` directory. Forwarded
results and discovery documents contain arbitrary JSON; other core results
are typed, including activation summaries and journal entries.
### Host restart
**HARD RULE: the mediator and all agents NEVER call `core.restart` without
@@ -472,7 +485,8 @@ imported method:
- There are no version numbers. This check replaces them.
- The check covers a fixed subset of JSON Schema: objects with `properties`
and `required`, the primitive types, arrays, optional and nullable values,
string enums, integer ranges, and `$ref`. A construct outside the subset
string enums, integer ranges, typed dictionaries (`additionalProperties`
with a value schema), and `$ref`. A construct outside the subset
fails the check.
- The check covers calls, not state. Old and new processes share the files in
`/state`, and `core.revert` restores only code. A plugin must keep its