Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d78a9ed
fix: purge localhost fallbacks from omnibase_infra, require env vars …
jonahgabriel Apr 2, 2026
2ecce12
Merge branch 'main' into jonah/omn-7227-omnibase-infra-purge-fallbacks
jonahgabriel Apr 2, 2026
9addccd
fix: ruff format on 3 files
jonahgabriel Apr 2, 2026
2317af6
fix(tests): update tests for localhost fallback removal [OMN-7227]
jonahgabriel Apr 2, 2026
a263800
fix(tests): remove Kafka bootstrap defaults — defeats @requires_kafka…
jonahgabriel Apr 2, 2026
6f51ae7
fix(ci): add ONEX_EXCLUDE to postgres handler env fallback, keep INV-…
jonahgabriel Apr 2, 2026
edd0de4
Merge remote-tracking branch 'origin/main' into jonah/omn-7227-omniba…
jonahgabriel Apr 2, 2026
fb4aaee
fix: correct INV-3 budget comment — handler_graph contributes 1, not …
jonahgabriel Apr 2, 2026
2752113
fix(lint): use fmt:skip to preserve ONEX_EXCLUDE on long line — passe…
jonahgabriel Apr 2, 2026
97cd384
fix: restore KAFKA_BOOTSTRAP_SERVERS test default in conftest [OMN-7227]
jonahgabriel Apr 2, 2026
afe0af2
fix(tests): remove KAFKA_BOOTSTRAP_SERVERS from global conftest defaults
jonahgabriel Apr 2, 2026
b610271
fix(tests): restore KAFKA_BOOTSTRAP_SERVERS in conftest, add KAFKA_IN…
jonahgabriel Apr 3, 2026
8291c58
fix: supply kafka_bootstrap_servers explicitly in ConfigSavingsEstima…
jonahgabriel Apr 3, 2026
d6e12fb
fix: supply kafka_bootstrap_servers in all observability config test …
jonahgabriel Apr 3, 2026
8750109
fix: add kafka_bootstrap_servers to monkeypatch env-based test cases
jonahgabriel Apr 3, 2026
24f5418
fix: supply required bootstrap_servers in ConfigSessionConsumer and o…
jonahgabriel Apr 3, 2026
1276399
fix: remove KAFKA_BOOTSTRAP_SERVERS from global _TEST_ENV_DEFAULTS
jonahgabriel Apr 3, 2026
191fa66
docs: update DLQ test comment — KAFKA_BOOTSTRAP_SERVERS no longer set…
jonahgabriel Apr 3, 2026
887aee9
fix: restore KAFKA_BOOTSTRAP_SERVERS global default, gate E2E tests o…
jonahgabriel Apr 3, 2026
e796a24
fix: gate Qdrant integration tests on QDRANT_INTEGRATION_TESTS=1
jonahgabriel Apr 3, 2026
a8d3fee
fix: ruff format Qdrant integration guard additions
jonahgabriel Apr 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions scripts/validate_no_env_fallbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: 2025 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
"""Validate that no localhost fallbacks exist in src/ Python files.

Scans src/**/*.py for patterns like:
- os.environ.get("...", "localhost...")
- default="localhost..."
- default="http://localhost..."
- default="bolt://localhost..."
- default="redis://localhost..."
- default="postgresql://localhost..."

Exits non-zero if any violations are found.
Skips test files (tests/, __tests__/).
"""

from __future__ import annotations

import re
import sys
from pathlib import Path

VIOLATIONS_PATTERNS = [
re.compile(r'os\.environ\.get\([^)]*,\s*"(localhost|http://localhost|bolt://localhost|redis://localhost|postgresql://localhost)'),
re.compile(r'default="(localhost|http://localhost|bolt://localhost|redis://localhost|postgresql://localhost)'),
]

SKIP_DIRS = {"tests", "__tests__", "test", "__pycache__"}


def scan(root: Path) -> list[tuple[str, int, str]]:
violations: list[tuple[str, int, str]] = []
for py_file in sorted(root.rglob("*.py")):
# Skip test directories
if any(part in SKIP_DIRS for part in py_file.parts):
continue
try:
lines = py_file.read_text().splitlines()
except (OSError, UnicodeDecodeError):
continue
for lineno, line in enumerate(lines, start=1):
for pattern in VIOLATIONS_PATTERNS:
if pattern.search(line):
violations.append((str(py_file), lineno, line.strip()))
break # one violation per line is enough
return violations


def main() -> int:
src_dir = Path(__file__).resolve().parent.parent / "src"
if not src_dir.is_dir():
print(f"ERROR: src directory not found at {src_dir}", file=sys.stderr)
return 1

violations = scan(src_dir)
if violations:
print(f"Found {len(violations)} localhost fallback(s):\n")
for filepath, lineno, line in violations:
print(f" {filepath}:{lineno}: {line}")
print("\nAll localhost/default fallbacks must be removed from src/.")
return 1

print("OK: No localhost fallbacks found in src/.")
return 0


if __name__ == "__main__":
sys.exit(main())
4 changes: 2 additions & 2 deletions src/omnibase_infra/cli/git_hook_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class ModelGitHookEmitParams(BaseModel):
outcome: str = Field(..., description="Hook outcome.")
gates: list[str] = Field(default_factory=list, description="Gate names evaluated.")
bootstrap_servers: str = Field(
default="localhost:19092",
default_factory=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
description="Kafka bootstrap servers.",
)

Expand Down Expand Up @@ -257,7 +257,7 @@ def _resolve_gates(gates_json: str | None, gates_file: Path | None) -> list[str]
@click.group()
@click.option(
"--bootstrap-servers",
default=lambda: os.environ.get("KAFKA_BOOTSTRAP_SERVERS", "localhost:19092"),
default=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
show_default=True,
help="Kafka bootstrap servers (overrides KAFKA_BOOTSTRAP_SERVERS env var).",
)
Expand Down
2 changes: 1 addition & 1 deletion src/omnibase_infra/cli/linear_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _build_event(
@click.group()
@click.option(
"--bootstrap-servers",
default=lambda: os.environ.get("KAFKA_BOOTSTRAP_SERVERS", "localhost:19092"),
default=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
show_default=True,
help="Kafka bootstrap servers (overrides KAFKA_BOOTSTRAP_SERVERS env var).",
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ModelKafkaEventBusConfig(BaseModel):

# Connection settings
bootstrap_servers: str = Field(
default="localhost:19092",
default_factory=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
description="Kafka bootstrap servers (host:port format, comma-separated for multiple)",
min_length=1,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# SPDX-License-Identifier: MIT
"""Configuration model for HandlerGraph."""

import os

from pydantic import BaseModel, ConfigDict, Field


Expand All @@ -22,7 +24,7 @@ class ModelGraphHandlerConfig(BaseModel):
model_config = ConfigDict(strict=True, frozen=True, extra="forbid")

uri: str = Field(
default="bolt://localhost:7687",
default_factory=lambda: os.environ["GRAPH_BOLT_URI"],
description="Bolt URI for graph database",
)
username: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from __future__ import annotations

import os

from pydantic import BaseModel, ConfigDict, Field


Expand All @@ -20,7 +22,7 @@ class ModelQdrantHandlerConfig(BaseModel):
model_config = ConfigDict(strict=True, frozen=True, extra="forbid")

url: str = Field(
default="http://localhost:6333",
default_factory=lambda: os.environ["QDRANT_URL"],
description="Qdrant server URL",
)
api_key: str | None = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import asyncio
import json
import logging
import os
import time
from datetime import UTC, datetime
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -176,7 +177,7 @@ def __init__(
container: ModelONEXContainer,
postgres_adapter: ProtocolPostgresAdapter | None = None,
dsn: str | None = None,
host: str = "localhost",
host: str | None = None,
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
port: int = 5432,
database: str = "omnibase_infra",
user: str = "postgres",
Expand Down Expand Up @@ -240,9 +241,9 @@ def __init__(
transport_type=cb_config.transport_type,
)

# Store configuration
# Store configuration — host is required via env var if not provided
self._dsn = dsn
self._host = host
self._host = host if host is not None else os.environ["POSTGRES_HOST"]
self._port = port
self._database = database
self._user = user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def handle(self, request: object, correlation_id: UUID) -> object:

from aiokafka.admin import AIOKafkaAdminClient

_kafka = os.environ.get("KAFKA_BOOTSTRAP_SERVERS", "localhost:19092") # ONEX_EXCLUDE # fmt: skip
_kafka = os.environ["KAFKA_BOOTSTRAP_SERVERS"] # ONEX_EXCLUDE # fmt: skip
admin = AIOKafkaAdminClient(
bootstrap_servers=_kafka, request_timeout_ms=2000
)
Expand All @@ -99,7 +99,7 @@ async def handle(self, request: object, correlation_id: UUID) -> object:

import httpx

qdrant_url = os.environ.get("QDRANT_URL", "http://localhost:6333") # ONEX_EXCLUDE # fmt: skip
qdrant_url = os.environ["QDRANT_URL"] # ONEX_EXCLUDE # fmt: skip
async with httpx.AsyncClient(timeout=2) as client:
resp = await client.get(f"{qdrant_url}/healthz")
components["qdrant"] = (
Expand Down
3 changes: 2 additions & 1 deletion src/omnibase_infra/probes/capability_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import json
import logging
import os
import socket
import urllib.error
import urllib.request
Expand Down Expand Up @@ -119,7 +120,7 @@ def http_health_check(url: str, timeout: float = 1.0) -> bool:

def probe_platform_tier(
kafka_servers: str = "",
intelligence_url: str = "http://localhost:8053",
intelligence_url: str = os.environ.get("INTELLIGENCE_URL", ""),
kafka_timeout: float = 1.0,
intel_timeout: float = 1.0,
) -> TierName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ModelKafkaProducerConfig(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)

bootstrap_servers: str = Field(
default="localhost:19092",
default_factory=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
description="Kafka bootstrap servers",
)
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
timeout_seconds: float = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ModelPostgresPoolConfig(BaseModel):

model_config = ConfigDict(frozen=True, extra="forbid", from_attributes=True)

host: str = Field(default="localhost", description="PostgreSQL host")
host: str = Field(default_factory=lambda: os.environ["POSTGRES_HOST"], description="PostgreSQL host")
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
port: int = Field(default=5432, ge=1, le=65535, description="PostgreSQL port")
user: str = Field(default="postgres", description="PostgreSQL user")
password: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class ModelRuntimeSchedulerConfig(BaseModel):

# Valkey (Redis-compatible) configuration for sequence number persistence
valkey_host: str = Field(
default="localhost",
default_factory=lambda: os.environ["VALKEY_HOST"],
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
description="Valkey host for sequence number persistence",
min_length=1,
max_length=255,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ class ConfigAgentActionsConsumer(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description=(
"Kafka bootstrap servers. Set via "
"OMNIBASE_INFRA_AGENT_ACTIONS_KAFKA_BOOTSTRAP_SERVERS env var for production."
"OMNIBASE_INFRA_AGENT_ACTIONS_KAFKA_BOOTSTRAP_SERVERS env var."
),
)
kafka_group_id: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConfigConsumerHealthProjection(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description="Kafka bootstrap servers.",
)
kafka_group_id: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class ConfigContextAuditConsumer(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description=(
"Kafka bootstrap servers. Set via "
"OMNIBASE_INFRA_CONTEXT_AUDIT_KAFKA_BOOTSTRAP_SERVERS env var for production."
"OMNIBASE_INFRA_CONTEXT_AUDIT_KAFKA_BOOTSTRAP_SERVERS env var."
),
)
kafka_group_id: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ConfigInjectionEffectivenessConsumer(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description=(
"Kafka bootstrap servers. Set via "
"OMNIBASE_INFRA_INJECTION_EFFECTIVENESS_KAFKA_BOOTSTRAP_SERVERS env var."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class ConfigLlmCostAggregation(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description=(
"Kafka bootstrap servers. Set via "
"OMNIBASE_INFRA_LLM_COST_KAFKA_BOOTSTRAP_SERVERS env var for production."
"OMNIBASE_INFRA_LLM_COST_KAFKA_BOOTSTRAP_SERVERS env var."
),
)
kafka_group_id: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ConfigSavingsEstimation(BaseSettings):
)

kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description="Kafka bootstrap servers.",
)
kafka_group_id: str = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class ConfigSkillLifecycleConsumer(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description=(
"Kafka bootstrap servers. Set via "
"OMNIBASE_INFRA_SKILL_LIFECYCLE_KAFKA_BOOTSTRAP_SERVERS env var for production."
"OMNIBASE_INFRA_SKILL_LIFECYCLE_KAFKA_BOOTSTRAP_SERVERS env var."
),
)
kafka_group_id: str = Field(
Expand Down
2 changes: 1 addition & 1 deletion src/omnibase_infra/services/post_merge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ConfigPostMergeConsumer(BaseSettings):

# Kafka connection
kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description="Kafka bootstrap servers",
)
kafka_group_id: str = Field(
Expand Down
4 changes: 2 additions & 2 deletions src/omnibase_infra/services/session/config_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class ConfigSessionConsumer(BaseSettings):

# Kafka connection
bootstrap_servers: str = Field(
default="localhost:19092",
description="Kafka bootstrap servers. Set via OMNIBASE_INFRA_SESSION_CONSUMER_BOOTSTRAP_SERVERS env var for production.",
...,
description="Kafka bootstrap servers. Set via OMNIBASE_INFRA_SESSION_CONSUMER_BOOTSTRAP_SERVERS env var.",
)
group_id: str = Field(
default="omnibase-infra-session-consumer",
Expand Down
2 changes: 1 addition & 1 deletion src/omnibase_infra/services/session/config_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ConfigSessionStorage(BaseSettings):
# config/shared_key_registry.yaml) first, then falls back to the bare
# field names so that direct construction (e.g. in tests) still works.
postgres_host: str = Field(
default="localhost",
...,
description="PostgreSQL host",
)
postgres_port: int = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
class ModelConfigGraphProjector(BaseModel):
"""Configuration for the session graph projector.

Connection defaults are sourced from OMNIMEMORY_MEMGRAPH_HOST/PORT
environment variables, falling back to localhost:7687.
Connection values are sourced from OMNIMEMORY_MEMGRAPH_HOST/PORT
environment variables (required, no fallback).
"""

model_config = ConfigDict(frozen=True, extra="forbid")

bootstrap_servers: str = Field(
default="localhost:19092",
default_factory=lambda: os.environ["KAFKA_BOOTSTRAP_SERVERS"],
description="Kafka bootstrap servers.",
)
consumer_group: str = Field(
Expand All @@ -39,11 +39,11 @@ class ModelConfigGraphProjector(BaseModel):
description="Regex pattern for Kafka topic subscription.",
)
memgraph_host: str = Field(
default_factory=lambda: os.environ.get("OMNIMEMORY_MEMGRAPH_HOST", "localhost"),
default_factory=lambda: os.environ["OMNIMEMORY_MEMGRAPH_HOST"],
description="Memgraph host.",
)
memgraph_port: int = Field(
default_factory=lambda: int(os.environ.get("OMNIMEMORY_MEMGRAPH_PORT", "7687")),
default_factory=lambda: int(os.environ["OMNIMEMORY_MEMGRAPH_PORT"]),
description="Memgraph bolt port.",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ConfigWaitlistSignupNotifier(BaseSettings):
)

kafka_bootstrap_servers: str = Field(
default="localhost:19092",
...,
description="Kafka bootstrap servers",
)
kafka_topic: str = Field(
Expand Down
2 changes: 1 addition & 1 deletion src/omnibase_infra/tui/consumers/consumer_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def consume_all(app: object) -> None:
Args:
app: The textual App instance to receive messages.
"""
bootstrap_servers = os.environ.get("KAFKA_BOOTSTRAP_SERVERS", "localhost:19092")
bootstrap_servers = os.environ["KAFKA_BOOTSTRAP_SERVERS"]
consumer: AIOKafkaConsumer | None = None
try:
Comment thread
jonahgabriel marked this conversation as resolved.
Resolved
consumer = AIOKafkaConsumer(
Expand Down
Loading
Loading