Skip to content

fix(hirag): Docker restart stability - Supabase realtime connection resilience - #333

Merged
POWERFULMOVES merged 8 commits into
mainfrom
fix/hirag-docker-restart-stability
Dec 19, 2025
Merged

POWERFULMOVES merged 8 commits into
mainfrom
fix/hirag-docker-restart-stability

Conversation

@POWERFULMOVES

@POWERFULMOVES POWERFULMOVES commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes Docker restart instability where Hi-RAG experienced ~109 HTTP 502 errors before successfully connecting to Supabase realtime.

Root Cause

  • Supabase realtime and PMOVES services run in separate Docker Compose stacks
  • No cross-stack dependency management
  • Kong proxy accepts connections before realtime is fully initialized
  • Fixed 5-second retry with ERROR logging created noisy logs

Solution: Multi-Layer Fix

1. Network Bridge (docker-compose.yml)

  • Add supabase_net external network reference to PMOVES stack
  • Enable direct container-to-container communication with Supabase
  • Hi-RAG can now connect directly to supabase_realtime_PMOVES.AI:4000

2. Startup Health Check (wait-for-deps.sh)

  • New entrypoint script checks Supabase realtime health before starting app
  • Configurable timeout (default: 120s) and interval (default: 5s)
  • Gracefully proceeds if service doesn't respond in time

3. Exponential Backoff (app.py)

  • Retry delays: 5s → 10s → 20s → 40s → 60s (max)
  • Startup grace period (120s) uses WARNING instead of ERROR logging
  • Backoff resets on successful connection

Changes

File Description
pmoves/docker-compose.yml Add supabase_net external network + update Hi-RAG networks
pmoves/services/hi-rag-gateway-v2/Dockerfile Add curl, wait script entrypoint
pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu Add wrapper entrypoint for NVIDIA
pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh New - startup health check
pmoves/services/hi-rag-gateway-v2/app.py Exponential backoff + grace period

New Environment Variables

Variable Default Description
WAIT_FOR_DEPS_MAX_WAIT 120 Max wait time for dependencies (seconds)
WAIT_FOR_DEPS_INTERVAL 5 Health check interval (seconds)
GEOMETRY_REALTIME_MAX_BACKOFF 60.0 Maximum retry delay (seconds)
GEOMETRY_REALTIME_STARTUP_GRACE 120.0 Grace period for startup logging

Test plan

  • Validate docker-compose config syntax
  • Validate wait-for-deps.sh bash syntax
  • Validate app.py Python syntax
  • Build hi-rag-gateway-v2 image successfully
  • Verify wait script runs on container start
  • Verify successful Supabase realtime subscription
  • Verify Hi-RAG query endpoint operational

Startup Logs (After Fix)

[wait-for-deps] Waiting for Supabase realtime at http://host.docker.internal:65421/realtime/v1/api/ping...
[wait-for-deps] Supabase realtime is ready!
INFO:hirag.gateway.v2:Subscribed to Supabase realtime geometry.cgp.v1 channel

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Added dependency initialization mechanism ensuring services start in proper sequence
    • Integrated PMOVES-Ultimate-TTS-Studio for enhanced text-to-speech capabilities
    • Implemented exponential backoff with startup grace period for improved connection resilience
  • Infrastructure

    • Configured Supabase network connectivity enabling improved inter-service communication
    • Enhanced container security by implementing non-root user execution
    • Optimized Docker builds with streamlined dependency management and PyTorch-based images

✏️ Tip: You can customize this high-level summary in your review settings.

Codex Agent and others added 3 commits December 19, 2025 07:07
Add external network reference to Supabase CLI stack (pmoves-net) enabling
direct container-to-container communication between PMOVES services and
Supabase realtime.

Changes:
- Add supabase_net external network definition
- Add supabase_net to hi-rag-gateway-v2 networks
- Add supabase_net to hi-rag-gateway-v2-gpu networks

This enables Hi-RAG to connect directly to supabase_realtime_PMOVES.AI
without routing through host.docker.internal, reducing startup latency
and improving reliability on Docker restarts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add entrypoint script that waits for Supabase realtime to be healthy
before starting the Hi-RAG application, preventing startup errors on
Docker restarts.

New files:
- scripts/wait-for-deps.sh: Health check script with configurable timeout

Dockerfile changes:
- Install curl for health checks
- Add ENTRYPOINT to run wait-for-deps.sh before uvicorn
- GPU variant: Create wrapper entrypoint for NVIDIA compatibility

Environment variables:
- WAIT_FOR_DEPS_MAX_WAIT: Maximum wait time (default: 120s)
- WAIT_FOR_DEPS_INTERVAL: Check interval (default: 5s)
- SUPABASE_REALTIME_DISABLED: Skip wait if set to true

The script checks Supabase realtime health via HTTP ping before
starting the application, eliminating the ~109 retry errors that
occurred during cold starts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Improve Supabase realtime connection resilience with smarter retry logic
and reduced log noise during startup.

Changes to _geometry_realtime_worker:
- Add exponential backoff: 5s → 10s → 20s → 40s → 60s (max)
- Add startup grace period (120s) with WARNING level logging
- Reset backoff on successful connection
- Track elapsed time for grace period calculation

New environment variables:
- GEOMETRY_REALTIME_MAX_BACKOFF: Maximum retry delay (default: 60s)
- GEOMETRY_REALTIME_STARTUP_GRACE: Grace period duration (default: 120s)

Before: Fixed 5s retry, ERROR level for all failures
After: Exponential backoff, WARNING during startup grace period

This reduces log noise from ~109 ERROR entries to a handful of
WARNING messages during normal startup scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Container startup infrastructure enhanced with Supabase realtime dependency management. Docker networking configured to enable cross-stack communication. Hi-RAG Gateway V2 service introduces startup sequencing via wait-for-dependencies script with exponential backoff logic. Ultimate TTS Studio Dockerfile refactored to use PyTorch base image. PMOVES-Ultimate-TTS-Studio added as Git submodule.

Changes

Cohort / File(s) Summary
Docker Compose Networking
pmoves/docker-compose.yml
Added external network supabase_net (name: pmoves-net); updated hi-rag-gateway services to join network for Supabase stack communication.
Hi-RAG Gateway V2 — Container Setup
pmoves/services/hi-rag-gateway-v2/Dockerfile, pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu
Added curl installation for health checks; introduced entrypoint wrapper to run wait-for-deps.sh before uvicorn; created non-root user pmoves with proper permissions; made startup scripts executable; updated ENTRYPOINT/CMD flow.
Hi-RAG Gateway V2 — Application Logic
pmoves/services/hi-rag-gateway-v2/app.py
Added GEOMETRY_REALTIME_MAX_BACKOFF and GEOMETRY_REALTIME_STARTUP_GRACE configuration constants; extended _geometry_realtime_worker with startup grace period, exponential backoff with cap, and improved exception handling (JSONDecodeError separate logging).
Hi-RAG Gateway V2 — Dependency Wait Script
pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
New shell script that waits for Supabase realtime health check via curl before starting application; supports environment variable controls (SUPABASE_REALTIME_URL, SUPABASE_REALTIME_DISABLED, WAIT_FOR_DEPS_MAX_WAIT, WAIT_FOR_DEPS_INTERVAL).
Git Submodule Configuration
.gitmodules
Added PMOVES-Ultimate-TTS-Studio submodule pointing to https://github.com/POWERFULMOVES/PMOVES-Ultimate-TTS-Studio.git.
Ultimate TTS Studio Build
pmoves/docker/ultimate-tts-studio/Dockerfile, PMOVES-Ultimate-TTS-Studio
Replaced CUDA/NVIDIA base images with PyTorch image (pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime); switched from forked repository clone to PMOVES fork with requirements.txt-driven installation; removed per-engine pip blocks; created non-root user and data directories (/data/hf, /data/cache); updated health check start period to 180s; updated submodule commit reference.

Sequence Diagram

sequenceDiagram
    participant Container as Container Start
    participant WaitScript as wait-for-deps.sh
    participant SBRealtime as Supabase Realtime
    participant App as uvicorn App
    
    Container->>WaitScript: Execute entrypoint
    
    loop Health Check Loop (interval: 5s, max: 120s)
        WaitScript->>SBRealtime: curl health check to HTTP endpoint
        alt Success
            SBRealtime-->>WaitScript: HTTP 200
            WaitScript->>WaitScript: Break loop
        else Timeout/Failure
            SBRealtime-->>WaitScript: Timeout or error
            WaitScript->>WaitScript: Log warning, continue
            Note over WaitScript: elapsed_time < grace_period<br/>log as warning, apply backoff
        end
    end
    
    WaitScript->>App: Execute command (uvicorn)
    App->>App: Start server on port 8086
    App-->>Container: Ready
    
    Note over App: During startup grace:<br/>connection failures use<br/>exponential backoff logic
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • The exponential backoff and startup grace period logic in app.py — verify the timing logic and exception handling align with intended retry behavior
  • Entrypoint wrapper sequencing in both Dockerfiles — ensure wait-for-deps.sh completes before uvicorn starts and that signal handling is correct for graceful shutdown
  • Supabase realtime URL conversion from WebSocket to HTTP in wait-for-deps.sh — verify the URL transformation handles edge cases
  • Non-root user permissions and ownership changes across multiple Dockerfiles — confirm no permission issues with script execution or data directory access

Possibly related PRs

  • #333: Implements identical code-level changes across docker-compose.yml, hi-rag-gateway-v2 Dockerfiles, wait-for-deps.sh, and app.py startup grace/backoff logic.
  • #232: Modifies pmoves/docker-compose.yml networking configuration with external network attachment and service wiring updates.

Poem

🐰 A startup waits with patience true,
Dependencies checked before we brew,
Supabase calls, exponential grace,
Backoff delays at a measured pace—
Soon uvicorn dances in containers anew!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: improving Docker restart stability by adding Supabase realtime connection resilience, which directly matches the multi-layer fix implemented across the changeset.
Description check ✅ Passed The description provides comprehensive context covering root cause, solution details, affected files, new environment variables, and test results, exceeding the template's summary requirements.

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a10e06 and 8993914.

📒 Files selected for processing (6)
  • .gitmodules (1 hunks)
  • PMOVES-Ultimate-TTS-Studio (1 hunks)
  • pmoves/docker/ultimate-tts-studio/Dockerfile (1 hunks)
  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (1 hunks)
  • pmoves/services/hi-rag-gateway-v2/app.py (4 hunks)
  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (2)

1-19: Consider adding set -u for safer script execution.

The script uses set -e to exit on errors, which is good. Consider also adding set -u to exit on undefined variables, which would catch configuration errors early.

🔎 Proposed enhancement
-set -e
+set -eu

This will make the script exit if any undefined variable is referenced, catching configuration errors before they cause silent failures.


51-66: LGTM! Wait loop with graceful timeout handling.

The script correctly:

  • Checks health endpoint with curl
  • Breaks immediately on success
  • Logs progress during wait
  • Continues after timeout with a warning (graceful degradation)
💡 Optional enhancement for debugging

Consider logging curl errors on failure for better diagnostics:

 while true; do
-    if curl -sf "$HEALTH_URL" -o /dev/null 2>&1; then
+    if curl_output=$(curl -sf "$HEALTH_URL" 2>&1); then
         echo "[wait-for-deps] Supabase realtime is ready!"
         break
+    else
+        # Optional: log curl error for debugging (only in verbose mode)
+        if [ "${WAIT_FOR_DEPS_VERBOSE:-false}" = "true" ]; then
+            echo "[wait-for-deps] Health check failed: $curl_output"
+        fi
     fi
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aab03ca and a1ffc77.

📒 Files selected for processing (5)
  • pmoves/docker-compose.yml (3 hunks)
  • pmoves/services/hi-rag-gateway-v2/Dockerfile (3 hunks)
  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (1 hunks)
  • pmoves/services/hi-rag-gateway-v2/app.py (4 hunks)
  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
pmoves/**/docker-compose.yml

📄 CodeRabbit inference engine (pmoves/AGENTS.md)

Use Compose profiles (data, workers) to scope what runs locally in docker-compose.yml

Files:

  • pmoves/docker-compose.yml
pmoves/services/**/*.py

📄 CodeRabbit inference engine (pmoves/AGENTS.md)

pmoves/services/**/*.py: Keep modules small and single-purpose; share helpers in services/common/
FastAPI routes: snake_case function names; path names kebab-case only in URLs
Validate payloads against schemas before publishing events using services/common/events.py

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
pmoves/**/*.py

📄 CodeRabbit inference engine (pmoves/AGENTS.md)

Python 3.11+, 4-space indentation, prefer type hints

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use Python 3.11+ with 4-space indentation and prefer type hints in all Python code

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
🧠 Learnings (7)
📚 Learning: 2025-12-07T11:03:53.415Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/AGENTS.md:0-0
Timestamp: 2025-12-07T11:03:53.415Z
Learning: Applies to pmoves/services/hi-rag-gateway/**/*.py : Hi-RAG gateway: after touching reranker or embedding code, run `make -C pmoves smoke-gpu` to validate FlagEmbedding/Qwen rerankers

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu
  • pmoves/services/hi-rag-gateway-v2/Dockerfile
📚 Learning: 2025-12-15T12:04:26.230Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/AGENTS.md:0-0
Timestamp: 2025-12-15T12:04:26.230Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/*.js : When a 3rd party package needs to be installed or repository downloaded, include them in the scripts

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-15T12:01:31.388Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/CLAUDE.md:0-0
Timestamp: 2025-12-15T12:01:31.388Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/{install,start,update,reset}.js : Scripts must be able to replicate install and launch steps 100% - include all 3rd party package installations and repository downloads in scripts, do not assume end user's system state, and make everything self-contained

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-15T12:04:26.230Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/AGENTS.md:0-0
Timestamp: 2025-12-15T12:04:26.230Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/*.js : Scripts must be able to replicate install and launch steps 100%. Make everything self-contained and do not assume end user's system state

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-15T12:03:17.291Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-15T12:03:17.291Z
Learning: Applies to {Dockerfile,docker-compose.yml,docker-compose.*.yml,pmoves/docker-compose.*.override.yml} : Dockerfile and docker-compose.yml must follow multi-arch build practices (amd64+arm64) with Trivy scanning for HIGH/CRITICAL vulnerabilities

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile
📚 Learning: 2025-12-15T12:03:17.291Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-15T12:03:17.291Z
Learning: Applies to services/**/README.md : Update services/*/README.md and pmoves/docs/PMOVES.AI PLANS/ runbooks when touching service operational code

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile
📚 Learning: 2025-12-15T12:03:17.291Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-15T12:03:17.291Z
Learning: UI updates: run make -C pmoves notebook-workbench-smoke ARGS='--thread=<uuid>' to lint the Next.js bundle and validate Supabase connectivity; reference pmoves/docs/UI_NOTEBOOK_WORKBENCH.md

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile
🧬 Code graph analysis (1)
pmoves/services/hi-rag-gateway-v2/app.py (3)
pmoves/services/hi-rag-gateway-v2/tests/test_swarm_meta.py (1)
  • get (82-86)
pmoves/services/hi-rag-gateway-v2/tests/test_gan_sidecar.py (1)
  • get (162-166)
pmoves/scripts/bootstrap_env.py (1)
  • get (165-170)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: tests (3.11)
  • GitHub Check: Analyze (python)
🔇 Additional comments (14)
pmoves/services/hi-rag-gateway-v2/app.py (4)

209-210: LGTM! Configuration constants are well-defined.

The new environment variables for backoff control and startup grace are properly configured with sensible defaults (60s max backoff, 120s startup grace).


890-891: LGTM! Startup timing and backoff initialization are correct.

Using time.monotonic() for startup tracking is the right choice as it's not affected by system clock changes. The backoff initialization ensures a minimum of 1.0s.


922-923: LGTM! Backoff reset on successful connection.

Resetting the backoff to the base value after a successful connection is the correct behavior and prevents indefinite backoff growth.


961-976: LGTM! Exponential backoff with startup grace is well-implemented.

The implementation correctly:

  • Uses WARNING-level logging during the startup grace period to reduce noise
  • Escalates to exception logging after the grace period expires
  • Applies exponential backoff with a configurable cap (GEOMETRY_REALTIME_MAX_BACKOFF)
  • Provides clear diagnostic information in logs (elapsed/grace times, backoff delay)

This should significantly reduce log noise during Docker restarts.

pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (1)

38-39: LGTM! Execute permission set correctly.

Making the wait-for-deps.sh script executable is necessary for it to function as part of the entrypoint chain.

pmoves/docker-compose.yml (2)

577-577: LGTM! Network configuration enables direct Supabase connectivity.

Adding supabase_net to the hi-rag-gateway-v2 service networks allows direct container-to-container communication with Supabase realtime, which is essential for the startup health checks.


695-695: LGTM! GPU variant correctly configured for Supabase connectivity.

The GPU variant also needs access to the Supabase network for health checks and realtime subscriptions.

pmoves/services/hi-rag-gateway-v2/Dockerfile (3)

5-7: LGTM! curl installation follows best practices.

Installing curl for health checks and cleaning up apt lists to reduce image size is the correct approach.


21-22: LGTM! Execute permission set correctly.

Making the wait-for-deps.sh script executable is necessary for it to function as the entrypoint.


33-35: LGTM! Entrypoint configuration is correct.

Using wait-for-deps.sh as the entrypoint with the uvicorn command as CMD is the correct pattern. The script will wait for dependencies, then exec the uvicorn command, properly replacing the shell process.

pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (4)

20-30: LGTM! Disabled and empty URL checks are correct.

The script properly handles multiple disabled values and skips waiting when no URL is configured, proceeding directly to execute the main command.


32-46: LGTM! URL conversion logic handles both deployment modes.

The script correctly converts WebSocket URLs to HTTP health check endpoints for both:

  • Kong-proxied URLs (ending with /realtime/v1)
  • Direct realtime container URLs (port 4000)

48-49: LGTM! Logging and timing setup are correct.

The diagnostic logging will help troubleshoot connectivity issues, and using epoch time for elapsed calculation is appropriate.


68-69: LGTM! Command execution follows entrypoint best practices.

Using exec "$@" to replace the shell process with the main command is the standard and correct pattern for entrypoint scripts. This ensures proper signal handling and process management.

Comment thread pmoves/docker-compose.yml
Comment on lines +1289 to +1294

# Bridge to Supabase CLI stack for direct container-to-container communication
# Enables services to connect directly to supabase_realtime without host.docker.internal
supabase_net:
external: true
name: pmoves-net

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find and inspect the pmoves/docker-compose.yml file
if [ -f "pmoves/docker-compose.yml" ]; then
    # Get total line count
    wc -l pmoves/docker-compose.yml
    # Read lines around 1289-1294
    echo "=== Lines 1285-1300 ==="
    sed -n '1285,1300p' pmoves/docker-compose.yml | cat -n
else
    echo "File not found"
fi

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 554


🏁 Script executed:

#!/bin/bash
# Search for all references to supabase_net in the compose file
echo "=== All references to supabase_net ==="
grep -n "supabase_net\|pmoves-net" pmoves/docker-compose.yml | head -20

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 314


🏁 Script executed:

#!/bin/bash
# Check file structure around networks section
echo "=== Network definitions in file ==="
grep -n "^networks:" pmoves/docker-compose.yml

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 117


🏁 Script executed:

#!/bin/bash
# Look for any scripts or setup instructions
echo "=== Looking for setup/README files ==="
find pmoves -maxdepth 2 -type f \( -name "README*" -o -name "setup*" -o -name ".env*" \) 2>/dev/null

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 525


🏁 Script executed:

#!/bin/bash
# Check which services use supabase_net
echo "=== Services using supabase_net ==="
sed -n '570,585p' pmoves/docker-compose.yml | cat -n
echo ""
sed -n '690,700p' pmoves/docker-compose.yml | cat -n

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 1137


🏁 Script executed:

#!/bin/bash
# Look at the services section structure and profiles
echo "=== Check for profiles in compose file ==="
grep -n "profiles:" pmoves/docker-compose.yml | head -20

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 1016


🏁 Script executed:

#!/bin/bash
# Look for documentation about network setup
echo "=== Checking README for network setup info ==="
grep -i "supabase\|network\|pmoves-net" pmoves/README.md | head -30

Repository: POWERFULMOVES/PMOVES.AI

Length of output: 3067


Clarify the Supabase CLI network dependency in the setup documentation.

The external network pmoves-net (referenced as supabase_net) is only needed when services with profiles that require Supabase connectivity are active (e.g., workers, gateway, agents). When using external networks in Docker Compose, they must be created before attempting to connect services to them. This network is created by the Supabase CLI stack (supabase start or make supa-start).

Ensure the setup documentation (e.g., docs/FIRST_RUN.md) explicitly states that the Supabase CLI must be initialized before running compose profiles that include services requiring this network. Consider adding a startup order note or a pre-flight check in the Makefile to prevent confusion during deployment.



async def _geometry_realtime_worker(ws_url: str, api_key: str) -> None:
import time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Remove redundant import statement.

The time module is already imported at line 2. This duplicate import is unnecessary.

🔎 Proposed fix
-    import time
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import time
🤖 Prompt for AI Agents
In pmoves/services/hi-rag-gateway-v2/app.py around line 883, there is a
redundant "import time" statement (time is already imported at line 2); remove
the duplicate import at line 883 so the module is only imported once and update
any surrounding whitespace or grouping of imports to keep the file tidy.

Comment thread pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu Outdated
Codex Agent and others added 2 commits December 19, 2025 07:40
Update PMOVES-Open-Notebook to include fix for UnboundLocalError
in sources.py when creating sources via JSON API.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pmoves/services/hi-rag-gateway-v2/app.py (1)

2-3: Consolidate duplicate top-level imports.

Lines 2 and 3 duplicate many imports (os, time, math, json, logging, re, sys, contextlib, ipaddress). These should be consolidated into a single import statement.

🔎 Proposed fix
-import os, time, math, json, logging, re, sys, contextlib, ipaddress, copy, threading
-import os, time, math, json, logging, re, sys, contextlib, ipaddress, importlib.util
+import os, time, math, json, logging, re, sys, contextlib, ipaddress, copy, threading, importlib.util
♻️ Duplicate comments (2)
pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (1)

41-46: Critical: Wrapper entrypoint logic is flawed.

The wrapper script has a logic error. The wait-for-deps.sh script uses exec "$@" at the end (line 72 in wait-for-deps.sh), which replaces the current process. When called with /bin/true, it will wait for dependencies, then exec /bin/true, which immediately exits. The subsequent line exec /opt/nvidia/nvidia_entrypoint.sh "$@" will never execute.

🔎 Proposed fix

The wrapper needs to be refactored to avoid the exec conflict. One approach is to inline the dependency wait logic directly in the wrapper:

-RUN printf '#!/bin/bash\nset -e\n/app/scripts/wait-for-deps.sh /bin/true\nexec /opt/nvidia/nvidia_entrypoint.sh "$@"\n' > /app/entrypoint-wrapper.sh && \
+RUN printf '#!/bin/bash\nset -e\n\n# Inline dependency wait logic\nSUPABASE_URL="${SUPABASE_REALTIME_URL:-ws://host.docker.internal:65421/realtime/v1}"\nDISABLED="${SUPABASE_REALTIME_DISABLED:-false}"\nMAX_WAIT="${WAIT_FOR_DEPS_MAX_WAIT:-120}"\nINTERVAL="${WAIT_FOR_DEPS_INTERVAL:-5}"\n\nif [ "$DISABLED" != "true" ] && [ "$DISABLED" != "1" ] && [ "$DISABLED" != "disabled" ] && [ "$DISABLED" != "none" ] && [ -n "$SUPABASE_URL" ]; then\n  HEALTH_URL=$(echo "$SUPABASE_URL" | sed "s|^ws://|http://|;s|^wss://|https://|;s|/websocket.*||;s|/socket.*||;s|\\?.*||")\n  if echo "$HEALTH_URL" | grep -q "/realtime/v1$"; then\n    HEALTH_URL="${HEALTH_URL}/api/ping"\n  elif echo "$HEALTH_URL" | grep -q ":4000"; then\n    HEALTH_URL=$(echo "$HEALTH_URL" | sed "s|/socket/websocket||")\n    HEALTH_URL="${HEALTH_URL}/api/ping"\n  fi\n  echo "[entrypoint] Waiting for Supabase realtime at $HEALTH_URL..."\n  start_time=$(date +%s)\n  while true; do\n    if curl -sf --connect-timeout 5 --max-time 10 "$HEALTH_URL" -o /dev/null 2>&1; then\n      echo "[entrypoint] Supabase realtime is ready!"\n      break\n    fi\n    elapsed=$(($(date +%s) - start_time))\n    if [ $elapsed -ge $MAX_WAIT ]; then\n      echo "[entrypoint] Warning: Supabase realtime not ready after ${MAX_WAIT}s, starting anyway..."\n      break\n    fi\n    echo "[entrypoint] Waiting... ($elapsed/${MAX_WAIT}s)"\n    sleep $INTERVAL\n  done\nfi\n\n# Now run the actual command via NVIDIA entrypoint\nexec /opt/nvidia/nvidia_entrypoint.sh "$@"\n' > /app/entrypoint-wrapper.sh && \
     chmod +x /app/entrypoint-wrapper.sh

Alternatively, modify wait-for-deps.sh to accept a --no-exec flag that skips the final exec when used as a library.

pmoves/services/hi-rag-gateway-v2/app.py (1)

883-883: Remove redundant import statement.

The time module is already imported at line 2. This duplicate import inside the function is unnecessary.

🔎 Proposed fix
-    import time
🧹 Nitpick comments (1)
pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (1)

20-30: Minor: Documentation inconsistency.

The disabled check on line 21 accepts "none" as a valid value, but the documentation comment on line 9 doesn't mention "none". Consider updating the comment for completeness.

🔎 Proposed fix
-#   SUPABASE_REALTIME_DISABLED - Set to "true" to skip the wait (default: false)
+#   SUPABASE_REALTIME_DISABLED - Set to "true", "1", "disabled", or "none" to skip the wait (default: false)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1ffc77 and 7a10e06.

📒 Files selected for processing (4)
  • PMOVES-Open-Notebook (1 hunks)
  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (1 hunks)
  • pmoves/services/hi-rag-gateway-v2/app.py (4 hunks)
  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • PMOVES-Open-Notebook
🧰 Additional context used
📓 Path-based instructions (3)
pmoves/services/**/*.py

📄 CodeRabbit inference engine (pmoves/AGENTS.md)

pmoves/services/**/*.py: Keep modules small and single-purpose; share helpers in services/common/
FastAPI routes: snake_case function names; path names kebab-case only in URLs
Validate payloads against schemas before publishing events using services/common/events.py

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
pmoves/**/*.py

📄 CodeRabbit inference engine (pmoves/AGENTS.md)

Python 3.11+, 4-space indentation, prefer type hints

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use Python 3.11+ with 4-space indentation and prefer type hints in all Python code

Files:

  • pmoves/services/hi-rag-gateway-v2/app.py
🧠 Learnings (6)
📚 Learning: 2025-12-15T12:04:26.230Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/AGENTS.md:0-0
Timestamp: 2025-12-15T12:04:26.230Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/*.js : When a 3rd party package needs to be installed or repository downloaded, include them in the scripts

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-15T12:01:31.388Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/CLAUDE.md:0-0
Timestamp: 2025-12-15T12:01:31.388Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/{install,start,update,reset}.js : Scripts must be able to replicate install and launch steps 100% - include all 3rd party package installations and repository downloads in scripts, do not assume end user's system state, and make everything self-contained

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-15T12:04:26.230Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/AGENTS.md:0-0
Timestamp: 2025-12-15T12:04:26.230Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/*.js : Scripts must be able to replicate install and launch steps 100%. Make everything self-contained and do not assume end user's system state

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh
📚 Learning: 2025-12-07T11:03:53.415Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/AGENTS.md:0-0
Timestamp: 2025-12-07T11:03:53.415Z
Learning: Applies to pmoves/services/hi-rag-gateway/**/*.py : Hi-RAG gateway: after touching reranker or embedding code, run `make -C pmoves smoke-gpu` to validate FlagEmbedding/Qwen rerankers

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu
📚 Learning: 2025-12-15T12:04:26.230Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/docs/ARTSTUFF/realtime/AGENTS.md:0-0
Timestamp: 2025-12-15T12:04:26.230Z
Learning: Applies to pmoves/docs/ARTSTUFF/realtime/**/*.js : Try to find development options to launch apps without Docker. Use automatic installation and launch for the user's platform via scripts instead of Docker

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu
📚 Learning: 2025-12-07T11:03:53.415Z
Learnt from: CR
Repo: POWERFULMOVES/PMOVES.AI PR: 0
File: pmoves/AGENTS.md:0-0
Timestamp: 2025-12-07T11:03:53.415Z
Learning: Agents images: default uses published images set in `pmoves/env.shared`. For custom code, build a thin overlay FROM the published image and tag it

Applied to files:

  • pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: tests (3.11)
🔇 Additional comments (11)
pmoves/services/hi-rag-gateway-v2/Dockerfile.gpu (2)

38-39: LGTM!

Correctly grants executable permission to the wait-for-deps.sh script.


48-53: LGTM!

Proper non-root user setup with video group membership for GPU device access. Good security practice.

pmoves/services/hi-rag-gateway-v2/scripts/wait-for-deps.sh (4)

1-18: LGTM!

Script header and environment variable setup are well-documented and correct.


32-46: LGTM!

URL conversion logic correctly handles both Kong-proxied and direct container realtime endpoints.


48-69: LGTM!

Health check loop with appropriate timeouts and graceful degradation when the service isn't ready.


71-72: LGTM!

Standard entrypoint pattern to replace the shell with the main command.

pmoves/services/hi-rag-gateway-v2/app.py (5)

209-210: LGTM!

New configuration constants for exponential backoff cap and startup grace period are correctly defined.


890-892: LGTM!

Properly initializes startup timing and backoff for the retry loop.


922-923: LGTM!

Correctly resets backoff delay to base value on successful connection, preventing unnecessarily long delays after transient failures.


929-931: LGTM!

Appropriate debug-level logging for JSON decode errors on non-critical message parsing failures.


962-981: LGTM!

Excellent startup grace period implementation:

  • Reduces log noise with WARNING level during the initial grace period
  • Shows remaining grace time for observability
  • Escalates to ERROR after grace expires
  • Implements exponential backoff with configurable cap

This directly addresses the PR objective of handling ~109 HTTP 502 errors during Docker restart without flooding logs.

Codex Agent and others added 3 commits December 19, 2025 11:30
- Add PMOVES-Ultimate-TTS-Studio as git submodule
- Sync fork with upstream SUP3RMASS1VE/Ultimate-TTS-Studio-SUP3R-Edition:
  - VoxCPM fix and 1.5 update
  - Fish Speech checkpoint download fix
  - Vibevoice model name change
  - Flash attention support for VibeVoice
  - Chatterbox turbo and watermark removal
- Update Dockerfile to clone from synced PMOVES fork
- Use upstream requirements.txt with all 7 engine dependencies
- Add test_all_tts_engines.py for comprehensive engine testing via gradio_client

Engines: KittenTTS, Kokoro, F5-TTS, IndexTTS2, Fish Speech, ChatterboxTTS, VoxCPM

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- wait-for-deps.sh: add WAIT_FOR_DEPS_ALLOW_DEGRADED flag for explicit degraded mode opt-in
- wait-for-deps.sh: log curl stderr on failure for better debugging
- wait-for-deps.sh: add URL validation before health check
- app.py: add debug-level stack traces during startup grace period
- app.py: add inline documentation for retry configuration vars
- Dockerfile.gpu: fix comment to accurately describe two-phase startup

These improvements address all findings from the code-reviewer,
silent-failure-hunter, and comment-analyzer review agents.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@POWERFULMOVES
POWERFULMOVES merged commit 6c80be4 into main Dec 19, 2025
6 checks passed
@POWERFULMOVES
POWERFULMOVES deleted the fix/hirag-docker-restart-stability branch December 19, 2025 17:27
POWERFULMOVES pushed a commit that referenced this pull request Dec 19, 2025
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Dec 19, 2025
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Dec 19, 2025
Documents the two-phase startup pattern with exec in child scripts,
explaining why CodeRabbit's "Critical" flag was incorrect.

Key insight: exec in a called script only replaces the child process,
not the parent wrapper. This is a valid pattern for GPU containers
that need both dependency waiting and NVIDIA entrypoint initialization.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 2, 2026
- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 2, 2026
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 3, 2026
- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 3, 2026
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES added a commit that referenced this pull request Jan 3, 2026
* feat(hirag): add wait-for-deps startup script

Add entrypoint script that waits for Supabase realtime to be healthy
before starting the Hi-RAG application, preventing startup errors on
Docker restarts.

New files:
- scripts/wait-for-deps.sh: Health check script with configurable timeout

Dockerfile changes:
- Install curl for health checks
- Add ENTRYPOINT to run wait-for-deps.sh before uvicorn
- GPU variant: Create wrapper entrypoint for NVIDIA compatibility

Environment variables:
- WAIT_FOR_DEPS_MAX_WAIT: Maximum wait time (default: 120s)
- WAIT_FOR_DEPS_INTERVAL: Check interval (default: 5s)
- SUPABASE_REALTIME_DISABLED: Skip wait if set to true

The script checks Supabase realtime health via HTTP ping before
starting the application, eliminating the ~109 retry errors that
occurred during cold starts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(hirag): add exponential backoff with startup grace period

Improve Supabase realtime connection resilience with smarter retry logic
and reduced log noise during startup.

Changes to _geometry_realtime_worker:
- Add exponential backoff: 5s → 10s → 20s → 40s → 60s (max)
- Add startup grace period (120s) with WARNING level logging
- Reset backoff on successful connection
- Track elapsed time for grace period calculation

New environment variables:
- GEOMETRY_REALTIME_MAX_BACKOFF: Maximum retry delay (default: 60s)
- GEOMETRY_REALTIME_STARTUP_GRACE: Grace period duration (default: 120s)

Before: Fixed 5s retry, ERROR level for all failures
After: Exponential backoff, WARNING during startup grace period

This reduces log noise from ~109 ERROR entries to a handful of
WARNING messages during normal startup scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): address PR review findings for restart stability

- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): implement PR review improvements

- wait-for-deps.sh: add WAIT_FOR_DEPS_ALLOW_DEGRADED flag for explicit degraded mode opt-in
- wait-for-deps.sh: log curl stderr on failure for better debugging
- wait-for-deps.sh: add URL validation before health check
- app.py: add debug-level stack traces during startup grace period
- app.py: add inline documentation for retry configuration vars
- Dockerfile.gpu: fix comment to accurately describe two-phase startup

These improvements address all findings from the code-reviewer,
silent-failure-hunter, and comment-analyzer review agents.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): remove redundant imports in app.py

- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): use container DNS for Supabase realtime instead of host.docker.internal (#335)

The host.docker.internal hostname resolves to Docker Desktop's gateway IP
(192.168.65.254) in WSL2, which doesn't properly route to host-bound ports.
This caused Hi-RAG to fail connecting to Supabase realtime after Docker restarts.

Changed default SUPABASE_REALTIME_URL from:
  ws://host.docker.internal:65421/realtime/v1
to:
  ws://supabase_kong_PMOVES.AI:8000/realtime/v1

Since both containers are on pmoves-net, direct container-to-container DNS
resolution works reliably.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): restore EvoSwarm mode and HRM integration

Fixes critical dead code in geometry_decode_text function:
- Changed `else` to `elif mode == "swarm"` to make swarm mode reachable
- Integrated HRM refinement in learned mode (maybe_refine)
- Added HRM status in default geometry mode
- Consistent response shape across all modes (namespace, modality, builder_pack)

Before: swarm mode was unreachable due to early returns in if-else
After: proper if-elif-else routing for learned/swarm/default modes

Resolves CodeRabbit review finding in PR #334

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: address PR #334 review issues across 4 files

route.ts (Critical):
- Import and use logError() instead of console.error
- Return HTTP 503 for configuration errors
- Return HTTP 502 for upstream/network failures

app.py (Important):
- Change except Exception to except (ImportError, ModuleNotFoundError)
- Fix variable shadowing: use top_pts instead of re-declaring pts

Dockerfile (Suggestions):
- Remove duplicate comment block at Step 12b
- Replace Pinokio line number references with descriptive names
- Fix huggingface-hub version comment (0.30.0 → 0.25.0)

sync.py (Suggestion):
- Make offline mode opt-in via NOTEBOOK_SYNC_GRACEFUL_DEGRADATION env var
- Fail explicitly if OPEN_NOTEBOOK_API_URL not set (unless env var enabled)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): remove extra_headers from WebSocket (uvloop incompatibility) (#400)

The websockets library's extra_headers parameter is not supported by
uvloop's create_connection(), which is used by uvicorn. Removed the
extra_headers parameter and rely on the apikey URL parameter for
Supabase realtime authentication.

Also:
- Add pmoves/vendor/python/ to .gitignore (unpacked packages)
- Remove 275+ unpacked package files from git tracking

Vendor submodules were already configured with POWERFULMOVES forks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES added a commit that referenced this pull request Jan 18, 2026
* feat(hirag): add wait-for-deps startup script

Add entrypoint script that waits for Supabase realtime to be healthy
before starting the Hi-RAG application, preventing startup errors on
Docker restarts.

New files:
- scripts/wait-for-deps.sh: Health check script with configurable timeout

Dockerfile changes:
- Install curl for health checks
- Add ENTRYPOINT to run wait-for-deps.sh before uvicorn
- GPU variant: Create wrapper entrypoint for NVIDIA compatibility

Environment variables:
- WAIT_FOR_DEPS_MAX_WAIT: Maximum wait time (default: 120s)
- WAIT_FOR_DEPS_INTERVAL: Check interval (default: 5s)
- SUPABASE_REALTIME_DISABLED: Skip wait if set to true

The script checks Supabase realtime health via HTTP ping before
starting the application, eliminating the ~109 retry errors that
occurred during cold starts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(hirag): add exponential backoff with startup grace period

Improve Supabase realtime connection resilience with smarter retry logic
and reduced log noise during startup.

Changes to _geometry_realtime_worker:
- Add exponential backoff: 5s → 10s → 20s → 40s → 60s (max)
- Add startup grace period (120s) with WARNING level logging
- Reset backoff on successful connection
- Track elapsed time for grace period calculation

New environment variables:
- GEOMETRY_REALTIME_MAX_BACKOFF: Maximum retry delay (default: 60s)
- GEOMETRY_REALTIME_STARTUP_GRACE: Grace period duration (default: 120s)

Before: Fixed 5s retry, ERROR level for all failures
After: Exponential backoff, WARNING during startup grace period

This reduces log noise from ~109 ERROR entries to a handful of
WARNING messages during normal startup scenarios.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): address PR review findings for restart stability

- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): implement PR review improvements

- wait-for-deps.sh: add WAIT_FOR_DEPS_ALLOW_DEGRADED flag for explicit degraded mode opt-in
- wait-for-deps.sh: log curl stderr on failure for better debugging
- wait-for-deps.sh: add URL validation before health check
- app.py: add debug-level stack traces during startup grace period
- app.py: add inline documentation for retry configuration vars
- Dockerfile.gpu: fix comment to accurately describe two-phase startup

These improvements address all findings from the code-reviewer,
silent-failure-hunter, and comment-analyzer review agents.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): remove redundant imports in app.py

- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): use container DNS for Supabase realtime instead of host.docker.internal (#335)

The host.docker.internal hostname resolves to Docker Desktop's gateway IP
(192.168.65.254) in WSL2, which doesn't properly route to host-bound ports.
This caused Hi-RAG to fail connecting to Supabase realtime after Docker restarts.

Changed default SUPABASE_REALTIME_URL from:
  ws://host.docker.internal:65421/realtime/v1
to:
  ws://supabase_kong_PMOVES.AI:8000/realtime/v1

Since both containers are on pmoves-net, direct container-to-container DNS
resolution works reliably.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): restore EvoSwarm mode and HRM integration

Fixes critical dead code in geometry_decode_text function:
- Changed `else` to `elif mode == "swarm"` to make swarm mode reachable
- Integrated HRM refinement in learned mode (maybe_refine)
- Added HRM status in default geometry mode
- Consistent response shape across all modes (namespace, modality, builder_pack)

Before: swarm mode was unreachable due to early returns in if-else
After: proper if-elif-else routing for learned/swarm/default modes

Resolves CodeRabbit review finding in PR #334

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: address PR #334 review issues across 4 files

route.ts (Critical):
- Import and use logError() instead of console.error
- Return HTTP 503 for configuration errors
- Return HTTP 502 for upstream/network failures

app.py (Important):
- Change except Exception to except (ImportError, ModuleNotFoundError)
- Fix variable shadowing: use top_pts instead of re-declaring pts

Dockerfile (Suggestions):
- Remove duplicate comment block at Step 12b
- Replace Pinokio line number references with descriptive names
- Fix huggingface-hub version comment (0.30.0 → 0.25.0)

sync.py (Suggestion):
- Make offline mode opt-in via NOTEBOOK_SYNC_GRACEFUL_DEGRADATION env var
- Fail explicitly if OPEN_NOTEBOOK_API_URL not set (unless env var enabled)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(hirag): remove extra_headers from WebSocket (uvloop incompatibility) (#400)

The websockets library's extra_headers parameter is not supported by
uvloop's create_connection(), which is used by uvicorn. Removed the
extra_headers parameter and rely on the apikey URL parameter for
Supabase realtime authentication.

Also:
- Add pmoves/vendor/python/ to .gitignore (unpacked packages)
- Remove 275+ unpacked package files from git tracking

Vendor submodules were already configured with POWERFULMOVES forks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Codex Agent <codex-agent@example.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 18, 2026
- GPU Dockerfile: add non-root user with video group (critical security fix)
- wait-for-deps.sh: add curl timeout (--connect-timeout 5 --max-time 10)
- app.py: add JSON parse failure logging at debug level
- app.py: include exception type in grace period logging messages

These changes address findings from the code-reviewer and silent-failure-hunter
agents that reviewed PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES added a commit that referenced this pull request Jan 18, 2026
…tability

fix(hirag): Docker restart stability - Supabase realtime connection resilience
POWERFULMOVES pushed a commit that referenced this pull request Jan 18, 2026
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 18, 2026
- Remove duplicate import line (lines 1-2 were near-identical)
- Remove redundant `import time` inside function (already imported at module level)

Addresses CodeRabbit review feedback from PR #333.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
POWERFULMOVES pushed a commit that referenced this pull request Jan 18, 2026
Documents the two-phase startup pattern with exec in child scripts,
explaining why CodeRabbit's "Critical" flag was incorrect.

Key insight: exec in a called script only replaces the child process,
not the parent wrapper. This is a valid pattern for GPU containers
that need both dependency waiting and NVIDIA entrypoint initialization.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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