smart_ide/docs/deployment-target.md
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

47 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Première cible de déploiement — client Linux + serveur distant (SSH)
## Variante : machine IA unique
Dans cette variante, **Ollama**, **AnythingLLM** et les **services** `smart_ide` tournent sur le **même hôte**. Les URLs `127.0.0.1` pour linférence et le RAG sont **locales à cette machine** ; Lapce et/ou le **front web** sur la même machine ou derrière le même reverse proxy les consomment **sans tunnel SSH**. Les **trois environnements** (test, pprod, prod) restent séparés par configuration et DNS — voir [platform-target.md](./platform-target.md). L**orchestrateur** et **`ia-dev-gateway`** peuvent cohabiter sur cet hôte.
Cette variante **ne remplace pas** le modèle client/serveur SSH : elle le complète pour les postes ou farms « tout-en-un ».
## Modèle
La **première cible de déploiement** décrite ci-dessous nest pas un poste tout-en-un sur la même machine que le socle IA.
| Rôle | Où ça tourne | Contenu typique |
|------|----------------|-----------------|
| **Client** | Machine **Linux** de lutilisateur (poste local) | Shell dédition / UX (ex. Lapce), orchestrateur côté client si applicable, connexion **SSH** persistante ou à la demande |
| **Serveur distant** | Hôte joignable en **SSH** (LAN, bastion, ou jump host selon linfra) | **Socle technique IA** (Ollama, AnythingLLM Docker, services associés), **clones des dépôts**, exécution des **agents** / scripts / OpenShell sur le périmètre autorisé ; **Local Office** ([`services/local-office/`](../services/local-office/), API fichiers Office programmatique) si déployé |
Lutilisateur travaille depuis un **Linux client** ; le **calcul**, les **modèles**, la **mémoire RAG** et les **sources de vérité Git** résident sur le **serveur** (ou une ferme de serveurs derrière la même session SSH).
## Conséquences
- Les URLs « locales » du serveur (`localhost:11434`, `localhost:3001`, …) sont **locales au serveur**. Depuis le client, laccès passe par **tunnel SSH** (`-L`), **ProxyJump**, ou configuration explicite (hostname interne, VPN) selon la politique réseau.
- L**agent gateway** et le **policy-runtime** (OpenShell) sexécutent idéalement **là où tournent les agents et les repos** — le serveur — sauf décision contraire documentée.
- Le **workspace AnythingLLM par projet** vit **côté serveur** (stockage du conteneur ou chemin monté sur lhôte distant). La moulinette de synchro lit les **dépôts sur le serveur**.
- **Local Office** : données sous `services/local-office/data/` (ou chemins surchargés par `STORAGE_PATH` / `DATABASE_PATH`) sur l**hôte qui exécute lAPI** ; à sauvegarder et à protéger comme toute instance de fichiers métier.
- Le client doit disposer dune **identité SSH** autorisée sur le serveur (voir `add-ssh-key.sh` et [infrastructure.md](./infrastructure.md)).
## Tunnels SSH (poste client)
Le poste client peut exposer localement les ports « loopback » du serveur via `ssh -L ...`.
Script daide (génère la commande à exécuter, sans la daemoniser) :
```bash
./scripts/smart-ide-ssh-tunnel-plan.sh --mode minimal
```
Ce script résout `--project/--env` via `projects/active-project.json` (local, gitignoré) ou variables, puis lit `projects/<id>/conf.json``smart_ide.remote_data_access.environments.<env>.ssh_host_alias`.
## Documentation liée
- Vision produit et envs : [platform-target.md](./platform-target.md)
- Topologie LAN / bastion : [infrastructure.md](./infrastructure.md)
- Services Ollama / AnythingLLM / Local Office sur lhôte qui **héberge** le socle : [services.md](./services.md)
- Répartition logique des modules : [system-architecture.md](./system-architecture.md) (à lire avec ce découpage physique)
- SSO front / docv : [features/sso-docv-enso.md](./features/sso-docv-enso.md)