Skip to content

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.

fix(wiki): make short names findable and give new pages their aliases at birth

rubenluetke10-beep2de791c2dc4d
diff --git a/jarvis/brain/wiki_context.py b/jarvis/brain/wiki_context.py
index ea9173a2f2..73723cfef7 100644
--- a/jarvis/brain/wiki_context.py
+++ b/jarvis/brain/wiki_context.py
@@ -129,33 +129,37 @@ _KEYWORD_LEG = "keyword"
def _extract_keywords(
text: str,
*,
- min_length: int = 4,
- max_keywords: int = 3,
+ min_length: int = 3,
+ max_keywords: int = 4,
) -> list[str]:
- """Extract 1-3 meaningful keywords from a user utterance.
+ """Extract up to ``max_keywords`` meaningful keywords from an utterance.
Strategy:
1. Tokenize on whitespace + punctuation.
- 2. Drop tokens shorter than ``min_length``.
+ 2. Drop tokens shorter than ``min_length``. Three is the floor the
+ 2026-08-11 recall audit set: short given names ("Joy", "Uwe") and
+ initialisms ("BMW") are exactly the tokens a memory question hangs
+ on, and the old floor of four made them structurally unsearchable.
3. Drop tokens that are in the stopword list (case-insensitive).
- 4. Prefer tokens that are capitalized mid-sentence (likely proper nouns),
- but include lowercase tokens too if there are not enough proper nouns.
- 5. Return up to ``max_keywords`` tokens, proper nouns first.
+ 4. Prefer tokens that are capitalized mid-sentence (proper nouns in
+ English; nouns in general in German — both are the searchable
+ content words), but include lowercase tokens too if there are not
+ enough capitalized ones. All-lowercase STT output simply keeps
+ source order.
+ 5. Return up to ``max_keywords`` tokens, capitalized ones first.
"""
raw_tokens = _TOKEN_RE.sub(" ", text).split()
# Filter by length and stopwords. The stopword register is PRE-FOLDED
- # ("fuer", "ueber"), so the token must be folded the same way before the # i18n-allow: folded stopword forms
- # lookup — comparing ``tok.lower()`` let every real umlaut
- # spelling through as a junk keyword. # i18n-allow: folded stopword forms
+ # ("fuer", "ueber"), so the token must be folded the # i18n-allow: folded stopword forms
+ # same way before the lookup — comparing ``tok.lower()`` let every real
+ # umlaut spelling through as a junk keyword. # i18n-allow: folded stopword forms
candidates: list[str] = []
for tok in raw_tokens:
if len(tok) < min_length:
continue
if fold_text(tok) in STOPWORDS:
continue
- # Skip leading token of the sentence (likely a greeting/verb, not a noun)
- # unless the whole utterance is very short (fewer than 4 tokens total)
candidates.append(tok)
if not candidates:
@@ -239,6 +243,12 @@ class WikiContextInjector:
def _miss(self, t0: float, reason: str) -> None:
"""Record one skipped injection: telemetry + the single INFO line."""
telemetry.inc("wiki_context_misses")
+ # Per-reason counter so "which gate eats the injections" is a
+ # /api/wiki/telemetry read instead of a log grep (2026-08-11 audit:
+ # the aggregate counter could not distinguish no_hits from a strict
+ # gate discard). Reasons are the stable slugs of MemoryVerdict plus
+ # this module's own literals — bounded vocabulary, safe as names.
+ telemetry.inc(f"wiki_context_miss_{reason}")
log.info(
"WikiContextInjector injected=False hits=0 latency_ms=%d reason=%s",
int((time.monotonic() - t0) * 1000),
diff --git a/jarvis/core/config.py b/jarvis/core/config.py
index cbc5c1adf1..526f79fedd 100644
--- a/jarvis/core/config.py
+++ b/jarvis/core/config.py
@@ -1477,7 +1477,7 @@ class MCPServerConfig(BaseModel):
transport: str = "stdio" # "stdio" | "http"
http_host: str = "127.0.0.1"
http_port: int = 47822
- auth_token_env: str = "JARVIS_MCP_TOKEN"
+ auth_token_env: str = "JARVIS_MCP_TOKEN" # noqa: S105 — env var NAME, not a secret
max_call_depth: int = 3 # loop guard
@@ -1545,7 +1545,7 @@ class UIConfig(BaseModel):
# ENV variable carrying the process-scoped UI bootstrap token. The native
# WebView exposes it once; AuthGate exchanges it for an unrelated HttpOnly
# session cookie and immediately clears the JavaScript value.
- auth_token_env: str = "JARVIS_UI_TOKEN"
+ auth_token_env: str = "JARVIS_UI_TOKEN" # noqa: S105 — env var NAME, not a secret
# Optional browser lock: when True, opening the UI in a browser on THIS
# machine (loopback) asks for the Control Key. Off by default — the local
# user walks straight in. Non-loopback access (LAN, VPS, reverse proxy)
@@ -2413,7 +2413,10 @@ class WikiContextConfig(BaseModel):
# timed out. The factory warms the connection at boot; the wider budget
# covers a lost warm-up race and stays inaudible next to the brain call.
latency_budget_ms: int = 150
- min_keyword_length: int = 4
+ # 3 (was 4): short given names ("Joy", "Uwe") and initialisms ("BMW")
+ # are exactly the tokens a memory question hangs on; the old floor made
+ # them structurally unsearchable (2026-08-11 recall audit).
+ min_keyword_length: int = 3
# Relevance gate (jarvis/brain/wiki_relevance.py). Retrieval always
# returns a ranked list, so without a gate every unrelated question gets
@@ -3434,17 +3437,6 @@ class AgenticIdeConfig(BaseModel):
),
)
- deck_reports: bool = Field(
- default=True,
- description=(
- "In the Command Deck, say a finished agent out loud instead of only "
- "counting it in the bell — one report at a time, and only while a "
- "conversation is open. Off leaves the deck's report lane on screen "
- "and silent. Has no effect in the terminal grid or chat view, "
- "which never speak."
- ),
- )
-
@field_validator("prompt_writer", mode="before")
@classmethod
def _usable_writer(cls, value: object) -> str:
@@ -4128,11 +4120,16 @@ class _FileCredStore:
# file before either reaches its atomic os.replace.
tmp = f.with_name(f"{f.name}.tmp.{os.getpid()}")
try:
- tmp.write_text(json.dumps(data), encoding="utf-8")
- try:
- os.chmod(tmp, 0o600)
- except Exception: # noqa: BLE001 — chmod is a no-op on Windows
- pass
+ # Born 0600, never chmodded down after the fact: write_text +
+ # chmod created the file 0644 for a moment, and on a multi-user
+ # Mac (this store is the documented fallback after a declined
+ # Keychain prompt) that window exposed every stored key to any
+ # other local account. A stale same-pid tmp from a crashed run
+ # is removed first so O_EXCL cannot trip over it.
+ tmp.unlink(missing_ok=True)
+ descriptor = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o600)
+ with os.fdopen(descriptor, "w", encoding="utf-8") as stream:
+ stream.write(json.dumps(data))
os.replace(tmp, f)
except OSError as exc:
tmp.unlink(missing_ok=True)
diff --git a/jarvis/memory/wiki/consolidator.py b/jarvis/memory/wiki/consolidator.py
index e1b8f4f0f5..e02dccf59b 100644
--- a/jarvis/memory/wiki/consolidator.py
+++ b/jarvis/memory/wiki/consolidator.py
@@ -53,6 +53,7 @@ from jarvis.memory.wiki.prompt import (
resolve_user_entity_slug,
)
from jarvis.memory.wiki.protocols import PageUpdate
+from jarvis.memory.wiki.search_aliases import ensure_page_aliases
from jarvis.memory.wiki.telemetry import telemetry
from jarvis.memory.wiki.wikilink import extract_wikilinks
@@ -734,6 +735,14 @@ class Consolidator:
write_plan[cid] = (None, None)
continue
new_body = self._with_source_marker(new_body, by_id[cid])
+ # Write-time language bridge: a page the judge just composed
+ # gets its multilingual ``search_aliases`` NOW, so it is born
+ # findable in the user's spoken language instead of waiting
+ # for a manual backfill run. Never raises; without a
+ # credential-ready provider the body passes through unchanged.
+ new_body = await ensure_page_aliases(
+ new_body, cfg=self._root_cfg, registry=self._registry
+ )
update = PageUpdate(
target_path=Path(target),
operation="create" if decision == "add" else "update",
diff --git a/jarvis/memory/wiki/search_aliases.py b/jarvis/memory/wiki/search_aliases.py
index ae32fff2d2..e7392e4793 100644
--- a/jarvis/memory/wiki/search_aliases.py
+++ b/jarvis/memory/wiki/search_aliases.py
@@ -47,6 +47,7 @@ __all__ = [
"MAX_ALIASES",
"backfill_vault",
"build_alias_prompt",
+ "ensure_page_aliases",
"generate_aliases",
"merge_aliases",
"parse_alias_response",
@@ -330,6 +331,66 @@ async def generate_aliases(
return aliases
+# ---------------------------------------------------------------------------
+# Write-time bridge
+# ---------------------------------------------------------------------------
+
+
+async def ensure_page_aliases(
+ page_text: str,
+ *,
+ cfg: Any,
+ registry: Any,
+ timeout_s: float = 15.0,
+) -> str:
+ """Return *page_text* with a populated ``search_aliases`` frontmatter field.
+
+ The write-time half of the language bridge: the consolidator routes every
+ proposed add/update body through here, so a page is born findable in the
+ user's own language instead of waiting for someone to run the backfill
+ route by hand (which the 2026-08-11 recall audit found nobody does).
+
+ Pages that already carry aliases pass through untouched — regeneration is
+ the backfill's ``overwrite`` decision, never an implicit side effect of an
+ unrelated fact landing on the page. Every failure mode returns the
+ ORIGINAL text: a page without aliases is merely as findable as it is
+ today, while raising here would block the write itself.
+ """
+ try:
+ from jarvis.memory.frontmatter import ( # noqa: PLC0415
+ parse_frontmatter,
+ write_frontmatter,
+ )
+
+ meta, body = parse_frontmatter(page_text)
+ if not meta:
+ # No parseable frontmatter — the schema validator downstream owns
+ # that verdict; injecting a field here would forge a frontmatter
+ # block the judge never proposed.
+ return page_text
+ if meta.get(ALIAS_FIELD):
+ return page_text
+
+ title_match = re.search(r"^\s{0,3}#\s+(.+)", body, re.MULTILINE)
+ title = (
+ title_match.group(1).strip()
+ if title_match
+ else str(meta.get("slug", "") or "")
+ )
+ generated = await generate_aliases(
+ title=title, body=body, cfg=cfg, registry=registry, timeout_s=timeout_s
+ )
+ if not generated:
+ return page_text
+ meta[ALIAS_FIELD] = merge_aliases(meta.get(ALIAS_FIELD), generated)
+ return write_frontmatter(meta, body)
+ except Exception: # noqa: BLE001 — the bridge must never block a write
+ log.warning(
+ "search_aliases: write-time alias injection failed", exc_info=True
+ )
+ return page_text
+
+
# ---------------------------------------------------------------------------
# Backfill over an existing vault
# ---------------------------------------------------------------------------