pub struct Document {
pub id: Uuid,
pub path_id: Uuid,
pub path: PathBuf,
pub hash: [u8; 32],
pub hierarchical_hash: [u8; 32],
pub mtime: i64,
pub size: u64,
pub mime_type: String,
pub arweave_tx: Option<String>,
}Expand description
A document node in the cognitive graph
Represents a single ingested file with its content hash for change detection and deduplication.
Fields§
§id: UuidUnique identifier for this document (BLAKE3-16 of content_hash)
path_id: UuidPath-based identifier for change detection (BLAKE3-16 of canonicalized path)
path: PathBufOriginal file path (relative to watched root)
hash: [u8; 32]BLAKE3 hash of file contents (canonicalized)
hierarchical_hash: [u8; 32]Merkle root of chunks (hierarchical hash)
mtime: i64Last modification time (Unix timestamp)
size: u64File size in bytes
mime_type: StringMIME type (e.g., “application/pdf”, “text/markdown”)
arweave_tx: Option<String>Arweave transaction ID if this document was synced from Arweave
Implementations§
Source§impl Document
impl Document
pub fn new(path: PathBuf, content: &[u8], mtime: i64) -> Self
Sourcepub fn set_hierarchical_hash(&mut self, hash: [u8; 32])
pub fn set_hierarchical_hash(&mut self, hash: [u8; 32])
Update the hierarchical hash (Merkle root of chunks)
Sourcepub fn compute_hierarchical_hash(chunk_hashes: &[[u8; 32]]) -> [u8; 32]
pub fn compute_hierarchical_hash(chunk_hashes: &[[u8; 32]]) -> [u8; 32]
Compute Merkle hash from chunks for provable correctness. Sorts chunk hashes before hashing so order doesn’t affect the result.
Sourcepub fn content_changed(&self, new_content: &[u8]) -> bool
pub fn content_changed(&self, new_content: &[u8]) -> bool
Check if the document content has changed