Documentation
¶
Overview ¶
Package corpus provides the product-owned SQLite system of record.
The corpus stores immutable source observations separately from normalized current-state projections. Projection writes reject stale source revisions, complete paginated facets replace prior children atomically, and local queries use deterministic ordering. Opening a corpus applies embedded Goose migrations and performs no network or process work.
Index ¶
- Constants
- Variables
- type CodeMatch
- type CodeSearchOptions
- type CodeSearchPage
- type Collection
- type CollectionMember
- type ControlStats
- type Corpus
- func (c *Corpus) AddCollectionMembers(ctx context.Context, collectionName string, members []CollectionMember) error
- func (c *Corpus) AdvanceFacet(ctx context.Context, repoID int64, threadID *int64, facet string, ...) error
- func (c *Corpus) AdvanceFacetCAS(ctx context.Context, repoID int64, threadID *int64, facet string, ...) (bool, error)
- func (c *Corpus) ApplyFacetObservationSet(ctx context.Context, repoID int64, threadID *int64, facet string, ...) error
- func (c *Corpus) ApplyFacetObservationSetCAS(ctx context.Context, repoID int64, threadID *int64, facet string, ...) (bool, error)
- func (c *Corpus) ApplyRepositoryObservation(ctx context.Context, owner, name, externalID string, sourceUpdatedAt time.Time, ...) (*Repository, error)
- func (c *Corpus) ApplyThreadObservation(ctx context.Context, repoID int64, kind string, number int, ...) (*Thread, error)
- func (c *Corpus) CheckIntegrity(ctx context.Context) error
- func (c *Corpus) Close() error
- func (c *Corpus) Clustering() *clustering.Store
- func (c *Corpus) CompleteFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
- func (c *Corpus) ControlStats(ctx context.Context, now time.Time) (ControlStats, error)
- func (c *Corpus) CountThreadsFiltered(ctx context.Context, repoID int64, kind, state string) (int, error)
- func (c *Corpus) CreateEvidence(ctx context.Context, item *evidence.Evidence) error
- func (c *Corpus) CreateJob(ctx context.Context, kind, request string) (*Job, error)
- func (c *Corpus) CurrentSourceRevision(ctx context.Context, subject evidence.SourceSubject) (*evidence.SourceRevision, error)
- func (c *Corpus) DeleteJobOwner(ctx context.Context, ownerID string) error
- func (c *Corpus) EnqueueFrontierItem(ctx context.Context, item FrontierItem) (*FrontierItem, bool, error)
- func (c *Corpus) ExportLocalMetadata(ctx context.Context, opts tracking.ExportOptions) (*tracking.Bundle, error)
- func (c *Corpus) FailFrontierItem(ctx context.Context, id int64, worker, failureKind, message string, ...) error
- func (c *Corpus) FailRun(ctx context.Context, id int64, message string) error
- func (c *Corpus) FindPortfolioOverlaps(ctx context.Context, candidates []PortfolioSubject, ...) ([]PortfolioOverlapResult, error)
- func (c *Corpus) FindRelated(ctx context.Context, ref domain.RepoRef, category investigation.Category) ([]domain.SourceRef, error)
- func (c *Corpus) FinishRun(ctx context.Context, id int64, stats string) error
- func (c *Corpus) FinishRunPartial(ctx context.Context, id int64, stats, message string) error
- func (c *Corpus) GetCodeDocument(ctx context.Context, ref domain.RepoRef, path string) (*CodeMatch, error)
- func (c *Corpus) GetCollection(ctx context.Context, name string) (*Collection, error)
- func (c *Corpus) GetContribution(ctx context.Context, id string) (*tracking.Contribution, error)
- func (c *Corpus) GetCoverage(ctx context.Context, repoID int64, threadID *int64, facet string) (*Coverage, error)
- func (c *Corpus) GetDiscoverySource(ctx context.Context, name string) (*DiscoverySource, error)
- func (c *Corpus) GetDossier(ctx context.Context, owner, name string) (*DossierRecord, []DossierSource, error)
- func (c *Corpus) GetFrontierItem(ctx context.Context, workKey string) (*FrontierItem, error)
- func (c *Corpus) GetHypothesis(ctx context.Context, id string) (*investigation.Hypothesis, error)
- func (c *Corpus) GetInvestigation(ctx context.Context, id string) (*investigation.Investigation, error)
- func (c *Corpus) GetIssueDraft(ctx context.Context, opportunityID string) (*contribution.IssueDraft, error)
- func (c *Corpus) GetJob(ctx context.Context, id string) (*Job, error)
- func (c *Corpus) GetLens(ctx context.Context, name string) (*LensRecord, error)
- func (c *Corpus) GetOpportunity(ctx context.Context, id string) (*investigation.Opportunity, error)
- func (c *Corpus) GetPullRequestDraft(ctx context.Context, opportunityID string) (*contribution.PullRequestDraft, error)
- func (c *Corpus) GetRepository(ctx context.Context, owner, name string) (*Repository, error)
- func (c *Corpus) GetRepositoryByID(ctx context.Context, id int64) (*Repository, error)
- func (c *Corpus) GetResolutionRecord(ctx context.Context, threadID int64) (*ResolutionRecord, error)
- func (c *Corpus) GetRun(ctx context.Context, id int64) (*Run, error)
- func (c *Corpus) GetThread(ctx context.Context, repoID int64, kind string, number int) (*Thread, error)
- func (c *Corpus) GetThreadByNumber(ctx context.Context, repoID int64, number int) (*Thread, error)
- func (c *Corpus) GetThreadObservationRevision(ctx context.Context, threadID int64, sourceUpdatedAt time.Time, ...) (*ThreadObservation, error)
- func (c *Corpus) GetTime(ctx context.Context, key string) (time.Time, bool, error)
- func (c *Corpus) GetValidationDefinition(ctx context.Context, id string) (*evidence.ValidationDefinition, error)
- func (c *Corpus) GetValidationRun(ctx context.Context, id string) (*evidence.ValidationRun, error)
- func (c *Corpus) GetWorkspace(ctx context.Context, id string) (*workspace.Workspace, error)
- func (c *Corpus) HeartbeatJobOwner(ctx context.Context, ownerID string, t time.Time) error
- func (c *Corpus) ImportLocalMetadata(ctx context.Context, bundle *tracking.Bundle) error
- func (c *Corpus) IsImported(ctx context.Context, hour string) (bool, error)
- func (c *Corpus) LatestCodeSnapshot(ctx context.Context, ref domain.RepoRef) (..., error)
- func (c *Corpus) LatestRateLimitObservations(ctx context.Context, limit int) ([]RateLimitObservation, error)
- func (c *Corpus) LatestThreadObservation(ctx context.Context, threadID int64) (*ThreadObservation, error)
- func (c *Corpus) LeaseFrontierItems(ctx context.Context, worker string, now time.Time, leaseDuration time.Duration, ...) ([]FrontierItem, error)
- func (c *Corpus) ListCodeDocuments(ctx context.Context, ref domain.RepoRef) ([]CodeMatch, error)
- func (c *Corpus) ListCollectionMembers(ctx context.Context, collectionName string) ([]CollectionMember, error)
- func (c *Corpus) ListCollections(ctx context.Context) ([]Collection, error)
- func (c *Corpus) ListContributionOutcomes(ctx context.Context, contributionID string) ([]*tracking.ContributionOutcome, error)
- func (c *Corpus) ListContributions(ctx context.Context, filter tracking.ContributionFilter) ([]*tracking.Contribution, error)
- func (c *Corpus) ListCoverage(ctx context.Context, repoID int64, threadID *int64) ([]Coverage, error)
- func (c *Corpus) ListDiscoverySources(ctx context.Context) ([]DiscoverySource, error)
- func (c *Corpus) ListDossiers(ctx context.Context, limit int) ([]DossierRecord, error)
- func (c *Corpus) ListEvidence(ctx context.Context, filter evidence.EvidenceFilter) (out []*evidence.Evidence, err error)
- func (c *Corpus) ListFacetObservations(ctx context.Context, repoID int64, threadID *int64, facet string) ([]FacetObservation, error)
- func (c *Corpus) ListFacetObservationsBounded(ctx context.Context, repoID int64, threadID *int64, facet string, limit int) ([]FacetObservation, bool, error)
- func (c *Corpus) ListHypotheses(ctx context.Context, investigationID string) ([]*investigation.Hypothesis, error)
- func (c *Corpus) ListInvestigations(ctx context.Context) ([]*investigation.Investigation, error)
- func (c *Corpus) ListJobEvents(ctx context.Context, jobID string) ([]JobEvent, error)
- func (c *Corpus) ListJobs(ctx context.Context, status string, limit int) ([]Job, error)
- func (c *Corpus) ListLenses(ctx context.Context) ([]LensRecord, error)
- func (c *Corpus) ListOpportunities(ctx context.Context, investigationID string) ([]*investigation.Opportunity, error)
- func (c *Corpus) ListPortfolioLinks(ctx context.Context) (out []PortfolioLink, err error)
- func (c *Corpus) ListPullRequestPortfolio(ctx context.Context, author, state string, limit int) (_ []PortfolioPullRequest, err error)
- func (c *Corpus) ListRepositories(ctx context.Context, query string, limit int) ([]Repository, error)
- func (c *Corpus) ListRepositoriesWithOptions(ctx context.Context, query string, opts RepositorySearchOptions) (RepositorySearchPage, error)
- func (c *Corpus) ListRepositoryObservations(ctx context.Context, repoID int64) ([]RepositoryObservation, error)
- func (c *Corpus) ListRunEvents(ctx context.Context, runID int64) ([]RunEvent, error)
- func (c *Corpus) ListRuns(ctx context.Context, limit int) ([]Run, error)
- func (c *Corpus) ListThreadObservations(ctx context.Context, threadID int64) ([]ThreadObservation, error)
- func (c *Corpus) ListThreads(ctx context.Context, repoID int64, kind string, limit int) ([]Thread, error)
- func (c *Corpus) ListThreadsFiltered(ctx context.Context, repoID int64, kind, state string, limit int) ([]Thread, error)
- func (c *Corpus) ListTriageEvents(ctx context.Context, filter tracking.TriageEventFilter) ([]*tracking.TriageEvent, error)
- func (c *Corpus) ListValidationDefinitions(ctx context.Context, opportunityID string) ([]*evidence.ValidationDefinition, error)
- func (c *Corpus) ListValidationRuns(ctx context.Context, opportunityID string) ([]*evidence.ValidationRun, error)
- func (c *Corpus) MarkImported(ctx context.Context, hour string) error
- func (c *Corpus) PromoteHypothesis(ctx context.Context, hypothesis *investigation.Hypothesis, ...) error
- func (c *Corpus) PromoteHypothesisWithEvidence(ctx context.Context, hypothesis *investigation.Hypothesis, ...) error
- func (c *Corpus) ReconcileInterruptedJobs(ctx context.Context, leaseTimeout time.Duration) error
- func (c *Corpus) RecordContributionOutcome(ctx context.Context, o *tracking.ContributionOutcome) error
- func (c *Corpus) RecordJobEvent(ctx context.Context, jobID, level, message string) error
- func (c *Corpus) RecordRateLimitObservation(ctx context.Context, observation RateLimitObservation) error
- func (c *Corpus) RecordRunEvent(ctx context.Context, runID int64, level, message string) error
- func (c *Corpus) RecordSourcePartition(ctx context.Context, partition SourcePartition) error
- func (c *Corpus) RecordTriageEvent(ctx context.Context, e *tracking.TriageEvent) error
- func (c *Corpus) RefreshDossier(ctx context.Context, repoID int64, owner, name, commitSHA string, ...) (int64, bool, error)
- func (c *Corpus) RegisterJobOwner(ctx context.Context, ownerID string, processID int, t time.Time) error
- func (c *Corpus) ReleaseFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
- func (c *Corpus) ReplacePortfolioSignals(ctx context.Context, snapshot PortfolioSignalSnapshot) (saved *PortfolioSignalSnapshot, err error)
- func (c *Corpus) RequestJobCancellation(ctx context.Context, id string) error
- func (c *Corpus) RetryFrontierItem(ctx context.Context, id int64, worker, message string, ...) error
- func (c *Corpus) SaveCollection(ctx context.Context, name string) (*Collection, error)
- func (c *Corpus) SaveContribution(ctx context.Context, item *tracking.Contribution) error
- func (c *Corpus) SaveDiscoverySource(ctx context.Context, source DiscoverySource) (*DiscoverySource, error)
- func (c *Corpus) SaveDossier(ctx context.Context, repoID int64, owner, name, commitSHA string, ...) (int64, error)
- func (c *Corpus) SaveEvidence(ctx context.Context, item *evidence.Evidence) error
- func (c *Corpus) SaveHypothesis(ctx context.Context, item *investigation.Hypothesis) error
- func (c *Corpus) SaveInvestigation(ctx context.Context, item *investigation.Investigation) error
- func (c *Corpus) SaveIssueDraft(ctx context.Context, item *contribution.IssueDraft) error
- func (c *Corpus) SaveLens(ctx context.Context, definition lens.Definition) (*LensRecord, error)
- func (c *Corpus) SaveOpportunity(ctx context.Context, item *investigation.Opportunity) error
- func (c *Corpus) SavePortfolioLink(ctx context.Context, link PortfolioLink) (*PortfolioLink, error)
- func (c *Corpus) SavePullRequestDraft(ctx context.Context, item *contribution.PullRequestDraft) error
- func (c *Corpus) SaveResolutionRecord(ctx context.Context, record ResolutionRecord) (saved *ResolutionRecord, err error)
- func (c *Corpus) SaveValidationDefinition(ctx context.Context, item *evidence.ValidationDefinition) error
- func (c *Corpus) SaveValidationRun(ctx context.Context, item *evidence.ValidationRun) error
- func (c *Corpus) SaveWorkspace(ctx context.Context, item *workspace.Workspace) error
- func (c *Corpus) SchemaVersion(ctx context.Context) (int64, error)
- func (c *Corpus) SearchCode(ctx context.Context, query string, ref domain.RepoRef, limit int) ([]CodeMatch, error)
- func (c *Corpus) SearchCodeWithOptions(ctx context.Context, query string, opts CodeSearchOptions) (CodeSearchPage, error)
- func (c *Corpus) SearchThreads(ctx context.Context, query string, limit int) ([]Thread, error)
- func (c *Corpus) SearchThreadsPage(ctx context.Context, query string, filter SearchFilter) (ThreadSearchPage, error)
- func (c *Corpus) SearchThreadsWithFilter(ctx context.Context, query string, filter SearchFilter) ([]Thread, error)
- func (c *Corpus) SetTime(ctx context.Context, key string, checkpoint time.Time) error
- func (c *Corpus) StartJob(ctx context.Context, id string) error
- func (c *Corpus) StartJobAs(ctx context.Context, id, ownerID string) error
- func (c *Corpus) StartRun(ctx context.Context, kind string) (*Run, error)
- func (c *Corpus) StartThreadInvestigation(ctx context.Context, item *investigation.Investigation, ...) (_ *investigation.Investigation, _ *investigation.Hypothesis, _ bool, ...)
- func (c *Corpus) Status(ctx context.Context) (Status, error)
- func (c *Corpus) StoreCodeSnapshot(ctx context.Context, ref domain.RepoRef, snapshot codeindex.Snapshot) (int64, bool, error)
- func (c *Corpus) TransitionJob(ctx context.Context, id, from, to, result, errStr string) error
- func (c *Corpus) UpdateJobProgress(ctx context.Context, id, progress, statistics string) error
- func (c *Corpus) UpsertRepository(ctx context.Context, repo Repository, payload string) (*Repository, error)
- func (c *Corpus) UpsertThread(ctx context.Context, thread Thread, payload string) (*Thread, error)
- type Coverage
- type DiscoverySource
- type DossierRecord
- type DossierSource
- type FacetObservation
- type FacetObservationInput
- type FrontierItem
- type Job
- type JobEvent
- type LensRecord
- type ObservationRef
- type PortfolioLink
- type PortfolioOverlapEvidence
- type PortfolioOverlapMatch
- type PortfolioOverlapResult
- type PortfolioPullRequest
- type PortfolioSignal
- type PortfolioSignalSnapshot
- type PortfolioSubject
- type RateLimitObservation
- type Repository
- type RepositoryObservation
- type RepositorySearchOptions
- type RepositorySearchPage
- type ResolutionRecord
- type Run
- type RunEvent
- type SearchFilter
- type SourcePartition
- type Status
- type Thread
- type ThreadObservation
- type ThreadSearchPage
Constants ¶
const ( FrontierQueued = "queued" FrontierLeased = "leased" FrontierCompleted = "completed" FrontierFailed = "failed" )
FrontierState describes the durable lifecycle of queued crawl work.
const ( FrontierFailureTransientExhausted = "transient_exhausted" FrontierFailureAbsent = "absent" FrontierFailureDeleted = "deleted" FrontierFailureArchived = "archived" FrontierFailurePermanent = "permanent" )
Frontier failure classifications keep terminal source outcomes distinct.
const ( ThreadKindIssue = "issue" ThreadKindPullRequest = "pull_request" )
ThreadKind names the thread types stored by the corpus.
const ( RunStatusRunning = "running" RunStatusCompleted = "completed" RunStatusPartial = "partial" RunStatusFailed = "failed" )
RunStatus values.
const ( JobStatusQueued = "queued" JobStatusRunning = "running" JobStatusSucceeded = "succeeded" JobStatusFailed = "failed" JobStatusCancelled = "cancelled" )
JobStatus values for the durable job lifecycle.
const ( // PortfolioSubjectPullRequest identifies a corpus pull-request thread. PortfolioSubjectPullRequest = "pull_request" // PortfolioSubjectOpportunity identifies a local contribution opportunity. PortfolioSubjectOpportunity = "opportunity" // PortfolioSubjectWorkspace identifies a local contribution workspace. PortfolioSubjectWorkspace = "workspace" // PortfolioFacetChangedFiles contains normalized changed paths. PortfolioFacetChangedFiles = "changed_files" // PortfolioFacetLinkedIssues contains normalized issue references. PortfolioFacetLinkedIssues = "linked_issues" // PortfolioFacetOpportunitySimilarity contains scored PR relationships. PortfolioFacetOpportunitySimilarity = "opportunity_similarity" // PortfolioSignalFilePath is a normalized changed-path signal. PortfolioSignalFilePath = "file_path" // PortfolioSignalLinkedIssue is a normalized linked-issue signal. PortfolioSignalLinkedIssue = "linked_issue" // PortfolioSignalOpportunitySimilarity is a scored subject relationship. PortfolioSignalOpportunitySimilarity = "opportunity_similarity" )
Variables ¶
var ErrJobCancelled = errors.New("job cancellation requested")
ErrJobCancelled is returned when a terminal transition is blocked because a cancellation has already been requested for the job.
var ErrJobOwnerNotFound = errors.New("job owner not found")
ErrJobOwnerNotFound is returned when a heartbeat targets an owner row that no longer exists.
var ErrResolutionNotFound = errors.New("resolution record not found")
ErrResolutionNotFound indicates that no current resolution projection exists.
var ErrThreadObservationRevisionNotFound = errors.New("thread observation revision not found")
ErrThreadObservationRevisionNotFound reports a projection revision whose immutable source observation is unavailable.
Functions ¶
This section is empty.
Types ¶
type CodeMatch ¶
type CodeMatch struct {
Repo domain.RepoRef
Commit string
Path string
Content string
Bytes int
Language string
SnapshotID int64
DocID int64
SnapshotCreatedAt time.Time
Rank float64
}
CodeMatch is one local code-search result at an immutable commit.
type CodeSearchOptions ¶
CodeSearchOptions scopes a paginated code-document keyword search.
type CodeSearchPage ¶
CodeSearchPage is a paginated result of a code-document keyword search.
type Collection ¶
type Collection struct {
ID int64
Name string
MemberCount int
CreatedAt time.Time
UpdatedAt time.Time
}
Collection is a named set of local corpus references.
type CollectionMember ¶
CollectionMember is one typed stable reference in a collection.
type ControlStats ¶
type ControlStats struct {
Repositories int
Threads int
Sources int
FrontierReady int
ActiveRuns int
ActiveJobs int
Freshest time.Time
}
ControlStats is a bounded local snapshot used by status and diagnostics.
type Corpus ¶
type Corpus struct {
// contains filtered or unexported fields
}
Corpus is a durable, product-owned SQLite archive for GitHub repositories and threads. It stores immutable observations and separately maintained current projections, runs, coverage facts, and an FTS5 thread index.
func Open ¶
Open opens or creates a corpus at path, applies pending migrations, and enables WAL, foreign keys, and a busy timeout. The returned Corpus is safe for concurrent use by a single writer with multiple readers.
func (*Corpus) AddCollectionMembers ¶
func (c *Corpus) AddCollectionMembers(ctx context.Context, collectionName string, members []CollectionMember) error
AddCollectionMembers idempotently adds a bounded batch of typed references.
func (*Corpus) AdvanceFacet ¶
func (c *Corpus) AdvanceFacet(ctx context.Context, repoID int64, threadID *int64, facet string, sourceUpdatedAt time.Time, complete bool, runID int64) error
AdvanceFacet records progress on a hydration facet for a repository or thread. The update wins only when the new (source_updated_at, observation_sequence) ordering is greater, so facets advance independently from one another and from the parent projection.
func (*Corpus) AdvanceFacetCAS ¶ added in v0.6.0
func (c *Corpus) AdvanceFacetCAS(ctx context.Context, repoID int64, threadID *int64, facet string, sourceUpdatedAt time.Time, complete bool, runID, expectedSequence int64) (bool, error)
AdvanceFacetCAS advances coverage only when the facet sequence captured before retrieval is still current.
func (*Corpus) ApplyFacetObservationSet ¶
func (c *Corpus) ApplyFacetObservationSet(ctx context.Context, repoID int64, threadID *int64, facet string, sourceUpdatedAt time.Time, pages []FacetObservationInput, complete bool, runID int64) error
ApplyFacetObservationSet records a complete ordered set of facet observations and advances coverage for the facet in a single transaction. The existing facet observations are replaced only when the new set wins the (source_updated_at, observation_sequence) ordering, so an interrupted or stale fetch leaves previous complete data in place.
sourceUpdatedAt is the authoritative source timestamp for the set as a whole. It is used when the set is empty and also combined with the per-page timestamps so the latest source timestamp always controls the ordering. Callers should pass the most recent source timestamp available for the facet (for example, the latest item update time, falling back to the thread's source_updated_at).
func (*Corpus) ApplyFacetObservationSetCAS ¶ added in v0.6.0
func (c *Corpus) ApplyFacetObservationSetCAS(ctx context.Context, repoID int64, threadID *int64, facet string, sourceUpdatedAt time.Time, pages []FacetObservationInput, complete bool, runID, expectedSequence int64) (bool, error)
ApplyFacetObservationSetCAS atomically replaces a facet only when its current coverage sequence still matches the sequence captured before retrieval.
func (*Corpus) ApplyRepositoryObservation ¶
func (c *Corpus) ApplyRepositoryObservation(ctx context.Context, owner, name, externalID string, sourceUpdatedAt time.Time, payload string) (*Repository, error)
ApplyRepositoryObservation records an immutable repository observation and updates the current projection only when the new observation wins the ordering (source_updated_at, then observation_sequence).
func (*Corpus) ApplyThreadObservation ¶
func (c *Corpus) ApplyThreadObservation(ctx context.Context, repoID int64, kind string, number int, state, title, body, author string, sourceUpdatedAt time.Time, payload string) (*Thread, error)
ApplyThreadObservation records an immutable thread observation and updates the current projection only when the new observation wins the ordering.
func (*Corpus) CheckIntegrity ¶
CheckIntegrity performs bounded, local database health checks and verifies that an immediate write lock can be acquired. It does not mutate user data.
func (*Corpus) Clustering ¶
func (c *Corpus) Clustering() *clustering.Store
Clustering returns the duplicate-candidate clustering store backed by this corpus. The corpus schema includes the clustering tables, so this store is ready for use after Open.
func (*Corpus) CompleteFrontierItem ¶
func (c *Corpus) CompleteFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
CompleteFrontierItem marks leased work complete. Only the lease owner can complete it, preventing a stale worker from overwriting a newer attempt.
func (*Corpus) ControlStats ¶
ControlStats returns local counts without triggering refresh or hydration.
func (*Corpus) CountThreadsFiltered ¶
func (c *Corpus) CountThreadsFiltered(ctx context.Context, repoID int64, kind, state string) (int, error)
CountThreadsFiltered counts threads after applying the same kind and state predicates as ListThreadsFiltered.
func (*Corpus) CreateEvidence ¶
CreateEvidence inserts evidence through the repository boundary.
func (*Corpus) CreateJob ¶
CreateJob creates a new job in the queued state with an opaque stable ID.
func (*Corpus) CurrentSourceRevision ¶
func (c *Corpus) CurrentSourceRevision(ctx context.Context, subject evidence.SourceSubject) (*evidence.SourceRevision, error)
CurrentSourceRevision returns the winning local revision for one evidence subject. It performs only SQLite reads.
func (*Corpus) DeleteJobOwner ¶
DeleteJobOwner removes a process owner record.
func (*Corpus) EnqueueFrontierItem ¶
func (c *Corpus) EnqueueFrontierItem(ctx context.Context, item FrontierItem) (*FrontierItem, bool, error)
EnqueueFrontierItem inserts work once. Replaying the same WorkKey returns the existing item without resetting attempts or terminal state.
func (*Corpus) ExportLocalMetadata ¶
func (c *Corpus) ExportLocalMetadata(ctx context.Context, opts tracking.ExportOptions) (*tracking.Bundle, error)
ExportLocalMetadata returns a redacted, deterministic snapshot of tracking metadata bounded by opts.Limit.
func (*Corpus) FailFrontierItem ¶
func (c *Corpus) FailFrontierItem(ctx context.Context, id int64, worker, failureKind, message string, now time.Time) error
FailFrontierItem marks a leased item terminally failed.
func (*Corpus) FindPortfolioOverlaps ¶ added in v0.6.0
func (c *Corpus) FindPortfolioOverlaps(ctx context.Context, candidates []PortfolioSubject, pullRequestThreadIDs []int64) ([]PortfolioOverlapResult, error)
FindPortfolioOverlaps compares candidates with exact authored PR corpus IDs. It is an offline read and preserves candidate input order.
func (*Corpus) FindRelated ¶
func (c *Corpus) FindRelated(ctx context.Context, ref domain.RepoRef, category investigation.Category) ([]domain.SourceRef, error)
FindRelated returns stored source references related to a repository and category.
func (*Corpus) FinishRunPartial ¶
FinishRunPartial records a completed run that made progress but encountered retryable gaps.
func (*Corpus) GetCodeDocument ¶
func (c *Corpus) GetCodeDocument(ctx context.Context, ref domain.RepoRef, path string) (*CodeMatch, error)
GetCodeDocument returns a single code document from the latest snapshot of a repository, or nil when no snapshot or document exists.
func (*Corpus) GetCollection ¶
GetCollection returns a named collection and its current member count.
func (*Corpus) GetContribution ¶
GetContribution returns a contribution by durable id.
func (*Corpus) GetCoverage ¶
func (c *Corpus) GetCoverage(ctx context.Context, repoID int64, threadID *int64, facet string) (*Coverage, error)
GetCoverage returns the coverage fact for a single facet.
func (*Corpus) GetDiscoverySource ¶
GetDiscoverySource returns a named source or nil.
func (*Corpus) GetDossier ¶
func (c *Corpus) GetDossier(ctx context.Context, owner, name string) (*DossierRecord, []DossierSource, error)
GetDossier returns the most recent persisted dossier for a repository, including its exact source set.
func (*Corpus) GetFrontierItem ¶
GetFrontierItem returns work by its stable key, or nil when absent.
func (*Corpus) GetHypothesis ¶
func (c *Corpus) GetHypothesis(ctx context.Context, id string) (*investigation.Hypothesis, error)
GetHypothesis returns a hypothesis by ID, or nil when absent.
func (*Corpus) GetInvestigation ¶
func (c *Corpus) GetInvestigation(ctx context.Context, id string) (*investigation.Investigation, error)
GetInvestigation returns an investigation by ID, or nil when absent.
func (*Corpus) GetIssueDraft ¶
func (c *Corpus) GetIssueDraft(ctx context.Context, opportunityID string) (*contribution.IssueDraft, error)
GetIssueDraft returns the issue draft for an opportunity, or nil when absent.
func (*Corpus) GetOpportunity ¶
func (c *Corpus) GetOpportunity(ctx context.Context, id string) (*investigation.Opportunity, error)
GetOpportunity returns an opportunity with its dependencies and provenance.
func (*Corpus) GetPullRequestDraft ¶
func (c *Corpus) GetPullRequestDraft(ctx context.Context, opportunityID string) (*contribution.PullRequestDraft, error)
GetPullRequestDraft returns the pull-request draft for an opportunity, or nil when absent.
func (*Corpus) GetRepository ¶
GetRepository returns the current projection of a repository, or nil if it has not been observed.
func (*Corpus) GetRepositoryByID ¶
GetRepositoryByID returns the current projection of a repository by id.
func (*Corpus) GetResolutionRecord ¶ added in v0.6.0
func (c *Corpus) GetResolutionRecord(ctx context.Context, threadID int64) (*ResolutionRecord, error)
GetResolutionRecord returns the current stale-safe resolution projection.
func (*Corpus) GetThread ¶
func (c *Corpus) GetThread(ctx context.Context, repoID int64, kind string, number int) (*Thread, error)
GetThread returns the current projection of a thread, or nil if it has not been observed.
func (*Corpus) GetThreadByNumber ¶
GetThreadByNumber returns the current projection of a thread by repository and number, regardless of kind, or nil if it has not been observed.
func (*Corpus) GetThreadObservationRevision ¶
func (c *Corpus) GetThreadObservationRevision(ctx context.Context, threadID int64, sourceUpdatedAt time.Time, observationSequence int64) (*ThreadObservation, error)
GetThreadObservationRevision returns the immutable observation matching a projection revision. It lets callers bind copied projection fields to the exact observation even if a newer projection is written concurrently.
func (*Corpus) GetValidationDefinition ¶
func (c *Corpus) GetValidationDefinition(ctx context.Context, id string) (*evidence.ValidationDefinition, error)
GetValidationDefinition returns a validation plan by ID, or nil when absent.
func (*Corpus) GetValidationRun ¶
GetValidationRun returns a validation result by ID, or nil when absent.
func (*Corpus) GetWorkspace ¶
GetWorkspace returns a managed workspace by ID, or nil when absent.
func (*Corpus) HeartbeatJobOwner ¶
HeartbeatJobOwner refreshes the lease heartbeat for an owner.
func (*Corpus) ImportLocalMetadata ¶
ImportLocalMetadata imports a bounded bundle idempotently. All writes happen in a single transaction; any referential or database failure leaves the corpus unchanged.
func (*Corpus) IsImported ¶
IsImported implements discovery.CheckpointStore for GH Archive hours.
func (*Corpus) LatestCodeSnapshot ¶
func (c *Corpus) LatestCodeSnapshot(ctx context.Context, ref domain.RepoRef) (*struct { RepoPath string CommitSHA string CreatedAt time.Time }, error)
LatestCodeSnapshot returns the most recently stored code snapshot for a repository, or nil if none exists.
func (*Corpus) LatestRateLimitObservations ¶
func (c *Corpus) LatestRateLimitObservations(ctx context.Context, limit int) ([]RateLimitObservation, error)
LatestRateLimitObservations returns the newest observation for each reported GitHub resource, ordered newest first.
func (*Corpus) LatestThreadObservation ¶
func (c *Corpus) LatestThreadObservation(ctx context.Context, threadID int64) (*ThreadObservation, error)
LatestThreadObservation returns the most recent observation for a thread by source time and observation sequence.
func (*Corpus) LeaseFrontierItems ¶
func (c *Corpus) LeaseFrontierItems(ctx context.Context, worker string, now time.Time, leaseDuration time.Duration, limit, budget int) ([]FrontierItem, error)
LeaseFrontierItems atomically claims ready work for a bounded interval. Expired leases are eligible for another worker. Higher priority wins, then earlier eligibility and insertion order.
func (*Corpus) ListCodeDocuments ¶
ListCodeDocuments returns all documents from the latest snapshot of a repository. Results are bounded to avoid unbounded offline work.
func (*Corpus) ListCollectionMembers ¶
func (c *Corpus) ListCollectionMembers(ctx context.Context, collectionName string) ([]CollectionMember, error)
ListCollectionMembers returns members in stable kind and reference order.
func (*Corpus) ListCollections ¶
func (c *Corpus) ListCollections(ctx context.Context) ([]Collection, error)
ListCollections returns collections in stable name order.
func (*Corpus) ListContributionOutcomes ¶
func (c *Corpus) ListContributionOutcomes(ctx context.Context, contributionID string) ([]*tracking.ContributionOutcome, error)
ListContributionOutcomes returns outcomes for a contribution.
func (*Corpus) ListContributions ¶
func (c *Corpus) ListContributions(ctx context.Context, filter tracking.ContributionFilter) ([]*tracking.Contribution, error)
ListContributions returns contributions in prepared-at order.
func (*Corpus) ListCoverage ¶
func (c *Corpus) ListCoverage(ctx context.Context, repoID int64, threadID *int64) ([]Coverage, error)
ListCoverage returns all coverage facts for a repository or thread.
func (*Corpus) ListDiscoverySources ¶
func (c *Corpus) ListDiscoverySources(ctx context.Context) ([]DiscoverySource, error)
ListDiscoverySources returns all sources in stable name order.
func (*Corpus) ListDossiers ¶
ListDossiers returns the most recent dossier for each repository up to limit.
func (*Corpus) ListEvidence ¶
func (c *Corpus) ListEvidence(ctx context.Context, filter evidence.EvidenceFilter) (out []*evidence.Evidence, err error)
ListEvidence returns evidence matching the supplied local filter.
func (*Corpus) ListFacetObservations ¶
func (c *Corpus) ListFacetObservations(ctx context.Context, repoID int64, threadID *int64, facet string) ([]FacetObservation, error)
ListFacetObservations returns immutable observations for a facet, ordered by observation sequence.
func (*Corpus) ListFacetObservationsBounded ¶
func (c *Corpus) ListFacetObservationsBounded(ctx context.Context, repoID int64, threadID *int64, facet string, limit int) ([]FacetObservation, bool, error)
ListFacetObservationsBounded returns at most limit immutable observations and reports whether additional stored pages exist. Ordering matches ListFacetObservations. It lets offline readers enforce a memory bound before payload decoding.
func (*Corpus) ListHypotheses ¶
func (c *Corpus) ListHypotheses(ctx context.Context, investigationID string) ([]*investigation.Hypothesis, error)
ListHypotheses returns hypotheses belonging to an investigation.
func (*Corpus) ListInvestigations ¶
func (c *Corpus) ListInvestigations(ctx context.Context) ([]*investigation.Investigation, error)
ListInvestigations returns investigations in deterministic creation order.
func (*Corpus) ListJobEvents ¶
ListJobEvents returns events for a job in chronological order.
func (*Corpus) ListJobs ¶
ListJobs returns recent jobs bounded by limit, optionally filtered by status.
func (*Corpus) ListLenses ¶
func (c *Corpus) ListLenses(ctx context.Context) ([]LensRecord, error)
ListLenses returns saved lenses in stable name order.
func (*Corpus) ListOpportunities ¶
func (c *Corpus) ListOpportunities(ctx context.Context, investigationID string) ([]*investigation.Opportunity, error)
ListOpportunities returns opportunities belonging to an investigation.
func (*Corpus) ListPortfolioLinks ¶ added in v0.6.0
func (c *Corpus) ListPortfolioLinks(ctx context.Context) (out []PortfolioLink, err error)
ListPortfolioLinks returns explicit links in stable PR/opportunity/workspace order.
func (*Corpus) ListPullRequestPortfolio ¶ added in v0.5.0
func (c *Corpus) ListPullRequestPortfolio(ctx context.Context, author, state string, limit int) (_ []PortfolioPullRequest, err error)
ListPullRequestPortfolio returns pull requests across all stored repositories. Author login and state are optional, case-insensitive filters; state "all" is equivalent to no state filter. The read is bounded and deterministic so callers can build portfolio views without repository-level N+1 queries.
func (*Corpus) ListRepositories ¶
func (c *Corpus) ListRepositories(ctx context.Context, query string, limit int) ([]Repository, error)
ListRepositories returns repositories matching an optional name query. An empty query lists all repositories ordered by most recently updated.
func (*Corpus) ListRepositoriesWithOptions ¶
func (c *Corpus) ListRepositoriesWithOptions(ctx context.Context, query string, opts RepositorySearchOptions) (RepositorySearchPage, error)
ListRepositoriesWithOptions returns repositories matching an optional name query with stable cursor pagination. Results are ordered by source_updated_at descending, then id descending, so the same cursor always returns the same next page on an unchanged corpus.
func (*Corpus) ListRepositoryObservations ¶
func (c *Corpus) ListRepositoryObservations(ctx context.Context, repoID int64) ([]RepositoryObservation, error)
ListRepositoryObservations returns immutable observations for a repository in insertion order.
func (*Corpus) ListRunEvents ¶
ListRunEvents returns events for a run in chronological order.
func (*Corpus) ListThreadObservations ¶
func (c *Corpus) ListThreadObservations(ctx context.Context, threadID int64) ([]ThreadObservation, error)
ListThreadObservations returns immutable observations for a thread in insertion order.
func (*Corpus) ListThreads ¶
func (c *Corpus) ListThreads(ctx context.Context, repoID int64, kind string, limit int) ([]Thread, error)
ListThreads returns threads for a repository, optionally filtered by kind, ordered by source update time descending and then number descending.
func (*Corpus) ListThreadsFiltered ¶
func (c *Corpus) ListThreadsFiltered(ctx context.Context, repoID int64, kind, state string, limit int) ([]Thread, error)
ListThreadsFiltered returns threads for a repository, optionally filtered by kind and state, ordered by source update time descending and then number descending. Filtering happens at the corpus boundary before any limit is applied, so bounded callers do not silently drop matching rows.
func (*Corpus) ListTriageEvents ¶
func (c *Corpus) ListTriageEvents(ctx context.Context, filter tracking.TriageEventFilter) ([]*tracking.TriageEvent, error)
ListTriageEvents returns triage events in source-event order.
func (*Corpus) ListValidationDefinitions ¶
func (c *Corpus) ListValidationDefinitions(ctx context.Context, opportunityID string) ([]*evidence.ValidationDefinition, error)
ListValidationDefinitions returns validation plans scoped to an opportunity.
func (*Corpus) ListValidationRuns ¶
func (c *Corpus) ListValidationRuns(ctx context.Context, opportunityID string) ([]*evidence.ValidationRun, error)
ListValidationRuns returns validation runs scoped to an opportunity.
func (*Corpus) MarkImported ¶
MarkImported records an imported GH Archive hour idempotently.
func (*Corpus) PromoteHypothesis ¶
func (c *Corpus) PromoteHypothesis(ctx context.Context, hypothesis *investigation.Hypothesis, opportunity *investigation.Opportunity) error
PromoteHypothesis atomically stores the promoted hypothesis and its new opportunity so a partial write cannot strand the hypothesis.
func (*Corpus) PromoteHypothesisWithEvidence ¶
func (c *Corpus) PromoteHypothesisWithEvidence(ctx context.Context, hypothesis *investigation.Hypothesis, opportunity *investigation.Opportunity, item *evidence.Evidence) error
PromoteHypothesisWithEvidence stores an optional promotion evidence record in the same transaction as the promoted hypothesis and opportunity.
func (*Corpus) ReconcileInterruptedJobs ¶
ReconcileInterruptedJobs marks running jobs as failed or cancelled when their owning process has not heartbeated within leaseTimeout. Live owners are left untouched, and stale owner records are removed.
It uses BEGIN IMMEDIATE so the write lock is acquired before any reads, avoiding a lock-upgrade race with concurrent heartbeats.
func (*Corpus) RecordContributionOutcome ¶
func (c *Corpus) RecordContributionOutcome(ctx context.Context, o *tracking.ContributionOutcome) error
RecordContributionOutcome stores a lifecycle event for a contribution.
func (*Corpus) RecordJobEvent ¶
RecordJobEvent appends a durable event to a job.
func (*Corpus) RecordRateLimitObservation ¶
func (c *Corpus) RecordRateLimitObservation(ctx context.Context, observation RateLimitObservation) error
RecordRateLimitObservation stores one bounded, redacted request observation.
func (*Corpus) RecordRunEvent ¶
RecordRunEvent appends a durable event to a run.
func (*Corpus) RecordSourcePartition ¶
func (c *Corpus) RecordSourcePartition(ctx context.Context, partition SourcePartition) error
RecordSourcePartition upserts the latest observation for one stable window.
func (*Corpus) RecordTriageEvent ¶
RecordTriageEvent stores a triage event with optional foreign-key-safe links.
func (*Corpus) RefreshDossier ¶
func (c *Corpus) RefreshDossier(ctx context.Context, repoID int64, owner, name, commitSHA string, asOf time.Time, sectionMetadata, snapshot string, generatedAt time.Time, sources []domain.SourceRef) (int64, bool, error)
RefreshDossier stores a dossier only when it is newer than the latest stored snapshot for the repository, or has changed at the same as-of time. It returns the dossier id and whether a new row was inserted.
func (*Corpus) RegisterJobOwner ¶
func (c *Corpus) RegisterJobOwner(ctx context.Context, ownerID string, processID int, t time.Time) error
RegisterJobOwner records a process owner with an explicit heartbeat time. Calling it again for an existing owner updates its process_id and heartbeat.
func (*Corpus) ReleaseFrontierItem ¶
func (c *Corpus) ReleaseFrontierItem(ctx context.Context, id int64, worker string, now time.Time) error
ReleaseFrontierItem returns leased but unstarted work to the queue. Because leasing increments attempts, releasing unstarted work refunds that attempt. Only the current lease owner can release the item.
func (*Corpus) ReplacePortfolioSignals ¶ added in v0.6.0
func (c *Corpus) ReplacePortfolioSignals(ctx context.Context, snapshot PortfolioSignalSnapshot) (saved *PortfolioSignalSnapshot, err error)
ReplacePortfolioSignals stores a complete child snapshot and atomically advances its projection only if its source clock is newer.
func (*Corpus) RequestJobCancellation ¶
RequestJobCancellation records a cancellation request. Queued jobs are moved directly to cancelled; running jobs have cancelled_at set so that they finish as cancelled.
func (*Corpus) RetryFrontierItem ¶
func (c *Corpus) RetryFrontierItem(ctx context.Context, id int64, worker, message string, earliestRunAt, now time.Time) error
RetryFrontierItem releases leased work after a transient failure. Once the attempt limit is reached, the item becomes terminally failed.
func (*Corpus) SaveCollection ¶
SaveCollection creates a named collection or returns its existing identity.
func (*Corpus) SaveContribution ¶
SaveContribution stores contribution metadata separate from GitHub state.
func (*Corpus) SaveDiscoverySource ¶
func (c *Corpus) SaveDiscoverySource(ctx context.Context, source DiscoverySource) (*DiscoverySource, error)
SaveDiscoverySource creates or updates a named source definition.
func (*Corpus) SaveDossier ¶
func (c *Corpus) SaveDossier(ctx context.Context, repoID int64, owner, name, commitSHA string, asOf time.Time, sectionMetadata, snapshot string, generatedAt time.Time, sources []domain.SourceRef) (int64, error)
SaveDossier persists a deterministic dossier snapshot and its exact sources.
func (*Corpus) SaveEvidence ¶
SaveEvidence inserts or updates an evidence record and its provenance.
func (*Corpus) SaveHypothesis ¶
func (c *Corpus) SaveHypothesis(ctx context.Context, item *investigation.Hypothesis) error
SaveHypothesis inserts or updates a hypothesis and its structured fields.
func (*Corpus) SaveInvestigation ¶
func (c *Corpus) SaveInvestigation(ctx context.Context, item *investigation.Investigation) error
SaveInvestigation inserts or updates an investigation record.
func (*Corpus) SaveIssueDraft ¶
func (c *Corpus) SaveIssueDraft(ctx context.Context, item *contribution.IssueDraft) error
SaveIssueDraft persists the latest rendered issue draft for an opportunity.
func (*Corpus) SaveLens ¶
func (c *Corpus) SaveLens(ctx context.Context, definition lens.Definition) (*LensRecord, error)
SaveLens creates or replaces a named lens after validating its scoring contract. Existing creation time is retained.
func (*Corpus) SaveOpportunity ¶
func (c *Corpus) SaveOpportunity(ctx context.Context, item *investigation.Opportunity) error
SaveOpportunity atomically persists an opportunity and its dependencies and source references.
func (*Corpus) SavePortfolioLink ¶ added in v0.6.0
func (c *Corpus) SavePortfolioLink(ctx context.Context, link PortfolioLink) (*PortfolioLink, error)
SavePortfolioLink idempotently records an explicit local workflow link.
func (*Corpus) SavePullRequestDraft ¶
func (c *Corpus) SavePullRequestDraft(ctx context.Context, item *contribution.PullRequestDraft) error
SavePullRequestDraft persists the latest pull-request draft for an opportunity.
func (*Corpus) SaveResolutionRecord ¶ added in v0.6.0
func (c *Corpus) SaveResolutionRecord(ctx context.Context, record ResolutionRecord) (saved *ResolutionRecord, err error)
SaveResolutionRecord appends a derivation and advances the current projection only when its source clock is newer.
func (*Corpus) SaveValidationDefinition ¶
func (c *Corpus) SaveValidationDefinition(ctx context.Context, item *evidence.ValidationDefinition) error
SaveValidationDefinition persists a validation plan without executing it.
func (*Corpus) SaveValidationRun ¶
SaveValidationRun persists the bounded result of an authorized validation execution.
func (*Corpus) SaveWorkspace ¶
SaveWorkspace inserts or replaces a managed workspace record.
func (*Corpus) SchemaVersion ¶
SchemaVersion returns the applied Goose schema version.
func (*Corpus) SearchCode ¶
func (c *Corpus) SearchCode(ctx context.Context, query string, ref domain.RepoRef, limit int) ([]CodeMatch, error)
SearchCode searches only the latest indexed snapshot of each repository.
func (*Corpus) SearchCodeWithOptions ¶
func (c *Corpus) SearchCodeWithOptions(ctx context.Context, query string, opts CodeSearchOptions) (CodeSearchPage, error)
SearchCodeWithOptions searches only the latest indexed snapshot of each repository with stable cursor pagination. Results are ordered by FTS5 rank ascending, then document id ascending. No network access occurs.
func (*Corpus) SearchThreads ¶
SearchThreads performs an FTS5 keyword search over thread titles and bodies. It returns matching threads ordered by FTS5 rank and limited to at most limit results. No network access occurs.
func (*Corpus) SearchThreadsPage ¶
func (c *Corpus) SearchThreadsPage(ctx context.Context, query string, filter SearchFilter) (ThreadSearchPage, error)
SearchThreadsPage performs an FTS5 keyword search with stable cursor pagination. Results are ordered by FTS5 rank ascending, then thread id ascending, so the same cursor always returns the same next page on an unchanged corpus. No network access occurs.
func (*Corpus) SearchThreadsWithFilter ¶
func (c *Corpus) SearchThreadsWithFilter(ctx context.Context, query string, filter SearchFilter) ([]Thread, error)
SearchThreadsWithFilter performs the same search as SearchThreads but supports filtering to a repository and thread kind.
func (*Corpus) SetTime ¶
SetTime atomically advances a discovery timestamp checkpoint. Older replayed checkpoints cannot move it backwards.
func (*Corpus) StartJobAs ¶
StartJobAs atomically transitions a queued job to running and claims it for the given owner. An empty ownerID leaves owner_id NULL.
func (*Corpus) StartThreadInvestigation ¶
func (c *Corpus) StartThreadInvestigation(ctx context.Context, item *investigation.Investigation, hypothesis *investigation.Hypothesis) (_ *investigation.Investigation, _ *investigation.Hypothesis, _ bool, returnErr error)
StartThreadInvestigation atomically inserts an investigation and its seed hypothesis. If the same thread already has an open investigation, the stored pair is returned without changing its original baseline.
func (*Corpus) StoreCodeSnapshot ¶
func (c *Corpus) StoreCodeSnapshot(ctx context.Context, ref domain.RepoRef, snapshot codeindex.Snapshot) (int64, bool, error)
StoreCodeSnapshot atomically stores one complete immutable code snapshot. Replaying the same repository commit returns the existing snapshot id.
func (*Corpus) TransitionJob ¶
TransitionJob performs a safe atomic terminal transition for a job. The current status must match from, and cancellation requests block transitions to non-cancelled terminal states. Terminal transitions clear the owner.
func (*Corpus) UpdateJobProgress ¶
UpdateJobProgress updates progress and statistics for a running job.
func (*Corpus) UpsertRepository ¶
func (c *Corpus) UpsertRepository(ctx context.Context, repo Repository, payload string) (*Repository, error)
UpsertRepository records a repository observation and updates the projection with all fields when the source ordering is newer.
type Coverage ¶
type Coverage struct {
ID int64
RepositoryID int64
ThreadID *int64
Facet string
SourceUpdatedAt time.Time
ObservationSequence int64
Complete bool
RunID *int64
UpdatedAt time.Time
}
Coverage records which hydration facet has been fetched for a repository or thread and whether it is complete. Each facet advances independently under the same source_updated_at/observation_sequence ordering as projections.
type DiscoverySource ¶
type DiscoverySource struct {
ID int64
Name string
Kind string
Definition string
Enabled bool
CreatedAt time.Time
UpdatedAt time.Time
}
DiscoverySource is one durable repository-discovery definition.
type DossierRecord ¶
type DossierRecord struct {
ID int64
RepositoryID int64
RepoOwner string
RepoName string
CommitSHA string
AsOf time.Time
SectionMetadata string
Snapshot string
GeneratedAt time.Time
CreatedAt time.Time
}
DossierRecord is a persisted deterministic dossier snapshot.
type DossierSource ¶
type DossierSource struct {
ID int64
DossierID int64
Source string
URL string
CommitSHA string
ObservedAt time.Time
AsOf time.Time
}
DossierSource is one exact source recorded for a dossier.
type FacetObservation ¶
type FacetObservation struct {
ID int64
RepositoryID int64
ThreadID *int64
Facet string
SourceUpdatedAt time.Time
ObservationSequence int64
Payload string
ObservedAt time.Time
}
FacetObservation is an immutable snapshot of a thread facet (comments, reviews, review comments, or PR details) received from a source.
type FacetObservationInput ¶
FacetObservationInput is an unpersisted facet observation page.
type FrontierItem ¶
type FrontierItem struct {
ID int64
WorkKey string
SubjectKind string
Owner string
Repo string
ThreadKind string
ThreadNumber int
Facet string
Priority int
Reason string
Source string
Attempts int
MaxAttempts int
EarliestRunAt time.Time
BudgetEstimate int
State string
LeaseOwner string
LeaseExpiresAt *time.Time
FailureKind string
LastError string
CreatedAt time.Time
UpdatedAt time.Time
}
FrontierItem is a deduplicated unit of repository, thread, or facet work. WorkKey is a stable product-owned identity chosen by the caller.
type Job ¶
type Job struct {
ID string
Kind string
Status string
Request string
Result string
Error string
Progress string
Statistics string
CreatedAt time.Time
StartedAt *time.Time
CompletedAt *time.Time
UpdatedAt time.Time
CancelledAt *time.Time
}
Job is a durable, cancellable unit of work.
type LensRecord ¶
LensRecord is a durable, reusable ranking definition.
type ObservationRef ¶ added in v0.6.0
ObservationRef identifies one immutable corpus observation used to derive a local portfolio or resolution fact. Kind is product-owned (for example, thread or facet) and ID is the corresponding corpus observation identity.
type PortfolioLink ¶ added in v0.6.0
type PortfolioLink struct {
ID int64 `json:"id"`
PullRequestThreadID int64 `json:"pull_request_thread_id"`
OpportunityID string `json:"opportunity_id,omitempty"`
WorkspaceID string `json:"workspace_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
PortfolioLink explicitly associates an authored PR with local workflow state. OpportunityID or WorkspaceID, and possibly both, must be present.
type PortfolioOverlapEvidence ¶ added in v0.6.0
type PortfolioOverlapEvidence struct {
Kind string `json:"kind"`
Value string `json:"value"`
Score float64 `json:"score,omitempty"`
SourceObservationRefs []ObservationRef `json:"source_observation_refs"`
}
PortfolioOverlapEvidence is an exact observed reason for an overlap.
type PortfolioOverlapMatch ¶ added in v0.6.0
type PortfolioOverlapMatch struct {
PullRequestThreadID int64 `json:"pull_request_thread_id"`
Evidence []PortfolioOverlapEvidence `json:"evidence"`
}
PortfolioOverlapMatch associates one candidate with an authored PR.
type PortfolioOverlapResult ¶ added in v0.6.0
type PortfolioOverlapResult struct {
Candidate PortfolioSubject `json:"candidate"`
Status string `json:"status"`
Coverage map[string]string `json:"coverage"`
Matches []PortfolioOverlapMatch `json:"matches"`
}
PortfolioOverlapResult preserves candidate input order. Status is overlap, no_overlap, or unknown. A no_overlap result requires complete coverage of every overlap facet for both the candidate and every compared PR.
type PortfolioPullRequest ¶ added in v0.5.0
PortfolioPullRequest identifies a pull request together with the repository that owns it. It is returned by global, offline portfolio reads.
type PortfolioSignal ¶ added in v0.6.0
type PortfolioSignal struct {
Kind string `json:"kind"`
Value string `json:"value"`
TargetKind string `json:"target_kind,omitempty"`
TargetRef string `json:"target_ref,omitempty"`
Score float64 `json:"score,omitempty"`
}
PortfolioSignal is one normalized overlap input. Similarity signals name a target subject and carry a score; path and linked-issue signals use Value.
type PortfolioSignalSnapshot ¶ added in v0.6.0
type PortfolioSignalSnapshot struct {
ID int64 `json:"id"`
Subject PortfolioSubject `json:"subject"`
Facet string `json:"facet"`
Signals []PortfolioSignal `json:"signals"`
SourceUpdatedAt time.Time `json:"source_updated_at"`
ObservationSequence int64 `json:"observation_sequence"`
SourceObservationRefs []ObservationRef `json:"source_observation_refs"`
ObservedAt time.Time `json:"observed_at"`
}
PortfolioSignalSnapshot is one complete, immutable facet replacement.
type PortfolioSubject ¶ added in v0.6.0
PortfolioSubject is a stable local identity. Pull-request references are decimal corpus thread IDs; opportunity and workspace references are IDs.
type RateLimitObservation ¶
type RateLimitObservation struct {
Attempt int
StatusCode int
Resource string
Limit int
Remaining int
Used int
ResetAt time.Time
Delay time.Duration
APIVersion string
SourceURL string
ObservedAt time.Time
}
RateLimitObservation is a redacted GitHub request/rate-limit measurement.
type Repository ¶
type Repository struct {
ID int64
Owner string
Name string
ExternalID string
Description string
DefaultBranch string
Language string
License string
Topics []string
Stars int
Watchers int
Forks int
OpenIssues int
Archived bool
Fork bool
SourceCreatedAt time.Time
SourceUpdatedAt time.Time
ObservationSequence int64
CreatedAt time.Time
UpdatedAt time.Time
}
Repository is the current projection of a GitHub repository.
type RepositoryObservation ¶
type RepositoryObservation struct {
ID int64
RepositoryID int64
SourceUpdatedAt time.Time
ObservationSequence int64
Payload string
ObservedAt time.Time
}
RepositoryObservation is an immutable snapshot received from a source.
type RepositorySearchOptions ¶
RepositorySearchOptions scopes a paginated repository search.
type RepositorySearchPage ¶
type RepositorySearchPage struct {
Repositories []Repository
NextCursor string
Total int
}
RepositorySearchPage is a paginated result of a repository keyword search.
type ResolutionRecord ¶ added in v0.6.0
type ResolutionRecord struct {
ID int64 `json:"id"`
ThreadID int64 `json:"thread_id"`
Kind string `json:"kind"`
Summary string `json:"summary"`
RuleVersion string `json:"rule_version"`
SourceUpdatedAt time.Time `json:"source_updated_at"`
ObservationSequence int64 `json:"observation_sequence"`
SourceObservationRefs []ObservationRef `json:"source_observation_refs"`
DerivedAt time.Time `json:"derived_at"`
}
ResolutionRecord is a deterministic local derivation over immutable source observations. It is not a root-cause claim and must identify its rule set.
type Run ¶
type Run struct {
ID int64
Kind string
Status string
StartedAt time.Time
CompletedAt *time.Time
Stats string
Error string
}
Run records a crawl, hydration, indexing, or validation attempt.
type SearchFilter ¶
type SearchFilter struct {
RepoID int64
Repo string
Kind string
State string
StateReason string
Merged *bool
Author string
Association string
Assignee string
Labels []string
UpdatedAfter time.Time
Limit int
Cursor string
}
SearchFilter scopes a thread keyword search.
type SourcePartition ¶
type SourcePartition struct {
SourceID int64
Key string
Query string
Qualifier string
Start time.Time
End time.Time
Total int
Pages int
Incomplete bool
Unsplittable bool
Retries int
ObservedAt time.Time
}
SourcePartition records one observed GitHub Search window.
type Thread ¶
type Thread struct {
ID int64
RepositoryID int64
Kind string
Number int
State string
StateReason string
Title string
Body string
Author string
AuthorAssociation string
Labels []string
Assignees []string
Draft bool
Locked bool
Milestone string
ClosedAt time.Time
MergedAt time.Time
Merged bool
SourceCreatedAt time.Time
SourceUpdatedAt time.Time
ObservationSequence int64
CreatedAt time.Time
UpdatedAt time.Time
// Rank is the query-specific FTS rank populated only by search results.
Rank float64
}
Thread is the current projection of an issue or pull request.
type ThreadObservation ¶
type ThreadObservation struct {
ID int64
ThreadID int64
SourceUpdatedAt time.Time
ObservationSequence int64
Payload string
ObservedAt time.Time
}
ThreadObservation is an immutable snapshot received from a source.
type ThreadSearchPage ¶
ThreadSearchPage is a paginated result of a thread keyword search.