Skip to content

feat(swarm): SP3 — real warm boot (shared cargo cache the worker reuses, gated)#14

Closed
New1Direction wants to merge 4 commits into
feat/swarm-collaborationfrom
feat/swarm-warm-boot
Closed

feat(swarm): SP3 — real warm boot (shared cargo cache the worker reuses, gated)#14
New1Direction wants to merge 4 commits into
feat/swarm-collaborationfrom
feat/swarm-warm-boot

Conversation

@New1Direction

Copy link
Copy Markdown
Owner

Track B SP3: a warm boot that isn't theater

speculative_warm_boot was a no-op bool-setter sitting on SpeculativeScheduler::run — a path production never runs. The real campaign work is the separate korg worker child's cargo check, which ran cold per worktree. SP3 makes warm boot do real work the real worker reuses.

The anti-theater mechanism

  • warm_target_dir(session_id) → a stable shared cargo target dir. Both the warm boot and the worker spawn derive it from the same session_id (the leader's sid is the coordinator's sid), so the worker reuses exactly what was warmed — with zero cross-process plumbing.
  • Warm boot (7a08f69): runs a real cargo check with CARGO_TARGET_DIR=warm_target_dir, compiling the dependency graph into the shared cache once. Hermetic: wrapped in a 60s timeout + cargo-presence guard, returns Skipped|Warmed|Unavailable (never Err, never hangs) — the bare-host path always completes.
  • Worker reuse (fc0b8f0): SubprocessBackend::spawn sets CARGO_TARGET_DIR=warm_target_dir(session) on the worker Command when speculative; cargo check honors it automatically (nothing clobbers it). So workers reuse the warmed dep artifacts instead of recompiling cold.
  • Gate (e371246): --speculative flag (default off → unchanged behavior); flips the leader + coordinator AtomicBool, read at spawn_worker_process. maybe_warm_boot is called before dispatch in the live campaign loop.

Honest scoping

  • Reuse is proven structurally (cache non-empty after a real warm + the worker env provably points at that same dir) — not a flaky timing benchmark.
  • The win is dependency-graph reuse (shared compiled deps across worktrees), not full per-worktree incremental reuse — consistent with the spec's claim.
  • SandboxPool left untouched (it primes a node/LSP world the cargo campaign never queries — wrong shape).
  • Known limits (disclosed): no single automated end-to-end test boots a real campaign + worker and asserts a cache hit (the two halves are each unit-proven + share one derivation); the --tui/--web campaign entrypoints don't thread the flag yet (headless leader paths do).

Test plan

  • cargo test --workspace — 32 binaries, 0 failures (korg-runtime 141 lib + keystone + run_once + 9 new SP3 tests)
  • warm boot populates a non-empty cache via real cargo; hermetic when cargo absent (no hang/panic)
  • worker_cargo_env points the worker at the warmed dir when speculative, empty when off
  • --speculative defaults off; flag read end-to-end into the worker spawn
  • fmt + clippy clean on touched code

Stacked on feat/swarm-collaboration (SP2). For review — not for merge ahead of the stack.

Spec: docs/superpowers/specs/2026-06-14-korg-swarm-sp3-warm-boot-design.md

New1Direction and others added 4 commits June 14, 2026 15:25
…metic, timeout-guarded)

New execution/warm_boot.rs: warm_target_dir(session) derives a STABLE shared
cargo target dir under the OS cache dir; warm_boot(session, repo, enabled) runs
cargo check into it with CARGO_TARGET_DIR set, wrapped in a 60s tokio timeout +
cargo-presence guard. Disabled -> Skipped (no dir); success -> Warmed (cache
non-empty = structural reuse proof); cargo-absent/spawn-fail/timeout ->
Unavailable, never hang/panic/abort. Deprecate the dag.rs speculative_warm_boot
no-op with a doc note pointing at the real mechanism.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ARGET_DIR)

Pure worker_cargo_env(session_id, speculative) returns the CARGO_TARGET_DIR pair
(== warm_target_dir(session)) under speculative, empty otherwise — the testable
anti-theater link. SubprocessBackend::spawn applies it to the worker Command, so
the live worker's observation::cargo_check (which honors CARGO_TARGET_DIR) reuses
the warmed cache. SessionSpec gains session_id + speculative; RuntimeCoordinator
carries an AtomicBool speculative flag (set_speculative/speculative) the leader
flips through its Arc, and spawn_worker_process reads both onto the spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ult off)

Adds clap --speculative to Cli (mirrors --inject-stress), threaded into the
leader via set_speculative(bool) which flips both the leader flag and the runtime
coordinator's AtomicBool (so spawned workers inherit CARGO_TARGET_DIR). The
campaign calls maybe_warm_boot() before dispatch in run_full_campaign and
run_observable_campaign: speculative on -> warm_boot(session, cwd, true) populates
the shared cache; off -> no-op (Skipped), unchanged path. Leader tests assert
speculative defaults off (leader + coordinator) and that set_speculative
propagates to the coordinator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
New1Direction added a commit that referenced this pull request Jun 15, 2026
…er reuses)

Lands the stacked branch 'feat/swarm-warm-boot' (PR #14) onto main.
@New1Direction

Copy link
Copy Markdown
Owner Author

Landed on main via the full stack merge — main is now 0eaefb4. This branch's commits are fully contained in main (GitHub: 'no new commits between main and this branch'), recorded by merge commit 0eaefb4 ("Merge PR #14"). Closing as merged-by-stack; deleting the now-redundant branch.

@New1Direction New1Direction deleted the branch feat/swarm-collaboration June 15, 2026 00:22
@New1Direction New1Direction deleted the feat/swarm-warm-boot branch June 15, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant