Skip to content

PROD-2307: adopt existing target containers by referenceName (mapping self-heal)#185

Merged
5PK merged 1 commit into
mainfrom
PROD-2307-adopt-containers-by-referencename
Jul 15, 2026
Merged

PROD-2307: adopt existing target containers by referenceName (mapping self-heal)#185
5PK merged 1 commit into
mainfrom
PROD-2307-adopt-containers-by-referencename

Conversation

@5PK

@5PK 5PK commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Defensive hardening for container-pushernot 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-pusher had no fallback: with no mapping row it always took the create path. Agility's saveContainer dedupes 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 through hasValidMappings, 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 by referenceName (unique per instance); if found, write the mapping row and skip instead of creating.

  • Case-insensitive reference-name match
  • Mapping write skipped under --preflight
  • Same-name / different-model match logs a warning (adopts on the unique name)

What this does NOT do (scope)

  • Does not resolve the ticket's divergent-hash nested-container doubling (orphans with names the source never had). That needs the source/target nested-container names to diverge, a path not reproducible on the current build — likely a ~13.16-era artifact. Cleanup of existing orphans is PROD-2282.
  • The content-item duplication observed under a missing mapping cache is a distinct root cause, tracked separately.

Testing

  • New container-pusher unit tests: adopt-by-referenceName, case-insensitive match, still-creates-when-no-match, preflight-no-write.
  • Full suite green: 1732 tests / 98 suites.
  • Live verification against test instances (d46a3d59-udb707fc0-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

… 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>
@5PK 5PK merged commit 89fdfb5 into main Jul 15, 2026
3 checks passed
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.

2 participants