Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -155,6 +155,17 @@ complete contract. They do **not** establish a current authority-loss bug: the
recommendation is diagnostic, the unknown field is synthetic, and the complete
source commitment still distinguishes both inputs. No model benefit is measured.

The release-only host-prompt decision probe composes its realistic external-wait
case through the existing complete-source TypeScript owner. Thin and brief modes
receive one checked source instance per probe batch, including complete task and
stop text; the scenario validator reads the source portfolio directly instead
of constructing an old compact packet. The four small independent decision
controls remain synthetic. The frozen raw/v0 model corpus and supported history
readers are unchanged. This migrates qualification input, not the ordinary CLI
writer or installed Host: provider execution remains explicitly release opt-in,
and scripted probe passes do not qualify model behavior, settlement, accepted
outcomes or complete cost.

### Differential context

Reuse the existing context-delivery owner and immutable capture mechanism.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ settlement plan 在投影中保留,改变其 Turn 身份会改变 action signa
recommendation 属于诊断,未知字段是合成输入,完整来源承诺仍能区分两份输入。
没有测量模型收益。

发布用宿主提示决策探针的真实 external-wait 场景,经既有完整来源 TypeScript owner
组合。Thin 与 brief 在每批探针中接收同一份已检查来源,保留完整任务和停止正文;
场景校验器直接读取来源 portfolio,不再构造旧压缩包。四个独立的小型决策对照仍为
合成输入,冻结的 raw/v0 模型语料和受支持历史 reader 不变。这只迁移资格验证输入,
不切换普通 CLI writer,也不证明已安装 Host 采用;provider 执行仍须显式 release
opt-in,脚本探针通过不代表模型行为、结算、验收成果或完整成本已经取得资格。

### 差分上下文

复用现有 context-delivery owner 与不可变 capture 机制。目标包含两个正交层,
Expand Down
10 changes: 6 additions & 4 deletions docs/development/testing-and-quality.md
Original file line number Diff line number Diff line change
Expand Up @@ -2301,8 +2301,9 @@ explicit release qualification. It defaults to no calls; missing credentials
report `skipped`, not a live pass. With securely injected `ARK_API_KEY`, it uses
Doubao evolving for two independent repetitions of quiet-work, notifying-wait,
quiet-wait, required-vision-replan and typed external-wait fallback cases in
each mode. The fallback case uses the real compact quota projection: its wait
transition already exists, so the host must advance the selected independent
each mode. The fallback case composes the complete quota source through the
shared TypeScript owner and reuses that checked instance in both modes. Its
wait transition already exists, so the host must advance the selected independent
successor and notify rather than authoring another transition. Expected
decisions remain outside model input. All attempts must pass; no answer
correction or retry-until-pass is used. Ordinary pytest only checks the probe
Expand All @@ -2313,8 +2314,9 @@ as separate evidence. Only hashes and pass/fail receipts are emitted, not raw
prompts/responses. Model transport failures fail qualification rather than
becoming environment skips.

仅发布前显式执行,普通 CI 不调用模型。检查静默不等于空转、等待不能擅自执行、
vision replan 未关闭时不能提前结束 Goal;
回退场景使用完整 C1 来源,thin 与 brief 每批共享同一份已检查契约;原四个小型
决策对照仍为合成输入。仅发布前显式执行,普通 CI 不调用模型。检查静默不等于空转、等待不能擅自执行、
vision replan 未关闭时不能提前结束 Goal;这不是完整 Claude/Codex 行为验收的替代。

```bash
# No provider call by default. Explicit release opt-in uses ARK_API_KEY from the environment.
Expand Down
7 changes: 2 additions & 5 deletions loopx/control_plane/testing/action_portfolio_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections.abc import Mapping
from typing import Any

from ..quota.cli_projection import compact_quota_should_run_cli_payload
from ..quota.effective_action import EffectiveAction
from ..quota.should_run import build_quota_should_run
from ..work_items.interaction_contract import build_interaction_contract
Expand Down Expand Up @@ -369,9 +368,7 @@ def validate_external_wait_fallback_scenario(
resume_blocked = list(summary.get("resume_blocked_items") or [])
first_resume_blocked = dict(resume_blocked[0]) if resume_blocked else {}
condition = dict(first_resume_blocked.get("resume_condition") or {})
compact = compact_quota_should_run_cli_payload(dict(source_packet))
compact_portfolio = dict(compact.get("action_portfolio") or {})
suggested = list(compact_portfolio.get("suggested_actions") or [])
suggested = list(portfolio.get("suggested_actions") or [])
first_suggested = dict(suggested[0]) if suggested else {}
if not (
selected.get("todo_id") == "todo_external_wait_fallback"
Expand All @@ -391,7 +388,7 @@ def validate_external_wait_fallback_scenario(
):
raise ValueError(
"external-wait scenario must expose the pending P0 condition while "
"executing the bounded fallback from the compact default packet"
"executing the bounded fallback from the complete quota source"
)


Expand Down
9 changes: 6 additions & 3 deletions loopx/control_plane/testing/host_prompt_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pathlib import Path

from ...heartbeat_prompt import build_heartbeat_prompt
from ..quota.cli_projection import compact_quota_should_run_cli_payload
from ..quota.effective_action import EffectiveAction
from ..quota.turn_envelope import compose_turn_decision
from .action_portfolio_scenarios import external_wait_fallback_scenario_source
from .model_tool_behavior import DoubaoExecToolClient

Expand Down Expand Up @@ -47,7 +47,9 @@ def cases() -> list[dict]:
} for name, work, notify, replan, action in rows]
probes.append({
"id": "wait_fallback_work",
"packet": compact_quota_should_run_cli_payload(external_wait_fallback_scenario_source()),
"packet": compose_turn_decision(
external_wait_fallback_scenario_source(), composed_settlement=True,
),
"expected": {"action": "work", "notify": True, "finish_goal": False},
})
return probes
Expand Down Expand Up @@ -83,9 +85,10 @@ def probe_messages(mode: str, packet: dict) -> list[dict]:
def run_probe(client: DoubaoExecToolClient, *, repeats: int = 2) -> dict:
if not 1 <= repeats <= 5:
raise ValueError("repeats must be between 1 and 5")
probes = cases()
results = []
for mode in ("thin", "brief"):
for case in cases():
for case in probes:
messages = probe_messages(mode, case["packet"])
for attempt in range(repeats):
# Each repetition is independent; failed attempts are not
Expand Down
56 changes: 56 additions & 0 deletions tests/control_plane/test_host_prompt_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

import pytest

from loopx.control_plane.effect_runtime import EffectRuntimeRejected
from loopx.control_plane.quota.turn_envelope import assert_complete_turn_decision
from loopx.control_plane.testing.action_portfolio_scenarios import (
external_wait_fallback_scenario_source,
)
from loopx.control_plane.testing.host_prompt_behavior import cases, probe_messages, run_probe


Expand Down Expand Up @@ -78,6 +83,57 @@ def test_oracle_boundary_allows_version_preconditions_but_rejects_answer_leakage
ScriptedClient().next_final_content(probe_messages("thin", cases()[0]))


def test_fallback_probe_delivers_one_complete_source_to_both_prompt_modes(monkeypatch):
source = external_wait_fallback_scenario_source()
stop = "保留完整材料和原权限。" * 60 + "\nStop when the original authority is revoked."
task = source["selected_todo"]["text"] + "\n" + "不得遗漏验收要求。" * 60
source["goal_boundary"]["stop_condition"] = stop
source["selected_todo"]["text"] = task
monkeypatch.setattr(
"loopx.control_plane.testing.host_prompt_behavior.external_wait_fallback_scenario_source",
lambda: source,
)

class CompleteSourceClient(ScriptedClient):
def __init__(self):
super().__init__()
self.fallbacks = []

def next_final_content(self, messages):
packet = sent_packet(messages)
if packet.get("selected_todo", {}).get("todo_id") == "todo_external_wait_fallback":
assert_complete_turn_decision(packet)
assert packet["goal_boundary"]["stop_condition"] == stop
assert packet["selected_todo"]["text"] == task
self.fallbacks.append(packet)
return super().next_final_content(messages)

client = CompleteSourceClient()
report = run_probe(client, repeats=1)
assert report["qualification_passed"]
assert client.count == report["provider_call_count"] == 10
assert len(client.fallbacks) == 2
assert client.fallbacks[0] == client.fallbacks[1]
assert source["goal_boundary"]["stop_condition"] == stop
assert source["selected_todo"]["text"] == task


@pytest.mark.parametrize("reserved", [
{"schema_version": "unknown_source_version"}, {"contract_binding": {}},
])
def test_unknown_source_binding_is_rejected_before_provider_call(monkeypatch, reserved):
source = external_wait_fallback_scenario_source()
source.update(reserved)
monkeypatch.setattr(
"loopx.control_plane.testing.host_prompt_behavior.external_wait_fallback_scenario_source",
lambda: source,
)
client = ScriptedClient()
with pytest.raises(EffectRuntimeRejected, match="reserved version/binding"):
run_probe(client, repeats=1)
assert client.count == 0


@pytest.mark.parametrize("mutation", [
{"action": "wait"}, {"notify": True}, {"finish_goal": True}, {"notify": 0},
])
Expand Down
Loading