Skip to content

test(substrate): measure Session latency and the warm-detach window live - #22

Closed
Sertaç Özercan (sozercan) wants to merge 5 commits into
substrate-parity-integrationfrom
substrate-latency-harness
Closed

Sertaç Özercan (sozercan) wants to merge 5 commits into
substrate-parity-integrationfrom
substrate-latency-harness

Conversation

@sozercan

Copy link
Copy Markdown
Member

Stacked on substrate-parity-integration, which is main + #19 + #20. Retarget to main once those merge.

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

  • A new latency mode in scripts/external-substrate-core-e2e.sh (hack/external-substrate-e2e/core/latency.go, latency.sh, latency-report.py).
    • It reuses a passed proof's identity and creates only public profiles, classes, and Tasks.
    • It runs detach (no window) and warm (with a window) scenarios, repeated and with a configurable window.
    • It follows worker Pods live, keeps only timing log lines, and joins them into report.json and summary.md.
    • It never reads Secret data, token hashes, or bootstrap material.
  • A cleanup fix. Tasks that belong to a Session can't finish deleting until their Session is gone. Cleanup now deletes Sessions first through Core's API, using a narrowly scoped account in the run namespace. It also grants the proof's Core TokenReview, which the released chart already has.

Results

Medians, prompt accepted, measured from Task creation:

Scenario Median
Cold start 19.8 s
Resume from Tag 27.8 s
Warm-window follow-up 13.5 s
  • The host was heavily loaded, so absolute numbers are inflated.
  • ADR 0055 validated in 6 of 6 runs. The same Actor, worker Pod, runtime instance, and supervisor boot were reused, with no credential rotation and no new Tag. The window then expired into a Tag, and turn 3 resumed from it.
  • The last two harness fixes (Tag-UID check, Session cleanup ordering) were not re-run in a full measurement. The cleanup fix ran live.

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.
Copilot AI balanced review requested due to automatic review settings November 18, 2026 02:29
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75f633cc-30e9-4871-a110-1185ebafb5b8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +188 to +193
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
Comment on lines +382 to +383
if len(newTags(afterT1, suspended)) == 0 {
l.violate("suspension of %s produced no native Tag", t1.Workspace)
Comment on lines +666 to +667
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; }
@sozercan

Copy link
Copy Markdown
Member Author

Superseded by #32, which has been merged into main. Closing.

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.

2 participants