Repository navigation
P3: Sandbox sharing-ratio experiments — E6/E7 on runc + git-daemon substrate - #58
Merged
Merged
Conversation
added 17 commits
July 3, 2026 11:58
P3 is re-scoped to a pure experiments phase measured on runc: the per-sandbox concurrency knee (-> KAGENTI_SANDBOX_CAP) as primary, provisioning ratio N derived from the per-leaf duty cycle. E6 saturation curve + E7 converge contention (which delivers the live mixed-ref converge validation deferred from P2 Task 7) + a light feed-back check at the derived CAP. In-cluster git-daemon load substrate; Kind-dev -> OCP-authoritative; hard correctness gates + reported ratio with a sanity floor. Kata/VM isolation + intra-pod hardening split out to new P4 (#57): the live OCP 4.20 cluster is all m6i.xlarge (no nested KVM), and the ratio baseline does not depend on Kata. Retitles #48 to the P3 experiments scope; folds in #54 as a P3 setup prerequisite; leaves #55/#56 separate. Registers the spec in docs/specs/README.md (P3 planned -> design, adds P4 row). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
10-task TDD plan implementing the P3 spec: env-gated exec-timing hook, E6/E7 analysis functions + structural tests, in-cluster git-daemon substrate, E6/E7 live drivers, setup-kind pool fix (#54), docs, and gated Kind->OCP verification. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Off by default (KAGENTI_EXEC_TIMING=1). Emits one [exec-timing] line per exec to stderr so a C=1 experiment run can sum sandbox-busy time and derive the per-leaf duty cycle. No production behavior change when unset. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…oor) Pure functions the E6 driver uses to turn a concurrency sweep into a recommended KAGENTI_SANDBOX_CAP (the knee), a per-leaf duty cycle, and the derived N ratio, guarded by a CI sanity floor. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…test worktreeConsistent asserts each leaf observed only its own ref's marker (no cross-contamination on a shared pod). The real-Redis test pins the P2 lease invariant: RedisLeaseStore grants at most cap concurrent leases. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Hermetic git:// server seeded with K refs (branch-i/marker.txt=branch-i), reachable pool-wide so mixed-ref converge works across sandboxes without GitHub egress. Wired into the base and OCP kustomizations. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… leases) dispatch_converge posts the P2 repoUrl+ref converge-path envelope; sum_exec_ms totals [exec-timing] ms from a harness pod log; max_leases_across_pool reads the P2 lease sets from Redis; plus gitd URL/wait and pool listing. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Sweeps concurrent converge-leaves against one pinned sandbox, computes the knee (recommended CAP) and the C=1 duty cycle (derived N) via the tested analysis functions, gates on the sanity floor, then verifies the pool never exceeds the derived CAP. Gated by E6_LIVE=1; records to EXPERIMENTS.md. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The script cd's to deploy/knative/ at startup, so the prior ./experiments/src/sharing.ts path did not resolve. Updated to ../../experiments/src/sharing.ts (two levels up to repo root). Verified: npx tsx -e import from ../../experiments/src/sharing.ts prints 'function function function function' for all four exports (detectKnee, dutyCycle, derivedRatio, sanityFloorPass), EXIT:0. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ile) Fires E7_REFS leaves converging distinct refs on one pinned sandbox; hard-gates that each worktree observed only its own ref (the live mixed-ref validation deferred from P2 Task 7) and reports the converge contention profile. Gated by E7_LIVE=1; records to EXPERIMENTS.md. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
A fresh Kind bring-up applied sandbox.yaml (single CR, no pool label, no git), incoherent with KAGENTI_SANDBOX_POOL_SELECTOR. Apply sandbox-pool.yaml and wait for all N pool pods via the common label. Prerequisite for P3's Kind experiments. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Authoritative P3 numbers land in EXPERIMENTS.md (cluster-experiment convention). RESULTS.md left untouched—it is regenerated by the E2 test. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Pool-selector precedence meant KAGENTI_SANDBOX_POD was silently ignored during the saturation curve (E6) and contention measurement (E7) — the harness consulted the pool selector first and never reached the single-pod path, so both experiments measured the full pool rather than one pinned sandbox. Fix 1 (CRITICAL): both drivers now include KAGENTI_SANDBOX_POOL_SELECTOR- on the kubectl set env call that pins the sandbox, ensuring the pool selector is removed before the pin takes effect. The E6 feed-back phase also restores KAGENTI_SANDBOX_POOL_SELECTOR=sh.kagenti.io/sandbox-pool=default when it un-pins; without this, the burst ran with neither pod nor pool set, causing max_leases_across_pool to return 0 and the MAXL<=KNEE check to pass vacuously. Fix 2 (IMPORTANT): add restore_ksvc_env() to lib.sh and install `trap 'restore_ksvc_env' EXIT` in both drivers, placed AFTER the gate check so an ungated SKIP run never issues a kubectl call. Fix 3 (IMPORTANT): guard the `cat "$d"/*.ms` glob in e6 run_rung under set -e; a fully-failed rung now records p95=999999 / thr=0 instead of aborting the script. Fix 4 (MINOR): drop unused `leaseKey` import from experiments/test/e7-converge-contention-structural.test.ts. Fix 5 (MINOR): correct the KAGENTI_SANDBOX_POD comment in service.yaml to note that the pod override only takes effect when the pool selector is unset. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
alpine/git:2.45.2 ships the git client but not the git-daemon binary, so the seed pod CrashLooped with 'git: daemon is not a git command'. Install the git-daemon Alpine subpackage before serving. Caught during P3 live verification. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…uty capture)
Four bugs caught running the drivers on live Kind (none observable via shellcheck
or the ungated no-op path):
- kubectl set env does not support the Knative Service CRD ('no kind Service
registered for serving.knative.dev/v1'). Add set_ksvc_env: read the container
env, mutate by name with jq (preserving the ANTHROPIC_* secretKeyRefs), and
replace the array via a JSON-patch op (mints a fresh revision). Rewire both
drivers + restore_ksvc_env.
- macOS/BSD date has no %N, so 'date +%s%3N' emitted a literal N and broke ms
arithmetic. Add a portable now_ms helper (GNU fast-path, python3 fallback,
second-precision last resort); replace all date +%s%3N.
- E6 duty cycle read exec-timing AFTER the whole sweep, by when Knative had
scaled the C=1 pod to zero (execMs=0 -> derivedRatio threw). Capture at C=1
while that pod is live; drain to zero before the sweep so it is fresh; split
the tsx so the knee is computed independently of duty (guarded, reports NA).
Live Kind: E6 pass=yes (execMs=357, duty=0.027, N~37, knee=4, feed-back PASS).
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
E6 full ladder: no saturation knee below c=16 (throughput still rising, p95 in bound), duty cycle 0.021 => derived N ~48:1 — sandbox busy ~2% of leaf wall. E7: mixed-ref consistency PASS across 6 distinct refs (deferred P2 Task 7 validation, now proven live). Kind = shape/relative per design D5; OCP is authoritative. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…orktree runLeaf's cleanupWorkspace removes each per-leaf worktree on completion, so the driver's post-hoc marker read always found MISSING (this transience is why P2 deferred the live validation). Each E7 leaf reviews marker.txt for pattern branch-i and the marker is exactly branch-i, so a correctly pinned worktree yields verdict FLAGGED; build the worktreeConsistent observations from the saved verdict JSON instead. Live Kind: E7 refs=6 consistent=yes. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
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.
Implements P3 (#48) of the two-tier FS-free epic (#49): the harness→sandbox sharing-ratio experiments, measured on the runc runtime. Kata/VM isolation + intra-pod hardening are split out to a new P4 (#57) — the ratio baseline does not depend on Kata, and the live OCP 4.20 cluster is all
m6i.xlarge(no nested KVM).Spec:
docs/specs/2026-07-03-p3-sandbox-sharing-ratio-experiments-design.md· Plan:docs/superpowers/plans/2026-07-03-p3-sandbox-sharing-ratio-experiments.mdWhat's here
KAGENTI_EXEC_TIMING, off by default) so a C=1 run can measure sandbox duty cycle.KAGENTI_SANDBOX_CAP(the knee) + derived provisioning ratio N (from the C=1 duty cycle). Pure analysis inexperiments/src/sharing.ts(unit-tested); bash driverdeploy/knative/e6-saturation.sh.deploy/knative/gitd.yaml): hermeticgit://repo with K seeded refs, no GitHub egress.e6/e7structural tests, incl. a real-Redis never-over-cap check); authoritative numbers land indeploy/knative/EXPERIMENTS.md.Live verification (Kind
sh-knative,SH_MODEL=claude-haiku-4-5)alpine/gitlacks thegit-daemonbinary;kubectl set envdoesn't support the Knative Service CRD (→set_ksvc_envjq read-modify + JSON-patch, preserving secret refs); macOSdatehas no%N(→ portablenow_ms); E6 duty capture / E7 worktree-read timing vs Knative scale-to-zero andcleanupWorkspace(→ capture at C=1 / derive from verdict).Follow-ups
setup-ocp.shpulls GHCRlatest), so OCP needs this branch's image published first. Kind establishes the direction (very high sharing ratio, no knee ≤16).converge.tsrobustness (P2, out of P3 scope):[ -d $REPO/.git ] || git cloneis not self-healing against a partial/non-git/workspace/repo(a pod killed mid-clone wedges). Recommend a dedicated issue.Assisted-By: Claude Code