Skip to content

Studio: assert the write ordering, not what the write resolves to - #10289

Merged
danielhanchen merged 2 commits into
mainfrom
fix-override-write-ordering-assertion
Sep 4, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix-override-write-ordering-assertion

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Repo tests (CPU) is red on main at 2d346cce0, on one test out of 15,843:

FAILED tests/studio/test_model_picker_contracts.py::test_override_writes_are_ordered_per_model
  assert 'const writesByKey = new Map<string, Promise<void>>();' in '...'

#10160 is right, and reordered nothing

That PR lets the API load settings panel forget an entry, so putModelOverride now returns a ModelOverrideWriteResult carrying removedKeys instead of returning void. The queue it is stored in changed type with it:

const writesByKey = new Map<string, Promise<ModelOverrideWriteResult>>();

The ordering itself is untouched. Checked line by line against the source rather than assumed:

what the test pins still there
one in-flight promise per key yes, writesByKey
key folded through modelOverrideKey(normalizeModelIdentity, normalizeGgufVariantIdentity) yes, byte for byte
chained on the settled tail, previous.catch(() => {}).then(() => sendModelOverride( yes, byte for byte
only the last writer clears the slot yes, byte for byte

Three of the four assertions still match unchanged. The one that broke names the promise's value type, and what a write resolves to has nothing to do with the order writes commit in.

The change

Assert that writes are serialised through one in-flight promise per key, without naming what that promise resolves to.

The obvious alternative, re-syncing the literal to Promise<ModelOverrideWriteResult>, is worse than it looks: it leaves the test failing the next time the result type changes, which is a change that reorders nothing. This is the same shape as #10267 and #10231, an assertion written as one exact literal over something that is not fixed.

While here, one assertion is added rather than only relaxed: writesByKey.set(key, write);. Without the tail being stored, every writer chains on the same empty slot and the ordering is gone, and nothing in the test noticed.

Verified by breaking it

Six edits to model-overrides.ts, each run against the test:

edit before, re-synced to the new type after
baseline passed passed
result type changes again, ordering untouched failed passed
the tail is never stored, a real ordering loss passed failed
serialisation removed entirely failed failed
writes no longer chain on the tail failed failed
any writer clears the slot, not just the last failed failed
the key stops folding the identity failed failed

The middle two rows are the point. The first column is what a plain re-sync gives you: still brittle against a harmless change, and still blind to a real one.

tests/studio/test_model_picker_contracts.py: 191 passed. No source changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T07:55:43.140766Z e62a381 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 4, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: e62a381803

ℹ️ 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 1e8eda3 into main Sep 4, 2026
21 of 24 checks passed
@danielhanchen
danielhanchen deleted the fix-override-write-ordering-assertion branch September 4, 2026 08:20
Souravrajvi0 pushed a commit to Souravrajvi0/unsloth that referenced this pull request Sep 4, 2026
…rd (unslothai#10307)

`Repo tests (CPU)` was red on `main` at `99a83f6a6` and `a2a4143ce`, and so on PRs branched from them, on one test out of 15,899:

```
FAILED tests/studio/test_auth_form_input_count.py::test_auth_flow_routes_do_not_mount_global_settings
  assert 'if (!active || !mounted) return null;' in mount
```

unslothai#10237 gave `SettingsDialogMount` a second surface, so the single lazy-mount flag became two:

```diff
-  const [mounted, setMounted] = useState(open || monitorOpen);
-  if (!active || !mounted) return null;
+  if (!active || !(settingsMounted || monitorMounted)) return null;
```

That is right and it did not open the auth routes. `!active` still short-circuits, so an inactive mount still renders nothing, which is the whole of what this test is named for. The other two assertions in the test still match byte for byte, so the chain it protects, auth route to `active={false}` to nothing rendered, is intact at every link. The assertion had simply quoted the auth gate and the lazy-mount bookkeeping as one string.

## The change

Assert the property rather than a spelling: `SettingsDialogMount` must return null from its own top level on every inactive render. The guard is read as a parse, because a textual match is what got us here:

- Comments and string bodies are blanked first, in a same-length copy so indices still line up. The assertion this replaces matched `// if (!active || !mounted) return null;` just as happily as the live line, so the guard could have been struck out entirely and the test would have stayed green.
- The slice is the real function body. The signature is `({ active }: { active: boolean })`, so the body brace is found by walking the parameter list rather than taking the first brace after the name.
- Only statements directly in that body count, so `(active) => { if (!active) return null; }` cannot answer for the component.
- The condition must be a disjunction whose first operand is `!active`. A top-level `?` or `,` disqualifies it, since both bind looser than `||`: `!active || mounted ? false : true` and `!active || track(), active` each leave the disjunction as a discarded sub-expression and skip the return while inactive. `?.` and `??` are neither.
- `{ return null; }` is accepted alongside `return null;`, so a bracing pass does not go red for nothing.

This is the same shape as unslothai#10267, unslothai#10231, unslothai#10289 and unslothai#10297. The file had already reached that conclusion twice on its own, as "Lock the count, not the spelling, so a rename does not falsely fail" and "Lock the behaviour, not one spelling of it, so either form passes". This assertion had not had the treatment.

## Verified by breaking it

The predicate was checked directly against 15 conditions, all correct. Then fifteen edits to `settings-dialog-mount.tsx`, each run against the test, next to what a plain re-sync of the literal would give:

| edit | re-synced literal | this change |
| --- | --- | --- |
| baseline | passed | passed |
| both mount flags renamed | **failed** | **passed** |
| a third surface joins the mount | **failed** | **passed** |
| the operands reordered | **failed** | **passed** |
| back to a single flag, as before unslothai#10237 | **failed** | **passed** |
| optional chaining in the second operand | **failed** | **passed** |
| the guard braced by a formatter | **failed** | **passed** |
| the `!active` half dropped | failed | failed |
| `||` becomes `&&` | failed | failed |
| the whole guard deleted | failed | failed |
| the gate inverted to `active` | failed | failed |
| a ternary swallows the disjunction | failed | failed |
| a comma expression discards the disjunction | failed | failed |
| the guard moved into a nested callback | failed | failed |
| the guard survives only as a comment | **passed** | **failed** |

Six harmless forms pass where a re-sync goes red on all six, none of which touches the auth routes. Nine real regressions fail. The last row is the one that matters most: a re-sync, and the assertion that was there before it, both accept a guard that exists only as a comment.

`tests/studio`: 7483 passed, 195 skipped. No source changes. Staging CI green.
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