Summary
Commit 0c671158 (feat: per-agent dispatch circuit breaker (#526) (#986)) adds a new top-level backend module src/backend/redis_breaker_util.py, imported by services/agent_client.py, but does not add a corresponding COPY line to docker/backend/Dockerfile. The backend Dockerfile copies top-level modules by explicit name, so the new file never lands in the image. The backend then crash-loops on startup with ModuleNotFoundError, taking down the whole platform (frontend/mcp-server/scheduler are gated on backend health via depends_on). Rebuilding with --no-cache does not help — the file is simply never copied.
Component
Backend / build packaging (docker/backend/Dockerfile)
Priority
P0 — backend fails to start; full platform outage on any deploy of this commit.
Error
ModuleNotFoundError: No module named 'redis_breaker_util'
File "/app/main.py", line 44, in <module>
from routers.auth import router as auth_router
File "/app/routers/agents.py", line 41, in <module>
from services.agent_service import (...)
File "/app/services/agent_service/lifecycle.py", line 27, in <module>
from services.skill_service import skill_service
File "/app/services/skill_service.py", line 26, in <module>
from services.agent_client import get_agent_client, AgentClientError
File "/app/services/agent_client.py", line 31, in <module>
from redis_breaker_util import (...)
Location
- File:
docker/backend/Dockerfile (top-level module COPY block, ~lines 62–68)
- Missing module:
src/backend/redis_breaker_util.py
- Importer:
src/backend/services/agent_client.py:31
Root Cause
docker/backend/Dockerfile enumerates top-level backend modules individually:
COPY ../../src/backend/main.py /app/
COPY ../../src/backend/config.py /app/
COPY ../../src/backend/models.py /app/
COPY ../../src/backend/db_models.py /app/
COPY ../../src/backend/dependencies.py /app/
COPY ../../src/backend/database.py /app/
COPY ../../src/backend/logging_config.py /app/
Subdirectories (routers/, services/, adapters/, utils/, db/, canary/) are copied wholesale, so the other new files in #986 (e.g. services/dispatch_breaker.py, services/circuit_breaker_view.py) are present — but the new top-level redis_breaker_util.py is not in the explicit list and is silently dropped. The module is present in source; it just never reaches /app in the image.
DB migrations from this commit (idempotency_keys table, schedule_executions.loop_id) run successfully before the import crash, confirming the DB layer is fine — this is purely a packaging defect.
Reproduction Steps
- Check out
0c671158 (or current dev).
- Build the backend image:
docker compose -f docker-compose.prod.yml build backend (with or without --no-cache).
- Start the stack:
docker compose -f docker-compose.prod.yml up -d.
docker logs trinity-backend → ModuleNotFoundError: No module named 'redis_breaker_util'; backend never becomes healthy; dependent services stay in Created.
Suggested Fix
Add the missing COPY for the new module:
# docker/backend/Dockerfile, alongside the other top-level modules
COPY ../../src/backend/redis_breaker_util.py /app/
Stronger fix — eliminate this entire class of bug by copying top-level modules with a glob so future additions don't silently drop out:
COPY ../../src/backend/*.py /app/
Recommended guardrail: add a build-time import smoke check to the backend image build (e.g. RUN python -c "import main"), so a missing module fails the build instead of shipping a broken image.
Environment
Related
Summary
Commit
0c671158(feat: per-agent dispatch circuit breaker (#526) (#986)) adds a new top-level backend modulesrc/backend/redis_breaker_util.py, imported byservices/agent_client.py, but does not add a correspondingCOPYline todocker/backend/Dockerfile. The backend Dockerfile copies top-level modules by explicit name, so the new file never lands in the image. The backend then crash-loops on startup withModuleNotFoundError, taking down the whole platform (frontend/mcp-server/scheduler are gated on backend health viadepends_on). Rebuilding with--no-cachedoes not help — the file is simply never copied.Component
Backend / build packaging (
docker/backend/Dockerfile)Priority
P0 — backend fails to start; full platform outage on any deploy of this commit.
Error
Location
docker/backend/Dockerfile(top-level module COPY block, ~lines 62–68)src/backend/redis_breaker_util.pysrc/backend/services/agent_client.py:31Root Cause
docker/backend/Dockerfileenumerates top-level backend modules individually:Subdirectories (
routers/,services/,adapters/,utils/,db/,canary/) are copied wholesale, so the other new files in #986 (e.g.services/dispatch_breaker.py,services/circuit_breaker_view.py) are present — but the new top-levelredis_breaker_util.pyis not in the explicit list and is silently dropped. The module is present in source; it just never reaches/appin the image.DB migrations from this commit (idempotency_keys table,
schedule_executions.loop_id) run successfully before the import crash, confirming the DB layer is fine — this is purely a packaging defect.Reproduction Steps
0c671158(or currentdev).docker compose -f docker-compose.prod.yml build backend(with or without--no-cache).docker compose -f docker-compose.prod.yml up -d.docker logs trinity-backend→ModuleNotFoundError: No module named 'redis_breaker_util'; backend never becomes healthy; dependent services stay inCreated.Suggested Fix
Add the missing COPY for the new module:
Stronger fix — eliminate this entire class of bug by copying top-level modules with a glob so future additions don't silently drop out:
COPY ../../src/backend/*.py /app/Recommended guardrail: add a build-time import smoke check to the backend image build (e.g.
RUN python -c "import main"), so a missing module fails the build instead of shipping a broken image.Environment
0c671158(dev, v0.6.0 + reliability commits)docker-compose.prod.yml, non-root backend imageRelated
docker/backend/Dockerfilesrc/backend/services/agent_client.py