Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d2d82cf
refactor(orchestrator): render full inbox batch, drop compaction bypa…
ZhengGong-amd Jul 29, 2026
6f127ee
refactor(policy): drop the free-form red-line scan
ZhengGong-amd Jul 30, 2026
b641abb
refactor(policy): remove the specialist_done validation path
ZhengGong-amd Jul 30, 2026
140e868
refactor(policy): observe rather than deny soft specialist dispatch s…
ZhengGong-amd Jul 30, 2026
7eeceb1
refactor(state): drop unreachable task-registry surface
ZhengGong-amd Jul 30, 2026
ca46bcd
feat(orchestrator): show specialist health to orchestration
ZhengGong-amd Jul 30, 2026
562b9ac
docs: drop references to the removed dispatch rules
ZhengGong-amd Jul 30, 2026
4de16b0
feat(orchestrator): make specialist failures visible in the inbox line
ZhengGong-amd Jul 30, 2026
ebce3a5
feat(orchestrator): report abandoned retries and expose in-flight tasks
ZhengGong-amd Jul 30, 2026
be9f83c
feat(orchestrator): render the GPU pool and lane capacities
ZhengGong-amd Jul 30, 2026
44b55ee
feat(orchestrator): let orchestration reap work it dispatched
ZhengGong-amd Jul 30, 2026
2893687
feat(orchestrator): add extend_lease so live work can outrun its TTL
ZhengGong-amd Jul 30, 2026
10c6594
feat(specialists): wire the two-way channel to a running specialist
ZhengGong-amd Jul 30, 2026
ac5ad43
fix(orchestrator): repair gaps found reviewing the instrumentation batch
ZhengGong-amd Jul 30, 2026
c9e14e9
refactor(orchestrator): drop defensive scaffolding from the new instr…
ZhengGong-amd Jul 30, 2026
e59e9f6
refactor(specialists): simplify proposal curation target
ZhengGong-amd Jul 30, 2026
f9e453d
fix(specialists): make rebench cleanup-safe
ZhengGong-amd Jul 30, 2026
ccd25f6
docs(specialists): align GPU and source-root guidance
ZhengGong-amd Jul 30, 2026
7ee7fd0
fix(runtime): preserve launch context and model metadata
ZhengGong-amd Jul 30, 2026
8c31e32
Merge remote-tracking branch 'origin/main' into feat/zgong/explore-op…
ZhengGong-amd Jul 30, 2026
be5b81a
chore: exclude temporary review notes
ZhengGong-amd Jul 30, 2026
cd5c8d3
chore: ignore temporary review notes
ZhengGong-amd Jul 30, 2026
0491edb
style: remove trailing blank line
ZhengGong-amd Jul 30, 2026
762a844
fix(orchestrator): drop the specialist block that never saw a specialist
ZhengGong-amd Jul 31, 2026
22c51db
test(orchestrator): cover the reader that now carries specialist visi…
ZhengGong-amd Jul 31, 2026
acad691
fix(orchestrator): make extend_lease actually extend the work it names
ZhengGong-amd Jul 31, 2026
9fc0905
Merge origin/main into feat/zgong/explore-opt-11
ZhengGong-amd Jul 31, 2026
8f1ab9d
test(orchestrator): exercise the extend_lease reaper path, not just i…
ZhengGong-amd Jul 31, 2026
6eb7319
test(orchestrator): lift coverage over the CI gate
ZhengGong-amd Aug 1, 2026
379eb89
fix(orchestrator): preserve late lease extensions
ZhengGong-amd Aug 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/hyperloom/agents/robustness/role/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class IntentType(str, Enum):
RESPONSE = "response"
REVIEW_VERDICT = "review_verdict"
KILL_TASK = "kill_task"
# Robustness never emits this; kept in the mirror for the contract test.
EXTEND_LEASE = "extend_lease"
PRUNE_BRANCH = "prune_branch"
ESCALATE_STRATEGY_CHANGE = "escalate_strategy_change"
# Robustness never emits this; kept in the mirror for the contract test.
Expand Down Expand Up @@ -739,14 +741,15 @@ class IntentSpec:
# Required-field map for intents robustness never emits but the upstream
# contract test still diffs against. No builder/validator: they are here only
# to keep :data:`PAYLOAD_REQUIRED` byte-equal with upstream ``_PAYLOAD_REQUIRED``.
# ``SPECIALIST_DONE`` is the specialist exit envelope (PolicyGate R3 validates
# it); ``REVIEW_VERDICT`` enforces only the structural ``target_proposal_msg_id``
# here (verdict/verdict_map mutual exclusion lives in upstream policy).
# ``SPECIALIST_DONE`` is the specialist exit envelope; ``REVIEW_VERDICT``
# enforces only the structural ``target_proposal_msg_id`` here
# (verdict/verdict_map mutual exclusion lives in upstream policy).
_REQUIRED_ONLY: Mapping[IntentType, tuple[str, ...]] = {
IntentType.PROPOSE_ACTION: ("action_name", "predicted_gain_pct"),
IntentType.REQUEST: ("target_agent", "kind"),
IntentType.RESPONSE: ("in_reply_to", "kind"),
IntentType.REVIEW_VERDICT: ("target_proposal_msg_id",),
IntentType.EXTEND_LEASE: ("task_id", "extra_sec"),
IntentType.SPECIALIST_DONE: (
"gap_canonical_id",
"domain",
Expand Down
6 changes: 4 additions & 2 deletions src/hyperloom/inference_optimizer/protocol/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class IntentType(str, Enum):
REQUEST = "request"
RESPONSE = "response"
REVIEW_VERDICT = "review_verdict" # Critic-only
KILL_TASK = "kill_task" # Robustness-only; payload.scope must be "task"
KILL_TASK = "kill_task" # payload.scope must be "task"
EXTEND_LEASE = "extend_lease" # refresh a live task's lease TTL
# Robustness-only scheduling police.
PRUNE_BRANCH = "prune_branch"
ESCALATE_STRATEGY_CHANGE = "escalate_strategy_change"
Expand Down Expand Up @@ -61,9 +62,10 @@ class Intent:
# verdict/verdict_map mutual exclusion enforced by _validate_review_verdict_payload.
IntentType.REVIEW_VERDICT: ("target_proposal_msg_id",),
IntentType.KILL_TASK: ("task_id", "reason"),
IntentType.EXTEND_LEASE: ("task_id", "extra_sec"),
IntentType.PRUNE_BRANCH: ("family", "reason"),
IntentType.ESCALATE_STRATEGY_CHANGE: ("reason", "next_action_hint"),
# specialist exit envelope; per-variant schema enforced by PolicyGate R3.
# specialist exit envelope; the runner re-stamps and defaults the payload.
IntentType.SPECIALIST_DONE: ("gap_canonical_id", "domain", "proposal_set", "empty", "summary"),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_orchestration_permissions():
assert IntentType.PRUNE_BRANCH in role.allowed_intents
assert IntentType.ESCALATE_STRATEGY_CHANGE in role.allowed_intents
assert IntentType.REVIEW_VERDICT not in role.allowed_intents
assert IntentType.KILL_TASK not in role.allowed_intents
assert IntentType.KILL_TASK in role.allowed_intents
assert IntentType.RESPONSE not in role.allowed_intents


Expand Down Expand Up @@ -123,7 +123,7 @@ def test_review_verdict_critic_only():


def test_kill_and_robustness_only_renamed():
assert KILL_TASK_SOURCE_ALLOWLIST == frozenset({"robustness"})
assert KILL_TASK_SOURCE_ALLOWLIST == frozenset({"robustness", "orchestration"})
assert ROBUSTNESS_ONLY_SOURCE_ALLOWLIST == frozenset({"robustness"})
assert ROBUSTNESS_ONLY_INTENTS == frozenset(
{
Expand Down Expand Up @@ -527,16 +527,26 @@ def test_gate_robustness_kill_task_ok(gate):
)


def test_gate_orchestration_kill_task_rejected(gate):
def test_gate_orchestration_kill_task_allowed(gate):
gate.validate_intent(
"orchestration",
Intent(
type=IntentType.KILL_TASK,
payload={"task_id": "t1", "reason": "stalled"},
),
)


def test_gate_orchestration_kill_task_process_scope_rejected(gate):
with pytest.raises(PolicyDenied) as exc:
gate.validate_intent(
"orchestration",
Intent(
type=IntentType.KILL_TASK,
payload={"task_id": "t1", "reason": "stalled"},
payload={"task_id": "t1", "reason": "stalled", "scope": "process"},
),
)
assert exc.value.rule == "role"
assert exc.value.rule == "kill_scope"


def test_gate_robustness_kill_task_process_scope_rejected(gate):
Expand Down
20 changes: 0 additions & 20 deletions src/hyperloom/inference_optimizer/tests/test_common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,26 +2429,6 @@ def test_llm_prompt_parse_response_edges() -> None:
assert parse_llm_response("[]") == {"executive_summary": "", "section_narratives": {}}


# ---------------------------------------------------------------------------
# orchestrator.state.orchestration_memory.deterministic_memory_fallback
# ---------------------------------------------------------------------------


def test_deterministic_memory_fallback_bad_gain() -> None:
from hyperloom.orchestrator.state.orchestration_memory import deterministic_memory_fallback

state = SimpleNamespace(
current_best={"tput": 123.0},
optimization_stack=[],
cumulative_gain_validated="not-a-number",
phase="EXPLORE",
macro_cycle=2,
)
record = deterministic_memory_fallback(state)
assert "current_plan" in record
assert "phase=EXPLORE" in record["current_plan"]


# ---------------------------------------------------------------------------
# orchestrator.specialists.profile
# ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,6 @@ class _Policy:
def should_checkpoint(self, **kw):
return False

def is_hard_compaction(self, n):
return False

coord._checkpoint_policy = _Policy()
assert await coord._maybe_checkpoint_orchestration(tick=5) is False

Expand All @@ -820,9 +817,6 @@ class _Policy:
def should_checkpoint(self, **kw):
return True

def is_hard_compaction(self, n):
return False

coord._checkpoint_policy = _Policy()
took = await coord._maybe_checkpoint_orchestration(tick=12, phase_changed=True)
assert took is True
Expand Down Expand Up @@ -863,7 +857,6 @@ async def _run(**kw):
def test_checkpoint_policy_context_fraction_env(tmp_path, monkeypatch) -> None:
monkeypatch.setenv("USER_DATA_PATH", str(tmp_path))
monkeypatch.setenv("INFERENCE_OPTIMIZER_CTX_SOFT_FRACTION", "0.5")
monkeypatch.setenv("INFERENCE_OPTIMIZER_CTX_HARD_FRACTION", "0.75")
sd = make_session_dir()
from .conftest import seed_target_analysis_marker

Expand All @@ -872,7 +865,6 @@ def test_checkpoint_policy_context_fraction_env(tmp_path, monkeypatch) -> None:
backends["orchestration"].model = "claude-opus-4-8" # type: ignore[attr-defined]
c = Coordinator(sd, backends=backends)
assert c._checkpoint_policy.context_token_soft == 100_000
assert c._checkpoint_policy.context_token_hard == 150_000


def test_orchestration_memory_rollback_env(tmp_path, monkeypatch) -> None:
Expand Down Expand Up @@ -901,9 +893,6 @@ class _Policy:
def should_checkpoint(self, **kw):
return True

def is_hard_compaction(self, n): # default: not hard
return False

coord._checkpoint_policy = _Policy()


Expand Down Expand Up @@ -947,30 +936,6 @@ async def test_checkpoint_degenerate_three_times_emits_medium_observation(coord:
assert any(p.get("severity") == "medium" and p.get("consecutive") == 3 for p in degraded)


@pytest.mark.asyncio
async def test_checkpoint_degenerate_hard_uses_fallback(coord: Coordinator) -> None:
import time

_make_conversational(coord, raw_text="still no JSON")
coord._checkpoint_enabled = True
coord._orchestration_seeded = True
coord._run_started_monotonic = time.monotonic()
coord.shared_state.phase = "EXPLORE"

class _Policy:
def should_checkpoint(self, **kw):
return True

def is_hard_compaction(self, n): # near the window → force
return True

coord._checkpoint_policy = _Policy()
took = await coord._maybe_checkpoint_orchestration(tick=20)
assert took is True
assert coord._orchestration_seeded is False
assert coord.shared_state.orchestration_memory.get("current_plan", "").startswith("[auto]")


@pytest.mark.asyncio
async def test_checkpoint_failure_resets_tracker(coord: Coordinator) -> None:
import time
Expand Down Expand Up @@ -1712,7 +1677,6 @@ async def test_handle_intent_routes_rare_types(coord: Coordinator, monkeypatch)
IntentType.PRUNE_BRANCH: "_handle_prune_branch",
IntentType.ALERT: "_handle_alert",
IntentType.UPDATE_STATE: "_handle_update_state",
IntentType.SPECIALIST_DONE: "_handle_specialist_done",
}
for it, attr in routes.items():

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
from types import SimpleNamespace


# --------------------------------------------------------------------------- #
# orchestrator.orchestration_memory.deterministic_memory_fallback #
# --------------------------------------------------------------------------- #
def test_deterministic_memory_fallback_bad_gain() -> None:
from hyperloom.orchestrator.state.orchestration_memory import deterministic_memory_fallback

state = SimpleNamespace(
current_best={"tput": 123.0},
optimization_stack=[],
cumulative_gain_validated="not-a-number", # triggers except
phase="EXPLORE",
macro_cycle=2,
)
record = deterministic_memory_fallback(state)
assert "current_plan" in record
assert "phase=EXPLORE" in record["current_plan"]


# --------------------------------------------------------------------------- #
# orchestrator.specialist_profile #
# --------------------------------------------------------------------------- #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ async def _stub(_ctx) -> dict:
assert executed["ran"] is False
updated = await sub.tasks.get(task.task_id)
assert updated.state == "cancelled"
assert updated.attempts == 0


@pytest.mark.asyncio
Expand Down Expand Up @@ -319,7 +318,6 @@ async def _stub(_ctx) -> dict:
assert executed["ran"] is True
updated = await tasks2.get(task_id)
assert updated.state == "succeeded"
assert updated.attempts == 1


class _ReconcileCoordStub:
Expand Down Expand Up @@ -498,3 +496,27 @@ async def _stub(_ctx) -> dict:
res = await sub.run_task(task)
assert res.state == "succeeded"
assert executed["ran"] is True


@pytest.mark.asyncio
async def test_killed_running_task_keeps_its_result(tmp_path, monkeypatch):
"""A task cancelled mid-flight still returns its executor result."""
sub = _runner_with_policy(tmp_path, monkeypatch)
task = await sub.tasks.create(
kind="report",
params={},
idempotency_key="k-kill-midflight",
)

async def _stub(ctx):
# Simulate a kill landing while the executor is still running.
await sub.tasks.transition(ctx.task.task_id, "cancelled", evidence={"reason": "killed"})
return {"produced": "work"}

sub.register_executor("report", _stub)

res = await sub.run_task(task)
assert res.state == "succeeded"
assert res.result == {"produced": "work"}
updated = await sub.tasks.get(task.task_id)
assert updated.state == "cancelled"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
CheckpointTracker,
build_memory_record,
context_window_for_model,
deterministic_memory_fallback,
is_degenerate_checkpoint,
parse_checkpoint_reply,
render_memory_for_seed,
Expand Down Expand Up @@ -246,14 +245,6 @@ def test_policy_context_token_soft_disabled_by_default():
)


def test_policy_is_hard_compaction():
p = CheckpointPolicy(context_token_hard=170_000)
assert p.is_hard_compaction(170_000)
assert not p.is_hard_compaction(169_999)
# Disabled (0) never fires.
assert not CheckpointPolicy().is_hard_compaction(10**9)


def test_tracker_set_context_tokens_and_reset_preserves_level():
t = CheckpointTracker()
t.set_context_tokens(123_456)
Expand Down Expand Up @@ -322,33 +313,6 @@ def test_build_memory_record_new_value_wins():
assert rec["learnings"] == ["L1", "L2"]


class _FakeState:
phase = "EXPLORE"
macro_cycle = 2
current_best = {"tput": 1234.5}
optimization_stack = [{"a": 1}, {"b": 2}]
cumulative_gain_validated = 12.34


def test_deterministic_memory_fallback_is_non_degenerate():
fb = deterministic_memory_fallback(_FakeState())
assert "EXPLORE" in fb["current_plan"]
assert "cycle=2" in fb["current_plan"]
assert "best_tput=1234.5" in fb["current_plan"]
assert "validated_gain=12.34%" in fb["current_plan"]
assert fb["tried_and_why"] == ["stack has 2 accepted change(s)"]
assert not is_degenerate_checkpoint(fb)


def test_deterministic_memory_fallback_missing_attrs():
class _Empty:
pass

fb = deterministic_memory_fallback(_Empty())
# Never raises; yields a usable record.
assert fb["current_plan"].startswith("[auto]")


# ---- next_cycle_directive: parse, sanitize, carry-forward ----


Expand Down
Loading
Loading