Skip to content

item 25B: workflow 错峰 fan-out (prefix-stagger, CC 2.1.229) #121

Closed

Description

@dahai80

背景

enhance-0819.md item 25 §175/§217 (CC 2.1.229):

动态 workflow 可配 size guideline + 错峰 fan-out (CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS, 兄弟读缓存 prefix 不重付, 2.1.229) + OTel workflow.run_id/name

25A 最小 runtime 已落 PR #105 (main 5d580d6): runtime.ts runWithConcurrency 并发池 min(16,cpu-2), 但 无 stagger — 所有 worker 窗口同时拉起, 兄弟 agent 各自重算 prompt prefix (本地 MLX 无 KV 共享时尤甚, 重复 prefill)。

缺口

runWithConcurrency (runtime.ts:41-65) worker loop 无启动延迟。并发 cap 限总数, 但不错峰 — burst 同时发出, 无 prefix cache 复用窗口。

grep STAGGER/stagger/CLAUDE_CODE_WORKFLOW in src = 0 (全新, default-off)。

落地

错峰 fan-out: 并发池 worker i 启动前 wait min(i, cap) * staggerMs (仅初始 burst 错峰, 后续 worker 补位无延迟)。default off (FUSION_WORKFLOW_PREFIX_STAGGER_MS/CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS 未设 = 0 = byte-identical 25A 行为)。无效值 fail-off = 0。

runtime 路径内, 已受双门禁 (feature WORKFLOW_SCRIPTS + FUSION_WORKFLOW_RUNTIME_ENABLED) — 非 runtime 启用零变化。

injectable delayFn (Rule 9 确定性测, 复用 item 16 无 fake-timer 教训)。

验证

typecheck 0 / 新测 pass / 全套 pass 无回归 / build:dev + build:dev:full / default-off byte-identical (staggerMs=0 → 25A runWithConcurrency 行为不变).

跨仓: 仅改 fusion-code runtime.ts + 测, 无上游依赖.

Co-Authored-By: Claude Fable 5 [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions