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(queuefs): reuse outer lock_handle for sidecar, image rewrite and experience writebacks (#2953)
baojun-zhang56c7f3d47269
diff --git a/openviking/parse/image_rewrite.py b/openviking/parse/image_rewrite.pyindex 366f10b62..7652d1d9f 100644--- a/openviking/parse/image_rewrite.py+++ b/openviking/parse/image_rewrite.py@@ -275,7 +275,13 @@ async def rewrite_image_uris(if rewrite_count > 0:try:- await viking_fs.write_file(md_uri, new_content, ctx=ctx)+ # TODO: This must be optimized once pathlock is pushed down into ragfs.+ await viking_fs.write_file(+ md_uri,+ new_content,+ ctx=ctx,+ lock_handle=lock_handle,+ )files_processed += 1references_rewritten += rewrite_countlogger.debug(f"[image_rewrite] Rewrote {rewrite_count} image ref(s) in {md_uri}")diff --git a/openviking/session/compressor_v2.py b/openviking/session/compressor_v2.pyindex 29fd1edd0..1be0238da 100644--- a/openviking/session/compressor_v2.py+++ b/openviking/session/compressor_v2.py@@ -1031,6 +1031,7 @@ class SessionCompressorV2:normalized_traj_uris,ctx,viking_fs,+ lock_handle=lock_handle,)except Exception as e:logger.warning(f"Failed to append source trajectories to {exp_uri}: {e}")@@ -1041,6 +1042,7 @@ class SessionCompressorV2:traj_uris: List[str],ctx,viking_fs,+ lock_handle=None,) -> None:from datetime import timezone@@ -1064,7 +1066,13 @@ class SessionCompressorV2:mf.links = new_exp_linksif links_changed:- await viking_fs.write_file(exp_uri, MemoryFileUtils.write(mf), ctx=ctx)+ # TODO: This must be optimized once pathlock is pushed down into ragfs.+ await viking_fs.write_file(+ exp_uri,+ MemoryFileUtils.write(mf),+ ctx=ctx,+ lock_handle=lock_handle,+ )tracer.info(f"[agent_link] wrote exp→traj links -> {exp_uri} (traj_count={len(traj_uris)})")diff --git a/openviking/storage/queuefs/semantic_processor.py b/openviking/storage/queuefs/semantic_processor.pyindex 9232071ce..8ff448a72 100644--- a/openviking/storage/queuefs/semantic_processor.py+++ b/openviking/storage/queuefs/semantic_processor.py@@ -1008,7 +1008,13 @@ class SemanticProcessor(DequeueHandlerBase):except Exception:continue # no sidecar at this leveltry:- await viking_fs.write_file(target_mapping, mapping_content, ctx=ctx)+ # TODO: This must be optimized once pathlock is pushed down into ragfs.+ await viking_fs.write_file(+ target_mapping,+ mapping_content,+ ctx=ctx,+ lock_handle=lock.handle,+ )except Exception:# Target subtree may not exist (doc removed in sync); skip.pass@@ -1173,9 +1179,7 @@ class SemanticProcessor(DequeueHandlerBase):first_sentence_end = Nonelast_sentence_end_within_limit = None- for sentence_end_match in re.finditer(- r"\.(?!\d)(?=\s|$)|[!?](?=\s|$)|[。?!]", text- ):+ for sentence_end_match in re.finditer(r"\.(?!\d)(?=\s|$)|[!?](?=\s|$)|[。?!]", text):sentence_end = sentence_end_match.end()if first_sentence_end is None:first_sentence_end = sentence_enddiff --git a/openviking/storage/queuefs/semantic_sidecar.py b/openviking/storage/queuefs/semantic_sidecar.pyindex 8bb129373..0c5c083fd 100644--- a/openviking/storage/queuefs/semantic_sidecar.py+++ b/openviking/storage/queuefs/semantic_sidecar.py@@ -34,7 +34,7 @@ async def write_semantic_sidecars(lock_manager = get_lock_manager()except Exception:- await _write_sidecars(viking_fs, dir_uri, overview, abstract, ctx)+ await _write_sidecars(viking_fs, dir_uri, overview, abstract, ctx, lock.handle)return Truelock_paths = [@@ -45,7 +45,7 @@ async def write_semantic_sidecars(if is_stale():logger.info("%s Skipping stale semantic write for %s", log_prefix, dir_uri)return False- await _write_sidecars(viking_fs, dir_uri, overview, abstract, ctx)+ await _write_sidecars(viking_fs, dir_uri, overview, abstract, ctx, lock.handle)return True@@ -55,6 +55,18 @@ async def _write_sidecars(overview: str,abstract: str,ctx: Optional[RequestContext],+ lock_handle: Any = None,) -> None:- await viking_fs.write_file(f"{dir_uri}/.overview.md", overview, ctx=ctx)- await viking_fs.write_file(f"{dir_uri}/.abstract.md", abstract, ctx=ctx)+ # TODO: This must be optimized once pathlock is pushed down into ragfs.+ await viking_fs.write_file(+ f"{dir_uri}/.overview.md",+ overview,+ ctx=ctx,+ lock_handle=lock_handle,+ )+ await viking_fs.write_file(+ f"{dir_uri}/.abstract.md",+ abstract,+ ctx=ctx,+ lock_handle=lock_handle,+ )