Skip to content
Merged
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
14 changes: 7 additions & 7 deletions docs/product/releases/v2.4.0.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions loopx/control_plane/quota/turn_envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2549,9 +2549,9 @@ function nativeReplanPresentation(request: JsonObject): JsonObject | undefined {
if (projection.sha256 === undefined || request.surface !== "complete_turn" &&
(request.surface !== "quota_packet" || Object.hasOwn(source, "schema_version") ||
Object.hasOwn(source, "contract_binding"))) return undefined;
// Preserve a bound reversal in the opening, before candidate choice.
if (scopedReplanYardstickReversal(source)) return undefined;
}
// Preserve a bound reversal in the opening, before candidate choice.
if (scopedReplanYardstickReversal(source)) return undefined;
const packet = object(source.replan_action_packet);
const review = object(object(source.autonomous_replan_obligation).replan_context);
// Existing staged files are presentation inputs. Do not derive a new source
Expand Down
6 changes: 2 additions & 4 deletions tests/control_plane/test_goal_create_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ def lose_claim_response(*args, **kwargs):
@pytest.mark.parametrize("completion_surface", ["native-cli", "external-worker"])
def test_ordinary_goal_replans_after_first_todo_and_delivers_the_missing_section(environment, app, monkeypatch, provider, completion_surface):
"""Real creation, native CLI and authority; only the work decision is scripted."""
monkeypatch.delenv("LOOPX_CONTEXT_DELIVERY", raising=False)
configure, _, _, project, runtime = environment
_, request, _ = app
configure(provider, mode="soft_claim")
Expand Down Expand Up @@ -425,10 +426,7 @@ def read_action(command):
assert result.returncode == 0, result.stdout + result.stderr
return json.loads(read_cli_context_for_oracle(result.stdout)[0])

from loopx.control_plane.quota.turn_envelope import _turn_envelope_result
assert "review" not in decision["replan_action_packet"]
staged = _turn_envelope_result("replan_cli_view", payload=decision)["replan_action_packet"]
review = read_action(staged["review"])
review = read_action(decision["replan_action_packet"]["review"])
writeback = read_action(review["next"]["writeback"])
stride = {**writeback["stride_control"]["minimal_example"],
"basis": "unexplained_gap", "action": "verify", "axes": {
Expand Down
30 changes: 13 additions & 17 deletions tests/control_plane/test_quota_acceptance_references.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def first_read(*args):
chunks.extend(page["content"].encode())
if page["eof"]:
assert len(chunks) == page["total_bytes"]
return view, selected_context_values(chunks)
return selected_context_values(chunks)
page = run_reader(page["next_command"])

registry_path = tmp_path / "registry.json"
Expand All @@ -230,23 +230,18 @@ def first_read(*args):
"--document", str(document), "--expected-provider-revision", before["provider_revision"],
"--operation-id", "source-requirements", "--execute")
expected = call("goal-acceptance", "inspect", "--goal-id", GOAL)["goal_acceptance_contract"]
guard_view, guard = first_read("--turn-instance-id", "turn-acceptance-sharing")
guard = first_read("--turn-instance-id", "turn-acceptance-sharing")
assert guard["/effective_action"] == "autonomous_replan_required"
assert guard["/normal_delivery_allowed"] is False
assert "/replan_action_packet/writeback" not in guard
assert "/replan_action_packet/review" not in guard
assert guard["/autonomous_replan_obligation/obligation_id"] == guard[
"/heartbeat_receipt/semantic_replan_obligation_id"
]
sources = "/interaction_contract/agent_channel/work_context/sources/"
guard_owner, = (path.removesuffix("/source") for path, value in guard.items()
if path.startswith(sources) and path.endswith("/source") and value == "goal_acceptance")
outcome_prefix = guard_owner + "/content/goal_acceptance_contract/outcome_requirements/outcomes/0"
assert guard[outcome_prefix + "/id"] == "export"
assert outcome_prefix + "/requirements" not in guard
command = guard_view["recovery"]["command"].split(" --offset ")[0] + f" --select {outcome_prefix}"
review = run_reader(guard["/replan_action_packet/review"])
assert review["obligation_id"] == guard["/heartbeat_receipt/semantic_replan_obligation_id"]
acceptance = review["acceptance_index"]
row, = acceptance["outcomes"]
assert row["id"] == "export"
command = acceptance["read_action_template"].replace("{outcome_ref}", row["outcome_ref"])
original = expected["outcome_requirements"]["outcomes"][0]
assert selected_context_values(run_reader(command)["content"].encode())[outcome_prefix] == original
assert run_reader(command)["outcome"] == original

# A later linked revision must reach the selected caller intact.
index.write_text("")
Expand All @@ -264,19 +259,20 @@ def first_read(*args):
"--document", str(document), "--expected-provider-revision", revision,
"--operation-id", "link-export", "--execute")
expected = call("goal-acceptance", "inspect", "--goal-id", GOAL)["goal_acceptance_contract"]
_, planning = first_read("--turn-instance-id", "turn-export-planning")
planning = first_read("--turn-instance-id", "turn-export-planning")
assert planning["/interaction_contract/agent_channel/delivery_allowed"] is False
assert "/replan_action_packet/review" not in planning
_, selected = first_read("--todo-id", added["todo_id"], "--turn-instance-id", "turn-export-delivery")
selected = first_read("--todo-id", added["todo_id"], "--turn-instance-id", "turn-export-delivery")
assert selected["/normal_delivery_allowed"] is True
assert selected["/selected_todo/todo_id"] == added["todo_id"]
assert "/replan_action_packet/review" not in selected
sources = "/interaction_contract/agent_channel/work_context/sources/"
owner, = (path.removesuffix("/source") for path, value in selected.items()
if path.startswith(sources) and path.endswith("/source") and value == "goal_acceptance")
outcome = selected[owner + "/content/goal_acceptance_contract/outcome_requirements/outcomes/0"]
assert outcome == expected["outcome_requirements"]["outcomes"][0]
assert original["revision"] < outcome["revision"]
assert selected_context_values(run_reader(command)["content"].encode())[outcome_prefix] == original
assert run_reader(command)["outcome"] == original


@pytest.mark.parametrize("provider", ["file", "sqlite"])
Expand Down
6 changes: 2 additions & 4 deletions tests/control_plane/test_settlement_input_discovery_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def run(*args):
@pytest.mark.parametrize("provider", ["file", "sqlite"])
def test_replan_authoring_example_links_actual_subsequent_work(tmp_path, monkeypatch, provider):
"""A caller following the delivered example must retain a real work link."""
monkeypatch.delenv("LOOPX_CONTEXT_DELIVERY", raising=False)
isolate_sqlite_runtime(tmp_path, monkeypatch)
project, runtime, registry = _write_fixture(tmp_path)
# Fund all three admitted Turns before execution; the shared fixture's
Expand Down Expand Up @@ -244,12 +245,9 @@ def run(*args):
rc, guard = _run_generated_cli(command, registry_path=registry)
assert rc == 0, (stage, guard.get("error"), guard.get("reason"))
if stage == "review":
from loopx.control_plane.quota.turn_envelope import _turn_envelope_result
channel = guard["interaction_contract"]["agent_channel"]
assert channel["must_attempt"] and not channel["delivery_allowed"]
assert "writeback" not in guard["replan_action_packet"]
staged_packet = _turn_envelope_result("replan_cli_view", payload=guard)["replan_action_packet"]
read_command = staged_packet["writeback"]
read_command = guard["replan_action_packet"]["writeback"]
result = subprocess.run(
shlex.split(read_command), cwd=project, capture_output=True, text=True, check=True, timeout=60,
)
Expand Down
36 changes: 36 additions & 0 deletions tests/control_plane_ts/turn_envelope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,42 @@ test("both replan readers surface an opted-in reversal for the bound task only",
Object.keys(explore.work_yardstick_reversal as JsonObject).map(field => prefix + field));
const detail = evaluateTurnEnvelope({operation: "replan_view", payload: captured, source_hash, stage: "explore"});
assert.deepEqual((detail.explore_basis as JsonObject).work_yardsticks, cues);
const nativeInput: JsonObject = {
operation: "context_delivery",
surface: "complete_turn",
scope: {goal_id: String(source.goal_id), agent_id: String(source.agent_id),
session_id: "session", context_epoch: "epoch"},
capture_id: "c".repeat(64),
context: {...captured, replan_read_path: "/capture/original.json"},
native_projection: {
path: "/capture/recovery.json",
sha256: "a".repeat(64),
source_path: "/capture/recovery.json",
command_template: "loopx --format json quota context-read --select '<pointer>'",
captured_decision: {path: "/capture/original.json", sha256: "c".repeat(64)},
},
consumed_pointers: {},
include_initial_read_plan: true,
observe_first_read: true,
};
const nativeResult = structuredClone(nativeInput);
const resolvePath = (root: unknown, path: (string | number)[]) => path.reduce<unknown>(
(row, key) => (row as Record<string | number, unknown>)[key], root);
for (const change of evaluateTurnEnvelope(nativeInput).changes as JsonObject[]) {
const path = change.path as (string | number)[], key = path.at(-1)!;
const parent = resolvePath(nativeResult, path.slice(0, -1)) as Record<string | number, unknown>;
if (change.remove) delete parent[key];
else parent[key] = structuredClone(
change.from ? resolvePath(nativeInput, change.from as (string | number)[]) : change.value);
}
const planSelections = (((nativeResult.initial_read_plan as JsonObject)
.plan as JsonObject).selections as {pointer: string}[]);
assert.ok(planSelections.some(row => row.pointer === `${prefix}proxy_order_reversed`));
assert.equal(
((nativeResult.context as JsonObject).replan_action_packet as JsonObject).review,
undefined,
);
assert.equal(nativeResult.projected, false);
} else {
assert.ok(!Object.hasOwn(explore, "work_yardstick_reversal"));
assert.equal(cuesInOpening.length, 0);
Expand Down
Loading