M11: Runner lifecycle surface (prepare/execute/finalize)

- Refactor ProcessingRunner.run() to delegate through lifecycle stages
- Add prepare(), execute(), finalize() with pass-through behavior
- Add test_runner_lifecycle_order contract test
- Preserve identical behavior; no API/CLI changes

Phase III — Runner & Service Boundary

Made-with: Cursor
This commit is contained in:
Michael Cahill 2026-03-11 23:38:17 -07:00
parent bc626a60b1
commit fb705fe646
5 changed files with 233 additions and 32 deletions

View file

@ -1,6 +1,7 @@
"""ProcessingRunner — unified execution entrypoint for Serena pipeline.
M10: Thin adapter around process_images_inner. No behavior changes.
M11: Lifecycle surface (prepare execute finalize). Pass-through behavior.
"""
@ -14,9 +15,24 @@ class ProcessingRequest:
class ProcessingRunner:
"""
Unified execution entrypoint for Serena processing pipeline.
M11: Exposes lifecycle stages for future instrumentation.
"""
def run(self, request):
"""Execute processing pipeline."""
"""Execute processing pipeline via lifecycle stages."""
state = self.prepare(request)
result = self.execute(state)
return self.finalize(state, result)
def prepare(self, request):
"""Lifecycle stage 1: prepare request. Pass-through in M11."""
return request
def execute(self, state):
"""Lifecycle stage 2: run processing. Delegates to process_images_inner."""
from modules.processing import process_images_inner
return process_images_inner(request.processing)
return process_images_inner(state.processing)
def finalize(self, state, result):
"""Lifecycle stage 3: finalize. Pass-through in M11."""
return result