← Back to Pull requests

Start a stand-in backend from the recording when a website build begins (R3.11) #2160

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 19, 2026 03:50 UTC
Author

Roadmap item: R3.11, "Start a stand-in backend from a recording automatically when a build begins" (claimed in the first commit).

What changed:

  • A Deep website build whose capture/ holds a recording (capture/original.har, else the first .har by name) builds a stand-in from it into capture/standin/ and serves it before the builder's turn, through the same web_standin_build / web_standin_start tools a builder would call. The feed says where it answers.

  • The builder gets the address in the brief, and in every later message, because the address can change from one run to the next. It's told to point the front end there while it builds and checks, through one development setting whose default stays the original's API. The stand-in only runs during the build.

  • The project keeps the port in craft.json (standin_port, optional, so the format version stays). The next build asks for that port first. If it's busy, the stand-in takes a free one and the feed says so. Only a listen failure falls back, including a saved port refused with a permission error. web_standin_start marks it in its error details (reason: listen_failed). Any other error isn't retried.

  • The run stops the stand-in when it ends: on success, failure, pause or a caught panic. It stops it through a handle (standin_tools::StandIns::stop), not through the tool. That way the stop waits on neither the session lock nor the session's mode, since a switch to Clean room during the build would make web_standin_stop refuse. The run takes charge of a stand-in it started before any feed callback runs: Worker::call_then hands over the start's result before ToolFinished, and the stand-in is stopped if a callback panics before the run holds it. A stand-in that was already serving the same file in the session (one the builder started) is reused and left running.

  • Clean room, non-website targets, captures with no recording, and a coding agent on another computer (which can't reach this computer's loopback) don't get a stand-in. A recording that can't be read is mentioned in the feed and the build goes on without it.

  • Docs: the roadmap line is ticked, with two new - [ ] lines: Play and the app opened outside the build have no stand-in, and a coding agent's own tool server doesn't list the run's stand-in in web_standin_show. STATUS row updated, craft.schema.json regenerated.
  • Verified:

  • New unit tests in rebuild::recorded_backend, using real loopback requests. They cover:

  • - the recorded answer being served
    - the port being kept
    - stopping, including after the session switched to Clean room
    - a stand-in already running in the session being left alone
    - a busy saved port falling back, and the feed naming it
    - an unreadable recording
    - Clean room, other targets and no recording getting nothing
    - how the recording is chosen
    - a feed callback panicking at the start's ToolFinished or at the status leaving nothing running, and a reused stand-in surviving it (red before the fix)
    - only a tagged listen failure falling back (red with the old FileError check); the engine's busy-port test checks the tag
  • New whole-run test (picking_up_a_build::a_website_build_serves_the_recorded_backend_while_it_builds): the follow-up message carries the kept port's address, and nothing is left running after a successful or a failed run. Red before the change: with the start disabled the port isn't kept; with the stop disabled the server is still listed after the run.

  • The brief test covers the address being given when a stand-in runs.

  • cargo test -p craft-anything-ai -p craft-anything-engine --no-fail-fast on macOS. Everything passes except unrelated tests:

  • - three cli_agents timing tests failed under machine load and pass when rerun alone;
    - three macOS-only apple_runtime screenshot/accessibility tests time out in this headless session. This change doesn't touch that module, and CI doesn't run those tests.
  • cargo clippy -p craft-anything-ai -p craft-anything-engine -p craft-anything-ui-egui --all-targets -- -D warnings, cargo fmt --all --check, cargo xtask layers, cargo xtask locks, cargo xtask secrets, cargo xtask schemas --check, cargo xtask tools --check.
  • Not verified: no live Deep website build with a real recorded site and a real front end calling the stand-in (the existing "Live-check a Deep website study's recording" line still covers it). Not run on Windows or Linux.

  • cargo fmt --all --check, cargo clippy -p <crates> --all-targets -- -D warnings,

  • cargo test -p <crates>, cargo xtask layers, cargo xtask secrets
  • Docs in this PR: the roadmap line ticked (and new - [ ] lines for what's left), STATUS if

  • what works changed, cargo xtask tools if tools were added
  • No other tool's code, scripts or wording copied (behaviour only; AGENTS.md)
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

  • New Features

  • - Deep website rebuilds can start a backend from a recorded capture and share its address with the builder.
    - The app can reuse a previously selected port, or choose an available port if that port cannot be used.
    - The running backend’s address and relevant instructions are included in later rebuild messages.
  • Bug Fixes

  • - Backends started for a rebuild are stopped when the run ends, including after a build failure.
    - Backend startup failures are reported without preventing the rebuild from continuing.
    - Rebuild guidance no longer shows stand-in instructions when no recording is available.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mansur-akhmadi Review duration: 17656m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.52) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #2160"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.7% · Safe to merge
    29.7%