client

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 2 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 client is the public way into the engine's local API, for views, harnesses and other programs outside Physa's module: it dials the engine's socket under the physa.v1 subprotocol, calls methods by name, receives the messages the engine sends of its own, and holds the input and output types of the methods for ideas, pursuits and evidence.

It imports nothing of the engine's store, forge or version control, so a program built on it stays small. The engine's API is typed with these same types, so a change to one is a change to the other.

Index

Constants

View Source
const (
	Subprotocol = "physa.v1" // the WebSocket subprotocol both sides require
	Path        = "/api"     // the only HTTP path the engine answers, with GET
	SocketName  = "engine.sock"
)
View Source
const (
	CodeBadRequest    = "bad_request"
	CodeUnknownMethod = "unknown_method"
	CodeInternal      = "internal"
)

The codes an error reply carries.

Variables

This section is empty.

Functions

func Socket

func Socket() (string, error)

Socket returns the path of the machine's engine socket: SocketName in Physa's settings directory. It does not check that an engine listens.

Types

type AddIn

type AddIn struct {
	Repo   string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Text   string `json:"text" desc:"The idea, in a few plain words."`
	Slug   string `json:"slug,omitempty" desc:"The slug to give it; made from the text when left out."`
	Person string `` /* 154-byte string literal not displayed */
}

AddIn is idea.add's input.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is one connection to the engine. Its methods may be called concurrently.

func Dial

func Dial(ctx context.Context, socketPath string) (*Client, error)

Dial connects to the engine listening on socketPath. ctx bounds the dial only, not the connection. An engine that does not answer under physa.v1 is closed and refused.

func (*Client) Call

func (c *Client) Call(ctx context.Context, method string, params, result any) error

Call calls method with params (nil means {}) and decodes its result into result (nil discards it). An error reply returns *Error. A closed connection returns an error wrapping the WebSocket close, so websocket.CloseStatus tells why it closed.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection with a normal closure and waits for the read loop to end. Closing a closed client returns nil.

func (*Client) Events

func (c *Client) Events() <-chan Event

Events returns the messages the engine sends of its own, in order. The channel holds 64; when it is full because nothing reads it, a new message is dropped. It closes when the connection does.

type Error

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

Error is the error a call replies with: a code from the list above and a message for a person.

func (*Error) Error

func (e *Error) Error() string

type Event

type Event struct {
	Name string
	Data json.RawMessage
}

Event is a message the engine sent of its own, not a reply.

type EvidenceIn

type EvidenceIn struct {
	Repo       string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Capability string `json:"capability,omitempty" desc:"Only facts for this capability's slug."`
	Pursuit    string `json:"pursuit,omitempty" desc:"Only facts for this pursuit's slug."`
	Limit      int    `json:"limit,omitempty" desc:"The most facts to return; 50 when left out, at most 500."`
}

EvidenceIn is evidence.list's input.

type EvidenceOut

type EvidenceOut struct {
	Kind       string `json:"kind" desc:"landed, reverted, lead_time, ci_passed, ci_failed or ci_passed_after_failing."`
	Commit     string `json:"commit,omitempty" desc:"The commit, as its first eight characters."`
	PR         int    `json:"pr,omitempty" desc:"The merged PR's number, for facts the forge showed."`
	Capability string `json:"capability,omitempty" desc:"The capability's slug, from the commit's Capability: trailer."`
	Pursuit    string `json:"pursuit,omitempty" desc:"The pursuit's slug, from the commit's Change: trailer."`
	Change     string `json:"change,omitempty" desc:"The planned change's name, from the commit's Change: trailer."`
	Idea       string `json:"idea,omitempty" desc:"The slug of the pursuit's idea."`
	At         string `json:"at" desc:"When it was observed to happen, RFC 3339 in UTC."`
	Source     string `json:"source" desc:"vcs or forge."`
	Seconds    *int64 `json:"seconds,omitempty" desc:"The lead time in seconds; set only for lead_time."`
	ByCommit   string `json:"by_commit,omitempty" desc:"For reverted, the revert's commit, as its first eight characters."`
}

EvidenceOut is one observed fact.

type IdeaOut

type IdeaOut struct {
	Slug         string       `json:"slug" desc:"The idea's slug."`
	Text         string       `json:"text" desc:"The idea."`
	Person       string       `json:"person" desc:"Who added it."`
	CreatedAt    string       `json:"created_at" desc:"When it was added, RFC 3339 in UTC."`
	Pursuit      string       `json:"pursuit,omitempty" desc:"The slug of its latest pursuit; left out when it has none."`
	PursuitState string       `json:"pursuit_state,omitempty" desc:"The state of its latest pursuit: active, done or stopped."`
	Pursuits     []PursuitOut `json:"pursuits,omitempty" desc:"Its pursuits, newest first; set by idea.show."`
}

IdeaOut is an idea and its facts. Pursuits is set only where the method says so.

type LandedOut

type LandedOut struct {
	Change string `json:"change" desc:"The change's name."`
	Commit string `json:"commit" desc:"The commit where it first landed on the default branch."`
	At     string `json:"at" desc:"When, RFC 3339 in UTC."`
}

LandedOut is a planned change that landed.

type NeedOut

type NeedOut struct {
	Kind string `json:"kind" desc:"appetite or breaker."`
	Text string `json:"text" desc:"What the person needs to know."`
	At   string `json:"at" desc:"When it was raised, RFC 3339 in UTC."`
}

NeedOut is an open Needs you item.

type PlanOut

type PlanOut struct {
	Pursuit string        `json:"pursuit" desc:"The pursuit."`
	N       int           `json:"n" desc:"The current revision's number."`
	Replans int           `json:"replans" desc:"How many times the plan was revised after the first."`
	Reason  string        `json:"reason,omitempty" desc:"Why the current revision was made; empty for the first."`
	Person  string        `json:"person" desc:"Who set the current revision."`
	At      string        `json:"at" desc:"When, RFC 3339 in UTC."`
	Changes []plan.Change `json:"changes" desc:"The planned changes."`
	History []RevisionOut `json:"history,omitempty" desc:"Every revision, oldest first; set when asked for."`
}

PlanOut is a pursuit's current plan.

type PlanSetIn

type PlanSetIn struct {
	Repo    string          `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Pursuit string          `json:"pursuit" desc:"The pursuit the plan is for."`
	Reason  string          `json:"reason,omitempty" desc:"Why the plan is revised: what the plan missed. Required from the second revision on."`
	Person  string          `json:"person" desc:"Who sets the plan."`
	Plan    json.RawMessage `` /* 133-byte string literal not displayed */
}

PlanSetIn is plan.set's input.

type PlanShowIn

type PlanShowIn struct {
	Repo    string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Pursuit string `json:"pursuit" desc:"The pursuit whose plan to show."`
	History bool   `json:"history,omitempty" desc:"Also return every revision, oldest first."`
}

PlanShowIn is plan.show's input.

type ProgressOut

type ProgressOut struct {
	Planned   []string      `json:"planned" desc:"The planned changes, in plan order."`
	Landed    []LandedOut   `json:"landed" desc:"The planned changes that landed on the default branch."`
	InWork    []string      `json:"in_work" desc:"Planned changes not landed that a session works on."`
	AsksOpen  int           `json:"asks_open" desc:"Asks open on the pursuit."`
	Spent     int64         `json:"spent" desc:"Tokens spent."`
	Appetite  int64         `json:"appetite,omitempty" desc:"The appetite in tokens; left out when the pursuit has none."`
	Replans   int           `json:"replans" desc:"How many times the plan was revised."`
	PerChange []SpendPerOut `json:"per_change" desc:"Spend per change, largest first."`
}

ProgressOut is a pursuit's progress as facts, never one number.

type PursuitOut

type PursuitOut struct {
	Slug       string        `json:"slug" desc:"The pursuit's slug."`
	Idea       string        `json:"idea" desc:"The slug of the idea it pursues."`
	IdeaText   string        `json:"idea_text" desc:"The idea."`
	Person     string        `json:"person" desc:"The person who started the pursuit."`
	Appetite   int64         `json:"appetite,omitempty" desc:"The appetite in tokens; left out when it has none."`
	Spent      int64         `json:"spent" desc:"The tokens spent so far."`
	State      string        `json:"state" desc:"active, done or stopped."`
	StopReason string        `json:"stop_reason,omitempty" desc:"Why it stopped; left out unless it did."`
	CreatedAt  string        `json:"created_at" desc:"When it was started, RFC 3339 in UTC."`
	StartedAt  string        `json:"started_at,omitempty" desc:"When it started, RFC 3339 in UTC."`
	EndedAt    string        `json:"ended_at,omitempty" desc:"When it ended, RFC 3339 in UTC; left out while active."`
	Signal     *SignalOut    `json:"signal,omitempty" desc:"The signal it is read against; left out for a pursuit started before signals."`
	Progress   *ProgressOut  `json:"progress,omitempty" desc:"Its progress as facts; set by pursuit.show."`
	Evidence   []EvidenceOut `json:"evidence,omitempty" desc:"The facts observed for the pursuit, newest first, at most 50; set by pursuit.show."`
	NeedsYou   []NeedOut     `json:"needs_you,omitempty" desc:"Its open Needs you items, newest first; set by pursuit.show."`
}

PursuitOut is a pursuit. Signal is set only by pursuit.show, pursuit.start and pursuit.stop, and left out for a pursuit started before signals.

type RepoIn

type RepoIn struct {
	Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
}

RepoIn is the input of the methods that list: the repo to read.

type RevisionOut

type RevisionOut struct {
	N       int      `json:"n" desc:"The revision's number, from 1."`
	Reason  string   `json:"reason,omitempty" desc:"Why it was revised; empty for the first."`
	Person  string   `json:"person" desc:"Who set it."`
	At      string   `json:"at" desc:"When, RFC 3339 in UTC."`
	Changes []string `json:"changes" desc:"The names of its changes."`
}

RevisionOut is one revision of a plan.

type SignalOut

type SignalOut struct {
	Claim    string `json:"claim" desc:"What should change, in the team's words."`
	For      string `json:"for" desc:"What counts as for the claim."`
	Against  string `json:"against" desc:"What counts as against it."`
	Window   string `json:"window" desc:"When it is read: a date, YYYY-MM-DD, today or later when the pursuit starts."`
	Resolver string `json:"resolver" desc:"Who or what reports the result: a named person, or a named check."`
}

SignalOut is a pursuit's signal, in its four parts.

type SlugIn

type SlugIn struct {
	Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Slug string `json:"slug" desc:"The idea's or pursuit's slug."`
}

SlugIn is the input of the methods that show one idea or pursuit.

type SpendIn

type SpendIn struct {
	Repo    string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Pursuit string `json:"pursuit" desc:"The pursuit the tokens were spent on."`
	Change  string `json:"change,omitempty" desc:"The planned change they were spent on; left out for the pursuit itself."`
	Session string `json:"session" desc:"The session's id."`
	Tokens  int64  `json:"tokens" desc:"The session's running total of tokens on this pursuit and change, not an increase."`
}

SpendIn is pursuit.spend's input.

type SpendOut

type SpendOut struct {
	Spent    int64  `json:"spent" desc:"The tokens the pursuit has spent."`
	Appetite int64  `json:"appetite,omitempty" desc:"The pursuit's appetite in tokens, left out when it has none; it is never raised."`
	State    string `json:"state" desc:"active, done or stopped."`
	Warned   bool   `json:"warned" desc:"True when this report raised the notice at 80% of the appetite."`
	Broke    bool   `json:"broke" desc:"True when this report made the circuit breaker stop the pursuit."`
}

SpendOut is pursuit.spend's output.

type SpendPerOut

type SpendPerOut struct {
	Change string `json:"change" desc:"The change's name; empty for the pursuit itself."`
	Tokens int64  `json:"tokens" desc:"The tokens spent."`
}

SpendPerOut is the tokens spent on one change.

type StartIn

type StartIn struct {
	Repo     string    `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Slug     string    `json:"slug" desc:"The idea to pursue."`
	Appetite string    `json:"appetite,omitempty" desc:"The appetite in tokens, such as 200k or 1.5m; left out for none, with no circuit breaker."`
	Signal   SignalOut `json:"signal" desc:"The signal the pursuit is read against; every part is required."`
	Person   string    `json:"person" desc:"The person who starts the pursuit."`
}

StartIn is pursuit.start's input.

type StopIn

type StopIn struct {
	Repo   string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Slug   string `json:"slug" desc:"The pursuit to stop."`
	Reason string `json:"reason,omitempty" desc:"Why it stops; \"stopped by <person>\" when left out."`
	Person string `json:"person" desc:"The person who stops the pursuit."`
}

StopIn is pursuit.stop's input.

type WorkIn

type WorkIn struct {
	Repo    string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
	Pursuit string `json:"pursuit" desc:"The pursuit."`
	Change  string `json:"change" desc:"The planned change the session works on."`
	Session string `json:"session" desc:"The session's id."`
}

WorkIn is pursuit.work's input.

type WorkOut

type WorkOut struct {
	Pursuit string `json:"pursuit" desc:"The pursuit."`
	Change  string `json:"change" desc:"The change the session now works on."`
}

WorkOut is pursuit.work's output.

Jump to

Keyboard shortcuts

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