def hash(self) -> str:
        """Hash the entity using only content-relevant fields."""
        if getattr(self, "_hash", None):
            return self._hash

        # Define content-relevant fields (exclude metadata fields)
        metadata_fields = {
            "sync_job_id",
            "vector",
            "_hash",
            "db_entity_id",
            "source_name",
            "sync_id",
            "sync_metadata",
        }

        # Get field names from the model
        all_fields = set(self.model_fields.keys())
        content_fields = all_fields - metadata_fields

        # Extract only content fields
        data = {k: v for k, v in self.model_dump().items() if k in content_fields}

        # Use stable serialization
        def stable_serialize(obj):
            if isinstance(obj, dict):
                return {k: stable_serialize(v) for k, v in sorted(obj.items())}
            elif isinstance(obj, (list, tuple)):
                return [stable_serialize(x) for x in obj]
            elif isinstance(obj, (str, int, float, bool, type(None))):
                return obj
            else:
                # Handle non-serializable types consistently
                return str(obj)

        # Create stable representation
        stable_data = stable_serialize(data)

        # Use canonical JSON encoding for consistent string representation
        json_str = json.dumps(stable_data, sort_keys=True, separators=(",", ":"))

        # Compute hash
        self._hash = hashlib.sha256(json_str.encode()).hexdigest()
        return self._hash
Hash the entity using only content-relevant fields.
backend/airweave/platform/entities/_base.py