chore(consistency): sync task status from DB [auto]

Updated by fix-consistency on 2026-09-04:
  - update .custodian-brief.md for rein-aharness

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a06ba0-10aa-7ea0-b20a-4f3fac39efe9
This commit is contained in:
custodian-sync 2026-09-04 11:00:20 +02:00
parent 7641fcde40
commit f01b765668
20 changed files with 1027 additions and 165 deletions

View file

@ -17,6 +17,13 @@ from pathlib import Path
from typing import Any
from rein_aharness.ops_run_client import OpsRun, OpsRunConfig, resolve_ops_target
from rein_aharness.repository_transaction import (
DirtyRepositoryError,
GitRepositoryError,
RepositoryBusyError,
RepositoryTransaction,
RepositoryTransactionError,
)
from rein_aharness.taskspec import TaskSpecError
# Approach command names (stable; used in metrics + ops_run.result)
@ -188,7 +195,7 @@ def execute_approach(
reopen=False,
)
try:
def _dispatch(tx: RepositoryTransaction | None) -> ApproachResult:
if name == APPROACH_FI_RESEARCH_BRIEF:
return _run_fi(target, report_to_hub=report_to_hub, commit=commit)
if name == APPROACH_BRIEF_DAILY:
@ -204,7 +211,53 @@ def execute_approach(
target, report_to_hub=report_to_hub, commit=commit
)
if name == APPROACH_AGENT_SESSION:
return _run_agent_session(run, target, report_to_hub=report_to_hub)
return _run_agent_session(
run, target, report_to_hub=report_to_hub, transaction=tx
)
return ApproachResult(
ok=False,
approach=name,
reason=f"approach not implemented: {name}",
reopen=False,
)
if name == APPROACH_AGENT_SESSION:
try:
return _dispatch(None)
except Exception as exc: # noqa: BLE001 — surface as fail ops_run
return ApproachResult(
ok=False,
approach=name,
reason=f"{type(exc).__name__}: {exc}",
reopen=True,
)
try:
with RepositoryTransaction(target, correlation_id=run.id) as tx:
result = _dispatch(tx)
result.result["repository_transaction"] = tx.evidence()
return result
except DirtyRepositoryError as exc:
return ApproachResult(
ok=False,
approach=name,
reason=f"refused: {exc}",
reopen=False,
)
except RepositoryBusyError as exc:
return ApproachResult(
ok=False,
approach=name,
reason=f"refused: {exc}",
reopen=True,
)
except (GitRepositoryError, RepositoryTransactionError) as exc:
return ApproachResult(
ok=False,
approach=name,
reason=f"refused: {exc}",
reopen=False,
)
except Exception as exc: # noqa: BLE001 — surface as fail ops_run
return ApproachResult(
ok=False,
@ -213,14 +266,6 @@ def execute_approach(
reopen=True,
)
return ApproachResult(
ok=False,
approach=name,
reason=f"approach not implemented: {name}",
reopen=False,
)
def _run_fi(target: Path, *, report_to_hub: bool, commit: bool) -> ApproachResult:
from rein_aharness.fi_research_brief import run_fi_research_brief
@ -360,7 +405,11 @@ def _run_mail_pipeline(
def _run_agent_session(
run: OpsRun, target: Path, *, report_to_hub: bool
run: OpsRun,
target: Path,
*,
report_to_hub: bool,
transaction: RepositoryTransaction | None = None,
) -> ApproachResult:
from rein_aharness.ops_run_client import ops_run_to_taskspec
from rein_aharness.runner import run_task
@ -384,16 +433,19 @@ def _run_agent_session(
)
# target already resolved into TaskSpec
assert spec.target_repo == target or True
r = run_task(spec, report_to_hub=report_to_hub)
r = run_task(spec, report_to_hub=report_to_hub, transaction=transaction)
result = {
"committed": r.committed,
"head_after": r.head_after,
"tool_profile": r.tool_profile,
"tokens_spent": r.tokens_spent,
}
if r.transaction:
result["repository_transaction"] = r.transaction
return ApproachResult(
ok=r.ok,
approach=APPROACH_AGENT_SESSION,
result={
"committed": r.committed,
"head_after": r.head_after,
"tool_profile": r.tool_profile,
"tokens_spent": r.tokens_spent,
},
result=result,
reason=r.reason,
reopen=not r.ok,
)