Skip to content

[local-make-worker-doctor-try-first-task-e2e-te] Make worker-doctor try-first-task e2e test independent of host service manager - #855

Merged
danii1 merged 1 commit into
mainfrom
feature/local-make-worker-doctor-try-first-task-e2e-te
Dec 4, 2026
Merged

danii1 merged 1 commit into
mainfrom
feature/local-make-worker-doctor-try-first-task-e2e-te

Conversation

@danii1

@danii1 danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

Task local-make-worker-doctor-try-first-task-e2e-te: Make worker-doctor try-first-task e2e test independent of host service manager

The try-first-task e2e test in worker-doctor.test.ts hard-coded ["service", "try-first-task"] as the next steps and read the command at index 1. It also inherited the host environment. buildWorkerDoctorReport swaps service for run-foreground when there is no service manager, as intended since PR #842. On containers and worker sandboxes the first step was therefore run-foreground and the test failed.

What changed

In packages/e2e/tests/local/worker-doctor.test.ts, the test now accepts either service or run-foreground as the first step. It still requires exactly two steps, with try-first-task last. It finds the command by id instead of by index. The rest is unchanged: the command still runs through the devintern shim and still checks that one task is enqueued headless.

Scope

Included: the one failing test. I searched packages/e2e/tests/local for other assertions on a service next step. The only other test that touches this, worker-init-noninteractive.test.ts line 122, already accepts either step. The no-bus test in worker-init-noninteractive.test.ts and the earlier one in worker-doctor.test.ts pin the env explicitly. Excluded: product code in readiness-json.ts and the service-manager detection.

Tradeoffs

I used the host-independent assertion rather than pinning the env. The test therefore doesn't pin which branch it takes, but it passes on both kinds of host. The pinned no-bus case is already covered by the earlier test. No e2e helper was added.

Blast Radius

Test-only change in one file. No product code or other callers are affected.

Verification

  • Built the CLI with bun run --filter @getdevintern/code build.
  • Ran bun test tests/local/worker-doctor.test.ts in packages/e2e: 2 pass, 0 fail. This sandbox has no systemd user bus, so it exercised the run-foreground branch, which failed before. I did not run it on a host with a bus, so the service branch is unverified.
  • bun run typecheck, bun run lint and bun run format completed without reported errors. I only looked at the last lines of their output.
  • Full bun run test in packages/e2e had 512 pass, 1 fail. The failure was a busy worker installs only after its task settles in worker-auto-update.test.ts. That file passes when run alone (4 pass), so it looks like a flake under full-suite load. I did not run the full suite on the base commit, and I did not check whether the flake also happens there.

🤖 Opened by DevIntern from local-make-worker-doctor-try-first-task-e2e-te

… worker-doctor try-first-task e2e test independent of host service manager
@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: 1735 · Commit: 652dc072fea51b2b06fd39ba24bd1977a02203b5

Verification report

Produced by __verify-1, execution 1 at 652dc072fea51b2b06fd39ba24bd1977a02203b5.

Show artifact
{
  "summary": "The change makes the try-first-task e2e test host-independent. The first step may be `service` or `run-foreground`, there must be exactly 2 steps, and the last is `try-first-task`. The command is now found by id instead of index 1. The test still runs the command as written to check that it enqueues the task headless. Blast radius: the diff only touches test code. `readiness-json.ts` and the product behavior are untouched. The sibling test `worker-init-noninteractive.test.ts:122` already accepts either step, and `:83` only asserts that `service` is absent. A grep of tests/local found no other assertion that pins `service`, so no sibling needs the same fix. I did not run the test on a host with a systemd user bus. I did not run the full `bun run test`, typecheck or lint.",
  "items": [
    {
      "priority": "info",
      "confidence": "high",
      "category": "testing",
      "file": "packages/e2e/tests/local/worker-doctor.test.ts",
      "line": "334",
      "issue": "The assertion accepts either `service` or `run-foreground` as the first step, so it can't tell which one the host should produce. It also doesn't pin the bus env.",
      "evidence": "Ran `bun test tests/local/worker-doctor.test.ts`: 2 pass, 0 fail. Ran the try-first-task test alone with `--test-name-pattern`: 1 pass. Both runs were on a host where this sandbox may lack a user bus. The branch is documented in a code comment. A grep for `\"service\"` in tests/local found no other pinned assertions.",
      "suggestion": "Optional: have the earlier test's no-bus env overrides also cover the `run-foreground` case, so each branch is checked deterministically."
    }
  ],
  "approved": true
}

Auto-review summary

Produced by auto-review, execution 1 at 652dc072fea51b2b06fd39ba24bd1977a02203b5.

Show artifact
{
  "iterations": 0,
  "success": true,
  "finalFeedback": {
    "summary": "This is a test-only change. It makes the `worker doctor --json` e2e test accept either `service` or `run-foreground` as the first next step, so the test no longer depends on whether the host has a systemd user bus. I read `serviceStep` and `runForegroundStep` in `readiness-json.ts:250-283`, and they are the only two ids the CLI emits in that position. `try-first-task` is still checked as the second and last step, and its command is still checked and then run. I did not run the test.",
    "items": [
      {
        "priority": "low",
        "confidence": "medium",
        "category": "testing",
        "file": "packages/e2e/tests/local/worker-doctor.test.ts",
        "line": "331-337",
        "issue": "The assertion now accepts either first step, so the test can no longer catch a regression where the host-dependent branch picks the wrong one. A host that has a systemd user bus but gets `run-foreground`, or the reverse, would pass. This is an accepted trade-off for host independence. A deterministic test of each branch lives elsewhere: `runForegroundStep` takes a `reason` argument and could be unit-tested with an injected service-manager check.",
        "evidence": "packages/code/src/lib/observability/readiness-json.ts:250-283 shows the two possible first-step ids. The branch is chosen by the service-manager check (readiness-json.ts:552), which the e2e test does not control.",
        "suggestion": "If there is not already a unit test for each branch (`service` and `run-foreground`), add one so the branch choice is covered deterministically. Optionally, the e2e test could also assert that `run-foreground` has `command === \"devintern worker\"`."
      }
    ],
    "approved": true
  },
  "unresolved": [],
  "stopReason": "approved",
  "commitSha": "652dc072fea51b2b06fd39ba24bd1977a02203b5",
  "history": [
    {
      "iteration": 1,
      "feedback": {
        "summary": "This is a test-only change. It makes the `worker doctor --json` e2e test accept either `service` or `run-foreground` as the first next step, so the test no longer depends on whether the host has a systemd user bus. I read `serviceStep` and `runForegroundStep` in `readiness-json.ts:250-283`, and they are the only two ids the CLI emits in that position. `try-first-task` is still checked as the second and last step, and its command is still checked and then run. I did not run the test.",
        "items": [
          {
            "priority": "low",
            "confidence": "medium",
            "category": "testing",
            "file": "packages/e2e/tests/local/worker-doctor.test.ts",
            "line": "331-337",
            "issue": "The assertion now accepts either first step, so the test can no longer catch a regression where the host-dependent branch picks the wrong one. A host that has a systemd user bus but gets `run-foreground`, or the reverse, would pass. This is an accepted trade-off for host independence. A deterministic test of each branch lives elsewhere: `runForegroundStep` takes a `reason` argument and could be unit-tested with an injected service-manager check.",
            "evidence": "packages/code/src/lib/observability/readiness-json.ts:250-283 shows the two possible first-step ids. The branch is chosen by the service-manager check (readiness-json.ts:552), which the e2e test does not control.",
            "suggestion": "If there is not already a unit test for each branch (`service` and `run-foreground`), add one so the branch choice is covered deterministically. Optionally, the e2e test could also assert that `run-foreground` has `command === \"devintern worker\"`."
          }
        ],
        "approved": true
      },
      "addressed": [],
      "commitSha": "652dc072fea51b2b06fd39ba24bd1977a02203b5"
    }
  ]
}

@danii1
danii1 merged commit e2266da into main Dec 4, 2026
1 check passed
@danii1
danii1 deleted the feature/local-make-worker-doctor-try-first-task-e2e-te branch December 4, 2026 15:22
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Auto-merge: merged (squash) at 652dc07.

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