mirror of
https://github.com/razzant/ouroboros.git
synced 2026-10-03 04:07:04 +00:00
Classify complete tool observations before dismissing a retired hidden turn. Show late proven work through the existing card projection with its recorded outcome and cost. Preserve an existing terminal card under metadata-less late starts; reuse the terminal predicate with the metrics lifecycle axis, since metrics do not carry the authored-message terminal-status field. Keep live metrics nonterminal and old/incomplete addressing aggregates hidden. Remove only the dead promoted_task_toolset router branch and SW1 script role from the keyless rehearsal. Exercise its actual managed-root loopback request and preserve repeatable child/probe final templates. This is the root-approved S1/S2 batch after review of8416d944. Native focused verification caught and resolved D1/D2 within this batch; their red receipts remain preserved. Protected size_ratchet_manifest.py was regenerated with the standard script: chat.js205675 to205673 only, with no baseline expansion. Validation:125sharedJS tests and132independentJS/probes pass;78focusedPython checks plus2SM1unit controls pass, including docs/BIBLE and both real ratchet nodes. Final ratchet delta and Ruff F pass. Full SM1 rehearsal was not rerun. Exact final model reviews and browser delta follow this immutable checkpoint; root retains composition, joint live cognitive workflow and public delivery. (cherry picked from commit b52b4c0898258132d3a2656eae6fa6b4d8871918)
53 lines
2.8 KiB
Python
53 lines
2.8 KiB
Python
"""Keyless SW1 wire starts at its managed root; reusable terminal templates survive."""
|
|
import json
|
|
from pathlib import Path
|
|
import urllib.request
|
|
|
|
import pytest
|
|
|
|
from devtools.e2e_live.scenarios import SW1_OBJECTIVE, sw1_stub_script
|
|
from devtools.e2e_live.stub_lane import routed_stub_model, stub_settings
|
|
from ouroboros.context import build_user_content
|
|
|
|
|
|
@pytest.mark.serial
|
|
@pytest.mark.parametrize("quoted_legacy_marker", [False, True])
|
|
def test_swarm_managed_root_starts_agent_script_over_loopback(quoted_legacy_marker):
|
|
task = {"id": "managed-root", "root_task_id": "managed-root", "text": SW1_OBJECTIVE,
|
|
"metadata": {"force_plan": True, "force_plan_source": "swarm"}}
|
|
content = build_user_content(task)
|
|
assert content.startswith("[SWARM_INITIATIVE]")
|
|
assert content.endswith(SW1_OBJECTIVE)
|
|
if quoted_legacy_marker:
|
|
content += '\nHistorical diagnostic quoted by the root: "promoted_task_toolset".'
|
|
script = sw1_stub_script(Path(__file__).resolve().parents[1])
|
|
with routed_stub_model(script) as stub:
|
|
cfg = stub_settings(stub, {})
|
|
assert cfg["OPENAI_COMPATIBLE_BASE_URL"] == stub.base_url
|
|
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
|
|
|
def request(model, tools):
|
|
body = {"model": model, "messages": [{"role": "user", "content": content}]}
|
|
if tools:
|
|
body["tools"] = [{"type": "function", "function": {
|
|
"name": "plan_task", "parameters": {"type": "object"}}}]
|
|
req = urllib.request.Request(stub.base_url + "/chat/completions", method="POST",
|
|
data=json.dumps(body).encode(), headers={"Content-Type": "application/json"})
|
|
with opener.open(req, timeout=5) as response:
|
|
return json.load(response)["choices"][0]["message"]
|
|
|
|
first = request("mock-model", True)
|
|
[call] = first["tool_calls"]
|
|
assert call["function"]["name"] == "plan_task"
|
|
assert json.loads(call["function"]["arguments"]) == script["agent"][0]["arguments"]
|
|
assert stub.roles == ["agent"]
|
|
assert set(stub.consumed()) == {"agent", "child", "probe"}
|
|
remaining_agent = len(script["agent"]) - 1
|
|
assert stub.consumed()["agent"] == remaining_agent
|
|
for _ in range(3):
|
|
assert request("mock-child", True)["content"] == script["child"][0]["final"]
|
|
assert request("mock-model", False)["content"] == script["probe"][0]["final"]
|
|
assert stub.roles == ["agent", "child", "probe", "child", "probe", "child", "probe"]
|
|
# These one-entry finals intentionally remain for future callers. The
|
|
# existing report records unused templates, not a new all-zero gate.
|
|
assert stub.consumed() == {"agent": remaining_agent, "child": 1, "probe": 1}
|