graflo.architecture.schema.identity_digest¶
Deterministic digest identity for hash-mode and funnel-mode vertices.
Identity is materialized at assemble time, before edges are assembled and
before documents are deduplicated on their identity fields. That ordering is not
incidental: a hash-mode vertex resolves to identity: ["id"], so a document
whose id is still empty has no dedup basis (merge_doc_basis folds the
whole batch into one document) and no endpoint key for its edges.
This module sits in architecture.schema (L2) rather than db (L5) because
architecture.pipeline (L4) calls into it — see test_layering. It mirrors
:mod:~graflo.architecture.schema.identity_uuid, which plays the same role for
assigned mode.
compute_funnel_identity(doc, funnel)
¶
Digest the first complete branch of funnel, or None if none fires.
A branch fires when every field in its when_all_present (defaulting to
its fields) is present and non-empty. None means the document has no
identity under this policy — callers must leave the identity field empty
rather than inventing a key, so the caster can drop the document.
Source code in graflo/architecture/schema/identity_digest.py
compute_hash_identity(doc, source_fields)
¶
Compute a deterministic SHA256 hex digest from source field values.
The payload is {field: value} with no branch marker, which is what makes
a legacy hash_identity_properties digest byte-identical to the values
produced before funnels existed. Do not add keys to this payload.
Source code in graflo/architecture/schema/identity_digest.py
compute_vertex_identity(doc, vertex)
¶
Synthetic identity for doc under vertex's digest policy.
Returns None when the vertex has no digest policy, when no funnel branch
fires, or when every flat source field is empty — the last case would
otherwise digest {field: None} and fold every empty document onto one
shared key.
Source code in graflo/architecture/schema/identity_digest.py
ensure_digest_identities_in_acc_vertex(acc_vertex, vertex_config)
¶
Materialize digest identities on acc_vertex docs before edge assembly.
acc_vertex maps vertex name -> location -> list of VertexRep (or
objects exposing a .vertex dict). Shaped like
:func:~graflo.architecture.schema.identity_uuid.ensure_assigned_uuids_in_acc_vertex.
Source code in graflo/architecture/schema/identity_digest.py
ensure_digest_identities_on_docs(data, vertex, *, preferred_field)
¶
Idempotent digest-identity ensure for a flat doc list (writer safety net).
Source code in graflo/architecture/schema/identity_digest.py
ensure_digest_identity_on_doc(doc, vertex, *, field)
¶
Fill an empty field on doc with its digest identity, in place.
Idempotent: a document that already carries a value is left untouched, so the writer-side safety net cannot overwrite an assemble-time key.