Repository navigation
fix(canary,issue-fix): restore drain smoke selection and add unit coverage - #9075
loopx-agent wants to merge 1 commit into
Conversation
…erage 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 family · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
当维护者或自动化门禁在改动 issue-fix 通知队列排空或接收端逻辑后运行 premerge 门禁与目录烟雾测试套件时,会直接触发该路径。
改动前,PR #9073 把通知队列回写烟雾测试排在 issue-fix-reviewer-routing 的第 5 位且产品入口大剖面先命中,导致 premerge 在每位上限 4 和烟雾套件上限 3 时把它静默丢弃,同时单元测试目录里没有任何针对排空函数与状态刷新助手的测试,回归只能靠手工全量跑或上线后才暴露;改动后,拆出的专用剖面把每组检查压到 3 项以内并排在大剖面之前,同时在单元测试目录直接验证 4 类核心排空与状态刷新合同。
实测改变通知队列排空实现文件时,premerge quick 与 standard 均稳定选中通知回写烟雾测试,烟雾测试套件三个子剖面全部全量通过且无截断,4 组排空单元测试和 21 项聚焦 pytest 全部通过。
本次仅调整 canary 剖面拆分与补充单元测试,不修改通知队列生产排空算法、持久化格式或无关剖面。
如果不修复这个缺口,后续任何针对通知重试抑制、语义历史去重或终端状态清理的回归都会继续绕过默认门禁并缺乏快速单测防线;把剖面控制在 3 项以内并补齐单元测试是一次完整、独立且可逆的闭环切片。
改动思路 / Approach
本次改动复用既有的 CURRENT_REPO_PROFILES、build_catalog_canary_plan、build_premerge_validation_gate 与 build_canary_smoke_suite_run 调度主链,以及 drain_issue_fix_reviewer_notification_queue 和 _row_with_live_lifecycle_facts 生产所有者,未新增任何抽象层、配置开关或运行期状态。
把通知排空、通知接收、reviewer 路由与 CLI JSON 边界校验拆分为互不干扰的窄剖面,保留原有 planner、premerge 与 smoke-suite 作为唯一调度和边界真源,不引入新的状态字段、配置开关或兼容分支;单元测试直接调用生产模块,不依赖 examples 包装层。当前 PR 边界严格限定在 canary 剖面定义、目录规划校验脚本与新增单元测试文件内,生产能力模块与领域状态写回路径零改动。
在剖面编排上,将原 issue-fix-reviewer-routing 里的 6 条烟雾检查按职责拆为三个各自不超过 3 项的聚焦剖面,并放在宽泛的 product-entry-workflows 之前:当只改动通知排空或通知接收模块时,精准命中 issue-fix-reviewer-notification-drain,从而不会因为宽剖面先占满 quick(上限 3)或 standard(上限 10)配额而漏掉通知回写回归。单元测试则直接构造临时目录中的合成 JSONL 账本和内存回调,独立验证核心状态转换而不耦合 examples/ 包装脚本。
具体改动 / Changes
对照规范 docs/development/good-smokes.md(固定基线 27eaeb127777378d1e95d98e478ccfa779d08873)以及 #9073 审阅 #5975681788 的修复准则:
| 规范条目 | 本 head 判断与核验证据 |
|---|---|
GS-UNIT-RULES |
implemented:纯规则与状态机分支放入 tests/capabilities/test_issue_fix_reviewer_notification_drain.py,直接覆盖 drain_issue_fix_reviewer_notification_queue 与 _row_with_live_lifecycle_facts,21 项聚焦 pytest 全通过。 |
GS-TARGETED-PROFILE |
implemented:loopx/canary/planner.py 拆分为三个 ≤3 项的聚焦剖面并在 tests/canary/test_issue_fix_drain_canary_selection.py 与 examples/canary/catalog-planner-smoke.py 验证在 max_checks_per_profile=3/4 和 limit=3 下稳定命中,且 smoke-health 保持零所有权流失。 |
GS-PUBLIC-SAFE |
implemented:所有新增测试使用 tmp_path 与合成标识(如 oc_fixture_chat、ou_fixture_reviewer),经 loopx check 扫描 4 个改动文件 0 告警、0 命中。 |
关键代码讲解
CURRENT_REPO_PROFILES剖面拆分:在product-entry-workflows之前定义了issue-fix-reviewer-notification-drain(2 项)、issue-fix-reviewer-routing(3 项)和issue-fix-json-input-boundary(1 项),确保每个剖面在tests/test_smoke_suite.py(默认每剖面 3 项)和premerge(每剖面 4 项、总上限quick=3/standard=10)下都不会被截断,同时通过独立trigger_hints避免误命中无关的workflow_plan.py改动。test_drain_restart_safe_queued_to_sent_durable_writeback与test_drain_suppresses_sent_unverified_without_requeue_or_duplicate_resend:直接调用drain_issue_fix_reviewer_notification_queue与read_issue_fix_pr_lifecycle_ledger_row,验证窗口外保持排队、窗口内queued -> sent落盘与重启后零重发;同时验证sent_unverified即使未生成已核验 receipt 也会把待发项清出队列避免重复打扰,并与写前失败保留队列形成正反对比。test_drain_semantic_history_matcher_deduplicates_delivered_notifications与test_row_with_live_lifecycle_facts_preserves_open_correction_and_refreshes_terminal:通过真实lark_reviewer_notification_sink与必失败runner证明语义历史命中时零外部调用、多 sink 精确隔离与范围歧义 fail-closed;并对_row_with_live_lifecycle_facts参数化测试OPEN(保留maintainer_correction投影)与MERGED/CLOSED(同时通过_lifecycle_packet与紧凑元数据回退路径刷新为terminal/remove)。test_reviewer_notification_drain_change_selects_postwrite_smoke_under_premerge_and_smoke_suite:将基线27eaeb1277与当前 head 的反事实选测固化到tests/canary/,同时校验workflow_plan.py不会误触发三个新剖面。
对主干的风险 / Risks
对基线与当前 head 进行反事实对比后未发现阻塞问题。主干变更集中在 loopx/canary/planner.py 的声明式剖面列表:由于将三个聚焦剖面移至 product-entry-workflows 之前,修改这些窄范围文件时 premerge --tier quick 会优先执行对应专项烟雾而非通用工作流烟雾;但负例验证显示修改 loopx/capabilities/issue_fix/workflow_plan.py 时选测集合与基线完全一致(仅 repo-architecture-budget 与 product-entry-workflows),且 loopx canary smoke-health 确认 358 个烟雾中仍有 126 个受 catalog_canary 覆盖、248 个具备定向归属、0 嵌套执行。
对于局部 tests/canary/ 中存在的 1 条失败(test_maintainability_ratchet.py::test_current_repository_debt_is_reviewed_without_line_count_pins),已通过在同一命令对比基线 27eaeb1277 与当前 head 证实为同一条未修改文件 loopx/control_plane/work_items/interaction_contract.py 上的既有 oversized_decision_function 超限(statements=96, decision_points=58),与本次 PR 改动路径完全无关;premerge 门禁已将其自动降级为 advisory_inherited_failure。
本 PR 未引入默认关闭的运行期开关(default_off_isolation 不适用),未新增公开协议/权限边界(authority_semantics 不适用),未修改任何共享词表(semantic_alignment 不适用),但直接测试内部辅助函数 _row_with_live_lifecycle_facts 意味着未来若重命名该私有符号需同步更新该单测。
我的整体评价 / Verdict
基于 exact head 288894864a66e8c653855302b6659e3f2fa618fb 的独立验证已全部在本地完成,不等待或依赖远程 CI。长程影响 long_horizon 为 improved,因为恢复了默认门禁对通知队列重启写回与防重发不变量的自动拦截,并补齐了快速单元测试;交互体验 user_experience 为 not_applicable(本次改动仅涉及 canary 剖面配置、planner 烟雾脚本与 pytest 单元测试,不触及渲染 UI 或用户交互入口,未核验范围 none)。可观测语义在通知排空相关改动下为 intentional_change_validated,在无关文件 workflow_plan.py 上保持完全等价。代码量 code_volume 为 necessary,整体改动比例 change_proportionality 为 proportionate(架构评估 retain)。
本地验证明细(全部基于 exact head 288894864a66e8c653855302b6659e3f2fa618fb):
pytest -q tests/capabilities/test_issue_fix_reviewer_notification_drain.py tests/canary/test_quality_surface_catalog.py tests/canary/test_smoke_fleet_health.py tests/canary/test_issue_fix_drain_canary_selection.py->PASS(21 passed)pytest -v tests/test_smoke_suite.py三个剖面(issue-fix-reviewer-routing4 passed、issue-fix-reviewer-notification-drain3 passed、issue-fix-json-input-boundary2 passed) ->PASS- 专项烟雾(
catalog-planner-smoke.py、issue-fix-reviewer-notification-drain-postwrite-smoke.py、issue-fix-reviewer-notification-sink-smoke.py)与loopx canary smoke-health->PASS - 静态与边界检查(
ruff check、mypy --follow-imports=silent4 文件、git diff --check、scripts/check_rfc_bilingual.py、loopx check --scan-path) ->PASS loopx canary premerge --tier quick(4/4 selected, 0 failures)与--tier standard(16/16 selected, 0 failures,含 1 条对未改动文件的 inherited advisory) ->PASS- 诊断性全量
tests/canary/:144 passed, 6 skipped, 1 pre-existing unrelated failure(与基线相同的interaction_contract.pyratchet)
剩余风险仅为测试直接依赖私有 helper _row_with_live_lifecycle_facts 名称这一低耦合点;无阻塞缺陷,建议准予合入。
English Verdict: APPROVE — Exact head 2888948 splits issue-fix reviewer notification drain/sink and JSON input checks into <=3-check profiles ahead of product-entry-workflows (restoring default premerge and smoke-suite coverage without over-matching unrelated files) and adds direct unit coverage for drain_issue_fix_reviewer_notification_queue and _row_with_live_lifecycle_facts, with all targeted pytest, smoke, lint/type, and premerge quick/standard checks passing locally.
Follow-up to the
#9073post-merge audit P1 finding (review#5975681788).Problem
loopx/canary/planner.py, PR#9073placedexamples/issue-fix-reviewer-notification-drain-postwrite-smoke.pyatchecks[4]and pushedexamples/issue-fix-reviewer-notification-sink-smoke.pytochecks[5]insideissue-fix-reviewer-routing. Becauseloopx/canary/premerge.pycaps selection atmax_checks_per_profile=4(limit=3inquick,limit=10instandard) andtests/test_smoke_suite.py/build_catalog_canary_plandefault tomax_checks_per_profile=3, both notification drain/sink smokes were silently dropped under default selection, andproduct-entry-workflowsmatched broadissue_fixpaths first.tests/had zero unit tests directly coveringdrain_issue_fix_reviewer_notification_queueand_row_with_live_lifecycle_facts.Changes
loopx/canary/planner.py,examples/canary/catalog-planner-smoke.py,tests/canary/test_issue_fix_drain_canary_selection.py):<= 3-check profiles placed ahead of the broadproduct-entry-workflowsprofile:issue-fix-reviewer-notification-drain(2 checks):issue-fix-reviewer-notification-drain-postwrite-smoke.py,issue-fix-reviewer-notification-sink-smoke.pyissue-fix-reviewer-routing(3 checks):issue-fix-capability-guide-smoke.py,issue-fix-reviewer-recommendation-smoke.py,issue-fix-reviewer-request-smoke.pyissue-fix-json-input-boundary(1 check):issue-fix-json-input-boundary-smoke.pycatalog_canaryownership inloopx canary smoke-healthwhile ensuring changingreviewer_notification_drain.py,reviewer_notification.py, or the drain/sink smokes selectsissue-fix-reviewer-notification-drain-postwrite-smoke.pyunder bothcanary premerge(quickandstandard,max_checks_per_profile=4) andtests/test_smoke_suite.py(max_checks_per_profile=3/limit=3).tests/capabilities/test_issue_fix_reviewer_notification_drain.py):drain_issue_fix_reviewer_notification_queueand_row_with_live_lifecycle_factswithout importingexamples/:queued -> sentdurable JSONL ledger writeback (including delivery-window hold and post-restart no-resend idempotency);sent_unverifiedsuppression removing unverified items from the queue without fabricating verified receipts or duplicating reminder sends (contrasted with pre-write failure retention);semantic_history_matcherdeduplicating already-delivered notifications throughlark_reviewer_notification_sink(plus multi-sink scoping and fail-closedscope_ambiguoushandling);_row_with_live_lifecycle_factspreservingmaintainer_correctionprojection fields onOPENPRs while refreshing terminalMERGEDandCLOSEDstates cleanly (both_lifecycle_packetand compact-metadata fallback paths, plus end-to-end drain cancellation).Verification (Head
288894864a66e8c653855302b6659e3f2fa618fb)pytest -q tests/capabilities/test_issue_fix_reviewer_notification_drain.py tests/canary/test_quality_surface_catalog.py tests/canary/test_smoke_fleet_health.py tests/canary/test_issue_fix_drain_canary_selection.py:21 passedpytest -v tests/test_smoke_suite.py --loopx-smoke-suite catalog-plan --loopx-smoke-profile issue-fix-reviewer-routing:4 passedpytest -v tests/test_smoke_suite.py --loopx-smoke-suite catalog-plan --loopx-smoke-profile issue-fix-reviewer-notification-drain:3 passedpytest -v tests/test_smoke_suite.py --loopx-smoke-suite catalog-plan --loopx-smoke-profile issue-fix-json-input-boundary:2 passedpython3 examples/canary/catalog-planner-smoke.py:okpython3 examples/issue-fix-reviewer-notification-drain-postwrite-smoke.py:okpython3 examples/issue-fix-reviewer-notification-sink-smoke.py:okloopx canary smoke-health:ok=true(358inventory,126catalog_canary,248targeted owners,0identical groups,0nested execution)ruff check,mypy --follow-imports=silent(4 touched files),git diff --check,scripts/check_rfc_bilingual.py --base origin/main --staged,loopx check --scan-path ...: all cleanloopx canary premerge --tier quick --from-git-diff --git-diff-base origin/main:passed(4/4selected,0failures,1inherited advisory maintainability finding on unmodifiedinteraction_contract.py)loopx canary premerge --tier standard --from-git-diff --git-diff-base origin/main:passed(16/16selected,0failures,1inherited advisory maintainability finding on unmodifiedinteraction_contract.py)