model

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	EffectRead    = "read"
	EffectWrite   = "write"
	EffectOutward = "outward"
)

The 3 effects, as the manifest writes them.

View Source
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

func Build(gen *protogen.Plugin) (*App, error)

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).

func BuildGo

func BuildGo(gen *protogen.Plugin) (*App, error)

BuildGo builds the app's model for a Go plugin: it is Build, and it ignores the standard parameters that a protoc-gen-go run sends beside hearth's own (see ParseGoParams), so that 1 buf template runs the manifest plugin and the Go plugins together.

func (*App) Manifest

func (a *App) Manifest() *manifest.Manifest

Manifest builds the app's manifest from the model.

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

func ParseGoParams(parameters string) (Params, error)

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

func ParseParams(parameters string) (Params, error)

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.

type Selector

type Selector struct {
	// Field is the dotted path of proto field names.
	Field string
	// Selector is the selector's name.
	Selector string
}

Selector is 1 request field that carries a selector value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL