Repository navigation
0392e8fe: a renamed Template definition adopts the Task it previously named - #323
Merged
Merged
Conversation
… named Applying a Template update whose definition ref changed planned add for the new ref and skip-removed for the old one: the Card kept a retired copy of the original Task beside a fresh one, doubling the work item (the sponsor-stats tasks doubled on the newsletter Cards). The manual adoption matched only Tasks with no Template provenance, so a Task the Template itself had named never matched. The plan now adopts the retiring Task whose normalized description names the renamed definition - the same matching key the manual adoption uses - when the description is unique on both sides: an open Task takes the renamed definition's fields under its old id, a resolved one keeps its resolution, and a Task the machinery itself skipped for the removed ref is restored. A Task an earlier update retired yields to the live Task, and definitions that renamed the work to different wording still add and retire as before. Repeated instances are never adopted. Dependency resolution, the acyclicity guard, and the apply transaction register the adopted Task's id under the new ref.
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.
Task: 0392e8fe (template-update duplicates manual tasks — sponsor-stats doubling on newsletter cards)
Problem
Applying a Card Template update whose task definition ref changed planned
addfor the new ref andskip-removedfor the old one (backend/src/templates/cardTemplateUpdates.ts, the!currentbranch + the retirement loop). The Card kept a retired-skipped copy of the original Task beside a fresh open copy — the sponsor-stats tasks doubled on the newsletter cards. The newsletter Card sync (syncIssueSlotTasks) applies Template updates without a human-reviewed preview, so every slot-booking change silently re-ran it.The existing manual-task adoption matched only Tasks with no Template provenance (
!(task.templateId && task.templateTaskRef)), so a Task the Template itself had named under the old ref never matched.Verified against origin/main with a reproduction: renaming
sponsor-stats→sponsor-stats-weeklyand applying yields twoCollect sponsor statstasks (one skipped, one new id).Fix
The plan now adopts the retiring Task whose normalized description (
description.trim().toLowerCase()— the same matching key the manual adoption uses) names the renamed definition, when the description is unique on both sides:updatewithadoptedRef),adopt),restore),Dependency resolution, the acyclicity guard, and the apply transaction register the adopted Task's id under the new ref. Genuinely distinct tasks (different descriptions, ambiguous duplicates) are preserved.
Tests
Six new cases in
backend/tests/card-template-updates.test.ts(renamed definition adoption): adopt + no-op re-apply (one task, same id), in-place update when content changed too, completed Task keeps its resolution, distinct wording still adds and retires, manual adoption then rename keeps one Task, and the retired-original vs live-copy preference. Four of them fail on origin/main.NODE_ENV=test FRONTEND_ROOT=../frontend SKIP_AUTH=true node --import tsx --test --test-force-exit tests/card-template-updates.test.ts→ 29 pass. Related suites (api-card-template-updates,template-task-dependencies,template-runtime-edits,newsletter-issue-cards,authored-templates) → 103 pass. Full backendtsc --noEmit(src, tests, scripts) clean.Operator cleanup (informational — NOT executed here)
No prod data was touched. Cleanup commands for the already-duplicated sponsor-stats tasks are collected in the task report; identification of affected cards needs prod data.