Documentation
¶
Overview ¶
Package model builds an app's model from the Protobuf files that a hearth plugin is asked to generate, and checks every rule of docs/specs/options.md.
Every plugin of hearth (the manifest, and the MCP, permission and event plugins of later tasks) shares this model: 1 service gives an app its operations, its capabilities, its selectors and its events.
Index ¶
Constants ¶
const ( EffectRead = "read" EffectWrite = "write" EffectOutward = "outward" )
The 3 effects, as the manifest writes them.
const ( ExposeUI = "ui" ExposeAgent = "agent" )
The 2 exposures, as the manifest writes them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// ID is the app's id: the plugin's app parameter.
ID string
// Version is the app's semantic version: the plugin's version parameter.
Version string
// Operations are the app's RPCs, sorted by full name.
Operations []Operation
// Events are the app's events, sorted by type.
Events []Event
// Capabilities are every capability of the operations and events, sorted
// and without a repeat.
Capabilities []string
// Selectors are every selector name of the operations and events, sorted
// and without a repeat.
Selectors []string
}
App is the model of 1 app, built from the Protobuf files of a plugin run.
func Build ¶
Build builds the app's model from the files of gen that are marked for generation, and checks every rule. It reports every problem it finds, 1 line each, sorted, and each line prefixed with the full name of its element. It reads the parameters of a hearth plugin (see ParseParams).
type Event ¶
type Event struct {
// Message describes the message that carries the event.
Message protoreflect.MessageDescriptor
// Type is the event's CloudEvents type.
Type string
// Topic is the broker topic.
Topic string
// Selector is the selector whose value the event carries, or "".
Selector string
// ReadPermission is the capability a consumer needs to read the event.
ReadPermission string
}
Event is 1 event that an RPC of the app publishes.
type Operation ¶
type Operation struct {
// Method describes the RPC.
Method protoreflect.MethodDescriptor
// Name is the RPC's full name.
Name string
// Permission is the capability the call needs.
Permission string
// Effect is "read", "write" or "outward".
Effect string
// Expose is where the RPC is reachable: "ui", "agent", or both.
Expose []string
// Selectors are the request fields that carry a selector value.
Selectors []Selector
// ObjectIDs are the request fields that carry an object id, as dotted
// paths of proto field names, or none. An RPC with at least 1 is an RPC on
// an object id: its permission check needs a hook that reads the stored
// object's selector value. Object ids are not in the manifest.
ObjectIDs []string
// Tool is the RPC's MCP tool name, or "" when agents do not reach it.
Tool string
// AgentDescription tells an agent when to call the RPC.
AgentDescription string
// Examples are request examples in the proto3 JSON form.
Examples []string
}
Operation is 1 RPC of the app's service.
type Params ¶
type Params struct {
// App is the app's id.
App string
// Version is the app's semantic version.
Version string
}
Params are the parameters of a hearth plugin.
func ParseGoParams ¶
ParseGoParams reads the parameters of a Go plugin: hearth's app and version, and the standard parameters that a protoc-gen-go run sends beside them: paths=import|source_relative, module=<path>, annotate_code[=true|false] and M<file>=<package>. A Go plugin ignores those, and it refuses every other parameter as ParseParams does.
func ParseParams ¶
ParseParams reads the plugin's parameters: "app=<id>,version=<major.minor.patch>". It refuses a missing or malformed app or version, and any other parameter. It reports every problem it finds, 1 line each, sorted.