{"record":{"id":"263f45dbaa99a578","repo":"abhigyanpatwari/GitNexus","slug":"managed-command-failed-state-exit-returncode","errorCode":null,"errorMessage":"managed command failed ({state}, exit={returncode}): {detail}","messagePattern":"managed command failed \\((.+?), exit=(.+?)\\): (.+?)","errorType":"exception","errorClass":"ManagedProcessError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/evolution.py","lineNumber":394,"sourceCode":"    overlay = overlay.expanduser().absolute()\n    expected_clone = Path(os.path.abspath(worktree.expanduser()))\n    sandbox_clone = Path(os.path.abspath(sandbox.clone.expanduser()))\n    if sandbox_clone != expected_clone:\n        raise ValueError(\"candidate sandbox does not bind the requested clone\")\n    digest, payload = candidate_overlay_payload(overlay)\n    relative_paths: list[str] = []\n    for relative, content in payload:\n        _replace_regular_file(worktree, relative, content)\n        relative_paths.append(relative.as_posix())\n\n    mkdir_command = [\"/bin/mkdir\", \"-p\", f\"{SANDBOX_TMP}/wfbench-empty-hooks\"]\n    mkdir_result = sandbox.run(\n        mkdir_command,\n        timeout=60,\n        env=build_sandbox_environment(),\n    )\n    if not mkdir_result.ok:\n        raise ManagedProcessError(mkdir_command, mkdir_result)\n\n    command, added = _sandbox_overlay_git(sandbox, [\"add\", \"--\", *relative_paths])\n    if not added.ok:\n        raise ManagedProcessError(command, added)\n    command, changed = _sandbox_overlay_git(\n        sandbox,\n        [\"diff\", \"--cached\", \"--quiet\", \"--no-ext-diff\", \"--no-textconv\", \"--\"],\n    )\n    if changed.returncode == 0:\n        raise ValueError(\"candidate overlay is byte-identical to the incumbent skills\")\n    if changed.returncode != 1:\n        raise ManagedProcessError(command, changed)\n\n    command, committed = _sandbox_overlay_git(\n        sandbox,\n        [\n            \"commit\",\n            \"--quiet\",","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/evolution.py#L376-L412","documentation":"Thrown as ManagedProcessError in apply_candidate_overlay (evolution.py:394) when the in-sandbox '/bin/mkdir -p /tmp/wfbench-empty-hooks' command does not finish cleanly. ManagedProcessError (process_control.py) formats state+returncode+detail (or the last 1000 bytes of stderr). result.ok is true only when state=='exited' and returncode==0, so any other terminal state — timeout, forced-kill, spawn-failure, ownership-failure — raises.","triggerScenarios":"The sandbox cannot spawn the mkdir: bwrap/PID-namespace ownership absent, the spawn fails, the command times out (60s), or mkdir exits non-zero. The detail field distinguishes which: 'spawn-failure', 'ownership-failure', 'timeout', 'forced-kill', or the captured stderr.","commonSituations":"bwrap not installed or preflight not run; sandbox helper (socat) missing; sandbox environment misbuilt so /bin or /tmp is not bound; running on a non-Linux host where Bubblewrap cannot establish the PID namespace.","solutions":["Run preflight_bubblewrap() and require_claude_sandbox_helpers() first to surface the exact missing primitive.","Inspect err.result.state and err.result.stderr_tail to identify spawn/ownership/timeout.","Ensure /bin/mkdir and /tmp are available inside the sandbox bind set (check build_sandbox_environment / mount args).","Run on a Linux host with Bubblewrap installed."],"exampleFix":"# before: call apply without preflight -> opaque 'spawn-failure'\napply_candidate_overlay(overlay, worktree, sandbox=sandbox)\n\n# after: preflight and inspect the managed result\nfrom workflow_bench.proposer_sandbox import preflight_bubblewrap, require_claude_sandbox_helpers\nfrom workflow_bench.process_control import ManagedProcessError\npreflight_bubblewrap()\nrequire_claude_sandbox_helpers()\ntry:\n    apply_candidate_overlay(overlay, worktree, sandbox=sandbox)\nexcept ManagedProcessError as exc:\n    print(exc.result.state, exc.result.returncode, exc.result.stderr_tail[-500:])\n    raise","handlingStrategy":"try-catch","validationCode":"from workflow_bench.proposer_sandbox import preflight_bubblewrap, require_claude_sandbox_helpers\n\ndef sandbox_preflight_ok() -> bool:\n    try:\n        preflight_bubblewrap()\n        require_claude_sandbox_helpers()\n        return True\n    except Exception:\n        return False","typeGuard":"from workflow_bench.process_control import ManagedProcessError, ManagedProcessResult\n\ndef is_managed_failure(exc: BaseException) -> bool:\n    return isinstance(exc, ManagedProcessError)","tryCatchPattern":"from workflow_bench.process_control import ManagedProcessError\n\ntry:\n    apply_candidate_overlay(overlay, worktree, sandbox=sandbox)\nexcept ManagedProcessError as exc:\n    res = exc.result\n    print('mkdir failed:', res.state, res.returncode, res.detail or res.stderr_tail[-500:])\n    raise","preventionTips":["Run preflight_bubblewrap() and require_claude_sandbox_helpers() before any overlay apply.","Run on a Linux host with Bubblewrap installed.","Inspect err.result.state/stderr_tail to distinguish spawn vs timeout vs ownership failure."],"tags":["sandbox","process","bwrap","benchmark","mkdir"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}