[AZ-621] Phase C: build_pre_constructed seeds c7_inference

Third subtask of AZ-618. Extends airborne_bootstrap.build_pre_constructed
additively with c7_inference (GPU InferenceRuntime). Wraps the existing
inference_factory.build_inference_runtime so a BUILD_TENSORRT_RUNTIME /
BUILD_PYTORCH_FP16_RUNTIME mismatch surfaces a clear operator-facing
AirborneBootstrapError naming BOTH airborne C7 flags plus the consuming
component slug, rather than bubbling up RuntimeNotAvailableError with no
context.

New public const C7_AIRBORNE_BUILD_FLAGS pairs each airborne runtime
with its gating env flag (onnx_trt_ep deliberately omitted — research
only). Tests stub at the factory boundary; real GPU/TensorRT load
remains Tier-2 only (consolidated at AZ-624). AZ-619 and AZ-620 test
files extended with a _stub_c7_inference_builder autouse fixture
mirroring the AZ-620 pattern for _build_c6_*.

18/18 runtime_root unit tests pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-19 06:47:05 +03:00
parent 1ab93fe0c7
commit 680ba29ae6
8 changed files with 398 additions and 11 deletions
@@ -0,0 +1,68 @@
# Batch 92 Report — AZ-621 Phase C: build_pre_constructed seeds c7_inference (cycle 1)
**Batch**: 92
**Date**: 2026-05-19
**Context**: Product implementation (greenfield Step 7 — Implement; AZ-618 umbrella, Phase C of 6)
**Tasks**: AZ-621 (3 cp) — 1 task
**Cycle**: 1
**Verdict**: COMPLETE — PASS (self-reviewed inline; 18/18 runtime_root tests green)
## Summary
Third of six subtasks decomposing the AZ-618 umbrella. Phase C extends `airborne_bootstrap.build_pre_constructed(config)` additively with `c7_inference` (the GPU InferenceRuntime). Wraps the existing `inference_factory.build_inference_runtime` so that a `BUILD_TENSORRT_RUNTIME`/`BUILD_PYTORCH_FP16_RUNTIME` mismatch surfaces a clear operator-facing `AirborneBootstrapError` naming BOTH airborne C7 flags + the consuming component slug, rather than bubbling up the lower-level `RuntimeNotAvailableError` with no consuming-component context.
### AZ-621 — build_pre_constructed Phase C (3 cp)
* **`src/gps_denied_onboard/runtime_root/airborne_bootstrap.py`**:
* Imports `build_inference_runtime` from `runtime_root.inference_factory` (Layer-5 sibling).
* New public constant `C7_AIRBORNE_BUILD_FLAGS: tuple[tuple[str, str], ...] = (("tensorrt", "BUILD_TENSORRT_RUNTIME"), ("pytorch_fp16", "BUILD_PYTORCH_FP16_RUNTIME"))` — single source of truth for the airborne-buildable C7 runtimes + their gating env flags (deliberately omits `onnx_trt_ep`, which is research-only per `module-layout.md`). Exported in `__all__`.
* New module-private helper `_build_c7_inference(config)` — calls `build_inference_runtime`; on `RuntimeNotAvailableError`, re-raises as `AirborneBootstrapError` naming `c7_inference` (the missing key), BOTH `C7_AIRBORNE_BUILD_FLAGS` entries (so operator sees production-default + Tier-0 fallback), and the consuming component slug(s) via `_configured_consumers_of_pre_constructed_key`. Preserves the original error via `raise ... from exc`.
* `build_pre_constructed(config)` now returns five keys: `c13_fdr`, `clock`, `c6_descriptor_index`, `c6_tile_store`, `c7_inference`. Additivity preserved per AZ-621 Constraint "MUST be additive on top of AZ-619 + AZ-620"; docstring updated to mention AZ-621 Phase C and the new raise path.
* No new `BUILD_*` env flag introduced (constraint satisfied) — only a Python-level tuple listing already-existing flag names.
* **`tests/unit/runtime_root/test_az619_pre_constructed_phase_a.py`**:
* New autouse fixture `_stub_c7_inference_builder` monkeypatches `_build_c7_inference` to an opaque sentinel — keeps AZ-619 tests focused on Phase A keys without entangling them with the new Phase C integration path (and avoids requiring `BUILD_TENSORRT_RUNTIME=ON` + real GPU for the AZ-619 cases).
* **`tests/unit/runtime_root/test_az620_pre_constructed_phase_b.py`**:
* New autouse fixture `_stub_c7_inference_builder` (same pattern as the AZ-619 file) — keeps AZ-620 tests focused on Phase B C6 wiring and error-translation, independent of Phase C.
* **`tests/unit/runtime_root/test_az621_pre_constructed_phase_c.py`** (new):
* `test_ac_621_1_adds_c7_inference` — stubs `build_inference_runtime` to an identifiable mock; asserts the bootstrap dict contains `c7_inference` referencing the stub return, and AZ-619 + AZ-620 keys are still present. Covers AC-621.1.
* `test_ac_621_2_both_build_flags_off_with_configured_consumer_raises_named_error` — stubs `build_inference_runtime` to raise `RuntimeNotAvailableError` (mirroring real `BUILD_*=OFF` behaviour); builds a config with `c3_matcher.strategy="disk_lightglue"`; asserts `AirborneBootstrapError` is raised whose message contains `c7_inference`, BOTH `BUILD_TENSORRT_RUNTIME` and `BUILD_PYTORCH_FP16_RUNTIME` (sourced from the new constant), and `c3_matcher`. Verifies the original error is preserved as `__cause__`. Covers AC-621.2.
* `test_ac_621_2_no_configured_consumer_still_raises_with_full_set` — defence-in-depth (mirrors the AZ-620 same-name pattern): even with no consumer configured, the bootstrap still fails loudly and the message lists the FULL theoretical consumer set (`c2_vpr`, `c3_matcher`, `c3_5_adhop`). Strengthens AC-621.2's operator-facing contract.
## File Ownership
* OWNED (component `runtime_root`):
* `src/gps_denied_onboard/runtime_root/airborne_bootstrap.py`
* `tests/unit/runtime_root/test_az619_pre_constructed_phase_a.py`
* `tests/unit/runtime_root/test_az620_pre_constructed_phase_b.py`
* `tests/unit/runtime_root/test_az621_pre_constructed_phase_c.py`
* READ-ONLY: imports from `runtime_root.inference_factory` (Layer-5 sibling within same package), `runtime_root.errors`, plus the AZ-619/620 modules already in scope (`storage_factory`, `clock`, `fdr_client`, `config`).
* No FORBIDDEN-zone writes.
## Test Results
* New unit tests: **3** under `tests/unit/runtime_root/test_az621_pre_constructed_phase_c.py` covering AC-621.1 + AC-621.2 (twice, defence-in-depth).
* Updated unit tests: AZ-619 (5/5 passing) and AZ-620 (3/3 passing) — both files extended with one autouse stub fixture each; no behavioural changes to existing assertions.
* AZ-591 regression (`test_az591_airborne_bootstrap.py`): **7/7 passing**`AIRBORNE_REQUIRED_PRE_CONSTRUCTED_KEYS` table consistency + airborne registration semantics + tier isolation all unchanged.
* Combined: `pytest tests/unit/runtime_root/ -q`**18/18 passed in 0.68 s**.
* No new ruff errors on touched files.
## Out of scope (deferred)
* Remaining keys in `AIRBORNE_REQUIRED_PRE_CONSTRUCTED_KEYS` — AZ-622 (`c3_lightglue_runtime` + `c3_feature_extractor`), AZ-623 (`c282_ransac_filter` + c5 helpers), AZ-624 (`main()` integration + AC-1..AC-5).
* Real GPU model load / TensorRT engine deserialization — consolidated at AZ-624's Tier-2 Jetson AC-5 run per `_docs/02_document/tests/tier2-jetson-testing.md`. This subtask stubs at the factory boundary, exactly mirroring the AZ-620 pattern for C6 storage.
* Cumulative review for batches 85-92 (8 batches deferred — K=3 default missed). Recorded as outstanding work; the previous session intentionally chose AZ-621 as the next single-task batch and did not run the cumulative review at the start. Next session should run cumulative review (scope: union of files changed since `cumulative_review_batches_82-84_cycle1_report.md`) BEFORE starting batch 93 (AZ-622) or batch 94 (AZ-623) — both are still in the AZ-618 remediation cycle and the architecture surface around `airborne_bootstrap.py` deserves a cross-batch sweep before the umbrella's `main()` wiring (AZ-624) lands.
## State
* Spec moved: `_docs/02_tasks/todo/AZ-621_pre_constructed_phase_c_c7_inference.md``_docs/02_tasks/done/`.
* Tracker: AZ-621 transitioned **To Do → In Progress** at batch start; will transition **In Progress → In Testing** after this commit (per implement skill Step 12).
* `_docs/_autodev_state.md` advanced to `last_completed_batch: 92`.
## Next Batch
* **Batch 93**: AZ-622 (3 cp) — Phase D of AZ-618 umbrella. Adds `c3_lightglue_runtime` + `c3_feature_extractor` to `build_pre_constructed`. Depends on AZ-619 + AZ-620 + AZ-621 (all will be in `done/` after this commit) + AZ-278 (already in `done/`).
* **Alternative Batch 93**: AZ-623 (3 cp) — Phase E. Independent of AZ-621; could batch alongside AZ-622 (combined 6 cp, well under the 20-cp cap) if next session prefers throughput over single-phase review focus.
* **Recommended sequencing for next session**: (1) run the deferred cumulative review for batches 85-92; (2) then batch 93 — single task (AZ-622) to maintain the AZ-618 single-phase-per-batch pattern, OR a two-task batch (AZ-622 + AZ-623) if cumulative review surfaces no architecture drift around the bootstrap surface.