Repository navigation
feat(OMN-11242): wire TopicProvisioner into runtime kernel startup - #1652
Conversation
…ization Provisions subscribe_topics from newly materialized contracts before wire_subscriptions is called, ensuring Kafka topics exist before any subscription attempt. Reads bootstrap_servers from the Kafka event bus instance (not env) to stay within approved env-read boundaries. Best-effort: TopicProvisioner failure logs a warning but never blocks materialization or subscription. Provisioning is skipped entirely when the runtime is using an inmemory event bus. Boot-time provisioning (section 3.5 in service_kernel.py) was already wired; this PR adds the dynamic-materialization path and 7 unit tests.
📝 WalkthroughWalkthroughThe PR adds best-effort Kafka topic pre-provisioning to runtime handler subscription wiring. Before wiring subscriptions for live-materialized handlers, the code now checks if the event bus is Kafka, extracts bootstrap servers, and ensures each subscribed topic exists using TopicProvisioner. Provisioning failures log warnings and do not block subscriptions. Comprehensive tests verify kernel boot integration, best-effort failure handling, and conditional provisioning behavior. ChangesTopic pre-provisioning for live handler subscriptions
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
tests/unit/runtime/test_topic_provisioner_integration.py (2)
43-51: ⚡ Quick winConsider replacing string-based source inspection with behavior verification.
String matching in source code is fragile and can break with refactoring (import aliasing, formatting changes). Since you have
test_provisioner_import_path_is_correctvalidating the import path, this test adds limited incremental value. Consider removing it or replacing it with an integration test that actually exercises the kernel boot sequence.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/runtime/test_topic_provisioner_integration.py` around lines 43 - 51, The test test_provisioner_is_referenced_in_kernel_source uses fragile string-based source inspection of service_kernel to look for "TopicProvisioner" and "ensure_provisioned_topics_exist"; replace it by either removing the test (since test_provisioner_import_path_is_correct already covers import validation) or convert it into a behavior/integration test that boots the kernel and asserts the TopicProvisioner integration by exercising service_kernel's boot path (e.g., invoking the kernel startup routine and verifying that ensure_provisioned_topics_exist is called or that the TopicProvisioner is registered), targeting the service_kernel module and the TopicProvisioner/ensure_provisioned_topics_exist symbols rather than matching source text.
102-120: ⚖️ Poor tradeoffOptional: Consider extracting the kernel simulation logic to a helper function.
The inline kernel section-3.5 simulation (lines 102-120) is complex and could be extracted to a reusable helper if other tests need similar behavior. Since this is currently the only test using this pattern, extraction is optional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/runtime/test_topic_provisioner_integration.py` around lines 102 - 120, Extract the inline kernel simulation block that calls provisioner.ensure_provisioned_topics_exist and logs via kernel_logger into a small reusable test helper (e.g., run_provisioning_and_log or simulate_kernel_provisioning) to reduce duplication and improve readability; move the try/except, the call to mock_provisioner.ensure_provisioned_topics_exist (preserve correlation_id param), the determination of log_level based on provisioning_result["status"], and the kernel_logger.log/kernel_logger.warning behavior into that helper, then replace the inline block with a single call to the new helper from the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/omnibase_infra/runtime/service_runtime_host_process.py`:
- Around line 3575-3604: The loop over subcontract.subscribe_topics is wrapped
by a single try/except so one failing ensure_topic_exists call aborts
provisioning for remaining topics; change to provision each topic independently
by moving the try/except inside the for loop (or catching exceptions around each
await _provisioner.ensure_topic_exists(topic_name=_topic)), logging a
non-blocking warning that includes node_name and the specific _topic on failure
while keeping the outer bootstrap/TopicProvisioner creation unchanged.
In `@tests/unit/runtime/test_topic_provisioner_integration.py`:
- Around line 94-96: The local import "import logging as _logging" is redundant
because logging is already imported at module scope; remove the line "import
logging as _logging" and ensure any references within the test (e.g., near the
import of TopicProvisioner from omnibase_infra.event_bus.service_topic_manager)
use the existing module-level "logging" name instead.
---
Nitpick comments:
In `@tests/unit/runtime/test_topic_provisioner_integration.py`:
- Around line 43-51: The test test_provisioner_is_referenced_in_kernel_source
uses fragile string-based source inspection of service_kernel to look for
"TopicProvisioner" and "ensure_provisioned_topics_exist"; replace it by either
removing the test (since test_provisioner_import_path_is_correct already covers
import validation) or convert it into a behavior/integration test that boots the
kernel and asserts the TopicProvisioner integration by exercising
service_kernel's boot path (e.g., invoking the kernel startup routine and
verifying that ensure_provisioned_topics_exist is called or that the
TopicProvisioner is registered), targeting the service_kernel module and the
TopicProvisioner/ensure_provisioned_topics_exist symbols rather than matching
source text.
- Around line 102-120: Extract the inline kernel simulation block that calls
provisioner.ensure_provisioned_topics_exist and logs via kernel_logger into a
small reusable test helper (e.g., run_provisioning_and_log or
simulate_kernel_provisioning) to reduce duplication and improve readability;
move the try/except, the call to
mock_provisioner.ensure_provisioned_topics_exist (preserve correlation_id
param), the determination of log_level based on provisioning_result["status"],
and the kernel_logger.log/kernel_logger.warning behavior into that helper, then
replace the inline block with a single call to the new helper from the test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f69538be-2105-4682-9d88-f3327c3b9bfa
📒 Files selected for processing (2)
src/omnibase_infra/runtime/service_runtime_host_process.pytests/unit/runtime/test_topic_provisioner_integration.py
|
…ra (#2242) * ci(OMN-14172): roll out integration silent-skip guard to omnibase_infra Enforcement-not-detection rollout of the OMN-14172 silent-skip false-green guard (omnimarket canary #1652, MERGED) to omnibase_infra — CI gate + pre-commit hook ship in the same PR (Operating Rule #5): - scripts/ci/check_integration_skips.py + integration_skip_guard.yaml, calibrated for infra's real Postgres-absence skip vocabulary (grepped from tests/); allowlists Kafka/Consul/Vault/Qdrant/live/catalog skips - new `integration-guard` CI job: provisions postgres:16-alpine (mirrors migration-integration), applies all migrations, exports OMNIBASE_INFRA_DB_URL + POSTGRES_* env, runs the curated Postgres-only proofs with --junitxml, then enforces check_integration_skips.py (fail-closed) - wired BLOCKING via ci_summary_gate.py SKIPPABLE_GATE_JOBS (the CI Summary umbrella required context); NO new branch-protection required context is registered here — deferred to operator/Codex once green on real PRs - integration-skip-guard pre-commit hook (--selftest, no DB needed) - tests/ci/test_check_integration_skips.py: case-(a) PASS + case-(b) RED regression proof plus full-vocabulary coverage OCC companion owed: omnibase_infra verify/receipt-gate needs Evidence-Source: OCC#<n> (Codex authors). * fix(ci): narrow integration skip guard proofs * fix(ci): make integration guard proof self-contained * ci(OMN-14172): fix integration guard review follow-ups



Summary
TopicProvisioner.ensure_provisioned_topics_exist()into the runtime kernel boot sequence (section 3.5 was already present inservice_kernel.py— confirmed and documented)_wire_live_handler_subscriptions()inservice_runtime_host_process.pynow callsTopicProvisioner.ensure_topic_exists()for each subscribe topic before callingwire_subscriptions()Changes
src/omnibase_infra/runtime/service_runtime_host_process.py: provision topics viaTopicProvisionerbeforewire_subscriptions()in_wire_live_handler_subscriptions(); reads bootstrap_servers fromself._event_bus._bootstrap_serversviaisinstance(self._event_bus, EventBusKafka)check (avoidsos.environread blocked bycheck-env-readspre-commit hook)tests/unit/runtime/test_topic_provisioner_integration.py: 7 new unit tests covering boot-time structural checks, best-effort failure handling, call ordering (provision before subscribe), inmemory bus skip, and no-wiring skipTest plan
uv run pytest tests/unit/runtime/test_topic_provisioner_integration.py -v— 7 tests passuv run pytest tests/ -m unit -v— full unit suite greenpre-commit run --all-files— all hooks passTicket
OMN-11242
dod_evidence
test_topic_provisioner_integration.pypass locallyTopicProvisionerreferenced inservice_kernel.py(section 3.5) andservice_runtime_host_process.py(_wire_live_handler_subscriptions)ensure_provisioned_topics_existcallable confirmed via import testwire_subscriptionsin test call logcheck-env-reads,kafka-no-hardcoded-fallback, mypy strictSummary by CodeRabbit
New Features
Tests
Evidence-Source: OCC#1147
Evidence-Ticket: OMN-11242