fix: worker never actually ran end-to-end against compose #64
No reviewers
Labels
No labels
in-progress
in-review
ready-for-agent
seam-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
patrick/Polaris!64
Loading…
Reference in a new issue
No description provided.
Delete branch "chore/fix-worker-compose-command"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While verifying #6's last acceptance criterion ("worker starts against the compose stack and logs a heartbeat on schedule") end-to-end -- rather than just taking the CLI wiring in #63 on faith -- I found three real bugs, chained:
infra/compose/docker-compose.yml: theworkerservice setcommand: ["polaris", "worker"], butbackend/Dockerfilealready setsENTRYPOINT ["polaris"]. Composecommand:replacesCMD, notENTRYPOINT, so the container actually ranpolaris polaris workerand exited immediately with an argparse error. Fixed tocommand: ["worker"].apiandworkersetPOLARIS_DB_URL, which is not aSettingsfield (it'sPOLARIS_DATABASE_URL) -- silently ignored (extra="ignore"), so both services actually connected tolocalhost:5432inside their own container instead of thedbservice. This affectedapitoo, not justworker-- nothing in the real compose stack could ever reach Postgres.backend/src/polaris/db/models/task.py: once the worker could actually reach a real, Alembic-migrated Postgres, the claim loop failed withinvalid input value for enum task_status: "QUEUED". SQLAlchemy'sEnum(TaskStatus, ...)persists the Python member name by default, not.value--0001's migration hand-writes the Postgres enum with lowercase labels (queued, ...) to match this project'sStrEnumconvention, but this column never setvalues_callableto match. Masked in tests becausetests/conftest.pybuilds its schema withBase.metadata.create_all(), which derives the enum type straight from the same (buggy) column definition rather than the migration -- so tests and the real migrated database silently disagreed. #9 (schema 0002) hit and fixed this exact issue for its own enums with a sharednative_enum()helper indb/models/_enum.py;task.pypredates that helper (PH0.2, sealed) and was never retrofitted. This pointstask_statusat the same helper.Verified end-to-end this time, not just unit-tested: built the real
workerimage, ranalembic upgrade headagainst a real Postgres via the compose stack, started theworkerservice for real, and watched it log a heartbeat on schedule with no errors. Full backend suite still green (134 passed, 5 skipped needing live Keycloak) after thetask.pyfix.Ticks the last acceptance-criteria box on #6.
🤖 Generated with Claude Code
https://claude.ai/code/session_013YioTVKBPoE6thZqbnTtnM
SQLAlchemy's Enum(SomeEnum) persists the Python member *name* ("QUEUED") by default, not its .value ("queued") -- easy to miss since both look right in isolation. 0001's migration hand-writes the Postgres enum with lowercase labels to match this project's enum.StrEnum convention, but task.py's column didn't set values_callable to match, so every claim-loop query against a real (Alembic-migrated) database failed with "invalid input value for enum task_status: QUEUED" -- masked in tests because conftest.py builds its schema with Base.metadata.create_all(), which derives the enum type straight from the (buggy) column definition instead of the migration. #9 (schema 0002) hit the same issue for its own enums and fixed it with a shared native_enum() helper in db/models/_enum.py -- task.py predates that helper and was never retrofitted, since it's PH0.2's sealed file, not PH1.1's. This just points task_status at the same helper. Found while verifying #6's "worker starts against the compose stack" acceptance criterion end-to-end. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013YioTVKBPoE6thZqbnTtnM