Skip to content

fix(wizard): no borrar workflows hermanos tras un merge CAS a mitad de un avance - #263

Draft
cursor[bot] wants to merge 2 commits into
developmentfrom
cursor/critical-bug-management-30ce
Draft

fix(wizard): no borrar workflows hermanos tras un merge CAS a mitad de un avance#263
cursor[bot] wants to merge 2 commits into
developmentfrom
cursor/critical-bug-management-30ce

Conversation

@cursor

@cursor cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

Resumen ejecutivo

Qué cambia

Tras un conflicto CAS a mitad de un advance(), el runtime del Wizard adopta los workflows remotos en la colección viva del owner en vez de reutilizar el snapshot anterior al merge.

Para qué sirve

El pin de persistencia de #258 reutilizaba esa colección en todos los checkpoints del mismo avance. Un retry CAS solo parcheaba revision, así que el siguiente persist clonaba la lista previa al merge y borraba workflows que otra pestaña acababa de añadir.

Impacto para el usuario

Un workflow de varios pasos que choca con un guardado concurrente ya no puede borrar checkpoints hermanos del mismo workspace.

Riesgo

  • Bajo
  • Medio
  • Alto

Estado

  • En desarrollo
  • Listo para revisión
  • Bloqueado por CI o revisión
  • Requiere migración o acción manual

Summary

#258 pins persist to {workspace, collection, openSequence} before execute() yields so a folder switch cannot retarget the checkpoint. That pin is reused for every persist in the same advance. On CAS conflict, persist() merged into a cloned candidate and only copied revision back onto owner.collection.

The next persist in the loop cloned the pre-merge owner (now with a matching revision) and saved it without the sibling workflows the merge had just written. Concrete trigger: another tab inserts a workflow and bumps the revision while step 1 of a two-step advance is executing; step 1's persist merges correctly, step 2's persist wipes the sibling.

adoptPersistMerge() now copies remote-only (or newer remote) workflows into the live owner collection and keeps the in-memory objects advanceUnlocked is mutating. Destination isolation after open() is unchanged.

This branch also contains the persist-after-open() pin from #258. If #258 merges first, only the CAS adopt commit remains here.

Overview

  1. Workspace already has a waiting workflow.
  2. User starts a two-step workflow whose first execute() is in flight.
  3. Another tab writes a new workflow and advances the CAS revision.
  4. Step 1 persist conflicts, merges, and saves all three workflows.
  5. Step 2 persist now keeps the sibling instead of overwriting it with the pre-merge list.
  6. The advancing workflow still finishes completed with both outputRefs.

Detailed changes

Backend

No backend changes.

UI and Wizard

  • persist() adopts the merged snapshot into the pinned owner collection after a CAS retry.
  • Live workflow object identity is preserved so later step mutations still persist.
  • this.collection is only rebound to that owner when the runtime still owns the open target.

Data, provenance and compatibility

No migration. Workspace isolation after open() is unchanged.

Files and ownership

  • ui/src/features/agent/wizardWorkflowRuntime.ts — adopt merged siblings into the pinned owner.
  • ui/tests/wizardWorkflowRuntime.test.mjs — inject a sibling mid-execute and assert it survives the next persist.
  • Conversation persist and Story Lab merge were left untouched.

Validation

  • Date (UTC): 2026-09-08

  • Base SHA: 2072943

  • Head SHA: 0840eef

  • Validation scope: focused

  • python3 scripts/verify_clean_repo.py — PASS

  • python -m compileall -q app/services app/launch.py scripts — N/A (UI-only)

  • Focused Python tests: N/A (UI-only)

  • cd ui && npm run i18n:check — not required (no catalog changes)

  • UI tests: npx tsx --tsconfig tsconfig.app.json --import ./tests/setupI18n.ts --test tests/wizardWorkflowRuntime.test.mjs tests/wizardConversationPersistence.test.mjs tests/rhythmic3dWorkflow.test.mjs — 35/35 pass

  • npx eslint src/features/agent/wizardWorkflowRuntime.ts tests/wizardWorkflowRuntime.test.mjs --max-warnings=0 — pass

  • cd ui && npm run build — not run (logic-only runtime change)

  • git diff --check — clean

  • E2E/smoke checks: N/A (unit-reproduced CAS overwrite; no UI surface change)

Code quality

  • Score: pending CI
  • Complexity trend: pending CI
  • Production LOC trend: pending CI
  • Regression versus main: pending CI
  • Ratchet: pending CI

CI and review

  • CI of this HEAD: pending

  • Cursor/Bugbot of this HEAD: pending

  • Independent agent review of this HEAD: pending

  • Human merge click (operational, not code review): pending

  • Reviewed at current HEAD

  • Earlier review; HEAD has changed since (stale)

  • Pending

  • Unavailable

Coste de la tarea

  • Tests simulados: 0 tokens externos
  • Tests reales: N/A
  • Llamadas LLM externas: 0
  • Tokens de prompt: N/A
  • Tokens de respuesta: N/A
  • Tokens totales: N/A
  • Generaciones de imágenes/audio/vídeo: 0
  • Tiempo transcurrido: N/A
  • Proveedores/modelos: N/A

Notes and limitations

Follow-up work

Checklist

  • The executive summary is understandable without reading the code.
  • The detailed Summary/Overview has not been removed or shortened.
  • Tests and their actual results are recorded.
  • Generated assets, secrets and local-only files are not committed.
  • Required CI and Cursor/Bugbot review are complete, or the PR is clearly marked as waiting for them.
Open in Web View Automation 

cursoragent and others added 2 commits September 9, 2026 00:05
…en()

Pin the collection that still holds the running workflow before execute()
yields. Switching folders mid-step no longer drops the finished checkpoint
on the source workspace or writes it into the destination.

Co-authored-by: ignaciodelcano+dcl <ignaciodelcano+dcl@gmail.com>
Pinning persist to the pre-open collection reused that snapshot for every
checkpoint in the same advance. A conflict retry only patched its revision,
so the next persist cloned the pre-merge list and dropped workflows the
merge had just adopted.

Co-authored-by: ignaciodelcano+dcl <ignaciodelcano+dcl@gmail.com>
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: low
Scope: 2 file(s); +195/-22; React UI

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

Findings

  • low — UI changed — rebuild before merge
    Run cd ui && npm run build (CI already does this). Pinokio Update rebuilds for end users; keep ui/dist untracked.

Changed files

  • modified: ui/src/features/agent/wizardWorkflowRuntime.ts, ui/tests/wizardWorkflowRuntime.test.mjs

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.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Code health

Quality score: 55.5/100

Higher is better. The score is a trend dashboard; the independent ratchet below remains the CI gate.

Component Weight Current Change
Cyclomatic health 45% 54.7 +0.0
File concentration 25% 62.1 +0.0
Oversized-file debt 20% 38.0 +0.0
Modularity 10% 77.9 +0.0

Change vs PR base: +0.0 points.

Metric Value
Production LOC 266,954
Production files 741
Test LOC 96,620
Functions measured 17,423
Functions complexity ≥ 15 845
Maximum complexity 672
Policy code-health-policy-v1
HEAD 6c3b8176a21b15cccff7bad527e6928787d6ea3b
Base 20729439779dd62c566c99013313d78f121198cc
UI measurement complete

Markdown, JSON catalogs and tests are out of this table. Only app/ runtime + ui/src TS/JS count.

Most complex functions

Complexity Where
672 app/wgp.py:7219 generate_video
381 ui/src/stores/useStore.ts:4084 Async method 'startGeneration'
355 app/_launch_runtime.py:23613 _run_generation
308 app/wgp.py:12359 generate_video_tab
268 ui/src/stores/useStore.ts:8636 Async method 'loadSettingsFromOutput'
260 ui/src/components/Sidebar/SceneAnimatorPanel.tsx:496 Function 'SceneAnimatorPanel'
258 app/services/director/planners/short_film.py:3433 ShortFilmPlanner._plan_story_driven
248 app/services/director_pipeline.py:13607 _run_video_generation
245 app/services/director_pipeline.py:7712 _run_pipeline
244 ui/src/features/agent/agentActions.ts:1145 Function 'parseAction'
226 app/services/director_pipeline.py:6541 update_comic_preview
225 ui/src/features/agent/agentActions.ts:2898 Async function 'executeAgentActions'

Trend vs baseline

Metric Δ
Production LOC +45
Test LOC +128
Functions ≥ 15 +0
Maximum complexity +0

Warnings

  • production LOC increased by +45

Ratchet passed.

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