Skip to content

refactor(quota): compose quota summary in one TypeScript planning crossing - #7881

Merged
loopx-agent merged 2 commits into
mainfrom
codex/quota-summary-ts-transaction-20261102
Nov 2, 2026
Merged

loopx-agent merged 2 commits into
mainfrom
codex/quota-summary-ts-transaction-20261102

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: TypeScript control-plane migration RFC: replacement-first migration of domain-neutral composition to the typed owner, with no parallel Python decision owner.
  • Goal/source and gap: User and project-asset quota summaries were composed in Python around the TypeScript planning and display owners. One summary took 1–5 cross-runtime calls (todo.quota_planning.project plus up to 4 todo.context.page). A plain JSON move to TypeScript was blocked: a characterization pass showed that source counts, metadata, Vision proofs and warning fields would lose their original Python values in JSON transport.
  • Observable before → after: Python composition of both summaries (about 300 lines plus _QuotaTodoLanes) → TypeScript owns source selection, lane composition, counts, limits, warnings and display projection inside the existing todo.quota_planning.project request. Python gathers compatibility facts and dereferences source references that the owner selected, so original values come back unchanged. Every pinned complete output is byte-identical.
  • Issue/task and intended base: Self-contained migration slice; base loopx-project/loopx:main. No issue closure claimed.

Author Declaration

  • Written by: model_agent: Factory Droid (lead, review and commits) with OpenAI Codex CLI (implementation).

Implemented against

Criterion Disposition Symbol / path Check
Pin current complete output before moving code implemented tests/control_plane/test_quota_summary_transaction_characterization.py, quota_summary_transaction_snapshots.json (27 cases, both summary kinds, call counts) byte-identical before and after
One typed owner, no new handler implemented quota_selection.ts prepareQuotaSummary / composeQuotaSummary inside the existing planning request; context_projection.ts reports selected source coordinates through a callback and reuses the existing display selector TS quota_summary_transaction.test.ts
Preserve original Python values across transport implemented quota_selection.py _decode_quota_summary_wire: validates reference coordinates, null targets, paths and expanded size before attaching source values test_quota_summary_source_references.py (malformed refs, bounds, mutable-row independence)
No fallback on owner refusal implemented refusal raises after one call; non-dict input makes zero calls characterization call counts
Do not add a same-basename Python/TS module pair implemented composition lives in quota_selection.ts (already paired), not a new quota_summary.ts; twin count stays 45/45 semantic-vocabulary-drift-smoke.py
Ledger entry in both languages implemented ledger/typescript-control-plane-migration-v0/2026-11-02-quota-summary-transaction{,.zh-CN}.md, linked from both RFC files check_rfc_bilingual.py
  • Self-check before submission: Read the full Python and TypeScript diff. Python only gathers facts and resolves references; every lane, count, limit and warning decision is in TypeScript. Confirmed the move into quota_selection.ts is code-identical apart from local helper renames.

Migration economics receipt

Field Result
Canonical owner loopx/control_plane/todos/quota_selection.ts (existing todo.quota_planning.project owner)
Legacy code deleted 300 lines of Python summary composition, including _QuotaTodoLanes
Bridge code added 91 lines of Python reference transport and validation, plus 14 lines of entrypoint wiring
Cross-runtime calls 1–5 → 1 per summary on every matrix path; non-dict input 0 → 0; owner refusal 1 → 1 with no fallback
Product net change +319 / −307 (net +12)
Facade exit None. The planning-only Python codec keeps direct planning callers and leaves when the last one migrates. Payload/status compaction and source helpers keep other callers.

No latency or long-horizon benefit is claimed.

Scope And Continuation

  • Completed scope and remaining work: Complete for both summary kinds. The remaining Python planning codec has its exit condition recorded in the ledger.
  • Deliberately not included: retiring the planning-only codec, the payload/status compaction helpers, and any installed-artifact or latency qualification.

Validation

  • Tested revision: 99facff
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
static passed ruff check on changed Python; npm run typecheck:control-plane; git diff --check.
unit passed Python characterization, source references, planning transport, quota selection, source precedence, status agent lane, semantic vocabulary drift: 251 passed.
unit passed TS selection across 39 quota/selection/display files: 657 passed, 38 skipped (PostgreSQL cases, no isolated server), 0 failed.
integration passed control-plane-integrated-canary-smoke.py: File and SQLite providers passed (real synthetic quota should-run journey).
canary passed loopx canary premerge --from-git-diff --git-diff-base origin/main: direct checks (diff, bilingual, compile, module ceilings), 10/10 catalog canaries, 8/8 risk-profile smokes and public-boundary scan passed; 0 manual holds.
unit failed (pre-existing) A broad run over 198 quota/status/scheduler-adjacent Python files (before the final in-file move) had 5,757 passed and 119 failed. The same 119 node ids fail on untouched origin/main (867615e), and the failure sets match exactly. A 10-test sample was rerun on this head and on main: 10/10 fail on both. They involve CLI capture argument requirements, monitor settlement expectations, periodic-report successors and steward configuration. None involve the changed code.
  • Coverage and gaps: PostgreSQL TS integration cases were skipped (no isolated server); no PostgreSQL store behavior changes. Installed-artifact and latency checks were not run.

Frontend / Visual Evidence

  • UI impact: none. The summary payload that status and quota consumers read is byte-identical.
  • Before / After / First viewport / States / Source data / Attention / Craft: N/A; no UI surface change.

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)
  • Benchmark boundary (adapters, runners, verifiers, scoring, evidence)
  • Capability or extension (providers, adapters, skills)
  • Public docs or presentation surface (README, protocols, dashboard)
  • Build, packaging, installer, or CI
  • Host or runtime integration

Technical Direction

  • Direction / acceptance reference: TypeScript control-plane migration RFC; quota summary is composition over existing typed owners, so it belongs in TypeScript. Python remains a fact-gathering and transport adapter.

Shared-authority RFC fixture impact

  • Production-scale fixture schema / semantic dimensions / conformance arms / three-arm rehearsal: N/A; read-only projection, no authority store or persisted format change.

Boundary Checklist

  • Reviewed diff and body for private state, credentials, raw traces, internal links and local machine paths; none included.
  • No maintainer-owned benchmark work duplicated.
  • Change remains scoped to the request described above.
  • Paired RFC and ledger files changed together (EN and zh-CN).
  • UI impact marked none.
  • Every branch commit includes a DCO Signed-off-by trailer (git commit -s).

Merge requires explicit maintainer authorization (quota rules under loopx/**).

…ssing

Extend the existing todo.quota_planning.project request so TypeScript
selects sources, composes lanes, counts, limits, warnings and display
projection for user and project-asset quota summaries. Python gathers
compatibility facts and dereferences owner-selected source references so
original values survive the JSON transport.

Pinned complete-output fixtures stay byte-identical; matrix paths drop
from 1-5 crossings to one, non-dict input stays at zero and owner refusal
stays at one without fallback. No handler, authority or persisted format
is added.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Signed-off-by: hhyykk <4408344+hhyykk@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T08:54:27.714205Z 99facff PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 99facff915

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if ((legacy || unknownSchema) && typeof payload.index === "number" && Number.isInteger(payload.index) && payload.index >= 0) {
presentation[1] = payload.index; presentation[2] = ""; presentation[3] = "";
}
return {...fact, presentation, payload, display_source: {record: payload}};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Recompute actionability after applying handoff readiness

When a successor has resume_when but no explicit resume_ready, and its handoff gate is cleared_with_successor, projectTodoSummaryDisplay adds resume_ready: true to the projected payload. However, the returned row retains fact.actionable, which Python computed from the unprojected source as false. Previously, actionability was computed after display projection. Comparing the parent implementation against this commit reproduces a successor disappearing from first_executable_items and executable_backlog_items, with its advancement count dropping from 1 to 0 despite the returned payload showing it as ready. Recompute the affected selection facts from the projected payload so cleared handoffs can resume execution.

Useful? React with 👍 / 👎.

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

1) 问题定义(为什么改、要解决什么)

  • 将用户与项目资产配额摘要(quota summary)的来源选择、泳道组合、计数与展示投影收敛至单次 todo.quota_planning.project 跨运行时调用,并通过来源引用保留原始 Python 标量/对象精度。

2) 改动摘要(按模块分组)

  • 单次跨运行时配额摘要组合 (loopx/control_plane/todos/quota_selection.py, loopx/control_plane/todos/quota_selection.ts, loopx/control_plane/todos/quota_summary.py):在 project_quota_planning 中新增 summary_kind 与 summary_request,由 TypeScript prepareQuotaSummary 与 composeQuotaSummary 组合完整配额摘要,再由 Python _decode_quota_summary_wire 解引用还原。
  • 快照与来源引用测试 (tests/control_plane/**, tests/control_plane_ts/**):新增事务快照等价性测试与来源引用保真测试。

3) 逐点审阅结论(架构、语义、正确性、测试、风险)

  • 架构方向:单次跨运行时边界收敛方向清晰,大幅精简了 quota_summary.py 的重复泳道拼装逻辑。
  • 正确性缺陷(Handoff 放行后的 Actionability 失步):在切换前,todo_summary_open_items 先运行 projectTodoSummaryDisplay(将 cleared_with_successor handoff 门控对应的后继 Todo 注入 resume_ready: True),随后才调用 encode(item) 计算 todo_item_is_actionable_open(item)。切换后,quota_selection.py:182 对未经过 projectTodoSummaryDisplay 的原始 value.get(key, []) 预先执行 encode(row, include_payload=False),此时携带 resume_when 但尚未显式落盘 resume_ready: True 的已放行 handoff 后继项的 fact.actionable 被计算为 False;而在 quota_selection.ts:532 中,prepareQuotaSummary 虽然通过 projectTodoSummaryDisplay 得到了含 resume_ready: true 的 payload,却直接沿用了旧的 fact.actionable(return {...fact, presentation, payload, display_source: {record: payload}}),导致该就绪后继项从 first_executable_items 与 executable_backlog_items 中丢失。

4) 建议修改项(分 P0/P1/P2,带文件路径和行号)

  • [P1] loopx/control_plane/todos/quota_selection.py:182 & loopx/control_plane/todos/quota_selection.ts:532:当 projectTodoSummaryDisplay 因 cleared_with_successor handoff 门控为条目注入 resume_ready: true 时,需同步按投影后的 payload(或在 Python 端 encode 时结合 handoff_gates)重算 actionable 与相关可执行性事实,并补充一条携带 resume_when + cleared_with_successor 的回归测试。

5) 最终结论(Verdict)

Changes requested (P1 actionability desync for cleared handoff successors with resume_when at exact head 99facff915f8ec3fc350bad835f9af179a635e7b).

@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=max

动机 / Motivation

读取 quota/status 的 Agent 和维护摘要逻辑的开发者。 原来普通完整来源有 2 次 succession、1 次 context 和 1 次 planning 调用;现在仍有一次 succession 来源读取,另一次 planning 内完成组合,输出保持完整一致。 独立的 24 个输入/摘要组合,完整输出逐字节一致;底层 transport 计数显示普通路径 4→2,含 user-action 的路径 7→2。64 个 Python tests、5 个 TS tests 与真实 File/SQLite integrated canary 通过。 本次不删除仍有消费者的 planning-only codec,不宣称总 transport 恒为一次、installed/latency 或长程效果已资格化。

改动思路 / Approach

已有 quota_selection.ts 是 scope、claim、resume、deadline 的 typed owner,把最终组合放在同一事务内符合其职责;source reference 是为保留既有值类型的明确 codec。 两类摘要完整迁入现有 TS owner,复用 display/source selection;Python 保留源类型事实和引用 transport,不增加 handler 或第二个 authority。 保持 Python 组合保留重复跨界;另建 quota_summary.ts 会增加 Python/TS 同名双份结构;普通 JSON 全量搬运会改变大整数、float 和 metadata。当前方案复用现有 owner,付出的 source-reference 验证成本有实际 lossless 回归覆盖。 正向路径从 summarize_user_todos_for_quota / summarize_project_asset_todos_for_quota → project_quota_planning → projectTodoQuotaPlanning 进入既有 owner,24 个完整输出全部一致;9007199254740993、1.0、嵌套 proof 与 warning 类型均保留;异常路径保留 现有 EffectRuntimeRejected 与 codec RuntimeError,负向测试通过;无第二次 Python planning fallback;非 dict 输入保持零调用。本次完整审查当前 head,没有继承先前模板审查的通过结论。

具体改动 / Changes

13 paths +887/-309;旧 Python 组合删除、现有 TS owner 扩展、transport decoder 与独立完整快照/负向测试、双语 ledger。 lane/count/limit/warning 在 quota_selection.ts;context_projection.ts 只报告已有选择的源坐标;Python codec 不选择允许工作。 新增 todo_quota_summary_wire_v1 是当前同版本内部 transport;没有 persisted schema、权限、provider 选择或第二个状态 owner。v0-v4 planning 历史 reader 仍有当前消费者,保留合理。

关键代码讲解

  • prepareQuotaSummary:复用 display owner 选源并准备摘要事务。 把旧 Python 选择移入已有 typed 边界。 输入为summary_request/source_rows 与 typed selection,关键条件是kind 仅 user/project_asset;缺失 source lane 明确拒绝。EffectRuntimeRequestError,不静默回退

  • composeQuotaSummary:完成所有 lane、count、limit 与 warning 组合。 保留原字段与限制,引用保留 Python 原值。 输入为planning lanes 与 source facts,关键条件是deadline 使用完整 source;展示限制不改变候选全集。非法必需 lane 拒绝

  • _decode_quota_summary_wire:验证源/目标坐标并恢复原始值类型。 先验证全部 patch、大小和唯一目标,再写入 summary。 输入为wire summary/source_copies/integer_copies 与原 source,关键条件是坐标只允许 str/非负 int,目标必须 null;越界/重复/过大拒绝。RuntimeError,不把损坏 wire 当成空摘要

规格为 docs/architecture/rfcs/typescript-control-plane-migration-v0.md,spec_revision 867615e2c3aa2a32516a71d46f11a20d6fcb3289;按真实生产 caller 迁移中性决策、保留必要 Python I/O/codec;当前 ledger 对应这一个完整替换边界。

  • replacement-first:implemented。两个公开摘要入口均复用同一 typed 组合 owner;旧 Python 组合与 _QuotaTodoLanes 退役。 对应 quota_summary.py → quota_selection.ts;源码对照 + 24-case paired execution。
  • lossless transport:implemented。保留源数值类型、完整 metadata、proof、warning,非法引用在应用 patch 前拒绝。 对应 _decode_quota_summary_wire;source-reference negative tests + full output parity。
  • real-path qualification:implemented。真实入口覆盖 File/SQLite;不以 unit/mock 替代 canary。 对应 examples/control-plane-integrated-canary-smoke.py;reviewer executed PASS on both backends。

对主干的风险 / Risks

最强风险是源码组合看似等价却悄悄改变原始 Python 数字/metadata,或限制展示时损失 scope、重试时钟和 closure proof。 为区分修复与无效测试,我对不可变 base/head 执行相同输入:base 24 完整输出为对照;普通 4 次 transport,user-actions 7 次;head 24 输出与 base 字节一致;对应路径降至 2 次 transport,其中组合仅一次。我在 effect_runtime_request 层计数,覆盖调用别名:旧测量忽略 succession preread 会低估完整调用数。因此这里明确区分一次组合调用与完整 transport 次数。 验证了 agent scope、other-agent user actions、legacy source、监测与 closure/successor proof;display cap 不裁剪 deadline 原始候选,source-reference 在展开前计预算。

  • PASSED:24-case paired corpus; 64 selected Python tests — PASS:24 outputs byte-identical;Python64 passed
  • PASSED:source-reference suite + 5 TS quota summary tests — PASS:无部分 patch、无拒绝回退
  • PASSED:examples/control-plane-integrated-canary-smoke.py — PASS:File 和 SQLite
  • PASSED:check_rfc_bilingual.py --base 867615e2c3aa2a32516a71d46f11a20d6fcb3289 --head HEAD; git diff --check — PASS,当前 head 日志保留

语义与 CI 对齐

沿用现有 typed Todo/display vocabulary;新 wire 是内部 transport。原 metadata 的真实性来自独立 source 坐标,不依赖 prose substring 分类。 没有新开关或默认启用变化;对 source 空/非法、legacy、非 dict、无 capability、owner refusal 均做完整对照,状态和权限没有旁路。 独立证据覆盖当前 changed invariant;远端 CI 的其他状态与合并 readiness 另行保留,没有把检查颜色当作正确性证明。 真实 source CLI 与 File/SQLite 已验证;没有 isolated PostgreSQL store 变更,无该后端新增持久化义务;未运行 installed/latency 或真实模型实验。作者大范围 119 个基线失败未作为本次独立验证结论。 作者文档“1–5→1”描述组合相关调用,若解读成完整 transport 总数就会低估仍存在的 succession preread;建议把这个计数边界写清。此表述修正不改变当前无损迁移结论。

我的整体评价 / Verdict

APPROVE:当前完整 diff 在所声明边界内达到 goal_achieved;long_horizon 为 preserved,配额、scope、阻塞、监测与 successor 的决策和回读保持;减少跨 runtime 次数是局部执行成本证据,并非任务效果或端到端延迟结论。 user_experience 为 preserved,现有 quota/status 消费者得到同一完整摘要,不需要迁移设置或操作流程。 quota/status payload 完整一致;未改变渲染/入口/设置,visual_review not_applicable。 已有 quota_selection.ts 是 scope、claim、resume、deadline 的 typed owner,把最终组合放在同一事务内符合其职责;source reference 是为保留既有值类型的明确 codec。 两类摘要完整迁入现有 TS owner,复用 display/source selection;Python 保留源类型事实和引用 transport,不增加 handler 或第二个 authority。 已删除旧 Python 组合,避免新建同名 TS 模块;仍活跃的 compaction/source helper 与 planning codec 暂留,最后 caller 迁出再退役。 不把本次 review 当作合并授权。

English verdict: APPROVE — 99facff915f8ec3fc350bad835f9af179a635e7b; both quota summaries now compose under the existing typed owner with byte-identical output; the complete ordinary transport path drops from four calls to two. 64 Python tests, 5 TypeScript tests, 24 paired cases and real File/SQLite integrated canary pass.

@loopx-agent
loopx-agent merged commit ba7bf77 into main Nov 2, 2026
6 of 7 checks passed
@loopx-agent
loopx-agent deleted the codex/quota-summary-ts-transaction-20261102 branch November 2, 2026 15:40
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.

2 participants