Skip to content

Preserve external chat import recovery across checkpoint failures - #16458

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
danielhanchen:fix-external-import-recovery-16419
Nov 2, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
danielhanchen:fix-external-import-recovery-16419

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Failed external-chat imports can commit messages without their checkpoint, causing retries to skip later turns. This preserves the atomic message/checkpoint change from #16420 and also clears a deleted chat's obsolete checkpoint in the transaction that recreates its thread, so an interrupted reimport remains retryable.

The importer continues to preserve edits and message deletions in surviving threads. There is no schema migration or change to the import UI. Existing historical threads with missing checkpoints remain outside this change.

Validation:

  • The original checkpoint-failure reproduction fails on main and recovers both turns with this change.
  • Deleting an imported chat and interrupting its reimport leaves only the later turn with fix(import): save messages and checkpoints atomically #16420; this change retains both turns after retry and imports zero on repeat.
  • Regression tests cover both recoveries, preserved Studio edits/deletions, parent links, checkpoint-only failures, and intentionally emptied surviving chats.
  • 590 storage/import/archive/research/generation tests passed with zero skips; Ruff and the pre-push checks pass.
  • The five focused tests passed on Linux, Apple Silicon macOS, and Windows, with zero skips.

The current head has review approval. Broad CI is still blocked by UI parity: the scorer reports zero stable differences and zero failed assertions, but excludes all 32 pairs as unstable against the null and exits with "NOTHING WAS COMPARED". That is an evidence gap to resolve before merging.

This includes the original contributor's commits from #16420. Maintainer pushes and a follow-up PR into that contributor's branch were both refused, so the correction is offered here for review.

Fixes #16419.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T06:27:34.703777Z 2dd439b 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. Bravo.

Reviewed commit: 2dd439b3ff

ℹ️ 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 added a commit to Etherll/unsloth that referenced this pull request Nov 2, 2026
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 2, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

The Parity verdict, scored against the null red here does not come from this change. This PR is backend-only. On this run, the null control (the same build compared against itself) measured all 32 action pairs as unstable, every one with the same "thread scaffolding outside any message" difference. That left nothing to score:

matched:                    0
unstable actions differing: 32  (expected to vary; not a verdict)
NOTHING WAS COMPARED. ... This is not a pass.

The other parity runs from the last few hours (#16449, #16450, #16451, #16452) matched 28 or 29 pairs each. Re-running the parity jobs should give it a real verdict.

@danielhanchen
danielhanchen merged commit f9cecc9 into unslothai:main Nov 2, 2026
danielhanchen added a commit that referenced this pull request Nov 2, 2026
…#16464)

## Summary

`Parity verdict, scored against the null` fails on unrelated PRs whose
base includes #16300 (`d56738f404`, the turn navigator at the chat's
left edge). In the last two hours it failed on #16458 (a backend-only
change) and on staging for #16463 and #16435, each time the same way:

```
matched:                    0
unstable actions differing: 32  (expected to vary; not a verdict)
NOTHING WAS COMPARED. ... This is not a pass.
```

In the null control (the same build on both arms), every action's thread
scaffold digest differs, even between two repetitions on the same arm,
while its length stays equal (`thread scaffolding outside any message
(24167->24167c)`). That is an instance id leaking into the structural
signature.

#16300 renders the navigator inside the thread root, outside every
message, as one button per turn with `data-turn-id={openerId}`.
`openerId` is the turn's opening message id (`thread-turns.ts` pushes
`message.id`). `scene/parity.js` already drops the values of
`data-message-id`, `data-thread-id` and the other id attributes it knew
about, but not this new one. Studio's message ids are short and random,
so `ID_RE` does not catch them in the value either.

The product is fine; the instrument fell behind the DOM.

## Change

- **`tests/studio/studiobench/scene/parity.js`:** an attribute is
volatile if it is in `VOLATILE_ATTRS`, or if its name matches
`data-*-id`. A volatile attribute keeps its presence in the signature
and loses only its value, as before.
- Every `data-*-id` in the frontend names an instance, e.g.
`data-turn-id`, `data-queue-item-id`, `data-bookmark-id`,
`data-entry-id`.
- So the next one added inside the thread cannot silently empty the
verdict the way this one did.
- Non-id data attributes (`data-turn`, `data-role`, `data-state`, ...)
still compare by value.
-
**`tests/studio/studiobench/fixture/selftest/test_studiobench_parity_digest.py`**
(these run the shipped `parity.js` under node):
- `test_every_data_id_attribute_is_volatile`: two different
`data-turn-id` values sign the same, a button with the attribute still
differs from one without it, and the same holds for
`data-queue-item-id`.
- `test_a_data_attribute_that_is_not_an_id_still_moves_the_signature`:
`data-turn="1"` against `"2"` still differs.

## Testing

- `tests/studio/studiobench/fixture/selftest`, `sweep/selftest` and
`analysis/selftest`: 606 passed.
- Sabotage: with main's `parity.js`,
`test_every_data_id_attribute_is_volatile` fails; the other new test
passes on both.
- Not proven here: I did not rerun the full parity sweep locally. The
PR's own parity job is the end-to-end check. On main's harness it should
report a non-zero `matched` count on this PR, as the runs before #16300
did (28 or 29).
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.

[Bug] Failed external-chat imports can skip newly appended turns

2 participants