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(security): clear the Security tab's actionable alerts and stop dist chunks from piling up (#405)
Ruben Lütke3e2f06d194ca
diff --git a/.githooks/pre-commit b/.githooks/pre-commitindex 09032d32ba..ef7be3179d 100755--- a/.githooks/pre-commit+++ b/.githooks/pre-commit@@ -71,17 +71,21 @@ fi# GIT: a commit that rewrites dist/index.html to freshly-hashed chunks while# the chunks themselves stay untracked works on the builder's machine (files# are on disk) but boots every clone to a blank spinner (cloud review-# 2026-07-18, AP-23). Checks the STAGED index, only when the commit touches-# dist/. rc 1 = confirmed missing chunk; any other rc fails OPEN.+# 2026-07-18, AP-23). It also refuses newly added ORPHAN chunks: earlier+# builds' files the build keeps on disk for open windows, which a blanket+# `git add` of dist/ would otherwise ship forever. Checks the STAGED index,+# only when the commit touches dist/. rc 1 = confirmed; any other rc fails OPEN.dist_gate="scripts/ci/check_dist_consistency.py"if [ -f "$dist_gate" ]; then"$PY" "$dist_gate" --staged </dev/nullif [ "$?" -eq 1 ]; thenecho ""- echo "pre-commit BLOCKED: DIST CONSISTENCY gate — half-shipped frontend bundle."- echo " The staged dist/index.html (or a chunk it loads) references files that"- echo " are NOT staged/tracked. Stage the ENTIRE rebuilt bundle as one set:"+ echo "pre-commit BLOCKED: DIST CONSISTENCY gate — inconsistent frontend bundle."+ echo " Either the staged dist/index.html (or a chunk it loads) references files"+ echo " that are NOT staged — stage the ENTIRE rebuilt bundle as one set:"echo " git add jarvis/ui/web/dist/index.html jarvis/ui/web/dist/assets/"+ echo " — or orphaned chunks of earlier builds are staged — untrack them with:"+ echo " python $dist_gate --staged --prune"echo " Bypass once with: git commit --no-verify"exit 1fidiff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex fec06552fb..349d17b295 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -17,6 +17,10 @@ updates:# platform-universal application lock when refreshing packaging tools.- package-ecosystem: pipdirectory: /scripts/ci+ # New releases wait a week before a PR, so a hijacked publish is+ # usually caught and yanked before it can reach this repository.+ cooldown:+ default-days: 7schedule:interval: weeklyopen-pull-requests-limit: 5@@ -29,6 +33,10 @@ updates:# review the diff carefully before merging (read TRUST_ROOT.md §7).- package-ecosystem: github-actionsdirectory: /+ # New releases wait a week before a PR, so a hijacked publish is+ # usually caught and yanked before it can reach this repository.+ cooldown:+ default-days: 7schedule:interval: weeklyday: monday@@ -68,6 +76,10 @@ updates:# `requirements.in` instructs.- package-ecosystem: pipdirectory: /+ # New releases wait a week before a PR, so a hijacked publish is+ # usually caught and yanked before it can reach this repository.+ cooldown:+ default-days: 7schedule:interval: weeklyday: monday@@ -80,3 +92,25 @@ updates:commit-message:prefix: depsinclude: scope++ # Container base images are pinned by digest (multi-arch index) so a+ # rebuilt image cannot silently change; this keeps those digests current.+ - package-ecosystem: docker+ directories: ["/", "/keyproxy", "/board-backend"]+ cooldown:+ default-days: 7+ schedule:+ interval: weekly+ day: monday+ time: "07:00"+ timezone: "Europe/Berlin"+ open-pull-requests-limit: 3+ groups:+ base-images:+ patterns: ["*"]+ labels:+ - dependencies+ - docker+ commit-message:+ prefix: deps+ include: scopediff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.ymlindex b2eb8e48a8..778126cb7a 100644--- a/.github/workflows/contributors.yml+++ b/.github/workflows/contributors.yml@@ -33,8 +33,9 @@ on:types: [closed]workflow_dispatch:+# Read-only by default; the job below asks for the push it makes.permissions:- contents: write+ contents: readconcurrency:# One constant group, NOT keyed on the ref: every run of this job pushes to@@ -51,6 +52,8 @@ jobs:if: github.event_name != 'pull_request_target' || github.event.pull_request.merged == trueruns-on: ubuntu-latesttimeout-minutes: 10+ permissions:+ contents: writesteps:- name: Checkoutuses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2diff --git a/.github/workflows/merge-train.yml b/.github/workflows/merge-train.ymlindex 381de12225..6dd4e2b196 100644--- a/.github/workflows/merge-train.yml+++ b/.github/workflows/merge-train.yml@@ -53,16 +53,19 @@ concurrency:group: merge-traincancel-in-progress: false+# Read-only by default; the one job below asks for what it writes.permissions:- contents: write- pull-requests: write- actions: write- checks: read+ contents: readjobs:train:name: merge trainruns-on: ubuntu-latest+ permissions:+ contents: write+ pull-requests: write+ actions: write+ checks: readtimeout-minutes: 60env:GH_TOKEN: ${{ secrets.INTEGRATION_TOKEN || github.token }}diff --git a/Dockerfile b/Dockerfileindex afc3c7ac00..43d2d24f04 100644--- a/Dockerfile+++ b/Dockerfile@@ -23,7 +23,7 @@# carries a ready-to-serve dist/ and needs no Node.# Mirror the package layout, including the shared marketplace catalog imported# by the frontend. Vite writes the bundle next to the frontend directory.-FROM node:22-slim AS web+FROM node:22-slim@sha256:c3de60bf2f9dd0ac6370e6117950ff62d6e339527e7472301c9c78a017978392 AS webWORKDIR /build/jarvis/ui/web/frontendCOPY jarvis/ui/web/frontend/package.json jarvis/ui/web/frontend/package-lock.json ./RUN npm ci@@ -32,7 +32,7 @@ COPY jarvis/marketplace/seed_catalog.json /build/jarvis/marketplace/seed_catalogRUN npm run build# --- Stage 2: runtime ---------------------------------------------------------FROM python:3.11-slim AS runtime+FROM python:3.11-slim@sha256:a2bc8c35469b6fe37735f7c4dae39049470b2ce068e73f799c02452de31d24c6 AS runtimeENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \diff --git a/board-backend/Dockerfile b/board-backend/Dockerfileindex efe32a4fa6..4ba859bdd3 100644--- a/board-backend/Dockerfile+++ b/board-backend/Dockerfile@@ -1,7 +1,7 @@# syntax=docker/dockerfile:1.7# --- Build-Stage ---------------------------------------------------------FROM --platform=$BUILDPLATFORM python:3.11-slim AS builder+FROM --platform=$BUILDPLATFORM python:3.11-slim@sha256:a2bc8c35469b6fe37735f7c4dae39049470b2ce068e73f799c02452de31d24c6 AS builderENV PIP_NO_CACHE_DIR=1 \PIP_DISABLE_PIP_VERSION_CHECK=1 \@@ -23,7 +23,7 @@ RUN python -m pip install --upgrade pip wheel \# --- Runtime-Stage -------------------------------------------------------FROM python:3.11-slim AS runtime+FROM python:3.11-slim@sha256:a2bc8c35469b6fe37735f7c4dae39049470b2ce068e73f799c02452de31d24c6 AS runtimeENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \diff --git a/jarvis/ui/web/frontend/osv-scanner.toml b/jarvis/ui/web/frontend/osv-scanner.tomlnew file mode 100644index 0000000000..55740920a0--- /dev/null+++ b/jarvis/ui/web/frontend/osv-scanner.toml@@ -0,0 +1,33 @@+# osv-scanner exceptions for package-lock.json in this folder.+#+# Every entry is a build-time-only (devDependencies) package with no fixed+# release reachable from our toolchain. None of them ships in the prebuilt+# bundle or runs inside the app: they parse our own CSS and source globs+# while `npm run build` runs, so the attacker-controlled input each advisory+# needs never reaches them. `ignoreUntil` forces a fresh review.++# braces: stack exhaustion on deeply nested brace patterns. 3.0.3 is the+# last release and the advisory lists no fix. Pulled by chokidar/micromatch+# (Tailwind's file watcher) with globs from tailwind.config.+[[IgnoredVulns]]+id = "GHSA-vfj7-8cjw-p6xm"+ignoreUntil = 2027-01-06+reason = "Dev-only build dependency, no fixed release; only our own config globs reach it."++[[IgnoredVulns]]+id = "CVE-2026-93687"+ignoreUntil = 2027-01-06+reason = "Alias of GHSA-vfj7-8cjw-p6xm."++# postcss-selector-parser: quadratic parsing of flat selectors, fixed in+# 7.1.6. Tailwind CSS 3 (^6.1.2) and @tailwindcss/typography (pins 6.0.10)+# require the 6.x line; it only parses the selectors in our own stylesheets.+[[IgnoredVulns]]+id = "GHSA-rj75-hqrm-r3gf"+ignoreUntil = 2027-01-06+reason = "Dev-only build dependency; the fix is 7.x, which Tailwind CSS 3 cannot use; parses only our own CSS."++[[IgnoredVulns]]+id = "CVE-2026-104844"+ignoreUntil = 2027-01-06+reason = "Alias of GHSA-rj75-hqrm-r3gf."diff --git a/jarvis/ui/web/frontend/package-lock.json b/jarvis/ui/web/frontend/package-lock.jsonindex 0b03a3fa51..1b0e8ca8b0 100644--- a/jarvis/ui/web/frontend/package-lock.json+++ b/jarvis/ui/web/frontend/package-lock.json@@ -7747,9 +7747,9 @@"license": "ISC"},"node_modules/source-map-js": {- "version": "1.2.1",- "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",- "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==","dev": true,"license": "BSD-3-Clause","engines": {diff --git a/keyproxy/Dockerfile b/keyproxy/Dockerfileindex a8a554dbac..b9a3ab64ac 100644--- a/keyproxy/Dockerfile+++ b/keyproxy/Dockerfile@@ -3,7 +3,7 @@# keyproxy — a small vendor-aware LLM key reverse proxy.# Single-stage slim image: no compiler toolchain is needed (pure-Python deps).-FROM python:3.11-slim+FROM python:3.11-slim@sha256:a2bc8c35469b6fe37735f7c4dae39049470b2ce068e73f799c02452de31d24c6ENV PYTHONDONTWRITEBYTECODE=1 \PYTHONUNBUFFERED=1 \diff --git a/keyproxy/requirements.txt b/keyproxy/requirements.txtindex be7ce521fb..ddd419fd68 100644--- a/keyproxy/requirements.txt+++ b/keyproxy/requirements.txt@@ -3,3 +3,8 @@fastapi>=0.110httpx>=0.27uvicorn[standard]>=0.29++# Security floors for transitive dependencies (fastapi/httpx pull them):+# anyio < 4.14.2 GHSA-82r6-8w77-94w6 / GHSA-5p39-cfhj-2xmp, idna < 3.15 GHSA-65pc-fj4g-8rjx.+anyio>=4.14.2+idna>=3.15diff --git a/scripts/ci/agent_integrate.py b/scripts/ci/agent_integrate.pyindex 0e9e36b564..4f71461aac 100644--- a/scripts/ci/agent_integrate.py+++ b/scripts/ci/agent_integrate.py@@ -363,6 +363,14 @@ def update(onto: str, mode: str, resolver_cmd: str, cwd: Path = REPO_ROOT) -> diexisting = sorted(s for s in specs if (cwd / s).exists())if existing:git("add", "-A", "--", *existing, cwd=cwd)+ if "frontend-build" in regen and "frontend-build" not in failed:+ # The build keeps retired chunks on disk for open windows, and a+ # fresh clone restarts that grace period, so `add -A` just staged+ # every earlier build's chunks too. Untrack them; disk is untouched.+ _sh(+ [sys.executable, "scripts/ci/check_dist_consistency.py", "--staged", "--prune"],+ cwd=cwd,+ )staged = git("diff", "--cached", "--name-only", cwd=cwd).stdout.strip()if staged:commit = git(diff --git a/scripts/ci/check_dist_consistency.py b/scripts/ci/check_dist_consistency.pyindex d157589a5e..c09a76eff5 100644--- a/scripts/ci/check_dist_consistency.py+++ b/scripts/ci/check_dist_consistency.py@@ -1,7 +1,9 @@#!/usr/bin/env python3"""Gate: the shipped frontend bundle must be self-consistent IN GIT.-The bug class (cloud review 2026-07-18): a frontend rebuild rewrites+Two bug classes, one chunk-graph walk.++**Missing chunks** (cloud review 2026-07-18): a frontend rebuild rewrites``dist/index.html`` to point at freshly-hashed chunks while the chunksthemselves exist only on disk, never ``git add``-ed. On the builder'smachine everything works (the files ARE on disk), so nothing looks wrong@@ -11,15 +13,36 @@ boots to a permanently-blank UI behind the splash spinner. Classic AP-23purpose (see the ``!jarvis/ui/web/dist/**`` carve-out in .gitignore), soa half-committed bundle IS a broken product for everyone else.-The check therefore reads every blob from GIT (HEAD, or the staged index-with ``--staged``), never from the working tree, and walks the chunk-graph: starting at ``dist/index.html``, every hashed asset reference-must resolve to a git-tracked file under ``dist/assets/``, transitively+**Orphaned chunks** (2026-10-06): ``scripts/publish-build.mjs`` keeps a+retired chunk on disk for 24 hours so an already-open window can still+lazy-load it. That grace ledger is untracked, so every fresh clone (the+merge train, every agent worktree) starts the clock again and a+``git add`` of the dist folder committed all retired chunks with the new+bundle. ``dist/assets`` grew to ~5,000 dead files (~210 MB); each copy of+a third-party chunk re-raised the same code-scanning alerts. A hashed file+under ``dist/assets/`` that nothing reachable from ``dist/index.html``+names is therefore refused too.++The check reads every blob from GIT (HEAD, or the staged index with+``--staged``), never from the working tree, and walks the chunk graph:+starting at ``dist/index.html``, every hashed asset reference must+resolve to a git-tracked file under ``dist/assets/``, transitivelythrough the referenced JS/CSS chunks (dynamic imports, font urls).+Modes:+ (default) check HEAD: missing AND orphaned chunks fail.+ --staged check the index, only when the commit touches dist/:+ missing chunks fail, and so do orphans this commit+ ADDS (orphans already in HEAD never wedge a commit).+ --staged --prune untrack every orphan in the index (``git rm+ --cached``); the files stay on disk for open windows.+ --prune-disk delete orphans from the working tree's dist/assets.+ For throwaway clones (merge train) only -- never the+ live desktop checkout, whose open windows need them.+Exit codes:0 -- consistent (or nothing to check: dist not tracked / not touched).- 1 -- CONFIRMED: at least one referenced chunk is not tracked by git.+ 1 -- CONFIRMED: a referenced chunk is not tracked, or an orphan is.3 -- could not check (no git, unreadable blob, ...). The hooks treatthis as fail-open so tooling noise never wedges a commit; CI isthe backstop.@@ -30,6 +53,8 @@ import reimport subprocessimport sysfrom collections import deque+from collections.abc import Callable, Iterable+from pathlib import PathDIST = "jarvis/ui/web/dist"ENTRY_HTML = f"{DIST}/index.html"@@ -45,6 +70,12 @@ _ASSETS_REF = re.compile(_RELATIVE_REF = re.compile(r"""["'(]\./([A-Za-z0-9._-]+-[A-Za-z0-9_-]{8}\.[a-z0-9]{2,5})""")+# Any hash-shaped file name, whatever precedes it. Used only to decide+# that a file IS referenced (``new URL("x-HASH.wasm", import.meta.url)``+# has no ./ prefix), so a false match keeps a file instead of dropping one.+_ANY_HASHED_NAME = re.compile(r"[A-Za-z0-9._@-]+-[A-Za-z0-9_-]{8}\.[a-z0-9]{2,5}")+# What publish-build.mjs treats as a generated, retirable asset.+_GENERATED_NAME = re.compile(r"-[A-Za-z0-9_-]{8}\.[a-z0-9]+$")# Only these blob types are scanned for onward references._SCANNABLE = (".js", ".mjs", ".css", ".html")@@ -77,8 +108,140 @@ def _refs_in(blob: str) -> set[str]:return names+def _walk(+ files: set[str], read: Callable[[str], str]+) -> tuple[set[str], dict[str, str]]:+ """Walk the chunk graph from the entry document.++ Returns the reachable files and the strictly referenced files that are+ absent (path -> first referrer). ``read`` raises on an unreadable file.+ """+ missing: dict[str, str] = {}+ visited: set[str] = set()+ queue: deque[str] = deque([ENTRY_HTML])+ while queue:+ path = queue.popleft()+ if path in visited:+ continue+ visited.add(path)+ blob = read(path)+ for name in sorted(_refs_in(blob)):+ ref = ASSETS_PREFIX + name+ if ref not in files:+ missing.setdefault(ref, path)+ elif ref.endswith(_SCANNABLE):+ queue.append(ref)+ else:+ visited.add(ref)+ for name in set(_ANY_HASHED_NAME.findall(blob)):+ ref = ASSETS_PREFIX + name+ if ref in files and ref not in visited:+ if ref.endswith(_SCANNABLE):+ queue.append(ref)+ else:+ visited.add(ref)+ return visited, missing+++def _orphans(files: Iterable[str], reachable: set[str]) -> list[str]:+ """Generated files directly under dist/assets that nothing reaches."""+ out = []+ for path in files:+ if not path.startswith(ASSETS_PREFIX):+ continue+ name = path[len(ASSETS_PREFIX):]+ if "/" in name or not _GENERATED_NAME.search(name):+ continue # public assets and nested folders are not build chunks+ if path not in reachable:+ out.append(path)+ return sorted(out)+++def _report_missing(missing: dict[str, str]) -> None:+ print("check_dist_consistency: BROKEN shipped frontend bundle.")+ print(+ " The entry chunk graph references files git does NOT track -- on a"+ )+ print(+ " fresh clone these 404 and the UI never mounts (blank spinner):"+ )+ for ref, referrer in sorted(missing.items()):+ print(f" MISSING {ref} (referenced by {referrer})")+ print(+ " Fix: commit the rebuilt bundle as ONE set -- `git add "+ f"{DIST}/index.html {ASSETS_PREFIX}` -- or rebuild it"+ )+ print(+ " (`npm run build` in jarvis/ui/web/frontend/) and stage everything"+ )+ print(" vite emitted, then retry.")+++def _report_orphans(orphans: list[str], staged: bool) -> None:+ print(+ f"check_dist_consistency: {len(orphans)} orphaned bundle file(s) "+ "would be shipped."+ )+ print(+ " Nothing reachable from dist/index.html loads them; they are chunks"+ )+ print(" of earlier builds the build keeps on disk for open windows:")+ for path in orphans[:20]:+ print(f" ORPHAN {path}")+ if len(orphans) > 20:+ print(f" ... and {len(orphans) - 20} more")+ if staged:+ print(+ " Fix: python scripts/ci/check_dist_consistency.py --staged --prune"+ )+ print(" (untracks them; the files stay on disk), then commit again.")+ else:+ print(+ " Fix: git rm --cached the files above (or run --staged --prune"+ )+ print(" after staging the bundle) and commit the removal.")+++def _prune_disk(root: Path) -> int:+ dist = root / DIST+ if not (dist / "index.html").is_file():+ return 0+ files = {+ p.relative_to(root).as_posix() for p in dist.rglob("*") if p.is_file()+ }++ def read(path: str) -> str:+ return (root / path).read_text(encoding="utf-8", errors="replace")++ try:+ reachable, missing = _walk(files, read)+ except OSError as exc:+ print(f"check_dist_consistency: could not read the bundle ({exc})")+ return 3+ if missing:+ _report_missing(missing)+ return 1+ orphans = _orphans(files, reachable)+ for path in orphans:+ (root / path).unlink()+ print(+ f"check_dist_consistency: removed {len(orphans)} orphaned bundle "+ f"file(s); {len(reachable)} reachable files kept."+ )+ return 0++def main(argv: list[str]) -> int:staged = "--staged" in argv+ prune = "--prune" in argv++ if "--prune-disk" in argv:+ try:+ root = Path(_git("rev-parse", "--show-toplevel").strip())+ except (subprocess.CalledProcessError, OSError) as exc:+ print(f"check_dist_consistency: not in a git checkout ({exc})")+ return 3+ return _prune_disk(root)try:tracked = _tracked_dist_files(staged)@@ -90,6 +253,7 @@ def main(argv: list[str]) -> int:# Nothing shipped -> nothing to keep consistent.return 0+ added: set[str] = set()if staged:# Only enforce when this commit actually touches dist/ -- an# unrelated commit must never be wedged by breakage another@@ -97,59 +261,51 @@ def main(argv: list[str]) -> int:# before anything leaves the machine).try:touched = _git("diff", "--cached", "--name-only", "--", DIST)+ added = set(+ _git(+ "diff", "--cached", "--name-only", "--diff-filter=A", "--", DIST+ ).split()+ )except (subprocess.CalledProcessError, OSError) as exc:print(f"check_dist_consistency: could not read staged diff ({exc})")return 3if not touched.strip():return 0- missing: dict[str, str] = {} # missing tracked path -> first referrer- visited: set[str] = set()- queue: deque[str] = deque([ENTRY_HTML])+ try:+ reachable, missing = _walk(tracked, lambda p: _read_blob(p, staged))+ except (subprocess.CalledProcessError, OSError) as exc:+ print(f"check_dist_consistency: could not read the bundle ({exc})")+ return 3- while queue:- path = queue.popleft()- if path in visited:- continue- visited.add(path)+ if missing:+ _report_missing(missing)+ return 1++ orphans = _orphans(tracked, reachable)+ if staged and prune and orphans:try:- blob = _read_blob(path, staged)+ for start in range(0, len(orphans), 200):+ _git("rm", "--cached", "--quiet", "--", *orphans[start:start + 200])except (subprocess.CalledProcessError, OSError) as exc:- print(f"check_dist_consistency: could not read {path} ({exc})")+ print(f"check_dist_consistency: could not untrack orphans ({exc})")return 3- for name in sorted(_refs_in(blob)):- ref = ASSETS_PREFIX + name- if ref not in tracked:- missing.setdefault(ref, path)- elif ref.endswith(_SCANNABLE):- queue.append(ref)-- if not missing:- state = "staged index" if staged else "HEAD"print(- "check_dist_consistency: OK - all "- f"{len(visited)} reachable bundle files tracked ({state})."+ f"check_dist_consistency: untracked {len(orphans)} orphaned bundle "+ "file(s); they stay on disk.")return 0+ blocking = [p for p in orphans if p in added] if staged else orphans+ if blocking:+ _report_orphans(blocking, staged)+ return 1- print("check_dist_consistency: BROKEN shipped frontend bundle.")- print(- " The entry chunk graph references files git does NOT track -- on a"- )- print(- " fresh clone these 404 and the UI never mounts (blank spinner):"- )- for ref, referrer in sorted(missing.items()):- print(f" MISSING {ref} (referenced by {referrer})")+ state = "staged index" if staged else "HEAD"print(- " Fix: commit the rebuilt bundle as ONE set -- `git add "- f"{DIST}/index.html {ASSETS_PREFIX}` -- or rebuild it"- )- print(- " (`npm run build` in jarvis/ui/web/frontend/) and stage everything"+ "check_dist_consistency: OK - all "+ f"{len(reachable)} reachable bundle files tracked, no orphans ({state}).")- print(" vite emitted, then retry.")- return 1+ return 0if __name__ == "__main__":diff --git a/scripts/ci/requirements-build.txt b/scripts/ci/requirements-build.txtindex eb876bf02d..bfe3043b8c 100644--- a/scripts/ci/requirements-build.txt+++ b/scripts/ci/requirements-build.txt@@ -3,3 +3,5 @@ build==1.6.1twine==7.0.0setuptools==84.0.0wheel==0.48.0+# Security floor for a transitive dependency (twine -> requests): GHSA-65pc-fj4g-8rjx.+idna>=3.15diff --git a/tests/unit/ci/test_check_dist_consistency.py b/tests/unit/ci/test_check_dist_consistency.pynew file mode 100644index 0000000000..442d7b424a--- /dev/null+++ b/tests/unit/ci/test_check_dist_consistency.py@@ -0,0 +1,94 @@+"""The dist-consistency gate: missing chunks and orphaned chunks."""++from __future__ import annotations++import shutil+import subprocess+from pathlib import Path++import pytest++from scripts.ci import check_dist_consistency as gate++A = gate.ASSETS_PREFIX+++def _bundle() -> dict[str, str]:+ return {+ gate.ENTRY_HTML: '<script type="module" src="/assets/index-AAAAAAAA.js"></script>',+ A + "index-AAAAAAAA.js": 'import("./Lazy-BBBBBBBB.js");import "./style-CCCCCCCC.css";',+ A + "Lazy-BBBBBBBB.js": 'new URL("ort-wasm-DDDDDDDD.wasm", import.meta.url)',+ A + "style-CCCCCCCC.css": "body{}",+ A + "ort-wasm-DDDDDDDD.wasm": "",+ # An earlier build's chunks: nothing reachable names them.+ A + "Lazy-EEEEEEEE.js": 'import("./Old-FFFFFFFF.js")',+ A + "Old-FFFFFFFF.js": "",+ # Public assets and nested folders are not build output.+ A + "material-file-icons/file-GGGGGGGG.svg": "",+ A + "logo.png": "",+ }+++def test_walk_reaches_the_live_graph_including_unprefixed_urls() -> None:+ files = _bundle()+ reachable, missing = gate._walk(set(files), files.__getitem__)+ assert not missing+ assert A + "ort-wasm-DDDDDDDD.wasm" in reachable+ assert A + "style-CCCCCCCC.css" in reachable+++def test_orphans_are_only_unreached_generated_chunks() -> None:+ files = _bundle()+ reachable, _ = gate._walk(set(files), files.__getitem__)+ assert gate._orphans(files, reachable) == [+ A + "Lazy-EEEEEEEE.js",+ A + "Old-FFFFFFFF.js",+ ]+++def test_missing_chunk_is_still_reported() -> None:+ files = _bundle()+ del files[A + "Lazy-BBBBBBBB.js"]+ _, missing = gate._walk(set(files), files.__getitem__)+ assert missing == {A + "Lazy-BBBBBBBB.js": A + "index-AAAAAAAA.js"}+++def _write(root: Path, files: dict[str, str]) -> None:+ for rel, text in files.items():+ path = root / rel+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(text, encoding="utf-8")+++def test_prune_disk_removes_only_orphans(tmp_path: Path) -> None:+ files = _bundle()+ _write(tmp_path, files)+ assert gate._prune_disk(tmp_path) == 0+ left = {p.relative_to(tmp_path).as_posix() for p in tmp_path.rglob("*") if p.is_file()}+ assert left == set(files) - {A + "Lazy-EEEEEEEE.js", A + "Old-FFFFFFFF.js"}+++def _git(root: Path, *args: str) -> str:+ return subprocess.run(+ ["git", *args], cwd=root, capture_output=True, text=True, check=True+ ).stdout++[email protected](shutil.which("git") is None, reason="git is not installed")+def test_staged_mode_blocks_added_orphans_and_prune_untracks_them(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]+) -> None:+ files = _bundle()+ _write(tmp_path, files)+ _git(tmp_path, "init", "-q")+ _git(tmp_path, "add", "--", gate.DIST)+ monkeypatch.chdir(tmp_path)++ assert gate.main(["--staged"]) == 1+ assert "ORPHAN" in capsys.readouterr().out++ assert gate.main(["--staged", "--prune"]) == 0+ staged = set(_git(tmp_path, "ls-files", "--cached").split())+ assert A + "Lazy-EEEEEEEE.js" not in staged+ assert (tmp_path / A / "Lazy-EEEEEEEE.js").is_file() # disk untouched+ assert gate.main(["--staged"]) == 0diff --git a/tests/unit/test_provider_spec.py b/tests/unit/test_provider_spec.pyindex 3f8909a3ac..72ff480a02 100644--- a/tests/unit/test_provider_spec.py+++ b/tests/unit/test_provider_spec.py@@ -6,6 +6,8 @@ POST /api/secrets/{key} falls into the whitelist hole."""from __future__ import annotations+from urllib.parse import urlsplit+from jarvis.setup.wizard import SECRETSfrom jarvis.ui.web.provider_spec import (PROVIDERS,@@ -212,14 +214,15 @@ def test_gemini_offers_both_aistudio_and_vertex() -> None:assert spec is not None, pid# Primary path is the AI-Studio API key.assert spec.auth_mode == "api_key"- assert spec.dashboard_url and "aistudio.google.com" in spec.dashboard_url+ assert urlsplit(spec.dashboard_url).hostname == "aistudio.google.com"# The Vertex path is offered as an explicit alternative.assert spec.alt_credential is not None, f"{pid}: missing Vertex alt path"alt = spec.alt_credentialassert "vertex" in alt.label.lower()assert alt.billing == "api"assert alt.credential_help- assert alt.dashboard_url and "cloud.google.com" in alt.dashboard_url+ host = urlsplit(alt.dashboard_url).hostname or ""+ assert host == "cloud.google.com" or host.endswith(".cloud.google.com")def test_other_families_have_no_google_project_credential_path() -> None: