Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(wiki): address Task-1 review findings on the vault-root resolver
Ruben Lütke103466881529
diff --git a/jarvis/memory/wiki/cli.py b/jarvis/memory/wiki/cli.pyindex df80f098de..9effd935a8 100644--- a/jarvis/memory/wiki/cli.py+++ b/jarvis/memory/wiki/cli.py@@ -30,6 +30,8 @@ import loggingimport sysfrom pathlib import Path+from .vault_root import resolve_vault_root+# Windows console encoding (cp1252 by default) breaks on em-dashes and# arrows; reconfigure to UTF-8 so user-visible output renders properly.# Same pattern as scripts/wiki_migrate_v0_to_v1.py and jarvis/__main__.py.@@ -40,10 +42,11 @@ if hasattr(sys.stderr, "reconfigure"):REPO_ROOT = Path(__file__).resolve().parents[3]-# Runtime default vault — mirrors WikiIntegrationConfig.vault_root-# ("wiki/obsidian-vault"). The legacy "data/workspace" tree is the-# soft-disabled B4 Curator snapshot and is NOT the search vault.-DEFAULT_VAULT = REPO_ROOT / "wiki" / "obsidian-vault"+# Runtime default vault — resolved through the one canonical resolver+# (spec A7), same as every other WikiIntegrationConfig.vault_root consumer.+# The legacy "data/workspace" tree is the soft-disabled B4 Curator snapshot+# and is NOT the search vault.+DEFAULT_VAULT = resolve_vault_root(None).pathDEFAULT_BACKUP_DIR = REPO_ROOT / "data" / "backups"DEFAULT_DB = REPO_ROOT / "data" / "jarvis.db"diff --git a/jarvis/memory/wiki/vault_root.py b/jarvis/memory/wiki/vault_root.pyindex b2f7ba001b..32b5019ffb 100644--- a/jarvis/memory/wiki/vault_root.py+++ b/jarvis/memory/wiki/vault_root.py@@ -41,18 +41,22 @@ def _non_empty_dir(p: Path) -> bool:def resolve_vault_root(- raw: str | Path | None, *, cwd: Path | None = None,+ raw: str | Path | None,+ *,+ cwd: Path | None = None,+ anchor: Path | None = None,) -> VaultRootResolution:"""Resolve the configured vault root to an absolute path.- ``cwd`` is injectable for tests; production callers omit it.+ ``cwd`` and ``anchor`` are injectable for tests; production callers+ omit both (``anchor`` defaults to :func:`repo_root`)."""raw_path = Path(raw) if raw else _DEFAULT_RELATIVEif raw_path.is_absolute():res = VaultRootResolution(raw_path.resolve(), "absolute", False)return _remember(res)- anchored = (repo_root() / raw_path).resolve()+ anchored = ((anchor or repo_root()) / raw_path).resolve()legacy = ((cwd or Path.cwd()) / raw_path).resolve()if legacy == anchored:return _remember(VaultRootResolution(anchored, "repo_root", False))diff --git a/jarvis/plugins/tool/wiki_page_read.py b/jarvis/plugins/tool/wiki_page_read.pyindex c89dfe757e..f177547962 100644--- a/jarvis/plugins/tool/wiki_page_read.py+++ b/jarvis/plugins/tool/wiki_page_read.py@@ -173,12 +173,12 @@ def _build_page_read_tool() -> "WikiPageReadTool":except Exception as exc: # noqa: BLE001log.debug("wiki-page-read: config load skipped: %s", exc)+ vault_root = resolve_vault_root(raw).pathif raw is None:log.warning("wiki-page-read: cfg.wiki_integration.vault_root not found; "- "defaulting to the standard vault location",+ "defaulting to %s",+ vault_root,)- vault_root = resolve_vault_root(raw).path-return WikiPageReadTool(vault_root=vault_root)diff --git a/jarvis/plugins/tool/wiki_recall.py b/jarvis/plugins/tool/wiki_recall.pyindex c10d3c134b..5250ca0ac9 100644--- a/jarvis/plugins/tool/wiki_recall.py+++ b/jarvis/plugins/tool/wiki_recall.py@@ -164,10 +164,12 @@ def _build_search_instance() -> "VaultSearch":except Exception as exc: # noqa: BLE001log.debug("wiki-recall: config load skipped: %s", exc)+ resolved = resolve_vault_root(raw).pathif raw is None:log.warning("wiki-recall: cfg.wiki_integration.vault_root not found; "- "defaulting to the standard vault location",+ "defaulting to %s",+ resolved,)- return VaultSearch(resolve_vault_root(raw).path)+ return VaultSearch(resolved)diff --git a/tests/unit/memory/wiki/test_vault_root.py b/tests/unit/memory/wiki/test_vault_root.pyindex c7fa943060..87308f52d9 100644--- a/tests/unit/memory/wiki/test_vault_root.py+++ b/tests/unit/memory/wiki/test_vault_root.py@@ -17,13 +17,36 @@ def test_absolute_root_passes_through(tmp_path):def test_populated_legacy_cwd_vault_wins_and_flags_conflict(tmp_path):- legacy = tmp_path / "wiki" / "obsidian-vault"+ """Hermetic: anchored vault EMPTY + legacy CWD vault POPULATED → legacy wins."""+ anchor = tmp_path / "repo"+ (anchor / "wiki" / "obsidian-vault").mkdir(parents=True) # exists but empty+ old_cwd = tmp_path / "elsewhere"+ legacy = old_cwd / "wiki" / "obsidian-vault"legacy.mkdir(parents=True)(legacy / "log.md").write_text("# log\n", encoding="utf-8")- res = resolve_vault_root("wiki/obsidian-vault", cwd=tmp_path)- # The anchored repo-root vault exists and is populated in this repo, so- # the anchor wins; the conflict must still be flagged for the health- # surface. If the anchored path were empty, legacy would win (see module).++ res = resolve_vault_root("wiki/obsidian-vault", cwd=old_cwd, anchor=anchor)++ assert res.path == legacy.resolve()+ assert res.source == "legacy_cwd"+ assert res.legacy_conflict is True+++def test_populated_anchored_vault_wins_over_populated_legacy(tmp_path):+ """Hermetic: BOTH populated → the anchor wins, conflict still flagged."""+ anchor = tmp_path / "repo"+ anchored = anchor / "wiki" / "obsidian-vault"+ anchored.mkdir(parents=True)+ (anchored / "log.md").write_text("# anchored log\n", encoding="utf-8")+ old_cwd = tmp_path / "elsewhere"+ legacy = old_cwd / "wiki" / "obsidian-vault"+ legacy.mkdir(parents=True)+ (legacy / "log.md").write_text("# legacy log\n", encoding="utf-8")++ res = resolve_vault_root("wiki/obsidian-vault", cwd=old_cwd, anchor=anchor)++ assert res.path == anchored.resolve()+ assert res.source == "repo_root"assert res.legacy_conflict is True