Technical Notes
Short lessons from production work, each small enough to read in under a minute.
Power-Off Still Bills the VPS
Hetzner console power-off keeps charging for the reserved server. The real off switch is terraform destroy. If you are pausing more than a few days, destroy. Git and GHCR should be the source of truth, not the box.
CRDs Before GitOps Consumers
Argo cannot sync a ServiceMonitor until kube-prometheus-stack has created monitoring.coreos.com CRDs. Install the operator first, then sync the app. Consumer before provider shows up as SyncFailed, not as a missing scrape target.
Liveness Is Not Readiness
/health should stay cheap and mean "process is up." /ready should dial Postgres and Redis and return 503 if either is missing. Mixing them either restarts a pod that is fine, or sends traffic to a pod that cannot do useful work.
Hybrid Retrieval in RAG
Run a metadata-filtered search (e.g. content_type + technology) and an unfiltered similarity search in parallel. Merge filtered-first, dedup by chunk ID. Filtered results give precision; unfiltered results fill context gaps the filters miss.
Query Rewriting Before Vector Search
Rewrite conversational messages into standalone search queries using an LLM + chat history before hitting the vector store. "Yeah what about that?" becomes "What mobile development services are available?" Single biggest retrieval quality improvement I've made.
HPSS for Harmonic-to-Noise Ratio
Instead of autocorrelation-based HNR, split the STFT into harmonic and percussive components via librosa's HPSS (median filtering on the spectrogram), then compute 10·log₁₀(E_harmonic / E_percussive). Different from Praat's HNR but captures voice quality well.
Dual Pitch Tracking
librosa pyin (probabilistic YIN) and Parselmouth (Praat autocorrelation) give noticeably different F0 contours on the same audio. pyin catches quiet voiced segments; Praat handles octave jumps better. Return both and let the consumer decide.
Parallel LLM Calls for Latency
When you need multiple independent LLM classifications (intent, entity extraction, query rewriting, ambiguity check), run them concurrently with a ThreadPoolExecutor. Total latency = slowest call, not the sum. deepcopy the state first; mutable dicts + threads = subtle bugs.
When Retrieval Returns Nothing
If the vector store returns zero relevant documents, skip the LLM entirely and return a templated honest response. The retriever is your ground truth. Letting the LLM fill the gap is how hallucinations happen in production.
Windows Stay Inside One Session
Build sliding windows inside one (subject, activity, device) run. The v1 notebook slid 80-sample frames over a concatenated table, so a window could mix two people or two labels. Majority vote on a mixed frame was a workaround. v2 never creates that frame.
GroupKFold Beats Headline Accuracy
The same 5 s phone flatten scored 0.8925 macro-F1 when windows were shuffled and 0.2924 under GroupKFold on subject_id. Per-class F1 then shows what survived: pocket phone still finds locomotion and cannot name eating. Cite the grouped number.