Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(skills): publish built-ins with stable Windows identities (#2738)
Call White215dd23017d8
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 91883935b..0ebf549b1 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -25,6 +25,7 @@ jobs:contents: readoutputs:docs_only: ${{ steps.scope.outputs.docs_only }}+ windows_control_ipc: ${{ steps.scope.outputs.windows_control_ipc }}steps:- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5with:@@ -764,8 +765,8 @@ jobs:windows-control-ipc:runs-on: windows-latest- needs: build-linux-artifacts- if: github.event_name != 'pull_request'+ needs: [changes, build-linux-artifacts]+ if: needs.changes.outputs.docs_only == 'false' && (github.event_name != 'pull_request' || needs.changes.outputs.windows_control_ipc == 'true')steps:- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5@@ -824,8 +825,10 @@ jobs:# A Windows directory listing reports st_dev and st_ino as zero, so a# Skill whose identity is taken from it fails every later identity check# and the catalog comes back empty -- how gh-v3.1.2rc5's bundled- # `vibe skill load -- use-avibe` failed. Only a real Windows filesystem- # shows it, and like the steps above it needs no packaged Runtime.+ # `vibe skill load -- use-avibe` failed. In-place publication compares+ # those identities across two enumerations; the same zero listing made+ # an unchanged source look changed. Only a real Windows filesystem shows+ # it, and like the steps above it needs no packaged Runtime.- name: Verify Skill discovery keeps real directory identitiesrun: python -m pytest tests/test_managed_skills.py -q -k zero_directory_entry_identitiesdiff --git a/core/managed_skills.py b/core/managed_skills.pyindex 5c54310c9..8f54ef100 100644--- a/core/managed_skills.py+++ b/core/managed_skills.py@@ -613,6 +613,12 @@ def parse_skill_file(return skill+def _dir_entry_stat(entry: os.DirEntry, *, follow_symlinks: bool = False) -> os.stat_result:+ # DirEntry.stat() reports st_dev/st_ino as zero on Windows; identity and+ # publication tokens need the path's real stat, same as discovery (#2270).+ return os.stat(entry.path, follow_symlinks=follow_symlinks)++def _root_children(root: Path,*,@@ -637,9 +643,7 @@ def _root_children(if entry.name in ignored_names:continuetry:- # DirEntry.stat() reports st_dev/st_ino as zero on Windows;- # identity checks downstream need the path's real stat.- entry_stat = os.stat(entry.path, follow_symlinks=False)+ entry_stat = _dir_entry_stat(entry, follow_symlinks=False)except OSError:continuechildren.append((entry.name, Path(entry.path), entry_stat))@@ -874,7 +878,7 @@ def _readable_builtin_catalog(root: Path) -> bool:if _is_catalog_noise(entry.name, child):continuetry:- child_stat = entry.stat(follow_symlinks=False)+ child_stat = _dir_entry_stat(entry, follow_symlinks=False)except OSError:continueif stat.S_ISDIR(child_stat.st_mode) and (child / "SKILL.md").is_file():@@ -1459,7 +1463,7 @@ def _snapshot_entries(root: Path) -> list[_SnapshotEntry]:f"Built-in Skill tree exceeds {BUILTIN_TREE_MAX_ENTRIES:,} entries")try:- child_stat = child.stat(follow_symlinks=False)+ child_stat = _dir_entry_stat(child, follow_symlinks=False)except OSError as exc:raise RuntimeError(f"Cannot inspect built-in Skill path: {relative}") from excfile_attributes = int(getattr(child_stat, "st_file_attributes", 0))diff --git a/scripts/ci_docs_only.py b/scripts/ci_docs_only.pyindex 1fb6e3ab2..c0229a727 100644--- a/scripts/ci_docs_only.py+++ b/scripts/ci_docs_only.py@@ -20,6 +20,12 @@ ROOT_DOCS = frozenset({# full: tests also glob plan prose, so a list of individual exceptions cannot# safely describe that boundary. AGENTS.md has a dedicated lightweight check.CONTRACT_DOCS = frozenset({"docs/INSTALL_FOR_AI.md", "docs/INSTALL_FOR_AI_ZH.md"})+# Built-in Skill publication compares directory identities. Windows DirEntry+# listings zero those identities, so that path must run on the real Windows job.+WINDOWS_CONTROL_IPC_PATHS = frozenset({+ "core/managed_skills.py",+ "tests/test_managed_skills.py",+})def narrative_path(path: str) -> bool:@@ -67,8 +73,8 @@ def impact_category(paths: list[str]) -> str:return "shared-or-mixed"-def classify(event_name: str, event: dict, sha: str, repo: Path) -> tuple[bool, str, str]:- """Return docs disposition, reason, and non-authoritative impact telemetry."""+def classify(event_name: str, event: dict, sha: str, repo: Path) -> tuple[bool, str, str, bool]:+ """Return docs disposition, reason, impact telemetry, and Windows IPC selection."""try:if not isinstance(event, dict):raise ValueError("event payload is not an object")@@ -107,22 +113,29 @@ def classify(event_name: str, event: dict, sha: str, repo: Path) -> tuple[bool,if len(fields) % 2:raise ValueError("incomplete diff records")paths = []+ irregular = Falsefor header, name in zip(fields[::2], fields[1::2]):meta = header.decode("ascii").split()if len(meta) != 5 or not meta[0].startswith(":"):raise ValueError("unexpected diff record")old_mode, new_mode = meta[0][1:], meta[1]+ path = name.decode("utf-8")+ paths.append(path)if meta[4] not in {"A", "M", "D"} or {old_mode, new_mode} - {"000000", "100644"}:- return False, "non-document file type or mode changed", "unknown"- paths.append(name.decode("utf-8"))+ irregular = True+ windows_control_ipc = any(path in WINDOWS_CONTROL_IPC_PATHS for path in paths)+ if irregular:+ return False, "non-document file type or mode changed", "unknown", windows_control_ipcimpact = impact_category(paths)for path in paths:if not narrative_path(path):- return False, f"full CI required by {json.dumps(path, ensure_ascii=True)}", impact- return True, f"all {len(paths)} changed paths are narrative documentation", impact+ return False, f"full CI required by {json.dumps(path, ensure_ascii=True)}", impact, windows_control_ipc+ return True, f"all {len(paths)} changed paths are narrative documentation", impact, Falseexcept (OSError, ValueError, KeyError, TypeError, subprocess.SubprocessError) as exc:# Do not print Git stderr, event payloads or arbitrary commit data.- return False, f"full CI: classification unavailable ({type(exc).__name__})", "unknown"+ # Conservatively select the Windows job when classification cannot prove+ # the Skill publication paths are absent from this event.+ return False, f"full CI: classification unavailable ({type(exc).__name__})", "unknown", Truedef main() -> None:@@ -131,7 +144,7 @@ def main() -> None:except (OSError, ValueError, KeyError):event = {}event_name = os.environ.get("GITHUB_EVENT_NAME", "")- docs_only, reason, impact = classify(+ docs_only, reason, impact, windows_control_ipc = classify(event_name, event, os.environ.get("GITHUB_SHA", ""), Path.cwd(),)# A master push supersedes the preceding run even when only docs changed.@@ -146,7 +159,9 @@ def main() -> None:if output:with Path(output).open("a", encoding="utf-8") as stream:stream.write(f"docs_only={str(docs_only).lower()}\n")+ stream.write(f"windows_control_ipc={str(windows_control_ipc).lower()}\n")print(f"docs_only={str(docs_only).lower()}: {reason}")+ print(f"windows_control_ipc={str(windows_control_ipc).lower()}")print(f"Impact shadow: {impact} (observation only; no test selection)")summary = os.environ.get("GITHUB_STEP_SUMMARY")if summary:diff --git a/tests/test_ci_docs_only.py b/tests/test_ci_docs_only.pyindex 3f92ca2ca..72d6378a7 100644--- a/tests/test_ci_docs_only.py+++ b/tests/test_ci_docs_only.py@@ -49,7 +49,7 @@ def repo(tmp_path: Path) -> Path:return root-def push(repo: Path, base: str, **overrides) -> tuple[bool, str, str]:+def push(repo: Path, base: str, **overrides) -> tuple[bool, str, str, bool]:after = git(repo, "rev-parse", "HEAD")event = {"before": base, "after": after, "created": False, "deleted": False, "forced": False}event.update(overrides)@@ -130,7 +130,18 @@ def test_doc_suffix_never_hides_non_document_modes(repo: Path, kind: str) -> Nonpath.unlink()path.symlink_to("core.py")commit(repo)- assert not push(repo, before)[0]+ result = push(repo, before)+ assert result[0] is False and result[3] is False+++def test_windows_control_ipc_survives_an_irregular_sibling_diff(repo: Path) -> None:+ before = git(repo, "rev-parse", "HEAD")+ write(repo, "core/managed_skills.py", "print('runtime')\n")+ (repo / "docs").mkdir(exist_ok=True)+ (repo / "docs/link.md").symlink_to("../core.py")+ commit(repo)+ result = push(repo, before)+ assert result[0] is False and result[3] is Truedef synthetic_pr(repo: Path) -> tuple[dict, str]:@@ -177,14 +188,17 @@ def test_unknown_push_evidence_falls_back_to_full(repo: Path, change: dict) -> Nbefore = git(repo, "rev-parse", "HEAD")write(repo, "AGENTS.md")commit(repo)- assert not push(repo, before, **change)[0]+ result = push(repo, before, **change)+ assert result[0] is False and result[3] is Truedef test_empty_diff_and_unsupported_or_broken_events_are_not_docs(repo: Path) -> None:sha = git(repo, "rev-parse", "HEAD")- assert not push(repo, sha)[0]+ result = push(repo, sha)+ assert result[0] is False and result[3] is Truefor name, payload in (("workflow_dispatch", {}), ("pull_request", {}), ("push", [])):- assert not classify(name, payload, sha, repo)[0]+ classified = classify(name, payload, sha, repo)+ assert classified[0] is False and classified[3] is True@pytest.mark.parametrize("event_name,expected", [("pull_request", "true"), ("push", "false")])@@ -209,14 +223,21 @@ def test_cli_keeps_docs_pr_fast_but_master_replaces_full_coverage("GITHUB_STEP_SUMMARY": str(summary)}result = subprocess.run([sys.executable, str(SCRIPT)], cwd=repo, env=env, capture_output=True, text=True)assert result.returncode == 0, result.stderr- assert output.read_text() == f"docs_only={expected}\n"+ assert output.read_text() == (+ f"docs_only={expected}\nwindows_control_ipc=false\n"+ )assert "Impact shadow: **docs-only**" in summary.read_text()if event_name == "push":assert "superseded code changes" in result.stdoutevent.unlink()result = subprocess.run([sys.executable, str(SCRIPT)], cwd=repo, env=env, capture_output=True, text=True)assert result.returncode == 0, result.stderr- assert output.read_text().splitlines() == [f"docs_only={expected}", "docs_only=false"]+ assert output.read_text().splitlines() == [+ f"docs_only={expected}",+ "windows_control_ipc=false",+ "docs_only=false",+ "windows_control_ipc=true",+ ]assert "Impact shadow: **unknown**" in summary.read_text()assert "full" in summary.read_text()@@ -246,10 +267,40 @@ def test_impact_shadow_never_authorizes_skipping_code_tests(repo: Path, tmp_path"GITHUB_EVENT_PATH": str(event), "GITHUB_OUTPUT": str(output),"GITHUB_STEP_SUMMARY": str(summary)})assert result.returncode == 0, result.stderr- assert output.read_text() == "docs_only=false\n" # No impact output for jobs to consume.+ # Impact stays observational; windows_control_ipc is an explicit extra job, not a skip.+ assert output.read_text() == "docs_only=false\nwindows_control_ipc=false\n"assert f"Impact shadow: **{category}**" in summary.read_text()[email protected](("path", "selected"), [+ ("core/managed_skills.py", True),+ ("tests/test_managed_skills.py", True),+ ("core/controller.py", False),+ ("tests/test_control_ipc.py", False),+])+def test_windows_control_ipc_selects_builtin_skill_publication_paths(+ repo: Path, tmp_path: Path, path: str, selected: bool,+) -> None:+ before = git(repo, "rev-parse", "HEAD")+ write(repo, path, "print('runtime')\n")+ sha = commit(repo)+ result = push(repo, before)+ assert result[0] is False and result[3] is selected+ event = tmp_path / "event.json"+ output = tmp_path / "output"+ event.write_text(json.dumps({"before": before, "after": sha,+ "created": False, "deleted": False, "forced": False}))+ ran = subprocess.run(+ [sys.executable, str(SCRIPT)], cwd=repo, capture_output=True, text=True,+ env={**os.environ, "GITHUB_EVENT_NAME": "push", "GITHUB_SHA": sha,+ "GITHUB_EVENT_PATH": str(event), "GITHUB_OUTPUT": str(output)},+ )+ assert ran.returncode == 0, ran.stderr+ assert output.read_text() == (+ f"docs_only=false\nwindows_control_ipc={str(selected).lower()}\n"+ )++def test_guidance_remains_enforced_when_an_agents_only_diff_skips_application_tests(repo: Path) -> None:root = SCRIPT.parents[1]paths = (diff --git a/tests/test_ci_pipeline.py b/tests/test_ci_pipeline.pyindex b8962f281..ba423cdc9 100644--- a/tests/test_ci_pipeline.py+++ b/tests/test_ci_pipeline.py@@ -378,8 +378,18 @@ def test_ui_checks_run_once_without_fencing_artifact_consumers() -> None:def test_windows_platform_checks_leave_only_latest_installer_smoke_on_prs() -> None:jobs = _jobs()- for name in ("windows-model-hub", "windows-control-ipc"):- assert jobs[name]["if"] == "github.event_name != 'pull_request'"+ assert jobs["windows-model-hub"]["if"] == "github.event_name != 'pull_request'"+ assert jobs["windows-control-ipc"]["needs"] == ["changes", "build-linux-artifacts"]+ assert jobs["windows-control-ipc"]["if"] == (+ "needs.changes.outputs.docs_only == 'false' && "+ "(github.event_name != 'pull_request' || needs.changes.outputs.windows_control_ipc == 'true')"+ )+ skill_step = next(+ step for step in jobs["windows-control-ipc"]["steps"]+ if step.get("name") == "Verify Skill discovery keeps real directory identities"+ )+ assert "tests/test_managed_skills.py" in skill_step["run"]+ assert "zero_directory_entry_identities" in skill_step["run"]assert jobs["windows-agent"]["if"] == ("needs.changes.outputs.docs_only == 'false' && github.event_name != 'pull_request'")@@ -563,6 +573,7 @@ def test_docs_scope_gates_all_work_without_filtering_away_required_checks() -> Nassert not job.get("continue-on-error")scope = jobs["changes"]assert scope["outputs"]["docs_only"] == "${{ steps.scope.outputs.docs_only }}"+ assert scope["outputs"]["windows_control_ipc"] == "${{ steps.scope.outputs.windows_control_ipc }}"assert not scope.get("if") and not scope.get("continue-on-error")command, = [s for s in scope["steps"] if s.get("id") == "scope"]assert command["run"] == "python3 scripts/ci_docs_only.py"diff --git a/tests/test_managed_skills.py b/tests/test_managed_skills.pyindex 99ecc8a84..7e2428c3e 100644--- a/tests/test_managed_skills.py+++ b/tests/test_managed_skills.py@@ -77,6 +77,59 @@ def _isolate_live_commands(monkeypatch, tmp_path: Path) -> tuple[Path, Path]:return home, cwd+def _install_zero_identity_scandir(monkeypatch) -> None:+ """Make DirEntry.stat() report unstable zero identities, as Windows listings do.++ Real Windows DirEntry.stat() zeros st_dev/st_ino. Two enumerations of an+ unchanged tree can therefore disagree if publication tokens those fields+ from the listing instead of the path. Keep the rest of the listing so+ callers that read attributes still work, and vary the zeroed identity+ across enumerations so a same-token fixture cannot hide the mismatch.+ """++ real_scandir = os.scandir+ sequence_fields = {"st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size"}+ enumerations = 0++ class _WindowsLikeEntry:+ def __init__(self, entry: os.DirEntry, generation: int) -> None:+ self.name = entry.name+ self.path = entry.path+ self._entry = entry+ self._generation = generation++ def stat(self, *, follow_symlinks: bool = True) -> os.stat_result:+ real = self._entry.stat(follow_symlinks=follow_symlinks)+ values = list(real)+ values[1] = self._generation # st_ino: listing identity, not the inode+ values[2] = 0 # st_dev+ extras = {+ name: getattr(real, name)+ for name in dir(real)+ if name.startswith("st_") and name not in sequence_fields+ }+ return os.stat_result(values, extras)++ def __getattr__(self, name: str):+ return getattr(self._entry, name)++ class _WindowsLikeScandir:+ def __init__(self, path) -> None:+ nonlocal enumerations+ enumerations += 1+ self._generation = enumerations+ self._iterator = real_scandir(path)++ def __enter__(self):+ generation = self._generation+ return (_WindowsLikeEntry(entry, generation) for entry in self._iterator)++ def __exit__(self, *exc_info) -> None:+ self._iterator.close()++ monkeypatch.setattr(managed_skills.os, "scandir", _WindowsLikeScandir)++def test_loose_parser_requires_only_portable_name_and_description(tmp_path: Path) -> None:skill_file = tmp_path / "skill" / "SKILL.md"skill_file.parent.mkdir()@@ -809,43 +862,7 @@ def test_discovery_ignores_zero_directory_entry_identities(tmp_path: Path, monke_write_skill(root, "beta", "beta", "Beta")linked = _write_skill(tmp_path / "shared", "formatter", "formatter", "Format")(root / "formatter").symlink_to(linked.parent, target_is_directory=True)- real_scandir = os.scandir- sequence_fields = {"st_mode", "st_ino", "st_dev", "st_nlink", "st_uid", "st_gid", "st_size"}-- class _WindowsLikeEntry:- def __init__(self, entry: os.DirEntry) -> None:- self.name = entry.name- self.path = entry.path- self._entry = entry-- def stat(self, *, follow_symlinks: bool = True) -> os.stat_result:- real = self._entry.stat(follow_symlinks=follow_symlinks)- values = list(real)- values[1] = 0 # st_ino- values[2] = 0 # st_dev- # Only the identity differs from a Windows listing; keep the rest- # (st_file_attributes, *_ns, ...) so callers that read it still work.- extras = {- name: getattr(real, name)- for name in dir(real)- if name.startswith("st_") and name not in sequence_fields- }- return os.stat_result(values, extras)-- def __getattr__(self, name: str):- return getattr(self._entry, name)-- class _WindowsLikeScandir:- def __init__(self, path) -> None:- self._iterator = real_scandir(path)-- def __enter__(self):- return (_WindowsLikeEntry(entry) for entry in self._iterator)-- def __exit__(self, *exc_info) -> None:- self._iterator.close()-- monkeypatch.setattr(managed_skills.os, "scandir", _WindowsLikeScandir)+ _install_zero_identity_scandir(monkeypatch)names = {skill.name for skill in resolve_skills(cwd)}assert {"use-avibe", "use-avibe-vault", "alpha", "beta", "formatter"} <= names@@ -1796,6 +1813,45 @@ def test_publication_rejects_source_changes_before_swap(publish_builtin_skills(source_root=source, destination_root=destination)+def test_publication_survives_zero_directory_entry_identities(+ tmp_path: Path,+ monkeypatch,+) -> None:+ """Windows DirEntry identities are zero; an unchanged source must still publish."""++ source = tmp_path / "source"+ destination = tmp_path / "builtin-skills"+ _write_skill(source, "alpha", "alpha", "Alpha")+ _install_zero_identity_scandir(monkeypatch)++ assert publish_builtin_skills(source_root=source, destination_root=destination) == destination+ assert (destination / "alpha" / "SKILL.md").is_file()+++def test_publication_detects_source_change_with_zero_directory_entry_identities(+ tmp_path: Path,+ monkeypatch,+) -> None:+ source = tmp_path / "source"+ destination = tmp_path / "builtin-skills"+ skill_file = _write_skill(source, "alpha", "alpha", "Alpha", "Old\n")+ original_copy = managed_skills._copy_snapshot_entries+ _install_zero_identity_scandir(monkeypatch)++ def copy_then_rewrite(entries, destination_root):+ original_copy(entries, destination_root)+ skill_file.write_text(+ "---\nname: alpha\ndescription: Alpha\n---\nNew\n",+ encoding="utf-8",+ )++ monkeypatch.setattr(managed_skills, "_copy_snapshot_entries", copy_then_rewrite)++ with pytest.raises(RuntimeError, match="source changed"):+ publish_builtin_skills(source_root=source, destination_root=destination)+ assert not destination.exists()++def test_publication_restores_previous_if_live_swap_fails(tmp_path: Path,monkeypatch,