fix(derive): resolve duplicate step ids so paths keep unique ids#115
Merged
Conversation
|
🔍 Preview deployed: https://8d90c1cd.toolpath.pages.dev |
A path's step ids must be unique, but sources reuse ids across distinct records — Claude Code reuses `uuid` on `attachment` lines, so two unrelated events arrive with the same id — and carrying a duplicate through breaks any consumer that keys on the id (e.g. a store with a UNIQUE (path_id, step_id) constraint). `derive_path` now resolves collisions inline as each step is emitted (via `push_step`): a byte-identical re-emission is dropped, and a same-id-but-different step is re-IDed to `<id>#<n>`. Because resolution happens during emission and updates `turn_to_step`, parent references follow the rename — a later step whose parent matched a renamed duplicate resolves to the renamed step, not the first occurrence. Bumps toolpath-convo 0.11.0 -> 0.11.1.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
derive_pathnow guarantees the derived path's step ids are unique.Sources reuse ids across distinct records — Claude Code reuses
uuidonattachmentlines, so two unrelated events arrive with the same id — and carrying a duplicate through breaks any consumer that keys on the id (e.g. a store with aUNIQUE (path_id, step_id)constraint). This is blocking real imports today.Collisions are resolved inline as each step is emitted (via
push_step):<id>#<n>so the original id stays recoverable and no data is lost.Because resolution happens during emission and updates
turn_to_step, parent references follow the rename — a later step whoseparent_idmatched a renamed duplicate resolves to the renamed step, not the first occurrence.derive_pathis already infallible (-> Path), so there's no signature change — this is purely additive.Scope
crates/toolpath-convo/src/derive.rs): apush_stephelper wired into the turn and event loops, plus 4 regression tests (drop, rename, event-dedup, parent-reference correctness).toolpath-convo0.11.0 → 0.11.1(patch), with the workspace / crates.json / CHANGELOG updates.cargo test --workspacegreen;cargo clippy --workspace -- -D warningsclean.Context vs #111
This is the dedup carved out of the larger cross-harness compaction PR (#108) so it can land on its own and unblock imports.
It overlaps with #111 (same drop-identical / rename-differing decision), with one caveat: #115 resolves collisions inline as steps are emitted, so parent references follow a rename — a later step pointing at a renamed duplicate resolves to
<id>#<n>, not the first occurrence. #111 does it as a post-pass over the finished step list, which renames correctly but leaves parent references pointing at the first occurrence. For the immediate blocking case (duplicateuuidon attachment/event lines, which have no children) the two are equivalent; they differ only for duplicate turns with children. Whichever lands first, the other can be closed or rebased.