delvewright_dsl/diagnostic.rs
1//! Diagnostics: the `--json` shape from spec-0002 and the stable `DW01xx` codes.
2//!
3//! # One cause, one line
4//!
5//! **A secondary whose premise is an already-reported primary is folded into
6//! that primary or suppressed, and the line that survives says how many
7//! dependants it stands for.** A refusal is the whole product at the moment an
8//! author meets it, and N copies of one sentence is a count the reader has to
9//! discount rather than information — worse, the copies come first and bury the
10//! one line that is theirs to act on.
11//!
12//! Measured on a 24-place campaign: deleting `layout-graph.json` printed
13//! `DW0824` (correct, one line) and then **`DW0842` twenty-four times**, once
14//! per `details[]` row, each saying the plan resolves 0 boxes; shortening the
15//! region by five courses printed **`DW0826` twenty-four times**, once per box,
16//! for one number in one document.
17//!
18//! The rule has two shapes, and which one applies is decided by whether the
19//! secondary still has anything of its own to say:
20//!
21//! 1. **Fold.** Every finding shares one cause and one repair, so they are one
22//! diagnostic naming all of them. The code is unchanged and still fires per
23//! item the moment the items differ — the folded arm is reachable only in the
24//! state that makes them identical. Instances: [`codes::QUEST_NOT_EXPANDED`]
25//! when stage 5 is empty (`crate::validate`), `DW0842` at a zero box count
26//! (`compiler::detail`), `DW0826` when more than one thing leaves the region
27//! (`crate::siteplan`).
28//! 2. **Defer.** The secondary is a real, separate finding whose NUMBER was
29//! measured against something already refused, so it keeps its own line and
30//! gains a clause naming what it is downstream of. Instances: `DW0818`'s
31//! clause when stage 5 declares no quests (`crate::layout`), and
32//! `crate::siteplan::off_grid_note` on every verdict computed from a box
33//! `DW0825` has refused.
34//!
35//! What the rule never does is drop a code's ability to refuse. Folding changes
36//! how many lines say a thing, never whether the run stops: every fold above is
37//! an error tier that still exits non-zero, and each has a test on both sides —
38//! primary present, one line; primary absent, the secondary fires per item as
39//! before.
40
41use serde::Serialize;
42
43/// **Which exit status a hard failure carrying this code ends the run with.**
44///
45/// The question this answers, and the only question it answers: *when this code
46/// is what stopped the run, does the process exit 2 or 3?*
47///
48/// * [`ExitTier::Analysis`] — **exit 2.** The compiler did its job and the
49/// CONTENT is the defect: a quest nothing can reach, a room too dark to read,
50/// a wave larger than the room it spawns in. The author fixes a campaign
51/// document or a prefab; nothing about the engine is wrong.
52/// * [`ExitTier::Build`] — **exit 3.** The compiler could not produce a tree it
53/// is willing to stand behind: geometry, navigation, the solver, the emitted
54/// call graph.
55///
56/// # Why it lives on the code and not at the call site
57///
58/// The tier is a property of the RULE — `DW0210` is an analysis-tier refusal
59/// wherever it is raised — and it was nonetheless re-derived from the code's
60/// SPELLING at three separate places in `delvec`'s `main`, each a copy of
61/// `code.id().starts_with("DW02") || code == …` with three named exceptions
62/// appended. Three copies of a rule is three chances to update two of them, and
63/// the spelling is not the rule: `DW0312`, `DW0313` and `DW0342` are
64/// analysis-tier codes whose numbers say otherwise, which is exactly why the
65/// exceptions had to be written out by hand in the first place.
66///
67/// # What a code that never stops a build declares
68///
69/// Most codes are reported as a [`Diagnostic`] among their phase's findings, and
70/// the PHASE decides the exit (`validate` exits 1, `analyze` exits 2). Such a
71/// code declares [`ExitTier::Build`], and that is a statement rather than a
72/// placeholder: it says that IF this rule ever refuses with a build under way,
73/// it stops the build. That is precisely what the string-prefix predicate did
74/// for every code it did not recognise, so the declaration is the behaviour,
75/// written down where the rule is.
76///
77/// There is no `Default` and no constructor that leaves it unsaid — a new
78/// code cannot be added without answering.
79#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
80pub enum ExitTier {
81 /// Exit 2: the content is the defect, not the build.
82 Analysis,
83 /// Exit 3: the compiler could not produce a tree.
84 Build,
85}
86
87impl ExitTier {
88 /// The process exit status this tier ends the run with.
89 ///
90 /// The numbers are the CLI's stable contract (`docs/reference/compiler.md`
91 /// §1): `0` ok, `1` validation, `2` analysis, `3` build.
92 pub const fn exit_status(self) -> u8 {
93 match self {
94 ExitTier::Analysis => 2,
95 ExitTier::Build => 3,
96 }
97 }
98}
99
100/// A stable DW diagnostic code together with the exit tier it stops a run at
101/// ([`ExitTier`]) and whose state its verdict is about ([`Subject`]).
102///
103/// A code is not a string that a check happens to quote; it is a rule with its
104/// properties, and they travel with it to every site that raises it. Every
105/// rule applies to every document the engine accepts (ADR-0024): there is one
106/// `dsl_version`, so a code carries nothing about when it starts binding.
107#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
108pub struct DwCode {
109 id: &'static str,
110 tier: ExitTier,
111 subject: Subject,
112}
113
114impl DwCode {
115 /// A rule, with the tier it exits at — see [`ExitTier`].
116 pub const fn new(id: &'static str, tier: ExitTier) -> DwCode {
117 DwCode {
118 id,
119 tier,
120 subject: Subject::Campaign,
121 }
122 }
123
124 /// Mark this code an **engine-property notice** — see [`Subject::Engine`]
125 /// for the test to apply before choosing it. Chained onto the constructor,
126 /// because the two questions are independent: *whose state is it about*,
127 /// and *what does it exit with*.
128 pub const fn about_the_engine(self) -> DwCode {
129 DwCode {
130 id: self.id,
131 tier: self.tier,
132 subject: Subject::Engine,
133 }
134 }
135
136 /// The stable code string (`DW0180`).
137 pub const fn id(self) -> &'static str {
138 self.id
139 }
140
141 /// Which exit status a hard failure carrying this code ends the run with.
142 pub const fn exit_tier(self) -> ExitTier {
143 self.tier
144 }
145
146 /// Whose state this code's verdict is about.
147 pub const fn subject(self) -> Subject {
148 self.subject
149 }
150}
151
152impl Serialize for DwCode {
153 /// Serializes as the bare code string: a `DwCode` in a JSON payload is the
154 /// `&'static str` it replaced; the tier and the subject are compiler-internal.
155 fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
156 s.serialize_str(self.id)
157 }
158}
159
160impl std::fmt::Display for DwCode {
161 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
162 f.write_str(self.id)
163 }
164}
165
166impl AsRef<str> for DwCode {
167 fn as_ref(&self) -> &str {
168 self.id
169 }
170}
171
172impl PartialEq<DwCode> for String {
173 fn eq(&self, other: &DwCode) -> bool {
174 self == other.id
175 }
176}
177
178impl PartialEq<String> for DwCode {
179 fn eq(&self, other: &String) -> bool {
180 self.id == other
181 }
182}
183
184impl PartialEq<DwCode> for str {
185 fn eq(&self, other: &DwCode) -> bool {
186 self == other.id
187 }
188}
189
190impl PartialEq<DwCode> for &str {
191 fn eq(&self, other: &DwCode) -> bool {
192 *self == other.id
193 }
194}
195
196impl PartialEq<&str> for DwCode {
197 fn eq(&self, other: &&str) -> bool {
198 self.id == *other
199 }
200}
201
202/// Diagnostic severity.
203#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
204#[serde(rename_all = "lowercase")]
205pub enum Severity {
206 /// A hard rejection.
207 Error,
208 /// Advisory. Reported and rendered like an error, but does **not** fail the
209 /// run — `delvec` exits non-zero only on [`Severity::Error`]. Reserved for
210 /// rules whose verdict depends on something the compiler cannot fully know
211 /// (e.g. `DW0330`: how much text fits depends on the player's window size and
212 /// GUI scale), where a hard rejection would be a guess dressed as a fact.
213 Warning,
214}
215
216/// One diagnostic, serialized as one JSON object per line by `delvec --json`.
217///
218/// Field order matches spec-0002: `code`, `severity`, `stage`, `path`, `message`.
219#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
220pub struct Diagnostic {
221 /// Stable machine code, e.g. `DW0101`.
222 pub code: String,
223 /// Severity.
224 pub severity: Severity,
225 /// The stage this diagnostic concerns (`world`, `npcs`, …), or empty.
226 pub stage: String,
227 /// JSON-pointer-ish location within the stage document.
228 pub path: String,
229 /// Human-readable explanation.
230 pub message: String,
231 /// Whose state this verdict is about, carried over from the [`DwCode`] that
232 /// raised it — the key `delvec` groups its output by.
233 ///
234 /// Not part of the `--json` wire shape (spec-0002 fixes that at `code`,
235 /// `severity`, `stage`, `path`, `message`): it decides how the run PRESENTS
236 /// a diagnostic, never something a consumer reads off one.
237 #[serde(skip)]
238 pub subject: Subject,
239}
240
241impl Diagnostic {
242 /// Build an error diagnostic.
243 pub fn error(
244 code: DwCode,
245 stage: impl Into<String>,
246 path: impl Into<String>,
247 message: impl Into<String>,
248 ) -> Self {
249 Diagnostic {
250 code: code.id().to_string(),
251 severity: Severity::Error,
252 stage: stage.into(),
253 path: path.into(),
254 message: message.into(),
255 subject: code.subject(),
256 }
257 }
258
259 /// Build a warning (advisory) diagnostic. Reported, but does not fail the run.
260 pub fn warning(
261 code: DwCode,
262 stage: impl Into<String>,
263 path: impl Into<String>,
264 message: impl Into<String>,
265 ) -> Self {
266 Diagnostic {
267 code: code.id().to_string(),
268 severity: Severity::Warning,
269 stage: stage.into(),
270 path: path.into(),
271 message: message.into(),
272 subject: code.subject(),
273 }
274 }
275
276 /// **Which of a run's three groups this line belongs in**, lowest first.
277 ///
278 /// The one authority on the order `delvec` prints in. See [`Subject`] for
279 /// what the split is and why.
280 #[must_use]
281 pub fn group(&self) -> Group {
282 match (self.severity, self.subject) {
283 (Severity::Error, _) => Group::Refusal,
284 (Severity::Warning, Subject::Campaign) => Group::AboutTheCampaign,
285 (Severity::Warning, Subject::Engine) => Group::AboutTheEngine,
286 }
287 }
288}
289
290/// **Whose state a code's verdict is about.**
291///
292/// The question this answers, and the only question it answers: *if the author
293/// changed nothing about their campaign and the engine's own tables were
294/// finished, would this line go away?*
295#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
296pub enum Subject {
297 /// The campaign. Every refusal, and every advisory whose verdict is a fact
298 /// about the documents in front of the author — the default, because a
299 /// diagnostic is addressed to an author unless it says otherwise.
300 #[default]
301 Campaign,
302 /// **The ENGINE**, regardless of the campaign: an engine table that is still
303 /// seeded, a standard that has not been calibrated. Nothing the author can
304 /// write moves it, and it is identical on every campaign the engine
305 /// compiles, so it prints after the lines that ARE theirs — see [`Group`].
306 ///
307 /// This is not a licence to make a campaign's problem quiet. The test is
308 /// whether the line would read the same on a different campaign; where it
309 /// names something the author wrote, it is a [`Subject::Campaign`] verdict
310 /// however advisory its tier.
311 Engine,
312}
313
314/// **The order a run's diagnostics are printed in**, and the labels they are
315/// printed under.
316///
317/// Author-actionable first, then advisories about the campaign, then notices
318/// about the engine. Measured on every site-plan run before this existed: four
319/// to six paragraphs saying "this is fine" or "the engine's own table is
320/// provisional", ahead of the one line the author was there to act on.
321///
322/// Ordering only — nothing is dropped, and every code that reported before
323/// reports now.
324#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
325pub enum Group {
326 /// A hard rejection. Yours to act on.
327 Refusal,
328 /// An advisory about the campaign: a measurement, or a verdict that depends
329 /// on something outside the documents.
330 AboutTheCampaign,
331 /// A notice about this engine, true regardless of the campaign.
332 AboutTheEngine,
333}
334
335impl Group {
336 /// The heading this group is printed under, with `n` lines in it.
337 #[must_use]
338 pub fn heading(self, n: usize) -> String {
339 match self {
340 Group::Refusal => format!("-- {n} refusal(s): these are yours to act on"),
341 Group::AboutTheCampaign => format!("-- {n} advisory(ies) about this campaign"),
342 Group::AboutTheEngine => {
343 format!("-- {n} notice(s) about this engine, true of any campaign")
344 }
345 }
346 }
347}
348
349/// The stable validation diagnostic codes (catalogued in
350/// `docs/reference/compiler.md` §5).
351///
352/// Every entry is a [`DwCode`], so every entry states its exit tier — there is
353/// no way to add one that does not.
354pub mod codes {
355 use super::{DwCode, ExitTier};
356
357 /// Document does not conform to its stage schema (unknown field / wrong type).
358 pub const SCHEMA: DwCode = DwCode::new("DW0100", ExitTier::Build);
359 /// Envelope `stage` does not match the document's slot.
360 pub const STAGE_MISMATCH: DwCode = DwCode::new("DW0101", ExitTier::Build);
361 /// Unsupported `dsl_version`.
362 pub const DSL_VERSION: DwCode = DwCode::new("DW0102", ExitTier::Build);
363 /// Inconsistent `campaign_id` across stages.
364 pub const CAMPAIGN_ID_MISMATCH: DwCode = DwCode::new("DW0103", ExitTier::Build);
365 /// Malformed id syntax (kebab-case / prefix).
366 pub const ID_SYNTAX: DwCode = DwCode::new("DW0110", ExitTier::Build);
367 /// Duplicate id within its namespace.
368 pub const ID_DUPLICATE: DwCode = DwCode::new("DW0111", ExitTier::Build);
369 /// Dangling reference: an id ref does not resolve.
370 pub const DANGLING_REF: DwCode = DwCode::new("DW0112", ExitTier::Build);
371 /// Stage-6 dialogue node unreachable from `root`.
372 pub const DIALOGUE_UNREACHABLE: DwCode = DwCode::new("DW0120", ExitTier::Build);
373 /// Stage-6 dialogue `root`/`next` references an unknown node.
374 pub const DIALOGUE_BAD_REF: DwCode = DwCode::new("DW0121", ExitTier::Build);
375 /// Stage-6 dialogue effect references an objective that is unknown, not a
376 /// `talk-to`, or a `talk-to` on a different NPC (foreign effect).
377 pub const DIALOGUE_BAD_OBJECTIVE: DwCode = DwCode::new("DW0122", ExitTier::Build);
378 /// A stage-5 `talk-to` objective has no reachable completing dialogue option
379 /// (the static half of the compiler's `DW0203` deadlock guarantee).
380 pub const DIALOGUE_UNCOVERED: DwCode = DwCode::new("DW0123", ExitTier::Build);
381 /// Quest dependency cycle.
382 pub const PLAN_CYCLE: DwCode = DwCode::new("DW0130", ExitTier::Build);
383 /// `finale` is not a declared quest.
384 pub const FINALE_UNKNOWN: DwCode = DwCode::new("DW0131", ExitTier::Build);
385 /// `finale` is not the convergent sink of the plan: some declared quest is
386 /// not a transitive dependency of it.
387 ///
388 /// **The name deliberately does not contain `FINALE_UNREACHABLE`, which
389 /// belongs to `DW0201`.** That code says the finale can never complete; this
390 /// one says nothing at all about the finale being reachable — in the fixture
391 /// that raises it the finale completes perfectly well and a side trip hangs
392 /// off the plan. Both are `DwCode`, so nothing but the name distinguishes
393 /// them at a call site, and `tools/ci/check-dw-codes.py` credits a bare
394 /// constant name mentioned in a crate's tests to **that crate's** code — so
395 /// one shared name would buy coverage for whichever rule the file happens to
396 /// sit next to.
397 pub const PLAN_NOT_CONVERGENT: DwCode = DwCode::new("DW0132", ExitTier::Build);
398 /// An optional quest inside the finale's dependency closure (spec-0051
399 /// §8.1) — including a finale that declares itself optional.
400 pub const OPTIONAL_ON_SPINE: DwCode = DwCode::new("DW0866", ExitTier::Build);
401 /// A mandatory quest whose `depends_on` edge or stage-5 `quest-complete`
402 /// trigger names an optional quest (spec-0051 §8.2).
403 pub const MANDATORY_ON_OPTIONAL: DwCode = DwCode::new("DW0867", ExitTier::Build);
404 /// A mandatory objective gated on a flag only an optional quest produces
405 /// (spec-0051 §8.3) — the mainline key behind participation.
406 ///
407 /// The participation-minimal replay (`DW0204`) is the compensating stronger
408 /// check behind it; this one refuses at the edge so the message can name
409 /// the strand.
410 pub const MAINLINE_KEY_OPTIONAL: DwCode = DwCode::new("DW0868", ExitTier::Build);
411 /// Objective `after` cycle.
412 pub const AFTER_CYCLE: DwCode = DwCode::new("DW0140", ExitTier::Build);
413 /// Anchor not provided by the area's bound prefab.
414 pub const ANCHOR_UNRESOLVED: DwCode = DwCode::new("DW0142", ExitTier::Build);
415 /// Item id not in the pinned 1.21.11 registry.
416 pub const ITEM_UNKNOWN: DwCode = DwCode::new("DW0143", ExitTier::Build);
417 /// (spec-0021) An `equipment` or `loot` enchantment id is not in the pinned
418 /// 1.21.11 enchantment registry.
419 pub const ENCHANTMENT_UNKNOWN: DwCode = DwCode::new("DW0433", ExitTier::Build);
420 /// (spec-0021) An enchantment level is outside the 1..=255 range vanilla's
421 /// `minecraft:enchantments` component can carry.
422 pub const ENCHANTMENT_LEVEL: DwCode = DwCode::new("DW0434", ExitTier::Build);
423 /// (spec-0021) Two `loot` entries target the same anchor, so one would
424 /// silently overwrite the other's contents.
425 pub const LOOT_DUPLICATE_ANCHOR: DwCode = DwCode::new("DW0435", ExitTier::Build);
426 /// (spec-0021) A `loot` declaration carries more stacks than the container
427 /// it fills has slots.
428 pub const LOOT_TOO_MANY_ITEMS: DwCode = DwCode::new("DW0432", ExitTier::Build);
429 /// A single-slot fill's `count` exceeds the item's `minecraft:max_stack_size`
430 /// in the pinned 1.21.11 registry. `item replace … container.<n> with <item>
431 /// <count>` fails **silently** above the cap, shipping an empty slot.
432 pub const ITEM_COUNT_OVER_STACK: DwCode = DwCode::new("DW0436", ExitTier::Build);
433 /// An `interact` declares `missing_item_hint` without a `requires_item`: the
434 /// hint answers a gate that does not exist, so it could never narrate.
435 pub const MISSING_ITEM_HINT_WITHOUT_ITEM: DwCode = DwCode::new("DW0437", ExitTier::Build);
436 /// Planned quest (stage 4) has no expansion in stage 5.
437 pub const QUEST_NOT_EXPANDED: DwCode = DwCode::new("DW0150", ExitTier::Build);
438 /// Stage-5 quest is not planned in stage 4.
439 pub const QUEST_NOT_PLANNED: DwCode = DwCode::new("DW0151", ExitTier::Build);
440 /// Stage-2 NPC has no stage-6 dialogue tree.
441 pub const NPC_WITHOUT_TREE: DwCode = DwCode::new("DW0152", ExitTier::Build);
442 /// Stage-6 dialogue tree references an NPC not declared in stage 2.
443 pub const TREE_WITHOUT_NPC: DwCode = DwCode::new("DW0153", ExitTier::Build);
444 /// Area binds neither or both of `prefab` / `prefab_pool` (exactly one
445 /// required).
446 pub const PREFAB_BINDING: DwCode = DwCode::new("DW0160", ExitTier::Build);
447 /// Area `prefab_pool` references a pool absent from `prefabs/` metadata.
448 pub const POOL_UNKNOWN: DwCode = DwCode::new("DW0161", ExitTier::Build);
449 /// Area `prefab` names a piece absent from `prefabs/` metadata — the same
450 /// obligation [`POOL_UNKNOWN`] carries on the other arm of the binding. It
451 /// is an error rather than a deferral because an area whose piece is absent
452 /// contributes no anchor set at all, so every per-area anchor proof over it
453 /// is SKIPPED rather than failed: a misspelling here is strictly less
454 /// checked than a correct name.
455 pub const PREFAB_UNKNOWN: DwCode = DwCode::new("DW0856", ExitTier::Build);
456 /// (v0.6, spec-0017) A stage-7 edit script is structurally invalid: an edit
457 /// names a region no earlier `select` in its batch defined, a composition
458 /// (`union`/`intersect`/`subtract`) lists too few regions, a box `min`
459 /// exceeds `max` on an axis, a surface band's `from` exceeds `to`, a palette
460 /// recipe is empty / carries a non-positive or non-finite weight or `scale`,
461 /// a `matching` list is empty, or a morph `by`/`passes` is 0. (Unknown block
462 /// ids in recipes reuse [`BLOCK_UNKNOWN`] / `DW0193`; id-syntax and
463 /// duplicate-name violations reuse `DW0110`/`DW0111`.)
464 pub const EDIT_INVALID: DwCode = DwCode::new("DW0162", ExitTier::Build);
465 /// (v0.3) A `kill` objective or `spawn-wave` effect references a `wave/<id>`
466 /// not declared in the stage-5 `waves` section (dangling wave reference).
467 pub const WAVE_UNKNOWN: DwCode = DwCode::new("DW0170", ExitTier::Build);
468 /// (v0.3) A declared wave is referenced by a `kill` objective but is never
469 /// spawned by any `spawn-wave` effect (referenced-but-never-spawned). A wave
470 /// must be spawned by some effect before its kill objective is reachable.
471 pub const WAVE_NEVER_SPAWNED: DwCode = DwCode::new("DW0171", ExitTier::Build);
472 /// (v0.3) A `requires_flags` entry references a `flag/<id>` that no `set-flag`
473 /// effect ever produces (dangling flag reference).
474 pub const FLAG_UNKNOWN: DwCode = DwCode::new("DW0172", ExitTier::Build);
475 /// (spec-0016 §1) A wave declares `respawns_on_rest: true` but the campaign
476 /// declares no `bonfire` — nothing can ever re-seat it, so the field is a
477 /// silent no-op. Either add the bonfire the re-seat is meant to hang off, or
478 /// drop the field.
479 pub const REST_RESEAT_NO_BONFIRE: DwCode = DwCode::new("DW0370", ExitTier::Build);
480 /// (spec-0016 §1) The campaign places a `bonfire`
481 /// but no class kit declares a `flask`. Resting replenishes the flask to its
482 /// declared count; with no flask the rest interaction's whole recovery half
483 /// is a no-op and the souls loop has no consumable to spend, so this is a
484 /// build error rather than a design choice.
485 pub const BONFIRE_NO_FLASK: DwCode = DwCode::new("DW0476", ExitTier::Build);
486 /// **An item gate a class cannot bring.** An objective completes only for a
487 /// player holding a named item, and some class's player has no way to be
488 /// holding it: the item's only source in the whole campaign is *another*
489 /// class's kit, or it has no source at all.
490 ///
491 /// A delve is played by one to four players who each pick one class, so an
492 /// objective reachable only by one class's pick is an objective a party can
493 /// be assembled unable to finish — and the party finds out at the thing they
494 /// cannot press. Quantified over EVERY class for the same reason
495 /// [`BONFIRE_NO_FLASK`] is: one class that cannot bring it is as broken as
496 /// none, because a solo player of that class is a supported party.
497 pub const ITEM_GATE_UNBRINGABLE: DwCode = DwCode::new("DW0849", ExitTier::Build);
498 /// (spec-0016 §1) A kit item's potion `contents`
499 /// is not something 1.21.11 can pour: declared on an item that carries no
500 /// `minecraft:potion_contents` component, empty (neither a named potion nor
501 /// an effect), an unknown potion or status-effect id, an amplifier or
502 /// duration outside the field vanilla stores it in, a lasting effect with no
503 /// `duration`, an instantaneous one *with* a duration, or a malformed
504 /// `color`.
505 pub const KIT_POTION_INVALID: DwCode = DwCode::new("DW0486", ExitTier::Build);
506 /// (spec-0016 §1) A potion-bearing kit item
507 /// declares no `contents` at `dsl_version` 0.8.0 — the Uncraftable Potion, a
508 /// bottle that pours nothing. The placeholder flask, as a build error.
509 pub const KIT_POTION_MISSING: DwCode = DwCode::new("DW0487", ExitTier::Build);
510 /// A `drops[]` `slot` entry does not
511 /// name a distinct slot the same entity's `equipment` actually fills — the
512 /// slot is empty, or the same slot is declared twice. A mob can only leave
513 /// behind a piece it wears, and it can only leave it behind once.
514 pub const DROP_SLOT_UNFILLED: DwCode = DwCode::new("DW0490", ExitTier::Build);
515 /// `drops[]` on an encounter that is
516 /// not billed `elite` or `boss`. Only a named fight leaves anything behind;
517 /// an ordinary mob's kit is never farmable (no-grind constitution), so the
518 /// declaration is refused rather than silently making rank-and-file gear
519 /// lootable.
520 pub const DROP_NOT_TIERED: DwCode = DwCode::new("DW0491", ExitTier::Build);
521 /// (spec-0067) An `equipment` piece is declared where the pinned game will
522 /// not show it on that body: the body's entity type draws no such piece in
523 /// that slot, the item declares a different slot, or the item's allowed
524 /// entities exclude the body. One code, three shapes in one message.
525 /// Validation-tier (exit 1).
526 pub const EQUIPMENT_UNSHOWN: DwCode = DwCode::new("DW0898", ExitTier::Build);
527 /// (spec-0071 §2) **A purchase whose literals do not add up.** In one effect
528 /// list, a charge (`add-state` moving a datum down) fires at a balance that
529 /// cannot pay it — the floor its own `when` and its list's enclosing gate
530 /// leave open is below the amount charged, or nothing floors it at all — or
531 /// the arm that answers below the price stops at a ceiling that is not one
532 /// below where the charge starts, leaving a gap or an overlap. A price has no
533 /// field (spec-0032): it is written as gate terms and a charge, so the
534 /// engine compares the copies. Validation-tier (exit 1).
535 pub const PURCHASE_ARITHMETIC: DwCode = DwCode::new("DW0901", ExitTier::Build);
536 /// (spec-0073 §8.1) **A health bar over a body whose health cannot move**:
537 /// an actor declaring `health_bar` that is not `vulnerable` and that no
538 /// `unleash-actor` names, so the only body the bar could ever read is an
539 /// invulnerable puppet. Validation-tier (exit 1).
540 pub const HEALTH_BAR_STILL: DwCode = DwCode::new("DW0909", ExitTier::Build);
541 /// (spec-0073 §8.2) **A health bar with nothing to title it**: no `title`
542 /// (or a blank one), and the fight has no single name of its own — a wave of
543 /// two entries or more, or a body with no `name`. Validation-tier (exit 1).
544 pub const HEALTH_BAR_UNTITLED: DwCode = DwCode::new("DW0910", ExitTier::Build);
545 /// (spec-0073 §8.4) **Advisory: a fight billed `boss` declares no
546 /// `health_bar`.** Warning tier, never blocking — the build proceeds. Fires
547 /// for `boss` only, on a wave or an actor alike; `elite` and `ordinary` are
548 /// never named by it.
549 pub const HEALTH_BAR_ADVISED: DwCode = DwCode::new("DW0912", ExitTier::Build);
550 /// (spec-0074 §8.1) **An `on_kill` bundle on a body no player can be credited
551 /// with killing**: on a wave no beat spawns (it resolves no area, so it has
552 /// no bodies and no kill machinery), or on an actor no `unleash-actor` names
553 /// that is not `vulnerable` (its body is `Invulnerable` for the whole delve).
554 /// A declaration nothing can exercise is refused. Validation-tier (exit 1).
555 pub const ON_KILL_UNREACHABLE: DwCode = DwCode::new("DW0913", ExitTier::Build);
556 /// (spec-0076 §7) **A standing display the sidebar cannot draw as declared.**
557 /// A `state[]` datum declares `display: sidebar` and the slot cannot show
558 /// what it is handed: a second datum already asks for the one slot (the
559 /// sidebar holds one objective, and "first wins" would hide a decision the
560 /// creator has to make); the datum has no `name` (the slot's heading is the
561 /// display name, and without one the objective's id would stand on screen);
562 /// or the datum is `party`-scoped (its value lives on `#party`, and the
563 /// sidebar hides every `#`-prefixed holder, so the display would be an empty
564 /// heading). One rule about what the slot can draw, three ways to ask for
565 /// what it cannot — the `DW0520` shape. Validation-tier (exit 1).
566 /// Prescription: keep one `display`, give the datum a `name`, or declare it
567 /// `player`-scoped; a `party` purse keeps its announcement and stands nowhere.
568 pub const STATE_DISPLAY_UNDRAWABLE: DwCode = DwCode::new("DW0919", ExitTier::Build);
569 /// (spec-0081 §6) **A celestial time whose shape states nothing a sky can
570 /// show.** One rule about one value's shape, four ways to break it: the
571 /// object names neither or both of `sun` / `moon`; it states a `phase` where
572 /// the moon is below the horizon; `world.time` states no `phase` where the
573 /// moon is up; a `set-time`, a design row or a camera states the phase the
574 /// world already declares. Validation-tier (exit 1). Prescription: name one
575 /// body, remove the phase nobody can see, state the phase the party sees, or
576 /// remove the restated phase.
577 pub const CELESTIAL_TIME: DwCode = DwCode::new("DW0931", ExitTier::Build);
578 /// (spec-0082 §5.1, §5.5) **An assembly's rig cannot be emitted as
579 /// declared.** The library holds no `rigs/<name>/rig.json` for the
580 /// assembly's `rig`, or the file does not parse, or it breaks a structural
581 /// rule (no part, an unknown block, a clip with no frame, a frame short a
582 /// part, a cadence outside `1..=20`, a non-finite transform, a zero scale);
583 /// or an `initial`, a strike step's `windup`/`strike`, or a `play-clip`
584 /// names a clip the rig lacks — the message lists the rig's clips.
585 /// Validation-tier (exit 1). Prescription: regenerate the rig with its
586 /// generator, or name a clip the rig declares (`delvec rig describe`
587 /// prints them).
588 pub const ASSEMBLY_RIG: DwCode = DwCode::new("DW0935", ExitTier::Build);
589 /// A `collect` `dropped_by` is not backed by the wave it names:
590 /// the wave declares no `{item}` drop of this objective's item, the count
591 /// asks for more copies than the wave's mobs can yield, or the objective
592 /// also declares a `container` (the item cannot come out of a box *and* off
593 /// a body).
594 pub const DROP_COLLECT_UNSOURCED: DwCode = DwCode::new("DW0492", ExitTier::Build);
595 /// A `collect` `dropped_by` is not ordered after the fight that
596 /// produces it: no `kill` objective for that wave precedes this collect in
597 /// the objective graph. Without that edge "kill the boss, take its key" is
598 /// an authoring intention the quest graph cannot prove, and the collect
599 /// reads as reachable from the campaign's first tick.
600 pub const DROP_COLLECT_UNORDERED: DwCode = DwCode::new("DW0493", ExitTier::Build);
601 /// (spec-0031, DSL v0.10) A `lethal_volumes[]` entry's `message` is blank.
602 ///
603 /// The volume would still kill — and would kill in silence, which is the one
604 /// thing the declaration exists to prevent. There is no compiler default that
605 /// could be right for a cliff, a lava pit and an acid pool at once, so a blank
606 /// wording is refused rather than papered over: a gate that reports green
607 /// while the player learns nothing is exactly the vacuous pass CLAUDE.md names.
608 pub const LETHAL_MESSAGE_BLANK: DwCode = DwCode::new("DW0512", ExitTier::Build);
609 /// (spec-0086 §3.2, §3.4, §3.5) **A loop whose release is not a fact about the
610 /// party, or that has none.**
611 ///
612 /// One rule — *the gate is the release, and the release is the party's* —
613 /// asked four ways: a loop with no gate term at all (it holds forever, a
614 /// soft-lock spelled out); a `requires_state` term naming a `player`-scoped
615 /// datum (one player released and another looped is a party split in two);
616 /// a `counts` naming a `player`-scoped datum (for the same reason); and a
617 /// `teleport` inside `on_cross` (the body was just moved, and a second move in
618 /// the same tick is two carries with one position). Validation-tier (exit 1).
619 /// Prescription: a `party` datum, a flag, or a release the party reaches.
620 pub const LOOP_GATE: DwCode = DwCode::new("DW0949", ExitTier::Build);
621 /// (spec-0062) **A killing volume and what shows it disagree.**
622 ///
623 /// One rule, three shapes, and every remedy each names is admitted by the
624 /// others — which is why one code carries all of them (spec-0062 §4).
625 ///
626 /// * **Caught floor that shows nothing.** Some cell the party can walk to
627 /// lies in the volume's keep-out, and the block under or in it is not one
628 /// of the volume's `shown_by`. The player reads stone and dies on it. The
629 /// remedy is the geometry's: lower the volume so its keep-out's top course
630 /// lies under the floor, draw its `extent` in, or author a block vanilla
631 /// hurts with under those cells and declare it. Never mark walkable-looking
632 /// ground unwalkable — the compiler knows and the player does not.
633 /// * **A declared signal the bytes do not hold.** A `shown_by` block under
634 /// or in no caught cell, whether the list is wrong or the volume catches
635 /// nothing at all. The `DW0887` shape, on a volume instead of a waterline.
636 /// * **A `shown_by` naming a block vanilla does not hurt a body with.** The
637 /// document arm, and the only one answerable with nothing placed:
638 /// `minecraft:stone` over stone is borne out by the bytes and shows
639 /// nothing.
640 ///
641 /// The world arm is raised by `delvec::compiler::lethal` over the final
642 /// assembled world (whether a cell is floor is a fact about the settled
643 /// bytes, so nothing before assembly can answer it); the document arm here,
644 /// by [`crate::validate`].
645 pub const LETHAL_INVISIBLE: DwCode = DwCode::new("DW0891", ExitTier::Build);
646 /// (spec-0088) **A gate that cannot stage a lethal volume.** Two shapes,
647 /// refused at the document where they are entered:
648 ///
649 /// * **`when: {}`** — a stage with no term. An always-live volume is
650 /// spelled by leaving `when` out; an empty gate says nothing and is not
651 /// a stage.
652 /// * **A `requires_state` term on a `player`-scoped datum.** A volume's
653 /// liveness is a fact about the place, so its gate is a fact about the
654 /// party: a term one player satisfies and another does not would be a
655 /// pit that kills one body and spares the one beside it, and the sweep's
656 /// entity half has no player to read a per-player score from.
657 ///
658 /// The remedy is to leave `when` out, or to name a flag or a `party`
659 /// datum. Raised by [`crate::validate`] with no world built.
660 pub const LETHAL_STAGE_GATE: DwCode = DwCode::new("DW0953", ExitTier::Build);
661 /// (spec-0031, DSL v0.10) **A grant whose removal is a later effect, not its
662 /// own duration.** A `give-effect` is still live at the moment a
663 /// `clear-effect` for the same effect fires in the same bundle, so the clear
664 /// — not the duration — is what ends it.
665 ///
666 /// A bundle that does not reach its end leaves the effect on the player: a
667 /// logout, a crash, a death mid-chain, a `sequence` whose remaining
668 /// `schedule` never runs. A duration expires with no cooperation from
669 /// anything, which is why `seconds` is mandatory and why vanilla's `infinite`
670 /// is absent from this surface — this diagnostic is what stops the same
671 /// hazard being rebuilt out of two effects that are individually fine.
672 pub const EFFECT_CLEARED_LIVE: DwCode = DwCode::new("DW0540", ExitTier::Build);
673 /// (spec-0031, DSL v0.10) A `give-effect`'s `seconds` is zero or beyond
674 /// [`crate::MAX_EFFECT_SECONDS`], or its `amplifier` is beyond
675 /// [`crate::MAX_POTION_AMPLIFIER`].
676 ///
677 /// Zero is the grant that never happens — the unbound-vacuity class as a
678 /// number. The ceilings are vanilla's own field widths, so a duration typed
679 /// in ticks or milliseconds is caught instead of silently overflowing.
680 pub const EFFECT_GRANT_BOUNDS: DwCode = DwCode::new("DW0541", ExitTier::Build);
681 /// (v0.3) A wave mob `entity` is not a known vanilla entity id. (Item-id
682 /// checks for `collect.item`, `interact.requires_item` and `give-item.item`
683 /// reuse [`ITEM_UNKNOWN`] / `DW0143`.)
684 pub const ENTITY_UNKNOWN: DwCode = DwCode::new("DW0173", ExitTier::Build);
685 /// (i18n) An l10n sidecar does not correctly cover a declared language: the
686 /// `l10n/<code>.json` file is absent, its envelope (`campaign_id` / `lang` /
687 /// `dsl_version`) is inconsistent, or it is **missing** a key from the
688 /// authoritative inventory (under-coverage). English (`en`) is implicit and
689 /// never declared, so it is never checked.
690 pub const L10N_MISSING: DwCode = DwCode::new("DW0180", ExitTier::Build);
691 /// (i18n) An l10n sidecar carries an **orphan** key that is not in the
692 /// authoritative string inventory derived from the stage docs (over-coverage).
693 pub const L10N_ORPHAN: DwCode = DwCode::new("DW0181", ExitTier::Build);
694 /// (i18n / harness oracle) A player-visible string — authored English or any
695 /// sidecar translation — contains the reserved completion-marker sigil
696 /// `[dw:complete`. That chat sequence is the validation bot's per-objective
697 /// completion oracle; content carrying it could forge a passing critical-path
698 /// step. The channel is reserved, not merely conventional.
699 pub const MARKER_RESERVED: DwCode = DwCode::new("DW0182", ExitTier::Build);
700 /// (i18n v2) A player-visible string — authored English or any sidecar
701 /// translation — contains a character from the reserved private-use block the
702 /// compiler uses to carry an l10n key from the stage docs to the text
703 /// component it is emitted into ([`crate::l10n::TR_SIGIL`]). Content carrying
704 /// it could impersonate a translation tag, or survive into the datapack and
705 /// render as a tofu box. The block is reserved, not merely conventional.
706 pub const TR_SIGIL_RESERVED: DwCode = DwCode::new("DW0183", ExitTier::Build);
707 /// (i18n v2) A declared language has no entry in the Minecraft language-code
708 /// mapping table ([`crate::l10n::mc_lang_code`]), so the resource pack has no
709 /// filename to write its `assets/delvewright/lang/<code>.json` under. A
710 /// language is never silently dropped: either the code is corrected to a
711 /// mapped one, or the table gains the entry.
712 pub const LANG_CODE_UNMAPPED: DwCode = DwCode::new("DW0184", ExitTier::Build);
713 /// (i18n v2) A campaign l10n sidecar defines a key in the reserved
714 /// `delvewright.` **chrome** namespace ([`crate::chrome`]). Those are the
715 /// engine's own on-screen strings — `New objective: `, `Choose your class`,
716 /// the default a bonfire shows — owned by the compiler, translated with it,
717 /// and authored by no campaign; a sidecar row under that prefix would be
718 /// written into the language file and silently replace product chrome for that
719 /// language. The namespace is reserved, not merely conventional.
720 pub const CHROME_RESERVED: DwCode = DwCode::new("DW0186", ExitTier::Build);
721 /// (i18n v2) An l10n sidecar row was translated from English the campaign no
722 /// longer holds: its `source` entry differs from the key's canonical English.
723 /// The translation is present, applied and **wrong**, and no key-set check can
724 /// see it — `DW0180`/`DW0181` compare key SETS, and a rewritten line moves no
725 /// key. Load-bearing for entity display names, whose key belongs to the first
726 /// site declaring a given text, so renaming one body can migrate a key to
727 /// another body and the row that goes stale is not the one the author edited.
728 pub const L10N_STALE: DwCode = DwCode::new("DW0187", ExitTier::Build);
729 /// (i18n v2) An l10n sidecar records provenance for only some of its rows (or
730 /// none), so `DW0187` cannot see the rest. A warning, not an error: the
731 /// `source` map is additive, and this is the one-version deprecation window
732 /// before it is required. It states the unguarded row count, so an
733 /// unadopted sidecar is a reported number on every run rather than silence
734 /// that reads like a pass.
735 pub const L10N_PROVENANCE_MISSING: DwCode = DwCode::new("DW0188", ExitTier::Build);
736 /// (v0.4, widened by spec-0084) An image id a campaign declares — a body's
737 /// `skin.texture_id` or a `world.textures[]` row's `id` — is malformed (not a bare kebab
738 /// token) or duplicated among the images of its kind (spec-0009). A missing `model` is a
739 /// schema error (`DW0100`); a missing PNG is a build error (`DW0309`).
740 pub const SKIN_INVALID: DwCode = DwCode::new("DW0190", ExitTier::Build);
741 /// (v0.4) A `talk-to` objective has no **ungated** reachable completing
742 /// dialogue option — every completing option is `requires_flags`-gated, so
743 /// the objective can deadlock the moment it activates (spec-0008 §1). Keep at
744 /// least one ungated completing path.
745 pub const DIALOGUE_FLAG_DEADLOCK: DwCode = DwCode::new("DW0191", ExitTier::Build);
746 /// (v0.4) A wave mob `effects[].effect` is not a known 1.21.11 effect id.
747 pub const EFFECT_UNKNOWN: DwCode = DwCode::new("DW0192", ExitTier::Build);
748 /// (v0.4) A `set-block` / `interact.prop` block id is not a known 1.21.11
749 /// block id.
750 pub const BLOCK_UNKNOWN: DwCode = DwCode::new("DW0193", ExitTier::Build);
751 /// (v0.4) An environment trigger id is malformed (`DW0110`-style) or
752 /// duplicated within the stage-5 `triggers` namespace.
753 pub const TRIGGER_INVALID: DwCode = DwCode::new("DW0194", ExitTier::Build);
754 /// (v0.4) A dialogue `talk-to` or `interact` objective targets an NPC after a
755 /// `despawn-npc` removes it on a reachable path (spec-0008 §5).
756 pub const NPC_DESPAWNED_REF: DwCode = DwCode::new("DW0195", ExitTier::Build);
757 /// (v0.5) An area `lighting.min_light` is out of the 1..=14 range (spec-0010).
758 pub const LIGHTING_RANGE: DwCode = DwCode::new("DW0196", ExitTier::Build);
759 /// (v0.6) A stage-2 NPC declares `deferred: true` but **no** `spawn-npc` effect
760 /// anywhere in the campaign ever summons it — the NPC never enters the world,
761 /// so its dialogue tree and any `talk-to` on it are unreachable content. The
762 /// NPC-lifecycle dual of [`NPC_DESPAWNED_REF`] / `DW0195`.
763 ///
764 /// (0197/0198 were *reserved* by spec-0011's draft and released when that spec
765 /// renumbered to `DW0340`/`DW0341`; they were never emitted by any code.)
766 pub const NPC_NEVER_SPAWNED: DwCode = DwCode::new("DW0197", ExitTier::Build);
767 /// (v0.6) A `talk-to` on a `deferred` NPC activates before the NPC can exist:
768 /// every `spawn-npc` for it sits in a quest that is a strict *descendant* of the
769 /// objective's quest on the stage-4 DAG (and none fires from a trigger or
770 /// dialogue), so the objective provably activates on an empty anchor.
771 pub const NPC_SPAWNED_LATE: DwCode = DwCode::new("DW0198", ExitTier::Build);
772 /// (v0.6) A `cutscene` effect's shape is invalid: it mixes the multi-shot
773 /// `shots` list with the single-shot `path`/`seconds` fields, gives neither,
774 /// or declares a shot with an empty camera `path`. A cutscene must resolve to
775 /// at least one shot, and every shot to at least one camera position.
776 pub const CUTSCENE_SHAPE: DwCode = DwCode::new("DW0199", ExitTier::Build);
777
778 /// (v0.6) `horizon: "ocean"` declared without a `boundary` (spec-0013):
779 /// validation-tier (exit 1). An infinite swimmable sea with no return rule is
780 /// an authoring error. Grouped in the DW032x world/region family by domain;
781 /// unlike the compiler-tier DW030x geometry codes it is raised at DSL
782 /// validation, so it exits 1.
783 pub const OCEAN_NO_BOUNDARY: DwCode = DwCode::new("DW0320", ExitTier::Build);
784 /// (v0.6) `boundary.margin` outside the `0..=64` range (spec-0013):
785 /// validation-tier (exit 1).
786 pub const BOUNDARY_MARGIN: DwCode = DwCode::new("DW0321", ExitTier::Build);
787 /// A stage-1 `horizon` param is out of range, or is a param of a base other
788 /// than the one declared (spec-0026): validation-tier (exit 1).
789 pub const HORIZON_PARAM: DwCode = DwCode::new("DW0853", ExitTier::Build);
790 /// A `horizon` whose base BUILDS terrain, on a campaign that states no
791 /// extent for that terrain to stand around (spec-0026): validation-tier
792 /// (exit 1).
793 ///
794 /// A surround rings a declared extent — a site plan's `region`. A campaign
795 /// that seats its pieces with `areas[]` declares none, and the union of
796 /// whatever gets placed is not a substitute: it is an artifact of the
797 /// compiler's fixed area stride, mostly the void between areas, so ringing
798 /// it builds a mountain range around empty space.
799 pub const SURROUND_NO_REGION: DwCode = DwCode::new("DW0855", ExitTier::Build);
800 /// (v0.6) A `sequence` effect is nested inside another `sequence` (directly, or
801 /// reachable via a nested `move-actor` `on_arrive`) — timelines do not recurse
802 /// (spec-0014). Flatten the inner steps into the outer timeline.
803 pub const NESTED_SEQUENCE: DwCode = DwCode::new("DW0329", ExitTier::Build);
804
805 /// (v0.6) Trap declaration structurally invalid (spec-0011): a malformed or
806 /// duplicated `trap/<id>`, an `at`/`disarm.via` that no area's prefab provides,
807 /// or a trap whose `disarm.via` collides with its own trigger anchor.
808 /// Validation-tier (exit 1). Renumbered off the spec's stale reserved number
809 /// (0197 — since taken).
810 pub const TRAP_INVALID: DwCode = DwCode::new("DW0340", ExitTier::Build);
811 /// (spec-0016 §2) A `shortcut` declaration is structurally invalid: a
812 /// malformed or duplicate `shortcut/<id>`, a `gate`/`unlock` anchor no area's
813 /// prefab provides, or a `gate` that IS the `unlock` (the mechanism must sit
814 /// on the far side, not in the doorway).
815 pub const SHORTCUT_INVALID: DwCode = DwCode::new("DW0371", ExitTier::Build);
816 /// (spec-0016 §2) A `close-gate` effect targets a gate a `shortcut` owns.
817 /// A shortcut opens **permanently** — that is the whole pattern — so its
818 /// permanence is structural: there is no verb that can put it back. Use a
819 /// different gate for the point-of-no-return beat.
820 pub const SHORTCUT_RESEALED: DwCode = DwCode::new("DW0372", ExitTier::Build);
821 /// (spec-0016 §3) An `ambush` declaration is structurally invalid: a
822 /// malformed or duplicate `ambush/<id>`, an empty `actors` list (an ambush
823 /// that ambushes nobody), or the same actor listed twice (the second
824 /// `spawn-actor` is a guarded no-op, so the author's intent silently halves).
825 /// The telegraph is deliberately NOT required — an un-telegraphed ambush is
826 /// core souls vocabulary.
827 pub const AMBUSH_INVALID: DwCode = DwCode::new("DW0375", ExitTier::Build);
828 /// (spec-0016 §4) A `timed-gate` declaration is structurally invalid: a
829 /// malformed or duplicate `timed-gate/<id>`, an `open_ticks` or
830 /// `closed_ticks` of 0 (a gate that never opens, or never closes — neither is
831 /// a timing gate), a `phase` at or beyond the full cycle, or a gate another
832 /// `timed-gate` or a `shortcut` already owns (two clocks fighting over one
833 /// region, or a clock fighting a permanent open), or a `disarm.via` anchor no
834 /// area's prefab provides / one that IS the gate anchor (the jam lever cannot
835 /// live inside the span it stops).
836 pub const TIMED_GATE_INVALID: DwCode = DwCode::new("DW0377", ExitTier::Build);
837 /// A `close-gate` effect targets the gate of a `timed-gate` that
838 /// declares a `disarm`. A disarm suppresses the clock **permanently with the
839 /// gate resting open** — a jammed portcullis stays up — so, exactly like a
840 /// `shortcut` (`DW0372`), its permanence is structural: there is no verb that
841 /// can re-arm it. Use a different gate for the beat that must re-seal, or drop
842 /// the `disarm`.
843 pub const TIMED_GATE_REARMED: DwCode = DwCode::new("DW0389", ExitTier::Build);
844 /// (spec-0016 §6) A wave's TD `lane` / `summon` declaration is structurally
845 /// invalid or internally contradictory: an empty `waypoints` list, a
846 /// waypoint anchor no area's prefab provides, a repeated consecutive
847 /// waypoint, an `aggro_radius` outside `4..=64`, a mob whose
848 /// `attributes.follow_range` disagrees with `aggro_radius` (they MUST be
849 /// equal — a patrolling raider holds ground against a target it cannot
850 /// engage), or `lane` together with `summon: aggro-edge` (a lane IS the
851 /// routing; aggro-edge is its opposite).
852 pub const LANE_INVALID: DwCode = DwCode::new("DW0381", ExitTier::Build);
853 /// (spec-0016 §6) A lane wave contains a non-raider species. `Patrolling` /
854 /// `patrol_target` are Raider NBT: on anything else they are dropped and the
855 /// mob simply stands where it spawned. The admitted set is vanilla's own
856 /// `#minecraft:raiders` tag, read from the vendored tag table — never a
857 /// species list this engine keeps. Non-raiders use `summon: aggro-edge`
858 /// instead.
859 pub const LANE_NOT_RAIDER: DwCode = DwCode::new("DW0382", ExitTier::Build);
860 /// (spec-0016 §6) A lane wave fields fewer than 2 mobs. A lone patroller
861 /// sets `Patrolling:0b` on itself when it finds no companion within its
862 /// follow range (vanilla), so a one-mob lane cancels itself.
863 pub const LANE_SQUAD_TOO_SMALL: DwCode = DwCode::new("DW0383", ExitTier::Build);
864 /// (spec-0016 §6) A lane `pillager` is not holding a crossbow. Its only
865 /// attack goal is the crossbow goal, so a pillager that acquires a target it
866 /// has no runnable attack for freezes in place indefinitely — patrol blocked
867 /// by the target, nothing to run instead (live-verified deadlock).
868 pub const LANE_UNARMED: DwCode = DwCode::new("DW0384", ExitTier::Build);
869 /// (spec-0016 §6) A `summon: aggro-edge` wave mob declares no
870 /// `attributes.follow_range`. That radius IS the summon ring — the distance
871 /// at which the mob perceives the party — so it is authored, never guessed
872 /// from a vanilla defaults table the compiler cannot verify.
873 pub const AGGRO_EDGE_NO_RANGE: DwCode = DwCode::new("DW0385", ExitTier::Build);
874 /// (v0.6) A trap dispense-payload item id is not in the pinned 1.21.11 registry
875 /// (spec-0011; mirrors `DW0143`). Validation-tier (exit 1). Renumbered off the
876 /// spec's stale reserved number (0198 — since taken).
877 pub const TRAP_PAYLOAD_UNKNOWN: DwCode = DwCode::new("DW0341", ExitTier::Build);
878
879 /// (spec-0022) A trap declares **no consequence at all**: neither the legacy
880 /// redstone `effect` nor a command `payload`. A trap that does nothing is
881 /// mute hardware the completability proofs would nonetheless reason about,
882 /// so it is a content mistake, not a no-op. Validation-tier (exit 1).
883 pub const TRAP_NO_CONSEQUENCE: DwCode = DwCode::new("DW0440", ExitTier::Build);
884 /// (spec-0022) A `volley` `projectile` / `collapse` `falling_block` /
885 /// `then_floor` id is not in the pinned 1.21.11 registry (a `projectile`
886 /// must be an ENTITY id, the collapse blocks BLOCK ids).
887 /// Validation-tier (exit 1).
888 pub const TRAP_VERB_ID_UNKNOWN: DwCode = DwCode::new("DW0441", ExitTier::Build);
889 /// (spec-0022) A `volley`'s `salvos` / `interval` is out of range (`salvos`
890 /// in `1..=16`, `interval` in `1..=200`). A volley fires its whole kill zone
891 /// every salvo, so the entity count is `salvos x cells`; and salvos spread
892 /// wider than the interval cap stop reading as one trap event.
893 /// Validation-tier (exit 1).
894 pub const VOLLEY_CADENCE: DwCode = DwCode::new("DW0443", ExitTier::Build);
895
896 /// (v0.6) A `shot_style` declaration is semantically invalid (spec-0015 shot
897 /// grammar): a styled shot with no `subject`; style-only fields (`subject`,
898 /// `subject_b`, `dist`, `degrees`, `bearing`) on an unstyled shot; a
899 /// `subject_b` on a style other than `two-shot` (or a `two-shot` without
900 /// one); `degrees` off `orbit-arc` or outside `45..=120`; `dist` outside
901 /// `1..=48`; or `bearing` outside `-360..=360`. Validation-tier (exit 1).
902 pub const SHOT_STYLE_INVALID: DwCode = DwCode::new("DW0348", ExitTier::Build);
903 /// (v0.6) A `side-track` / `low-follow` shot whose subject has no
904 /// compiler-known motion: those styles dolly *with* a moving subject, so the
905 /// subject must be an NPC/actor with a matching `move-npc`/`move-actor` in
906 /// the same effect group or the same `sequence` timeline (an `anchor`
907 /// subject can never move). Validation-tier (exit 1). Use `locked-off` /
908 /// `push-in` for a static subject instead.
909 pub const SHOT_SUBJECT_UNMOVED: DwCode = DwCode::new("DW0349", ExitTier::Build);
910
911 /// (v0.4, added round-6) A `use` trigger anchored where an NPC stands.
912 /// Right-click on an NPC already belongs to its dialogue advancement; a
913 /// second interaction hitbox in the same cell makes the client's entity
914 /// ray-pick ambiguous, and whichever entity loses the tie is silently dead
915 /// — the round-6 island soft-lock class (an exactly co-located hitbox
916 /// starved the giant's dialogue of every right-click). `strike` triggers
917 /// are exempt: a left-click has no dialogue meaning, so the compiler rides
918 /// the trigger's tag on the NPC's own hitbox instead of summoning a second
919 /// one. Validation-tier (exit 1).
920 pub const USE_TRIGGER_ON_NPC: DwCode = DwCode::new("DW0350", ExitTier::Build);
921
922 /// (v0.6, spec-0018) `world.min_players` outside the `1..=4` range. A delve is
923 /// played by ONE party of 1–4 (ADR/CLAUDE.md product definition), so a declared
924 /// mandatory party size can never sit outside it. Validation-tier (exit 1).
925 pub const PARTY_SIZE: DwCode = DwCode::new("DW0356", ExitTier::Build);
926 /// (spec-0077 §7) **A respawn wait that cannot be honoured.**
927 /// `world.respawn_wait.seconds` lies outside `1..=120`, or the campaign
928 /// declares a `respawn_wait` and no `set-checkpoint` or `bonfire` for a
929 /// fallen player to come back to (the wait hangs off the checkpoint respawn
930 /// edge, so with none it is a silently dead declaration). One rule about what
931 /// a wait needs, two ways to break it. Validation-tier (exit 1). The build's
932 /// own self-check that a shipped selector cannot read a waiter is `DW0926`.
933 /// Prescription: a value in `1..=120`, or a checkpoint, or drop the field.
934 pub const RESPAWN_WAIT_INVALID: DwCode = DwCode::new("DW0925", ExitTier::Build);
935 /// (v0.6, spec-0018) A `carrier: "one"` `give-item` sits in a bundle that is
936 /// only ever reached from the **scheduler** (`move-npc`/`move-actor`
937 /// `on_arrive`, a `sequence` step). `carrier: "one"` means "hand this single
938 /// quest prop to the player whose action earned it"; a scheduled bundle runs
939 /// with the server command source and has no acting player, so there is no
940 /// defensible recipient. Give it to the whole party (drop `carrier`), or move
941 /// the hand-off onto the beat that a player completes. Validation-tier (exit 1).
942 pub const PARTY_CARRIER_SCHEDULED: DwCode = DwCode::new("DW0357", ExitTier::Build);
943
944 /// (v0.6) `world.difficulty` is `peaceful`. On
945 /// peaceful the server discards every hostile-category mob as it is ticked —
946 /// `/summon`ed, `NoAI`, `PersistenceRequired`, all of it — so a peaceful delve
947 /// is one in which every wave, every hostile actor and every ambush silently
948 /// ceases to exist. There is no delve that wants that, so the keyword is
949 /// refused rather than honoured. Validation-tier (exit 1).
950 pub const DIFFICULTY_INVALID: DwCode = DwCode::new("DW0468", ExitTier::Build);
951 /// (v0.6) A campaign fields scripted `actors[]` (an
952 /// ambush desugars into these too) but **no** `waves[]` and no declared
953 /// `world.difficulty`, so the compiler's historical derivation ships
954 /// `difficulty=peaceful` — under which every one of those actors that is a
955 /// hostile species is discarded on the tick it spawns. The compiler cannot
956 /// decide the question for the author: the pinned entity registry is a
957 /// membership set with no mob-category data, so "is this actor a monster" is
958 /// not something it can verify rather than guess. Advisory (warning,
959 /// exit 0) — declaring `world.difficulty` settles it either way.
960 pub const DIFFICULTY_UNDECLARED_ACTORS: DwCode = DwCode::new("DW0469", ExitTier::Build);
961 /// (spec-0016 §1, spec-0023, souls ruling 5/7: "stage bosses never respawn
962 /// on rest") A wave declares BOTH `tier: boss` and `respawns_on_rest: true`.
963 /// `tier` and `respawns_on_rest` are two fields on the same [`Wave`]
964 /// declaration — the only place a "boss" billing and a "re-seat on rest"
965 /// contract can land on one another; an [`Actor`] carries `tier` too but has
966 /// no `respawns_on_rest` field at all (it is killed by hand, never re-seated
967 /// by a bonfire), so this is the sole structurally expressible violation of
968 /// the ruling. A rest-respawning boss re-fight breaks the retry economy the
969 /// ruling exists to protect: a boss is the campaign's named fight, not
970 /// trash pressure the party grinds back down every rest. Validation-tier
971 /// (exit 1), `dsl::validate`. Prescription: drop `tier: boss` if the
972 /// encounter really is meant to re-seat (bill it `elite` instead), or drop
973 /// `respawns_on_rest` if it really is the boss.
974 ///
975 /// [`Wave`]: crate::stages::Wave
976 /// [`Actor`]: crate::stages::Actor
977 pub const BOSS_RESPAWNS_ON_REST: DwCode = DwCode::new("DW0499", ExitTier::Build);
978
979 // -- DSL v0.10 runtime state (spec-0031) ---------------------------------
980
981 /// (v0.10, spec-0031) A `state/<kebab>` reference — in a `requires_state`
982 /// comparison or in a `set-state`/`add-state`/`clear-state` verb — names a
983 /// datum the campaign never declares in the stage-5 `state` list. Unlike a
984 /// flag, a datum IS declared: its scope and its initial value are facts no
985 /// use site can supply, so an undeclared reference is not "a datum that
986 /// happens to start at zero", it is a datum with no defined multiplayer
987 /// semantics at all. Validation-tier (exit 1). Prescription: declare it, or
988 /// fix the id.
989 pub const STATE_UNDECLARED: DwCode = DwCode::new("DW0500", ExitTier::Build);
990 /// (v0.10, spec-0031) A gate's `requires_state` reads a declared datum that
991 /// **no verb anywhere in the campaign ever writes**. The datum can only ever
992 /// hold its declared `initial`, so the comparison's answer was decided at
993 /// authoring time and the gate is a constant wearing a condition's clothes.
994 ///
995 /// This is the vacuity rule at the level of one datum (CLAUDE.md: *a green
996 /// gate that binds to nothing is vacuous, not a pass*) — the numeric
997 /// equivalent of the bot's combat floor examining zero enemies for nineteen
998 /// rounds. Validation-tier (exit 1). Prescription: write the datum somewhere
999 /// (`set-state`/`add-state`/`clear-state`), or drop the comparison and say
1000 /// what you meant unconditionally.
1001 pub const STATE_NEVER_WRITTEN: DwCode = DwCode::new("DW0501", ExitTier::Build);
1002 /// (v0.10, spec-0031) A declared datum that **no gate anywhere in the
1003 /// campaign ever reads**. Either some verb writes it and nothing ever asks
1004 /// (the write is inert — a counter nobody consults), or nothing touches it at
1005 /// all (a dead declaration). Runtime state exists to be compared against; a
1006 /// datum with no reader is bookkeeping no player can ever observe.
1007 /// Validation-tier (exit 1). Prescription: gate something on it with
1008 /// `requires_state`, or delete the declaration and its writes.
1009 pub const STATE_NEVER_READ: DwCode = DwCode::new("DW0502", ExitTier::Build);
1010 /// (v0.10, spec-0031) A `player`-scoped datum is referenced where emission
1011 /// has no acting player to read or write it against.
1012 ///
1013 /// Two such places exist, and both are properties of the SITE, not of the
1014 /// verb: a scheduler-only bundle (a `sequence` step, a `move-npc` /
1015 /// `move-actor` `on_arrive`) runs with the server command source — the same
1016 /// seam `DW0357` polices for `carrier: "one"` — and the gates emission
1017 /// evaluates against the party holder rather than against a player (an
1018 /// objective's activation guard, a trigger's arming gate, a trap's arming
1019 /// gate) have no `@s` either. Validation-tier (exit 1). Prescription: declare
1020 /// the datum `party`-scoped if the whole party shares it, or move the
1021 /// read/write onto a site a player drives (a dialogue option, a cast
1022 /// placement, an effect on a beat a player completes).
1023 pub const STATE_SCOPE_UNREACHABLE: DwCode = DwCode::new("DW0503", ExitTier::Build);
1024 /// (v0.10, spec-0032) A `stakes[]` declaration is unusable as a personal
1025 /// wager: its `state` is a datum the campaign never declares, or one declared
1026 /// `party`-scoped.
1027 ///
1028 /// **The scope half is the multiplayer decision most likely to be made by
1029 /// accident** (spec-0032, stated for correction rather than left to emerge).
1030 /// A stake is one player's loss and one player's chance to get it back; a
1031 /// party-shared purse would turn a teammate's death into a penalty on
1032 /// everyone, and nothing in the JSON would say so. Validation-tier (exit 1).
1033 /// Prescription: declare the datum `player`-scoped, or point the stake at a
1034 /// datum that is.
1035 pub const STAKE_STATE_SCOPE: DwCode = DwCode::new("DW0520", ExitTier::Build);
1036 /// (v0.10, spec-0032) A `drop-stake` effect names a stake the campaign never
1037 /// declares in the stage-5 `stakes` list. Validation-tier (exit 1).
1038 /// Prescription: declare it, or fix the id.
1039 pub const STAKE_UNDECLARED: DwCode = DwCode::new("DW0521", ExitTier::Build);
1040 /// (v0.10, spec-0032) A declared stake that **no `drop-stake` effect anywhere
1041 /// in the campaign ever leaves**. The retention policy, the forfeit rule and
1042 /// the whole placement table are computed for a mechanism no beat can fire —
1043 /// a declaration wearing a feature's clothes.
1044 ///
1045 /// The same vacuity rule `DW0502` states for a datum with no reader
1046 /// (CLAUDE.md: *a green gate that binds to nothing is vacuous, not a pass*).
1047 /// Validation-tier (exit 1). Prescription: drop it from a beat — `on_death`
1048 /// is the usual one — or delete the declaration.
1049 pub const STAKE_NEVER_DROPPED: DwCode = DwCode::new("DW0522", ExitTier::Build);
1050 /// (v0.10, spec-0032) A `shops[].offers[]` entry that cannot deliver
1051 /// anything: it declares no `effects`, so its button is drawn, is pressable,
1052 /// and does nothing.
1053 ///
1054 /// The shop analogue of the invisible-affordance rule: a control the player
1055 /// can operate must have an observable answer. A refusal counts — an offer
1056 /// whose only effect is a gated `narrate` saying "you cannot afford that" is
1057 /// exactly the authored shape spec-0032 asks for. Validation-tier (exit 1).
1058 /// Prescription: give the offer effects, or delete it.
1059 pub const SHOP_OFFER_INERT: DwCode = DwCode::new("DW0523", ExitTier::Build);
1060 /// (v0.10, spec-0032) A `forfeit` of kind `proportion` whose `percent` is
1061 /// above 100 — a death that takes more than the whole purse. Validation-tier
1062 /// (exit 1). Prescription: 0–100, or use `all`.
1063 pub const STAKE_FORFEIT_RANGE: DwCode = DwCode::new("DW0524", ExitTier::Build);
1064 /// (v0.10, spec-0032) **A comparison read after the bundle has already changed
1065 /// what it compares.** An effect's `requires_state` names a datum that an
1066 /// EARLIER effect in the same bundle writes, so the gate is evaluated against
1067 /// the post-write value, not the value the beat started with.
1068 ///
1069 /// Found in the emitted output of spec-0032's own first shop. The authored
1070 /// shape a shop wants is "the purchase behind `at-least 1`, the apology behind
1071 /// `at-most 0`" — and written in that order, buying your LAST ember prints both:
1072 /// the debit runs, the balance falls to 0, and the apology's gate — evaluated
1073 /// after it — now holds. Vanilla evaluates each `execute` when it reaches it,
1074 /// which is the whole reason a per-effect gate is useful, so this is not a bug
1075 /// to fix in emission: it is an ordering hazard that only reading the generated
1076 /// function reveals. The fix is always the same and always local — **put the
1077 /// reading effect before the writing one** — which is why this is a warning
1078 /// naming the earlier write rather than a refusal.
1079 ///
1080 /// Warning-tier (exit 0). Prescription: move the gated effect ahead of the
1081 /// write, or gate it on something the bundle does not itself change.
1082 pub const STATE_READ_AFTER_WRITE: DwCode = DwCode::new("DW0527", ExitTier::Build);
1083
1084 /// (v0.11) **A press answer addressed to a click vanilla cannot attribute.**
1085 /// A trigger declares `audience: presser` on something other than an
1086 /// `on: use`.
1087 ///
1088 /// `minecraft:player_interacted_with_entity` is the only vanilla criterion
1089 /// that runs a function as the player who clicked, and it fires on
1090 /// right-clicks alone. A left-click is recorded in the interaction entity's
1091 /// `attack` NBT — a UUID no command can become — and an `approach` involves no
1092 /// click at all. Approximating it (polling the record and assuming the nearest
1093 /// player) is the downstream folklore CLAUDE.md's no-hack rule excludes, so the
1094 /// capability is refused rather than faked.
1095 pub const TRIGGER_AUDIENCE_UNATTRIBUTABLE: DwCode = DwCode::new("DW0427", ExitTier::Build);
1096
1097 /// (v0.11) **A trigger id in the compiler's reserved `dw-` namespace.** The
1098 /// compiler synthesizes triggers of its own — today the press answer every
1099 /// sealed gate and shortcut door gives (`trigger/dw-press-…`) — and two
1100 /// triggers sharing an id would share one `dw_trig_…` tag and one emitted
1101 /// function, so one of them would silently disappear. Reserving the prefix
1102 /// makes the collision impossible by construction instead of improbable.
1103 pub const TRIGGER_ID_RESERVED: DwCode = DwCode::new("DW0428", ExitTier::Build);
1104
1105 /// (v0.11) **A sealed body with no press answer**, uniformly over the
1106 /// pressable class. A `shortcuts[]` door or
1107 /// a `close-gate`'s wall is sealed, and nothing says what it answers when the
1108 /// party presses it — no `use` trigger anchored on it, and (for a
1109 /// `close-gate`) no authored `sealed_hint`.
1110 ///
1111 /// The compiler deliberately does **not** fill that silence. A baked default
1112 /// is the compiler making a design statement — about tone, about what this
1113 /// specific door is — on the author's behalf, and then never telling them it
1114 /// did; an error makes the author say it. Same rule as "no hacks at any
1115 /// layer": if content needs a thing, the DSL exposes it and the author
1116 /// declares it, rather than a lower layer inventing it.
1117 ///
1118 /// One rule for the whole pressable class: two objects of the same class do
1119 /// not get two defaulting policies, which would be the "capability keyed to
1120 /// the verb" defect this very surface is CLAUDE.md's worked example of.
1121 pub const SEALED_BODY_UNANSWERED: DwCode = DwCode::new("DW0429", ExitTier::Build);
1122
1123 /// (v0.11, spec-0034) **A declared locomotion the engine cannot hold the
1124 /// body to** — today exactly one value, `aquatic`.
1125 ///
1126 /// The declaration surface exists so an author can claim a capability and
1127 /// have the claim PROVEN. `aquatic` is the one
1128 /// class that carries no exemption and governs no rule: it is a ledger
1129 /// label the compiler derives from vanilla's own `#minecraft:aquatic` tag.
1130 /// Declaring it could therefore never change a verdict, so it would always
1131 /// land in `DW0454` — and a value whose only possible outcome is another
1132 /// diagnostic is a trap, not a surface.
1133 ///
1134 /// The gap it names, stated rather than left to folklore (CLAUDE.md's
1135 /// no-hack rule): the compiler routes **every** body on standable ground,
1136 /// and `flooded` cells are impassable and never floor for every body. There
1137 /// is no water-traversal model for a declaration to feed, so there is
1138 /// nothing to hold an aquatic claim to. When routing grows one, this
1139 /// refusal is what has to be deleted to enable the value.
1140 ///
1141 /// Error tier, raised in `validate_campaign_with`, so the run ends at the
1142 /// validation tier (exit 1). Prescription: remove the declaration — a body whose
1143 /// route crosses water is governed by the flooded-cell rules already, and
1144 /// the derived aquatic class still reaches the binding ledger.
1145 pub const TRAVERSAL_UNPROVABLE: DwCode = DwCode::new("DW0455", ExitTier::Build);
1146
1147 /// A gate contradicts itself, so it can NEVER open: a flag on both its
1148 /// `requires_flags` and `forbids_flags`, or `requires_state` terms on one
1149 /// datum that no integer satisfies (`at-least 5` with `at-most 3`, two
1150 /// different `equals`). The thing carrying it — objective, effect, trigger,
1151 /// trap, dialogue option, cast placement, shop offer — is authored content
1152 /// that provably never happens, which is a defect in what the document
1153 /// SAYS, not a stylistic lint. One rule over the whole closed consumer set
1154 /// ([`crate::gate::for_each_gate`]), because satisfiability is a property
1155 /// of the gate, never of the verb that first needed the question answered.
1156 ///
1157 /// Error tier, validation (exit 1).
1158 pub const GATE_NEVER_OPENS: DwCode = DwCode::new("DW0847", ExitTier::Build);
1159 /// An asset's licence is outside the ADR-0013 allowlist, or its record lacks
1160 /// a field the allowlist's rule for that asset requires. One code for every
1161 /// asset that records a licence: a prefab catalog card (`delvec prefab`,
1162 /// `delvec::admit::diag::DW_LICENSE`) and an image a campaign declares in
1163 /// `world.textures[]` (spec-0084 §6.3, `crate::license`).
1164 pub const LICENSE_REFUSED: DwCode = DwCode::new("DW0741", ExitTier::Build);
1165 /// (spec-0084 §6.1) A `world.textures[]` row's `replaces` names a texture the
1166 /// pinned client does not ship — not the `minecraft` namespace, a path with
1167 /// `textures/` or `.png` left on, another version's path, a misspelling — or
1168 /// two rows replace one texture. Judged against the census vendored from the
1169 /// pinned client jar (`delvec::compiler::textures`); the duplicate half is
1170 /// judged in validation, where no census is needed.
1171 pub const TEXTURE_PATH: DwCode = DwCode::new("DW0939", ExitTier::Build);
1172 /// (spec-0084 §6.2) A `world.textures[]` row's file is not an image the
1173 /// named texture can be replaced by: not a PNG, not `k·w₀ × k·h₀` of the
1174 /// vanilla frame (or `k·w₀ × n·k·h₀` with a sidecar), a sidecar that does not
1175 /// parse as vanilla's animation metadata, or bytes identical to vanilla's.
1176 pub const TEXTURE_IMAGE: DwCode = DwCode::new("DW0940", ExitTier::Build);
1177 /// (spec-0085 §4.3) **A particle the game does not draw from a bare id.** A
1178 /// `particle` effect names an id the pinned registry
1179 /// (`crates/dsl/data/particles-1.21.11.json`) does not hold, or one whose
1180 /// type takes options (`dust`, `block`, `item`, …) — which the verb cannot
1181 /// carry, so the emitted command would be refused by the game.
1182 ///
1183 /// Error tier, validation (exit 1).
1184 pub const PERCEPTION_UNKNOWN_PARTICLE: DwCode = DwCode::new("DW0941", ExitTier::Build);
1185 /// (spec-0085 §3.3) **An audience on a party fact.** An effect states the
1186 /// envelope's `audience` or `in` on a verb the emitter fires once for the
1187 /// world ([`crate::stages::Verb::addresses_players`] answers `false`) — a
1188 /// flag, a gate, a block, a region, a timeline, a rocket. A box has no party
1189 /// and a world fact has no audience; a `sequence`'s steps each state their
1190 /// own.
1191 ///
1192 /// Error tier, validation (exit 1).
1193 pub const PERCEPTION_AUDIENCE_ON_A_PARTY_FACT: DwCode = DwCode::new("DW0942", ExitTier::Build);
1194 /// (spec-0085 §5.3) **A sight effect that ends under a camera.** In one
1195 /// timeline, a `give-effect` of a sight effect
1196 /// ([`crate::perception::SIGHT`]) overlaps a `cutscene` step and ends inside
1197 /// it, or within the effect's wind-down after it, so the effect starts
1198 /// ramping down on screen. The `give-effect` half of the findings-ledger
1199 /// row whose general form is that a granted sight effect outlasts any
1200 /// authored camera it can overlap.
1201 ///
1202 /// Error tier, validation (exit 1).
1203 pub const PERCEPTION_SIGHT_UNDER_A_CAMERA: DwCode = DwCode::new("DW0944", ExitTier::Build);
1204}
1205
1206#[cfg(test)]
1207mod tests {
1208 use super::*;
1209
1210 /// The tier's arithmetic is the CLI's published contract
1211 /// (`docs/reference/compiler.md` §1), so it is asserted rather than left to
1212 /// whoever next reads the `match`.
1213 #[test]
1214 fn a_tier_maps_to_its_published_exit_status() {
1215 assert_eq!(ExitTier::Analysis.exit_status(), 2);
1216 assert_eq!(ExitTier::Build.exit_status(), 3);
1217 }
1218
1219 /// A code carries the tier it was declared with, independently of what its
1220 /// number happens to spell — which is the
1221 /// whole point of moving the tier off the code's spelling. `DW0312` is the
1222 /// live instance: a `DW03xx` number that exits 2.
1223 #[test]
1224 fn a_code_carries_the_tier_it_declares_not_the_one_its_number_spells() {
1225 // `let`, not `const`: a `const NAME: DwCode = …` here would be a SECOND
1226 // diagnostic constant declaring a live code, and `tools/ci/check-dw-codes.py`
1227 // reads every `crates/**/*.rs` — it refuses one code declared twice, and
1228 // it is right to. Measured: this test written with `const` reds that gate
1229 // on all three codes.
1230 let analysis_spelt_dw03 = DwCode::new("DW0312", ExitTier::Analysis);
1231 let build_spelt_dw03 = DwCode::new("DW0311", ExitTier::Build);
1232
1233 assert_eq!(analysis_spelt_dw03.exit_tier(), ExitTier::Analysis);
1234 assert_eq!(analysis_spelt_dw03.exit_tier().exit_status(), 2);
1235 assert_eq!(build_spelt_dw03.exit_tier().exit_status(), 3);
1236 }
1237
1238 /// A code's properties are independent, and `about_the_engine`
1239 /// rebuilds the struct field by field — the one place where setting one
1240 /// could silently reset another. Today it cannot (there is no `Default` and
1241 /// no struct-update syntax, so an omitted field is a compile error), but
1242 /// "the compiler would catch it" is a claim about the current shape, and
1243 /// this is the assertion that survives the shape changing.
1244 #[test]
1245 fn marking_a_code_an_engine_notice_keeps_its_tier() {
1246 let engine_notice = DwCode::new("DW0813", ExitTier::Analysis).about_the_engine();
1247 assert_eq!(engine_notice.subject(), Subject::Engine);
1248 assert_eq!(engine_notice.exit_tier(), ExitTier::Analysis);
1249 assert_eq!(engine_notice.id(), "DW0813");
1250 }
1251}