Skip to content

[local-test-e2e-code-host-github-offline-worker] test(e2e): code-host-github — offline worker review-feedback polling and auto-merge watcher - #851

Merged
danii1 merged 1 commit into
mainfrom
feature/local-test-e2e-code-host-github-offline-worker
Dec 4, 2026
Merged

danii1 merged 1 commit into
mainfrom
feature/local-test-e2e-code-host-github-offline-worker

Conversation

@danii1

@danii1 danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Why

Task local-test-e2e-code-host-github-offline-worker: test(e2e): code-host-github — offline worker review-feedback polling and auto-merge watcher

The GitHub worker loops had no offline coverage. A worker that opens a PR and then ignores "changes requested", answers the same comment twice, or auto-merges a PR it should hold is a user-facing failure. Only the one-shot devintern auto-merge command and the GitLab worker loops were covered before. This change adds offline tests for review polling and the worker auto-merge watcher.

What changed

  • providers/fake-github-worker-pulls.ts (new):
    • Extends FakeGitHubPulls with the routes a worker calls beyond it: PR create and list, repo metadata, and the base-branch check probe.
    • Also serves reviews, inline review comments, replies and reactions.
    • Head SHA and changed files are read from the local bare remote on every request.
  • providers/fake-github-pulls.ts (small edit):
    • Adds a protected extraRoute hook for subclasses.
    • Exports FAKE_GITHUB_LOGIN.
    • Makes nextCommentId protected.
  • helpers/github-offline-worker.ts (new):
    • Wraps WorkerFixture, with the remote set to https://github.com/e2e-org/fixture.git.
    • Maps that URL to the bare repo through the existing git insteadOf wrapper, and points the API preload at the fake.
    • Sets poll_interval = 1, optional [workspace] auto-merge keys, and branch-head helpers.
  • tests/local/worker-github-review-polling.test.ts (new):
    • Runs an injected task and checks that the worker opens PR fix(pm-desktop): list GitHub App repos via installations #7 on the fake.
    • Adds a bot-authored comment (ignored) and a reviewer's CHANGES_REQUESTED review with an inline comment.
    • Asserts one agent run in review mode, a fast-forward push with no force flag in the git log, and a reaction on the comment.
    • Asserts no repeat run, reaction or push over later polls.
  • tests/local/worker-github-auto-merge.test.ts (new):
    • Positive case: the worker merges its own safe-path PR. The PUT .../merge body carries the head sha and merge_method: squash, and the auto-merged label is applied.
    • Negative case, failing check: no merge, needs-human-review label, status comment.
    • Negative case, deny-path hit: no merge, needs-human-review label, comment names the path.
    • Every case asserts no unexpected 404 routes.
  • docs/coverage/code-host-github.md:
    • The review-polling row is now default.
    • New auto-merge watcher row.
    • The auto-merge Missing text is narrowed.
    • The Priority 5 backlog item is struck through only for review polling.
    • New Test notes entry.

Scope

Included: both gaps, offline only. Excluded: CI repair, conflict resolution and @mention (the rest of Priority 5), and the agent merge-safety review. No product code changed.

Tradeoffs

  • I reused installGitlabGitRewrite for the GitHub git mapping instead of duplicating it. It is host-agnostic despite the name.
  • The fake shells out to git on each request to read the head SHA and file list. That is cheap here and keeps the fake stateless about pushes.
  • The worker never posted a text reply in this scenario, only a reaction. The task text anticipated "replies/reacts", so I asserted the reaction and recorded this as "Observed (unconfirmed intent)" in the coverage row.

Blast Radius

  • The only existing file touched is fake-github-pulls.ts, and the change is additive (a hook that returns undefined by default). Its one consumer, github-auto-merge.test.ts, still passes in the full suite.
  • The new tests only run when packages/code/dist/index.js exists.
  • Each of the three auto-merge tests takes about 8 s; review polling takes about 14 s.

Verification

  • bun run --filter @getdevintern/code build: passed.
  • New tests (both files, run together): 4 pass, 0 fail.
  • bun run --filter @devintern/e2e test (full local suite): 503 pass, 16 skip, 3 todo, 1 fail.
    • The failure is worker-doctor.test.ts, "offers try-first-task on a ready workspace". The received list contains an extra run-foreground step.
    • It reproduces when that file runs alone and looks tied to this host having no service manager, which the recent commit "no service-install step on hosts without a service manager" touches.
    • I did not touch doctor code or that test, but I did not confirm it fails the same way on the base commit.
  • bun run --filter @devintern/e2e typecheck: passed.
  • bun run --filter @devintern/e2e lint: 0 warnings, 0 errors.
  • bun run --filter @devintern/e2e format:check: passed.
  • Repo-wide bun run lint (including knip and the lint ratchet): completed with no reported findings.
  • Not verified: real GitHub API responses. Everything runs against loopback fakes.

🤖 Opened by DevIntern from local-test-e2e-code-host-github-offline-worker

…(e2e): code-host-github — offline worker review-feedback polling and auto-merge watcher
@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: 1725 · Commit: 848a16b66842522d2ac6c630591f42595225f6c7

Verification report

Produced by __verify-1, execution 1 at 848a16b66842522d2ac6c630591f42595225f6c7.

Show artifact
{
  "summary": "Both gaps are covered. The review-polling and auto-merge-watcher tests run a real worker against a loopback GitHub fake. I ran both test files: 4 pass, 0 fail. The e2e typecheck, lint and format:check pass, and the repo-wide lint (knip and the ratchet) shows no failure. I did not re-run the full e2e suite, and I did not re-run the build; dist/index.js already existed. The change is safe because every call is confined to loopback: the fake serves only the routes the product uses, anything else becomes a recorded 404 that the tests assert is empty, and the Git remote is a local bare repo. The base fake only gained a no-op `extraRoute` hook and a `FAKE_GITHUB_LOGIN` export, so the existing github-auto-merge test and its consumers are unaffected.",
  "items": [
    {
      "priority": "low",
      "confidence": "medium",
      "category": "documentation",
      "file": "packages/e2e/tests/local/worker-github-review-polling.test.ts",
      "line": "10",
      "issue": "The header comment and test name say the worker replies on the comment thread, but the test asserts a reaction only, and that the number of worker replies does not grow. The coverage doc correctly records this as 'Observed (unconfirmed intent)'.",
      "evidence": "The test file asserts reactions at lines ~72-80 and workerReplies() only as an unchanged count. The doc row says 'it posted no reply in this scenario'.",
      "suggestion": "Reword the header and test name to say the worker reacts to the comment instead of replying."
    },
    {
      "priority": "info",
      "confidence": "high",
      "category": "testing",
      "file": "packages/e2e/tests/local/worker-github-auto-merge.test.ts",
      "line": "1",
      "issue": "The two test files take about 30 s together, and the negative controls use a fixed 3 s sleep. This is acceptable but slightly slows the default suite.",
      "evidence": "bun test on both files: 4 pass, 0 fail, 29.95s.",
      "suggestion": "None required."
    }
  ],
  "approved": true
}

Auto-review summary

Produced by auto-review, execution 1 at 848a16b66842522d2ac6c630591f42595225f6c7.

Show artifact
{
  "iterations": 0,
  "success": true,
  "finalFeedback": {
    "summary": "This PR adds offline e2e coverage for GitHub worker review polling and the auto-merge watcher. It adds a fake GitHub server, a worker fixture helper, two test files, a small `extraRoute` hook in `FakeGitHubPulls`, and coverage-doc updates. It only touches `packages/e2e`, so no product code or shipped package is affected. The hook defaults to `undefined`, so the existing `github-auto-merge` test keeps its behavior. I checked by grep that the helpers the new code uses exist: `installGitlabGitRewrite` (`gitlab-worker-follow-up.ts:31`), `agentInvocations`, `branchFile`, `waitForSettled`, `workspaceTomlExtra`, `rootPrefix`, `FakeGitHubPulls.writes`, and the `E2E_REVIEW_GREETING` fake-agent handling. I did not run the tests, so the new scenarios themselves are unproven. The remaining issues are a stale header comment, an `AggregateError` that discards the underlying errors, and a few unproven doc and test claims.",
    "items": [
      {
        "priority": "low",
        "confidence": "medium",
        "category": "documentation",
        "file": "packages/e2e/tests/local/worker-github-review-polling.test.ts",
        "line": "1-14",
        "issue": "The header comment says the worker must 'reply on the comment thread'. The test asserts a reaction only and never asserts a reply. The coverage doc says the poller posts no text reply, so the comment contradicts both the test and the doc. The `workerReplies()` assertions only check that the count stays unchanged, and it starts at 0, so they prove nothing.",
        "evidence": "worker-github-review-polling.test.ts header vs the reactions assertions; code-host-github.md says 'it posted no reply in this scenario'",
        "suggestion": "Change the header to say the worker reacts to the addressed comment. Drop the `workerReplies` no-change assertions or add a comment saying they are only a guard."
      },
      {
        "priority": "low",
        "confidence": "medium",
        "category": "testing",
        "file": "packages/e2e/tests/local/worker-github-review-polling.test.ts",
        "line": "57-58",
        "issue": "The test mutates `github.reviewComments[0].user.login` after creating the comment, to fake a bot-authored comment. This is awkward and depends on array order. A bot-comment helper or a `user` parameter on `addReviewComment` would be clearer.",
        "evidence": "pointed: worker-github-review-polling.test.ts:57-58",
        "suggestion": "Add an optional `login` argument to `addReviewComment`."
      },
      {
        "priority": "low",
        "confidence": "medium",
        "category": "code-quality",
        "file": "packages/e2e/helpers/github-offline-worker.ts",
        "line": "108-111",
        "issue": "`dispose()` throws an `AggregateError` with a fixed message. The `afterEach` cleanup only prints `error.message`, so the underlying cleanup failures are lost.",
        "evidence": "pointed: the cleanup loops in both new test files log only `(error as Error).message`",
        "suggestion": "Include the sub-error messages in the `AggregateError` message."
      },
      {
        "priority": "low",
        "confidence": "low",
        "category": "code-quality",
        "file": "packages/e2e/providers/fake-github-worker-pulls.ts",
        "line": "164-175",
        "issue": "The fake's `listPulls` and `reply` paths, and the `since` filtering in `listReviewComments`, are not exercised by assertions. The documented 'no reply' observation means `reply` is dead code in these tests. The coverage doc also lists 'Last reviewed 2026-12-04' and `default` status for scenarios I could not confirm pass.",
        "evidence": "unproven: tests were not run",
        "suggestion": "Remove unused fake routes, or note them as reserved for follow-up scenarios."
      },
      {
        "priority": "info",
        "confidence": "low",
        "category": "testing",
        "file": "packages/e2e/tests/local/worker-github-auto-merge.test.ts",
        "line": "100-112",
        "issue": "The failing-check negative control holds for 3 seconds (`Bun.sleep(3_000)`) and then asserts no merge. This is a time-based negative that could pass before the watcher re-evaluates, though the label wait mostly mitigates it. It also adds roughly 3 s per test.",
        "evidence": "pointed: worker-github-auto-merge.test.ts:106,126",
        "suggestion": "Accept as is, or key the negative off a second watcher poll."
      }
    ],
    "approved": true
  },
  "unresolved": [],
  "stopReason": "approved",
  "commitSha": "848a16b66842522d2ac6c630591f42595225f6c7",
  "history": [
    {
      "iteration": 1,
      "feedback": {
        "summary": "This PR adds offline e2e coverage for GitHub worker review polling and the auto-merge watcher. It adds a fake GitHub server, a worker fixture helper, two test files, a small `extraRoute` hook in `FakeGitHubPulls`, and coverage-doc updates. It only touches `packages/e2e`, so no product code or shipped package is affected. The hook defaults to `undefined`, so the existing `github-auto-merge` test keeps its behavior. I checked by grep that the helpers the new code uses exist: `installGitlabGitRewrite` (`gitlab-worker-follow-up.ts:31`), `agentInvocations`, `branchFile`, `waitForSettled`, `workspaceTomlExtra`, `rootPrefix`, `FakeGitHubPulls.writes`, and the `E2E_REVIEW_GREETING` fake-agent handling. I did not run the tests, so the new scenarios themselves are unproven. The remaining issues are a stale header comment, an `AggregateError` that discards the underlying errors, and a few unproven doc and test claims.",
        "items": [
          {
            "priority": "low",
            "confidence": "medium",
            "category": "documentation",
            "file": "packages/e2e/tests/local/worker-github-review-polling.test.ts",
            "line": "1-14",
            "issue": "The header comment says the worker must 'reply on the comment thread'. The test asserts a reaction only and never asserts a reply. The coverage doc says the poller posts no text reply, so the comment contradicts both the test and the doc. The `workerReplies()` assertions only check that the count stays unchanged, and it starts at 0, so they prove nothing.",
            "evidence": "worker-github-review-polling.test.ts header vs the reactions assertions; code-host-github.md says 'it posted no reply in this scenario'",
            "suggestion": "Change the header to say the worker reacts to the addressed comment. Drop the `workerReplies` no-change assertions or add a comment saying they are only a guard."
          },
          {
            "priority": "low",
            "confidence": "medium",
            "category": "testing",
            "file": "packages/e2e/tests/local/worker-github-review-polling.test.ts",
            "line": "57-58",
            "issue": "The test mutates `github.reviewComments[0].user.login` after creating the comment, to fake a bot-authored comment. This is awkward and depends on array order. A bot-comment helper or a `user` parameter on `addReviewComment` would be clearer.",
            "evidence": "pointed: worker-github-review-polling.test.ts:57-58",
            "suggestion": "Add an optional `login` argument to `addReviewComment`."
          },
          {
            "priority": "low",
            "confidence": "medium",
            "category": "code-quality",
            "file": "packages/e2e/helpers/github-offline-worker.ts",
            "line": "108-111",
            "issue": "`dispose()` throws an `AggregateError` with a fixed message. The `afterEach` cleanup only prints `error.message`, so the underlying cleanup failures are lost.",
            "evidence": "pointed: the cleanup loops in both new test files log only `(error as Error).message`",
            "suggestion": "Include the sub-error messages in the `AggregateError` message."
          },
          {
            "priority": "low",
            "confidence": "low",
            "category": "code-quality",
            "file": "packages/e2e/providers/fake-github-worker-pulls.ts",
            "line": "164-175",
            "issue": "The fake's `listPulls` and `reply` paths, and the `since` filtering in `listReviewComments`, are not exercised by assertions. The documented 'no reply' observation means `reply` is dead code in these tests. The coverage doc also lists 'Last reviewed 2026-12-04' and `default` status for scenarios I could not confirm pass.",
            "evidence": "unproven: tests were not run",
            "suggestion": "Remove unused fake routes, or note them as reserved for follow-up scenarios."
          },
          {
            "priority": "info",
            "confidence": "low",
            "category": "testing",
            "file": "packages/e2e/tests/local/worker-github-auto-merge.test.ts",
            "line": "100-112",
            "issue": "The failing-check negative control holds for 3 seconds (`Bun.sleep(3_000)`) and then asserts no merge. This is a time-based negative that could pass before the watcher re-evaluates, though the label wait mostly mitigates it. It also adds roughly 3 s per test.",
            "evidence": "pointed: worker-github-auto-merge.test.ts:106,126",
            "suggestion": "Accept as is, or key the negative off a second watcher poll."
          }
        ],
        "approved": true
      },
      "addressed": [],
      "commitSha": "848a16b66842522d2ac6c630591f42595225f6c7"
    }
  ]
}

@danii1
danii1 merged commit 5141a0e into main Dec 4, 2026
1 check passed
@danii1

danii1 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Auto-merge: merged (squash) at 848a16b.

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

@danii1
danii1 deleted the feature/local-test-e2e-code-host-github-offline-worker branch December 4, 2026 14:23
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