Skip to content

fix(cli): open_verb fails provider:id routing + UX polish #471

Closed

Description

@Sinity

Problem

NFC normalization gap

hash_text() in lib/hashing.py:16-25 correctly applies unicodedata.normalize("NFC", text). But hash_payload() in lib/hashing.py:39-48 does NOT normalize string values. _normalize_for_hash() at pipeline/ids.py:60-73 also performs no Unicode normalization.

The same conversation parsed from two different export sources (one NFC, one NFD) produces different content hashes → unnecessary re-ingestion.

Attachment seed collision

attachment_seed() at pipeline/ids.py:76-89 filters out None values with | separator. If message_provider_id is None, downstream fields shift left:

  • provider="chatgpt", attachment_id="a", message_provider_id=None, name="bob" → "chatgpt|a|bob|..."
  • provider="chatgpt", attachment_id="a", message_provider_id="bob", name=None → "chatgpt|a|bob|..." (identical)

This fallback path is only triggered when file is missing AND no sha256/digest/hash in metadata, so practical collision rate is low but correctness gap remains.

Affected code

  • lib/hashing.py:39-48 — hash_payload doesn't normalize
  • pipeline/ids.py:60-73 — _normalize_for_hash no NFC
  • pipeline/ids.py:76-89 — attachment_seed None-filtering collision

Fix direction

  • Add unicodedata.normalize("NFC", ...) to _normalize_for_hash() for every string value
  • Use explicit sentinel for None in attachment_seed instead of filtering

Discovered during adversarial audit 2026-04-26.

Activity

  1. added
    type:fix
    area:core
    on Apr 26, 2026
  2. changed the title [-]fix(hash): NFC normalization gap + attachment seed collision[/-] [+]fix(cli): open_verb fails provider:id routing + UX polish[/+] on Apr 26, 2026
  3. Sinity commented on Apr 26, 2026

    @Sinity
    OwnerAuthor

    Partially addressed by #489. Remaining items tracked in this issue.

  4. Sinity commented on Apr 27, 2026

    @Sinity
    OwnerAuthor

    Verified resolved on master. Both sub-issues are already fixed:

    _normalize_for_hash (polylogue/pipeline/ids.py) applies unicodedata.normalize("NFC", value) to every string scalar — the hash_payload path goes through this function. The committed implementation already addresses the NFC gap.

    attachment_seed (polylogue/pipeline/ids.py:80-92) already uses the explicit <null> sentinel for None values, so the field-shifting collision described in the issue cannot happen — (provider, attachment_id, None, name) and (provider, attachment_id, name, None) produce different seeds.

    No code change required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coretype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions