Skip to content

factory: 上游同步追平(d2db89b79) - #33

Merged
im47cn merged 4 commits into
mainfrom
factory/sync-d2db89b79
Sep 3, 2026
Merged

im47cn merged 4 commits into
mainfrom
factory/sync-d2db89b79

Conversation

@im47cn-bot

@im47cn-bot im47cn-bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

上游同步追平

  • 锚点: awesome-rules@d2db89b79(im47cn/awesome-rules main tip;上次锚点 2be9f99,落后 23 commits)
  • 上游增量: PR #116(repo 传参/幂等/space_id/原子释放/base 显式化评审波)、#118(sync 门禁 rc 语义化 + cmp 整文件精确比对 + blame-ignore 脏守卫)、#119(coderabbit wave-17:guard rev-parse fail-closed / label_history 滤空 / mktemp 原子暂存 / ADR-009 可移植性)、#120(config-evals-gate + downstream-check 两段式 trap)、#121(write_stamp 取最新留档 / --only 未知 id 拒跑 / target 越仓拦截,wop-web-tools 反哺)、#122(label_history changes-requested 评论补杀)
  • 模式: 中心版 sync-from-upstream.sh --apply --commit --anchor main,full 面 15 文件覆盖(新增 tests/test_upstream_sync_check.py、tests/test_fix_issue_pr_body.py),upstream-lock.json 锚点 2be9f99 → d2db89b79
  • Sourcery 回归闸: 同步脚本内 .factory 面追平前基线 + 追平后复扫均干净;PR diff 面首跑红——追平采用的上游 mutations/run.py 触发 low-code-quality(run.py:331-436),对齐上游 2026-09-01 评审保留项后复绿(52138d6,10 个变更 .py 文件零 issue)

追平配套本地适配(skip 面 + 周界外闸配置)

  1. factory-local.json 增 port_point: "011d8d8c"——上游 feedback.py 新契约(fail-closed 缺键即崩;反哺扫描下界 = 本仓移植首提 011d8d8)
  2. .factory/mutations/run.py 采用上游版——被测对象与 full 面测试对齐:write_stamp 取最新 EVIDENCE 留档、--only 未知 id 拒跑、target 越仓拦截、docstring 可选门(本仓未配置 → docstring 缺陷 SKIP)
  3. defects.json B-105 锚点随源演进——digest.py:30 已 f-string 化(PR audit: §2.2 错误分类闭集 + D14/D15 SM2 userId 方向拆分(源 227cf03) #28 整改 use-fstring-for-concatenation),% 格式锚点失配(FAIL-config fail-closed 暴露)
  4. kill rate 重证: 11/11 = 100%、负例 2/2(两次连续全量一致);evidence-stamp.json 周界指纹重绑 ec23e01d;双套件 364 passed
  5. .sourcery.yaml 增 low-code-quality 保留项——上游 2026-09-01 评审同款 disable(同文件同规则:mutations/run.py 长 main 顺序流程聚合标签,无可操作子建议,拆分收益边际);本仓触发系追平采用上游 runner 后的规则配置滞后,对齐处置而非重演评审(重构该文件会重新制造同步漂移)

上游反馈候选

tests/test_mutations_run.py 属 full(零本地化),但其被测对象 mutations/run.py 位于 skip 目录 mutations/——每轮下游追平都会重现本轮的 20 红(测试先行、runner 滞后)。建议上游将 mutations/run.py 提升为 full 或将该测试降为 local(正道经 feedback-upstream 反哺)。

人工合并后下游即与上游 d2db89b79 对齐。

Sourcery 摘要

使工厂自动化和验证工具链与上游 awesome-rules 保持一致,同时加强同步、托管、变异测试和安全契约。

新功能:

  • 通过锚点 d2db89b79,使工厂工具和契约与上游 awesome-rules 同步。
  • 添加可选的文档字符串变异门支持,并加强变异运行器验证。

错误修复:

  • 防止将致命的上游同步错误报告为检查通过。
  • 确保在提前退出的情况下也能可靠清理临时文件,并在竞争期间保留锁所有权。
  • 防止不安全的锁释放竞争、变异目标中的路径遍历、无效缺陷筛选条件和格式错误的标签标记。
  • 保留 PR 关闭元数据,并要求明确指定 Codeup 目标分支。

增强功能:

  • 改进托管平台检测、命名空间映射、标签操作幂等性、证据标记和故障关闭式防护行为。
  • 使用原子操作写入上游同步内容,并防止 blame-ignore 文件意外包含本地更改。

测试:

  • 扩展对同步退出代码、临时文件清理、锁竞争、托管契约、防护失败、PR 正文要求和变异运行器验证的回归测试覆盖范围。

杂项:

  • 更新本地工厂配置、变异缺陷锚点、证据标记和 blame-ignore 元数据,使其与同步后的上游状态保持一致。
Original summary in English

Summary by Sourcery

Bring the factory automation and validation toolchain into alignment with upstream awesome-rules while hardening synchronization, hosting, mutation testing, and safety contracts.

New Features:

  • Synchronize the factory tooling and contracts with upstream awesome-rules through anchor d2db89b79.
  • Add optional docstring mutation-gate support and stricter mutation-runner validation.

Bug Fixes:

  • Prevent fatal upstream-sync errors from being reported as clean checks.
  • Make temporary-file cleanup reliable across early exits and preserve lock ownership during contention.
  • Prevent unsafe lock release races, path traversal in mutation targets, invalid defect filters, and malformed label markers.
  • Preserve PR closure metadata and require explicit Codeup target branches.

Enhancements:

  • Improve hosting platform detection, namespace mapping, label-operation idempotency, evidence stamping, and fail-closed guard behavior.
  • Use atomic upstream synchronization writes and protect blame-ignore files from accidental inclusion of local changes.

Tests:

  • Expand regression coverage for synchronization exit codes, temporary-file cleanup, lock contention, hosting contracts, guard failures, PR body requirements, and mutation-runner validation.

Chores:

  • Update local factory configuration, mutation defect anchors, evidence stamps, and blame-ignore metadata to match the synchronized upstream state.

@im47cn-bot
im47cn-bot requested a review from im47cn as a code owner September 3, 2026 06:37
@changeset-bot

changeset-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 52138d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @im47cn-bot, this account has used its review budget of 5,000,000 diff characters for the last 7 days.

You can request another review in 3 days and 12 hours by commenting @sourcery-ai review.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 3862f5c7-7519-4609-82ec-59cad0100e6e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

审查者指南

本 PR 以 sync-from-upstream.sh 为中心将 factory full 面追平至 awesome-rules d2db89b79,同时把上游评审波中的 fail-closed、幂等、原子暂存/释放、平台参数和退出码契约落入本地脚本与 Python 工具,并通过新增回归测试及 364 项测试、11/11 mutation kill rate 验证同步结果。

fail-closed 上游同步时序图

sequenceDiagram
    participant Check as upstream-sync-check.sh
    participant Sync as sync-from-upstream.sh
    participant Git as Git 上游
    participant Gate as 验证门

    Check->>Sync: --check
    Sync->>Git: 解析锚点并比较文件
    Git-->>Sync: 比较结果
    Sync-->>Check: rc=0 clean / rc=1 drift / rc>=2 fatal
    alt rc=0
        Check-->>Check: 报告 full 面 clean
    else rc=1
        Check->>Gate: 将 drift 转交下游处理
    else rc>=2
        Check-->>Check: 传播致命退出码
    end
Loading

原子变更验证时序图

sequenceDiagram
    participant Runner as mutations/run.py
    participant Config as factory-local.json
    participant Target as 仓库目标
    participant Gate as Guard 或测试门
    participant Stamp as evidence-stamp.json

    Runner->>Config: 加载 final_gate_cmd 和可选的 docstring_gate_cmd
    Runner->>Target: 验证仓库内目标
    Runner->>Target: apply_defect
    Runner->>Gate: run_gate
    Gate-->>Runner: 退出码
    Runner->>Target: 恢复原始内容
    alt 所有必需缺陷均通过
        Runner->>Stamp: write_stamp
    else 未知的 --only 或无效目标/配置
        Runner-->>Runner: fail-closed
    end
Loading

下游同步检查结果状态图

stateDiagram-v2
    [*] --> Checking
    Checking --> Clean: rc=0
    Checking --> Drift: rc=1
    Checking --> Fatal: rc>=2
    Clean --> [*]: exit 0
    Drift --> HumanReview: 本地 drift
    Drift --> ApplySync: full drift
    HumanReview --> [*]
    ApplySync --> [*]
    Fatal --> [*]: 传播 rc
Loading

文件级变更

变更 详情 文件
同步上游 factory 工具链并更新锚点与分发边界
  • 将 full 面文件追平至 awesome-rules d2db89b79,并更新 upstream-lock.json
  • 新增上游同步退出码、PR 正文和相关回归测试
  • 增加 .git-blame-ignore-revs,保护同步提交不吞并本地改动
.factory/sync-from-upstream.sh
.factory/upstream-lock.json
.factory/upstream-sync-check.sh
.factory/tests/test_upstream_sync_check.py
.factory/tests/test_sync_from_upstream.py
.factory/tests/test_fix_issue_pr_body.py
.git-blame-ignore-revs
强化 shell 同步与巡检流程的原子性、清理和参数契约
  • 使用 mktemp、分阶段 EXIT trap 和原子 mv 避免暂存文件泄漏及自覆盖损坏
  • 在持锁成功后才清理锁文件,避免竞争退出删除他实例锁
  • 使用 NUL 分隔路径传递,显式传递 PR base 和 body
  • 让 upstream-sync-check 原样传播 rc≥2 的致命错误
.factory/downstream-check.sh
.factory/sync-from-upstream.sh
.factory/fix-issue.sh
.factory/tests/test_downstream_check.py
收紧 guard、hosting 和 Codeup 平台适配的 fail-closed 与幂等语义
  • git rev-parse 失败时禁用主工作树回退,防止路径误判放行
  • 支持按目标仓库检测 hosting 平台,并修正 Codeup namespace、space_id 和显式 base 传递
  • 使标签添加/移除幂等,过滤空标记及 changes-requested 评论
.factory/guard.py
.factory/hosting.py
.factory/tests/test_guard_fresh_clone.py
.factory/tests/test_hosting.py
扩展 mutations runner 的门配置、输入校验和证据留档逻辑
  • 新增可选 docstring gate,并统一命令 fail-closed 校验及退出码判定
  • 拒绝未知 --only id、越出仓库根的 target 和无效 gate 配置
  • write_stamp 缺省选择最新 EVIDENCE 留档,并保持注入文件最终恢复
.factory/mutations/run.py
.factory/mutations/defects.json
.factory/mutations/evidence-stamp.json
.factory/mutations/EVIDENCE-2026-08-24.md
.factory/factory-local.json
.factory/tests/test_mutations_run.py
补充同步追平后的本地适配与验证证据
  • 配置 feedback.py 所需 port_point 并同步 B-105 缺陷锚点
  • 记录 11/11 kill rate、负例通过及 364 项测试通过结果
  • 保留 mutations runner 与 full 测试契约对 skip 目录的下游适配风险
.factory/factory-local.json
.factory/mutations/defects.json
.factory/mutations/evidence-stamp.json
.factory/mutations/EVIDENCE-2026-08-24.md
.factory/mutations/run.py

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以回复审查评论并使用 @sourcery-ai issue,从中创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中任意位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,随时(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审查!

自定义使用体验

访问你的控制面板以:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 以 sync-from-upstream.sh 为中心将 factory full 面追平至 awesome-rules d2db89b79,同时把上游评审波中的 fail-closed、幂等、原子暂存/释放、平台参数和退出码契约落入本地脚本与 Python 工具,并通过新增回归测试及 364 项测试、11/11 mutation kill rate 验证同步结果。

Sequence diagram for fail-closed upstream synchronization

sequenceDiagram
    participant Check as upstream-sync-check.sh
    participant Sync as sync-from-upstream.sh
    participant Git as Git upstream
    participant Gate as Validation gates

    Check->>Sync: --check
    Sync->>Git: Resolve anchor and compare files
    Git-->>Sync: Comparison result
    Sync-->>Check: rc=0 clean / rc=1 drift / rc>=2 fatal
    alt rc=0
        Check-->>Check: Report full面 clean
    else rc=1
        Check->>Gate: Route drift for downstream handling
    else rc>=2
        Check-->>Check: Propagate fatal exit code
    end
Loading

Sequence diagram for atomic mutation verification

sequenceDiagram
    participant Runner as mutations/run.py
    participant Config as factory-local.json
    participant Target as Repository target
    participant Gate as Guard or test gate
    participant Stamp as evidence-stamp.json

    Runner->>Config: Load final_gate_cmd and optional docstring_gate_cmd
    Runner->>Target: Validate in-repository target
    Runner->>Target: apply_defect
    Runner->>Gate: run_gate
    Gate-->>Runner: Exit code
    Runner->>Target: Restore original content
    alt All required defects pass
        Runner->>Stamp: write_stamp
    else Unknown --only or invalid target/config
        Runner-->>Runner: Fail closed
    end
Loading

State diagram for downstream synchronization check outcomes

stateDiagram-v2
    [*] --> Checking
    Checking --> Clean: rc=0
    Checking --> Drift: rc=1
    Checking --> Fatal: rc>=2
    Clean --> [*]: exit 0
    Drift --> HumanReview: local drift
    Drift --> ApplySync: full drift
    HumanReview --> [*]
    ApplySync --> [*]
    Fatal --> [*]: propagate rc
Loading

File-Level Changes

Change Details Files
同步上游 factory 工具链并更新锚点与分发边界
  • 将 full 面文件追平至 awesome-rules d2db89b79,并更新 upstream-lock.json
  • 新增上游同步退出码、PR 正文和相关回归测试
  • 增加 .git-blame-ignore-revs,保护同步提交不吞并本地改动
.factory/sync-from-upstream.sh
.factory/upstream-lock.json
.factory/upstream-sync-check.sh
.factory/tests/test_upstream_sync_check.py
.factory/tests/test_sync_from_upstream.py
.factory/tests/test_fix_issue_pr_body.py
.git-blame-ignore-revs
强化 shell 同步与巡检流程的原子性、清理和参数契约
  • 使用 mktemp、分阶段 EXIT trap 和原子 mv 避免暂存文件泄漏及自覆盖损坏
  • 在持锁成功后才清理锁文件,避免竞争退出删除他实例锁
  • 使用 NUL 分隔路径传递,显式传递 PR base 和 body
  • 让 upstream-sync-check 原样传播 rc≥2 的致命错误
.factory/downstream-check.sh
.factory/sync-from-upstream.sh
.factory/fix-issue.sh
.factory/tests/test_downstream_check.py
收紧 guard、hosting 和 Codeup 平台适配的 fail-closed 与幂等语义
  • git rev-parse 失败时禁用主工作树回退,防止路径误判放行
  • 支持按目标仓库检测 hosting 平台,并修正 Codeup namespace、space_id 和显式 base 传递
  • 使标签添加/移除幂等,过滤空标记及 changes-requested 评论
.factory/guard.py
.factory/hosting.py
.factory/tests/test_guard_fresh_clone.py
.factory/tests/test_hosting.py
扩展 mutations runner 的门配置、输入校验和证据留档逻辑
  • 新增可选 docstring gate,并统一命令 fail-closed 校验及退出码判定
  • 拒绝未知 --only id、越出仓库根的 target 和无效 gate 配置
  • write_stamp 缺省选择最新 EVIDENCE 留档,并保持注入文件最终恢复
.factory/mutations/run.py
.factory/mutations/defects.json
.factory/mutations/evidence-stamp.json
.factory/mutations/EVIDENCE-2026-08-24.md
.factory/factory-local.json
.factory/tests/test_mutations_run.py
补充同步追平后的本地适配与验证证据
  • 配置 feedback.py 所需 port_point 并同步 B-105 缺陷锚点
  • 记录 11/11 kill rate、负例通过及 364 项测试通过结果
  • 保留 mutations runner 与 full 测试契约对 skip 目录的下游适配风险
.factory/factory-local.json
.factory/mutations/defects.json
.factory/mutations/evidence-stamp.json
.factory/mutations/EVIDENCE-2026-08-24.md
.factory/mutations/run.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@im47cn
im47cn merged commit 2248b96 into main Sep 3, 2026
23 checks passed
@im47cn
im47cn deleted the factory/sync-d2db89b79 branch September 3, 2026 09:16
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.

2 participants