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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
//! The EMISSION NAMESPACE: the mark every name this crate mints into somebody else's scope wears,
//! held as ONE value a front end sets rather than as a constant each mint re-spells.
//!
//! # What the seat is FOR, and who the second occupant is
//!
//! This crate is *model in, tokens out* — the derive builds a model today, and `ingraph-compiler`
//! will build one from a manifest. Both of those are `ingraph`'s own front ends and both want
//! `__ig`. The occupant this seat exists for is the third: a DOMAIN FRAMEWORK that depends on
//! `ingraph-codegen` directly, builds the same models, and emits them under its own name —
//! `mediagraph-codegen` is the first, and it passes `__mg`.
//!
//! Without the seat that framework's expansions would carry `ingraph`'s mark on every name they put
//! in an author's scope, which is wrong twice over: the names read as another crate's, and the
//! FENCE that makes them safe is a fence the other framework's derive is not holding. A namespace
//! is minted in and refused in by the same party or it is not a namespace at all — see
//! [`EmissionPrefix::refused`], which is the half a front end spends before it ever reaches a mint.
//!
//! # MIXED GRAPHS ARE LEGAL, which is why this is a value and not a feature flag
//!
//! One deployment may hold raw-`ingraph` records beside a platform's, and their names are per
//! DECLARATION rather than per build: a `__ig_key__` field on one record and a `__mg_key__` field
//! on the next are two expansions of two models, and nothing downstream is entitled to assume a
//! single mark. A `cfg` or a crate-wide constant would have made that arrangement unrepresentable;
//! a field on the model makes it the ordinary case.
//!
//! # WHAT IS AND IS NOT INSIDE THE SEAT
//!
//! The seat covers every name that lands in a SHARED namespace — the declaring module's scope, a
//! database catalog, a wire face, or an emitted public API. Those are the names a second framework
//! could stand beside, so those are the names a second framework must be able to move.
//!
//! It does NOT cover a name minted inside an anonymous `const _: () = { … }` block or bound by a
//! `let` in a generated function body. Two expansions cannot see one another's anonymous const, so
//! there is nothing there for a mark to separate — `__ig_says_goodbye` in
//! [`crate::emit`] and `__ig_row` in [`crate::aggregate`] are spelled once, collide with nothing,
//! and stay as they are. The tell is the FRAME: a name in the shared namespace wears `__` at both
//! ends, and every one of those is threaded here.
use Cow;
use format_ident;
/// The mark a framework's emitted names are minted under — `__ig` for `ingraph` itself.
///
/// # It holds the mark WITHOUT the joining underscore
///
/// `__ig`, not `__ig_`: the separator belongs to the join rather than to the namespace, because the
/// two shapes this mints — [`framed`](Self::framed) and [`prefixed`](Self::prefixed) — place it
/// identically and a mark carrying its own would make one of them spell a double. It is also the
/// shape the FENCE reads: a declared name is refused for *starting with the mark*, and a fence
/// holding `__ig_` would let a column called `__ig` itself through.
///
/// # `Cow`, because both occupants are real
///
/// The framework's own mark is a `&'static str` and costs nothing to carry; a front end computing
/// one — from a manifest, or from a domain crate's own configuration — owns a `String`. A `Cow`
/// serves both without making the common case allocate, and [`INGRAPH`](Self::INGRAPH) is `const`
/// for the same reason.
;
/// What every namespace leads with, framework's or platform's — and what a DECLARED
/// `<db>(alias(prefix = …))` is held to by [`crate::alias::refused`], which reads it from here.
///
/// The shape a reader already reads as *not the author's*, and the one rule that keeps two
/// frameworks' marks inside one reserved region instead of each confiscating a word of the
/// declaration's own vocabulary. ONE spelling, because the two seats fence the same region: a lead
/// the platform seat admitted and the alias word refused would be a namespace a model could hold
/// and no database could mint in.
pub const FRAMEWORK_LEAD: &str = "__";