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
feat(skills): quality lint + kill the spawn-skill-author phantom
Ruben Lütkee00678eeb7ba
diff --git a/docs/LLM-CONTEXT.md b/docs/LLM-CONTEXT.mdindex 8401bda9b7..7b76943bbf 100644--- a/docs/LLM-CONTEXT.md+++ b/docs/LLM-CONTEXT.md@@ -383,7 +383,7 @@ Verified against the actual file tree (not just CLAUDE.md claims):| 0–4 Foundations | live | Protocols, plugin system, FastAPI/React, speech pipeline, skill system, tool-use loop, harness dispatch, core memory || 5 Vision/Action/Admin/Async/Control + Tiered Routing | live | `jarvis/{vision,admin,tasks,control,telemetry}/`, `ROUTER_TOOLS` frozenset, ADR-0001..0011 || 6 Self-Healing Worker-Critic | live | `jarvis/missions/{manager,kontrollierer,critic,workers,isolation,worker_runtime,voice,safety}/`. 458 mission tests. Wired via `bootstrap_missions` |-| 7 Self-Mod (foundation + writer + tools) | live | `jarvis/core/self_mod/` (audit, errors, pending, registry, schema, writer). `spawn-skill-author` **IS** registered at `pyproject.toml:208` (CLAUDE.md says otherwise — see §25) |+| 7 Self-Mod (foundation + writer + tools) | live | `jarvis/core/self_mod/` (audit, errors, pending, registry, schema, writer). `spawn-skill-author` is **NOT** reachable from the brain — see §25; the live authoring path is the `skill-creator` builtin plus `POST /api/skills/creator/*` || Awareness A0–A5 | live | `jarvis/awareness/` (state, story, salience, verdichter, working_set, episode, watchers, probes). A1 + A3 router tools registered || Wiki B0/B1/B2/B3/B5/B7/B8/B9 | live | `jarvis/memory/wiki/` (curator, atomic_writer, page, integration, scheduler, session_rollup, voice_bridge, telemetry, vault_index, watcher, search). 3 router tools || Wiki B4 (legacy Curator) | soft-disabled | `factory.py:736-757` gates on `cfg.memory.legacy_curator.enabled` (default `false` since 2026-05-17). `data/workspace/` snapshot stays on disk for 35 reader sites |@@ -671,7 +671,7 @@ Self-mod writeup: [`docs/self_mod.md`](docs/self_mod.md) — 8 mutable settingsTwo drifts surfaced during the agent audit; flag them before quoting CLAUDE.md to a fresh chat:-1. **`spawn-skill-author` IS registered in `pyproject.toml:208`** as `spawn-skill-author = "jarvis.brain.tools.skill_authoring:SpawnSkillAuthorTool"` (landed 2026-05-17 per inline comment). CLAUDE.md still says "7.5 `spawn_skill_author` not yet registered in `pyproject.toml`" — outdated. The Phase-7.5 self-modifying skill-authoring tool is wired.+1. **`spawn-skill-author` is NOT wired** (corrected 2026-07-25). It carried a `pyproject.toml` entry point, and this document previously concluded from that registration that the tool was live — it was not, and that claim misled every agent session reading this file. The tool is absent from `ROUTER_TOOLS` (the only allow-set, so `factory.py` filters it out), AND its `__init__` requires a `runner=` argument the entry-point loader cannot supply — so adding it to `ROUTER_TOOLS` raises `TypeError` at tool load rather than fixing anything. The entry point has been removed; skill authoring lives in the `skill-creator` builtin and `POST /api/skills/creator/{draft,refine,validate,commit}`, which already enforce the AP-15 draft guard. Guarded by `tests/unit/brain/test_router_tool_entrypoint_parity.py`.2. **`jarvis/sub_jarvis/` directory still exists** as an **empty placeholder** (no `__init__.py`, no files) despite CLAUDE.md and `docs/jarvis-agents-bridge.md §11` declaring it deleted in Welle 4. Cleanup is structurally complete (no code references), but the empty dir itself is leftover.diff --git a/jarvis/brain/tools/skill_authoring.py b/jarvis/brain/tools/skill_authoring.pyindex 29d3f987da..1d9867c16b 100644--- a/jarvis/brain/tools/skill_authoring.py+++ b/jarvis/brain/tools/skill_authoring.py@@ -1,4 +1,4 @@-"""`spawn_skill_author` — Anthropic tool for main-Jarvis (Phase 7.5).+"""`spawn_skill_author` — NOT WIRED. Read this before trying to enable it.Plan-§7.5: the tool delegates skill creation via the Jarvis-Agent worker(Wave-4 rebrand, frontier worker). Does not write anything itself — the@@ -6,6 +6,28 @@ Plan-§7.5: the tool delegates skill creation via the Jarvis-Agent workerPlan-§AD-2: exclusively main-Jarvis tier; the Jarvis-Agent worker has noaccess to this tool (recursion guard).++**Status (2026-07-25): deliberately unreachable from the brain.** It was a+phantom for months — an entry point in ``pyproject.toml`` made three docs claim+the tool was live while it could never load. It is broken in TWO independent+ways, and the second is the one that matters:++1. it is absent from ``ROUTER_TOOLS``, the only allow-set, so+ ``jarvis/brain/factory.py`` filters it out; and+2. :meth:`SpawnSkillAuthorTool.__init__` REQUIRES ``runner=``, which the+ entry-point loader cannot supply — so adding the name to ``ROUTER_TOOLS``+ (the obvious one-line "fix") raises ``TypeError`` at tool load.++The capability is not missing: the ``skill-creator`` builtin plus+``POST /api/skills/creator/{draft,refine,validate,commit}`` are the live+authoring path and already enforce the AP-15 draft guard. A router tool would be+a third route to the same behaviour, a fourth place to forget that guard, and+one more entry competing for router selection — this repo already has a+documented ``run_skill`` vs ``spawn_skill_author`` confusion on record.++The class stays because its tests exercise the ``SkillAuthoringRunner``+contract, which IS live behind the REST creator. Do not register it without+also giving it a constructor the loader can call."""from __future__ import annotationsdiff --git a/jarvis/skills/quality.py b/jarvis/skills/quality.pynew file mode 100644index 0000000000..f7a999022c--- /dev/null+++ b/jarvis/skills/quality.py@@ -0,0 +1,316 @@+"""Can this skill ever be FOUND? — separate from "does it load?".++``validator.py`` answers whether a SKILL.md parses and is safe. This module+answers a different question that nothing asked before: whether a skill has+enough distinctive vocabulary to be reachable at all. A skill can be perfectly+valid, perfectly enabled, and still invisible to every matching channel.++That is not hypothetical. Live on the maintainer's disk:++* ``browser-tabs`` — ``description: ''``, a body of one heading, and ``name:+ Browser Tabs`` (a display string, not a slug, which also breaks by-name+ ``run-skill`` lookup). It cannot be matched, listed usefully, or invoked.+* ``control-api`` — no trigger and English-only vocabulary, so a German request+ loses to whichever plugin's product noun happens to collide. The routing eval+ records it as a known gap.++**Deliberately NOT merged into ``validate_skill``.** Merging would demote+several of the maintainer's existing skills to DRAFT on the next hot reload — a+self-inflicted outage delivered as a safety improvement.++**And deliberately not enforced by the loader.** Enforce at the WRITE boundary,+report at the READ boundary, never at the LOAD boundary. A content rule applied+at load time suppresses the skills nobody anticipated as well as the bad ones,+silently, at boot, with no signal — which is AP-27's shape.+"""+from __future__ import annotations++import re+from dataclasses import dataclass, field+from typing import Any, Literal++Severity = Literal["error", "warning"]++# --- codes ------------------------------------------------------------------++Q_EMPTY_DESCRIPTION = "Q001"+Q_NO_WHEN_TO_USE = "Q002"+Q_EMPTY_BODY = "Q003"+Q_TOO_FEW_TERMS = "Q004"+Q_TERM_COLLISION = "Q005"+Q_GREEDY_TRIGGER = "Q006"+Q_NAME_NOT_A_SLUG = "Q007"+Q_MISSION_WITHOUT_WHEN = "Q008"++QUALITY_CODES: tuple[str, ...] = (+ Q_EMPTY_DESCRIPTION,+ Q_NO_WHEN_TO_USE,+ Q_EMPTY_BODY,+ Q_TOO_FEW_TERMS,+ Q_TERM_COLLISION,+ Q_GREEDY_TRIGGER,+ Q_NAME_NOT_A_SLUG,+ Q_MISSION_WITHOUT_WHEN,+)++#: Below this many distinctive terms a skill is unreachable by construction —+#: no channel has anything to match on.+MIN_DISTINCTIVE_TERMS = 3++#: Vocabulary overlap above this against another active skill means the two are+#: competing for the same requests and one will always lose.+COLLISION_THRESHOLD = 0.6++_SLUG_RE = re.compile(r"^[a-z0-9][a-z0-9._-]*$")+++@dataclass(frozen=True, slots=True)+class QualityFinding:+ code: str+ severity: Severity+ message: str+ hint: str = ""+++@dataclass(frozen=True, slots=True)+class QualityReport:+ skill_name: str = ""+ findings: tuple[QualityFinding, ...] = field(default_factory=tuple)++ @property+ def errors(self) -> tuple[QualityFinding, ...]:+ return tuple(f for f in self.findings if f.severity == "error")++ @property+ def warnings(self) -> tuple[QualityFinding, ...]:+ return tuple(f for f in self.findings if f.severity == "warning")++ @property+ def ok(self) -> bool:+ """True when nothing blocks. Warnings do not block."""+ return not self.errors++ def as_dict(self) -> dict[str, Any]:+ return {+ "skill_name": self.skill_name,+ "ok": self.ok,+ "findings": [+ {+ "code": f.code,+ "severity": f.severity,+ "message": f.message,+ "hint": f.hint or None,+ }+ for f in self.findings+ ],+ }+++def distinctive_terms(skill: Any) -> frozenset[str]:+ """Content terms this skill can be matched on.++ Uses the shared scorer's own surfaces and stopword handling, so "what can be+ matched" here means exactly what the matcher can match — not a second+ opinion that drifts from it.+ """+ try:+ from jarvis.skills.relevance import _skill_surfaces, tokenize+ except Exception: # noqa: BLE001+ return frozenset()+ terms: set[str] = set()+ try:+ for _field, text in _skill_surfaces(skill):+ terms |= set(tokenize(text))+ except Exception: # noqa: BLE001+ return frozenset()+ return frozenset(terms)+++def _text(value: Any) -> str:+ return str(value or "").strip()+++def lint_skill(skill: Any, *, peers: list[Any] | None = None) -> QualityReport:+ """Report whether ``skill`` can be found. Never raises.++ ``peers`` are the other active skills, used for the collision check. Omit+ them to skip that check (e.g. when linting a draft before it is installed).+ """+ name = str(getattr(skill, "name", "") or "")+ findings: list[QualityFinding] = []+ frontmatter = getattr(skill, "frontmatter", None)++ if frontmatter is None:+ # A parse failure is validator territory; there is nothing to judge here.+ return QualityReport(skill_name=name, findings=())++ # Q007 — a display-string name is a functional break, not a style nit: the+ # brain looks skills up by name, so "Browser Tabs" cannot be invoked.+ if name and not _SLUG_RE.match(name):+ findings.append(+ QualityFinding(+ code=Q_NAME_NOT_A_SLUG,+ severity="warning",+ message=f"name {name!r} is a display string, not a slug",+ hint="use lowercase-with-hyphens; run-skill looks skills up by name",+ )+ )++ description = _text(getattr(frontmatter, "description", ""))+ when_to_use = _text(getattr(frontmatter, "when_to_use", ""))++ if not description:+ findings.append(+ QualityFinding(+ code=Q_EMPTY_DESCRIPTION,+ severity="error",+ message="description is empty",+ hint=(+ "the description IS the listing entry the model reads — "+ "without it the skill is invisible to every channel"+ ),+ )+ )+ if not when_to_use:+ findings.append(+ QualityFinding(+ code=Q_NO_WHEN_TO_USE,+ severity="warning",+ message="no when_to_use",+ hint=(+ "quote the phrases a user would actually say, in the "+ "languages they speak — that text is what the matcher mines"+ ),+ )+ )++ if not _body_has_instructions(skill):+ findings.append(+ QualityFinding(+ code=Q_EMPTY_BODY,+ severity="error",+ message="body contains no instructions",+ hint="a skill whose body is only a heading does nothing when it fires",+ )+ )++ terms = distinctive_terms(skill)+ if len(terms) < MIN_DISTINCTIVE_TERMS:+ findings.append(+ QualityFinding(+ code=Q_TOO_FEW_TERMS,+ severity="error",+ message=(+ f"only {len(terms)} distinctive term(s) — unreachable by "+ "construction"+ ),+ hint=(+ "add tags, a when_to_use, or intent_objects; function words "+ "do not count"+ ),+ )+ )++ execution = str(getattr(frontmatter, "execution", "inline") or "inline").lower()+ if execution == "mission" and not when_to_use:+ findings.append(+ QualityFinding(+ code=Q_MISSION_WITHOUT_WHEN,+ severity="error",+ message="execution: mission without when_to_use",+ hint=(+ "a mission skill can never auto-fire (it starts a process), "+ "so the model must be able to choose it — and it chooses "+ "from when_to_use"+ ),+ )+ )++ triggers = tuple(getattr(frontmatter, "triggers", ()) or ())+ for trigger in triggers:+ if getattr(trigger, "type", "") != "voice":+ continue+ pattern = _text(getattr(trigger, "pattern", ""))+ if not pattern:+ continue+ core = pattern.strip("^$()")+ if core and "|" not in core and len(core) < 4 and not core.startswith("\\"):+ findings.append(+ QualityFinding(+ code=Q_GREEDY_TRIGGER,+ severity="warning",+ message=f"trigger {pattern!r} is a very short bare pattern",+ hint="it will match unrelated turns; anchor it or add context",+ )+ )++ if peers and terms:+ for peer in peers:+ peer_name = str(getattr(peer, "name", "") or "")+ if not peer_name or peer_name == name:+ continue+ peer_terms = distinctive_terms(peer)+ if not peer_terms:+ continue+ overlap = len(terms & peer_terms) / max(1, len(terms | peer_terms))+ if overlap > COLLISION_THRESHOLD:+ findings.append(+ QualityFinding(+ code=Q_TERM_COLLISION,+ severity="warning",+ message=(+ f"vocabulary is {overlap:.0%} identical to "+ f"{peer_name!r}"+ ),+ hint=(+ "the two compete for the same requests and one will "+ "always lose — give each a distinctive term"+ ),+ )+ )+ break++ return QualityReport(skill_name=name, findings=tuple(findings))+++def _body_has_instructions(skill: Any) -> bool:+ """Reuse the authoring guard so both paths agree on "empty body"."""+ body = str(getattr(skill, "body", "") or "")+ try:+ from jarvis.skills.authoring.service import body_has_instructions++ return bool(body_has_instructions(body))+ except Exception: # noqa: BLE001+ # Conservative local fallback: at least one non-heading, non-blank line.+ for line in body.splitlines():+ stripped = line.strip()+ if stripped and not stripped.startswith("#"):+ return True+ return False+++def lint_registry(skills: list[Any]) -> list[QualityReport]:+ """Lint every skill against its peers. Used by the health strip."""+ active = list(skills or ())+ return [lint_skill(skill, peers=active) for skill in active]+++__all__ = [+ "COLLISION_THRESHOLD",+ "MIN_DISTINCTIVE_TERMS",+ "QUALITY_CODES",+ "Q_EMPTY_BODY",+ "Q_EMPTY_DESCRIPTION",+ "Q_GREEDY_TRIGGER",+ "Q_MISSION_WITHOUT_WHEN",+ "Q_NAME_NOT_A_SLUG",+ "Q_NO_WHEN_TO_USE",+ "Q_TERM_COLLISION",+ "Q_TOO_FEW_TERMS",+ "QualityFinding",+ "QualityReport",+ "Severity",+ "distinctive_terms",+ "lint_registry",+ "lint_skill",+]diff --git a/jarvis/ui/web/skills_routes.py b/jarvis/ui/web/skills_routes.pyindex 096475debd..ee5aafc064 100644--- a/jarvis/ui/web/skills_routes.py+++ b/jarvis/ui/web/skills_routes.py@@ -727,6 +727,38 @@ async def match_test(request: Request, body: MatchTestRequest) -> dict[str, Any]}[email protected]("/lint", openapi_extra={"x-jarvis-readonly": True})+async def lint_skills(request: Request) -> dict[str, Any]:+ """Report which installed skills can never be FOUND.++ Different question from ``validate``: that one asks whether a SKILL.md+ parses and is safe, this one asks whether a skill carries enough distinctive+ vocabulary to be reachable at all. A skill can be perfectly valid, enabled,+ and still invisible to every matching channel — which is how a skill with an+ empty description and a one-heading body sat installed and unnoticed.++ Read-only and advisory. Deliberately not enforced by the loader: a content+ rule applied at load time suppresses the skills nobody anticipated along+ with the bad ones, silently, at boot, with no signal (AP-27). Enforce at the+ write boundary, report here.+ """+ registry = _require_registry(request)++ from jarvis.skills.quality import lint_registry++ try:+ skills = list(registry.list())+ except Exception: # noqa: BLE001+ skills = []+ reports = [report for report in lint_registry(skills) if report.findings]+ return {+ "total_skills": len(skills),+ "with_findings": len(reports),+ "unreachable": sum(1 for report in reports if report.errors),+ "reports": [report.as_dict() for report in reports],+ }++@router.get("/match-log", openapi_extra={"x-jarvis-readonly": True})async def match_log_recent(request: Request,diff --git a/pyproject.toml b/pyproject.tomlindex 2823fe5b1a..3b647b0ce6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -571,12 +571,18 @@ ultrawiki-search = "jarvis.plugins.tool.ultrawiki_search:UltraWikiSearchTool"# clusters (the Knowledge matrix + per-turn system-prompt source). Router-tier,# write, monitor. Closes the gap left by the soft-disabled legacy Curator.update-profile = "jarvis.plugins.tool.profile_update:UpdateProfileTool"-# Phase 7.5 — skill authoring (router-tier, ask). Spawns the-# SkillAuthoringRunner over the Jarvis-Agent bridge. Implementation lives at-# jarvis/brain/tools/skill_authoring.py since 2026-05-12; registration-# was missing until the 2026-05-17 audit (CLAUDE.md flagged it as-# "not yet registered in pyproject.toml" — this is that line landing).-spawn-skill-author = "jarvis.brain.tools.skill_authoring:SpawnSkillAuthorTool"+# NOTE (2026-07-25): `spawn-skill-author` used to be registered here and was a+# PHANTOM — a registration that made three docs claim the tool was live while it+# could never load. It is absent from ROUTER_TOOLS (the only allow-set, so+# factory.py filtered it out), and its __init__ requires a `runner=` argument+# the entry-point loader cannot supply, so the tempting one-line "just add it to+# ROUTER_TOOLS" fix raises TypeError at tool load. The entry point is removed+# rather than wired, because the capability is not missing: the `skill-creator`+# builtin plus POST /api/skills/creator/{draft,refine,validate,commit} are the+# live authoring path, already enforcing the AP-15 draft guard. A router tool+# would be a third route to the same behaviour and a fourth place to forget that+# guard. Enforced by+# tests/unit/brain/test_router_tool_entrypoint_parity.py.# App-Control (2026-05-31) — gives the brain a complete overview of the Desktop# App and lets it change settings/providers/MCP by voice/chat. Router-tier;# direct safe/ask-gated actions, never a spawn (AP-5/AP-14). describe is read-onlydiff --git a/tests/unit/brain/test_router_tool_entrypoint_parity.py b/tests/unit/brain/test_router_tool_entrypoint_parity.pynew file mode 100644index 0000000000..93e8dde4c4--- /dev/null+++ b/tests/unit/brain/test_router_tool_entrypoint_parity.py@@ -0,0 +1,159 @@+"""Every registered tool entry point must actually be reachable.++``jarvis/diagnostics/doctor.py`` already checks one direction: every name in+``ROUTER_TOOLS`` resolves to a registered tool. Nothing checked the REVERSE, and+that is where a phantom lives: ``spawn-skill-author`` sat in ``pyproject.toml``+for months while being absent from ``ROUTER_TOOLS``, so ``factory.py`` filtered+it out on every boot and it could never load.++The cost was not the dead code — it was the documentation. Three separate docs+concluded from the entry point that the tool was live, and+``docs/LLM-CONTEXT.md`` went further and "corrected" CLAUDE.md in the wrong+direction. Every agent session read that. A registration is a claim, and an+unreachable claim is worse than an absence.++This test makes the claim checkable.+"""+from __future__ import annotations++import tomllib+from pathlib import Path++from jarvis.brain.factory import ROUTER_TOOLS++REPO = Path(__file__).resolve().parents[3]++#: Tools that are registered on purpose WITHOUT being router-visible. Each entry+#: names why, because an unexplained exemption is how the next phantom hides.+INTERNAL_ONLY: dict[str, str] = {+ # Loaded into the hidden local-action tool dict by+ # jarvis/brain/factory.py::_load_local_action_tools — deterministic+ # execution only, never offered to the model (that is the whole point of the+ # local-action gate).+ "dispatch-to-harness": "local-action tool set, never model-visible",+ "open-app": "local-action tool set, never model-visible",+ "type-text": "local-action tool set, never model-visible",+ "hotkey": "local-action tool set, never model-visible",+ "reset-orb-position": "local-action tool set, never model-visible",+ # Attached by the router only when a turn is about the screen+ # (jarvis/brain/vision_gate.py), so it is not a static ROUTER_TOOLS member.+ "screenshot": "gated per-turn by the vision gate",+}+++def _declared_tool_entry_points() -> dict[str, str]:+ """``{entry point name: target}`` from the [jarvis.tool] group in pyproject."""+ data = tomllib.loads((REPO / "pyproject.toml").read_text(encoding="utf-8"))+ group = (+ data.get("project", {})+ .get("entry-points", {})+ .get("jarvis.tool", {})+ )+ assert group, "no [project.entry-points.'jarvis.tool'] group found"+ return dict(group)+++#: Entry points that no allow-set admits TODAY. Recorded rather than tolerated+#: silently: ``ROUTER_TOOLS`` is the only allow-set, so ``factory.py`` filters+#: every one of these out on every boot.+#:+#: This is a BACKLOG, not a permission list. Each needs one of three outcomes —+#: wire it, explain it in ``INTERNAL_ONLY``, or delete the entry point — and the+#: tests below let the count shrink but never grow. Auditing all sixteen was out+#: of scope for the change that added this gate; leaving them undeclared would+#: have meant a red gate nobody could act on, and dropping the gate would have+#: meant the next phantom goes unnoticed again.+KNOWN_UNREACHABLE: frozenset[str] = frozenset({+ # Computer-Use primitives — candidates for the local-action set or for the+ # `computer-use` umbrella that IS router-visible.+ "click",+ "click-element",+ "move-mouse",+ "read-visible-ui-state",+ "scroll",+ "switch-window",+ "wait-for-element",+ "wait-for-ui-state",+ # Mission / review vocabulary from earlier waves.+ "dispatch-to-admin",+ "dispatch-with-review",+ "multi-spawn",+ # Superseded by the wiki + awareness tools.+ "remember",+ "whoami",+ # Dev-loop helpers, plausibly worker-only by design.+ "start-preview-server",+ "verify-localhost",+ "verify-via-curl",+})+++def test_no_new_unreachable_tool_entry_point_appears() -> None:+ """A registration that no allow-set admits is a phantom, not a feature.++ ``spawn-skill-author`` is why this exists: it sat registered for months,+ filtered out on every boot, while three docs concluded from the registration+ that it was live.+ """+ declared = _declared_tool_entry_points()+ unreachable = {+ name+ for name in declared+ if name not in ROUTER_TOOLS and name not in INTERNAL_ONLY+ }+ new = sorted(unreachable - KNOWN_UNREACHABLE)+ assert not new, (+ f"new unreachable tool entry point(s): {new}\n"+ "factory.py filters these out on every boot, so the registration is a "+ "claim nothing honours. Add the name to ROUTER_TOOLS (and confirm the "+ "constructor takes no required arguments), or to INTERNAL_ONLY with a "+ "reason, or remove the entry point."+ )+++def test_the_unreachable_backlog_only_shrinks() -> None:+ """Wiring or deleting one must remove it from the list, not leave it stale.++ Without this the backlog rots into a permission list, which is exactly the+ state that let the original phantom survive.+ """+ declared = _declared_tool_entry_points()+ unreachable = {+ name+ for name in declared+ if name not in ROUTER_TOOLS and name not in INTERNAL_ONLY+ }+ resolved = sorted(KNOWN_UNREACHABLE - unreachable)+ assert not resolved, (+ f"these are no longer unreachable: {resolved} — remove them from "+ "KNOWN_UNREACHABLE so the list keeps meaning something."+ )+++def test_the_spawn_skill_author_phantom_stays_removed() -> None:+ """Regression guard for the specific phantom that motivated this test.++ Re-registering it would ALSO crash: its __init__ requires `runner=`, which+ the entry-point loader cannot supply.+ """+ assert "spawn-skill-author" not in _declared_tool_entry_points()+ assert "spawn-skill-author" not in ROUTER_TOOLS+ assert "spawn_skill_author" not in ROUTER_TOOLS+++def test_the_dead_tool_still_documents_why_it_is_unwired() -> None:+ """The class is kept for its runner tests — the docstring must say so.++ Without the warning the obvious "fix" is to add the name to ROUTER_TOOLS,+ which raises TypeError at tool load rather than working.+ """+ import jarvis.brain.tools.skill_authoring as module++ doc = module.__doc__ or ""+ assert "NOT WIRED" in doc+ assert "TypeError" in doc+++def test_internal_only_exemptions_all_carry_a_reason() -> None:+ for name, reason in INTERNAL_ONLY.items():+ assert reason.strip(), f"{name} is exempt without a stated reason"diff --git a/tests/unit/skills/test_quality.py b/tests/unit/skills/test_quality.pynew file mode 100644index 0000000000..a9d1b50509--- /dev/null+++ b/tests/unit/skills/test_quality.py@@ -0,0 +1,302 @@+"""Can this skill ever be FOUND? — the check nothing performed before.++``validate_skill`` asks whether a SKILL.md parses and is safe. These tests cover+the different question: whether a skill carries enough distinctive vocabulary to+be reachable at all. A skill can be perfectly valid, enabled, and invisible.++Every ERROR-level rule here was written against something real on disk, not+imagined: a skill with an empty description and a one-heading body, and a skill+whose vocabulary is English-only while the user speaks German (the routing eval+records that one as a known gap independently).+"""+from __future__ import annotations++from typing import Any++import pytest++from jarvis.skills import quality+++class _FakeRiskPolicy:+ def __init__(self, tier: str = "monitor") -> None:+ self.default_tier = tier+++class _FakeTrigger:+ def __init__(self, pattern: str) -> None:+ self.type = "voice"+ self.pattern = pattern+++class _FakeFrontmatter:+ def __init__(+ self,+ *,+ description: str = "Runs a focused work sprint with a timer.",+ when_to_use: str = "Use when the user wants to concentrate.",+ category: str = "productivity",+ tags: list[str] | None = None,+ execution: str = "inline",+ triggers: list[Any] | None = None,+ intent_objects: list[str] | None = None,+ ) -> None:+ self.description = description+ self.when_to_use = when_to_use+ self.category = category+ self.tags = tags if tags is not None else ["focus", "timer", "sprint"]+ self.execution = execution+ self.risk_policy = _FakeRiskPolicy()+ self.triggers = triggers or []+ self.intent_verbs: list[str] = []+ self.intent_objects = intent_objects or []+++class _FakeSkill:+ def __init__(+ self,+ name: str = "deep-work-mode",+ frontmatter: _FakeFrontmatter | None = None,+ body: str = "# Deep work\n\nSilence notifications and start a timer.\n",+ ) -> None:+ self.name = name+ self.frontmatter = frontmatter if frontmatter is not None else _FakeFrontmatter()+ self.body = body+++def _codes(report: quality.QualityReport) -> set[str]:+ return {finding.code for finding in report.findings}+++# ---------------------------------------------------------------------------+# A healthy skill+# ---------------------------------------------------------------------------+++def test_a_well_formed_skill_reports_nothing() -> None:+ report = quality.lint_skill(_FakeSkill())+ assert report.ok+ assert report.findings == ()+++def test_a_broken_frontmatter_is_left_to_the_validator() -> None:+ """Nothing to judge here — a parse failure is validator territory."""+ skill = _FakeSkill()+ skill.frontmatter = None+ assert quality.lint_skill(skill).findings == ()+++# ---------------------------------------------------------------------------+# The errors — each one written against something real on disk+# ---------------------------------------------------------------------------+++def test_an_empty_description_is_an_error() -> None:+ """The description IS the listing entry the model reads."""+ report = quality.lint_skill(+ _FakeSkill(frontmatter=_FakeFrontmatter(description=""))+ )+ assert quality.Q_EMPTY_DESCRIPTION in _codes(report)+ assert not report.ok+++def test_a_body_with_only_a_heading_is_an_error() -> None:+ """A skill that does nothing when it fires is worse than one that misses."""+ report = quality.lint_skill(_FakeSkill(body="## Browser Tabs\n"))+ assert quality.Q_EMPTY_BODY in _codes(report)+ assert not report.ok+++def test_too_few_distinctive_terms_is_an_error() -> None:+ """Unreachable by construction — no channel has anything to match on."""+ report = quality.lint_skill(+ _FakeSkill(+ name="x1",+ frontmatter=_FakeFrontmatter(+ description="the and but", when_to_use="", tags=[], category=""+ ),+ body="# x1\n\nthe and but\n",+ )+ )+ assert quality.Q_TOO_FEW_TERMS in _codes(report)+++def test_function_words_do_not_count_as_vocabulary() -> None:+ """Uses the shared scorer's own stopword handling, so "matchable" here means+ exactly what the matcher can match."""+ terms = quality.distinctive_terms(+ _FakeSkill(+ name="s",+ frontmatter=_FakeFrontmatter(+ description="der die das und oder aber", # i18n-allow: speech input+ when_to_use="",+ tags=[],+ category="",+ ),+ )+ )+ assert len(terms) < quality.MIN_DISTINCTIVE_TERMS+++def test_a_mission_skill_without_when_to_use_is_unreachable() -> None:+ """It can never auto-fire (it starts a process), so the model must be able+ to CHOOSE it — and it chooses from when_to_use."""+ report = quality.lint_skill(+ _FakeSkill(+ name="cloud-debug",+ frontmatter=_FakeFrontmatter(execution="mission", when_to_use=""),+ )+ )+ assert quality.Q_MISSION_WITHOUT_WHEN in _codes(report)+ assert not report.ok+++# ---------------------------------------------------------------------------+# The warnings+# ---------------------------------------------------------------------------+++def test_a_display_string_name_is_flagged() -> None:+ """Functional, not stylistic: run-skill looks skills up BY NAME, so a skill+ called "Browser Tabs" cannot be invoked."""+ report = quality.lint_skill(_FakeSkill(name="Browser Tabs"))+ assert quality.Q_NAME_NOT_A_SLUG in _codes(report)++[email protected]("name", ["deep-work-mode", "plugin-google_calendar", "cli-gcloud"])+def test_real_slugs_are_accepted(name: str) -> None:+ assert quality.Q_NAME_NOT_A_SLUG not in _codes(quality.lint_skill(_FakeSkill(name=name)))+++def test_a_missing_when_to_use_is_a_warning_not_an_error() -> None:+ """control-api's actual defect — and it must not block a save."""+ report = quality.lint_skill(_FakeSkill(frontmatter=_FakeFrontmatter(when_to_use="")))+ assert quality.Q_NO_WHEN_TO_USE in _codes(report)+ assert report.ok, "a warning must never block"+++def test_colliding_vocabulary_is_flagged() -> None:+ """plugin-discord and plugin-slack really are ~76 % identical, which is why+ "send a message" is ambiguous between them."""+ first = _FakeSkill(+ name="plugin-slack",+ frontmatter=_FakeFrontmatter(+ description="Send and read messages in a workspace channel.",+ when_to_use="Use for channel messages.",+ tags=["messages", "channel"],+ ),+ )+ second = _FakeSkill(+ name="plugin-discord",+ frontmatter=_FakeFrontmatter(+ description="Send and read messages in a workspace channel.",+ when_to_use="Use for channel messages.",+ tags=["messages", "channel"],+ ),+ )+ report = quality.lint_skill(first, peers=[first, second])+ assert quality.Q_TERM_COLLISION in _codes(report)+ assert report.ok, "collision is advisory — both skills may be legitimate"+++def test_distinct_skills_do_not_collide() -> None:+ first = _FakeSkill(name="deep-work-mode")+ second = _FakeSkill(+ name="plugin-gmail",+ frontmatter=_FakeFrontmatter(+ description="Read and send email from the inbox.",+ when_to_use="Use for mail.",+ tags=["mail", "inbox"],+ ),+ )+ report = quality.lint_skill(first, peers=[first, second])+ assert quality.Q_TERM_COLLISION not in _codes(report)+++def test_a_very_short_bare_trigger_is_flagged() -> None:+ report = quality.lint_skill(+ _FakeSkill(frontmatter=_FakeFrontmatter(triggers=[_FakeTrigger("ab")]))+ )+ assert quality.Q_GREEDY_TRIGGER in _codes(report)+++def test_a_real_alternation_trigger_is_fine() -> None:+ report = quality.lint_skill(+ _FakeSkill(+ frontmatter=_FakeFrontmatter(+ triggers=[_FakeTrigger("(fokusmodus|deep work mode)")] # i18n-allow+ )+ )+ )+ assert quality.Q_GREEDY_TRIGGER not in _codes(report)+++# ---------------------------------------------------------------------------+# Contract+# ---------------------------------------------------------------------------+++def test_only_errors_block() -> None:+ report = quality.lint_skill(_FakeSkill(frontmatter=_FakeFrontmatter(when_to_use="")))+ assert report.warnings+ assert not report.errors+ assert report.ok+++def test_every_finding_code_is_in_the_closed_vocabulary() -> None:+ cases = [+ _FakeSkill(frontmatter=_FakeFrontmatter(description="")),+ _FakeSkill(body="# only a heading\n"),+ _FakeSkill(name="Display Name"),+ _FakeSkill(frontmatter=_FakeFrontmatter(execution="mission", when_to_use="")),+ _FakeSkill(frontmatter=_FakeFrontmatter(triggers=[_FakeTrigger("ab")])),+ ]+ for skill in cases:+ for finding in quality.lint_skill(skill).findings:+ assert finding.code in quality.QUALITY_CODES+ assert finding.severity in ("error", "warning")+++def test_every_finding_carries_an_actionable_hint() -> None:+ """A report the maintainer cannot act on is noise."""+ report = quality.lint_skill(+ _FakeSkill(name="Browser Tabs", frontmatter=_FakeFrontmatter(description=""))+ )+ assert report.findings+ assert all(f.message.strip() for f in report.findings)+ assert all(f.hint.strip() for f in report.findings)+++def test_the_report_serialises_for_the_rest_layer() -> None:+ payload = quality.lint_skill(_FakeSkill()).as_dict()+ assert payload["skill_name"] == "deep-work-mode"+ assert payload["ok"] is True+ assert payload["findings"] == []+++def test_lint_registry_reports_each_skill_against_its_peers() -> None:+ skills = [_FakeSkill(name=f"skill-{i}") for i in range(3)]+ reports = quality.lint_registry(skills)+ assert len(reports) == 3+ assert [r.skill_name for r in reports] == ["skill-0", "skill-1", "skill-2"]+++def test_linting_never_raises_on_a_degenerate_skill() -> None:+ class _Bare:+ pass++ assert isinstance(quality.lint_skill(_Bare()), quality.QualityReport)+++def test_the_loader_is_not_involved() -> None:+ """Enforce at the WRITE boundary, report at the READ boundary, never at LOAD.++ A content rule applied at load time suppresses the skills nobody anticipated+ along with the bad ones — silently, at boot, with no signal (AP-27).+ """+ from pathlib import Path++ import jarvis.skills.loader as loader++ source = Path(loader.__file__).read_text(encoding="utf-8")+ assert "quality" not in source