# gitlab selected-host takeover verification

base: 3e47c1cabc463145e485f1ee02e092832cd45c34
head: ffeeedc47e0c9949c481836b47506a98d8f6bb16

## real provider and glab routing
glab 1.124.0, Linux, disposable checkout, origin=host A, gitlab remote=host B, GL_HOST=B. Hosts are two loopback HTTP GitLab API stubs; tokens are fake fixture values. Real provider and CLI services spawn real glab; requests below are captured at HTTP endpoints. No live GitLab account, UI/client transport, desktop/mobile, macOS or Windows exercised. No render paths changed.

### main
{
  "url": "http://localhost:18922/acme/web/-/merge_requests/7",
  "requests": [
    {
      "host": "B",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7?include_diverged_commits_count=true",
      "token": "fake-B"
    },
    {
      "host": "B",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb?license=false",
      "token": "fake-B"
    },
    {
      "host": "B",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7",
      "token": "fake-B"
    },
    {
      "host": "B",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7",
      "token": "fake-B"
    },
    {
      "host": "B",
      "method": "PUT",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7/merge",
      "token": "fake-B"
    },
    {
      "host": "B",
      "method": "POST",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7/cancel_merge_when_pipeline_succeeds",
      "token": "fake-B"
    }
  ]
}

### final branch
{
  "url": "http://localhost:18921/acme/web/-/merge_requests/7",
  "requests": [
    {
      "host": "A",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7?include_diverged_commits_count=true",
      "token": "fake-A"
    },
    {
      "host": "A",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb?license=false",
      "token": "fake-A"
    },
    {
      "host": "A",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7",
      "token": "fake-A"
    },
    {
      "host": "A",
      "method": "GET",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7",
      "token": "fake-A"
    },
    {
      "host": "A",
      "method": "PUT",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7/merge",
      "token": "fake-A"
    },
    {
      "host": "A",
      "method": "POST",
      "path": "/api/v4/projects/acme%2Fweb/merge_requests/7/cancel_merge_when_pipeline_succeeds",
      "token": "fake-A"
    }
  ]
}

## check:changed through blacksmith
No changes detected, skipping sync (3ms)
blacksmith-check: uploading 7 objects, 5 KiB
No changes detected, skipping sync (4ms)
From https://github.com/pingdotgg/t3code
 * branch              3e47c1cabc463145e485f1ee02e092832cd45c34 -> FETCH_HEAD
$ node scripts/check-changed.ts ⊘ cache disabled
check:changed: 4 files since 3e47c1cabc46

> vp format  pass  0.4s
Checking formatting...

All matched files use the correct format.
Finished in 198ms on 4 files using 4 threads.

> vp lint  pass  1.6s
Found 0 warnings and 0 errors.
Finished in 1.5s on 4 files with 200 rules using 4 threads.

> vp knip 1/2  pass  29.2s

> vp test (5 files)  pass  34.0s

 RUN  v5.0.5 /home/runner/_work/maria-blacksmith/maria-blacksmith-source

 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestCli.legacy.test.ts (14 tests) 26ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts (42 tests) 86ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts (11 tests) 50ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabCli.test.ts (5 tests) 11ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.rateLimit.test.ts (1 test) 14ms

 Test Files  5 passed (5)
      Tests  73 passed (73)
   Start at  10:33:45
   Duration  27.34s (transform 67%, setup 25%, import 8%)


> vp typecheck (10 packages)  pass  34.5s
~/apps/desktop$ tsc --noEmit
~/packages/client-runtime$ tsc --noEmit
~/packages/source-control-definitions$ tsc --noEmit ◉ cache hit, replaying

~/infra/relay$ tsc --noEmit
~/packages/source-control-gitlab$ tsc --noEmit

~/apps/web$ tsc --noEmit

~/apps/mobile$ tsc --noEmit

~/scripts$ tsc --noEmit

~/packages/provider-pi$ tsc --noEmit

~/apps/server$ tsc --noEmit




---
vp run: 1/10 cache hit (10%), 10/10 successful, 1.48s saved. @t3tools/scripts#typecheck not cached because it modified its inputs. (Run `vp run --last-details` for full details)

> vp knip 2/2  pass  40.1s

check:changed summary
  pass  format  0.4s
  pass  lint  1.6s
  pass  knip 1/2  29.2s
  pass  knip 2/2  40.1s
  pass  typecheck (10 packages)  34.5s
  pass  test (5 files)  34.0s
  CI also runs: full test suites, build
  unused patch check skipped: no dependency files changed



## full gitlab package tests through blacksmith
No changes detected, skipping sync (3ms)
No changes detected, skipping sync (4ms)
note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.

 RUN  v5.0.5 /home/runner/_work/maria-blacksmith/maria-blacksmith-source

 ✓  root  packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts (29 tests) 15ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts (42 tests) 45ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts (11 tests) 15ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabCli.test.ts (5 tests) 10ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabSourceControlProvider.test.ts (12 tests) 15ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabSourceControlProvider.git.test.ts (3 tests) 149ms
 ✓  root  packages/source-control-gitlab/src/shared/definition.test.ts (6 tests) 4ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestCli.legacy.test.ts (14 tests) 19ms
 ✓  root  packages/source-control-gitlab/src/server/gitLabDiscovery.test.ts (3 tests) 7ms
 ✓  root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.rateLimit.test.ts (1 test) 11ms

 Test Files  10 passed (10)
      Tests  126 passed (126)
   Start at  10:31:17
   Duration  7.86s (transform 67%, import 17%, setup 14%, tests 1%)



## regressions on main through blacksmith
No changes detected, skipping sync (4ms)
blacksmith-check: uploading 3736 objects, 13680 KiB
No changes detected, skipping sync (3ms)
note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.

 RUN  v5.0.5 /home/runner/_work/maria-blacksmith/maria-blacksmith-source

stdout | packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts > keeps reads and merge on the selected host when glab prefers another remote
[10:31:00.129] ERROR (#1): Error [AssertionError]: expected [ 'other.gitlab.example.test', …(5) ] to deeply equal [ 'gitlab.example.test:8443', …(4) ]
    at /home/runner/_work/maria-blacksmith/maria-blacksmith-source/packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts:80:25 {
  actual: [
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test'
  ],
  expected: [
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443'
  ],
  showDiff: true,
  operator: 'deepStrictEqual',
  [cause]: undefined
}

stdout | packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts > keeps reads and disable-auto-merge on the selected host when glab prefers another remote
[10:31:00.136] ERROR (#14): Error [AssertionError]: expected [ 'other.gitlab.example.test', …(4) ] to deeply equal [ 'gitlab.example.test:8443', …(4) ]
    at /home/runner/_work/maria-blacksmith/maria-blacksmith-source/packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts:80:25 {
  actual: [
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test',
    'other.gitlab.example.test'
  ],
  expected: [
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443',
    'gitlab.example.test:8443'
  ],
  showDiff: true,
  operator: 'deepStrictEqual',
  [cause]: undefined
}

 ❯  root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts (11 tests | 2 failed | 9 skipped) 20ms
   × keeps reads and merge on the selected host when glab prefers another remote 15ms
   × keeps reads and disable-auto-merge on the selected host when glab prefers another remote 4ms
   ↓ gitLabViewerPermissions (2)
     ↓ offers everything to a viewer GitLab says can merge
     ↓ keeps merge, now and later, from a viewer GitLab says cannot
   ↓ getChangeRequest base freshness (4)
     ↓ getChangeRequestPreview preserves merge request fields without fetching project settings
     ↓ getChangeRequestSummary preserves merge request fields without fetching project settings
     ↓ reads a counted divergence as a branch that has fallen behind
     ↓ says nothing at all where GitLab counted nothing
   ↓ optional activity reads (3)
     ↓ reports unauthenticated instead of successful partial activity
     ↓ reports missing-tool instead of successful partial activity
     ↓ keeps comments and commits when optional discussions and reactions fail

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯

 FAIL   root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts > keeps reads and merge on the selected host when glab prefers another remote
AssertionError: expected [ 'other.gitlab.example.test', …(5) ] to deeply equal [ 'gitlab.example.test:8443', …(4) ]

 Test Files  1 failed (1)
      Tests  2 failed | 9 skipped (11)
   Start at  10:30:52
   Duration  7.93s (transform 89%, import 5%, setup 5%)

- Expected
+ Received

  [
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
  ]

 ❯ packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts:80:25

     78|       yield* provider.runAction({ ...reference, action });
     79|
     80|       expect(readHosts).toEqual(Array(5).fill(selectedHost));
       |                         ^
     81|       expect({ url: detail.url, mutatedHosts: mergedHosts }).toEqual({
     82|         url: `https://${selectedHost}/acme/web/-/merge_requests/7`,
 ❯ ~effect/Effect/successCont node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:1422:28
 ❯ ~effect/Effect/evaluate node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/core.ts:585:30
 ❯ FiberImpl.runLoop node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:654:41
 ❯ FiberImpl.evaluate node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:595:23
 ❯ node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5689:9
 ❯ node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5767:19
 ❯ Module.<anonymous> node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5786:5

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL   root  packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts > keeps reads and disable-auto-merge on the selected host when glab prefers another remote
AssertionError: expected [ 'other.gitlab.example.test', …(4) ] to deeply equal [ 'gitlab.example.test:8443', …(4) ]

- Expected
+ Received

  [
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
-   "gitlab.example.test:8443",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
+   "other.gitlab.example.test",
  ]

 ❯ packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts:80:25
     78|       yield* provider.runAction({ ...reference, action });
     79|
     80|       expect(readHosts).toEqual(Array(5).fill(selectedHost));
       |                         ^
     81|       expect({ url: detail.url, mutatedHosts: mergedHosts }).toEqual({
     82|         url: `https://${selectedHost}/acme/web/-/merge_requests/7`,
 ❯ ~effect/Effect/successCont node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:1422:28
 ❯ ~effect/Effect/evaluate node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/core.ts:585:30
 ❯ FiberImpl.runLoop node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:654:41
 ❯ FiberImpl.evaluate node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:595:23
 ❯ node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5689:9
 ❯ node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5767:19
 ❯ Module.<anonymous> node_modules/.pnpm/effect@4.0.5/node_modules/effect/src/internal/effect.ts:5786:5

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯

