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(ultrawiki): stop the knowledge base ingesting the app's own recordings

Ruben Lütkee61f3ab54568
diff --git a/jarvis/ultrawiki/connectors/local_folder.py b/jarvis/ultrawiki/connectors/local_folder.py
index 8e24755d85..4bb13eef4e 100644
--- a/jarvis/ultrawiki/connectors/local_folder.py
+++ b/jarvis/ultrawiki/connectors/local_folder.py
@@ -140,6 +140,59 @@ NOISE_DIR_NAMES: frozenset[str] = frozenset(
}
)
+def _own_data_dirs() -> tuple[Path, ...]:
+ """The app's OWN data directories, resolved once per walk. Never raises.
+
+ Why a folder import needs to know this (2026-07-27 forensic). A user
+ pointed the folder connector at the directory the app itself lives in and
+ got a 236 131-item corpus, of which 218 419 were wake-word debug clips
+ from ``data/wake_debug`` — 92 % of everything the knowledge base held was
+ the app's own recordings of itself. Each one was queued for a
+ transcription and a summary, which is a backlog measured in weeks made
+ entirely of noise.
+
+ Matched by resolved PATH rather than by folder name, and that distinction
+ is the whole point: ``data`` is far too common a name to blocklist. Real
+ people keep research data, exports and project files in folders called
+ exactly that, and a name rule would silently swallow them. Only the
+ directory this installation actually writes to is skipped.
+
+ Both candidates are returned because they can genuinely differ: the
+ project-root ``data/`` and the per-user fallback used when that path is
+ read-only (headless installs, site-packages, ``JARVIS_DATA_DIR``).
+ """
+ found: list[Path] = []
+ try:
+ from jarvis.core import config as core_config # noqa: PLC0415 — lazy (AP-26)
+
+ candidates = [getattr(core_config, "DATA_DIR", None)]
+ resolver = getattr(core_config, "_resolve_writable_data_dir", None)
+ if callable(resolver):
+ candidates.append(resolver())
+ except Exception: # noqa: BLE001 — an unresolvable data dir must not stop a walk
+ log.debug("%s: could not resolve the app data dir", __name__, exc_info=True)
+ return ()
+ for candidate in candidates:
+ if candidate is None:
+ continue
+ try:
+ found.append(Path(candidate).resolve())
+ except (OSError, ValueError):
+ continue
+ return tuple(dict.fromkeys(found))
+
+
+def _is_own_data_dir(path: Path, own_data: tuple[Path, ...]) -> bool:
+ """Is *path* one of the app's own data directories? Never raises."""
+ if not own_data:
+ return False
+ try:
+ resolved = path.resolve()
+ except (OSError, ValueError):
+ return False
+ return any(resolved == own for own in own_data)
+
+
#: Text-shaped suffixes read as UTF-8. Deliberately an ALLOWLIST: a folder
#: full of photos, videos and installers must import as nothing rather than
#: as megabytes of replacement characters. Grouped for review, flattened
@@ -429,12 +482,17 @@ class LocalFolderConnector:
if skip_dirs is not None
else frozenset(name.lower() for name in self.SKIP_DIR_NAMES)
)
+ own_data = _own_data_dirs()
matches: list[tuple[str, Path]] = []
for dirpath, dirnames, filenames in os.walk(root):
+ base = Path(dirpath)
dirnames[:] = sorted(
- d for d in dirnames if not d.startswith(".") and d.lower() not in skip
+ d
+ for d in dirnames
+ if not d.startswith(".")
+ and d.lower() not in skip
+ and not _is_own_data_dir(base / d, own_data)
)
- base = Path(dirpath)
for name in filenames:
if name.startswith("."):
continue
diff --git a/jarvis/ultrawiki/media_enrich.py b/jarvis/ultrawiki/media_enrich.py
index d4ceb8dc38..9a02f30386 100644
--- a/jarvis/ultrawiki/media_enrich.py
+++ b/jarvis/ultrawiki/media_enrich.py
@@ -118,6 +118,13 @@ def image_prompt() -> str:
#: cache thumbnails. Each one would still cost a full model call.
MIN_IMAGE_BYTES = 20 * 1024
+#: Recordings below this hold no speech worth a model call. 16 kB is well
+#: under a second of 16-bit mono PCM at any rate a microphone actually uses,
+#: so it clears notification blips and truncated fragments without reaching
+#: anything a person would call a recording. Deliberately far more permissive
+#: than the image floor: a genuinely short voice note is still a voice note.
+MIN_RECORDING_BYTES = 16 * 1024
+
#: Path SEGMENTS that mean "this file belongs to a program, not to the user".
#: Matched segment-wise and case-blind, so ``my-database-notes`` survives while
#: ``data/`` does not. The measured motivation: one real Desktop held 218,419
@@ -148,6 +155,19 @@ PROGRAM_DIR_NAMES: frozenset[str] = frozenset(
# reason nothing is ever described.
+def _program_folder_of(name: str) -> str:
+ """The first program-folder segment in *name*, or ``""``.
+
+ Segment-wise and case-blind, and never the last component, so a file
+ called ``data.wav`` is judged by where it lives rather than by its name.
+ """
+ parts = [p.strip().lower() for p in str(name).replace("\\", "/").split("/")]
+ for segment in parts[:-1]: # the filename itself is never a folder
+ if segment in PROGRAM_DIR_NAMES:
+ return segment
+ return ""
+
+
def skip_reason_for_image(name: str, *, size_bytes: int) -> str:
"""Why this picture is not worth a model call, or ``""`` to read it.
@@ -160,13 +180,50 @@ def skip_reason_for_image(name: str, *, size_bytes: int) -> str:
f"the picture is too small to hold readable content "
f"({size_bytes} bytes); icons and thumbnails are skipped"
)
- parts = [p.strip().lower() for p in str(name).replace("\\", "/").split("/")]
- for segment in parts[:-1]: # the filename itself is never a folder
- if segment in PROGRAM_DIR_NAMES:
- return (
- f"it sits in a program folder ({segment}/), which holds "
- "generated files rather than your own pictures"
- )
+ segment = _program_folder_of(name)
+ if segment:
+ return (
+ f"it sits in a program folder ({segment}/), which holds "
+ "generated files rather than your own pictures"
+ )
+ return ""
+
+
+def skip_reason_for_recording(name: str, *, size_bytes: int) -> str:
+ """Why this recording is not worth a model call, or ``""`` to read it.
+
+ The audio counterpart of :func:`skip_reason_for_image`, and the reason it
+ now exists: the provenance rule above was written FROM the 218 419
+ wake-word debug clips one real machine holds under ``data/wake_debug``,
+ and then applied to pictures only — the exact files that motivated it went
+ on queuing a transcription each, 220 520 model calls deep (measured live
+ 2026-07-27). A cheap gate that skips the case it was built for is not a
+ gate.
+
+ Two rules, both decidable offline from the item alone:
+
+ * **Provenance** — a program folder holds a machine's own output. An app's
+ debug dump, a cache, a build directory: none of it is something anyone
+ recorded, and transcribing it produces noise at the cost of the corpus.
+ * **Size** — below :data:`MIN_RECORDING_BYTES` there is less than a second
+ of audio at any sane rate, which is a fragment rather than a recording.
+
+ Deliberately NOT a rule: the file's own name. Real recordings are named
+ anything at all, and a name-shaped filter would be exactly the kind of
+ spelling-based gate that keeps producing both false skips and false
+ passes (AP-27 makes the same argument about wake words).
+ """
+ segment = _program_folder_of(name)
+ if segment:
+ return (
+ f"it sits in a program folder ({segment}/), which holds files a "
+ "program wrote rather than anything you recorded"
+ )
+ if size_bytes < MIN_RECORDING_BYTES:
+ return (
+ f"the recording is too short to hold speech ({size_bytes} bytes); "
+ "clips this small are skipped"
+ )
return ""
diff --git a/jarvis/ultrawiki/pipeline.py b/jarvis/ultrawiki/pipeline.py
index c03434bdd1..ab7b0cdf10 100644
--- a/jarvis/ultrawiki/pipeline.py
+++ b/jarvis/ultrawiki/pipeline.py
@@ -1194,6 +1194,21 @@ class PipelineWorker:
data, filename=filename, cfg=self._cfg
)
elif kind in ("audio", "video"):
+ # The same gate, which this lane went without. Pictures were
+ # filtered by provenance from the day the rule was written; audio
+ # was not, and the files the rule was written FROM are recordings:
+ # 218 419 wake-word debug clips under data/wake_debug on one live
+ # machine, 220 520 items queued for a transcription each
+ # (2026-07-27). Whichever lane is missing the gate is the lane that
+ # spends the corpus.
+ skip = media_enrich.skip_reason_for_recording(
+ self._media_path_for(item, filename), size_bytes=len(data)
+ )
+ if skip:
+ await self._record_media_outcome(
+ item, text="", reason=skip, retryable=False
+ )
+ return
result = await media_enrich.transcribe_recording(
data, filename=filename, cfg=self._cfg
)
diff --git a/tests/unit/ultrawiki/test_media_provenance.py b/tests/unit/ultrawiki/test_media_provenance.py
new file mode 100644
index 0000000000..e25a213cc6
--- /dev/null
+++ b/tests/unit/ultrawiki/test_media_provenance.py
@@ -0,0 +1,107 @@
+"""The gate that skipped the very files it was written for.
+
+Forensic 2026-07-27. A folder source pointed at the directory the app itself
+lives in produced a 236 131-item corpus. 218 419 of those items — 92 % of
+everything the knowledge base held — were wake-word debug clips the app had
+recorded of itself into ``data/wake_debug``, and 220 520 items sat queued for
+a media-enrichment model call each.
+
+``media_enrich.PROGRAM_DIR_NAMES`` already existed, and its own docstring
+named those clips as the measured motivation. It was only ever consulted on
+the image path. The recordings that motivated the rule were exempt from it.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+from jarvis.ultrawiki.connectors.local_folder import _is_own_data_dir, _own_data_dirs
+from jarvis.ultrawiki.media_enrich import (
+ MIN_RECORDING_BYTES,
+ skip_reason_for_image,
+ skip_reason_for_recording,
+)
+
+BIG = 4 * 1024 * 1024
+
+
+class TestRecordingProvenance:
+ def test_the_wake_debug_clips_are_skipped(self) -> None:
+ """The exact path 218 419 items came from."""
+ reason = skip_reason_for_recording(
+ "Personal Jarvis/data/wake_debug/wake_000001_rms0.003_Deine_Hohen_.wav",
+ size_bytes=BIG,
+ )
+ assert reason
+ assert "data/" in reason
+
+ def test_a_real_voice_note_survives(self) -> None:
+ """The rule must cost nothing to anything a person actually recorded."""
+ assert (
+ skip_reason_for_recording(
+ "Voice Memos/2026-07-12 call with the accountant.m4a", size_bytes=BIG
+ )
+ == ""
+ )
+
+ def test_a_short_but_real_recording_survives(self) -> None:
+ """A brief voice note is still a voice note; only fragments go."""
+ assert skip_reason_for_recording("Notes/idea.m4a", size_bytes=64 * 1024) == ""
+
+ def test_a_fragment_is_skipped(self) -> None:
+ assert skip_reason_for_recording("Notes/blip.wav", size_bytes=200)
+
+ def test_a_folder_the_user_named_data_is_judged_by_path_not_name(self) -> None:
+ """`data` is far too common a folder name to blocklist outright...
+
+ ...on the ENRICHMENT side it is a deliberate exception, because a model
+ call is expensive and the folder is machine output either way. The
+ distinction that protects the user's own files lives in the walker
+ (see :class:`TestOwnDataDirIsSkipped`), which matches a resolved path.
+ """
+ assert skip_reason_for_recording("data/whatever.wav", size_bytes=BIG)
+
+ def test_the_filename_alone_never_decides(self) -> None:
+ """A file merely CALLED data.wav is not machine output (AP-27's logic)."""
+ assert skip_reason_for_recording("Recordings/data.wav", size_bytes=BIG) == ""
+
+ def test_windows_separators_are_understood(self) -> None:
+ assert skip_reason_for_recording(
+ r"Personal Jarvis\data\wake_debug\wake_01.wav", size_bytes=BIG
+ )
+
+ def test_the_image_gate_still_behaves(self) -> None:
+ """The refactor that added the audio gate must not move the image one."""
+ assert skip_reason_for_image("data/wake_debug/x.png", size_bytes=BIG)
+ assert skip_reason_for_image("Photos/holiday.jpg", size_bytes=BIG) == ""
+ assert skip_reason_for_image("Photos/icon.png", size_bytes=512)
+
+ def test_the_floor_is_permissive_enough_for_a_second_of_speech(self) -> None:
+ """16-bit mono at 16 kHz is 32 kB a second — the floor must sit under it."""
+ assert MIN_RECORDING_BYTES < 32 * 1024
+
+
+class TestOwnDataDirIsSkipped:
+ """The walker half: never ingest the directory this install writes to."""
+
+ def test_the_apps_own_data_dir_is_recognised(self) -> None:
+ own = _own_data_dirs()
+ assert own, "the app must be able to resolve its own data dir"
+ assert _is_own_data_dir(Path(own[0]), own)
+
+ def test_an_unrelated_folder_named_data_is_not(self, tmp_path: Path) -> None:
+ """The reason this matches a PATH and not the name `data`.
+
+ People keep research data, exports and project files in a folder
+ called exactly that. A name rule would swallow them silently, which
+ is a worse failure than the one it fixes.
+ """
+ elsewhere = tmp_path / "Research" / "data"
+ elsewhere.mkdir(parents=True)
+ assert _is_own_data_dir(elsewhere, _own_data_dirs()) is False
+
+ def test_a_missing_path_never_raises(self, tmp_path: Path) -> None:
+ assert _is_own_data_dir(tmp_path / "nope" / "gone", _own_data_dirs()) is False
+
+ def test_no_resolvable_data_dir_skips_nothing(self, tmp_path: Path) -> None:
+ assert _is_own_data_dir(tmp_path, ()) is False