When you create a Knowledge Block that builds on existing knowledge, you declare that relationship explicitly in theDocumentation Index
Fetch the complete documentation index at: https://docs.xandrlabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
sources array. Each entry is a kbHash value pointing to a parent KB. The protocol treats these references as edges in a directed acyclic graph (DAG): edges run from child to parent, and the global graph of all published KBs must remain acyclic. This structure makes the full derivation history of any KB traceable without relying on a central index.
The sources array
sources is an array of kbHash strings — one entry per parent KB. A root KB (one that is not derived from anything) has an empty sources array. A KB that synthesizes two prior KBs lists both of their kbHash values:
Normalization before hashing
For identity purposes,sources is treated as a set, not an ordered list. Before computing kbHash, the protocol:
- Removes duplicate entries from
sources. - Sorts the remaining entries lexicographically.
- Checks that no entry matches the KB’s own eventual
kbHash(self-reference is forbidden).
kbHash values will produce the same kbHash after normalization. You do not need to pre-sort sources before calling kbHashFromEnvelope — normalization is applied automatically.
Sorting at hash time does not mean duplicate or cyclic lineage is valid. Duplicates and cycles are rejected during publication and registry validation. Normalization only defines a deterministic preimage for a well-formed envelope.
Building a derived KB
UsebuildDerivedEnvelope from @alx/protocol to construct a KB that references parent KBs. The function handles source normalization (sorting and 0x-prefix normalization) and artifactHash derivation automatically:
buildDerivedEnvelope sorts sources lexicographically and ensures all kbId values in derivation.inputs carry the 0x prefix, so the envelope it returns is ready to hash.
Immutability after publication
Once a KB is published, its lineage is permanently fixed. The publishedkbHash already commits to the normalized sources array — changing lineage would require a different kbHash, which means it would be a different KB.
If you need to revise the lineage of a KB, publish a new KB and reference the old one in its sources array to preserve the history chain. This append-only model ensures no published KB can be silently retroactively modified.
Parent limits
The reference registry contract allows a maximum of 8 parent KBs per Knowledge Block. Attempts to publish a KB with more than 8 entries insources will be rejected by the contract.
Validation rules
The protocol enforces the following rules onsources during publication:
| Rule | Effect |
|---|---|
| Self-reference | Rejected — a KB cannot list itself as a parent |
| Duplicate entries | Rejected during publication (normalized away for hashing only) |
| Cycles (direct or indirect) | Rejected — the global DAG must remain acyclic |
| More than 8 parents | Rejected by the registry contract |
Why lineage matters
Lineage is how ALX Protocol makes attribution and value distribution deterministic. Because every KB explicitly declares its parents, the full graph of contributions to any KB is always visible and verifiable. This enables:- Attribution — identifying which KBs contributed to a given output.
- Settlement — distributing value to contributors in proportion to their lineage participation.
- Traceability — auditing the provenance of any artifact, including in AI pipelines and multi-agent systems.
kbHash, so the history of how knowledge evolved is preserved in the graph structure itself.
For the identity derivation formula that commits to sources, see Identity. For the canonicalization step that processes sources before hashing, see Canonicalization.