-
Notifications
You must be signed in to change notification settings - Fork 0
fix(db): stop v11 from clobbering non-claude harness labels (#19) #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Priority-1 gap: this only fixes the v11 migration going forward for databases whose
PRAGMA user_versionis still below 11. Databases that already ran the buggy v11 migration already haveharness='claude'and aclaude:-derived session ID written;_run_migrationsskips v11 for them (already applied), and_backfill_exchange_provenance(~line 422) only selects rows wheresession_id IS NULL OR harness IS NULL" — which is none of them, since v11 already filled both. So every legacy grok/omp-pi/opencode/codex exchange that was mislabeled by the old buggy v11 stays permanently mislabeled after this fix. Please add an idempotent repair migration/backfill that identifies non-Claudesource_pathvalues among already-claude`-labeled legacy rows and rewrites their harness/session_id/canonical exchange id — not just fix the forward path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — fixed in 328f40a.
Added migration v13 (
_migrate_v13_repair_legacy_claude_mislabel) that specifically targets DBs already past the buggy v11 (PRAGMA user_version >= 11). It walks everyconversationsrow, re-derives the correct harness fromsource_pathwith the same_infer_harness_and_source_session_idheuristic used by v11/backfill, and for any exchange whose storedharnessdisagrees, rewritesharness,session_id,source_session_id, and — when the column already exists (i.e._backfill_canonical_exchange_idsalready ran against the stale values) —canonical_exchange_id. It also drops the staleclaude-hashedsessionsrow for that conversation once nothing references it anymore (safe: that id issha256("claude:" + source_path), unique per conversation sincesource_pathis unique).It's registered in
_MIGRATIONSso it runs exactly once per DB via the normalPRAGMA user_versiongate, and is independently idempotent (re-deriving already-correct rows is a no-op) if ever invoked again.Regression test:
test_migration_v13_repairs_exchanges_already_mislabeled_by_old_buggy_v11builds a DB frozen atuser_version=12withharness='claude'and aclaude:-derivedsession_id/canonical_exchange_idalready persisted for a grok conversation — reproducing exactly the state a DB that already ran the old buggy v11 would be in. I verified it fails (assert 'claude' == 'grok') with v13 unregistered and passes with it registered.Also had to fix
test_migration_v12_adds_exchange_conversation_ply_index_to_existing_db, which hardcodedlen(_MIGRATIONS) - 1assuming v12 was the last migration; it now targets_MIGRATIONS.index(_migrate_v12_add_exchange_conversation_ply_index)so it still isolates v12 regardless of how many migrations exist.make checkrun directly (not via git hooks, per issue #46): 664 passed, 0 lint issues, 0 typecheck errors.