Repository navigation
Adopt bounded local-concurrency policy for Zed Rust task/process execution #107
Copy link
Copy link
Open
Description
Goal
Establish an organization-level concurrency policy for Zed Rust tooling so repositories cannot accidentally consume unbounded local resources through ad hoc thread/process spawning or unbounded in-memory work queues.
Primary implementation tracker: zed-pkg/zed-cli#472
Proposed policy
For local task/build/install/package execution paths that can fan out work:
- use a fixed-size reusable worker pool or another explicitly bounded executor;
- use a bounded job queue with defined backpressure/saturation semantics;
- do not use naked/ad hoc
std::thread::spawnin fan-out paths unless the site is narrowly justified and independently bounded; - bound subprocess concurrency separately from worker-thread concurrency;
- derive safe defaults conservatively and keep explicit user overrides (
--jobs, config, etc.) validated; - ensure shutdown joins workers and does not leak background work past the command lifetime;
- test concurrency/resource invariants with large synthetic workloads;
- keep task identity/deduplication and locking semantics race-safe;
- prefer a small auditable scheduler abstraction over introducing a heavyweight runtime solely for bounded fan-out.
Suggested reusable invariants
- live worker threads <= configured worker count;
- live child processes <= configured process budget;
- queued jobs <= configured queue capacity;
- input/task graph size cannot directly determine thread count;
- queue saturation produces explicit backpressure rather than memory growth;
- all workers/children are reaped before the owning command returns;
- concurrency configuration rejects zero/invalid values and has a documented default;
- nested work cannot deadlock the scheduler by synchronously filling its own queue.
Enforcement ideas
- add organization guidance under the shared
.githubrepository / contributor instructions; - add a lightweight static check for suspicious task-path
thread::spawn/ unbounded channel usage where practical; - require explicit tests for max thread/process/queue occupancy when a repo introduces parallel execution;
- have zed-pkg lifecycle hooks / git hooks invoke the check in repositories that own local execution machinery;
- document approved primitives/patterns and exception criteria.
Initial scope
Start with zed-pkg/zed-cli and the native zed task runtime, then apply the rule opportunistically to other Rust repositories that execute bounded local work.
Acceptance criteria
- shared policy documented in
zed-pkg/.github; - implementation tracker remains cross-linked to
zed-cli#472; - enforcement mechanism defined for task/process execution repositories;
-
zed-cliadopts a fixed worker pool + bounded queue; - tests prove thread/process/queue bounds;
- exception process for legitimately dedicated threads is documented;
- policy is suitable for reuse by zed-pkg lifecycle hooks and git hooks.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
ORESoftware commentedon Sep 21, 2026
Primary implementation tracker: zed-pkg/zed-cli#472
@claude please review this proposed organization policy for practicality and enforceability across Zed Rust repositories. Please compare it with the concrete
zed-cliimplementation tracker and comment on a minimal shared policy/check that catches dangerous fan-out without flagging legitimate dedicated threads.Please cover:
thread::spawn, unbounded channels/queues, or both;Please leave concrete suggested policy text and enforcement steps in this issue.
docs: draft bounded local concurrency policy for #107
ORESoftware commentedon Sep 21, 2026
Companion policy draft is now in PR #108: #108
The implementation-side draft is zed-pkg/zed-cli#473: zed-pkg/zed-cli#473