Documentation
¶
Overview ¶
Package contextual assembles bounded lexical evidence and graph context.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSeedSelector reports a selector that is neither lexical nor a // metadata filter, or that attempts to combine the two modes. ErrInvalidSeedSelector = errors.New("context seed selector is invalid") // ErrInvalidBudget reports a non-positive resource bound or timeout. ErrInvalidBudget = errors.New("context query budget is invalid") // ErrResponseBudgetTooSmall reports a budget unable to encode response metadata. ErrResponseBudgetTooSmall = errors.New("context response budget cannot represent result") )
Functions ¶
This section is empty.
Types ¶
type Completion ¶
type Completion struct {
Complete bool `json:"complete"`
Truncated bool `json:"truncated"`
TimedOut bool `json:"timedOut"`
Visited int `json:"visited"`
ReturnedRows int `json:"returnedRows"`
ResponseBytes int `json:"responseBytes"`
}
Completion describes the bounded execution and encoded response.
type ContextNode ¶
type ContextNode struct {
Node repository.Node `json:"node"`
Path SupportingPath `json:"path"`
}
ContextNode contains a node and its canonical supporting path. Seed nodes have a zero-length path and appear in seed evidence order.
type ContextRequest ¶
type ContextRequest = SearchExpandRequest
ContextRequest describes context assembly. It has the same execution semantics as SearchExpand, but its response prioritizes seed evidence.
type ContextResult ¶
type ContextResult = SearchExpandResult
ContextResult is the assembled evidence context response.
type Evidence ¶
type Evidence struct {
Node repository.Node `json:"node"`
Score float64 `json:"score,omitempty"`
MatchedFields []string `json:"matchedFields,omitempty"`
Snippets map[string]string `json:"snippets,omitempty"`
}
Evidence is a lexical match or a metadata-filter seed. Score and snippet fields are populated only for lexical evidence.
type ProjectionMetadata ¶
type ProjectionMetadata struct {
State string `json:"state"`
NodeRoot repository.ObjectID `json:"nodeRoot"`
}
ProjectionMetadata identifies the branch-head projection used for seed retrieval.
type QueryBudget ¶
type QueryBudget struct {
MaxRows int `json:"maxRows"`
MaxVisited int `json:"maxVisited"`
MaxDepth int `json:"maxDepth"`
MaxResponseBytes int `json:"maxResponseBytes"`
Timeout time.Duration `json:"timeout"`
}
QueryBudget bounds seed retrieval, graph traversal, response size, and time.
func DefaultQueryBudget ¶
func DefaultQueryBudget() QueryBudget
DefaultQueryBudget returns conservative bounds for contextual queries.
type SearchExpandRequest ¶
type SearchExpandRequest struct {
Branch string `json:"branch"`
// Commit optionally identifies a reachable commit. The projection is
// branch-head-only, so a historical commit is intentionally rejected by
// seed retrieval with repository.ErrHistoricalProjectionUnsupported.
Commit *repository.ObjectID `json:"commit,omitempty"`
Seeds SeedSelector `json:"seeds"`
// SeedLimit limits evidence retrieved before graph expansion. Zero uses
// Budget.MaxRows for backward-compatible bounded seed retrieval.
SeedLimit int `json:"seedLimit,omitempty"`
Direction Direction `json:"direction"`
EdgeTypes []string `json:"edgeTypes,omitempty"`
Budget QueryBudget `json:"budget"`
}
SearchExpandRequest describes a lexical-or-filter seed query followed by bounded graph expansion against the same pinned snapshot.
type SearchExpandResult ¶
type SearchExpandResult struct {
Snapshot SnapshotMetadata `json:"snapshot"`
Projection ProjectionMetadata `json:"projection"`
Budget QueryBudget `json:"budget"`
Completion Completion `json:"completion"`
Evidence []Evidence `json:"evidence"`
Nodes []ContextNode `json:"nodes"`
Edges []repository.Edge `json:"edges"`
Paths []SupportingPath `json:"paths"`
CapacityExhausted bool `json:"capacityExhausted,omitempty"`
}
SearchExpandResult is the bounded graph expansion response.
type SeedSelector ¶
type SeedSelector struct {
Query string `json:"query,omitempty"`
Labels []string `json:"labels,omitempty"`
Predicates []repository.MetadataPredicate `json:"predicates,omitempty"`
}
SeedSelector selects ranked lexical evidence or deterministic metadata matches. Query is mutually exclusive with Labels and Predicates.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements contextual graph query use cases.
func NewService ¶
func NewService(repo *repository.Repository) *Service
NewService constructs contextual use cases over repo.
func (*Service) Context ¶
func (s *Service) Context(ctx context.Context, request ContextRequest) (ContextResult, error)
Context retrieves ranked seed evidence first, then bounded related graph context.
func (*Service) SearchExpand ¶
func (s *Service) SearchExpand(ctx context.Context, request SearchExpandRequest) (SearchExpandResult, error)
SearchExpand retrieves lexical or metadata seeds and expands their bounded graph context.
type SnapshotMetadata ¶
type SnapshotMetadata struct {
Branch string `json:"branch"`
Commit repository.ObjectID `json:"commit"`
Snapshot repository.ObjectID `json:"snapshot"`
}
SnapshotMetadata identifies the immutable snapshot used for all returned data.