Repository navigation
fix(workers): admit same-tool jobs against a shared running limit - #183
Merged
LIghtJUNction merged 1 commit intoSep 29, 2026
Merged
Conversation
Each EffectWorker serializes its own loop, but several workers could claim different pending jobs of the same tool at once, so a tool had no cross-worker concurrency bound (F162.ToolSpec.concurrency). A process-local lock cannot express that fact; only the jobs table seen under the claim's write transaction (BEGIN IMMEDIATE on SQLite, the global advisory lock on PostgreSQL) is shared by every worker. The claim now counts live running jobs per tool id in the same write transaction that expires stale leases, and skips any pending tool job whose tool is already at its limit, continuing in next_at,id order so other tools and non-tool jobs are not blocked. Expired leases still become uncertain first and are not counted. The limit comes from the job's captured tool revision. Published revisions have no concurrency field and keep their bytes, signatures and receipts; absence means 1 (tighter than before). An explicit value must be an int in 1..32; anything else is rejected (invalid_tool_concurrency) by read_tool and fails the job at claim without executing it, never becoming unbounded. Co-authored-by: Cursor <cursoragent@cursor.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
LIghtJUNction
merged commit Sep 29, 2026
84071b8
into
integrate/all-open-20260929
10 of 14 checks passed
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
补齐
docs/DESIGN_CONTRACT_INVENTORY.md中确认的缺口 F162.ToolSpec.concurrency:每个EffectWorker进程内是串行的,但多个 worker 可以同时领取同一工具的不同 pending job,原先没有跨 worker 的上限。EffectWorker._claim在处理过期 lease 的那个写事务里(SQLite 用BEGIN IMMEDIATE,PostgreSQL 用全局 advisory lock),按工具 id 统计仍为running的 job。不用进程内锁,因为进程内锁不是所有 worker 共享的事实。next_at,id找下一个可领取的,所以其他工具和非 tool job 不会被堵住。uncertain,不计入 running。descriptor()、ToolSpec、签名、request_id、账本和 receipt 字节都不改;修订里没有concurrency字段就按 1 处理,比之前更严格。concurrency必须是 1..32 的 int(bool 不算)。其他值会被read_tool拒绝(invalid_tool_concurrency),领取时该 job 被标为failed,不会执行,也不会变成无上限。jobs.body里的 JSON。不包括:
docs/DESIGN_CONTRACT_INVENTORY.{md,json}带有 review-commit 标记的审计条目这次没有更新。测试
在
tests/test_tools.py里扩展了测试,走真实的 PostgreSQLinstalled夹具;第二个 worker 使用独立的Application实例:tool_curl)的 job 和一个非 tool job;第一个 job 结束后,被跳过的 job 才能被领取。concurrency=2时,允许第二个,拒绝第三个。canonical(descriptor('dns')),且不含concurrency。0, 33, -1, True, '2', 1.5, None都会被拒绝,job 标为 failed,runner 没有被调用。新测试在实现前已确认失败。本地(PostgreSQL 由 conftest 通过 initdb 启动)所有涉及
EffectWorker/_claim/save_job/read_tool的测试文件:315 passed。Made with Cursor