diff --git a/.github/scripts/check-fleet-lock.sh b/.github/scripts/check-fleet-lock.sh
new file mode 100755
index 0000000000..4376fafb2f
--- /dev/null
+++ b/.github/scripts/check-fleet-lock.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+# Fleet Cargo.lock freshness guard (#10363).
+#
+# fleet-search path-depends on atlas-search crates (atlas-core,
+# atlas-embed, atlas-proto) whose manifests live outside the fleet
+# workspace. When one of them gains a dependency, pkgs/fleet/Cargo.lock
+# silently falls behind: nothing in the fleet tree changed, and crane's
+# own lockfile check compares the lock with the vendor dir built from
+# that same lock, so a stale lock validates against itself. The first
+# failure used to be a switch build dying at fleet-0.1.0.drv with
+# "no matching package named ... found" (#8260, then #10362).
+#
+# This guard re-resolves the fleet workspace against the real manifests
+# with `cargo metadata --locked`, which refuses to run when the
+# committed lock is not the lock cargo would write. It compiles
+# nothing, so it takes seconds.
+#
+# Usage: check-fleet-lock.sh [MANIFEST]
+# MANIFEST defaults to pkgs/fleet/Cargo.toml in this repo.
+# Extra cargo flags (for example --offline) can be passed in
+# FLEET_LOCK_CARGO_FLAGS.
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+MANIFEST="${1:-$ROOT/pkgs/fleet/Cargo.toml}"
+
+if [ ! -f "$MANIFEST" ]; then
+ echo "::error::fleet lock guard: manifest not found: $MANIFEST"
+ exit 1
+fi
+if ! command -v cargo >/dev/null 2>&1; then
+ echo "::error::fleet lock guard: cargo is not on PATH"
+ exit 1
+fi
+
+# shellcheck disable=SC2086 # FLEET_LOCK_CARGO_FLAGS is a flag list.
+if out=$(cargo metadata --locked --format-version 1 ${FLEET_LOCK_CARGO_FLAGS:-} \
+ --manifest-path "$MANIFEST" 2>&1 >/dev/null); then
+ echo "fleet lock guard: OK — $(dirname "$MANIFEST")/Cargo.lock matches the resolved workspace"
+ exit 0
+fi
+
+echo "$out" | tail -20
+if printf '%s' "$out" | grep -qE 'lock file .*needs to be updated|cannot update the lock file|--locked was passed'; then
+ echo "::error::fleet lock guard: $(dirname "$MANIFEST")/Cargo.lock is stale against the manifests it resolves (often an atlas-search crate gained a dependency). Fix: cargo update --workspace --manifest-path $MANIFEST, then commit the lock."
+else
+ echo "::error::fleet lock guard: cargo could not resolve $MANIFEST (see the output above)"
+fi
+exit 1
diff --git a/.github/scripts/check-fleet-lock.test.sh b/.github/scripts/check-fleet-lock.test.sh
new file mode 100755
index 0000000000..b138135bc3
--- /dev/null
+++ b/.github/scripts/check-fleet-lock.test.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+# Contract tests for check-fleet-lock.sh (#10363).
+# Builds a path-only fixture shaped like fleet: a workspace member that
+# path-depends on a crate outside the workspace. The guard must pass a
+# fresh lock, and fail once the outside crate gains a dependency the
+# committed lock does not know. Path-only, so it runs offline.
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+CHECK="$SCRIPT_DIR/check-fleet-lock.sh"
+TMP="$(mktemp -d)"
+trap 'rm -rf "$TMP"' EXIT
+export FLEET_LOCK_CARGO_FLAGS=--offline
+export CARGO_TARGET_DIR="$TMP/target"
+
+failures=0
+note_fail() {
+ echo "FAIL: $1"
+ failures=$((failures + 1))
+}
+
+crate() { # crate
[dependency lines...]
+ local dir=$1 name=$2
+ shift 2
+ mkdir -p "$dir/src"
+ {
+ printf '[package]\nname = "%s"\nversion = "0.1.0"\nedition = "2021"\n\n[dependencies]\n' "$name"
+ printf '%s\n' "$@"
+ } >"$dir/Cargo.toml"
+ : >"$dir/src/lib.rs"
+}
+
+# pkgs/{fleet,atlas}: fleet's member reaches into atlas by path.
+crate "$TMP/pkgs/atlas/core" atlas-core
+crate "$TMP/pkgs/atlas/extra" atlas-extra
+crate "$TMP/pkgs/fleet/crates/search" fleet-search 'atlas-core = { path = "../../../atlas/core" }'
+printf '[workspace]\nmembers = ["crates/search"]\nresolver = "2"\n' >"$TMP/pkgs/fleet/Cargo.toml"
+MANIFEST="$TMP/pkgs/fleet/Cargo.toml"
+cargo generate-lockfile --offline --manifest-path "$MANIFEST" >/dev/null 2>&1
+
+if bash "$CHECK" "$MANIFEST" >/dev/null 2>&1; then
+ echo "ok: a fresh lock passes"
+else
+ note_fail "a fresh lock should pass"
+fi
+
+# atlas-core gains a dependency; nothing under pkgs/fleet changes.
+crate "$TMP/pkgs/atlas/core" atlas-core 'atlas-extra = { path = "../extra" }'
+if out=$(bash "$CHECK" "$MANIFEST" 2>&1); then
+ note_fail "a lock missing the new atlas edge should fail"
+elif ! printf '%s' "$out" | grep -qF 'is stale'; then
+ note_fail "the stale-lock failure should name the stale lock"
+ printf '%s\n' "$out" | sed 's/^/ /'
+else
+ echo "ok: a lock missing the new atlas edge fails, naming the stale lock"
+fi
+
+# The fix the guard names makes it pass again.
+cargo update --workspace --offline --manifest-path "$MANIFEST" >/dev/null 2>&1
+if bash "$CHECK" "$MANIFEST" >/dev/null 2>&1; then
+ echo "ok: the named fix makes it pass"
+else
+ note_fail "the lock should pass after cargo update --workspace"
+fi
+
+if bash "$CHECK" "$TMP/missing/Cargo.toml" >/dev/null 2>&1; then
+ note_fail "a missing manifest should fail"
+else
+ echo "ok: a missing manifest fails"
+fi
+
+if [ "$failures" -ne 0 ]; then
+ echo "check-fleet-lock.test: $failures failure(s)"
+ exit 1
+fi
+echo "check-fleet-lock.test: OK"
diff --git a/.github/scripts/check-fleet-smoke.sh b/.github/scripts/check-fleet-smoke.sh
index 91a7095150..971c635ced 100755
--- a/.github/scripts/check-fleet-smoke.sh
+++ b/.github/scripts/check-fleet-smoke.sh
@@ -14,7 +14,10 @@
# silently skipped suite cannot report green;
# 3. the registry row fleet.smoke is status "mapped" and names this
# workflow as its venue;
-# 4. .github/ci-policy.md carries the fleet-smoke tier row.
+# 4. .github/ci-policy.md carries the fleet-smoke tier row;
+# 5. the workflow also runs on atlas-search manifest changes and
+# runs check-fleet-lock.sh before the build, so a fleet lock
+# left stale by an atlas dependency change fails by name (#10363).
# A disagreement fails, naming the broken leg.
#
# Usage: check-fleet-smoke.sh [ROOT] (default: repo root)
@@ -72,6 +75,14 @@ if ! grep -qF 'passed, 0 failed' "$WF"; then
err "workflow does not assert the suite's 'passed, 0 failed' summary — a skipped suite could report green"
fi
+# 5. The lock guard and the atlas path filter (#10363).
+if ! grep -qF 'bash .github/scripts/check-fleet-lock.sh' "$WF"; then
+ err "workflow does not run check-fleet-lock.sh — a stale fleet lock would only fail inside the nix build"
+fi
+if ! grep -qF '"pkgs/atlas-search/crates/**"' "$WF"; then
+ err "workflow path filter does not cover pkgs/atlas-search/crates/** — an atlas dependency change could skip the lock guard"
+fi
+
# 3 + 4. Registry row and policy row agree with the workflow.
python3 - "$REGISTRY" <<'PYEOF' || err "registry row fleet.smoke is not mapped to .github/workflows/fleet-smoke.yml"
import json
diff --git a/.github/scripts/check-fleet-smoke.test.sh b/.github/scripts/check-fleet-smoke.test.sh
index aaca52210e..9fc612a0cf 100755
--- a/.github/scripts/check-fleet-smoke.test.sh
+++ b/.github/scripts/check-fleet-smoke.test.sh
@@ -57,6 +57,16 @@ make_fixture "$MUT"
sed -i '/pkgs\/fleet\/\*\*/d' "$MUT/.github/workflows/fleet-smoke.yml"
expect_fail "$MUT" "workflow without the pkgs/fleet path filter"
+MUT="$TMP/no-lock-guard"
+make_fixture "$MUT"
+sed -i '/bash .github\/scripts\/check-fleet-lock.sh/d' "$MUT/.github/workflows/fleet-smoke.yml"
+expect_fail "$MUT" "workflow without the fleet lock guard"
+
+MUT="$TMP/no-atlas-paths"
+make_fixture "$MUT"
+sed -i '/pkgs\/atlas-search\/crates/d' "$MUT/.github/workflows/fleet-smoke.yml"
+expect_fail "$MUT" "workflow without the atlas-search path filter"
+
MUT="$TMP/pr-trigger"
make_fixture "$MUT"
sed -i 's/^ workflow_dispatch:/ pull_request:\n workflow_dispatch:/' "$MUT/.github/workflows/fleet-smoke.yml"
diff --git a/.github/workflows/fleet-smoke.yml b/.github/workflows/fleet-smoke.yml
index 2acc09c841..52224d9c87 100644
--- a/.github/workflows/fleet-smoke.yml
+++ b/.github/workflows/fleet-smoke.yml
@@ -21,9 +21,15 @@ on:
branches: [main]
paths:
- "pkgs/fleet/**"
+ # fleet-search builds atlas-search crates by path, so an atlas
+ # manifest change can break the fleet lock and build (#10363).
+ - "pkgs/atlas-search/Cargo.toml"
+ - "pkgs/atlas-search/crates/**"
- ".github/workflows/fleet-smoke.yml"
- ".github/scripts/check-fleet-smoke.sh"
- ".github/scripts/check-fleet-smoke.test.sh"
+ - ".github/scripts/check-fleet-lock.sh"
+ - ".github/scripts/check-fleet-lock.test.sh"
workflow_dispatch:
permissions:
@@ -50,6 +56,13 @@ jobs:
bash .github/scripts/check-fleet-smoke.sh
bash .github/scripts/check-fleet-smoke.test.sh
+ # Before the nix build, so a stale lock fails here by name
+ # instead of as "no matching package" deep in fleet-0.1.0.drv.
+ - name: Fleet Cargo.lock matches the atlas manifests (#10363)
+ run: |
+ bash .github/scripts/check-fleet-lock.test.sh
+ bash .github/scripts/check-fleet-lock.sh
+
- uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23
- uses: DeterminateSystems/magic-nix-cache-action@84c0677f58dcedf3b91f8223ce36a9ea5b3c84b7 # v15
diff --git a/pkgs/fleet/README.md b/pkgs/fleet/README.md
index ce5666e9c8..6e9d64bad0 100644
--- a/pkgs/fleet/README.md
+++ b/pkgs/fleet/README.md
@@ -262,7 +262,9 @@ both installs. If the build fails in the cargo vendor step with
'atlas-core'` (or another atlas crate), `pkgs/fleet/Cargo.lock` has
drifted from the atlas-search path dependencies again — the fleet
lock covers their external dependencies too (see `default.nix`).
-Regenerate it before building:
+`bash .github/scripts/check-fleet-lock.sh` names that drift in
+seconds without building anything (fleet-smoke runs it on atlas-search
+manifest changes too, #10363). Regenerate the lock before building:
```sh
(cd pkgs/fleet && cargo update --workspace)