The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
tech(M6): CI hat nie geprueft, ob sich das Produkt ueberhaupt bauen laesst
David517c29a63ccd
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 1a8f17ce..a6ccb1da 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -185,3 +185,122 @@ jobs:working-directory: src-taurirun: cargo clippy --all-targetscontinue-on-error: true++ # ── Is the product still buildable at all? ───────────────────────────────+ #+ # Audit M6, and the hole underneath it. Until this job existed, no workflow+ # ever ran `tauri build`. CI ran `npm run build` (vite), `cargo check` and+ # `cargo test` — all three pass happily on a configuration that cannot be+ # bundled — and the single place `tauri build` did run was release.yml, with+ # TAURI_SIGNING_PRIVATE_KEY supplied from secrets. So the one lane able to+ # see a bundling failure was the one lane configured never to hit it.+ #+ # What that hid, at 10bfa0d7 (v2.6.7), in the shipped product: with+ # `bundle.createUpdaterArtifacts` set next to `plugins.updater.pubkey`,+ # `tauri build` wrote the installers to disk and THEN exited 1 with "A public+ # key has been found, but no private key". Anyone without the release+ # secret — a contributor, a fork, an AGPL-3.0 §6 recipient — could not build+ # the product. Measured on Windows and reproduced on macOS; fixed in+ # a0030ad2 by dropping that one field.+ #+ # This job builds with NO signing key, deliberately, and the script unsets+ # the two signing variables itself. Rationale in scripts/ci-tauri-build.sh:+ # a gate that consumes a secret goes quietly green in a fork where the secret+ # is absent, and — measured locally — handing the broken 10bfa0d7 config a+ # key makes it exit 0, so a key-carrying gate would have been green on the+ # exact commit it exists to fail. No secret is read here, so a fork is held+ # to precisely this check with nothing to configure.+ #+ # The step has no `continue-on-error` and the script does not pipe the exit+ # code away (PIPESTATUS[0], not `tee`'s status). A build that leaves+ # installers on disk and still exits non-zero fails this job — which is the+ # exact shape of the defect above.+ tauri-build:+ runs-on: ${{ matrix.platform }}+ # A hung bundler must fail loudly rather than burn the 6-hour job ceiling,+ # the way the Linux lane did on 2026-08-15 (see release.yml).+ timeout-minutes: 60+ strategy:+ fail-fast: false+ matrix:+ # The platforms this product actually ships, read off release.yml's+ # build-tauri matrix — there is no macOS lane (dropped in c1644d9a).+ # release-build-gate.test.ts compares the two lists on every run, so+ # re-adding a release platform without covering it here fails a test+ # instead of silently narrowing this gate.+ platform: [ubuntu-22.04, windows-latest]++ steps:+ - name: Checkout repository+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1+ with:+ # Empty on push/pull_request (checkout falls back to the triggering+ # commit); the release tag when release.yml calls this workflow.+ ref: ${{ inputs.ref }}++ - name: Setup Node.js+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0+ with:+ node-version-file: '.nvmrc'+ cache: 'npm'++ - name: Install Rust stable+ uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable++ - name: Rust cache+ uses: swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2+ with:+ workspaces: './src-tauri -> target'++ - name: Install Linux dependencies+ if: matrix.platform == 'ubuntu-22.04'+ timeout-minutes: 20+ env:+ DEBIAN_FRONTEND: noninteractive+ run: |+ sudo apt-get update+ sudo apt-get install -y \+ libwebkit2gtk-4.1-dev \+ libayatana-appindicator3-dev \+ librsvg2-dev \+ patchelf \+ libgtk-3-dev \+ libsoup-3.0-dev \+ libjavascriptcoregtk-4.1-dev \+ libxdo-dev \+ build-essential \+ curl \+ wget \+ file \+ libssl-dev++ # Same stub as the cargo-check job above, for the same reason:+ # tauri-build's copy_binaries hard-fails on a missing externalBin, and a+ # real llama.cpp build costs ~20 min that this gate does not need — it is+ # asking whether the app bundles, not whether inference works. The real+ # binaries are built in release.yml and sidecar-windows.yml.+ #+ # Measured 2026-09-01 on macOS: a zero-byte stub survives the full+ # `tauri build`, ad-hoc codesigning of the sidecar included (exit 0, .app+ # + .dmg produced). macOS is the strictest of the three here — Linux and+ # Windows do not sign the sidecar at all — but this has NOT been observed+ # on the two runner platforms, because no Actions run was permitted.+ - name: Stub llama-server sidecar+ shell: bash+ run: |+ mkdir -p src-tauri/bin+ triple="$(rustc -vV | awk '/^host:/{print $2}')"+ case "$triple" in+ *-windows-*) touch "src-tauri/bin/lu-llama-server-$triple.exe" ;;+ *) touch "src-tauri/bin/lu-llama-server-$triple" ;;+ esac+ ls -la src-tauri/bin/++ - name: Install npm dependencies+ run: npm ci++ # No `continue-on-error`, no `|| true`, no `if: secrets…` — see the+ # header. Deliberately the last word on whether this commit is shippable.+ - name: Tauri build (unsigned — exit code is the verdict)+ shell: bash+ run: bash scripts/ci-tauri-build.shdiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 7541bd4a..282bbca8 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -30,6 +30,47 @@ env:VULKAN_SDK_VERSION: '1.4.313.2'jobs:+ # The Latest flag comes off FIRST, before anything is gated or built.+ #+ # `enforce-prerelease` at the bottom of this file is the final word, and it is+ # correct — but it runs after `gate` and `build-tauri`, so between "someone+ # clicked Publish release" and "the flag comes off" there is a window in which+ # GitHub has already pointed `releases/latest` at an unverified build. The+ # download routes on lu-labs.ai follow that pointer and so does every+ # installed updater. On 2026-08-10 that window was minutes and 2.6.4 went out+ # through it. The audit's own first suggestion for M6 was to pull the Latest+ # check forward rather than only to invert it; 6a472f16 did the inverting.+ #+ # Adding the tauri-build lane to ci.yml (Audit M6, the build gate) made that+ # window materially longer, because `gate` now compiles and bundles the app on+ # two platforms before `build-tauri` even starts. So the demotion happens here+ # too, in a job with no `needs:`, which starts within seconds of the trigger.+ #+ # Same script, deliberately: it is idempotent and it can never undo a+ # deliberate flip (see the header of scripts/enforce-prerelease.mjs). Running+ # it twice in one run is two identical PATCHes tens of minutes apart, not a+ # race. This does NOT replace enforce-prerelease: that one also has to run+ # when the build fails, and it is what holds the promise on a re-run.+ #+ # Only on the `release` trigger. The window this closes is "GitHub flagged+ # this Latest by itself, just now", which exists on `release: published` and+ # nowhere else; on workflow_dispatch the flag is a human's verdict.+ demote-on-arrival:+ if: github.event_name == 'release'+ runs-on: ubuntu-22.04+ steps:+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0+ with:+ node-version: 20+ - name: Take the Latest flag off before anything is built+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ GITHUB_REPOSITORY: ${{ github.repository }}+ TAG: ${{ github.event.release.tag_name }}+ PUBLISHED_TAG: ${{ github.event.release.tag_name }}+ run: node scripts/enforce-prerelease.mjs+# A build is not a decision — and neither is a green master. Until this job# existed, `release.yml` typechecked nothing, ran no test and no lint: any# commit that happened to sit on master when someone clicked "Publish release"diff --git a/scripts/ci-tauri-build.sh b/scripts/ci-tauri-build.shnew file mode 100755index 00000000..92339ac2--- /dev/null+++ b/scripts/ci-tauri-build.sh@@ -0,0 +1,158 @@+#!/usr/bin/env bash+#+# ci-tauri-build.sh — the check that asks "is this product still buildable?"+#+# WHY THIS EXISTS+# ---------------+# On 2026-09-01 `npm run tauri build` was measured on Windows and reproduced on+# macOS: it wrote the installers to disk and then exited 1.+#+# Finished 2 bundles at: … .app … .dmg … .app.tar.gz (updater)+# Error A public key has been found, but no private key.+# Make sure to set `TAURI_SIGNING_PRIVATE_KEY` environment variable.+# TAURI_BUILD_EXIT=1+#+# That defect was already present at 10bfa0d7 (v2.6.7), i.e. in the shipped+# product: `bundle.createUpdaterArtifacts` asked the bundler for signed updater+# artifacts while `plugins.updater.pubkey` sat next to it, so the bundler+# demanded a private key nobody outside the release runner has. Anybody who+# cloned the repo and built it got exit 1 — a fork, a contributor, an AGPL-3.0+# recipient exercising §6.+#+# Nobody noticed for one structural reason: `.github/workflows/ci.yml` never ran+# `tauri build`. It ran `npm run build` (vite), `cargo check`, `cargo test` —+# every one of which passes on a config that cannot be bundled. The only place+# `tauri build` ever ran was release.yml, and there+# `TAURI_SIGNING_PRIVATE_KEY` comes out of GitHub secrets, so the one lane that+# could have seen the failure was the one lane configured not to hit it.+#+# THE KEY, AND WHY THIS SCRIPT REFUSES TO HAVE ONE+# ------------------------------------------------+# This script deliberately builds with NO signing key, and it unsets the two+# signing variables itself rather than merely not setting them:+#+# * A gate that reads a secret is a gate that can go quietly green in a fork,+# where the secret does not exist. The usual shapes of that — `if:+# ${{ secrets.X != '' }}`, `continue-on-error: true`, `|| true` — all end in+# a check that reports success while having verified nothing. None of them+# appear here, and none can: there is no secret to be missing.+# * Keyless is also the configuration the defect lives in. Handing the build a+# key would have made the broken 10bfa0d7 config build cleanly and the gate+# would have been green on the exact commit it exists to fail.+# * A fork is therefore held to precisely the check upstream is held to, with+# no repository settings and no secrets to configure.+#+# The trade this makes, stated plainly: if `createUpdaterArtifacts` is ever+# switched back on in `src-tauri/tauri.conf.json` (it is legitimately on in the+# real release branch, where the key exists), this gate goes red and says why.+# That is the intended reading — "this tree cannot be built by anyone who is not+# the release runner" is a finding, not a false alarm — but it does mean the+# release branch has to pass the updater-artifact request to the release build+# (`tauri build --config …` in release.yml) instead of baking it into the+# checked-in config. See the report for the human-side task.+#+# WHAT "PASSED" MEANS HERE+# ------------------------+# Three conditions, all required, in this order:+# 1. `tauri build` exited 0. Taken from PIPESTATUS[0], not from `tee`.+# 2. The build left installers behind. An exit 0 that bundles nothing is not+# a build.+# 3. The log carries no signing complaint. This is the belt to (1)'s braces:+# the original defect printed its error AFTER "Finished 2 bundles at", so+# artifact existence proves nothing, and if a future tauri demotes that+# error to a warning the exit code would stop reporting it.+#+# Usage:+# scripts/ci-tauri-build.sh # build the checked-in config+# scripts/ci-tauri-build.sh -c '<json>' # extra args go to `tauri build`+#+# Sourceable: `main` only runs when the file is executed, so tests can source it+# and call `build_verdict` directly (see the sibling of this file in+# src/lib/__tests__/).+#+set -uo pipefail++BUNDLE_DIR="${BUNDLE_DIR:-src-tauri/target/release/bundle}"+BUILD_LOG="${BUILD_LOG:-tauri-build.log}"++# Everything the bundlers of the two shipped platforms (and this Mac) emit.+# Matched case-insensitively against file names under the bundle directory.+INSTALLER_SUFFIXES='\.(AppImage|deb|rpm|msi|exe|dmg)$'++# The bundler's own words when a pubkey is configured and no private key is in+# the environment. Both halves are matched: the sentence, and the variable it+# names, so a reworded message still trips the second one.+SIGNING_COMPLAINT='A public key has been found, but no private key|TAURI_SIGNING_PRIVATE_KEY'++log() { printf '%s\n' "$*" >&2; }++# How many installer files a build left behind. Directory may not exist.+count_installers() {+ local dir="$1"+ [ -d "$dir" ] || { printf '0\n'; return 0; }+ # `grep -c` exits 1 on zero matches, which is a legitimate answer here and+ # not an error — `|| true` keeps it from propagating through pipefail.+ find "$dir" -type f 2>/dev/null | grep -Eci "$INSTALLER_SUFFIXES" || true+}++# build_verdict <exit_code> <log_file> <bundle_dir>+#+# The whole judgement, separated from the build so it can be executed by a test+# against real files instead of being read and hoped about. Returns 0 only when+# all three conditions hold; prints the reason for anything else.+build_verdict() {+ local code="$1" logfile="$2" dir="$3"+ local installers+ installers="$(count_installers "$dir")"++ if [ "$code" -ne 0 ]; then+ log "FAIL: tauri build exited $code (it left $installers installer file(s) behind —"+ log " artifacts on disk are not a passing build)."+ return 1+ fi++ if [ "$installers" -eq 0 ]; then+ log "FAIL: tauri build exited 0 but produced no installer under '$dir'."+ return 1+ fi++ if [ -f "$logfile" ] && grep -qE "$SIGNING_COMPLAINT" "$logfile"; then+ log "FAIL: tauri build exited 0, but the log asks for a signing key."+ log " A keyless build must not need one. Check bundle.createUpdaterArtifacts."+ return 1+ fi++ log "OK: tauri build exited 0 and bundled $installers installer file(s), unsigned."+ return 0+}++main() {+ # 1. No signing key, on purpose — see the header. Unset rather than assumed+ # absent, so a runner-level env var cannot quietly turn this green.+ unset TAURI_SIGNING_PRIVATE_KEY+ unset TAURI_SIGNING_PRIVATE_KEY_PASSWORD++ # 2. Start from an empty bundle directory, so "did this build produce+ # installers" cannot be answered by a previous build's leftovers. That is+ # the same mistake discord-announce.yml made with release assets on+ # 2026-08-15, counted rather than attributed.+ rm -rf "$BUNDLE_DIR"+ rm -f "$BUILD_LOG"++ log "Building WITHOUT a signing key (deliberate). Bundle dir: $BUNDLE_DIR"++ # 3. `tee` so the log is both visible in the runner and greppable afterwards.+ # The exit code comes out of PIPESTATUS[0]: `$?` after a pipeline is tee's+ # status, which is 0 whatever the build did. pipefail is set as well; the+ # explicit read is what the reader should be able to check at a glance.+ npm run tauri -- build --ci "$@" 2>&1 | tee "$BUILD_LOG"+ local code=${PIPESTATUS[0]}+ log "TAURI_BUILD_EXIT=$code"++ build_verdict "$code" "$BUILD_LOG" "$BUNDLE_DIR"+}++# Only run when executed directly, so tests can source the pure functions.+if [ "${BASH_SOURCE[0]}" = "${0}" ]; then+ main "$@"+fidiff --git a/src/lib/__tests__/release-build-gate.test.ts b/src/lib/__tests__/release-build-gate.test.tsnew file mode 100644index 00000000..e065b955--- /dev/null+++ b/src/lib/__tests__/release-build-gate.test.ts@@ -0,0 +1,310 @@+/**+ * CI has to try building the product, and it has to believe the exit code.+ *+ * THE GAP THIS NAILS SHUT+ * -----------------------+ * At 10bfa0d7 (v2.6.7 — the shipped product, not an experiment artefact)+ * `npm run tauri build` wrote its installers to disk and then exited 1:+ *+ * Finished 2 bundles at: … .app … .dmg … .app.tar.gz (updater)+ * Error A public key has been found, but no private key.+ * Make sure to set `TAURI_SIGNING_PRIVATE_KEY` environment variable.+ * TAURI_BUILD_EXIT=1+ *+ * `bundle.createUpdaterArtifacts` asked the bundler for signed updater+ * artefacts while `plugins.updater.pubkey` sat next to it, so the bundler+ * demanded a private key that only the release runner has. Anybody else —+ * contributor, fork, AGPL-3.0 §6 recipient — got exit 1. Fixed in a0030ad2 by+ * removing that one field; `updater-tot-und-unsigniert.test.ts` keeps the+ * config half from coming back.+ *+ * This file keeps the OTHER half from coming back: the reason nobody noticed+ * for a whole release. `.github/workflows/ci.yml` ran `npm run build` (vite),+ * `cargo check` and `cargo test` — all three pass on a config that cannot be+ * bundled — and never ran `tauri build` once. The only lane that did was+ * release.yml, where TAURI_SIGNING_PRIVATE_KEY comes out of GitHub secrets, so+ * the single job able to see the failure was the one job configured never to+ * meet it. A build that produces artefacts and still exits non-zero was+ * structurally invisible to this project.+ *+ * WHAT IS ASSERTED, AND HOW+ * -------------------------+ * Two halves, deliberately:+ *+ * 1. Structure — the gate exists in ci.yml, covers exactly the platforms+ * release.yml ships, reads no secret, and carries no escape hatch. Read+ * out of the YAML text by job block, because this repo has no YAML parser+ * as a declared dependency and adding one for a test is not worth a new+ * supply-chain edge. The slicing relies on one documented property of a+ * GitHub workflow file: jobs sit at exactly two spaces under `jobs:`.+ *+ * 2. Behaviour — `build_verdict` from scripts/ci-tauri-build.sh is EXECUTED+ * in a real bash against real files on disk, including the precise+ * "artefacts present, exit 1" shape above. Nothing here is mocked; the+ * function that decides red-or-green is the function that runs in CI.+ *+ * VERIFICATION LIMIT, stated on purpose: no GitHub Actions run was permitted+ * for any of this. The workflow file has never executed. What is proven is the+ * script's judgement (locally, by execution), the file's syntax and schema+ * (actionlint 1.7.12 + shellcheck 0.11.0), and the structural claims below.+ *+ * Run: npx vitest run src/lib/__tests__/release-build-gate.test.ts+ */+import { describe, it, expect } from 'vitest'+import { execFileSync } from 'node:child_process'+import { readFileSync, existsSync, statSync, mkdtempSync, writeFileSync, mkdirSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { fileURLToPath } from 'node:url'+import { dirname, resolve, join } from 'node:path'+import { bashInterpreter } from '../../api/__tests__/bash-interpreter'++const here = dirname(fileURLToPath(import.meta.url))+const root = resolve(here, '../../..')+const read = (rel: string) => readFileSync(resolve(root, rel), 'utf8')++const CI_YML = read('.github/workflows/ci.yml')+const RELEASE_YML = read('.github/workflows/release.yml')+const GATE_SCRIPT_REL = 'scripts/ci-tauri-build.sh'+const GATE_SCRIPT = resolve(root, GATE_SCRIPT_REL)++/**+ * The lines belonging to one job, by indentation.+ *+ * A workflow's jobs are the keys at exactly two spaces under `jobs:`, so the+ * block runs from ` <name>:` to the next line that starts a sibling key at+ * that same depth. Comment lines at two spaces (` # …`) are part of the block+ * they precede, not a new key, so they must not end it.+ */+function jobBlock(yaml: string, job: string): string {+ const lines = yaml.split(/\r?\n/)+ const start = lines.findIndex((l) => l === ` ${job}:`)+ if (start < 0) return ''+ let end = lines.length+ for (let i = start + 1; i < lines.length; i++) {+ const l = lines[i]+ if (/^ {2}[^\s#]/.test(l)) { end = i; break }+ if (/^\S/.test(l) && l.trim() !== '') { end = i; break }+ }+ return lines.slice(start, end).join('\n')+}++/**+ * The same block with prose removed.+ *+ * These workflows are heavily commented, and the comments name the very things+ * that must not appear as settings ("no `continue-on-error`, no `|| true`").+ * A check that cannot tell a rule from a note about the rule is not a check —+ * it just punishes documentation.+ */+function withoutComments(block: string): string {+ return block+ .split(/\r?\n/)+ .filter((l) => !/^\s*#/.test(l))+ .map((l) => l.replace(/\s#.*$/, ''))+ .join('\n')+}++/** `platform: [a, b]` — the flat matrix form ci.yml uses. */+function flatMatrixPlatforms(block: string): string[] {+ const m = block.match(/^\s*platform:\s*\[([^\]]*)\]\s*$/m)+ if (!m) return []+ return m[1].split(',').map((s) => s.trim().replace(/^['"]|['"]$/g, '')).filter(Boolean)+}++/** `- platform: xyz` — the include-list form release.yml uses. */+function includeMatrixPlatforms(block: string): string[] {+ return [...block.matchAll(/^\s*-\s*platform:\s*(\S+)\s*$/gm)]+ .map((m) => m[1].replace(/^['"]|['"]$/g, ''))+}++// ── 1. Structure ───────────────────────────────────────────────────────────++describe('ci.yml actually tries to build the product', () => {+ const gate = jobBlock(CI_YML, 'tauri-build')++ it('has a job that runs tauri build — the step that did not exist', () => {+ expect(gate, 'no `tauri-build` job in .github/workflows/ci.yml').not.toBe('')+ expect(gate).toContain(`bash ${GATE_SCRIPT_REL}`)+ })++ it('covers exactly the platforms release.yml ships — no silent narrowing', () => {+ const shipped = includeMatrixPlatforms(jobBlock(RELEASE_YML, 'build-tauri'))+ const gated = flatMatrixPlatforms(gate)++ // Guard the guard: if the extraction ever stops finding anything, this+ // test must fail loudly instead of comparing two empty lists.+ expect(shipped.length, 'could not read release.yml build-tauri platforms').toBeGreaterThan(0)+ expect([...gated].sort()).toEqual([...shipped].sort())+ })++ it('reads no secret, so a fork is held to the same check', () => {+ // The whole point of building unsigned. A gate that consumes a secret is+ // green-by-absence everywhere the secret is not configured — and, measured+ // locally on 2026-09-01, handing the broken 10bfa0d7 config a signing key+ // makes `tauri build` exit 0, so a key-carrying gate would have passed on+ // the exact commit it exists to fail.+ expect(withoutComments(gate)).not.toMatch(/secrets\./)+ expect(withoutComments(gate)).not.toMatch(/TAURI_SIGNING_PRIVATE_KEY/)+ })++ it('has no escape hatch that could report success without building', () => {+ expect(withoutComments(gate)).not.toMatch(/continue-on-error/)+ expect(withoutComments(gate)).not.toMatch(/\|\|\s*true/)+ })++ it('is part of what a release must pass, not a lane beside it', () => {+ // release.yml reuses this whole workflow as its gate. If it ever stops+ // doing so, the build check silently leaves the release path — which is+ // the drift M6 was about in the first place.+ expect(CI_YML).toMatch(/^\s{2}workflow_call:/m)+ expect(jobBlock(RELEASE_YML, 'gate')).toContain('uses: ./.github/workflows/ci.yml')+ expect(jobBlock(RELEASE_YML, 'build-tauri')).toMatch(/^\s*needs:\s*gate\s*$/m)+ })+})++describe('a longer gate must not mean a longer window at Latest', () => {+ // The cost of the job above: `gate` now compiles and bundles on two+ // platforms, so the stretch between "Publish release" and "enforce-prerelease+ // finally runs" grew by the length of a full build. GitHub points+ // releases/latest at a published full release by itself, immediately, and+ // both the lu-labs.ai download routes and every installed updater follow that+ // pointer — so that stretch is exposure, and this job is what keeps the build+ // gate from paying for itself with it.+ const early = jobBlock(RELEASE_YML, 'demote-on-arrival')+ const late = jobBlock(RELEASE_YML, 'enforce-prerelease')++ it('demotes on arrival, sequenced behind nothing', () => {+ expect(early, 'no `demote-on-arrival` job in release.yml').not.toBe('')+ expect(early).toContain('node scripts/enforce-prerelease.mjs')+ // A `needs:` here would put it back behind the build and undo the point.+ expect(withoutComments(early)).not.toMatch(/^\s*needs:/m)+ })++ it('still keeps the final word after the build', () => {+ // The early job is an addition, not a replacement: the late one also has to+ // run when the build FAILED, which is when leaving the flag on would be+ // worst, and it is what holds the promise on a manual re-run.+ expect(late).not.toBe('')+ expect(late).toMatch(/^\s*needs:\s*build-tauri\s*$/m)+ expect(late).toMatch(/^\s*if:\s*always\(\)\s*$/m)+ expect(late).toContain('node scripts/enforce-prerelease.mjs')+ })+})++describe('the gate script is shaped so the exit code survives', () => {+ // Prose stripped, for the reason `withoutComments` exists — and because the+ // mutation probe caught this exact hole: with the raw text, replacing+ // `${PIPESTATUS[0]}` with `$?` in the code left the assertion green, because+ // the comment above that line also says "PIPESTATUS[0]". The check has to+ // read the script, not the explanation of the script.+ const script = withoutComments(read(GATE_SCRIPT_REL))++ it('exists and is executable', () => {+ expect(existsSync(GATE_SCRIPT)).toBe(true)+ if (process.platform === 'win32') {+ const mode = execFileSync('git', ['ls-files', '-s', GATE_SCRIPT_REL], { cwd: root, encoding: 'utf8' })+ .split(' ')[0]+ expect(mode).toBe('100755')+ } else {+ expect(statSync(GATE_SCRIPT).mode & 0o100).toBeTruthy()+ }+ })++ it('takes the build status from PIPESTATUS, not from tee', () => {+ // `npm run … | tee log` followed by `$?` reads tee's status, which is 0+ // whatever the build did. That single mistake would rebuild the exact+ // blind spot this job exists to close.+ expect(script).toContain('PIPESTATUS[0]')+ // `set -uo pipefail` or `set -o pipefail`; deliberately NOT a bare search+ // for the word, which a comment would satisfy.+ expect(script).toMatch(/^set\s+-[a-z]*o\s+pipefail\s*$/m)+ })++ it('unsets the signing variables instead of assuming they are absent', () => {+ expect(script).toMatch(/unset TAURI_SIGNING_PRIVATE_KEY\b/)+ expect(script).toMatch(/unset TAURI_SIGNING_PRIVATE_KEY_PASSWORD\b/)+ })+})++// ── 2. Behaviour — real bash, real files, no mocks ─────────────────────────++describe('build_verdict, executed', () => {+ const BASH = bashInterpreter()++ /** Source the script (main is guarded) and run the verdict for real. */+ function verdict(code: number, logfile: string, bundleDir: string): number {+ try {+ execFileSync(BASH, ['-c', `source '${GATE_SCRIPT}'; build_verdict ${code} '${logfile}' '${bundleDir}'`], {+ stdio: ['ignore', 'pipe', 'pipe'],+ encoding: 'utf8',+ })+ return 0+ } catch (e) {+ const status = (e as { status?: number }).status+ return typeof status === 'number' ? status : 1+ }+ }++ /** A throwaway tree: a bundle dir with one installer, plus two build logs. */+ function fixture() {+ const dir = mkdtempSync(join(tmpdir(), 'lu-build-gate-'))+ const bundle = join(dir, 'bundle', 'dmg')+ mkdirSync(bundle, { recursive: true })+ writeFileSync(join(bundle, 'LU Experiment_2.6.7_aarch64.dmg'), 'not really a dmg')+ const failing = join(dir, 'failing.log')+ // The literal tail of the 2026-09-01 measurement.+ writeFileSync(+ failing,+ 'Finished 2 bundles at:\n' ++ ' /x/LU Experiment.app\n' ++ ' /x/LU Experiment_2.6.7_aarch64.dmg\n' ++ ' /x/LU Experiment.app.tar.gz (updater)\n' ++ 'Error A public key has been found, but no private key. ' ++ 'Make sure to set `TAURI_SIGNING_PRIVATE_KEY` environment variable.\n',+ )+ const clean = join(dir, 'clean.log')+ writeFileSync(clean, 'Finished 2 bundles at:\n /x/LU Experiment.app\n')+ return { dir, bundleRoot: join(dir, 'bundle'), empty: join(dir, 'nothing-here'), failing, clean }+ }++ it('THE case: installers on disk and exit 1 is still a failure', () => {+ const f = fixture()+ try {+ // Exactly a0030ad2: the bundler finished its two bundles, wrote them+ // out, and then exited 1. "The artefacts are there" is not a verdict.+ expect(verdict(1, f.failing, f.bundleRoot)).not.toBe(0)+ } finally {+ rmSync(f.dir, { recursive: true, force: true })+ }+ })++ it('a clean keyless build passes', () => {+ const f = fixture()+ try {+ expect(verdict(0, f.clean, f.bundleRoot)).toBe(0)+ } finally {+ rmSync(f.dir, { recursive: true, force: true })+ }+ })++ it('exit 0 with nothing bundled is a failure too', () => {+ const f = fixture()+ try {+ expect(verdict(0, f.clean, f.empty)).not.toBe(0)+ } finally {+ rmSync(f.dir, { recursive: true, force: true })+ }+ })++ it('exit 0 while the log begs for a signing key is a failure', () => {+ const f = fixture()+ try {+ // Belt to the exit code's braces. Should a future tauri demote that+ // error to a warning, the exit code stops carrying the news and this is+ // the only thing left that notices.+ expect(verdict(0, f.failing, f.bundleRoot)).not.toBe(0)+ } finally {+ rmSync(f.dir, { recursive: true, force: true })+ }+ })+})