Feat: P2 shared sandbox pool with N:M lease-based routing - #53
Merged
Merged
Conversation
added 12 commits
July 2, 2026 22:32
Design for Phase 2 of the two-tier FS-free harness epic (#46): scale Archetype A to N:M leaf-harness→sandbox routing. Locks per-sandbox RWO repo copies (no RWX on the deployable path), harness-side pod selection with Redis expiry-scored leases, ref-pinned lazy converge with per-leaf git worktrees, and a static-N sandbox pool. Registers the spec and updates the P2 registry row (planned -> design). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Seven-task TDD plan implementing the P2 spec (#46): pool pod discovery, Redis lease store, least-loaded selector, ref-pinned converge + worktree, run-leaf wiring, N-pod deploy, and gated live smoke. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
This was referenced Jul 3, 2026
This was referenced Jul 6, 2026
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.
P2 — Shared sandbox pool + harness→sandbox routing
Part of the two-tier FS-free harness epic (#49). Depends on P1 (#45, merged). Implements #46.
Scales Archetype A from one sandbox to a static pool of N single-instance
SandboxCRs: short-lived, fresh-context leaf harnesses load-balance across the pool via Redis leases, each leaf's repo is lazily converged to a pinned git ref, and its work is isolated in a per-leafgit worktree— the harness still touching no filesystem.Spec:
docs/specs/2026-07-02-p2-shared-sandbox-pool-design.md· Plan:docs/superpowers/plans/2026-07-02-p2-shared-sandbox-pool.mdWhat's in it
@sh/k8s-sandbox/pool.ts) — list Running pods by a shared label.harness/sandbox-lease.ts) — per-pod expiry-scored sorted set; atomic Lua acquire (sweep-expired + ZCARD-under-cap); crash reclaim is implicit via TTL.harness/select-sandbox.ts) — picks least-loaded pod under a soft cap, throwsSandboxPoolSaturatedErrorwhen full, falls back to single-pod when no pool selector is set.harness/converge.ts) — shared/workspace/repoobject store (flock-serializedgit fetch) + per-leafgit worktree; shell inputs single-quote-escaped.harness/run-leaf.ts) —LeafEnvelopegainsrepoUrl/ref; select → converge → heartbeat → run →finallycleanup+release, after the verdict fast-path. FS-free contract preserved (all FS viaexec).sandbox-pool.yaml(3 CRs, own RWO PVC each, common pool label,gitin the image),KAGENTI_SANDBOX_POOL_SELECTOR, OCP overlay patched for all pool members.Design decisions (from brainstorm)
Per-sandbox RWO copy (no RWX on the deployable path; RWX documented as the alternative) · harness-side pick + Redis leases (no new deployable component) · ref-pinned lazy converge (eager pre-warm deferred) · static-N pool (config knob). Soft cap. Kata isolation, the ~20:1 ratio, and autoscaling are P3 (#48).
Testing
POOL_LIVE_SMOKE=1):ACQUIRE_LUAcap enforcement + expiry reclaim against real Redis.Follow-ups (non-blocking)
setup-kind.shat the pool manifest (currently the singlesandbox.yaml).503 Retry-Afterper spec §4.3 (async requeue path already correct; sync fails fast, fail-safe).Assisted-By: Claude Code