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
fix(storage): 修复写入协调消息提前消费导致的锁泄漏 (#6300)
bot-of-qin-ctxc89efb7c37dc
diff --git a/openviking/storage/content_write.py b/openviking/storage/content_write.pyindex 9cdacb092..5f53d98f8 100644--- a/openviking/storage/content_write.py+++ b/openviking/storage/content_write.py@@ -428,7 +428,7 @@ class ContentWriteCoordinator:Each operation follows the same create/replace/append semantics as ``write``;``upsert`` is available for callers that already hold the desired final tree.All target files stay locked from state validation through the last write,- while unrelated files remain writable. Refresh starts after the locks are released.+ while unrelated files remain writable. Locks are released after refresh completes.Derived summaries are generated once per batch. Operation count and content size haveno application-level quotas; all operations undergo access and path validation.With skip_conflicts, changed, missing or occupied targets are returned in@@ -467,7 +467,6 @@ class ContentWriteCoordinator:prepared_resources: dict[str, _PreparedInlineResource] = {}committed_resource_plans: list[_PreparedInlineResource] = []write_error: Exception | None = None- lock_settled = Falsetry:for operation in normalized_operations:uri = operation["uri"]@@ -587,24 +586,20 @@ class ContentWriteCoordinator:refresh_kinds[uri] = "added"except BaseException:await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = Trueraisetelemetry_id = get_current_telemetry().telemetry_idcoordinator_work_id: str | None = None- handoff_pending = Falserefresh_outcome: Optional[_BatchRefreshOutcome] = Nonetry:if refresh_kinds or sidecar_directories or committed_resource_plans:- lock_handoff = await self._viking_fs._async_agfs.pathlock_to_handoff(lease)- _, coordinator_work_id = await self._enqueue_lock_coordinator(+ coordinator_work_id = await self._enqueue_lock_coordinator(root_uri=normalized_root,context_type=context_type_for_uri(normalized_root),ctx=ctx,telemetry_id=telemetry_id,- lock_handoff=lock_handoff,+ lease=lease,)- handoff_pending = Truetry:for directory_uri, options in sorted(sidecar_directories.items()):await self._vectorize_semantic_directory(@@ -689,7 +684,6 @@ class ContentWriteCoordinator:"Batch refresh failed while preserving an earlier write error",exc_info=True,)- queue_status = Noneelse:cause = str(exc).strip() or type(exc).__name__raise OpenVikingError(@@ -706,51 +700,22 @@ class ContentWriteCoordinator:"cause": cause,},) from exc- finally:- if coordinator_work_id is not None:- await run_to_completion(- lambda: self._mark_coordinator_enqueue_complete(- coordinator_work_id, ctx- )- )- coordinator_work_id = None-- if handoff_pending:- try:- await self._viking_fs._async_agfs.pathlock_handoff(lease)- except BaseException:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True- raise- else:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True- queue_status = (- await self._wait_for_request(telemetry_id=telemetry_id)- if wait and wait_for_queues- else refresh_outcome.queue_status- if refresh_outcome is not None- else None- )- if wait and wait_for_queues and queue_status is not None and write_error is None:- self._raise_refresh_errors(queue_status)- if refresh_outcome is not None and queue_status is not None:- refresh_outcome = replace(refresh_outcome, queue_status=queue_status)- else:- queue_status = None- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = Truefinally:- if not lock_settled:- if handoff_pending:- try:- await self._viking_fs._async_agfs.pathlock_handoff(lease)- except BaseException:- await self._viking_fs._async_agfs.pathlock_release(lease)- raise- else:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True+ await run_to_completion(+ lambda: self._finish_write_lock(lease, coordinator_work_id, ctx)+ )++ queue_status = (+ await self._wait_for_request(telemetry_id=telemetry_id)+ if coordinator_work_id is not None and wait and wait_for_queues+ else refresh_outcome.queue_status+ if refresh_outcome is not None+ else None+ )+ if wait and wait_for_queues and queue_status is not None and write_error is None:+ self._raise_refresh_errors(queue_status)+ if refresh_outcome is not None and queue_status is not None:+ refresh_outcome = replace(refresh_outcome, queue_status=queue_status)if write_error is not None:raise write_error@@ -1072,8 +1037,8 @@ class ContentWriteCoordinator:context_type: str,ctx: RequestContext,telemetry_id: str,- lock_handoff: dict[str, Any],- ) -> tuple[SemanticMsg, str]:+ lease: Any,+ ) -> str:"""Enqueue the sole lease owner before scheduling request work."""context = get_task_context()if context is None:@@ -1090,7 +1055,7 @@ class ContentWriteCoordinator:role=str(ctx.role),skip_vectorization=True,telemetry_id=telemetry_id,- lock_handoff=lock_handoff,+ lock_handoff=await self._viking_fs._async_agfs.pathlock_to_handoff(lease),generation_trigger="content_write",aggregate_directory=False,propagate_to_parent=False,@@ -1100,19 +1065,29 @@ class ContentWriteCoordinator:receipt = await semantic_queue.enqueue(msg)if not receipt.work_id:raise RuntimeError("Lock coordinator was enqueued without Task Work identity")- return msg, receipt.work_id+ return receipt.work_id- async def _mark_coordinator_enqueue_complete(+ async def _finish_write_lock(self,- work_id: str,+ lease: Any,+ coordinator_work_id: str | None,ctx: RequestContext,) -> None:+ """Publish completion only after the producer has handed off its lease."""+ agfs = self._viking_fs._async_agfs+ if coordinator_work_id is None:+ await agfs.pathlock_release(lease)+ return+ try:+ await agfs.pathlock_handoff(lease)+ except BaseException:+ await agfs.pathlock_release(lease)+ raisecontext = get_task_context()- if context is None:- raise RuntimeError("TaskContext is required for lock-coordinated content writes")+ assert context is not Noneawait get_task_tracker().mark_enqueue_complete(context.task_id,- work_id,+ coordinator_work_id,account_id=ctx.account_id,user_id=ctx.user.user_id,)@@ -1620,9 +1595,7 @@ class ContentWriteCoordinator:) from excprevious_content: Optional[str] = None- lock_settled = Falsecoordinator_work_id: str | None = None- handoff_pending = Falsetry:target_state = await self._classify_locked_write_target(uri, ctx=ctx)target_preexisting = target_state.preexisting@@ -1660,15 +1633,13 @@ class ContentWriteCoordinator:prepared.plan.direct_index_actions or prepared.plan.file_refresh is not None)if has_async_work:- lock_handoff = await self._viking_fs._async_agfs.pathlock_to_handoff(lease)- _, coordinator_work_id = await self._enqueue_lock_coordinator(+ coordinator_work_id = await self._enqueue_lock_coordinator(root_uri=uri,context_type=context_type,ctx=ctx,telemetry_id=telemetry_id,- lock_handoff=lock_handoff,+ lease=lease,)- handoff_pending = Truework = await commit_and_enqueue_plan(prepared.plan,ctx=ctx,@@ -1688,58 +1659,32 @@ class ContentWriteCoordinator:ingest_options.acl_update, ctx)- if coordinator_work_id is not None:- await run_to_completion(- lambda: self._mark_coordinator_enqueue_complete(coordinator_work_id, ctx)- )- coordinator_work_id = None- if handoff_pending:- try:- await self._viking_fs._async_agfs.pathlock_handoff(lease)- except BaseException:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True- raise- else:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True-- queue_status = (- await self._wait_for_request(telemetry_id=telemetry_id)- if wait and wait_for_queues- else None- )- written_bytes = len(final_bytes)- semantic_status, vector_status = self._plan_statuses(- work, wait=wait and wait_for_queues, queue_status=queue_status- )- return self._build_write_result(- uri=uri,- root_uri=root_uri,- context_type=context_type,- mode=response_mode,- written_bytes=written_bytes,- queue_status=queue_status,- semantic_status=semantic_status,- vector_status=vector_status,- )- except BaseException:- # Once formal content is committed it is not rolled back for a later- # enqueue failure. The request propagates that failure so the caller- # can retry; explicit writes always recommit their final bytes, even- # when N already matches V, which makes that retry safe while V lags F.- raisefinally:- if not lock_settled:- if handoff_pending:- try:- await self._viking_fs._async_agfs.pathlock_handoff(lease)- except BaseException:- await self._viking_fs._async_agfs.pathlock_release(lease)- raise- else:- await self._viking_fs._async_agfs.pathlock_release(lease)- lock_settled = True+ # Committed content is retained even if a later enqueue fails. Already+ # queued work must still finish before its coordinator releases the lock.+ await run_to_completion(+ lambda: self._finish_write_lock(lease, coordinator_work_id, ctx)+ )++ queue_status = (+ await self._wait_for_request(telemetry_id=telemetry_id)+ if wait and wait_for_queues+ else None+ )+ written_bytes = len(final_bytes)+ semantic_status, vector_status = self._plan_statuses(+ work, wait=wait and wait_for_queues, queue_status=queue_status+ )+ return self._build_write_result(+ uri=uri,+ root_uri=root_uri,+ context_type=context_type,+ mode=response_mode,+ written_bytes=written_bytes,+ queue_status=queue_status,+ semantic_status=semantic_status,+ vector_status=vector_status,+ )@staticmethoddef _ensure_explicit_write_content_action(diff --git a/openviking/storage/queuefs/semantic_msg.py b/openviking/storage/queuefs/semantic_msg.pyindex 4bbb151f6..626bc6839 100644--- a/openviking/storage/queuefs/semantic_msg.py+++ b/openviking/storage/queuefs/semantic_msg.py@@ -76,8 +76,6 @@ class SemanticMsg:aggregate_directory: bool = Trueuse_hierarchical_aggregation: bool = Falsepropagate_to_parent: bool = True- # Hold a producer's lease until already-enqueued embedding work settles.- wait_for_embeddings_only: bool = False# Hold a producer's lease until every other root in this request settles.wait_for_request_completion: bool = Falsecopy_source_uri: str = ""@@ -118,7 +116,6 @@ class SemanticMsg:aggregate_directory: bool = True,use_hierarchical_aggregation: bool = False,propagate_to_parent: bool = True,- wait_for_embeddings_only: bool = False,wait_for_request_completion: bool = False,copy_source_uri: str = "",file_md5s: Optional[Dict[str, str]] = None,@@ -159,7 +156,6 @@ class SemanticMsg:self.aggregate_directory = bool(aggregate_directory)self.use_hierarchical_aggregation = bool(use_hierarchical_aggregation)self.propagate_to_parent = bool(propagate_to_parent)- self.wait_for_embeddings_only = bool(wait_for_embeddings_only)self.wait_for_request_completion = bool(wait_for_request_completion)self.copy_source_uri = copy_source_uriself.file_md5s = dict(file_md5s or {})@@ -250,7 +246,6 @@ class SemanticMsg:aggregate_directory=data.get("aggregate_directory", True),use_hierarchical_aggregation=data.get("use_hierarchical_aggregation", False),propagate_to_parent=data.get("propagate_to_parent", True),- wait_for_embeddings_only=data.get("wait_for_embeddings_only", False),wait_for_request_completion=data.get("wait_for_request_completion", False),copy_source_uri=data.get("copy_source_uri", ""),file_md5s=(data.get("file_md5s") if isinstance(data.get("file_md5s"), dict) else None),diff --git a/openviking/storage/queuefs/semantic_processor.py b/openviking/storage/queuefs/semantic_processor.pyindex 3ed865652..21b9ed482 100644--- a/openviking/storage/queuefs/semantic_processor.py+++ b/openviking/storage/queuefs/semantic_processor.py@@ -570,26 +570,8 @@ class SemanticProcessor(DequeueHandlerBase):logger.debug("Processing semantic message id=%s uri=%s", msg.id, msg.uri)- # Resolving a deleted root can recreate it for lock metadata.- # Settle queued ownership before acknowledging skipped work.- if not await get_viking_fs().exists(msg.uri, ctx=current_ctx):- logger.info("Skipping semantic message for missing root: uri=%s", msg.uri)- await work.skip()- return ProcessResult.success()-- if (- not msg.wait_for_embeddings_only- and not msg.wait_for_request_completion- and self._vlm_resolver is None- ):- raise RuntimeError(- "SemanticProcessor requires a VLM resolver for account-owned work"- )- if not await work.acquire_lock(current_ctx):- return ProcessResult.success()- semantic_lock = work.scope- assert semantic_lock is not Nonetask_context = get_task_context()+ enqueue_complete = Trueif msg.wait_for_request_completion and task_context is not None:tracker = get_task_tracker()enqueue_complete = await tracker.is_enqueue_complete(@@ -604,29 +586,43 @@ class SemanticProcessor(DequeueHandlerBase):account_id=task_context.account_id,user_id=task_context.user_id,)- else:- enqueue_complete = True- siblings_pending = False- if not enqueue_complete and not tracker.has_active_producer(- task_context.task_id+ if siblings_pending or (+ not enqueue_complete+ and tracker.has_active_producer(task_context.task_id)+ ):+ # Leave ownership with the producer until it finishes+ # submission and hands off, without occupying a worker.+ await asyncio.sleep(0.05)+ await work.reenqueue()+ execute_status = "requeued"+ return ProcessResult.requeued()++ # Resolving a deleted root can recreate it for lock metadata.+ # Settle queued ownership before acknowledging skipped work.+ if not msg.wait_for_request_completion and not await get_viking_fs().exists(+ msg.uri, ctx=current_ctx):+ logger.info("Skipping semantic message for missing root: uri=%s", msg.uri)+ await work.skip()+ return ProcessResult.success()++ if not msg.wait_for_request_completion and self._vlm_resolver is None:+ raise RuntimeError(+ "SemanticProcessor requires a VLM resolver for account-owned work"+ )+ if not await work.acquire_lock(current_ctx):+ return ProcessResult.success()+ semantic_lock = work.scope+ assert semantic_lock is not None+ if not enqueue_complete:return ProcessResult.failed("Content write producer ended before child Work enqueue completed")- if not enqueue_complete or siblings_pending:- # Keep a single-worker semantic queue moving while this- # coordinator retains the producer's lease.- await asyncio.sleep(0.05)- await work.reenqueue()- execute_status = "requeued"- return ProcessResult.requeued()dag_stats = Noneprocessing_succeeded = Falsetry:- if msg.wait_for_embeddings_only or msg.wait_for_request_completion:- # SemanticMessageWork drains embeddings for the single-write- # coordinator; the batch coordinator reaches this point only- # after every sibling root has settled.+ if msg.wait_for_request_completion:+ # The coordinator only releases the lease after sibling work settles.passelif msg.plan is not None:if msg.uri.rstrip("/") != msg.plan.root_uri:@@ -752,12 +748,7 @@ class SemanticProcessor(DequeueHandlerBase):incremental_update=is_incremental,target_uri=target_uri,recursive=msg.recursive,- lock=(- None- if msg.generation_trigger == "content_write"- and msg.lock_handoff is not None- else semantic_lock.lock- ),+ lock=semantic_lock.lock,is_code_repo=msg.is_code_repo,changes=changes,skip_vectorization=msg.skip_vectorization,diff --git a/tests/storage/test_content_write_processing_mode.py b/tests/storage/test_content_write_processing_mode.pyindex fd2140968..5dec204dd 100644--- a/tests/storage/test_content_write_processing_mode.py+++ b/tests/storage/test_content_write_processing_mode.py@@ -1,6 +1,7 @@# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.# SPDX-License-Identifier: AGPL-3.0+import asynciofrom types import SimpleNamespacefrom unittest.mock import AsyncMock@@ -9,7 +10,7 @@ import pytestfrom openviking.core.context import ContextLevelfrom openviking.server.identity import RequestContext, Rolefrom openviking.service.task_store import PersistentTaskStore-from openviking.service.task_tracker import TaskTracker+from openviking.service.task_tracker import TaskTracker, get_task_trackerfrom openviking.service.task_work_index import bind_task_contextfrom openviking.session.memory.utils.memory_file_utils import MemoryFileUtilsfrom openviking.storage import content_write as content_write_module@@ -20,8 +21,7 @@ from openviking.storage.content_write import ContentWriteCoordinatorfrom openviking.storage.context_update_plan import ContextUpdatePlan, FileRefreshIntentfrom openviking.storage.queuefs.queue_middleware import EnqueueReceiptfrom openviking.storage.queuefs.semantic_ops.freshness_policy import FreshnessAction-from openviking.telemetry.context import bind_telemetry-from openviking.telemetry.operation import OperationTelemetry+from openviking.storage.queuefs.semantic_processor import SemanticProcessorfrom openviking.utils.ingest_options import IngestOptionsfrom openviking_cli.exceptions import InvalidArgumentError, NotFoundErrorfrom openviking_cli.session.user_id import UserIdentifier@@ -275,66 +275,91 @@ async def test_direct_write_reads_target_once_after_lock_and_reuses_formal_state@pytest.mark.asyncio-async def test_direct_write_hands_exact_lock_to_request_coordinator(monkeypatch, ctx):[email protected]("write_error", [None, RuntimeError, asyncio.CancelledError])+async def test_direct_write_holds_lock_until_submitted_work_settles(monkeypatch, ctx, write_error):uri = "viking://resources/demo.md"fake_fs = _FakeVikingFS()- fake_fs.stat = AsyncMock(return_value={"isDir": False})+ fake_fs.stat = AsyncMock(return_value={"not_found": True})+ fake_fs.exists = AsyncMock(return_value=False)coordinator = ContentWriteCoordinator(viking_fs=fake_fs)- plan = ContextUpdatePlan(- uri,- "resource",- file_refresh=FileRefreshIntent(uri, "new-md5"),- )coordinator._prepare_inline_resource_plan = AsyncMock(return_value=SimpleNamespace(- plan=plan,+ plan=ContextUpdatePlan(uri, "resource", file_refresh=FileRefreshIntent(uri, "new-md5")),store=None,artifact_ref=None,target=None,))- monkeypatch.setattr(- content_write_module,- "commit_and_enqueue_plan",- AsyncMock(- return_value=SimpleNamespace(- semantic_requested=True,- vector_requested=True,- semantic_action=FreshnessAction.REFRESH_NOW.value,- )- ),- )queue = SimpleNamespace(enqueue=AsyncMock(return_value=EnqueueReceipt("queued", "work-1")))- manager = SimpleNamespace(SEMANTIC="semantic", get_queue=lambda *args, **kwargs: queue)+ manager = SimpleNamespace(SEMANTIC="Semantic", get_queue=lambda *args, **kwargs: queue)monkeypatch.setattr(content_write_module, "get_queue_manager", lambda: manager)- telemetry = OperationTelemetry(operation="content.write", enabled=False)-- with (- bind_telemetry(telemetry),- bind_task_context("test-task", "account-1", "user-1", enqueued_work=[]),+ monkeypatch.setattr(+ "openviking.storage.queuefs.semantic_processor.get_viking_fs", lambda: fake_fs+ )+ scope = SimpleNamespace(lock={"id": "lock-1"}, close=AsyncMock())+ monkeypatch.setattr(+ "openviking.storage.queuefs.semantic_processor.SemanticLockScope.resolve",+ AsyncMock(return_value=scope),+ )+ processor = SemanticProcessor(vlm_resolver=None)+ processor._reenqueue_semantic_msg = AsyncMock()+ tracker = get_task_tracker()+ owner = {"account_id": ctx.account_id, "user_id": ctx.user.user_id}+ task = await tracker.create("content_write", **owner)+ for work_id, queue_name in (+ ("producer", "Inline"),+ ("work-1", "Semantic"),+ ("embed", "Embedding"),):- result = await coordinator._write_direct_with_refresh(- uri=uri,- root_uri="viking://resources",- content="updated",- mode="replace",- response_mode="replace",- context_type="resource",- wait=False,- ctx=ctx,- telemetry_id=telemetry.telemetry_id,- ingest_options=IngestOptions(),+ await tracker.register_work(task.task_id, work_id, queue_name, **owner)++ async def consume():+ with bind_task_context(task.task_id, **owner, work_id="work-1", enqueued_work=[]):+ return await processor.on_dequeue(queue.enqueue.await_args.args[0].to_dict())++ async def commit(*args, **kwargs):+ # The coordinator runs before the new file exists or the producer hands off.+ assert (await consume()).outcome.value == "requeued"+ scope.close.assert_not_awaited()+ if write_error is not None:+ raise write_error("submission interrupted")+ return SimpleNamespace(+ semantic_requested=True,+ vector_requested=True,+ semantic_action=FreshnessAction.REFRESH_NOW.value,)- coordinator_msg = queue.enqueue.await_args.args[0]- assert coordinator_msg.wait_for_request_completion is True- assert coordinator_msg.lock_handoff["covered_paths"] == [- {"path": "/fake/file", "kind": "exact"}- ]+ monkeypatch.setattr(content_write_module, "commit_and_enqueue_plan", commit)+ with bind_task_context(task.task_id, **owner, work_id="producer", enqueued_work=[]):+ try:+ result = await coordinator._write_direct_with_refresh(+ uri=uri,+ root_uri="viking://resources",+ content="updated",+ mode="replace",+ response_mode="replace",+ context_type="resource",+ wait=False,+ ctx=ctx,+ telemetry_id="",+ ingest_options=IngestOptions(),+ )+ except BaseException as exc:+ assert write_error is not None and isinstance(exc, write_error)+ else:+ assert write_error is None+ assert result["semantic_status"] == result["vector_status"] == "queued"+assert fake_fs._async_agfs.release_calls == []assert fake_fs._async_agfs.handoff_calls == ["lock-1"]- assert result["semantic_status"] == "queued"- assert result["vector_status"] == "queued"+ assert await tracker.is_enqueue_complete(task.task_id, "work-1", **owner)+ await tracker.mark_work_done(task.task_id, "producer", **owner)+ assert (await consume()).outcome.value == "requeued"+ scope.close.assert_not_awaited()+ await tracker.mark_work_done(task.task_id, "embed", **owner)+ assert (await consume()).outcome.value == "success"+ scope.close.assert_awaited_once()+ await tracker.mark_work_done(task.task_id, "work-1", **owner)@pytest.mark.asynciodiff --git a/tests/storage/test_semantic_processor_target_preexisting.py b/tests/storage/test_semantic_processor_target_preexisting.pyindex 278a67a82..242c59bf6 100644--- a/tests/storage/test_semantic_processor_target_preexisting.py+++ b/tests/storage/test_semantic_processor_target_preexisting.py@@ -187,77 +187,6 @@ async def test_stale_content_write_keeps_file_work_without_directory_aggregationprocessor._enqueue_parent_refresh.assert_not_awaited()-async def test_content_write_handoff_is_not_reused_for_sidecar_writes(monkeypatch):- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.get_viking_fs",- lambda: _FakeVikingFS(),- )- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.SemanticTreeExecutor",- _FakeTreeExecutor,- )- scope = SimpleNamespace(lock={"id": "file-exact-lock"}, close=AsyncMock())- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.SemanticLockScope.resolve",- AsyncMock(return_value=scope),- )-- _FakeTreeExecutor.calls = []- _FakeTreeExecutor.runs = []- processor = _processor()- processor._enqueue_parent_refresh = AsyncMock()- msg = SemanticMsg(- uri="viking://resources/wiki",- context_type="resource",- recursive=False,- changes={"modified": ["viking://resources/wiki/changed.md"]},- generation_trigger="content_write",- lock_handoff={"owner_id": "producer"},- )-- await processor.on_dequeue(msg.to_dict())-- assert _FakeTreeExecutor.calls[0]["lock"] is None- scope.close.assert_awaited_once()---async def test_embedding_lock_wait_skips_semantic_execution(monkeypatch):- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.get_viking_fs",- lambda: _FakeVikingFS(),- )- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.SemanticTreeExecutor",- _FakeTreeExecutor,- )- scope = SimpleNamespace(lock={"id": "file-exact-lock"}, close=AsyncMock())- monkeypatch.setattr(- "openviking.storage.queuefs.semantic_processor.SemanticLockScope.resolve",- AsyncMock(return_value=scope),- )-- _FakeTreeExecutor.calls = []- _FakeTreeExecutor.runs = []- processor = SemanticProcessor(vlm_resolver=None)- msg = SemanticMsg(- uri="viking://resources/wiki/changed.md",- context_type="resource",- recursive=False,- skip_vectorization=True,- lock_handoff={"owner_id": "producer"},- generation_trigger="content_write",- aggregate_directory=False,- wait_for_embeddings_only=True,- )-- await processor.on_dequeue(msg.to_dict())-- assert _FakeTreeExecutor.calls == []- scope.close.assert_awaited_once()--@pytest.mark.asyncio@pytest.mark.parametrize("recursive", [False, True])async def test_memory_reindex_uses_semantic_executor(monkeypatch, recursive):