From 7a91b9ee5d98f599064c00a4f6573f3b783511f7 Mon Sep 17 00:00:00 2001 From: "lusendong.6789" Date: Tue, 17 Nov 2026 21:18:01 +0800 Subject: [PATCH] refactor(context): retire experimental compaction working memory Signed-off-by: lusendong.6789 --- ...ction-memory-retirement-browser-smoke.mjs} | 68 +++-- .../capability-localization.ts | 2 - .../machine-configuration-settings.tsx | 33 +-- docs/architecture/rfcs/README.md | 13 +- docs/architecture/rfcs/STATUS.md | 9 +- docs/architecture/rfcs/STATUS.zh-CN.md | 9 +- .../2026-11-17-retirement.md | 51 ++++ .../2026-11-17-retirement.zh-CN.md | 41 +++ .../sparse-compaction-working-memory-v0.md | 10 +- ...arse-compaction-working-memory-v0.zh-CN.md | 10 +- docs/product/releases/v2.4.0.md | 36 +-- .../assets/compaction-memory-narrow.png | Bin 47940 -> 0 bytes .../assets/compaction-memory-off.png | Bin 95279 -> 0 bytes .../reference/assets/compaction-memory-on.png | Bin 95260 -> 0 bytes docs/reference/required-work-context.md | 87 ++----- loopx/capabilities/configuration_ui.py | 5 - .../machine_configuration/builtins.py | 8 +- .../compaction_memory.py | 34 +-- .../machine_configuration/contract.py | 52 ++-- loopx/cli_commands/quota_capture.py | 9 - .../control_plane/quota/compaction_memory.ts | 80 ------ loopx/control_plane/quota/turn_envelope.ts | 2 - .../turn_driver/compaction_memory.py | 129 ---------- .../test_machine_configuration_contract.py | 35 ++- tests/control_plane/test_compaction_memory.py | 233 ------------------ .../test_compaction_memory_retirement.py | 138 +++++++++++ .../compaction_memory.test.ts | 60 ----- tests/control_plane_ts/turn_envelope.test.ts | 14 +- tests/test_chat_machine_configuration_api.py | 54 +++- 29 files changed, 445 insertions(+), 777 deletions(-) rename apps/presentation/dashboard/smoke/{compaction-memory-browser-smoke.mjs => compaction-memory-retirement-browser-smoke.mjs} (68%) create mode 100644 docs/architecture/rfcs/ledger/sparse-compaction-working-memory-v0/2026-11-17-retirement.md create mode 100644 docs/architecture/rfcs/ledger/sparse-compaction-working-memory-v0/2026-11-17-retirement.zh-CN.md delete mode 100644 docs/reference/assets/compaction-memory-narrow.png delete mode 100644 docs/reference/assets/compaction-memory-off.png delete mode 100644 docs/reference/assets/compaction-memory-on.png delete mode 100644 loopx/control_plane/quota/compaction_memory.ts delete mode 100644 loopx/control_plane/turn_driver/compaction_memory.py delete mode 100644 tests/control_plane/test_compaction_memory.py create mode 100644 tests/control_plane/test_compaction_memory_retirement.py delete mode 100644 tests/control_plane_ts/compaction_memory.test.ts diff --git a/apps/presentation/dashboard/smoke/compaction-memory-browser-smoke.mjs b/apps/presentation/dashboard/smoke/compaction-memory-retirement-browser-smoke.mjs similarity index 68% rename from apps/presentation/dashboard/smoke/compaction-memory-browser-smoke.mjs rename to apps/presentation/dashboard/smoke/compaction-memory-retirement-browser-smoke.mjs index 9e929b2566..5d3c9276f8 100644 --- a/apps/presentation/dashboard/smoke/compaction-memory-browser-smoke.mjs +++ b/apps/presentation/dashboard/smoke/compaction-memory-retirement-browser-smoke.mjs @@ -1,5 +1,5 @@ -// PR-scoped regression: a packaged switch uses real preview/apply/readback, -// survives reload, rejects stale writes and removes its opt-in on disablement. +// Retirement regression: a saved experimental opt-in stays inert and hidden; +// sibling settings retain real preview/apply/readback and stale-write recovery. // Isolated machine, empty registry, unavailable native host; no model calls. import assert from "node:assert/strict"; import {spawn} from "node:child_process"; @@ -14,6 +14,12 @@ const root = await mkdtemp(join(tmpdir(), "loopx-compaction-preference-")); const port = Number(process.env.LOOPX_COMPACTION_MEMORY_PORT ?? 5414); const screenshots = process.env.LOOPX_COMPACTION_MEMORY_SCREENSHOTS; const registry = join(root, "registry.json"); +await mkdir(join(root, "runtime", "machine"), {recursive: true}); +await writeFile(join(root, "runtime", "machine", "configuration.json"), JSON.stringify({ + schema_version: "loopx_machine_configuration_v0", namespaces: { + compaction_memory: {schema_version: "compaction_memory_machine_defaults_v0", enabled: true}, + }, +})); await writeFile(registry, '{"goals":[]}'); await mkdir(join(root, "home")); if (screenshots) await mkdir(screenshots, {recursive: true}); @@ -39,28 +45,24 @@ try { }); const open = async () => { await page.goto(`${base}/chat/?settings_scope=machine&settings_tab=capabilities`, {waitUntil: "networkidle"}); - await page.getByText("Compaction working memory (experimental)", {exact: true}).first().click(); + await page.getByText("Progressive context", {exact: true}).first().click(); + assert.equal(await page.getByText("Compaction working memory (experimental)", {exact: true}).count(), 0); + assert.equal(await page.getByRole("switch", {name: "Enable experimental compaction working memory"}).count(), 0); }; - const toggle = page.getByRole("switch", {name: "Enable experimental compaction working memory"}); + const progressive = page.getByRole("switch", {name: "Read context progressively"}); + const delta = page.getByRole("switch", {name: "Use cross-turn delta automatically on supported hosts"}); const configuration = async () => (await (await page.request.get(`${base}/api/chat/machine-configuration`)).json()).machine_configuration; const capture = async name => { if (screenshots) await page.screenshot({path: join(screenshots, name)}); }; await open(); - assert.equal(await toggle.isChecked(), false); - await capture("desktop-off.png"); - let beforeSave = workRequests.length; - await toggle.click(); - await page.getByText("Compaction working memory preference saved.", {exact: true}).waitFor(); - assert.equal(workRequests.length, beforeSave, "Enabling does not create a conversation or Turn"); - assert.equal(await toggle.isChecked(), true); - assert.equal((await configuration()).namespaces.compaction_memory.enabled, true); - await open(); - assert.equal(await toggle.isChecked(), true, "Persisted readback survives a fresh page"); - await capture("desktop-on.png"); + assert.equal(await progressive.isChecked(), true); + assert.equal(await delta.isChecked(), true); + assert.equal((await configuration()).namespaces.compaction_memory, undefined); + await capture("desktop-settings.png"); await page.setViewportSize({width: 430, height: 932}); assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true); - await capture("narrow-on.png"); + await capture("narrow-settings.png"); await page.setViewportSize({width: 1440, height: 1000}); // Keep the actual backend and invalidate only the request's CAS expectation. @@ -68,29 +70,12 @@ try { await page.route(apply, route => route.continue({postData: JSON.stringify({ ...route.request().postDataJSON(), expected_plan_revision: `sha256:${"0".repeat(64)}`, })})); - beforeSave = workRequests.length; - await toggle.click(); + await progressive.click(); await page.getByText(/machine-configuration plan revision changed/u).waitFor(); - assert.equal(workRequests.length, beforeSave, "A rejected setting starts no work"); - assert.equal(await toggle.isChecked(), true, "A rejected save must not look disabled"); - assert.equal((await configuration()).namespaces.compaction_memory.enabled, true); + assert.equal(await progressive.isChecked(), true, "A rejected save retains the confirmed value"); + assert.equal((await configuration()).namespaces.context_delivery, undefined); await capture("desktop-rejected.png"); await page.unroute(apply); - beforeSave = workRequests.length; - await toggle.click(); - await page.getByText("Compaction working memory preference saved.", {exact: true}).waitFor(); - assert.equal(workRequests.length, beforeSave, "Disabling starts no work"); - assert.equal(await toggle.isChecked(), false); - assert.equal((await configuration())?.namespaces.compaction_memory, undefined, "Disable restores older-editor compatibility"); - await open(); - assert.equal(await toggle.isChecked(), false); - // Exercise the shared save helper with the pre-existing switches while the - // experiment is absent. Each setting preserves the other's confirmed value. - await page.getByText("Progressive context", {exact: true}).first().click(); - const progressive = page.getByRole("switch", {name: "Read context progressively"}); - const delta = page.getByRole("switch", {name: "Use cross-turn delta automatically on supported hosts"}); - assert.equal(await progressive.isChecked(), true); - assert.equal(await delta.isChecked(), true); await progressive.click(); await page.getByText("Progressive reads preference saved.", {exact: true}).waitFor(); assert.equal((await configuration()).namespaces.context_delivery.mode, "off"); @@ -99,15 +84,18 @@ try { await page.getByText("Cross-turn delta preference saved.", {exact: true}).waitFor(); assert.equal((await configuration()).namespaces.context_delivery.delta_delivery, "off"); assert.equal(await progressive.isChecked(), false); + await open(); + assert.equal(await progressive.isChecked(), false); + assert.equal(await delta.isChecked(), false); assert.equal((await configuration()).namespaces.compaction_memory, undefined); await page.evaluate(() => localStorage.setItem("loopx-pw-locale", "zh-CN")); await page.reload({waitUntil: "networkidle"}); - await page.getByText("压缩工作记忆(实验)", {exact: true}).first().click(); - assert.equal(await page.getByRole("switch", {name: "启用实验性压缩工作记忆"}).isChecked(), false); - await capture("chinese-off.png"); + assert.equal(await page.getByText("压缩工作记忆(实验)", {exact: true}).count(), 0); + assert.equal(await page.getByRole("switch", {name: "启用实验性压缩工作记忆"}).count(), 0); + await capture("chinese-settings.png"); // Existing Workbench entry may create Session metadata; no Turn is dispatched. assert.equal(workRequests.some(path => path.endsWith("/turns")), false); - console.log("compaction working memory: packaged enable/reload/stale-save/disable/Chinese readback passed"); + console.log("compaction memory retirement: legacy-on hidden; sibling save/reload/stale-write recovery passed"); } finally { await browser?.close(); if (server.exitCode === null) { diff --git a/apps/presentation/dashboard/src/features/personal-workspace/capability-localization.ts b/apps/presentation/dashboard/src/features/personal-workspace/capability-localization.ts index 7ea0c17994..bb4d4f76dc 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/capability-localization.ts +++ b/apps/presentation/dashboard/src/features/personal-workspace/capability-localization.ts @@ -12,7 +12,6 @@ type FieldCopy = Record> = { en: { - compaction_memory: {displayName: "Compaction working memory (experimental)", description: "Restore source-backed work notes after context compaction."}, context_delivery: {displayName: "Progressive context", description: "Read current requirements before supporting material. Supported hosts can reuse unchanged context independently."}, codex_chat: {displayName: "Codex Goal conversation defaults", description: "Choose the native Codex profile, model, speed tier and reasoning effort for new Goal conversations. Existing conversations keep their original history. This does not start or reconfigure an active Agent Loop, worker or steward."}, decision_context: {displayName: "Find evidence", description: "Find advisory evidence with a temporary private profile. OpenViking and BM25 are retrieval implementations; this page does not save a binding or enable automatic memory."}, @@ -83,7 +82,6 @@ const capabilityCopy: Record> = { }, }, "zh-CN": { - compaction_memory: {displayName: "压缩工作记忆(实验)", description: "上下文压缩后恢复有来源的工作要点。"}, context_delivery: {displayName: "渐进上下文", description: "先展示当前目标与约束,按需读取材料;支持的宿主可独立复用跨轮上下文。"}, codex_chat: {displayName: "Codex Goal 对话默认值", description: "分别选择 Codex 配置来源、模型、速度档和推理强度,作用于本机的新 Goal 对话。已有对话保留原历史;不会启动或重配正在运行的 Agent Loop、工作 Agent 或管家。"}, decision_context: {displayName: "资料召回", description: "通过临时私有配置查找参考证据。OpenViking、BM25 是检索实现;本页不保存绑定,也不启用自动记忆。"}, diff --git a/apps/presentation/dashboard/src/features/personal-workspace/machine-configuration-settings.tsx b/apps/presentation/dashboard/src/features/personal-workspace/machine-configuration-settings.tsx index 73481eb4f4..20730ae91d 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/machine-configuration-settings.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/machine-configuration-settings.tsx @@ -289,24 +289,15 @@ export function MachineConfigurationSettings({ section, onChanged }: { await saveImmediatePreference(configuration, label); } - async function setCompactionMemory(enabled: boolean) { - if (busy || !editorAvailable || selected?.capability_id !== "compaction_memory") return; - // Removing the opt-in namespace also restores compatibility with older editors. - await saveImmediatePreference(enabled ? {...selected.default, enabled: true} : null, - locale === "zh-CN" ? "压缩工作记忆" : "Compaction working memory"); - } - - async function saveImmediatePreference(configuration: Record | null, label: string) { + async function saveImmediatePreference(configuration: Record, label: string) { if (busy || !editorAvailable || !selected?.machine_namespace) return; const namespace = selected.machine_namespace; const generation = editorGeneration.current; setBusy("apply"); setError(null); setNotice(null); try { - const plan = configuration === null ? await previewMachineConfigurationRemoval(namespace) - : await previewMachineConfiguration(namespace, configuration); + const plan = await previewMachineConfiguration(namespace, configuration); if (generation !== editorGeneration.current) return; - if (configuration === null) await applyMachineConfigurationRemoval(namespace, plan.plan_revision); - else await applyMachineConfiguration(namespace, configuration, plan.plan_revision); + await applyMachineConfiguration(namespace, configuration, plan.plan_revision); if (generation !== editorGeneration.current) { onChanged?.(); return; } setReadbackPending(selected.display_name); const next = await fetchMachineConfiguration(); @@ -314,8 +305,7 @@ export function MachineConfigurationSettings({ section, onChanged }: { setInspection(next); setReadbackPending(null); const saved = next.machine_configuration?.namespaces[namespace]; - if (next.status === "invalid" || (configuration === null ? saved !== undefined - : Object.entries(configuration).some(([key, value]) => saved?.[key] !== value))) { + if (next.status === "invalid" || Object.entries(configuration).some(([key, value]) => saved?.[key] !== value)) { throw new Error(locale === "zh-CN" ? "保存后的配置已变化,请刷新后重试。" : "The saved configuration changed. Refresh and retry."); } setNotice(locale === "zh-CN" ? `${label}偏好已保存。` : `${label} preference saved.`); @@ -561,18 +551,7 @@ export function MachineConfigurationSettings({ section, onChanged }: { ? "渐进读取先提供当前要求,支持材料按需展开,适用于所有宿主。跨轮差分独立控制:仅在受支持的 POSIX Codex App/SSH、benchmark 心跳已保留完整旧上下文时自动使用,否则恢复完整当前输入。关闭偏好和实验显式关闭均继续生效。保存不会安装 hook、启动实验或证明当前会话已采用差分。" : "Progressive reads present current requirements before expandable supporting material on every host. Cross-turn delta is independent: automatic reuse requires a supported POSIX Codex App/SSH or benchmark heartbeat and complete retained context; otherwise the current full input is restored. Saved off preferences and explicit experiment opt-outs remain effective. Saving installs no hook, starts no experiment and does not prove current-session delta use."}

: null} - {selected.capability_id === "compaction_memory" ?
-
-

{locale === "zh-CN" - ? "仅作用于本机已经支持上下文恢复的原生根会话。压缩时保留有来源的工作标题、短注记及引用,之后恢复;不增加模型调用,不安装 hook,也不省略当前必读要求。关闭会移除实验设置以支持旧版编辑器,已保存的引用仍保留。尚未验证任务效果与完整成本收益。" - : "Applies to this device's native root sessions that already support context recovery. Keeps source-bound work titles, short notes and references at compaction and restores them afterward. No additional model calls, hook installation or skipped required reads. Disabling removes the experiment setting for older editors and retains saved references. Task effectiveness and total-cost gains remain unverified."}

-
: null} - {editorAvailable && selected.capability_id !== "context_delivery" && selected.capability_id !== "compaction_memory" ? <>{editorMode === "json" || !selected.configuration_editor.fields.some((field) => field.key === "enabled" && field.input_kind === "boolean") ?
+ {editorAvailable && selected.capability_id !== "context_delivery" ? <>{editorMode === "json" || !selected.configuration_editor.fields.some((field) => field.key === "enabled" && field.input_kind === "boolean") ?
@@ -621,7 +600,7 @@ export function MachineConfigurationSettings({ section, onChanged }: { ) : null} - {editorAvailable && selected.capability_id !== "context_delivery" && selected.capability_id !== "compaction_memory" ?