Repository navigation
feat(workflow): item 25B 错峰 fan-out (prefix-stagger, CC 2.1.229, #121) - #122
Merged
Merged
Conversation
并发池 worker 启动前错峰延迟, 让后启 agent 复用先启 agent 已预热的
prompt prefix 缓存 (本地 MLX 无 KV 共享时兄弟 agent 各自重算 prefill,
错峰给复用窗口)。
- workflowStaggerMs(): env 解析 FUSION_WORKFLOW_PREFIX_STAGGER_MS (优先)
回落 CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS; 非法/负数/NaN/Infinity
fail-off = 0。default off (env 未设/空 = 0) = 25A byte-identical。
- runWithConcurrency 加 staggerMs + 注入 delay 参数: worker k 启动前
wait k*staggerMs (仅初始 burst, 前 cap 个 worker; worker 0 不延迟;
后续补位无延迟)。staggerMs=0 走无延迟分支 = 25A 行为。
- createParallel/PipelinePrimitive 各注入 workflowStaggerMs()。
- 导出 runWithConcurrency/workflowStaggerMs/DelayFn 供测试。
- 14 新单测: env 解析 10 case (default off/FUSION 优先/回落/非法 fail-off/
有效值) + runWithConcurrency 7 case (staggerMs=0 不调 delay byte-identical/
错峰 [50,100,150] 排序解耦调度/仅前 cap 错峰/cap<items 全完成/throw null/
空/单 worker 不延迟)。
双门禁不变 (feature("WORKFLOW_SCRIPTS") 编译期 + FUSION_WORKFLOW_RUNTIME_ENABLED=1
运行期), stagger 在已门禁 runtime 路径内, 无独立 gate。
验证: typecheck 0 / 40 stagger 测 pass / 380 全套无回归 / build+build:dev
+build:dev:full+build pass / biome clean。
Co-Authored-By: Claude Fable 5 <[email protected]>
dahai80
added a commit
that referenced
this pull request
Aug 22, 2026
Patch release bundling 17 commits since v0.4.23: - item 15(a) MLX OOM auto-recovery gc+retry (#129) - #7 one-click diagnostic fixAction framework (#131) - 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127) - #4 proactive MLX OOM detection via /v1/health (#125) - item 17 fullscreen pre-compact history + :598 synthetic decouple (#123) - item 25B workflow stagger fan-out (#122) - item 21 auto-mode local rule classifier test coverage (#120) - item 23 archive plugin source + SHA-256 lock (#118) - item 24 marketplace command source (#116) - item 6 transcript disk trimming + crash-safe checkpoint (#114) - item 5 normalizeMessages secondary normalize cache (#112) - item 19 screen-reader plaintext render (#110) - item 16 compact retry countdown + stall hint (#108) - item 25A workflow execution runtime docs (#106) - item 25A minimal workflow execution runtime (#105) - item 12 subagent auto-background threshold (#103) - item 20 vimInsertModeRemaps dual-key INSERT sequence (#101) Co-Authored-By: Claude Fable 5 <[email protected]>
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.
item 25B — workflow 错峰 fan-out (CC 2.1.229 PREFIX_STAGGER_MS)
Closes #121.
序列末项: 25A → 16 → 19 → 5 → 6 → 24 → 23 → 21 → 25B (全 ✅)。
背景
25A (PR #105, main 5d580d6) 落地最小 workflow runtime,
runWithConcurrency(thunks, cap)并发池 min(16, cpu-2), 无错峰。本地 MLX 无 KV 共享 → 兄弟 agent 各自重算 prompt prefill。错峰让后启 agent 在先启 agent 预热 prefix 缓存窗口内复用。改动 (2 文件, +214/-6)
runtime.ts:
workflowStaggerMs()— env 解析FUSION_WORKFLOW_PREFIX_STAGGER_MS(FUSION 优先, fusion-code 约定) 回落CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MS(CC 原名)。非法/负数/NaN/Infinity → fail-off = 0 + logForDebugging。default off (env 未设/空 = 0) = 25A byte-identical。runWithConcurrency<T>(thunks, cap, staggerMs = 0, delay: DelayFn = defaultDelay)— worker k 启动前await delay(k * staggerMs)(仅初始 burst, 前 cap 个 worker; worker 0 不延迟; 后续补位无延迟)。staggerMs=0 走无延迟分支 = 25A 行为。DelayFn可注入 (测试确定性, 复用 item 16 无 fake-timer 教训)。createParallelPrimitive/createPipelinePrimitive各注入workflowStaggerMs()。runWithConcurrency/workflowStaggerMs/DelayFn供测试。workflowRuntime.test.ts — 14 新单测:
设计取舍
验证
bun run typecheck— 0 errorsbun test src/__tests__/workflowRuntime.test.ts— 40 pass (14 新 + 26 原 25A)bun test src/__tests__/— 380 pass, 0 fail, 无回归bun run build+build:dev+build:dev:full— 全 passbiome checkchanged 文件 — clean (defaultDelay 多行格式 biome 要求, 改在新增块内)Co-Authored-By: Claude Fable 5 [email protected]