Repository navigation
fix(planning): make planning_batch and outcome refinement schemas self-contained - #9263
loopx-agent wants to merge 4 commits into
Conversation
…f-contained Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
使用 loopx-planned 初始规划阶段(w0)或直接调用 goal-acceptance refine / benchmark.runtime.planning_batch 声明目标成果要求与初始 Todo 的模型规划者及基准运行时调用方。
在基准分支(main)上,planning_batch 引导语缺少完整嵌套键结构与 opaque ID 正则、planning_batch --help 直接因读取文件失败报错、且 GoalOutcomeValidationError 与子进程错误包装会隐藏字符上限和缺失键详情,导致模型不得不多次读取源码试错;本 PR 将完整 schema 与约束自包含到提示词、--help/--schema 与校验报错中,在零源码探测前提下即可定位或一次写对。
真实长程基准执行观察表明,w0 规划阶段此前常因不知道 outcome.source.ref 不能带路径斜杠/空格且上限 128 字符、不知道 planning_batch 不支持 --help(原实现直接以 sys.argv[1] 读文件触发 FileNotFoundError)、以及 goal-acceptance refine 只返回泛化错误 "outcome fields are missing or unsupported" / "source ref must be bounded nonempty text" 且 planning_batch 丢弃 error_detail,迫使模型耗费数十轮工具调用去 cat/rg LoopX 内部 .py/.ts 源码反推字段。
已验证:planning_batch --help 与 --schema 均正常返回 0 并给出完整字段契约;planning_batch_guidance() 内联嵌套 JSON、128 字符 opaque ID 规则、action_kind 约束与 status="ready" 直接返回指引;非法提案在调用任何 LoopX CLI 前即以路径+规则+实测长度失败,且 TypeScript GoalOutcomeValidationError 与 PlanningBatchCommandError 均输出确切字节/条目超限及允许字段列表而不回显任何调用方输入值或私有键名。
不放宽任何既有成果字节上限(131072 B)、字段容量(32 项要求 / 1024 / 2000 / 512 / 128 字符)或 opaque ID 校验规则,不引入基准特定硬编码捷径,也不改动 todo plan 契约与执行期唤醒提示。
改动思路 / Approach
flowchart LR
P[规划模型读取 planning_batch_guidance<br/>或 --help / --schema] --> B[planning_batch.py _request 前置校验]
B -- 字段/长度/ID/action_kind 非法 --> E1[立即退出 rc=1<br/>输出路径+规则+整数计数<br/>零 CLI 子进程, 零值回显]
B -- 结构合法 --> L[loopx goal-acceptance refine & todo add]
L -- TS outcome_requirements.ts 拒绝 --> E2[GoalOutcomeValidationError<br/>保留 error_code 与固定规则 error_detail<br/>PlanningBatchCommandError 原样透传]
L -- 写入成功 & readback 通过 --> OK[退出 rc=0<br/>直接返回 status='ready' + todo_ids]
说明:以上流程基于评审头 9263@bd5e0a566701cb5ecc1dbf5d1cf8603c0a8ebc5e 源码(benchmark/runtime/planning_batch.py、loopx/control_plane/goals/outcome_requirements.ts、loopx/cli_commands/goal_acceptance.py)绘制(说明性示意,非容器渲染采集;界面视觉检查不适用)。
- 分层与职责归属:
- 提示词与 CLI 自描述(
benchmark/runtime/planning_batch.py、loopx/cli_commands/goal_acceptance.py、benchmark/runtime/RUNTIME.md):将原先分散在.ts/.py源码中的嵌套键名、字符与数量上限、opaque ASCII ID 正则、action_kind规则以及“成功即直接返回status="ready"”说明收敛进planning_batch_guidance()、--help/--schema与goal-acceptance --help。 - 前置拦截与错误保真(
benchmark/runtime/planning_batch.py):通过argparse替代裸sys.argv[1],避免--help崩溃;在调用任何 LoopX CLI 前对字段集合、字符串规则、opaque ID 与action_kind(直接复用loopx/control_plane/todos/contract.py的normalize_todo_action_kind与TODO_ACTION_KIND_PATTERN)进行无副作用校验;当下游 CLI 仍返回错误时,新增PlanningBatchCommandError保留error_detail、error_code、stage与current_provider_revision。 - 服务端公开报错可诊断性与脱敏守恒(
loopx/control_plane/goals/outcome_requirements.ts):describeTextFailure、id()、keys()与list()在保持GoalOutcomeValidationError零调用方字符串/键名回显红线的前提下,补齐实际字符/条目计数、上限、缺失必选键与允许键集合;其中超过 128 字符的 ID 同时告知长度超限和字符集限制。
- 提示词与 CLI 自描述(
- 架构与边界评估:在生产端保持所有核心校验与持久状态权威仍在 TypeScript
outcome_requirements.ts与 Pythontodos/contract.py;planning_batch.py复用TODO_ACTION_KIND_PATTERN/normalize_todo_action_kind并在 CLI 入口做前置结构诊断与错误字段透传,outcome_requirements.ts仅增强静态规则提示而不改变错误码或写入语义,总体增量精准服务目标且易独立回退。覆盖benchmark/runtime/{planning_batch.py,RUNTIME.md}、loopx/control_plane/goals/outcome_requirements.ts、loopx/cli_commands/goal_acceptance.py及三组配套双语/双栈(TS+Python)回归测试。
具体改动 / Changes
精确 diff(d38052695c2c..bd5e0a566701)共 7 个文件,+609 / -52 行:
| 文件 | 变更行数 | 角色 |
|---|---|---|
benchmark/runtime/planning_batch.py |
+291 / -41 |
argparse (--help/--schema)、完整 planning_batch_guidance()、前置契约校验与 PlanningBatchCommandError |
loopx/control_plane/goals/outcome_requirements.ts |
+41 / -9 |
增强 GoalOutcomeValidationError 文本/ID/键/数组容量诊断(零输入值泄露) |
loopx/cli_commands/goal_acceptance.py |
+6 / -0 |
在 goal-acceptance --help 补充 Outcome declaration (refine) 文档与限额 |
benchmark/runtime/RUNTIME.md |
+2 / -1 |
文档同步补充 planning_batch --schema 入口 |
tests/control_plane/test_benchmark_planning_batch.py |
+180 / -0 |
--help/--schema/引导语、前置无 CLI 拒绝与无泄露、及上游 error_detail 保真测试 |
tests/control_plane/test_goal_outcome_diagnostics.py |
+55 / -1 |
更新合并后的超长+非法字符报错预期,新增缺失/额外键与超限总结无泄露断言 |
tests/control_plane_ts/goal_outcome_refinement.test.ts |
+34 / -0 |
TS 单元测试覆盖 GoalOutcomeValidationError 字符数、缺失键、数组容量及无敏感值回显 |
关键代码讲解
planning_batch_schema/planning_batch_guidance/_build_parser(benchmark/runtime/planning_batch.py#L41-L150,#L400-L452)
将planning_batch的提案 JSON 结构与规则(input_digest、expected_provider_revision、outcome、todos)以机械可解析的benchmark_planning_batch_proposal_v1字典和简洁 CLI/提示语同时呈现,并修复原sys.argv[1]裸读导致--help直接FileNotFoundError的缺陷;保留原有optional、LOOPX_PLANNING_RESULT、断点原样重放及非空 frontier 走普通流程等约束条款。_record/_opaque_id/_action_kind/_request(benchmark/runtime/planning_batch.py#L153-L271)
与上游outcome_requirements.ts及todos/contract.py逐项对齐(128/1024/2000/32/512/64上限及^[A-Za-z0-9][A-Za-z0-9_.:@-]*$),在本地直接过滤非对象、缺漏或多余字段(仅返回unsupported field count与允许键集合)、超长或非法字符,减少失败子进程往返。PlanningBatchCommandError与错误透传(benchmark/runtime/planning_batch.py#L33-L39,#L340-L355,#L441-L450)
不再吞掉 LoopX CLI JSON 返回中的error_detail、error_code与current_provider_revision,而是结构化合并到planning_batch退出 1 的 stdout JSON 载荷,便于调用方按真实原因修正或使用当前 revision 重试。describeTextFailure/id/keys/list(loopx/control_plane/goals/outcome_requirements.ts#L35-L88)
保留既有GoalOutcomeValidationError类与goal_acceptance_invalid_request错误码(见acceptance_authority.ts#L655-L657),把原固定泛化文案升级为“规则 + 校验器实测数值/缺失键/允许列表”,严格禁止输出调用方字符串内容或未授权键名。
规范对照(spec_basis):引用已接受契约文档 docs/reference/goal-acceptance-observations.md(revision e1f1d6607b2cb704c076e4a1e30d8f63955b62af):
| criterion_id | 契约要求摘要 | 本头部状态 | 验证依据 |
|---|---|---|---|
ERROR-DETAIL-HYGIENE |
error_detail 仅包含固定规则文本、校验器标签与实测数字,绝不回显调用方输入值、多余键名或 provider/IO 上下文 |
implemented (outcome_requirements.ts#L42-L88, planning_batch.py#L161-L214) |
test_goal_outcome_diagnostics.py, goal_outcome_refinement.test.ts, test_benchmark_planning_batch.py, run_cf_9263.py |
REJECT-NO-WRITE |
校验失败不得写入或更改 Goal 状态,修正后沿用同操作/当前 revision 可成功提交 | implemented (outcome_requirements.ts#L176-L286) |
test_goal_outcome_diagnostics.py (test_native_rejection_then_corrected_same_operation) |
STABLE-ERROR-CODE |
goal-acceptance 与 refresh-state 拒绝继续返回既有稳定 error_code(goal_acceptance_invalid_request) |
implemented (acceptance_authority.ts#L655-L657) |
test_goal_outcome_diagnostics.py, run_cf_9263.py |
对主干的风险 / Risks
- 阻断性发现:无阻塞发现(no blocking finding)。
- 负向与契约风险核对:
- 长程与隐私泄露风险:核对了
_record()、keys()、describeTextFailure()、_opaque_id()与id()全分支:超出长度只输出整数长度,不支持键仅输出整型计数unsupported field count: N,非法字符串永不拼入错误文本。 planning_batch提示词变更与现有行为隔离(default_off_isolation/observable_semantics):planning_batch_guidance()仅注入到LOOPX_TASK_STAGE=plan的loopx-planned启动输入(benchmark/runtime/planning.py#L28-L36),不影响执行期 heartbeat/Turn 提示或非loopx-planned模式;保留全部现有中断重放与阻塞回退语义,新增when it exits 0 with status="ready", do not make extra todo list or goal-acceptance calls与planning.py#L73-L114(validate_plan_readback)一致且无过早绕过风险;实测cli-output-budget-regression-smoke.py在 base 与 head 均通过。- 跨语言边界重复权衡:
benchmark/runtime/planning_batch.py存在与 TSoutcome_requirements.ts对应的整型上限镜像(128 / 1024 / 2000 / 32 / 512 / 64);鉴于 Python 内核loopx/control_plane/goals/acceptance.py本身不复制 TS schema 常量且跨语言无法直接 import.ts,由双边单元测试与canary premerge共同守护一致性的做法代价合理且比额外搭建代码生成层更轻量;仅需未来调整 TS 上限时同步更新planning_batch.py与goal_acceptance.py帮助文案(非阻断维护注意事项)。 scope_fit与authority_semantics:planning_batch_guidance()与planning_batch.py由benchmark/runtime/planning.py生产调用,_action_kind复用现有todos/contract.py规范化函数,无未调用模块、无新增授权或角色词汇。
- 长程与隐私泄露风险:核对了
语义与 CI 对齐
本 PR 复用既有词汇(reuse_existing),未新增共享持久化状态字段或控制面枚举;outcome_requirements.ts 与 goal-acceptance --help 沿用已接受文档 docs/reference/goal-acceptance-observations.md 定义的 error_detail 规则与 goal_acceptance_invalid_request 错码;planning_batch --schema 输出本地辅助版本标识 benchmark_planning_batch_proposal_v1 仅供人类/模型只读自省。所有本地静态检查、TS/Py 单元测试与 cli-output-budget 回归烟雾已于本机实测核验(远程 GitHub CI 按 wait_for_ci: false 不作为等待门禁)。
- 本地验证与对照矩阵(
wait_for_ci: false):
| 检查项 | 范围与条件 | 状态 | 观察结果 |
|---|---|---|---|
npm run typecheck:control-plane & node --test |
TS 控制面类型检查 + 3 组 goal_outcome_* / goal_acceptance_authority 测试 |
PASS | tsc 0 错;105 passed, 0 failed(27 条 PostgreSQL 用例因本机无 PG 环境跳过) |
Targeted pytest -rs (5 suites) |
test_benchmark_planning_batch.py, test_goal_outcome_diagnostics.py, test_task_entry.py, test_goal_outcome_refinement.py, test_goal_acceptance_cli.py |
PASS | 171 passed, 54 skipped(688.37s;54 skips 均为 .venv 缺失可选 harbor 包引起的 test_task_entry.py importorskip) |
ruff / git diff --check / mypy --strict / loopx check |
修改文件 + 17 个 pyproject.toml strict 内核模块 + 边界扫描 |
PASS | ruff 0 错;git diff --check 干净;mypy --strict 17 文件 0 错;loopx check errors=0 |
examples/control_plane/cli-output-budget-regression-smoke.py |
.venv/bin/python 在 Base (d38052695c2c) 与 Head (bd5e0a566701) 实跑 |
PASS | Base (BASE_EC=0) 与 Head (HEAD_EC=0) 均输出 cli-output-budget-regression-smoke ok |
loopx canary premerge --from-git-diff |
--git-diff-base d38052695c2c8a2e67cdb2c1eb6f4c6651eabd4d |
DIAGNOSTIC | direct_checks 4/4、py_compile 1/1、risk_profile_smokes 8/8 及 9/10 catalog canaries 均通过;cli-output-budget-regression-smoke.py 因系统 python3.12 缺 pytest (ModuleNotFoundError) 在 0.081s 失败,上述 .venv 直接验证已证实通过(manual_hold_count: 1 benchmark_sensitive) |
独立反事实对照(run_cf_9263.py) |
Base (d38052695c2c) vs Head (bd5e0a566701) 对比 9 个 CLI/规划路径 |
PASS | Base:--help/--schema rc=1、planning_batch_guidance 缺嵌套结构/regex/直返提示、goal-acceptance --help 缺 schema、非法 source.ref 调用 CLI 且丢 error_detail;Head:--help/--schema rc=0、非法提案零 CLI 调用且零敏感路径回显、真实 refine 返回精确字符/键/计数诊断且零回显、有效 planning_batch 端到端产出 status="ready" 绑定 Todo ID、上游错误保留 stage |
- 最缺失的残留验证(非阻断):本地
.venv未安装harbor(54 个test_task_entry.py集成用例跳过),且实际线上容器内模型能否真正将w0耗时从 ~15m 降至 1–2 次调用需下一轮 liveloopx-plannedbenchmark 试验观察。
我的整体评价 / Verdict
- 长程与用户体验评估(
outcome_impact):long_horizon = improved——显著消除初始规划w0因缺少契约自描述导致的反复源码摸索与多轮试错开销,同时保持全部现有唤醒与断点重放不变量;user_experience = preserved——CLI--help/--schema与错误诊断更清晰,且无额外人工确认负担。 - 视觉审查(
visual_review):本 PR 仅涉及 CLI 帮助文本、JSON Schema 引导、前置字段校验与报错文案优化,不改变任何前端页面或可视化渲染表面。(unverified_scope:none)。 - 契约与变更体量评估:本 PR
reuses existing vocabulary(沿用docs/reference/goal-acceptance-observations.md与todos/contract.py);code_volume = necessary、compatibility_assessment = retain、change_proportionality = proportionate、default_off_isolation = isolated、authority_semantics = not_applicable。 - Exact-Head Freshness & Verdict:已复核远程精准头
9263@bd5e0a566701cb5ecc1dbf5d1cf8603c0a8ebc5e(基于main@d38052695c2c8a2e67cdb2c1eb6f4c6651eabd4d)为OPEN、MERGEABLE且无未解决线程。
English Verdict: APPROVE — Self-contained schema guidance, upfront validation, --help/--schema ergonomics, and non-leaking GoalOutcomeValidationError diagnostics cleanly eliminate w0 planning schema guesswork at 9263@bd5e0a566701cb5ecc1dbf5d1cf8603c0a8ebc5e.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
运行初始规划的调用者需要按 CLI 自带的 schema 准备提案,在任何 owner 调用前获得准确错误。 原初始规划把实际 acceptance 长度检查交给现有 Goal owner,缺少可发现的前置 schema。 Python 按 Unicode 码点计数。File 和 SQLite 的真实 CLI 各接受 513 个非 BMP 字符的 objective、1,001 个字符的 requirement description、257 个字符的 source summary 进入 refine,TS 分别按 1,026、2,002、514 个 UTF-16 code units 拒绝。有界字段的 schema、前置检查和最终验收三处需要说明同一单位。 当前头增加 --schema 和 --help、Python 前置校验与保留上游诊断的 receipt。 本轮只测源码和隔离的两个 provider,未作模型调用、正式安装或 CI 查询。
改动思路 / Approach
Python 继续协调初始批次,TypeScript 保留 Goal outcome 验证。两端要使用同一字段规则或明确重用一个 validator。 现有 Goal owner 决定最终接受。本地 schema 合同承诺相同约束,不能有第二个不同字符预算。 采用 Goal owner 当前计数单位可保留已发布接受条件。不要为修复 CLI 帮助随意改变已有存储契约。
具体改动 / Changes
逐项检查当前头 bd5e0a5 和 merge base d380526,7 个文件,+609/-52。7 个文件覆盖终端帮助、实际批次、typed diagnostics 和测试。 评审依据为 d380526。 目标规范
关键代码讲解
planning_batch_schema将三个有界说明字段标为 chars。 schema_text用 Python 计数;apply_initial_plan之后才进入原 acceptance 提交。 前置检查 · 原入口text按 JS string length 即 UTF-16 code units 给出实际验证。 ownerschema-owner-parity的说明字段计数不一致。planning-replay当前实证仍按原稳定操作重试。
对主干的风险 / Risks
[P2] 计划 schema 与 Goal owner 对 Unicode 长度的判定不一致。 Python 按 Unicode 码点计数。File 和 SQLite 的真实 CLI 各接受 513 个非 BMP 字符的 objective、1,001 个字符的 requirement description、257 个字符的 source summary 进入 refine,TS 分别按 1,026、2,002、514 个 UTF-16 code units 拒绝。有界字段的 schema、前置检查和最终验收三处需要说明同一单位。 让 Python 和 TS 使用同一明确计量规则,并在 --schema、--help 和错误文本写明单位。给三个字段添加刚好在限额与超过限额的非 BMP 输入对照。 以上三个字段的拒绝均发生在下游,原 typed 错误完整保留。另将同一准确头与后来主干做三方合并验证,受影响入口和规则文件保持同一 blob。
256 个同样的字符恰为 512 UTF-16 code units,File 和 SQLite 均返回 ready,且只有一个实际 Todo。257 个字符的六次拒绝均没写入 Todo,保留上游 typed 错误。 独立运行 Python(72 passed)、TypeScript(105 通过,27 跳过),类型检查和 Ruff 通过。预合并 6 项直接检查、18 项选中检查通过。 未验证 PostgreSQL 或隔离环境之外的运行项目。预合并资格状态为 quality_receipt_missing。
我的整体评价 / Verdict
请求修改。Python 继续协调初始批次,TypeScript 保留 Goal outcome 验证。两端要使用同一字段规则或明确重用一个 validator。 现有 Goal owner 决定最终接受。本地 schema 合同承诺相同约束,不能有第二个不同字符预算。 前置化功能缺少与共享 owner 的 Unicode 边界一致性。 保留有用的结构化错误,再让真实提交与显示的边界一致。 变更位于 CLI 和技术参考。
English verdict: REQUEST_CHANGES at bd5e0a5. Use one explicit character-length unit in schema, preflight, and Goal validation. File and SQLite each reject three schema-valid non-BMP inputs only after an upstream refine call. Both accept the 512-code-unit control.
…units Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent · Gemini · Google · self_reported
Exact head reviewed: 8f5ac08f3b043307e4ae791ff732c61ead91b05a (base d38052695c2c8a2e67cdb2c1eb6f4c6651eabd4d; incremental since earlier approval at bd5e0a5667: commit 8f5ac08f3b, 7 files +197/-51; review thread PRRT_kwDOStEbEs66i6fs resolved).
动机 / Motivation
Benchmark 规划唤醒阶段的模型调用方(python -m benchmark.runtime.planning_batch)以及使用 goal-acceptance refine 的操作者。 变更前后场景:以含 513 个 emoji(1026 UTF-16 code units)的 objective 为例,变更前 Python 预检按 513 个 code point 放行,随后在 TypeScript refine 阶段以 1026 超限被拒;变更后 Python 预检立即拒绝并报告完全一致的 got 1026 UTF-16 code units, max 1024。 可观测结果:Python 预检与 TypeScript goal-acceptance refine 对所有有界字段(objective、requirements[*].description、source.summary、opaque IDs)使用完全一致的 UTF-16 code unit 边界与错误文本,且 512/1000/256 个 emoji 的精确边界提案可通过真实 File 与 SQLite CLI 落盘并读回。 非目标:不改变任何字符上限数值,不放宽 opaque ID 字符集规则,不新增持久化字段或新的 CLI 子命令。
初始规划阶段通过 python -m benchmark.runtime.planning_batch PROPOSAL.json 声明 outcome 并写入 Todo。此前 Python 预检用 len(str)(Unicode code point)计长,而落库权威 TypeScript goal-acceptance refine 使用 String.length(UTF-16 code unit),导致非 BMP 字符(如 emoji)两侧边界与报错数字不一致。本次增量把两侧统一到 UTF-16 code unit,并同步更新 --schema、--help、guidance、goal-acceptance --help、RUNTIME.md 与 TS 错误提示。
改动思路 / Approach
架构评估:_utf16_code_unit_len 保留在既有规划预检入口 benchmark/runtime/planning_batch.py,不改变 TypeScript outcome_requirements.ts 的最终落库权威,仅使前置校验与权威规则对齐。 当前 PR 边界:覆盖 planning_batch 预检计数/schema/help/guidance、outcome_requirements.ts 与 goal_acceptance.py 错误/帮助单位措辞、RUNTIME.md 一行文档以及对应的 TS/Py 边界测试。
单一规则、两处执行:TS String.length 仍是落库权威;Python 仅新增 _utf16_code_unit_len(value) = len(value.encode("utf-16-le")) // 2,在 _text(含上限时)和 _opaque_id 中替换 len()。
| 输入 | 旧 Python 预检 | 新 Python 预检 | TS refine |
|---|---|---|---|
| objective = 512 个 emoji(1024 units) | 通过 | 通过 | 通过 |
| objective = 513 个 emoji(1026 units) | 通过(513) | 拒绝:got 1026 UTF-16 code units, max 1024 |
拒绝(同数字) |
错误文本与 --schema 字段名(max_utf16_code_units、length_unit)同步更名,消除 chars 歧义。--schema 为只读帮助输出,无持久化消费者。
具体改动 / Changes
benchmark/runtime/planning_batch.py:新增_utf16_code_unit_len;_text在max_chars存在时按 UTF-16 code unit 比较并在错误中报告该单位;_opaque_id同样改用该计数;planning_batch_schema()增加length_unit: utf16_code_units,各字段min_chars/max_chars改为min_utf16_code_units/max_utf16_code_units;planning_batch_guidance()与 argparse epilog 明确单位并注明非 BMP emoji 计为 2。loopx/control_plane/goals/outcome_requirements.ts:describeTextFailure全部分支将chars改为UTF-16 code units,校验逻辑value.length > max保持不变。loopx/cli_commands/goal_acceptance.py:--help的 refine 说明同步单位。benchmark/runtime/RUNTIME.md:一行文档同步。- 测试:
test_benchmark_planning_batch.py新增 3 个非 BMP 溢出预检用例及 File/SQLite 真实 CLI 的精确边界用例;test_goal_outcome_diagnostics.py通过真实goal-acceptance refineCLI 验证精确边界通过与 1026/2002/514 拒绝且不回显输入;goal_outcome_refinement.test.ts新增同等边界的 TS 单测。
本地验证(exact head 8f5ac08f3b):tsc --project tsconfig.control-plane.json --noEmit rc=0;goal_outcome_refinement.test.ts 34 passed / 0 failed / 0 skipped;pytest test_benchmark_planning_batch.py test_goal_outcome_diagnostics.py test_goal_outcome_refinement.py 77 passed / 0 skipped / 0 failed;pytest benchmark/tests/test_task_entry.py(sforge + harbor 启用)113 passed / 0 skipped / 0 failed;ruff 与 git diff --check 通过;loopx check public boundary scan 7 files clean;canary premerge --from-git-diff --git-diff-base origin/main 17/18 通过,唯一失败 cli-output-budget-regression-smoke.py 仅因系统 python3 缺少 pytest(用仓库 .venv/bin/python 独立重跑输出 cli-output-budget-regression-smoke ok)。变异检验:将 _utf16_code_unit_len 改回 len(value) 后 3 个非 BMP 预检用例失败,证明测试有效捕获该不变量。git merge-tree 与当前 origin/main(833a3b50f9)无冲突。
对主干的风险 / Risks
- 行为变化仅作用于含非 BMP 字符且 UTF-16 长度超限的文本:原可绕过 Python 预检但在 TS 失败的输入,现于预检阶段即给出与 TS 一致的错误;纯 BMP 输入接受集合零变化。
--schema键名从max_chars改为max_utf16_code_units:仓内仅测试与提示引用,外部若硬编码旧键需适配。- 残余边界(既有差异,非本 PR 引入):JSON 中的孤立代理项(lone surrogate)在 Python
encode("utf-16-le")时抛出UnicodeEncodeError(ValueError子类,被同一预检路径拒绝),此前写入 UTF-8 文档同样失败;Pythonstr.strip()与 JStrim()的空白字符集细微差异(如U+FEFF)亦属既有行为。
我的整体评价 / Verdict
架构评估:_utf16_code_unit_len 保留在既有规划预检入口 benchmark/runtime/planning_batch.py,不改变 TypeScript outcome_requirements.ts 的最终落库权威,仅使前置校验与权威规则对齐。 当前 PR 边界:覆盖 planning_batch 预检计数/schema/help/guidance、outcome_requirements.ts 与 goal_acceptance.py 错误/帮助单位措辞、RUNTIME.md 一行文档以及对应的 TS/Py 边界测试。 增量修复精准闭环 PRRT_kwDOStEbEs66i6fs 所指出的 Python/TS 计数单位不一致,验证覆盖 TS 单测、真实 File/SQLite CLI、完整 test_task_entry.py(113 passed)与变异敏感性检验,未发现阻塞问题。残余风险为孤立代理项与空白集合的既有细微差异,最值得后续补充的验证是一条 lone-surrogate 输入诊断测试。
English verdict: APPROVE — Python preflight now aligns with the TypeScript UTF-16 code unit authority across all bounded fields, verified on File/SQLite CLIs (77 + 113 passed), TS suite (34 passed), and mutation sensitivity with no blocking findings at 8f5ac08f3b.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 显式 target_key: null 应在计划写入前被拒绝。 原主线收到显式 target_key: null 时退出 1,Goal provider revision 与 Todo 均无变化。候选退出 0,持久化验收条件和一个没有 target_key 的 runnable Todo。省略字段及有效字符串在候选都按预期写入。 两种存储的对照结果一致。当前 _request 用 row.get("target_key") is not None,把非法值变成了缺省,计划 writer 随后按有效提案执行。使用键存在性区分省略与显式 null,把存在的值交给原 _text 验证。将缺省、null、有效字符串都加到真实 CLI 回归中,拒绝用例核对状态零变更。 预检分支
动机 / Motivation
批量提交首轮计划的 benchmark worker 与用 CLI 登记 Goal 验收的调用方。 调用方过去要查源码才能知道字段限制,部分无效输入直到子命令执行才被发现。候选为帮助、模板和错误增加字段规则,也将目标验收字段统一到 UTF-16 code units。 三个长文本字段的非 BMP 正反例通过。可选 target_key 的 null 输入在 File 和 SQLite 上从写入前拒绝改成了创建 Goal 条件和 Todo,并返回 ready。 没有启动付费模型或实际 benchmark trial。
恢复 target_key 作为可省略字符串的输入边界,在任何计划写入前拒绝显式 null。
改动思路 / Approach
保留规划入口的预检与 Goal 的权威验收,修复现有分支的缺省判定,避免增加第二套 Todo 写入规则。 本 PR 可交付自描述契约和诊断,但须保住原规划输入边界。 Python 提供可读 schema 与更早的参数诊断,TypeScript 仍决定持久化约束和拒绝结果。对照基线 d38052695c2c8a2e67cdb2c1eb6f4c6651eabd4d 的 benchmark/runtime/RUNTIME.md 所述 Initial planning batch,以及现有验收 owner 的 UTF-16 code units 上限。前者仍需通过同一输入和持久结果的反例,后者已经复验。 基线规划协议
具体改动 / Changes
完整 base 到 8f5ac08f3b043307e4ae791ff732c61ead91b05a 差异为 7 文件 +755/-52。当前头相对旧 review 的主要增量是 Python 的 UTF-16 计量与相应测试,旧评审指出的三个非 BMP 上限差异已复验修复。生产变化还包括规划 CLI 的 --help 与 --schema、_request 的前置字段检查,随后保留原声明与 Todo 写入顺序。Goal 验收入口在 help 显示声明形状,TS writer 报告长度、字段、形状与标识符约束。用户能在错误里看到字段及原因,测试确认不会回显原值。 规划 schema TS 验收校验
对主干的风险 / Risks
规划与 Goal 验收定向 Python 77 项通过。TypeScript 105 项通过、27 项 PostgreSQL 环境用例跳过。本地 premerge 的 6 项直接检查和 18 项选中检查无执行失败,benchmark_sensitive 人工项待确认。File 和 SQLite 两组原生对照均保留合法省略和字符串写入,只有显式 null 产生了 schema 未声明的成功与新的 provider revision。先拒绝不合规的输入可避免把调用者带入已初始化的工作状态。复验了 UTF-16 的三个长度边界,以及修正相同操作后的 readback 和重试。原 Unicode 线程已解决,当前没有未解决的旧线程。 原 Unicode 线程
我的整体评价 / Verdict
保留自描述 schema、准确错误和共享 UTF-16 单位。将 null 拒绝收回原输入校验,并以原生命令确认不写入验收条件或 Todo。当前修改没有涉及渲染页面。
English verdict: REQUEST_CHANGES at 8f5ac08. Reject an explicit null target_key before any write. The candidate commits a ready plan for that input on both File and SQLite, whereas the baseline rejects it.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 升级后保留未完成规划批次的原声明身份
_action_kind 返回小写规范值,随后 _request 将该值纳入声明 ID 的摘要。旧版在摘要中使用原 token 表示。 对旧批次使用原提案稳定表示追认同一声明与原 effects,或者为声明身份保留原摘要语义。将 token 验证和 Todo 的规范化继续交给现有 owner。补测旧版写入部分计划后,在新版本用原文件完成 binding。 候选代码
动机 / Motivation
在 File 或 SQLite Goal 上用 initial planning batch 写入验收与 Todo,并需要从中断恢复的 benchmark runner 调用方。 旧规划入口缺少字段说明与位置诊断。它在向 Todo owner 提交前保留 action_kind 的大小写,旧批次也用这份表示生成 outcome ID。 在现有规划入口提供自带 schema 和准确错误,保持 Goal 声明、Todo 写入和原提案重放语义。
用显式 null 验证可选字段拒绝,另以已部分写入的小写 action_kind 规划提案执行原参数重试。 当前候选在 File 和 SQLite 上均拒绝显式 null,provider revision 保持稳定。基线写入的普通小写计划可以在候选上继续,并绑定原有 Todo。
旧版接受大小写混合的 token Implement,真实声明及首条 Todo 已写入,随后响应丢失。操作者依照运行手册,在升级后提交同一份未改动提案。 _action_kind 返回小写规范值,随后 _request 将该值纳入声明 ID 的摘要。旧版在摘要中使用原 token 表示。 File 和 SQLite 的旧版对照能重放并绑定两个 Todo。换成当前候选后,原提案报 Planning declaration is missing or changed,只留下原来未绑定的一条 Todo;provider revision 无新的写入。 File 与 SQLite 均运行仓库真实 planning CLI。只在首条写入成功后模拟响应丢失,其他读写均使用原 Goal provider。
改动思路 / Approach
Python preflight 校验模型的 JSON,现有 Goal acceptance 与 Todo 写入权威继续维护声明、provider CAS 和 receipt。恢复入口用原声明 ID 核验已写入的批次。 局部调整批次规范化与声明摘要的分界,保持现有 effect ID、既有 Todo owners 和精确 readback。
具体改动 / Changes
关键代码讲解
评审头 8e6eaee,合并基线 d380526。7 个文件,+818/−52。 依据 Initial plan proposal schema 和 Reuse the unchanged proposal after interruption 核对现有入口。 仓库规范 Goal outcome 恢复设计
- planning_batch_schema。向调用方公开字段类型、长度、计数和实例。 代码
- _action_kind。在进入任何子命令前复用 Todo token 正规化,结果目前也进入声明摘要。 代码
- _declared_outcome。在 provider revision 改变时回读并匹配已有声明的 owner、目标和要求。 代码
- apply_initial_plan。串联声明、Todo 写入、原 receipts 和绑定。 代码
- text。保留目标验收的 TS UTF-16 校验并输出字段级错误。 代码
对主干的风险 / Risks
语义与 CI 对齐
定向 Python 套件,基线 21 项通过、候选 全套仍未返回结果。候选 17 项定向 CLI/输入边界测试通过。候选的 105 项 TypeScript 用例通过,27 项 PostgreSQL 环境用例跳过。 标准 premerge 含 6 项直接和 18 项选中检查,0 项直接失败、1 项选中失败。 语义词表 smoke 在 210 秒超时。 完整 restart 由隔离 File 与 SQLite 重现。结论未使用远端 CI、评测试跑或 PostgreSQL 跳过项。
我的整体评价 / Verdict
当前头需要修改。旧版仍可完成原批次。新版使用相同提案时会稳定停在原声明匹配步骤。恢复已有计划时应沿原 receipt 绑定,避免重新提交一个不同计划。 下一次验收须确认旧批次用未改动的 proposal 恢复剩余 Todo 和 binding,并回读原 Todo ID。
English verdict: REQUEST_CHANGES — the head rekeys accepted legacy mixed-case action kinds and cannot recover an interrupted batch from the unchanged proposal. Exact head 8e6eaee.
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 保留首轮计划的跨版本重试与声明身份。 旧规划批次会去除 requirement ID 和 source ref 首尾空白,然后写入合法 ID。新头的预检直接拒绝原文件。 旧批次接受 Validate 并将原 token 纳入声明摘要。Todo owner 接收并规范化 token。新头在计算摘要前改用小写值,查找不到旧声明。 对两种输入,File 和 SQLite 都先实际写入验收条件和一个 Todo,再模拟遗失 Todo 响应。新头重试退出 1,provider revision 与未关联 Todo ID 保持原样。基线重试关联同一个 Todo ID 并返回 ready。 保留旧批次 ID 的去空白规则,并在验证 action_kind 时保留生成声明摘要所用的旧值,或提供经真实重放验证的兼容路径。 规划输入校验
动机 / Motivation
通过 benchmark worker 提交首次计划的调用者,需要从帮助确认可提交字段,并在写入回执丢失后继续原计划。 旧批次如果已经建好验收条件和 Todo,只差最后关联,调用者保留原提案即可重试。当前头遇到两类过去可提交的输入时,重试会在关联前停止。 独立的 File 和 SQLite 测试都保留了已写入的 Todo,却只有基线可以用同一份提案关联原 ID 并返回 ready。当前头的 schema 和字段诊断另有可验证改进。 本次范围是现有规划入口及 Goal 验收的帮助、诊断和恢复,没有运行付费模型或打分任务。 初始计划已写入部分状态后的跨版本重试仍有阻塞。
改动思路 / Approach
保留对新 schema 的发现路径和原生 writer。新增前置检查复用现有动作校验,但需要保留之前已接受的初始提案及其操作身份。 只覆盖现有首轮批次入口和可公开的原生验收诊断。现有 Goal owner 和 Todo owner 继续执行权限和持久化检查。 正常批次先核对工作快照和 provider revision,再声明验收条件、创建有序 Todo,并把读回的真实 ID 关联到条件。这个顺序也决定了先前写入但响应丢失时怎样安全重试。普通规划仍由现有路径处理,包括已有工作、要求变化和阻塞。
具体改动 / Changes
完整差异涉及七个文件,增加 818 行、删除 52 行。 运行文档解释 schema 的发现方式。规划 CLI 增加字段诊断、UTF-16 计量与原生错误传递。Goal 验收 CLI 补充声明帮助。TypeScript writer 报告字段规则和实测限额,保留稳定错误码。三个测试文件覆盖实际计划与持久读回、Python 验收 CLI 拒绝、TS 校验规则和脱敏。基线的 declaration_and_binding 与 regular_planning_fallback 得到保持。unchanged_proposal_replay 未满足。 基线规划合同 原生验收与重试合同
关键代码讲解
- _opaque_id 在解析提案时检查标识符,增加了对过去会被去除的首尾空白的拒绝。 标识符预检
- _action_kind 复用 Todo token 检查。返回小写值以后,apply_initial_plan 会用不同字段值推导声明摘要。旧回执保护正确阻止错连,但调用者无法完成之前合法的提交。 动作校验 声明身份
- describeTextFailure 用固定规则、输入类型和 UTF-16 长度生成公开诊断。Goal writer 继续持有变更权限,受信的错误详情沿现有 CLI 传递。 验收校验
对主干的风险 / Risks
PASS。显式 null 在 Goal 和 Todo 写入之前退出 1。省略或合法字符串返回 ready 并读回目标键。两个真实存储均通过。 回归测试也核对三个非 BMP 字段的 UTF-16 计量。精确头原定向 Python 17 项通过。File 的合法提案首次达到测试进程 30 秒上限,仅将本地测试等待上限改为 180 秒后,原 File 和 SQLite 用例及预检共 14 项通过。TypeScript 105 项通过,27 项 PostgreSQL 用例因未配置服务跳过。TypeScript 类型检查、Ruff、diff 检查通过。快速预合并的四项直接检查与 Python 编译通过。CLI 输出预算 smoke 在组合运行中超时。单独执行同一 smoke 通过。 当前主干三方合成无冲突,保留相同七文件差异。 原 null 评审
FAIL。跨版本重试对照确认新头拒绝后没有重复写入,风险是已有 Todo 无法通过原操作完成关联。已通过的当前头测试没有覆盖上述两个旧提案形态。
语义与 CI 对齐
继续使用现有 Todo action 词汇、Goal 验收 owner 和逐效果回执。当前变更影响既有中断重试义务。在隔离的 File 和 SQLite 各用旧 CLI 声明并创建一个 Todo,丢掉该响应,再用新 CLI 运行同一份 JSON,读回原 Todo ID 的关联和 ready。 重试合同
我的整体评价 / Verdict
现有规划入口的 schema 与原生诊断达到可直接发现和验证的效果,显式 null 的上一轮缺陷已经修复。长期运行仍受到跨版本恢复回退影响,调用者会拿到无法用原提案继续的拒绝。保留旧输入规范化和声明身份后,重跑两个后端的跨版本恢复。这次变化出现在 CLI 及 runner 提示文字,没有改动渲染页面。 使用两个隔离存储的源码 CLI,丢失写入响应由测试子进程模拟。未运行已安装应用、PostgreSQL、模型采样或 GitHub CI。
English verdict: REQUEST_CHANGES at 8e6eaee. The explicit null target_key regression is fixed. Valid legacy plans still cannot finish after a lost Todo receipt on File or SQLite when the proposal has padded IDs or a mixed-case action token.
…est on retry Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Summary
Makes initial task planning (
planning_batch) andgoal-acceptance refineschema constraints self-contained and immediately diagnosable without requiring callers to inspect LoopX source files:Self-contained
planning_batchCLI & prompt (benchmark/runtime/planning_batch.py,benchmark/runtime/RUNTIME.md):sys.argv[1]file open (which crashed on--help) withargparsesupporting--helpand--schema(planning_batch_schema()), printing exact required/optional JSON keys, length bounds, opaque identifier regex,action_kindtoken pattern, and a minimal example payload.planning_batch_guidance()to inline the exact nested JSON shape (outcome.{objective, requirements:[{id,description}], source:{ref,summary}},todos:[{text, action_kind, target_key?}]), explicitly state the opaque ASCII identifier rule (1..128chars matching^[A-Za-z0-9][A-Za-z0-9_.:@-]*$, no/paths or spaces) onoutcome.source.refandrequirements[*].id, reference--schema, and clarify that a successfulstatus="ready"batch result can be returned directly without extratodo list/goal-acceptance inspectcalls._request,_record,_text,_opaque_id,_action_kindreusingnormalize_todo_action_kind/TODO_ACTION_KIND_PATTERNfromloopx/control_plane/todos/contract.py) before spawning any LoopX subprocess, rejecting invalid field shapes, unsupported keys (by count + allowed list without echoing caller values/keys), length overflows, and invalid identifiers/tokens in milliseconds.PlanningBatchCommandErrorso subprocess failures preserve structurederror_detail,error_code,stage, andcurrent_provider_revisionin the returned JSON receipt rather than droppingerror_detail.Actionable, leak-free
GoalOutcomeValidationErrordiagnostics (loopx/control_plane/goals/outcome_requirements.ts):text(),id(),keys(), andlist()diagnostics with exact rule reasons, observed lengths/counts, limits, missing required field names, and allowed field lists while strictly preserving public-error hygiene (fixed rule text, validator-owned field names, and integer counts only — zero caller strings or caller keys echoed).got N chars, max 128) and opaque-ID character rules together when an ID/source ref exceeds128characters.goal-acceptance --helpdeclaration schema (loopx/cli_commands/goal_acceptance.py):Outcome declaration (refine):section togoal-acceptance --helpdocumenting therefineJSON document shape, opaque ID pattern, and character/item limits.Verification
npm run typecheck:control-plane— passed (tsc --project tsconfig.control-plane.json --noEmit)node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/goal_outcome_refinement.test.ts tests/control_plane_ts/goal_outcome_capacity.test.ts tests/control_plane_ts/goal_acceptance_authority.test.ts—105 passed, 0 failed(27 skippedPostgreSQL integration cases without PG env)ruff check benchmark/runtime/planning_batch.py loopx/cli_commands/goal_acceptance.py tests/control_plane/test_goal_outcome_diagnostics.py tests/control_plane/test_benchmark_planning_batch.py+git diff --check— passedpytest -q -rs tests/control_plane/test_benchmark_planning_batch.py tests/control_plane/test_goal_outcome_diagnostics.py—37 passed(0 skipped, 0 failed)pytest -q -rs benchmark/tests/test_task_entry.py tests/control_plane/test_goal_outcome_refinement.py—94 passed, 54 skipped(harboroptional package not installed in local venv,0 failed)python -m loopx.cli --format json --runtime-root <runtime-root> check --scan-path .—ok: true, errors: 0python -m loopx.cli --format json --runtime-root <runtime-root> canary premerge --from-git-diff --git-diff-base origin/main—direct_checks: 4/4 passed,python_compile: 1/1 passed,catalog_canaries: 10/10 passed,risk_profile_smokes: 8/8 passed,failures: 0(gate.status: manual_review_required,manual_hold_count: 1)