Files
manual_slop/conductor/tracks/gui_decoupling_controller_20260302/debrief.md

4.7 KiB

Comprehensive Debrief: GUI Decoupling Track (Botched Implementation)

1. Track Overview

  • Track Name: GUI Decoupling & Controller Architecture
  • Track ID: gui_decoupling_controller_20260302
  • Primary Objective: Decouple business logic from gui_2.py (3,500+ lines) into a headless AppController.

2. Phase-by-Phase Failure Analysis

Phase 1: Controller Skeleton & State Migration

  • Status: [x] Completed (with major issues)
  • What happened: State variables (locks, paths, flags) were moved to AppController. App was given a __getattr__ and __setattr__ bridge to delegate to the controller.
  • Failure: The delegation created a "Phantom State" problem. Sub-agents began treating the two objects as interchangeable, but they are not. Shadowing (where App has a variable that blocks Controller) became a silent bug source.

Phase 2: Logic & Background Thread Migration

  • Status: [x] Completed (with critical regressions)
  • What happened: Async loops, AI client calls, and project I/O were moved to AppController.
  • Failure 1 (Over-deletion): Tier 3 workers deleted essential UI-thread handlers from App (like _handle_approve_script). This broke button callbacks and crashed the app on startup.
  • Failure 2 (Thread Violation): A "fallback queue processor" was added to the Controller thread. This caused two threads to race for the same event queue. If the Controller won, the UI never blinked/updated, causing simulation timeouts.
  • Failure 3 (Property Erasure): During surgical cleanups in this high-reasoning session, the current_provider getter/setter in AppController was accidentally deleted while trying to remove a redundant method. App now attempts to delegate to a non-existent attribute, causing AttributeError.

Phase 3: Test Suite Refactoring

  • Status: [x] Completed (fragile)
  • What happened: conftest.py was updated to patch AppController methods.
  • Failure: The live_gui sandbox environment (isolated workspace) was broken because the Controller now eagerly checks for credentials.toml on startup. The previous agent tried to "fix" this by copying secrets into the sandbox, which is a security regression and fragile.

Phase 4: Final Validation

  • Status: [ ] FAILED
  • What happened: Integration tests and extended simulations fail or timeout consistently.
  • Root Cause: Broken synchronization between the Controller's background processing and the GUI's rendering loop. The "Brain" (Controller) and "Limb" (GUI) are disconnected.

3. Current "Fucked" State of the Codebase

  • src/gui_2.py: Contains rendering but is missing critical property logic. It still shadows core methods that should be purely in the controller.
  • src/app_controller.py: Missing core properties (current_provider) and has broken start_services logic.
  • tests/conftest.py: Has a messy live_gui fixture that uses environment variables (SLOP_CREDENTIALS, SLOP_MCP_ENV) but points to a sandbox that is missing the actual files.
  • sloppy.py: The entry point works but the underlying classes are in a state of partial migration.

4. Immediate Recovery Plan (New Phase 5)

Phase 5: Stabilization & Cleanup

  1. Task 5.1: AST Synchronization Audit. Manually (via AST) compare App and AppController. Ensure every property needed for the UI exists in the Controller and is correctly delegated by App.
  2. Task 5.2: Restore Controller Properties. Re-implement current_provider and current_model in AppController with proper logic (initializing adapters, clearing stats).
  3. Task 5.3: Explicit Delegation. Remove the "magic" __getattr__ and __setattr__. Replace them with explicit property pass-throughs. This will make AttributeError visible during static analysis rather than runtime.
  4. Task 5.4: Fix Sandbox Isolation. Ensure live_gui fixture in conftest.py correctly handles credentials.toml via SLOP_CREDENTIALS env var pointing to the root, and ensure sloppy.py respects it.
  5. Task 5.5: Event Loop Consolidation. Ensure there is EXACTLY ONE asyncio loop running, owned by the Controller, and that the GUI thread only reads from _pending_gui_tasks.

5. Technical Context for Next Session

  • Encoding issues: temp_conftest.py and other git-shipped files often have UTF-16 or different line endings. Use Python-based readers to bypass read_file failures.
  • Crucial Lines: src/gui_2.py line 180-210 (Delegation) and src/app_controller.py line 460-500 (Event Processing) are the primary areas of failure.
  • Mocking: All patch targets in tests/ must now be audited to ensure they hit the Controller, not the App.