Skip to content

factory: 上游同步追平(e8666f866) - #25

Closed
im47cn-bot wants to merge 1 commit into
mainfrom
factory/sync-e8666f866
Closed

im47cn-bot wants to merge 1 commit into
mainfrom
factory/sync-e8666f866

Conversation

@im47cn-bot

@im47cn-bot im47cn-bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

概要

真源 awesome-rules main @ e8666f866 同步:full 面 12 文件覆盖 + skip 面 run.py 手工追平 + port_point 入库。

内容

  • full 面 12 文件覆盖:本地中间态快照由真源规范版取代
  • mutations/run.py(skip 面)手工合并至 main canonical:本地版为 ADR-009 前旧快照(207 行 diff,76 行本地独有内容经审全为旧实现、无仓特有增量),补回 _docstring_gate_words/DOCSTRING_GATE。本仓 factory-local.json 未配置 docstring_gate_cmd → docstring 缺陷走 SKIP 路径,不实跑未配置的门
  • port_point=011d8d8 入库(本仓 .factory 首提锚,对齐 feedback.py 数据化指针)
  • 未触碰 chore/docstring-gate 分支(6 提交未合并,另行处理)

验证

  • python3 -m pytest .factory/tests -q:rc=0 全绿(275 测试;修复前 3 失败——2× _docstring_gate_words AttributeError + judge rc=2 语义,均为 main 新测试 × 本地旧 run.py 的符号缺口,run.py 追平后消除)

后续

Sourcery 追平闸与 hosting 降级护栏待反哺 PR im47cn/awesome-rules#88 人工合入后,下一轮追平带回。

Sourcery 摘要

将 .factory 工具链与上游规范版本同步,同时新增仓库感知的验证、托管状态兼容性和运维诊断功能。

新功能:

  • 在问题修复和 PR 验证工作流中,新增可选的、默认拒绝的文档字符串验证门禁。
  • 通过评论标记支持 Codeup 标签和评审状态同步,包括标签历史记录和“请求修改”信号。

问题修复:

  • 改进对配置为裸仓库或其他不可用状态的 Git 仓库的诊断。
  • 修正解析上游仓库时 ~/ 路径的展开。
  • 使调度停滞状态持久化环境快照,并发送 macOS 通知。

增强功能:

  • 使反馈上游端口可按仓库配置,并在缺失时默认拒绝。
  • 整合 factory 变更执行,并扩展其功能以处理文档字符串缺陷及其覆盖率报告。
  • 恢复并统一 factory 工具链在同步、托管和验证组件中的上游规范行为。

测试:

  • 扩展 factory 测试,覆盖文档字符串门禁配置与判断、基于 Codeup 标记的标签和评审状态、反馈文件跟踪以及 CLI 行为。

杂项:

  • 在 factory 本地配置中记录仓库的上游同步点。
Original summary in English

Summary by Sourcery

Synchronize the .factory toolchain with the upstream canonical version while adding repository-aware validation, hosting-state compatibility, and operational diagnostics.

New Features:

  • Add an optional, fail-closed docstring validation gate across issue fixing and PR validation workflows.
  • Support Codeup label and review state synchronization through comment markers, including label history and changes-requested signals.

Bug Fixes:

  • Improve diagnostics for Git repositories configured as bare or otherwise unavailable.
  • Correct expansion of ~/ paths when resolving upstream repositories.
  • Make dispatch stalls persist environment snapshots and emit macOS notifications.

Enhancements:

  • Make the feedback upstream port point repository-configurable and fail closed when missing.
  • Consolidate factory mutation execution and extend it to handle docstring defects and their coverage reporting.
  • Restore and align the factory toolchain with the upstream canonical behavior across its synchronization, hosting, and validation components.

Tests:

  • Extend factory tests for docstring gate configuration and judgment, Codeup marker-based labels and review states, feedback file tracking, and CLI behavior.

Chores:

  • Record the repository's upstream synchronization point in factory-local configuration.

advisory 合规:分支名 factory/sync-e8666f866(M2 约定 anchor[:9] 9 位短 SHA);同锚点重跑 push 同分支自动更新本 PR(幂等)。

- full 面 12 文件覆盖(cron-dispatch/factory-state/feedback.py/guard.py/
  factory_lib.py/hosting.py/fix-issue/validate-pr/feedback-upstream/全套测试)
- mutations/run.py(skip 面)手工合并至 main canonical:补 docstring 门
  (_docstring_gate_words/DOCSTRING_GATE,本仓未配置 docstring_gate_cmd,
  缺陷走 SKIP)——本地版为 ADR-009 前旧快照,76 行独有内容均为旧实现
  无仓特有增量;全量测试 rc=0 全绿
- factory-local.json 注入 port_point=011d8d8(本仓 .factory 首提锚)
@im47cn-bot im47cn-bot added the factory:needs-review PR已开待人工审查 label Aug 31, 2026
@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 11fc072

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

@coderabbitai

coderabbitai Bot commented Aug 31, 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: Pro Plus

Run ID: 26412920-673a-441d-8681-81337103e956


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 Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

审查者指南

本 PR 将 .factory 工具链追平至上游 e8666f866,并以本仓配置承载 port_point;重点新增可选、默认跳过但配置损坏即失败的 docstring 门,补齐 Codeup 评论标记兼容、Git/调度诊断及路径修复,同时扩展测试覆盖,验证结果为 275 项全绿。

可选 docstring 验证门的时序图

sequenceDiagram
    participant Workflow as fix-issue_or_validate-pr
    participant FactoryLib as factory_lib.py
    participant DocGate as docstring_gate_cmd
    participant Output as docstring-output.txt

    Workflow->>FactoryLib: docstring-gate
    FactoryLib-->>Workflow: command_or_empty
    alt command configured
        Workflow->>DocGate: execute configured command
        DocGate-->>Output: validation result
        alt gate fails
            Workflow-->>Workflow: stop workflow
        end
    else command not configured
        Workflow-->>Workflow: skip docstring gate
    end
Loading

Codeup 评论标记标签同步的时序图

sequenceDiagram
    participant Factory as hosting.py
    participant Codeup as Codeup
    participant Comments as Comment markers

    Factory->>Codeup: POST changeRequests/{p}/comments/list
    Codeup-->>Factory: open_and_resolved_comments
    Factory->>Factory: _marker_label
    alt add label
        Factory->>Codeup: POST changeRequests/{p}/comments
        Codeup-->>Comments: store unresolved label marker
        Factory->>Codeup: POST changeRequests/{p}/labels
    else remove label
        Factory->>Codeup: PUT changeRequests/{p}/comments/{id}
        Codeup-->>Comments: mark marker resolved
    end
    Factory-->>Factory: label_history
Loading

文件级变更

变更 详情 文件
将上游 canonical .factory 工具链同步到本仓,并补入本仓特有的同步锚点。
  • 覆盖同步 12 个 full 面工具链文件及测试
  • 将 port_point 数据化写入本地配置并由 feedback.py fail-closed 读取
  • 保留并清理本地特化逻辑,未合并 chore/docstring-gate 分支
.factory/factory-local.json
.factory/feedback.py
.factory/factory-state.sh
.factory/factory_lib.py
.factory/cron-dispatch.sh
.factory/fix-issue.sh
.factory/validate-pr.sh
.factory/hosting.py
.factory/mutations/run.py
新增可选且 fail-closed 的 docstring 验证门,贯通修复、PR 验证和 mutation 灵敏度测试流程。
  • 通过 factory-local.json 配置并安全校验 docstring_gate_cmd,缺失时明确跳过
  • 在 fix-issue.sh 和 validate-pr.sh 中独立执行门并保存证据
  • 在 mutations/run.py 中支持 docstring 缺陷、退出码判断、SKIP 与汇总
.factory/factory_lib.py
.factory/fix-issue.sh
.factory/validate-pr.sh
.factory/mutations/run.py
.factory/tests/test_factory_lib.py
.factory/tests/test_mutations_run.py
扩展 Codeup 托管适配,以评论标记补齐标签和评审状态同步能力。
  • 合并平台原生标签与未 resolved 的 label-add 评论标记
  • 以 resolved 评论实现移除、标签历史记录和幂等降级
  • 识别 changes-requested 标记并映射为严格评审状态
.factory/hosting.py
.factory/tests/test_hosting.py
增强运行环境诊断、反馈路径兼容性和调度停滞可观测性。
  • 为 bare 或不可用 Git 仓库输出 core.bare 等诊断信息
  • 修正 upstream_path 的 ~/ 展开
  • 停滞标记持久化环境快照并发送 macOS 通知
  • 调整反馈文件映射测试以覆盖多提交场景
.factory/factory-state.sh
.factory/factory_lib.py
.factory/feedback-upstream.sh
.factory/cron-dispatch.sh
.factory/tests/test_feedback.py
重构 mutation runner 的执行组织,同时保持缺陷注入后的清理和证据完整性。
  • 将缺陷加载、处理、还原校验、汇总逻辑集中到 main 流程
  • 保留 dirty target 跳过与还原残留的致命错误检查
  • 修正输出处理和最终 evidence stamp 绑定逻辑
.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 将 .factory 工具链追平至上游 e8666f866,并以本仓配置承载 port_point;重点新增可选、默认跳过但配置损坏即失败的 docstring 门,补齐 Codeup 评论标记兼容、Git/调度诊断及路径修复,同时扩展测试覆盖,验证结果为 275 项全绿。

Sequence diagram for optional docstring validation gate

sequenceDiagram
    participant Workflow as fix-issue_or_validate-pr
    participant FactoryLib as factory_lib.py
    participant DocGate as docstring_gate_cmd
    participant Output as docstring-output.txt

    Workflow->>FactoryLib: docstring-gate
    FactoryLib-->>Workflow: command_or_empty
    alt command configured
        Workflow->>DocGate: execute configured command
        DocGate-->>Output: validation result
        alt gate fails
            Workflow-->>Workflow: stop workflow
        end
    else command not configured
        Workflow-->>Workflow: skip docstring gate
    end
Loading

Sequence diagram for Codeup comment-marker label synchronization

sequenceDiagram
    participant Factory as hosting.py
    participant Codeup as Codeup
    participant Comments as Comment markers

    Factory->>Codeup: POST changeRequests/{p}/comments/list
    Codeup-->>Factory: open_and_resolved_comments
    Factory->>Factory: _marker_label
    alt add label
        Factory->>Codeup: POST changeRequests/{p}/comments
        Codeup-->>Comments: store unresolved label marker
        Factory->>Codeup: POST changeRequests/{p}/labels
    else remove label
        Factory->>Codeup: PUT changeRequests/{p}/comments/{id}
        Codeup-->>Comments: mark marker resolved
    end
    Factory-->>Factory: label_history
Loading

File-Level Changes

Change Details Files
将上游 canonical .factory 工具链同步到本仓,并补入本仓特有的同步锚点。
  • 覆盖同步 12 个 full 面工具链文件及测试
  • 将 port_point 数据化写入本地配置并由 feedback.py fail-closed 读取
  • 保留并清理本地特化逻辑,未合并 chore/docstring-gate 分支
.factory/factory-local.json
.factory/feedback.py
.factory/factory-state.sh
.factory/factory_lib.py
.factory/cron-dispatch.sh
.factory/fix-issue.sh
.factory/validate-pr.sh
.factory/hosting.py
.factory/mutations/run.py
新增可选且 fail-closed 的 docstring 验证门,贯通修复、PR 验证和 mutation 灵敏度测试流程。
  • 通过 factory-local.json 配置并安全校验 docstring_gate_cmd,缺失时明确跳过
  • 在 fix-issue.sh 和 validate-pr.sh 中独立执行门并保存证据
  • 在 mutations/run.py 中支持 docstring 缺陷、退出码判断、SKIP 与汇总
.factory/factory_lib.py
.factory/fix-issue.sh
.factory/validate-pr.sh
.factory/mutations/run.py
.factory/tests/test_factory_lib.py
.factory/tests/test_mutations_run.py
扩展 Codeup 托管适配,以评论标记补齐标签和评审状态同步能力。
  • 合并平台原生标签与未 resolved 的 label-add 评论标记
  • 以 resolved 评论实现移除、标签历史记录和幂等降级
  • 识别 changes-requested 标记并映射为严格评审状态
.factory/hosting.py
.factory/tests/test_hosting.py
增强运行环境诊断、反馈路径兼容性和调度停滞可观测性。
  • 为 bare 或不可用 Git 仓库输出 core.bare 等诊断信息
  • 修正 upstream_path 的 ~/ 展开
  • 停滞标记持久化环境快照并发送 macOS 通知
  • 调整反馈文件映射测试以覆盖多提交场景
.factory/factory-state.sh
.factory/factory_lib.py
.factory/feedback-upstream.sh
.factory/cron-dispatch.sh
.factory/tests/test_feedback.py
重构 mutation runner 的执行组织,同时保持缺陷注入后的清理和证据完整性。
  • 将缺陷加载、处理、还原校验、汇总逻辑集中到 main 流程
  • 保留 dirty target 跳过与还原残留的致命错误检查
  • 修正输出处理和最终 evidence stamp 绑定逻辑
.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

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

嘿——我发现了 2 个问题

AI Agent 提示词
请处理此次代码审查中的评论:

## 单独评论

### 评论 1
<location path=".factory/tests/test_feedback.py" line_range="325-330" />
<code_context>
     """_files_by_sha 结果必须挂回 commits(feedable/pending 判定的 files 来源)。"""
     commits = [{"sha": "a" * 40, "subject": "s", "feedable": True},
                {"sha": "b" * 40, "subject": "t", "feedable": False}]
-    fbs = {"a" * 40: {"factory_lib.py"}}  # b 无映射 → 验证 .get 回退空集契约
+    fbs = {"a" * 40: {"factory_lib.py"}, "b" * 40: {"hosting.py"}}
     monkeypatch.setattr(feedback, "_git_log_commits", lambda: commits)
     monkeypatch.setattr(feedback, "_files_by_sha", lambda: fbs)
     out = feedback._gather_commits()
-    assert out[0]["files"] == {"factory_lib.py"}  # 有映射 → 合并
-    assert out[1]["files"] == set()  # 无映射 → 空集(实现若去掉回退,此处 KeyError)
+    assert out[0]["files"] == {"factory_lib.py"}
+    assert out[1]["files"] == {"hosting.py"}
+    # 未触碰资产的提交 → 空集(feedable_assets/collect_pending 的 .get 契约)
+    assert out[0]["files"] == fbs["a" * 40]
</code_context>
<issue_to_address>
**issue (testing):** 该测试不再覆盖缺失文件映射时的回退逻辑:它为两个提交都添加了映射,因此即使 `_gather_commits()` 从 `.get(sha, set())` 改为直接索引,并因未映射的提交而引发 `KeyError`,测试仍会通过。修改后的断言和注释声称覆盖了回退逻辑,但 fixture 已不再提供这种情况。

**建议修复:** 保持第二个提交不出现在 `fbs` 中,并断言其文件集合为空;同时单独断言有映射的提交保留其文件集合。
</issue_to_address>

### 评论 2
<location path=".factory/fix-issue.sh" line_range="433-435" />
<code_context>
+  # docstring 门(可选门:docstring_gate_cmd 未配置 → 空输出跳过;配置损坏
+  # → factory_lib fail-closed 非零终止)。对外 API 100% + 内部 ≥80% 阈值
+  # 由各仓检查器自定;产物独立落 docstring-output.txt,不污染测试证据。
+  DG_CMD="$(python3 "${REPO}/.factory/factory_lib.py" docstring-gate)"
+  if [ -n "${DG_CMD}" ]; then
+    read -r -a DG_ARGS <<< "${DG_CMD}"
+    if ! (cd "${WT}" && "${DG_ARGS[@]}") > "${DIR}/docstring-output.txt" 2>&1; then
+      echo "docstring 门失败(详见 ${DIR}/docstring-output.txt)" >&2; exit 1
</code_context>
<issue_to_address>
**issue (bug_risk):** shell 使用方既不验证 `docstring_gate_cmd` 中嵌入的换行符,也不验证其他换行符;`read -r -a` 只读取命令替换输出的第一行。Python mutation runner 则会对完整值使用 `shlex.split`,因此工作流脚本和变更验证执行配置命令时使用的参数不同。

**触发条件:** 当 `docstring_gate_cmd` 在 JSON 字符串中包含嵌入的换行符时。

**建议修复:** 在命令验证期间拒绝换行符,或者传递序列化的参数列表,而不是分别在 Python 和 shell 中重新解析命令文本。
</issue_to_address>

Sourcery 评估

需要人工审查。 需要先处理 2 个发现;此外,Codeup 适配器现在会发布并解决对外可见的标记评论,并使用这些评论来驱动标签和“请求修改”审查状态,而门控变更可能影响自动合并决策。回滚不会移除评论、撤销解决状态,也不会逆转任何已经根据这些信号执行的下游自动化操作。

阻塞性发现:.factory/tests/test_feedback.py:330、.factory/fix-issue.sh:435


Sourcery 对开源项目免费——如果你喜欢我们的审查,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
Original comment in English

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".factory/tests/test_feedback.py" line_range="325-330" />
<code_context>
     """_files_by_sha 结果必须挂回 commits(feedable/pending 判定的 files 来源)。"""
     commits = [{"sha": "a" * 40, "subject": "s", "feedable": True},
                {"sha": "b" * 40, "subject": "t", "feedable": False}]
-    fbs = {"a" * 40: {"factory_lib.py"}}  # b 无映射 → 验证 .get 回退空集契约
+    fbs = {"a" * 40: {"factory_lib.py"}, "b" * 40: {"hosting.py"}}
     monkeypatch.setattr(feedback, "_git_log_commits", lambda: commits)
     monkeypatch.setattr(feedback, "_files_by_sha", lambda: fbs)
     out = feedback._gather_commits()
-    assert out[0]["files"] == {"factory_lib.py"}  # 有映射 → 合并
-    assert out[1]["files"] == set()  # 无映射 → 空集(实现若去掉回退,此处 KeyError)
+    assert out[0]["files"] == {"factory_lib.py"}
+    assert out[1]["files"] == {"hosting.py"}
+    # 未触碰资产的提交 → 空集(feedable_assets/collect_pending 的 .get 契约)
+    assert out[0]["files"] == fbs["a" * 40]
</code_context>
<issue_to_address>
**issue (testing):** The test no longer exercises the missing-file mapping fallback: it adds a mapping for both commits and therefore would pass even if `_gather_commits()` changed from `.get(sha, set())` to direct indexing and raised `KeyError` for an unmapped commit. The modified assertion and comment claim fallback coverage while the fixture no longer provides it.

**Suggested fix:** Keep the second commit absent from `fbs` and assert its files are an empty set, while separately asserting mapped commits retain their file sets.
</issue_to_address>

### Comment 2
<location path=".factory/fix-issue.sh" line_range="433-435" />
<code_context>
+  # docstring 门(可选门:docstring_gate_cmd 未配置 → 空输出跳过;配置损坏
+  # → factory_lib fail-closed 非零终止)。对外 API 100% + 内部 ≥80% 阈值
+  # 由各仓检查器自定;产物独立落 docstring-output.txt,不污染测试证据。
+  DG_CMD="$(python3 "${REPO}/.factory/factory_lib.py" docstring-gate)"
+  if [ -n "${DG_CMD}" ]; then
+    read -r -a DG_ARGS <<< "${DG_CMD}"
+    if ! (cd "${WT}" && "${DG_ARGS[@]}") > "${DIR}/docstring-output.txt" 2>&1; then
+      echo "docstring 门失败(详见 ${DIR}/docstring-output.txt)" >&2; exit 1
</code_context>
<issue_to_address>
**issue (bug_risk):** The shell consumers validate neither embedded newlines nor other line breaks in `docstring_gate_cmd`; `read -r -a` reads only the first line of the command-substitution output. The Python mutation runner uses `shlex.split` on the full value, so the configured command is executed with different arguments by the workflow scripts and by mutation verification.

**Triggers:** When `docstring_gate_cmd` contains an embedded newline in the JSON string.

**Suggested fix:** Reject newline characters during command validation, or pass a serialized argument list instead of reparsing command text independently in Python and shell.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 2 findings to address first, and the Codeup adapter now posts and resolves externally visible marker comments and uses them to drive labels and changes-requested review state, while the gate changes can affect automated merge decisions. Reverting will not remove comments, undo resolutions, or reverse any downstream automation that already acted on those signals.

Blocking findings: .factory/tests/test_feedback.py:330, .factory/fix-issue.sh:435


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines -325 to -330
fbs = {"a" * 40: {"factory_lib.py"}} # b 无映射 → 验证 .get 回退空集契约
fbs = {"a" * 40: {"factory_lib.py"}, "b" * 40: {"hosting.py"}}
monkeypatch.setattr(feedback, "_git_log_commits", lambda: commits)
monkeypatch.setattr(feedback, "_files_by_sha", lambda: fbs)
out = feedback._gather_commits()
assert out[0]["files"] == {"factory_lib.py"} # 有映射 → 合并
assert out[1]["files"] == set() # 无映射 → 空集(实现若去掉回退,此处 KeyError)

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.

issue (testing): 该测试不再覆盖缺失文件映射时的回退逻辑:它为两个提交都添加了映射,因此即使 _gather_commits() 从 .get(sha, set()) 改为直接索引,并因未映射的提交而引发 KeyError,测试仍会通过。修改后的断言和注释声称覆盖了回退逻辑,但 fixture 已不再提供这种情况。

建议修复: 保持第二个提交不出现在 fbs 中,并断言其文件集合为空;同时单独断言有映射的提交保留其文件集合。

Original comment in English

issue (testing): The test no longer exercises the missing-file mapping fallback: it adds a mapping for both commits and therefore would pass even if _gather_commits() changed from .get(sha, set()) to direct indexing and raised KeyError for an unmapped commit. The modified assertion and comment claim fallback coverage while the fixture no longer provides it.

Suggested fix: Keep the second commit absent from fbs and assert its files are an empty set, while separately asserting mapped commits retain their file sets.

Comment thread .factory/fix-issue.sh
Comment on lines +433 to +435
DG_CMD="$(python3 "${REPO}/.factory/factory_lib.py" docstring-gate)"
if [ -n "${DG_CMD}" ]; then
read -r -a DG_ARGS <<< "${DG_CMD}"

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.

issue (bug_risk): shell 使用方既不验证 docstring_gate_cmd 中嵌入的换行符,也不验证其他换行符;read -r -a 只读取命令替换输出的第一行。Python mutation runner 则会对完整值使用 shlex.split,因此工作流脚本和变更验证执行配置命令时使用的参数不同。

触发条件: 当 docstring_gate_cmd 在 JSON 字符串中包含嵌入的换行符时。

建议修复: 在命令验证期间拒绝换行符,或者传递序列化的参数列表,而不是分别在 Python 和 shell 中重新解析命令文本。

Original comment in English

issue (bug_risk): The shell consumers validate neither embedded newlines nor other line breaks in docstring_gate_cmd; read -r -a reads only the first line of the command-substitution output. The Python mutation runner uses shlex.split on the full value, so the configured command is executed with different arguments by the workflow scripts and by mutation verification.

Triggers: When docstring_gate_cmd contains an embedded newline in the JSON string.

Suggested fix: Reject newline characters during command validation, or pass a serialized argument list instead of reparsing command text independently in Python and shell.

@im47cn-bot im47cn-bot changed the title chore(factory): 追平上游 .factory 工具链 @e8666f866 factory: 上游同步追平(e8666f866) Aug 31, 2026
@im47cn-bot

Copy link
Copy Markdown
Contributor Author

被 factory/sync-63301f27(PR #26)取代:锚点 20f6a632 → 63301f27,Sourcery 基线随上游清零 PR im47cn/awesome-rules#92 同步;run.py 归位上游 canonical + factory-local.json 补 port_point 已在 #26 落地。只关不删。

@im47cn-bot im47cn-bot closed this Aug 31, 2026
@im47cn-bot
im47cn-bot deleted the factory/sync-e8666f866 branch September 3, 2026 09:19
im47cn pushed a commit that referenced this pull request Oct 18, 2026
字节级同步合并后 crypto-vectors.json:_meta v0.4-draft、rsa2048 节内联就位
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

factory:needs-review PR已开待人工审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant