Help us shape the future of Go! Take the 2026 Go Developer Survey

ingestion

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ingestion defines snapshot contracts, pure identity rules and HTTP clients. It contains no collector filesystem or server persistence behavior.

Index

Constants

View Source
const (
	GitHubSourceID = "github"
	GitHubTrigger  = "github"
)

Server-authored producer markers; public ingestion rejects both.

View Source
const MaxRequestBytes = 64 << 20
View Source
const ProtocolVersion = 4

Variables

This section is empty.

Functions

func BranchIdentity added in v0.2.2

func BranchIdentity(metadata Metadata) string

BranchIdentity is the stable branch of a stream: a producer's branch ID survives renames; otherwise the branch label identifies it.

func ComparisonPolicy

func ComparisonPolicy(metadata Metadata) string

ComparisonPolicy identifies a stream independently of resolved commit tips.

func ContentIdentity

func ContentIdentity(request Request) (string, error)

ContentIdentity preserves the established observation identity algorithm. Unknown full content identities remain independent unless all scopes are empty.

func LegacyComparisonKind added in v0.2.1

func LegacyComparisonKind(mode review.DiffMode, source string, metadata Metadata, scopes []review.DiffMode) review.ComparisonKind

LegacyComparisonKind interprets captured scopes without modifying their stored manifests or request identities. Explicit manifest kinds take precedence at reads.

func Payload added in v0.2.2

func Payload(request Request) ([]byte, string, error)

Payload is a request's stored representation and its replay hash. A replay under the same submission identity must hash identically.

func StreamID added in v0.2.2

func StreamID(sourceID, repositoryKey, checkoutKey, branch, comparisonPolicy string) string

StreamID names one stream head without exposing its keys or depending on row identity.

func StreamKey added in v0.2.2

func StreamKey(contextID string, metadata Metadata) string

StreamKey names the review stream of a new observation. Keyed checkouts share their stream head identity; piped observations form a stream of their own.

func Validate

func Validate(input Request) error

Types

type AgentSession

type AgentSession struct {
	Harness string `json:"harness"`
	ID      string `json:"id"`
	Name    string `json:"name,omitempty"`
}

AgentSession identifies the session observing a capture, never its authorship.

type Checkout added in v0.2.1

type Checkout struct {
	RepositoryKey string
	CheckoutKey   string
}

Checkout is a persisted checkout identity within a source.

type Client

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

func NewClient

func NewClient(endpoint, token string) *Client

func (*Client) Health

func (client *Client) Health(ctx context.Context) (Health, error)

Health probes authentication, database reads and ingestion compatibility.

func (*Client) ObservationCurrent

func (client *Client) ObservationCurrent(ctx context.Context, id string) (bool, error)

ObservationCurrent checks the durable stream head before suppressing a sync. Another collector can supersede an acknowledged observation in this checkout.

func (*Client) SyncTo

func (client *Client) SyncTo(ctx context.Context, input Request, stateID string, progress func(Job)) (Receipt, error)

SyncTo distinguishes durable acceptance from committed publication. Cancelling this wait does not cancel a job already accepted by the server.

type Commit added in v0.2.2

type Commit struct {
	review.Commit
	Snapshot *review.RepositoryDiff      `json:"snapshot,omitempty"`
	Patches  map[string]review.FilePatch `json:"patches,omitempty"`
}

Commit is one captured branch commit with its diff against its first parent. Merge commits carry no snapshot or patches.

type Comparison

type Comparison struct {
	Kind       string `json:"kind"`
	BaseRef    string `json:"baseRef"`
	BaseCommit string `json:"baseCommit,omitempty"`
	MergeBase  string `json:"mergeBase,omitempty"`
}

Comparison records the interpretation and resolved Git baseline of a capture. Kind is working-tree or branch; absent comparisons retain legacy HEAD semantics.

type Filter

type Filter struct {
	Query       string
	Repository  string
	Branch      string
	Worktree    string
	Hostname    string
	SourceID    string
	RunID       string
	Harness     string
	SessionID   string
	SessionName string
	// Latest omits stale snapshots: each stream's head plus stream-less
	// observations such as piped diffs.
	Latest bool
	// Selection is composition policy, never parsed from requests.
	Selection Selection
}

func (Filter) IsZero added in v0.2.1

func (filter Filter) IsZero() bool

IsZero reports a filter that neither restricts results nor selects a scope.

type Health

type Health struct {
	IngestionEnabled bool   `json:"ingestionEnabled"`
	QueuedIngestion  bool   `json:"queuedIngestion"`
	StateID          string `json:"stateId"`
	ProtocolVersion  int    `json:"protocolVersion"`
}

Health identifies the durable destination, including replacement databases.

type Job

type Job struct {
	ID           string `json:"id"`
	SubmissionID string `json:"submissionId"`
	State        string `json:"state"`
	Attempt      int    `json:"attempt"`
	ContextID    string `json:"contextId,omitempty"`
	Detail       string `json:"detail,omitempty"`
}

type Metadata

type Metadata struct {
	SourceID         string        `json:"sourceId"`
	Hostname         string        `json:"hostname"`
	RunID            string        `json:"runId"`
	Agent            string        `json:"agent"`
	Trigger          string        `json:"trigger"`
	RepositoryKey    string        `json:"repositoryKey"`
	RepositoryName   string        `json:"repositoryName"`
	RemoteURL        string        `json:"remoteUrl"`
	CheckoutKey      string        `json:"checkoutKey"`
	Root             string        `json:"root"`
	WorktreeName     string        `json:"worktreeName"`
	LinkedWorktree   *bool         `json:"linkedWorktree,omitempty"`
	Branch           string        `json:"branch"`
	BranchID         string        `json:"branchId,omitempty"`
	Head             *string       `json:"head"`
	CollectedAt      int64         `json:"collectedAt"`
	ActivityAt       int64         `json:"activityAt,omitempty"`
	CollectorVersion string        `json:"collectorVersion"`
	Comparison       *Comparison   `json:"comparison,omitempty"`
	AgentSession     *AgentSession `json:"agentSession,omitempty"`
	TriggerRoot      string        `json:"triggerRoot,omitempty"`
	PullRequest      *PullRequest  `json:"pullRequest,omitempty"`
}

Metadata records facts at collection time. Paths and hostnames are labels, not globally unique identities. Account identity comes from the server.

func (Metadata) Reserved added in v0.2.1

func (metadata Metadata) Reserved() bool

Reserved reports metadata only the server's GitHub integration may submit.

type Problem

type Problem struct {
	Status int    `json:"status"`
	Detail string `json:"detail"`
}

func (*Problem) Error

func (problem *Problem) Error() string

type PullRequest added in v0.2.1

type PullRequest struct {
	Provider       string            `json:"provider"`
	RepositoryID   int64             `json:"repositoryId"`
	FullName       string            `json:"fullName"`
	Number         int               `json:"number"`
	URL            string            `json:"url"`
	Title          string            `json:"title"`
	Body           string            `json:"body"`
	State          string            `json:"state"`
	Draft          bool              `json:"draft"`
	Author         PullRequestAuthor `json:"author"`
	BaseRef        string            `json:"baseRef"`
	HeadRef        string            `json:"headRef"`
	HeadRepository string            `json:"headRepository"`
	CreatedAt      int64             `json:"createdAt"`
	UpdatedAt      int64             `json:"updatedAt"`
}

PullRequest describes the hosted pull request a capture reviews. Only the server's GitHub integration authors it; public ingestion rejects it.

type PullRequestAuthor added in v0.2.1

type PullRequestAuthor struct {
	Login string `json:"login"`
	URL   string `json:"url"`
}

type Receipt

type Receipt struct {
	ContextID string `json:"contextId"`
	ReviewURL string `json:"reviewUrl"`
	MCPURL    string `json:"mcpUrl"`
}

type Request

type Request struct {
	ProtocolVersion int      `json:"protocolVersion"`
	SubmissionID    string   `json:"submissionId"`
	ContentHash     string   `json:"contentHash,omitempty"`
	Metadata        Metadata `json:"metadata"`
	Scopes          []Scope  `json:"scopes"`
	Commits         []Commit `json:"commits,omitempty"`
	CommitsTotal    int      `json:"commitsTotal,omitempty"`
}

Request is one immutable observation. Replays retain the submission ID; fresh observations may reuse an existing review when ContentHash matches. Commits are optional protocol 4 metadata of branch comparisons, oldest first; CommitsTotal also counts commits beyond review.MaxCommits.

type Scope

type Scope struct {
	Snapshot review.RepositoryDiff       `json:"snapshot"`
	Patches  map[string]review.FilePatch `json:"patches"`
}

type Selection added in v0.2.1

type Selection struct {
	Scoped       bool
	SourceID     string
	Checkouts    []Checkout
	SubmissionID string
	ContextID    string
}

Selection restricts the catalog to the composition's selected checkouts or capture submission, optionally one context. An unscoped selection restricts only by ContextID; a scoped one without checkouts or submission matches nothing.

Jump to

Keyboard shortcuts

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