STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_requirements_schema_completeness Namespace Reference

Functions

set[str] _keys_layer1_reads ()
 test_every_key_layer1_reads_is_declared ()
 test_the_scan_actually_finds_keys ()
 test_previously_undeclared_keys_now_round_trip (key)

Variables

str LAYER1 = Path(__file__).resolve().parent.parent / "engine/optimizer/layers/layer1_static_optimization.py"
set RUNTIME_ONLY = set()
tuple READ_PATTERNS

Detailed Description

Every requirement key Layer 1 reads must be DECLARED in DesignRequirementsConfig.

A pydantic model silently DROPS unknown keys. So a key the optimizer reads but the schema
does not declare cannot be set at all: `PUT /api/config` returns 200 and discards it, a YAML
carrying it loads without it, and the value the optimizer uses is always its hardcoded
fallback. Four such keys even had labelled controls in the Configuration editor, so the UI
offered knobs that did nothing.

Sixteen keys were in that state when this test was written (2026-09-14), including
`max_chamber_length_m`, the throat-area search bounds, and the whole injector ring-geometry
group. This test fails if anyone adds a seventeenth.

The reverse direction is deliberately NOT checked: a declared field with no reader is
harmless (it may be read by Layer 2/3, the frontend, or a future consumer).

Function Documentation

◆ _keys_layer1_reads()

set[str] test_requirements_schema_completeness._keys_layer1_reads ( )
protected

◆ test_every_key_layer1_reads_is_declared()

test_requirements_schema_completeness.test_every_key_layer1_reads_is_declared ( )

Definition at line 48 of file test_requirements_schema_completeness.py.

References _keys_layer1_reads().

◆ test_previously_undeclared_keys_now_round_trip()

test_requirements_schema_completeness.test_previously_undeclared_keys_now_round_trip ( key)
These four were readable-but-unsettable and are the reason this test exists.

Definition at line 76 of file test_requirements_schema_completeness.py.

◆ test_the_scan_actually_finds_keys()

test_requirements_schema_completeness.test_the_scan_actually_finds_keys ( )
Guard the guard: if the regexes stop matching, the test above passes vacuously.

Definition at line 62 of file test_requirements_schema_completeness.py.

References _keys_layer1_reads().

Variable Documentation

◆ LAYER1

str test_requirements_schema_completeness.LAYER1 = Path(__file__).resolve().parent.parent / "engine/optimizer/layers/layer1_static_optimization.py"

Definition at line 25 of file test_requirements_schema_completeness.py.

◆ READ_PATTERNS

tuple test_requirements_schema_completeness.READ_PATTERNS
Initial value:
1= (
2 r'_requirement_float\‍(\s*requirements,\s*["\']([A-Za-z0-9_]+)["\']',
3 r'_requirement_bool\‍(\s*requirements,\s*["\']([A-Za-z0-9_]+)["\']',
4 r'_requirement_int\‍(\s*requirements,\s*["\']([A-Za-z0-9_]+)["\']',
5 r'requirements\.get\‍(\s*["\']([A-Za-z0-9_]+)["\']',
6 r'_req_lookup\‍(\s*requirements,\s*["\']([A-Za-z0-9_]+)["\']',
7)

Definition at line 31 of file test_requirements_schema_completeness.py.

◆ RUNTIME_ONLY

set test_requirements_schema_completeness.RUNTIME_ONLY = set()

Definition at line 29 of file test_requirements_schema_completeness.py.