Changeset 8aea9a0 in flexoentity
- Timestamp:
- 10/19/25 17:55:13 (3 months ago)
- Branches:
- master
- Children:
- dfce52b
- Parents:
- 3a0b0ce
- Files:
-
- 2 edited
-
flexoentity/id_factory.py (modified) (1 diff)
-
tests/test_id_stress.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
flexoentity/id_factory.py
r3a0b0ce r8aea9a0 108 108 hash_seed = canonical_seed(f"{domain}:{etype}:{text}") 109 109 base_hash = FlexOID._blake_hash(hash_seed) 110 # unique_hash = ( 111 # FlexOID._ensure_unique(base_hash) if enforce_unique else base_hash 112 # ) 110 113 unique_hash = ( 111 FlexOID._ensure_unique(base_hash) if enforce_unique else base_hash114 FlexOID._ensure_unique(base_hash) if enforce_unique and version == 1 else base_hash 112 115 ) 113 114 116 ver_part = f"{version:03d}{estate}" 115 117 flexo_id_str = f"{domain}-{etype}{date_part}-{unique_hash}@{ver_part}" -
tests/test_id_stress.py
r3a0b0ce r8aea9a0 26 26 assert len(ids) == len(set(ids)), "ID collisions detected in bulk generation" 27 27 28 29 def test_disambiguator_trigger(): 30 """ 31 Force a deterministic collision by hashing same text twice. 32 Should produce -A suffix for second one. 33 """ 34 domain = "AF" 35 etype = EntityType.QUESTION 36 estate = EntityState.DRAFT 37 text = "identical question text" 38 id1 = FlexOID.generate(domain, etype, estate, text) 39 id2 = FlexOID.generate(domain, etype, estate, text) 40 assert id1 != id2 41 assert id1.signature == id2.signature 42 assert "-A" in str(id2), f"Expected '-A' suffix in disambiguated ID, got {id2}" 43 44 28 def test_disambiguator_trigger(): 29 """ 30 Generating the same entity twice with same inputs yields identical ID. 31 (No runtime disambiguation; IDs are deterministic by design.) 32 """ 33 domain = "AF" 34 etype = EntityType.QUESTION 35 estate = EntityState.DRAFT 36 text = "identical question text" 37 id1 = FlexOID.generate(domain, etype, estate, text) 38 id2 = FlexOID.generate(domain, etype, estate, text) 39 # IDs must be identical, because we now enforce determinism, not randomization 40 assert id1 == id2 41 assert id1.signature == id2.signature 42 45 43 def test_id_reproducibility_across_runs(): 46 44 """
Note:
See TracChangeset
for help on using the changeset viewer.
