feat(orchestration): #307 D6 — slow-start batching primitive for fan-out spawns#479
Open
windoliver wants to merge 13 commits into
Open
feat(orchestration): #307 D6 — slow-start batching primitive for fan-out spawns#479windoliver wants to merge 13 commits into
windoliver wants to merge 13 commits into
Conversation
Standalone pure slowStartBatch primitive (k8s replica_set.go style): geometric batches 1->2->4->8, halt on first batch failure. Failure taxonomy task|backpressure|admission -> halted/throttled. BatchStrategy config (spec.batchStrategy home) + bounded computeBackoffMs. Metric grove_spawn_batch_size via onSpawnBatch observer. No live wiring - consumed by #306/#336/#337/#358.
6 TDD tasks: BatchStrategy+validation, computeBackoffMs, failure classification, slowStartBatch runner+metric, failure-path coverage, barrel exports. All in src/core/slow-start-batch.ts (pure, standalone).
- DEFAULT_MAX_BATCH_SIZE named constant (consistency) - backoff baseMs/maxMs positive-int rejection coverage - doc multiplier semantics; lock multiplier=1 acceptance with a test (fixed-size batches / constant backoff are intentionally valid)
- drop redundant '- offset' in initial batch size (offset is 0 here) - comment-fill no-op spawn callbacks (biome noEmptyBlockStatements) - add multiplier=1 termination + non-power-of-two final-batch tests through the public slowStartBatch API (lock termination + sizing)
…ackoff.ts collision) src/core/backoff.ts already exports computeBackoffMs (full-jitter, randomized, hardcoded x2 — for claim-retry thundering-herd). Ours is deterministic + configurable-multiplier for predictable controller requeue. Rename at the source so the core barrel exports it directly with no alias; whole-project tsc --noEmit clean.
…te backoff.ts distinction
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.
Closes #307.
Summary
slowStartBatchprimitive (k8sreplica_set.goslowStartBatchstyle): geometric batches 1 → 2 → 4 → 8, halt the moment a batch sees a failure (later batches never dispatch).task/admission→halted(report, wait for user; admission surfaces an actionable reason);backpressure(RuntimeUnavailableError) →throttled+ boundedretryAfterMsfor the controller to requeue. Terminal wins on mixed batches. Classifier is injectable (defaultFailureClassifierrecognizes the existingAdmissionRejectError).BatchStrategyconfig — the canonical home forspec.batchStrategy— withnormalizeBatchStrategyvalidation and a deterministic, configurable-multipliercomputeSlowStartBackoffMs(distinct from the jittered claim-retrybackoff.ts:computeBackoffMs).grove_spawn_batch_sizemetric surfaced via anonSpawnBatchobserver callback (mirrorsTaskController'sonTransition/onError; feat(orchestration): spawn backpressure conditions + queue depth metrics #337 wires a real exporter later).src/core/slow-start-batch.ts, re-exported from the core barrel.Scope (deliberate)
No
TaskGroupentity, noOwnerKind:"task", no live spawn-path wiring, no metrics exporter — there is no fan-out/TaskGroup component yet (TaskController reconciles singleAgentTasks). This primitive is what #306 / #336 / #337 / #358 will call. Design + plan:docs/superpowers/specs/2026-06-08-307-slow-start-batching-design.md.Acceptance mapping
taskfailure →halted,attempted === 1✅RuntimeUnavailablein batch-1 → no batch-2, recoverable throttled state —throttled+retryAfterMs✅halted,reasonsurfaced ✅grove_spawn_batch_sizeper TaskGroup —onSpawnBatch({ taskGroupId, batchSize, ... })✅spec.batchStrategy—BatchStrategy+normalizeBatchStrategy✅Test Plan
bun test src/core/slow-start-batch.test.ts→ 23 pass / 0 fail, 100% line+function coverage of the modulenpx tsc --noEmit→ clean (whole project)typecheck+buildgates green