diff --git a/.agents/cloud-setup.sh b/.agents/cloud-setup.sh new file mode 100755 index 0000000..66945a5 --- /dev/null +++ b/.agents/cloud-setup.sh @@ -0,0 +1,378 @@ +#!/usr/bin/env bash +# Generated by stll-cloud-setup. Regenerate with stll-cloud-setup. +# Networked installation and offline service startup are separate lifecycle steps. +# Cached filesystems may not preserve processes; run start at every session start. +# Supported platform: Ubuntu 24.04 (noble), amd64/arm64, root or passwordless sudo. +set -euo pipefail + +usage() { echo 'Usage: cloud-setup.sh install|start' >&2; exit 2; } +[[ "$#" == 1 ]] || usage +case "$1" in install|start) MODE="$1" ;; *) usage ;; esac +fail() { echo "cloud-setup: $*" >&2; exit 1; } +trap 'echo "cloud-setup: command failed at line $LINENO" >&2' ERR +# Each phase logs its start and duration so a stalled phase is visible in the task log. +step() { + local name="$1" started="$SECONDS" + shift + echo "cloud-setup: $name started" >&2 + "$@" + echo "cloud-setup: $name done in $((SECONDS - started))s" >&2 +} +[[ -f /etc/os-release ]] || fail 'Ubuntu 24.04 is required' +. /etc/os-release +[[ "$ID" == ubuntu && "$VERSION_ID" == 24.04 && "$VERSION_CODENAME" == noble ]] || fail 'Only Ubuntu 24.04 (noble) is supported' +SCRIPT="$(realpath -- "$0")" +REPO_ROOT="$(cd -- "$(dirname -- "$SCRIPT")/.." && pwd -P)" +[[ "$SCRIPT" == "$REPO_ROOT/.agents/cloud-setup.sh" ]] || fail 'Run the generated repository script' +if [[ "$(id -u)" != 0 ]]; then + command -v sudo >/dev/null && sudo -n true || fail 'Root or passwordless sudo is required' + exec sudo -n -- bash "$SCRIPT" "$MODE" +fi +OUTPUT_UID="$(printenv SUDO_UID || id -u)" +[[ "$OUTPUT_UID" =~ ^[0-9]+$ ]] || fail 'Invalid invoking user' +OUTPUT_GID="$(getent passwd "$OUTPUT_UID" | cut -d: -f4)" +[[ "$OUTPUT_GID" =~ ^[0-9]+$ ]] || fail 'Invoking user is unavailable' +OUTPUT_USER="$(getent passwd "$OUTPUT_UID" | cut -d: -f1)" +OUTPUT_HOME="$(getent passwd "$OUTPUT_UID" | cut -d: -f6)" +[[ -n "$OUTPUT_USER" && "$OUTPUT_HOME" == /* && -d "$OUTPUT_HOME" ]] || fail 'Invoking user requires an existing home directory' +root() { "$@"; } +# Service daemons outlive setup, so they inherit no descriptor beyond stdio: a cloud +# runner can pass its terminal as extra descriptors and wait until every copy closes. +service_run() ( + for descriptor in "/proc/$BASHPID/fd/"*; do + descriptor="$(basename -- "$descriptor")" + if [[ "$descriptor" =~ ^[0-9]+$ ]] && (( descriptor > 2 )); then eval "exec $descriptor>&-"; fi + done + exec runuser -u stll-cloud -- "$@" +) +BUN_VERSION='1.4.3' +NODE_VERSION='26.10.0' +NODE_DIR="/opt/stll-cloud/node/$NODE_VERSION" +BUN_DIR="/opt/stll-cloud/bun/$BUN_VERSION" +export PATH="$NODE_DIR/bin:$BUN_DIR:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +BUN_CACHE="/var/cache/stll-cloud/bun/$OUTPUT_UID" + +[[ -f "$REPO_ROOT/.node-version" && ! -L "$REPO_ROOT/.node-version" ]] || fail 'A regular root .node-version is required' +[[ "$(awk 'NF { if (++count > 1 || NF != 1) exit 1; value=$1 } END { if (count != 1) exit 1; print value }' "$REPO_ROOT/.node-version")" == "$NODE_VERSION" ]] || fail 'Node selector changed; regenerate cloud-setup.sh' +cd -- "$REPO_ROOT" +case "$(uname -m)" in + x86_64) ARCH=amd64; NODE_ARCH=x64; BUN_ARCH=x64 ;; + aarch64|arm64) ARCH=arm64; NODE_ARCH=arm64; BUN_ARCH=aarch64 ;; + *) fail 'Only amd64 and arm64 are supported' ;; +esac + + +release_log_holders() { + # Processes left by package scripts may still hold a step log after the command exits. + # Setup starts its own services later, so end them rather than let them write into a + # deleted log for their whole lifetime. + # One find over all descriptor links; no process per descriptor. + local log="$1" root="${CLOUD_PROC_ROOT:-/proc}" fd pid + while IFS= read -r fd; do + pid="${fd%/fd/*}" + pid="${pid##*/}" + [[ "$pid" =~ ^[0-9]+$ && "$pid" != "$$" ]] || continue + kill -TERM "$pid" 2>/dev/null || true + done < <(find "$root" -mindepth 3 -maxdepth 3 -path "$root/[0-9]*/fd/*" -lname "$log" 2>/dev/null) +} +network_run() ( + local host="$1" seconds="$2" status=0 + shift 2 + network_log="$(mktemp)" || return "$?" + trap 'rm -f -- "$network_log"' EXIT + trap 'exit 129' HUP + trap 'exit 130' INT + trap 'exit 143' TERM + # Output goes to a file, never a pipe: package scripts may leave processes that keep + # inherited descriptors open, and a pipe reader would wait for them past the command. + # Input is never the terminal: timeout runs the command outside the foreground process + # group, where apt restoring terminal settings on a terminal stdin stops it for good. + timeout --signal=TERM --kill-after=5s "$seconds"s "$@" < /dev/null > "$network_log" 2>&1 || status=$? + release_log_holders "$network_log" + cat -- "$network_log" || fail 'Cannot capture network command output' + [[ "$status" != 0 ]] || return 0 + if [[ "$status" == 124 || "$status" == 137 || "$status" == 28 ]] || grep -Eiq 'timed[[:space:]-]+out|time[[:space:]-]+out|timeout[[:space:]]+(was[[:space:]]+)?(reached|expired)|(connection|operation|socket)[[:space:]-]+timeout' "$network_log"; then + fail "download timed out: $host" + fi + return "$status" +) +download_file() { + local url="$1" destination="$2" seconds="$3" host + host="$(printf '%s\n' "$url" | cut -d/ -f3 | sed 's/.*@//')" + [[ "$url" == https://* && -n "$host" ]] || fail 'Downloads require an HTTPS host' + network_run "$host" "$seconds" curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --tlsv1.2 --connect-timeout 20 --max-time "$seconds" --retry 3 --retry-all-errors --retry-max-time "$seconds" "$url" -o "$destination" +} +apt_network() { + local hosts + # --print-uris reads configured indexes without contacting their servers. + hosts="$(set -o pipefail; apt-get --print-uris update | awk -F/ '/^\047https?:\/\// { host=$3; sub(/.*@/, "", host); if (!seen[host]++) { printf "%s%s", separator, host; separator="," } }')" || return "$?" + [[ -n "$hosts" ]] || hosts='configured APT hosts' + # APT_DEADLINE: whole-call seconds; callers that also unpack packages may extend it. + network_run "$hosts" "${APT_DEADLINE:-180}" apt-get -o Acquire::http::Timeout=20 -o Acquire::https::Timeout=20 -o Acquire::Retries=3 -o APT::Update::Error-Mode=any "$@" +} +apt_refresh_for() { + # Skip the refresh only when the install downloads nothing: then no package + # source is contacted and stale cached indexes cannot point at missing files. + local uris + if uris="$(DEBIAN_FRONTEND=noninteractive apt-get --print-uris -qq -y --no-install-recommends install "$@" 2>/dev/null)" && [[ -z "$uris" ]]; then + return 0 + fi + apt_network update +} + + +node_ready() { + local node_version npm_version npx_version + [[ -x "$NODE_DIR/bin/node" && -x "$NODE_DIR/bin/npm" && -x "$NODE_DIR/bin/npx" ]] || return 1 + node_version="$("$NODE_DIR/bin/node" --version)" || return 1 + [[ "$node_version" == "v$NODE_VERSION" ]] || return 1 + npm_version="$("$NODE_DIR/bin/npm" --version)" || return 1 + [[ "$npm_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || return 1 + npx_version="$("$NODE_DIR/bin/npx" --version)" || return 1 + [[ "$npx_version" == "$npm_version" ]] || return 1 +} +runtime_ready() { + node_ready || fail 'Pinned Node, npm or npx is unavailable; run install' + [[ -x "$BUN_DIR/bun" && "$($BUN_DIR/bun --version)" == "$BUN_VERSION" ]] || fail 'Pinned Bun is unavailable; run install' +} +install_runtimes() ( + if [[ ! -s /etc/ssl/certs/ca-certificates.crt ]]; then + command -v update-ca-certificates >/dev/null || fail 'System CA certificate bundle is missing; restore ca-certificates in the base image offline before install' + update-ca-certificates || fail 'System CA certificate bundle could not be repaired offline; restore ca-certificates in the base image before install' + fi + [[ -s /etc/ssl/certs/ca-certificates.crt ]] || fail 'System CA certificate bundle is unavailable after offline repair; restore ca-certificates in the base image before install' + if ! command -v curl >/dev/null || ! command -v unzip >/dev/null || ! command -v xz >/dev/null || ! command -v openssl >/dev/null || ! command -v gpg >/dev/null || ! ldconfig -p | awk '$1 == "libatomic.so.1" { found=1 } END { exit !found }'; then + apt_refresh_for ca-certificates curl unzip xz-utils openssl gnupg util-linux libatomic1 + DEBIAN_FRONTEND=noninteractive apt_install ca-certificates curl unzip xz-utils openssl gnupg util-linux libatomic1 + fi + local node_archive bun_archive bun_folder + # Subshell scope retains scratch for EXIT cleanup after a failed command. + scratch="$(mktemp -d)" + trap 'rm -rf -- "$scratch"' EXIT + if ! node_ready; then + node_archive="node-v$NODE_VERSION-linux-$NODE_ARCH.tar.xz" + download_file "https://nodejs.org/dist/v$NODE_VERSION/$node_archive" "$scratch/$node_archive" 120 + download_file "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt" "$scratch/node-sums" 45 + (cd "$scratch"; awk -v name="$node_archive" '$2 == name { print; count++ } END { if (count != 1) exit 1 }' node-sums | sha256sum --strict -c -) + install -d -m 755 "$NODE_DIR" + tar -xJf "$scratch/$node_archive" --strip-components=1 -C "$NODE_DIR" + fi + if [[ ! -x "$BUN_DIR/bun" ]] || [[ "$($BUN_DIR/bun --version)" != "$BUN_VERSION" ]]; then + bun_folder="bun-linux-$BUN_ARCH" + bun_archive="$bun_folder.zip" + download_file "https://github.com/oven-sh/bun/releases/download/bun-v$BUN_VERSION/$bun_archive" "$scratch/$bun_archive" 120 + download_file "https://github.com/oven-sh/bun/releases/download/bun-v$BUN_VERSION/SHASUMS256.txt" "$scratch/bun-sums" 45 + (cd "$scratch"; awk -v name="$bun_archive" '$2 == name || $2 == "*" name { print $1 " " name; count++ } END { if (count != 1) exit 1 }' bun-sums | sha256sum --strict -c -) + unzip -q "$scratch/$bun_archive" -d "$scratch/bun" + install -d -m 755 "$BUN_DIR" + install -m 755 "$scratch/bun/$bun_folder/bun" "$BUN_DIR/bun" + fi + runtime_ready + ln -sfnT -- "$NODE_DIR/bin/node" /usr/local/bin/node + ln -sfnT -- "$NODE_DIR/bin/npm" /usr/local/bin/npm + ln -sfnT -- "$NODE_DIR/bin/npx" /usr/local/bin/npx + ln -sfnT -- "$BUN_DIR/bun" /usr/local/bin/bun +) + +dependency_install() { + local directory download_hosts + for directory in /var/cache/stll-cloud /var/cache/stll-cloud/bun; do + [[ ! -L "$directory" ]] || fail 'Dependency cache parent must not be a symlink' + if [[ -e "$directory" ]]; then + [[ -d "$directory" && "$(stat -c '%u' "$directory")" == 0 ]] || fail 'Dependency cache parent must be root-owned' + fi + install -d -m 755 -o root -g root "$directory" + done + [[ ! -L "$BUN_CACHE" ]] || fail 'Dependency cache must not be a symlink' + if [[ -e "$BUN_CACHE" ]]; then + [[ -d "$BUN_CACHE" && "$(stat -c '%u' "$BUN_CACHE")" == "$OUTPUT_UID" ]] || fail 'Dependency cache ownership differs from the invoking user' + fi + install -d -m 700 -o "$OUTPUT_UID" -g "$OUTPUT_GID" "$BUN_CACHE" + # Report hostnames only: lockfile/config URLs may contain credentials. + # These are known install hosts; lifecycle scripts can contact other hosts. + download_hosts="$(HOME="$OUTPUT_HOME" "$NODE_DIR/bin/node" -e ' +const fs = require("node:fs"); +const path = require("node:path"); +const hosts = new Set(["registry.npmjs.org"]); +const inputs = [process.env.BUN_CONFIG_REGISTRY ?? "", process.env.NPM_CONFIG_REGISTRY ?? "", process.env.npm_config_registry ?? ""]; +for (const file of ["bun.lock", ".npmrc", "bunfig.toml", path.join(process.env.HOME, ".npmrc"), path.join(process.env.HOME, ".bunfig.toml"), path.join(process.env.XDG_CONFIG_HOME ?? process.env.HOME, ".bunfig.toml")]) { + if (fs.existsSync(file)) inputs.push(fs.readFileSync(file, "utf8")); +} +for (const input of inputs) { + for (const match of input.matchAll(/(?:git\+)?https?:\/\/[^\s"\x27<>\\]+/g)) { + try { hosts.add(new URL(match[0].replace(/^git\+/, "")).hostname); } catch {} + } + if (/github:/.test(input)) { hosts.add("github.com"); hosts.add("codeload.github.com"); } +} +process.stdout.write([...hosts].sort().join(",")); +')" + # Bun 1.4.3 socket inactivity timeout, in seconds; the outer bound includes scripts. + network_run "$download_hosts" 240 runuser -u "$OUTPUT_USER" -- env HOME="$OUTPUT_HOME" BUN_INSTALL_CACHE_DIR="$BUN_CACHE" PATH="$PATH" BUN_CONFIG_HTTP_IDLE_TIMEOUT=20 "$BUN_DIR/bun" install --frozen-lockfile +} + + +# Prevent package maintainer scripts from starting unmanaged system services. +apt_install() ( + # EXIT runs after function locals expire; this subshell owns the trap state. + backup='' + policy_state=untouched + [[ ! -L /var/lock/stll-cloud-apt.lock ]] || fail 'Invalid package install lock' + exec 8>/var/lock/stll-cloud-apt.lock + flock -x -w 120 8 || fail 'Another package installation is active' + [[ ! -L /usr/sbin/policy-rc.d ]] || fail 'Unsupported service-start policy symlink' + [[ ! -e /usr/sbin/policy-rc.d || -f /usr/sbin/policy-rc.d ]] || fail 'Unsupported service-start policy file' + backup="$(mktemp -d)" + cleanup_package_policy() { + local status=$? + trap - EXIT HUP INT TERM + if [[ "$policy_state" == installed ]]; then + if [[ -f "$backup/original" ]]; then + if ! cp -p "$backup/original" /usr/sbin/policy-rc.d; then status=1; fi + else + if ! rm -f /usr/sbin/policy-rc.d; then status=1; fi + fi + fi + rm -rf -- "$backup" + exit "$status" + } + trap cleanup_package_policy EXIT + trap 'exit 129' HUP + trap 'exit 130' INT + trap 'exit 143' TERM + if [[ -e /usr/sbin/policy-rc.d ]]; then cp -p /usr/sbin/policy-rc.d "$backup/original"; fi + policy_state=installed + printf '%s\n' '#!/bin/sh' 'exit 101' > /usr/sbin/policy-rc.d + chmod 755 /usr/sbin/policy-rc.d + local package + for package in "$@"; do + if [[ "$package" == */* ]]; then + # apt cannot fetch local archives with --download-only, so their installs + # stay one call. Package triggers can be slow on cloud filesystems; the + # longer whole-call deadline covers them while Acquire timeouts still + # bound each network request. + APT_DEADLINE=600 DEBIAN_FRONTEND=noninteractive apt_network install -y --no-install-recommends "$@" + return + fi + done + # The network deadline covers downloads only; unpacking and maintainer scripts + # (for example locale generation or cluster creation) run offline afterwards. + DEBIAN_FRONTEND=noninteractive apt_network install -y --no-install-recommends --download-only "$@" + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-download "$@" +) + + + +prepare_state() { :; } + +install_services() { + + : +} + +start_services() { :; } + + + +fetch_verified() { + download_file "$1" "$3" 120 + printf '%s %s\n' "$2" "$3" | sha256sum --strict -c - >/dev/null +} + + +install_tools() { + : + +} +verify_tools() { + : + +} +install_shell_environment() ( + # Subshell scope retains temporary for EXIT cleanup after a failed command. + [[ ! -L '/etc/profile.d/stll-cloud.sh' ]] || fail 'Managed shell profile must not be a symlink' + if [[ -e '/etc/profile.d/stll-cloud.sh' ]]; then + [[ -f '/etc/profile.d/stll-cloud.sh' && "$(stat -c '%h:%u' '/etc/profile.d/stll-cloud.sh')" == 1:0 ]] || fail 'Managed shell profile must be a root-owned single-link file' + fi + temporary="$(mktemp)" + trap 'rm -f -- "$temporary"' EXIT + cat > "$temporary" <<'STLL_CLOUD_PROFILE' +# Generated by stll-cloud-setup; managed cloud shell environment. +# Remove managed entries before prepending, including repeated shell startup. +_stll_cloud_remaining="${PATH-}" +_stll_cloud_result='' +_stll_cloud_separator='' +while :; do + case "$_stll_cloud_remaining" in + *:*) _stll_cloud_part="${_stll_cloud_remaining%%:*}"; _stll_cloud_remaining="${_stll_cloud_remaining#*:}"; _stll_cloud_more=yes ;; + *) _stll_cloud_part="$_stll_cloud_remaining"; _stll_cloud_more=no ;; + esac + case "$_stll_cloud_part" in + '/opt/stll-cloud/node/26.10.0/bin'|'/opt/stll-cloud/bun/1.4.3'|/usr/local/bin) ;; + *) _stll_cloud_result="$_stll_cloud_result$_stll_cloud_separator$_stll_cloud_part"; _stll_cloud_separator=: ;; + esac + [ "$_stll_cloud_more" = yes ] || break +done +export PATH='/opt/stll-cloud/node/26.10.0/bin:/opt/stll-cloud/bun/1.4.3:/usr/local/bin'"${_stll_cloud_separator:+:}$_stll_cloud_result" +unset _stll_cloud_remaining _stll_cloud_result _stll_cloud_separator _stll_cloud_part _stll_cloud_more +STLL_CLOUD_PROFILE + if ! cmp -s "$temporary" '/etc/profile.d/stll-cloud.sh'; then install -m 644 "$temporary" '/etc/profile.d/stll-cloud.sh'; fi + runuser -u "$OUTPUT_USER" -- env HOME="$OUTPUT_HOME" bash -c ' +set -euo pipefail +for name in .bashrc .profile .bash_profile .bash_login; do + file="$HOME/$name" + if [[ ! -e "$file" && ! -L "$file" && "$name" != .bashrc && "$name" != .profile ]]; then continue; fi + [[ ! -L "$file" ]] || { echo "cloud-setup: shell startup file must not be a symlink: $name" >&2; exit 1; } + if [[ -e "$file" ]]; then + [[ -f "$file" && "$(stat -c '\''%h:%u'\'' "$file")" == "1:$(id -u)" ]] || { echo "cloud-setup: shell startup file must be owned and single-link: $name" >&2; exit 1; } + fi + temporary="$(mktemp "$HOME/.stll-cloud-shell.XXXXXX")" + trap '\''rm -f -- "$temporary"'\'' EXIT + if [[ "$name" == .bashrc ]]; then + printf '\''%s\n'\'' '\''# stll-cloud: early environment'\'' '\''. /etc/profile.d/stll-cloud.sh'\'' > "$temporary" + fi + if [[ -f "$file" ]]; then + # Remove only exact managed blocks; preserve unrelated startup lines and permissions. + awk '\'' + $0 == "# stll-cloud: early environment" || $0 == "# stll-cloud: session environment" { + if ((getline following) <= 0 || following != ". /etc/profile.d/stll-cloud.sh") exit 1 + next + } + { print } + '\'' "$file" >> "$temporary" || { echo "cloud-setup: managed shell startup block differs: $name" >&2; exit 1; } + fi + printf '\''%s\n'\'' '\''# stll-cloud: session environment'\'' '\''. /etc/profile.d/stll-cloud.sh'\'' >> "$temporary" + if [[ -f "$file" ]] && cmp -s "$temporary" "$file"; then rm -- "$temporary"; continue; fi + if [[ -f "$file" ]]; then chmod --reference="$file" "$temporary"; else chmod 644 "$temporary"; fi + mv -f -- "$temporary" "$file" +done +' +) +verify_shell_environment() { + [[ -f '/etc/profile.d/stll-cloud.sh' && ! -L '/etc/profile.d/stll-cloud.sh' && "$(stat -c '%h:%u' '/etc/profile.d/stll-cloud.sh')" == 1:0 ]] || fail 'Managed shell environment is unavailable; run install' + [[ "$(sha256sum -- '/etc/profile.d/stll-cloud.sh' | cut -d ' ' -f1)" == 'a7dedf20b0380fb3ac726140bd85f0324ca3b99a499adcb850809292f82cfc7f' ]] || fail 'Managed shell environment differs; run install' +} + + +[[ ! -e 'rust-toolchain.toml' && ! -L 'rust-toolchain.toml' ]] || fail 'rust-toolchain.toml appeared; regenerate cloud-setup.sh' +[[ ! -e 'rust-toolchain' && ! -L 'rust-toolchain' ]] || fail 'rust-toolchain appeared; regenerate cloud-setup.sh' + + + + + +if [[ "$MODE" == install ]]; then + step runtimes install_runtimes + step services install_services + step tools install_tools + step shell install_shell_environment + step dependencies dependency_install + + exit 0 +fi +step runtime-check runtime_ready +step tool-check verify_tools +step shell install_shell_environment +step shell-check verify_shell_environment + +step state prepare_state +step service-start start_services diff --git a/.changeset/modern-fans-jump.md b/.changeset/modern-fans-jump.md new file mode 100644 index 0000000..a845151 --- /dev/null +++ b/.changeset/modern-fans-jump.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..fe7a931 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,19 @@ +{ + "attribution": { + "commit": "", + "pr": "" + }, + "hooks": { + "SessionStart": [ + { + "matcher": "", + "hooks": [ + { + "type": "command", + "command": "if [ \"${CLAUDE_CODE_REMOTE:-}\" = \"true\" ]; then\n cloud_setup_incomplete() {\n printf '%s\\n' 'Cloud setup could not establish a verified session environment. From the repository root, run bash .agents/cloud-setup.sh install and then bash .agents/cloud-setup.sh start. Do not assume pinned tools or services are ready until start succeeds.'\n printf '%s\\n' \"cloud-setup: $1\" >&2\n exit 0\n }\n bash \"$CLAUDE_PROJECT_DIR/.agents/cloud-setup.sh\" start >&2 || cloud_setup_incomplete 'startup failed; run install'\n if [ -n \"${CLAUDE_ENV_FILE:-}\" ]; then\n if [ ! -s /etc/profile.d/stll-cloud.sh ]; then\n cloud_setup_incomplete 'cloud shell profile is unavailable; run install'\n fi\n cloud_shell_exports=\"$(cat /etc/profile.d/stll-cloud.sh)\" || cloud_setup_incomplete 'cloud shell profile could not be read; run install'\n [ -n \"$cloud_shell_exports\" ] || cloud_setup_incomplete 'cloud shell profile is unavailable; run install'\n printf '\\n%s\\n' \"$cloud_shell_exports\" >> \"$CLAUDE_ENV_FILE\" || cloud_setup_incomplete 'session environment could not be persisted; check its write access and rerun start'\n fi\nfi" + } + ] + } + ] + } +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index bde73b0..ce250a9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,10 @@ version: 2 updates: - package-ecosystem: bun - directory: / + directories: + - / + - /fixtures/benign/basic + - /fixtures/malicious/install-hook schedule: interval: weekly day: saturday @@ -18,15 +21,55 @@ updates: - patch ignore: - dependency-name: oxlint + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: oxlint-tsgolint + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: "@oxlint/plugins" + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: "@stll/oxlint-plugin" + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: oxfmt + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: lefthook + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: typescript + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: "@typescript/native" + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: typescript-compat + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: bun-types + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - package-ecosystem: github-actions directory: / schedule: @@ -45,12 +88,57 @@ updates: - patch ignore: - dependency-name: actions/checkout + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: oven-sh/setup-bun + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/setup-node + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/setup-python + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: astral-sh/setup-uv + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/cache + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/cache/restore + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/cache/save + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/upload-artifact + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch - dependency-name: actions/download-artifact + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch + - dependency-name: stella/.github/.github/workflows/package-consumer-compat.yml + update-types: + - version-update:semver-major + - version-update:semver-minor + - version-update:semver-patch diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b81876..51d417b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,9 +53,12 @@ jobs: verify: runs-on: ubuntu-latest timeout-minutes: 15 + env: + BASE_REF: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.sha) || (github.event_name == 'push' && github.event.before) || 'unavailable-toolchain-base' }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + fetch-depth: 0 persist-credentials: false - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: @@ -70,23 +73,15 @@ jobs: - run: bun run lint:ws - run: bun run typecheck - name: Verify typecheck rejects a seeded error - shell: bash + run: bunx --no-install stll-typecheck-probe --project packages/core/tsconfig.json --seed-dir packages/core/src -- bun run typecheck + - name: Detect toolchain changes + id: toolchain run: | - fixture=packages/core/src/typecheck-proof.ts - test ! -e "$fixture" - trap 'rm -f "$fixture"' EXIT - printf 'export const typecheckProof: number = "wrong";\n' > "$fixture" - if bun run typecheck > "$RUNNER_TEMP/typecheck-proof.log" 2>&1; then - cat "$RUNNER_TEMP/typecheck-proof.log" - echo "Typecheck accepted a seeded type error" - exit 1 - fi - cat "$RUNNER_TEMP/typecheck-proof.log" - grep -q 'TS2322' "$RUNNER_TEMP/typecheck-proof.log" - rm "$fixture" - trap - EXIT - bun run typecheck + bunx --no-install stll-toolchain-changed --since "$BASE_REF" > "$RUNNER_TEMP/toolchain-changes.json" + node --input-type=module -e 'import fs from "node:fs"; const result = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); if (typeof result.changed !== "boolean") throw new Error("Missing toolchain changed result"); fs.appendFileSync(process.env.GITHUB_OUTPUT, `changed=${result.changed}\n`);' "$RUNNER_TEMP/toolchain-changes.json" - run: bun run check:typecheck-parity + if: steps.toolchain.outputs.changed == 'true' + - run: bun test scripts/tooling-adoption.test.ts - run: bun run lint - run: bun run format:check - run: bun run test diff --git a/.github/workflows/quarantine-policy.yml b/.github/workflows/quarantine-policy.yml new file mode 100644 index 0000000..700f19f --- /dev/null +++ b/.github/workflows/quarantine-policy.yml @@ -0,0 +1,16 @@ +name: Package quarantine policy + +on: + pull_request: + merge_group: + +permissions: + contents: read + +jobs: + enforce: + name: Enforce package quarantine + if: github.repository == 'stella/skillguard' + permissions: + contents: read + uses: stella/.github/.github/workflows/quarantine-policy.yml@5764ab66e4df84cfd2e642c7d7e4678261e668f8 diff --git a/.github/workflows/quarantine-prune.yml b/.github/workflows/quarantine-prune.yml new file mode 100644 index 0000000..f109123 --- /dev/null +++ b/.github/workflows/quarantine-prune.yml @@ -0,0 +1,19 @@ +name: Package quarantine prune + +on: + schedule: + - cron: "47 * * * *" + +permissions: + contents: read + +jobs: + prune: + name: Remove expired quarantine exceptions + if: github.repository == 'stella/skillguard' + permissions: + contents: read + uses: stella/.github/.github/workflows/quarantine-prune.yml@5764ab66e4df84cfd2e642c7d7e4678261e668f8 + secrets: + CHANGELOG_APP_ID: ${{ secrets.CHANGELOG_APP_ID }} + CHANGELOG_APP_PRIVATE_KEY: ${{ secrets.CHANGELOG_APP_PRIVATE_KEY }} diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..8a94b99 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +26.10.0 diff --git a/bun.lock b/bun.lock index 11cc16e..76b8ff7 100644 --- a/bun.lock +++ b/bun.lock @@ -7,7 +7,8 @@ "devDependencies": { "@changesets/changelog-github": "1.0.1", "@changesets/cli": "3.0.3", - "@stll/oxlint-config": "0.12.0", + "@stll/oxlint-config": "1.4.0", + "@stll/oxlint-plugin": "0.2.2", "@stll/typescript-config": "0.8.0", "@types/node": "26.6.5", "@typescript/native": "npm:typescript@7.0.2", @@ -116,6 +117,58 @@ "@emnapi/wasi-threads": ["@emnapi/wasi-threads@1.2.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA=="], + "@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.28.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ=="], + + "@esbuild/android-arm": ["@esbuild/android-arm@0.28.2", "", { "os": "android", "cpu": "arm" }, "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg=="], + + "@esbuild/android-arm64": ["@esbuild/android-arm64@0.28.2", "", { "os": "android", "cpu": "arm64" }, "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A=="], + + "@esbuild/android-x64": ["@esbuild/android-x64@0.28.2", "", { "os": "android", "cpu": "x64" }, "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q=="], + + "@esbuild/darwin-arm64": ["@esbuild/darwin-arm64@0.28.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw=="], + + "@esbuild/darwin-x64": ["@esbuild/darwin-x64@0.28.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw=="], + + "@esbuild/freebsd-arm64": ["@esbuild/freebsd-arm64@0.28.2", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw=="], + + "@esbuild/freebsd-x64": ["@esbuild/freebsd-x64@0.28.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg=="], + + "@esbuild/linux-arm": ["@esbuild/linux-arm@0.28.2", "", { "os": "linux", "cpu": "arm" }, "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w=="], + + "@esbuild/linux-arm64": ["@esbuild/linux-arm64@0.28.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug=="], + + "@esbuild/linux-ia32": ["@esbuild/linux-ia32@0.28.2", "", { "os": "linux", "cpu": "ia32" }, "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ=="], + + "@esbuild/linux-loong64": ["@esbuild/linux-loong64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ=="], + + "@esbuild/linux-mips64el": ["@esbuild/linux-mips64el@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA=="], + + "@esbuild/linux-ppc64": ["@esbuild/linux-ppc64@0.28.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ=="], + + "@esbuild/linux-riscv64": ["@esbuild/linux-riscv64@0.28.2", "", { "os": "linux", "cpu": "none" }, "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA=="], + + "@esbuild/linux-s390x": ["@esbuild/linux-s390x@0.28.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg=="], + + "@esbuild/linux-x64": ["@esbuild/linux-x64@0.28.2", "", { "os": "linux", "cpu": "x64" }, "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ=="], + + "@esbuild/netbsd-arm64": ["@esbuild/netbsd-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw=="], + + "@esbuild/netbsd-x64": ["@esbuild/netbsd-x64@0.28.2", "", { "os": "none", "cpu": "x64" }, "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw=="], + + "@esbuild/openbsd-arm64": ["@esbuild/openbsd-arm64@0.28.2", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ=="], + + "@esbuild/openbsd-x64": ["@esbuild/openbsd-x64@0.28.2", "", { "os": "openbsd", "cpu": "x64" }, "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw=="], + + "@esbuild/openharmony-arm64": ["@esbuild/openharmony-arm64@0.28.2", "", { "os": "none", "cpu": "arm64" }, "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q=="], + + "@esbuild/sunos-x64": ["@esbuild/sunos-x64@0.28.2", "", { "os": "sunos", "cpu": "x64" }, "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g=="], + + "@esbuild/win32-arm64": ["@esbuild/win32-arm64@0.28.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ=="], + + "@esbuild/win32-ia32": ["@esbuild/win32-ia32@0.28.2", "", { "os": "win32", "cpu": "ia32" }, "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA=="], + + "@esbuild/win32-x64": ["@esbuild/win32-x64@0.28.2", "", { "os": "win32", "cpu": "x64" }, "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g=="], + "@eslint-community/eslint-utils": ["@eslint-community/eslint-utils@4.9.1", "", { "dependencies": { "eslint-visitor-keys": "^3.4.3" }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "sha512-phrYmNiYppR7znFEdqgfWHXR6NCkZEK7hwWDHZUjit/2/U0r6XvkDl0SYnoM51Hq7FhCGdLDT6zxCCOY1hexsQ=="], "@eslint-community/regexpp": ["@eslint-community/regexpp@4.12.2", "", {}, "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew=="], @@ -322,6 +375,8 @@ "@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.87.0", "", { "os": "win32", "cpu": "x64" }, "sha512-k+m/EShyXE29J/r1fjk0HlAzhN5JhIvj044oSJkXTEkCLrWZQgXb/3r4q5LTw/eaKW/4GuMXG2xmiJs3s5rPNw=="], + "@oxlint/plugins": ["@oxlint/plugins@1.88.0", "", {}, "sha512-G2xbfWTrbqYRhR/vfeKNMQf/sS3/ti0iKJAAkRxHuXWZH/hne/dyIb9QKk5LuR6cJLARxsL6FMoAYmfspd74MQ=="], + "@pnpm/deps.graph-sequencer": ["@pnpm/deps.graph-sequencer@1100.0.1", "", {}, "sha512-pOr5+q1fLYKwFN3LAJuGZEnfXDcQ73zqgDHMtGy+K+uIoUqyY+6MeDCWFwfu+4EFuq76I5EPFofoNAI+Bmmq4A=="], "@quansync/fs": ["@quansync/fs@1.0.0", "", { "dependencies": { "quansync": "^1.0.0" } }, "sha512-4TJ3DFtlf1L5LDMaM6CanJ/0lckGNtJcMjQ1NAV6zDmA0tEHKZtxNKin8EgPaVX1YzljbxckyT2tJrpQKAtngQ=="], @@ -360,7 +415,9 @@ "@sonarsource/analyzer-commons-configurations": ["@sonarsource/analyzer-commons-configurations@2.31.0-5284", "", {}, "sha512-ruk3blMs9BE9RNSp9LPpWZAIjxJmq4Cp00E3cELIHz7Kym3WxdWGRlKOMYLRQ5tJg/de7jN5AtEElY3bGIfTcw=="], - "@stll/oxlint-config": ["@stll/oxlint-config@0.12.0", "", { "dependencies": { "picomatch": "4.0.5", "semver": "7.8.5", "smol-toml": "1.9.0", "yaml": "2.9.0" }, "peerDependencies": { "oxlint": ">=1.87.0 <2", "oxlint-tsgolint": ">=7.0.2003 <8" }, "bin": { "stll-cloud-setup": "dist/cloud-setup-cli.mjs", "stll-toolchain-check": "dist/toolchain-check-cli.mjs", "stll-typecheck-parity": "dist/typecheck-parity-cli.mjs" } }, "sha512-mUKh7mk9rhoapdv2Eomt2IguV1olabxIjUb33Ow//YOugCmfAMSI9UjyIoc/FImp9q2CXM6rZQDBCyHzsyK/5Q=="], + "@stll/oxlint-config": ["@stll/oxlint-config@1.4.0", "", { "dependencies": { "acorn": "8.19.0", "esbuild": "0.28.2", "picomatch": "4.0.7", "semver": "7.8.5", "smol-toml": "1.9.1", "tsx": "4.23.15", "yaml": "2.9.1" }, "peerDependencies": { "oxlint": ">=1.87.0 <2", "oxlint-tsgolint": ">=7.0.2003 <8", "vite": "8.1.5" }, "optionalPeers": ["vite"], "bin": { "stll-dependabot": "dist/dependabot-cli.mjs", "stll-cloud-setup": "dist/cloud-setup-cli.mjs", "stll-consumer-compat": "dist/consumer-compat-cli.mjs", "stll-toolchain-check": "dist/toolchain-check-cli.mjs", "stll-typecheck-probe": "dist/typecheck-probe-cli.mjs", "stll-publish-contract": "dist/publish-contract-cli.mjs", "stll-typecheck-parity": "dist/typecheck-parity-cli.mjs", "stll-toolchain-changed": "dist/toolchain-changed-cli.mjs" } }, "sha512-F5E4Jsq8LfIivOn5ssv8j3QaGnApg6CM9x3PKBpS3S+3FJexbJJcTdka2sZpCGfQwOxlLkIQ1J4RgIH81o9v7w=="], + + "@stll/oxlint-plugin": ["@stll/oxlint-plugin@0.2.2", "", { "peerDependencies": { "@oxlint/plugins": ">=1.75.0 <2", "oxlint": ">=1.75.0 <2" } }, "sha512-ZhE55byN2+Y+S/0734kckX8cC5IKb9ulCEg296ww9psTUEzhwHiBF0/WdFx9q8tclkhpbEQ17mgO0WWb91ZHYw=="], "@stll/skillguard": ["@stll/skillguard@workspace:packages/cli"], @@ -464,7 +521,7 @@ "@yuku-toolchain/types": ["@yuku-toolchain/types@0.19.0", "", {}, "sha512-tFkNbsP4WXX9UMUC5syJGdK9dPMLK0PPaIuXCcCYH75sZ8MrebfBZ2XvCILRTw8AgLivSSCfDa4R67iYBDa4Kg=="], - "acorn": ["acorn@8.16.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="], + "acorn": ["acorn@8.19.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw=="], "acorn-jsx": ["acorn-jsx@5.3.2", "", { "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ=="], @@ -498,6 +555,8 @@ "empathic": ["empathic@2.1.0", "", {}, "sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw=="], + "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=="], + "escape-string-regexp": ["escape-string-regexp@4.0.0", "", {}, "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA=="], "eslint": ["eslint@10.4.0", "", { "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", "@eslint/config-array": "^0.23.5", "@eslint/config-helpers": "^0.6.0", "@eslint/core": "^1.2.1", "@eslint/plugin-kit": "^0.7.1", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.4.2", "@types/estree": "^1.0.6", "ajv": "^6.14.0", "cross-spawn": "^7.0.6", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^9.1.2", "eslint-visitor-keys": "^5.0.1", "espree": "^11.2.0", "esquery": "^1.7.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "json-stable-stringify-without-jsonify": "^1.0.1", "minimatch": "^10.2.4", "natural-compare": "^1.4.0", "optionator": "^0.9.3" }, "peerDependencies": { "jiti": "*" }, "optionalPeers": ["jiti"], "bin": { "eslint": "bin/eslint.js" } }, "sha512-loXy6bWOoP3EP6JA7jo6p5jMpBJmHmsNZM5SFRHLdh1MGOPurMnNBj4ZlAbaqUAaQWbCr7jHV4P7gzAyryZWkQ=="], @@ -544,6 +603,8 @@ "formatly": ["formatly@0.11.4", "", { "dependencies": { "fd-package-json": "^2.0.0", "package-manager-detector": "^1.8.0" }, "bin": { "formatly": "bin/index.mjs" } }, "sha512-TeCC10lP8KCgoX+Fe5lryILIT0/Dy+nP0OSVnsuB5CwXoLuOdqxCYlPFF1inR8S/zTy1ec7TjhS2TeRKWzzImA=="], + "fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="], + "functional-red-black-tree": ["functional-red-black-tree@1.0.1", "", {}, "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g=="], "get-tsconfig": ["get-tsconfig@4.14.3", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA=="], @@ -662,7 +723,7 @@ "picocolors": ["picocolors@1.1.1", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="], - "picomatch": ["picomatch@4.0.5", "", {}, "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A=="], + "picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], "prelude-ls": ["prelude-ls@1.2.1", "", {}, "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="], @@ -718,7 +779,7 @@ "sisteransi": ["sisteransi@1.0.5", "", {}, "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg=="], - "smol-toml": ["smol-toml@1.9.0", "", {}, "sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ=="], + "smol-toml": ["smol-toml@1.9.1", "", {}, "sha512-j7WyPdf0CJoutMzMoPLF/bVXHtKZIT9Rb4eGeEbWw8X2t5oirjPgpL+OpaENZrILYaXqYwnVH+qgUwVbl+pUJQ=="], "string_decoder": ["string_decoder@1.1.1", "", { "dependencies": { "safe-buffer": "~5.1.0" } }, "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg=="], @@ -738,6 +799,8 @@ "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="], + "tsx": ["tsx@4.23.15", "", { "dependencies": { "esbuild": "~0.28.0" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": { "tsx": "dist/cli.mjs" } }, "sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw=="], + "turbo": ["turbo@2.11.7", "", { "optionalDependencies": { "@turbo/darwin-64": "2.11.7", "@turbo/darwin-arm64": "2.11.7", "@turbo/linux-64": "2.11.7", "@turbo/linux-arm64": "2.11.7", "@turbo/windows-64": "2.11.7", "@turbo/windows-arm64": "2.11.7" }, "bin": { "turbo": "bin/turbo" } }, "sha512-RhXHbqfvY6o3xt/zSHCwSNwLrZlXiqHzewi4eAj9PtZ1T1CqgMJ2yIDb7SKPTG9IikTm925mfzL6hldQVdyNWw=="], "type-check": ["type-check@0.4.0", "", { "dependencies": { "prelude-ls": "^1.2.1" } }, "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew=="], @@ -762,7 +825,7 @@ "word-wrap": ["word-wrap@1.2.5", "", {}, "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA=="], - "yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="], + "yaml": ["yaml@2.9.1", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw=="], "yocto-queue": ["yocto-queue@0.1.0", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="], @@ -776,31 +839,29 @@ "zod": ["zod@4.6.7", "", {}, "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg=="], - "@changesets/config/picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], - "@changesets/format/tinyexec": ["tinyexec@1.3.0", "", {}, "sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ=="], - "@changesets/git/picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], + "@changesets/parse/yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="], "@eslint-community/eslint-utils/eslint-visitor-keys": ["eslint-visitor-keys@3.4.3", "", {}, "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag=="], "@eslint/config-array/minimatch": ["minimatch@10.2.5", "", { "dependencies": { "brace-expansion": "^5.0.5" } }, "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg=="], + "@manypkg/tools/yaml": ["yaml@2.9.0", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA=="], + "bun-types/undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="], "eslint/minimatch": ["minimatch@10.2.5", "", { "dependencies": { "brace-expansion": "^5.0.5" } }, "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg=="], - "eslint-plugin-sonarjs/yaml": ["yaml@2.9.1", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw=="], - - "knip/picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], + "espree/acorn": ["acorn@8.16.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="], - "knip/yaml": ["yaml@2.9.1", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw=="], + "knip/smol-toml": ["smol-toml@1.9.0", "", {}, "sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ=="], "rolldown-plugin-dts/get-tsconfig": ["get-tsconfig@5.0.0-beta.6", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-X6fBC0pmImC70gvX2zm56go9hx0MyoGVdG0tUCkg/D+Xnh5TJsOZ7iDbOdI3PvmtrDxnu1YdDufpK2QJX1Meqw=="], - "tsdown/cac": ["cac@7.1.0", "", {}, "sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA=="], + "tinyglobby/picomatch": ["picomatch@4.0.5", "", {}, "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A=="], - "tsdown/picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], + "tsdown/cac": ["cac@7.1.0", "", {}, "sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA=="], "@eslint/config-array/minimatch/brace-expansion": ["brace-expansion@5.0.6", "", { "dependencies": { "balanced-match": "^4.0.2" } }, "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g=="], diff --git a/bunfig.toml b/bunfig.toml index 8cf86ca..875d5cb 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,9 +1,9 @@ [install] -linker = "hoisted" +linker = "isolated" # 5-day quarantine: reject package versions published less than 5 days ago. minimumReleaseAge = 432_000 minimumReleaseAgeExcludes = [ - "@stll/oxlint-config", - "@stll/typescript-config", - "bun-types", # quarantine-expires: 2026-10-15T05:29:43.845Z + "@stll/oxlint-config", # quarantine-excluded-since: 2026-10-17T00:00:00.000Z + "@stll/oxlint-plugin", # quarantine-excluded-since: 2026-10-17T00:00:00.000Z + "@stll/typescript-config", # quarantine-excluded-since: 2026-10-17T00:00:00.000Z ] diff --git a/knip.json b/knip.json index 606541d..d4ce023 100644 --- a/knip.json +++ b/knip.json @@ -4,6 +4,9 @@ "ignoreBinaries": ["check"], "ignoreDependencies": ["@typescript/native", "bun-types"], "workspaces": { + ".": { + "entry": ["scripts/**/*.test.ts"] + }, "packages/cli": { "entry": ["src/**/*.test.ts"] }, diff --git a/oxlint.config.ts b/oxlint.config.ts index 4eebe0e..7f05228 100644 --- a/oxlint.config.ts +++ b/oxlint.config.ts @@ -1,9 +1,16 @@ import { library } from "@stll/oxlint-config"; +import { + portableSafetyPluginSpecifiers, + portableSafetyRules, +} from "@stll/oxlint-plugin"; export default library({ + // Generated scanner/build caches and Turbo's task cache contain no source. ignorePatterns: ["**/.cache/**", "**/.turbo/**"], - jsPlugins: ["eslint-plugin-sonarjs"], + // Additive scanner safety checks; coverage is measured by tooling-adoption.test.ts. + jsPlugins: [...portableSafetyPluginSpecifiers, "eslint-plugin-sonarjs"], rules: { + ...portableSafetyRules, "sonarjs/code-eval": "error", "sonarjs/confidential-information-logging": "error", "sonarjs/no-hardcoded-secrets": "error", @@ -12,6 +19,6 @@ export default library({ "sonarjs/no-inverted-boolean-check": "error", "sonarjs/no-unthrown-error": "error", "sonarjs/slow-regex": "error", - "sonarjs/stateful-regex": "error" + "sonarjs/stateful-regex": "error", }, }); diff --git a/package.json b/package.json index 1550bdf..11b9899 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "devDependencies": { "@changesets/changelog-github": "1.0.1", "@changesets/cli": "3.0.3", - "@stll/oxlint-config": "0.12.0", + "@stll/oxlint-config": "1.4.0", + "@stll/oxlint-plugin": "0.2.2", "@stll/typescript-config": "0.8.0", "@types/node": "26.6.5", "@typescript/native": "npm:typescript@7.0.2", diff --git a/scripts/toolchain-policy.test.ts b/scripts/toolchain-policy.test.ts index 37e010e..3c31c58 100644 --- a/scripts/toolchain-policy.test.ts +++ b/scripts/toolchain-policy.test.ts @@ -37,4 +37,20 @@ describe("TypeScript toolchain policy", () => { expect(rootPackage.devDependencies.typescript).toBe("6.0.3"); expect(rulesPackage.dependencies.typescript).toBe("6.0.3"); }); + + test("delegates seeded failure and clean recovery to the shared probe", async () => { + const workflow = await Bun.file( + new URL("../.github/workflows/ci.yml", import.meta.url), + ).text(); + const proof = workflow + .split(" - name: Verify typecheck rejects a seeded error\n") + .at(1) + ?.split(" - name: Detect toolchain changes\n") + .at(0); + expect(proof?.trim()).toBe( + "run: bunx --no-install stll-typecheck-probe --project packages/core/tsconfig.json --seed-dir packages/core/src -- bun run typecheck", + ); + expect(workflow).not.toContain("typecheck-proof.ts"); + expect(workflow).not.toContain("typecheck-proof.log"); + }); }); diff --git a/scripts/tooling-adoption.test.ts b/scripts/tooling-adoption.test.ts new file mode 100644 index 0000000..c37d2aa --- /dev/null +++ b/scripts/tooling-adoption.test.ts @@ -0,0 +1,189 @@ +import { library } from "@stll/oxlint-config"; +import { + portableSafetyPluginSpecifiers, + portableSafetyRules, +} from "@stll/oxlint-plugin"; +import { describe, expect, test } from "bun:test"; +import { execFileSync, spawnSync } from "node:child_process"; +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; +import { fileURLToPath } from "node:url"; + +import config from "../oxlint.config"; + +const root = fileURLToPath(new URL("../", import.meta.url)); +const read = (path: string) => readFileSync(join(root, path), "utf8"); + +// Each fixture exercises the actual syntax and options of its declared rule. +const sonarFixtures = { + "code-eval": + 'import vm from "node:vm";\n\nexport const inspect = (input) => vm.runInNewContext(input);', + "confidential-information-logging": + 'import { Signale } from "signale";\n\nexport const logger = new Signale();', + "no-hardcoded-secrets": + // Random synthetic token: the detector skips placeholder-shaped values such as runs of the alphabet. + // oxlint-disable-next-line sonarjs/no-hardcoded-secrets -- Synthetic token exercises the retained secret detector. + 'export const token = "njuwYWd3dC1WVElPwI6liXfgb80cJadq2nCeZJlYNpfqPv6rpJN6LywqkAxhCi7Q";', // gitleaks:allow + "no-identical-conditions": + "export const inspect = (input) => { if (input === 1) return 2; else if (input === 1) return 3; return 4; };", + "no-identical-functions": + "export const first = (value) => {\nconst result = value + 1;\nconst doubled = result * 2;\nreturn doubled + 3;\n};\nexport const second = (value) => {\nconst result = value + 1;\nconst doubled = result * 2;\nreturn doubled + 3;\n};", + "no-inverted-boolean-check": + "export const inspect = (left, right) => !(left === right);", + "no-unthrown-error": + 'export const inspect = () => { new Error("problem"); };', + // The check reports only exponential backtracking, so the fixture nests quantifiers. + "slow-regex": "export const inspect = (input) => /(a+)+$/u.test(input);", + "stateful-regex": + 'const pattern = /match/g; export const first = pattern.test("first"); export const second = pattern.test("second");', +}; + +const isDiagnostic = ( + value: unknown, +): value is { code: string; filename: string } => + typeof value === "object" && + value !== null && + "code" in value && + typeof value.code === "string" && + "filename" in value && + typeof value.filename === "string"; + +describe("shared tooling adoption", () => { + test("adds the complete portable pack without weakening shared defaults", () => { + const central = library({ + jsPlugins: [...portableSafetyPluginSpecifiers], + rules: { ...portableSafetyRules }, + }); + for (const [name, disposition] of Object.entries(central.rules ?? {})) { + expect(config.rules?.[name]).toEqual(disposition); + } + expect(config.overrides).toHaveLength(central.overrides?.length ?? 0); + for (const [index, override] of (central.overrides ?? []).entries()) { + expect(config.overrides?.at(index)).toMatchObject(override); + } + const retained = Object.keys(config.rules ?? {}) + .filter((name) => name.startsWith("sonarjs/")) + .map((name) => name.slice("sonarjs/".length)) + .toSorted(); + expect(retained).toEqual(Object.keys(sonarFixtures).toSorted()); + }); + + test("measures shared coverage against every retained Sonar check", () => { + const directory = mkdtempSync(join(root, ".tooling-coverage-")); + const lint = (name: string, candidate: ReturnType) => { + const path = join(directory, `${name}.json`); + writeFileSync( + path, + JSON.stringify({ + ...candidate, + // These JS syntax fixtures do not need a TypeScript project. + options: { ...candidate.options, typeAware: false }, + }), + ); + const result = spawnSync( + "bun", + [ + "--bun", + "oxlint", + "-c", + path, + "--format", + "json", + ...Object.keys(sonarFixtures).map((rule) => + join(directory, `${rule}.js`), + ), + ], + { cwd: root, encoding: "utf8" }, + ); + expect(result.status).toBe(1); + const output: unknown = JSON.parse(result.stdout); + if ( + typeof output !== "object" || + output === null || + !("diagnostics" in output) || + !Array.isArray(output.diagnostics) || + !output.diagnostics.every(isDiagnostic) + ) { + throw new Error("Expected structured lint diagnostics"); + } + return output.diagnostics; + }; + try { + for (const [name, source] of Object.entries(sonarFixtures)) { + writeFileSync(join(directory, `${name}.js`), source); + } + const central = lint( + "central", + library({ + jsPlugins: [...portableSafetyPluginSpecifiers], + rules: { ...portableSafetyRules }, + }), + ); + const retained = lint("retained", config); + for (const name of Object.keys(sonarFixtures)) { + expect( + retained.some( + (diagnostic) => + diagnostic.filename.endsWith(`/${name}.js`) && + diagnostic.code.includes(name), + ), + ).toBe(true); + } + const sharedMatches = Object.keys(sonarFixtures).filter((name) => + central.some((diagnostic) => + diagnostic.filename.endsWith(`/${name}.js`), + ), + ); + expect(sharedMatches).toEqual([ + "no-identical-conditions", + "no-unthrown-error", + ]); + } finally { + rmSync(directory, { recursive: true, force: true }); + } + }); + + test("cloud generation is reproducible and third-party quarantine stays enabled", () => { + const paths = [".agents/cloud-setup.sh", ".claude/settings.json"]; + const before = paths.map(read); + execFileSync("bun", ["--bun", "stll-cloud-setup"], { cwd: root }); + expect(paths.map(read)).toEqual(before); + const bunfig = Bun.TOML.parse(read("bunfig.toml")); + expect(bunfig.install.minimumReleaseAge).toBe(432_000); + expect(bunfig.install.minimumReleaseAgeExcludes.toSorted()).toEqual([ + "@stll/oxlint-config", + "@stll/oxlint-plugin", + "@stll/typescript-config", + ]); + for (const workflow of ["quarantine-policy", "quarantine-prune"]) { + expect(read(`.github/workflows/${workflow}.yml`)).toContain( + `uses: stella/.github/.github/workflows/${workflow}.yml@`, + ); + } + }); + + test("Dependabot generation includes tracked fixture package roots reproducibly", () => { + const before = read(".github/dependabot.yml"); + execFileSync("bun", ["--bun", "stll-dependabot"], { cwd: root }); + expect(read(".github/dependabot.yml")).toBe(before); + for (const directory of [ + "/fixtures/benign/basic", + "/fixtures/malicious/install-hook", + ]) { + expect(before).toContain(` - ${directory}\n`); + expect(read(`${directory.slice(1)}/package.json`)).toBeString(); + } + }); + + test("parity uses the shared detector and complete Git history", () => { + const workflow = read(".github/workflows/ci.yml") + .split(" verify:\n") + .at(1); + expect(workflow).toContain("fetch-depth: 0"); + expect(workflow).toContain('stll-toolchain-changed --since "$BASE_REF"'); + expect(workflow).toContain("github.event.pull_request.base.sha"); + expect(workflow).toContain("github.event.before"); + expect(workflow).toContain("unavailable-toolchain-base"); + expect(workflow).toContain("if: steps.toolchain.outputs.changed == 'true'"); + }); +}); diff --git a/stll-toolchain.json b/stll-toolchain.json new file mode 100644 index 0000000..41937d0 --- /dev/null +++ b/stll-toolchain.json @@ -0,0 +1,5 @@ +{ + "cloud": { + "install": "bun install --frozen-lockfile" + } +}