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
22 changes: 14 additions & 8 deletions apps/desktop/loopx-control-plane/src-tauri/src/macos_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use flate2::read::GzDecoder;
use serde_json::Value;
use tauri_plugin_updater::Update;

const PUBLIC_DEFAULT_CONTRACT: &str =
const ARTIFACT_DEFAULT_CONTRACTS: &str =
include_str!("../../../../../loopx/cli_commands/public_default_contract.json");

/// Read the publisher's observed contract inside the signature-verified bytes
Expand All @@ -31,7 +31,9 @@ pub(crate) fn qualify_candidate(
}
let invalid = "runtime_bundle_invalid";
let unavailable = "update_platform_unavailable";
let supported: Value = serde_json::from_str(PUBLIC_DEFAULT_CONTRACT).map_err(|_| invalid)?;
let supported: Value = serde_json::from_str(ARTIFACT_DEFAULT_CONTRACTS).map_err(|_| invalid)?;
let current = supported.get("current").ok_or(invalid)?;
let historical = supported.get("historical").ok_or(invalid)?;
let identity_path = Path::new("LoopX.app/Contents/Resources/runtime/identity.json");
let mut archive = tar::Archive::new(GzDecoder::new(Cursor::new(verified_bytes)));
let mut qualified = false;
Expand All @@ -46,7 +48,8 @@ pub(crate) fn qualify_candidate(
let mut raw = Vec::new();
entry.read_to_end(&mut raw).map_err(|_| invalid)?;
let identity = crate::bundled_runtime::parse_identity(&raw)?;
if identity["default_contract"] != supported {
let observed = &identity["default_contract"];
if observed != current && observed != historical {
return Err(unavailable.into());
}
qualified = true;
Expand Down Expand Up @@ -194,7 +197,7 @@ mod tests {
Some(serde_json::json!({"surface": "unknown"})),
Some(serde_json::json!({
"surface": "complete_turn",
"schema_version": "loopx_turn_envelope_v1",
"schema_version": "loopx_turn_envelope_v0",
"interaction_schema_version": "loopx_interaction_contract_v0"
})),
];
Expand All @@ -216,10 +219,13 @@ mod tests {
assert!(qualify_candidate("stable", "2.3.0", &bytes).is_ok());
}

identity["default_contract"] = serde_json::from_str(PUBLIC_DEFAULT_CONTRACT).unwrap();
fs::write(identity_path, identity.to_string()).unwrap();
let bytes = archive(&candidate);
crate::prepared_update::save(&cache, "main", version, "unused", &bytes).unwrap();
let qualified: Value = serde_json::from_str(ARTIFACT_DEFAULT_CONTRACTS).unwrap();
for contract in ["historical", "current"] {
identity["default_contract"] = qualified[contract].clone();
fs::write(&identity_path, identity.to_string()).unwrap();
let bytes = archive(&candidate);
crate::prepared_update::save(&cache, "main", version, "unused", &bytes).unwrap();
}
let pointer = fs::read(cache.join("prepared.json")).unwrap();
assert!(crate::prepared_update::save(&cache, "main", version, "unused", b"bad").is_err());
assert_eq!(fs::read(cache.join("prepared.json")).unwrap(), pointer);
Expand Down
34 changes: 12 additions & 22 deletions benchmark/edgebench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ effective work Turns** by default. Use `--replan-after-turns N` to set a differe
count (1–6); `--replan-after-turns 3` retains the previous benchmark default.
Use `--replan-after-todos 3` for the previous completed-Todo cadence
as an explicit ablation. The two options are mutually exclusive and require a
heartbeat profile. This default is independent of `--task-entry`, feedback mode,
and `--turn-envelope`. Official, single and native-goal profiles are unchanged.
heartbeat profile. This default is independent of `--task-entry` and feedback mode.
Official, single and native-goal profiles are unchanged.

The shared control plane counts settled work Turns, not tool calls or idle wakes;
other replan reasons may trigger sooner. Both runtime and worker-profile receipts
Expand Down Expand Up @@ -1005,26 +1005,16 @@ review, proposal adoption and task gains require trajectory evidence.

## Quota input and historical Short

Current C1 sources give both heartbeat profiles the complete v1 input by
default. `--complete-turn` explicitly requests the complete contract, including
on supported historical product revisions. Context delivery remains a separate
setting. The [Host protocol](../../docs/reference/protocols/turn-envelope-v0.md#explicit-complete-v1-host-entry--显式完整-v1-host-入口)
documents original captures, readback and settlement.

For a historical Short benchmark arm, use its recorded product and runner
revisions. With `--turn-envelope`, the current worker verifies the selected CLI's
actual v0 response using a read-only preview before starting a model. C1 or an
unavailable preview rejects the request. A `fresh_replan` checkpoint preloads a
different view and is incompatible with Short. Inspect the wake's
`quota_input_contract` eligibility and the actual saved decision before using
a result in a comparison. Include startup and wake costs under the same study
protocol.

中文:当前 C1 的两种 heartbeat profile 默认交付完整 v1,`--complete-turn`
也可在支持的历史产品版本中显式选择完整输入。旧 Short 组应按记录的产品和 runner
版本复现。当前 worker 在启动模型前用只读预演核实 v0,回执
`quota_input_contract` 记录预期、实测版本与资格。C1 或无法核实的来源会拒绝请求。
`fresh_replan` 会预载另一种输入,因此不能与 Short 合用。
Both heartbeat profiles use complete v1. Context delivery remains a separate
setting. See the [Host protocol](../../docs/reference/protocols/turn-envelope-v0.md#complete-v1-host-entry--完整-v1-host-入口)
for original captures, readback and settlement.

Reproduce historical Short and explicit Complete treatments on their recorded
product and runner revisions. Review the original decision, wake receipt and
complete startup and wake costs before using the result in a comparison.

中文:两种 heartbeat profile 默认使用完整 v1,交付传输单独配置。复现历史 Short
或显式 Complete 组时按原产品和 runner 版本执行,并核对原决策、回执和完整成本。

## Close a managed native attempt

Expand Down
13 changes: 2 additions & 11 deletions benchmark/edgebench/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from sforge.harness.run_agent import run_agent
from sforge.harness.task_spec import make_task_spec

from benchmark.runtime.codex import TASK_ENTRIES, turn_envelope_receipt
from benchmark.runtime.codex import TASK_ENTRIES
from loopx.reasoning_effort import REASONING_EFFORTS
from loopx.control_plane.work_items.stride_policy_codec import stride_strategy_options
from benchmark.runtime.sforge import (
Expand Down Expand Up @@ -124,11 +124,6 @@ def main(argv=None):
help="New-run default: native public feedback; blind/best-only are explicit controls")
parser.add_argument("--managed-run-json", type=Path,
help="Opt-in private binding for native terminal proof, consumed by the controller")
turn_view = parser.add_mutually_exclusive_group()
turn_view.add_argument("--turn-envelope", action="store_true",
help="Historical Short envelope treatment; the worker requires a verified v0 quota response")
turn_view.add_argument("--complete-turn", action="store_true",
help="Explicit complete v1 Turn contract with shared exact-Turn settlement; heartbeat workers only")
parser.add_argument("--context-delivery", choices=("off", "on"),
help="Native Codex context delivery: on by default for heartbeat workers; pass off to disable")
parser.add_argument("--execution-observation", choices=("local_probe",),
Expand Down Expand Up @@ -213,8 +208,7 @@ def main(argv=None):
try:
execution = profile_execution(
args.worker, task_entry=args.task_entry,
context_delivery=args.context_delivery, turn_envelope=args.turn_envelope,
complete_turn=args.complete_turn, validation_command=args.validation_command_json,
context_delivery=args.context_delivery, validation_command=args.validation_command_json,
native_child_limit=args.native_child_limit,
)
except ValueError as error:
Expand Down Expand Up @@ -462,8 +456,6 @@ def main(argv=None):
task_objective=task_objective,
task_entry=args.task_entry,
validation_command=execution.validation_command,
turn_envelope=args.turn_envelope,
**({"complete_turn": True} if args.complete_turn else {}),
context_delivery=args.context_delivery,
**({"execution_observation": args.execution_observation}
if args.execution_observation is not None else {}),
Expand Down Expand Up @@ -548,7 +540,6 @@ def main(argv=None):
"loopx_commit": pins[0], "runner_commit": pins[1],
"sforge_source": sforge_source if native_result_scope is not None else active_source_receipt(),
"local_docker_images": local_docker_images,
**turn_envelope_receipt(explicit=args.turn_envelope, complete=args.complete_turn),
**({"context_delivery": "on"} if args.context_delivery != "off" else {}),
**({"execution_observation": args.execution_observation}
if args.execution_observation is not None else {}),
Expand Down
36 changes: 12 additions & 24 deletions benchmark/runtime/RUNTIME.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,20 @@ agents:
replan_after_turns: 6
```

Historical Short trials request `turn_envelope: true` in heartbeat `kwargs`.
Before planning or execution starts a model, the worker previews the selected
product's quota response through the same CLI. Its wake receipt records the
expected and observed versions and eligibility in `quota_input_contract`. C1
sources return v1 and the Short request fails before Host preparation. A
`fresh_replan` checkpoint preloads a distinct view and also prevents a Short
launch. The preview has no Turn identity and creates no admission or capture.
Ordinary and explicit Complete wakes proceed without this Short preview.

Use the recorded product and runner revisions to reproduce a historical
treatment. On a qualified v0 source, an execution wake records
`turn_envelope_source=explicit` once it renders the Short bootstrap. Its
same-invocation full decision remains available through `detail_ref.full_decision`.
The planning prompt has its own input. Include the preview in startup
and wake cost when measuring a new attempt with this runner. Keep captures
private and preserve the settings and receipts of existing attempts.
Historical Short trials used `turn_envelope: true` and verified a v0 guard
response before launching a model. Reproduce them with their recorded product
and runner revisions. Include the original preview in startup and wake cost.
The current runner rejects explicit historical display requests before Host
preparation. Current heartbeat runs use the complete v1 default. Preserve the
original decision, preview eligibility and complete settings of frozen runs.

New native heartbeat trials default to context delivery `on`. Add
`context_delivery: "off"` to the same heartbeat agent `kwargs` to disable it.
An explicit off is pinned into both native tools and worker preflight; it cannot
inherit a machine-wide on. Plain, native-Goal and Turn execution remain off.
Only the existing Codex heartbeat worker accepts `"on"`; booleans, other modes and
scenario names are rejected. This is an experimental transport setting, separate
from `turn_envelope`.
scenario names are rejected. This transport setting preserves the default
complete v1 source.
The existing EdgeBench/SForge entry exposes the same selection through
`--context-delivery off` to disable a heartbeat worker's on default. Existing
running or frozen trials retain their recorded source and treatment; do not
Expand Down Expand Up @@ -224,12 +214,10 @@ Do not modify an active/frozen trial. Set `context_delivery: "off"` for a new tr
to roll back; default runs install no hooks, trust or trace settings. No scorer,
budget, task semantics or launch authority changes with this option.

Checkpoint capture is independent of this display experiment. A `fresh_replan`
declaration may establish a private capture/handoff socket while
`turn_envelope` remains false: the worker keeps the ordinary dispatcher and quota
input, and only an explicit true setting selects the short view. This replaces
the earlier implicit activation by checkpoint handoff. Do not relabel older
receipts or trajectories as feature-off; qualify their actual input separately.
A `fresh_replan` declaration can establish a private capture and handoff socket
with either inline or progressive delivery. Both consume the same complete v1
decision. Interpret old receipts and trajectories according to their recorded
treatment and product revision.

| Mode | Execution/continuation | LoopX skills and state |
| --- | --- | --- |
Expand Down
2 changes: 1 addition & 1 deletion benchmark/runtime/SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ These are recommendations, not automatically launched experiments.
| Reference | `--worker heartbeat-resume --task-entry loopx-planned --replan-after-turns 6` | Planned entry with effective-turn replanning |
| Seeded | Replace only `--task-entry` with `seeded-todo` | Does initial task decomposition help? |
| Explore | Replace only `--worker` with `heartbeat-explore` | Are recorded evidence and subsequent route choices useful? |
| Historical Short envelope | Use the recorded product and runner revisions with `--turn-envelope`; the current worker verifies v0 before launch | Does short input with reachable original detail reduce overhead while preserving decisions? |
| Historical Short envelope | Use the recorded product and runner revisions and check the original v0 receipt | Does short input with reachable original detail reduce overhead while preserving decisions? |
| Todo cadence | Replace `--replan-after-turns 6` with `--replan-after-todos 3` | How do units and thresholds change interruptions? This is a combined ablation. |
| No LoopX | `--worker official`; omit LoopX-specific flags | What is the net effect of the whole LoopX treatment? |

Expand Down
8 changes: 3 additions & 5 deletions benchmark/runtime/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
research_participants, verify_research_participants,
)
from .checkpoint_handoff import CHECKPOINT_CAPTURE_SECONDS
from .codex import explicit_turn_display
from .codex import reject_retired_turn_display


def normalize_checkpoint_request_path(value: str) -> str:
Expand Down Expand Up @@ -222,7 +222,7 @@ def capture_before_replan(env: dict[str, str], receipt: dict[str, Any], body: st
raise ValueError("fresh_replan checkpoint trigger requires a heartbeat execute wake")
started = time.monotonic()
guard_path = Path(env["LOOPX_WAKE_LOG_DIR"]) / receipt["turn_id"] / "checkpoint-start-guard.json"
# Use the CLI's original-decision capture, including with TurnEnvelope off.
# Use the CLI's original-decision capture even with inline delivery.
# The checkpoint selector needs the full source; the model consumes the
# ordinary CLI projection of those same bytes, never a second guard.
capture_root = Path(tempfile.mkdtemp(prefix="checkpoint-start-", dir=guard_path.parent))
Expand All @@ -231,9 +231,7 @@ def capture_before_replan(env: dict[str, str], receipt: dict[str, Any], body: st
"--goal-id", env["LOOPX_GOAL_ID"], "--agent-id", env["LOOPX_AGENT_ID"],
"--runtime-profile", "generic_cli", "--turn-instance-id", receipt["turn_id"],
"--available-capability", "shell", "--available-capability", "filesystem_write"]
display = explicit_turn_display(env)
if display.complete_turn:
command.append("--complete-turn")
reject_retired_turn_display(env)
native_context = env.get("LOOPX_CONTEXT_DELIVERY") == "on" and bool(env.get("LOOPX_CODEX_CONTEXT_DIR"))
if native_context:
# The native reader selects full/delta after SessionStart. Ask the
Expand Down
5 changes: 2 additions & 3 deletions benchmark/runtime/checkpoint_wake.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ def _capture(self, held, deadline):
"registry": self.env["LOOPX_REGISTRY"], "runtime_root": self.env["LOOPX_RUNTIME_ROOT"],
"goal_id": self.env["LOOPX_GOAL_ID"], "agent_id": self.env["LOOPX_AGENT_ID"],
"turn_instance_id": held["quota"]["heartbeat_receipt"]["turn_instance_id"],
# Generated guards use the default complete v1 contract without emitting
# --complete-turn; bind the CLI flag explicitly so retired aliases are rejected.
"turn_envelope": self.receipt.get("turn_envelope", False),
# Pin the current command grammar against the recorded invocation.
"turn_envelope": False,
"complete_turn": False,
"capture_root": str(self.capture_root), "socket_path": self.socket_path,
"decision_sha256": held["sha256"]}
Expand Down
27 changes: 7 additions & 20 deletions benchmark/runtime/codex.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def __post_init__(self) -> None:
object.__setattr__(self, "context_delivery", "on" if self.mode == "heartbeat" else "off")
if self.context_delivery not in ("off", "on") or (self.context_delivery != "off" and self.mode != "heartbeat"):
raise ValueError("context_delivery supports only off or on with heartbeat execution")
if not isinstance(self.turn_envelope, bool) or (self.turn_envelope and self.mode != "heartbeat"):
raise ValueError("turn_envelope requires heartbeat execution and a boolean opt-in")
if type(self.complete_turn) is not bool or (self.complete_turn and (self.mode != "heartbeat" or self.turn_envelope)):
raise ValueError("complete_turn requires heartbeat execution without legacy turn_envelope")
if self.turn_envelope is not False or self.complete_turn is not False:
raise ValueError("Historical turn_envelope and complete_turn treatments require the recorded product and runner revisions")
if self.mode not in MODES or self.context not in CONTEXTS:
raise ValueError("unsupported execution mode or iteration context")
if self.task_entry is None:
Expand Down Expand Up @@ -89,22 +87,11 @@ def native_goal(self) -> bool:
return self.mode in {"native-goal", "loopx-goal"}


def turn_envelope_receipt(*, explicit: bool, complete: bool = False) -> dict:
"""Record only the explicit display opt-in; checkpoint capture is independent."""
return {**({"turn_envelope": True, "turn_envelope_source": "explicit"} if explicit else {}),
**({"complete_turn": True, "complete_turn_source": "explicit"} if complete else {})}


def explicit_turn_display(env: dict[str, str]) -> Execution:
"""Decode the shared explicit display request through its Execution owner."""
selected = {}
for variable, field in (("LOOPX_TURN_ENVELOPE", "turn_envelope"),
("LOOPX_COMPLETE_TURN", "complete_turn")):
value = env.get(variable, "0")
if value not in {"0", "1"}:
raise ValueError(f"{variable} must be 0 or 1")
selected[field] = value == "1"
return Execution(**selected)
def reject_retired_turn_display(env: dict[str, str]) -> None:
"""Fail historical requests before a new benchmark can use the wrong treatment."""
for variable in ("LOOPX_TURN_ENVELOPE", "LOOPX_COMPLETE_TURN"):
if env.get(variable, "0") != "0":
raise ValueError(f"{variable} requires the recorded historical product and runner revisions")


def native_child_instructions(limit: int | None) -> str:
Expand Down
Loading
Loading