Repository navigation
chore: ruff lint 接入 + factory 同步 36a8749c + 版本 0.2.1 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1097,10 +1097,17 @@ def _add_label_lock(self, p, name): | |
| time.sleep(0.05) | ||
| continue | ||
| break | ||
| with contextlib.suppress(OSError): | ||
| try: | ||
| with open(os.path.join(lock_dir, "pid"), "w", | ||
| encoding="ascii") as fh: | ||
| fh.write(str(os.getpid())) | ||
| except OSError as e: | ||
| # 无 pid 残锁会被判陈旧致另一进程接管(双写):释放并拒持锁 | ||
| shutil.rmtree(lock_dir, ignore_errors=True) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 高 · 替换后的锁被删除 如果 pid 文件创建或写入失败,而不含 pid 的目录在陈旧锁宽限期过后仍然存在,并且另一个调用者重新获取了该锁,OSError 处理程序就会按路径调用 只有在确认 面向 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 Remove Prompt for AI agentsIn `.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. |
||
| raise HostingError( | ||
| f"add {name}: 锁 pid 写入失败({e}),fail-closed 拒持锁", | ||
| code=1, | ||
| ) from e | ||
| try: | ||
| yield | ||
| finally: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "anchor": "181618c32492fb41f5a2a14f52515449fdc1c9eb", | ||
| "anchor": "36a8749c9385dba755ef495e523f6a4358d483f9", | ||
| "upstream": "/Users/dreambt/sources/awesome-factory", | ||
| "synced_at": "2026-11-01T03:45:40+00:00" | ||
| "synced_at": "2026-11-09T05:51:11+00:00" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,3 +149,17 @@ jobs: | |
| run: pip install griffe==1.14.0 | ||
| - name: API snapshot gate (regenerate to temp file, git diff --exit-code) | ||
| run: python3 scripts/check-api-snapshot.py | ||
|
|
||
| # ruff 静态检查(E4/E7/E9/F;配置见 pyproject.toml [tool.ruff],vendored .factory | ||
| # 已排除)。版本锁定保证检查集稳定;纯静态、秒级。 | ||
| lint: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 中 · Lint 失败未被追踪 当 lint 任务失败,而 将 lint 任务加入 面向 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 Include the lint job in the dependencies of both Prompt for AI agentsIn `.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`. |
||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
| - name: Install pinned ruff | ||
| run: pip install ruff==0.17.3 | ||
| - name: ruff check | ||
| run: ruff check . | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| import base64 | ||
| import hashlib | ||
| import json | ||
| import os | ||
| import re | ||
|
|
||
| import pytest | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 中 · 多余的租约参数看起来有效
当
lease-fresh命令接收到锁路径以及一个或多个额外参数时,main只读取argv[2]并忽略其余参数,因此格式错误的调用会返回锁的存活/失效状态,而不是文档规定的参数错误状态码 2;调用方可能会误以为这是有效的租约检查结果。要求恰好提供一个锁路径参数,其他任何参数数量都返回 2。
面向 AI 代理的提示
Original comment in English
🟡 Medium · Extra lease arguments look valid
When the
lease-freshcommand is called with a lock path and one or more extra arguments,mainreads onlyargv[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