E-CC-HELPERS closes with the three remaining Layer-1 helpers and E-CC-CONF closes with the env > YAML > defaults precedence test gate. All four tickets ship with frozen public surfaces, hermetic unit tests, and no upward (components.*) imports. * AZ-271 — tests/unit/shared/config/test_precedence.py (5 ACs + smoke test + helper that names the layer in failure messages). * AZ-282 — helpers/ransac_filter.py: static RansacFilter + RansacResult; cv2.setRNGSeed(0) for byte-equal determinism; median residual semantics pinned by contract. * AZ-276 — helpers/imu_preintegrator.py + make_imu_preintegrator; GTSAM PreintegratedCombinedMeasurements; strict-monotonic ts_ns guard runs before any state mutation. Adjacent hygiene: _types/nav.py ImuSample/ImuWindow now use ts_ns:int and the spec-mandated ImuBias dataclass. * AZ-278 — helpers/lightglue_runtime.py: structural R14 fix. LightGlueRuntime + non-blocking concurrent-access guard that raises rather than serialising. EngineHandle Protocol in _types/manifests.py + KeypointSet/CorrespondenceSet in _types/matching.py (Protocol surface adds approved by spec). Dependency conflict (Finding 1, user-approved): gtsam 4.2 (PyPI) is numpy-1.x-ABI only; opencv-python>=4.12 needs numpy>=2 at runtime. Resolution: opencv-python pin relaxed to >=4.11.0.86,<4.12. The D-CROSS-CVE-1 ratchet at ci/opencv_pin_gate.py is held at 4.11.0 with the original 4.12.0 floor restored once a numpy-2-compatible gtsam wheel ships. Full replay procedure in _docs/_process_leftovers/2026-05-11_d_cross_cve_1_opencv_pin_deferred.md. Tests: 294 passed, 2 skipped (cmake/actionlint env-skips, pre-existing). 43 new tests added for batch 5. Ruff check + format clean. Co-authored-by: Cursor <cursoragent@cursor.com>
3.3 KiB
Config Precedence Unit Tests
Task: AZ-271_config_precedence_tests Name: Config Precedence Tests Description: A focused unit-test module that verifies the env > YAML > defaults precedence rule for at least 3 keys per layer (per epic AZ-246 AC-3) and the multi-file YAML merge order (later wins). Companion to AZ-269 / AZ-270. Complexity: 2 points Dependencies: AZ-269_config_loader, AZ-270_compose_root Component: shared.config (cross-cutting; epic AZ-246 / E-CC-CONF) Tracker: AZ-271 Epic: AZ-246 (E-CC-CONF)
Document Dependencies
_docs/02_document/contracts/shared_config/composition_root_protocol.md— the contract whose precedence invariant this test suite verifies.
Problem
The composition_root_protocol contract declares a hard precedence rule. Without explicit, tabular tests covering at least 3 keys per layer, regressions in the loader silently flip precedence and cause field bugs that only show up in production deployments where env overrides matter most.
Outcome
- A pytest module with clearly-named cases covering precedence for ≥3 keys at each layer.
- A multi-file YAML merge case proving later paths win over earlier paths.
- Failure messages name the layer (env / YAML / defaults) so on-call engineers can triage fast.
Scope
Included
- Precedence cases for ≥3 keys at each of: env > YAML, YAML > defaults, multi-file YAML merge order.
- One reachability case driving
compose_rootend-to-end with a stub Config to prove the loader and composition functions integrate cleanly. - Test fixtures (in-memory YAML strings + env dict, no real files needed for precedence cases; one tmp_path for the multi-file case).
Excluded
- Performance microbench — owned by AZ-269.
- Strategy/build-flag mismatch tests — owned by AZ-270.
- Per-component config block tests — owned by each component epic.
Acceptance Criteria
AC-1: env > YAML for at least 3 keys
Given env sets LOG_LEVEL, FDR_QUEUE_SIZE, MAVLINK_BAUD and YAML sets all three to different values
When load_config(env, [yaml]) runs
Then all three resolved values match env
AC-2: YAML > defaults for at least 3 keys
Given env is empty and YAML sets log.level, fdr.queue_size, mavlink.baud
When load_config(env, [yaml]) runs
Then all three resolved values match YAML (not the documented defaults)
AC-3: Defaults apply for at least 3 keys
Given env is empty and YAML omits the three keys
When load_config(env, [yaml]) runs
Then all three resolved values match the documented defaults
AC-4: Multi-file YAML — later wins
Given two YAML paths setting the same key to different values
When load_config(env, [first, second]) runs
Then the resolved value matches the second file
AC-5: Failure messages name the layer Given a precedence assertion fails When pytest reports the failure Then the assertion message names which layer's value was expected and which was found
Non-Functional Requirements
Reliability
- Tests are hermetic: no real env vars consulted, no real YAML files outside tmp_path.
Constraints
- Test file path is fixed at
tests/unit/shared/config/test_precedence.py(mirrors thetests/unit/<component>/convention from module-layout.md Layout Rule 7 —shared/configis the component slug). - Cases use the SAME 3 keys per layer to make the test matrix comparable across layers.