parallel-planner

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Parallel Planner Protocol

并行规划器协议

Analyze task steps — which ones must wait for each other, which ones can run simultaneously? Build a dependency graph, form parallel groups, and prevent conflicts.
Core principle: Sequential is safe but slow. Parallel is fast but requires care. Making the right distinction is this skill's job.

分析任务步骤——哪些步骤必须相互等待,哪些可以同时运行?构建依赖关系图,形成并行组,并防止冲突。
核心原则: 顺序执行安全但缓慢,并行执行快速但需要谨慎。做出正确的区分是本技能的职责。

Parallelization Criteria

并行化判定标准

A step can run in parallel only if all conditions are met:
  • Not dependent on another step's output
  • Does not write to a resource another step reads (no write conflict)
  • Does not modify shared state (global variable, same file)
  • If it fails, it does not block other parallel steps
A step must run sequentially if any of these apply:
  • Its input is another step's output
  • It writes to the same file / DB table / API resource
  • Order matters for correctness (e.g., schema before data)
  • Must be atomic (inside a transaction)

仅当所有以下条件满足时,步骤才可并行执行:
  • 不依赖其他步骤的输出
  • 不会写入其他步骤读取的资源(无写冲突)
  • 不会修改共享状态(全局变量、同一文件)
  • 若执行失败,不会阻塞其他并行步骤
任意以下情况存在时,步骤必须顺序执行:
  • 其输入是其他步骤的输出
  • 写入同一文件/数据库表/API资源
  • 顺序对正确性至关重要(例如:先定义 schema 再处理数据)
  • 必须是原子操作(在事务内执行)

Parallelizable Work Types

可并行的工作类型

TypeParallel WhenSequential When
Web searchDifferent topics/sourcesResult of search A needed for search B
Code generationWriting to different filesFile B imports from file A
API callsReading from same or different resourcesAuth token needed first
Data processingDifferent data slicesNormalization before analysis
Independent subtasksNo shared output/resourceTest depends on module

类型可并行场景需顺序场景
网页搜索不同主题/来源搜索A的结果需用于搜索B
代码生成写入不同文件文件B导入文件A
API调用读取相同或不同资源需先获取认证令牌
数据处理处理不同数据分片需先归一化再分析
独立子任务无共享输出/资源测试依赖于模块

Conflict Detection

冲突检测

After identifying parallel candidates, check for conflicts:
确定并行候选步骤后,检查以下冲突:

Write-Write Conflict

写-写冲突

Two steps write to the same resource → cannot be parallel. Solution: Run sequentially OR write to separate files, then merge.
两个步骤写入同一资源 → 不可并行。 解决方案:顺序执行,或写入不同文件后再合并。

Read-Write Conflict

读-写冲突

One step reads while another writes to the same resource → cannot be parallel. Solution: Read first, then write (sequential).
一个步骤读取资源时,另一个步骤写入该资源 → 不可并行。 解决方案:先读取,再写入(顺序执行)。

Resource Contention

资源竞争

Shared rate limits or connection pools → limit parallel count. Solution: Cap at 3 parallel, run in batches.

共享速率限制或连接池 → 限制并行数量。 解决方案:最多并行3个步骤,分批执行。

Output Format

输出格式

PARALLEL PLANNER
Total steps: N | Parallel groups: N | Sequential steps: N
Estimated speedup: ~X% faster
PARALLEL PLANNER
Total steps: N | Parallel groups: N | Sequential steps: N
Estimated speedup: ~X% faster

Dependency Graph

Dependency Graph

[mermaid or text visualization]
[mermaid or text visualization]

Execution Plan

Execution Plan

Group 1 — Parallel (N steps)

Group 1 — Parallel (N steps)

  • #A: [step]
  • #B: [step]
  • #C: [step] -> All complete, then proceed to Group 2
  • #A: [step]
  • #B: [step]
  • #C: [step] -> All complete, then proceed to Group 2

Group 2 — Sequential

Group 2 — Sequential

  • #D: [step] (requires: #A, #B)
  • #E: [step] (requires: #D)
  • #D: [step] (requires: #A, #B)
  • #E: [step] (requires: #D)

Conflict Warnings

Conflict Warnings

[If any — blocked parallel candidates and reason]
[If any — blocked parallel candidates and reason]

Steps Kept Sequential

Steps Kept Sequential

StepReasonDepends On
#DUses #A output#A

---
StepReasonDepends On
#DUses #A output#A

---

Speed Estimate

速度估算

Sequential total = Sum(all step durations)
Parallel total   = Sum(longest step per group)
Speedup          = (Sequential - Parallel) / Sequential * 100
Complexity-based estimates when duration is unknown:
  • Simple (file read, short code): ~1 unit
  • Medium (API call, analysis): ~3 units
  • Heavy (web research, large code): ~5 units

Sequential total = Sum(all step durations)
Parallel total   = Sum(longest step per group)
Speedup          = (Sequential - Parallel) / Sequential * 100
当未知执行时长时,基于复杂度估算:
  • 简单(文件读取、短代码):~1单位
  • 中等(API调用、分析):~3单位
  • 复杂(网页调研、大型代码):~5单位

When to Skip

何时跳过

  • 2 or fewer steps — parallelization is meaningless
  • All steps are sequentially dependent
  • User said "do it step by step"
  • Transaction-bound operations (must be atomic)

  • 2个及以下步骤 — 并行化无意义
  • 所有步骤均为顺序依赖
  • 用户要求“逐步执行”
  • 事务绑定操作(必须为原子操作)

Guardrails

防护规则

  • Never parallelize write operations to the same resource — even if it seems safe.
  • Always show the dependency graph — the user must see why steps are ordered this way.
  • Cross-skill: works with
    task-decomposer
    (provides the step list) and
    tool-selector
    (optimizes tool usage within groups).
  • 绝不对同一资源的写入操作进行并行化 — 即使看似安全。
  • 始终展示依赖关系图 — 用户必须了解步骤如此排序的原因。
  • 跨技能协作:可与
    task-decomposer
    (提供步骤列表)和
    tool-selector
    (优化组内工具使用)配合工作。