PROD-2307: adopt existing target containers by referenceName (mapping self-heal)#185
Merged
Merged
Conversation
… self-heal) Defensive hardening, not the fix for the ticket's headline symptom. When the local mapping cache is absent (fresh machine, CI runner, wiped agility-files, or a create that succeeded server-side but was never mapped), container-pusher had no fallback: with no mapping row it always took the create path. Agility's saveContainer dedupes by referenceName so this rarely produced a visible duplicate container, but the missing mapping row is the real damage — downstream content/pages resolve container references through hasValidMappings, and a missing container mapping tips content into the create path, which is what feeds duplicate accumulation across syncs. This mirrors the model-pusher PROD-2211 map-on-adopt path: before creating, look for an existing target container matching by referenceName (unique per instance) and, if found, write the mapping row and skip instead of creating. Reference names are matched case-insensitively; the mapping write is skipped under --preflight; a same-name/different-model match logs a warning. What this does NOT do: it does not resolve the ticket's divergent-hash nested container doubling (orphans with names the source never had), which requires the source/target nested-container names to diverge — a path not reproducible on the current build. That is handled separately (orphan cleanup / PROD-2282), and the content-item duplication observed under a missing mapping cache is a distinct root cause tracked on its own. Verified: fresh-state sync now reports containers adopted (skipped) with mapping rows written instead of re-created; a second sync is stable. Full suite green (1732 tests); 4 new container-pusher unit tests cover adopt, case-insensitive match, still-creates-when-no-match, and preflight-no-write. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jules-exel
approved these changes
Jul 14, 2026
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.
Summary
Defensive hardening for
container-pusher— not the fix for PROD-2307's headline symptom (see caveats).When the local mapping cache is absent (fresh machine, CI runner, wiped
agility-files, or a create that succeeded server-side but was never mapped),container-pusherhad no fallback: with no mapping row it always took the create path. Agility'ssaveContainerdedupes by reference name, so this rarely produced a visible duplicate container — but the missing mapping row is the real damage. Downstream content/pages resolve container references throughhasValidMappings, and a missing container mapping tips content into the create path, which is what feeds duplicate accumulation across syncs.Change
Mirrors the merged PROD-2211 map-on-adopt path in
model-pusher: before creating, look for an existing target container matching byreferenceName(unique per instance); if found, write the mapping row and skip instead of creating.--preflightWhat this does NOT do (scope)
Testing
container-pusherunit tests: adopt-by-referenceName, case-insensitive match, still-creates-when-no-match, preflight-no-write.d46a3d59-u→db707fc0-u): a fresh-state sync now reports containers adopted (skipped) with mapping rows written instead of re-created; a second sync is stable.🤖 Generated with Claude Code