Skip to content

perf: bootstrap Caido concurrently with the scan start - #1143

Merged
0xallam merged 2 commits into
mainfrom
devin/1787330572-lazy-sandbox-join
Aug 21, 2026
Merged

perf: bootstrap Caido concurrently with the scan start#1143
0xallam merged 2 commits into
mainfrom
devin/1787330572-lazy-sandbox-join

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Session bring-up blocked on the Caido bootstrap (sidecar login + project setup, a couple of seconds of guest-side polling) before the scan could start, even though nothing needs the proxy client until the first proxy tool call. The bootstrap now runs as a task and bring-up returns as soon as the container is up; the client is resolved at first use.

# session_manager.create_or_reuse
caido_client = CaidoBootstrapHandle(
    asyncio.create_task(bootstrap_caido(session, ...), name=f"caido-bootstrap-{scan_id}")
)
# proxy tools
client = await _ctx_client(ctx)   # was: _ctx_client(ctx)

Two things the handle has to get right:

  • get() awaits under asyncio.shield, so one caller's cancellation (a tool timeout) does not cancel the bootstrap everyone else shares.
  • A failed bootstrap no longer kills the scan at bring-up; it surfaces to every get() caller, and the proxy tools degrade to their existing "client unavailable" result. aclose() cancels an in-flight bootstrap or closes the finished client, so the cleanup path stays leak-free either way.

Callers that already stored the bundle's caido_client keep working: aclose() is the only method cleanup used.

Testing

tests/test_caido_handle.py covers resolution, peek() before/after completion, repeated failure propagation, a cancelled caller not cancelling the shared task, and both aclose() paths (in-flight cancel, finished-client close, failed bootstrap swallowed). tests/test_proxy_client.py gains handle-resolution and failed-bootstrap-degrades-to-None cases.

953 tests, ruff, mypy, bandit green.

Link to Devin session: https://app.devin.ai/sessions/b55b94e7b0e6401a9348bcb505c7f91f

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR starts Caido bootstrap concurrently with scan startup and resolves the shared client on first proxy use.

  • Adds a cancellation-shielded bootstrap handle with lifecycle cleanup.
  • Moves partially connected client cleanup around the complete Caido connection and project setup sequence.
  • Updates proxy tools to await bootstrap resolution and degrade gracefully after bootstrap failures.
  • Adds coverage for cancellation, failure propagation, deferred resolution, and cleanup behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
strix/runtime/caido_bootstrap.py The connection attempt now runs inside the cleanup guard, resolving the previously reported partial-client leak.
strix/runtime/caido_handle.py Adds shared bootstrap resolution, cancellation shielding, result inspection, and lifecycle cleanup.
strix/runtime/session_manager.py Starts Caido bootstrap as a named background task and stores its handle in the session bundle.
strix/tools/proxy/tools.py Proxy tools now resolve deferred clients asynchronously and retain their existing unavailable-client behavior after bootstrap failure.
tests/test_caido_bootstrap.py Verifies that cancellation or failure during connection closes the partially initialized client.
tests/test_caido_handle.py Covers deferred resolution, shared-task cancellation shielding, failure propagation, and both cleanup states.
tests/test_proxy_client.py Covers direct clients, bootstrap handles, missing clients, and failed bootstrap degradation.

Reviews (2): Last reviewed commit: "fix: close the Caido client when connect..." | Re-trigger Greptile

Comment thread strix/runtime/caido_handle.py
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

@greptile

@0xallam
0xallam merged commit 1c499c5 into main Aug 21, 2026
3 checks passed
@0xallam
0xallam deleted the devin/1787330572-lazy-sandbox-join branch August 21, 2026 19:10
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