Documentation
¶
Overview ¶
Package serve exposes questmaster runtime snapshots and socket mutations over a local transport. It is a presentation layer over existing runtime and tracker readers; it never owns orchestration state.
Index ¶
- Constants
- func DefaultSocketPath() string
- type ArtifactSnapshot
- type Change
- type ChangeSource
- type CurrentSession
- type Envelope
- type FileChangeSource
- type MutationCommandRunner
- type ProjectSnapshot
- type QuestSnapshot
- type RepoSnapshot
- type Request
- type Server
- type SessionSnapshot
- type Snapshotter
- type TrackerSnapshot
Constants ¶
const (
ServeProtocolVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func DefaultSocketPath ¶
func DefaultSocketPath() string
DefaultSocketPath returns the default local socket path for qm serve.
Types ¶
type ArtifactSnapshot ¶ added in v0.3.36
type ArtifactSnapshot struct {
Kind string `json:"kind"`
Path string `json:"path"`
Label string `json:"label"`
SessionID string `json:"session_id"`
ProjectID string `json:"project_id"`
AddedAt string `json:"added_at"`
Missing bool `json:"missing,omitempty"`
}
ArtifactSnapshot is a tracker-visible runtime artifact reference.
type Change ¶
type Change struct {
Topics []string
SessionIDs []string
Clock bool
// BroadTracker marks a tracker change that must rebuild the full tracker
// snapshot, such as repo-colors edits or manifest rewrites that can alter
// agent identity and repo grouping. It survives coalescing so a broad change
// merged with per-session changes is not silently demoted to a delta.
BroadTracker bool
// Lifecycle marks a change that can alter tmux session liveness (manifest
// create/delete, session-dir events) as opposed to a state.json/artifacts
// content rewrite. Only lifecycle changes invalidate the tmux
// list-sessions TTL cache. Survives coalescing like BroadTracker.
Lifecycle bool
}
Change is a topic-level invalidation produced by serve's file watcher or by the serve-side clock for elapsed/runtime fields. It names the smallest existing wire surfaces that need to be re-snapshotted; the payload shape remains the existing topic response.
type ChangeSource ¶
ChangeSource publishes file-watch and clock invalidations to subscribers.
type CurrentSession ¶
type CurrentSession struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
SessionType string `json:"session_type,omitempty"`
}
CurrentSession identifies the session the current process is attached to, when QUESTMASTER_SESSION gives serve that context.
type Envelope ¶
type Envelope struct {
ProtocolVersion int `json:"protocol_version"`
Type string `json:"type"`
ID json.RawMessage `json:"id,omitempty"`
OK *bool `json:"ok,omitempty"`
Topic string `json:"topic,omitempty"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Envelope is one JSON line sent by serve.
type FileChangeSource ¶
type FileChangeSource struct {
// contains filtered or unexported fields
}
FileChangeSource watches the durable qm files that feed serve's read models. It does not own state; it only turns filesystem events into topic invalidations.
func NewFileChangeSource ¶
func NewFileChangeSource(ctx context.Context, snapshotter *Snapshotter, clockInterval time.Duration) (*FileChangeSource, error)
NewFileChangeSource creates and starts the serve file watcher. clockInterval drives only elapsed/runtime clock fields; state changes are watcher-driven.
func (*FileChangeSource) Close ¶
func (s *FileChangeSource) Close() error
type MutationCommandRunner ¶
type MutationCommandRunner interface {
RunMutationCommand(context.Context, []string, []byte) ([]byte, error)
}
MutationCommandRunner runs a qm command for serve mutations that belong to the CLI/session lifecycle path.
type ProjectSnapshot ¶ added in v0.3.44
type ProjectSnapshot struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
Color string `json:"color,omitempty"`
}
ProjectSnapshot is a historical repo project discovered from session manifests. Linked worktrees share one ID and path through repo.Resolve.
type QuestSnapshot ¶
type QuestSnapshot struct {
ID string `json:"id"`
Content string `json:"content"`
ProjectID string `json:"project_id,omitempty"`
ProjectPath string `json:"project_path,omitempty"`
ProjectName string `json:"project_name,omitempty"`
Done bool `json:"done"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
type RepoSnapshot ¶
type RepoSnapshot struct {
Identity string `json:"identity,omitempty"`
Name string `json:"name,omitempty"`
Color string `json:"color,omitempty"`
}
RepoSnapshot carries tracker repo grouping metadata.
type Request ¶
type Request struct {
ID json.RawMessage `json:"id,omitempty"`
Method string `json:"method"`
Topics []string `json:"topics,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
Request is one JSON line sent by a client.
type Server ¶
type Server struct {
SocketPath string
Snapshotter *Snapshotter
ClockInterval time.Duration
ChangeSource ChangeSource
// MutationRunner is injectable for tests; production re-execs this binary
// for CLI-owned session lifecycle mutations.
MutationRunner MutationCommandRunner
TmuxClient *tmux.Client
DirQuerier dirsuggest.DirQuerier
}
Server serves snapshots, subscriptions, and mutations over a Unix domain socket.
type SessionSnapshot ¶
type SessionSnapshot struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Status string `json:"status"`
State string `json:"state,omitempty"`
ElapsedMS int64 `json:"elapsed_ms"`
ElapsedSince *time.Time `json:"elapsed_since,omitempty"`
LatestActivity string `json:"latest_activity,omitempty"`
LastKind string `json:"last_kind,omitempty"`
WorktreePath string `json:"worktree_path,omitempty"`
PrimaryAgent string `json:"primary_agent,omitempty"`
SessionType string `json:"session_type,omitempty"`
ParentID string `json:"parent_id,omitempty"`
WorkerCount int `json:"worker_count"`
IsCurrent bool `json:"is_current"`
Artifacts []ArtifactSnapshot `json:"artifacts,omitempty"`
Repo RepoSnapshot `json:"repo,omitempty"`
DisplayColor string `json:"display_color,omitempty"`
}
SessionSnapshot is one tracker row with live activity already applied.
type Snapshotter ¶
type Snapshotter struct {
// contains filtered or unexported fields
}
Snapshotter builds the read-only data surfaces served to clients.
func NewSnapshotter ¶
NewSnapshotter creates a snapshot reader from existing qm services.
func (*Snapshotter) Invalidate ¶
func (s *Snapshotter) Invalidate(change Change)
func (*Snapshotter) StateRoot ¶
func (s *Snapshotter) StateRoot() string
StateRoot returns the durable session-state root read by serve.
func (*Snapshotter) TrackerForChange ¶
func (s *Snapshotter) TrackerForChange(change Change) (TrackerSnapshot, error)
type TrackerSnapshot ¶
type TrackerSnapshot struct {
ObservedAt time.Time `json:"observed_at"`
Current *CurrentSession `json:"current,omitempty"`
Sessions []SessionSnapshot `json:"sessions"`
Projects []ProjectSnapshot `json:"projects,omitempty"`
Artifacts []ArtifactSnapshot `json:"artifacts,omitempty"`
Quests []QuestSnapshot `json:"quests,omitempty"`
}
TrackerSnapshot is the native tracker's read model.