Skip to content

fix: bound Caido readiness probe by wall-clock deadline, not fixed attempts - #1056

Open
roshanaryal1 wants to merge 2 commits into
usestrix:mainfrom
roshanaryal1:fix/caido-boot-wait-deadline
Open

fix: bound Caido readiness probe by wall-clock deadline, not fixed attempts#1056
roshanaryal1 wants to merge 2 commits into
usestrix:mainfrom
roshanaryal1:fix/caido-boot-wait-deadline

Conversation

@roshanaryal1

Copy link
Copy Markdown

Summary

  • _login_as_guest() in strix/runtime/caido_bootstrap.py retried loginAsGuest a fixed 10 times with capped exponential backoff (~68s total), independent of how long the sandbox actually took to boot Caido.
  • The sandbox entrypoint runs chown -R over a large pre-installed toolchain tree before starting caido-cli on port 48080. On a loaded host or CI runner this is deterministically slow (one report measured ~27 minutes), so scans there fail before a single LLM call is ever made, with a generic curl exit 7 error that reads like a local network problem rather than a slow sandbox boot.
  • Replaced the fixed attempt count with a wall-clock deadline, configurable via a new STRIX_CAIDO_BOOT_WAIT_S setting (default 180s). Fast hosts are unaffected — the loop still returns as soon as Caido is reachable. Slow/shared hosts and CI runners can raise the budget via env var instead of hitting a hardcoded ceiling.
  • The final error message now reports elapsed time and attempt count, not just attempts.

Changes

  • strix/config/settings.py — new RuntimeSettings.caido_boot_wait_s field (STRIX_CAIDO_BOOT_WAIT_S, default 180.0)
  • strix/runtime/caido_bootstrap.py_login_as_guest loops against time.monotonic() deadline instead of range(1, attempts+1); bootstrap_caido gains a boot_wait_s param
  • strix/runtime/session_manager.py — passes load_settings().runtime.caido_boot_wait_s through to bootstrap_caido
  • tests/test_caido_bootstrap.py — new tests: succeeds once Caido comes up mid-retry, and respects the configured deadline (raises with elapsed-time message, not "after N attempts")

Fixes #1036, and should also resolve the GitHub Actions failure in #1037 (same root cause — CI runners are exactly the "loaded host" case the fixed 68s budget can't cover).

Test plan

  • uv run pytest tests/test_caido_bootstrap.py -v — new tests pass
  • uv run pytest tests/ — full suite (888 tests) passes, no regressions
  • uv run ruff check / ruff format --check — clean
  • uv run mypy on changed files — clean
  • Manual repro on a loaded/CI-like host (I don't have access to the reporters' exact slow-boot environments — happy to have them verify, or point me at a way to reproduce a slow chown -R boot locally)

🤖 Generated with Claude Code

…tempts

_login_as_guest() retried loginAsGuest exactly 10 times with capped
exponential backoff (~68s total), regardless of how long the sandbox
actually took to boot Caido. The sandbox entrypoint chowns a large
toolchain tree before starting caido-cli, which can take minutes on a
loaded host or CI runner, so every scan there failed before a single
LLM call was made.

Replace the fixed attempt count with a wall-clock deadline, configurable
via STRIX_CAIDO_BOOT_WAIT_S (default 180s). Fast hosts are unaffected;
slow/shared hosts and CI runners can raise the budget instead of hitting
a hardcoded ceiling. The error message now reports elapsed time and
attempt count instead of just attempts.

Fixes usestrix#1036, usestrix#1037
Copilot AI lite review requested due to automatic review settings August 11, 2026 04:46

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces Caido’s fixed readiness-attempt limit with a configurable monotonic-time budget and threads the new runtime setting through session creation.

  • Adds STRIX_CAIDO_BOOT_WAIT_S with a 180-second default.
  • Converts guest-login retries to deadline-based backoff.
  • Adds tests for eventual readiness and deadline failure diagnostics.

Confidence Score: 4/5

The readiness fix should be adjusted before merging because the configured wall-clock deadline can still be exceeded by the final curl attempt.

The retry loop checks expiration only after a fixed-timeout exec, so a request started near the deadline can keep session creation blocked for almost 15 additional seconds and produce an inaccurate elapsed-time diagnostic.

Files Needing Attention: strix/runtime/caido_bootstrap.py, tests/test_caido_bootstrap.py

Important Files Changed

Filename Overview
strix/runtime/caido_bootstrap.py Implements deadline-based retries, but a fixed per-attempt timeout allows the readiness operation and diagnostic to exceed the configured wall-clock budget.
strix/config/settings.py Adds a positive, environment-configurable Caido startup budget with a 180-second default.
strix/runtime/session_manager.py Correctly passes the resolved runtime startup budget into Caido bootstrap.
tests/test_caido_bootstrap.py Covers retry success and deadline failure, but does not verify a final blocking attempt is bounded by the remaining deadline.

Comments Outside Diff (1)

  1. strix/runtime/caido_bootstrap.py, line 56-66 (link)

    P1 Final attempt exceeds deadline

    When a curl attempt begins shortly before the configured deadline, its fixed 15-second timeout is not capped by the remaining budget, causing session startup to exceed STRIX_CAIDO_BOOT_WAIT_S while the error reports only the shorter configured duration.

    Knowledge Base Used: Runtime and Docker Sandbox

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: strix/runtime/caido_bootstrap.py
    Line: 56-66
    
    Comment:
    **Final attempt exceeds deadline**
    
    When a curl attempt begins shortly before the configured deadline, its fixed 15-second timeout is not capped by the remaining budget, causing session startup to exceed `STRIX_CAIDO_BOOT_WAIT_S` while the error reports only the shorter configured duration.
    
    **Knowledge Base Used:** [Runtime and Docker Sandbox](https://app.greptile.com/strix-org-3/-/custom-context/knowledge-base/usestrix/strix/-/docs/runtime-and-docker.md)
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Prompt To Fix All With AI
### Issue 1
strix/runtime/caido_bootstrap.py:56-66
**Final attempt exceeds deadline**

When a curl attempt begins shortly before the configured deadline, its fixed 15-second timeout is not capped by the remaining budget, causing session startup to exceed `STRIX_CAIDO_BOOT_WAIT_S` while the error reports only the shorter configured duration.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix: bound Caido readiness probe by wall..." | Re-trigger Greptile

Greptile review on usestrix#1056: the fixed 15s curl timeout wasn't bounded by
the remaining wall-clock budget, so an attempt starting just before the
deadline could block session creation for up to 15s past
STRIX_CAIDO_BOOT_WAIT_S, and the resulting error would understate the
actual elapsed time.

Move the deadline check to the top of the loop and pass
min(15, remaining) as the per-attempt timeout.
@roshanaryal1

Copy link
Copy Markdown
Author

Good catch — fixed in 21e5ae0: the deadline check now happens before each attempt, and the per-attempt curl timeout is capped to min(15, remaining) so a request starting near the deadline can no longer push session creation past STRIX_CAIDO_BOOT_WAIT_S. Added a test asserting the capped timeout is passed to session.exec.

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.

loginAsGuest gives up after ~68s: fixed 10-attempt retry too short for slow sandbox boot (chown -R before caido-cli)

2 participants