smart_ide/services/ia_dev/deploy/lib/deploy-conf-handling.sh
Nicolas Cantu 58cc2493e5 chore: consolidate ia_dev module, sync tooling, and harden gateways (0.0.5)
Initial state:
- ia_dev was historically referenced as ./ia_dev in docs and integrations, while the vendored module lives under services/ia_dev.
- AnythingLLM sync and hook installation had error masking / weak exit signaling.
- Proxy layers did not validate proxy path segments, allowing path normalization tricks.

Motivation:
- Make the IDE-oriented workflow usable (sync -> act -> deploy/preview) with explicit errors.
- Reduce security footguns in proxying and script automation.

Resolution:
- Standardize IA_DEV_ROOT usage and documentation to services/ia_dev.
- Add SSH remote data mirroring + optional AnythingLLM ingestion.
- Extend AnythingLLM pull sync to support upload-all/prefix and fail on upload errors.
- Harden smart-ide-sso-gateway and smart-ide-global-api proxying with safe-path checks and non-leaking error responses.
- Improve ia-dev-gateway runner validation and reduce sensitive path leakage.
- Add site scaffold tool (Vite/React) with OIDC + chat via sso-gateway -> orchestrator.

Root cause:
- Historical layout changes (submodule -> vendored tree) and missing central contracts for path resolution.
- Missing validation for proxy path traversal patterns.
- Overuse of silent fallbacks (|| true, exit 0 on partial failures) in automation scripts.

Impacted features:
- Project sync: git pull + AnythingLLM sync + remote data mirror ingestion.
- Site frontends: SSO gateway proxy and orchestrator intents (rag.query, chat.local).
- Agent execution: ia-dev-gateway script runner and SSE output.

Code modified:
- scripts/remote-data-ssh-sync.sh
- scripts/anythingllm-pull-sync/sync.mjs
- scripts/install-anythingllm-post-merge-hook.sh
- cron/git-pull-project-clones.sh
- services/smart-ide-sso-gateway/src/server.ts
- services/smart-ide-global-api/src/server.ts
- services/smart-ide-orchestrator/src/server.ts
- services/ia-dev-gateway/src/server.ts
- services/ia_dev/tools/site-generate.sh

Documentation modified:
- docs/** (architecture, API docs, ia_dev module + integration, scripts)

Configurations modified:
- config/services.local.env.example
- services/*/.env.example

Files in deploy modified:
- services/ia_dev/deploy/*

Files in logs impacted:
- logs/ia_dev.log (runtime only)
- .logs/* (runtime only)

Databases and other sources modified:
- None

Off-project modifications:
- None

Files in .smartIde modified:
- .smartIde/agents/*.md
- services/ia_dev/.smartIde/**

Files in .secrets modified:
- None

New patch version in VERSION:
- 0.0.5

CHANGELOG.md updated:
- yes
2026-04-04 18:36:43 +02:00

61 lines
2.4 KiB
Bash

#!/usr/bin/env bash
# ia_dev — conf.json handling identical for every managed project (jq, secrets_path → SECRETS_BASE).
# Add here any new deploy.* field that must be read the same way for all projects.
# Do not put project-specific paths, hostnames, or phase ordering here beyond generic keys.
_DEPLOY_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=../../lib/conf_path_resolve.sh
source "${_DEPLOY_LIB_DIR}/../../lib/conf_path_resolve.sh"
# ia_dev_deploy_require_jq <log_tag> — exit 1 if jq missing (e.g. log_tag="[orchestrator]")
ia_dev_deploy_require_jq() {
local tag="${1:-[ia_dev][deploy]}"
if ! command -v jq >/dev/null 2>&1; then
echo "${tag}[ERROR] jq is required to read deploy.* from conf.json" >&2
exit 1
fi
}
# ia_dev_deploy_secrets_export_from_conf <conf_path> — export SECRETS_BASE + LECOFFRE_SECRETS_BASE when deploy.secrets_path is a directory
ia_dev_deploy_secrets_export_from_conf() {
local conf="${1:?}"
local secrets_path
secrets_path="$(jq -r '.deploy.secrets_path // empty' "$conf")"
secrets_path="$(ia_dev_resolve_path_from_conf "$conf" "$secrets_path")"
if [[ -n "$secrets_path" && "$secrets_path" != "null" && -d "$secrets_path" ]]; then
export SECRETS_BASE="$secrets_path"
export LECOFFRE_SECRETS_BASE="$secrets_path"
fi
}
# ia_dev_deploy_export_runtime_context <repository_root> <env> — required handoff to project orchestrator (blocking checks below)
ia_dev_deploy_export_runtime_context() {
local repo="${1:?}"
local env="${2:?}"
export IA_DEV_DEPLOY_REPO_ROOT="$repo"
export IA_DEV_DEPLOY_ENV="$env"
}
# ia_dev_deploy_assert_handoff_context <repository_root> <env> <log_tag> — exit 1 if exports missing or inconsistent (no fallback)
ia_dev_deploy_assert_handoff_context() {
local repo="${1:?}"
local env="${2:?}"
local tag="${3:-[orchestrator]}"
if [[ -z "$repo" || ! -d "$repo" ]]; then
echo "${tag}[ERROR] Handoff: repository root invalid or not a directory: ${repo}" >&2
exit 1
fi
if [[ -z "$env" ]]; then
echo "${tag}[ERROR] Handoff: env is empty" >&2
exit 1
fi
if [[ "${IA_DEV_DEPLOY_REPO_ROOT:-}" != "$repo" ]]; then
echo "${tag}[ERROR] Handoff: IA_DEV_DEPLOY_REPO_ROOT mismatch or unset (expected ${repo})" >&2
exit 1
fi
if [[ "${IA_DEV_DEPLOY_ENV:-}" != "$env" ]]; then
echo "${tag}[ERROR] Handoff: IA_DEV_DEPLOY_ENV mismatch or unset (expected ${env}, got ${IA_DEV_DEPLOY_ENV:-})" >&2
exit 1
fi
}