Skip to content

Backend Refactor Summary

Context

This summary captures the recent backend/state-engine refactor work and the follow-on fixes needed to stabilize the test suite. It documents the key changes and the commits involved so future contributors can trace the rationale and scope.

Commits Covered

  • e760a1ce - refactor: consolidate state engine
  • bd30ecf9 - fix: unblock full test run

What Changed

1) Unified State Engine

  • Consolidated transactional and enhanced state engine behavior into the core StateEngine implementation.
  • Removed legacy engine subclasses and updated call sites to use feature flags.
  • Introduced enum-based feature flags (StateEngineFeature) to avoid stringly-typed feature requests.

2) Structured Backend Configuration

  • Added typed backend configuration dataclasses for local, S3, and PostgreSQL backends.
  • Added BackendType enum to standardize backend selection.
  • Updated factory and hybrid execution paths to accept BackendType + config objects (or a backend instance) instead of string/dict pairs.

3) Test Suite Alignment

  • Updated tests to use the unified API and feature enums.
  • Updated hybrid execution API tests to patch create_state_engine rather than LocalStateBackend inside the hybrid module.
  • Adjusted provider loader tests to respect the provider cache directory setting when set (now provider_cache_dir, a flag and [tool.nf.config] key; integration tests set it per worker).

4) Transaction Safety Fix

  • Fixed transaction commit/rollback to apply changes directly to the in-memory state instead of re-entering resource locks via update_resource_state, which could deadlock the test suite.

Files Touched (Highlights)

  • libs/netherframe.core/netherframe/core/backends/state_engine.py
  • libs/netherframe.core/netherframe/core/backends/state_engine_factory.py
  • libs/netherframe.core/netherframe/core/hybrid_execution.py
  • libs/netherframe.core/netherframe/core/phases/executor.py
  • libs/netherframe.core/netherframe/core/orchestration/unified_orchestrator.py
  • libs/netherframe.core/tests/test_hybrid_execution_api.py
  • libs/netherframe.core/tests/test_provider_loader.py
  • Docs updated under docs/core/ and docs/guides/ to reflect the new API

Testing

  • uv run poe test-all
  • uv run poe test-all-full