1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! 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:
//!
//! 1. define grammar metadata in [`grammar`]
//! 2. publish that metadata into an existing project snapshot with [`build`]
//! 3. reopen the snapshot through [`resolver`]
//! 4. start from authoritative participating files
//! 5. use grammar-aware narrowing only as an optimization layer
//!
//! # Public Modules
//!
//! - [`build`] publishes grammar specifications and external-driver payloads
//! into a project snapshot
//! - [`grammar`] defines the build-side grammar model and query-time capability
//! contract
//! - [`resolver`] exposes 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
//!
//! ```no_run
//! use gritpack_searchlib::grammar::GrammarId;
//! use gritpack_searchlib::resolver::{
//! LoadedProjectResolver, ModuleQuery, PackageScope, ParticipatingFileQuery,
//! QuerySelection, ReferenceQuery,
//! };
//!
//! # async fn demo() -> Result<(), gritpack_searchlib::CliError> {
//! 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}");
//! }
//! }
//! _ => {}
//! }
//! # Ok(())
//! # }
//! ```
use ;
use ;
pub use CliError;