@@ -35,6 +35,14 @@ inputs:
3535 alongside.
3636 required : false
3737 default : " false"
38+ save-sticky-disk :
39+ description : >
40+ Whether this job may commit the shared dependency snapshot. One
41+ designated job per node-version key; only honored outside pull_request
42+ events so feature-branch installs can never publish a protected
43+ snapshot.
44+ required : false
45+ default : " false"
3846 runtime-cache-sticky-disk :
3947 description : Whether runtime caches should use Blacksmith sticky disks instead of actions/cache.
4048 required : false
@@ -58,8 +66,8 @@ inputs:
5866 save-vitest-fs-cache :
5967 description : >
6068 Whether this job may save the shared Vitest filesystem module cache.
61- Other matrix jobs restore the warm seed without committing competing
62- snapshots .
69+ Only honored outside pull_request events for sticky disks; PR jobs
70+ always mount the protected snapshot read-only .
6371 required : false
6472 default : " false"
6573 build-all-cache-scope :
@@ -116,36 +124,42 @@ runs:
116124 if : inputs.sticky-disk == 'true'
117125 uses : useblacksmith/stickydisk@5b350170ae4ef55b536b548ef5f5896e76a6b54f # v1.4.0
118126 with :
119- # The key covers every dependency and lifecycle input. PR scope keeps
120- # feature snapshots separate from protected pushes. The v2 marker lets
121- # exact warm hits trust the snapshotted stock layout without rescanning.
122- key : ${{ github.repository }}-node-deps-bind-v2-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || 'protected' }}-${{ inputs.node-version }}-frozen-${{ inputs.frozen-lockfile }}-${{ hashFiles('**/package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', '.npmrc', '.pnpmfile.cjs', 'pnpmfile.cjs', '.github/actions/setup-node-env/sticky-importers.sh', 'scripts/postinstall-bundled-plugins.mjs', 'scripts/preinstall-package-manager-warning.mjs', 'scripts/prepare-git-hooks.mjs') }}
127+ # One stable disk per Node line. The v2 per-PR/per-manifest-hash keys
128+ # saturated Blacksmith's installation-wide sticky-disk budget. Install
129+ # inputs, runner platform, and the exact Node patch live in the runtime
130+ # marker below, so changes refresh this disk in place.
131+ key : ${{ github.repository }}-node-deps-bind-v3-${{ inputs.node-version }}
123132 path : /var/tmp/openclaw-node-deps
124- # v1.4.0 skips commit after failed/cancelled steps or ambiguous failure
125- # detection, so an incomplete first hydration cannot seed this key.
126- commit : if-missing
127-
128- - name : Mount protected Vitest transform seed
129- if : inputs.vitest-fs-cache == 'true' && (inputs.sticky-disk == 'true' || inputs.runtime-cache-sticky-disk == 'true') && github.event_name == 'pull_request' && runner.os != 'Windows'
130- uses : useblacksmith/stickydisk@5b350170ae4ef55b536b548ef5f5896e76a6b54f # v1.4.0
131- with :
132- # Same-repository PRs read the protected snapshot but never write it.
133- # Content-addressed misses stay in the PR-scoped overlay below.
134- key : ${{ github.repository }}-vitest-fs-v2-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}
135- path : /var/tmp/openclaw-vitest-fs-protected-seed
136- commit : false
133+ # Single semantic writer: only the designated trusted-push job may
134+ # commit, so pull_request clones stay read-only. Like every sticky
135+ # disk here, this gate binds cooperating code, not hostile code: the
136+ # enforced trust boundary is the fork/dispatch runner gate in ci.yml,
137+ # and same-repo PR authors already hold repository write access.
138+ # Explicit true (not on-change) because the allocated-byte heuristic
139+ # can miss a fingerprint refresh whose reinstall keeps disk usage
140+ # stable, permanently stranding consumers on a stale marker. v1.4.0
141+ # skips commit after failed/cancelled steps, so a broken install
142+ # cannot seed this key.
143+ commit : ${{ inputs.save-sticky-disk == 'true' && github.event_name != 'pull_request' && 'true' || 'false' }}
137144
138145 - name : Mount Vitest transform cache sticky disk
139146 if : inputs.vitest-fs-cache == 'true' && (inputs.sticky-disk == 'true' || inputs.runtime-cache-sticky-disk == 'true') && runner.os != 'Windows'
140147 uses : useblacksmith/stickydisk@5b350170ae4ef55b536b548ef5f5896e76a6b54f # v1.4.0
141148 with :
142- # One stable disk per trust scope. The generation guard below clears
149+ # One stable disk per runner shape. The old per-PR overlay disks
150+ # minted a new backing disk for every PR and helped saturate
151+ # Blacksmith's installation-wide sticky-disk budget, 429-failing every
152+ # mount. Cache entries are content-hash keyed (id+content+env), so PRs
153+ # can safely read the protected snapshot directly; PR-local misses are
154+ # rebuilt in the discarded mount. The generation guard below clears
143155 # incompatible transform inputs without leaking one disk per lockfile.
144- key : ${{ github.repository }}-vitest-fs-v2-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || ' protected' }} -${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}
156+ key : ${{ github.repository }}-vitest-fs-v2-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}
145157 path : /var/tmp/openclaw-vitest-fs-cache
146- # One semantic writer only. Explicit true avoids stickydisk's allocated-
147- # byte heuristic missing equal-size replacements or prune-balanced writes.
148- commit : ${{ inputs.save-vitest-fs-cache == 'true' && 'true' || 'false' }}
158+ # Single semantic writer: only the designated non-PR writer commits;
159+ # pull_request mounts stay read-only clones. Explicit true avoids
160+ # stickydisk's allocated-byte heuristic missing equal-size
161+ # replacements or prune-balanced writes.
162+ commit : ${{ inputs.save-vitest-fs-cache == 'true' && github.event_name != 'pull_request' && 'true' || 'false' }}
149163
150164 - name : Restore and save Vitest transform cache
151165 if : inputs.vitest-fs-cache == 'true' && inputs.sticky-disk != 'true' && inputs.runtime-cache-sticky-disk != 'true' && inputs.save-vitest-fs-cache == 'true' && runner.os != 'Windows'
@@ -171,30 +185,28 @@ runs:
171185 if : inputs.vitest-fs-cache == 'true' && runner.os != 'Windows'
172186 env :
173187 CACHE_GENERATION : ${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', '**/package.json', '**/tsconfig*.json', 'vitest.config.*', 'test/vitest/**') }}
174- CACHE_WRITER : ${{ inputs.save-vitest-fs-cache == 'true' && '1' || '0' }}
188+ # Sticky PR mounts never commit, so pruning there would only burn
189+ # shard wall clock on a discarded clone; non-sticky (actions/cache)
190+ # writers still prune their PR-scoped archives.
191+ CACHE_WRITER : ${{ inputs.save-vitest-fs-cache == 'true' && ((inputs.sticky-disk != 'true' && inputs.runtime-cache-sticky-disk != 'true') || github.event_name != 'pull_request') && '1' || '0' }}
175192 shell : bash
176193 run : |
177194 set -euo pipefail
178195 cache_root=/var/tmp/openclaw-vitest-fs-cache
179- seed_root=/var/tmp/openclaw-vitest-fs-protected-seed
180196 generation_file="$cache_root/.openclaw-transform-generation"
181197 mkdir -p "$cache_root"
182198 cache_generation=""
183199 if [[ -f "$generation_file" ]]; then
184200 cache_generation="$(<"$generation_file")"
185201 fi
186202 cache_entry="$(find "$cache_root" -mindepth 1 -maxdepth 1 -print -quit)"
203+ # Read-only PR mounts clear a mismatched generation too: the wipe only
204+ # affects the discarded local clone, and mixing generations could
205+ # false-hit transforms produced under incompatible tsconfig/lockfile.
187206 if [[ -n "$cache_entry" ]] && [[ "$cache_generation" != "$CACHE_GENERATION" ]]; then
188207 echo "Vitest transform inputs changed; clearing incompatible cache generation"
189208 find "$cache_root" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
190209 fi
191- seed_generation_file="$seed_root/.openclaw-transform-generation"
192- if [[ -f "$seed_generation_file" ]] && [[ "$(<"$seed_generation_file")" == "$CACHE_GENERATION" ]]; then
193- echo "Merging matching protected Vitest transform seed"
194- cp -a --no-clobber "$seed_root"/. "$cache_root"/
195- elif [[ -f "$seed_generation_file" ]]; then
196- echo "Ignoring protected Vitest transform seed from an incompatible generation"
197- fi
198210 printf '%s\n' "$CACHE_GENERATION" > "$generation_file"
199211 # The shard runner treats this as a persistent root and assigns one
200212 # isolated subdirectory per concurrent Vitest worker.
@@ -254,6 +266,12 @@ runs:
254266 - name : Bind sticky node_modules into workspace
255267 if : inputs.sticky-disk == 'true'
256268 shell : bash
269+ env :
270+ # Evaluated before this step's bind mount populates node_modules, so
271+ # the '**/package.json' glob only sees checkout manifests. Recomputing
272+ # this hash any later would sweep snapshot-internal package.json files
273+ # into the fingerprint and permanently miss the warm path.
274+ DEPS_INPUT_FINGERPRINT : frozen-${{ inputs.frozen-lockfile }}-${{ hashFiles('**/package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', '.npmrc', '.pnpmfile.cjs', 'pnpmfile.cjs', '.github/actions/setup-node-env/sticky-importers.sh', 'scripts/postinstall-bundled-plugins.mjs', 'scripts/preinstall-package-manager-warning.mjs', 'scripts/prepare-git-hooks.mjs') }}
257275 run : |
258276 set -euo pipefail
259277 sticky_root=/var/tmp/openclaw-node-deps
@@ -269,8 +287,10 @@ runs:
269287 exit 1
270288 fi
271289 findmnt --target "$workspace_modules"
290+ deps_fingerprint="os-${RUNNER_OS:?}-arch-${RUNNER_ARCH:?}-node-$(node --version)-${DEPS_INPUT_FINGERPRINT:?}"
272291 # zizmor: ignore[github-env] static trusted path defined in this composite action.
273292 echo "PNPM_CONFIG_STORE_DIR=$sticky_store" >> "$GITHUB_ENV"
293+ echo "OPENCLAW_STICKY_DEPS_FINGERPRINT=$deps_fingerprint" >> "$GITHUB_ENV"
274294 # pnpm exec may reconcile a restored workspace before nested builds.
275295 # Sticky jobs already have every build tool, so invoke their Node entrypoints directly.
276296 echo "OPENCLAW_BUILD_ALL_NO_PNPM=1" >> "$GITHUB_ENV"
@@ -309,6 +329,7 @@ runs:
309329 FROZEN_LOCKFILE : ${{ inputs.frozen-lockfile }}
310330 STICKY_DISK : ${{ inputs.sticky-disk }}
311331 STICKY_ROOT : /var/tmp/openclaw-node-deps
332+ STICKY_WRITER : ${{ inputs.save-sticky-disk == 'true' && github.event_name != 'pull_request' && 'true' || 'false' }}
312333 run : |
313334 set -euo pipefail
314335 export PATH="$NODE_BIN:$PATH"
@@ -353,19 +374,36 @@ runs:
353374 ln -sfn . "$PNPM_CONFIG_MODULES_DIR/node_modules"
354375 export NODE_PATH="$PNPM_CONFIG_MODULES_DIR${NODE_PATH:+:$NODE_PATH}"
355376 fi
356- sticky_ready_marker="$STICKY_ROOT/.install-complete-v2"
357- if [ "$STICKY_DISK" = "true" ] && [ -f "$sticky_ready_marker" ]; then
377+ sticky_marker="$STICKY_ROOT/.openclaw-deps-fingerprint"
378+ sticky_fingerprint=""
379+ if [ "$STICKY_DISK" = "true" ] && [ -f "$sticky_marker" ]; then
380+ sticky_fingerprint="$(<"$sticky_marker")"
381+ fi
382+ if [ "$STICKY_DISK" = "true" ] && [ -n "$sticky_fingerprint" ] &&
383+ [ "$sticky_fingerprint" = "${OPENCLAW_STICKY_DEPS_FINGERPRINT:?}" ]; then
358384 bash "$GITHUB_ACTION_PATH/sticky-importers.sh" restore "$STICKY_ROOT" "$GITHUB_WORKSPACE"
359- echo "Sticky dependency snapshot is ready ; skipping pnpm install"
385+ echo "Sticky dependency snapshot matches the install fingerprint ; skipping pnpm install"
360386 else
387+ if [ "$STICKY_DISK" = "true" ] && [ -n "$sticky_fingerprint" ]; then
388+ echo "Sticky dependency snapshot is stale (disk: $sticky_fingerprint, want: $OPENCLAW_STICKY_DEPS_FINGERPRINT); reinstalling"
389+ fi
390+ # A stale marker must not survive a mid-install failure: the commit
391+ # heuristics skip failed steps, but a wrong marker plus a partial
392+ # tree would poison every consumer if one ever slipped through.
393+ if [ "$STICKY_DISK" = "true" ] && [ "$STICKY_WRITER" = "true" ]; then
394+ rm -f "$sticky_marker"
395+ fi
361396 pnpm "${install_args[@]}" || pnpm "${install_args[@]}"
362397 if [ -n "${PNPM_CONFIG_MODULES_DIR:-}" ]; then
363398 rm -rf node_modules
364399 ln -sfn "$PNPM_CONFIG_MODULES_DIR" node_modules
365400 ln -sfn . "$PNPM_CONFIG_MODULES_DIR/node_modules"
366401 fi
367- if [ "$STICKY_DISK" = "true" ]; then
368- bash "$GITHUB_ACTION_PATH/sticky-importers.sh" capture "$STICKY_ROOT" "$GITHUB_WORKSPACE"
402+ # Only the designated trusted writer captures importer archives and
403+ # publishes the fingerprint; read-only clones are discarded at job
404+ # end, so capturing there would only burn shard wall clock.
405+ if [ "$STICKY_DISK" = "true" ] && [ "$STICKY_WRITER" = "true" ]; then
406+ bash "$GITHUB_ACTION_PATH/sticky-importers.sh" capture "$STICKY_ROOT" "$GITHUB_WORKSPACE" "$OPENCLAW_STICKY_DEPS_FINGERPRINT"
369407 fi
370408 fi
371409
0 commit comments