:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): run the desktop cloud-task bootstrap in the background (#105298)
Alessandro Pogliaghif03310593073
diff --git a/docs/internal/cloud-task-sandbox.md b/docs/internal/cloud-task-sandbox.mdindex 793bdca5283f..dbf3d945d7bc 100644--- a/docs/internal/cloud-task-sandbox.md+++ b/docs/internal/cloud-task-sandbox.md@@ -27,6 +27,9 @@ Poll `/tmp/posthog-preview/status.json` until `state` is `ready` or `failed`:`pnpm install --frozen-lockfile --prefer-offline` links from the prebaked pnpm store, and Playwright Chromium is preinstalled.Product and Storybook builds still run from source.+In `products/desktop`, the backend starts `pnpm bootstrap:cloud-task` in the background while the agent boots.+Run `pnpm bootstrap:cloud-task:wait` there before any other `pnpm` command, so a second install does not race it.+## TestsScope every run to what you changed, with `hogli test --changed` or the test files that cover the touched code.diff --git a/products/desktop/AGENTS.md b/products/desktop/AGENTS.mdindex 20be6fe71cbd..80912c5d00bd 100644--- a/products/desktop/AGENTS.md+++ b/products/desktop/AGENTS.md@@ -208,6 +208,7 @@ await boot(container);- `pnpm install`: install dependencies.- `pnpm bootstrap:cloud-task`: link dependencies from the prebaked pnpm store without running unrelated app install hooks, then build the packages required before scoped typechecks in cloud tasks.+- `pnpm bootstrap:cloud-task:wait`: in a cloud task, the backend already started `bootstrap:cloud-task` in the background. Run this before any other `pnpm` command here, so a second install does not race it. Exit code 2 means nothing was started, so run `pnpm bootstrap:cloud-task` yourself.- `pnpm dev`: run agent watch and desktop app.- `pnpm build`: build all packages.- `pnpm typecheck`: typecheck all packages.diff --git a/products/desktop/package.json b/products/desktop/package.jsonindex e764a3d38b01..072b608b1113 100644--- a/products/desktop/package.json+++ b/products/desktop/package.json@@ -11,6 +11,7 @@"preinstall": "node scripts/enforce-pnpm.mjs","postinstall": "bash scripts/ensure-phrocs.sh --update","bootstrap:cloud-task": "pnpm install --frozen-lockfile --prefer-offline --ignore-scripts && pnpm build:deps",+ "bootstrap:cloud-task:wait": "sh scripts/wait-cloud-task-bootstrap.sh","dev": "node scripts/dev-with-skills.mjs pnpm dev:app","dev:app": "pnpm build:deps && bash scripts/ensure-phrocs.sh && bin/phrocs --config mprocs.yaml","dev:mprocs": "node scripts/dev-with-skills.mjs pnpm dev:app:mprocs",diff --git a/products/desktop/scripts/wait-cloud-task-bootstrap.sh b/products/desktop/scripts/wait-cloud-task-bootstrap.shnew file mode 100755index 000000000000..e310b34fa41e--- /dev/null+++ b/products/desktop/scripts/wait-cloud-task-bootstrap.sh@@ -0,0 +1,33 @@+#!/bin/sh+# Blocks until the backend-launched `pnpm bootstrap:cloud-task` finishes, then exits with its code.+# The state directory is written by _prepare_posthog_desktop_cloud_task in+# products/tasks/backend/temporal/process_task/activities/provision_sandbox.py.+set -eu++STATE_DIR=${POSTHOG_DESKTOP_BOOTSTRAP_STATE_DIR:-/tmp/posthog-desktop-bootstrap}+# Longer than the backend build deadline plus its kill grace, so a hung build reports exit 124.+TIMEOUT_SECONDS=${POSTHOG_DESKTOP_BOOTSTRAP_WAIT_SECONDS:-960}++if [ ! -f "$STATE_DIR/started" ]; then+ echo "No background Desktop bootstrap in this sandbox. Run: pnpm bootstrap:cloud-task" >&2+ exit 2+fi++waited=0+while [ ! -f "$STATE_DIR/exit" ]; do+ if [ "$waited" -ge "$TIMEOUT_SECONDS" ]; then+ echo "Desktop bootstrap still running after ${TIMEOUT_SECONDS}s. Log: $STATE_DIR/log" >&2+ exit 124+ fi+ sleep 1+ waited=$((waited + 1))+done++code=$(cat "$STATE_DIR/exit")+elapsed=$(($(date -r "$STATE_DIR/exit" +%s) - $(cat "$STATE_DIR/started")))+if [ "$code" -ne 0 ]; then+ tail -n 40 "$STATE_DIR/log" >&2+ echo "Desktop bootstrap failed with exit code $code after ${elapsed}s. Run: pnpm bootstrap:cloud-task" >&2+ exit "$code"+fi+echo "Desktop bootstrap finished in ${elapsed}s."diff --git a/products/tasks/backend/temporal/execute_sandbox/workflow.py b/products/tasks/backend/temporal/execute_sandbox/workflow.pyindex 14e223d13a43..72cf65d81669 100644--- a/products/tasks/backend/temporal/execute_sandbox/workflow.py+++ b/products/tasks/backend/temporal/execute_sandbox/workflow.py@@ -23,7 +23,7 @@ from temporalio.common import RetryPolicyfrom posthog.temporal.common.base import PostHogWorkflowfrom posthog.temporal.oauth import PosthogMcpScopes-from products.tasks.backend.constants import DEV_STACK_IMAGE_NAME, is_same_run_resume_state+from products.tasks.backend.constants import is_same_run_resume_statefrom products.tasks.backend.error_telemetry import truncate_error_messagefrom products.tasks.backend.logic.services.sandbox import is_public_sandbox_repofrom products.tasks.backend.temporal.constants import (@@ -148,8 +148,6 @@ SHUTDOWN_REJECTION_DETAIL = "child_shutting_down"FOLLOWUP_SOURCE_USER = "user"FOLLOWUP_SOURCE_CI = "ci"-_DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT = timedelta(minutes=20)-@dataclassclass ExecuteSandboxInput:@@ -1164,9 +1162,6 @@ class ExecuteSandboxWorkflow(PostHogWorkflow):checkout_repository = self.context.repositories[0] if len(self.context.repositories) == 1 else Nonewill_checkout = bool(checkout_repository and prepared.branch and has_clone_credentials)- def prepares_desktop(repository: str) -> bool:- return self.context.custom_image_name == DEV_STACK_IMAGE_NAME and repository.casefold() == "posthog/posthog"-if will_clone:await self._emit_progress("clone", "in_progress", "Cloning repository", "setup")await asyncio.gather(@@ -1180,11 +1175,7 @@ class ExecuteSandboxWorkflow(PostHogWorkflow):github_token=prepared.github_token,shallow_clone=prepared.shallow_clone,),- start_to_close_timeout=(- _DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT- if prepares_desktop(repository)- else timedelta(minutes=5)- ),+ start_to_close_timeout=timedelta(minutes=5),retry_policy=RetryPolicy(maximum_attempts=3),)for repository in repositories_to_clone@@ -1198,7 +1189,6 @@ class ExecuteSandboxWorkflow(PostHogWorkflow):if will_checkout and not is_resume:assert checkout_repository is not Noneassert prepared.branch is not None- prepares_repository_desktop = prepares_desktop(checkout_repository)branch_label_active = f"Checking out branch {prepared.branch}"branch_label_done = f"Checked out branch {prepared.branch}"await self._emit_progress("checkout", "in_progress", branch_label_active, "setup")@@ -1213,9 +1203,7 @@ class ExecuteSandboxWorkflow(PostHogWorkflow):shallow_clone=prepared.shallow_clone,used_snapshot=used_snapshot,),- start_to_close_timeout=(- _DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT if prepares_repository_desktop else timedelta(minutes=5)- ),+ start_to_close_timeout=timedelta(minutes=5),retry_policy=RetryPolicy(maximum_attempts=3),)await self._emit_progress("checkout", "completed", branch_label_done, "setup")diff --git a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.pyindex 52e93070652b..090c920f7843 100644--- a/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py+++ b/products/tasks/backend/temporal/process_task/activities/provision_sandbox.py@@ -11,7 +11,6 @@ from django.utils import timezoneimport posthoganalyticsfrom temporalio import activity-from temporalio.exceptions import ApplicationErrorfrom posthog.dataclasses import frozenfrom posthog.models.user_integration import ReauthorizationRequired@@ -184,12 +183,24 @@ class CheckoutBranchInSandboxInput:used_snapshot: bool+# Kept in sync with products/desktop/scripts/wait-cloud-task-bootstrap.sh, which the agent+# runs to block on the build and read its result.+DESKTOP_BOOTSTRAP_STATE_DIR = "/tmp/posthog-desktop-bootstrap"+DESKTOP_BOOTSTRAP_WAIT_SCRIPT = "scripts/wait-cloud-task-bootstrap.sh"+DESKTOP_BOOTSTRAP_TIMEOUT_SECONDS = 15 * 60++def _prepare_posthog_desktop_cloud_task(ctx: TaskProcessingContext, sandbox: SandboxBase, repository: str) -> None:- """Build Desktop workspace exports from the task's checked-out source.+ """Start building Desktop workspace exports from the task's checked-out source.The dev-stack image warms pnpm's content-addressed store but deliberately doesnot retain checkout-specific node_modules or dist directories. Prepare only theinternal PostHog checkout that uses that image, after its final branch is in place.++ The build runs detached so the agent does not wait for it before its first turn.+ Most tasks never touch Desktop, and the ones that do wait on the state directory+ through `pnpm bootstrap:cloud-task:wait`. A failed launch is logged and not raised,+ because the agent can still run the bootstrap itself."""if (not ctx.desktop_workspace_warm_enabled@@ -200,18 +211,43 @@ def _prepare_posthog_desktop_cloud_task(ctx: TaskProcessingContext, sandbox: Sanreturnrepo_path = f"{sandbox_repo_path(repository)}/products/desktop"- emit_agent_log(ctx.run_id, "debug", "Preparing Desktop workspace dependencies")- result = sandbox.execute(- f"cd {shlex.quote(repo_path)} && pnpm bootstrap:cloud-task",- timeout_seconds=10 * 60,+ state_dir = shlex.quote(DESKTOP_BOOTSTRAP_STATE_DIR)+ # `timeout` replaces the deadline the blocking exec used to enforce. Its exit code is+ # renamed into place so the wait script never reads a partial file.+ build = (+ f"timeout -k 30 {DESKTOP_BOOTSTRAP_TIMEOUT_SECONDS} pnpm bootstrap:cloud-task > {state_dir}/log 2>&1 & "+ f"echo $! > {state_dir}/build.pid; wait $!; "+ f"echo $? > {state_dir}/exit.tmp && mv {state_dir}/exit.tmp {state_dir}/exit")+ # Exit 3 skips a branch without the wait script, because its agent cannot wait on the build.+ # A retried clone activity recloned the tree under any running build, so stop that build first.+ # `timeout` leads its own process group, hence the second kill.+ # setsid detaches the build because the sandbox runtime reaps exec children on return.+ launch = (+ f"cd {shlex.quote(repo_path)} || exit 1; "+ f"[ -f {DESKTOP_BOOTSTRAP_WAIT_SCRIPT} ] || exit 3; "+ f"if [ -f {state_dir}/launcher.pid ] && [ ! -f {state_dir}/exit ]; then "+ f'kill -TERM "$(cat {state_dir}/launcher.pid)" 2>/dev/null; '+ f'kill -TERM -- "-$(cat {state_dir}/build.pid 2>/dev/null)" 2>/dev/null; fi; '+ f"rm -rf {state_dir} && mkdir -p {state_dir} && date +%s > {state_dir}/started || exit 1; "+ f"setsid sh -c {shlex.quote(build)} > /dev/null 2>&1 < /dev/null & "+ f"echo $! > {state_dir}/launcher.pid"+ )+ try:+ result = sandbox.execute(launch, timeout_seconds=30)+ except Exception as e:+ logger.warning("desktop_bootstrap_launch_failed", extra={"run_id": ctx.run_id, "error": str(e)})+ return+ if result.exit_code == 3:+ emit_agent_log(ctx.run_id, "debug", "Skipped Desktop workspace preparation: branch has no wait script")+ returnif result.exit_code != 0:- output = (result.stderr or result.stdout)[-2_000:]- raise ApplicationError(- f"Failed to prepare Desktop workspace: {output}",- type="DesktopCloudTaskBootstrapError",- non_retryable=True,+ logger.warning(+ "desktop_bootstrap_launch_failed",+ extra={"run_id": ctx.run_id, "exit_code": result.exit_code, "stderr": result.stderr[-500:]},)+ return+ emit_agent_log(ctx.run_id, "debug", "Started Desktop workspace preparation in the background")@dataclassdiff --git a/products/tasks/backend/temporal/process_task/activities/tests/test_provision_sandbox.py b/products/tasks/backend/temporal/process_task/activities/tests/test_provision_sandbox.pyindex bb2546c56a66..7a2d107347d6 100644--- a/products/tasks/backend/temporal/process_task/activities/tests/test_provision_sandbox.py+++ b/products/tasks/backend/temporal/process_task/activities/tests/test_provision_sandbox.py@@ -2,6 +2,8 @@ import osimport sysimport socketimport asyncio+import subprocess+from pathlib import Pathimport pytest@@ -62,21 +64,94 @@ def _context_for_desktop_bootstrap()-def test_prepares_desktop_workspace_for_posthog_dev_stack_task(mocker):- sandbox = mocker.Mock()- sandbox.config.image_fallback = None- sandbox.execute.return_value = ExecutionResult(stdout="", stderr="", exit_code=0)-- _prepare_posthog_desktop_cloud_task(- _context_for_desktop_bootstrap(),- sandbox,- "PostHog/posthog",+class _ShellSandbox:+ def __init__(self, env: dict[str, str]) -> None:+ self.config = type("Config", (), {"image_fallback": None})()+ self.env = env++ def execute(self, command: str, timeout_seconds: int) -> ExecutionResult:+ result = subprocess.run(["sh", "-c", command], env=self.env, capture_output=True, text=True, timeout=10)+ return ExecutionResult(stdout=result.stdout, stderr=result.stderr, exit_code=result.returncode)+++def desktop_bootstrap_shell(mocker, tmp_path):+ repo = tmp_path / "repo"+ (repo / "products" / "desktop" / "scripts").mkdir(parents=True)+ (repo / "products" / "desktop" / "scripts" / "wait-cloud-task-bootstrap.sh").touch()+ state_dir = tmp_path / "state"+ fake_bin = tmp_path / "bin"+ fake_bin.mkdir()+ pnpm = fake_bin / "pnpm"+ pnpm.write_text(+ f'#!/bin/sh\necho "$@" >> {tmp_path}/calls\n'+ f"while [ ! -f {tmp_path}/release ]; do sleep 0.05; done\n"+ f"exit $(cat {tmp_path}/release)\n")+ pnpm.chmod(0o755)+ mocker.patch.object(provision_sandbox_module, "sandbox_repo_path", return_value=str(repo))+ mocker.patch.object(provision_sandbox_module, "DESKTOP_BOOTSTRAP_STATE_DIR", str(state_dir))+ env = {+ **os.environ,+ "PATH": f"{fake_bin}:{os.environ['PATH']}",+ "POSTHOG_DESKTOP_BOOTSTRAP_STATE_DIR": str(state_dir),+ }+ return _ShellSandbox(env), tmp_path- sandbox.execute.assert_called_once_with(- "cd /tmp/workspace/repos/posthog/posthog/products/desktop && pnpm bootstrap:cloud-task",- timeout_seconds=10 * 60,- )++def _wait_for_desktop_bootstrap(env: dict[str, str]) -> subprocess.CompletedProcess[str]:+ script = Path(__file__).parents[7] / "products/desktop/scripts/wait-cloud-task-bootstrap.sh"+ return subprocess.run(["sh", str(script)], env=env, capture_output=True, text=True, timeout=30)+++ "pnpm_exit_code, build_timeout_seconds, expected_exit_code",+ [(0, 60, 0), (3, 60, 3), (None, 1, 124)],+)+def test_desktop_bootstrap_runs_detached_and_reports_its_exit_code(+ mocker, desktop_bootstrap_shell, pnpm_exit_code, build_timeout_seconds, expected_exit_code+):+ sandbox, tmp_path = desktop_bootstrap_shell+ mocker.patch.object(provision_sandbox_module, "DESKTOP_BOOTSTRAP_TIMEOUT_SECONDS", build_timeout_seconds)++ _prepare_posthog_desktop_cloud_task(_context_for_desktop_bootstrap(), sandbox, "PostHog/posthog")+ assert (tmp_path / "state" / "started").exists()+ if pnpm_exit_code is not None:+ (tmp_path / "release").write_text(str(pnpm_exit_code))+ waited = _wait_for_desktop_bootstrap(sandbox.env)++ assert (tmp_path / "calls").read_text() == "bootstrap:cloud-task\n"+ assert waited.returncode == expected_exit_code, waited.stderr+++def test_desktop_bootstrap_relaunch_replaces_a_running_build(desktop_bootstrap_shell):+ sandbox, tmp_path = desktop_bootstrap_shell++ _prepare_posthog_desktop_cloud_task(_context_for_desktop_bootstrap(), sandbox, "posthog/posthog")+ first_launcher = int((tmp_path / "state" / "launcher.pid").read_text())+ _prepare_posthog_desktop_cloud_task(_context_for_desktop_bootstrap(), sandbox, "posthog/posthog")+ (tmp_path / "release").write_text("0")+ waited = _wait_for_desktop_bootstrap(sandbox.env)++ assert waited.returncode == 0, waited.stderr+ assert (tmp_path / "calls").read_text() == "bootstrap:cloud-task\nbootstrap:cloud-task\n"+ assert not Path(f"/proc/{first_launcher}").exists()+++def test_desktop_bootstrap_skips_a_branch_without_the_wait_script(desktop_bootstrap_shell):+ sandbox, tmp_path = desktop_bootstrap_shell+ (tmp_path / "repo" / "products" / "desktop" / "scripts" / "wait-cloud-task-bootstrap.sh").unlink()++ _prepare_posthog_desktop_cloud_task(_context_for_desktop_bootstrap(), sandbox, "posthog/posthog")++ assert not (tmp_path / "state").exists()+ assert not (tmp_path / "calls").exists()+++def test_wait_for_desktop_bootstrap_reports_when_nothing_was_launched(tmp_path):+ env = {**os.environ, "POSTHOG_DESKTOP_BOOTSTRAP_STATE_DIR": str(tmp_path / "missing")}++ assert _wait_for_desktop_bootstrap(env).returncode == 2@pytest.mark.parametrize(@@ -116,22 +191,19 @@ def test_skips_desktop_workspace_preparation_when_warm_flag_is_off(mocker):sandbox.execute.assert_not_called()-def test_desktop_workspace_preparation_failure_is_non_retryable(mocker):- from temporalio.exceptions import ApplicationError-+ "execute_behavior",+ [+ {"return_value": ExecutionResult(stdout="", stderr="no space left", exit_code=1)},+ {"side_effect": RuntimeError("sandbox exec failed")},+ ],+)+def test_desktop_bootstrap_launch_failure_does_not_fail_the_run(mocker, execute_behavior):sandbox = mocker.Mock()sandbox.config.image_fallback = None- sandbox.execute.return_value = ExecutionResult(stdout="", stderr="build failed", exit_code=1)+ sandbox.execute.configure_mock(**execute_behavior)- with pytest.raises(ApplicationError) as error:- _prepare_posthog_desktop_cloud_task(- _context_for_desktop_bootstrap(),- sandbox,- "posthog/posthog",- )-- assert error.value.non_retryable is True- assert "build failed" in str(error.value)+ _prepare_posthog_desktop_cloud_task(_context_for_desktop_bootstrap(), sandbox, "posthog/posthog")@pytest.mark.parametrize(diff --git a/products/tasks/backend/temporal/process_task/tests/test_workflow.py b/products/tasks/backend/temporal/process_task/tests/test_workflow.pyindex 3a820e929aea..6a35b72d6fa6 100644--- a/products/tasks/backend/temporal/process_task/tests/test_workflow.py+++ b/products/tasks/backend/temporal/process_task/tests/test_workflow.py@@ -2808,59 +2808,11 @@ class TestProcessTaskWorkflowUnit:result = await workflow._get_sandbox_for_repository()assert cloned == ["posthog/posthog", "posthog/code"]- assert clone_options["posthog/posthog"]["start_to_close_timeout"] == timedelta(minutes=20)- assert clone_options["posthog/posthog"]["retry_policy"].maximum_attempts == 3- assert clone_options["posthog/code"]["start_to_close_timeout"] == timedelta(minutes=5)- assert clone_options["posthog/code"]["retry_policy"].maximum_attempts == 3+ for repository in ("posthog/posthog", "posthog/code"):+ assert clone_options[repository]["start_to_close_timeout"] == timedelta(minutes=5)+ assert clone_options[repository]["retry_policy"].maximum_attempts == 3assert result.clone_ms is None- async def test_get_sandbox_for_repository_uses_desktop_budget_for_snapshot_checkout(self, monkeypatch):- workflow = ProcessTaskWorkflow()- workflow._context = _build_context(- github_integration_id=123,- repository="posthog/posthog",- custom_image_name="posthog-dev-stack",- )- prepared = PrepareSandboxForRepositoryOutput(- sandbox_name="sandbox-name",- repository="posthog/posthog",- github_token="ghs_token",- branch="feature-branch",- environment_variables={},- snapshot_id="repo-snapshot-id",- snapshot_external_id=None,- used_snapshot=True,- should_create_snapshot=False,- shallow_clone=True,- image_source="repository_snapshot",- image_source_label="repository snapshot x",- )- created = CreateSandboxForRepositoryOutput(- sandbox_id="sandbox-123",- sandbox_url="https://sandbox.example",- connect_token="connect-token",- )- checkout_options: dict[str, Any] = {}-- async def fake_execute_activity(activity_fn: Any, *args: Any, **kwargs: Any) -> Any:- if activity_fn is prepare_sandbox_for_repository:- return prepared- if activity_fn is create_sandbox_for_repository:- return created- if activity_fn is checkout_branch_in_sandbox:- checkout_options.update(kwargs)- return None- if activity_fn is emit_progress_activity:- return None- raise AssertionError(f"Unexpected activity call: {activity_fn}")-- monkeypatch.setattr(process_task_workflow_module.workflow, "execute_activity", fake_execute_activity)-- await workflow._get_sandbox_for_repository()-- assert checkout_options["start_to_close_timeout"] == timedelta(minutes=20)- assert checkout_options["retry_policy"].maximum_attempts == 3-async def test_overlap_releases_agent_after_primary_clone_and_materializes_failed_secondary(self, monkeypatch):workflow = ProcessTaskWorkflow()workflow._context = _build_context(diff --git a/products/tasks/backend/temporal/process_task/workflow.py b/products/tasks/backend/temporal/process_task/workflow.pyindex 8ed9bc305750..ff5860a13a42 100644--- a/products/tasks/backend/temporal/process_task/workflow.py+++ b/products/tasks/backend/temporal/process_task/workflow.py@@ -17,7 +17,7 @@ from posthog.dataclasses import frozenfrom posthog.temporal.common.base import PostHogWorkflowfrom posthog.temporal.oauth import PosthogMcpScopes-from products.tasks.backend.constants import DEV_STACK_IMAGE_NAME, SNAPSHOT_KIND_FILESYSTEM, is_same_run_resume_state+from products.tasks.backend.constants import SNAPSHOT_KIND_FILESYSTEM, is_same_run_resume_statefrom products.tasks.backend.error_telemetry import truncate_error_messagefrom products.tasks.backend.logic.services.sandbox import is_public_sandbox_repofrom products.tasks.backend.temporal.babysit_pr.prompts import (@@ -369,9 +369,6 @@ _PATCH_ID_EXCLUDE_WIZARD_FROM_BOOT_TOTAL = "tasks-exclude-wizard-from-boot-total# Preserve that command order on replay while new runs can release it after the primary clone._PATCH_ID_AGENT_READY_AFTER_PRIMARY_CLONE = "tasks-agent-ready-after-primary-clone"-# Desktop preparation links a large workspace and writes compiled package outputs. Give-# that non-idempotent work one attempt with a budget larger than its inner 10-minute cap.-_DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT = timedelta(minutes=20)_DEV_STACK_PREVIEW_WAIT_TIMEOUT = timedelta(minutes=15)@@ -2128,9 +2125,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):checkout_repository = self.context.repositories[0] if len(self.context.repositories) == 1 else Nonewill_checkout = bool(checkout_repository and prepared.branch and has_clone_credentials)- def prepares_desktop(repository: str) -> bool:- return self.context.custom_image_name == DEV_STACK_IMAGE_NAME and repository.casefold() == "posthog/posthog"-overlap = bool(self.context.overlap_clone_boot_enabled and will_clone)boot_path = "overlap" if overlap else "classic"launch_ms: int | None = None@@ -2158,7 +2152,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):async def clone_repository(repository: str,) -> tuple[CloneRepositoryInSandboxOutput | None, bool, bool]:- prepares_repository_desktop = prepares_desktop(repository)try:clone_output = await workflow.execute_activity(clone_repository_in_sandbox,@@ -2169,9 +2162,7 @@ class ProcessTaskWorkflow(PostHogWorkflow):github_token=prepared.github_token,shallow_clone=prepared.shallow_clone,),- start_to_close_timeout=(- _DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT if prepares_repository_desktop else timedelta(minutes=5)- ),+ start_to_close_timeout=timedelta(minutes=5),retry_policy=RetryPolicy(maximum_attempts=3),)except Exception as error:@@ -2246,7 +2237,6 @@ class ProcessTaskWorkflow(PostHogWorkflow):if will_checkout and checkout_repository not in failed_repositories and not is_resume:assert checkout_repository is not Noneassert prepared.branch is not None- prepares_repository_desktop = prepares_desktop(checkout_repository)branch_label_active = f"Checking out branch {prepared.branch}"branch_label_done = f"Checked out branch {prepared.branch}"await self._emit_progress("checkout", "in_progress", branch_label_active, "setup", wait=False)@@ -2261,9 +2251,7 @@ class ProcessTaskWorkflow(PostHogWorkflow):shallow_clone=prepared.shallow_clone,used_snapshot=used_snapshot,),- start_to_close_timeout=(- _DESKTOP_BOOTSTRAP_ACTIVITY_TIMEOUT if prepares_repository_desktop else timedelta(minutes=5)- ),+ start_to_close_timeout=timedelta(minutes=5),retry_policy=RetryPolicy(maximum_attempts=3),)# Pre-rollout histories (and mocked tests) recorded a null result here.