Skip to content

refactor: delete dead sync worker + entrypoints (keep live sync/dispatch.py)#474

Merged
jlunder00 merged 2 commits into
devfrom
feature/delete-sync-package
Jul 5, 2026
Merged

refactor: delete dead sync worker + entrypoints (keep live sync/dispatch.py)#474
jlunder00 merged 2 commits into
devfrom
feature/delete-sync-package

Conversation

@jlunder00

Copy link
Copy Markdown
Owner

Summary

Scoped-down version of brief 0d. The original brief's pre-check ("git grep clean outside sync/") was wrong: sync/dispatch.py is actively imported and called by api/routes/integrations.py (dispatch_sync, manual-sync trigger + initial_sync_and_register) and has live test coverage in tests/api/test_integrations.py. Deleting it would have been a real behavior regression, not a cleanup — confirmed with team lead, scoping to the actually-dead pieces.

Deleted (the vestigial LISTEN-loop worker, confirmed absent from prod per its own docstring — "Fly.io/production deployments no longer require this process... [program:sync] section intentionally absent from production config", superseded by inline FastAPI BackgroundTasks since Phase F):

  • sync/worker.py (219 lines — SyncWorker, PG LISTEN loop, APScheduler cron jobs)
  • sync/main.py + sync/__main__.py (the python -m sync entrypoint)
  • tests/sync/test_worker.py + tests/sync/__init__.py (now-empty test package)

Kept untouched:

  • sync/dispatch.py — live dispatch mechanism (PG NOTIFY), imported by api/routes/integrations.py
  • api/routes/integrations.py — out of scope for this cleanup, not touched
  • Migration d2e3f4a5b6c7_sync_worker_integration_lookup.py (DB artifact, per brief)

No doc/config references to the deleted worker were found (grepped .md, supervisord/fly config) — nothing to update.

Flagged for follow-up (not investigated, out of scope here): since the LISTEN worker isn't running in prod, dispatch_sync's PG NOTIFY may have no consumer there — the manual-sync/initial-sync paths may be effective no-ops in prod, with real sync handled by the inline BackgroundTasks path since Phase F. Worth a dedicated investigation, not a cleanup-scope fix.

Test plan

  • Full pytest suite: 12 pre-existing failures, identical to origin/dev baseline (missing claude_agent_sdk module + in-flight SDK-migration test failures unrelated to this change) — zero new failures.
  • grep confirms no remaining references to sync.worker/sync.main/SyncWorker anywhere in the codebase.

jlunder00 added 2 commits July 4, 2026 17:59
…tch.py)

Remove sync/worker.py (LISTEN-loop/SyncWorker/cron process), sync/main.py
and sync/__main__.py (python -m sync entrypoint), and their test coverage
(tests/sync/test_worker.py). This process's own docstring confirmed it's
absent from prod supervisord config since Phase F moved Google Calendar
push notifications to inline FastAPI BackgroundTasks.

sync/dispatch.py is intentionally KEPT: it's live-imported by
api/routes/integrations.py (dispatch_sync, called on manual-sync trigger
and initial_sync_and_register) and has real test coverage in
tests/api/test_integrations.py. Deleting it would break the API process.

Migration d2e3f4a5b6c7 (DB artifact) is untouched per brief.
Code review on PR #474 caught three real gaps in the initial deletion:

- docker-compose.yml still had a `sync:` service running `python -m sync`
  (no profiles guard, restart:unless-stopped) — would crash-loop on any
  `docker compose up` now that the entrypoint is gone. Removed the service.
- systemd/tether-sync.service still pointed at the deleted `python -m sync`
  entrypoint. Confirmed dormant (not among the three deployed services —
  tether-bot/tether-api/tether-mcp — and no active CI references it).
  Deleted.
- The deleted tests/sync/test_worker.py contained the only direct tests of
  sync/dispatch.py (test_dispatch_sync_issues_pg_notify,
  test_dispatch_sync_webhook_type) — the module we deliberately kept live.
  Every dispatch_sync reference in tests/api/test_integrations.py
  monkeypatches it away, so dispatch.py's real body had zero coverage after
  the first commit. Relocated both tests to tests/sync/test_dispatch.py.

Also fixed stale sync/__init__.py docstring (still described the removed
LISTEN worker).
@jlunder00

Copy link
Copy Markdown
Owner Author

Addressed code review findings in commit c6f6974:

  1. docker-compose.yml sync: service — deleted. It ran python -m sync with restart: unless-stopped and no profiles guard; would have crash-looped on any docker compose up post-deletion.
  2. systemd/tether-sync.service — deleted. Confirmed dormant (not one of the three deployed services per CLAUDE.md: tether-bot/tether-api/tether-mcp; no active CI references it).
  3. Lost test coverage for the kept sync/dispatch.py — relocated the two direct dispatch tests (test_dispatch_sync_issues_pg_notify, test_dispatch_sync_webhook_type) from the deleted tests/sync/test_worker.py into new tests/sync/test_dispatch.py. These were the only tests exercising dispatch.py's real body (everything in tests/api/test_integrations.py monkeypatches it away).

Also fixed a stale sync/__init__.py docstring that still described the removed LISTEN worker.

Full suite re-verified: same 12 pre-existing baseline failures (unrelated to this change), 823 passed (821 + 2 relocated dispatch tests), zero new failures.

@jlunder00
jlunder00 merged commit facabc6 into dev Jul 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant