Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""
Immutable merge operation - field cannot be changed once set.
"""
from typing import Any, Type
from openviking.session.memory.merge_op.base import (
FieldType,
MergeOp,
MergeOpBase,
get_python_type_for_field,
)
class ImmutableOp(MergeOpBase):
"""Immutable merge operation - field cannot be changed once set."""
op_type = MergeOp.IMMUTABLE
def get_output_schema_type(self, field_type: FieldType) -> Type[Any]:
return get_python_type_for_field(field_type)
def get_output_schema_description(self, field_description: str) -> str:
return (
f"Immutable field '{field_description}' - can only be set once, cannot be modified. "
"None and blank strings are unset and may receive their first value."
)
@staticmethod
def is_set(value: Any) -> bool:
"""Blank string placeholders are unset; zero and False are real values."""
return value is not None and not (isinstance(value, str) and not value.strip())
async def apply(self, current_value: Any, patch_value: Any) -> Any:
if not self.is_set(current_value):
return patch_value
# Keep current value if already set
return current_value