Skip to content

Refactor pipeline mode handling with strategy pattern and harden retrieval imports#52

Draft
cursor[bot] wants to merge 2 commits intodevelopmentfrom
cursor/codebase-structural-improvements-0b51
Draft

Refactor pipeline mode handling with strategy pattern and harden retrieval imports#52
cursor[bot] wants to merge 2 commits intodevelopmentfrom
cursor/codebase-structural-improvements-0b51

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 13, 2026

Summary

  • Centralized runtime mode validation in src/config.py using a single _read_mode() path and explicit allowed mode sets.
  • Added a pipeline Strategy + Factory in src/core/pipeline/mode_strategy.py and reused it from both ingestion entry points.
  • Replaced duplicated pipeline_mode branching in src/workers/tasks/ingestion.py and src/core/saving/auto_kg.py with strategy dispatch.
  • Removed duplicated model mode constants by reusing MODEL_MODES from config in src/core/instances.py.
  • Hardened retrieve controller import behavior by deferring heavy imports (kg_agent, NER extractor) to function scope to reduce import-time failure points.
  • Stabilized architecture test stubs to match the retrieve controller surface.

Design Patterns Applied

  • Strategy: PipelineModeStrategy implementations for lightweight and accurate behavior.
  • Factory Method: PipelineModeStrategyFactory.create() selects strategy by mode.

Tests

  • Added tests/test_config_pipeline_mode_refactors.py covering:
    • mode validation and defaults (PIPELINE_MODE, OCR_MODE, AGENTIC_ARCHITECTURE)
    • strategy factory behavior and invalid mode rejection
    • integration assertions that ingestion and auto-kg use strategy dispatch
  • Full suite run:
    • python3 -m pytest -q
    • Result: 52 passed, 1 warning

Commits

  • 5dc8549 Refactor pipeline mode handling with strategy factory
  • 4db81d7 Defer heavy retrieve imports and stabilize architecture stubs
Open in Web View Automation 

cursoragent and others added 2 commits April 13, 2026 08:08
Co-authored-by: Christian <ChrisCoder9000@users.noreply.github.com>
Co-authored-by: Christian <ChrisCoder9000@users.noreply.github.com>
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