Documentation
¶
Overview ¶
Package humanapi is the broker's human listener, :8080, reached only through oauth2-proxy (§3): the UI, the room list, and one WebSocket per open room. Every API and WebSocket request is authenticated and admitted by group first; a room's reads then go through admits (D7: the caller can read the room's repository on GitHub) and policy.Allowed. The UI's static files are not: oauth2-proxy fronts the listener. Live events come from the fan-out hub.
Index ¶
- Constants
- func CataloguePolicy(cat *CatalogueCache, p authn.Principal, onBehalfOf string) coordination.ResolvePolicy
- func ClassPolicy(classes map[string]intake.Class) coordination.ResolvePolicy
- type ActLog
- type Action
- type Actor
- type Authenticator
- type CatalogueCache
- type CatalogueReads
- type CatalogueSource
- type CoordinationGateway
- type CoordinationPlanner
- type CoordinationViews
- type Dashboard
- type GitHubLinkStore
- type GitHubLinker
- type GitHubOAuth
- type GrantStore
- type HandoffStartRecorder
- type HandoffStore
- type Hub
- type Intake
- type IntentClassifier
- type IntentModel
- type IntentSamples
- type IssueStarter
- type Log
- type Policy
- type PolicyGateway
- type PolicyRecords
- type Redactor
- type Runs
- type ScreenshotReader
- type Server
- type SlackAct
- type SlackActor
- type SlackAnswer
- type SlackDecideStore
- type SlackDecider
- type SlackDecision
- type SlackLinkFinder
- type SlackLinkStore
- type SlackLinker
- type SponsoredAuthenticator
- type StagesSource
- type StartIssueRequest
- type StartIssueResult
- type TaskActor
- type TaskAnswerer
- type TaskCanceller
- type TaskCreator
- type TaskPlanner
- type TaskRetrier
- type TaskSplitter
- type WorkflowChoice
Constants ¶
const ( GitHubLinkPath = "/link/github" GitHubCallbackPath = "/link/github/callback" )
The link's paths. The callback is the one unauthenticated /link/ route, and the path oauth2-proxy's skip-auth-route names (GET=^/link/github/callback$): it is stable.
const ( ViaWeb = "web" ViaRoomctl = "roomctl" ViaMCP = "mcp" )
The clients a human's act comes through (factory interfaces F8). Only the web UI's standing may steer and decide (ruling P18), and only its text is stored as typed: a local agent can drive maku and the MCP server on its human's token.
const ExceptionLifetime = 14 * 24 * time.Hour
ExceptionLifetime is how long an approved exception may carry a promotion.
const ForkedFrom = roomctrl.ForkedFrom
ForkedFrom annotates a forked Room with <source room>@<seq>; roomctrl owns it, since the Room's task status must skip the copied prefix.
const GitHubLinkTTL = 10 * time.Minute
GitHubLinkTTL is how long a flow may run, from the start to the confirm.
const SlackLinkTTL = 10 * time.Minute
SlackLinkTTL is how long a code may be confirmed.
Variables ¶
This section is empty.
Functions ¶
func CataloguePolicy ¶ added in v0.52.0
func CataloguePolicy(cat *CatalogueCache, p authn.Principal, onBehalfOf string) coordination.ResolvePolicy
CataloguePolicy is the broker's ResolvePolicy over the factory's catalogue, read as p for onBehalfOf (WF13): a class the repository offers, with the roles of the repository's default workflow (WF3) without the scoper, and the class's ceiling as the task ceiling, one run priced at a tenth of it. A class the catalogue does not offer is coordination.ErrUnknownClass.
func ClassPolicy ¶ added in v0.38.0
func ClassPolicy(classes map[string]intake.Class) coordination.ResolvePolicy
ClassPolicy is the broker's ResolvePolicy over the intake class table: a class's roles (without the scoper) and its ceiling as the task ceiling, one run priced at a tenth of it. A class the table does not define is coordination.ErrUnknownClass. It reads no repository: every repository resolves the same table, and the factory holds each child to its own repository's policy later.
Types ¶
type ActLog ¶
type ActLog interface {
Room(ctx context.Context, id string) (store.RoomState, error)
Append(ctx context.Context, d envelope.Draft) (envelope.Event, bool, error)
AppendAsDriver(ctx context.Context, driver string, epoch int64, d envelope.Draft) (envelope.Event, bool, error)
Enqueue(ctx context.Context, d envelope.Draft, author, text string) (envelope.Event, error)
PromoteQueued(ctx context.Context, roomID string, ref int64, driver string, epoch int64, runID string, d envelope.Draft) (envelope.Event, error)
RemoveQueued(ctx context.Context, roomID string, ref int64, d envelope.Draft) (envelope.Event, error)
ChangeDriver(ctx context.Context, roomID string, expect int64, to, reason string, d envelope.Draft) (envelope.Event, bool, error)
DriverSeen(ctx context.Context, roomID, principal string, acted bool) error
CloseRoom(ctx context.Context, roomID, reason string) error
// start_run checks for a pending run, reads the brief's sources, then records
// the run with what it consumed.
PendingRuns(ctx context.Context, roomID string, within time.Duration) ([]string, error)
BriefSources(ctx context.Context, roomID string) ([]envelope.Event, error)
Queue(ctx context.Context, roomID string) ([]store.Queued, error)
Stored(ctx context.Context, d envelope.Draft) (envelope.Event, bool, error)
RecordRunRequest(ctx context.Context, d envelope.Draft, runID string, refs []int64, fields map[string]any) (envelope.Event, error)
// decide reads the approval, then records the first valid decision (phase 5).
Approval(ctx context.Context, id string) (store.Approval, error)
Decide(ctx context.Context, approvalID, decision, by, reason string, d envelope.Draft) (envelope.Event, store.Approval, error)
// fork reads the commit at its seq, then copies the prefix (phase 6); a
// forked room's start_run reads its forked_from for the brief.
BriefSourcesThrough(ctx context.Context, roomID string, seq int64) ([]envelope.Event, error)
Fork(ctx context.Context, src string, upTo int64, r store.NewRoom, d envelope.Draft, fields map[string]any) (envelope.Event, error)
Range(ctx context.Context, roomID string, afterSeq int64, limit int) ([]envelope.Event, error)
}
ActLog is the part of the store the actions write; *store.Store implements it.
type Action ¶
type Action struct {
Kind string `json:"kind"`
Text string `json:"text,omitempty"`
Delivery string `json:"delivery,omitempty"`
Ref int64 `json:"ref,omitempty"`
To string `json:"to,omitempty"`
Reason string `json:"reason,omitempty"`
Role string `json:"role,omitempty"`
PRURL string `json:"prUrl,omitempty"`
EgressProfiles []string `json:"egressProfiles,omitempty"`
Principal string `json:"principal,omitempty"` // invite
MemberRole string `json:"memberRole,omitempty"` // invite
Approver bool `json:"approver,omitempty"` // invite
ApprovalID string `json:"approvalId,omitempty"` // decide
Decision string `json:"decision,omitempty"` // decide: approved | denied
Seq int64 `json:"seq,omitempty"` // fork: the last event copied
Note string `json:"note,omitempty"` // fork
Approvals string `json:"approvals,omitempty"` // fork: attended (the default) | unattended
Discard bool `json:"discard,omitempty"` // cancel: also close the PR, the branch and the issue
Deeper bool `json:"deeper,omitempty"` // retry: step up once to the next workflow (WR4)
}
Action is an act frame's action (docs/api.md, Actions).
type Actor ¶
type Actor struct {
Log ActLog
Groups policy.Groups
Runs Runs
Redactor Redactor
Rooms client.Client
Requester runrequest.Requester
// Cancels is the factory's cancel and discard of the room's task (#644); nil refuses both.
Cancels TaskCanceller
// Retries is the factory's retry (plain or deeper) of the room's task (WR4); nil refuses both.
Retries TaskRetrier
// Answers, Splits, and Plans reach the factory's task-act routes with the caller's own token
// (phase G1); nil falls back to type-asserting Cancels (runrequest.Factory implements all of
// them) and refuses with factory_unavailable when absent.
Answers TaskAnswerer
Splits TaskSplitter
Plans TaskPlanner
// RoomActs is human.roomActs (phase G): the room act kinds enabled on this broker, among
// answer, retry, split, plan, file, stop. Nil takes config.DefaultRoomActs ([answer, retry]);
// a non-nil empty slice disables all gated room acts.
RoomActs []string
OnReject func(ctx context.Context, reason string)
// OnDecided observes a human decision's wait since its request
// (rooms_approval_decision_seconds).
OnDecided func(time.Duration)
// Now is the clock OnDecided's wait is measured on; nil means time.Now. Server.Routes
// hands it the Server's own when this one is unset.
Now func() time.Time
// Logger records one line per act, accepted or refused (nil: none).
Logger *slog.Logger
// Writes reports whether p may write room's repository on GitHub: a digest-bound approval
// (hardening HR28) is decided only with that standing, as Slack's step 10 asks. Server.Routes
// hands it the Server's Identity and Access when this one is unset; nil refuses every
// digest-bound decision.
Writes func(ctx context.Context, room *v1alpha1.Room, p authn.Principal) (bool, error)
// contains filtered or unexported fields
}
Actor serves humans' act frames: every write a human makes to a room. Log, Groups, Runs and Redactor are required; Rooms is required for invite and new rooms, Requester for start_run.
func (*Actor) Handle ¶
func (a *Actor) Handle(ctx context.Context, p authn.Principal, webUI bool, session string, room *v1alpha1.Room, f wire.ClientFrame) wire.ServerFrame
Handle serves one act frame of p in room, through the web UI or maku (ruling P18), on the connection session, and returns its ack.
func (*Actor) HandleVia ¶
func (a *Actor) HandleVia(ctx context.Context, p authn.Principal, via, session string, room *v1alpha1.Room, f wire.ClientFrame) (out wire.ServerFrame)
HandleVia is Handle for an act that came through via: ViaWeb, ViaRoomctl or ViaMCP. Only the web UI's standing may steer and decide (P18), and only its text is stored as typed (F8).
type Authenticator ¶
Authenticator maps a request to a human principal; *authn.Humans implements it, Origin check included. authn.ErrForbidden means a foreign Origin.
type CatalogueCache ¶ added in v0.45.0
type CatalogueCache struct {
// contains filtered or unexported fields
}
CatalogueCache reads a repository's catalogue from the factory and keeps each answer for a minute, per repository and per caller: the answer carries the caller's own maintainer flag, so one caller's is never served to another (P18). It holds at most 256 answers, dropping the least recently used. An error is never cached.
func NewCatalogueCache ¶ added in v0.45.0
func NewCatalogueCache(src CatalogueSource, reads CatalogueReads, now func() time.Time) *CatalogueCache
NewCatalogueCache is a cache over src. reads and now may be nil: no counting, the wall clock.
func (*CatalogueCache) Get ¶ added in v0.45.0
func (c *CatalogueCache) Get(ctx context.Context, p authn.Principal, repository, onBehalfOf string) (catalogue.Catalogue, error)
Get is repository's catalogue for p. A factory refusal comes back as the runrequest.ErrRefused it is; every other failure is errCatalogueUnavailable.
func (*CatalogueCache) Repositories ¶ added in v0.53.0
Repositories is the factory's served repository list for p, cached for catalogueTTL (WF12). No stale list older than the cache's lifetime is ever returned.
type CatalogueReads ¶ added in v0.45.0
CatalogueReads counts a read by outcome; *metrics.Set implements it.
type CatalogueSource ¶ added in v0.45.0
type CatalogueSource interface {
Catalogue(ctx context.Context, accessToken, repository, onBehalfOf string) (catalogue.Catalogue, error)
Repositories(ctx context.Context, accessToken string) ([]string, error)
}
CatalogueSource is the factory's catalogue route as the broker reads it, with the caller's own token; runrequest.Factory implements it.
type CoordinationGateway ¶ added in v0.39.0
type CoordinationGateway interface {
CoordinationDraft(ctx context.Context, accessToken, parent string, in coordination.CoordinationConfirmation, onBehalfOf string) (coordination.CoordinationConfirmation, error)
CoordinationConfirm(ctx context.Context, accessToken, parent string, in coordination.CoordinationConfirmation) (coordination.CoordinationConfirmation, error)
CoordinationRecover(ctx context.Context, accessToken, parent, code string, planVersion int32) error
}
CoordinationGateway is the factory's coordination routes as the broker forwards to them, with the caller's own token (v4 MR4, MR5). runrequest.Factory satisfies it.
type CoordinationPlanner ¶ added in v0.38.0
type CoordinationPlanner struct {
// Mode is the coordination switch (MR16): off lists nothing; plan and execute both plan, since
// this tool never files.
Mode string
// Resolve is the broker-side policy when the factory's catalogue is not read: the class table's
// roles and ceiling (ClassPolicy). With Server.Catalogue, CataloguePolicy replaces it (WF13). The
// factory re-resolves each child at its repository's confirmed policy before anything is filed.
Resolve coordination.ResolvePolicy
// NewID is a fresh draft id when the request names none; nil means taskid.Random.
NewID func() string
}
CoordinationPlanner is coordination_plan as the broker serves it: the switch's mode, the policy its children resolve through, and the draft id source. Everything else — the model, the guard, the requester resolution, the daily counter and the clock — is Server.Intake's, so the two planners share one route and one allowance. Nil, or mode off, lists no tool.
type CoordinationViews ¶ added in v0.39.0
type CoordinationViews interface {
View(ctx context.Context, parentTask string) (coordination.CoordinationView, error)
}
CoordinationViews reads the core's unfiltered view of a coordination parent (v4 MR13): an uncached, read-only reader. Its errors wrap coordinationview.ErrNoCoordination or ErrCoordinationUnavailable. The unfiltered value never leaves this package: every caller goes through filterCoordination.
type Dashboard ¶
Dashboard is one link template the room page fills with a room's ids (human.dashboards): {room}, {run}, {task}, {created} and {ended}, each URL-encoded, and a link whose value is missing hidden.
type GitHubLinkStore ¶ added in v0.47.0
type GitHubLinkStore interface {
StartGitHubLink(ctx context.Context, stateSHA256 []byte, sub string, nonceSHA256 []byte, expires, now time.Time) error
GitHubState(ctx context.Context, stateSHA256 []byte, now time.Time) (store.GitHubState, error)
SetGitHubStateUser(ctx context.Context, stateSHA256 []byte, githubID int64, login string, now time.Time) error
ConfirmGitHubLink(ctx context.Context, stateSHA256 []byte, sub string, now time.Time) (string, error)
GitHubLinkOf(ctx context.Context, sub string) (store.GitHubLink, bool, error)
UnlinkGitHub(ctx context.Context, sub, actor string, admin bool, now time.Time) (bool, error)
TouchGitHubLink(ctx context.Context, sub string, now time.Time) (bool, error)
}
GitHubLinkStore is the part of the store the link reads and writes; *store.Store has it.
type GitHubLinker ¶ added in v0.47.0
type GitHubLinker struct {
Store GitHubLinkStore
OAuth GitHubOAuth
WebOrigin string // GitHub's site, scheme://host: the start's redirect, which the page's form-action allows
ClientID func() (string, error)
ClientSecret func() (string, error)
Changed func(sub string)
Rand io.Reader // nil: crypto/rand
}
GitHubLinker is human.githubLink: the store, GitHub's flow at WebOrigin, and the OAuth client, read at use so a rotated secret needs no restart. Changed, when set, is told each sub whose link was written or removed, so a cached login does not outlive it.
type GitHubOAuth ¶ added in v0.47.0
type GitHubOAuth interface {
AuthorizeURL(clientID, redirect, state, challenge string) string
ExchangeCode(ctx context.Context, clientID, clientSecret, code, verifier, redirect string) (string, error)
User(ctx context.Context, token string) (int64, string, error)
RevokeUserToken(ctx context.Context, clientID, clientSecret, token string) error
}
GitHubOAuth is GitHub's web flow; github.OAuth has it.
type GrantStore ¶ added in v0.40.0
type GrantStore interface {
CreateGrant(ctx context.Context, n store.NewGrant) (store.Grant, error)
Grant(ctx context.Context, id string) (store.Grant, error)
Grants(ctx context.Context, f store.GrantFilter) ([]store.Grant, error)
GrantEvents(ctx context.Context, id string) ([]store.GrantEvent, error)
MoveGrant(ctx context.Context, id string, m store.GrantMove) (store.Grant, error)
}
GrantStore is the store's grants as the human API reads and moves them; *store.Store has it.
type HandoffStartRecorder ¶ added in v0.54.4
type HandoffStartRecorder interface {
RecordHandoffStart(ctx context.Context, h store.HandoffStart) error
}
HandoffStartRecorder records a web start, so the factory can confirm the App's factory/ready on the issue it filed (broker-confirmed handoff). *store.Store implements it.
type HandoffStore ¶ added in v0.53.0
type HandoffStore interface {
PutHandoff(ctx context.Context, h store.Handoff) error
GetHandoff(ctx context.Context, id string, now time.Time) (store.Handoff, error)
}
HandoffStore stores and reads in-progress handoff plans on the broker. *store.Store implements it.
type Hub ¶
type Hub interface {
Subscribe(ctx context.Context, roomID string) (*fanout.Sub, error)
Unsubscribe(*fanout.Sub)
}
Hub is the fan-out hub's subscription side; *fanout.Hub implements it.
type Intake ¶ added in v0.35.0
type Intake struct {
Classes map[string]intake.Class
Allow map[string]bool
Model *intake.Model
// InternalModel is the governed model route for private and internal repositories (v5 P0-T1).
// Nil keeps the planner public-only: non-public repositories are refused before any call. When
// set, any request whose candidates include a non-public repository routes exclusively here.
InternalModel *intake.Model
// Public answers whether GitHub reports a repository public: the guard's visibility read.
Public intake.Publicity
// Paths answers whether a served repository holds a file at path, through the factory App's
// read. Nil grounds no quoted path: the planner then chooses among the candidates (#626).
Paths func(ctx context.Context, repository, path string) (bool, error)
// Links resolves a Slack user to the account it is linked to. Nil refuses every sponsored plan.
Links SlackLinkFinder
// Daily is the per-requester cap in a UTC day. Below one, no plan is made: a floor of zero would
// otherwise read as "no cap", which is the opposite of what an operator typed.
Daily int
// MaxRounds is the clarification-round cap. A revision reaching it accepts the remaining
// recommendations and returns a final plan without another model call.
MaxRounds int
// Fallback is the config's fallback: `off` leaves the degraded composer unreachable, `composer`
// makes it the answer when the call fails rather than a plan.
Fallback string
// WholePlans files every issue of a confirmed multi-issue plan in order (phase H2).
WholePlans bool
// Now is the clock the daily cap and the plan's composition read; nil means time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Intake is the planner as the broker serves it (human.intake.plan): the class table and the allowlist from config, the one bounded model call, the visibility read the public-only guard asks, the link tables a sponsored plan resolves its requester through, the daily cap, the degraded composer's switch and the clock. Nil on the server means the switch is off: neither tool exists on any list, so the list a deployment sees is the list it has.
It carries no channel ceiling: a channel is the caller's to state (the Slack App passes its channel's maxCostUSD as the tool's ceiling argument, as it passes max_cost to run_create), and Compose takes the lower of it and the class's.
type IntentClassifier ¶ added in v0.45.0
type IntentClassifier struct {
// Principal is the one sponsored principal that may call, system:<name>; TeamID its workspace.
Principal string
TeamID string
Model IntentModel
// Alias is the model's alias, logged with each classification.
Alias string
// Links resolves a Slack user to the account it is linked to (SI12). Nil refuses every call.
Links SlackLinkFinder
// Samples stores a reply of a channel that opted in. Nil stores nothing. Redactor runs over the
// text first, as every text the platform stores does.
Samples IntentSamples
Redactor Redactor
// MinConfidence, ConfirmTTL and MaxInputChars are SI18's thresholds; DailyCalls and PerUserPerHour
// SI13's caps; RetentionDays SI19's.
MinConfidence float64
ConfirmTTL time.Duration
MaxInputChars int
DailyCalls int
PerUserPerHour int
RetentionDays int
// Now is the clock the caps and the expiry read; nil means time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
IntentClassifier is human.slackIntents: who may call, for which workspace, the model, the link tables the author is resolved through, the caps and the bounds (SI3, SI12, SI13, SI18, SI19). Nil on the server is the switch off: the tool is on no list.
type IntentModel ¶ added in v0.45.0
type IntentModel interface {
Classify(ctx context.Context, reply, phase string) ([]byte, intent.Usage, error)
}
IntentModel is the one call the tool makes; *intent.Model has it.
type IntentSamples ¶ added in v0.45.0
type IntentSamples interface {
InsertIntentSample(ctx context.Context, in store.IntentSample, retentionDays int) (int64, error)
}
IntentSamples is the opt-in reply store; *store.Store has it.
type IssueStarter ¶ added in v0.54.0
type IssueStarter interface {
StartIssue(ctx context.Context, req StartIssueRequest) (StartIssueResult, error)
}
IssueStarter files a handoff's issue on GitHub and applies its labels for a linked viewer.
type Log ¶
type Log interface {
Range(ctx context.Context, roomID string, afterSeq int64, limit int) ([]envelope.Event, error)
Room(ctx context.Context, id string) (store.RoomState, error)
// Queue is the room's still-queued messages, for the state frame: a page's tail
// of events rarely reaches back to them (review 4.5 I1).
Queue(ctx context.Context, roomID string) ([]store.Queued, error)
// OpenApprovals is the room's pending approvals, for the state frame, likewise.
OpenApprovals(ctx context.Context, roomID string) ([]store.Approval, error)
// LastTaskState is the room's last task facts above seq after, for the room list's hold
// need (#78): its wait reason is not projected into the Room status.
LastTaskState(ctx context.Context, roomID string, after int64) (json.RawMessage, error)
// TaskStateAt is the task facts as they stood at seq upTo, above after: room_changes' baseline.
TaskStateAt(ctx context.Context, roomID string, after, upTo int64) (json.RawMessage, error)
// TaskReasons is the reason code of each room's last task facts above its bound, in one
// read: the room list's failed rows say why they failed.
TaskReasons(ctx context.Context, after map[string]int64) (map[string]string, error)
// LastEventAt is when each listed room's log last moved, for the room list.
LastEventAt(ctx context.Context, roomIDs []string) (map[string]time.Time, error)
// SealedSince is the rooms sealed at or after since, the last closed first, at most limit:
// the room list's closed view.
SealedSince(ctx context.Context, since time.Time, limit int) ([]store.RoomState, error)
}
Log is the part of the store the API reads.
type Policy ¶ added in v0.40.0
type Policy struct {
Factory PolicyGateway
Records PolicyRecords
// Operator is whether a GitHub login approves exceptions (policyManagement.operators).
Operator func(login string) bool
NewID func() string
}
Policy is the promotion workflow, policyManagement.promotion (stage 6): the settings pages, each class's evidence read through the factory, and the promotion and exception records. Maku records and links; a maintainer's own pull request changes the class (MP1, MP14).
type PolicyGateway ¶ added in v0.40.0
type PolicyGateway interface {
PolicyEvidence(ctx context.Context, accessToken, repository string) (evidence.Report, error)
PolicyRepositories(ctx context.Context, accessToken string) ([]string, error)
PolicyPreview(ctx context.Context, accessToken, repository, file string) (policyview.Preview, error)
PolicyDecisions(ctx context.Context, accessToken, repository string, pr int) (policyview.Timeline, error)
PolicyRecentDecisions(ctx context.Context, accessToken, repository, since string) (policyview.Recent, error)
PolicyBacktest(ctx context.Context, accessToken, repository string, request policyview.BacktestRequest, since string) (policyview.Backtest, error)
PolicyPromote(ctx context.Context, accessToken, repository, class string, minimum int) (promotepkg.Result, error)
PolicyPromotionStatus(ctx context.Context, accessToken, repository, class string, number int) (promotepkg.Status, error)
PolicyDrill(ctx context.Context, accessToken, repository string, number int) (runrequest.PolicyDrillResult, error)
// PolicyList, Policy and the two previews are the MergePolicies' pages (B16).
PolicyList(ctx context.Context, accessToken string) ([]evidence.PolicyReport, error)
Policy(ctx context.Context, accessToken, name string) (evidence.PolicyReport, error)
PolicyPreviewBindings(ctx context.Context, accessToken, repository string, bindings []config.Binding) (policyview.BindingPreview, error)
PolicyPreviewPolicy(ctx context.Context, accessToken, name string, spec config.PolicySpec) (policyview.PolicyPreview, error)
}
PolicyGateway is the factory's policy routes as the broker forwards to them, with the caller's own token (merge policy stage 6). runrequest.Factory satisfies it.
type PolicyRecords ¶ added in v0.40.0
type PolicyRecords interface {
RecordPromotion(ctx context.Context, p store.Promotion) (store.Promotion, error)
OpenPromotion(ctx context.Context, id string, number int, url, branch string) (store.Promotion, error)
MovePromotion(ctx context.Context, id, state string, pullRequest int, by string) (store.Promotion, error)
Promotion(ctx context.Context, id string) (store.Promotion, error)
RequestException(ctx context.Context, e store.Exception) (store.Exception, error)
DecideException(ctx context.Context, id, state, by, note string, expires time.Time) (store.Exception, error)
Exception(ctx context.Context, id string) (store.Exception, error)
PolicyAudit(ctx context.Context, repository string) ([]store.Promotion, []store.Exception, error)
}
PolicyRecords is the promotion workflow's audit; *store.Store implements it.
type Redactor ¶
type Redactor interface {
Payload(ctx context.Context, raw json.RawMessage) (json.RawMessage, []string, error)
}
Redactor removes secrets from a JSON payload before it is appended (§4); *redact.Redactor implements it.
type ScreenshotReader ¶ added in v0.56.0
type ScreenshotReader interface {
Screenshots(ctx context.Context, room string) ([]store.ScreenshotMeta, error)
Screenshot(ctx context.Context, room, digest string) (store.Screenshot, error)
}
ScreenshotReader is the store's screenshot reads (harness screenshots phase B); *store.Store implements it.
type Server ¶
type Server struct {
// Sponsored authenticates a sponsored principal's bearer on /mcp (factory interfaces F4, R13);
// nil while human.mcp.sponsored is empty, and then every sponsored token is refused.
Sponsored SponsoredAuthenticator
// Tasks is run_create's factory; nil answers no_factory.
Tasks TaskCreator
Humans Authenticator
Groups policy.Groups
// HumanMode is the human listener's mode ("oidc", "local"), which maku's discovery reports so
// `configure --url` knows whether an IdP and a token are needed. Empty reads as OIDC: the
// deployment every broker before local mode carried.
HumanMode string
// Origins are the origins requests may come from, set in local mode alone (authn.LoopbackOrigins
// of publicURL): there is no token there, so an every-route check on Origin is the only CSRF
// gate, and it covers the public and static routes too. Nil installs no such gate; an OIDC
// install relies on its authenticator's own Origin check, which every authenticated route calls.
Origins []string
// WebClient is the web UI's client id, read at use (Ruling AS-a): a session
// through it is the web UI, which may steer and decide (ruling P18).
WebClient func() string
// PublicURL, Issuer, RoomctlClient and ProjectID are what `maku
// configure` needs (GET /api/roomctl); the ids are read at use like WebClient.
PublicURL string
Issuer string
RoomctlClient func() string
ProjectID func() string
// Preset, TokenUse, Scopes and Audience are the human block's (v4 D8): maku signs in to any
// OIDC issuer from them. An empty Preset or TokenUse reads as zitadel's, access.
Preset string
TokenUse string
Scopes []string
Audience func() string
Rooms client.Reader
// FactoryPrincipal is the system principal whose task facts name a closed room's repository,
// once the factory has deleted its Room; "" leaves a closed room unreadable.
FactoryPrincipal string
Namespace string
Log Log
// Screenshots reads the images runs' bridges relayed (harness screenshots phase B); nil serves
// neither screenshot route.
Screenshots ScreenshotReader
Hub Hub
Runs Runs
Metrics *metrics.Set
UI fs.FS // Task 2.5; nil serves 404
Actor *Actor // serves act frames (phase 4); nil refuses every one
// Identity and Access are D7's GitHub check: who the caller is on GitHub, and
// whether they may read a room's repository. Either nil shows rooms to admins only.
// StartDefault and StartExcept configure human.mcp.start (UX3): StartDefault offers start on
// planner-served repositories (or every repository when no planner is configured), except those
// lowercased owner/name entries in StartExcept.
StartDefault bool
StartExcept map[string]bool
Identity *ghidentity.Resolver
Access *repoaccess.Checker
// CoordinationViews reads coordination parents' views (v4 MR13); nil while coordination is
// off, which serves no coordination route and attaches no family to a summary.
CoordinationViews CoordinationViews
// SponsoredRepositories is each sponsored principal's repository upper bound, keyed by its
// principal id system:<name> (human.mcp.sponsored[].repositories): the only reach it has into
// a family's children.
SponsoredRepositories map[string]map[string]bool
// CoordinationWrites forwards a parent's draft and confirmations to the factory with the
// caller's own token; nil serves neither route. Only beside CoordinationViews.
CoordinationWrites CoordinationGateway
Logger *slog.Logger
// Dashboards are the room page's link templates (human.dashboards), served on GET
// /api/roomctl; none shows no group.
Dashboards []Dashboard
// MCP serves POST /mcp, the MCP server maku mcp relays (human.mcp.enabled). Off, /mcp is a 404.
MCP bool
// Needs serves GET /api/needs, needs/v1's human door (CD28; human.needs.enabled, on unless a file
// turns it off). Off, /api/needs is a 404 and the App's own door is needs_list on /mcp.
Needs bool
// SlackLink is the Slack self-serve link (human.slackLink): its two tools for the Slack App and
// the /link/slack page. Nil serves neither.
SlackLink *SlackLinker
// GitHubLink is the GitHub account link (human.githubLink, v4 D8): /link/github and the admin's
// DELETE /api/links/github/{sub}. Nil serves neither.
GitHubLink *GitHubLinker
// Grants is human.approvalMemory: the saved approval grants' page and API (merge policy stage
// 5). Nil serves neither.
Grants GrantStore
// SlackDecide is human.slackDecide: the App's one route that records a decision, for forge.push
// only (v3.x Slack push approval D2, D13). Nil serves nothing: the path is the mux's 404.
SlackDecide *SlackDecider
// SlackStop, SlackRetry and SlackAnswer are human.slackStop, human.slackRetry and
// human.slackAnswer: POST /api/slack/stops, /retries and /answers for the Slack App (SI6, SI23).
// Nil serves nothing: each path is a 404.
SlackStop *SlackActor
SlackRetry *SlackActor
SlackAnswer *SlackActor
// Intake is the governed planner (human.intake.plan). Nil is the switch off: neither intake_plan
// nor plan_check exists on any /mcp list, so the list a deployment sees is the list it has.
Intake *Intake
// Handoffs stores in-progress handoff plans for 24 hours; nil refuses handoff calls as unavailable.
Handoffs HandoffStore
// IssueStarter files a handoff's issue on GitHub and applies its labels for POST /api/handoffs/{id}/start.
// Nil refuses web start as unavailable.
IssueStarter IssueStarter
// HandoffStarts records each web start (broker-confirmed handoff): the factory accepts the App's
// factory/ready on the filed issue only against that record. Nil refuses web start as unavailable.
HandoffStarts HandoffStartRecorder
// Intents is human.slackIntents: intent_classify, the Slack App's read-only classification of a
// thread reply (natural-language intents). Nil is the switch off: the tool is on no list.
Intents *IntentClassifier
// Coordination is coordination_plan (v4 MR4): listed beside the planner while its mode is not
// off. Nil, or off, lists nothing.
Coordination *CoordinationPlanner
// Catalogue reads what a repository offers at intake from the factory (classes_list and the
// settings pages' Profiles row). Nil lists no classes_list and leaves the pages without it.
Catalogue *CatalogueCache
// Stages forwards GET /api/stages to the factory's GET /v1/stages (WR5). Nil serves 404.
Stages StagesSource
// Unsafe is the install's unsafe settings (config install.unsafe, v4 D18), which GET /api/install
// shows every signed-in human and the web UI turns into a banner on every page.
Unsafe []string
// FactoryInstall is the factory's banner codes (GET /v1/install, v4 D3), read with the caller's
// own token; nil, or a caller without one, reads none.
FactoryInstall func(ctx context.Context, accessToken string) ([]string, error)
// Policy is the promotion workflow (policyManagement.promotion, merge policy stage 6): the
// settings pages and the policy API. Nil serves neither: each path is the mux's 404.
Policy *Policy
// RoomActs is human.roomActs (phase G): the room acts enabled over a room's connection.
// Nil takes config.DefaultRoomActs ([answer, retry]).
RoomActs []string
// Connection bounds; zero takes the default.
HelloWait time.Duration // the first frame must arrive within it (10 s)
WriteWait time.Duration // one frame to the socket (10 s)
PingEvery time.Duration // the keep-alive period (30 s)
PongWait time.Duration // a ping's pong must arrive within it (10 s)
// MaxLifetime caps a connection below its token's expiry (1 h): ZITADEL's
// tokens live 12 h by default, and this bounds a revoked member's socket.
MaxLifetime time.Duration
// Now is the clock the token-expiry check and the summary read, and the session
// lifetime is computed from it (min of the token's remaining life and MaxLifetime) before
// being handed to Timer; nil means time.Now.
// Deadlines handed to the runtime (the route's write deadline, a context's) stay on
// its own clock: a fake one there would expire a request before it starts, or never.
Now func() time.Time
// Timer starts the lifetime cap and each ping's wait: it returns the channel that
// fires after d and a stop. Nil means time.NewTimer; tests step their own.
Timer func(d time.Duration) (fired <-chan time.Time, stop func() bool)
// contains filtered or unexported fields
}
Server is the :8080 API. Humans, Groups, WebClient, Rooms, Namespace, Log, Hub and Runs are required; the rest is optional.
type SlackAct ¶ added in v0.53.0
type SlackAct struct {
Team string `json:"team"`
User string `json:"user"`
Channel string `json:"channel"`
MessageTS string `json:"messageTS"`
Room string `json:"room"`
Deeper bool `json:"deeper,omitempty"`
}
SlackAct is the POST /api/slack/stops and POST /api/slack/retries body (SI6, WR4).
type SlackActor ¶ added in v0.53.0
type SlackActor struct {
Store SlackLinkFinder
Principal string // "system:slack-app"
TeamID string
Rooms client.Reader
Namespace string
Identity *ghidentity.Resolver
Access *repoaccess.Checker
Tasks TaskActor
Metrics *metrics.Set
Logger *slog.Logger
// contains filtered or unexported fields
}
SlackActor is human.slackStop or human.slackRetry: modelled on SlackDecider (SI6).
type SlackAnswer ¶ added in v0.53.0
type SlackAnswer struct {
Team string `json:"team"`
User string `json:"user"`
Channel string `json:"channel"`
MessageTS string `json:"messageTS"`
Room string `json:"room"`
Text string `json:"text"`
}
SlackAnswer is the POST /api/slack/answers body (SI6).
type SlackDecideStore ¶ added in v0.35.0
type SlackDecideStore interface {
SlackLink(ctx context.Context, team, user string) (sub string, found bool, err error)
Approval(ctx context.Context, id string) (store.Approval, error)
Decide(ctx context.Context, approvalID, decision, by, reason string, d envelope.Draft) (envelope.Event, store.Approval, error)
Room(ctx context.Context, id string) (store.RoomState, error)
}
SlackDecideStore is the part of the store the route reads and writes; *store.Store has it.
type SlackDecider ¶ added in v0.35.0
type SlackDecider struct {
Store SlackDecideStore
Principal string // "system:slack-app"
TeamID string
Rooms client.Reader
Namespace string
Groups policy.Groups
Identity *ghidentity.Resolver
Access *repoaccess.Checker
Runs Runs
Metrics *metrics.Set
OnDecided func(time.Duration)
Logger *slog.Logger
// contains filtered or unexported fields
}
SlackDecider is human.slackDecide: who may call, for which workspace, and the readings standing is resolved from. Groups is left zero on purpose (D15): the broker holds no token for the linked human, so standing is exactly the Room CR's, and an agents-admin who is neither the room's owner nor one of its approvers is refused here and decides on the room page.
type SlackDecision ¶ added in v0.35.0
type SlackDecision struct {
Team string `json:"team"`
User string `json:"user"`
Channel string `json:"channel"`
MessageTS string `json:"messageTS"`
ApprovalID string `json:"approvalId"`
Branch string `json:"branch"`
Decision string `json:"decision"`
}
SlackDecision is §1's body. Every field is checked against its shape before any read.
type SlackLinkFinder ¶ added in v0.35.0
type SlackLinkFinder interface {
SlackLink(ctx context.Context, team, user string) (sub string, found bool, err error)
}
SlackLinkFinder is the part of the store a sponsored plan resolves its requester through: the ZITADEL account a Slack user is linked to. *store.Store has it; nil refuses every sponsored plan as not_linked, which is the one reason that sends the person somewhere they can act.
type SlackLinkStore ¶
type SlackLinkStore interface {
MintSlackCode(ctx context.Context, codeSHA256 []byte, c store.SlackCode, now time.Time) error
SlackCode(ctx context.Context, codeSHA256 []byte, now time.Time) (store.SlackCode, error)
LinkSlack(ctx context.Context, codeSHA256 []byte, team, sub string, now time.Time) (store.SlackCode, error)
SlackLinksOf(ctx context.Context, sub string) ([]store.SlackLink, error)
UnlinkSlack(ctx context.Context, team, user, sub string) (bool, error)
}
SlackLinkStore is the part of the store the link reads and writes; *store.Store has it.
type SlackLinker ¶
type SlackLinker struct {
Store SlackLinkStore
Principal string
TeamID string
Repository string
Rand io.Reader // nil: crypto/rand
}
SlackLinker is human.slackLink: who may mint codes (the Slack App's sponsored principal, system:<name>), for which workspace, and the repository whose installation names a login.
type SponsoredAuthenticator ¶
type SponsoredAuthenticator interface {
Authenticate(ctx context.Context, raw string) (authn.Principal, error)
}
SponsoredAuthenticator maps a bearer to its sponsored principal; *authn.Sponsored is the broker's.
type StagesSource ¶ added in v0.54.0
type StagesSource interface {
Stages(ctx context.Context, accessToken, repository, class string, last int) (stages.Report, error)
WorkflowDryRun(ctx context.Context, accessToken string, in stages.DryRunRequest) (stages.DryRunResult, error)
}
StagesSource reads a repository's per-stage report and workflow dry-run from the factory with the caller's token (WR5, WR11); runrequest.Factory satisfies it.
type StartIssueRequest ¶ added in v0.54.0
type StartIssueRequest struct {
Repository string
Title string
Body string
Labels []string
Viewer string
Principal string
}
StartIssueRequest is the issue POST /api/handoffs/{id}/start files on GitHub for a linked viewer.
type StartIssueResult ¶ added in v0.54.0
StartIssueResult is the filed GitHub issue's number and URL.
type TaskActor ¶ added in v0.53.0
type TaskActor interface {
StopTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)
RetryTask(ctx context.Context, task, onBehalfOf, accessToken string) (string, error)
AnswerTask(ctx context.Context, task, onBehalfOf, text, accessToken string) (string, error)
}
TaskActor reaches the factory's stop, retry and answer routes on behalf of a linked Slack user.
type TaskAnswerer ¶ added in v0.54.0
type TaskAnswerer interface {
AnswerTaskHuman(ctx context.Context, task, text, accessToken string) (string, error)
}
TaskAnswerer reaches the factory's answers route with the caller's own token (phase G1); runrequest.Factory implements it.
type TaskCanceller ¶ added in v0.53.10
type TaskCanceller interface {
CancelTask(ctx context.Context, task string, discard bool, accessToken string) (string, error)
}
TaskCanceller reaches the factory's cancellations route with the caller's own token (#644); runrequest.Factory implements it.
type TaskCreator ¶
type TaskCreator interface {
CreateTask(ctx context.Context, r runrequest.TaskRequest) (runrequest.TaskResult, error)
}
TaskCreator is the factory's intake api, as the broker reaches it with the caller's own token.
type TaskPlanner ¶ added in v0.54.0
type TaskPlanner interface {
PlanTaskHuman(ctx context.Context, task, decision, note, accessToken string) (string, error)
}
TaskPlanner reaches the factory's plans route with the caller's own token (phase G1); runrequest.Factory implements it.
type TaskRetrier ¶ added in v0.54.0
type TaskRetrier interface {
RetryTaskHuman(ctx context.Context, task string, deeper bool, accessToken string) (runrequest.RetryResult, error)
}
TaskRetrier reaches the factory's retries route with the caller's own token (WR4); runrequest.Factory implements it.
type TaskSplitter ¶ added in v0.54.0
type TaskSplitter interface {
SplitTaskHuman(ctx context.Context, task, decision, accessToken string) (string, error)
}
TaskSplitter reaches the factory's splits route with the caller's own token (phase G1); runrequest.Factory implements it.
type WorkflowChoice ¶ added in v0.54.0
type WorkflowChoice struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
CeilingUSD float64 `json:"ceilingUSD,omitempty"`
StepUpCeilingUSD float64 `json:"stepUpCeilingUSD,omitempty"`
Path []string `json:"path,omitempty"`
}
WorkflowChoice describes one workflow offered by the catalogue for a handoff plan.
Source Files
¶
- access.go
- acts.go
- brief.go
- catalogue.go
- closedlist.go
- coordination.go
- coordination_view.go
- coordination_write.go
- events.go
- foldcache.go
- fork.go
- gate.go
- githublink.go
- grants.go
- handoff.go
- inbox.go
- install.go
- intake.go
- intentclassify.go
- issuedraft.go
- machinetext.go
- mcp.go
- mcpact.go
- mcpprompts.go
- mcpread.go
- mcptasks.go
- needs.go
- pins.go
- policy.go
- rooms.go
- runcreate.go
- screenshots.go
- server.go
- slackacts.go
- slackanswer.go
- slackdecide.go
- slacklink.go
- stages.go
- startrun.go
- summary.go
- tasktool.go
- upgrade.go
- ws.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ui embeds the built web UI: web/ builds it (`task ui:build`) into dist/, which is committed, and `task ui:check` fails when the two differ.
|
Package ui embeds the built web UI: web/ builds it (`task ui:build`) into dist/, which is committed, and `task ui:check` fails when the two differ. |