Skip to content

fix(ci): stop the api integration shard partition rotating every run - #955

Merged
juliopolycarpo merged 9 commits into
mainfrom
fix/952-api-integration-partition
Aug 27, 2026
Merged

juliopolycarpo merged 9 commits into
mainfrom
fix/952-api-integration-partition

Conversation

@juliopolycarpo

@juliopolycarpo juliopolycarpo commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Make the api-integration shard partition reproducible, and give the bug class
it was exposed to an actual detector.

PR #951 took that suite out of isolate mode to dodge Bun's isolate-runner hang,
leaving one lane that is both sharded and unisolated: 101 files sharing a
module graph, split by a timings-balanced partition that rotates every run. A
file's companions changed run to run, so a leak surfaced as an intermittent
failure in a file nobody touched. Separately, the randomized-order nightly — the
only thing in CI meant to catch that class — ran every lane at --parallel=1,
which implies --isolate, so it could not see cross-file leakage at all.

Fixing that second half exposed four real leaks in the first. Additional silent
leakage gaps found during review are tracked separately in #956.

Changes

  • Drop timingsPath from the api-integration lane and the
    --timings/--update-timings flags from its coverage script, so --shard
    falls back to Bun's round-robin over the alphabetical file list — a partition
    every shard derives from the file set alone. The same commit now always splits
    the same way.
  • Add an unisolated api-integration entry to randomized-order-nightly.yml.
    The matrix becomes include-only so each lane carries its own isolation
    setting and path; artifacts and job names key on the lane, since two entries
    now share workspace: api.
  • Fix the order-dependent integration tests the new lane exposed, in four files
    and three shapes: per-user rows under a fixed user id
    (settings-agents, settings-app-settings), one fixture built in beforeAll
    and shared by every test (chat-todos), and a beforeAll seeding user rows
    that a sibling describe consumed (settings-connectors, which failed
    secret_metadata's foreign key and answered 500 on every persisting route).
  • Pin both lane opt-outs and the nightly's isolation settings in
    scripts/tests/, so neither can drift back silently.

Test Plan

  • bun run check passes
  • bun run test passes
  • bun run build passes
  • New UI strings use @mangostudio/shared/i18n (no hardcoded strings)
  • Manually smoke-tested: login, chat creation, image generation

No production application code changed — this is CI topology, test fixes, and
documentation, so the manual smoke path has nothing to exercise.

Measured on Bun 1.4.0, apps/api/tests/integration (101 files, 85.3s total,
--shard=i/8):

Split Critical shard Reproducible
--timings, balanced (rotates) 20.3s no
Round-robin (what the lane now runs) 29.9s yes

+9.6s, and cheap because one file (spawn-runtime-child, 20.3s) is 24% of the
lane and is the floor under any split.

  • Determinism: two consecutive no-timings runs produced byte-identical
    partitions — the stride i-1, i-1+8, … over the sorted paths, union 101
    files, no duplicates.
  • Soak: 48 shard runs across six partitions (two round-robin, four rotated —
    ±20% jitter and 0.5–2×) came back 0 fail. That is the evidence for taking this
    over unsharding the lane, which would cost 85.3s on the critical path.
  • The new nightly lane: before the test fixes, --randomize seeds 1, 2 and
    3 failed 5, 5 and 4 tests in files that are green in the fixed order — the
    detector caught those leaks. After the fixes, all three seeds give 837 pass /
    17 skip / 0 fail. These results do not establish that no silent gaps remain;
    the known follow-ups are listed in bug: three order-dependency holes remain in the unisolated api-integration lane #956.

Screenshots / GIFs

Not applicable; no UI changes.

Notes

Closes #952. Refs #889, #951, #954, #956.

Every test in settings-agents.integration.test.ts persisted per-user rows
into the shared in-memory database — user_app_settings, user_tool_settings,
and the built-in agent overrides a PUT saves — under one fixed user id, and
nothing truncates those rows between tests. Isolation does not cover this:
`--isolate` gives each file a fresh module graph, not each test.

The file was therefore order-dependent, and in one direction it failed. With
"updates built-in default settings per user" running first, its persisted
`default` override is what "synthesizes default from legacy app settings and
enabled tools" then reads, so the assertion on `Legacy chat prompt` got
`Persisted chat prompt`. Reproduced with `bun test --randomize --seed=2`
(also 4, 5 and 6; 1, 3, 7 and 8 were clean) — the failure the randomized-order
nightly has reported on the api lane every night since that workflow landed.

Namespace the rows with a fresh identity per test rather than enumerating the
tables to truncate, so a test that later writes a new one cannot reopen the
hole. All eight probe seeds now pass.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
PR #951 took the api integration suite out of isolate mode to dodge Bun's
isolate-runner hang (oven-sh/bun#39709), leaving one lane that is both
sharded and unisolated. Its 101 files share a module graph, so what a shard
runs a file beside decides what that file inherits: the in-memory database
from setupTestEnvironment(), any mock.module registration, the memoized
getAuth(). The partition deciding those companions came from a timings file
that --update-timings refreshes every run and CI caches across runs, so it
rotated — a leak would surface as an intermittent failure in a file nobody
touched, on a partition nobody could reproduce. #951's own first CI run
already hit the class: shard 3 failed because app.ts snapshotted
getConfig().corsOrigins at module evaluation, so which file imported app
first decided what the CORS gate saw.

Drop the lane's timingsPath and the --timings/--update-timings flags, so
`--shard=i/N` falls back to the round-robin over the alphabetical file list
every shard derives independently from the file set alone. The same commit
now always produces the same partition.

Measured on the lane (Bun 1.4.0, 101 files, 85.3s total, --shard=i/8): the
critical shard goes 20.3s -> 29.9s. Cheap because one file
(spawn-runtime-child, 20.3s) is 24% of the lane and is the floor under any
split, so the balancing had little left to win. Determinism verified rather
than assumed: two consecutive no-timings runs produced byte-identical
partitions, union 101 files, no duplicates.

A soak of 48 shard runs over six partitions — two round-robin and four
rotated, from +/-20% jitter to 0.5-2x — came back 0 fail, which is the
evidence for taking this over unsharding the lane. If the nightly's
unisolated lane ever does go red on cross-file leakage, that escalation is
still available at 85.3s on the critical path instead of 29.9s.

Closes #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
randomized-order-nightly.yml exists for "the one class the merge gate cannot
see: a test that passes only because of what the file before it left behind."
Every lane in it ran with --parallel=1, which means one worker *isolated* —
Bun implies --isolate — so each file got a fresh global and cross-file
leakage was unreachable. The workflow could only ever surface order
dependence inside a single file, and the class it was written for had no
detector anywhere in CI.

That gap is what let the api integration lane rely on a rotating shard
partition for safety rather than on evidence. Give it a detector: the matrix
becomes include-only so each lane carries its own isolation setting and path,
and a new api-integration entry re-runs tests/integration with no --parallel
at all — the mode the merge gate actually uses. Artifacts and the job name
key on the lane rather than the workspace, since two entries now share
`workspace: api`.

scripts/tests/randomized-order-nightly.unit.test.ts pins the two properties
that decide whether the workflow can detect anything: that the unisolated
lane exists, and that it is never quietly handed the --parallel=1 every other
lane takes.

Refs #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
The new randomized-order lane failed 4-5 tests on every seed tried (1, 2, 3),
in three files that are green in the fixed order. `--randomize` reorders `it`
and `describe` blocks within a file as well as the files themselves, so all
three are reachable without any cross-file leakage at all.

settings-app-settings: every test persisted `user_app_settings` under one
fixed user id, so "persists app settings per user" was what "returns defaults
for a new user" read back when the shuffle put them in that order. Fresh
identity per test, and the malformed-JSON row's fixed primary key namespaced
with it.

chat-todos: `insertTestUser`/`insertTestChat` already mint fresh ids per call,
but they were called once in `beforeAll`, so every test shared one chat. The
three todos written by "returns the persisted todo list" were what "returns an
empty list when the chat has no todos" then read. Minting the fixtures in
`beforeEach` is the whole fix.

settings-connectors: `beforeAll` runs per `describe`, and the `openai
connector routes` block seeded `user` rows for two identities it never
authenticates as — both belong to the `openai project-scoped connector routes`
block, which had no `beforeAll` of its own. Scheduled the other way round,
every route there that persists a connector failed `secret_metadata`'s foreign
key and answered 500 (`PRAGMA foreign_keys = ON` is unconditional). Each block
now seeds exactly the identities it uses, through one idempotent helper.

Verified on the full 101-file lane, unisolated: seeds 1, 2 and 3 all give
837 pass / 17 skip / 0 fail, against 5, 5 and 4 failures before.

Refs #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 36654769-ef05-4c83-b9b2-ada1fdc2c158

📥 Commits

Reviewing files that changed from the base of the PR and between 3986a32 and 17c5ee5.

📒 Files selected for processing (12)
  • .github/workflows/randomized-order-nightly.yml
  • apps/api/package.json
  • apps/api/tests/integration/routes/chat-todos.integration.test.ts
  • apps/api/tests/integration/routes/settings-agents.integration.test.ts
  • apps/api/tests/integration/routes/settings-app-settings.integration.test.ts
  • apps/api/tests/integration/routes/settings-connectors.integration.test.ts
  • apps/api/tests/support/connectors/index.ts
  • apps/api/tests/support/factories/index.ts
  • docs/reference/testing.md
  • scripts/lib/test-lanes.ts
  • scripts/tests/randomized-order-nightly.unit.test.ts
  • scripts/tests/test-lanes.unit.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Summary by CodeRabbit

  • Testing

    • Added a dedicated nightly integration-test lane with reproducible, round-robin sharding.
    • Improved test isolation and fixture handling to prevent order-dependent failures.
    • Added regression coverage for nightly workflow configuration, test lanes, and connector mock restoration.
    • Nightly artifacts are now labeled by test lane for easier diagnosis.
  • Documentation

    • Expanded testing guidance for randomized order runs, sharding behavior, isolation, and recently detected failure patterns.

Walkthrough

The PR adds an explicit unisolated api-integration nightly lane. The lane remains sharded but uses deterministic round-robin partitioning instead of timings-based partitioning. The workflow passes lane-specific isolation and path arguments and names artifacts by lane. Integration tests now create per-test identities, chats, and settings rows. Connector tests seed users within their own scopes and restore Gemini mocks. Unit tests validate the workflow and lane configuration.

Sequence Diagram(s)

sequenceDiagram
  participant NightlyWorkflow
  participant TEST_LANES
  participant BunTestRunner
  participant APIIntegrationTests
  NightlyWorkflow->>TEST_LANES: Select api-integration lane
  TEST_LANES->>BunTestRunner: Configure deterministic round-robin shards
  BunTestRunner->>APIIntegrationTests: Run each shard in one shared module graph
Loading

Assessment against linked issues

Objective Addressed Explanation
Make api-integration sharding deterministic while keeping it unisolated [#952] ✅
Remove order-dependent shared state from integration tests [#952] ✅
Avoid re-isolating the lane because of the upstream Bun issue [#952] ✅

Assessment against linked issues: Out-of-scope changes

No out-of-scope functional changes found.

Merge Risk: ⚪ Minimal · up to 17c5e

The change makes API integration sharding reproducible and adds detection for cross-test leakage while fixing the exposed tests. No actionable merge-blocking risk remains beyond normal checks and review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added type: test Test coverage, test infrastructure, or test reliability work. type: ci CI, release, checks, automation, or GitHub workflow changes. area: api Elysia routes, API modules, middleware, or backend services. area: build Binary build, runtime paths, packaging, or standalone output. area: docs Documentation tree, guides, reference docs, or contributor docs. labels Aug 27, 2026
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

PR head: 17c5ee5 • base: 3986a32 • CI run

Commits — 9 commits

Base 3986a32 → head 17c5ee5, oldest first.

  • 1fe5b6a fix(api): give the settings-agents tests a fresh identity per test
  • dced82e fix(ci): stop the api integration shard partition rotating every run
  • efb3a8c ci: soak the unisolated api integration lane in the randomized nightly
  • 2b27d3b fix(api): remove three order dependencies the unisolated nightly exposed
  • 4fa4cb7 fix(test): restore the real gemini module after the connector suite
  • 3f7ea07 refactor(test): mint per-test identities from the shared factories
  • 8855ecb fix(test): seed the user row for the connector blocks that authenticate as TEST_USER
  • d9e1460 test(ci): bind the nightly workflow guards to the lane they claim to check
  • 17c5ee5 fix(ci): carry the job env in the randomized nightly reproduce notice
Full commit messages

1fe5b6a fix(api): give the settings-agents tests a fresh identity per test

fix(api): give the settings-agents tests a fresh identity per test

Every test in settings-agents.integration.test.ts persisted per-user rows
into the shared in-memory database — user_app_settings, user_tool_settings,
and the built-in agent overrides a PUT saves — under one fixed user id, and
nothing truncates those rows between tests. Isolation does not cover this:
`--isolate` gives each file a fresh module graph, not each test.

The file was therefore order-dependent, and in one direction it failed. With
"updates built-in default settings per user" running first, its persisted
`default` override is what "synthesizes default from legacy app settings and
enabled tools" then reads, so the assertion on `Legacy chat prompt` got
`Persisted chat prompt`. Reproduced with `bun test --randomize --seed=2`
(also 4, 5 and 6; 1, 3, 7 and 8 were clean) — the failure the randomized-order
nightly has reported on the api lane every night since that workflow landed.

Namespace the rows with a fresh identity per test rather than enumerating the
tables to truncate, so a test that later writes a new one cannot reopen the
hole. All eight probe seeds now pass.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

dced82e fix(ci): stop the api integration shard partition rotating every run

fix(ci): stop the api integration shard partition rotating every run

PR #951 took the api integration suite out of isolate mode to dodge Bun's
isolate-runner hang (oven-sh/bun#39709), leaving one lane that is both
sharded and unisolated. Its 101 files share a module graph, so what a shard
runs a file beside decides what that file inherits: the in-memory database
from setupTestEnvironment(), any mock.module registration, the memoized
getAuth(). The partition deciding those companions came from a timings file
that --update-timings refreshes every run and CI caches across runs, so it
rotated — a leak would surface as an intermittent failure in a file nobody
touched, on a partition nobody could reproduce. #951's own first CI run
already hit the class: shard 3 failed because app.ts snapshotted
getConfig().corsOrigins at module evaluation, so which file imported app
first decided what the CORS gate saw.

Drop the lane's timingsPath and the --timings/--update-timings flags, so
`--shard=i/N` falls back to the round-robin over the alphabetical file list
every shard derives independently from the file set alone. The same commit
now always produces the same partition.

Measured on the lane (Bun 1.4.0, 101 files, 85.3s total, --shard=i/8): the
critical shard goes 20.3s -> 29.9s. Cheap because one file
(spawn-runtime-child, 20.3s) is 24% of the lane and is the floor under any
split, so the balancing had little left to win. Determinism verified rather
than assumed: two consecutive no-timings runs produced byte-identical
partitions, union 101 files, no duplicates.

A soak of 48 shard runs over six partitions — two round-robin and four
rotated, from +/-20% jitter to 0.5-2x — came back 0 fail, which is the
evidence for taking this over unsharding the lane. If the nightly's
unisolated lane ever does go red on cross-file leakage, that escalation is
still available at 85.3s on the critical path instead of 29.9s.

Closes #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

efb3a8c ci: soak the unisolated api integration lane in the randomized nightly

ci: soak the unisolated api integration lane in the randomized nightly

randomized-order-nightly.yml exists for "the one class the merge gate cannot
see: a test that passes only because of what the file before it left behind."
Every lane in it ran with --parallel=1, which means one worker *isolated* —
Bun implies --isolate — so each file got a fresh global and cross-file
leakage was unreachable. The workflow could only ever surface order
dependence inside a single file, and the class it was written for had no
detector anywhere in CI.

That gap is what let the api integration lane rely on a rotating shard
partition for safety rather than on evidence. Give it a detector: the matrix
becomes include-only so each lane carries its own isolation setting and path,
and a new api-integration entry re-runs tests/integration with no --parallel
at all — the mode the merge gate actually uses. Artifacts and the job name
key on the lane rather than the workspace, since two entries now share
`workspace: api`.

scripts/tests/randomized-order-nightly.unit.test.ts pins the two properties
that decide whether the workflow can detect anything: that the unisolated
lane exists, and that it is never quietly handed the --parallel=1 every other
lane takes.

Refs #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

2b27d3b fix(api): remove three order dependencies the unisolated nightly exposed

fix(api): remove three order dependencies the unisolated nightly exposed

The new randomized-order lane failed 4-5 tests on every seed tried (1, 2, 3),
in three files that are green in the fixed order. `--randomize` reorders `it`
and `describe` blocks within a file as well as the files themselves, so all
three are reachable without any cross-file leakage at all.

settings-app-settings: every test persisted `user_app_settings` under one
fixed user id, so "persists app settings per user" was what "returns defaults
for a new user" read back when the shuffle put them in that order. Fresh
identity per test, and the malformed-JSON row's fixed primary key namespaced
with it.

chat-todos: `insertTestUser`/`insertTestChat` already mint fresh ids per call,
but they were called once in `beforeAll`, so every test shared one chat. The
three todos written by "returns the persisted todo list" were what "returns an
empty list when the chat has no todos" then read. Minting the fixtures in
`beforeEach` is the whole fix.

settings-connectors: `beforeAll` runs per `describe`, and the `openai
connector routes` block seeded `user` rows for two identities it never
authenticates as — both belong to the `openai project-scoped connector routes`
block, which had no `beforeAll` of its own. Scheduled the other way round,
every route there that persists a connector failed `secret_metadata`'s foreign
key and answered 500 (`PRAGMA foreign_keys = ON` is unconditional). Each block
now seeds exactly the identities it uses, through one idempotent helper.

Verified on the full 101-file lane, unisolated: seeds 1, 2 and 3 all give
837 pass / 17 skip / 0 fail, against 5, 5 and 4 failures before.

Refs #952.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

4fa4cb7 fix(test): restore the real gemini module after the connector suite

fix(test): restore the real gemini module after the connector suite

`mock.restore()` does not revert `mock.module()`, so the stubs the
`Gemini aliases API` block installs for `src/services/gemini` stayed
swapped for the rest of the lane. `restoreConnectorProviderMocks()` only
re-registered openai and base-url-policy, so nothing put gemini back.

Under `--randomize` that block can run before the alias route tests in
the same file, which then assert against the stub rather than the route
— a vacuous pass, and the wrong-state failure the unisolated
`api-integration` lane exists to catch.

Captures the whole namespace at module load (`{ ...geminiService }`)
rather than a hand-listed subset: the overrides tests install are
partial, and the route modules bind `InvalidGeminiApiKeyError` and
`GeminiValidationUnavailableError` for `instanceof` checks, so restoring
a subset leaves the same hole in a different shape. `mock.module` on an
already-loaded module merges, so re-registering the full namespace
overwrites every stubbed key back to the real one.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

3f7ea07 refactor(test): mint per-test identities from the shared factories

refactor(test): mint per-test identities from the shared factories

`settings-agents` and `settings-app-settings` each carried their own
`interface TestIdentity` and their own `identitySeq` mint — the same
contract `UserFixture` in tests/support/factories already exports, in a
third and fourth copy. The next suite that needs per-test identities
would have copied a fifth.

`makeTestIdentity(prefix, name)` mints without inserting, which is what
these suites want: their rows are keyed by user id and nothing truncates
the tables in between, so the id is the namespace and the `user` row
itself is never read. The counter is module-level, so ids stay unique
across the files sharing one module graph in the unisolated
`api-integration` lane.

Row ids now suffix `testUser.id` rather than the bare counter, so the
row and the identity that owns it cannot drift apart.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

8855ecb fix(test): seed the user row for the connector blocks that authenticate as TEST_USER

fix(test): seed the user row for the connector blocks that authenticate as TEST_USER

The file's own rule is that every `describe` seeds the identities it
authenticates as, but `settings connectors routes` and `Gemini aliases
API` both authenticate as `TEST_USER` with no `user` row behind it. That
holds only while no route those blocks exercise persists a user-owned
row: the first test added to either that POSTs a connector hits
`secret_metadata`'s foreign key on a missing `user.id` and answers 500 —
reopening the hole the project-scoped block just closed.

`seedUsers` moves to tests/support/factories as `ensureTestUsers`,
next to the `insertTestUser` it was re-implementing. Keeping a private
copy meant a `user` schema change had to land in two places, and missing
the test-only one fails with a NOT NULL violation on an unrelated PR.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

d9e1460 test(ci): bind the nightly workflow guards to the lane they claim to check

test(ci): bind the nightly workflow guards to the lane they claim to check

Two of the five guards were passing for reasons unrelated to what they
assert:

- `covers every workspace that owns a Bun test lane` did a bare
  `toContain('workspace: api')`, which the new integration-only entry
  satisfies on its own. Deleting the whole-workspace `api` lane would
  stop `apps/api/tests/unit` running under randomization while the test
  stayed green. Now asserted against the entries carrying `path: ""`.
- `expect(entry).not.toContain('--parallel')` passed only because the
  comment mentioning `--parallel=1` happens to land inside the *api*
  entry's capture. Moving that paragraph one entry down — a comment
  edit, no behavior change — turned a load-bearing test red. Comments
  are now stripped before the assertions read the entry.

Extraction moves onto `extractStepBlocksAtIndent`, the helper every other
workflow policy test in this directory uses, instead of a second regex
dialect; entries are bounded to the `include:` body so the last one no
longer runs to EOF; the lane is matched on the entry's own first line so
`api` cannot claim `api-integration`'s block by prefix; and the workflow
is read once rather than per test.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

17c5ee5 fix(ci): carry the job env in the randomized nightly reproduce notice

fix(ci): carry the job env in the randomized nightly reproduce notice

The header comment promises each job prints the exact command to
reproduce its own lane, but the notice printed only the `bun test`
flags, dropping the `DATABASE_PATH` and `MANGOSTUDIO_DIAGNOSTIC_LOGS`
the job sets. Pasting it locally ran a different suite than the one that
went red — and for the unisolated `api-integration` lane that notice is
the only record of how to reproduce a leak.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>

📝 Changelog Preview

Entries this branch would add to the changelog on release:

[Unreleased]

🐛 Bug Fixes

  • (ci) Carry the job env in the randomized nightly reproduce notice
  • (test) Seed the user row for the connector blocks that authenticate as TEST_USER
  • (test) Restore the real gemini module after the connector suite
  • (api) Remove three order dependencies the unisolated nightly exposed
  • (ci) Stop the api integration shard partition rotating every run
  • (api) Give the settings-agents tests a fresh identity per test

♻️ Refactor

  • (test) Mint per-test identities from the shared factories

🧪 Testing

  • (ci) Bind the nightly workflow guards to the lane they claim to check

👷 CI

  • Soak the unisolated api integration lane in the randomized nightly
CI duration (wall clock, critical path, slowest jobs)

CI Duration

Report-only timing from the Actions jobs API; runner variance does not affect the gate.
Comparisons cover the jobs both runs share, so main-only stages never skew the baseline.

Metric Base Head Δ
Wall clock (shared jobs) 11m 36s 5h 41m 2s 🔴 ▲ +5h 29m 26s
Critical path Distribution / Build immutable distribution · 2m 28s Distribution / Build immutable distribution · 2m 25s 🟢 ▼ -3s

Since previous PR run: 11m 3s → 5h 41m 2s (🔴 ▲ +5h 29m 59s)

Five slowest head jobs

Job Base Head Δ
Distribution / Build immutable distribution 2m 28s 2m 25s 🟢 ▼ -3s
QA Metrics / Collect 1m 53s 1m 43s 🟢 ▼ -10s
Test / Tests (frontend) 59s 1m 7s 🔴 ▲ +8s
Test / Tests (shard 3/8) 51s 1m 0s 🔴 ▲ +9s
Smoke — Binary / Binary darwin-x64 40s 58s 🔴 ▲ +18s

QA Gate — Coverage & Quality

Base: 3986a32 • Head: 2e2fe6c • generated 2026-08-27T14:14:58.120Z

✅ No attention signals — collected metrics look healthy against base.

LoC (code): 🟢 ▼ -8 • Line coverage (all workspaces): ⚪ ▲ = 0 • Quick check: pass • Duplication: 🟢 ▼ -0.01pp • Bundle gzip: ⚪ ▲ = 0 • Locked deps: ⚪ ▲ = 0 • Tests passed: 🟢 ▲ +6

Metric details (coverage, LoC, bundle, dependencies, tests, duplication, tooling)

Coverage

API/shared/runtime branches and statements are source-derived from LCOV line hits because Bun LCOV does not emit branch or statement records.

Workspace Metric Base Head Δ
frontend lines 82.51% (46,694/56,594) 82.55% (46,693/56,563) 🟢 ▲ +0.04pp
frontend statements 84.08% (12,157/14,459) 84.08% (12,157/14,459) ⚪ ▲ = 0
frontend functions 79.19% (3,284/4,147) 79.19% (3,284/4,147) ⚪ ▲ = 0
frontend branches 56.16% (6,222/11,080) 56.16% (6,222/11,080) ⚪ ▲ = 0
api lines 82.73% (73,770/89,165) 82.69% (73,792/89,234) 🔴 ▼ -0.04pp
api statements 81.92% (29,373/35,854) 81.91% (29,378/35,865) 🔴 ▼ -0.01pp
api functions 83.54% (7,179/8,594) 82.77% (7,080/8,554) 🔴 ▼ -0.77pp
api branches 50.81% (11,153/21,949) 50.84% (11,159/21,949) 🟢 ▲ +0.03pp
shared lines 98.02% (15,619/15,935) 98.02% (15,619/15,935) ⚪ ▲ = 0
shared statements 94.90% (2,736/2,883) 94.90% (2,736/2,883) ⚪ ▲ = 0
shared functions 92.90% (445/479) 92.89% (444/478) 🔴 ▼ -0.01pp
shared branches 60.69% (928/1,529) 60.69% (928/1,529) ⚪ ▲ = 0
runtime lines 82.83% (27,468/33,161) 82.83% (27,472/33,168) ⚪ ▲ = 0
runtime statements 79.74% (9,801/12,291) 79.74% (9,801/12,291) ⚪ ▲ = 0
runtime functions 77.25% (2,007/2,598) 76.99% (1,997/2,594) 🔴 ▼ -0.26pp
runtime branches 49.69% (3,790/7,627) 49.68% (3,789/7,627) 🔴 ▼ -0.01pp

Lines of Code

Workspace Base Head Δ
frontend 760 files / 82,243 lines 760 files / 82,243 lines files ⚪ ▲ = 0 • code ⚪ ▲ = 0
api 1,057 files / 154,168 lines 1,057 files / 154,160 lines files ⚪ ▲ = 0 • code 🟢 ▼ -8
shared 206 files / 29,551 lines 206 files / 29,551 lines files ⚪ ▲ = 0 • code ⚪ ▲ = 0
runtime 836 files / 43,219 lines 836 files / 43,219 lines files ⚪ ▲ = 0 • code ⚪ ▲ = 0
total 2,859 files / 309,181 lines 2,859 files / 309,173 lines files ⚪ ▲ = 0 • code 🟢 ▼ -8

Frontend Bundle

Metric Base Head Δ
gzip total 1.11 MiB 1.11 MiB ⚪ ▲ = 0
gzip JavaScript 1.10 MiB 1.10 MiB ⚪ ▲ = 0
gzip CSS 18.8 KiB 18.8 KiB ⚪ ▲ = 0
gzip HTML 808 B 808 B ⚪ ▲ = 0
tracked files 50 50 ⚪ ▲ = 0

Dependencies

Metric Base Head Δ
locked packages 668 668 ⚪ ▲ = 0
direct dependencies 43 43 ⚪ ▲ = 0
direct devDependencies 36 36 ⚪ ▲ = 0
workspace manifests 5 5 ⚪ ▲ = 0

Tests

Single full-suite pass (unit + integration, from the coverage run).

Base Head Δ passed
9,091 passed (root 842 / frontend 1,904 / api 4,552 / shared 832 / runtime 961) · exit 0 · 40s 9,097 passed (root 848 / frontend 1,904 / api 4,552 / shared 832 / runtime 961) · exit 0 · 40s 🟢 ▲ +6

Code Duplication (jscpd)

Metric Base Head Δ
clones 1,324 1,322 🟢 ▼ -2
duplicated lines 15,482 15,459 🟢 ▼ -23
percentage 3.94% 3.94% 🟢 ▼ -0.01pp

Repo Tooling

Metric Base Head Δ
Full repo check pass pass ⚪ ▲ = 0
TS errors (total) 0 0 ⚪ ▲ = 0
Circular dependencies 0 0 ⚪ ▲ = 0

`mock.restore()` does not revert `mock.module()`, so the stubs the
`Gemini aliases API` block installs for `src/services/gemini` stayed
swapped for the rest of the lane. `restoreConnectorProviderMocks()` only
re-registered openai and base-url-policy, so nothing put gemini back.

Under `--randomize` that block can run before the alias route tests in
the same file, which then assert against the stub rather than the route
— a vacuous pass, and the wrong-state failure the unisolated
`api-integration` lane exists to catch.

Captures the whole namespace at module load (`{ ...geminiService }`)
rather than a hand-listed subset: the overrides tests install are
partial, and the route modules bind `InvalidGeminiApiKeyError` and
`GeminiValidationUnavailableError` for `instanceof` checks, so restoring
a subset leaves the same hole in a different shape. `mock.module` on an
already-loaded module merges, so re-registering the full namespace
overwrites every stubbed key back to the real one.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
`settings-agents` and `settings-app-settings` each carried their own
`interface TestIdentity` and their own `identitySeq` mint — the same
contract `UserFixture` in tests/support/factories already exports, in a
third and fourth copy. The next suite that needs per-test identities
would have copied a fifth.

`makeTestIdentity(prefix, name)` mints without inserting, which is what
these suites want: their rows are keyed by user id and nothing truncates
the tables in between, so the id is the namespace and the `user` row
itself is never read. The counter is module-level, so ids stay unique
across the files sharing one module graph in the unisolated
`api-integration` lane.

Row ids now suffix `testUser.id` rather than the bare counter, so the
row and the identity that owns it cannot drift apart.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
…te as TEST_USER

The file's own rule is that every `describe` seeds the identities it
authenticates as, but `settings connectors routes` and `Gemini aliases
API` both authenticate as `TEST_USER` with no `user` row behind it. That
holds only while no route those blocks exercise persists a user-owned
row: the first test added to either that POSTs a connector hits
`secret_metadata`'s foreign key on a missing `user.id` and answers 500 —
reopening the hole the project-scoped block just closed.

`seedUsers` moves to tests/support/factories as `ensureTestUsers`,
next to the `insertTestUser` it was re-implementing. Keeping a private
copy meant a `user` schema change had to land in two places, and missing
the test-only one fails with a NOT NULL violation on an unrelated PR.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
…check

Two of the five guards were passing for reasons unrelated to what they
assert:

- `covers every workspace that owns a Bun test lane` did a bare
  `toContain('workspace: api')`, which the new integration-only entry
  satisfies on its own. Deleting the whole-workspace `api` lane would
  stop `apps/api/tests/unit` running under randomization while the test
  stayed green. Now asserted against the entries carrying `path: ""`.
- `expect(entry).not.toContain('--parallel')` passed only because the
  comment mentioning `--parallel=1` happens to land inside the *api*
  entry's capture. Moving that paragraph one entry down — a comment
  edit, no behavior change — turned a load-bearing test red. Comments
  are now stripped before the assertions read the entry.

Extraction moves onto `extractStepBlocksAtIndent`, the helper every other
workflow policy test in this directory uses, instead of a second regex
dialect; entries are bounded to the `include:` body so the last one no
longer runs to EOF; the lane is matched on the entry's own first line so
`api` cannot claim `api-integration`'s block by prefix; and the workflow
is read once rather than per test.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
The header comment promises each job prints the exact command to
reproduce its own lane, but the notice printed only the `bun test`
flags, dropping the `DATABASE_PATH` and `MANGOSTUDIO_DIAGNOSTIC_LOGS`
the job sets. Pasting it locally ran a different suite than the one that
went red — and for the unisolated `api-integration` lane that notice is
the only record of how to reproduce a leak.

Signed-off-by: Julio Polycarpo <julio@polycarpo.dev>
@juliopolycarpo
juliopolycarpo merged commit 17f6abb into main Aug 27, 2026
79 of 81 checks passed
@juliopolycarpo
juliopolycarpo deleted the fix/952-api-integration-partition branch August 27, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api Elysia routes, API modules, middleware, or backend services. area: build Binary build, runtime paths, packaging, or standalone output. area: docs Documentation tree, guides, reference docs, or contributor docs. type: ci CI, release, checks, automation, or GitHub workflow changes. type: test Test coverage, test infrastructure, or test reliability work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The api integration lane is both sharded and unisolated, so each shard's module graph has a different, rotating set of companions

1 participant