Skip to content

tests: follow the remote-connection contract through its refactor - #8467

Merged
danielhanchen merged 10 commits into
mainfrom
fix-remote-connection-contract-drift
Aug 13, 2026
Merged

danielhanchen merged 10 commits into
mainfrom
fix-remote-connection-contract-drift

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

tests/studio/test_remote_connection_models_contract.py has two assertions that fail on main today, so Repo tests (CPU) is red on every PR:

FAILED test_frontend_sync_backfills_local_models_to_backend
  assert 'Promise.allSettled(backfillTasks)' in ...
FAILED test_chat_page_hydrates_connections_on_startup
  assert 'syncExternalProvidersFromBackend' in ...

Both pin implementation details that have since moved. The behaviour they exist to protect is intact:

  • The inline Promise.allSettled(backfillTasks) is now await settleTasksIfCurrent(backfillTasks, isCurrent). That helper (features/credentials/reconciliation.ts) does await Promise.allSettled(tasks.map((task) => task())) behind a staleness guard, so every backfill task is still settled and a stale response no longer applies.
  • Provider hydration moved off the chat page into features/credentials/bootstrap.ts, which app/routes/__root.tsx runs. Connections now hydrate app-wide instead of only once chat mounts.

So the tests fail on working code, and simply deleting the assertions would stop pinning the contract at all.

Fix

Follow the code. The backfill test asserts the call plus what the helper does; the hydration test asserts the bootstrap call and the root route that runs it, and is renamed since the chat page is no longer what does this.

Assertions match the call sites, not the bare names. An import survives deleting the call, so "syncExternalProvidersFromBackend" in source would pass on a startup that hydrates nothing. That was a real weakness in my first draft, caught by mutation testing rather than by reading.

Testing

pytest tests/studio/test_remote_connection_models_contract.py : 7 passed.

Mutation-tested, since a contract test that cannot fail is worse than none:

broken result
Promise.allSettled to Promise.all in the helper caught
the syncExternalProvidersFromBackend(providers, ...) call in bootstrap caught
the bootstrapPersistedCredentials() call in the root route caught
the settleTasksIfCurrent(backfillTasks call in sync caught

Both assertions pin implementation details that moved, so they fail on working
code and red-line Repo tests (CPU) on every PR.

The inline `Promise.allSettled(backfillTasks)` is now behind
settleTasksIfCurrent, which adds a staleness guard. Assert the call and what
the helper does, so "every backfill task is settled, one slow task cannot drop
the rest" stays pinned rather than assumed.

Provider hydration moved off the chat page into the credential bootstrap that
the root route runs, so connections hydrate app-wide rather than only once chat
mounts. The test follows it there and is renamed, since it is no longer the
chat page that does this.

Assertions match the call sites, not the bare names: an import survives
deleting the call, so a name-only check would pass on a startup that hydrates
nothing. Verified by mutation - breaking allSettled, the sync call, the
bootstrap call and the settle call each fail the test.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Two more assertions pinning shapes that moved, failing on working code.

The lost-POST proof left settleLostGeneration: the id snapshot is now taken by
the caller before the request and handed over as a NewRecordProbeBaseline, and
the comparison lives in hasUnknownRecord. That is stronger than before, since
the set can no longer be rebuilt in the catch. The test follows it into
lib/gallery-flags.ts and additionally pins the canJudgeUnpinned guard, which is
what stops an inconclusive listing from reading as proof.

effectiveRecommended became a Set, so picking the representative is a
membership test rather than an equality check.

Mutation tested, seven for seven: breaking the unknown-id check, the
canJudgeUnpinned guard, the probe call, the pre-request snapshot, the error
message and either half of the representative rule each fail the tests.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

pre-commit-ci Bot and others added 2 commits August 11, 2026 18:53
…y group

Review caught three assertions that pass while the behaviour they name is
broken, and one of them was covering a real bug.

footprintVariants picked its per-group representative from the flattened
effectiveRecommended set, so with two families in one neutral repo sharing
quant names, the other group's recommended quant could stand in here and
resolve companions against the wrong base repo. That is the exact case this
contract exists for. effectiveRecommendedByGroup is already built above and
key is in scope, so the lookup is keyed now.

The hydration test only proved bootstrapPersistedCredentials() appears inside
CredentialBootstrapGate, not that the gate is mounted, so removing the wrapper
stopped hydration with the test still green. It pins the mount too.

The lost-POST test checked three strings that can each be present while the
baseline handed to the probe is recomputed after the POST. It now pins the
order and the flow: snapshot before generateDiffusionImage, that same
probeBaseline into settleLostGeneration, and that baseline into
hasUnknownRecord.

Mutation tested, nine for nine: each of the three new holes, plus the six from
the earlier rounds.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Three conflicts, all of them main and this branch repairing the same
contract drift independently.

tests/studio/test_remote_connection_models_contract.py, both hunks: main
(#8506) already followed the sync backfill to settleTasksIfCurrent and
renamed the hydration test, so the branch's version of that work is
redundant. Kept main's naming, docstring and the robust "allSettled" in
helper check, and folded in the one thing the branch had that main did
not: the assertions match CALL sites rather than bare names.
"bootstrapPersistedCredentials" alone is satisfied by the import on line
23 of __root.tsx, so main's assertion passes on a root that imports the
bootstrap and never runs it; "bootstrapPersistedCredentials()" pins the
call on line 108, and "<CredentialBootstrapGate>" pins that the gate
wrapping it is actually rendered. Same for the bootstrap's own call,
"syncExternalProvidersFromBackend(providers".

tests/studio/test_model_picker_contracts.py, the lost-generate-POST
test: main followed the proof into hasUnknownRecord loosely ("baseline"
in fn, the export exists); this branch pinned the data flow instead --
the baseline is built BEFORE the POST and the probe refuses to judge an
inconclusive listing. Those are different guarantees, so both are kept;
the branch's local name for the helper file was dropped in favour of
main's.

tests/studio/test_model_picker_contracts.py, the footprint-group test:
main tracked the source through effectiveRecommended becoming a Set and
asserted membership in it. That set is flattened across dependency
groups, which is the bug this branch fixes in pickers.tsx, so main's
assertions describe the behaviour being removed. Took the branch's
keyed-lookup assertions.

One resolution beyond the marked conflicts: main moved the row badge off
the flattened effectiveRecommended set (effectiveRecommendedByGroup.get
(group.key) === v.quant) and this branch moves the footprint
representative off it, so after the merge the memo has no readers left.
Deleted it, along with the comment that named the footprint
representative as its reason for existing. biome runs correctness rules
with "all": true, so leaving it would fail lint.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@danielhanchen

Copy link
Copy Markdown
Member Author

Merged current main in (51cdde69f); back to MERGEABLE.

Three conflicts, and one resolution outside the marked hunks that I want a second pair of eyes on.

Conflicts

test_remote_connection_models_contract.py, both hunks. #8506 rewrote this file on main first. I kept main's naming, docstring and its "allSettled" in helper check, and folded in the one thing this branch has that main lacks: the assertions match call sites, not bare names. "bootstrapPersistedCredentials" in root is satisfied by the import on line 23 of __root.tsx, so main's form passes on a root that imports the bootstrap and never runs it. Verified against the merged tree: line 23 is the import, line 108 is void bootstrapPersistedCredentials().finally(...), line 479 is the <CredentialBootstrapGate> wrapper. Same for syncExternalProvidersFromBackend(providers.

test_model_picker_contracts.py, lost-generate-POST. Main follows the proof into hasUnknownRecord loosely ("baseline" in fn); this branch pins the data flow (baseline built before the POST, probe refuses to judge an inconclusive listing). Different guarantees, so both are kept, using main's local name for the flags file.

test_model_picker_contracts.py, footprint group. Main asserts membership in the flattened set, which is exactly the behaviour this branch removes. Took the branch's keyed-lookup assertions.

The part worth checking

Main moved the row badge off the flattened set (effectiveRecommendedByGroup.get(group.key) === v.quant) and this branch moves the footprint representative off it, so after the merge effectiveRecommended has zero readers. I deleted the memo and its comment, which named the footprint representative as its whole reason for existing.

studio/frontend/biome.json sets "correctness": { "all": true }, so noUnusedVariables would fail Frontend CI on a leftover. But studio/frontend/node_modules is absent here, so I ran neither biome nor tsc: the deletion is safe by grep (no reference anywhere in src/, tests/, or studio/frontend/tests/), and the lint claim is reasoning rather than a run. Frontend CI is the check to watch.

Why this one is worth keeping, unlike #8429

It carries a live source fix main does not have. pickers.tsx still resolves the GGUF footprint representative against the flattened effectiveRecommended set, so two families sharing quant names in one neutral repo let the other group's pick stand in and companions resolve against the wrong base repo.

tests/studio/test_model_picker_contracts.py
+ test_remote_connection_models_contract.py    189 passed
tests/studio (whole tree)                      3100 passed, 3 skipped
ruff format + ruff check                       clean

danielhanchen and others added 2 commits August 13, 2026 08:37
… key

The footprint representative buckets rows by the backend's dependency_key
("flux.2-klein:<digest>"), but looked the recommendation up in
effectiveRecommendedByGroup, which is keyed by presentation group
("quantizations", "text-frames", "reference-media"). Every lookup was
undefined, so the recommended-quant branch never ran and whichever row tier
ordering put first spoke for the group, sending its filename and download
state to resolveDownloadFootprint. The recommendation is now reachable from
the variant object the presentation grouping already placed, which keeps the
per-group scoping without joining two key spaces.

Also scope the backfill contract's allSettled assertion to the body of
settleTasksIfCurrent. reconciliation.ts allSettles again in
runCredentialBootstrap, so the module-wide search stayed green when
settleTasksIfCurrent was regressed to Promise.all, which is the
one-failure-sinks-the-rest bug that assertion exists to catch.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

…ling

Two contracts passed on code that was broken.

The lost-generate probe contract only checked that the id snapshot expression
existed somewhere, that the baseline was built before the POST, and that
probeBaseline reached the probe. Swapping the knownIds argument for a fresh
empty set kept all three true while every record already on the page read as
unknown, so a POST that never reached the backend was reported as a finished
image. Capture the snapshot variable and pin it as the third argument, over
whitespace-normalised source so reformatting the call cannot break the pin.

The provider backfill contract asserted the call and the allSettled by
substring, neither of which contains await. Dropping await from the helper or
from its call site left it green even though the sync then resolves with the
writes still in flight, which loses them on an immediate close or a session
transition. Add tests/studio/test_provider_backfill_awaits_batch.py, which
slices both hops verbatim into the node harness and drives them with
timer-backed tasks, and give the frontend suite the same delayed-task case
against the real helper. Normalise whitespace in the remaining wiring
assertion, which a wrapped argument list was already enough to fail.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 7210a4d7bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit 620b9fa into main Aug 13, 2026
35 of 45 checks passed
@danielhanchen
danielhanchen deleted the fix-remote-connection-contract-drift branch August 13, 2026 11:56
danielhanchen added a commit to mahiatlinux/unsloth that referenced this pull request Aug 13, 2026
Resolves the contract-test conflict: main reformatted the Vulkan gate
assertion in unslothai#8467 while this branch scoped the gate to the GGUF picker.
Keeps both, as one named literal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant