Documentation
¶
Overview ¶
Package machinesnapshot defines the public, privacy-safe HTTP and durable storage contract for hosted WB machine state.
Index ¶
- Constants
- Variables
- func NormalizeAttentionReason(needsAttention bool, value string) string
- func SnapshotKey(login, machine string) (string, error)
- func SortPublished(snapshots []PublishedSnapshot)
- func ValidateIdentity(value string) error
- type ListResponse
- type PublishedSnapshot
- type PullRequest
- type Receipt
- type Snapshot
- type SnapshotStore
- type StoreResult
- type StoredSnapshot
- type Worktree
Constants ¶
const ( // SchemaVersion is the only hosted snapshot schema this build accepts. SchemaVersion = 1 // SnapshotPath is the authenticated endpoint used by the CLI and hub host. SnapshotPath = "/v0/workbench/machines/snapshot" // Collection is the authoritative durable collection for hosted records. Collection = "workbench_machine_snapshots" MaxWorktrees = 5000 MaxRepositories = 5000 MaxIdentityLength = 128 MaxRepositoryLen = 256 MaxTaskLength = 256 MaxTaskSummaryLen = 240 MaxBranchLength = 512 MaxStatusLength = 64 MaxOwnerLength = 256 MaxAttentionLen = 1024 MaxPRURLLength = 2048 AttentionOwnerInactive = "owner session is no longer active" AttentionSupersessionReview = "supersession evidence requires review" AttentionAbsorptionReview = "absorption evidence requires review" AttentionReviewRequired = "worktree requires attention" )
Variables ¶
Functions ¶
func NormalizeAttentionReason ¶
NormalizeAttentionReason maps local free-form diagnostics onto the hosted allowlist so paths and command output never cross the wire.
func SnapshotKey ¶
SnapshotKey derives the stable flat document ID for one login/machine pair. The delimiter prevents ambiguous concatenation and the hash keeps identity text from altering a storage hierarchy.
func SortPublished ¶
func SortPublished(snapshots []PublishedSnapshot)
SortStored gives stable responses without exposing a persistence ordering.
func ValidateIdentity ¶
ValidateIdentity applies the hosted login and machine identifier contract.
Types ¶
type ListResponse ¶
type ListResponse struct {
Snapshots []PublishedSnapshot `json:"snapshots"`
}
ListResponse is the authenticated, privacy-safe response consumed by WB.
type PublishedSnapshot ¶
type PublishedSnapshot struct {
Snapshot Snapshot `json:"snapshot"`
ReceivedAt time.Time `json:"received_at"`
}
PublishedSnapshot is the privacy-safe stored view returned to a publisher. The internal digest is deliberately omitted from the wire response.
type PullRequest ¶
type PullRequest struct {
Number int `json:"number" firestore:"number"`
URL string `json:"url" firestore:"url"`
State string `json:"state,omitempty" firestore:"state,omitempty"`
}
PullRequest is the hosted link for one worktree review.
type Receipt ¶
type Receipt struct {
IdentityID string `json:"identity_id,omitempty"`
MachineID string `json:"machine_id,omitempty"`
Login string `json:"login"`
Machine string `json:"machine"`
PublishedAt time.Time `json:"published_at"`
ReceivedAt time.Time `json:"received_at"`
Updated bool `json:"updated"`
}
Receipt is the server response to one publish attempt.
type Snapshot ¶
type Snapshot struct {
SchemaVersion int `json:"schema_version" firestore:"schema_version"`
Login string `json:"login" firestore:"login"`
Machine string `json:"machine" firestore:"machine"`
PublishedAt time.Time `json:"published_at" firestore:"published_at"`
LastSeenAt time.Time `json:"last_seen_at,omitempty" firestore:"last_seen_at,omitempty"`
Repositories []string `json:"repositories" firestore:"repositories"`
Worktrees []Worktree `json:"worktrees" firestore:"worktrees"`
}
Snapshot is the complete allowlist of machine state that may cross the hosted boundary. Repositories are canonical identities used as routing candidates, never authorization. The snapshot intentionally has no path, projects root, commit SHA, repository diagnostics, prompts, credentials, or command output.
type SnapshotStore ¶
type SnapshotStore interface {
StoreLatest(ctx context.Context, snapshot StoredSnapshot) (StoreResult, error)
ListLatest(ctx context.Context) ([]StoredSnapshot, error)
}
SnapshotStore is the durable persistence port used by the host adapter. StoreLatest MUST atomically key records by login/machine, keep the candidate with the newest PublishedAt, reject a different payload at the same PublishedAt, and return the existing record without a write when Digest is already current. ListLatest returns at most one record for every key.
type StoreResult ¶
type StoreResult struct {
Current StoredSnapshot
Updated bool
}
StoreResult is returned by an atomic latest-snapshot replacement.
func ResolveLatest ¶
func ResolveLatest(current *StoredSnapshot, candidate StoredSnapshot) (StoreResult, error)
ResolveLatest is the deterministic comparison durable adapters apply inside their transaction. It makes retries idempotent and prevents delayed deliveries from replacing newer machine state.
type StoredSnapshot ¶
type StoredSnapshot struct {
Snapshot Snapshot `json:"snapshot" firestore:"snapshot"`
ReceivedAt time.Time `json:"received_at" firestore:"received_at"`
Digest string `json:"digest" firestore:"digest"`
}
StoredSnapshot is the durable, server-stamped record. Digest identifies the exact validated payload without retaining the request bytes.
type Worktree ¶
type Worktree struct {
Task string `json:"task" firestore:"task"`
TaskSummary string `json:"task_summary,omitempty" firestore:"task_summary,omitempty"`
Stream string `json:"stream,omitempty" firestore:"stream,omitempty"`
Repository string `json:"repository" firestore:"repository"`
Branch string `json:"branch" firestore:"branch"`
Lifecycle string `json:"lifecycle,omitempty" firestore:"lifecycle,omitempty"`
OwnerState string `json:"owner_status,omitempty" firestore:"owner_status,omitempty"`
Owner string `json:"owner,omitempty" firestore:"owner,omitempty"`
LastActivityAt time.Time `json:"last_activity_at,omitempty" firestore:"last_activity_at,omitempty"`
NeedsAttention bool `json:"needs_attention,omitempty" firestore:"needs_attention,omitempty"`
AttentionReason string `json:"attention_reason,omitempty" firestore:"attention_reason,omitempty"`
PullRequest *PullRequest `json:"pull_request,omitempty" firestore:"pull_request,omitempty"`
}
Worktree is the hosted dashboard projection of one WB worktree.