Skip to content

Commit 6419249

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/android-wear-thread-follow-stacked
2 parents ab59618 + 356bec6 commit 6419249

395 files changed

Lines changed: 2612 additions & 9195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/setup-node-env/action.yml‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,19 @@ runs:
325325
326326
sticky_marker="$STICKY_ROOT/.openclaw-deps-fingerprint"
327327
sticky_fingerprint=""
328+
sticky_fingerprint_matches="false"
328329
sticky_snapshot_matches="false"
329330
if [ "$STICKY_DISK" = "true" ] && [ -f "$sticky_marker" ]; then
330331
sticky_fingerprint="$(<"$sticky_marker")"
331332
fi
332333
if [ "$STICKY_DISK" = "true" ] && [ -n "$sticky_fingerprint" ] &&
333334
[ "$sticky_fingerprint" = "${OPENCLAW_STICKY_DEPS_FINGERPRINT:?}" ]; then
334-
sticky_snapshot_matches="true"
335+
sticky_fingerprint_matches="true"
336+
if bash "$GITHUB_ACTION_PATH/sticky-importers.sh" restore "$STICKY_ROOT" "$GITHUB_WORKSPACE"; then
337+
sticky_snapshot_matches="true"
338+
else
339+
echo "::warning::Sticky dependency fingerprint matches, but restored importer contents are incomplete; reinstalling"
340+
fi
335341
fi
336342
if [ "$STICKY_DISK" = "true" ] && [ "$STICKY_WRITER" != "true" ] &&
337343
[ "$sticky_snapshot_matches" != "true" ]; then
@@ -345,7 +351,7 @@ runs:
345351
mkdir -p "$ephemeral_store"
346352
export PNPM_CONFIG_STORE_DIR="$ephemeral_store"
347353
echo "PNPM_CONFIG_STORE_DIR=$ephemeral_store" >> "$GITHUB_ENV"
348-
echo "Sticky dependency snapshot is stale; using runner-local storage for this read-only run"
354+
echo "Sticky dependency snapshot is unusable; using runner-local storage for this read-only run"
349355
fi
350356
351357
install_args=(
@@ -389,10 +395,11 @@ runs:
389395
export NODE_PATH="$PNPM_CONFIG_MODULES_DIR${NODE_PATH:+:$NODE_PATH}"
390396
fi
391397
if [ "$sticky_snapshot_matches" = "true" ]; then
392-
bash "$GITHUB_ACTION_PATH/sticky-importers.sh" restore "$STICKY_ROOT" "$GITHUB_WORKSPACE"
393-
echo "Sticky dependency snapshot matches the install fingerprint; skipping pnpm install"
398+
echo "Sticky dependency snapshot matches the install fingerprint and importer contents; skipping pnpm install"
394399
else
395-
if [ "$STICKY_DISK" = "true" ] && [ -n "$sticky_fingerprint" ]; then
400+
if [ "$sticky_fingerprint_matches" = "true" ]; then
401+
echo "Sticky dependency snapshot importer contents are incomplete; reinstalling"
402+
elif [ "$STICKY_DISK" = "true" ] && [ -n "$sticky_fingerprint" ]; then
396403
echo "Sticky dependency snapshot is stale (disk: $sticky_fingerprint, want: $OPENCLAW_STICKY_DEPS_FINGERPRINT); reinstalling"
397404
fi
398405
# A stale marker must not survive a mid-install failure: the commit
@@ -435,7 +442,7 @@ runs:
435442
fi
436443
437444
if [ "$STICKY_DISK" = "true" ]; then
438-
# This step already establishes an exact fingerprint match or finishes
445+
# This step already establishes a content-validated snapshot or finishes
439446
# a frozen-lockfile install. pnpm 11's redundant pre-run check treats
440447
# our intentionally pruned plugin-local node_modules as stale and can
441448
# launch concurrent implicit installs when later CI steps fan out.

‎.github/actions/setup-node-env/dependency-fingerprint.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const INSTALL_INPUT_FILES = [
3939
"pnpmfile.cjs",
4040
".github/actions/setup-node-env/dependency-fingerprint.mjs",
4141
".github/actions/setup-node-env/sticky-importers.sh",
42+
".github/actions/setup-node-env/verify-importers.mjs",
4243
"scripts/postinstall-bundled-plugins.mjs",
4344
"scripts/lib/package-dist-imports.mjs",
4445
"scripts/preinstall-package-manager-warning.mjs",

‎.github/actions/setup-node-env/sticky-importers.sh‎

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,97 @@ mode="${1:?mode is required}"
55
sticky_root="${2:?sticky root is required}"
66
workspace="${3:?workspace is required}"
77
archive="$sticky_root/importer-node-modules.tar"
8+
archive_checksum="$sticky_root/.openclaw-importer-archive.sha256"
9+
importer_manifest="$sticky_root/importer-node-modules.manifest"
810
marker="$sticky_root/.openclaw-deps-fingerprint"
11+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
13+
archive_sha256() {
14+
if command -v sha256sum >/dev/null 2>&1; then
15+
sha256sum -- "$1" | awk '{print $1}'
16+
else
17+
shasum -a 256 "$1" | awk '{print $1}'
18+
fi
19+
}
20+
21+
clear_importers() {
22+
(
23+
cd "$workspace"
24+
find . \( -type d -o -type l \) -name node_modules -prune \
25+
! -path ./node_modules -exec rm -rf -- {} +
26+
)
27+
}
28+
29+
verify_importers() {
30+
node "$script_dir/verify-importers.mjs" "$workspace" "$1"
31+
}
932

1033
case "$mode" in
1134
capture)
1235
fingerprint="${4:?fingerprint is required}"
1336
mkdir -p "$sticky_root"
1437
list_file="$(mktemp)"
1538
temp_archive="$archive.tmp.$$"
39+
temp_checksum="$archive_checksum.tmp.$$"
40+
temp_manifest="$importer_manifest.tmp.$$"
41+
temp_marker="$marker.tmp.$$"
1642
cleanup() {
17-
rm -f "$list_file" "$temp_archive"
43+
rm -f "$list_file" "$temp_archive" "$temp_checksum" "$temp_manifest" "$temp_marker"
1844
}
1945
trap cleanup EXIT
46+
# Do not publish a fingerprint for an install whose importer resolution is
47+
# already falling through to a wrong hoisted version.
48+
rm -f "$marker" "$archive_checksum" "$importer_manifest"
2049
(
2150
cd "$workspace"
22-
find . -type d -name node_modules -prune ! -path ./node_modules -print0 >"$list_file"
51+
find . \( -type d -o -type l \) -name node_modules -prune \
52+
! -path ./node_modules -print0 >"$list_file"
2353
tar --create --file "$temp_archive" --null --files-from "$list_file"
2454
)
55+
tr '\0' '\n' <"$list_file" >"$temp_manifest"
56+
# Record the exact importer set and check its live resolution before a
57+
# writer can publish the marker.
58+
verify_importers "$temp_manifest"
59+
{
60+
archive_sha256 "$temp_archive"
61+
archive_sha256 "$temp_manifest"
62+
} >"$temp_checksum"
2563
mv "$temp_archive" "$archive"
26-
# The marker lands last: a fingerprint is only ever visible next to the
27-
# importer archive it describes, so consumers cannot restore a torn pair.
28-
printf '%s\n' "$fingerprint" > "$marker"
64+
mv "$temp_manifest" "$importer_manifest"
65+
mv "$temp_checksum" "$archive_checksum"
66+
# The marker lands last. Consumers also verify the archive bytes and every
67+
# registry-backed importer resolution before trusting this snapshot.
68+
printf '%s\n' "$fingerprint" >"$temp_marker"
69+
mv "$temp_marker" "$marker"
2970
;;
3071
restore)
31-
if [[ ! -f "$archive" ]]; then
32-
echo "::error::sticky importer node_modules archive is missing: $archive" >&2
72+
if [[ ! -f "$archive" || ! -f "$archive_checksum" || ! -f "$importer_manifest" ]]; then
73+
echo "sticky importer archive, manifest, or checksum is missing under $sticky_root" >&2
74+
exit 1
75+
fi
76+
expected_archive_checksum="$(sed -n '1p' "$archive_checksum" | tr -d '[:space:]')"
77+
expected_manifest_checksum="$(sed -n '2p' "$archive_checksum" | tr -d '[:space:]')"
78+
actual_archive_checksum="$(archive_sha256 "$archive")"
79+
actual_manifest_checksum="$(archive_sha256 "$importer_manifest")"
80+
if [[ ! "$expected_archive_checksum" =~ ^[a-f0-9]{64}$ ]] || \
81+
[[ ! "$expected_manifest_checksum" =~ ^[a-f0-9]{64}$ ]] || \
82+
[[ "$actual_archive_checksum" != "$expected_archive_checksum" ]] || \
83+
[[ "$actual_manifest_checksum" != "$expected_manifest_checksum" ]]; then
84+
echo "sticky importer archive or manifest checksum mismatch" >&2
85+
exit 1
86+
fi
87+
# A restored archive is authoritative for checkout-local importer links.
88+
# Clear first so entries absent from the archive cannot survive from a
89+
# reused workspace, and clear again when validation rejects the restore.
90+
clear_importers
91+
if ! tar --extract --file "$archive" --directory "$workspace"; then
92+
clear_importers
93+
exit 1
94+
fi
95+
if ! verify_importers "$importer_manifest"; then
96+
clear_importers
3397
exit 1
3498
fi
35-
tar --extract --file "$archive" --directory "$workspace"
3699
;;
37100
*)
38101
echo "unsupported sticky importer mode: $mode" >&2

0 commit comments

Comments
 (0)