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. It shows no type from internal/ in its API: it carries its own wire types.
Index ¶
- Constants
- func Socket() (string, error)
- type AddIn
- type ChangeOut
- type Client
- type Error
- type Event
- type EvidenceIn
- type EvidenceOut
- type IdeaOut
- type LandedOut
- type NeedOut
- type PlanOut
- type PlanSetIn
- type PlanShowIn
- type ProgressOut
- type PursuitOut
- type RepoIn
- type RevisionOut
- type RunAskIn
- type RunCallIn
- type RunCreateIn
- type RunFindingIn
- type RunOut
- type RunOutcomeIn
- type RunReportOut
- type RunResultIn
- type RunStateIn
- type SignalOut
- type SlugIn
- type SpendIn
- type SpendOut
- type SpendPerOut
- type StartIn
- type StopIn
- type WorkIn
- type WorkOut
Constants ¶
const ( Subprotocol = "physa.v1" // the WebSocket subprotocol both sides require Path = "/api" // the only HTTP path the engine answers, with GET SocketName = "engine.sock" )
const ( CodeBadRequest = "bad_request" CodeUnknownMethod = "unknown_method" CodeInternal = "internal" )
The codes an error reply carries.
Variables ¶
This section is empty.
Functions ¶
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 ChangeOut ¶ added in v0.0.41
type ChangeOut struct {
Name string `json:"name"`
Capability string `json:"capability"`
What string `json:"what"`
Acceptance []string `json:"acceptance"`
MustNot []string `json:"must_not"`
After []string `json:"after"`
}
ChangeOut is one planned change of a plan.
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 ¶
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 ¶
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.
type Error ¶
Error is the error a call replies with: a code from the list above and a message for a person.
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 []ChangeOut `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 RunAskIn ¶ added in v0.0.46
type RunAskIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
Question string `json:"question" desc:"What the harness asks."`
}
RunAskIn is run.ask's input.
type RunCallIn ¶ added in v0.0.46
type RunCallIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
Choice string `json:"choice" desc:"The call the harness made."`
Reason string `json:"reason" desc:"Why it made it."`
}
RunCallIn is run.call's input.
type RunCreateIn ¶ added in v0.0.46
type RunCreateIn 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's slug."`
Change string `json:"change" desc:"The planned change the run works on."`
Level int `json:"level" desc:"The run's level, 0 to 3."`
}
RunCreateIn is run.create's input.
type RunFindingIn ¶ added in v0.0.46
type RunFindingIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
Check string `json:"check" desc:"The check that found it."`
Level string `json:"level" desc:"The finding's level."`
Text string `json:"text" desc:"What was found."`
}
RunFindingIn is run.finding's input.
type RunOut ¶ added in v0.0.46
type RunOut struct {
ID int64 `json:"id" desc:"The run's id."`
Pursuit string `json:"pursuit" desc:"The pursuit's slug."`
Change string `json:"change" desc:"The planned change."`
PlanRevision int `json:"plan_revision" desc:"The plan's revision it was created from."`
Level int `json:"level" desc:"The run's level, 0 to 3."`
State string `` /* 129-byte string literal not displayed */
Branch string `json:"branch,omitempty" desc:"The branch of its work."`
Commit string `json:"commit,omitempty" desc:"The sha of its latest result."`
PR string `json:"pr,omitempty" desc:"The url of its pull request."`
EndReason string `json:"end_reason,omitempty" desc:"Why it ended in error, when given."`
StderrTail string `json:"stderr_tail,omitempty" desc:"The end of the harness's stderr."`
Started string `json:"started" desc:"When it started, RFC 3339 in UTC."`
Ended string `json:"ended,omitempty" desc:"When it ended, RFC 3339 in UTC; set by a result or an error, and left out until then."`
}
RunOut is a run.
type RunOutcomeIn ¶ added in v0.0.46
type RunOutcomeIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
Item int `json:"item" desc:"The acceptance item's place in the change's list, from 1."`
Verdict string `json:"verdict" desc:"passed, failed or judged."`
Commit string `json:"commit" desc:"The full sha the verdict is for."`
VouchedBy string `json:"vouched_by" desc:"Who vouches for the verdict; required."`
}
RunOutcomeIn is run.outcome's input.
type RunReportOut ¶ added in v0.0.46
type RunReportOut struct {
ID int64 `json:"id" desc:"The report's id."`
Stale bool `json:"stale" desc:"True for an outcome whose commit is not the run's latest result's."`
SaidBy string `json:"said_by,omitempty" desc:"harness, on a finding: the harness's word, never Physa's."`
}
RunReportOut is one thing a harness reported on a run.
type RunResultIn ¶ added in v0.0.46
type RunResultIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
Branch string `json:"branch" desc:"The branch the run's work is on."`
Commit string `json:"commit" desc:"The full sha of the run's latest commit."`
PR string `json:"pr" desc:"The url of the run's pull request."`
}
RunResultIn is run.result's input.
type RunStateIn ¶ added in v0.0.46
type RunStateIn struct {
Repo string `json:"repo" desc:"The repo, as an absolute path to it or to a directory inside it."`
Run int64 `json:"run" desc:"The run's id."`
State string `json:"state" desc:"working, blocked, done or error; only error ends the run."`
Reason string `json:"reason,omitempty" desc:"Why it ended in error; only with the state error."`
StderrTail string `json:"stderr_tail,omitempty" desc:"The end of the harness's stderr, kept to its last 4096 bytes."`
}
RunStateIn is run.state's input.
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.