Repository navigation
factory: 上游同步追平(2be9f99) - #31
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team 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 将工厂工具链追平到上游 2be9f99:以中心仓巡检脚本和增强版同步脚本管理多下游自动追平及单提交落库,同时强化运行时自愈、环境密封、配置质量门、Codeup/GitHub 适配和 issue 预检,并以大量回归测试覆盖同步安全、平台契约与故障场景。 中心化下游同步时序图sequenceDiagram
participant Operator
participant Checker as downstream-check.sh
participant Center as Center repository
participant Sync as sync-from-upstream.sh
participant Downstream as Downstream repository
Operator->>Checker: --apply-commit
Checker->>Center: Read downstream.json
loop Each downstream repository
Checker->>Sync: --repo path --anchor main --check
Sync->>Center: Read upstream manifest and files
Sync->>Downstream: Detect drift
alt Drift detected
Checker->>Sync: --repo path --anchor main --apply --commit
Sync->>Downstream: Atomically replace full files
Sync->>Downstream: Update upstream-lock.json
Sync->>Downstream: Commit synchronization changes
else Clean
Sync-->>Checker: Clean
end
end
Checker-->>Operator: Summary and exit status
同步安全门时序图sequenceDiagram
participant Sync as sync-from-upstream.sh
participant Repo as Target repository
participant Sourcery
participant Git as Git repository
Sync->>Repo: Resolve --repo to repository root
Sync->>Git: Check tracked .factory changes
alt Dirty .factory with --commit
Git-->>Sync: Uncommitted changes
Sync-->>Repo: Abort fail-closed
else Clean target
Sync->>Sourcery: Review .factory baseline
Sourcery-->>Sync: Clean baseline
Sync->>Repo: Atomically stage full-file updates
Sync->>Sourcery: Review updated .factory
alt Updated files clean
Sync->>Git: Stage lock and files
Sync->>Git: Commit synchronization
else Regression detected
Sync-->>Repo: Abort without updating lock
end
end
issue 创建预检流程图flowchart TD
Create[Issue create request] --> Body{Acceptance section or checkbox?}
Body -->|No| RejectBody[Reject before platform request]
Body -->|Yes| Label{factory:* label allowed?}
Label -->|No, except needs-human| RejectLabel[Reject before platform request]
Label -->|Yes| Platform[Create issue on hosting platform]
文件级变更
提示与命令与 Sourcery 交互
自定义使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's Guide该 PR 将工厂工具链追平到上游 2be9f99:以中心仓巡检脚本和增强版同步脚本管理多下游自动追平及单提交落库,同时强化运行时自愈、环境密封、配置质量门、Codeup/GitHub 适配和 issue 预检,并以大量回归测试覆盖同步安全、平台契约与故障场景。 Sequence diagram for centralized downstream synchronizationsequenceDiagram
participant Operator
participant Checker as downstream-check.sh
participant Center as Center repository
participant Sync as sync-from-upstream.sh
participant Downstream as Downstream repository
Operator->>Checker: --apply-commit
Checker->>Center: Read downstream.json
loop Each downstream repository
Checker->>Sync: --repo path --anchor main --check
Sync->>Center: Read upstream manifest and files
Sync->>Downstream: Detect drift
alt Drift detected
Checker->>Sync: --repo path --anchor main --apply --commit
Sync->>Downstream: Atomically replace full files
Sync->>Downstream: Update upstream-lock.json
Sync->>Downstream: Commit synchronization changes
else Clean
Sync-->>Checker: Clean
end
end
Checker-->>Operator: Summary and exit status
Sequence diagram for synchronization safety gatessequenceDiagram
participant Sync as sync-from-upstream.sh
participant Repo as Target repository
participant Sourcery
participant Git as Git repository
Sync->>Repo: Resolve --repo to repository root
Sync->>Git: Check tracked .factory changes
alt Dirty .factory with --commit
Git-->>Sync: Uncommitted changes
Sync-->>Repo: Abort fail-closed
else Clean target
Sync->>Sourcery: Review .factory baseline
Sourcery-->>Sync: Clean baseline
Sync->>Repo: Atomically stage full-file updates
Sync->>Sourcery: Review updated .factory
alt Updated files clean
Sync->>Git: Stage lock and files
Sync->>Git: Commit synchronization
else Regression detected
Sync-->>Repo: Abort without updating lock
end
end
Flow diagram for issue creation prechecksflowchart TD
Create[Issue create request] --> Body{Acceptance section or checkbox?}
Body -->|No| RejectBody[Reject before platform request]
Body -->|Yes| Label{factory:* label allowed?}
Label -->|No, except needs-human| RejectLabel[Reject before platform request]
Label -->|Yes| Platform[Create issue on hosting platform]
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 代理的提示
请处理本次代码审查中的评论:
## 各条评论
### 评论 1
<location path=".factory/tests/gitenv.py" line_range="42-70" />
<code_context>
+# 测试子进程链锚定工具(所在目录进 PATH 白名单:python3 → bash → git)
</code_context>
<issue_to_address>
**issue (bug_risk):** `_sealed_path` 仅通过 `/usr/bin:/bin` 查找 `python3`、`git` 和 `bash`,然后返回这些目录及备用目录。在 macOS 安装中,如果 `python3` 仅位于 `/opt/homebrew/bin` 或其他非 POSIX 目录,返回的 `PATH` 将无法解析 `python3`,因此调用 `python3` 的测试子进程会在工厂链运行之前失败。
**触发条件:** 测试主机在 `/usr/bin` 或 `/bin` 中没有 `python3` 时;这在基于 Homebrew 的 macOS 配置中很常见。
**建议修复:** 从明确批准的工具路径中解析每个必需工具,或以清晰的配置错误终止;不要静默地将必需的解释器从密封的 PATH 中遗漏。
</issue_to_address>
### 评论 2
<location path=".factory/hosting.py" line_range="72" />
<code_context>
import urllib.parse
import urllib.request
-FACTORY_HOSTING = os.environ.get("FACTORY_HOSTING", "github")
+FACTORY_HOSTING = os.environ.get("FACTORY_HOSTING")
</code_context>
<issue_to_address>
**nitpick:** 模块文档说明 `FACTORY_HOSTING=github` 是默认值,但更改后的配置现在会使其保持未设置状态,而 `current_adapter` 会根据远程仓库自动检测 Codeup。对于使用 Codeup 远程仓库的仓库,文档中描述的平台选择契约并不成立,这可能会误导依赖所述默认行为的运维人员和调用方。
**触发条件:** 运维人员或集成依赖模块头部文档来预测适配器选择时。
**建议修复:** 更新模块文档字符串,说明显式设置的 `FACTORY_HOSTING` 值具有优先级;未设置时则根据 `origin` 推断,并回退到 GitHub。
</issue_to_address>Sourcery 评估
需要人工审查。 需要优先处理 1 个发现;此外,此更改会影响计划调度行为、下游仓库写入、托管平台上的标签/评论以及 issue 创建策略,因此缺陷可能会发送外部警报、创建不正确的生命周期记录,或在多个仓库中提交更改。还原代码可以阻止未来的影响,但无法撤销已经产生的通知、评论、标签或提交。
阻塞性发现:.factory/tests/gitenv.py:70
请帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
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/gitenv.py" line_range="42-70" />
<code_context>
+# 测试子进程链锚定工具(所在目录进 PATH 白名单:python3 → bash → git)
</code_context>
<issue_to_address>
**issue (bug_risk):** `_sealed_path` resolves `python3`, `git`, and `bash` only through `/usr/bin:/bin` and then returns those directories plus the fallback directories. On macOS installations where `python3` is available only in `/opt/homebrew/bin` or another non-POSIX directory, the returned `PATH` cannot resolve `python3`, so test subprocesses that invoke `python3` fail before the factory chain runs.
**Triggers:** When the test host does not have `python3` in `/usr/bin` or `/bin`, which is common on Homebrew-based macOS setups.
**Suggested fix:** Resolve each required tool from an explicitly approved tool path or fail with a clear configuration error; do not silently omit a required interpreter from the sealed PATH.
</issue_to_address>
### Comment 2
<location path=".factory/hosting.py" line_range="72" />
<code_context>
import urllib.parse
import urllib.request
-FACTORY_HOSTING = os.environ.get("FACTORY_HOSTING", "github")
+FACTORY_HOSTING = os.environ.get("FACTORY_HOSTING")
</code_context>
<issue_to_address>
**nitpick:** The module documentation says `FACTORY_HOSTING=github` is the default, but the changed configuration now leaves it unset and `current_adapter` auto-detects Codeup from the remote. The documented platform-selection contract is false for repositories with Codeup remotes, which can mislead operators and callers that rely on the stated default behavior.
**Triggers:** When an operator or integration relies on the module header documentation to predict adapter selection.
**Suggested fix:** Update the module docstring to state that an explicit `FACTORY_HOSTING` value takes precedence and that an unset value is inferred from `origin`, falling back to GitHub.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this changes scheduled dispatch behavior, downstream repository writes, hosting-side labels/comments and issue-creation policy, so a defect could send external alerts, create incorrect lifecycle records, or commit changes across multiple repositories. Reverting the code would stop future effects, but it would not undo notifications, comments, labels, or commits already produced.
Blocking findings: .factory/tests/gitenv.py:70
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| # 测试子进程链锚定工具(所在目录进 PATH 白名单:python3 → bash → git) | ||
| _ANCHOR_TOOLS = ("python3", "git", "bash") | ||
| # POSIX 标准目录兜底(sed/grep/sh 等 coreutils 所在) | ||
| _FALLBACK_DIRS = ("/usr/bin", "/bin") | ||
|
|
||
|
|
||
| def _sealed_path() -> str: | ||
| """PATH 白名单:锚定工具所在目录 ∪ POSIX 标准目录。 | ||
|
|
||
| 目录级白名单(非工具级):够跑 python3→bash→git 测试链即可, | ||
| 宿主私有目录(pip user bin 等)整体剥除——sourcery 不可见 → | ||
| 夹具闸 command -v 探测跳过 → 零出网(issue #109 陷阱①)。 | ||
|
|
||
| 锚定解析强制走 POSIX 标准目录(PR #111 Sourcery 评论①):宿主 | ||
| PATH 永不参与白名单推导——锚定工具与 sourcery 同目录共存时 | ||
| (如 homebrew bin 同时装 python3 与 sourcery),该目录不可再 | ||
| 泄漏进白名单。锚定工具均在标准目录内可解析(/usr/bin/python3、 | ||
| /usr/bin/git、/bin/bash),解析失败亦有 _FALLBACK_DIRS 兜底。 | ||
| """ | ||
| dirs: list[str] = [] | ||
| for tool in _ANCHOR_TOOLS: | ||
| where = shutil.which(tool, path=os.pathsep.join(_FALLBACK_DIRS)) | ||
| d = os.path.dirname(where) if where else None | ||
| if d and d not in dirs: | ||
| dirs.append(d) | ||
| for d in _FALLBACK_DIRS: | ||
| if d not in dirs: | ||
| dirs.append(d) | ||
| return os.pathsep.join(dirs) |
There was a problem hiding this comment.
issue (bug_risk): _sealed_path 仅通过 /usr/bin:/bin 查找 python3、git 和 bash,然后返回这些目录及备用目录。在 macOS 安装中,如果 python3 仅位于 /opt/homebrew/bin 或其他非 POSIX 目录,返回的 PATH 将无法解析 python3,因此调用 python3 的测试子进程会在工厂链运行之前失败。
触发条件: 测试主机在 /usr/bin 或 /bin 中没有 python3 时;这在基于 Homebrew 的 macOS 配置中很常见。
建议修复: 从明确批准的工具路径中解析每个必需工具,或以清晰的配置错误终止;不要静默地将必需的解释器从密封的 PATH 中遗漏。
Original comment in English
issue (bug_risk): _sealed_path resolves python3, git, and bash only through /usr/bin:/bin and then returns those directories plus the fallback directories. On macOS installations where python3 is available only in /opt/homebrew/bin or another non-POSIX directory, the returned PATH cannot resolve python3, so test subprocesses that invoke python3 fail before the factory chain runs.
Triggers: When the test host does not have python3 in /usr/bin or /bin, which is common on Homebrew-based macOS setups.
Suggested fix: Resolve each required tool from an explicitly approved tool path or fail with a clear configuration error; do not silently omit a required interpreter from the sealed PATH.
| import urllib.parse | ||
| import urllib.request | ||
|
|
||
| FACTORY_HOSTING = os.environ.get("FACTORY_HOSTING", "github") |
There was a problem hiding this comment.
nitpick: 模块文档说明 FACTORY_HOSTING=github 是默认值,但更改后的配置现在会使其保持未设置状态,而 current_adapter 会根据远程仓库自动检测 Codeup。对于使用 Codeup 远程仓库的仓库,文档中描述的平台选择契约并不成立,这可能会误导依赖所述默认行为的运维人员和调用方。
触发条件: 运维人员或集成依赖模块头部文档来预测适配器选择时。
建议修复: 更新模块文档字符串,说明显式设置的 FACTORY_HOSTING 值具有优先级;未设置时则根据 origin 推断,并回退到 GitHub。
Original comment in English
nitpick: The module documentation says FACTORY_HOSTING=github is the default, but the changed configuration now leaves it unset and current_adapter auto-detects Codeup from the remote. The documented platform-selection contract is false for repositories with Codeup remotes, which can mislead operators and callers that rely on the stated default behavior.
Triggers: When an operator or integration relies on the module header documentation to predict adapter selection.
Suggested fix: Update the module docstring to state that an explicit FACTORY_HOSTING value takes precedence and that an unset value is inferred from origin, falling back to GitHub.
|
处置:①已修复 ②不改码(真源 awesome-rules#116,commit d6e6b57) ① 平台选择 docstring 过时:真源已改为「FACTORY_HOSTING 显式设置优先;未设置按 origin remote 检测(codeup.aliyun.com → codeup,github.com/无 remote → github 历史默认)」,与实现对齐。 ② 真源合入 main 后随下次 sync 分发(①部分)。 |
上游同步追平
2be9f99(im47cn/awesome-rules main tip)sync-from-upstream.sh --apply --commit,full 面直接覆盖(零本地化),含 upstream-lock.json 锚点更新人工合并后下游即与上游
2be9f99对齐。Sourcery 总结
将工厂工具链同步追平至上游 2be9f99,并强化跨仓同步、门控校验、Codeup 适配、运行时自愈与故障告警。
新功能:
Bug 修复:
改进:
测试:
杂项:
Original summary in English
Summary by Sourcery
将工厂工具链同步追平至上游 2be9f99,并强化跨仓同步、门控校验、Codeup 适配、运行时自愈与故障告警。
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: