protoschema

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package protoschema generates a JSON Schema describing the vix daemon⇄client wire protocol by reflecting over the payload structs registered in internal/protocol (protocol.EventTypes / protocol.CommandTypes).

The generated schema is the machine-readable contract that downstream clients (e.g. the native macOS app under apps/vix-mac) consume to stay in lockstep with the Go structs. cmd/protoschema writes it to internal/protocol/schema/vix-protocol.schema.json; a test in this package fails when the committed file drifts from the generator output.

Index

Constants

View Source
const SchemaURI = "https://json-schema.org/draft/2020-12/schema"

SchemaURI is the JSON Schema dialect the generated document declares.

Variables

This section is empty.

Functions

func Generate

func Generate() ([]byte, error)

Generate builds the full protocol schema and returns it as indented JSON with a trailing newline. Output is deterministic (encoding/json sorts map keys), so it is safe to diff against a committed golden file.

func GenerateSwift

func GenerateSwift() ([]byte, error)

GenerateSwift emits Swift `Codable` structs for every type in the protocol schema's $defs, derived from the same buildDoc() walk as the JSON schema. The output is a single self-contained file that depends only on the hand-written JSONValue support type (Sources/VixProtocol/JSONValue.swift) and Foundation.

The Go structs → schema → Swift chain is fully mechanical: a committed-file drift test on both outputs keeps the Swift models in lockstep with the daemon.

func ValidateCommand

func ValidateCommand(discriminator string, data any) error

ValidateCommand is the client→daemon analog of ValidateEvent.

func ValidateEvent

func ValidateEvent(discriminator string, data any) error

ValidateEvent checks that a daemon→client event's data payload conforms to the generated schema for its discriminator. A nil data (payload-less event such as event.agent_done) is accepted only for events registered without a payload.

func ValidateRPC

func ValidateRPC(typeName string, data any) error

ValidateRPC checks that an RPC projection value (keyed by type name, e.g. "ThreadSummary") conforms to the generated schema.

Types

This section is empty.

Jump to

Keyboard shortcuts

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