Session: Backend Cleanup & Service Independence
Date: 2026-05-27
Scope: pipeline/backend/refactor/, pipeline/backend/database/migrations/, pipeline/backend/tests/, pipeline/backend/docker-compose.yml, pipeline/backend/Caddyfile, knowledge/, .opencode/skills/
Summary
Removed three orphaned directories from pipeline/backend/: the refactor/ migration project, the tests/ integration suite, and the central docker-compose.yml orchestrator. Migrated database schema knowledge to knowledge/. Each backend service now runs independently via its own docker-compose.yml on a shared dev network.
Key Learnings
New Patterns
- Migrations belong as numbered directories under the service they target (
database/migrations/001_initial_migration/), not as standalone projects. They are one-shot scripts tracked in git but not installed as packages. No__init__.py, nopyproject.toml— just standalone.pyfiles with relative imports. - One-shot scripts should not become permanent packages. The refactor project had its own
pyproject.toml,uv.lock,.venv/— overhead for scripts that ran once and are done. If there’s a chance of reuse, the pattern is: loose scripts in amigrations/orscripts/dir, using the project’s installed dev dependencies. - Docker Compose
include:is convenient but couples services. Removing the central orchestrator and running eachdocker-compose.ymlindependently works because all sub-composes definenetworks: dev: name: dev— Docker reuses the named network. No config changes needed. - Named Docker volumes survive
docker compose down. Onlydocker compose down -vor explicitdocker volume rmremoves them. This makes theinclude:→ independent transition safe for stateful services like Infisical’s PostgreSQL.
Decisions
- Delete migration scripts rather than preserve them in-tree. The v0→v1 migration is completed. The scripts are single-use and the knowledge (what was transformed, results) is preserved in
knowledge/journal/fixes/db-v0-to-v1-migration.md. Git history has the code if ever needed. - Delete
pipeline/backend/tests/. SDK integration tests overlap with lemna-sdk’s own tests. Endpoint integration tests exist in each endpoint repo. The standalone test project added maintenance burden for rarely-run tests. - Delete central
docker-compose.ymlandCaddyfile. Each service manages its own compose. Caddyfile was entirely commented out — no active routes. - Historical journal sessions are not rewritten. References to deleted paths (
pipeline/backend/refactor/,pipeline/backend/tests/) inknowledge/journal/sessions/done/are left as-is — they accurately describe what happened at the time. Only active/planning docs and skills are updated.
Pitfalls
- Docker Compose warns about pre-existing volumes and networks when running sub-composes independently after a central compose is removed. These are benign —
volume "infisical-pg_data" already exists but was not created by Docker Composejust means compose didn’t create it this run. Addingexternal: trueto the volume/network definitions would suppress the warnings but isn’t required. - The
include:compose pattern creates project-scoped networks (e.g.,backend_infisical) that differ from standalone project networks (e.g.,secrets_infisical). After transitioning, the containers join thesecrets_infisicalnetwork instead. This doesn’t affect functionality since inter-service communication uses the shareddevnetwork, not the project-scoped one. - Git submodules look like directories but have their own
.git. Therefactor/andtests/directories were NOT submodules (their.gitpointed to the parent repo), which made them safe to delete without submodule commands.
Skill Updates Needed
- map skill:
pipeline/backend/entry needs updating — removetests/reference, note that services run independently (no central compose) - essentials skill: Add note about named Docker volumes surviving
docker compose down(not a pitfall, but worth knowing) - patterns skill: Add the
migrations/001_X/pattern for one-shot database migration scripts
Files Modified
- Created:
knowledge/journal/fixes/db-v0-to-v1-migration.md,knowledge/journal/fixes/db-v0-to-v1-exploration-report.json - Created then deleted:
pipeline/backend/database/migrations/001_initial_migration/(created, then deleted by user decision) - Deleted:
pipeline/backend/refactor/(entire directory),pipeline/backend/tests/(entire directory),pipeline/backend/docker-compose.yml,pipeline/backend/Caddyfile - Updated:
pipeline/backend/database/.gitignore(reverted — removed!*.jsonand!*.sh),pipeline/backend/database/pyproject.toml(reverted — removed migration dev deps) - Updated:
.opencode/skills/secrets/SKILL.md(removedtests/conftest.pycallout, updated.envreferences) - Updated:
.opencode/skills/map/SKILL.md(removedmigrations/entry, needs further update fortests/and central compose) - Updated:
knowledge/index.md(added db-v0-to-v1 migration entry under Fixes) - Updated:
knowledge/plans/local-dev-test-plan.md(noted backend tests removed, updated commands) - Updated:
knowledge/plans/monorepo-decomposition-plan.md(resolved tests question as deleted, updated migration steps)