Repository navigation
test(substrate): measure Session latency and the warm-detach window live - #22
Sertaç Özercan (sozercan) wants to merge 5 commits into
Conversation
Add a latency mode to the actual Core and deployed provider proof: a Job that reuses the passed proof's image and identity to time cold turns, suspension on detach, resume from Tag, and Orka ADR 0055 warm-window follow-ups, with exact-instance evidence that a warm turn reattaches the running Actor. A host script follows worker Pods live, keeps only timing log lines, and joins them into report.json and summary.md.
…orker capture A Session keeps one RuntimeSession UID across turns, so a warm follow-up is checked for a new generation and prompt instead of a new UID. Follow worker Pods as projected boot milestones, read every provider replica, build the measurement client from the checkout, and report the pre-dispatch states and worker boot timeline.
…g count Idle retention collects older workspaces' Tags during a run.
…eir Tasks A Session member Task keeps its frozen authority until Session cleanup records its runtime cleanup receipt, so the documented cleanup stalled on every latency Task. Cleanup now deletes each referenced Session from a run-namespace ServiceAccount that may only read Tasks and delete Sessions, and grants Core the TokenReview its released chart already has.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved bugs can reuse the wrong latency window, misattribute or falsely reject measurements, read prohibited Secret data, and retry indefinitely during API failures.
5 open issues
What changed in this PR
Adds live, multi-turn Session latency measurements to the external Substrate proof harness, covering cold starts, Tag resumes, and ADR 0055 warm-window reuse. It also updates cleanup to retire Sessions before their Tasks.
Changes:
- Adds configurable latency scenarios and checks for warm-instance reuse and eventual suspension.
- Collects timing logs and generates per-phase JSON and Markdown summaries.
- Adds Session cleanup through Core’s API with dedicated permissions and TokenReview support.
| File | Description |
|---|---|
scripts/external-substrate-core-e2e.sh |
Adds the latency command. |
hack/external-substrate-e2e/README.md |
Documents latency runs, evidence, and Session cleanup. |
hack/external-substrate-e2e/core/sessions.go |
Deletes referenced Sessions through Core’s API with bounded retries. |
hack/external-substrate-e2e/core/main.go |
Dispatches measurement and Session-cleanup modes. |
hack/external-substrate-e2e/core/latency.sh |
Runs the measurement Job and collects timing artifacts. |
hack/external-substrate-e2e/core/latency.go |
Implements latency scenarios and lifecycle checks. |
hack/external-substrate-e2e/core/latency-report.py |
Joins timing evidence and summarizes phase durations. |
hack/external-substrate-e2e/core/install.py |
Grants Core permission to create TokenReviews. |
hack/external-substrate-e2e/core/cleanup.sh |
Deletes Sessions before Tasks and guards against active measurements. |
Review effort: Balanced
| pool = (snapshot.get('runtimePool') or {}) | ||
| stopped = [entry for entry in find(core, 'ACP workspace runtime stopped', sequence=sequence) if entry.get('action') == 'suspend'] | ||
| stopped = [entry for entry in stopped if not pool or entry.get('runtimePool', '').startswith('acp-ws')] | ||
| workspace_stopped = find(provider, 'Substrate runtime stopped', workspaceName=event['workspace'], sequence=sequence) | ||
| pools = {entry.get('runtimePool') for entry in workspace_stopped if entry.get('runtimePool')} | ||
| stopped = [entry for entry in stopped if not pools or entry.get('runtimePool') in pools] |
| s.Pool = map[string]any{"uid": string(pool.GetUID()), "specDesiredReplicas": specReplicas, "desiredReplicas": desired, "currentReplicas": current, | ||
| "lifecycle": str(pool, "status", "lifecycle"), "admissionState": str(pool, "status", "admissionState"), | ||
| "activeInstance": str(pool, "status", "activeInstance", "runtimeInstanceID"), "bootID": str(pool, "status", "activeInstance", "bootID")} | ||
| var secrets corev1.SecretList |
| if len(newTags(afterT1, suspended)) == 0 { | ||
| l.violate("suspension of %s produced no native Tag", t1.Workspace) |
| if err := l.c.Get(ctx, client.ObjectKey{Namespace: l.namespace, Name: name}, existing); err == nil { | ||
| return nil |
| start="$(date +%s)" | ||
| status=0 | ||
| while true; do | ||
| current="$(kubectl -n "${client_namespace}" --request-timeout=15s get job "${job_name}" -o json)" || { sleep 2; continue; } |
|
Superseded by #32, which has been merged into |

Why
The Core proof runs one Task. Choosing the next Substrate latency work needs live per-phase numbers for a multi-turn Session: a cold start, a resume from Tag, and a follow-up inside the ADR 0055 warm window. ADR 0055 also needed live validation.
What
latencymode inscripts/external-substrate-core-e2e.sh(hack/external-substrate-e2e/core/latency.go,latency.sh,latency-report.py).detach(no window) andwarm(with a window) scenarios, repeated and with a configurable window.report.jsonandsummary.md.Results
Medians, prompt accepted, measured from Task creation: