Skip to content

Read only matching task leases for Agent status - #8561

Merged
huangruiteng merged 5 commits into
mainfrom
codex/select-status-lease-snapshot-20261111
Nov 11, 2026
Merged

huangruiteng merged 5 commits into
mainfrom
codex/select-status-lease-snapshot-20261111

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Status collection supplied both quota guards with lease evidence by reading the full canonical Todo snapshot into Python. With one selected Todo and 320 archived Todos, the two status reads returned about 950 KB of internal RPC data. The status caller already supplies the open Todo IDs it observes. The canonical snapshot owner now returns the matching lease records after validating the full provider head. Selection and continuation bind to one provider revision.

This head is rebased onto main at e251264bca5d003995ccc122b874341b4148b8f4. The conflict with newer compact-contract reads was resolved by preserving both include_contract_rows and lease selection, while rejecting lease-only reads combined with a Todo summary or projection confirmation.

Author Declaration

  • Written by: model_agent, OpenAI Codex (GPT-6 family).

Implemented against

Criterion Disposition Symbol or path Verification
Validate the complete canonical source before transporting selected leases implemented loopx/control_plane/coordination/canonical_snapshot_page.ts File, SQLite and real PostgreSQL lease-selection tests; malformed projection remains a projection failure
Return only matching lease records for observed open Todo IDs, with no Todo payload implemented loopx/control_plane/agents/execution_facts.py Matching active/released leases, empty match, missing lease and read-only authority checks
Bind selection and every continuation page to one Goal, store incarnation, provider revision and query digest implemented loopx/control_plane/coordination/canonical_snapshot.py Reordered selectors are canonicalized; changed selection and escaped rows fail closed
Preserve newer compact Todo-contract reads without mixing them with lease-only transport implemented loopx/control_plane/coordination/local_authority.py Lease selection with summary, projection readback or disabled leases is rejected before provider work

The bounded refactor removes the obsolete per-Todo unreadability branch after canonical cutover. It adds no cache, persistent state, write authority or provider-specific query.

Scope And Continuation

This slice covers the status observation used by quota preflight and Agent management. #8560 addresses the separate read owned by quota preparation. Installed adoption and whole-Turn model cost remain program acceptance work.

Repair And Conflict Resolution

  • Rebased over the latest tested main and resolved the compact-contract conflict without dropping either behavior.
  • Added a regression that rejects lease-only reads mixed with Todo summary or projection readback.
  • Extended the lease-selection test to File, SQLite and a disposable real PostgreSQL authority store.
  • Reconciled concurrent content-digest inventory changes during rebase; the final diff contains no incidental digest-owner changes.
  • No UI or public protocol surface changes.

Validation

  • Tested revision: 48fdf95819c119abf6867078f643471cdb5ffe52
  • Run state: finished (local qualification).
  • Input classes: synthetic, public_fixture, and disposable live backend.
Check kind Result Public-safe evidence or limitation
integration passed 144 focused Python tests passed across canonical snapshot integration, Agent lifecycle and quota execution preparation on File and SQLite; the transport-admission module also passed in the preceding full run.
real_backend passed Isolated PostgreSQL 16.2 authority-store suite passed 392 tests. The same run executed the 48-test canonical snapshot page suite with File, SQLite and PostgreSQL, all passing.
regression_parity passed Continuation rejects a changed selector; lease-only transport rejects mixed summary/readback; malformed projections still fail with the original projection error; all reads leave authority unchanged.
static passed TypeScript control-plane type checking, bilingual RFC diff and DCO checks passed.
performance evidence preserved The original real-entrypoint qualification reduced status guard RPC result bodies from about 3,045,671 to 2,100,209 bytes on File and from 3,046,004 to 2,100,542 bytes on SQLite.
uv run --extra test python -m pytest -q \
  tests/control_plane/test_canonical_snapshot.py \
  tests/control_plane/test_canonical_snapshot_integration.py \
  tests/control_plane/test_agent_lifecycle_state.py \
  tests/control_plane/test_quota_execution_preparation.py
node --no-warnings --experimental-sqlite --experimental-strip-types --test \
  tests/control_plane_ts/canonical_snapshot_page.test.ts \
  tests/control_plane_ts/content_digest_single_owner.test.ts
npm run -s test:postgresql-authority-store
npm run -s typecheck:control-plane
uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD

Frontend / Visual Evidence

  • UI impact: none.
  • Source data for visuals: none.

Type of Change

  • Refactoring
  • Test update

LoopX Area

  • Control plane

Shared-authority RFC fixture impact

N/A. This delivery scopes an existing snapshot response without changing the authority contract.

Boundary Checklist

  • Public-safe diff and evidence.
  • Scope matches the observed status transfer.
  • Bilingual diff check passed.
  • UI impact is none.
  • The commits include DCO sign-off.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max

评审提交:8a564f263d0718b10803d1f622e3b76d26470531

动机 / Motivation

查看 Agent 状态或运行 quota preflight 时,系统需要判断当前工作涉及哪些有效、过期或无法读取的租约。旧实现跨进程返回完整 Todo 和 lease 快照,Python 再从中筛选状态所需的租约。当前实现先由 TypeScript 校验完整来源,再把状态已经看到的 Todo 对应租约传给 Python。在含 320 条归档的同一状态夹具中,File 的这一读取从 2,144,365 降到 3,197 字节,SQLite 从 2,144,379 降到 3,211 字节。五个 Agent 状态一致。过期活动租约仍显示 unknown,关闭 Todo 的租约不会影响状态。来源损坏时仍显示 unavailable,续页更换选择范围会拒绝。测量覆盖单次 status 租约读取的 UTF-8 JSON 结果。端到端耗时、模型用量和 Windows 运行环境仍待验证。测量覆盖单次 status 租约读取的 UTF-8 JSON 结果。端到端耗时、模型用量和 Windows 运行环境仍待验证。

改动思路 / Approach

沿用现有 canonical snapshot、状态判定和权限边界。选择条件随快照续页校验。只收窄状态所需的传输。整份来源的版本、内容和 lease 关系继续由 provider 校验。 状态入口已有本轮可见 Todo 的 ID。读端用这些 ID 选择租约,快照仍校验完整 canonical 来源、版本及关系。Python 校验分页和返回范围,再用原到期规则计算 Agent 状态。

具体改动 / Changes

关键代码讲解

七个文件,+128/−42。按基线核对 agent-state-parity、canonical-failure-and-live-lane 和 same-revision-lease-read。TypeScript 将选择条件纳入查询摘要,Python 拒绝漏页、越界租约与混合来源。完整 Todo 查询仍使用原请求。基线状态规则 快照选择 分页校验

配对状态的五个 Agent 分别验证有效、过期、已释放、缺失及无关租约。刻意从真实查询删掉过期 Todo 后,两种后端都会把 unknown 错显示为 launchable,独立状态断言随即失败。

对主干的风险 / Risks

状态缩小的是一次跨进程响应,provider 仍验证全量来源。完整读、损坏 manifest、选择范围变化以及不相关的关闭 Todo 均有对照。真实 PostgreSQL 保留同一版本的有效和已释放租约,更换续页选择时拒绝。

语义与 CI 对齐

226 项 Python、47 项 TypeScript 快照验证、392 项 PostgreSQL 16.15 集成验证,以及 TypeScript、Ruff 与 standard canary 通过。独立测量使用 File 和 SQLite 的正常 status 命令。

我的整体评价 / Verdict

通过当前提交的独立评审。范围收窄保留了租约状态、来源失败和分页连续性,五类状态在两个本地后端均与基线一致。状态字段和优先级沿用原契约。测量覆盖单次 status 租约读取的 UTF-8 JSON 结果。端到端耗时、模型用量和 Windows 运行环境仍待验证。

English verdict: APPROVE. Scoped status transport preserves lease lifecycle, provider revision and full-source refusal on the tested paths.

songoow
songoow previously approved these changes Nov 11, 2026

@songoow songoow 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.

动机 / Motivation

查看 Agent 状态或执行 quota guard 时,调用者只需要当前开放任务的租约,却重复接收整个 Goal 的任务正文。 一个 Goal 含大量已归档任务、只剩少量开放任务时,原读取把全部正文传给 Python;现在先完整验证同一 canonical head,再只传所请求任务的租约。 实际 File/SQLite snapshot 测试证明只返回匹配 lease、保留 revision 和查询边界;Agent 状态测试继续区分当前、过期、释放、外来 owner 和不可读证据。 本次只减少内部传输,不减少完整源验证,不改 lease 写入、Agent 的执行判定或 provider SQL,也不声称整次操作的耗时收益。

改动思路 / Approach

选择发生在已有 snapshot owner 完成 canonical collection 验证之后;Python 只验证运输边界,既有 Agent projection 继续决定执行状态。 当前仅新增内部 lease_todo_ids 读取形态,普通完整读取、provider 持久化、租约获取和状态判定规则均保留原 owner。

Agent facts 已知道它要观察的开放 Todo 集合,因此由它传入精确 id,现有 snapshot reader 返回匹配租约即可。不需要第二套 provider reader、索引或跨请求缓存。空选择只表示这个请求没有租约记录,不能推断整个 Goal 为空;不可读 authority 仍传为 unavailable,让原 lifecycle projection 保持未知状态。

具体改动 / Changes

关键代码讲解

  • readCanonicalSnapshotFromStore 将去重排序后的 selector 纳入 query digest,仍先运行完整 canonical collection 校验,然后减少运输的 Todo/lease 行及无关 metadata。revision、store identity、计数和 continuation 校验继续生效;同一 id 集合换顺序不会失效,换集合会拒绝。
  • read_canonical_snapshot 要求 lease-only 返回零 Todo,每条 lease 都在请求集合内,数量与分页进度完整一致。read_canonical_todos_if_promoted 进一步拒绝把选择性 lease 读取与全任务 summary 或写回确认混用,避免把局部数据当全局结论。
  • _open_todo_leases 不再搬运后筛选完整集合。删除的 per-Todo unreadable set 在基线始终为空;真正的源读取失败仍影响所有有开放任务的 Agent。现有 lease owner 归属、过期计算和 lane 优先级不变。

本轮精确 head 8a564f2,实际 base beff0f3。依据基线 docs/reference/canonical-snapshot-pagination.md:S1(同一 head 与查询/游标一致性)、S2(失败丢弃部分结果,保留原 recovery)、S3(普通完整读取语义)均已核对并验证。发布前 main 为 bcf1b63;比对 coordination、Agent 和 lease owner 与基线无变化,新的 context 首读和 cursor 恢复不触及这些规则。

对主干的风险 / Risks

最强反例是“只看选中任务,漏掉坏的无关记录”,最终把不可读状态当作 idle。实现仍先验证完整 collection,实际损坏 manifest 的选择性读取保留原生失败原因;Python 还拒绝 escaped lease 和不完整页。另一个风险是 selector 变化后复用旧 cursor:query digest 已纳入规范化集合,真实 provider 的对应测试覆盖了拒绝路径。新行为只增加一次请求内的选择,不建立需要过期/失效管理的 state。

独立执行 Python lifecycle/snapshot/integration 112/112 通过(71.50 秒),TS canonical snapshot 47/47 通过(30.56 秒);File/SQLite 的完整与选择性读取、原状态不变、非法范围、错误 provenance 均有覆盖。control-plane typecheck、Python syntax、diff check 通过。子进程显式绑定此 head 的 PYTHONPATH,并使用独立临时 runtime。

语义与 CI 对齐

这是现有 snapshot vocabulary 的内部扩展。省略 selector 的完整读取保持原行为;局部 transport 的计数与完整 read-model 的总量分别解释。远端 packet 没有可用 checks,CI 仍是未知诊断。实际 PostgreSQL 未运行,不能算作 PostgreSQL qualification;本次没有修改其 store、SQL 或持久化协议,改动发生在既有 provider load 之后的共同投影边界。

我的整体评价 / Verdict

未发现阻止此 head 的新缺陷。对长程运行,收益是重复状态读取少传与判断无关的归档正文;对用户体验,原状态含义、失败恢复和交互步骤保持。这个改动复用已有 owner,规模与传输问题相称,完整 source 校验和失败语义也保留。

检查的是内部 snapshot 与 Agent facts 调用链,没有 UI 布局或渲染更改。 未运行真实 PostgreSQL 服务、Windows 或安装 Host,也未测端到端性能。 这些未验证维度没有被包装成通过结果;此结论覆盖已执行的共同读取逻辑与实际 File/SQLite 边界。

Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported

English verdict: APPROVE

@mergify

mergify Bot commented Nov 11, 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, @loopx-agent.

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 Nov 11, 2026
@huangruiteng
huangruiteng force-pushed the codex/select-status-lease-snapshot-20261111 branch from 8a564f2 to 01deda8 Compare November 11, 2026 08:10
@mergify mergify Bot removed the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Nov 11, 2026
@huangruiteng
huangruiteng force-pushed the codex/select-status-lease-snapshot-20261111 branch from 01deda8 to 18ed9ab Compare November 11, 2026 08:34
loopx-agent and others added 5 commits November 11, 2026 16:36
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
@huangruiteng
huangruiteng force-pushed the codex/select-status-lease-snapshot-20261111 branch from 18ed9ab to 48fdf95 Compare November 11, 2026 08:42

@huangruiteng huangruiteng 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-5 · OpenAI · self_reported

Independent approval

动机 / Motivation

查看 Agent 状态或运行 quota preflight 的调用者,需要从同一 canonical head 判断开放 Todo 的有效、过期或已释放租约。同一 Goal 有一个开放 Todo 和大量归档 Todo 时,旧路径把完整 Todo 正文和租约一起送到 Python 再筛选;新路径先验证完整来源,只传输所选 Todo 的匹配租约。状态读取保留有效、过期、已释放和来源不可读时的原判定,同时把内部租约响应从接近 950 KB 降到数 KB。本 PR 不改变 provider 写路径、lease 准入、Agent 调度权限或整轮模型成本。这个切片完整解决 status 观察的重复传输,而不是只把一个局部 helper 挪动位置。

改动思路 / Approach

沿用现有 canonical snapshot reader、provider revision 和 continuation owner。调用者已经知道自己观察的开放 Todo ID,因此把这些 ID 作为可选 selector;TypeScript 仍先加载并验证完整 collection,之后才把 Todo transport 收窄为空、只返回匹配 lease。Python 再校验每页没有 Todo、租约没有越出选择范围,并使用原 expiry、owner 和 lane 规则生成状态。

选择只发生在既有 canonical snapshot owner 完成全量来源校验之后,避免新增 provider reader、缓存或第二套租约规则。收窄仅覆盖 status 观察所需的内部 lease transport;普通完整读、写 authority 和 provider SQL 保持原边界。

这里没有必要另建 SQL 查询或跨请求缓存:两者都会复制 revision、store identity、query digest 与失败恢复逻辑。可选字段同时保持所有既有调用者的默认读取形态。

具体改动 / Changes

评审提交为 48fdf95,行为对照基线为 e251264。七个文件 +168/−42,生产改动集中在四个 canonical snapshot 与 Agent facts 文件,其余是跨 provider 回归。

规范固定在 e251264:docs/reference/canonical-snapshot-pagination.md。

  • snapshot-revision-binding(已验证)。规范化 selector 进入 query digest,续页继续绑定同一 Goal、store identity、provider revision 与 cursor。调换 ID 顺序不改变查询;改变集合会拒绝旧 continuation。
  • snapshot-failure-recovery(已验证)。完整 source 仍先经过 projection、manifest 与 digest 校验。损坏来源、逃逸 lease、页计数不一致或混合 summary/readback 都不返回部分结果。
  • snapshot-complete-read-parity(已验证)。未提供 lease_todo_ids 的普通调用仍使用原完整读取;已有 projection confirmation、compact contract rows 和状态规则继续走各自既有路径。

关键代码讲解

  • readCanonicalSnapshotFromStore。用字段存在与否区分 lease-only 与完整读,将 selector 排序去重后纳入 query digest;完整 collection 校验通过后才构造空 Todo、选定 lease 的页面。代码
  • read_canonical_snapshot。每一页都携带同一选择范围,并拒绝 Todo population、lease 数量超界或任意未选 Todo ID。代码
  • read_canonical_todos_if_promoted。lease-only 不能同时请求 Todo summary 或 projection readback,新增拒绝发生在 provider 调用之前,避免把局部数据包装成完整结论。代码
  • _open_todo_leases。调用者直接传入手头开放 Todo 集合,返回的匹配 lease 继续交给原状态投影;authority 不可读仍返回 unavailable,而不是伪装成空结果。代码

对主干的风险 / Risks

最强的错误路径不是在筛选时漏掉租约,而是先筛选后验证,从而让损坏的归档记录被忽略并把 Agent 误判为 idle。当前实现把完整 canonical collection 校验放在 transport 收窄之前,损坏 manifest、错误 digest、store replacement 和 revision 变化都继续走原失败路径;新增回归还证明未选 lease 逃逸与 selector 变化会拒绝整个读取。

PASS。当前 head 的 144 项 Python 关联测试覆盖 status、quota preparation、File/SQLite canonical integration 和混合 caller 拒绝。TypeScript snapshot 与 digest ownership 共 64 项通过,1 项因普通运行没有 PostgreSQL URL 而跳过。随后在同一 head 用隔离 PostgreSQL 16.2 运行 48 项 canonical snapshot 测试,File、SQLite、PostgreSQL 全部通过。control-plane typecheck、RFC 双语检查和 diff hygiene 也通过。

PASS。同一 ID 集合换顺序可继续分页;新增或替换选择会得到 canonical_snapshot_changed;错误的 include_leases、summary 或 projection readback 组合在 provider 工作前拒绝。完整读取继续传回全部 Todos,说明默认 caller 没有语义漂移。

UNVERIFIED。Hosted checks 在本 review 时仍可能排队,且没有在本机验证 Windows 或 installed-host。它们属于独立 merge-readiness 与发布风险,不由本次内部读取结论替代。

语义与 CI 对齐

这是现有 canonical snapshot vocabulary 的可选内部扩展,没有新持久字段或写权限。lease-only 的 selector 是派生读取范围,不是 canonical authority;完整来源仍是唯一 owner。CI 中的 PostgreSQL job 与本机隔离实例覆盖同一路径,剩余 hosted 状态只作为合并门禁观察。

我的整体评价 / Verdict

未发现阻断问题。长程上,归档任务持续累积时,status 不再反复传输与租约判断无关的正文;用户侧状态、失败恢复和操作步骤保持不变。这个机制复用已有 snapshot owner,生产改动规模与收益相称,也没有引入缓存或权限扩张。

已验证当前 head 的 File、SQLite、PostgreSQL,以及完整来源失败、续页选择变化、逃逸租约和混合 caller 拒绝。剩余不确定性是 hosted CI、Windows 和 installed-host,不影响本次已覆盖的读取不变量。

English verdict: APPROVE. Lease-only status transport preserves complete canonical validation, provider revision and continuation scope across File, SQLite and PostgreSQL.

@huangruiteng
huangruiteng merged commit 81abf35 into main Nov 11, 2026
6 of 10 checks passed
@huangruiteng
huangruiteng deleted the codex/select-status-lease-snapshot-20261111 branch November 11, 2026 08:47
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