diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95c087be14..cc1255badb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,6 +117,9 @@ jobs: CLAWHUB_CI_TEST_OBSERVATIONS: "1" run: bun run ci:unit + - name: Offline dependency compatibility + run: bun run test:dependency-compat + - name: Upload test observations if: ${{ always() }} continue-on-error: true diff --git a/bun.lock b/bun.lock index 34eb7f1a3a..46f309dc68 100644 --- a/bun.lock +++ b/bun.lock @@ -9,7 +9,7 @@ "@convex-dev/auth": "0.0.98", "@convex-dev/migrations": "0.3.8", "@convex-dev/rate-limiter": "0.4.3", - "@convex-dev/workpool": "0.4.15", + "@convex-dev/workpool": "0.4.16", "@fontsource/bricolage-grotesque": "5.3.0", "@fontsource/ibm-plex-mono": "5.3.0", "@fontsource/noto-sans-sc": "5.3.1", @@ -33,19 +33,19 @@ "@shikijs/rehype": "4.6.0", "@tanstack/react-router": "1.170.46", "@tanstack/react-start": "1.169.5", - "@vercel/oidc": "4.0.8", + "@vercel/oidc": "4.0.9", "arktype": "2.2.9", "class-variance-authority": "0.7.1", "clawhub-schema": "workspace:0.0.2", "clsx": "2.1.1", - "convex": "1.49.0", + "convex": "1.50.0", "convex-helpers": "0.1.135", "fflate": "0.8.3", "franc-min": "6.2.0", "h3": "2.0.8", - "ignore": "7.0.14", + "ignore": "7.0.16", "jose": "6.2.17", - "lucide-react": "1.72.0", + "lucide-react": "1.74.0", "mermaid": "^11.17.2", "mime": "4.1.2", "monaco-editor": "0.57.0", @@ -121,9 +121,9 @@ "@openclaw/plugin-inspector": "0.4.6", "arktype": "2.2.9", "commander": "15.1.0", - "croner": "11.0.0", + "croner": "11.0.1", "fflate": "0.8.3", - "ignore": "7.0.14", + "ignore": "7.0.16", "json5": "2.2.3", "mime": "4.1.2", "ora": "10.0.0", @@ -150,7 +150,7 @@ "arktype": "2.2.9", "commander": "15.1.0", "fflate": "0.8.3", - "ignore": "7.0.14", + "ignore": "7.0.16", "json5": "2.2.3", "mime": "4.1.2", "ora": "10.0.0", @@ -169,7 +169,7 @@ "version": "0.0.2", "dependencies": { "arktype": "2.2.9", - "croner": "11.0.0", + "croner": "11.0.1", "json5": "2.2.3", "unicode-case-folding": "1.1.2", "yaml": "2.9.1", @@ -261,7 +261,7 @@ "@convex-dev/rate-limiter": ["@convex-dev/rate-limiter@0.4.3", "", { "dependencies": { "@convex-dev/batch-worker": "0.3.5" }, "peerDependencies": { "convex": "^1.43.0", "react": "^18.2.0 || ^19.0.0" }, "optionalPeers": ["react"] }, "sha512-IXIEGbZBANC5B23pGmIui7p49kSiltNWyJ7wX7nFmkR396X/Oj9ebgScgxSJMAW7DkhpUtt1NAnQHhjB0v6a/A=="], - "@convex-dev/workpool": ["@convex-dev/workpool@0.4.15", "", { "dependencies": { "@convex-dev/batch-worker": "^0.3.6" }, "peerDependencies": { "convex": "^1.43.0", "convex-helpers": "^0.1.94" } }, "sha512-eweNWj3nHnUpwT40S5qwtA/d9LbuVMXlBP6GqM5tE4+eAOkzWbudiiCz9bi1bBpFSjtnbdRfQ+PoBG/STqgj8A=="], + "@convex-dev/workpool": ["@convex-dev/workpool@0.4.16", "", { "dependencies": { "@convex-dev/batch-worker": "^0.3.6" }, "peerDependencies": { "convex": "^1.43.0", "convex-helpers": "^0.1.94" } }, "sha512-QtR9lEidys0yGtjlbtJzhcC6RGxs4uICnewWZmiolDnUlX4Y8z5v4hGwDzON3TRDIzL3Pd/WPY/jXRKZnQW4Bg=="], "@edge-runtime/primitives": ["@edge-runtime/primitives@6.0.0", "", {}, "sha512-FqoxaBT+prPBHBwE1WXS1ocnu/VLTQyZ6NMUBAdbP7N2hsFTTxMC/jMu2D/8GAlMQfxeuppcPuCUk/HO3fpIvA=="], @@ -429,13 +429,13 @@ "@next/swc-darwin-x64": ["@next/swc-darwin-x64@16.4.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA=="], - "@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@16.4.6", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA=="], + "@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@16.4.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA=="], - "@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@16.4.6", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA=="], + "@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@16.4.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA=="], - "@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@16.4.6", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ=="], + "@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@16.4.6", "", { "os": "linux", "cpu": "x64" }, "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ=="], - "@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@16.4.6", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA=="], + "@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@16.4.6", "", { "os": "linux", "cpu": "x64" }, "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA=="], "@next/swc-win32-arm64-msvc": ["@next/swc-win32-arm64-msvc@16.4.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ=="], @@ -523,21 +523,21 @@ "@oxfmt/binding-linux-arm-musleabihf": ["@oxfmt/binding-linux-arm-musleabihf@0.78.0", "", { "os": "linux", "cpu": "arm" }, "sha512-lIK0XJi4JP1FnhuLjR/JWhQHGghZc+ghFNnbZTQC8kxsmrkW3ex8CeF7fp0FT+rEP0Nm6voCYkasL8poVWA9sQ=="], - "@oxfmt/binding-linux-arm64-gnu": ["@oxfmt/binding-linux-arm64-gnu@0.78.0", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-o2LJIHfW3ZADOjDVk5c7MM1M8CiAG43GTc4mlJAK23fOHgru4CvnqWedCoCXpIsKokoRdEa7XdQywPGZv1BAiA=="], + "@oxfmt/binding-linux-arm64-gnu": ["@oxfmt/binding-linux-arm64-gnu@0.78.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-o2LJIHfW3ZADOjDVk5c7MM1M8CiAG43GTc4mlJAK23fOHgru4CvnqWedCoCXpIsKokoRdEa7XdQywPGZv1BAiA=="], - "@oxfmt/binding-linux-arm64-musl": ["@oxfmt/binding-linux-arm64-musl@0.78.0", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-G+lUaQk94Vo+4byyd8X2+pPXtd7wObpdbvBC8xyozZD0ROSVBI3XpNNR6HECkJq4Q51AwLuJG81f4x+4eqvSrw=="], + "@oxfmt/binding-linux-arm64-musl": ["@oxfmt/binding-linux-arm64-musl@0.78.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-G+lUaQk94Vo+4byyd8X2+pPXtd7wObpdbvBC8xyozZD0ROSVBI3XpNNR6HECkJq4Q51AwLuJG81f4x+4eqvSrw=="], - "@oxfmt/binding-linux-ppc64-gnu": ["@oxfmt/binding-linux-ppc64-gnu@0.78.0", "", { "os": "linux", "cpu": "ppc64", "libc": "glibc" }, "sha512-r76PAZf9/ZgF/iDRaIf8nLsr4x6ZHe/j2QLmWUjoQ46Sa11qMO68a5u5iux3y8vLzqYTS/xtKO9PjjMfyk5png=="], + "@oxfmt/binding-linux-ppc64-gnu": ["@oxfmt/binding-linux-ppc64-gnu@0.78.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-r76PAZf9/ZgF/iDRaIf8nLsr4x6ZHe/j2QLmWUjoQ46Sa11qMO68a5u5iux3y8vLzqYTS/xtKO9PjjMfyk5png=="], - "@oxfmt/binding-linux-riscv64-gnu": ["@oxfmt/binding-linux-riscv64-gnu@0.78.0", "", { "os": "linux", "cpu": "none", "libc": "glibc" }, "sha512-SQiXTt/c4aVoRXkJvhf4Y/sA1XYe3XjSMDbdX5PiAssBuHERoGtncQXz0KKWkXPejWTKlAL4mZSQZdHOCiw7TA=="], + "@oxfmt/binding-linux-riscv64-gnu": ["@oxfmt/binding-linux-riscv64-gnu@0.78.0", "", { "os": "linux", "cpu": "none" }, "sha512-SQiXTt/c4aVoRXkJvhf4Y/sA1XYe3XjSMDbdX5PiAssBuHERoGtncQXz0KKWkXPejWTKlAL4mZSQZdHOCiw7TA=="], - "@oxfmt/binding-linux-riscv64-musl": ["@oxfmt/binding-linux-riscv64-musl@0.78.0", "", { "os": "linux", "cpu": "none", "libc": "musl" }, "sha512-VNB3wFUx/rAqwVNW+uyXxb+c0HUrmcS51UPkFMDWJY95c6Tck6u6HOyVLsqiYoC8kh2mGlwanYmjb/R2McvN0A=="], + "@oxfmt/binding-linux-riscv64-musl": ["@oxfmt/binding-linux-riscv64-musl@0.78.0", "", { "os": "linux", "cpu": "none" }, "sha512-VNB3wFUx/rAqwVNW+uyXxb+c0HUrmcS51UPkFMDWJY95c6Tck6u6HOyVLsqiYoC8kh2mGlwanYmjb/R2McvN0A=="], - "@oxfmt/binding-linux-s390x-gnu": ["@oxfmt/binding-linux-s390x-gnu@0.78.0", "", { "os": "linux", "cpu": "s390x", "libc": "glibc" }, "sha512-1nbI0Y7SXwx2f4mJmKt58MaDdjAcoaYM90pBMGdcZCsTW2taFW1/MUi3uQGRPAN2n+3PldCdO9m+D6x+gU/heg=="], + "@oxfmt/binding-linux-s390x-gnu": ["@oxfmt/binding-linux-s390x-gnu@0.78.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-1nbI0Y7SXwx2f4mJmKt58MaDdjAcoaYM90pBMGdcZCsTW2taFW1/MUi3uQGRPAN2n+3PldCdO9m+D6x+gU/heg=="], - "@oxfmt/binding-linux-x64-gnu": ["@oxfmt/binding-linux-x64-gnu@0.78.0", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-I2z2ISPjrl3CSRF5fmQkNnoh46UVU1GjM1V0+COJyNZcj0SDNM4DrPP2/gXCX38YJ1P2BL6sF2VdsJ+pEYEbJQ=="], + "@oxfmt/binding-linux-x64-gnu": ["@oxfmt/binding-linux-x64-gnu@0.78.0", "", { "os": "linux", "cpu": "x64" }, "sha512-I2z2ISPjrl3CSRF5fmQkNnoh46UVU1GjM1V0+COJyNZcj0SDNM4DrPP2/gXCX38YJ1P2BL6sF2VdsJ+pEYEbJQ=="], - "@oxfmt/binding-linux-x64-musl": ["@oxfmt/binding-linux-x64-musl@0.78.0", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-YHt5nKKFxT4SruI57FHnEhGRSDuoFqNoAM3moYCClg70mjjS39gBBbdzaZv+N0otdzvQVuHTPu3jFu5tpqC3XQ=="], + "@oxfmt/binding-linux-x64-musl": ["@oxfmt/binding-linux-x64-musl@0.78.0", "", { "os": "linux", "cpu": "x64" }, "sha512-YHt5nKKFxT4SruI57FHnEhGRSDuoFqNoAM3moYCClg70mjjS39gBBbdzaZv+N0otdzvQVuHTPu3jFu5tpqC3XQ=="], "@oxfmt/binding-openharmony-arm64": ["@oxfmt/binding-openharmony-arm64@0.78.0", "", { "os": "none", "cpu": "arm64" }, "sha512-WH21lBMU+LYzF7aMeozTZlyc44oa2F+I5OtQ7RwuidCDoAxgTyN1s34rx0PBYrio56+2G88U9VOnYJsyV7VMHQ=="], @@ -573,21 +573,21 @@ "@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-5pJ9NjMvH7WMUqXB6bTTOSemBm39w2cod27Hu3+Yom/GhbTeNXlYcpDx1o4CgBP6fhp0YHG66TNdVaUm6sHjsA=="], - "@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.93.0", "", { "os": "linux", "cpu": "arm64", "libc": "glibc" }, "sha512-pRf+7jtbt2fHE23SX7qBxRgnBZicUgsoCK1PVIjnOk+t3a6UBkpt/GrKI99WlxsKUxftz/5nv/kfKvScmYywkw=="], + "@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-pRf+7jtbt2fHE23SX7qBxRgnBZicUgsoCK1PVIjnOk+t3a6UBkpt/GrKI99WlxsKUxftz/5nv/kfKvScmYywkw=="], - "@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.93.0", "", { "os": "linux", "cpu": "arm64", "libc": "musl" }, "sha512-zM8Fd/K8sqGvsBcJBZ3oVZ3ctGWbszA08IaGt5gFFF5RcunppAI/ZnAXbouABvnWeJ//S44KKlfPZnDDbeiphg=="], + "@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-zM8Fd/K8sqGvsBcJBZ3oVZ3ctGWbszA08IaGt5gFFF5RcunppAI/ZnAXbouABvnWeJ//S44KKlfPZnDDbeiphg=="], - "@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.93.0", "", { "os": "linux", "cpu": "ppc64", "libc": "glibc" }, "sha512-7qKCnvhZKDXJG2pdbLazd2hw4FxjJHbZOFrrbzyy5PdHfPLH9vnNUa1le01A8uItZuYKPBPncH+HCoEiFT4SgA=="], + "@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.93.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-7qKCnvhZKDXJG2pdbLazd2hw4FxjJHbZOFrrbzyy5PdHfPLH9vnNUa1le01A8uItZuYKPBPncH+HCoEiFT4SgA=="], - "@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.93.0", "", { "os": "linux", "cpu": "none", "libc": "glibc" }, "sha512-2pgulxC6G8V5wE750NJE/fRkf9aO6i6yoj10wyaR2EdiNtan4OemsOtsQ0ZTXGdY8Q3IoTmlND3GYvjJsvikYg=="], + "@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-2pgulxC6G8V5wE750NJE/fRkf9aO6i6yoj10wyaR2EdiNtan4OemsOtsQ0ZTXGdY8Q3IoTmlND3GYvjJsvikYg=="], - "@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.93.0", "", { "os": "linux", "cpu": "none", "libc": "musl" }, "sha512-yWsn6Gg2PnGG5jlyDz5+pHGiMTMiy4adaa4WRMzDgzB8efaShk1JMmTHIBSVLQMh0tYXRs4CN5uJCO79r4Mi4g=="], + "@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-yWsn6Gg2PnGG5jlyDz5+pHGiMTMiy4adaa4WRMzDgzB8efaShk1JMmTHIBSVLQMh0tYXRs4CN5uJCO79r4Mi4g=="], - "@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.93.0", "", { "os": "linux", "cpu": "s390x", "libc": "glibc" }, "sha512-WCn5plwp/ezS2RDPQKp0/EXEVRr9/dDexUdRKmsMFqzNM5xBSZ1wbsi3PuMk1VfkMRnI5BuazCsziCWMXRDOlw=="], + "@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.93.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WCn5plwp/ezS2RDPQKp0/EXEVRr9/dDexUdRKmsMFqzNM5xBSZ1wbsi3PuMk1VfkMRnI5BuazCsziCWMXRDOlw=="], - "@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.93.0", "", { "os": "linux", "cpu": "x64", "libc": "glibc" }, "sha512-F2CGjb9LAkzH+IYTZSzd1klQ1vk5z6Utjax64WeLByCkYXbVDbsun+Oy2hLfW2MDSKCvW+jwy/9ld0EPgdeu+A=="], + "@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F2CGjb9LAkzH+IYTZSzd1klQ1vk5z6Utjax64WeLByCkYXbVDbsun+Oy2hLfW2MDSKCvW+jwy/9ld0EPgdeu+A=="], - "@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.93.0", "", { "os": "linux", "cpu": "x64", "libc": "musl" }, "sha512-plf5DE2objcG8Tf7mXRuRa8tT8rzDkpjqXQtKoGsKHWkpgsialbON1+cCtoSEUTVbQUjXvuAm8vV9+3rR0yCBw=="], + "@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-plf5DE2objcG8Tf7mXRuRa8tT8rzDkpjqXQtKoGsKHWkpgsialbON1+cCtoSEUTVbQUjXvuAm8vV9+3rR0yCBw=="], "@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.93.0", "", { "os": "none", "cpu": "arm64" }, "sha512-Kp2yJrKvoTe9FfKdO/xwLNUbs2bYTMKx0+aoQD1s0h/Tx0kSgtHSdGmrk8tTKdluosjFbo88qYRIaNIX43AfFw=="], @@ -1023,11 +1023,11 @@ "@upsetjs/venn.js": ["@upsetjs/venn.js@2.0.0", "", { "optionalDependencies": { "d3-selection": "^3.0.0", "d3-transition": "^3.0.1" } }, "sha512-WbBhLrooyePuQ1VZxrJjtLvTc4NVfpOyKx0sKqioq9bX1C1m7Jgykkn8gLrtwumBioXIqam8DLxp88Adbue6Hw=="], - "@vercel/cli-config": ["@vercel/cli-config@0.3.8", "", { "dependencies": { "xdg-app-paths": "5", "zod": "^4.6.6" } }, "sha512-C6av1p4tN+rHIcD0rdlsx3y9SaosRUU67dbgrjbLG8KdAK8oNVzfKg0ckV+1qWh5VC/Ft1BN3Pg/PuXSKNFVOA=="], + "@vercel/cli-config": ["@vercel/cli-config@0.4.0", "", { "dependencies": { "xdg-app-paths": "5.1.0", "zod": "^4.6.6" } }, "sha512-7+DnWjfcHA/u2FjiPMknhlqZFmJZZq1qS5ziIxNH+3zNBo2U4NQjkJABKDGMZlLBlBLK94RXuA2dceC4SCFumA=="], "@vercel/cli-exec": ["@vercel/cli-exec@1.0.1", "", { "dependencies": { "execa": "5.1.1" } }, "sha512-g9XerViJ/paZujufXYcu5XYI2vU2rtB4sgdpjUHde5RnOkdmpu0ngH46LCFGHoPXO/C+qDPSczIHIRN+8Q2YKQ=="], - "@vercel/oidc": ["@vercel/oidc@4.0.8", "", { "dependencies": { "@vercel/cli-config": "0.3.8", "@vercel/cli-exec": "1.0.1", "jose": "^5.9.6" } }, "sha512-8wcmhuhrEsQlgTvPfRIeE4Y2geSaid0a1DP+um1PfNK4ETjqnfGTL5k5l7vS2T8A2gOx/MV7yNGxUJTs+0tqPQ=="], + "@vercel/oidc": ["@vercel/oidc@4.0.9", "", { "dependencies": { "@vercel/cli-config": "0.4.0", "@vercel/cli-exec": "1.0.1", "jose": "^5.9.6" } }, "sha512-LBNEPlKHv3ZAhOX2Dcj1hrxdmqYrdzxukGltouKbyjU8IeJvAFSuOHn5X0ZWg0qG2huANcgrHAb03giWeUyubQ=="], "@vitejs/plugin-react": ["@vitejs/plugin-react@6.3.0", "", { "dependencies": { "@rolldown/pluginutils": "^1.0.1" }, "peerDependencies": { "@rolldown/plugin-babel": "^0.1.7 || ^0.2.0 || ^0.3.0", "babel-plugin-react-compiler": "^1.0.0", "oxc-transform-react": ">=0.152.0 <0.157.0", "vite": "^8.0.0" }, "optionalPeers": ["@rolldown/plugin-babel", "babel-plugin-react-compiler", "oxc-transform-react"] }, "sha512-H9E955aVvD2F4zNHCw4eIZbIfF6xKldlh7MNu+hSU7xwQzh65lI/N+CJWqmfhi0PEjDXIt/H7T7J/4wU63KJiw=="], @@ -1139,7 +1139,7 @@ "convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="], - "convex": ["convex@1.49.0", "", { "dependencies": { "esbuild": "0.27.0", "prettier": "^3.0.0", "ws": "8.21.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "@clerk/react": "^6.4.3", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "@clerk/react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-mkr9oXF8/arkCI1kvYyGytWd62oVXNABh4uwLeI4UQVN6Zuudm4DlmSzNUJKF63djk6f/uUXC+6ffuVSkPLvzA=="], + "convex": ["convex@1.50.0", "", { "dependencies": { "esbuild": "0.27.0", "prettier": "^3.0.0", "ws": "8.21.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "@clerk/react": "^6.4.3", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "@clerk/react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-WzzCad5hyzU4zzW0ChyUGB3Mil4LgRYMYii9cyQtC24WQnfaRgkZB0IKyhIIgRm1a2IXiGJoZnVYYSfttiap3Q=="], "convex-helpers": ["convex-helpers@0.1.135", "", { "peerDependencies": { "@standard-schema/spec": "^1.0.0", "convex": "^1.46.0", "hono": "^4.0.5", "prettier": "^3.0.0", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": "^5.5 || ^6.0.0 || ^7.0.0", "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["@standard-schema/spec", "hono", "prettier", "react", "typescript", "zod"], "bin": { "convex-helpers": "dist/bin.cjs" } }, "sha512-UX2f9j6pk90UyosPhnYQ1Q6nmUF/klUn/LZGp6BM8Ps5r+cZyY66ULhB1Vp3lUOY4EdjS3RLCKyaoTUg0BqhoA=="], @@ -1153,7 +1153,7 @@ "cose-base": ["cose-base@1.0.3", "", { "dependencies": { "layout-base": "^1.0.0" } }, "sha512-s9whTXInMSgAp/NVXVNuVxVKzGH2qck3aQlVHxDCdAEPgtMKwc4Wq6/QKhgdEdgbLSi9rBTAcPoRa6JpiG4ksg=="], - "croner": ["croner@11.0.0", "", {}, "sha512-T17ADjdttrVToyzLpLq9Xb9xzcMwpQ/M3Qs9szhh0MVNTbv6NWQ9OFYa2qlzPYXFMn+uoDlnW1IpIv6cAvFtyA=="], + "croner": ["croner@11.0.1", "", {}, "sha512-/fmHcoczPy5cMcmJ6ex7J7LAwb545V1dNmRrdDGP3hwStg/06IYP56YgBySCSdWGDz2PJYQyDukaR8b8R5o2HA=="], "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], @@ -1297,7 +1297,7 @@ "es-toolkit": ["es-toolkit@1.47.0", "", {}, "sha512-n1GuoD0WEQZMBk5tttoZSqwgyLx01oqa5XsBmCHwPyNe1S9jPBEmtR2pSgp2kJuWE3ciFZ6yRHmY4pM4C3OOkw=="], - "esbuild": ["esbuild@0.28.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.28.2", "@esbuild/android-arm": "0.28.2", "@esbuild/android-arm64": "0.28.2", "@esbuild/android-x64": "0.28.2", "@esbuild/darwin-arm64": "0.28.2", "@esbuild/darwin-x64": "0.28.2", "@esbuild/freebsd-arm64": "0.28.2", "@esbuild/freebsd-x64": "0.28.2", "@esbuild/linux-arm": "0.28.2", "@esbuild/linux-arm64": "0.28.2", "@esbuild/linux-ia32": "0.28.2", "@esbuild/linux-loong64": "0.28.2", "@esbuild/linux-mips64el": "0.28.2", "@esbuild/linux-ppc64": "0.28.2", "@esbuild/linux-riscv64": "0.28.2", "@esbuild/linux-s390x": "0.28.2", "@esbuild/linux-x64": "0.28.2", "@esbuild/netbsd-arm64": "0.28.2", "@esbuild/netbsd-x64": "0.28.2", "@esbuild/openbsd-arm64": "0.28.2", "@esbuild/openbsd-x64": "0.28.2", "@esbuild/openharmony-arm64": "0.28.2", "@esbuild/sunos-x64": "0.28.2", "@esbuild/win32-arm64": "0.28.2", "@esbuild/win32-ia32": "0.28.2", "@esbuild/win32-x64": "0.28.2" }, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA=="], + "esbuild": ["esbuild@0.28.2", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.28.2", "@esbuild/android-arm": "0.28.2", "@esbuild/android-arm64": "0.28.2", "@esbuild/android-x64": "0.28.2", "@esbuild/darwin-arm64": "0.28.2", "@esbuild/darwin-x64": "0.28.2", "@esbuild/freebsd-arm64": "0.28.2", "@esbuild/freebsd-x64": "0.28.2", "@esbuild/linux-arm": "0.28.2", "@esbuild/linux-arm64": "0.28.2", "@esbuild/linux-ia32": "0.28.2", "@esbuild/linux-loong64": "0.28.2", "@esbuild/linux-mips64el": "0.28.2", "@esbuild/linux-ppc64": "0.28.2", "@esbuild/linux-riscv64": "0.28.2", "@esbuild/linux-s390x": "0.28.2", "@esbuild/linux-x64": "0.28.2", "@esbuild/netbsd-arm64": "0.28.2", "@esbuild/netbsd-x64": "0.28.2", "@esbuild/openbsd-arm64": "0.28.2", "@esbuild/openbsd-x64": "0.28.2", "@esbuild/openharmony-arm64": "0.28.2", "@esbuild/sunos-x64": "0.28.2", "@esbuild/win32-arm64": "0.28.2", "@esbuild/win32-ia32": "0.28.2", "@esbuild/win32-x64": "0.28.2" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA=="], "escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="], @@ -1401,7 +1401,7 @@ "iconv-lite": ["iconv-lite@0.6.3", "", { "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" } }, "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw=="], - "ignore": ["ignore@7.0.14", "", {}, "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ=="], + "ignore": ["ignore@7.0.16", "", {}, "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A=="], "import-meta-resolve": ["import-meta-resolve@4.2.0", "", {}, "sha512-Iqv2fzaTQN28s/FwZAoFq0ZSs/7hMAHJVX+w8PZl3cY19Pxk6jFFalxQoIfW2826i/fDLXv8IiEZRIT0lDuWcg=="], @@ -1499,7 +1499,7 @@ "lucia": ["lucia@3.2.2", "", { "dependencies": { "@oslojs/crypto": "^1.0.1", "@oslojs/encoding": "^1.1.0" } }, "sha512-P1FlFBGCMPMXu+EGdVD9W4Mjm0DqsusmKgO7Xc33mI5X1bklmsQb0hfzPhXomQr9waWIBDsiOjvr1e6BTaUqpA=="], - "lucide-react": ["lucide-react@1.72.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-fbF5i1GU8GODETa3Q7rXqrJrcx3iPYrQtxthom103zGx+Z0BGwKYAW9s+9435ohYJ7hQm0av0PoZcqI1CRwNrg=="], + "lucide-react": ["lucide-react@1.74.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-A1doIs/1fj1WnPbtIT7WRiM6Kvw5NUg+BtkoOh3Shpr4obwSDVt6WxCEcNH56EWprzuCoKle1OF0RqIkojwL1A=="], "lz-string": ["lz-string@1.5.0", "", { "bin": { "lz-string": "bin/bin.js" } }, "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ=="], @@ -2019,7 +2019,7 @@ "ws": ["ws@8.23.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ=="], - "xdg-app-paths": ["xdg-app-paths@5.5.1", "", { "dependencies": { "os-paths": "^4.0.1", "xdg-portable": "^7.2.0" } }, "sha512-hI3flOB4PLZIy5prbtTpirobtPE2ZtZ52szO+2mM9Efp6ErM398La+C1lIpNWDfNoQk+6Lsi6nMcCwVB7pxeMQ=="], + "xdg-app-paths": ["xdg-app-paths@5.1.0", "", { "dependencies": { "xdg-portable": "^7.0.0" } }, "sha512-RAQ3WkPf4KTU1A8RtFx3gWywzVKe00tfOPFfl2NDGqbIFENQO4kqAJp7mhQjNj/33W5x5hiWWUdyfPq/5SU3QA=="], "xdg-portable": ["xdg-portable@7.3.0", "", { "dependencies": { "os-paths": "^4.0.1" } }, "sha512-sqMMuL1rc0FmMBOzCpd0yuy9trqF2yTTVe+E9ogwCSWQCdDEtQUwrZPT6AxqtsFGRNxycgncbP/xmOOSPw5ZUw=="], diff --git a/package.json b/package.json index fb7f27e571..f91470a228 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "skills-sh:prove-trending": "bun scripts/skills-sh-catalog/prove-trending-test.ts", "skills:install": "npx --yes skills@1.5.16 add openclaw/carapace --skill openclaw-design openclaw-brand openclaw-carapace openclaw-design-system openclaw-marketing-pages openclaw-design-audit --agent codex --copy --yes", "test": "vitest run", + "test:dependency-compat": "bun install --cwd scripts/fixtures/dependency-baseline --frozen-lockfile && vitest run --config vitest.dependency.config.ts", "test:e2e": "vitest run -c vitest.e2e.config.ts", "test:e2e:local": "bash scripts/run-playwright-local.sh", "test:e2e:prod-http": "vitest run -c vitest.e2e.config.ts e2e/prod-http-smoke.e2e.test.ts", @@ -98,7 +99,7 @@ "@convex-dev/auth": "0.0.98", "@convex-dev/migrations": "0.3.8", "@convex-dev/rate-limiter": "0.4.3", - "@convex-dev/workpool": "0.4.15", + "@convex-dev/workpool": "0.4.16", "@fontsource/bricolage-grotesque": "5.3.0", "@fontsource/ibm-plex-mono": "5.3.0", "@fontsource/noto-sans-sc": "5.3.1", @@ -122,19 +123,19 @@ "@shikijs/rehype": "4.6.0", "@tanstack/react-router": "1.170.46", "@tanstack/react-start": "1.169.5", - "@vercel/oidc": "4.0.8", + "@vercel/oidc": "4.0.9", "arktype": "2.2.9", "class-variance-authority": "0.7.1", "clawhub-schema": "workspace:0.0.2", "clsx": "2.1.1", - "convex": "1.49.0", + "convex": "1.50.0", "convex-helpers": "0.1.135", "fflate": "0.8.3", "franc-min": "6.2.0", "h3": "2.0.8", - "ignore": "7.0.14", + "ignore": "7.0.16", "jose": "6.2.17", - "lucide-react": "1.72.0", + "lucide-react": "1.74.0", "mermaid": "^11.17.2", "mime": "4.1.2", "monaco-editor": "0.57.0", diff --git a/packages/clawhub-admin/package.json b/packages/clawhub-admin/package.json index a7a0677b94..90e27d53e1 100644 --- a/packages/clawhub-admin/package.json +++ b/packages/clawhub-admin/package.json @@ -33,7 +33,7 @@ "arktype": "2.2.9", "commander": "15.1.0", "fflate": "0.8.3", - "ignore": "7.0.14", + "ignore": "7.0.16", "json5": "2.2.3", "mime": "4.1.2", "ora": "10.0.0", diff --git a/packages/clawhub/package.json b/packages/clawhub/package.json index a78fe9ae04..5184211277 100644 --- a/packages/clawhub/package.json +++ b/packages/clawhub/package.json @@ -41,9 +41,9 @@ "@openclaw/plugin-inspector": "0.4.6", "arktype": "2.2.9", "commander": "15.1.0", - "croner": "11.0.0", + "croner": "11.0.1", "fflate": "0.8.3", - "ignore": "7.0.14", + "ignore": "7.0.16", "json5": "2.2.3", "mime": "4.1.2", "ora": "10.0.0", diff --git a/packages/schema/package.json b/packages/schema/package.json index 95c2471da8..f91073f3fd 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -91,7 +91,7 @@ }, "dependencies": { "arktype": "2.2.9", - "croner": "11.0.0", + "croner": "11.0.1", "json5": "2.2.3", "unicode-case-folding": "1.1.2", "yaml": "2.9.1" diff --git a/scripts/dependency-account-compat.proof.ts b/scripts/dependency-account-compat.proof.ts new file mode 100644 index 0000000000..be7a7fa538 --- /dev/null +++ b/scripts/dependency-account-compat.proof.ts @@ -0,0 +1,86 @@ +/* @vitest-environment node */ +import { spawnSync } from "node:child_process"; +import { randomBytes } from "node:crypto"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { resolve, join } from "node:path"; +import { expect, it } from "vitest"; + +function runFixture(runtime: string, file: string, args: string[] = []) { + const home = mkdtempSync(join(tmpdir(), "dependency-compat-")); + const nonce = randomBytes(32).toString("hex"); + writeFileSync(join(home, ".clawhub-dependency-fixture"), nonce, { mode: 0o600 }); + try { + const result = spawnSync(runtime, [resolve("scripts/fixtures", file), ...args], { + cwd: home, + env: { + CLAWHUB_DEPENDENCY_FIXTURE_HOME: home, + CLAWHUB_DEPENDENCY_FIXTURE_NONCE: nonce, + HOME: home, + USERPROFILE: home, + PATH: process.env.PATH, + TMPDIR: tmpdir(), + NO_COLOR: "1", + }, + encoding: "utf8", + timeout: 10_000, + }); + expect(result.status, result.stderr || String(result.error ?? result.stdout)).toBe(0); + return JSON.parse(result.stdout.trim().split("\n").at(-1) ?? "null"); + } finally { + rmSync(home, { force: true, recursive: true }); + } +} + +it("preserves legacy Convex credentials through account selection and permission changes", () => { + expect(runFixture(process.execPath, "convex-account-compat.mjs")).toEqual({ + legacyReadable: true, + selection: true, + preserved: true, + permissions: true, + }); +}); + +it.each(["xdg", "legacy", "precedence"])( + "preserves OIDC behavior with %s configuration", + (layout) => { + for (const packageName of ["baseline", "candidate"]) { + expect( + runFixture(process.execPath, "vercel-oidc-compat.mjs", [packageName, layout]), + ).toMatchObject({ + layout, + fresh: true, + request: true, + file: true, + refresh: true, + }); + } + }, +); + +it.each([ + ["convex-account-compat.mjs", ".convex/config.json", []], + ["vercel-oidc-compat.mjs", ".now/auth.json", ["candidate", "legacy"]], +] as const)( + "refuses an unowned direct invocation of %s before changing credentials", + (file, credential, args) => { + const home = mkdtempSync(join(tmpdir(), "dependency-compat-")); + const path = join(home, credential); + const original = '{"token":"fixture-preexisting-credential"}'; + try { + mkdirSync(resolve(path, ".."), { recursive: true }); + writeFileSync(path, original); + const result = spawnSync(process.execPath, [resolve("scripts/fixtures", file), ...args], { + cwd: home, + env: { HOME: home, USERPROFILE: home, PATH: process.env.PATH, NO_COLOR: "1" }, + encoding: "utf8", + timeout: 10_000, + }); + expect(result.status).not.toBe(0); + expect(result.stderr).toContain("Run through the dependency fixture runner."); + expect(readFileSync(path, "utf8")).toBe(original); + } finally { + rmSync(home, { force: true, recursive: true }); + } + }, +); diff --git a/scripts/fixtures/component-upgrade/app.ts.txt b/scripts/fixtures/component-upgrade/app.ts.txt new file mode 100644 index 0000000000..9c8077469a --- /dev/null +++ b/scripts/fixtures/component-upgrade/app.ts.txt @@ -0,0 +1,91 @@ +import { Workpool } from "@convex-dev/workpool"; +import { makeFunctionReference } from "convex/server"; +import { ConvexError, v } from "convex/values"; +import { components } from "./_generated/api"; +import { internalAction, internalMutation, internalQuery } from "./functions"; + +function localOnly() { + if (!/^http:\/\/127\.0\.0\.1:\d+$/.test(process.env.CONVEX_SITE_URL ?? "")) + throw new Error("Dependency fixtures require the owned local backend."); +} +const ref = (name: string) => makeFunctionReference(name); + +export const seed = internalMutation({ + args: {}, + handler: async (ctx) => { + localOnly(); + const userId = await ctx.db.insert("users", { role: "admin", handle: "dependency-fixture" }); + await ctx.db.insert("dependencyUpgradeGate", { started: false, released: false }); + return { userId }; + }, +}); + +export const gate = internalMutation({ + args: { started: v.optional(v.boolean()), released: v.optional(v.boolean()) }, + handler: async (ctx, args) => { + localOnly(); + const row = await ctx.db.query("dependencyUpgradeGate").unique(); + if (!row) throw new Error("Missing fixture gate."); + await ctx.db.patch(row._id, args); + }, +}); + +export const observeGate = internalQuery({ + args: {}, + handler: async (ctx) => { + localOnly(); + return await ctx.db.query("dependencyUpgradeGate").unique(); + }, +}); + +export const failAfterGate = internalAction({ + args: {}, + handler: async (ctx) => { + localOnly(); + await ctx.runMutation(ref("dependencyUpgradeFixtures:gate"), { started: true }); + const deadline = Date.now() + 180_000; + while (Date.now() < deadline) { + const state = await ctx.runQuery(ref("dependencyUpgradeFixtures:observeGate"), {}); + if (state?.released) throw new ConvexError({ fixture: "retained-completion" }); + await new Promise((resolve) => setTimeout(resolve, 50)); + } + throw new Error("Fixture gate was not released before the deadline."); + }, +}); + +export const startFailure = internalMutation({ + args: {}, + handler: async (ctx) => { + localOnly(); + const pool = new Workpool(components.searchReports, { maxParallelism: 1 }); + return await pool.enqueueAction(ctx, ref("dependencyUpgradeFixtures:failAfterGate"), {}, { retry: false }); + }, +}); + +export const enqueueReportAndPause = internalMutation({ + args: {}, + handler: async (ctx) => { + localOnly(); + const report = await ctx.runMutation(ref("searchReports:start"), { + view: "recommendations", artifactKind: "plugin", + }); + await ctx.runMutation(components.searchReports.config.update, { maxParallelism: 0 }); + return report; + }, +}); + +export const parallelism = internalMutation({ + args: { value: v.union(v.literal(0), v.literal(1)) }, + handler: async (ctx, { value }) => { + localOnly(); + await ctx.runMutation(components.searchReports.config.update, { maxParallelism: value }); + }, +}); + +export const reportRow = internalQuery({ + args: { reportId: v.id("searchReportRuns") }, + handler: async (ctx, { reportId }) => { + localOnly(); + return await ctx.db.get(reportId); + }, +}); diff --git a/scripts/fixtures/component-upgrade/schema.ts.txt b/scripts/fixtures/component-upgrade/schema.ts.txt new file mode 100644 index 0000000000..e502fc6f79 --- /dev/null +++ b/scripts/fixtures/component-upgrade/schema.ts.txt @@ -0,0 +1,10 @@ +import { defineSchema, defineTable } from "convex/server"; +import { v } from "convex/values"; +import original from "./_dependencyUpgradeOriginalSchema"; + +export * from "./_dependencyUpgradeOriginalSchema"; + +export default defineSchema({ + ...original.tables, + dependencyUpgradeGate: defineTable({ started: v.boolean(), released: v.boolean() }), +}); diff --git a/scripts/fixtures/convex-account-compat.mjs b/scripts/fixtures/convex-account-compat.mjs new file mode 100644 index 0000000000..00d06fbe6c --- /dev/null +++ b/scripts/fixtures/convex-account-compat.mjs @@ -0,0 +1,111 @@ +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { chmodSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; +import Module, { createRequire } from "node:module"; +import { homedir } from "node:os"; +import { dirname, join } from "node:path"; +import { assertFixtureHome, rejectExternalIo } from "./dependency-network-guard.mjs"; + +assertFixtureHome(); + +const verifyIo = rejectExternalIo(); +function helpers(baseline) { + const require = createRequire( + baseline ? new URL("./dependency-baseline/package.json", import.meta.url) : import.meta.url, + ); + const root = dirname(require.resolve("convex/package.json")); + assert.equal( + JSON.parse(readFileSync(join(root, "package.json"))).version, + baseline ? "1.49.0" : "1.50.0", + ); + const filename = join(root, "dist/cli.bundle.cjs"); + const code = readFileSync(filename, "utf8"); + const expectedHash = baseline + ? "de7c7ded59ba4258c76cc308fc28e429f23fd3a31df419364183fe444d824621" + : "b27df8835a27baafc85611e1d11a655fb79f6ad860674a71a7679cb8a6035d43"; + assert.equal( + createHash("sha256").update(code).digest("hex"), + expectedHash, + "Published CLI bundle changed; inspect the new entrypoint before qualifying it.", + ); + const entry = "\nvoid main();"; + assert.equal(code.split(entry).length, 2, "Pinned CLI entrypoint changed."); + const exports = baseline + ? "readGlobalConfig, nodeFs" + : "readGlobalConfig, nodeFs, readAccountSettings, getAccountSelection, legacyAuthForFirstAccount, writeAccountCredentials, initializeDefaultAccount, writeAccountDirectory, readAccountAuth, loadAccountCredentials"; + // Expose the published helper bodies without invoking the CLI, login or telemetry. + const loaded = new Module(filename); + loaded.filename = filename; + loaded.paths = Module._nodeModulePaths(root); + loaded._compile(code.replace(entry, `\nmodule.exports = { ${exports} };`), filename); + return loaded.exports; +} +const previous = helpers(true); +const current = helpers(false); +const cleanups = new Map(); +const ctx = { + fs: current.nodeFs, + crash: async ({ printedMessage }) => { + throw new Error(printedMessage); + }, + registerCleanup: (fn) => { + const id = String(cleanups.size); + cleanups.set(id, fn); + return id; + }, + removeCleanup: (id) => cleanups.delete(id), +}; +const configPath = join(homedir(), ".convex/config.json"); +mkdirSync(dirname(configPath), { recursive: true }); +const legacy = { accessToken: "fixture-legacy-token", preservedSetting: "keep" }; +writeFileSync(configPath, JSON.stringify(legacy)); +chmodSync(configPath, 0o644); +assert.deepEqual(previous.readGlobalConfig(ctx), { accessToken: legacy.accessToken }); +assert.deepEqual(current.readGlobalConfig(ctx), { accessToken: legacy.accessToken }); +if (process.platform !== "win32") assert.equal(statSync(configPath).mode & 0o777, 0o600); +assert.deepEqual(await current.readAccountSettings(ctx), legacy); +assert.equal(await current.getAccountSelection(ctx), null); +assert.equal( + (await current.legacyAuthForFirstAccount(ctx, { name: "work", source: "fixture" })).accessToken, + legacy.accessToken, +); +await current.writeAccountCredentials(ctx, "work", legacy.accessToken); +await current.initializeDefaultAccount(ctx, { name: "work", source: "fixture" }, true); +assert.equal((await current.getAccountSelection(ctx)).name, "work"); +await current.writeAccountCredentials(ctx, "personal", "fixture-personal-token"); +await current.writeAccountDirectory(ctx, "personal"); +assert.equal((await current.getAccountSelection(ctx)).name, "personal"); +mkdirSync("child"); +const parent = process.cwd(); +process.chdir("child"); +assert.equal((await current.getAccountSelection(ctx)).name, "personal"); +process.chdir(parent); +assert.equal(previous.readGlobalConfig(ctx).accessToken, legacy.accessToken); +assert.equal(JSON.parse(readFileSync(configPath, "utf8")).preservedSetting, "keep"); +process.env.CONVEX_ACCOUNT = "work"; +assert.equal((await current.getAccountSelection(ctx)).name, "work"); +assert.equal((await current.getAccountSelection(ctx, { name: "personal" })).name, "personal"); +delete process.env.CONVEX_ACCOUNT; +writeFileSync(".env.local", "CONVEX_ACCOUNT=work\n"); +assert.equal((await current.getAccountSelection(ctx)).name, "work"); +writeFileSync("custom.env", "CONVEX_ACCOUNT=personal\n"); +assert.equal((await current.getAccountSelection(ctx, { envFile: "custom.env" })).name, "personal"); +writeFileSync(".env.local", "CONVEX_ACCOUNT=\n"); +assert.equal((await current.getAccountSelection(ctx)).name, "personal"); +assert.equal( + (await current.readAccountAuth(ctx, { name: "work", source: "fixture" })).accessToken, + legacy.accessToken, +); +if (process.platform !== "win32") { + const directory = join(homedir(), ".convex/accounts"); + chmodSync(directory, 0o755); + chmodSync(join(directory, "work.json"), 0o644); + current.loadAccountCredentials(ctx, "work"); + assert.equal(statSync(directory).mode & 0o777, 0o700); + assert.equal(statSync(join(directory, "work.json")).mode & 0o777, 0o600); +} +assert.equal(cleanups.size, 0); +verifyIo(); +console.log( + JSON.stringify({ legacyReadable: true, selection: true, preserved: true, permissions: true }), +); diff --git a/scripts/fixtures/dependency-baseline/bun.lock b/scripts/fixtures/dependency-baseline/bun.lock new file mode 100644 index 0000000000..14d4dc6b04 --- /dev/null +++ b/scripts/fixtures/dependency-baseline/bun.lock @@ -0,0 +1,132 @@ +{ + "lockfileVersion": 2, + "configVersion": 1, + "workspaces": { + "": { + "name": "clawhub-dependency-baseline", + "dependencies": { + "@convex-dev/workpool": "0.4.15", + "@vercel/oidc": "4.0.8", + "convex": "1.49.0", + }, + }, + }, + "overrides": { + "xdg-app-paths": "5.5.1", + }, + "packages": { + "@convex-dev/batch-worker": ["@convex-dev/batch-worker@0.3.6", "", { "dependencies": { "convex-helpers": "^0.1.127" }, "peerDependencies": { "convex": "^1.43.0" } }, "sha512-tR+9DaHR3jG3oqkIFX0ok/6944h7UHEQgT6HTmiuxU+lERYuYMsxA2IWwFD5yTFbCpO3YJhqXU4QdGY90sgUqQ=="], + + "@convex-dev/workpool": ["@convex-dev/workpool@0.4.15", "", { "dependencies": { "@convex-dev/batch-worker": "^0.3.6" }, "peerDependencies": { "convex": "^1.43.0", "convex-helpers": "^0.1.94" } }, "sha512-eweNWj3nHnUpwT40S5qwtA/d9LbuVMXlBP6GqM5tE4+eAOkzWbudiiCz9bi1bBpFSjtnbdRfQ+PoBG/STqgj8A=="], + + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.27.0", "", { "os": "aix", "cpu": "ppc64" }, "sha512-KuZrd2hRjz01y5JK9mEBSD3Vj3mbCvemhT466rSuJYeE/hjuBrHfjjcjMdTm/sz7au+++sdbJZJmuBwQLuw68A=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.27.0", "", { "os": "android", "cpu": "arm" }, "sha512-j67aezrPNYWJEOHUNLPj9maeJte7uSMM6gMoxfPC9hOg8N02JuQi/T7ewumf4tNvJadFkvLZMlAq73b9uwdMyQ=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.27.0", "", { "os": "android", "cpu": "arm64" }, "sha512-CC3vt4+1xZrs97/PKDkl0yN7w8edvU2vZvAFGD16n9F0Cvniy5qvzRXjfO1l94efczkkQE6g1x0i73Qf5uthOQ=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.27.0", "", { "os": "android", "cpu": "x64" }, "sha512-wurMkF1nmQajBO1+0CJmcN17U4BP6GqNSROP8t0X/Jiw2ltYGLHpEksp9MpoBqkrFR3kv2/te6Sha26k3+yZ9Q=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.27.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-uJOQKYCcHhg07DL7i8MzjvS2LaP7W7Pn/7uA0B5S1EnqAirJtbyw4yC5jQ5qcFjHK9l6o/MX9QisBg12kNkdHg=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.27.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-8mG6arH3yB/4ZXiEnXof5MK72dE6zM9cDvUcPtxhUZsDjESl9JipZYW60C3JGreKCEP+p8P/72r69m4AZGJd5g=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.27.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-9FHtyO988CwNMMOE3YIeci+UV+x5Zy8fI2qHNpsEtSF83YPBmE8UWmfYAQg6Ux7Gsmd4FejZqnEUZCMGaNQHQw=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.27.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-zCMeMXI4HS/tXvJz8vWGexpZj2YVtRAihHLk1imZj4efx1BQzN76YFeKqlDr3bUWI26wHwLWPd3rwh6pe4EV7g=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.27.0", "", { "os": "linux", "cpu": "arm" }, "sha512-t76XLQDpxgmq2cNXKTVEB7O7YMb42atj2Re2Haf45HkaUpjM2J0UuJZDuaGbPbamzZ7bawyGFUkodL+zcE+jvQ=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.27.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-AS18v0V+vZiLJyi/4LphvBE+OIX682Pu7ZYNsdUHyUKSoRwdnOsMf6FDekwoAFKej14WAkOef3zAORJgAtXnlQ=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.27.0", "", { "os": "linux", "cpu": "ia32" }, "sha512-Mz1jxqm/kfgKkc/KLHC5qIujMvnnarD9ra1cEcrs7qshTUSksPihGrWHVG5+osAIQ68577Zpww7SGapmzSt4Nw=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.27.0", "", { "os": "linux", "cpu": "none" }, "sha512-QbEREjdJeIreIAbdG2hLU1yXm1uu+LTdzoq1KCo4G4pFOLlvIspBm36QrQOar9LFduavoWX2msNFAAAY9j4BDg=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.27.0", "", { "os": "linux", "cpu": "none" }, "sha512-sJz3zRNe4tO2wxvDpH/HYJilb6+2YJxo/ZNbVdtFiKDufzWq4JmKAiHy9iGoLjAV7r/W32VgaHGkk35cUXlNOg=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.27.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-z9N10FBD0DCS2dmSABDBb5TLAyF1/ydVb+N4pi88T45efQ/w4ohr/F/QYCkxDPnkhkp6AIpIcQKQ8F0ANoA2JA=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.27.0", "", { "os": "linux", "cpu": "none" }, "sha512-pQdyAIZ0BWIC5GyvVFn5awDiO14TkT/19FTmFcPdDec94KJ1uZcmFs21Fo8auMXzD4Tt+diXu1LW1gHus9fhFQ=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.27.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-hPlRWR4eIDDEci953RI1BLZitgi5uqcsjKMxwYfmi4LcwyWo2IcRP+lThVnKjNtk90pLS8nKdroXYOqW+QQH+w=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.27.0", "", { "os": "linux", "cpu": "x64" }, "sha512-1hBWx4OUJE2cab++aVZ7pObD6s+DK4mPGpemtnAORBvb5l/g5xFGk0vc0PjSkrDs0XaXj9yyob3d14XqvnQ4gw=="], + + "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.27.0", "", { "os": "none", "cpu": "arm64" }, "sha512-6m0sfQfxfQfy1qRuecMkJlf1cIzTOgyaeXaiVaaki8/v+WB+U4hc6ik15ZW6TAllRlg/WuQXxWj1jx6C+dfy3w=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.27.0", "", { "os": "none", "cpu": "x64" }, "sha512-xbbOdfn06FtcJ9d0ShxxvSn2iUsGd/lgPIO2V3VZIPDbEaIj1/3nBBe1AwuEZKXVXkMmpr6LUAgMkLD/4D2PPA=="], + + "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.27.0", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-fWgqR8uNbCQ/GGv0yhzttj6sU/9Z5/Sv/VGU3F5OuXK6J6SlriONKrQ7tNlwBrJZXRYk5jUhuWvF7GYzGguBZQ=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.27.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-aCwlRdSNMNxkGGqQajMUza6uXzR/U0dIl1QmLjPtRbLOx3Gy3otfFu/VjATy4yQzo9yFDGTxYDo1FfAD9oRD2A=="], + + "@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.27.0", "", { "os": "none", "cpu": "arm64" }, "sha512-nyvsBccxNAsNYz2jVFYwEGuRRomqZ149A39SHWk4hV0jWxKM0hjBPm3AmdxcbHiFLbBSwG6SbpIcUbXjgyECfA=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.27.0", "", { "os": "sunos", "cpu": "x64" }, "sha512-Q1KY1iJafM+UX6CFEL+F4HRTgygmEW568YMqDA5UV97AuZSm21b7SXIrRJDwXWPzr8MGr75fUZPV67FdtMHlHA=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.27.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-W1eyGNi6d+8kOmZIwi/EDjrL9nxQIQ0MiGqe/AWc6+IaHloxHSGoeRgDRKHFISThLmsewZ5nHFvGFWdBYlgKPg=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.27.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-30z1aKL9h22kQhilnYkORFYt+3wp7yZsHWus+wSKAJR8JtdfI76LJ4SBdMsCopTR3z/ORqVu5L1vtnHZWVj4cQ=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.27.0", "", { "os": "win32", "cpu": "x64" }, "sha512-aIitBcjQeyOhMTImhLZmtxfdOcuNRpwlPNmlFKPcHQYPhEssw75Cl1TSXJXpMkzaua9FUetx/4OQKq7eJul5Cg=="], + + "@vercel/cli-config": ["@vercel/cli-config@0.3.8", "", { "dependencies": { "xdg-app-paths": "5", "zod": "^4.6.6" } }, "sha512-C6av1p4tN+rHIcD0rdlsx3y9SaosRUU67dbgrjbLG8KdAK8oNVzfKg0ckV+1qWh5VC/Ft1BN3Pg/PuXSKNFVOA=="], + + "@vercel/cli-exec": ["@vercel/cli-exec@1.0.1", "", { "dependencies": { "execa": "5.1.1" } }, "sha512-g9XerViJ/paZujufXYcu5XYI2vU2rtB4sgdpjUHde5RnOkdmpu0ngH46LCFGHoPXO/C+qDPSczIHIRN+8Q2YKQ=="], + + "@vercel/oidc": ["@vercel/oidc@4.0.8", "", { "dependencies": { "@vercel/cli-config": "0.3.8", "@vercel/cli-exec": "1.0.1", "jose": "^5.9.6" } }, "sha512-8wcmhuhrEsQlgTvPfRIeE4Y2geSaid0a1DP+um1PfNK4ETjqnfGTL5k5l7vS2T8A2gOx/MV7yNGxUJTs+0tqPQ=="], + + "convex": ["convex@1.49.0", "", { "dependencies": { "esbuild": "0.27.0", "prettier": "^3.0.0", "ws": "8.21.0" }, "peerDependencies": { "@auth0/auth0-react": "^2.0.1", "@clerk/clerk-react": "^4.12.8 || ^5.0.0", "@clerk/react": "^6.4.3", "react": "^18.0.0 || ^19.0.0-0 || ^19.0.0" }, "optionalPeers": ["@auth0/auth0-react", "@clerk/clerk-react", "@clerk/react", "react"], "bin": { "convex": "bin/main.js" } }, "sha512-mkr9oXF8/arkCI1kvYyGytWd62oVXNABh4uwLeI4UQVN6Zuudm4DlmSzNUJKF63djk6f/uUXC+6ffuVSkPLvzA=="], + + "convex-helpers": ["convex-helpers@0.1.136", "", { "peerDependencies": { "@standard-schema/spec": "^1.0.0", "convex": "^1.46.0", "hono": "^4.0.5", "prettier": "^3.0.0", "react": "^17.0.2 || ^18.0.0 || ^19.0.0", "typescript": "^5.5 || ^6.0.0 || ^7.0.0", "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["@standard-schema/spec", "hono", "prettier", "react", "typescript", "zod"], "bin": { "convex-helpers": "dist/bin.cjs" } }, "sha512-GoveeoUdEyg0hpCNNAjAimgn4P3mx7f8Yy5oSISck9AquxfL3NbtQesUwhZLrDkCWasK2i1COjb7ZjQseonovA=="], + + "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], + + "esbuild": ["esbuild@0.27.0", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.0", "@esbuild/android-arm": "0.27.0", "@esbuild/android-arm64": "0.27.0", "@esbuild/android-x64": "0.27.0", "@esbuild/darwin-arm64": "0.27.0", "@esbuild/darwin-x64": "0.27.0", "@esbuild/freebsd-arm64": "0.27.0", "@esbuild/freebsd-x64": "0.27.0", "@esbuild/linux-arm": "0.27.0", "@esbuild/linux-arm64": "0.27.0", "@esbuild/linux-ia32": "0.27.0", "@esbuild/linux-loong64": "0.27.0", "@esbuild/linux-mips64el": "0.27.0", "@esbuild/linux-ppc64": "0.27.0", "@esbuild/linux-riscv64": "0.27.0", "@esbuild/linux-s390x": "0.27.0", "@esbuild/linux-x64": "0.27.0", "@esbuild/netbsd-arm64": "0.27.0", "@esbuild/netbsd-x64": "0.27.0", "@esbuild/openbsd-arm64": "0.27.0", "@esbuild/openbsd-x64": "0.27.0", "@esbuild/openharmony-arm64": "0.27.0", "@esbuild/sunos-x64": "0.27.0", "@esbuild/win32-arm64": "0.27.0", "@esbuild/win32-ia32": "0.27.0", "@esbuild/win32-x64": "0.27.0" }, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" } }, "sha512-jd0f4NHbD6cALCyGElNpGAOtWxSq46l9X/sWB0Nzd5er4Kz2YTm+Vl0qKFT9KUJvD8+fiO8AvoHhFvEatfVixA=="], + + "execa": ["execa@5.1.1", "", { "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", "human-signals": "^2.1.0", "is-stream": "^2.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^4.0.1", "onetime": "^5.1.2", "signal-exit": "^3.0.3", "strip-final-newline": "^2.0.0" } }, "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg=="], + + "get-stream": ["get-stream@6.0.1", "", {}, "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg=="], + + "human-signals": ["human-signals@2.1.0", "", {}, "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="], + + "is-stream": ["is-stream@2.0.1", "", {}, "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg=="], + + "isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="], + + "jose": ["jose@5.10.0", "", {}, "sha512-s+3Al/p9g32Iq+oqXxkW//7jk2Vig6FF1CFqzVXoTUXt2qz89YWbL+OwS17NFYEvxC35n0FKeGO2LGYSxeM2Gg=="], + + "merge-stream": ["merge-stream@2.0.0", "", {}, "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w=="], + + "mimic-fn": ["mimic-fn@2.1.0", "", {}, "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="], + + "npm-run-path": ["npm-run-path@4.0.1", "", { "dependencies": { "path-key": "^3.0.0" } }, "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw=="], + + "onetime": ["onetime@5.1.2", "", { "dependencies": { "mimic-fn": "^2.1.0" } }, "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg=="], + + "os-paths": ["os-paths@4.4.0", "", {}, "sha512-wrAwOeXp1RRMFfQY8Sy7VaGVmPocaLwSFOYCGKSyo8qmJ+/yaafCl5BCA1IQZWqFSRBrKDYFeR9d/VyQzfH/jg=="], + + "path-key": ["path-key@3.1.1", "", {}, "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q=="], + + "prettier": ["prettier@3.10.1", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-70vp3ZUYoPlFbF9uiTdXHUUCGEIp7d4+6p+8DYbkm2jP7x/3i/paXVF6dopSI3zd/CEitrZN1rc4i85xWmmXlg=="], + + "shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="], + + "shebang-regex": ["shebang-regex@3.0.0", "", {}, "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A=="], + + "signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="], + + "strip-final-newline": ["strip-final-newline@2.0.0", "", {}, "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA=="], + + "which": ["which@2.0.2", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "node-which": "./bin/node-which" } }, "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA=="], + + "ws": ["ws@8.21.0", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g=="], + + "xdg-app-paths": ["xdg-app-paths@5.5.1", "", { "dependencies": { "os-paths": "^4.0.1", "xdg-portable": "^7.2.0" } }, "sha512-hI3flOB4PLZIy5prbtTpirobtPE2ZtZ52szO+2mM9Efp6ErM398La+C1lIpNWDfNoQk+6Lsi6nMcCwVB7pxeMQ=="], + + "xdg-portable": ["xdg-portable@7.3.0", "", { "dependencies": { "os-paths": "^4.0.1" } }, "sha512-sqMMuL1rc0FmMBOzCpd0yuy9trqF2yTTVe+E9ogwCSWQCdDEtQUwrZPT6AxqtsFGRNxycgncbP/xmOOSPw5ZUw=="], + + "zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="], + } +} diff --git a/scripts/fixtures/dependency-baseline/package.json b/scripts/fixtures/dependency-baseline/package.json new file mode 100644 index 0000000000..ceaf47b7b9 --- /dev/null +++ b/scripts/fixtures/dependency-baseline/package.json @@ -0,0 +1,13 @@ +{ + "name": "clawhub-dependency-baseline", + "private": true, + "type": "module", + "dependencies": { + "@convex-dev/workpool": "0.4.15", + "@vercel/oidc": "4.0.8", + "convex": "1.49.0" + }, + "overrides": { + "xdg-app-paths": "5.5.1" + } +} diff --git a/scripts/fixtures/dependency-network-guard.mjs b/scripts/fixtures/dependency-network-guard.mjs new file mode 100644 index 0000000000..9a7b44033f --- /dev/null +++ b/scripts/fixtures/dependency-network-guard.mjs @@ -0,0 +1,49 @@ +import assert from "node:assert/strict"; +import childProcess from "node:child_process"; +import { lstatSync, readFileSync, realpathSync } from "node:fs"; +import http from "node:http"; +import https from "node:https"; +import net from "node:net"; +import { homedir } from "node:os"; +import { basename, join } from "node:path"; +import tls from "node:tls"; + +export function assertFixtureHome() { + const directory = process.env.CLAWHUB_DEPENDENCY_FIXTURE_HOME; + const nonce = process.env.CLAWHUB_DEPENDENCY_FIXTURE_NONCE; + assert.ok( + directory && /^[a-f0-9]{64}$/.test(nonce ?? ""), + "Run through the dependency fixture runner.", + ); + const home = realpathSync(directory); + assert.equal(realpathSync(homedir()), home, "Fixture HOME must match its declared directory."); + assert.equal(realpathSync(process.cwd()), home, "Fixture cwd must match its HOME."); + assert.ok(basename(home).startsWith("dependency-compat-"), "Unexpected fixture directory."); + const marker = join(home, ".clawhub-dependency-fixture"); + const info = lstatSync(marker); + assert.ok(info.isFile() && !info.isSymbolicLink(), "Missing fixture ownership marker."); + if (process.getuid) assert.equal(info.uid, process.getuid(), "Fixture marker has another owner."); + assert.equal(readFileSync(marker, "utf8"), nonce, "Fixture ownership marker mismatch."); +} + +export function rejectExternalIo(fetchFixture) { + let unexpected = 0; + const reject = () => { + unexpected++; + throw new Error("Unexpected network or subprocess in dependency fixture."); + }; + http.request = http.get = https.request = https.get = reject; + net.connect = net.createConnection = tls.connect = reject; + net.Socket.prototype.connect = reject; + childProcess.fork = reject; + childProcess.spawn = childProcess.spawnSync = reject; + childProcess.exec = childProcess.execSync = reject; + childProcess.execFile = childProcess.execFileSync = reject; + globalThis.fetch = async (...args) => { + const response = await fetchFixture?.(...args); + return response ?? reject(); + }; + return () => { + if (unexpected) throw new Error(`${unexpected} unexpected external operations.`); + }; +} diff --git a/scripts/fixtures/vercel-oidc-compat.mjs b/scripts/fixtures/vercel-oidc-compat.mjs new file mode 100644 index 0000000000..9950512aeb --- /dev/null +++ b/scripts/fixtures/vercel-oidc-compat.mjs @@ -0,0 +1,93 @@ +import assert from "node:assert/strict"; +import { mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { createRequire } from "node:module"; +import { homedir } from "node:os"; +import { dirname, join } from "node:path"; +import { assertFixtureHome, rejectExternalIo } from "./dependency-network-guard.mjs"; + +assertFixtureHome(); + +const [name, layout] = process.argv.slice(2); +const require = + name === "baseline" + ? createRequire(new URL("./dependency-baseline/package.json", import.meta.url)) + : createRequire(import.meta.url); +const oidcPath = require.resolve("@vercel/oidc"); +const oidcRequire = createRequire(oidcPath); +const configPath = oidcRequire.resolve("@vercel/cli-config"); +const configRequire = createRequire(configPath); +const xdgPath = configRequire.resolve("xdg-app-paths"); +function packageVersion(entry) { + let directory = dirname(entry); + for (;;) { + try { + return JSON.parse(readFileSync(join(directory, "package.json"), "utf8")).version; + } catch { + const parent = dirname(directory); + assert.notEqual(parent, directory); + directory = parent; + } + } +} +const versions = [packageVersion(oidcPath), packageVersion(configPath), packageVersion(xdgPath)]; +assert.deepEqual( + versions, + name === "baseline" ? ["4.0.8", "0.3.8", "5.5.1"] : ["4.0.9", "0.4.0", "5.1.0"], +); + +const dataHome = join(homedir(), "xdg-data"); +if (layout !== "legacy") process.env.XDG_DATA_HOME = dataHome; +const expectedConfig = + layout === "legacy" ? join(homedir(), ".now") : join(dataHome, "com.vercel.cli"); +mkdirSync(expectedConfig, { recursive: true }); +writeFileSync(join(expectedConfig, "auth.json"), JSON.stringify({ token: "fixture-vercel-token" })); +writeFileSync(join(expectedConfig, "config.json"), JSON.stringify({ credStorage: "file" })); +if (layout === "precedence") { + mkdirSync(join(homedir(), ".now")); + writeFileSync(join(homedir(), ".now/auth.json"), JSON.stringify({ token: "wrong-legacy-token" })); +} +const jwt = (tag) => + [ + "e30", + Buffer.from(JSON.stringify({ exp: 4_102_444_800, tag })).toString("base64url"), + "fixture", + ].join("."); +const fresh = jwt("fresh"); +let refreshes = 0; +const verifyIo = rejectExternalIo(async (url, init) => { + assert.equal( + String(url), + "https://api.vercel.com/v1/projects/fixture-project/token?source=vercel-oidc-refresh&teamId=fixture-team", + ); + assert.equal(init.method, "POST"); + assert.equal(init.headers.Authorization, "Bearer fixture-vercel-token"); + refreshes++; + return new Response(JSON.stringify({ token: fresh }), { status: 200 }); +}); +const { getGlobalPathConfig } = oidcRequire("@vercel/cli-config"); +assert.equal(getGlobalPathConfig(), expectedConfig); +const { getVercelOidcToken } = require("@vercel/oidc"); +process.env.VERCEL_OIDC_TOKEN = fresh; +assert.equal(await getVercelOidcToken(), fresh); +const requestToken = jwt("request"); +globalThis[Symbol.for("@vercel/request-context")] = { + get: () => ({ headers: { "x-vercel-oidc-token": requestToken } }), +}; +assert.equal(await getVercelOidcToken(), requestToken); +delete globalThis[Symbol.for("@vercel/request-context")]; +const fileToken = jwt("file"); +const tokenFile = join(homedir(), "fixture-oidc-token"); +writeFileSync(tokenFile, fileToken); +process.env.VERCEL_OIDC_TOKEN_FILE = tokenFile; +assert.equal(await getVercelOidcToken(), fileToken); +delete process.env.VERCEL_OIDC_TOKEN_FILE; +delete process.env.VERCEL_OIDC_TOKEN; +assert.equal(await getVercelOidcToken({ project: "fixture-project", team: "fixture-team" }), fresh); +assert.equal(refreshes, 1); +delete process.env.VERCEL_OIDC_TOKEN; +assert.equal(await getVercelOidcToken({ project: "fixture-project", team: "fixture-team" }), fresh); +assert.equal(refreshes, 1); +verifyIo(); +console.log( + JSON.stringify({ versions, layout, fresh: true, request: true, file: true, refresh: true }), +); diff --git a/scripts/playwright-local-convex.test.ts b/scripts/playwright-local-convex.test.ts index a6249b9a6e..12ebb5b711 100644 --- a/scripts/playwright-local-convex.test.ts +++ b/scripts/playwright-local-convex.test.ts @@ -2,15 +2,14 @@ import { spawn, type ChildProcess } from "node:child_process"; import { once } from "node:events"; -import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; import { get } from "node:http"; +import { createServer } from "node:net"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; import { expect, it } from "vitest"; -import { z } from "zod"; import type { LocalConvexBootstrapResult } from "./playwright-local-convex"; -// The fixture kills its listener between probes, so each request owns its socket. function probe(url: string): Promise { return new Promise((resolveBody, reject) => { const request = get(url, { agent: false }, (response) => { @@ -22,76 +21,211 @@ function probe(url: string): Promise { response.once("end", () => resolveBody(body)); response.once("error", reject); }); + request.setTimeout(500, () => request.destroy(new Error("Probe timed out."))); request.once("error", reject); }); } -it.skipIf(process.platform === "win32").each([ - { bootstrapExit: 0, disconnect: false }, - { bootstrapExit: 7, disconnect: false }, - { bootstrapExit: 0, disconnect: true }, -])("owns bootstrap descendants through cleanup: %j", async ({ bootstrapExit, disconnect }) => { +async function freePort() { + const server = createServer(); + server.listen(0, "127.0.0.1"); + await once(server, "listening"); + const address = server.address(); + if (!address || typeof address === "string") throw new Error("No fixture port."); + await new Promise((resolveClose) => server.close(() => resolveClose())); + return address.port; +} + +function nextMessage(owner: ChildProcess) { + return new Promise((resolveMessage, reject) => { + const timer = setTimeout(() => reject(new Error("No launcher result.")), 4_000); + owner.once("message", (result: LocalConvexBootstrapResult) => { + clearTimeout(timer); + resolveMessage(result); + }); + }); +} + +type FixtureOptions = { + bootstrapExit?: number; + leakedBootstrapBackend?: boolean; + backendMode?: "early-exit" | "wrong-instance"; + backendMissing?: boolean; + invalidConfig?: boolean; +}; + +async function fixture( + options: FixtureOptions, + check: (owner: ChildProcess, url: string) => Promise, +) { const directory = await mkdtemp(join(tmpdir(), "clawhub-backend-owner-")); - const serverPath = join(directory, "server.mjs"); - const addressPath = join(directory, "address.json"); let owner: ChildProcess | undefined; - let serverUrl: string | undefined; try { + const cloud = await freePort(); + let site = await freePort(); + while (site === cloud) site = await freePort(); + const version = "precompiled-test"; + const stateDir = join(directory, ".convex/local/default"); + const binaryDir = join(directory, ".cache/convex/binaries", version); + const binary = join(binaryDir, "convex-local-backend"); + await mkdir(stateDir, { recursive: true }); + await mkdir(binaryDir, { recursive: true }); + const config = { + deploymentName: "anonymous-fixture", + instanceSecret: "a".repeat(64), + backendVersion: options.invalidConfig ? "../wrong" : version, + ports: { cloud, site }, + }; + // Cover both Convex 1.50 cleanup and earlier CLIs that leaked a listener. await writeFile( - serverPath, - `import { createServer } from 'node:http'; + join(directory, "bunx"), + `#!/usr/bin/env node import { writeFileSync } from 'node:fs'; -const server = createServer((request, response) => { - response.end('alive'); - if (request.url === '/stop') server.close(() => process.exit(0)); -}); -server.listen(0, '127.0.0.1', () => { - writeFileSync(${JSON.stringify(addressPath)}, JSON.stringify({ port: server.address().port })); - process.stdout.write('ready'); -}); +import { spawn } from 'node:child_process'; +writeFileSync(${JSON.stringify(join(stateDir, "config.json"))}, ${JSON.stringify(JSON.stringify(config))}); +if (${Boolean(options.leakedBootstrapBackend)}) { + const child = spawn('node', [${JSON.stringify(binary)}, '--port', '${cloud}', '--instance-name', 'anonymous-fixture', '--instance-secret', '${"a".repeat(64)}'], { stdio: ['ignore', 'pipe', 'ignore'] }); + child.stdout.once('data', () => process.exit(${options.bootstrapExit ?? 0})); +} else process.exit(${options.bootstrapExit ?? 0}); `, + { mode: 0o755 }, ); - await writeFile( - join(directory, "bunx"), - `#!/usr/bin/env bun -import { spawn } from 'node:child_process'; -const backend = spawn(process.execPath, [${JSON.stringify(serverPath)}], { - stdio: ['ignore', 'pipe', 'ignore'], + if (!options.backendMissing) { + await writeFile( + binary, + `#!/usr/bin/env node +import { createServer } from 'node:http'; +const args = process.argv.slice(2); +const value = (flag) => { const index = args.indexOf(flag); return index < 0 ? undefined : args[index + 1]; }; +if (${JSON.stringify(options.backendMode)} === 'early-exit') process.exit(9); +if (value('--instance-secret') !== 'a'.repeat(64)) process.exit(8); +if (args.includes('--local-storage') && value('--interface') !== '127.0.0.1') process.exit(6); +if (args.includes('--local-storage') && (!args.includes('--disable-beacon') || process.env.SENTRY_DSN !== '')) process.exit(5); +const name = ${JSON.stringify(options.backendMode)} === 'wrong-instance' ? 'wrong' : value('--instance-name'); +const server = createServer((request, response) => { + response.end(name); + if (request.url === '/stop') server.close(() => process.exit(0)); }); -backend.stdout.once('data', () => process.exit(Number(process.argv[2]))); +setTimeout(() => server.listen(Number(value('--port')), value('--interface') ?? '127.0.0.1', () => process.stdout.write('ready')), 100); `, - { mode: 0o755 }, + { mode: 0o755 }, + ); + } + owner = spawn( + "bun", + [resolve("scripts/playwright-local-convex.ts"), "convex", "dev", "--skip-push"], + { + cwd: directory, + detached: true, + stdio: ["ignore", "pipe", "pipe", "ipc"], + env: { + ...process.env, + HOME: directory, + PATH: `${directory}:${process.env.PATH}`, + VITE_CONVEX_URL: `http://127.0.0.1:${cloud}`, + VITE_CONVEX_SITE_URL: `http://127.0.0.1:${site}`, + PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION: version, + PLAYWRIGHT_WEB_SERVER_TIMEOUT_MS: "2000", + }, + }, ); + let diagnostics = ""; + owner.stdout?.on("data", (data) => { + diagnostics += String(data); + }); + owner.stderr?.on("data", (data) => { + diagnostics += String(data); + }); + try { + await check(owner, `http://127.0.0.1:${cloud}`); + } catch (error) { + throw new Error(diagnostics, { cause: error }); + } + } finally { + if (owner?.pid && owner.exitCode === null && owner.signalCode === null) { + // Let the owner terminate its detached bootstrap group before forcing it down. + if (owner.connected) owner.disconnect(); + let timer: ReturnType | undefined; + try { + await Promise.race([ + once(owner, "exit"), + new Promise((resolveTimeout) => { + timer = setTimeout(resolveTimeout, 5_500); + }), + ]); + } finally { + clearTimeout(timer); + } + if (owner.exitCode === null && owner.signalCode === null) { + const exited = once(owner, "exit"); + process.kill(-owner.pid, "SIGKILL"); + await exited; + } + } + await rm(directory, { recursive: true, force: true }); + } +} - owner = spawn("bun", [resolve("scripts/playwright-local-convex.ts"), String(bootstrapExit)], { - detached: true, - stdio: ["ignore", "pipe", "pipe", "ipc"], - env: { ...process.env, PATH: `${directory}:${process.env.PATH}` }, +it.skipIf(process.platform === "win32").each([false, true])( + "owns its backend after bootstrap exits (leaked: %j)", + async (leakedBootstrapBackend) => { + await fixture({ leakedBootstrapBackend }, async (owner, url) => { + expect(await nextMessage(owner)).toEqual({ status: "ready" }); + expect(await probe(`${url}/instance_name`)).toBe("anonymous-fixture"); + expect(owner.exitCode).toBeNull(); + process.kill(-owner.pid!, "SIGTERM"); + await expect + .poll(() => + probe(url).then( + () => true, + () => false, + ), + ) + .toBe(false); + // Keep the leader alive so the runner can kill any remaining descendants. + expect(owner.exitCode).toBeNull(); }); - const bootstrapOwner = owner; - const result = await new Promise((resolveResult, reject) => { - bootstrapOwner.once("error", reject); - bootstrapOwner.once("exit", () => - reject(new Error("Owner exited before reporting bootstrap")), - ); - bootstrapOwner.once("message", resolveResult); + }, +); + +it + .skipIf(process.platform === "win32") + .each([ + { bootstrapExit: 7 }, + { bootstrapExit: 7, leakedBootstrapBackend: true }, + { backendMode: "early-exit" as const }, + { backendMode: "wrong-instance" as const }, + { backendMissing: true }, + { invalidConfig: true }, + ])("does not report a failed backend as ready: %j", async (options) => { + await fixture(options, async (owner) => { + expect((await nextMessage(owner)).status).toBe("error"); + }); +}); + +it.skipIf(process.platform === "win32")( + "reports an unexpected backend exit after readiness", + async () => { + await fixture({}, async (owner, url) => { + expect((await nextMessage(owner)).status).toBe("ready"); + const failure = nextMessage(owner); + await probe(`${url}/stop`); + expect(await failure).toEqual({ + status: "error", + message: "Local Convex backend exited with code 0.", + }); }); - expect(result.status).toBe(bootstrapExit === 0 ? "ready" : "error"); - const { port } = z - .object({ port: z.number() }) - .parse(JSON.parse(await readFile(addressPath, "utf8"))); - const url = `http://127.0.0.1:${port}`; - serverUrl = url; - expect(await probe(url)).toBe("alive"); - expect(owner.exitCode).toBeNull(); + }, +); - if (disconnect) { +it.skipIf(process.platform === "win32")( + "cleans up its backend when the runner disconnects", + async () => { + await fixture({}, async (owner, url) => { + expect((await nextMessage(owner)).status).toBe("ready"); const exited = once(owner, "exit"); owner.disconnect(); await exited; - } else { - if (!owner.pid) throw new Error("Owner did not start"); - process.kill(-owner.pid, "SIGTERM"); await expect .poll(() => probe(url).then( @@ -100,27 +234,7 @@ backend.stdout.once('data', () => process.exit(Number(process.argv[2]))); ), ) .toBe(false); - expect(owner.exitCode).toBeNull(); - expect(owner.signalCode).toBeNull(); - const exited = once(owner, "exit"); - process.kill(-owner.pid, "SIGKILL"); - await exited; - } - await expect - .poll(() => - probe(url).then( - () => true, - () => false, - ), - ) - .toBe(false); - } finally { - if (serverUrl) await probe(`${serverUrl}/stop`).catch(() => {}); - if (owner?.pid && owner.exitCode === null && owner.signalCode === null) { - const exited = once(owner, "exit"); - process.kill(-owner.pid, "SIGKILL"); - await exited; - } - await rm(directory, { recursive: true, force: true }); - } -}); + }); + }, + 10_000, +); diff --git a/scripts/playwright-local-convex.ts b/scripts/playwright-local-convex.ts index d698893476..bd8ae94279 100644 --- a/scripts/playwright-local-convex.ts +++ b/scripts/playwright-local-convex.ts @@ -1,31 +1,180 @@ -import { spawn } from "node:child_process"; +import { spawn, type ChildProcess } from "node:child_process"; +import { accessSync, constants, lstatSync, readFileSync } from "node:fs"; +import { homedir } from "node:os"; +import { join, resolve } from "node:path"; export type LocalConvexBootstrapResult = { status: "ready" } | { status: "error"; message: string }; if (!process.send) throw new Error("Local Convex requires its runner's IPC channel."); const send = process.send.bind(process); -// Keep the process-group leader alive after Convex's one-shot bootstrap exits. +// Retain the group leader until the runner finishes killing owned descendants. process.on("message", () => {}); -process.on("SIGTERM", () => {}); -process.on("SIGINT", () => {}); +let bootstrap: ChildProcess | undefined; +let backend: ChildProcess | undefined; +let stopping = false; + +function signalBootstrap(signal: NodeJS.Signals) { + if (!bootstrap?.pid) return; + try { + process.kill(-bootstrap.pid, signal); + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== "ESRCH") throw error; + } +} + +function stop() { + if (stopping) return; + stopping = true; + signalBootstrap("SIGTERM"); + backend?.kill("SIGTERM"); + // The runner force-kills this group after five seconds; bootstrap has its own group. + setTimeout(() => signalBootstrap("SIGKILL"), 4_000); +} +process.on("SIGTERM", stop); +process.on("SIGINT", stop); process.on("disconnect", () => { + stop(); process.kill(-process.pid, "SIGTERM"); - setTimeout(() => process.kill(-process.pid, "SIGKILL"), 5_000); + setTimeout(() => { + signalBootstrap("SIGKILL"); + process.kill(-process.pid, "SIGKILL"); + }, 5_000); }); -const bootstrap = spawn("bunx", process.argv.slice(2), { stdio: "inherit" }); function report(result: LocalConvexBootstrapResult) { if (process.connected) send(result); } -bootstrap.once("error", (error) => report({ status: "error", message: error.message })); -bootstrap.once("exit", (code, signal) => { - report( - code === 0 - ? { status: "ready" } - : { - status: "error", - message: `Local Convex bootstrap exited with ${signal ?? `code ${code}`}.`, - }, + +const sleep = (ms: number) => new Promise((resolveSleep) => setTimeout(resolveSleep, ms)); + +async function probe(url: string) { + try { + const response = await fetch(new URL("/instance_name", url), { + signal: AbortSignal.timeout(1_000), + }); + return { reachable: true, name: response.ok ? await response.text() : null }; + } catch { + return { reachable: false, name: null }; + } +} + +async function main() { + // Give bootstrap its own group so older CLIs cannot leave an orphan backend. + bootstrap = spawn("bunx", process.argv.slice(2), { detached: true, stdio: "inherit" }); + await new Promise((resolveBootstrap, reject) => { + bootstrap!.once("error", () => reject(new Error("Local Convex bootstrap could not start."))); + bootstrap!.once("exit", (code, signal) => { + if (code === 0) resolveBootstrap(); + else reject(new Error(`Local Convex bootstrap exited with ${signal ?? `code ${code}`}.`)); + }); + }); + if (stopping) return; + + const stateDir = resolve(".convex/local/default"); + const config = JSON.parse(readFileSync(join(stateDir, "config.json"), "utf8")) as { + backendVersion?: unknown; + deploymentName?: unknown; + instanceSecret?: unknown; + ports?: { cloud?: unknown; site?: unknown }; + } | null; + const version = config?.backendVersion; + const name = config?.deploymentName; + const secret = config?.instanceSecret; + const cloud = config?.ports?.cloud; + const site = config?.ports?.site; + const url = new URL(process.env.VITE_CONVEX_URL ?? ""); + const siteUrl = new URL(process.env.VITE_CONVEX_SITE_URL ?? ""); + const isLoopback = (value: URL) => + value.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(value.hostname); + if ( + typeof version !== "string" || + !/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(version) || + (process.env.PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION && + version !== process.env.PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION) || + typeof name !== "string" || + !/^[a-zA-Z0-9_-]+$/.test(name) || + typeof secret !== "string" || + !/^[a-fA-F0-9]{64}$/.test(secret) || + typeof cloud !== "number" || + !Number.isInteger(cloud) || + cloud < 1 || + cloud > 65_535 || + typeof site !== "number" || + !Number.isInteger(site) || + site < 1 || + site > 65_535 || + cloud === site || + !isLoopback(url) || + url.port !== String(cloud) || + !isLoopback(siteUrl) || + siteUrl.port !== String(site) + ) { + throw new Error("Local Convex bootstrap produced an invalid or mismatched configuration."); + } + // Convex 1.50 cleans up after --skip-push; earlier CLIs leaked the backend. + signalBootstrap("SIGTERM"); + const stopDeadline = Date.now() + 5_000; + while ((await probe(url.href)).reachable && Date.now() < stopDeadline) await sleep(50); + signalBootstrap("SIGKILL"); + if ((await probe(url.href)).reachable) { + throw new Error("Local Convex bootstrap did not release its port."); + } + if (stopping) return; + + const binary = join(homedir(), ".cache/convex/binaries", version, "convex-local-backend"); + if (!lstatSync(binary).isFile()) throw new Error("Local Convex backend must be a regular file."); + accessSync(binary, constants.X_OK); + backend = spawn( + binary, + [ + "--interface", + "127.0.0.1", + "--disable-beacon", + "--port", + String(cloud), + "--site-proxy-port", + String(site), + "--instance-name", + name, + "--instance-secret", + secret, + "--local-storage", + join(stateDir, "convex_local_storage"), + join(stateDir, "convex_local_backend.sqlite3"), + ], + { stdio: "inherit", env: { ...process.env, SENTRY_DSN: "" } }, ); + let failure: Error | undefined; + let backendReady = false; + backend.once("error", () => { + failure = new Error("Local Convex backend could not start."); + if (backendReady && !stopping) report({ status: "error", message: failure.message }); + }); + backend.once("exit", (code, signal) => { + failure = new Error(`Local Convex backend exited with ${signal ?? `code ${code}`}.`); + if (backendReady && !stopping) report({ status: "error", message: failure.message }); + }); + const deadline = Date.now() + Number(process.env.PLAYWRIGHT_WEB_SERVER_TIMEOUT_MS ?? 300_000); + while (!stopping && Date.now() < deadline) { + if (failure) throw failure; + const result = await probe(url.href); + if (failure) throw failure; + if (result.reachable) { + if (result.name !== name) + throw new Error("Unexpected local Convex instance on the selected port."); + backendReady = true; + report({ status: "ready" }); + return; + } + await sleep(50); + } + if (!stopping) throw new Error("Local Convex backend did not become ready before the deadline."); +} + +void main().catch((error: unknown) => { + signalBootstrap("SIGKILL"); + if (!stopping) { + report({ status: "error", message: error instanceof Error ? error.message : String(error) }); + } }); diff --git a/scripts/run-local-component-upgrade.ts b/scripts/run-local-component-upgrade.ts new file mode 100644 index 0000000000..50fe577a22 --- /dev/null +++ b/scripts/run-local-component-upgrade.ts @@ -0,0 +1,775 @@ +#!/usr/bin/env bun +import assert from "node:assert/strict"; +import { spawn, spawnSync, type ChildProcess } from "node:child_process"; +import { createHash, generateKeyPairSync } from "node:crypto"; +import { once } from "node:events"; +import { + chmodSync, + copyFileSync, + existsSync, + lstatSync, + mkdirSync, + readFileSync, + readdirSync, + realpathSync, + renameSync, + rmSync, + statSync, + writeFileSync, +} from "node:fs"; +import { createServer } from "node:net"; +import { dirname, join, relative, resolve } from "node:path"; +import { BaseConvexClient, ConvexHttpClient } from "convex/browser"; +import { makeFunctionReference, type UserIdentityAttributes } from "convex/server"; +import type { Value } from "convex/values"; +import ts from "typescript"; + +type ObservedRow = { + _id: string; + workId: string; + maxParallelism: number; + retry: boolean; + runResult: { kind: string; error: string; errorData?: Value }; +}; + +const root = process.cwd(); +const capsule = join(root, ".artifacts/component-upgrade"); +const home = join(capsule, "fixture-home"); +const packageCache = join(root, ".artifacts/component-upgrade-cache"); +const backendVersion = "precompiled-2026-10-22-1447815"; +const cloud = 43220; +const site = 43221; +const url = `http://127.0.0.1:${cloud}`; +const siteUrl = `http://127.0.0.1:${site}`; +const templates = join(root, "scripts/fixtures/component-upgrade"); +let owner: ChildProcess | undefined; +let ownCapsule = false; +let passed = false; +const baseEnv: NodeJS.ProcessEnv = { + PATH: process.env.PATH, + HOME: home, + BUN_INSTALL_CACHE_DIR: packageCache, + TMPDIR: "/tmp", + LANG: "en_US.UTF-8", + CI: "1", + CONVEX_AGENT_MODE: "anonymous", + VITE_CONVEX_URL: url, + VITE_CONVEX_SITE_URL: siteUrl, + PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION: backendVersion, + PLAYWRIGHT_WEB_SERVER_TIMEOUT_MS: "180000", +}; +const digest = (bytes: string | Buffer) => createHash("sha256").update(bytes).digest("hex"); + +async function command(args: string[], cwd = capsule) { + const child = spawn(args[0]!, args.slice(1), { + cwd, + env: baseEnv, + detached: true, + stdio: ["ignore", "pipe", "pipe"], + }); + let output = ""; + for (const stream of [child.stdout, child.stderr]) + stream.on("data", (chunk) => { + output = (output + chunk).slice(-100_000); + }); + const timer = setTimeout(() => { + if (child.pid) process.kill(-child.pid, "SIGTERM"); + }, 180_000); + const force = setTimeout(() => { + if (child.pid) process.kill(-child.pid, "SIGKILL"); + }, 185_000); + let code: number | null; + try { + [code] = await once(child, "exit"); + } finally { + clearTimeout(timer); + clearTimeout(force); + } + if (code !== 0) + throw new Error( + `Fixture command failed (${args.slice(0, 3).join(" ")}): ${output.slice(-4_000)}`, + ); + return output; +} + +function baselineManifest(text: string) { + const manifest = JSON.parse(text); + for (const section of ["dependencies", "devDependencies"]) { + if (manifest[section]?.convex === "1.50.0") manifest[section].convex = "1.49.0"; + if (manifest[section]?.["@convex-dev/workpool"] === "0.4.16") + manifest[section]["@convex-dev/workpool"] = "0.4.15"; + } + return JSON.stringify(manifest, null, 2) + "\n"; +} + +function copiedSource(verify = false, deployed = false) { + const listed = spawnSync("git", ["ls-files", "-z"], { cwd: root, encoding: "utf8" }); + assert.equal(listed.status, 0); + const tracked = listed.stdout.split("\0").filter(Boolean); + const manifests = tracked.filter((file) => /^packages\/[^/]+\/package\.json$/.test(file)); + const selected = new Set([ + "package.json", + "bun.lock", + "tsconfig.json", + "convex/tsconfig.json", + ...manifests, + ]); + for (const file of ["convex.json", "bunfig.toml"]) + if (existsSync(join(root, file))) selected.add(file); + const rootManifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8")); + for (const file of Object.values(rootManifest.patchedDependencies ?? {})) { + assert.equal(typeof file, "string"); + selected.add(file as string); + } + const queue = tracked.filter( + (file) => + file.startsWith("convex/") && + /\.[cm]?[jt]s$/.test(file) && + !/\.test\.|\/__tests__\//.test(file), + ); + const addRelative = (file: string, specifier: string) => { + const base = specifier.startsWith("@/") + ? join(root, "src", specifier.slice(2)) + : resolve(root, dirname(file), specifier); + assert.ok(base.startsWith(root + "/"), "Source import escaped the checkout."); + const candidates = [ + base, + ...[".ts", ".tsx", ".js", ".json", ".d.ts", "/index.ts", "/index.tsx", "/index.js"].map( + (suffix) => base + suffix, + ), + ]; + if (base.endsWith(".js")) + candidates.push(base.slice(0, -3) + ".ts", base.slice(0, -3) + ".d.ts"); + const source = candidates.find( + (candidate) => existsSync(candidate) && statSync(candidate).isFile(), + ); + assert.ok(source, `Unresolved source import: ${file} -> ${specifier}`); + queue.push(relative(root, source)); + }; + // Preserve the generated local schema package consumed by Convex imports. + for (const file of tracked.filter( + (path) => path.startsWith("packages/schema/src/") && !path.includes(".test."), + )) + queue.push(file); + if (existsSync(join(root, "packages/schema/dist"))) { + const visit = (directory: string) => { + for (const entry of readdirSync(join(root, directory), { withFileTypes: true })) { + const file = join(directory, entry.name); + if (entry.isDirectory()) visit(file); + else if (entry.isFile()) selected.add(file); + else throw new Error("Schema artifact must not contain symlinks."); + } + }; + visit("packages/schema/dist"); + } + while (queue.length) { + const file = queue.pop()!; + if (selected.has(file)) continue; + selected.add(file); + // Local push regenerates declaration imports; stale type-only edges are not runtime closure. + if (file.endsWith(".d.ts")) continue; + const code = readFileSync(join(root, file), "utf8"); + for (const imported of ts.preProcessFile(code, true, true).importedFiles) { + if (imported.fileName.startsWith(".") || imported.fileName.startsWith("@/")) + addRelative(file, imported.fileName); + } + } + const sourceHash = createHash("sha256"); + for (const file of [...selected].sort()) { + assert.ok( + !file + .split("/") + .some((part) => part.startsWith(".env") || part === ".convex" || part === ".git"), + ); + const bytes = readFileSync(join(root, file)); + sourceHash.update(file + "\0").update(bytes); + if (verify) { + // Codegen owns these five derived files once baseline functions have been pushed. + if (deployed && /^convex\/_generated\/(api|server|dataModel)\.(js|d\.ts)$/.test(file)) + continue; + if (file === "bun.lock") continue; // Checked semantically below against the two permitted package changes. + if (file === "package.json" || manifests.includes(file)) { + assert.equal(readFileSync(join(capsule, file), "utf8"), baselineManifest(bytes.toString())); + } else { + const stored = + file === "convex/schema.ts" ? "convex/_dependencyUpgradeOriginalSchema.ts" : file; + assert.ok( + readFileSync(join(capsule, stored)).equals(bytes), + `Changed prepared source: ${file}`, + ); + } + } else { + mkdirSync(dirname(join(capsule, file)), { recursive: true }); + writeFileSync(join(capsule, file), bytes); + } + } + return { + manifests: ["package.json", ...manifests], + sourceHash: sourceHash.digest("hex"), + files: selected.size, + }; +} + +function packageProof(directory = capsule) { + // Use package paths directly: Bun honors the invoking checkout's tsconfig aliases. + const convex = realpathSync(join(directory, "node_modules/convex")); + const workpool = realpathSync(join(directory, "node_modules/@convex-dev/workpool")); + const manifest = JSON.parse(readFileSync(join(workpool, "package.json"), "utf8")); + assert.ok( + convex.startsWith(directory + "/") && workpool.startsWith(directory + "/"), + "Fixture packages must be capsule-owned.", + ); + const hash = createHash("sha256"); + const visit = (directory: string) => { + for (const name of readdirSync(join(workpool, directory)).sort()) { + const file = join(directory, name); + if (statSync(join(workpool, file)).isDirectory()) visit(file); + else hash.update(file + "\0").update(readFileSync(join(workpool, file))); + } + }; + visit("src"); + return { + convex: JSON.parse(readFileSync(join(convex, "package.json"), "utf8")).version, + workpool: manifest.version, + cliSha256: digest(readFileSync(join(convex, "dist/cli.bundle.cjs"))), + workpoolSourceSha256: hash.digest("hex"), + }; +} + +async function freePort(port: number) { + const server = createServer(); + server.listen(port, "127.0.0.1"); + await once(server, "listening"); + await new Promise((done) => server.close(() => done())); +} + +async function startBackend() { + owner = spawn( + "bun", + [ + join(root, "scripts/playwright-local-convex.ts"), + "convex", + "dev", + "--skip-push", + "--typecheck", + "disable", + "--codegen", + "disable", + "--local-cloud-port", + String(cloud), + "--local-site-port", + String(site), + "--local-backend-version", + backendVersion, + ], + { + cwd: capsule, + env: baseEnv, + detached: true, + stdio: ["ignore", "pipe", "pipe", "ipc"], + }, + ); + let tail = ""; + for (const stream of [owner.stdout!, owner.stderr!]) + stream.on("data", (chunk) => { + tail = (tail + chunk).slice(-4_000); + }); + await new Promise((done, fail) => { + const finish = (error?: Error) => { + clearTimeout(timer); + owner!.off("message", message); + owner!.off("error", finish); + owner!.off("exit", exited); + if (error) fail(error); + else done(); + }; + const message = (value: { status: string; message?: string }) => + finish(value.status === "ready" ? undefined : new Error(value.message ?? tail)); + const exited = () => finish(new Error("Local backend owner exited.")); + const timer = setTimeout(() => finish(new Error("Local backend bootstrap timeout.")), 180_000); + owner!.on("message", message); + owner!.once("error", finish); + owner!.once("exit", exited); + }); +} + +async function stopBackend() { + if (!owner?.pid || owner.exitCode !== null || owner.signalCode !== null) return; + if (owner.connected) owner.disconnect(); + let timer: ReturnType | undefined; + await Promise.race([ + once(owner, "exit"), + new Promise((done) => { + timer = setTimeout(done, 6_000); + }), + ]); + clearTimeout(timer); + if (owner.exitCode === null && owner.signalCode === null) { + const exited = once(owner, "exit"); + process.kill(-owner.pid, "SIGKILL"); + await exited; + } +} + +async function waitFor( + read: () => Promise, + ready: (value: T) => boolean, + label: string, +): Promise { + const deadline = Date.now() + 120_000; + while (Date.now() < deadline) { + const value = await read(); + if (ready(value)) return value; + await new Promise((done) => setTimeout(done, 100)); + } + throw new Error(`Timed out observing ${label}.`); +} + +async function main() { + assert.ok(process.argv.includes("--run"), "Use --run for the owned local upgrade fixture."); + const pausedHash = process.argv.find((arg) => arg.startsWith("--resume-paused="))?.split("=")[1]; + const seededHash = process.argv.find((arg) => arg.startsWith("--resume-seeded="))?.split("=")[1]; + const resumeHash = + pausedHash ?? + seededHash ?? + process.argv.find((arg) => arg.startsWith("--resume-pre-push="))?.split("=")[1]; + if (resumeHash) { + assert.match(resumeHash, /^[a-f0-9]{64}$/); + assert.equal(realpathSync(capsule), join(realpathSync(root), ".artifacts/component-upgrade")); + assert.equal( + readFileSync(join(capsule, ".fixture-owner"), "utf8"), + "clawhub-local-component-upgrade\n", + ); + assert.equal(statSync(capsule).uid, process.getuid?.()); + } else { + assert.ok(!existsSync(capsule), "Existing fixture capsule is not disposable by inference."); + } + if (!existsSync(packageCache)) mkdirSync(packageCache, { recursive: true, mode: 0o700 }); + const cacheInfo = lstatSync(packageCache); + assert.ok(cacheInfo.isDirectory() && !cacheInfo.isSymbolicLink()); + assert.equal( + realpathSync(packageCache), + join(realpathSync(root), ".artifacts/component-upgrade-cache"), + ); + if (process.getuid) assert.equal(cacheInfo.uid, process.getuid()); + await freePort(cloud); + await freePort(site); + if (!resumeHash) mkdirSync(capsule, { recursive: true }); + ownCapsule = true; + const inputs = copiedSource(Boolean(resumeHash), Boolean(seededHash || pausedHash)); + if (resumeHash) assert.equal(inputs.sourceHash, resumeHash); + const cachedBinary = join( + root, + ".artifacts/native-home/.cache/convex/binaries", + backendVersion, + "convex-local-backend", + ); + assert.equal( + realpathSync(cachedBinary), + join(realpathSync(root), relative(root, cachedBinary)), + "Cached backend path must not escape through symlinks.", + ); + const binaryInfo = lstatSync(cachedBinary); + assert.ok(binaryInfo.isFile() && !binaryInfo.isSymbolicLink()); + if (process.getuid) assert.equal(binaryInfo.uid, process.getuid()); + const binarySha256 = digest(readFileSync(cachedBinary)); + const localBinary = join(home, ".cache/convex/binaries", backendVersion, "convex-local-backend"); + if (resumeHash) { + assert.equal(realpathSync(home), join(realpathSync(capsule), "fixture-home")); + assert.equal(digest(readFileSync(localBinary)), binarySha256); + } else { + mkdirSync(home, { mode: 0o700 }); + mkdirSync(dirname(localBinary), { recursive: true }); + copyFileSync(cachedBinary, localBinary); + chmodSync(localBinary, 0o700); + } + if (!resumeHash) + writeFileSync(join(capsule, ".fixture-owner"), "clawhub-local-component-upgrade\n", { + mode: 0o600, + }); + const original = new Map( + inputs.manifests.map((file) => [file, readFileSync(join(root, file), "utf8")]), + ); + const candidateLock = readFileSync(join(root, "bun.lock")); + if (resumeHash) { + assert.ok( + readFileSync(join(capsule, "convex/schema.ts")).equals( + readFileSync(join(templates, "schema.ts.txt")), + ), + ); + assert.ok( + readFileSync(join(capsule, "convex/dependencyUpgradeFixtures.ts")).equals( + readFileSync(join(templates, "app.ts.txt")), + ), + ); + } else { + for (const [file, text] of original) writeFileSync(join(capsule, file), baselineManifest(text)); + renameSync( + join(capsule, "convex/schema.ts"), + join(capsule, "convex/_dependencyUpgradeOriginalSchema.ts"), + ); + writeFileSync( + join(capsule, "convex/schema.ts"), + readFileSync(join(templates, "schema.ts.txt")), + ); + writeFileSync( + join(capsule, "convex/dependencyUpgradeFixtures.ts"), + readFileSync(join(templates, "app.ts.txt")), + ); + await command(["bun", "install", "--ignore-scripts"]); + } + const parseLock = (text: string) => ts.parseConfigFileTextToJson("bun.lock", text).config; + const oldLock = parseLock(readFileSync(join(capsule, "bun.lock"), "utf8")); + const nextLock = parseLock(candidateLock.toString()); + const changed = [ + ...new Set([...Object.keys(oldLock.packages), ...Object.keys(nextLock.packages)]), + ] + .filter( + (key) => JSON.stringify(oldLock.packages[key]) !== JSON.stringify(nextLock.packages[key]), + ) + .sort(); + assert.deepEqual(changed, ["@convex-dev/workpool", "convex"]); + const baseline = packageProof(); + assert.equal(baseline.convex, "1.49.0"); + assert.equal(baseline.workpool, "0.4.15"); + assert.deepEqual(baseline, packageProof(join(root, "scripts/fixtures/dependency-baseline"))); + console.log( + JSON.stringify({ + phase: "baseline", + target: url, + backendVersion, + binarySha256, + inputs, + packages: baseline, + }), + ); + const database = join(capsule, ".convex/local/default/convex_local_backend.sqlite3"); + const databaseInode = resumeHash ? statSync(database).ino : undefined; + await startBackend(); + if (resumeHash) + assert.equal(statSync(database).ino, databaseInode, "Existing database was replaced."); + const config = JSON.parse( + readFileSync(join(capsule, ".convex/local/default/config.json"), "utf8"), + ); + assert.equal(config.backendVersion, backendVersion); + assert.equal(config.ports.cloud, cloud); + assert.equal(config.ports.site, site); + const deployment = `anonymous:${config.deploymentName}`; + // Explicit self-hosted credentials prevent cloud deployment lookup or CLI-owned backend restart. + const cliEnv = join(capsule, ".fixture-cli.env"); + assert.equal(typeof config.adminKey, "string"); + assert.ok(!/[\r\n]/.test(config.adminKey)); + writeFileSync( + cliEnv, + `CONVEX_SELF_HOSTED_URL=${url}\nCONVEX_SELF_HOSTED_ADMIN_KEY=${config.adminKey}\n`, + { mode: 0o600 }, + ); + if (resumeHash && !seededHash && !pausedHash) { + const tables = await command(["bunx", "convex", "data", "--env-file", cliEnv]); + assert.equal( + tables.trim(), + "There are no tables in the database.", + "Only a pre-push database can resume.", + ); + } + // The published runtime supports admin auth; it is intentionally absent from public SDK types. + const client = new ConvexHttpClient(url) as ConvexHttpClient & { + setAdminAuth: (key: string, identity?: UserIdentityAttributes) => void; + }; + client.setAdminAuth(config.adminKey); + const { publicKey, privateKey } = generateKeyPairSync("rsa", { modulusLength: 2048 }); + const changes = { + CLAWHUB_DISABLE_CRONS: "1", + DEV_AUTH_ENABLED: "1", + DEV_AUTH_CONVEX_DEPLOYMENT: deployment, + AUTH_GITHUB_ID: "local-fixture", + AUTH_GITHUB_SECRET: "local-fixture", + SITE_URL: "http://127.0.0.1:43222", + CLAWHUB_SKILLS_SH_ROLLOUT_MODE: "test", + JWT_PRIVATE_KEY: privateKey + .export({ type: "pkcs8", format: "pem" }) + .toString() + .trimEnd() + .replace(/\n/g, " "), + JWKS: JSON.stringify({ keys: [{ use: "sig", ...publicKey.export({ format: "jwk" }) }] }), + }; + const envResponse = await fetch(new URL("/api/update_environment_variables", url), { + method: "POST", + headers: { Authorization: `Convex ${config.adminKey}`, "Content-Type": "application/json" }, + body: JSON.stringify({ + changes: Object.entries(changes).map(([name, value]) => ({ name, value })), + }), + }); + assert.ok(envResponse.ok, "Local environment setup failed."); + const push = () => + command([ + "bunx", + "convex", + "run", + "--push", + "--env-file", + cliEnv, + "--inline-query", + "null", + "--typecheck", + "disable", + ]); + const rows = async (table: string): Promise => { + // Match the published CLI: system queries use a component-scoped WebSocket subscription. + let receive: (value: Value) => void; + let reject: (error: unknown) => void; + const result = new Promise((resolveResult, rejectResult) => { + receive = resolveResult; + reject = rejectResult; + }); + const system = new BaseConvexClient( + url, + (tokens) => { + for (const token of tokens) { + try { + const value = system.localQueryResultByToken(token); + if (value !== undefined) receive(value); + } catch (error) { + reject(error); + } + } + }, + { webSocketConstructor: WebSocket, unsavedChangesWarning: false }, + ) as BaseConvexClient & { + setAdminAuth: (key: string) => void; + localQueryResultByToken: (token: string) => Value | undefined; + subscribe: ( + name: string, + args: Record, + options: { componentPath: string }, + ) => { unsubscribe: () => void }; + }; + let subscription: { unsubscribe: () => void } | undefined; + let timer: ReturnType | undefined; + try { + system.setAdminAuth(config.adminKey); + subscription = system.subscribe( + "_system/cli/tableData", + { + table, + order: "asc", + paginationOpts: { cursor: null, numItems: 10 }, + }, + { componentPath: "searchReports" }, + ); + timer = setTimeout(() => reject(new Error("Component observation timed out.")), 10_000); + const page = (await result) as { page: ObservedRow[]; isDone: boolean }; + assert.ok( + page.isDone && Array.isArray(page.page) && page.page.length <= 10, + "Fixture observation exceeded its bounded page.", + ); + return page.page; + } finally { + clearTimeout(timer); + try { + subscription?.unsubscribe(); + } finally { + await system.close(); + } + } + }; + if (!seededHash && !pausedHash) await push(); + const mutation = (name: string, args = {}) => + client.mutation(makeFunctionReference<"mutation">(`dependencyUpgradeFixtures:${name}`), args); + const query = (name: string, args = {}) => + client.query(makeFunctionReference<"query">(`dependencyUpgradeFixtures:${name}`), args); + let userId: string; + let pausedReport: { reportId: string; workId: string } | undefined; + if (seededHash || pausedHash) { + const snapshot = JSON.parse( + await command([ + "bunx", + "convex", + "run", + "--env-file", + cliEnv, + "--inline-query", + ` + return { + users: await ctx.db.query("users").take(2), + gates: await ctx.db.query("dependencyUpgradeGate").take(2), + reports: await ctx.db.query("searchReportRuns").take(2), + }; + `, + ]), + ); + assert.equal(snapshot.users.length, 1); + assert.equal(snapshot.users[0].handle, "dependency-fixture"); + assert.equal(snapshot.users[0].role, "admin"); + assert.equal(snapshot.gates.length, 1); + assert.equal(snapshot.gates[0].started, Boolean(pausedHash)); + assert.equal(snapshot.gates[0].released, Boolean(pausedHash)); + if (pausedHash) { + assert.equal(snapshot.reports.length, 1); + assert.equal(snapshot.reports[0].state, "pending"); + pausedReport = { reportId: snapshot.reports[0]._id, workId: snapshot.reports[0].workId }; + const work = await rows("work"); + assert.equal(work.length, 1); + assert.equal(work[0]!._id, pausedReport.workId); + const starts = await rows("pendingStart"); + assert.equal(starts.length, 1); + assert.equal(starts[0]!.workId, pausedReport.workId); + const globals = await rows("globals"); + assert.equal(globals.length, 1); + assert.equal(globals[0]!.maxParallelism, 0); + } else { + assert.equal(snapshot.reports.length, 0); + for (const table of [ + "work", + "pendingStart", + "pendingCompletion", + "pendingCancelation", + "payload", + "internalState", + ]) + assert.equal((await rows(table)).length, 0, `Seeded continuation found existing ${table}.`); + } + userId = snapshot.users[0]._id; + } else { + ({ userId } = await mutation("seed")); + } + const issuer = "https://convex.test"; + const identity = { subject: userId, issuer, tokenIdentifier: `${issuer}|${userId}` }; + client.setAdminAuth(config.adminKey, identity); + let failureId: string; + let queued: { reportId: string }; + if (pausedReport) { + const completion = await rows("pendingCompletion"); + assert.equal(completion.length, 1); + assert.notEqual(completion[0]!.workId, pausedReport.workId); + failureId = completion[0]!.workId; + queued = pausedReport; + } else { + failureId = await mutation("startFailure"); + await waitFor( + () => query("observeGate"), + (gate) => gate.started, + "old action started", + ); + queued = await mutation("enqueueReportAndPause"); + await mutation("gate", { released: true }); + } + const oldCompletion = await waitFor( + () => rows("pendingCompletion"), + (items) => items.some((item: { workId: string }) => item.workId === failureId), + "old failed completion persisted", + ); + const failedOld = oldCompletion.find((item: { workId: string }) => item.workId === failureId); + assert.ok(failedOld); + assert.equal(failedOld.runResult.kind, "failed"); + assert.equal(failedOld.retry, false); + assert.match(failedOld.runResult.error, /retained-completion/); + assert.ok( + oldCompletion.every( + (item: { runResult: object }) => !Object.hasOwn(item.runResult, "errorData"), + ), + ); + const before = { + report: await query("reportRow", { reportId: queued.reportId }), + work: await rows("work"), + start: await rows("pendingStart"), + completion: oldCompletion, + globals: await rows("globals"), + }; + assert.equal(before.report.state, "pending"); + assert.equal(before.globals[0].maxParallelism, 0); + assert.ok(before.start.some((item: { workId: string }) => item.workId === before.report.workId)); + console.log( + JSON.stringify({ + phase: "retained-baseline", + queuedReport: true, + failedCompletion: true, + pendingStarts: before.start.length, + completions: before.completion.length, + }), + ); + for (const [file, text] of original) writeFileSync(join(capsule, file), text); + writeFileSync(join(capsule, "bun.lock"), candidateLock); + await command(["bun", "install", "--ignore-scripts", "--frozen-lockfile"]); + const candidate = packageProof(); + assert.equal(candidate.convex, "1.50.0"); + assert.equal(candidate.workpool, "0.4.16"); + assert.deepEqual(candidate, packageProof(root)); + await push(); + const after = { + report: await query("reportRow", { reportId: queued.reportId }), + work: await rows("work"), + start: await rows("pendingStart"), + completion: await rows("pendingCompletion"), + globals: await rows("globals"), + }; + assert.deepEqual(after, before, "Paused persisted state changed across upgrade."); + console.log( + JSON.stringify({ phase: "upgraded-paused", persistedStateUnchanged: true, candidate }), + ); + await mutation("parallelism", { value: 1 }); + const ready = await waitFor( + () => + client.action(makeFunctionReference<"action">("searchReports:get"), { + reportId: queued.reportId, + }), + (value) => value.status === "ready", + "retained report completed", + ); + assert.equal(ready.reportId, queued.reportId); + await waitFor( + () => rows("pendingCompletion"), + (items) => items.length === 0, + "old completion drained", + ); + await waitFor( + () => rows("work"), + (items) => items.length === 0, + "retained work finished", + ); + await mutation("gate", { started: false, released: false }); + const candidateFailureId = await mutation("startFailure"); + await waitFor( + () => query("observeGate"), + (gate) => gate.started, + "new action started", + ); + await mutation("parallelism", { value: 0 }); + await mutation("gate", { released: true }); + const newCompletion = await waitFor( + () => rows("pendingCompletion"), + (items) => items.some((item: { workId: string }) => item.workId === candidateFailureId), + "new errorData persisted", + ); + const failedNew = newCompletion.find( + (item: { workId: string }) => item.workId === candidateFailureId, + ); + assert.ok(failedNew); + assert.equal(failedNew.runResult.kind, "failed"); + assert.equal(failedNew.retry, false); + assert.deepEqual(failedNew.runResult.errorData, { fixture: "retained-completion" }); + passed = true; + console.log( + JSON.stringify({ + phase: "passed", + backendVersion, + binarySha256, + sourceHash: inputs.sourceHash, + baseline, + candidate, + retainedReportCompleted: true, + oldCompletionPreserved: true, + newErrorDataStored: true, + rollbackQualified: false, + }), + ); +} + +try { + await main(); +} finally { + await stopBackend(); + if (ownCapsule && passed) rmSync(capsule, { recursive: true, force: true }); + else if (ownCapsule) + console.error("Retained the owned component-upgrade capsule after failure; backend stopped."); +} diff --git a/scripts/run-playwright-local-auth.ts b/scripts/run-playwright-local-auth.ts index 94f91fd596..064cc6208d 100644 --- a/scripts/run-playwright-local-auth.ts +++ b/scripts/run-playwright-local-auth.ts @@ -411,6 +411,23 @@ async function startLocalConvex(args: string[], env: NodeJS.ProcessEnv, convexUr process.cwd(), ["inherit", "inherit", "inherit", "ipc"], ); + let ready = false; + let startupFailure: Error | undefined; + const failAfterReady = (message: string) => { + if (!ready) { + startupFailure = new Error(message); + return; + } + if (cleanupPromise) return; + console.error(message); + void cleanup().finally(() => process.exit(1)); + }; + child.on("message", (result: LocalConvexBootstrapResult) => { + if (result.status === "error") failAfterReady(result.message); + }); + child.once("exit", (code, signal) => + failAfterReady(`Local Convex launcher exited with ${signal ?? `code ${code}`}.`), + ); try { await new Promise((resolve, reject) => { child.once("error", reject); @@ -423,6 +440,8 @@ async function startLocalConvex(args: string[], env: NodeJS.ProcessEnv, convexUr }); }); await waitUntilReachable(convexUrl, "Local Convex", child); + if (startupFailure) throw startupFailure; + ready = true; return; } catch (error) { await stopManagedChild(child); diff --git a/specs/ci.md b/specs/ci.md index 176feaa294..75cc7288e2 100644 --- a/specs/ci.md +++ b/specs/ci.md @@ -136,7 +136,12 @@ backend environment, and then publishes once. Cron definitions read deployment environment variables during publication, so `CLAWHUB_DISABLE_CRONS=1` must be set before the first push. Application readiness checks never republish code, and no development watcher can push again while the app builds. A persistent -launcher retains ownership of the backend process group through cleanup. +launcher retains ownership of the backend process group through cleanup. CLI +bootstrap only creates the isolated configuration; it may stop its backend when +it exits. The launcher then starts the selected cached backend binary directly +and checks `/instance_name` before reporting readiness. It does not depend on a +backend surviving CLI cleanup, and a backend exit aborts the browser run. This +owned test backend binds only to loopback and disables beacon/crash reporting. CI pins the local-auth backend with `PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION`. Before bootstrap, it restores the versioned binary cache or downloads the Linux diff --git a/specs/dependency-upgrade-qualification.md b/specs/dependency-upgrade-qualification.md new file mode 100644 index 0000000000..b884352acd --- /dev/null +++ b/specs/dependency-upgrade-qualification.md @@ -0,0 +1,80 @@ +# Dependency upgrade qualification + +`bun run test:dependency-compat` installs the small, frozen baseline fixture in +`scripts/fixtures/dependency-baseline`, then runs offline package compatibility +checks. It does not change the application's selected dependency versions. + +The baseline pins Convex 1.49.0, Workpool 0.4.15, and Vercel OIDC 4.0.8. Its +private install pins xdg-app-paths 5.5.1; the candidate OIDC 4.0.9 must still +resolve cli-config 0.4.0 and xdg-app-paths 5.1.0. The tests verify actual resolved +package versions before exercising behavior. + +Every child receives a temporary HOME and working directory, synthetic tokens, +and an allowlisted environment. A private marker and nonce bind each child to +its canonical HOME and working directory; direct invocation fails before package +loading or credential writes. The ordinary Linux unit job runs this same command. Unexpected HTTP, socket, and subprocess calls +fail. OIDC refresh uses an in-memory response; no request reaches Vercel. + +The Convex probe binds exact published CLI bundle hashes and exposes unchanged +account helper bodies in memory by replacing only the known final CLI entry +invocation. This checks legacy-file readability, preserved settings, account +selection, and permission changes. It does not test authenticated account +access, login, or the full CLI command dispatcher. + +The OIDC probe runs both real package implementations against XDG, legacy, and +precedence fixtures. It checks request, environment, and file tokens plus cached +refresh and configuration lookup. This qualifies the executing platform's path +semantics; it is not proof of an untested operating system. + +These offline checks do not establish Workpool persisted-state compatibility. +That requires a separate real-backend upgrade preserving one database across +the baseline and candidate component deployments. Once a candidate stores +`errorData` in a failed completion, do not assume Workpool 0.4.15 can read it. + +## Retained database fixture + +The manual fixture runs on Linux or macOS with Bun 1.4.4 and a supported Node.js +version from `CONTRIBUTING.md`. Use a fresh, task-owned checkout with frozen root +dependencies and no copied `.env.local` or `.convex` state. Run the offline command +above first to install its exact baseline packages. + +The fixture expects the pinned backend executable in the private cache at +`.artifacts/native-home/.cache/convex/binaries/precompiled-2026-10-22-1447815/convex-local-backend`. +Populate that cache through the existing local-auth harness. This command boots +and shuts down the normal harness, but only lists browser tests; it does not claim +to run them. Its clean environment prevents inherited deployment credentials. +The harness also performs its normal dependency warmup and application build. + +```bash +mkdir -p -m 700 .artifacts/native-home +env -i PATH="$PATH" HOME="$PWD/.artifacts/native-home" CI=1 \ + CLAWHUB_LOCAL_CHECK_MODE=throttled \ + PLAYWRIGHT_LOCAL_AUTH_BACKEND_VERSION=precompiled-2026-10-22-1447815 \ + bun run test:pw:local-auth -- --list +bun scripts/run-local-component-upgrade.ts --run +``` + +Ports 43220 and 43221 must be free. The runner copies only the owned, validated +backend executable into a fresh private HOME. It creates a disposable source +capsule under `.artifacts/component-upgrade` and uses a separate task-owned Bun +package cache. The live application checkout and its dependency versions are +unchanged. No remote deployment or real account credentials are used. + +The baseline deploys Convex 1.49.0 and Workpool 0.4.15. A real failing action waits +on an explicit gate while a real report is enqueued and the pool is paused in the +same transaction. The action then fails through the released worker. Official +component-scoped queries verify the old failed completion and pending report. + +The fixture restores the exact candidate lockfile, deploys Convex 1.50.0 and +Workpool 0.4.16 into the same backend and database, compares the paused persisted +state, and only then releases the queue. It requires the original report to +complete, the old completion to drain, and a new failure to retain `errorData`. +The result qualifies this forward upgrade on the pinned backend, not rollback +or every production data shape. + +Success removes the capsule and stops the backend. Failure stops the backend +and retains the capsule. The named pre-push, seeded, and paused continuation +modes require the recorded source hash and validate their exact state before +continuing; they never reset the database or replay completed enqueue steps. +Do not use a continuation mode after the candidate has been deployed. Failed +state requires inspection before choosing a continuation. diff --git a/vitest.dependency.config.ts b/vitest.dependency.config.ts new file mode 100644 index 0000000000..b10a4f80cc --- /dev/null +++ b/vitest.dependency.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + environment: "node", + include: ["scripts/dependency-account-compat.proof.ts"], + testTimeout: 15_000, + maxWorkers: 1, + }, +});