Skip to content

refactor(control-plane): converge decision_scope repair hints in TypeScript and eliminate Any - #9428

Merged
huangruiteng merged 1 commit into
mainfrom
codex/decision-scope-ts-convergence
Nov 25, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/decision-scope-ts-convergence

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

  • Outcome basis / optional anchor: Cross-Python/TypeScript control-plane convergence for todo.decision_scope repair-hint selection, hot-path consistency indexing in TypeScript, and Zero-Any typing in the Python codec.
  • Goal/source and gap: loopx/control_plane/todos/decision_scope.py previously maintained a 75-line Python decision chain in build_required_decision_scope_repair_hint alongside the TypeScript decision_scope.ts rule owner, carried 44 Any annotations, and decisionScopeConsistency in loopx/control_plane/todos/decision_scope.ts recomputed scopeStandingAuthority on every open Agent Todo while rescanning all gates/actions and re-validating scope regexes inside nested (item × required_scope) loops.
  • Observable before → after, with the validation row that proves it:
    • Before: repair-hint priority and wording rules lived in Python (decision_scope.py), decision_scope.py had any_count=44, and decisionScopeConsistency performed repeated per-item standing-authority filtering and unindexed cross-kind gate/action scans.
    • After: decision_scope.ts owns repair-plan selection (operation: "repair_hint" and outer repair_plan on failed operation: "consistency" envelopes without mutating consistency keys, keeping build_required_decision_scope_consistency + build_required_decision_scope_repair_hint at 1 RPC on the quota should-run path while re-querying TS if a caller passes a plain or mutated dict and preserving the registered Python effective_action producer site); decisionScopeConsistency indexes valid scopes by kind and lazily memoizes standing authority per owner; decision_scope.py has any_count=0 and dict_any_count=0 under mypy --strict. Proven by tests/control_plane_ts/decision_scope.test.ts and tests/control_plane/test_todo_decision_scope_runtime_boundary.py.
  • Issue/task and intended base: Bounded control-plane convergence and hotspot optimization targeting main.

Author Declaration

  • Written by: OpenAI Codex (GPT-6.2 Sol model agent), orchestrated and independently verified by Google Gemini.

Implemented against

  • Specification and revision: Accepted TypeScript control-plane ownership policy in AGENTS.md and existing todo.decision_scope contracts in loopx/control_plane/todos/decision_scope.{py,ts} at origin/main.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Converge decision-scope repair-plan priority and text selection into TypeScript with 1 RPC on the consistency+repair path and fail-closed validation implemented projectDecisionScopeRepairPlan, evaluateDecisionScope in loopx/control_plane/todos/decision_scope.ts; build_required_decision_scope_consistency, build_required_decision_scope_repair_hint in loopx/control_plane/todos/decision_scope.py tests/control_plane_ts/decision_scope.test.ts and tests/control_plane/test_todo_decision_scope_runtime_boundary.py
Preserve registered effective_action producer ownership and zero semantic vocabulary drift implemented build_required_decision_scope_repair_hint in loopx/control_plane/todos/decision_scope.py pytest -q tests/architecture/test_semantic_vocabulary_drift.py tests/architecture/test_semantic_producer_binding.py
Index valid scopes by kind and lazily memoize standing authority by owner in decisionScopeConsistency with exact output/exception parity implemented indexDecisionScopes, coveringRows, decisionScopeConsistency in loopx/control_plane/todos/decision_scope.ts tests/control_plane_ts/decision_scope.test.ts
Eliminate all Any annotations in decision_scope.py implemented loopx/control_plane/todos/decision_scope.py mypy --strict loopx/control_plane/todos/decision_scope.py and test_decision_scope_codec_has_no_any_annotations
  • Self-check before submission: Reviewed the full Python and TypeScript diff line by line, verified npm run typecheck:control-plane, 15 TypeScript unit tests, ruff, mypy --strict, zero-Any module metrics, File + SQLite real-CLI fallback/lifecycle/standing-order suites, semantic vocabulary/producer drift checks, loopx check public-boundary scan, check_rfc_bilingual.py, and loopx canary premerge.

Scope And Continuation

  • Completed scope and remaining work: Complete within this bounded todo.decision_scope slice. Callers such as stall_repair.py retain their existing call signatures without modification.
  • Slice boundary / successor: N/A — todo.decision_scope repair-plan selection and codec typing are complete within this module pair.

Validation

  • Tested revision: 3dea2e7b8f09c250fd401d847a78fc43f74c133d
  • Run state: finished
  • Input classes: synthetic, public_fixture
Check kind Result Public-safe evidence / limitation
static passed npm run typecheck:control-plane, ruff check, mypy --strict loopx/control_plane/todos/decision_scope.py, module_metrics (any_count=0, dict_any_count=0), loopx check public-boundary scan, and scripts/check_rfc_bilingual.py --base origin/main --head HEAD.
unit passed node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/decision_scope.test.ts (15 passed) and pytest -q tests/control_plane/test_todo_decision_scope_consistency.py tests/control_plane/test_todo_decision_scope_runtime_boundary.py.
real_backend passed pytest -q tests/control_plane/test_scoped_gate_fallback_cli.py tests/control_plane/test_todo_decision_scope_cli_validation.py tests/control_plane/test_todo_decision_scope_lifecycle.py tests/control_plane/test_standing_decision_order.py across isolated local file_v0 and sqlite_v0 canonical authority stores on qualified Node 24.21.0.
regression_parity passed pytest -q tests/architecture/test_semantic_vocabulary_drift.py tests/architecture/test_semantic_producer_binding.py tests/architecture/test_semantic_python_production.py and loopx canary premerge --from-git-diff --git-diff-base origin/main passed; mutation/changed-errors and malformed-runtime-response tests verify fail-closed re-evaluation without Python fallback.
  • Coverage and gaps: Local file_v0 and sqlite_v0 backends and real CLI quota should-run paths were exercised; remote PostgreSQL authority service is unaffected by this read-only projection rule and was not separately run.

See validation disclosure guidance.

Frontend / Visual Evidence

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

Type of Change

  • Refactoring (no functional changes)
  • Test update

LoopX Area

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

Technical Direction

  • Direction / acceptance reference, when applicable: Core control-plane hardening and TypeScript single-rule-owner convergence.

Shared-authority RFC fixture impact

  • Production-scale fixture schema: Unchanged (productionScaleCoordinationFixture verified without mutation in tests/control_plane_ts/decision_scope.test.ts).
  • Semantic dimensions changed, or reviewed no-impact rationale: No persisted state schema, authority store wire format, or registered vocabulary values changed; internal todo_decision_scope_repair_plan_v0 transport envelope stays between decision_scope.ts and decision_scope.py.
  • Provider conformance arms run: Isolated local file_v0 and sqlite_v0 arms via real CLI/authority fixtures.
  • Read-only legacy/file/PostgreSQL three-arm rehearsal (required for promotion, runtime-routing, or compatibility-projection changes): N/A — no promotion, runtime-routing, or store-compatibility change.

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths (including .loopx/, .codex/goals/, and live ACTIVE_GOAL_STATE.md).
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • Existing English/Chinese RFC pairs (including ledger entries) both have a diff, and the local premerge check python3 scripts/check_rfc_bilingual.py --base origin/main --head HEAD passes, or no paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

…Script and eliminate Any

Signed-off-by: Codex <codex@openai.com>
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T06:36:56.973996Z 3dea2e7 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.

@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.2-sol · OpenAI · runtime_reported · xhigh

动机 / Motivation

Quota 准入读取所选 Todo 的权威决策来源,并将可疑的 scope 投影送回修复者。 基线由 TypeScript 计算关系,再由 Python 根据错误数组选择修复文字,几种含义相近的判定跨了两个所有者。 旧版和候选对同样的输入给出同样的准入、用户等待和修复说明。 修复计划的选择与关系判定现在位于同一个 TypeScript owner,正常组合路径仍只需一次 RPC。 本次验收限于同一修复与准入路径。打包宿主及远端 PostgreSQL 没有纳入本轮验证。 保留前置条件、恢复建议和当前 authority 也就保留了后续可验证的工作。 迁移规则

改动思路 / Approach

本 PR 限于 Todo scope 的一致性判定、修复说明与现有 Python 调用编解码。 TypeScript 以一种规则选择关系和修复计划,Python 继续输出已有的 effective_action 生产者及序列化回执。 stall_repair 仍按原流程读取已选 Todo。索引按 scope kind 建立并保留源顺序,对同 owner 的 standing authority 做一次本地工作。临时计划绑定错误签名。普通 dict、签名变化会重用同一个求值 owner。复杂度的收益以可对照的源码运行和结果回读验证。

具体改动 / Changes

精确头 3dea2e7b8f09c250fd401d847a78fc43f74c133d,基线 3347302d17195fc63fdb916f96fdd18fc00f0ebf。全五文件增 575 行、删 157 行。两个源文件处理决策和编解码,另三份测试保护一致性、运行时拒绝、有效和无效 scope 顺序、原生产词汇。覆盖 规则归属 与 真实入口对照。

关键代码讲解

decisionScopeConsistency 复用已建立的索引,同时保留严格的精确目标限制。projectDecisionScopeRepairPlan 统一克服 Python 和 TypeScript 间重复维护的修复优先级。_ConsistencyProjection 私有计划不进入公开 consistency 字段。遇到不合法的 envelope,codec 继续拒绝。 TypeScript 规则 · Python codec

对主干的风险 / Risks

PASS。真实 File/SQLite CLI 中,匹配 gate 保持等待用户。缺少 gate 或精确目标不一致时保留不同修复消息、触发条件和实际控制结果。 两个版本的退出码、真实 scope 诊断和整组修复文字一致,已分开读回两端权威 Todo 和展示状态。SQLite 的同一精确目标冲突样本中,只替换一条原因文本,原 action 不变,独立的完整原因断言拒绝变体。 Python 107 项、TypeScript 15 项及类型检查通过。源码 premerge 的 6 项直接检查和 18 项所选检查通过。 同容器范围和语义边界补充验证为 313 passed in 97.63s (0:01:37)。

语义与 CI 对齐

保留修复依据和精确 target 限制,减少重复索引及跨语言的规则分岔。 已有对应 gate 时照旧由用户决策。错误时还是原来的解释和修复条件。 在 96 个工作项的小型合成 TypeScript 对照中,两个版本结果相等,共享 owner 的 scope 检查中位数约 3.08→0.15 毫秒。另三个形状结果也相等。这是纯求值数据,不用于推断部署端到端开销。本评审验证源码 CLI、File 和 SQLite。未验证已打包宿主、远端 PostgreSQL、真实模型是否采纳指令或远端 CI。

我的整体评价 / Verdict

批准。原等待、具体修复义务和持久化边界在本地两个 provider 保持一致。单一 TypeScript owner 同时给出一致性和修复计划,留下的 Python 映射维持了现有调用和注册生产点。

English verdict: APPROVE at 3dea2e7. File and SQLite CLI parity preserves waits, complete repair guidance, and unchanged authority, with the typed decision owner consolidated.

@huangruiteng
huangruiteng merged commit f37e1c6 into main Nov 25, 2026
14 of 15 checks passed
@huangruiteng
huangruiteng deleted the codex/decision-scope-ts-convergence branch November 25, 2026 07:01
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.

4 participants