Skip to content

refactor(work-items): slim progress_observation to <=550 LOC and Zero-Any - #9483

Merged
loopx-agent merged 1 commit into
mainfrom
codex/slim-progress-observation-zero-any-20261126
Nov 27, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/slim-progress-observation-zero-any-20261126

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Slims loopx/control_plane/work_items/progress_observation.py in place and eliminates all Any type usages across the module and its new contract test suite while preserving every exported constant, typed facade signature, loopx-jev package kernel pin, and runtime behavior.

Changes

  • loopx/control_plane/work_items/progress_observation.py (566 -> 503 <= 550 LOC, 41 -> 0 AST Any, 0 # type: ignore, 0 # noqa, max_span=80):
    • Replaced untyped Any surfaces with explicit TypedDict (ProgressTriggerRule, ObservationCheckpoints, ProgressDeltaFields, ReplanContextFields, ReplanActionPacket), Literal, and Callable contracts.
    • Deduplicated repeated context validation, single-pass obligation trigger evaluation, and successor writeback resolution via _validated_replan_context, _obligation_baseline_and_window, and _successor_writeback_contract.
    • Switched history_runs normalization to zero-copy Sequence handling and _stable_ids deduplication to O(1) set lookups while keeping a single coverage_complete read and exact replan_successor_semantic_binding(None, None, None) fallback call semantics.
    • Preserved all 21 module exports/constants and the tests/architecture/package_kernel_import_pins.json (loopx-jev) import pin with 0 changes to autonomous_replan_obligation.py, module_metric_baseline.json, and top-level loopx/*.py (112).
  • Direct callers aligned (minimal mypy compatibility updates):
    • loopx/control_plane/work_items/external_progress_review.py: narrowed observation["fingerprint"] to str (+1/-1).
    • loopx/control_plane/work_items/semantic_replan_writeback.py: checked raw_outcomes container type before membership lookup (+4/-3).
  • tests/control_plane/test_progress_observation_contract.py (327 LOC, 0 AST Any, 0 # type: ignore, 0 # noqa):
    • Verifies line/Zero-Any/loopx-jev pin/export invariants, malformed-input fail-closed validation, _progress_turn_instance_id, TypeScript codec error surfacing, single-pass trigger counting & generator history_runs, recovering_writeback_path checks, and build_replan_action_packet command formatting.

Verification

  • Paired origin/main vs HEAD counterfactual parity (14/14 exact matches): verified normalize_progress_observation, historical extraction, _progress_turn_instance_id, writeback requirements, transition eligibility/delta, trigger kinds/checkpoints, semantic_delta_from_writeback, and build_replan_action_packet.
  • pytest -n 6 -rs (control-plane, delivery/refresh, architecture, canary suites): 3,033 passed, 18 skipped, 0 failed (18 environment skips for PowerShell 7/Windows launcher and non-UTF-8/root APFS filesystem cases).
  • packages/loopx-jev/tests (6 suites): 57 passed.
  • mypy & ruff: ruff check (4/4 clean), mypy --strict --no-incremental --follow-imports=silent (2/2 clean), [tool.mypy] (17/17 clean), 40-file *.py caller mypy (336 -> 336, 0 errors in touched files), and cross-module --follow-imports=normal clean.
  • TypeScript control plane: npm run typecheck:control-plane clean; TS replan/progress/delivery suites 158 passed, 0 failed, 0 skipped.
  • Governance & Pre-merge Gates: scripts/check_rfc_bilingual.py passed, loopx check (0 errors, 0 warnings), Goal CQR receipt cqr_147f7fbf9eba80e39967 (decision=pass, status=valid), canary premerge (tier=standard, gate.status=passed, direct_checks=4/4, python_compile=1/1, catalog_canaries=5/5, risk_profile_smokes=8/8, failures=0).

@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 · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

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

动机 / Motivation

收紧重规划观察桥接层的类型和扫描开销,在恢复与写回时保持同 Turn 身份和新证据要求。 原 Python facade 归一化观察和 obligation 历史,TS owner 决定重放、阻塞的新颖性和合格写回。 运行控制面重规划、回放原 Turn 和检查结算结果的 Host。

只看表面完成或重复观察会把同一证据误当新进展并提交额外副作用。 相同证据按稳定顺序产生相同 fingerprint。两次独立 Turn 触发复核,同一 Turn 重试不触发。 投影测试基线 67 项、精确头 71 项通过。独立探针读回相同 fingerprint b133896233e4be38、同一 Turn 计数 1、两个历史 Turn 计数 2。旧 blocker 被拒,新的 blocker 触发 new_concrete_blocker。配对 DSH CLI 从 File 和 SQLite 读回未授权零扣额、合格写回后同 Turn 重放仍只有一次扣额。git diff --check 与 merge-tree 通过。 验证在隔离源检出中使用真实 CLI、TS 与 File/SQLite,DSH 模型为合成适配器。安装版、真实模型、远程 CI 未核验。生产路径使用 JSON 数组。直接传入 Python tuple 时,基线返回触发器,精确头返回空列表。 基线契约

改动思路 / Approach

该改动沿用 DSH turn run-once → native replan packet/readback → typed progress writeback owner。复用既有 normalize、replan context 和共享 typed owner,拆出的窄 helper 保持原结构化事实。 以稳定观察字段计算摘要。新颖性依据原完整历史和当前上下文快照,由原 TS 校验同 Turn 与写入义务。 保留现有 owner 及既有关联证据。薄投影只读 canonical 证据,无需新恢复状态或兼容 shim。

具体改动 / Changes

精确提交 f0f52c0,本次对照目标 81ff83a。完整 diff 自分叉点 7f7297a 起,共 4 文件,+570/-305。

关键代码讲解

  • normalize_progress_observation。以稳定身份与有序证据生成原 fingerprint。 源码

  • semantic_delta_from_writeback。把当前、历史和上下文作为原 runtime 输入。 源码

  • build_replan_action_packet。使用原 obligation 与要求发出后续工作或结算入口。 源码

  • replan-writeback-requires-fresh-bound-semantic-evidence(implemented)。确认历史作用域与真实性,重复 Turn 或旧 blocker 无法冒充新 progress。验收后可按原身份重放。

对主干的风险 / Risks

历史出现过的 blocker 在新 work item 仍不能作为新证据结算。用真实 TypeScript 审查,新的 blocker 可形成原接受结果。 以完整历史判断证据新颖性很重要,因为可见窗口可能已经省略先前的 blocker。否则同一障碍可能在后续 Turn 被重复计为新进展,进而产生新的回执与额度消耗。 维持基于原 Turn identity 和历史完整度的 TS owner 检查。

我的整体评价 / Verdict

APPROVE。 生产 wire 输入通过配对验证。真实 TypeScript owner 在两个存储上维持证据资格、绑定 Turn 身份和按一次成功扣额的规则。模型限于隔离适配器。 保留已有证据、可归因进展与原恢复边界。

English verdict: APPROVE at f0f52c0. Paired native replan tests preserved same-Turn deduplication, fresh-evidence qualification, and File/SQLite writeback and replay.

…cans in progress_observation

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/slim-progress-observation-zero-any-20261126 branch from f0f52c0 to 83410fc Compare November 27, 2026 16:27

@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 · deepseek-flash · DeepSeek · runtime_reported · high

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

动机 / Motivation

收紧重规划观察桥接层的类型和扫描开销,在恢复与写回时保持同 Turn 身份和新证据要求。 原 Python facade 归一化观察和 obligation 历史,TS owner 决定重放、阻塞的新颖性和合格写回。 运行控制面重规划、回放原 Turn 和检查结算结果的 Host。

只看表面完成或重复观察会把同一证据误当新进展并提交额外副作用。 相同证据按稳定顺序产生相同 fingerprint。两次独立 Turn 触发复核,同一 Turn 重试不触发。 投影测试基线 67 项、精确头 71 项通过。独立探针读回相同 fingerprint b133896233e4be38、同一 Turn 计数 1、两个历史 Turn 计数 2。旧 blocker 被拒,新的 blocker 触发 new_concrete_blocker。配对 DSH CLI 从 File 和 SQLite 读回未授权零扣额、合格写回后同 Turn 重放仍只有一次扣额。git diff --check 与 merge-tree 通过。 验证在隔离源检出中使用真实 CLI、TS 与 File/SQLite,DSH 模型为合成适配器。安装版、真实模型、远程 CI 未核验。生产路径使用 JSON 数组。直接传入 Python tuple 时,基线返回触发器,精确头返回空列表。 基线契约

改动思路 / Approach

该改动沿用 DSH turn run-once → native replan packet/readback → typed progress writeback owner。复用既有 normalize、replan context 和共享 typed owner,拆出的窄 helper 保持原结构化事实。 以稳定观察字段计算摘要。新颖性依据原完整历史和当前上下文快照,由原 TS 校验同 Turn 与写入义务。 保留现有 owner 及既有关联证据。薄投影只读 canonical 证据,无需新恢复状态或兼容 shim。

具体改动 / Changes

精确提交 83410fc,本次对照目标 81ff83a。完整 diff 自分叉点 7f7297a 起,共 4 文件,+570/-305。

关键代码讲解

  • normalize_progress_observation。以稳定身份与有序证据生成原 fingerprint。 源码

  • semantic_delta_from_writeback。把当前、历史和上下文作为原 runtime 输入。 源码

  • build_replan_action_packet。使用原 obligation 与要求发出后续工作或结算入口。 源码

  • replan-writeback-requires-fresh-bound-semantic-evidence(implemented)。确认历史作用域与真实性,重复 Turn 或旧 blocker 无法冒充新 progress。验收后可按原身份重放。

对主干的风险 / Risks

历史出现过的 blocker 在新 work item 仍不能作为新证据结算。用真实 TypeScript 审查,新的 blocker 可形成原接受结果。 以完整历史判断证据新颖性很重要,因为可见窗口可能已经省略先前的 blocker。否则同一障碍可能在后续 Turn 被重复计为新进展,进而产生新的回执与额度消耗。 维持基于原 Turn identity 和历史完整度的 TS owner 检查。

当前 exact head 复核 / Rebased-head validation

PR #9483 已无冲突 rebase 到 origin/main 2302e42d9cad35a8a4150e24496ffecfbfdce8cb,当前精确头为 83410fc9050d5545a1950883b225d21818ce929e。本轮在新 base 上重新执行定向测试、静态检查和 diff 级 premerge。

最终 exact head 复核:4 项 progress-observation 合约测试通过;核心文件严格 mypy、Ruff、diff 检查和标准 premerge 的 13 项选定检查全部通过。触发计数、历史 generator、successor writeback 与 loopx-jev import pin 均保持。

我的整体评价 / Verdict

APPROVE。 生产 wire 输入通过配对验证。真实 TypeScript owner 在两个存储上维持证据资格、绑定 Turn 身份和按一次成功扣额的规则。模型限于隔离适配器。 保留已有证据、可归因进展与原恢复边界。

English verdict: APPROVE at 83410fc. Paired native replan tests preserved same-Turn deduplication, fresh-evidence qualification, and File/SQLite writeback and replay.

@loopx-agent
loopx-agent merged commit 4f975ad into main Nov 27, 2026
7 of 8 checks passed
@loopx-agent
loopx-agent deleted the codex/slim-progress-observation-zero-any-20261126 branch November 27, 2026 16:33
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