Skip to content

[local-test-e2e-sandbox-worker-fail-closed-when] test(e2e): sandbox — worker fail-closed when the auto-preferred provider cannot start, and docker failover chain - #853

Merged
danii1 merged 1 commit into
mainfrom
feature/local-test-e2e-sandbox-worker-fail-closed-when
Dec 4, 2026
Merged

danii1 merged 1 commit into
mainfrom
feature/local-test-e2e-sandbox-worker-fail-closed-when

Conversation

@danii1

@danii1 danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

Task local-test-e2e-sandbox-worker-fail-closed-when: test(e2e): sandbox — worker fail-closed when the auto-preferred provider cannot start, and docker failover chain

The worker runs unattended, so a sandbox failure has to fail closed. Worker runs were untested for two cases: AGENT_SANDBOX=auto when the preferred provider (nono) is installed but can't start, and AGENT_SANDBOX=docker in a failover chain whose fallback docker can't wrap.

What changed

  • packages/e2e/tests/local/sandbox-auto-preferred-cannot-start-worker.test.ts (new): runs the real built worker with AGENT_SANDBOX=auto, AGENT_HARNESS=opencode, and a nono stub on PATH that answers --version but fails every run.
    • It asserts the opencode stub never spawns and nono was actually asked to run.
    • The run is recorded as deferred with nono's start error as the reason, the task row goes back to pending, nothing is pushed, and the worker stays up.
  • packages/e2e/tests/local/sandbox-docker-chain-worker.test.ts (new): runs the real worker with AGENT_SANDBOX=docker and chain claude-code,goose.
    • A stub sbx answers detection and prints a usage limit on exec.
    • Docker can't wrap goose, so the test asserts the goose stub never spawns, the task is requeued with a deferred run, and nothing is pushed.
    • The fixture root sits outside the OS temp dir because docker refuses worktrees under it.
  • packages/e2e/docs/coverage/sandbox.md:
    • Added two new Coverage rows before Backlog, each with Status, Evidence, Missing and Last reviewed: 2026-12-04.
    • Narrowed the Missing text on the auto provider selection and docker/native worker-chain rows, and bumped their review dates.
    • Added a Test notes entry. No Backlog item was struck through.

Scope

Only the two gaps, plus their area file. No product code, shared helper, README, coverage matrix, or other area file changed. I did not commit or push.

The "fallback becomes unwrappable after startup" case is still listed as Missing. Whether a notification is raised for the repeated nono start failure is not asserted and is recorded as Missing.

Tradeoffs

  • Deferred, not failed: the nono test asserts what the product does today (deferred and retried), not what it should do. The docs don't say which is intended, so the row records "Observed (unconfirmed intent)".
  • Cost: the docker test needs a fixture root outside the OS temp dir, which adds a little setup.

Blast Radius

  • Changed files: two new test files and one docs file, no exports changed, so knip and the lint ratchet should be unaffected. I did not run repo-wide bun run lint.
  • Retry timing: the nono test relies on the worker deferring after a start failure, as observed in the logs (attempt 2/5, then a 2 minute harness cooldown). A product change to that retry behavior would fail it.

Verification

  • Build: bun run --filter @getdevintern/code build was not run. A built CLI was already present, and I did not rebuild it.
  • New tests: both pass when run on their own with bun test.
  • Full suite: bun run --filter @devintern/e2e test finished with 500 pass, 16 skip, 3 todo and 2 failures. A second full run had 1 failure, the worker-doctor.test.ts test named above. That test also fails when run alone (it errors at a toEqual at worker-doctor.test.ts:331). I did not identify the second failure from the first run, because the output wasn't captured.
  • Base commit: I did not re-run that test on the base commit, so I haven't confirmed it was already failing there.
  • Other gates: typecheck, lint, and format:check for @devintern/e2e all passed.

🤖 Opened by DevIntern from local-test-e2e-sandbox-worker-fail-closed-when

…(e2e): sandbox — worker fail-closed when the auto-preferred provider cannot start, and docker failover chain
@danii1 danii1 added the devintern-authored Pull request written by DevIntern working its own backlog label Dec 4, 2026
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Artifacts & verification

Run: 1726 · Commit: c71aa5c170e5d1011b4d1fc812597320f4a0b5ca

Verification report

Produced by __verify-1, execution 1 at c71aa5c170e5d1011b4d1fc812597320f4a0b5ca.

Show artifact
{
  "summary": "Both gaps are covered. `sandbox-auto-preferred-cannot-start-worker.test.ts` starts a real worker with `AGENT_SANDBOX=auto` and a broken `nono` stub. It asserts the agent never ran, the run is `deferred` with nono's start error, nothing was pushed, and the daemon stays up. `sandbox-docker-chain-worker.test.ts` runs `AGENT_SANDBOX=docker` with a `claude-code,goose` chain. goose is correctly unwrappable: `SBX_AGENT_NAMES` in `packages/agent-harness/src/sandbox/providers/docker.ts:52-57` has no goose entry. I ran both new tests and both passed (2 pass, 21 expects, 1.5s). typecheck, oxlint, format:check and knip all passed. The full e2e suite had 1 failure, `worker-doctor.test.ts` ('offers try-first-task on a ready workspace'). It also fails on the base branch because the host expects the 'service' step and gets 'run-foreground', so it is not caused by this change. The change touches only new test files and `packages/e2e/docs/coverage/sandbox.md`, so nothing else consumes it. The docs update is honest: unconfirmed intent is marked 'Observed (unconfirmed intent)', the old row's Missing text is narrowed, and Last reviewed is 2026-12-04. Two things are left open. The Backlog was not checked for items to strike through. The worker notification on repeated start failure is documented as unasserted.",
  "items": [
    {
      "priority": "info",
      "confidence": "medium",
      "category": "documentation",
      "file": "packages/e2e/docs/coverage/sandbox.md",
      "line": "88",
      "issue": "The task asked to strike through completed `## Backlog` items. The diff shows no Backlog edits, and I did not check whether a matching item exists.",
      "evidence": "The diff has no Backlog hunks; I did not read the Backlog section.",
      "suggestion": "Confirm whether a Backlog entry for these two gaps exists and strike it through if so."
    }
  ],
  "approved": true
}

Auto-review summary

Produced by auto-review, execution 1 at c71aa5c170e5d1011b4d1fc812597320f4a0b5ca.

Show artifact
{
  "iterations": 0,
  "success": true,
  "finalFeedback": {
    "summary": "This PR adds two offline e2e tests for worker sandbox fail-closed behaviour, plus matching coverage-doc updates. It touches no product code, so the blast radius is limited to the e2e suite. The change is safe because every helper it imports exists (`pathWithoutProvider`, `runtimeBinDir`, `stubExecutable`, `createSandboxHome`, `configureFailover`, `invocationCount`, `stubDiagnostics`, and `WorkerFixture` with its methods). I checked this by grepping `packages/e2e/helpers`, which is pointed-level evidence. I did not run the tests, because they need a built CLI. `WorkerFixture.dispose` removes the root, so the docker test's custom root is cleaned up.",
    "items": [
      {
        "priority": "low",
        "confidence": "medium",
        "category": "code-quality",
        "file": "packages/e2e/tests/local/sandbox-auto-preferred-cannot-start-worker.test.ts",
        "line": "1-12",
        "issue": "The header comment says the run \"settles as a visible failure\" and that the test asserts only outcomes that hold \"whichever way the product decides\". The body pins one specific outcome: the task is `pending` with a `deferred` run, an exact `outcome_reason`, and the agent never spawns. The comment misleads anyone who later changes the deferral behaviour.",
        "evidence": "File lines 1-12 versus the assertions around lines 100-122. The coverage doc says the intended outcome is unconfirmed.",
        "suggestion": "Reword the header to say the test pins the observed fail-closed deferral, so a deliberate product change shows up as a test change."
      },
      {
        "priority": "low",
        "confidence": "medium",
        "category": "testing",
        "file": "packages/e2e/tests/local/sandbox-auto-preferred-cannot-start-worker.test.ts",
        "line": "96-100",
        "issue": "The conditional `if (unsandboxed.length > 0) expect(logs).toContain(...)` is dead code. Later `expect(agentSpawns).toEqual([])` and `not.toContain(\"running the agent unsandboxed\")` make it either unreachable or contradictory.",
        "evidence": "Same file, lines 96-100 versus 107-118.",
        "suggestion": "Drop the conditional block and keep the strict assertions."
      },
      {
        "priority": "low",
        "confidence": "low",
        "category": "testing",
        "file": "packages/e2e/tests/local/sandbox-docker-chain-worker.test.ts",
        "line": "68-80",
        "issue": "The test waits for the primary's usage-limit window to be persisted and then for the requeue. It passes on the `deferred` and `usage limit` result without proving the fallback was considered and rejected as unwrappable rather than skipped for some other reason. The goose-never-spawns check cannot tell those two causes apart.",
        "evidence": "Unproven. I did not run the test, and the diff asserts no log line about the unwrappable fallback.",
        "suggestion": "Assert a log or run-reason mention of goose being unsupported by docker, if the product emits one."
      }
    ],
    "approved": true
  },
  "unresolved": [],
  "stopReason": "approved",
  "commitSha": "c71aa5c170e5d1011b4d1fc812597320f4a0b5ca",
  "history": [
    {
      "iteration": 1,
      "feedback": {
        "summary": "This PR adds two offline e2e tests for worker sandbox fail-closed behaviour, plus matching coverage-doc updates. It touches no product code, so the blast radius is limited to the e2e suite. The change is safe because every helper it imports exists (`pathWithoutProvider`, `runtimeBinDir`, `stubExecutable`, `createSandboxHome`, `configureFailover`, `invocationCount`, `stubDiagnostics`, and `WorkerFixture` with its methods). I checked this by grepping `packages/e2e/helpers`, which is pointed-level evidence. I did not run the tests, because they need a built CLI. `WorkerFixture.dispose` removes the root, so the docker test's custom root is cleaned up.",
        "items": [
          {
            "priority": "low",
            "confidence": "medium",
            "category": "code-quality",
            "file": "packages/e2e/tests/local/sandbox-auto-preferred-cannot-start-worker.test.ts",
            "line": "1-12",
            "issue": "The header comment says the run \"settles as a visible failure\" and that the test asserts only outcomes that hold \"whichever way the product decides\". The body pins one specific outcome: the task is `pending` with a `deferred` run, an exact `outcome_reason`, and the agent never spawns. The comment misleads anyone who later changes the deferral behaviour.",
            "evidence": "File lines 1-12 versus the assertions around lines 100-122. The coverage doc says the intended outcome is unconfirmed.",
            "suggestion": "Reword the header to say the test pins the observed fail-closed deferral, so a deliberate product change shows up as a test change."
          },
          {
            "priority": "low",
            "confidence": "medium",
            "category": "testing",
            "file": "packages/e2e/tests/local/sandbox-auto-preferred-cannot-start-worker.test.ts",
            "line": "96-100",
            "issue": "The conditional `if (unsandboxed.length > 0) expect(logs).toContain(...)` is dead code. Later `expect(agentSpawns).toEqual([])` and `not.toContain(\"running the agent unsandboxed\")` make it either unreachable or contradictory.",
            "evidence": "Same file, lines 96-100 versus 107-118.",
            "suggestion": "Drop the conditional block and keep the strict assertions."
          },
          {
            "priority": "low",
            "confidence": "low",
            "category": "testing",
            "file": "packages/e2e/tests/local/sandbox-docker-chain-worker.test.ts",
            "line": "68-80",
            "issue": "The test waits for the primary's usage-limit window to be persisted and then for the requeue. It passes on the `deferred` and `usage limit` result without proving the fallback was considered and rejected as unwrappable rather than skipped for some other reason. The goose-never-spawns check cannot tell those two causes apart.",
            "evidence": "Unproven. I did not run the test, and the diff asserts no log line about the unwrappable fallback.",
            "suggestion": "Assert a log or run-reason mention of goose being unsupported by docker, if the product emits one."
          }
        ],
        "approved": true
      },
      "addressed": [],
      "commitSha": "c71aa5c170e5d1011b4d1fc812597320f4a0b5ca"
    }
  ]
}

@danii1
danii1 merged commit e4055ed into main Dec 4, 2026
1 check passed
@danii1
danii1 deleted the feature/local-test-e2e-sandbox-worker-fail-closed-when branch December 4, 2026 14:36
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Auto-merge: merged (squash) at c71aa5c.

Every changed file is inside the workspace's safe paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merged devintern-authored Pull request written by DevIntern working its own backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant