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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//! **THE SUGAR WORD'S EXPANSION** — `knn(searchable(tower = "…"))` written back out as the
//! `#[ingraph::search]` recipe an author would otherwise have typed, and put through the pipeline
//! that reads a typed one.
//!
//! ```ignore
//! #[ingraph::vector(upstream(node = "Keyframe", clip = "clip"), dedup(hash), graphql(async_graphql))]
//! pub struct Shots {
//! #[ingraph(embedding, knn(searchable(tower = "crate::ClipText")), toy)]
//! clip: Embedding<f32, DIM, Clip>,
//! }
//! ```
//!
//! forges, beside the index's own expansion:
//!
//! ```ignore
//! #[ingraph::search(crate = "::ingraph",
//! shared(question(type = "<crate::ClipText as ::ingraph::SearchTower>::Question")),
//! graphql(async_graphql))]
//! pub struct ShotsClipSearch {
//! #[ingraph(tower(question(type = "crate::ClipText", shared)))]
//! shots: Shots,
//! }
//! ```
//!
//! # NOTHING IS UNDER IT, and that is the whole claim
//!
//! This module builds a DECLARATION and hands it to [`super::parse`] and `SearchModel::emit` — the
//! same two functions the attribute macro calls, in the same order, with the host echoed the same
//! way. There is no recipe emitter for a forged recipe, no runtime trait a sugared column has and a
//! hand-written one does not, and no branch anywhere downstream that asks which of the two it is
//! looking at. `sugar/tests.rs` pins the claim by expanding both and comparing the tokens.
//!
//! The consequence a reader should draw from that is the SUPPORT boundary: a sugared column has
//! exactly the recipe words this module writes, and the moment a second one is wanted — a weight, a
//! floor, a second member, a second seat — the answer is to write the recipe, not to grow this
//! grammar. The refusal inside `searchable(…)` says so in as many words.
//!
//! # The four things the word decides, and where each comes from
//!
//! | piece | source |
//! |---|---|
//! | the recipe's NAME, and therefore its wire fields | `{Index}{Field}Search`, in the emission's own camel-join convention |
//! | the shared SEAT's type | the TOWER's, read as `<Tower as SearchTower>::Question` rather than restated |
//! | the arm's binding | `shared`, bare — one seat and one arm of one name, so the resolution is by name |
//! | whether a wire field lands at all | the INDEX's own `graphql(…)` block, passed through |
//!
//! The seat's type is a PROJECTION and not a copy, which is the property that keeps the two
//! declarations from drifting: a tower that changes what it is asked changes this seat with it, and
//! a recipe that had restated the type would have gone quietly wrong at the next edit.
use ToUpperCamelCase as _;
use ;
use quote;
/// Every recipe this declaration's elections asked for, expanded.
///
/// EMPTY where no election wrote the word, which is every declaration written before it existed —
/// the sugar adds items and moves none, so an index that says nothing expands to exactly what it
/// expanded to yesterday.
pub
/// ONE forged recipe, through the recipe macro's own body.
///
/// The order is `equipped`'s, because it IS `equipped`'s: echo the host, parse, emit. A refusal
/// becomes a `compile_error!` beside the host for the reason every other one does — an attribute
/// macro replaces the item it sits on, so deleting the type would bury the message under every
/// mention of it.
/// The two-piece set as TOKENS — the recipe's arguments and the struct they sit on.
///
/// Separate from [`forge`] so a test can read the DECLARATION this word stands for, which is the
/// thing an author has to be able to picture: the equivalence pin compares expansions, and this
/// function is what makes the two sides of it readable side by side.
pub
/// `graphql(<backend>, …)` for the forged recipe — the INDEX's own block, passed through.
///
/// Inherited rather than always written, and never invented: the recipe's wire face is what this
/// word is for, but WHICH backends dress a declaration is a decision its author already made one
/// grain up. An index that dresses nothing forges a recipe that dresses nothing — it still mints
/// the fusion door and the packages, exactly as a hand-written `#[ingraph::search]` with no
/// `graphql(…)` does.
/// `{Index}{Field}Search` — the forged recipe's name.
///
/// The emission's own camel-join convention, for the reason `{Index}{Field}{Engine}` and
/// `{Record}By{Field}` take it: a name a declaration can COLLIDE with is refused at the declaration
/// rather than mangled out of reach, and a reader who has to find this type in a schema can spell
/// it. It is also the wire face — `shotsClipSearch` and `shotsClipSearchKeys` are `lower_initial`
/// of exactly this — so a mangled name would have crossed the wire.
/// The forged recipe's ONE member field — the index, under its own name.
///
/// The INDEX's name and not the election's, because a member IS an index: it is what the evidence
/// arm is named after (`{Recipe}{Member}Sighting`), and naming it for the column would tell a reader
/// of that arm that the recipe fuses columns.
/// Tokens as the quoted string the recipe grammar reads a type out of.