Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ async def test_compose_prompt_orchestration_all_advisory_blocks(
assert token in out


def test_research_scout_seed_block_keeps_all_rounds(coord: Coordinator) -> None:
def test_research_scout_seed_block_keeps_findings_and_questions_only(coord: Coordinator) -> None:
from hyperloom.orchestrator.knowledge import research_hints

research_hints.append_hints(
Expand Down Expand Up @@ -1410,11 +1410,14 @@ def test_research_scout_seed_block_keeps_all_rounds(coord: Coordinator) -> None:

assert "hint one" in block
assert "hint two" in block
assert '"name": "first"' in block
assert '"name": "second"' in block
assert "question one" in block
assert "question two" in block
assert "ignore-me" not in block
# Proposals moved to the shared untested-proposal queue, which also drops
# the ones already benched; rendering them here as well would double them.
assert "Untested executable proposals" not in block
assert '"name": "first"' not in block
assert '"name": "second"' not in block


@pytest.mark.asyncio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2073,10 +2073,16 @@ def _build_specialist_prompt_text() -> str:
return system_prompt + "\n" + user_prompt


def test_specialist_prompt_renders_top_6_target():
def test_specialist_prompt_renders_proposal_target_and_ceiling():
text = _build_specialist_prompt_text()
assert "AT MOST **6** entries" in text
assert "top-6" in text
# Section 8 states both numbers; Section 1 repeats them so the target is
# visible before the specialist starts working, not only at exit time.
assert "**2 entries is the norm, 4 the hard cap.**" in text
assert "**2 proposals is the norm, 4 the hard" in text
# Both the padding and the keep-going pressures need a stated counterweight.
assert "``empty=true`` is better than one" in text
assert "stop once" in text and "not the only stop" in text
assert "a coin-flip proposal is worse than none" in text
assert "reviews each surviving variant" in text


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

"""The grid author's two prompt surfaces agree on where a grid comes from and how big it gets."""

from __future__ import annotations


def _grid_prompt_surfaces() -> list[str]:
from hyperloom.orchestrator.prompts.prompt_builder import (
_idea_generation_lines,
_format_grid_injection_hint,
)

return [_format_grid_injection_hint("explore") or "", "\n".join(_idea_generation_lines())]


def test_both_grid_surfaces_state_the_same_target_and_ceiling():
for surface in _grid_prompt_surfaces():
assert "4" in surface
assert "maximum 6" in surface
assert all("Untested proposals (current cycle)" in s for s in _grid_prompt_surfaces()[1:])


def test_the_stale_proposal_set_wording_is_gone():
from pathlib import Path

from hyperloom.orchestrator.prompts import prompt_builder

stale = "proposal_set drives the next"
assert stale not in Path(prompt_builder.__file__).read_text(encoding="utf-8")
md = Path(prompt_builder.__file__).parent / "orchestration.md"
assert "specialist proposal_set" not in md.read_text(encoding="utf-8")
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# SPDX-FileCopyrightText: 2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT

"""Shared proposal/variant identity.

The fingerprints below were captured from the explore executor's own identity
block before it was refactored onto this helper. They are pinned rather than
recomputed: a change here re-keys ``explore_search["tested"]``, so every
resumed session would re-bench its whole history.
"""

from __future__ import annotations

import pytest

from hyperloom.orchestrator.actions.executors._proposal_identity import (
controls_of,
effective_fingerprint,
is_executable,
normalize_proposal,
)


# (label, extra_args, extra_envs, variant controls, base controls, expected fingerprint)
_GOLDEN = [
("plain", "--max-num-seqs 128", {"A": "1"}, ([], [], "append"), ([], [], ""), "caacd6bf1da76201"),
("variant-only", "--max-num-seqs 128", {"A": "1"}, (["--x"], ["E"], "append"), ([], [], ""), "39cfaf303d04885d"),
("base-only", "--max-num-seqs 128", {"A": "1"}, ([], [], "append"), (["--b"], ["BE"], ""), "e85521a43890c743"),
("both", "--max-num-seqs 128", {"A": "1"}, (["--x"], ["E"], "append"), (["--b"], ["BE"], ""), "1e630973fad523ab"),
("overlap", "--max-num-seqs 128", {}, (["--b"], [], "append"), (["--b"], [], ""), "9cb8463804e7a11c"),
("variant-replace", "", {"A": "1"}, ([], [], "replace"), ([], [], ""), "7f4d4d32a84df525"),
("base-replace", "", {"A": "1"}, ([], [], "append"), ([], [], "replace"), "7f4d4d32a84df525"),
("removal-only", "", {}, (["--enable-prefix-caching"], [], "append"), ([], [], ""), "ca4d2e9e9760543a"),
("empty", "", {}, ([], [], "append"), ([], [], ""), "164374825086dc65"),
]


def _controls(remove_args, unset_envs, args_mode) -> dict:
return controls_of(
normalize_proposal({"remove_args": remove_args, "unset_envs": unset_envs, "args_mode": args_mode})
)


@pytest.mark.parametrize(
"args,envs,variant,base,expected",
[row[1:] for row in _GOLDEN],
ids=[row[0] for row in _GOLDEN],
)
def test_effective_fingerprint_matches_the_pinned_executor_values(args, envs, variant, base, expected):
b_remove, b_unset, b_mode = base
assert (
effective_fingerprint(
args,
envs,
controls=_controls(*variant),
base_remove_args=b_remove,
base_unset_envs=b_unset,
base_args_mode=b_mode,
)
== expected
)


def test_base_controls_change_the_fingerprint():
controls = _controls(["--x"], [], "append")
assert effective_fingerprint("--a 1", {}, controls=controls) != effective_fingerprint(
"--a 1", {}, controls=controls, base_remove_args=["--b"]
)


def test_removal_union_is_base_first_and_deduped():
both = effective_fingerprint("", {}, controls=_controls(["--b", "--v"], [], "append"), base_remove_args=["--b"])
assert both == effective_fingerprint("", {}, controls=_controls(["--b", "--v"], [], "append"))


@pytest.mark.parametrize(
"proposal,expected",
[
({"extra_args": "--a 1"}, True),
({"extra_server_args": "--a 1"}, True),
({"extra_envs": {"A": "1"}}, True),
({"remove_args": ["--a"]}, True),
({"unset_envs": ["A"]}, True),
({"args_mode": "replace"}, True),
({"name": "research-only", "reason": "read the scheduler"}, False),
({"extra_args": " ", "extra_envs": {}}, False),
],
)
def test_is_executable(proposal, expected):
assert is_executable(normalize_proposal(proposal)) is expected


def test_normalize_resolves_the_args_alias_and_keeps_atomic():
fields = normalize_proposal(
{
"name": " coupled ",
"extra_server_args": " --a 1 ",
"extra_envs": {"A": 1},
"remove_args": "--drop",
"args_mode": "REPLACE",
"atomic": True,
"reason": "needs the paired headroom",
}
)
assert fields == {
"name": "coupled",
"extra_args": "--a 1",
"extra_envs": {"A": "1"},
"remove_args": ["--drop"],
"unset_envs": [],
"args_mode": "replace",
"atomic": True,
"reason": "needs the paired headroom",
}


def test_controls_of_drops_defaults():
assert controls_of(normalize_proposal({"extra_args": "--a 1"})) == {}
assert controls_of(normalize_proposal({"remove_args": ["--x"], "args_mode": "replace"})) == {
"remove_args": ["--x"],
"args_mode": "replace",
}
Loading
Loading