Saltar a contenido

SOURCE-003 Promote Core Write Path Implementation 001

Fecha local: 2026-06-15

Estado: WRITE PATH FUTURO PREPARADO / BLOCKED / SIN CARGA CORE

portal_visible = yes

Scope: tenant

tenant_id: alpuntodeventa

Owner: Gabi / Carlos Canu

Fuente de verdad: docs/tenants/alpuntodeventa/business-observer/design/SOURCE-003-PROMOTE-CORE-WRITE-PATH-IMPLEMENTATION-001.md

1. Objetivo

Preparar en scripts/source_003_importer.py la ruta futura de escritura para:

powershell python scripts/source_003_importer.py promote-core --execute

No se habilita escritura real. promote-core sigue DRY_RUN y promote-core --execute sigue BLOCKED, incluso con confirmaciones incompletas. No se ejecutaron confirmaciones completas.

2. Safe point

Control Resultado
workspace C:\APV\openclawai
rama main
HEAD inicial b386bf25a343eec8d063e2fc21f5ff87d9b6d487
origin/main inicial b386bf25a343eec8d063e2fc21f5ff87d9b6d487
ultimo commit inicial docs: review source 003 promote core execute gate
decision SAFE POINT PASS

3. Archivos modificados

Archivo Impacto
scripts/source_003_importer.py Agrega future_write_path a la salida de promote-core y promote-core --execute; documenta controles, transaccion futura, idempotencia, bloqueo de batch duplicado, timestamps y rollback/rebuild, con escritura deshabilitada.
docs/tenants/alpuntodeventa/business-observer/design/SOURCE-003-PROMOTE-CORE-WRITE-PATH-IMPLEMENTATION-001.md Registra esta implementacion bloqueada.
docs/tenants/alpuntodeventa/business-observer/design/SOURCE-003-PYTHON-IMPORTER-SKELETON-001.md Actualiza el contrato observado del skeleton.
mkdocs.yml, README.md, docs/PROJECT-STATE.md, docs/ROADMAP.md, docs/governance/ACTIVE-CONTEXT.md, docs/tenants/alpuntodeventa/business-observer/README.md, docs/tenants/alpuntodeventa/business-observer/PROJECT-STATE.md, docs/tenants/alpuntodeventa/business-observer/ROADMAP.md Publican y resumen el nuevo estado.

4. Ruta futura preparada

La salida JSON ahora expone details.future_write_path con:

  • write_path_prepared=true;
  • write_path_enabled=false;
  • DB permitida openclaw_business_observer_dev;
  • RAW source business_observer.raw_source_003_sales_items;
  • CORE target business_observer.core_source_003_sales_items;
  • batch 1827f887-9499-4579-b4f3-234d54f41f7f;
  • RAW batch rows = 1886;
  • CORE row_count inicial = 0;
  • filas esperadas a promover 1886;
  • columnas CORE destino 66;
  • post-check esperado CORE batch rows = 1886;
  • fingerprint obligatorio;
  • bloqueo postgres-sandbox;
  • bloqueo de batch duplicado en CORE;
  • idempotencia por tenant_id + sync_batch_id + line_key;
  • preservacion de source_row_hash y line_key;
  • promoted_at, created_at y updated_at gobernados por DB o timestamp transaccional futuro;
  • raw_loaded_at preservado desde RAW;
  • rollback/rebuild documentado, pero no habilitado.

5. Transaccion futura

El plan futuro queda documentado como una unica transaccion controlada:

  1. BEGIN con semantica ON_ERROR_STOP.
  2. Revalidar fingerprint aprobado dentro de la transaccion.
  3. Bloquear si aparece postgres-sandbox.
  4. Proteger el scope del batch CORE autorizado.
  5. Ejecutar pre-checks RAW/CORE.
  6. Construir el set candidato RAW -> CORE.
  7. Calcular inserted + updated + unchanged + blocked = 1886.
  8. Escribir CORE solo en una tarea futura aprobada.
  9. Ejecutar post-checks antes de COMMIT.
  10. ROLLBACK ante FAIL o BLOCKED.

6. Resultado observado

promote-core:

  • result = DRY_RUN;
  • raw_batch_rows = 1886;
  • core_row_count = 0;
  • candidate_rows = 1886;
  • target_columns = 66;
  • duplicates_core = 0;
  • future_write_path.write_path_prepared = true;
  • future_write_path.write_path_enabled = false;
  • db_write=false;
  • data_written=false;
  • sync_enabled=false.

promote-core --execute:

  • result = BLOCKED;
  • confirmaciones faltantes listadas;
  • future_write_path.write_path_prepared = true;
  • future_write_path.write_path_enabled = false;
  • db_touched=false;
  • db_write=false;
  • sql_executed=false;
  • sql_write=false;
  • data_written=false;
  • sync_enabled=false.

promote-core --execute --confirm-local-dev:

  • result = BLOCKED;
  • confirmaciones incompletas listadas;
  • data_written=false;
  • sync_enabled=false.

7. Bloqueos preservados

Siguen bloqueados:

  • INSERT, COPY, UPDATE, DELETE;
  • escritura real en CORE;
  • modificacion de RAW;
  • CSV nuevo;
  • runner;
  • rollback real;
  • VPS, Docker, OpenClaw, NPM y Portainer;
  • push y deploy;
  • produccion;
  • sync diaria.

8. Validaciones

text python -m py_compile scripts/source_003_importer.py -> PASS python scripts/source_003_importer.py --help -> PASS python scripts/source_003_importer.py promote-core -> DRY_RUN python scripts/source_003_importer.py promote-core --execute -> BLOCKED python scripts/source_003_importer.py promote-core --execute --confirm-local-dev -> BLOCKED git diff --check -> PASS .venv-portal\Scripts\mkdocs.exe build --strict -> PASS

9. Decision

text WRITE PATH FUTURO PREPARADO / BLOCKED / SIN CARGA CORE

La ruta futura queda preparada y visible en el importer, pero no ejecutable. CORE conserva row_count = 0; RAW no se modifico; data_written=false y sync_enabled=false.