Expand description
Compiler-facing resolver and grammar integration surface for Gritpack.
This crate is the handoff boundary for compiler, language-server, and other language-tooling integrations. It intentionally exposes the narrow read-side resolver API, the build-side grammar publication helpers, and the shared grammar model types.
§Who This Is For
gritpack-searchlib is for compiler and toolchain authors who need to work
against a compiled Gritpack project snapshot.
The primary workflow is:
- define grammar metadata in
grammar - publish that metadata into an existing project snapshot with
build - reopen the snapshot through
resolver - start from authoritative participating files
- use grammar-aware narrowing only as an optimization layer
§Public Modules
buildpublishes grammar specifications and external-driver payloads into a project snapshotgrammardefines the build-side grammar model and query-time capability contractresolverexposes the read-only resolver API over compiled snapshot state
§Correctness Model
The key rule for consumers is:
- participating files are the correctness baseline
- grammar-aware queries are narrowing optimizations over that baseline
If a narrowing answer is non-authoritative, callers should fall back to the broader participating-file set before making semantic decisions.
§Quick Start
use gritpack_searchlib::grammar::GrammarId;
use gritpack_searchlib::resolver::{
LoadedProjectResolver, ModuleQuery, PackageScope, ParticipatingFileQuery,
QuerySelection, ReferenceQuery,
};
let resolver = LoadedProjectResolver::open(std::path::Path::new("/workspace/project")).await?;
let participating = resolver.participating_files(&ParticipatingFileQuery {
package_scope: PackageScope::AnyDependency,
});
assert!(participating.authoritative);
let grammar = GrammarId {
dialect: "lumen/1.0.0".to_string(),
name: "modules".to_string(),
version: 1,
};
match resolver.files_for_query(
&grammar,
&ReferenceQuery::Modules(vec![ModuleQuery {
package_scope: PackageScope::AnyDependency,
name: "demo::thing".to_string(),
}]),
)? {
Some(QuerySelection::Files(selection)) if selection.authoritative => {
for path in selection.file_paths {
println!("candidate={path}");
}
}
_ => {}
}Modules§
- build
- Build-side helpers for publishing grammar data into a Gritpack resolver snapshot.
- grammar
- Build-side grammar model for Gritpack resolver indexes.
- resolver
- Read-only resolver API over a compiled Gritpack project snapshot.