Skip to content

Stop two Studio contract tests reddening main on a rename and a 2px nudge - #8115

Closed
danielhanchen wants to merge 4 commits into
unslothai:mainfrom
danielhanchen:fix/studio-gate-launcher-transaction
Closed

danielhanchen wants to merge 4 commits into
unslothai:mainfrom
danielhanchen:fix/studio-gate-launcher-transaction

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Two source-scraping contract tests are failing on main right now, and both fail for the same reason: they pin a spelling rather than the behaviour, so an ordinary change to the code under test reads as a repo-wide red.

tests/python/test_studio_runtime_gate.py::test_terminal_update_holds_the_gate_through_environment_mutation

#8092 replaced _release_self_exe_lock_windows with _WindowsLauncherUpdateTransaction. The test sliced studio.py from def update( up to that helper name, so the rename took the whole slice down with it:

body = source[source.index("def update(") : source.index("def _release_self_exe_lock_windows")]
E   ValueError: substring not found

It now ends at the next definition rather than at a name inside the body, and asserts the ordering that actually matters, including that the launcher transaction sits INSIDE the gate: the transaction renames the running launcher aside, so a second Studio the gate never excluded would be mutating the same install underneath it.

tests/studio/test_desktop_reliability_frontend_contract.py

#8102 nudged the mac titlebar by 2px (--studio-titlebar-navigation-offset-y 2px to 4px, --studio-chat-header-padding-top 7px to 9px) and reddened two tests, because they spelled the numbers out as literals. What the layout depends on is the row keeping its shape, so the offset is now bounded (positive, and inside the 48px titlebar) and the chat header is asserted to stay 5px below it.

Still catches a real break: moving the padding to 12px reproduces the failure.

Both slices also go through a helper that reports a moved anchor by name, so the next rename says which one went instead of raising a bare index error.

Verified with pytest tests/python tests/studio: 3721 passed, the two failures gone. The two remaining local failures (test_e2e_no_torch_sandbox, test_tokenizers_and_torch_constraint) build a no-torch venv and fail in my sandbox on main too; CI reports neither.

danielhanchen and others added 2 commits August 7, 2026 15:55
…udge

unslothai#8092 replaced `_release_self_exe_lock_windows` with the launcher transaction,
and the update-gate test sliced `studio.py` up to that name, so the rename took
the whole slice down as `ValueError: substring not found`. It now ends at the
next definition, asserts the transaction sits inside the gate, and reports a
moved anchor by name instead of a bare index error.

unslothai#8102 nudged the mac titlebar by 2px and reddened the repo the same way,
because the frontend contract spelled the numbers out. What the layout depends
on is the row keeping its shape, so the offset is bounded and the chat header
is asserted to stay 5px below it. A wrong value still fails: moving the padding
to 12px reproduces the failure.
@danielhanchen

Copy link
Copy Markdown
Member Author

On the red here, so it is not read as this branch's:

pip scan-packages (extras / hf-stack / studio) fails on main right now, from the huggingface_hub 1.27.0 evidence hash the shipped baseline no longer matches. #8110 carries that fix and its three scan jobs pass; this branch is cut from main without it, so it inherits the red.

Source lint failed on fatal: shallow file has changed since we read it in the import-hoist step, which is a shallow-clone race in the checkout rather than anything in the diff. Re-run and it is back to pending.

Nothing else outstanding: the two contract tests this PR fixes pass, 35 passed / 11 skipped locally.

@danielhanchen

Copy link
Copy Markdown
Member Author

The four Backend tests reds here (Python 3.10 / 3.11 / 3.12 / 3.13) are not from this branch. #7985 widened _stream_completion to return usage and four assertions in test_research_runs_hardening.py still expect the old 3-tuple, so every open PR inherits them.

Confirmed by comparing this branch with #8115/#8110: the two share no files with each other and neither touches studio/backend/tests/, yet both fail on the same four test ids.

Fixed in #8120, with a guard that reads the tuple width from the function's own return annotation so the next arity change cannot drift past the tests again.

@danielhanchen

Copy link
Copy Markdown
Member Author

main is red in three independent places right now, and each of these three PRs fixes exactly one of them, so every one of them still shows the other two as failures. Merging all three in any order turns main green; merging any one alone will not.

None of the three touches the others' files, so there are no conflicts between them.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b8b9cefa2

ℹ️ 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".

body = source[source.index("def update(") : source.index("def _release_self_exe_lock_windows")]
# Ended at the next definition, not a helper inside the body: #8092 removed
# `_release_self_exe_lock_windows` and the old anchor took the slice with it.
body = _slice_between(source, "def update(", "class _WindowsLauncherUpdateTransaction")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Derive the update boundary from the next declaration

If _WindowsLauncherUpdateTransaction is moved above update during a behavior-preserving reorganization, _slice_between finds the end anchor before the start anchor and returns an empty string, so this contract fails at the first body.index(...). This recreates the source-layout brittleness the change is intended to remove; determine the next top-level declaration after def update( (or inspect the function via the AST) instead of naming a particular later class.

Useful? React with 👍 / 👎.

Comment on lines +553 to +556
provider = APP_PROVIDER.read_text(encoding = "utf-8")
found = re.findall(rf'"{re.escape(name)}":\s*"(-?\d+)px"', provider)
assert found, f"the provider no longer sets {name}"
assert len(set(found)) == 1, f"{name} is set to more than one value: {sorted(set(found))}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope the CSS lookup to the Mac chrome style

If CUSTOM_CHROME_STYLE needs a different --studio-chat-header-padding-top from MAC_NATIVE_CHROME_STYLE, this helper collects both values and fails the uniqueness assertion even when the Mac titlebar relationship remains unchanged. The provider already defines these as separate platform styles, so the lookup used by the Mac contract should be limited to the MAC_NATIVE_CHROME_STYLE block rather than imposing an unrelated cross-platform equality.

Useful? React with 👍 / 👎.

encoding = "utf-8"
)
# Zero puts the row on the traffic lights; large drops it out of the 48px bar.
assert 0 < _provider_css_px("--studio-titlebar-navigation-offset-y") <= 8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the navigation nudge by its actual titlebar

When the offset is increased to 8px, this assertion passes even though the native Mac style provides a 34px desktop titlebar and each navigation button is 30px tall, so the translated box extends beyond the titlebar (8 + 30 > 34). Read the button size and the applicable --studio-desktop-titlebar-height and compare those values instead of using the unrelated magic upper bound of 8.

Useful? React with 👍 / 👎.

Comment on lines +567 to +570
assert (
_provider_css_px("--studio-chat-header-padding-top")
- _provider_css_px("--studio-titlebar-navigation-offset-y")
) == 5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the chat controls within their header

If the navigation offset and chat padding are changed together to 7px and 12px, both new contracts pass because the offset remains within 8 and the difference remains 5, but the Mac header is 44px tall and its controls are 33px tall, so the padding requires 45px and pushes the controls outside the row. In addition to checking relative alignment, assert that padding plus control height does not exceed the applicable header height.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member Author

Superseded by #8132, closing.

#8132 repaired tests/python/test_studio_runtime_gate.py and tests/studio/test_desktop_reliability_frontend_contract.py directly, which is the same ground this covered. I checked rather than assumed: on a fresh worktree at 4e193139d with nothing of mine applied, both files plus studio/backend/tests/test_research_runs_hardening.py pass together, 156 passed and 11 skipped.

Nothing here is left to land. The wider point this was part of is also resolved: the three-way CI deadlock between this, #8120 and #8110 is gone, and #8110 has been rebased onto main and narrowed to the one defect that is still real.

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