nmbrs_workload/vocab.rs
1// Copyright 2024-2026 Jonathan Shook
2// SPDX-License-Identifier: Apache-2.0
3
4//! Flat name projections of the workload-construction registry.
5//!
6//! The single declaration point for every construction is
7//! [`crate::construction`] — enumerable node types carrying each
8//! element's name, valid forms, and documentation, discoverable
9//! against partial ASTs. This module projects those tables down
10//! to plain name lists for consumers that only need the
11//! vocabulary surface (the synthesizer superfuzz's coverage
12//! universe, docs tooling). The parser consumes the construction
13//! tables directly for its rejection checks.
14//!
15//! Known hygiene gap (open): PHASE-level unknown keys are not
16//! yet rejected at parse — see
17//! [`crate::construction::PhaseNode`]'s `open_surface`.
18
19use crate::construction as c;
20
21fn names(table: &'static [c::ElementSpec]) -> Vec<&'static str> {
22 table.iter().map(|e| e.name).collect()
23}
24
25/// Phase-level configuration keys (pinned to the
26/// `WorkloadPhase` struct by the serde field probe in
27/// `construction::tests`).
28pub fn phase_fields() -> Vec<&'static str> {
29 names(c::PHASE_ELEMENTS)
30}
31
32/// Op-template keys owned by the workload model (never forwarded
33/// to the adapter's op-field surface).
34pub fn op_model_fields() -> Vec<&'static str> {
35 names(c::OP_MODEL_ELEMENTS)
36}
37
38/// Op keys that carry the statement payload.
39pub fn op_stmt_fields() -> Vec<&'static str> {
40 names(c::OP_STMT_ELEMENTS)
41}
42
43/// Keys of a phase-level `poll:` block (SRD-75).
44pub fn phase_poll_fields() -> Vec<&'static str> {
45 names(c::POLL_ELEMENTS)
46}
47
48/// Sub-keys of an op's `abstract:` interface (SRD-108 Part B).
49pub fn abstract_interface_keys() -> Vec<&'static str> {
50 names(c::ABSTRACT_ELEMENTS)
51}
52
53/// Evaluation kinds accepted inside `evaluations:`.
54pub fn evaluation_kinds() -> Vec<&'static str> {
55 names(c::EVALUATIONS_ELEMENTS)
56}
57
58/// Structural scenario-node keys.
59pub fn scenario_node_keys() -> Vec<&'static str> {
60 names(c::SCENARIO_NODE_ELEMENTS)
61}
62
63/// GK binding declaration classes used from workload `bindings:`
64/// blocks.
65pub fn binding_classes() -> Vec<&'static str> {
66 names(c::BINDING_CLASS_ELEMENTS)
67}
68
69#[cfg(test)]
70mod tests {
71 use super::*;
72
73 /// The projections stay live views of the construction
74 /// tables — spot-check sentinel entries from each.
75 #[test]
76 fn projections_reflect_the_construction_tables() {
77 assert!(phase_fields().contains(&"poll"));
78 assert!(op_model_fields().contains(&"abstract"));
79 assert!(op_stmt_fields().contains(&"stmt"));
80 assert!(phase_poll_fields().contains(&"until"));
81 assert!(abstract_interface_keys().contains(&"results"));
82 assert!(evaluation_kinds().contains(&"relevancy"));
83 assert!(scenario_node_keys().contains(&"for_combinations"));
84 assert!(binding_classes().contains(&"cursor"));
85 }
86}