Documentation
¶
Overview ¶
Package search implements the local search engine over the SQLite store: candidate collection from cached samples, compatibility shards, and the FTS index; C7 score fusion; environment grading with the always-sensitive execution-context axis (docs/execution-context.md §5); and §11.5 delta construction. NO_SAFE_MATCH (Miss) is deliberately better than a wrong HIT (goal.md §3.8).
Package search implements the local search side of CodeSampleX: shard syncing/warming plus (in sibling files) ranking and grading over the local SQLite store. Shards are read-only compatibility summaries pulled from the server; nothing in this package uploads anything.
Index ¶
Constants ¶
const DefaultLimit = 3
DefaultLimit is the result count when the request omits Limit (C7).
Variables ¶
This section is empty.
Functions ¶
func FetchMissing ¶ added in v0.1.4
func FetchMissing(ctx context.Context, e Engine, sy *Syncer, mode string, req domain.SearchRequest) bool
FetchMissing pulls the shards for packages the caller NAMED but this machine has never synced, and reports whether anything new arrived.
It exists because of the shape of the actual question. `csx sync` warms the shards for packages already in the local inventory plus the server's HOT list — and the library an agent asks about is, in the normal case, one it is ABOUT TO ADD. That package is in neither list, so the network could hold a verified answer and this machine would return NO_SAFE_MATCH, advising a `csx sync` that would never fetch it.
Only on a miss, only for packages the caller named, and never from the dependency tree: the tree is context, and fetching a shard names the package to the server.
Community mode only. In local-only mode the whole point is that nothing about the caller's work leaves, and asking for a shard by name would announce the exact interest that mode exists to keep private — so a local-only install answers from what it has, and says so.
func SeedSampleDoc ¶
func SeedSampleDoc(ctx context.Context, db *localdb.DB, manifest domain.SampleManifest, sampleID, status string) error
SeedSampleDoc saves a sample's case + metadata row and indexes its FTS document (kind "sample") in one step. It is the shared ingestion helper for tests, shard warm-up, and sample install: anything that makes a sample locally searchable goes through here so the samples table and the FTS index never drift apart.
Types ¶
type Engine ¶
Engine runs searches over one local store.
func (Engine) Search ¶
func (e Engine) Search(ctx context.Context, req domain.SearchRequest) domain.SearchResponse
Search implements the C7 pipeline: candidate collection (package / symbol / error-fingerprint / FTS sources), score fusion, environment gate + execution-context rules, verification-strength rerank, recency decay, and the known-failure demotion. Best score below the threshold means NO_SAFE_MATCH: Miss=true, no results.
type Syncer ¶
Syncer performs ETag-aware conditional GETs of compatibility shards (contract C6) and indexes their contents into the local FTS table so offline search keeps working during server outages (goal.md §3.9).
func (*Syncer) SyncAll ¶
SyncAll syncs every key, continuing past individual failures so one unreachable shard (or a down server) never blocks the rest (goal.md §3.9). All failures are aggregated into the returned error. SyncAll warms every key and returns HOW MANY ACTUALLY SUCCEEDED.
It used to return only an error, and the caller reported len(keys) as the warmed count — so a sync that failed every key still printed "warmed shard keys: 124" and exited 0. A count of what was attempted is not a count of what worked, and the user was reading it as the latter.