Discovery
Found while reviewing the #4305 fix. 99 infrastructure Python scripts contain:
sys.path.append("${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}")
# or:
sys.path.insert(0, "${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}")
Python treats this as a literal string — ${...} shell expansion never occurs inside Python string literals. The sys.path entry becomes the useless string "${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}" which is not a directory path and resolves nothing.
Verification
import sys
sys.path.append("${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}")
print(sys.path[-1]) # → "${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}" (literal, never a real path)
Why Scripts Still Work in Production
Ansible shell wrappers (e.g. start-coordinator.sh) run:
export PYTHONPATH="${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}:$PYTHONPATH"
The shell does expand this, so scripts work via PYTHONPATH in production. The broken sys.path.append lines are dead no-ops — they neither help nor hurt in production, but give a false sense that the import path is being set.
Impact
Correct Fix
# Replace:
sys.path.append("${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}")
# With:
import os, sys
sys.path.insert(0, os.environ.get("AUTOBOT_PROJECT_ROOT", "/opt/autobot/code_source"))
Scope
grep -rn 'sys.path.*\${' autobot-infrastructure/ | grep -v ".pyc" | wc -l
# → 99
This is a bulk fix — good candidate for sed/script across 99 files.
Discovery
Found while reviewing the #4305 fix. 99 infrastructure Python scripts contain:
Python treats this as a literal string —
${...}shell expansion never occurs inside Python string literals. The sys.path entry becomes the useless string"${AUTOBOT_PROJECT_ROOT:-/opt/autobot/code_source}"which is not a directory path and resolves nothing.Verification
Why Scripts Still Work in Production
Ansible shell wrappers (e.g.
start-coordinator.sh) run:The shell does expand this, so scripts work via PYTHONPATH in production. The broken
sys.path.appendlines are dead no-ops — they neither help nor hurt in production, but give a false sense that the import path is being set.Impact
/opt/autobot/code_source)from autobot_shared.network_constants import ServiceURLstotest_llm_awareness.pydirectly after one of these broken sys.path lines — making the silent failure more visibleautobot-infrastructure/shared/scripts/Correct Fix
Scope
This is a bulk fix — good candidate for
sed/script across 99 files.