Skip to content

fix(infra): purge hardcoded localhost/paths [OMN-7226] - #1266

Merged
jonahgabriel merged 2 commits into
mainfrom
jonah/omn-7226-purge-hardcoded-omnibase_infra
Apr 13, 2026
Merged

jonahgabriel merged 2 commits into
mainfrom
jonah/omn-7226-purge-hardcoded-omnibase_infra

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Apr 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Findings triaged

Test plan

  • Pre-commit passes (all hooks green)
  • mypy passes on changed files
  • introspect.py respects ONEX_RUNTIME_URL env var when set

Summary by CodeRabbit

  • Improvements

    • Health endpoint URL is now configurable via environment variable with a localhost fallback.
    • Default introspection publish topic updated to use the canonical platform topic value.
  • Documentation

    • Clarified example deployment notes to recommend production Kafka bootstrap server configuration.
  • Tests

    • Added integration tests validating CLI introspection topic behavior and nonzero exit on publish failure.

- introspect.py: replace hardcoded http://localhost:8080 health endpoint
  with os.environ.get("ONEX_RUNTIME_URL", "http://localhost:8080")
- snapshot_publisher_registration.py: annotate docstring localhost:19092
  example with local-path-ok marker
@github-actions
github-actions Bot enabled auto-merge April 13, 2026 10:10
@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Introspection payload now builds the health endpoint from the ONEX_RUNTIME_URL environment variable with a http://localhost:8080 fallback and appends /{nid}/health. Example comments clarified Kafka bootstrap usage for local vs production and new CLI integration tests for the introspect command were added.

Changes

Cohort / File(s) Summary
Introspection CLI
src/omnibase_infra/cli/infra_test/introspect.py
Compute endpoints.health using ONEX_RUNTIME_URL (fallback http://localhost:8080) and append /{nid}/health. Switched default introspection topic constant to EnumPlatformTopic.EVT_NODE_INTROSPECTION_V1.value.
Examples / Tests
src/omnibase_infra/projectors/snapshot_publisher_registration.py, tests/integration/test_introspect_cli.py
Annotated example Kafka bootstrap config as local-only; added integration tests for the introspect CLI covering default topic, --topic override, and nonzero rpk failure exit behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code at break of day,
Env vars nudged the health URL my way.
Kafka notes for local cheer,
Tests ensure the rpk call is clear —
A little change, a tidy play. 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: replacing hardcoded localhost/paths with environment variable configuration in the infra module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-7226-purge-hardcoded-omnibase_infra

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/omnibase_infra/cli/infra_test/introspect.py (1)

26-26: ⚠️ Potential issue | 🟠 Major

Replace raw topic literal with canonical topic constant (CI blocker).

Line 26 introduces/retains a raw topic string and is currently failing CI (check_topic_literals.py). Please switch DEFAULT_INTROSPECTION_TOPIC to the repository’s canonical topics constant/loader entry instead of a literal.

As per coding guidelines, src/**/*.py: Hardcoded topic strings like 'onex.evt.foo.bar.v1' are forbidden - must use contract-declared topic names via contract loader.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/omnibase_infra/cli/infra_test/introspect.py` at line 26, Replace the raw
string assigned to DEFAULT_INTROSPECTION_TOPIC with the repository’s canonical
topic constant/loader entry: import the contract topics constant or loader
function used elsewhere in the codebase (the module that exposes the canonical
topic names, e.g., TOPICS or get_topic) and set DEFAULT_INTROSPECTION_TOPIC to
that canonical value (for example TOPICS.NODE_INTROSPECTION or
get_topic("platform.node-introspection.v1")); ensure you remove the hardcoded
"onex.evt.platform.node-introspection.v1" literal so the file passes
check_topic_literals.py.
🧹 Nitpick comments (1)
src/omnibase_infra/cli/infra_test/introspect.py (1)

84-86: Normalize ONEX_RUNTIME_URL before concatenation.

Line 85 can produce // when ONEX_RUNTIME_URL ends with /. Strip trailing slashes before composing the health URL.

♻️ Proposed refactor
-    return {
+    runtime_base_url = os.environ.get("ONEX_RUNTIME_URL", "http://localhost:8080").rstrip("/")
+    return {
         "node_id": nid,
         "node_type": node_type,
         "node_version": {"major": major, "minor": minor, "patch": patch},
         "declared_capabilities": {},
         "discovered_capabilities": {},
         "contract_capabilities": None,
         "endpoints": {
-            "health": f"{os.environ.get('ONEX_RUNTIME_URL', 'http://localhost:8080')}/{nid}/health"
+            "health": f"{runtime_base_url}/{nid}/health"
         },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/omnibase_infra/cli/infra_test/introspect.py` around lines 84 - 86,
Normalize the ONEX_RUNTIME_URL before concatenation: retrieve the env var
(os.environ.get('ONEX_RUNTIME_URL', 'http://localhost:8080')), call .rstrip('/')
on it to remove trailing slashes, and then build the health endpoint using that
normalized base (e.g., f"{base}/{nid}/health") so that the "endpoints" ->
"health" entry in the dict never contains a double slash; update the code that
constructs the endpoints/health URL in introspect.py (where ONEX_RUNTIME_URL and
nid are used).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/omnibase_infra/cli/infra_test/introspect.py`:
- Line 26: Replace the raw string assigned to DEFAULT_INTROSPECTION_TOPIC with
the repository’s canonical topic constant/loader entry: import the contract
topics constant or loader function used elsewhere in the codebase (the module
that exposes the canonical topic names, e.g., TOPICS or get_topic) and set
DEFAULT_INTROSPECTION_TOPIC to that canonical value (for example
TOPICS.NODE_INTROSPECTION or get_topic("platform.node-introspection.v1"));
ensure you remove the hardcoded "onex.evt.platform.node-introspection.v1"
literal so the file passes check_topic_literals.py.

---

Nitpick comments:
In `@src/omnibase_infra/cli/infra_test/introspect.py`:
- Around line 84-86: Normalize the ONEX_RUNTIME_URL before concatenation:
retrieve the env var (os.environ.get('ONEX_RUNTIME_URL',
'http://localhost:8080')), call .rstrip('/') on it to remove trailing slashes,
and then build the health endpoint using that normalized base (e.g.,
f"{base}/{nid}/health") so that the "endpoints" -> "health" entry in the dict
never contains a double slash; update the code that constructs the
endpoints/health URL in introspect.py (where ONEX_RUNTIME_URL and nid are used).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4505844a-d702-46dc-b6b0-1f4629f4b2ea

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4eb1b and e401266.

📒 Files selected for processing (2)
  • src/omnibase_infra/cli/infra_test/introspect.py
  • src/omnibase_infra/projectors/snapshot_publisher_registration.py

…st [OMN-7226]

Use EnumPlatformTopic.EVT_NODE_INTROSPECTION_V1.value instead of the
hardcoded literal in introspect.py. Add integration tests asserting the
CLI invokes rpk with the canonical topic constant.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/omnibase_infra/cli/infra_test/introspect.py`:
- Around line 84-86: Normalize the ONEX_RUNTIME_URL before composing
endpoints['health']: read os.environ.get('ONEX_RUNTIME_URL'), treat empty/blank
values as missing (fallback to 'http://localhost:8080'), strip any trailing
slashes (e.g., rstrip('/')) to avoid double slashes, then build the health URL
as base + '/' + nid + '/health'. Update the code that constructs the "endpoints"
dict (the "health" entry referencing nid and ONEX_RUNTIME_URL) to use this
normalized base.

In `@tests/integration/test_introspect_cli.py`:
- Around line 38-39: Replace the hardcoded broker CLI arg list ["introspect",
"--broker", "localhost:19092"] with a value read from the
KAFKA_BOOTSTRAP_SERVERS environment variable (or set it in the test with
monkeypatch.setenv) so tests use env-driven broker addresses; update all
occurrences (the CLI invocation lists at the three occurrences) to build args
like ["introspect", "--broker", os.environ["KAFKA_BOOTSTRAP_SERVERS"]] or use
monkeypatch.setenv("KAFKA_BOOTSTRAP_SERVERS", value) before calling the CLI
runner, ensuring you import os and/or use the pytest monkeypatch fixture and
keep catch_exceptions=False unchanged.
🪄 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: 73d6205b-8dca-4bf2-98c9-47d6b1967022

📥 Commits

Reviewing files that changed from the base of the PR and between e401266 and e4b788b.

📒 Files selected for processing (2)
  • src/omnibase_infra/cli/infra_test/introspect.py
  • tests/integration/test_introspect_cli.py

Comment on lines +84 to +86
"endpoints": {
"health": f"{os.environ.get('ONEX_RUNTIME_URL', 'http://localhost:8080')}/{nid}/health"
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Normalize ONEX_RUNTIME_URL before building endpoints.health.

At Line 85, an empty ONEX_RUNTIME_URL produces /{nid}/health, and a trailing slash produces //{nid}/health. Normalize and fallback on empty values.

Suggested patch
-        "endpoints": {
-            "health": f"{os.environ.get('ONEX_RUNTIME_URL', 'http://localhost:8080')}/{nid}/health"
-        },
+        "endpoints": {
+            "health": f"{(os.environ.get('ONEX_RUNTIME_URL') or 'http://localhost:8080').rstrip('/')}/{nid}/health"
+        },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/omnibase_infra/cli/infra_test/introspect.py` around lines 84 - 86,
Normalize the ONEX_RUNTIME_URL before composing endpoints['health']: read
os.environ.get('ONEX_RUNTIME_URL'), treat empty/blank values as missing
(fallback to 'http://localhost:8080'), strip any trailing slashes (e.g.,
rstrip('/')) to avoid double slashes, then build the health URL as base + '/' +
nid + '/health'. Update the code that constructs the "endpoints" dict (the
"health" entry referencing nid and ONEX_RUNTIME_URL) to use this normalized
base.

Comment on lines +38 to +39
["introspect", "--broker", "localhost:19092"],
catch_exceptions=False,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Replace hardcoded broker CLI args with env-driven values in tests.

Lines 38, 69, and 92 pass a fixed broker address (localhost:19092). Read broker from KAFKA_BOOTSTRAP_SERVERS (or set it via monkeypatch.setenv in each test) and pass that variable instead.

Suggested patch pattern
+import os
...
-                ["introspect", "--broker", "localhost:19092"],
+                ["introspect", "--broker", os.environ["KAFKA_BOOTSTRAP_SERVERS"]],
...
-                ["introspect", "--broker", "localhost:19092", "--topic", custom_topic],
+                ["introspect", "--broker", os.environ["KAFKA_BOOTSTRAP_SERVERS"], "--topic", custom_topic],
...
-                ["introspect", "--broker", "localhost:19092"],
+                ["introspect", "--broker", os.environ["KAFKA_BOOTSTRAP_SERVERS"]],

As per coding guidelines: "Never hardcode broker addresses -- use environment variables instead".

Also applies to: 69-70, 92-93

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/test_introspect_cli.py` around lines 38 - 39, Replace the
hardcoded broker CLI arg list ["introspect", "--broker", "localhost:19092"] with
a value read from the KAFKA_BOOTSTRAP_SERVERS environment variable (or set it in
the test with monkeypatch.setenv) so tests use env-driven broker addresses;
update all occurrences (the CLI invocation lists at the three occurrences) to
build args like ["introspect", "--broker",
os.environ["KAFKA_BOOTSTRAP_SERVERS"]] or use
monkeypatch.setenv("KAFKA_BOOTSTRAP_SERVERS", value) before calling the CLI
runner, ensuring you import os and/or use the pytest monkeypatch fixture and
keep catch_exceptions=False unchanged.

jonahgabriel added a commit that referenced this pull request Apr 13, 2026
Fallout from PRs #1264 (OMN-8605) and #1262 (OMN-8550) which landed on
main without test verification, blocking PR #1266 from going green.

Fix 1 — test_topic_suffix_exports.py:
  `from omnibase_infra.topics import __init__ as topics_init` resolved to
  a method-wrapper, not the module. Replace with a standard module import.

Fix 2 — test_protocol_ownership.py:
  KNOWN_DUPLICATE_LOCATIONS["ProtocolPublisher"] was missing the
  node_baseline_capture entry added by OMN-7484. Also allowlists
  ProtocolDomainPlugin (still present in runtime/ as a backward-compat
  shim post OMN-8550 SPI migration).

Fix 3 — test_topic_parity.py / check_contract_topic_parity.py:
  8 SUFFIX_* constants added in #1264 had no spec group entries:
    - 6 omniclaude injection-effectiveness topics (OMN-1889, OMN-2942)
      added to _OMNICLAUDE_AGENT_OBSERVABILITY_TOPIC_SUFFIXES in
      platform_topic_suffixes.py, and to _LEGACY_ALLOWLIST (cross-repo,
      contract.yaml lives in omniclaude).
    - onex.evt.git.hook.v1 and onex.evt.linear.snapshot.v1 added to
      ALL_OMNIBASE_INFRA_TOPIC_SPECS (3 partitions, 7-day retention),
      and to _LEGACY_ALLOWLIST (CLI relay producers, no node contract).

No new tickets filed per standing rule — OMN-8605 and OMN-8550 are
the parent tickets for these regressions.
@jonahgabriel
jonahgabriel merged commit d5fc7a9 into main Apr 13, 2026
47 of 52 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-7226-purge-hardcoded-omnibase_infra branch April 13, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant