Skip to content

Compare the upgraded studio.db by the rows the old build wrote, not its bytes - #11678

Merged
danielhanchen merged 1 commit into
mainfrom
fix/legacy-upgrade-sim-additive-columns
Sep 23, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/legacy-upgrade-sim-additive-columns

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

(Python 3.13, rest) has been red on every PR whose backend rest shard ran after #11607 merged (#11667, #11668, #11599). The failure reproduces on main:

FAILED tests/multi_account/test_legacy_upgrade_sim.py::test_populated_legacy_install_survives_app_import_and_owner_reads
  File ".../tests/multi_account/legacy_probe.py", line 71, in main
    assert (home / name).read_bytes() == payload, f"Owner read changed {name}"
AssertionError: Owner read changed studio.db

Cause

#11607 added fork_boundary_message_id and fork_title_base to chat_threads. Like settings_json and the other columns before them, they are added with ALTER TABLE ... ADD COLUMN when a current build opens studio.db. I diffed the database before and after the owner's reads, and that is the only change: the same row, with two new NULL columns.

The simulation froze its legacy schema in #10588 and compared studio.db byte for byte after the owner's reads. #11607 is the first additive migration since then that runs on those reads. Any later one would have failed the same way.

The product is right and the test was too strict. Adding a nullable column is how this schema has always grown, and it is what test_downgrade_sim.py already accepts for old builds: they read their own named columns.

Change

  • seed.py: new legacy_studio_rows(). It reads every table in the frozen schema through the columns that table had then. A dropped or renamed legacy column raises instead of comparing equal.
  • legacy_probe.py: captures those rows after seeding and requires them unchanged after the owner's reads. This is the same treatment auth.db already gets through old_auth_row. Every other file is still compared byte for byte, and so is studio.db across the import step, which writes nothing today.

Verification

  • tests/multi_account/: 830 passed. On main, test_legacy_upgrade_sim.py fails as above.
  • Sabotage in storage/studio_db.py's migration. Each of these fails the test:
    • rewriting chat_threads.model_id and updated_at, which no other assertion in the probe reads: Owner read changed legacy studio.db rows.
    • dropping the legacy column model_gguf_variant: Owner read changed legacy studio.db rows.
    • deleting the seeded app_settings row.
    • rewriting the seeded theme setting.

…ts bytes

#11607 added fork_boundary_message_id and fork_title_base to chat_threads,
and like every column before them they are added with ALTER TABLE when a
current build opens studio.db. The legacy upgrade simulation compared
studio.db byte for byte after the owner's reads, so the first additive
migration since #10588 froze the fixture failed it: "Owner read changed
studio.db", on every PR whose backend rest shard ran after #11607 merged.

Nothing the old build wrote changed. The probe now reads every legacy
table through its legacy columns before and after, the way it already
treats auth.db, and keeps the byte comparison for every other file and
for the import step.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 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-23T12:16:37.883712Z 5bf99cb 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 5bf99cb85d

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@danielhanchen
danielhanchen merged commit 0c8baba into main Sep 23, 2026
3 of 35 checks passed
@danielhanchen
danielhanchen deleted the fix/legacy-upgrade-sim-additive-columns branch September 23, 2026 12:45
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ts bytes (unslothai#11678)

unslothai#11607 added fork_boundary_message_id and fork_title_base to chat_threads,
and like every column before them they are added with ALTER TABLE when a
current build opens studio.db. The legacy upgrade simulation compared
studio.db byte for byte after the owner's reads, so the first additive
migration since unslothai#10588 froze the fixture failed it: "Owner read changed
studio.db", on every PR whose backend rest shard ran after unslothai#11607 merged.

Nothing the old build wrote changed. The probe now reads every legacy
table through its legacy columns before and after, the way it already
treats auth.db, and keeps the byte comparison for every other file and
for the import step.
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