Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

ci(vendor): pinned driver downloads retry with backoff and are cached by content hash

garrytan032dd1ff6b2f
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 465e983f94..bdc6370a60 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -395,6 +395,12 @@ jobs:
# check:schema-migration-order compares new schema migrations with
# origin/master's latest version; a depth-1 fetch of the ref is enough.
- run: git fetch --no-tags --depth=1 origin +refs/heads/master:refs/remotes/origin/master
+ # check:vendor-postgres rebuilds vendor/postgres from two pinned downloads (npm, GitHub). They are kept by content
+ # hash, so a transient outage cannot turn verify red; every file is hash-checked on use, so a mismatch still fails.
+ - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
+ with:
+ path: ~/.cache/gbrain-vendor
+ key: gbrain-vendor-${{ hashFiles('vendor/update-postgres.sh') }}
# Receipts (X2): verify records every check's real outcome (pass, fail,
# timeout, self-skip) as one JUnit testcase; logs stay on failure.
# The typecheck job below runs tsc, so verify skips its own copy here.
diff --git a/vendor/README.md b/vendor/README.md
index a221d7fc46..38b02e10ef 100644
--- a/vendor/README.md
+++ b/vendor/README.md
@@ -110,8 +110,10 @@ export, verify the upstream license and compare every byte. Run without
installed service. No driver dependency installation is required after regeneration.
`bun run verify` runs the check as `check:vendor-postgres`
(`scripts/check-vendor-postgres.sh`), so a fix in one copy that is missing from
-the patch or the other copies fails CI. Without network it is a recorded skip
-locally and a failure under CI.
+the patch or the other copies fails CI. The two pinned downloads are retried
+(bounded, with backoff) and kept by content hash in `~/.cache/gbrain-vendor`
+(`GBRAIN_VENDOR_CACHE`; test.yml caches it), and each is hash-checked on use.
+Without network and cache it is a recorded skip locally and a failure under CI.
For security updates, the GBrain release maintainer owns this dependency:
review upstream security advisories and supported releases, update the exact
diff --git a/vendor/update-postgres.sh b/vendor/update-postgres.sh
index a5e07fe5a9..55c24154f9 100644
--- a/vendor/update-postgres.sh
+++ b/vendor/update-postgres.sh
@@ -4,16 +4,29 @@ set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
-curl -fsSL https://registry.npmjs.org/postgres/-/postgres-3.4.9.tgz -o "$WORK/upstream.tgz"
-echo '183dea741d31d73f7180523a71d443eb1bb64a9d9608e1287b79ad9f207911ed17aeb2f93def9ee020a726b44c9cbd7362d44366641055bbceb6d2e72832e76b upstream.tgz' | (cd "$WORK" && sha512sum -c -)
+# Pinned downloads are kept by content hash, so a CI cache or a second run reuses them; a cached file is used only when its
+# hash still matches, and every file is hash-checked whichever way it arrived.
+CACHE="${GBRAIN_VENDOR_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/gbrain-vendor}"
+digest() { if command -v "sha$1sum" >/dev/null 2>&1; then "sha$1sum" "$2"; else shasum -a "$1" "$2"; fi | cut -d' ' -f1; }
+fetch() {
+ local url="$1" dest="$2" bits="$3" want="$4"
+ if [[ -f "$CACHE/$want" && "$(digest "$bits" "$CACHE/$want")" == "$want" ]]; then cp "$CACHE/$want" "$dest"; return; fi
+ # Bounded retries with curl's own exponential backoff (1, 2, 4, 8 s): a transient registry or GitHub failure is retried,
+ # a missing file or a hash mismatch is not.
+ curl -fsSL --retry 4 --retry-all-errors --connect-timeout 20 --max-time 120 "$url" -o "$dest"
+ if [[ "$(digest "$bits" "$dest")" != "$want" ]]; then echo "update-postgres: $url does not match its pinned SHA-$bits" >&2; exit 1; fi
+ mkdir -p "$CACHE" && cp "$dest" "$CACHE/$want.$$" && mv "$CACHE/$want.$$" "$CACHE/$want" || true
+}
+fetch https://registry.npmjs.org/postgres/-/postgres-3.4.9.tgz "$WORK/upstream.tgz" 512 \
+ 183dea741d31d73f7180523a71d443eb1bb64a9d9608e1287b79ad9f207911ed17aeb2f93def9ee020a726b44c9cbd7362d44366641055bbceb6d2e72832e76b
mkdir "$WORK/postgres"
tar -xzf "$WORK/upstream.tgz" --strip-components=1 -C "$WORK/postgres"
patch --no-backup-if-mismatch -d "$WORK/postgres" -p1 < "$ROOT/patches/[email protected]"
awk '/^diff --git / { keep = ($3 ~ /^a\/src\//) } keep' "$ROOT/patches/[email protected]" |
sed 's|a/src/|a/cf/src/|g; s|b/src/|b/cf/src/|g' > "$WORK/cf.patch"
patch --no-backup-if-mismatch -d "$WORK/postgres" -p1 < "$WORK/cf.patch"
-curl -fsSL https://raw.githubusercontent.com/porsager/postgres/v3.4.9/UNLICENSE -o "$WORK/postgres/UNLICENSE"
-echo 'b5065838cbac452dfc855ba6e6e031481ad2c68406f70d21ead9321374653e6c UNLICENSE' | (cd "$WORK/postgres" && sha256sum -c -)
+fetch https://raw.githubusercontent.com/porsager/postgres/v3.4.9/UNLICENSE "$WORK/postgres/UNLICENSE" 256 \
+ b5065838cbac452dfc855ba6e6e031481ad2c68406f70d21ead9321374653e6c
if [[ "${1:-}" == '--check' ]]; then
diff -ru "$ROOT/vendor/postgres" "$WORK/postgres"
elif [[ $# -eq 0 ]]; then