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
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ export function MachineConfigurationSettings({ section, onChanged }: {
async function setContextDelivery(mode: "off" | "on" | "auto", key: "mode" | "delta_delivery" = "mode") {
if (busy || !editorAvailable || selected?.capability_id !== "context_delivery" || !selected.machine_namespace) return;
const namespace = selected.machine_namespace;
const configuration = {...selected.default, ...selectedCurrent, [key]: mode};
const configuration: Record<string, unknown> = {...selected.default, ...selectedCurrent,
schema_version: selected.default?.schema_version ?? selectedCurrent?.schema_version, [key]: mode};
const generation = editorGeneration.current;
setBusy("apply"); setError(null); setNotice(null);
try {
Expand All @@ -295,7 +296,8 @@ export function MachineConfigurationSettings({ section, onChanged }: {
if (generation !== editorGeneration.current) return;
setInspection(next);
setReadbackPending(null);
if (next.machine_configuration?.namespaces[namespace]?.[key] !== mode) {
const saved = next.machine_configuration?.namespaces[namespace];
if (saved?.mode !== configuration.mode || saved?.delta_delivery !== configuration.delta_delivery) {
throw new Error(locale === "zh-CN" ? "保存后的配置已变化,请刷新后重试。" : "The saved configuration changed. Refresh and retry.");
}
const targetLabel = key === "delta_delivery"
Expand Down
24 changes: 14 additions & 10 deletions docs/reference/required-work-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,11 @@ revision-locked preview, apply, readback, disable and rollback owner. Read-only
editors cannot save; sibling settings and Goal records remain unchanged. No choice
installs hooks, trusts a host or proves actual delivery or model retention.

The existing `context_delivery_machine_defaults_v0` namespace accepts
`{"schema_version":"context_delivery_machine_defaults_v0","mode":"on","delta_delivery":"auto"}`.
`mode` and `antigravity_mode` keep their `on|off` values; omitted `delta_delivery`
defaults to `auto` and also accepts `off`. Old saved rows remain readable.
The editor saves `context_delivery_machine_defaults_v1` with both choices.
For example, `{"schema_version":"context_delivery_machine_defaults_v1","mode":"off","delta_delivery":"auto"}`
allows a supported host to compare complete documents without progressive presentation.
Existing v0 rows with `mode=off` retain their original full delivery, including rows
that stored an implicit `delta_delivery=auto`. Editing either switch adopts v1.
`machine-config preview/apply --namespace context_delivery --config-json FILE`
requires the original preview revision. Removing the namespace restores progressive
reads, supported-host Delta AUTO and Antigravity manager history reads. Save the
Expand All @@ -595,8 +596,9 @@ other declared hosts and recovery do not need native setup. A plain read-only
`should-run` stays read-only: capture files do not create a Turn, receipt, session,
journal or execution lease. `--delta-delivery off` independently disables Delta
while retaining progressive reads. Delta AUTO only uses supported declared
continuity hosts. Explicit `--context-delivery off`, a saved off or an inherited
`LOOPX_CONTEXT_DELIVERY=off` keeps the original complete inline path. Environment
continuity hosts. A lone `--context-delivery off` or inherited `LOOPX_CONTEXT_DELIVERY=off` keeps
the original complete path. Explicit `--context-delivery off --delta-delivery auto`
requests cross-Turn reuse of the complete document when continuity is available. Environment
on alone supplies no host, retention or execution proof. Private capture failure
retains the complete current input rather than using an older capture.
New benchmark heartbeat trials default to `context_delivery=on`; pass `off` to
Expand Down Expand Up @@ -961,17 +963,19 @@ quota 能力候选沿用同一精确 codec 复用已登记 Todo 的正文、标
应用、读回、关闭和回滚 owner。只读编辑器不能保存;不改写其他配置和 Goal,不安装/信任 hook,
保存偏好不证明原生初始化、实际投递或模型保留。

既有 `context_delivery_machine_defaults_v0` namespace 接受
`{"schema_version":"context_delivery_machine_defaults_v0","mode":"on","delta_delivery":"auto"}`。
`mode` 与 `antigravity_mode` 保留 `on|off`;可选的 `delta_delivery` 默认为 `auto`,也可为 `off`;旧配置继续可读。
设置页以 `context_delivery_machine_defaults_v1` 同时保存两个选择。
例如 `{"schema_version":"context_delivery_machine_defaults_v1","mode":"off","delta_delivery":"auto"}`
让支持的宿主比较完整文档,同时关闭渐进呈现。旧 v0 配置的 `mode=off` 保留原完整交付,
包括曾隐式存入 `delta_delivery=auto` 的记录。编辑任一开关才采用 v1。
CLI 的 `machine-config preview/apply --namespace context_delivery --config-json FILE` 仍需原预览修订。
移除 namespace 恢复渐进读取、支持宿主的 Delta AUTO 与 Antigravity 管家历史读取;要保持关闭应保存对应 off。
管家自动选择交付历史的读取方式。有权限读取私有快照的原生管家可按需读取已有历史,当前目标与待办仍直接可见。既有显式 `antigravity_mode=off` 偏好继续生效。

CLI 的 `--context-delivery auto`(省略时也使用此门面)跨宿主先呈现当前要求,再按需展开材料。
普通 CLI、其他已声明宿主及恢复读取不要求原生初始化;只读 `should-run` 仍不创建 Turn、回执、会话、journal 或执行 lease。
`--delta-delivery off` 可独立关闭跨轮差分而保留渐进读取;Delta AUTO 只使用支持连续性的已声明宿主。
显式 `--context-delivery off`、已保存的关闭及继承的 `LOOPX_CONTEXT_DELIVERY=off` 保留原完整内联路径。
单独指定 `--context-delivery off` 或继承 `LOOPX_CONTEXT_DELIVERY=off` 保留原完整交付路径。
同时指定 `--context-delivery off --delta-delivery auto` 时,有连续性依据的宿主可以复用完整文档的跨轮差分。
环境 on 不证明宿主、保留或执行权限。私有捕获失败时保留本次完整输入,不借用旧捕获。
新 benchmark heartbeat trial 默认 `context_delivery=on`,指定 `off` 可关闭;其他跑法仍关闭。
worker 把本次运行已解析的选择固定传给预检和 solver 子进程,不改写调用方原设置,
Expand Down
12 changes: 10 additions & 2 deletions examples/personal-workspace-browser/configuration-backup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,16 @@ export const configurationBackupScenario = {
await contextSwitch.click();
await page.getByText("Progressive reads preference saved.", {exact: true}).waitFor();
const storedSettings = () => readFile(join(root, "runtime/machine/configuration.json"), "utf8").then(JSON.parse);
assert.equal((await storedSettings()).namespaces.context_delivery.mode, "off");
const deltaOnly = (await storedSettings()).namespaces.context_delivery;
assert.deepEqual([deltaOnly.schema_version, deltaOnly.mode, deltaOnly.delta_delivery],
["context_delivery_machine_defaults_v1", "off", "auto"]);
contextSwitch = await openContextSettings();
assert.equal(await contextSwitch.isChecked(), false, "A saved off must survive reload and the new on default");
const deltaSwitch = page.getByRole("switch", {name: "Use cross-turn delta automatically on supported hosts"});
assert.equal(await deltaSwitch.isChecked(), true);
await deltaSwitch.click();
await page.getByText("Cross-turn delta preference saved.", {exact: true}).waitFor();
assert.equal(await contextSwitch.isChecked(), false);
const applyRoute = "**/api/chat/machine-configuration/apply";
await page.route(applyRoute, route => route.fulfill({status: 503, contentType: "application/json", body: JSON.stringify({ok: false, error: "Fixture unavailable"})}));
await contextSwitch.click();
Expand All @@ -237,7 +244,8 @@ export const configurationBackupScenario = {
await contextSwitch.click();
await page.getByText("Progressive reads preference saved.", {exact: true}).waitFor();
const afterSettings = await storedSettings();
assert.equal(afterSettings.namespaces.context_delivery.mode, "on");
assert.deepEqual([afterSettings.namespaces.context_delivery.mode, afterSettings.namespaces.context_delivery.delta_delivery],
["on", "off"]);
assert.equal(afterSettings.namespaces.goal_storage.new_goal_provider, "sqlite", "The opt-out/on transaction must preserve sibling settings");
return {coverageEntries: context.coverageEntries, errors: context.errors, backend, verified: `Actual settings backend: Codex default on, saved off/reload, failed apply and explicit on; Packaged configuration recovery and full archive inspection; real ${backend.source_provider} head/history after original-source loss, no Goal registration, keyboard, corrupt-input recovery, immutable history reload and narrow viewport`};
} finally {
Expand Down
20 changes: 15 additions & 5 deletions loopx/capabilities/machine_configuration/context_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,43 @@


CONTEXT_DELIVERY_MACHINE_SCHEMA = "context_delivery_machine_defaults_v0"
INDEPENDENT_CONTEXT_SCHEMA = "context_delivery_machine_defaults_v1"


def normalize_context_delivery_machine_defaults(raw: Mapping[str, Any]) -> dict[str, Any]:
keys = set(raw)
if not ({"schema_version", "mode"} <= keys <= {"schema_version", "mode", "delta_delivery", "antigravity_mode"}) or (
raw.get("schema_version") != CONTEXT_DELIVERY_MACHINE_SCHEMA
raw.get("schema_version") not in (CONTEXT_DELIVERY_MACHINE_SCHEMA, INDEPENDENT_CONTEXT_SCHEMA)
):
raise ValueError("context_delivery requires its schema_version and mode")
if raw["schema_version"] == INDEPENDENT_CONTEXT_SCHEMA and "delta_delivery" not in raw:
raise ValueError("independent context preferences require delta_delivery")
antigravity_mode = raw.get("antigravity_mode", "on")
delta = raw.get("delta_delivery", "auto")
if (raw["mode"] not in ("off", "on") or antigravity_mode not in ("off", "on")
or delta not in ("off", "auto")):
raise ValueError("context_delivery mode and antigravity_mode must be off/on; delta_delivery off/auto")
return {
"schema_version": CONTEXT_DELIVERY_MACHINE_SCHEMA,
"schema_version": raw["schema_version"],
"mode": raw["mode"],
"delta_delivery": delta,
**({"antigravity_mode": antigravity_mode} if "antigravity_mode" in raw else {}),
}


def _public_context_preferences(value: Mapping[str, Any]) -> dict[str, Any]:
# Older editors saved an implicit auto even when the master switch was off.
if value["schema_version"] == CONTEXT_DELIVERY_MACHINE_SCHEMA and value["mode"] == "off":
return {**value, "delta_delivery": "off"}
return dict(value)


def context_delivery_machine_configuration_namespace() -> MachineConfigurationNamespace:
return MachineConfigurationNamespace(
namespace="context_delivery",
schema_versions=frozenset({CONTEXT_DELIVERY_MACHINE_SCHEMA}),
schema_versions=frozenset({CONTEXT_DELIVERY_MACHINE_SCHEMA, INDEPENDENT_CONTEXT_SCHEMA}),
normalize=normalize_context_delivery_machine_defaults,
project_public=lambda value: dict(value),
project_public=_public_context_preferences,
apply_public_update=lambda current, update: {**dict(current or {}), **dict(update)},
title="Progressive context",
description=(
Expand All @@ -45,7 +55,7 @@ def context_delivery_machine_configuration_namespace() -> MachineConfigurationNa
),
documentation={"path": "docs/reference/required-work-context.md#machine-default"},
default_configuration={
"schema_version": CONTEXT_DELIVERY_MACHINE_SCHEMA,
"schema_version": INDEPENDENT_CONTEXT_SCHEMA,
"mode": "on",
"delta_delivery": "auto",
},
Expand Down
13 changes: 10 additions & 3 deletions loopx/cli_commands/context_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ def apply_context_machine_options(
No hook, trust, tracing or automation is installed.
"""
explicit = getattr(args, "context_delivery", None)
if explicit == "off":
if explicit == "off" and getattr(args, "delta_delivery", None) != "auto":
return
args.context_delivery = explicit or "off"
# Existing benchmark workers retain their explicit opt-out. A machine
# default must not silently change a frozen worker's disabled transport.
# An environment on alone still supplies no activation or host proof.
if explicit is None and os.environ.get("LOOPX_CONTEXT_DELIVERY") == "off":
args.delta_delivery = "off"
return
command = getattr(args, "quota_command", None)
if not heartbeat and command not in {"should-run", "context-config", "context-project", "context-hook", "context-read"}:
Expand All @@ -108,12 +109,18 @@ def apply_context_machine_options(
if using_default:
value = machine_registry.resolve("context_delivery").public_descriptor()["configuration_template"]
if value["mode"] == "off":
return
from ..capabilities.machine_configuration.context_delivery import INDEPENDENT_CONTEXT_SCHEMA

if value["schema_version"] != INDEPENDENT_CONTEXT_SCHEMA:
args.delta_delivery = "off"
return
# Presentation is host-neutral. Only Delta needs declared lifecycle
# continuity. A read-only query must not manufacture an admitted Turn.
args.context_delivery = explicit or "auto"
args.context_delivery = explicit or ("auto" if value["mode"] == "on" else "off")
if getattr(args, "delta_delivery", None) is None:
args.delta_delivery = value.get("delta_delivery", "auto")
if args.context_delivery == "off" and args.delta_delivery == "off":
return
if ((command == "should-run" and not (getattr(args, "turn_instance_id", None)
or bool(getattr(args, "begin_turn", False)))) or os.name != "posix") and explicit != "on":
args.delta_delivery = "off"
Expand Down
Loading
Loading