collector

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package collector produces Git-aware ingestion requests. It has no server or database dependency; CLI and agent hooks use the same collection entrypoint.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnchanged = errors.New("checkout unchanged")

ErrUnchanged means the checkout still matches its acknowledged fingerprint.

Functions

func Collect

func Collect(ctx context.Context, directory string, options Options) (ingestion.Request, error)

func CollectChanged

func CollectChanged(ctx context.Context, directory string, options Options, previousFingerprint string) (ingestion.Request, string, error)

CollectChanged checks complete content identity before constructing previews. A nonempty fingerprint is safe to persist only after successful ingestion. Unknown identities always produce a request, even when a prior value exists.

func CollectPatch

func CollectPatch(ctx context.Context, raw, directory string, options Options) (ingestion.Request, error)

CollectPatch records immutable input with its submission directory as provenance.

func Fingerprint

func Fingerprint(request ingestion.Request) string

Fingerprint identifies checkout contents and stable provenance, excluding submission/agent/session/time and filesystem-based snapshot revisions. Empty means full identity cannot be proven; never use it to suppress a sync.

func SourceID

func SourceID() (string, error)

SourceID identifies this installation independently of its hostname/path. Ephemeral environments can provide DIFFX_SOURCE_ID explicitly.

func SourceIdentity

func SourceIdentity(ctx context.Context, root, sourceID, branch, base string) (string, error)

SourceIdentity uses persisted Git identities. Paths and branch labels are location hints, not the source's identity. Branch identifies object-only recovery; an empty branch identifies the live checkout.

Types

type Discovery

type Discovery struct {
	Sources     []DiscoverySource
	Diagnostics []string
}

func Discover

func Discover(ctx context.Context, input, sourceID, base string) (Discovery, error)

Discover examines only the supplied workspace (two levels, 128 directories), then Git's registered worktrees and unmerged local refs. It never fetches, switches branches, creates worktrees, or searches unrelated directories.

func DiscoverCheckout

func DiscoverCheckout(ctx context.Context, input, sourceID, base string) (Discovery, error)

DiscoverCheckout resolves only the selected live checkout. Non-Git input returns ErrNotRepository; callers decide whether to ignore a hook event.

type DiscoverySource

type DiscoverySource struct {
	InputPath string
	Path      string
	Branch    string
	Base      string
	Identity  string
}

type Options

type Options struct {
	SourceID         string
	Hostname         string
	RunID            string
	Agent            string
	SessionName      string
	Trigger          string
	TriggerRoot      string
	CollectorVersion string
	SubmissionID     string
	Base             string
	Branch           string
	OnSource         func(ingestion.Metadata, diffsource.Comparison)
}

Jump to

Keyboard shortcuts

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