From 9f69794fd983562166c46b193e75368d15635b70 Mon Sep 17 00:00:00 2001 From: csfet9 Date: Fri, 2 Jan 2026 01:26:46 +0100 Subject: [PATCH 1/4] feat: Add local LLM improvements for reasoning models and Docker startup ## Reasoning Model Support - Strip thinking tags from local LLM responses (, , , |startthink|/|endthink|) - Enables Qwen3, DeepSeek, and other reasoning models to work with JSON extraction - Non-breaking: only affects responses that contain thinking tags ## Docker Retry Start Script - New retry-start.sh waits for dependencies before starting Hindsight - Checks LLM Studio availability at /v1/models endpoint - Checks database connectivity (skipped for embedded pg0) - Configurable via HINDSIGHT_RETRY_MAX and HINDSIGHT_RETRY_INTERVAL env vars - Prevents startup failures when LLM Studio isn't ready yet Tested on Apple Silicon M4 Max with Qwen3 8B via LM Studio. --- docker/standalone/Dockerfile | 21 ++--- docker/standalone/retry-start.sh | 78 +++++++++++++++++++ .../hindsight_api/engine/llm_wrapper.py | 13 ++++ 3 files changed, 103 insertions(+), 9 deletions(-) create mode 100755 docker/standalone/retry-start.sh diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index a68471117..b130367d1 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -144,9 +144,10 @@ RUN useradd -m -s /bin/bash hindsight # Copy API with virtual environment from builder COPY --from=api-builder /app/api /app/api -# Copy startup script +# Copy startup scripts COPY docker/standalone/start-all.sh /app/start-all.sh -RUN chmod +x /app/start-all.sh +COPY docker/standalone/retry-start.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh /app/retry-start.sh # Create data directory for pg0 and set ownership RUN mkdir -p /app/data && chown -R hindsight:hindsight /app @@ -183,7 +184,7 @@ ENV HINDSIGHT_ENABLE_API=true ENV HINDSIGHT_ENABLE_CP=false ENV PYTHONUNBUFFERED=1 -CMD ["/app/start-all.sh"] +CMD ["/app/retry-start.sh"] # ============================================================================= # Stage: Final Image - Control Plane Only @@ -203,9 +204,10 @@ COPY --from=cp-builder /app/memory-poc/hindsight-control-plane/public ./public WORKDIR /app -# Copy startup script +# Copy startup scripts COPY docker/standalone/start-all.sh /app/start-all.sh -RUN chmod +x /app/start-all.sh +COPY docker/standalone/retry-start.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh /app/retry-start.sh # Install curl for health checks RUN apk add --no-cache curl bash @@ -217,7 +219,7 @@ ENV HINDSIGHT_CP_DATAPLANE_API_URL=http://localhost:8888 ENV HINDSIGHT_ENABLE_API=false ENV HINDSIGHT_ENABLE_CP=true -CMD ["/app/start-all.sh"] +CMD ["/app/retry-start.sh"] # ============================================================================= # Stage: Final Image - Standalone (both API and Control Plane) @@ -258,9 +260,10 @@ COPY --from=cp-builder /app/memory-poc/hindsight-control-plane/public ./public WORKDIR /app -# Copy startup script +# Copy startup scripts COPY docker/standalone/start-all.sh /app/start-all.sh -RUN chmod +x /app/start-all.sh +COPY docker/standalone/retry-start.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh /app/retry-start.sh # Create data directory for pg0 and set ownership RUN mkdir -p /app/data && chown -R hindsight:hindsight /app @@ -306,7 +309,7 @@ ENV HINDSIGHT_ENABLE_API=true ENV HINDSIGHT_ENABLE_CP=true ENV PYTHONUNBUFFERED=1 -CMD ["/app/start-all.sh"] +CMD ["/app/retry-start.sh"] # ============================================================================= # Default target selection based on build args diff --git a/docker/standalone/retry-start.sh b/docker/standalone/retry-start.sh new file mode 100755 index 000000000..509340e9e --- /dev/null +++ b/docker/standalone/retry-start.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Retry wrapper - waits for dependencies before starting hindsight + +LLM_BASE_URL="${HINDSIGHT_API_LLM_BASE_URL:-http://host.docker.internal:1234/v1}" +MAX_RETRIES="${HINDSIGHT_RETRY_MAX:-0}" # 0 = infinite +RETRY_INTERVAL="${HINDSIGHT_RETRY_INTERVAL:-10}" + +# Check if external database is configured (skip check for embedded pg0) +# If HINDSIGHT_API_DATABASE_URL is not set, we use embedded pg0 which starts with start-all.sh +SKIP_DB_CHECK=false +if [ -z "${HINDSIGHT_API_DATABASE_URL}" ]; then + SKIP_DB_CHECK=true + echo "No external database configured - using embedded pg0" +else + DB_HOST="${HINDSIGHT_API_DATABASE_URL}" + # Extract DB host from URL for checking + DB_CHECK_HOST=$(echo "$DB_HOST" | sed -E 's|.*@([^:/]+):([0-9]+)/.*|\1 \2|') +fi + +check_db() { + if $SKIP_DB_CHECK; then + return 0 # Skip check, always pass + fi + if command -v pg_isready &> /dev/null; then + pg_isready -h $(echo $DB_CHECK_HOST | cut -d' ' -f1) -p $(echo $DB_CHECK_HOST | cut -d' ' -f2) &>/dev/null + else + # Fallback: try connecting with Python + python3 -c "import socket; s=socket.socket(); s.settimeout(5); exit(0 if s.connect_ex(('$(echo $DB_CHECK_HOST | cut -d' ' -f1)', $(echo $DB_CHECK_HOST | cut -d' ' -f2))) == 0 else 1)" 2>/dev/null + fi +} + +check_llm() { + curl -sf "${LLM_BASE_URL}/models" --connect-timeout 5 &>/dev/null +} + +echo "Waiting for dependencies to be ready..." +attempt=1 + +while true; do + echo "Attempt $attempt of $( [ "$MAX_RETRIES" -eq 0 ] && echo 'unlimited' || echo "$MAX_RETRIES" )..." + + db_ok=false + llm_ok=false + + if check_db; then + if $SKIP_DB_CHECK; then + echo " [OK] Database (embedded pg0 - starts with app)" + else + echo " [OK] Database accessible" + fi + db_ok=true + else + echo " [..] Database not accessible" + fi + + if check_llm; then + echo " [OK] LLM Studio accessible" + llm_ok=true + else + echo " [..] LLM Studio not accessible (${LLM_BASE_URL})" + fi + + if $db_ok && $llm_ok; then + echo "" + echo "All dependencies ready! Starting Hindsight..." + echo "" + exec /app/start-all.sh + fi + + if [ "$MAX_RETRIES" -ne 0 ] && [ "$attempt" -ge "$MAX_RETRIES" ]; then + echo "Max retries reached. Exiting." + exit 1 + fi + + echo "Waiting ${RETRY_INTERVAL}s before retry..." + sleep "$RETRY_INTERVAL" + ((attempt++)) +done diff --git a/hindsight-api/hindsight_api/engine/llm_wrapper.py b/hindsight-api/hindsight_api/engine/llm_wrapper.py index d3e11f9bd..569c95678 100644 --- a/hindsight-api/hindsight_api/engine/llm_wrapper.py +++ b/hindsight-api/hindsight_api/engine/llm_wrapper.py @@ -6,6 +6,7 @@ import json import logging import os +import re import time from typing import Any @@ -305,6 +306,18 @@ async def call( content = response.choices[0].message.content + # Strip reasoning model thinking tags (various formats) + # Supports: , , , |startthink|/|endthink| + if content: + original_len = len(content) + content = re.sub(r".*?", "", content, flags=re.DOTALL) + content = re.sub(r".*?", "", content, flags=re.DOTALL) + content = re.sub(r".*?", "", content, flags=re.DOTALL) + content = re.sub(r"\|startthink\|.*?\|endthink\|", "", content, flags=re.DOTALL) + content = content.strip() + if len(content) < original_len: + logger.debug(f"Stripped {original_len - len(content)} chars of reasoning tokens") + # For local models, they may wrap JSON in markdown code blocks if self.provider in ("lmstudio", "ollama"): clean_content = content From e65a645925b540b60c55c64fe6c8226c6205678f Mon Sep 17 00:00:00 2001 From: csfet9 Date: Sat, 3 Jan 2026 01:45:53 +0100 Subject: [PATCH 2/4] refactor: make thinking token stripping opt-in via env var --- hindsight-api/hindsight_api/config.py | 1 + hindsight-api/hindsight_api/engine/llm_wrapper.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hindsight-api/hindsight_api/config.py b/hindsight-api/hindsight_api/config.py index 9f20b14ae..423672f25 100644 --- a/hindsight-api/hindsight_api/config.py +++ b/hindsight-api/hindsight_api/config.py @@ -18,6 +18,7 @@ ENV_LLM_BASE_URL = "HINDSIGHT_API_LLM_BASE_URL" ENV_LLM_MAX_CONCURRENT = "HINDSIGHT_API_LLM_MAX_CONCURRENT" ENV_LLM_TIMEOUT = "HINDSIGHT_API_LLM_TIMEOUT" +ENV_LLM_STRIP_THINKING = "HINDSIGHT_API_LLM_STRIP_THINKING" ENV_EMBEDDINGS_PROVIDER = "HINDSIGHT_API_EMBEDDINGS_PROVIDER" ENV_EMBEDDINGS_LOCAL_MODEL = "HINDSIGHT_API_EMBEDDINGS_LOCAL_MODEL" diff --git a/hindsight-api/hindsight_api/engine/llm_wrapper.py b/hindsight-api/hindsight_api/engine/llm_wrapper.py index 569c95678..80ea3ddb6 100644 --- a/hindsight-api/hindsight_api/engine/llm_wrapper.py +++ b/hindsight-api/hindsight_api/engine/llm_wrapper.py @@ -20,6 +20,7 @@ DEFAULT_LLM_MAX_CONCURRENT, DEFAULT_LLM_TIMEOUT, ENV_LLM_MAX_CONCURRENT, + ENV_LLM_STRIP_THINKING, ENV_LLM_TIMEOUT, ) @@ -299,16 +300,18 @@ async def call( ) if self.provider not in ("lmstudio", "ollama"): call_params["response_format"] = {"type": "json_object"} - + logger.debug(f"Sending request to {self.provider}/{self.model} (timeout={self.timeout})") response = await self._client.chat.completions.create(**call_params) logger.debug(f"Received response from {self.provider}/{self.model}") content = response.choices[0].message.content - # Strip reasoning model thinking tags (various formats) + # Strip reasoning model thinking tags when enabled (opt-in for local LLMs) # Supports: , , , |startthink|/|endthink| - if content: + # Enable with HINDSIGHT_API_LLM_STRIP_THINKING=true for reasoning models + # that embed thinking in their output (e.g., Qwen3, DeepSeek on LM Studio) + if content and os.getenv(ENV_LLM_STRIP_THINKING, "false").lower() == "true": original_len = len(content) content = re.sub(r".*?", "", content, flags=re.DOTALL) content = re.sub(r".*?", "", content, flags=re.DOTALL) From 4cc8e2ad8b296b37b5742963af124d5b52878b8f Mon Sep 17 00:00:00 2001 From: csfet9 Date: Sat, 3 Jan 2026 01:50:14 +0100 Subject: [PATCH 3/4] refactor: merge retry logic into start-all.sh (opt-in via HINDSIGHT_WAIT_FOR_DEPS) --- docker/standalone/Dockerfile | 21 ++++----- docker/standalone/retry-start.sh | 78 -------------------------------- docker/standalone/start-all.sh | 66 +++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 90 deletions(-) delete mode 100755 docker/standalone/retry-start.sh diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index b130367d1..a68471117 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -144,10 +144,9 @@ RUN useradd -m -s /bin/bash hindsight # Copy API with virtual environment from builder COPY --from=api-builder /app/api /app/api -# Copy startup scripts +# Copy startup script COPY docker/standalone/start-all.sh /app/start-all.sh -COPY docker/standalone/retry-start.sh /app/retry-start.sh -RUN chmod +x /app/start-all.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh # Create data directory for pg0 and set ownership RUN mkdir -p /app/data && chown -R hindsight:hindsight /app @@ -184,7 +183,7 @@ ENV HINDSIGHT_ENABLE_API=true ENV HINDSIGHT_ENABLE_CP=false ENV PYTHONUNBUFFERED=1 -CMD ["/app/retry-start.sh"] +CMD ["/app/start-all.sh"] # ============================================================================= # Stage: Final Image - Control Plane Only @@ -204,10 +203,9 @@ COPY --from=cp-builder /app/memory-poc/hindsight-control-plane/public ./public WORKDIR /app -# Copy startup scripts +# Copy startup script COPY docker/standalone/start-all.sh /app/start-all.sh -COPY docker/standalone/retry-start.sh /app/retry-start.sh -RUN chmod +x /app/start-all.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh # Install curl for health checks RUN apk add --no-cache curl bash @@ -219,7 +217,7 @@ ENV HINDSIGHT_CP_DATAPLANE_API_URL=http://localhost:8888 ENV HINDSIGHT_ENABLE_API=false ENV HINDSIGHT_ENABLE_CP=true -CMD ["/app/retry-start.sh"] +CMD ["/app/start-all.sh"] # ============================================================================= # Stage: Final Image - Standalone (both API and Control Plane) @@ -260,10 +258,9 @@ COPY --from=cp-builder /app/memory-poc/hindsight-control-plane/public ./public WORKDIR /app -# Copy startup scripts +# Copy startup script COPY docker/standalone/start-all.sh /app/start-all.sh -COPY docker/standalone/retry-start.sh /app/retry-start.sh -RUN chmod +x /app/start-all.sh /app/retry-start.sh +RUN chmod +x /app/start-all.sh # Create data directory for pg0 and set ownership RUN mkdir -p /app/data && chown -R hindsight:hindsight /app @@ -309,7 +306,7 @@ ENV HINDSIGHT_ENABLE_API=true ENV HINDSIGHT_ENABLE_CP=true ENV PYTHONUNBUFFERED=1 -CMD ["/app/retry-start.sh"] +CMD ["/app/start-all.sh"] # ============================================================================= # Default target selection based on build args diff --git a/docker/standalone/retry-start.sh b/docker/standalone/retry-start.sh deleted file mode 100755 index 509340e9e..000000000 --- a/docker/standalone/retry-start.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -# Retry wrapper - waits for dependencies before starting hindsight - -LLM_BASE_URL="${HINDSIGHT_API_LLM_BASE_URL:-http://host.docker.internal:1234/v1}" -MAX_RETRIES="${HINDSIGHT_RETRY_MAX:-0}" # 0 = infinite -RETRY_INTERVAL="${HINDSIGHT_RETRY_INTERVAL:-10}" - -# Check if external database is configured (skip check for embedded pg0) -# If HINDSIGHT_API_DATABASE_URL is not set, we use embedded pg0 which starts with start-all.sh -SKIP_DB_CHECK=false -if [ -z "${HINDSIGHT_API_DATABASE_URL}" ]; then - SKIP_DB_CHECK=true - echo "No external database configured - using embedded pg0" -else - DB_HOST="${HINDSIGHT_API_DATABASE_URL}" - # Extract DB host from URL for checking - DB_CHECK_HOST=$(echo "$DB_HOST" | sed -E 's|.*@([^:/]+):([0-9]+)/.*|\1 \2|') -fi - -check_db() { - if $SKIP_DB_CHECK; then - return 0 # Skip check, always pass - fi - if command -v pg_isready &> /dev/null; then - pg_isready -h $(echo $DB_CHECK_HOST | cut -d' ' -f1) -p $(echo $DB_CHECK_HOST | cut -d' ' -f2) &>/dev/null - else - # Fallback: try connecting with Python - python3 -c "import socket; s=socket.socket(); s.settimeout(5); exit(0 if s.connect_ex(('$(echo $DB_CHECK_HOST | cut -d' ' -f1)', $(echo $DB_CHECK_HOST | cut -d' ' -f2))) == 0 else 1)" 2>/dev/null - fi -} - -check_llm() { - curl -sf "${LLM_BASE_URL}/models" --connect-timeout 5 &>/dev/null -} - -echo "Waiting for dependencies to be ready..." -attempt=1 - -while true; do - echo "Attempt $attempt of $( [ "$MAX_RETRIES" -eq 0 ] && echo 'unlimited' || echo "$MAX_RETRIES" )..." - - db_ok=false - llm_ok=false - - if check_db; then - if $SKIP_DB_CHECK; then - echo " [OK] Database (embedded pg0 - starts with app)" - else - echo " [OK] Database accessible" - fi - db_ok=true - else - echo " [..] Database not accessible" - fi - - if check_llm; then - echo " [OK] LLM Studio accessible" - llm_ok=true - else - echo " [..] LLM Studio not accessible (${LLM_BASE_URL})" - fi - - if $db_ok && $llm_ok; then - echo "" - echo "All dependencies ready! Starting Hindsight..." - echo "" - exec /app/start-all.sh - fi - - if [ "$MAX_RETRIES" -ne 0 ] && [ "$attempt" -ge "$MAX_RETRIES" ]; then - echo "Max retries reached. Exiting." - exit 1 - fi - - echo "Waiting ${RETRY_INTERVAL}s before retry..." - sleep "$RETRY_INTERVAL" - ((attempt++)) -done diff --git a/docker/standalone/start-all.sh b/docker/standalone/start-all.sh index 0206534fc..e280734f1 100755 --- a/docker/standalone/start-all.sh +++ b/docker/standalone/start-all.sh @@ -5,6 +5,72 @@ set -e ENABLE_API="${HINDSIGHT_ENABLE_API:-true}" ENABLE_CP="${HINDSIGHT_ENABLE_CP:-true}" +# ============================================================================= +# Dependency waiting (opt-in via HINDSIGHT_WAIT_FOR_DEPS=true) +# +# Problem: When running with LM Studio, the LLM may take time to load models. +# If Hindsight starts before LM Studio is ready, it fails on LLM verification. +# This wait loop ensures dependencies are ready before starting. +# ============================================================================= +if [ "${HINDSIGHT_WAIT_FOR_DEPS:-false}" = "true" ]; then + LLM_BASE_URL="${HINDSIGHT_API_LLM_BASE_URL:-http://host.docker.internal:1234/v1}" + MAX_RETRIES="${HINDSIGHT_RETRY_MAX:-0}" # 0 = infinite + RETRY_INTERVAL="${HINDSIGHT_RETRY_INTERVAL:-10}" + + # Check if external database is configured (skip check for embedded pg0) + SKIP_DB_CHECK=false + if [ -z "${HINDSIGHT_API_DATABASE_URL}" ]; then + SKIP_DB_CHECK=true + else + DB_CHECK_HOST=$(echo "$HINDSIGHT_API_DATABASE_URL" | sed -E 's|.*@([^:/]+):([0-9]+)/.*|\1 \2|') + fi + + check_db() { + if $SKIP_DB_CHECK; then + return 0 + fi + if command -v pg_isready &> /dev/null; then + pg_isready -h $(echo $DB_CHECK_HOST | cut -d' ' -f1) -p $(echo $DB_CHECK_HOST | cut -d' ' -f2) &>/dev/null + else + python3 -c "import socket; s=socket.socket(); s.settimeout(5); exit(0 if s.connect_ex(('$(echo $DB_CHECK_HOST | cut -d' ' -f1)', $(echo $DB_CHECK_HOST | cut -d' ' -f2))) == 0 else 1)" 2>/dev/null + fi + } + + check_llm() { + curl -sf "${LLM_BASE_URL}/models" --connect-timeout 5 &>/dev/null + } + + echo "⏳ Waiting for dependencies to be ready..." + attempt=1 + + while true; do + db_ok=false + llm_ok=false + + if check_db; then + db_ok=true + fi + + if check_llm; then + llm_ok=true + fi + + if $db_ok && $llm_ok; then + echo "✅ Dependencies ready!" + break + fi + + if [ "$MAX_RETRIES" -ne 0 ] && [ "$attempt" -ge "$MAX_RETRIES" ]; then + echo "❌ Max retries ($MAX_RETRIES) reached. Dependencies not available." + exit 1 + fi + + echo " Attempt $attempt: DB=$( $db_ok && echo 'ok' || echo 'waiting' ), LLM=$( $llm_ok && echo 'ok' || echo 'waiting' )" + sleep "$RETRY_INTERVAL" + ((attempt++)) + done +fi + # Copy pre-cached PostgreSQL data if runtime directory is empty (first run with volume) if [ "$ENABLE_API" = "true" ]; then PG0_CACHE="/home/hindsight/.pg0-cache" From f5248d83f2dcaa0559bb52a67cbb566a5baa931b Mon Sep 17 00:00:00 2001 From: csfet9 Date: Sat, 3 Jan 2026 02:43:49 +0100 Subject: [PATCH 4/4] fix: resolve pg0 stale instance config in Docker build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove stale pg0 instance data after pre-caching binaries to avoid port conflicts (was using hardcoded port 5555 from build time) - Remove unused cache copy logic from start-all.sh - Add database backup instructions to CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 21 +++++++++++++++++++++ docker/standalone/Dockerfile | 15 +++++++-------- docker/standalone/start-all.sh | 12 ------------ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f02314cde..75c50699e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -84,6 +84,27 @@ PostgreSQL with pgvector. Schema managed via Alembic migrations in `hindsight-ap Key tables: `banks`, `memory_units`, `documents`, `entities`, `entity_links` +### Database Backups (IMPORTANT) +**Before any operation that may affect the database, run a backup:** +```bash +docker exec hindsight /backups/backup.sh +``` + +Operations requiring backup: +- Running database migrations +- Modifying Alembic migration files +- Rebuilding Docker images +- Resetting or recreating containers +- Any schema changes +- Bulk data operations + +Backups are stored in `~/hindsight-backups/` on the host. + +To restore: +```bash +docker exec -it hindsight /backups/restore.sh +``` + ## Key Conventions ### Memory Banks diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index a68471117..9b761805f 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -157,9 +157,7 @@ USER hindsight # Set PATH for hindsight user ENV PATH="/app/api/.venv/bin:${PATH}" -# Pre-cache PostgreSQL binaries by starting/stopping pg0-embedded -ENV PG0_HOME=/home/hindsight/.pg0-cache - +# pg0 will download PostgreSQL binaries on first run ENV PG0_HOME=/home/hindsight/.pg0 # Pre-download ML models to avoid runtime download (conditional) @@ -272,16 +270,17 @@ USER hindsight ENV PATH="/app/api/.venv/bin:${PATH}" # Pre-cache PostgreSQL binaries by starting/stopping pg0-embedded -ENV PG0_HOME=/home/hindsight/.pg0-cache +# Note: We use a temp instance just to download binaries, then delete instance data +# to avoid stale port config. Only installation binaries are kept. +ENV PG0_HOME=/home/hindsight/.pg0 RUN /app/api/.venv/bin/python -c "\ from pg0 import Pg0; \ print('Pre-caching PostgreSQL binaries...'); \ -pg = Pg0(name='hindsight', port=5555, username='hindsight', password='hindsight', database='hindsight'); \ +pg = Pg0(name='temp-cache', username='hindsight', password='hindsight', database='hindsight'); \ pg.start(); \ pg.stop(); \ -print('PostgreSQL pre-cached to PG0_HOME')" || echo "Pre-download skipped" - -ENV PG0_HOME=/home/hindsight/.pg0 +print('PostgreSQL binaries cached')" && \ + rm -rf /home/hindsight/.pg0/instances || echo "Pre-download skipped" # Pre-download ML models to avoid runtime download (conditional) ARG PRELOAD_ML_MODELS diff --git a/docker/standalone/start-all.sh b/docker/standalone/start-all.sh index e280734f1..e4e5d5275 100755 --- a/docker/standalone/start-all.sh +++ b/docker/standalone/start-all.sh @@ -71,18 +71,6 @@ if [ "${HINDSIGHT_WAIT_FOR_DEPS:-false}" = "true" ]; then done fi -# Copy pre-cached PostgreSQL data if runtime directory is empty (first run with volume) -if [ "$ENABLE_API" = "true" ]; then - PG0_CACHE="/home/hindsight/.pg0-cache" - PG0_HOME="/home/hindsight/.pg0" - if [ -d "$PG0_CACHE" ] && [ "$(ls -A $PG0_CACHE 2>/dev/null)" ]; then - if [ ! "$(ls -A $PG0_HOME 2>/dev/null)" ]; then - echo "📦 Copying pre-cached PostgreSQL data..." - cp -r "$PG0_CACHE"/* "$PG0_HOME"/ 2>/dev/null || true - fi - fi -fi - # Track PIDs for wait PIDS=()