protocol

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package protocol defines the JSON request/response envelopes exchanged inside Noise payloads (PRD 24) and the mapping from domain errors to wire codes. Internal error text never crosses the daemon boundary.

Index

Constants

View Source
const (
	CodeVaultLocked   = "VAULT_LOCKED"
	CodeAuthFailed    = "AUTH_FAILED"
	CodeNotFound      = "NOT_FOUND"
	CodeDenied        = "DENIED"
	CodeIntegrity     = "INTEGRITY_FAILURE"
	CodeConflict      = "CONFLICT"
	CodeInvalid       = "INVALID_REQUEST"
	CodeRateLimited   = "RATE_LIMITED"
	CodeExists        = "ALREADY_EXISTS"
	CodeUninitialized = "NOT_INITIALIZED"
	CodeWeakPassword  = "WEAK_PASSWORD"
	CodeInternal      = "INTERNAL"
)

Error codes (PRD 14.4 maps these to CLI exit codes).

View Source
const Version = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	ProtocolVersion int             `json:"protocolVersion"`
	RequestID       string          `json:"requestId"`
	Operation       string          `json:"operation"`
	Payload         json.RawMessage `json:"payload,omitempty"`
}

type Response

type Response struct {
	ProtocolVersion int             `json:"protocolVersion"`
	RequestID       string          `json:"requestId"`
	OK              bool            `json:"ok"`
	Data            json.RawMessage `json:"data,omitempty"`
	Error           *WireError      `json:"error,omitempty"`
}

func ErrResponse

func ErrResponse(requestID string, err error) *Response

ErrResponse builds a failure envelope from any error.

func OKResponse

func OKResponse(requestID string, data any) (*Response, error)

OKResponse builds a success envelope; data must marshal cleanly.

type WireError

type WireError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func MapError

func MapError(err error) *WireError

MapError converts any error into a wire error with a fixed, non-sensitive message.

Jump to

Keyboard shortcuts

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