Skip to content

fix(quota): avoid duplicate selected todo context - #5882

Merged
huangruiteng merged 5 commits into
loopx-project:mainfrom
mikamikasuki:codex/loopx-2881-selected-todo-context
Oct 8, 2026
Merged

huangruiteng merged 5 commits into
loopx-project:mainfrom
mikamikasuki:codex/loopx-2881-selected-todo-context

Conversation

@mikamikasuki

@mikamikasuki mikamikasuki commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Goal And Delivered Outcome

  • Outcome basis: This scoped follow-up implements the accepted duplicate-context direction in issue #2881 under the current quota and Turn Envelope contracts.
  • Goal and gap: A selected Todo can already carry the body needed for the current action, while quota and Turn Envelope work context serialized that body again. Safe deduplication requires an exact current-source read and preservation of unique notes, authority metadata, and read obligations.
  • Observable before → after: The original small-output regression exceeded the registered limits: quota JSON was 21,871 characters / 579 lines against 20,000 / 520, and Turn Envelope JSON was 9,835 against 9,000. The reviewed compact Markdown path then omitted the full work-context instruction. The updated renderers reuse the selected body while emitting that instruction once beside the reference.
  • Related work and intended base: Related to issue #2881; tested against canonical main 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc.

Author Declaration

  • Written by: model_agent — OpenAI GPT-6 Luna.

Implemented against

  • Specification and revision: The scoped direction in issue #2881, docs/reference/required-work-context.md, and docs/reference/protocols/turn-envelope-v0.md at 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc.
  • Criteria:
Criterion Disposition Implementation / regression
Reuse selected-Todo text only after validating the exact current record and lossless full body implemented projectInteractionWorkContext; interaction and work-requirement tests
Remove the duplicate body without dropping unique source details implemented Quota and Turn Envelope projections; canonical-note and source-read regressions
Preserve required reads, freshness checks, recovery instructions, and non-authorization semantics in JSON and Markdown implemented Context projection and exact CLI JSON-to-Markdown regression on both compact paths
  • Self-check: Reviewed the final diff, verified the new commit's DCO trailer, reproduced the instruction loss on both surfaces before the fix, and reran the focused behavior and repository checks below.

Scope And Continuation

  • Completed scope: Reuse one exact selected-Todo body only when a validated current-source read proves it is lossless, while retaining unique canonical notes, relationships, authority metadata, source revision, and the complete work-context instruction.
  • Slice boundary: Complete within this scope. Broader default-summary redesign and multi-surface adoption remain outside this duplicate-body fix.

Validation

  • Tested revision: 06b4b704b4ccec9087028f5dc97dd62b720bd3a5 (base 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc).
  • Run state: Local validation finished; exact-head GitHub checks are running or queued.
  • Input classes: synthetic CLI fixtures.
Check kind Result Evidence
Regression and behavior passed tests/control_plane/test_cli_output_budget.py and tests/test_operator_markdown_renderers.py: 38 passed, including two real CLI cases asserting the full JSON instruction appears exactly once in quota and Turn Envelope Markdown. The same two cases failed on parent head 2d74132e69ed2224e076ae62ac2e09941f0e3d31.
Work-context contract passed tests/control_plane/test_selected_work_requirements.py: 11 passed.
TypeScript regressions passed on parent head; unchanged in this follow-up interaction_contract.test.ts: 13 passed; turn_envelope.test.ts: 29 passed.
Static checks passed Ruff on all changed files, Python compilation, and git diff --check.
Repository validation passed loopx canary premerge --from-git-diff: 19 selected checks, zero failures or manual holds.
  • Coverage and gaps: The CLI regression exercises both compact renderers through actual JSON and Markdown commands. This change does not add a selection-to-detail concurrency fence or claim broader product-level token or latency results.

Frontend / Visual Evidence

  • UI impact: none
  • Before: N/A
  • After: N/A
  • States and viewports shown: N/A
  • Source data: none
  • Attention review: N/A

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring (no functional changes)
  • Documentation update
  • Test update

LoopX Area

  • Control plane (goals, todos, quota, scheduler, registry, runtime)

Technical Direction

  • Direction / acceptance reference: The accepted, bounded duplicate-context direction in issue #2881.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: N/A.
  • Semantic dimensions changed: N/A; no authority schema or provider semantics changed.
  • Provider conformance arms run: N/A.
  • Read-only legacy/file/PostgreSQL rehearsal: N/A.

Boundary Checklist

@mikamikasuki

Copy link
Copy Markdown
Contributor Author

CI follow-up

I reran the crowded quota_should_run JSON measurement at the exact PR base and head with the CI runtime bootstrap used by the output-budget smoke:

  • Base 2244b96f1e2e5c90bef43ae4c140c0994bfcc07a: 35,710 characters (35,000-character ceiling).
  • PR head 8f1b3b72d7fb579b5dc642caee3afffc9f21019a: 35,418 characters.

The PR head reduces this row by 292 characters, while both revisions remain above the absolute ceiling. The kernel-static-checks failure in run 37637529874 is therefore present on the exact base and is not introduced by this PR. The saved evidence records the bootstrap and measurements.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent; model=gpt-6.1-sol; provider=OpenAI; declaration_source=runtime_reported; reasoning_effort=xhigh

Independent exact-head review: 8f1b3b72d7fb579b5dc642caee3afffc9f21019a, immutable base 2244b96f1e2e5c90bef43ae4c140c0994bfcc07a. Two current blocking findings below.

动机

从普通 heartbeat/quota 获取完整任务与停止条件、再开始工作的 Agent 和 CLI 用户。

本 PR 让短任务普通输出从 21,871 缩为 19,138 字符,Turn 短包从 9,835 缩为 7,039;但合法长任务被当成来源变化而阻止交付,短任务的完整续接 note 则随整条 source 删除。

真实 Legacy/File/SQLite 长任务案例在当前 head 3 项失败、基础版本 6 项全通过;真实 File/SQLite 短任务的 note 停止条件在 base 的普通/Turn 包内,在 head 两种包内消失且 delivery_allowed 仍为 true。

不要求等待更大的 GH-C88 默认摘要设计,不新增权威状态或权限;不以缩小字数证明提示语义或模型采用质量。

改动思路

复用现有 TypeScript interaction owner 判定读取完成,Python 只读当前源;去掉重复正文应保留同一 owner 的完整任务 metadata/来源及读取义务。 本 PR 的小范围去重方向已由维护者 #2881 接受;当前 slice 必须先修复长正文误判和 canonical 续接信息丢失,不能以降低预算为由删除这些内容。 selected_todo_projection intentionally bounds text and continuation_hint; the prior exact source is the full carrier. body equality can reuse text, but whole-record omission drops note/source/revision not present in that hot view. Existing full_decision refs can serve detail only with a preserved mandatory read, identity and content hash. Default read model changes, no new native write; mismatch currently marks complete=false/delivery_allowed=false. Short equality currently removes the whole exact record while declaring source fulfilled. Do nothing retains measured duplicate-output defect. A general summary redesign is unnecessary here; body-only equality and preservation of unique metadata is a bounded correction under the existing typed owner. Restore full source whenever the hot body is not lossless.

具体改动

11 files +177/-10: TS interaction/envelope read projections, Python routing/diagnose/Markdown, two protocol docs and three test files. Docs and PR disclose shape, selected ref and local pointer removal; actual long/note regressions require correction before shipping.

Contract: docs/reference/required-work-context.md; docs/reference/protocols/turn-envelope-v0.md; maintainer #2881 comment #2881 (comment), immutable revision 2244b96f1e2e5c90bef43ae4c140c0994bfcc07a. #5844 已接受 full effective current task/readback 与 progressive Goal;维护者允许 bounded 去重,但不授权删除任务续接或把展示摘要当完整权威。 bounded-dedup — implemented: Reuse exactly equal selected body instead of duplicate serialization. complete-long-task — not_met: An unchanged long canonical task remains delivered and usable through actual guard and host. complete-continuation — not_met: Retain complete note/metadata/source obligations while deduplicating the body.

关键代码讲解

  1. projectInteractionWorkContext: At259 byte equality rejects a bounded hot summary; at278 matching short text removes the full unique detail record. Preserve full source or deduplicate text alone.

  2. _compact_selected_todo: Unchanged real producer calls bounded protocol_action_text(limit=320); continuation_hint is also bounded. This source invalidates the assumption that selected_todo is full.

  3. actionProjection: Drops reference-only work_context once action has selected text/ref; other work sources and reads remain. Canonical unique fields must remain reachable.

  4. turnActionProjection: Projects large agent guidance through existing signed full_decision hash earlier to fit emitted pretty JSON; no authority granted by projected guidance.

  5. attach_work_context: Reads real exact source and updates typed channel; false completeness blocks delivery, and local Goal pointer is removed after constructing exact progressive read.

对主干的风险

A valid hot-view summary is falsely classified as changed source; entire full detail removal silently loses unique continuation/stop information while the packet declares it delivered. 真实 guard/exact Todo/TurnEnvelope 和 File/SQLite backend,合成独立 Goal 与过时兼容 Markdown;没有修改活动 Goal。基础版本 subprocess 来源显式隔离。未执行收费模型或已安装 App/Lark adoption。

Independent 245 Python passed /5 failed in chosen broad output/Turn suite, 41 TS passed and typecheck passed. The five failures reproduce among the base output suite (21 passed/6 failed); the previous compact small-packet failure is repaired. Additional current-work suite: head 3 passed/3 failed versus correctly isolated base 6 passed. Four real canonical File/SQLite base/head rows preserve the detail note only at base; default head declares delivery_allowed=true without that tail. Standard premerge: 5 direct passed, 18 of19 selected passed; output-budget regression is failed, not relabelled green. The isolated base premerge stops at small JSON output, while this head stops at crowded output; that run alone does not establish unrelated baseline attribution. The author's later crowded-size comparison is a claim read, not borrowed independent validation. First baseline current-work run used the head editable CLI in generated subprocesses and was invalid for base attribution; PYTHONPATH-isolated immutable base rerun gives 6 passed.

[P1] Deliver full unchanged long tasks instead of rejecting their bounded selected summary

A production selected_todo_projection contains a bounded task body while the exact canonical Todo returns the full unchanged body. New text equality marks the valid source unavailable: Legacy/File/SQLite long-task cases all leave selected_todo pending and hold dependent delivery. The old source fallback delivers the full record. Minimum repair: Use equality only to choose body reuse; when the selected view is bounded/different, preserve the full canonical source after existing identity/lifecycle/claim validation. Validate genuine changes against authoritative snapshot/version instead of the display prefix. Recheck: uv run --extra test python -m pytest -q tests/control_plane/test_selected_work_requirements.py.

[P1] Keep unique canonical continuation and readback when removing duplicate text

A short equal canonical task has a long note ending in a hold condition; File/SQLite authority differs from the historical Goal display. Exact Todo detail retains the hold, but both ordinary and Turn head output omit it; pending reads contain only Goal, complete=true and delivery_allowed=true. Base includes the full note in both carriers. selected_todo contains only a truncated continuation hint. Minimum repair: Replace only duplicate text with a reference while retaining note/relations/source/authority revision, or preserve an explicit mandatory lossless exact-detail read. A mixed/stale Goal document does not substitute for canonical detail. Recheck: uv run --extra test python -m pytest -q tests/control_plane/test_todo_conversation_context.py tests/control_plane/test_selected_work_requirements.py.

语义与 CI 对齐

Full current-task retention is a present accepted obligation; lower characters do not justify removing decision semantics. Advisory is empty and full-tree semantic checks pass, yet real default source/host counterexamples violate this contract. Generic work_context freshness/authority instruction disappears from reference-only Markdown/Turn output; pending Goal read still retains its own reason. No independent equivalence is claimed for dropped general clause; body-only repair must preserve equivalent obligations. Concrete long-body and canonical-note counterexamples already block approval. Feature-off parity is not claimed: default source carrier changes, long work is held and short note is lost. Turn transport being optional does not isolate this default behavior. Agent context remains guidance_only; current task/source consumption and failure hold are obligations. Source completion is machine-enforced and must not be waived as guidance or budget optimization. 本轮未查询、轮询或等待 CI。静态 advisory 空结果不认证语义等价;实际原始记录、生产入口和同输入基础版本对照才是判据。

我的整体评价

REQUEST_CHANGES; delivery judgment not_yet_proven. 长任务正常续接被误阻止,短任务停止条件在 canonical 路径丢失;本轮已复现,需最小 typed-owner 修复。 短包更易读取,但用户需要多余恢复或会漏看后续约束;当前两条实际工作路径不满足完整交付。 复用现有 TypeScript interaction owner 判定读取完成,Python 只读当前源;去掉重复正文应保留同一 owner 的完整任务 metadata/来源及读取义务。 本 PR 的小范围去重方向已由维护者 #2881 接受;当前 slice 必须先修复长正文误判和 canonical 续接信息丢失,不能以降低预算为由删除这些内容。 Future-facing pass: repair through the same typed owner with explicit carrier completeness and body-only reuse; retain metadata and source-specific freshness. Do not add another Python decision rule or standalone capability. Companion regression must cover actual bounded selection, not manually supplied equal objects.

残余边界:未认证安装后的 App/Lark、真实模型遵守、长期 token/延迟收益;现有五项输出预算/旧 scheduler route 断言失败仍保留;canary 的预算失败归属尚未闭合,不标为通过或无关。 这不关闭父 Goal,也不授予 control-plane 合并权限;该 PR 继续交维护者处理。

English verdict: REQUEST_CHANGES - 8f1b3b7; Real current-work tests regress from immutable-base6pass to head3pass/3fail for Legacy/File/SQLite long tasks. Real File/SQLite note-tail probes show default/Turn context loss while delivery remains allowed. Short budgets improve, but neither that nor41 passing TS tests certifies semantic preservation. Five older output tests and a premerge budget failure remain; no CI consulted.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUEST_CHANGES — the two previous canonical-content blockers are repaired, but the new compact Markdown branch drops work-context obligations.

动机

使用 quota/Turn Envelope 的 Agent,以及依赖它长期推进和恢复任务的用户。使用 quota/Turn Envelope 的 Agent 每轮读取当前任务;之前重复接收同一短正文,现在正文只保留一份,长任务和独有 note 仍完整送达。

当前真实 CLI 的长任务和 short-note 回归通过;同一96行场景中小 quota 从21871降至19196字符、Turn JSON从10498降至7650,但两个 Markdown 路径删掉必读、新鲜度、恢复和非授权指令。

不证明全部GH-C88、用户前端导航改进、真实模型采用或不同领域多Goal长期token/延迟。整体默认输出精简、真实模型多轮采用和净token/延迟收益未验;本切片必须先恢复 Markdown 指令,并把已有并发正文新鲜度缺口留给 work-context/selection owner。

改动思路

此轮审阅 exact head 09b34d760a53bbf6b18055b0698a0812d06f076c,以 immutable base 7be8943a40d1804ef80f34484598b3e49baf7af7 对照整个15文件、458新增/25删除切片。spec_ref:docs/reference/required-work-context.md、docs/reference/protocols/turn-envelope-v0.md 和 #2881 已接受的维护者方向;spec_revision:7be8943a40d1804ef80f34484598b3e49baf7af7。C1 完整正文及独有note/关系/来源修订、C2 身份/生命周期/claim与精确正文去重、C3 每种调用形式保留必读/新鲜度/恢复/非授权义务、C4 同一quota/Turn owner的有界输出。C1/C2的有界读回与C4成立;C3未满足。新增snapshot检查仅在调用者提供hash时有效,不能证明生产准入正文fence。

单一 typed fulfillment owner 加同源完整读回适合这个去重问题;正文去重不能把模型执行义务一起删除。在本 PR 两个 Markdown 分支各保留一次完整指令,复测正文单份/长正文/note/恢复;若650字符 ceiling容不下必要指令,按同一base/head语义对照作有据预算决策。Python负责完整来源IO,TS仍是唯一fulfillment规则源;没有新增authority store、CLI开关或自动授权。默认输出形状会改变,不能称feature-off逐字节不变。既有前端/Lark配置无需新增用户操作;本次检查的是实际CLI体验,未验证打包前端采用。

具体改动

关键代码讲解

  1. _source_content(context_readback.py:21)直接读完整canonical File/SQLite记录;legacy从完整Goal读取正文并核对两次读取间修订。它修复长任务因为320字符显示摘要而被错误拒绝,canonical note不被摘要替代。
  2. projectInteractionWorkContext(interaction_contract.ts:237)核对ID、状态与claim;只有正文完全相等才用selected_todo_ref复用,独有note/关系/authority保留。完整来源与显示摘要不同则保留完整来源。供入hash时确实检查SHA;全树生产搜索与实测未发现选择路径生成hash。
  3. actionProjection(turn_envelope.ts:593)把同一内容投射到Turn,保留selected_todo_authority;较早压缩的agent_context仍通过签名full-decision detail_ref取回。这是投影变化,不是新准入权限。
  4. work_context_lines(turn_envelope_markdown.py:7)和quota_markdown.py:710新增reference-only早返回:它们忽略仍存在于JSON的instruction。这不是仅删除第二份正文。

真实CLI正向:Legacy/File/SQLite长任务全文,以及File/SQLite短正文带独有note和provider修订,在普通quota与Turn都保持;当前20项Python、42项TS和typecheck/Ruff通过,原两条P1逐项得到独立验证。真实CLI负向:相同公共small fixture在base的quota/Turn Markdown有完整工作上下文指令;head短任务分支只剩complete/ref/authority。普通quota仍列Goal读取命令,但丢了“工作前”条件、后续新鲜度、恢复fresh guard与非授权解释。不能把complete=True当已消费所有必读项。

语义与CI对齐

当前19项native premerge加5项direct检查全部通过,包含输出预算、语义词表和公共边界。semantic advisory的0项不覆盖动态JSON字段或指令语义。未查询或等待GitHub CI。使用同一当前probe/fixture分别跑immutable base/head的96行实际CLI测量(measurement模式本身不执行预算断言;premerge另行执行):quota小JSON 21871→19196字符,Turn JSON 10498→7650,多subagent Turn 11426→8541,正文去重的局部收益可见。但字数/形状/绿测试不证明指令等价。

对主干的风险

**[P1] 保留两个Markdown路径的执行义务。**触发是短正文完全匹配且无额外work-context事实。turn_envelope_markdown.py:9–16和quota_markdown.py:710–717返回引用行时丢弃整个instruction,实际base/head CLI已证实:工作前读取current/pending sources、不要重复本轮已完成读取、之后核对来源新鲜度、不可用/变化后恢复并重新guard,以及context不授予权限,全都从head Markdown消失。JSON仍保留它们,调用者不能靠JSON字段在另一表示中的存在补齐自己没收到的语义。请在两条compact路径各输出一次这些义务,再验证body单份、来源修订、pending reads、long/note及失败恢复;预算容不下必要说明时保留语义并作有据预算决策。

另一个明确保留的相关缺口:在合成隔离的真实File/SQLite authority中,用原生CAS在选择与detail之间只改正文、保留ID/状态/claim;base和head都返回complete/delivery_allowed。本轮不把它算新增回归,也不称snapshot mismatch单测已经证明生产fence。既有selection/work-context owner仍需接上实际正文快照或明确同等freshness规则;不要把provider_revision观察值误称准入hash。没有用活跃Goal做测试或修改真实任务。

我的整体评价

正文单份、长任务不中断、canonical note不丢,分别减少重复阅读、假阻塞和恢复时遗漏;这些是已验证的正向效果。当前受阻的是同一精简路径删掉长期继续所需的约束:局部输出更小,整体语义仍有负向回归。单一 typed fulfillment owner 加同源完整读回适合这个去重问题;正文去重不能把模型执行义务一起删除。在本 PR 两个 Markdown 分支各保留一次完整指令,复测正文单份/长正文/note/恢复;若650字符 ceiling容不下必要指令,按同一base/head语义对照作有据预算决策。

整体GH-C88、真实模型多轮净token/延迟、不同领域Agent采用仍未验证;单次尺寸和测试数不代表长程效率。没有合并、升级或关闭整体Goal。旧review的两条原问题已解决,这条新增Markdown语义阻塞应在新exact head修复后再验。

English verdict: REQUEST_CHANGES. Preserve the work-context instruction in both reference-only Markdown paths. Exact-body deduplication, complete long requirements and canonical notes are independently verified; the pre-existing File/SQLite selection-to-read body race is disclosed separately and is not claimed as a new regression. Current local checks pass, but they do not cover the lost prose obligations. No fleet/token/latency or merge-readiness claim.

Reviewer: model_agent; OpenAI gpt-6.1-sol; reasoning effort xhigh; runtime_reported; execution observation 8284886a42e8c01490ddf6cd2d31c0828f94896eff0d058d4d2b9e04b1dedbb8.

@mikamikasuki

Copy link
Copy Markdown
Contributor Author

Fixed in d468347. Both compact Markdown renderers now retain the work-context instruction once beside the reference. The real CLI and renderer regressions pass with the focused 19-test suite; Ruff, Python compilation, and diff checks pass. The separate selection-to-detail concurrency case is explicitly left outside this follow-up. Current-head CI has started and is still pending.

loopx-agent
loopx-agent previously approved these changes Oct 7, 2026

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent; OpenAI gpt-6.1-sol; reasoning effort xhigh; runtime_reported; execution observation a41f2c61cf4a8bf720774e126e6db751e223a479efdbbd66a149d9eb0827b075.

Exact head: d468347; base: d605f73.

动机

使用 quota 和 Turn Envelope 的 Agent,以及依赖它持续推进和恢复任务的用户。Agent 读取一个短任务时,以前同一正文在行动和工作上下文中各出现一次;现在正文只携带一份。长任务继续提供完整来源,独有备注也保留,Markdown 会明确说明何时必读和重新检查。

真实 CLI 复验确认两个 Markdown 路径恢复执行说明;长正文和独有备注通过。相同 96 行场景中小 quota JSON 从 21871 降为 19196 字符,Turn JSON 从 10498 降为 7650 字符。

本次不证明全部默认输出精简、真实模型多轮净 token 或延迟收益,也不关闭多 Goal 不同领域 Agent 的整体业务验收。选择与详情之间只改正文的 File/SQLite 并发缺口在基线和上一版都存在;生产选择路径尚未生成正文快照。本 PR 只完成单份内容及表示保真的切片。

改动思路

单一 TypeScript fulfillment owner 加完整来源读回适合这个有界问题;当前两个 Markdown 调用已复用同一渲染器,消除了重复分支导致的语义遗漏。完成当前正文去重、完整内容和执行说明保留;不扩张到新的准入快照协议、整个默认输出设计或真实 Agent 长期成本验收。完整来源 IO 仍在 Python 适配层,是否履行读取及可否复用正文仍由原 TypeScript owner 决定。不是把完整任务改成摘要:320 字符行动视图不足时保留完整来源;短正文相等时仅移除重复正文,独有备注、关系和来源修订仍送达。当前无新 CLI 开关、authority store 或生命周期授权。普通 quota、Turn 和 diagnose 复用这个路径;当前 quota 调用共享 Markdown formatter 已在基线中,跟进修复其共享函数即可覆盖两个调用者。

具体改动

规范依据:docs/reference/required-work-context.md 与 docs/reference/protocols/turn-envelope-v0.md,规范修订 d605f73720c48c5f9bc4cbb5bd669352e7dcc709;#2881 维护者接受的有界方向。C1 完整正文/独有事实,C2 当前身份生命周期 claim 及精确正文去重,C3 每种表示保留必读、新鲜度、恢复和非授权义务,C4 使用既有 quota/Turn owner 作有界输出;本切片均已实现。生产准入正文快照不是已实现的 C2 扩张承诺。

关键代码讲解

  • _source_content(context_readback.py:21)直接读当前完整 canonical 或 legacy 内容;legacy 两次读取间修订变化拒绝继续。原长正文 P1 已由真实 Legacy/File/SQLite CLI 复验解决。
  • projectInteractionWorkContext(interaction_contract.ts:237)用 ID、状态和 claim 核验来源,正文相等才去重;独有备注、关系和 authority 保留,原短任务丢备注 P1 已解决。供入 hash 时可验证,但实际选择路径尚无其 producer。
  • actionProjection(turn_envelope.ts:593)保留同源 work_context 与 authority;更早的 guidance 投影仍可通过签名 full-decision 引用读全,不新增权限。
  • work_context_lines(turn_envelope_markdown.py:7)现在在 reference-only 行后输出一次完整 instruction,quota 与 Turn 都调用它。新实际 JSON/Markdown 对照证实原第三条 P1 解决;Goal 完整必读项仍保留,complete 不代表已读完 Goal。

当前 25 项 Python、42 项 TS、typecheck 和 Ruff 通过。完整 14 文件 +563/-25 的本次 diff 已复核;前一 head 的来源读取、选择和 typed projection blob 未变,三处修复/测试 delta 重新检查。真实 paired 96 行/arm 中:quota JSON 21871→19196,Turn JSON 10498→7650,多 subagent Turn 11426→8541;quota Markdown 8690→6133,Turn Markdown 3949→907。测量模式不执行预算断言;当前 canary 单独执行预算检查并通过。

对主干的风险

默认 work-context 形状确有变化,两份正文成为一个引用和完整 unique facts;这不是 feature-off 逐字节相等承诺。独有 note、来源失败及生命周期/claim 门禁有真实回归覆盖。最危险的反例原先是正文精简时删除执行说明;当前两条真实 Markdown 路径都保留当前/pending 必读、不要重复 fulfilled reads、之后重验来源、不可用或变化后恢复并 fresh guard、context 不授予权限。instruction 从两份变成一份,没有靠字段相等推断 prose 等价。

此前实际 File/SQLite 的选择到详情正文并发,在基线和前一 head 都宽松;当前相关 blobs 未变,未重复运行或把它称新回归。新完整正文与来源 revision 是观察,不是准入快照 fence。该缺口由既有 selection/work-context owner 处理,作者也明确没有关闭它。无活跃 Goal 测试、模型任务、账户或权限改变;用户前端/Lark没有新增操作,未声称当前 CLI 切片已关闭它们的整体采用。

语义与 CI 对齐

当前 exact-head 原生 canary 19 selected +5 direct 全通过,零失败、跳过或 manual hold;包含语义、输出预算与公开边界检查。advisory0 不覆盖动态 JSON 或语义,另有实际指令比较。未查询或等待 GitHub CI,合并资格另行读回。使用既有 typed vocabulary/owner,display marker 保持 local,不引入新共享闭集。

我的整体评价

APPROVE。long_horizon 与 user_experience 在这个切片中均 improved:反复读取不再携带重复短正文,长任务不假阻塞,独有事实和恢复义务保留;可观察的本地尺寸收益与当前语义证据一致。单一 TypeScript fulfillment owner 加完整来源读回适合这个有界问题;当前两个 Markdown 调用已复用同一渲染器,消除了重复分支导致的语义遗漏。完成当前正文去重、完整内容和执行说明保留;不扩张到新的准入快照协议、整个默认输出设计或真实 Agent 长期成本验收。没有以绿色预算测试取代义务分析;相邻的 bounded future-facing pass 已实际统一 formatter。真实模型和多领域多 Goal 的净成本/持续效果仍待独立验收。当前已逐项解决之前三条 P1;保留并发来源快照的既有缺口,不合并或升级。

English verdict: APPROVE at d468347. All three prior content/Markdown findings are independently resolved for the reviewed slice. Current real CLI comparisons preserve full long requirements, unique canonical facts and every work-context obligation while reducing duplicate output. 25 Python, 42 TS and 19 selected plus 5 direct canary checks passed. The pre-existing concurrent-body selection boundary and real fleet/model net-cost qualification remain separate; approval is not merge authority.

@mikamikasuki

Copy link
Copy Markdown
Contributor Author

CI follow-up

The failed test shards include the deferred todo_done case in test_causal_blocked_closeout_cli.py. I reproduced that case on canonical main 8beff600 and fixed the test-only command order in PR #5912: acquire the lease while the Todo is runnable, then defer it atomically with the pending wait. No product behavior is changed by that fix. I will track #5912's checks before deciding whether this branch needs any CI refresh.

@mikamikasuki

Copy link
Copy Markdown
Contributor Author

Selection-to-detail freshness follow-up

The selection-to-detail mutation regression now reproduces on current main 159f00fc: both the File and SQLite cases fail because the selected projection has no content_revision. The same two cases pass on PR #5911 head 40c97136 (2 passed). That PR carries the full-text revision through selection and verifies it at readback.

@mergify

mergify Bot commented Oct 8, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @mikamikasuki.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Oct 8, 2026
@huangruiteng

Copy link
Copy Markdown
Collaborator

有冲突

@mikamikasuki
mikamikasuki force-pushed the codex/loopx-2881-selected-todo-context branch from d468347 to 3488d6f Compare October 8, 2026 03:28
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Oct 8, 2026
Signed-off-by: mika <211269698+mikamikasuki@users.noreply.github.com>
Signed-off-by: mika <211269698+mikamikasuki@users.noreply.github.com>
Signed-off-by: mika <211269698+mikamikasuki@users.noreply.github.com>
Signed-off-by: mika <211269698+mikamikasuki@users.noreply.github.com>
@mikamikasuki
mikamikasuki force-pushed the codex/loopx-2881-selected-todo-context branch from 3488d6f to 2d74132 Compare October 8, 2026 04:42
@mikamikasuki

Copy link
Copy Markdown
Contributor Author

Synced the branch to canonical main at 82d1b83 after the conflict notice; all four signed commits are rebased on the current base. The updated head 2d74132 passes 60 focused Python tests, 42 related TypeScript tests, control-plane typecheck, Ruff, Python compilation, diff checks, and 19 selected pre-merge checks with zero failures or holds. I updated the PR description with the current task scope, before/after behavior, regressions, exact tested base/head, and validation results. GitHub reports the branch mergeable; exact-head CI is running or queued, with code-owner review still required.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=xhigh

English verdict: REQUEST_CHANGES — exact head 2d74132e69ed2224e076ae62ac2e09941f0e3d31 reintroduces the reference-only Markdown instruction loss. The body deduplication and local checks pass; losing current-work obligations still blocks approval. No CI was queried or awaited.

动机

依赖普通 quota 或 TurnEnvelope Markdown 推进任务的 agent 和操作者会受到这项改动影响。同一个选定 Todo 正文原先在热区和 work_context 中重复出现;本改动只复用确实相同的正文,保留完整长文本、独有 note/关系/authority 和剩余必读项。真实 CLI 已能省去短正文的重复,但 reference-only Markdown 同时删掉了依赖前必读、后续 freshness 重验、恢复后 fresh guard 和不授予 authority 的操作约束。本 PR 不改变 Todo 选择/准入/claim/lease/quota 权限,也不替代 GH-C88 的整体默认摘要设计或证明模型采用。本轮必须修复两个 Markdown 分支的操作约束丢失;整体默认摘要、模型采用和跨进程选择到详情的更强事务 fence 保持原 owner 的既有边界。

改动思路

正文去重属于既有 typed interaction owner;Python 读取真实 canonical/legacy内容,TS 判断身份、生命周期、claim、revision和正文是否可复用,formatter只负责投影。当前 PR 交付完整约束不变的正文去重及其 shared projection;两种 Markdown 必须在本 PR 修复,整体默认摘要和更强跨读事务仍由现有 owner 后续处理。 已完整准入且相同的正文可以引用一次;独有 note/relations、authority revision 和操作约束不能视为冗余。完全取消 source read 会失去真实内容/生命周期核验;另建 selector 或 Python 决策 owner 也没有必要。

具体改动

完整 base 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc → head 为15文件、+461/-29。发布前发现旧 head 3488d6f5190e03ec6b4eeb276f87ec92b9c4c9e6 已更新,旧结论未发布。重新取得完整 packet、当前 accepted base docs 和当前 base/head diff:15 个改动文件在旧/新 base 及旧/新 head 中逐个 blob 相同。新主干相邻 effect-runtime 路由 delta 仅新增 content-reference handlers、调整 Node 错误类型和 server info 权限发布;当前 work-context owner 未被替换。仍在新 exact head 重新执行53 Python、42 TS、typecheck、5direct+19selected premerge,并以同一个真实 CLI fixture/harness对照当前 base/head。未用旧运行替代当前版本。

当前15文件全 diff及周边 source/selection/projection/renderer读取完成,旧批准 d4683473 已失效,未继承。维护者 issue comment 6035382620 同意有界去重、向统一 quota packet/TurnEnvelope 方向推进;该批准不授权移除操作约束。

接受规范先于实现读取:docs/reference/required-work-context.md,固定到 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc;同时读取该 revision 的 docs/reference/protocols/turn-envelope-v0.md 相关义务。原文标题 Required work context 下的完整正文、独有 metadata 与 pending read carrier 在 JSON implemented。段落 Source failure retains the unresolved read 的恢复后 fresh guard、原文 Reading current content is not an execution grant or proof of Goal completion. 的 authority 边界在 reference-only Markdown 未满足。这里以原文段落/标题识别 criteria,未发明新的编号或 roadmap gate。

关键代码讲解

  • _source_content(context_readback.py:22)读取完整 canonical record,legacy 分支再读 state bytes并核对刚读的 Goal revision;保留 current source revision,而不是把 bounded list当全文。
  • projectInteractionWorkContext(interaction_contract.ts:238)验证 exact Todo身份、状态、claim和正文/revision;短正文只省 text,独有 note/relations和authority留在source。bounded body保留canonical全文;供应 snapshot不符仍pending。
  • actionProjection(turn_envelope.ts:593)采用同一work_context/read owner;不能将 source availability 当成所有 pending reads已消费。work_context_lines(turn_envelope_markdown.py:7)与 quota formatter 的 compact 分支却没有输出instruction。

[P1] reference-only Markdown 再次丢失 current-work 操作约束

定位 loopx/presentation/renderers/turn_envelope_markdown.py:9–18 及 quota_markdown.py:710–720。这两个新分支只打印 complete/ref/authority;字段允许 instruction,却不输出它。同一实文件小场景,base 的普通 quota/TurnEnvelope Markdown 都包含完整 work_context.instruction;新 head 的 JSON 保留完整 instruction,但两种 Markdown 都缺失它,required_reads 仍存在。53 Python、42 TS 和标准 premerge 全绿不覆盖这个 oracle。

独立期望来自接受的工作契约,不来自预算 fixture:依赖动作前消费current sources/pending reads、不得重复本次已满足的读取、后续动作重新核验 freshness、unavailable/changed source 恢复并获取 fresh guard、读取不授予authority。新JSON仍携带这些条款;新Markdown全数丢失。本轮真实CLI小场景测得 ordinary Markdown8984→5912字符、Envelope4133→632字符;这些只是输出成本,不能证明条款等价或模型理解。

复现:从当前 tests/control_plane/test_cli_output_budget.py 的 _write_fixture(SCENARIOS[0]) 生成隔离fixture,以 _surface_commands 的 quota_should_run 和 _mode_variant_commands 的 quota_should_run_turn_envelope 分别运行 JSON/Markdown。取得当前JSON work_context.instruction 并断言其完整语义出现在对应Markdown;base两条均通过,新head两条均失败。现有新增renderer test只检查compact reference和没有大section,未断言保留instruction。

最小修复:两种 Markdown reference-only 分支保留完整 instruction 一次,尽量共用 work_context_lines,避免两个副本再次偏离;新增真实 quota/TurnEnvelope JSON→Markdown语义回归,并按独立预算证据保留有用约束,不能靠删义务换预算。 旧 09b34d... review指出过同一缺陷,作者曾在 d4683473 保留instruction;当前新head并未保留该修复。它是未解决的当前finding,不能以review年代或更新head为理由dismiss。

对主干的风险

53 Python tests(包括真实 CLI 预算矩阵、legacy/File/SQLite scoped User gates、长文本与 canonical note),42 TS tests、control-plane typecheck 和5direct+19selected premerge 全通过。实际 base/head CLI pair确认 exact sources与pending reads保留,但 Markdown instruction 回归。 供应 full snapshot changed、missing/ambiguous/source unavailable、独有 canonical note及scoped User gate由当前suite覆盖;真实current JSON→Markdown pair才暴露语义丢失。新 _context_text_sha256只消费已有上游producer携带的snapshot;未携带时display-only分支接受current exact canonical read。更强selection-to-detail事务边界独立处理,不将已存在的并发缺口伪装为本PR新回归。

语义与CI对齐

复用既有TS work-context owner,没有 substring denylist、域特定通用义务或新的权限来源。此项是普通输出的默认变化,docs明确相同正文ref与metadata保留;没有opt-in/default-off声称。保持pending Goal全文读取和source failure hold,不能把机器义务降为省略的guidance。未测试模型采纳、跨进程长时间并发、真实外部发布或新的packaged frontend交互;本PR没有新增frontend设置/操作入口。

我的整体评价

有界去重有实际价值且owner归属合理;当前不能批准。未来改动的最小收敛是两种Markdown共用一份完整formatter,在预算fixture之外用契约语义作oracle。正文去重属于既有 typed interaction owner;Python 读取真实 canonical/legacy内容,TS 判断身份、生命周期、claim、revision和正文是否可复用,formatter只负责投影。当前 PR 交付完整约束不变的正文去重及其 shared projection;两种 Markdown 必须在本 PR 修复,整体默认摘要和更强跨读事务仍由现有 owner 后续处理。

Signed-off-by: mika <211269698+mikamikasuki@users.noreply.github.com>
@mikamikasuki

Copy link
Copy Markdown
Contributor Author

Fixed in 06b4b704. Both compact Markdown paths now use work_context_lines and include the full work_context.instruction exactly once beside the selected-Todo reference. I added real CLI JSON-to-Markdown regressions for ordinary quota and Turn Envelope; both failed on parent head 2d74132 and pass on this head. Validation on 06b4b704: 38 output-budget/renderer tests and 11 work-context contract tests passed; Ruff, Python compilation, diff checks, and 19 selected pre-merge canaries passed. GitHub exact-head checks have started.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=xhigh

English verdict: APPROVE — exact head 06b4b704b4ccec9087028f5dc97dd62b720bd3a5, base 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc. The complete short/long task, unique canonical facts, pending reads and work-context obligations survive the real CLI paths. Both parent-version instruction regressions fail and the fixed head passes. 55 current Python tests and 5 direct plus 19 selected premerge checks pass; 42 TS tests and typecheck are explicitly reused from the unchanged parent typed/dependency tree. No GitHub CI was queried or awaited. Approval does not grant merge authority or prove model/fleet adoption.

动机

依赖普通 quota 或 TurnEnvelope Markdown 推进任务的 agent 和操作者会受到这项改动影响。
同一个选定 Todo 正文原先在热区和 work_context 中重复出现;本改动只复用确实相同的正文,保留完整长文本、独有 note/关系/authority 和剩余必读项。
真实 CLI 复验确认短正文只复用一次,长正文和独有 canonical note 保留,两种 Markdown 均恢复完整工作约束及 pending reads。
本 PR 不改变 Todo 选择/准入/claim/lease/quota 权限,也不替代 GH-C88 的整体默认摘要设计或证明模型采用。
依赖同一任务反复工作的操作者不用重复读取已送达的正文,同时仍能看到何时重验、如何恢复及权限边界。本次验收的是有界去重和表示保真,更广默认摘要、模型采用与并发快照不由输出字数或本轮测试代替。

改动思路

正文去重属于既有 typed interaction owner;Python 只读取真实 canonical/legacy 内容,TS 判断身份、生命周期、claim、revision和正文可复用性,共用 formatter 负责两种 Markdown 投影。
完成当前正文去重、完整来源及工作约束保真的有界切片;整体默认摘要、模型采用和更强选择到详情事务仍保持既有 owner 的边界。
不做改动会保留每轮重复正文;只删除整个 source 会丢掉 note、关系和修订;另建选择器或 Python 决策规则又增加第二权威。当前只复用字节相同的正文,显示摘要不足时继续提供真实全文,独有 metadata 不被视为冗余。来源失败保留必读命令并阻止依赖工作;complete 只表示来源可用,不代表已经消费剩余 Goal 全文。已应用相关简化:quota 删除重复 compact 分支,调用既有 work_context_lines;不增加第二权威或新的兼容模式。

具体改动

完整 base 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc → head 06b4b704b4ccec9087028f5dc97dd62b720bd3a5 的14文件、+512/-27已复核,包含来源 IO、typed fulfillment、Turn 投影、diagnose 概览、两份协议文档、IO census和五份测试。前一次 head 2d74132e69ed2224e076ae62ac2e09941f0e3d31 → 当前只有两种 renderer 和两份测试的修复 delta;其中 quota 回到既有 shared formatter,所以不再出现在 whole-PR 净 diff。11个当前 PR blob不变,base不变;完整 TS、锁定依赖及相关 owning caller 也无变更,明确复用该父版本42项 TS与typecheck证据,不称本轮重新运行。

规范先于实现读取:docs/reference/required-work-context.md 与 docs/reference/protocols/turn-envelope-v0.md,固定修订 82d1b837479dd5eb64b581bb0ca36d8c1ff1f0cc;维护者在 #2881 的接受方向 允许有界去重。head修改的文档不是独立判据。以原文标题/段落识别:Required work context — implemented,完整正文、独有 metadata和pending read;Source failure retains the unresolved read — implemented,恢复后fresh guard与源故障hold;Reading current content is not an execution grant or proof of Goal completion. — implemented,真实两种Markdown都保留非授权解释。没有新增roadmap编号或用未来要求阻止有界修复。

关键代码讲解

  • _source_content(context_readback.py:22)从当前 canonical File/SQLite 读完整记录;legacy读取state bytes并核验刚读的Goal修订,不把320字符显示摘要当全文。Python仍是IO适配。
  • projectInteractionWorkContext(interaction_contract.ts:238)核对ID、生命周期、claim和正文修订;只有相同正文才用ref,独有note/关系/authority保留。供入完整snapshot不符保持pending;未提供snapshot的实际跨进程选择fence没有被宣称完成。
  • actionProjection(turn_envelope.ts:593)投射同一typed context/pending read;guidance预算reserve提前走已有full-decision引用,不增加权限。diagnose._goal_list_view只去掉概览中的第二份选定读取计划,selected仍保留完整carrier。
  • work_context_lines(turn_envelope_markdown.py:7)compact分支在ref/authority后输出完整instruction一次。quota和Turn都调用它,不再各维护一个分支;两个真实CLI回归断言JSON指令出现在对应Markdown一次。

本次已逐条核对旧review:5445353728的长任务误阻塞、canonical note丢失由当前Legacy/File/SQLite真实测试验证修复;5446980105及5451642001的Markdown约束缺失由当前实CLI/父版本敏感性验证修复。旧5447876405的已撤回批准未继承。本轮新结论建立后再走原生closeout;review年代或head更新本身不证明finding解决。

对主干的风险

当前55项Python通过,包括长正文、File/SQLite独有note/scoped User gate、missing/ambiguous/source failure、legacy修订改变及完整CLI输出预算。两个新增实际CLI回归在父版本均失败、在修复head通过;独立同harness的base/head JSON→Markdown两条输出均保留完整instruction和pending reads。当前head普通Markdown6177字符、Turn907字符;父版丢约束时632字符的更小Turn不是正确性收益,不删义务来满足尺寸。

语义与CI对齐

原生premerge本轮5direct+19selected全通过;复用的42TS/typecheck来自精确父版本和完整typed/dependency tree无变化检查。复用既有typed vocabulary/owner,display marker保持local;没有substring分类、域特定通用义务或新的权限来源。普通默认carrier形状改变已在两份文档披露,没有opt-in/default-off声称;机器source hold与pending read不能降为guidance。基线措辞和当前措辞逐条比较,保留before-work读取、fulfilled不重复、后续freshness、unavailable/changed恢复fresh guard与no-authority。

更强File/SQLite选择到详情正文事务fence是旧base/旧head都存在的缺口,本次相关owner未变,不伪装成新回归或宣称snapshot单测关闭它。source与真实隔离文件经过验证;模型理解、长时间跨进程并发、真实外部效果、已安装App/Lark采用未验。没有新用户操作/配置入口,本切片不以CLI通过声称完成这些产品旅程。

我的整体评价

APPROVE。在已接受的有界切片中,long_horizon 与 user_experience 均 improved:反复工作少一份重复正文,合法长任务可继续,独有事实、真实来源修订和恢复义务保留。正文去重属于既有 typed interaction owner;Python 只读取真实 canonical/legacy 内容,TS 判断身份、生命周期、claim、revision和正文可复用性,共用 formatter 负责两种 Markdown 投影。 完成当前正文去重、完整来源及工作约束保真的有界切片;整体默认摘要、模型采用和更强选择到详情事务仍保持既有 owner 的边界。 已应用相关简化:quota 删除重复 compact 分支,调用既有 work_context_lines;不增加第二权威或新的兼容模式。 当前全PR风险与机制成本相称,旧三个实际内容/表示缺陷均已有对应证据;完整业务采用、并发快照、维护者合并和安装升级仍分别保留。没有把绿色测试、review或readiness当合并授权或整体Goal验收。

@huangruiteng
huangruiteng merged commit 21707b7 into loopx-project:main Oct 8, 2026
24 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants