Skip to content

refactor(control-plane): apply 3-layer write_scope subtraction convergence - #9256

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/write-scope-subtraction-20261122
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/write-scope-subtraction-20261122

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Implements the three-layer write_scope subtraction convergence across TypeScript control-plane owners, Python runtime/CLI adapters, reference docs, and test suites—replacing first-screen truncation glue from #9078, #9106, and #9086 with structural subtraction at the source.

1. Layer 1 — Fold Goal Whitelists & Defer cba.active_write_scope

  • Redundant path folding (loopx/control_plane/coordination/configuration.py, loopx/control_plane/quota/goal_boundary.py, loopx/boundary_authority.py, loopx/configure_goal.py): Fold subpaths covered by broad local prefixes (**, /**, dir/**) inside coordination.write_scope and internally within checkpointed_boundary_authority.active_write_scope, while preserving cross-repository / explicit external-boundary exclusions, sensitive credential directories, and --harden policy compatibility.
  • First-screen deferral (loopx/control_plane/quota/progressive_context.ts, loopx/control_plane/quota/turn_envelope.ts): Move goal_boundary.checkpointed_boundary_authority.active_write_scope off Page 0 / required-context.json into on-demand context-read --select /goal_boundary/checkpointed_boundary_authority/active_write_scope, retaining compact active_count / inactive_count summary counts on the opening surface.
  • Multi-detail warm opening fix (loopx/control_plane/quota/progressive_context.ts): Update withLinkedObservedRemainder to track all deferred detail pointers in openingSplit.details so warm reuse of /goal_boundary/write_scope no longer leaves un-reused CBA arrays stranded on Page 0.

2. Layer 2 — Default-Off required_write_scopes & Retire False-Positive Gate

  • Default-off projection (loopx/control_plane/todos/context_projection.ts, quota_selection.ts, quota_summary.py, selected_todo_projection.py, work_items/action_portfolio.ts, work_items/planning_inventory.ts): Stop projecting required_write_scopes into agent_todo_summary, selected_todo, capability_gate, and action_portfolio by default (while preserving raw scope metadata lookup strictly for adaptive_children child-lane isolation in task_orchestration_admission.py).
  • False-positive repair retirement (loopx/control_plane/quota/projection_repair.py, should_run.py): Disable required_write_scope_missing_from_goal_boundary auto-repair when goal_boundary.write_scope already covers the Goal root or when the selected Todo binds task_repository.
  • Workspace guard simplification (loopx/control_plane/agents/workspace_guard.py): Base isolated worktree requirements on action_kind (PEER_WRITE_ACTION_KINDS) + task_repository instead of requiring per-path required_write_scopes.

3. Layer 3 — Retire task_lease write_scope_conflict Hard Blocks & Reclaim Glue

  • Lease exclusivity (loopx/control_plane/work_items/task_lease_acquire.ts, task_lease_acquire_decision.ts, coordination/claim_execution.ts, coordination/task_lease_acquire.ts, coordination/todo_claim.ts, quota/adaptive_children.ts, capabilities/explore/todo_branch_plan.py): Return task_lease acquisition to Todo ownership + same-checkout/worktree (sameLeaseWorkspace) exclusivity (workspace_lease_conflict), stopping default per-path write_scopes collection and write_scope_conflict rejections.
  • Reclaim #9078 / #9106 / #9086 glue (loopx/cli_commands/todo.py, todo_argument_validation.py, docs/reference/canonical-lease-renew.md, docs/reference/required-work-context.md, loopx/pi_goal_mode/README.md): Retire _thin_claim_overlap_advisories and inline claim-overlap detail wiring (-68 net lines in loopx/cli_commands/todo.py), and keep a clean boundary with open PR #8941 (note for #8941: update its claim_execution.ts check from "write_scope_conflict" to "workspace_lease_conflict" when integrating alongside this PR).

Empirical Measurements (Representative Multi-Boundary Snapshot, Before vs. After)

Metric Before After Delta
goal_boundary.write_scope items 295 5 -98.3%
goal_boundary.write_scope compact JSON 12,631 B 419 B -96.7%
goal_boundary section in required-context.json 16,571 B 4,099 B -75.3%
cba.active_write_scope (7 active entries) on Page 0 true false (on-demand 392 B) deferred
agent_todo_summary rows with required_write_scopes 7 0 -100%
agent_todo_summary compact JSON 44,752 B 40,658 B -9.1%
required-context.json total bytes 502,609 B 486,973 B -15,636 B
projection.json total bytes 836,240 B 571,444 B -31.7%
Progressive first_read_command total bytes 41,692 B 29,530 B -29.2%
Raw --turn-envelope total JSON (boundary field) 705,151 B (13,665 B) 567,420 B (2 B) -19.5%
  • Diff stat (origin/main..HEAD): 58 files changed, 873 insertions(+), 601 deletions(-) (runtime files: 26 files, +471/-221; loopx/cli_commands/todo.py: +0/-68 net lines).

Verification

  • loopx canary premerge --from-git-diff --git-diff-base origin/main --goal-id personal-loopx-maintenance: passed (19/19: 4 direct checks including scripts/check_rfc_bilingual.py, py_compile, 10 catalog canaries, 8 risk-profile smokes, public boundary scan across all 58 files; Goal-bound CQR receipt cqr_63d728bce1633b3a6d77 verified valid).
  • npm run typecheck:control-plane: passed.
  • uv run --extra test mypy (17 configured Python source files): passed.
  • uv run --extra test ruff check (all changed .py files): passed.
  • node --experimental-strip-types --test: tests/pi_goal_loop_runtime.test.mjs (83 pass, 0 fail); targeted TS control-plane suites covering changed modules (437 pass, 1 skipped PostgreSQL, 0 fail). (Note: an earlier full npm run test:control-plane run passed 6,732/6,824 with 91 PostgreSQL skips and 1 pre-existing unrelated failure on origin/main in tests/control_plane_ts/content_digest_single_owner.test.ts:911:1 for control_plane/quota/execution_loss_closeout_record.ts.)
  • pytest:
    • Full tests/control_plane/test_todo_claim_argument_recovery.py + tests/control_plane/test_quota_settlement_cli.py (after final test edits): 283 passed.
    • tests/control_plane/test_canonical_claim_execution_proof.py + tests/control_plane/test_task_orchestration_admission.py + tests/control_plane/test_adaptive_child_admission_characterization.py: 72 passed.
    • Full control-plane + root verification sweep on loopx/ code prior to the two final test-expectation updates (task-1642): 2,320 passed, 74 skipped, with the 5 stale pre-subtraction assertions resolved and re-verified cleanly above.

…gence

Layer 1 folds redundant coordination.write_scope and cba.active_write_scope entries under broad prefixes (preserving external/credential boundaries and --harden compatibility) and moves cba.active_write_scope off page-0 first read into on-demand context-read.

Layer 2 stops projecting required_write_scopes into agent_todo_summary, selected_todo, capability_gate, and action_portfolio by default, disables required_write_scope_missing_from_goal_boundary repair when Goal covers repo root or task_repository is bound, and bases workspace_guard isolation checks on action_kind + task_repository.

Layer 3 stops collecting/checking per-path write_scope_conflict blocks across task_lease_acquire, adaptive_children, coordination, and todo_branch_plan while returning leases to Todo ownership + same-workspace locking, retiring thin claim overlap advisories, and reclaiming page-0 truncation glue.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

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

Reviewer: model_agent · Gemini · Google · self_reported

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

动机 / Motivation

受影响调用方与操作者:本变更影响读取 LoopX 决策首屏上下文(quota should-run 与 context-read)的 Agent Host、配置目标白名单(goal_boundary.write_scope)与已审批边界(checkpointed_boundary_authority)的维护者,以及在多 Agent 场景下调用任务租约(task-lease acquire)和自适应子任务分发(adaptive_children)的协同执行方。

改造前后的具体场景:在旧路径中,只要某个 Goal 同时配置了宽泛前缀和大量细粒度子路径,或者每个 Todo 都带有冗长的路径范围列表(required_write_scopes,即每个任务声明的可写路径范围):(1) goal_boundary.write_scope 与 checkpointed_boundary_authority.active_write_scope 会把已被覆盖的子路径和审批列表原样堆入首屏,迫使控制信息挤出首页预算;(2) 每个摘要与动作候选里的 required_write_scopes 不仅膨胀上下文体积,还会让 projection_repair 在 Goal 已覆盖仓库根或任务绑定外部仓库时误触发边界修复阻断,而多 Agent 隔离检查也以路径范围存在与否为前提;(3) 多 Agent 在独立 Git worktree 并行工作时,仅因路径范围重叠就会在 task-lease acquire 阶段被 write_scope_conflict 硬拒绝。改造后,Layer 1 在源头折叠被宽前缀覆盖的本地子路径并将已审批数组延迟到按需 context-read;Layer 2 默认从 agent_todo_summary、selected_todo、capability_gate 与 action_portfolio 移除 required_write_scopes,改为基于 action_kind 与 task_repository 判定隔离与边界修复;Layer 3 退场 write_scope_conflict 硬阻断,将租约互斥收敛到物理 checkout 冲突(workspace_lease_conflict)。

可观测改进:在确切提交 bbbdb3085f53ab0261953361447f70b30c03831a 的本地实测中:fold_write_scope_subpaths 可将包含 ** 与子路径的本地白名单折叠为精简前缀,在剔除冗余本地子路径的同时保留凭证路径与跨仓库绝对路径;prepareInitialOpening 与 progressivePreparationScopes 在保留 active_count 与 inactive_count 计数摘要的前提下将 active_write_scope 与 entries 移出首屏;decideTaskLeaseAcquire 与 admitAdaptiveChildren 允许不同工作目录或不同所有者在重叠 write_scopes 下继续获取租约与分配子任务。

非目标:本 PR 不从 Todo 规范存储或 todo list 显式读取中删除 required_write_scopes;不在 checkpointed_boundary_authority.active_write_scope 与 coordination.write_scope 之间做跨边界折叠;不引入跨 Goal 全局物理文件锁;也不在本 PR 内直接改写待整合 PR #8941。

剩余缺口:在确切头 bbbdb3085f53ab0261953361447f70b30c03831a 仍存在两项阻塞问题:其一,settlement_cli.py 与 workspace_guard.py 仍向 build_delivery_workspace_causality 传入已裁剪掉 required_write_scopes 的 selected_todo 投影,导致同时声明 required_write_scopes 与 same_agent_non_delivery 的任务绕过工作区校验,并使仅声明 required_write_scopes 的任务被错误记为 unknown;其二,本 PR 修改的 docs/reference/required-work-context.md 第 349 至 355 行及第 384 至 388 行仍在指引迁移后从捕获读取已删除的 /selected_todo/required_write_scopes。

改动思路 / Approach

本 PR 采用“源头减法 + 分层所有权收敛”的架构路径,整体沿着既有的配置归一、首屏渐进读、边界修复、结算因果与租约裁决所有者推进,没有另起平行的状态裁剪层或新的外围截断胶水(reusing existing owners configuration.py, progressive_context.ts, projection_repair.py, task_lease_acquire_decision.ts)。

层级 变更前基线 (7fb1c851...) 变更后确切头 (bbbdb308...) 关键边界与实测状态
Layer 1 源头折叠与延迟 goal_boundary.write_scope 全量展开子路径;cba.active_write_scope 与 entries 常驻首屏 fold_write_scope_subpaths 按 goal_repo 折叠被 **/dir/** 覆盖的本地子路径;prepareInitialOpening 仅在首屏保留计数并将数组延迟到 context-read 凭证段/后缀与外部绝对路径保持不折叠;withLinkedObservedRemainder 修复多 detail 热复用丢失问题(源读+实测 PASS)
Layer 2 默认去投影与守卫简化 agent_todo_summary、selected_todo、capability_gate、action_portfolio 均默认携带 required_write_scopes 默认从上述投影移除 required_write_scopes;projection_repair 在覆盖仓库根或绑定 task_repository 时跳过修复并借助 raw_agent_todo_summary 兜底;workspace_guard 改看 action_kind + task_repository 遗漏消费端:settlement_cli.py:459 与 workspace_guard.py:245 仍喂入精简后的 selected_todo,实测触发 same_agent_non_delivery 绕过与 unknown 降级(CLI 对照 FAIL)
Layer 3 租约互斥收敛 decideTaskLeaseAcquire 与 admitAdaptiveChildren 按重叠路径拒绝(write_scope_conflict);todo claim 附带 thin_claim_overlap_advisories 收敛为 Todo 所有权 + 同物理 checkout 互斥(workspace_lease_conflict),允许重叠范围并行获取租约;清理 todo.py 冗余通知逻辑(-68 行) 保留显式 write_scopes 写入与覆盖率函数以兼容历史读取;残留少量未接线变量(CLI 对照 PASS)

注:上表基于 7fb1c851ade04fd31a21f395f0447ca832d2aeb5 与 bbbdb3085f53ab0261953361447f70b30c03831a 的源码审计(fold_write_scope_subpaths、prepareInitialOpening、build_boundary_projection_repair_hint、selected_todo_projection、quota_rollout_details、observe_goal_delivery_workspace_isolation、decideTaskLeaseAcquire、admitAdaptiveChildren)及受控 CLI 对比探测,表格本身为结构说明而非独立覆盖率证明。

架构与比例评估:就三层减法架构本身而言,把折叠放在配置与边界入口、把延迟读取放在 TypeScript 渐进上下文所有者、把互斥语义收口于租约裁决所有者,同时只在 projection_repair.py 与 task_orchestration_admission.py 保留受控原始查询,实现了不变量、策略与投影的清晰分离,但必须修复 settlement_cli.py 与 workspace_guard.py 消费裁剪后 selected_todo 导致的因果绕过。当前 PR 边界聚焦 Goal 白名单折叠、首屏上下文减负、边界误报消除和租约目录锁收敛,不删除规范存储中的范围声明,也不触碰外部集成 PR #8941。

具体改动 / Changes

本 PR 共变更 58 个文件(+873 / -601 行):生产代码 25 个文件(+470 / -220)、测试与夹具 29 个文件(+344 / -309)、文档 3 个文件(+53 / -70)及示例冒烟脚本 1 个文件(+6 / -2)。主要热点集中在 loopx/control_plane/coordination/configuration.py(+195/-7)、loopx/control_plane/quota/progressive_context.ts(+61/-45)、loopx/cli_commands/todo.py(+0/-68)、loopx/control_plane/quota/projection_repair.py(+62/-1)、loopx/control_plane/quota/turn_envelope.ts(+21/-24)及 loopx/control_plane/quota/task_orchestration_admission.py(+33/-1)。

规范依据(spec_basis):no_spec(spec_source: none)。代码库中不存在预先写定本“三层 write_scope 减法收敛”重构的独立 RFC;docs/reference/canonical-lease-renew.md 与 docs/reference/required-work-context.md 均在本 PR 内与实现一并修改,因此不能作为独立于补丁的前置验收规范,交付判断完全基于 problem_context 与既有运行时不变量(例如 test_non_delivery_policy_cannot_override_repository_write_contract)。

关键代码讲解

  1. fold_write_scope_subpaths(loopx/control_plane/coordination/configuration.py:116-194):在配置与边界投影层去重并折叠已被 **、/** 或某确定父前缀 dir/** 覆盖的本地路径(包括解析 goal_repo 前缀对应的仓库内绝对路径)。关键不变量由 _is_sensitive_or_unfoldable(loopx/control_plane/coordination/configuration.py:70-87)保护:含 ..、~、;、_CREDENTIAL_SCOPE_SEGMENTS(如 .ssh、secrets)或 _CREDENTIAL_FILE_SUFFIXES(.key / .pem 等)的条目直接标记为不可折叠,仓库外绝对路径仅能在同为外部显式 dir/** 时折叠,且带 glob 元字符的父茎不参与前缀吞并。loopx/boundary_authority.py 复用了该函数在 active_write_scope 内部独立折叠,不与 coordination.write_scope 交叉折叠,从而保住持久化审批记录。
  2. prepareInitialOpening(loopx/control_plane/quota/progressive_context.ts:775-847):重构渐进首屏拆分逻辑,不再依赖 scope 是否存在才寻找 goal_boundary,而是主动检查 checkpointed_boundary_authority(校验 schema_version === "checkpointed_boundary_authority_v0" 及整型计数)。当存在非空 active_write_scope 或 entries 时,将 checkpointed_boundary_authority 展开为轻量标量键留在首屏,并把两个数组指针加入 details 以供 context-read --select 按需拉取;配合 withLinkedObservedRemainder 校验 openingSplit.details 全集,避免 /goal_boundary/write_scope 热复用后遗漏未复用的 CBA 数组。
  3. build_boundary_projection_repair_hint(loopx/control_plane/quota/projection_repair.py:224-335):在判断 required_write_scope_missing_from_goal_boundary 修复前,通过 _lookup_raw_todo(raw_agent_todo_summary, ...) 补回被默认投影裁掉的 required_write_scopes 与 task_repository。当 task_repository 非空或 _goal_boundary_covers_repo_root 为真(即边界已包含 **、/**、. 或 goal_repo 根)时直接返回 None,不再打断正常交付轮次;若边界确实窄于本地子路径(如 docs/** vs private/**),仍可靠触发 boundary_projection_repair。
  4. selected_todo_projection(loopx/control_plane/quota/selected_todo_projection.py:10-58):从 SELECTED_TODO_COMPACT_FIELDS 移除 "required_write_scopes",同时保留 "continuation_policy"、"task_repository" 与 "required_capabilities"。这达到了减小 selected_todo 载荷的目的,但也把“只剩半截写入契约的投影对象”传给了下游仍在调用 build_delivery_workspace_causality 的 settlement_cli.py 与 workspace_guard.py(见风险节阻塞项)。
  5. decideTaskLeaseAcquire(loopx/control_plane/work_items/task_lease_acquire_decision.ts:677-766):移除 write_scope_conflict 对其他有效租约的阻断分支,仅在 workspace !== null && sameLeaseCheckout(workspace, other.write_workspace) 时返回 conflict / workspace_lease_conflict(同时保留 todo_lease_conflict、CAS version_mismatch、lease_repository_mismatch、lease_workspace_repository_mismatch 与 idempotency_key_reuse 校验,并将 nextLease.write_scopes 仍经 comparisonWriteScopes 写入以维持现有结构兼容)。

对主干的风险 / Risks

阻塞性发现(Blocking Findings)

  1. Blocking / High — quota_rollout_details 与 observe_goal_delivery_workspace_isolation 消费裁剪后的 selected_todo,破坏工作区因果校验与 same_agent_non_delivery 防绕过不变量

    • 触发条件与路径:当 Todo 声明了 required_write_scopes(如 docs/**),但未设置 task_repository 且 required_capabilities 未包含 filesystem_write 时:
      • selected_todo_projection(loopx/control_plane/quota/selected_todo_projection.py:10-36)移除了 required_write_scopes 却保留了 continuation_policy。
      • loopx/control_plane/quota/settlement_cli.py:445-460(quota_rollout_details)与 loopx/control_plane/agents/workspace_guard.py:235-268(observe_goal_delivery_workspace_isolation,由 loopx/control_plane/quota/should_run_packet.py:1713 调用)直接把该裁剪后的 selected_todo 传给 build_delivery_workspace_causality。
    • 实测风险结果:在以 7fb1c851ade04fd31a21f395f0447ca832d2aeb5 与 bbbdb3085f53ab0261953361447f70b30c03831a 对照同一真实夹具的 CLI 探测中:
      • 越权绕过场景(Todo 同时设置 required_write_scopes=docs/** 与 continuation_policy=same_agent_non_delivery):基线将 quota_should_run 事件落盘为 delivery_workspace_requirement="required"(declared_repository_or_write_contract),而当前头却翻转为 "not_required"(explicit_non_delivery_without_repository_writes),且 delivery_workspace_isolation 退化为 {}。进入 loopx/state_refresh.py:1303 时因 workspace_requirement == "not_required" 跳过工作区快照抓取与隔离校验,进入 loopx/control_plane/quota/slot_accounting.py:286(仅修复空/unknown)及 :487 时也跳过修补并允许无工作区直接记账消费,直接击穿了 tests/control_plane/test_delivery_workspace_causality.py:70-83 与 loopx/control_plane/quota/settlement_workspace_causality.ts:244-256 所保护的安全不变量。
      • 未设策略场景(Todo 仅设置 required_write_scopes=src/**):quota_should_run 事件与 loopx/state_refresh.py:1451 写入 runs/index.jsonl 的记录均由 "required" 降级为 "unknown"(todo_write_contract_not_explicit)。
    • 最小修复与回归测试:仿照 loopx/control_plane/quota/projection_repair.py:262-269 的做法,在裁剪前用完整原始 Todo(如从 prepared / agent_todos 按 todo_id 找回原始记录,或提前在 should_run_packet.py 计算并传递未裁剪字段)驱动 quota_rollout_details 与 observe_goal_delivery_workspace_isolation 内的 build_delivery_workspace_causality;新增一条集成回归测试,覆盖 required_write_scopes=["loopx/**"] + continuation_policy="same_agent_non_delivery" 走完 quota should-run -> refresh-state -> quota spend-slot 仍必须强制要求 "required" 而不允许绕过。
  2. Blocking / Medium — docs/reference/required-work-context.md 与当前捕获格式自相矛盾,误导迁移场景读取不存在的指针

    • 位置与触发:本 PR 修改了 docs/reference/required-work-context.md:211-214 与 loopx/control_plane/quota/turn_envelope.ts:1333-1383、loopx/control_plane/quota/selected_todo_projection.py:10-36,明确在捕获的 selected_todo 及 progressivePreparationScopes 中删除了 /selected_todo/required_write_scopes。但同一文件 docs/reference/required-work-context.md:349-355(英文)与 L384-L388(中文)仍明文指示:“Large Goal and selected Todo write scope lists are available from the same capture at /goal_boundary/write_scope and /selected_todo/required_write_scopes” / “可从同一捕获按 /goal_boundary/write_scope 和 /selected_todo/required_write_scopes 读取”。
    • 最小修复:同步更新该中英文两段,删除已失效的 /selected_todo/required_write_scopes 捕获指针,明确仅 /goal_boundary/write_scope 位于捕获中,若工作树迁移需核对 Todo 范围则于迁移后通过 todo list 读取(与第 211–214 行保持一致)。

非阻塞观察(Non-Blocking / Follow-up)

  • selectedWorkLaunchBasis 遗失写入范围变化敏感度(loopx/control_plane/quota/turn_envelope.ts:910-918):selectedWorkLaunchBasis 仍对 selected.required_write_scopes ?? [] 计算摘要,而在 selected_todo 省略该字段后该项恒为 [];若两次探测间仅修改了 Todo 的 required_write_scopes,loopx/cli_commands/turn_decision.py:443 不会触发 current_turn_work_changed 重试。若仍希望在宿主启动门保护范围变更,需基于原始 Todo 字段或显式确认其已退场。
  • 可顺手清理的死代码(Follow-up):loopx/control_plane/quota/adaptive_children.ts:10 留有未使用的 evaluateQuotaSchedulingWriteScopesOverlap 导入;loopx/capabilities/explore/todo_branch_plan.py:438,519 留有只写不读的 selected_scopes;task_lease_acquire.ts、claim_execution.ts、todo_claim.ts 及 cli_commands/task_lease.py 仍保留永远为空的 integration_overlap_advisories 透传分支;resume_planning.ts:38,44 仍投影 required_write_scopes(靠下游 quota_summary.py 剥离)。此外 loopx/configure_goal.py:704 在参数解析阶段不带 goal_repo 调用一次 normalize_goal_write_scope,随后在 :1279-1298 再带 goal_repo 二次折叠,功能无错但可进一步合并。
  • 范围适配、权限边界与隔离评估(scope_fit / authority_semantics / default_off_isolation / domain_neutrality / guidance_vs_obligation):本 PR 全部改动均挂载于 configure-goal、quota should-run、context-read、task-lease acquire 等真实生产入口,无孤立仅测试函数;公共协议命名(task_lease_v0、workspace_lease_conflict、quota_selected_todo_v0、delivery_workspace_causality_v0)未伪造跨 Goal 全局锁或独立多 Agent 选举语义(authority_semantics: aligned);--context-delivery off 对 Page-0 CBA 延迟路径保持隔离(default_off_isolation: isolated),但 Layer 2 移除 required_write_scopes 属于全局默认变更(已导致上述结算因果缺口);规则均为类型化字段与路径归一化驱动(非子串匹配),文案保持领域中性(domain_neutrality),提示与强制动作的边界清晰(guidance_vs_obligation)。

语义与 CI 对齐

  • 词汇与契约对齐(semantic_alignment):本 PR 复用现有词汇 workspace_lease_conflict 替代退场的 write_scope_conflict,examples/semantic-vocabulary-drift-smoke.py 本地执行 PASS,没有新增未注册状态词汇。然而,由于 quota_selected_todo_v0 在默认投影中移除了 required_write_scopes,导致同一契约链上的下游消费者 delivery_workspace_causality_v0(settlement_cli.py:459、workspace_guard.py:245)和文档契约(docs/reference/required-work-context.md:352,386)出现 契约破坏(violated),需按阻塞项 1 与 2 修复后重跑上述对照探测与 tests/control_plane/test_delivery_workspace_causality.py、tests/control_plane/test_quota_settlement_cli.py 验证。
  • CI 策略与 Pre-merge 状态(wait_for_ci: false):按仓库与评审策略不等待或轮询远端 GitHub Actions CI。本地 uv run --extra test loopx ... canary premerge --from-git-diff --git-diff-base origin/main 执行 4 项直接检查 + 10 项 catalog canaries + 8 项 risk-profile smokes + 58 文件公私边界扫描全部 PASS(0 失败,0 私密泄露);唯一令 canary premerge 整体返回 ok: false 的原因是远端 origin/main 已推进到 bbd26838366cf03b371f5a2308833e03d1e1229b,使先前基于 7fb1c851ade04fd31a21f395f0447ca832d2aeb5 签发的 CQR 收据 cqr_63d728bce1633b3a6d77 状态变为 stale_receipt(修复阻塞项后应针对最新基底重新 prepare 并签发 CQR)。

本地验证矩阵(validation_matrix)

用例 / 检查 命令与范围 状态 结果摘要 必须
changed_invariant_positive 受控基线与当前头 loopx quota should-run / task-lease acquire CLI 对照探测 + node --experimental-strip-types -e(decideTaskLeaseAcquire 与 admitAdaptiveChildren) PASS Layer 1 将 4 项折叠为 ["**", "secrets/key.pem"];Layer 3 在重叠 docs/** vs docs/a.md 下由基线 write_scope_conflict(rc=1)变为 ok: true(rc=0),admitAdaptiveChildren 准入子任务 是
material_negative_or_failure 同上对照探测中 todo_docs(required_write_scopes=docs/** + continuation_policy=same_agent_non_delivery)与 todo_src(仅 required_write_scopes=src/**)经 quota should-run FAIL 基线两者均写入 delivery_workspace_requirement="required",头部错误翻转为 "not_required"(explicit_non_delivery_without_repository_writes)与 "unknown",且 delivery_workspace_isolation 被清空 是
repository_required_checks (TypeScript + MJS) npm run typecheck:control-plane;node --experimental-strip-types --test tests/pi_goal_loop_runtime.test.mjs ...(383 项)+ --experimental-sqlite 运行相关 13 个 TS 套件(214 项) PASS typecheck 通过;382 pass / 0 fail / 1 skip(PostgreSQL 未配置);额外 214 pass / 0 fail / 0 skip 是
repository_required_checks (Python 静态与测试) ruff check(变更 .py);mypy(17 配置源文件);pytest -n auto(13 个变更测试文件 737 项)+ pytest(10 个变更与因果测试文件 614 项) PASS ruff 与 mypy 均 0 错误;737 passed;613 passed, 1 skipped(test_cli_output_budget.py:2013 因临时目录长度跳过 depth-12 布局) 是
repository_required_checks (Canary Premerge & 公私边界) loopx canary premerge --from-git-diff --git-diff-base origin/main + rg 扫描本地路径前缀 FAIL (CQR stale) 直接检查 6/6、Catalog 10/10、Risk Profile 8/8、公私边界 58 文件、RFC 双语检查全部 PASS;仅因 origin/main 前移导致 cqr_63d728bce1633b3a6d77 为 stale_receipt 是
诊断对照:content_digest_single_owner.test.ts node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/content_digest_single_owner.test.ts FAIL (pre_existing_unrelated) 16 pass / 1 fail(:911:1 缺失 execution_loss_closeout_record.ts);已验证 7fb1c851... 基线同样引入 BARE_SHA256_PATTERN 且未进固定名单,与本 PR 无因果关系 否

我的整体评价 / Verdict

  • 结果影响判断(problem_context.outcome_impact):

    • long_horizon:regression(退化)。尽管 Layer 1 折叠/首屏减重与 Layer 3 退场目录重叠冲突有效减少了上下文噪声和误阻断,但 Layer 2 在裁剪 selected_todo.required_write_scopes 时未同步更新 settlement_cli.py:459 与 workspace_guard.py:245,使得包含 same_agent_non_delivery 与 required_write_scopes 的 Todo 在长程执行链(quota should-run -> refresh-state -> spend-slot)上跳过工作区抓拍与隔离校验并可完成记账消费,属于确定的跨回合约束绕过。
    • user_experience:regression(退化)。一方面 docs/reference/required-work-context.md:349-355,384-388 在工作树迁移指引中仍指向已不存在的 /selected_todo/required_write_scopes,导致依赖文档排查范围的交互回合受阻;另一方面仅声明 required_write_scopes 的 Todo 在 quota_should_run 与运行记录中的诊断因果信息退化为 unknown(todo_write_contract_not_explicit)。
    • user_experience.visual_review:not_applicable(unverified_scope: none)。本 PR 58 个变更文件仅覆盖控制面 TS/Python 运行时、CLI 投影、参考文档与测试夹具,未触及任何前端/仪表盘视图渲染,因此视觉人工检查不适用且无未验证视觉范围(unverified_scope: none)。
  • 可观测语义与体量评估(observable_semantics / code_volume / change_proportionality):通过向 7fb1c851ade04fd31a21f395f0447ca832d2aeb5 与 bbbdb3085f53ab0261953361447f70b30c03831a 提交完全相同的测试夹具并经真实 loopx CLI 执行对照,observable_semantics 判定为 unintended_drift:Layer 1 折叠与 Layer 3 租约行为按预期演进,但 Layer 2 对 selected_todo 的字段裁剪破坏了 delivery_workspace_causality_v0 消费者对“非交付策略不能覆盖显式写范围”的不变量保证。整体变更体量(58 文件 +873/-601)与重构目标是相称的(code_volume: necessary,兼容性决策为在主体契约 retain 历史 todo list 与 task_orchestration_admission 原始读取的同时,将 adaptive_children.ts 未使用导入等死代码清理列为 follow_up;change_proportionality: proportionate,architecture_assessment: retain)。权限语义(authority_semantics: aligned)及渐进读开关隔离(default_off_isolation: isolated)均成立。

  • 词汇与合规归类:本 PR 复用既有词汇(reuse_existing,semantic-vocabulary-drift-smoke.py PASS),未创造平行协议名,但因消费者断链构成契约违规(semantic_alignment: violated);修复 settlement_cli.py、workspace_guard.py 与 docs/reference/required-work-context.md,补齐 same_agent_non_delivery + required_write_scopes 回归测试并针对最新 origin/main 重新刷新 CQR 收据后,即可重新发起 exact-head 复审。当前确切头 bbbdb3085f53ab0261953361447f70b30c03831a 未达到合入标准。

English verdict: REQUEST_CHANGES — Fix the build_delivery_workspace_causality bypass/downgrade in settlement_cli.py and workspace_guard.py (which read selected_todo without required_write_scopes) and remove the stale /selected_todo/required_write_scopes pointer from docs/reference/required-work-context.md.

This branch has not been deployed

No deployments
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.

1 participant