model

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT Package model holds the domain types shared across commit-query providers. It is a leaf package with no internal dependencies so provider clients and renderers can depend on it without creating import cycles.

SPDX-License-Identifier: MIT

Index

Constants

View Source
const (
	WindowDateBasisCommitter = "committer"
	WindowDateBasisAuthor    = "author"
	// WindowDateBasisMixed describes queries combining discovery date bases.
	WindowDateBasisMixed = "mixed"
)

Window date basis values for commit-query and activity evidence. GitHub's list-commits since/until filter on the committer date, which diverges from the author date after a rebase, cherry-pick, or amend; the result states which date bounded the window rather than leaving it implicit.

View Source
const (
	// BaseSourceParentOfEarliest is the ordinary case: the comparison base is
	// the first parent of the earliest in-window commit.
	BaseSourceParentOfEarliest = "parent-of-earliest"
	// BaseSourceRepositoryRoot means the earliest in-window commit is the
	// repository's root commit, so there is no parent to compare against. The
	// comparison runs from that root commit itself, which makes its contents
	// the base state: the files it introduced are NOT reported as changes in
	// the window. BaseSHA is empty in this case, and a disclosure states the
	// limitation.
	BaseSourceRepositoryRoot = "repository-root"
)

Base sources for Boundaries.BaseSource.

View Source
const (
	StatusAhead     = "ahead"
	StatusIdentical = "identical"
	StatusDiverged  = "diverged"
	StatusBehind    = "behind"
)

Comparison statuses reported by the provider for a boundary comparison.

View Source
const (
	// BasisObserved means per-commit file data was actually fetched and lists
	// the path. Certain.
	BasisObserved = "observed"
	// BasisInferred means a declared rule produced the association; Rule names
	// which one.
	BasisInferred = "inferred"
)

Correlation bases. A correlation MUST NOT carry BasisObserved unless ActivityCommit.Enriched is true for every SHA it names.

View Source
const (
	// RulePathMention fires when the commit message body contains the path
	// verbatim. Strong.
	RulePathMention = "path-mention"
	// RuleScopeMatch fires when a Conventional Commit scope matches a leading
	// path segment. Weak: a scope names a component, not a path, and the two
	// only usually coincide.
	RuleScopeMatch = "scope-match"
)

Correlation rules, recorded in Correlation.Rule for inferred bases.

View Source
const (
	// DisclosureBudgetBounded: the request ceiling stopped the query.
	DisclosureBudgetBounded = "budget-bounded"
	// DisclosureCollectionFailed: a provider or cancellation error stopped gathering.
	DisclosureCollectionFailed = "collection-failed"
	// DisclosureSearchIncomplete: GitHub could not guarantee a complete search.
	DisclosureSearchIncomplete = "search-incomplete"
	// DisclosureSearchCapped: the search exceeds GitHub's 1,000-result bound.
	DisclosureSearchCapped = "search-capped"
	// DisclosureQuotaExhausted: the provider rate limit stopped the query.
	DisclosureQuotaExhausted = "quota-exhausted"
	// DisclosureProviderCapped: the comparison hit the provider's file cap.
	DisclosureProviderCapped = "provider-capped"
	// DisclosurePatchTruncated: patch text exceeded MaxDiffBytes.
	DisclosurePatchTruncated = "patch-truncated"
	// DisclosureAncestryDiverged: the boundaries do not share ancestry.
	DisclosureAncestryDiverged = "ancestry-diverged"
	// DisclosureNetComparisonBlindspot is unconditional whenever a change set
	// is produced.
	DisclosureNetComparisonBlindspot = "net-comparison-blindspot"
	// DisclosureReferenceScoped is unconditional whenever a change set is
	// produced.
	DisclosureReferenceScoped = "reference-scoped"
	// DisclosureAuthorFilterNotApplied: an author filter narrowed the commit
	// list but cannot narrow the change set.
	DisclosureAuthorFilterNotApplied = "author-filter-not-applied"
	// DisclosureEnrichmentPartial: the enrichment subset delivered was smaller
	// than the one requested.
	DisclosureEnrichmentPartial = "enrichment-partial"
)

Disclosure kinds. The two marked unconditional below are emitted whenever a change set is produced, including on a completely clean result: a boundary comparison always carries the blind spots, so stating them only when something went wrong would overstate the ordinary case.

View Source
const (
	PRSchemaVersion      = "sting.prs.skaphos.io/v1"
	PRInboxSchemaVersion = "sting.pr-inbox.skaphos.io/v1"
)

PRSchemaVersion and PRInboxSchemaVersion independently version the PR workflows.

View Source
const ActivitySchemaVersion = "sting.activity.skaphos.io/v1"

ActivitySchemaVersion pins the ActivityResult contract, independently of SchemaVersion which pins Result. Bump it on any breaking change to ActivityResult or the types it contains. The two versions are deliberately separate: a repository-activity change must not force downstream consumers that only read Result (e.g. a Wake evidence adapter) to re-pin.

View Source
const DefaultMaxDiffBytes = 60000

DefaultMaxDiffBytes is the default per-commit patch-text budget used when a query requests full diffs but does not set an explicit limit.

View Source
const DefaultMaxRequests = 500

DefaultMaxRequests bounds the provider requests a single query may consume. It is a fixed constant by design: deriving it from remaining quota would make the same request return different results on different runs, breaking the determinism the evidence contract depends on.

View Source
const SchemaVersion = "sting.skaphos.io/v2"

SchemaVersion identifies the sting Result contract. It is emitted on every Result so downstream consumers (e.g. a Wake evidence adapter) can pin the shape they map from and detect drift. Bump it on any breaking change to Result or Commit.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityCommit added in v1.1.0

type ActivityCommit struct {
	SHA        string `json:"sha"`
	Repo       string `json:"repo"`
	Author     string `json:"author,omitempty"`
	AuthorName string `json:"author_name"`
	Email      string `json:"email,omitempty"`
	URL        string `json:"url"`
	// Message is the full commit message body, not just the summary.
	Message string `json:"message"`
	// AuthorDate is the git author date; CommitterDate is the git committer
	// date. They diverge after a rebase, cherry-pick, or amend, and GitHub
	// bounds the window by the latter.
	AuthorDate    time.Time `json:"author_date"`
	CommitterDate time.Time `json:"committer_date"`
	// ParentSHAs lists the commit's parents; the first element is the first
	// parent, which is what boundary resolution follows.
	ParentSHAs []string `json:"parent_shas,omitempty"`
	// Enriched is true only when all per-commit file pages were fetched. It is
	// the precondition for any observed correlation naming this commit.
	Enriched bool `json:"enriched,omitempty"`
	// Files retains fetched pages even when enrichment stops early. When
	// Enriched is false this list is incomplete and cannot prove path absence.
	Files []File `json:"files,omitempty"`
}

ActivityCommit is a commit in an activity window. It is deliberately distinct from Commit rather than a reuse: it carries the parent SHAs and committer date that boundary resolution needs, and Commit is pinned by SchemaVersion so it must not gain fields.

func (ActivityCommit) Summary added in v1.1.0

func (c ActivityCommit) Summary() string

Summary is the first line of the commit message.

type ActivityQuery added in v1.1.0

type ActivityQuery struct {
	// Provider is the source control provider. Only ProviderGitHub is
	// supported; anything else is rejected at resolve time.
	Provider Provider
	// Repo is the "owner/name" target.
	Repo string
	// Ref is the branch or tag to examine. Empty means the repository's
	// default branch.
	Ref string
	// Since and Until bound the window, normalized to UTC.
	Since time.Time
	Until time.Time
	// Author optionally narrows the commit listing. The change set is not
	// author-filtered — a boundary comparison has no notion of authorship —
	// and a disclosure says so whenever both are present.
	Author string
	// IncludeDiffs requests bounded patch text in the change set.
	IncludeDiffs bool
	// MaxDiffBytes caps patch text; 0 uses DefaultMaxDiffBytes.
	MaxDiffBytes int
	// EnrichCommits is the size of the opt-in per-commit detail subset. It
	// costs at least one request per commit and is what enables observed (rather than
	// inferred) path attribution. 0 disables enrichment.
	EnrichCommits int
	// MaxRequests caps the provider requests this query may consume. 0
	// disables the ceiling; it defaults to DefaultMaxRequests.
	MaxRequests int
	// EstimateOnly reports projected cost and stops, gathering no evidence.
	EstimateOnly bool
}

ActivityQuery is the resolved, normalized repository-activity request. It is produced once by config.ResolveActivity and never mutated downstream, so the window is normalized at exactly one boundary.

type ActivityResult added in v1.1.0

type ActivityResult struct {
	// SchemaVersion pins the ActivityResult contract; it is always
	// ActivitySchemaVersion and never the zero value.
	SchemaVersion string    `json:"schema_version"`
	GeneratedAt   time.Time `json:"generated_at"`
	Provider      Provider  `json:"provider"`
	Repo          string    `json:"repo"`
	// Ref is the reference actually compared, never empty in output.
	Ref   string    `json:"ref"`
	Since time.Time `json:"since"`
	Until time.Time `json:"until"`
	// WindowDateBasis names which commit date bounded the window: "committer"
	// or "author". GitHub filters on the committer date.
	WindowDateBasis string           `json:"window_date_basis"`
	Boundaries      Boundaries       `json:"boundaries"`
	Count           int              `json:"count"`
	Commits         []ActivityCommit `json:"commits"`
	ChangeSet       ChangeSet        `json:"change_set"`
	Correlations    []Correlation    `json:"correlations,omitempty"`
	// Completion flags distinguish observed absence from evidence not gathered.
	// ChangeSetCollected can be true with Truncated paths; disclosures still apply.
	CommitsCollected   bool `json:"commits_collected"`
	ChangeSetCollected bool `json:"change_set_collected"`
	EstimateOnly       bool `json:"estimate_only"`
	// Cost is always populated, including on every early-return path: a query
	// that stopped early must still report what it spent.
	Cost CostReport `json:"cost"`
	// Disclosures record everything that bounded or degraded the result, plus
	// the two unconditional blind-spot statements that accompany any change
	// set.
	Disclosures []Disclosure `json:"disclosures,omitempty"`
}

ActivityResult is a repository's activity over a window: the commits, the aggregate change set derived from comparing the window's boundary states, the correlations between them, and what the whole thing cost. Every field exists so the result can be re-derived and audited.

type Boundaries added in v1.1.0

type Boundaries struct {
	// BaseSHA is the parent of the earliest in-window commit. Empty when the
	// earliest in-window commit is the repository root.
	BaseSHA string `json:"base_sha"`
	// HeadSHA is the latest in-window commit.
	HeadSHA string `json:"head_sha"`
	// BaseSource records how the base was chosen: BaseSourceParentOfEarliest
	// or BaseSourceRepositoryRoot. Resolution is by ancestry, never by
	// timestamp proximity.
	BaseSource string `json:"base_source"`
	// Status is the provider's comparison status: ahead, identical, diverged,
	// or behind.
	Status string `json:"status"`
	// SharedRoot is false when the boundaries do not share ancestry, in which
	// case the change set is suppressed rather than rendered.
	SharedRoot bool `json:"shared_ancestry"`
}

Boundaries are the two commits a change set was derived from.

type ChangeSet added in v1.1.0

type ChangeSet struct {
	// Paths is sorted lexicographically so identical upstream state yields
	// byte-identical output; provider ordering is not guaranteed stable.
	Paths          []ChangedPath `json:"paths"`
	TotalAdditions int           `json:"total_additions"`
	TotalDeletions int           `json:"total_deletions"`
	// Truncated is true when the provider's file cap clipped the comparison.
	Truncated bool `json:"truncated,omitempty"`
}

ChangeSet is the aggregate per-path delta between the window's boundaries.

type ChangedPath added in v1.1.0

type ChangedPath struct {
	Path           string `json:"path"`
	PreviousPath   string `json:"previous_path,omitempty"`
	Status         string `json:"status"`
	Additions      int    `json:"additions"`
	Deletions      int    `json:"deletions"`
	Patch          string `json:"patch,omitempty"`
	PatchTruncated bool   `json:"patch_truncated,omitempty"`
}

ChangedPath is one path's net change across the window.

type Commit

type Commit struct {
	SHA        string    `json:"sha"`
	Repo       string    `json:"repo"`             // "owner/repo"
	Author     string    `json:"author,omitempty"` // GitHub login, if known
	AuthorName string    `json:"author_name"`      // git author name
	Email      string    `json:"email,omitempty"`  // git author email
	Date       time.Time `json:"date"`             // git author date
	// CommitterDate preserves the GitHub committer timestamp when supplied.
	// Date remains the author timestamp for compatibility.
	CommitterDate time.Time `json:"committer_date,omitzero"`
	// WindowDateBasis states which timestamp selected this commit. Omitted
	// when a provider path does not report a verified basis.
	WindowDateBasis string `json:"window_date_basis,omitempty"`
	Message         string `json:"message"` // full commit message
	URL             string `json:"url"`     // html_url
	// Source records how the commit was discovered so a match is auditable:
	// "search" (commit search index), "repo" (default-branch listing), or
	// "pull/<n>" (open pull-request branch). Empty for provider paths that do
	// not tag a source (e.g. GitLab).
	Source    string `json:"source,omitempty"`
	Additions int    `json:"additions,omitempty"`
	Deletions int    `json:"deletions,omitempty"`
	Changes   int    `json:"changes,omitempty"`
	Files     []File `json:"files,omitempty"`
}

Commit is a normalized commit record independent of the GitHub API shape.

func (Commit) Summary

func (c Commit) Summary() string

Summary is the first line of the commit message.

type Correlation added in v1.1.0

type Correlation struct {
	Path string `json:"path"`
	// SHAs is sorted; empty means the path is unattributed.
	SHAs []string `json:"shas,omitempty"`
	// Basis is BasisObserved or BasisInferred.
	Basis string `json:"basis"`
	// Rule names the rule that produced an inferred basis.
	Rule string `json:"rule,omitempty"`
}

Correlation links a changed path to the commits that plausibly produced it, labeled with how the link was established so a consumer can tell observation from inference and filter accordingly.

type CostReport added in v1.1.0

type CostReport struct {
	// Estimated is the projected request count; 0 when no estimate was run.
	Estimated int `json:"estimated"`
	Consumed  int `json:"consumed"`
	// Ceiling is the configured request cap; 0 means disabled.
	Ceiling        int       `json:"ceiling"`
	QuotaRemaining int       `json:"quota_remaining"`
	QuotaLimit     int       `json:"quota_limit"`
	QuotaResetsAt  time.Time `json:"quota_resets_at,omitempty"`
}

CostReport accounts for what a query consumed and what quota remains. It is always populated, including on failure paths.

type Disclosure added in v1.1.0

type Disclosure struct {
	Kind       string `json:"kind"`
	Reason     string `json:"reason"`
	NextAction string `json:"next_action,omitempty"`
}

Disclosure states something that bounded or degraded a result, with the reason and, where one exists, the next action. A failure or a limit with no stated reason is a defect.

type File added in v0.0.3

type File struct {
	Path           string `json:"path"`
	PreviousPath   string `json:"previous_path,omitempty"`
	Status         string `json:"status,omitempty"`
	Additions      int    `json:"additions,omitempty"`
	Deletions      int    `json:"deletions,omitempty"`
	Changes        int    `json:"changes,omitempty"`
	Patch          string `json:"patch,omitempty"`
	PatchTruncated bool   `json:"patch_truncated,omitempty"`
}

File is a normalized file-level change record for a commit.

type PRActivityEntry added in v1.2.0

type PRActivityEntry struct {
	PR              PullRequest `json:"pr"`
	Matches         []PRMatch   `json:"matches"`
	MatchesComplete bool        `json:"matches_complete"`
}

PRActivityEntry carries only confirmed selected actions.

type PRCostReport added in v1.2.0

type PRCostReport struct {
	Consumed          int      `json:"consumed"`
	Ceiling           int      `json:"ceiling"`
	IdentityRequests  int      `json:"identity_requests"`
	DiscoveryRequests int      `json:"discovery_requests"`
	HistoryRequests   int      `json:"history_requests"`
	Quota             *PRQuota `json:"quota,omitempty"`
}

PRCostReport counts actual dispatched requests; categories sum to Consumed.

type PRCoverage added in v1.2.0

type PRCoverage struct {
	DiscoveryComplete bool `json:"discovery_complete"`
	EvidenceComplete  bool `json:"evidence_complete"`
}

PRCoverage separates candidate discovery from matching-evidence evaluation.

type PRDisclosure added in v1.2.0

type PRDisclosure struct {
	Kind       string `json:"kind"`
	Reason     string `json:"reason"`
	NextAction string `json:"next_action,omitempty"`
	Repo       string `json:"repo,omitempty"`
	Number     int    `json:"number,omitempty"`
	Stream     string `json:"stream,omitempty"`
}

PRDisclosure is a sanitized and attributable limitation, error, or selection fact.

type PRDraftFilter added in v1.2.0

type PRDraftFilter string

PRDraftFilter distinguishes omission from explicit draft selection.

const (
	PRDraftAll     PRDraftFilter = "all"
	PRDraftOnly    PRDraftFilter = "only"
	PRDraftExclude PRDraftFilter = "exclude"
)

type PRInboxEntry added in v1.2.0

type PRInboxEntry struct {
	PR              PullRequest      `json:"pr"`
	Reasons         []PRRelationship `json:"reasons"`
	ReasonsComplete bool             `json:"reasons_complete"`
}

PRInboxEntry carries all confirmed current personal reasons in fixed order.

type PRInboxQuery added in v1.2.0

type PRInboxQuery struct {
	Provider       Provider         `json:"provider"`
	Scope          Scope            `json:"scope"`
	Repos          []string         `json:"repos"`
	Org            string           `json:"org"`
	User           string           `json:"user"`
	IdentitySource string           `json:"identity_source"`
	Relationships  []PRRelationship `json:"relationships"`
	State          PRState          `json:"state"`
	Draft          PRDraftFilter    `json:"draft"`
	MaxPRs         int              `json:"max_prs"`
	MaxRequests    int              `json:"max_requests"`
}

PRInboxQuery has no activity window. Empty User is resolved by the collector.

type PRInboxResult added in v1.2.0

type PRInboxResult struct {
	SchemaVersion string         `json:"schema_version"`
	Workflow      string         `json:"workflow"`
	Provider      Provider       `json:"provider"`
	GeneratedAt   time.Time      `json:"generated_at"`
	Query         PRInboxQuery   `json:"query"`
	PRs           []PRInboxEntry `json:"prs"`
	Count         int            `json:"count"`
	Coverage      PRCoverage     `json:"coverage"`
	Truncated     bool           `json:"truncated"`
	Cost          PRCostReport   `json:"cost"`
	Disclosures   []PRDisclosure `json:"disclosures"`
}

PRInboxResult is the independently versioned current-work evidence envelope.

type PRMatch added in v1.2.0

type PRMatch struct {
	ID      string    `json:"id"`
	Kind    string    `json:"kind"`
	At      time.Time `json:"at"`
	Source  string    `json:"source"`
	EventID *int64    `json:"event_id"`
}

PRMatch is one distinct confirmed occurrence, independent of current state.

type PRQuery added in v1.2.0

type PRQuery struct {
	Provider    Provider      `json:"provider"`
	Scope       Scope         `json:"scope"`
	Repos       []string      `json:"repos"`
	Org         string        `json:"org"`
	Author      string        `json:"author"`
	Role        string        `json:"role"`
	State       PRState       `json:"state"`
	Draft       PRDraftFilter `json:"draft"`
	TimeBasis   PRTimeBasis   `json:"time_basis"`
	Since       time.Time     `json:"since"`
	Until       time.Time     `json:"until"`
	MaxPRs      int           `json:"max_prs"`
	MaxRequests int           `json:"max_requests"`
}

PRQuery is a resolved, inclusive UTC activity selection.

type PRQuota added in v1.2.0

type PRQuota struct {
	Limit     int       `json:"limit"`
	Remaining int       `json:"remaining"`
	Reset     time.Time `json:"reset"`
}

PRQuota is the last observed provider quota, not a combined search/core quota.

type PRRelationship added in v1.2.0

type PRRelationship string

PRRelationship is a current personal inclusion reason, not a past review action.

const (
	PRAuthored        PRRelationship = "authored"
	PRAssigned        PRRelationship = "assigned"
	PRReviewRequested PRRelationship = "review-requested"
)

type PRResult added in v1.2.0

type PRResult struct {
	SchemaVersion string            `json:"schema_version"`
	Workflow      string            `json:"workflow"`
	Provider      Provider          `json:"provider"`
	GeneratedAt   time.Time         `json:"generated_at"`
	Query         PRQuery           `json:"query"`
	PRs           []PRActivityEntry `json:"prs"`
	Count         int               `json:"count"`
	Coverage      PRCoverage        `json:"coverage"`
	Truncated     bool              `json:"truncated"`
	Cost          PRCostReport      `json:"cost"`
	Disclosures   []PRDisclosure    `json:"disclosures"`
}

PRResult is the versioned activity evidence envelope, including partial failures.

type PRState added in v1.2.0

type PRState string

PRState is current provider state; closed excludes merged work.

const (
	PRStateOpen   PRState = "open"
	PRStateMerged PRState = "merged"
	PRStateClosed PRState = "closed"
	PRStateAll    PRState = "all"
)

type PRTimeBasis added in v1.2.0

type PRTimeBasis string

PRTimeBasis identifies the activity timestamps selected by a query.

const (
	PRTimeCreated PRTimeBasis = "created"
	PRTimeUpdated PRTimeBasis = "updated"
	PRTimeMerged  PRTimeBasis = "merged"
	PRTimeClosed  PRTimeBasis = "closed"
	PRTimeAny     PRTimeBasis = "any"
)

type Provider

type Provider string

Provider identifies the source control provider a query targets.

const (
	ProviderGitHub Provider = "github"
	ProviderGitLab Provider = "gitlab"
)

func (Provider) Valid

func (p Provider) Valid() bool

Valid reports whether p is a recognized provider.

type PullRequest added in v1.2.0

type PullRequest struct {
	Repo               string     `json:"repo"`
	Number             int        `json:"number"`
	URL                string     `json:"url"`
	Title              string     `json:"title"`
	Author             string     `json:"author"`
	State              *PRState   `json:"state"`
	Draft              *bool      `json:"draft"`
	CreatedAt          *time.Time `json:"created_at"`
	UpdatedAt          *time.Time `json:"updated_at"`
	MergedAt           *time.Time `json:"merged_at"`
	ClosedAt           *time.Time `json:"closed_at"`
	Assignees          []string   `json:"assignees"`
	RequestedReviewers []string   `json:"requested_reviewers"`
	RequestedTeams     []string   `json:"requested_teams"`
	BaseRef            *string    `json:"base_ref"`
	HeadRef            *string    `json:"head_ref"`
	Labels             []string   `json:"labels"`
	Milestone          *string    `json:"milestone"`
	Additions          *int       `json:"additions"`
	Deletions          *int       `json:"deletions"`
	ChangedFiles       *int       `json:"changed_files"`
	MissingFields      []string   `json:"missing_fields"`
}

PullRequest contains available provider facts. MissingFields distinguishes unknown nulls from known absence; nil slices are unknown and empty slices are known empty.

type Query

type Query struct {
	// Provider is the source control provider to query.
	Provider Provider
	// Author is the provider author identifier whose commits are wanted. For
	// GitHub this is a login or an email; in the search scope an email is
	// matched with the author-email: qualifier and a login with author:. For
	// GitLab this is matched against the commit author string.
	Author string
	// Since and Until are inclusive window bounds. GitHub search and PR
	// discovery use author date; repository/org listings use committer date.
	// Provider filtering is preserved, not emulated by post-filtering an
	// already time-limited listing. A zero Until means "now".
	Since time.Time
	Until time.Time
	// Scope selects the discovery strategy.
	Scope Scope
	// Repos is the list of "owner/repo" targets for ScopeRepos.
	Repos []string
	// Org is the organization login for ScopeOrg.
	Org string
	// IncludeStats requests per-commit additions/deletions. This costs one
	// extra API call per commit, so it is off by default.
	IncludeStats bool
	// IncludeFiles requests per-file change summaries. Providers usually fetch
	// this from the same detail endpoint as stats.
	IncludeFiles bool
	// IncludeDiffs requests patch text for changed files. This implies
	// IncludeFiles and is bounded by MaxDiffBytes.
	IncludeDiffs bool
	// MaxDiffBytes caps patch text per commit when IncludeDiffs is true.
	MaxDiffBytes int
	// MaxCommits caps the number of commits returned (0 = no cap).
	MaxCommits int
	// IncludePullRequests augments repos/org discovery with commits found on
	// open pull-request branches. These commits are not yet on a default branch,
	// so commit search and branch listing miss them; enabling this enumerates
	// open PRs per repo and merges author-matching commits as evidence. It costs
	// extra API calls (one PR list + one commit list per PR), so it is off by
	// default. GitHub only; ignored for GitLab.
	IncludePullRequests bool
	// MaxRequests caps the provider API requests this query may consume
	// (0 = no cap). Reaching the cap yields the partial results gathered so far
	// rather than an abort.
	//
	// Query is a request type, not part of the serialized evidence contract, so
	// adding a field here does not bump SchemaVersion.
	MaxRequests int
}

Query describes a single commit-retrieval request.

type Result

type Result struct {
	// SchemaVersion pins the Result contract (see the package SchemaVersion
	// constant). GeneratedAt records when the query ran, giving the result
	// evidence-style provenance.
	SchemaVersion string    `json:"schema_version"`
	GeneratedAt   time.Time `json:"generated_at"`
	Provider      Provider  `json:"provider,omitempty"`
	Author        string    `json:"author"`
	Scope         Scope     `json:"scope"`
	Since         time.Time `json:"since"`
	Until         time.Time `json:"until"`
	// WindowDateBasis is author, committer, or mixed for GitHub discovery.
	// Mixed means repo listings use committer date and open-PR discovery uses
	// author date; each commit records its own basis. Empty means unspecified.
	WindowDateBasis string   `json:"window_date_basis,omitempty"`
	Count           int      `json:"count"`
	Commits         []Commit `json:"commits"`
	// Truncated is true when a cap or later-stage failure made the evidence
	// incomplete.
	Truncated bool `json:"truncated,omitempty"`
	// Cost reports provider requests consumed by the query. Disclosures explain
	// any bound or degradation so a partial result remains auditable in the
	// structured evidence, not only in CLI or MCP error text.
	Cost        CostReport   `json:"cost"`
	Disclosures []Disclosure `json:"disclosures,omitempty"`
	// Skipped lists repositories an org-scope scan could not list and skipped so
	// that one bad repo (e.g. an empty repo, or one the token cannot read) does
	// not abort the whole scan. Empty/omitted when nothing was skipped.
	Skipped []SkippedRepo `json:"skipped,omitempty"`
}

Result is the outcome of a Query: the matching commits plus the parameters that produced them, suitable for direct serialization.

type Scope

type Scope string

Scope selects how commits are discovered for an author.

const (
	// ScopeSearch uses GitHub's global commit search index (author across all
	// indexed public repositories). Broad but limited to indexed/public repos.
	ScopeSearch Scope = "search"
	// ScopeRepos lists commits within an explicit set of "owner/repo" targets.
	ScopeRepos Scope = "repos"
	// ScopeOrg enumerates an organization's repositories and lists commits in each.
	ScopeOrg Scope = "org"
)

func (Scope) Valid

func (s Scope) Valid() bool

Valid reports whether s is a recognized scope.

type SkippedRepo added in v0.0.5

type SkippedRepo struct {
	Repo   string `json:"repo"`
	Reason string `json:"reason"`
}

SkippedRepo records a repository that an org-scope scan could not list and chose to skip rather than abort the whole scan. Reason is a short, human-readable cause (e.g. "empty repository", "not found"). Surfacing skips keeps a partial result auditable instead of silently dropping the repo.

Jump to

Keyboard shortcuts

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