Skip to content

Commit 3a96d7b

Browse files
mrveissclaude
andauthored
refactor(setup_wizard): replace port magic numbers with _ROLE_INFRA_VARS and _CHROMADB_PORT constant (#3526)
Replace hardcoded 8080 with _ROLE_INFRA_VARS["ai-stack"][1] so the AI stack port has a single definition, and introduce _CHROMADB_PORT = 8100 as a module-level constant so the ChromaDB port stays in sync with the Ansible role defaults without silent divergence. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3121d06 commit 3a96d7b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

autobot-slm-backend/api/setup_wizard.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ def _build_inventory_children(
152152
), # Issue #3431: 8082 is WSL2/Hyper-V reserved (Windows NPU)
153153
}
154154

155+
# ChromaDB runs on the AI stack VM but is NOT a separately-routed role, so it
156+
# has no entry in _ROLE_INFRA_VARS. This constant must match chromadb_port in
157+
# ansible/roles/ai-stack/defaults/main.yml and backend_chromadb_port in
158+
# ansible/roles/backend/defaults/main.yml (#3526).
159+
_CHROMADB_PORT = 8100
160+
155161

156162
def _build_infra_vars(
157163
node_roles: list,
@@ -523,14 +529,14 @@ async def _generate_dynamic_inventory(
523529
# that reference {{ ai_stack_host }} resolve correctly (#3515).
524530
if injected_ai_stack and "ai_stack_host" not in infra_vars:
525531
infra_vars["ai_stack_host"] = "127.0.0.1"
526-
infra_vars["ai_stack_port"] = 8080
532+
infra_vars["ai_stack_port"] = _ROLE_INFRA_VARS["ai-stack"][1]
527533
# Auto-derive backend_chromadb_host from ai_stack_host for fleet deployments (#3523).
528534
# In co-located setups ai_stack_host is 127.0.0.1 (correct); in fleet setups it
529535
# is the AI stack node IP (also correct). backend_chromadb_host in role defaults
530536
# is always 127.0.0.1 and has no knowledge of fleet topology.
531537
if "ai_stack_host" in infra_vars and "backend_chromadb_host" not in infra_vars:
532538
infra_vars["backend_chromadb_host"] = infra_vars["ai_stack_host"]
533-
infra_vars["backend_chromadb_port"] = 8100
539+
infra_vars["backend_chromadb_port"] = _CHROMADB_PORT
534540
inventory = _build_inventory_dict(hosts, children, infra_vars)
535541

536542
fd, path = tempfile.mkstemp(suffix=".yml", prefix="wizard-inventory-")

0 commit comments

Comments
 (0)