﻿# Composite training keys: avoid collisions caused by delimiter concatenation

Composite training keys: avoid collisions caused by delimiter concatenation. A practical data-quality guide with failure mechanisms, validation steps, acceptance evidence and primary references.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/dq-composite-key-delimiter-ambiguity/
Language: en

A preprocessing job forms a key by joining source fields with a separator. A field itself contains that separator, making different field tuples produce the same serialized key.

## The mechanism that changes the example

A composite key needs an unambiguous representation of component boundaries, types and missingness. Hashing an ambiguous concatenation preserves its collision rather than repairing the encoding.



## Define the comparison boundary

A length-prefixed or structured tuple representation must define its own character encoding and type tags. The strings '1' and '01', the integer 1, an empty string, and an absent component need not represent the same business identity.

Test the encoder and decoder together using adversarial component values. Escaping is adequate only if the reverse procedure is unambiguous and uses the same versioned rules. A fixed separator with informal replacement rules is difficult to audit across independent producers.

Keep normalization separate from serialization. If case folding or Unicode normalization intentionally merges source identities, record that business decision before constructing the key. A cryptographic hash can compact a well-defined byte representation, but it cannot determine whether two source tuples should have been considered equal.

## A constructed test case

Construct source tuples in which the chosen delimiter also appears inside a component. Show that naive concatenation can yield the same key for different tuples, then demonstrate exact reconstruction under the approved canonical encoding.

## A reproducible validation procedure

Generate tuples containing separators, empty strings and missing components. Round-trip the chosen canonical representation and compare tuple identity. Verify uniqueness before hashing and version the key-construction rule.

Include an unchanged control and a deliberately invalid case. Verify that the checker distinguishes them before testing the complete release.

Exercise the actual preparation path, including later serialization and reload. Limit retained diagnostic content to the evidence required for this comparison.

## Evidence needed for acceptance

Retain the original components and a collision audit for the serialized composite key.

## Containment and recovery

A collision-free representation does not make an unstable business key suitable for long-lived lineage.

Quarantine an invalid release candidate or use an explicit partial-release rule. Preserve the last approved artifact and record corrections without silently rewriting historical inputs.

## Interpretation and references

Implementation references: [JSON data interchange specification](https://www.rfc-editor.org/rfc/rfc8259); [pandas merge validation](https://pandas.pydata.org/docs/reference/api/pandas.merge.html).

This is a proposed engineering validation, not an executed Retrivium benchmark. Documentation specifies interfaces; dataset acceptance needs its own evidence and must be repeated after relevant dependency changes.

## Related reading

Continue with [COCO: preserve image and annotation identities](/journal/data-guide-coco-instance-caption-identities/); [Unicode comparison keys need a chosen equivalence rule](/journal/guide-unicode-api-comparison-key/). These guides supply adjacent context; the decision in this article remains the specific example-preservation check above.
