Repository navigation
chore: ruff lint 接入 + factory 同步 36a8749c + 版本 0.2.1 - #50
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
审查者指南实现从 SDK 模块中移除未使用的导入,并保留通过通配符导出的
配置配置固定的 Ruff lint 检查集,并将其添加为 CI 检查。
将 commitlint 配置重命名为 CommonJS 格式,并更新钩子,使其检查并引用重命名后的文件。
将软件包版本升级至 0.2.1。
测试在清理 Ruff 相关问题时,从现有 SDK 测试中移除未使用的导入。
添加回归测试,覆盖缺少
锁文件与供应商代码将供应商提供的 factory 文件与上游同步,包括
在本地配置和上游锁元数据中记录已同步的 factory 状态。
提示与命令与 Sourcery 互动
自定义使用体验访问你的仪表板,以便:
获取帮助Original review guide in EnglishReviewer's GuideImplementationRemove unused imports from SDK modules and preserve the wildcard-exported
ConfigurationConfigure the pinned Ruff lint set and add it as a CI check.
Rename the commitlint configuration to CommonJS and update the hook to check and reference the renamed file.
Bump the package version to 0.2.1.
TestsRemove unused imports from existing SDK tests as part of the Ruff cleanup.
Add regression coverage for missing
Lock files and vendored codeSync the vendored factory files with upstream, including argument validation for
Record the synchronized factory state in its local configuration and upstream lock metadata.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
There was a problem hiding this comment.
嘿——我发现了 3 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".factory/hosting.py" line_range="1106" />
<code_context>
fh.write(str(os.getpid()))
+ except OSError as e:
+ # 无 pid 残锁会被判陈旧致另一进程接管(双写):释放并拒持锁
+ shutil.rmtree(lock_dir, ignore_errors=True)
+ raise HostingError(
+ f"add {name}: 锁 pid 写入失败({e}),fail-closed 拒持锁",
</code_context>
<issue_to_address>
**Replacement lock gets deleted**
When pid-file creation or writing fails after the pid-less directory outlives the stale-lock grace period and another caller reclaims it, the OSError handler calls `shutil.rmtree(lock_dir)` by pathname without verifying ownership, deleting the replacement owner's active lock; another caller then enters the critical section and can post a duplicate label.
Remove `lock_dir` only after verifying it is still the lock directory created by this writer.
</issue_to_address>
### Comment 2
<location path=".github/workflows/ci.yml" line_range="155" />
<code_context>
+
+ # ruff 静态检查(E4/E7/E9/F;配置见 pyproject.toml [tool.ruff],vendored .factory
+ # 已排除)。版本锁定保证检查集稳定;纯静态、秒级。
+ lint:
+ runs-on: ubuntu-latest
+ steps:
</code_context>
<issue_to_address>
**Lint failures go untracked**
When the lint job fails while `test` and `oldest-deps` pass, `notify-failure` and `notify-recovery` do not depend on the lint job, so the failure goes untracked and the recovery job can close an existing failure issue while the workflow is red.
Include the lint job in the dependencies of both `notify-failure` and `notify-recovery`.
</issue_to_address>
### Comment 3
<location path=".factory/factory_lib.py" line_range="1447-1449" />
<code_context>
# 不可读/内容畸形 = 死(SIGKILL 残锁过期同判)。退出码 0=活 1=死
# 2=参数错。PG 形态(SUPABASE_DB)租约在库中,调用方不得用本
# 命令的输出断言死活(保守 unknown)。
+ if len(argv) < 3:
+ print("lease-fresh: 缺锁文件路径参数", file=sys.stderr)
+ return 2
lock = Path(argv[2])
try:
</code_context>
<issue_to_address>
**Extra lease arguments look valid**
When the `lease-fresh` command is called with a lock path and one or more extra arguments, `main` reads only `argv[2]` and ignores remaining arguments, so a malformed invocation returns the lock’s live/dead status instead of the documented parameter-error status 2; a caller can mistake the result for a valid lease check.
Require exactly one lock-path argument and return 2 for any other argument count.
</issue_to_address>Sourcery 评估
待批准。 请先处理 3 项发现。
阻塞性发现:.factory/hosting.py:1106、.github/workflows/ci.yml:155、.factory/factory_lib.py:1449
Original comment in English
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".factory/hosting.py" line_range="1106" />
<code_context>
fh.write(str(os.getpid()))
+ except OSError as e:
+ # 无 pid 残锁会被判陈旧致另一进程接管(双写):释放并拒持锁
+ shutil.rmtree(lock_dir, ignore_errors=True)
+ raise HostingError(
+ f"add {name}: 锁 pid 写入失败({e}),fail-closed 拒持锁",
</code_context>
<issue_to_address>
**Replacement lock gets deleted**
When pid-file creation or writing fails after the pid-less directory outlives the stale-lock grace period and another caller reclaims it, the OSError handler calls `shutil.rmtree(lock_dir)` by pathname without verifying ownership, deleting the replacement owner's active lock; another caller then enters the critical section and can post a duplicate label.
Remove `lock_dir` only after verifying it is still the lock directory created by this writer.
</issue_to_address>
### Comment 2
<location path=".github/workflows/ci.yml" line_range="155" />
<code_context>
+
+ # ruff 静态检查(E4/E7/E9/F;配置见 pyproject.toml [tool.ruff],vendored .factory
+ # 已排除)。版本锁定保证检查集稳定;纯静态、秒级。
+ lint:
+ runs-on: ubuntu-latest
+ steps:
</code_context>
<issue_to_address>
**Lint failures go untracked**
When the lint job fails while `test` and `oldest-deps` pass, `notify-failure` and `notify-recovery` do not depend on the lint job, so the failure goes untracked and the recovery job can close an existing failure issue while the workflow is red.
Include the lint job in the dependencies of both `notify-failure` and `notify-recovery`.
</issue_to_address>
### Comment 3
<location path=".factory/factory_lib.py" line_range="1447-1449" />
<code_context>
# 不可读/内容畸形 = 死(SIGKILL 残锁过期同判)。退出码 0=活 1=死
# 2=参数错。PG 形态(SUPABASE_DB)租约在库中,调用方不得用本
# 命令的输出断言死活(保守 unknown)。
+ if len(argv) < 3:
+ print("lease-fresh: 缺锁文件路径参数", file=sys.stderr)
+ return 2
lock = Path(argv[2])
try:
</code_context>
<issue_to_address>
**Extra lease arguments look valid**
When the `lease-fresh` command is called with a lock path and one or more extra arguments, `main` reads only `argv[2]` and ignores remaining arguments, so a malformed invocation returns the lock’s live/dead status instead of the documented parameter-error status 2; a caller can mistake the result for a valid lease check.
Require exactly one lock-path argument and return 2 for any other argument count.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: .factory/hosting.py:1106, .github/workflows/ci.yml:155, .factory/factory_lib.py:1449
| fh.write(str(os.getpid())) | ||
| except OSError as e: | ||
| # 无 pid 残锁会被判陈旧致另一进程接管(双写):释放并拒持锁 | ||
| shutil.rmtree(lock_dir, ignore_errors=True) |
There was a problem hiding this comment.
🟠 高 · 替换后的锁被删除
如果 pid 文件创建或写入失败,而不含 pid 的目录在陈旧锁宽限期过后仍然存在,并且另一个调用者重新获取了该锁,OSError 处理程序就会按路径调用 shutil.rmtree(lock_dir),却不验证所有权,从而删除新所有者正在使用的锁;随后另一个调用者会进入临界区,并可能发布重复标签。
只有在确认 lock_dir 仍是此写入者创建的锁目录后,才将其删除。
面向 AI 代理的提示
在 `.factory/hosting.py` 第 1106 行:
**替换后的锁被删除**
如果 pid 文件创建或写入失败,而不含 pid 的目录在陈旧锁宽限期过后仍然存在,并且另一个调用者重新获取了该锁,OSError 处理程序就会按路径调用 `shutil.rmtree(lock_dir)`,却不验证所有权,从而删除新所有者正在使用的锁;随后另一个调用者会进入临界区,并可能发布重复标签。
只有在确认 `lock_dir` 仍是此写入者创建的锁目录后,才将其删除。Original comment in English
🟠 High · Replacement lock gets deleted
When pid-file creation or writing fails after the pid-less directory outlives the stale-lock grace period and another caller reclaims it, the OSError handler calls shutil.rmtree(lock_dir) by pathname without verifying ownership, deleting the replacement owner's active lock; another caller then enters the critical section and can post a duplicate label.
Remove lock_dir only after verifying it is still the lock directory created by this writer.
Prompt for AI agents
In `.factory/hosting.py` at line 1106:
**Replacement lock gets deleted**
When pid-file creation or writing fails after the pid-less directory outlives the stale-lock grace period and another caller reclaims it, the OSError handler calls `shutil.rmtree(lock_dir)` by pathname without verifying ownership, deleting the replacement owner's active lock; another caller then enters the critical section and can post a duplicate label.
Remove `lock_dir` only after verifying it is still the lock directory created by this writer.|
|
||
| # ruff 静态检查(E4/E7/E9/F;配置见 pyproject.toml [tool.ruff],vendored .factory | ||
| # 已排除)。版本锁定保证检查集稳定;纯静态、秒级。 | ||
| lint: |
There was a problem hiding this comment.
🟡 中 · Lint 失败未被追踪
当 lint 任务失败,而 test 和 oldest-deps 通过时,notify-failure 和 notify-recovery 都不依赖 lint 任务,因此这次失败不会被追踪;即使工作流处于失败状态,恢复任务仍可能关闭现有的失败问题单。
将 lint 任务加入 notify-failure 和 notify-recovery 两者的依赖项中。
面向 AI 代理的提示
在 `.github/workflows/ci.yml` 第 155 行:
**Lint 失败未被追踪**
当 lint 任务失败,而 `test` 和 `oldest-deps` 通过时,`notify-failure` 和 `notify-recovery` 都不依赖 lint 任务,因此这次失败不会被追踪;即使工作流处于失败状态,恢复任务仍可能关闭现有的失败问题单。
将 lint 任务加入 `notify-failure` 和 `notify-recovery` 两者的依赖项中。Original comment in English
🟡 Medium · Lint failures go untracked
When the lint job fails while test and oldest-deps pass, notify-failure and notify-recovery do not depend on the lint job, so the failure goes untracked and the recovery job can close an existing failure issue while the workflow is red.
Include the lint job in the dependencies of both notify-failure and notify-recovery.
Prompt for AI agents
In `.github/workflows/ci.yml` at line 155:
**Lint failures go untracked**
When the lint job fails while `test` and `oldest-deps` pass, `notify-failure` and `notify-recovery` do not depend on the lint job, so the failure goes untracked and the recovery job can close an existing failure issue while the workflow is red.
Include the lint job in the dependencies of both `notify-failure` and `notify-recovery`.| if len(argv) < 3: | ||
| print("lease-fresh: 缺锁文件路径参数", file=sys.stderr) | ||
| return 2 |
There was a problem hiding this comment.
🟡 中 · 多余的租约参数看起来有效
当 lease-fresh 命令接收到锁路径以及一个或多个额外参数时,main 只读取 argv[2] 并忽略其余参数,因此格式错误的调用会返回锁的存活/失效状态,而不是文档规定的参数错误状态码 2;调用方可能会误以为这是有效的租约检查结果。
要求恰好提供一个锁路径参数,其他任何参数数量都返回 2。
面向 AI 代理的提示
在 `.factory/factory_lib.py` 第 1447–1449 行:
**多余的租约参数看起来有效**
当 `lease-fresh` 命令接收到锁路径以及一个或多个额外参数时,`main` 只读取 `argv[2]` 并忽略其余参数,因此格式错误的调用会返回锁的存活/失效状态,而不是文档规定的参数错误状态码 2;调用方可能会误以为这是有效的租约检查结果。
要求恰好提供一个锁路径参数,其他任何参数数量都返回 2。Original comment in English
🟡 Medium · Extra lease arguments look valid
When the lease-fresh command is called with a lock path and one or more extra arguments, main reads only argv[2] and ignores remaining arguments, so a malformed invocation returns the lock’s live/dead status instead of the documented parameter-error status 2; a caller can mistake the result for a valid lease check.
Require exactly one lock-path argument and return 2 for any other argument count.
Prompt for AI agents
In `.factory/factory_lib.py` at lines 1447-1449:
**Extra lease arguments look valid**
When the `lease-fresh` command is called with a lock path and one or more extra arguments, `main` reads only `argv[2]` and ignores remaining arguments, so a malformed invocation returns the lock’s live/dead status instead of the documented parameter-error status 2; a caller can mistake the result for a valid lease check.
Require exactly one lock-path argument and return 2 for any other argument count.
内容
本地门禁
Sourcery 摘要
改进 lint 检查和锁安全检查,同时更新项目工具、工厂元数据和补丁版本。
Bug 修复:
增强:
构建:
CI:
测试:
杂项:
Original summary in English
Summary by Sourcery
Improve linting and lock-safety checks while updating project tooling, factory metadata, and the patch version.
Bug Fixes:
Enhancements:
Build:
CI:
Tests:
Chores: