Phase 6c-2: QA nits — dead code, N+1 query, dep hygiene, k8s hardening
Goal: Address 5 actionable QA nits from PR #130 review to bring the embedding worker to production quality.
Owner: Dev agent
Repo:
forgejo_admin/pal-e-docsDepends on: Phase 6c (PR #130 must merge first)
Problem
QA approved PR #130 with 7 nits. 2 are no-ops (hardcoded image tag is inherited pattern; health server binding 0.0.0.0 is standard k8s). 5 are actionable:
Fix
- Nit 1: Dead code.
EMBEDDABLE_TYPESconstant defined at line 52 but never referenced. Either use it in the block filtering logic (replacing inline checks) or remove it. Prefer using it — it makes the filtering explicit and testable. - Nit 2: Redundant
set_isolation_level. The reconnection path (line 523) callsconn.set_isolation_level()but_connect()already sets it. Remove the duplicate call in the reconnect path. - Nit 3: N+1 query for note titles.
_fetch_pending_blocksdoes a per-block query to get the parent note title for heading context. At 5K blocks during backfill, this is 5K extra queries. Fix: batch the title lookup with a JOIN or a single query that fetches all needed note titles upfront. - Nit 4: Duplicate
httpxdependency.httpxappears in both main deps (line 25) and dev deps (line 32) inpyproject.toml. Remove from dev deps — it's now a production dependency. - Nit 6: No
terminationGracePeriodSeconds. The worker handles SIGTERM gracefully but k8s defaults to 30s before SIGKILL. Add explicitterminationGracePeriodSeconds: 60to give the worker time to finish a batch and resetprocessingblocks topending.
Related
phase-postgres-6-vector-search— parent phasephase-postgres-6c1-autoclose-enforcement— sibling subphase (also discovered during 6c)