Skip to content

fix: preserve standalone WanGP API bootstrap - #35

Merged
IAnMove merged 1 commit into
mainfrom
fix/standalone-wangp-session-bootstrap
Sep 1, 2026
Merged

fix: preserve standalone WanGP API bootstrap#35
IAnMove merged 1 commit into
mainfrom
fix/standalone-wangp-session-bootstrap

Conversation

@IAnMove

@IAnMove IAnMove commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Problema

El muro WanGP del PR #31 reutiliza correctamente la instancia cargada por HocusPocus, pero dejó sin bootstrap a la API Python documentada. En un proceso externo, shared.api.init() encontraba el muro sin enlazar y fallaba antes de poder importar WanGP.

Solución

  • Añade services/generation/bootstrap.py como segundo y único bootstrap explícito, reservado a shared.api.init().
  • Reutiliza la instancia enlazada o sys.modules["wgp"] cuando ya existe.
  • Importa una sola vez en un proceso standalone y enlaza exactamente la instancia registrada.
  • Valida el root antes de enlazar y rechaza runtimes distintos.
  • Hace bind_wgp idempotente para la misma instancia y rechaza una segunda instancia.
  • Mantiene a consumidores ordinarios detrás de get_wgp, sin imports implícitos.
  • Actualiza el gate arquitectónico y la documentación del contrato.

Tests

  • Suite Python completa: 1559 passed, 22 warnings.
  • Focalizados bootstrap, muro, arquitectura y concat: 30 passed.
  • compileall: OK.
  • verify_clean_repo: PASS.
  • check_documentation_links: PASS.
  • check_brand_contract: PASS.
  • check_dependency_contract: PASS.
  • scripts/architecture_contracts.py: PASS.

Cobertura añadida

  • bootstrap standalone sin launch;
  • import único y reutilización del singleton;
  • instancia ya registrada en sys.modules;
  • root incompatible sin bind parcial;
  • import fallido o no registrado;
  • rechazo de un segundo runtime;
  • integración real de shared.api.init() con módulo falso.

Alcance

PR independiente del router Recipes. No modifica _launch_runtime.py, UI, rutas HTTP, vendor WanGP ni archivos de generación del usuario.


Note

Medium Risk
Touches the singleton WanGP runtime boundary and the only non-launch wgp import path; mistakes could break standalone integrations or double-bind runtimes, but behavior is heavily gated and tested.

Overview
Restores the documented standalone Python API after the WanGP “wall” left shared.api.init() unable to import and bind wgp in external processes.

Adds services/generation/bootstrap.py with get_or_bootstrap_wgp: reuses an already-bound instance or sys.modules["wgp"], otherwise performs the single allowed importlib load, verifies the module root matches init(root=...), and binds that exact singleton. shared.api runtime setup now delegates to this helper instead of inline bind logic.

bind_wgp / get_wgp gain locking, reject None and a second distinct runtime, and point unbound callers at launch or shared.api.init(). Architecture docs, API.md, and test_architecture_contracts treat bootstrap as the second explicit allowlisted wgp import beside _launch_runtime.py. New tests cover singleton reuse, root mismatch, failed imports, and end-to-end init() without launch.

Reviewed by Cursor Bugbot for commit b44b516. Configure here.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: low
Scope: 8 file(s); +251/-28; backend services, docs

Automated review from scripts/analyze_pr.py. This is a heuristic pass (no LLM) so humans still own the merge decision.

Findings

  • No heuristic issues. Still run the CI checklist below.

Changed files

  • added: app/services/generation/bootstrap.py, tests/test_shared_api_bootstrap.py
  • modified: app/docs/API.md, app/services/generation/runtime.py, app/shared/api.py, docs/development/ARCHITECTURE_FOUNDATION.md, tests/test_architecture_contracts.py, tests/test_generation_runtime.py

CONTRIBUTING checklist

  • python scripts/verify_clean_repo.py
  • python -m compileall -q app/services app/launch.py scripts
  • cd ui && npm run build if the UI changed
  • No weights, CivitAI sidecars, or generated guides
  • Stays local-first (no required accounts / telemetry)

Posted by the repo PR review workflow. Re-runs on each push to the PR.

@IAnMove

IAnMove commented Sep 1, 2026

Copy link
Copy Markdown
Owner Author

cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b44b516. Configure here.

@IAnMove
IAnMove merged commit f373667 into main Sep 1, 2026
5 checks passed
@IAnMove
IAnMove deleted the fix/standalone-wangp-session-bootstrap branch September 5, 2026 11:54
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