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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
use *;
use Value;
// The dimension-agnostic cargo-metadata reads (`cargo_metadata`, `find_package`, `crate_root_file`,
// and `member_src_dirs`, a pure derivation of the latter) live in 星表 (`xingbiao`), the shared
// substrate below the 三儀 — one reader, so the static and semantic dimensions cannot drift apart on
// how they read the workspace. 圭表 keeps only its own *observation semantics* below (dependency
// source/kind, workspace membership), which are not neutral infrastructure.
pub use ;
/// The names of the workspace's member crates. Because Modou runs
/// `cargo metadata --no-deps`, the `packages` array contains exactly the workspace
/// members (no transitive dependencies), so their names are the membership set used
/// by the workspace-scoped rule and by coverage. A `path` dependency that points
/// outside the workspace is therefore absent here, as intended.
pub
/// Whether a `cargo metadata` dependency belongs to the selected table. `kind` is
/// null for normal deps, `"dev"` / `"build"` otherwise.
/// Names of the target's dependencies in the selected table that resolve to a registry
/// or git source. Path/internal dependencies, and dependencies in other tables, are
/// excluded.
///
/// Names are package names, not local renames (`foo = { package = "bar" }` is
/// reported as `bar`), and platform-specific (`[target.'cfg(…)'.dependencies]`) and
/// `optional` deps are included — a declared dependency is governed as declared
/// (PROJECT.md).
pub
/// Whether `dependency` is the package's OWN self-referential edge — Cargo genuinely permits
/// (and a doctest/dogfooding pattern genuinely uses) a crate declaring itself as a
/// `[dev-dependencies]` path dependency on itself (`main = { path = "." }`), which
/// `cargo metadata --no-deps` emits verbatim as an ordinary-shaped edge whose `name` equals the
/// package's own. This is never a CROSS-crate concern — there is no OTHER crate for a governance
/// rule to react to — so every rule that scans "the target's dependency names/sources" must
/// exclude it identically; a per-rule copy of this check (the round-11 fix's original shape,
/// which excluded it only inside `Rule::RestrictWorkspaceDependenciesTo`'s own arm) left the
/// identical false positive live in every sibling rule reading the same [`dependencies`] /
/// [`dependencies_with_disallowed_source`] observation (found on a round-12 adversarial review —
/// see `PROJECT.md`'s Decisions). Filtering here, at the shared observation source, closes every
/// consuming rule at once.
/// Names of the target's dependencies in the selected table, regardless of source —
/// internal workspace path dependencies included. Used by the forbid and restrict-to
/// rules, which (unlike the external rule) must see internal crate-to-crate
/// dependencies. Same conventions as [`external_dependencies`]: package names (not
/// local renames), and platform-specific / `optional` deps are included (PROJECT.md).
/// Never includes the target's own self-referential edge (see [`is_self_dependency`]).
pub
/// The **import identifiers** a crate's declared dependencies are written under in source: each
/// dependency's `rename` when present (a Cargo `pkg = { package = "…" }` / `dep = { package = "…" }`
/// rename), else its package `name`, normalized `-`→`_` to the Rust path spelling (`async-trait` →
/// `async_trait`). This is the vocabulary the inline confinement's `strict_external` modifier
/// matches a fully-qualified path head against.
///
/// 圭表-own (三儀 ⊥ 三儀 — see the module preamble): a small parallel of
/// `hunyi::crate_scope::dependency_names`, **not** a dependency on 渾儀, reading only the
/// `package["dependencies"]` value 圭表 already obtains via 星表 (so no new crate dependency). Unlike
/// [`dependencies`]/[`external_dependencies`] (which read `name` only), it is rename-aware and
/// `-`→`_`-folded, matching the source spelling.
///
/// **Deliberately unfiltered by kind or source** (unlike [`dependencies`]/[`external_dependencies`]):
/// dev-, build-, and path dependencies are all included. A broader name set makes MORE heads resolve
/// as external, never fewer — the fail-safe direction for the one forbidden bug (a false negative) —
/// while the local-precedence ladder still keeps any genuinely-local item local. The only cost is a
/// possible reaction on a dev/build-dep name used inside scanned test code.
pub
/// Classify a dependency's **declared** source kind from its `cargo metadata`
/// (`--no-deps`) `source` field. Mirrors [`external_dependencies`]'s convention (a
/// null source is internal/path) one notch finer:
///
/// - **null** source → `Path` (a `path = "…"` / internal dependency)
/// - source beginning **`git+`** → `Git` (cargo spells a declared git source `git+<url>`)
/// - any other non-null source → `Registry` (the residual: `registry+`, `sparse+`, and
/// alternative registries, so a new registry scheme classifies correctly with no code
/// change — the same robustness `external_dependencies` relies on)
///
/// Only `Git` is matched by a positive prefix and only `Path` by null; `Registry` is the
/// residual. Verified against `cargo metadata --no-deps` on a probe manifest: a
/// `git = "…"` dependency reads `source = "git+…"` **even with a `version` key and even
/// when `optional = true`**, and a workspace-**inherited** git dependency
/// (`{ workspace = true }`) reads `git+…` too (cargo flattens the inherited source into
/// the member's manifest). A path dependency reads `source = null`. The read is hermetic
/// — a pure function of the manifests, no lockfile and no network.
/// The **real package names** (not local renames) of the target's dependencies in the
/// selected table whose classified [`SourceKind`] is not in `allowed`. The observation
/// for [`Rule::RestrictDependencySourcesTo`]. Same conventions as [`dependencies`]:
/// walks every declared dependency of the kind (path/internal included, since `Path` is
/// a governed source), reports the package name (a renamed dep by its real name), and
/// includes `optional` deps — a declared source is governed as declared (PROJECT.md), and
/// an optional git dependency blocks publishing just as a required one does. An empty
/// `allowed` set flags every dependency of the kind. Never includes the target's own
/// self-referential edge (see [`is_self_dependency`]) — its declared source (always `Path`,
/// a null `source`) is otherwise indistinguishable from a genuine internal dependency.
pub
/// The **declared feature request** the target authors on a dependency `crate_name` in
/// the selected table: the union, across every matching edge, of each edge's explicit
/// `features = [...]` list, ∪ the pseudo-feature `default` when any such edge leaves
/// default features enabled (`uses_default_features` absent, or `true`). Matches
/// `crate_name` by **package name** (the `name` field), not a local `rename`/alias, exactly
/// as [`dependencies`]/[`external_dependencies`] do — a dependency renamed `myc` whose real
/// package is `real-c` is matched as `real-c`. A crate may appear under more than one edge
/// of the same kind — a plain `[dependencies]` entry and a `[target.'cfg(…)'.dependencies]`
/// entry are both `Normal` — so the set is the union across all of them.
///
/// Reads only the target package's own declared edges: it never reads `crate_name`'s
/// package entry (unreadable for an external crate under the `--no-deps` substrate) and
/// never reads `resolve.nodes[].features` (the resolved/unified set, which feature
/// unification folds every workspace crate's enables into). The result is therefore the
/// target's authored request alone — declared, not resolved (PROJECT.md) — and does not
/// expand through `crate_name`'s own `[features]` table, so a transitively-enabled feature
/// is not chased. When the target does not declare `crate_name` in the selected kind, the
/// set is empty. If `crate_name` names the target's OWN package (a `RestrictFeaturesOf`/
/// `ForbidFeaturesOf` boundary naming its own crate — a possible, if unusual, constitution
/// shape), the target's self-referential edge (see [`is_self_dependency`]) is never matched
/// either: a self-dependency's "declared feature request" is not a cross-crate feature-flag
/// concern this rule exists to govern.
pub