The options¶
An app on hearth writes 1 Protobuf service, and annotates it with hearth's options. The plugins read those annotations, so the app's permissions, its MCP tools, its events and its manifest all come from 1 set of files.
The options live in frostyard/hearth/v1/options.proto, and every app imports
it:
syntax = "proto3";
package frostyard.frostmarks.v1;
import "frostyard/hearth/v1/options.proto";
option go_package = "example.com/frostmarks/gen/v1;marksv1";
The 3 options¶
| Option | On | What it declares |
|---|---|---|
hearth_rpc |
a method | the RPC's permission, effect, exposure, agent description and examples |
hearth_selector |
a field | the selector name that the field carries |
hearth_event |
a message | the event's object, verb, selector and read permission |
The extension numbers 51370 to 51379 are hearth's in-house range until the Protobuf global extension registry grants a number.
Annotate an RPC¶
Every method needs hearth_rpc:
service Marks {
rpc ListBookmarks(ListBookmarksRequest) returns (ListBookmarksResponse) {
option (frostyard.hearth.v1.hearth_rpc) = {
permission: "marks:read"
effect: EFFECT_READ
expose: EXPOSE_UI
expose: EXPOSE_AGENT
agent_description: "List the bookmarks of a folder."
examples: "{\"folder\": {\"name\": \"/reading\"}}"
};
}
}
permissionis the capability the call needs, as<app>:<capability>. The app part is the plugin'sappparameter.effectisEFFECT_READfor a call that changes nothing,EFFECT_WRITEfor a change that can be undone, andEFFECT_OUTWARDfor an irreversible change or one that leaves the system.exposelists where the RPC is reachable:EXPOSE_UIfor the app's own user interface,EXPOSE_AGENTfor an MCP tool. At least 1 is required.agent_descriptiontells an agent when to call the tool.examplesholds request examples, each a JSON object in the proto3 JSON form of the request.
An agent RPC¶
An RPC that agents reach must be a faithful tool: not streaming, and its
request and response messages carry neither google.protobuf.Any nor a map of
messages. Follow the messages your RPC names, and keep the tool's input and
output plain.
A UI-only RPC may carry Any, because no agent sees its schema.
Selectors¶
A request field that names a selector carries hearth_selector:
The field must be a singular string. hearth finds it through the request's
singular message fields, so folder.name in this request is the selector
folder:
A selector must be on a path of singular fields. A map value or a repeated message has no single value for the permission check to read, so generation fails when a selector field sits inside 1 of them:
message ListBookmarksRequest {
// Generation fails: the selector is inside a map value.
map<string, FolderRef> folders = 1;
}
Declare an event¶
An event is 1 message with hearth_event:
message BookmarkCreated {
option (frostyard.hearth.v1.hearth_event) = {
object: "bookmark"
verb: "created"
selector: "folder"
read_permission: "marks:read"
};
string id = 1;
}
The event's type is org.frostyard.<app>.<object>.<verb>, and its topic is
<app>.<object>.<verb>, plus .<selector> when it carries 1.
A read permission that a selector scopes must be on the topic of every event
that names it. Here, marks:read is scoped by the selector folder (1 RPC
carries it), so an event with read_permission: "marks:read" must carry
selector: "folder". An event whose read permission no RPC scopes may carry a
selector, or none.
Generate¶
Run the plugin from buf:
# buf.gen.yaml
version: v2
plugins:
- local: protoc-gen-hearth-manifest
out: gen
opt:
- app=marks
- version=0.1.0
- local: protoc-gen-go
out: gen/go
opt:
- paths=source_relative
- local: protoc-gen-hearth-authz
out: gen/go
opt:
- paths=source_relative
- app=marks
- version=0.1.0
- local: protoc-gen-hearth-mcp
out: gen/go
opt:
- paths=source_relative
- app=marks
- version=0.1.0
The manifest plugin writes gen/manifest.json. When a rule fails, it writes
nothing and prints 1 line for each problem; buf shows the lines and exits with
an error.
The 2 Go plugins write <file>_hearth_authz.go and <file>_hearth_mcp.go beside
the Go code that protoc-gen-go writes. buf sends them the standard
parameters of a Go plugin (paths, module, annotate_code, M<file>), and
they ignore those. Read the permissions guide and
the MCP guide for the code they write.
The plugin declares the proto3 optional feature, so a message may use an
optional field. Without that declaration, protoc and buf refuse the plugin
for a file that holds 1.
Look up every member of the file it writes in the manifest format.