feat: dual-run config file, bulk writeback, writeback_push

RMGR-WP-0003: load ~/.repo-manager/dual-run.yaml; bulk-status-sync uses
RM writeback; optional push after writeback when configured.
This commit is contained in:
tegwick 2026-08-11 02:32:15 +02:00
parent cb6eddf92b
commit 71c94c940a
2 changed files with 120 additions and 22 deletions

View file

@ -169,6 +169,8 @@ async def bulk_status_sync(
updated: list[Task] = []
events: list[ProgressEvent] = []
author = body.author or "custodian"
# Cache repo resolution for dual-run writeback (RMGR-WP-0003)
repo_cache: dict = {}
for update in body.updates:
task = tasks_by_id[update.task_id]
previous_status = status_value(task.status)
@ -182,6 +184,32 @@ async def bulk_status_sync(
parent_workstream=ws,
previous_task_status=previous_status,
)
if target_status != previous_status:
try:
from api.models.managed_repo import ManagedRepo
from api.services.repo_manager_dual_run import try_writeback_for_task
from api.services.workplan_files import resolve_repo_path
repo_id = ws.repo_id if ws else None
if repo_id is not None:
if repo_id not in repo_cache:
repo_cache[repo_id] = await session.get(ManagedRepo, repo_id)
repo = repo_cache[repo_id]
if repo is not None:
try_writeback_for_task(
repo_path=resolve_repo_path(repo),
repo_slug=repo.slug,
task_id=str(task.id),
status=target_status,
reason="state-hub bulk-status-sync dual-run",
)
except Exception:
import logging
logging.getLogger(__name__).exception(
"repo-manager dual-run bulk writeback failed for task %s",
update.task_id,
)
event = ProgressEvent(
task_id=task.id,
workplan_id=task.workplan_id,