Skip to content

Rot Elimination Plans: Systematic Codebase Cleanup#59

Draft
trissim wants to merge 8 commits intomainfrom
rot-elimination-plans
Draft

Rot Elimination Plans: Systematic Codebase Cleanup#59
trissim wants to merge 8 commits intomainfrom
rot-elimination-plans

Conversation

@trissim
Copy link
Collaborator

@trissim trissim commented Dec 15, 2025

Rot Elimination Plans: Systematic Codebase Cleanup

Overview

9 plans to eliminate ~3500 lines of rot. No wrappers. No backwards compatibility.

Dependency Graph

┌─────────────────────────────────────────────────────────────┐
│  INDEPENDENT (Wave 1 - Can Start Immediately)               │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐         │
│  │ psygnal      │ │ styling      │ │ config       │         │
│  │ migration    │ │ centralized  │ │ merging      │         │
│  │ (~120 lines) │ │ (~200 lines) │ │ (~90 lines)  │         │
│  └──────────────┘ └──────────────┘ └──────────────┘         │
│  ┌──────────────┐ ┌──────────────┐                          │
│  │ python       │ │ dimension    │                          │
│  │ serializer   │ │ abstraction  │                          │
│  │ (~950 lines) │ │ (~400 lines) │                          │
│  └──────────────┘ └──────────────┘                          │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│  STREAMING (Wave 2 - Sequential)                            │
│  ┌──────────────┐     ┌──────────────┐                      │
│  │ backend      │ ──► │ message      │                      │
│  │ unification  │     │ protocol     │                      │
│  │ (~300 lines) │     │ (~100 lines) │                      │
│  └──────────────┘     └──────────────┘                      │
└─────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────┐
│  COMPILER (Wave 3 - Sequential, Highest Risk)               │
│  ┌──────────────┐     ┌──────────────┐                      │
│  │ generic      │ ──► │ step         │                      │
│  │ compiler     │     │ executor     │                      │
│  │ spec         │     │ extraction   │                      │
│  │ (~200 lines) │     │ (~647 lines) │                      │
│  └──────────────┘     └──────────────┘                      │
└─────────────────────────────────────────────────────────────┘

Plan Summaries

Plan What It Does Lines Saved
plan_01_psygnal_migration Replace 8 callback lists with psygnal Signals ~120
plan_01_centralized_styling Move 227 setStyleSheet calls to app-level stylesheet ~200
plan_01_eliminate_config_merging Delete 90 lines that duplicate config framework ~90
plan_01_python_source_serializer Replace 950-line pickle_to_python with type-dispatched formatters ~950
plan_03_dimension_abstraction Replace 103 channel/slice/frame references with HyperstackDimensions ~400
plan_01_streaming_backend_unification Merge Napari/Fiji backends into one ABC ~300
plan_02_streaming_message_protocol Replace stringly-typed JSON with typed dataclasses ~100
plan_01_generic_compiler_spec Replace Dict[str, Any] plans with typed frozen StepPlan ~200
plan_02_step_executor_extraction Move 647-line process() to dedicated StepExecutor ~647

Key Principles

  1. No wrappers — Delete old code, update callers, fail loud
  2. No backwards compatibility — If something breaks, fix it properly
  3. DECLARATION → INTROSPECTION → DERIVATION — Implementations declare, ABCs derive
  4. Typed over stringly-typed — Frozen dataclasses over Dict[str, Any]

Testing Strategy

  • Each plan must pass existing tests before merge
  • Manual smoke test after each plan
  • Full integration test after all plans merge

Files

  • plans/rot_elimination/00_MASTER_PLAN.md — Dependency graph, execution order, testing strategy
  • plans/rot_elimination/plan_*.md — Individual plans with cleanup sections

8 plans for systematic codebase cleanup:
- Centralized styling (PyQt)
- Config merging elimination (Orchestrator)
- psygnal migration (ObjectState callbacks)
- Python source serializer (pickle_to_python)
- Streaming backend unification
- Step executor extraction
- Streaming message protocol
- Dimension abstraction (Fiji viewer)
@continue
Copy link

continue bot commented Dec 15, 2025

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts

- plan_02_step_executor_extraction: Removed over-engineered 'ExecutionPhase'
  abstraction. The 647 lines are REAL complexity that moves to StepExecutor,
  not phases. Honest about what gets deleted vs moved.

- plan_01_psygnal_migration: Added complete caller enumeration (11 callers).
  Surgical scope: only object_state.py and its callers. Qt signals stay as-is.

- plan_01_centralized_styling: Acknowledged Qt stylesheet limitations.
  Added object name convention for variant styling. Honest about dynamic
  styling that must stay.

- 00_MASTER_PLAN.md: Added dependency graph, execution order, testing
  strategy, and risk mitigation. Wave 1 (independent), Wave 2 (streaming),
  Wave 3 (compiler - highest risk).
Each plan now has explicit guardrails to prevent agents from
falling back to 'competent' solutions:

- psygnal: No wrapper methods, no adapter classes, no fallbacks
- executor: No per-step subclasses, no process() wrappers, no phases
- styling: No StyleManager singletons, no helper methods
- config merging: No merge helpers, no fallback merging
- streaming backend: No abstract methods, no override behavior
- streaming protocol: No fallback parsing, no .get() defaults
- dimensions: No 6-param wrappers, no per-dimension helpers
- serializer: No old function wrappers, no context-specific registries
- compiler: No Dict[str,Any], no mutable plans, no per-step phases

All antipatterns show ❌ WRONG code with explanation of why it's wrong.
- No temporary compatibility shims
- No parallel implementations 'for safety'
- No batching multiple plans into one PR
- No feature flags for gradual rollout
- No 'clean up later' TODOs
- No tests for deprecated behavior

Principle: Every PR makes codebase strictly simpler. If line count goes up, you're doing it wrong.
- Use test_main[disk-ImageXpress-3d-multiprocessing-direct-none-none]
- Unit tests run in terminal, not saved to files
- Manual testing by user for streaming/UI
- Split object_state.py (2507 lines) into:
  - object_state_registry.py (1182 lines): ObjectStateRegistry singleton
  - object_state.py (1350 lines): FieldProxy + ObjectState
- Updated all 22 import statements across pyqt_gui
- Fixed indentation issues from sed replacement in 4 files
- Verified OpenHCS runs successfully
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

Comments