mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(orchestrator): task-scoped oscillation breaker for escalate/unblock ping-pong (#685)
* fix(orchestrator): task-scoped oscillation breaker for escalate/unblock ping-pong An escalation ping-pong oscillates a task between two agents (cell PM escalate_up -> BLOCKED -> main PM unblock -> restored -> respawn -> escalate again). The per-(agent, task) respawn gate never trips on it: the restored side is dispatched by _dispatch_claimed_without_agent, which consults no respawn counter at all, so one side of the round trip always has fuel regardless of the other's strikes — and even a tripped main-PM counter only stalls the task silently at blocked instead of surfacing the oscillation. - Strikes are counted task-scoped at the unblock() chokepoint (agent-agnostic; legitimate needs_revision rework never calls unblock, so it structurally cannot trip this), durable in the existing orchestration_markers column — no migration. - Progress between round-trips (commits / revision_count advancing) resets the count: real forward motion is not an oscillation. - On trip: the task is blocked with a HUMAN resolver (the budget-breach posture), both dispatchers stop respawning onto it, further unblock() refuses until an admin override clears the marker, and the CEO notification names both agents and the cycle count. - _notification_has_live_work now treats a HITL-blocked related task as no live work, closing the same loop for the admin-route escalation path. * fix(orchestrator): wire the oscillation trip to the dispatchers and make recovery reachable - TaskResponse serializes blocker_resolver_type: the dispatchers' HITL-blocked skip and the notification-path live-work check now actually fire over the wire instead of only against in-process rows. - The oscillation marker clears on every human transition out of BLOCKED (snapshot or not), and the human unblock route treats a tripped task as the requested intervention: clears the marker and proceeds, while the agent gateway verb keeps refusing. - The progress fingerprint includes the terminal-children count, so a coordination root whose children advanced between escalations resets instead of accruing toward a false trip. --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ from roboco.foundation.policy.content import markers as m
|
||||
|
||||
# Named constant — ruff PLR2004 forbids magic-value comparisons.
|
||||
_TWO = 2
|
||||
_THREE = 3
|
||||
|
||||
|
||||
def _task(om: dict | None = None) -> SimpleNamespace:
|
||||
@@ -155,3 +156,47 @@ def test_block_flip_count_bump_and_notify() -> None:
|
||||
assert m.is_block_flip_notified(t) is True
|
||||
# Marking notified must not reset the counter.
|
||||
assert m.get_block_flip_count(t) == _TWO
|
||||
|
||||
|
||||
def test_oscillation_strikes_accrue_on_unchanged_fingerprint() -> None:
|
||||
t = _task()
|
||||
assert m.get_oscillation_strikes(t) == 0
|
||||
assert m.is_oscillation_tripped(t) is False
|
||||
assert m.bump_oscillation_strikes(t, [0, 0]) == 1
|
||||
assert m.bump_oscillation_strikes(t, [0, 0]) == _TWO
|
||||
assert m.bump_oscillation_strikes(t, [0, 0]) == _THREE
|
||||
assert m.get_oscillation_strikes(t) == _THREE
|
||||
assert m.is_oscillation_tripped(t) is False
|
||||
|
||||
|
||||
def test_oscillation_strikes_reset_on_progress() -> None:
|
||||
t = _task()
|
||||
m.bump_oscillation_strikes(t, [0, 0])
|
||||
assert m.bump_oscillation_strikes(t, [0, 0]) == _TWO
|
||||
# A new commit landed between rounds — real progress resets to 1.
|
||||
assert m.bump_oscillation_strikes(t, [1, 0]) == 1
|
||||
# A revision round completing is progress too.
|
||||
assert m.bump_oscillation_strikes(t, [1, 0]) == _TWO
|
||||
assert m.bump_oscillation_strikes(t, [1, 1]) == 1
|
||||
|
||||
|
||||
def test_mark_oscillation_tripped_preserves_strikes_and_fingerprint() -> None:
|
||||
t = _task()
|
||||
m.bump_oscillation_strikes(t, [2, 1])
|
||||
m.bump_oscillation_strikes(t, [2, 1])
|
||||
m.mark_oscillation_tripped(t)
|
||||
assert m.is_oscillation_tripped(t) is True
|
||||
assert m.get_oscillation_strikes(t) == _TWO
|
||||
# tripped survives a subsequent bump (belt-and-suspenders — the guard is
|
||||
# meant to refuse before another bump ever happens).
|
||||
m.bump_oscillation_strikes(t, [2, 1])
|
||||
assert m.is_oscillation_tripped(t) is True
|
||||
|
||||
|
||||
def test_clear_marker_removes_oscillation_state() -> None:
|
||||
t = _task()
|
||||
m.bump_oscillation_strikes(t, [0, 0])
|
||||
m.mark_oscillation_tripped(t)
|
||||
m.clear_marker(t, m.OSCILLATION_STRIKES)
|
||||
assert m.get_oscillation_strikes(t) == 0
|
||||
assert m.is_oscillation_tripped(t) is False
|
||||
|
||||
Reference in New Issue
Block a user