Repository navigation
factory: 上游同步追平(e8666f866) - #25
im47cn-bot wants to merge 1 commit into
Conversation
- 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 首提锚)
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
审查者指南本 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
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
文件级变更
提示与命令与 Sourcery 交互
自定义你的使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's Guide本 PR 将 .factory 工具链追平至上游 e8666f866,并以本仓配置承载 port_point;重点新增可选、默认跳过但配置损坏即失败的 docstring 门,补齐 Codeup 评论标记兼容、Git/调度诊断及路径修复,同时扩展测试覆盖,验证结果为 275 项全绿。 Sequence diagram for optional docstring validation gatesequenceDiagram
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
Sequence diagram for Codeup comment-marker label synchronizationsequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我发现了 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
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| 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) |
There was a problem hiding this comment.
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.
| DG_CMD="$(python3 "${REPO}/.factory/factory_lib.py" docstring-gate)" | ||
| if [ -n "${DG_CMD}" ]; then | ||
| read -r -a DG_ARGS <<< "${DG_CMD}" |
There was a problem hiding this comment.
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.
字节级同步合并后 crypto-vectors.json:_meta v0.4-draft、rsa2048 节内联就位
概要
真源 awesome-rules main @ e8666f866 同步:full 面 12 文件覆盖 + skip 面 run.py 手工追平 + port_point 入库。
内容
_docstring_gate_words/DOCSTRING_GATE。本仓 factory-local.json 未配置docstring_gate_cmd→ docstring 缺陷走 SKIP 路径,不实跑未配置的门chore/docstring-gate分支(6 提交未合并,另行处理)验证
python3 -m pytest .factory/tests -q:rc=0 全绿(275 测试;修复前 3 失败——2×_docstring_gate_wordsAttributeError + judge rc=2 语义,均为 main 新测试 × 本地旧 run.py 的符号缺口,run.py 追平后消除)后续
Sourcery 追平闸与 hosting 降级护栏待反哺 PR im47cn/awesome-rules#88 人工合入后,下一轮追平带回。
Sourcery 摘要
将 .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:
Bug Fixes:
Enhancements:
Tests:
Chores:
advisory 合规:分支名
factory/sync-e8666f866(M2 约定anchor[:9]9 位短 SHA);同锚点重跑 push 同分支自动更新本 PR(幂等)。