From 1b42778210f4cf5f88f9c54fb88c46faa2434608 Mon Sep 17 00:00:00 2001 From: tianxiaochannel-oss88 Date: Mon, 30 Nov 2026 00:08:23 -0500 Subject: [PATCH 1/2] Build Desktop candidates with the official Cua Driver cache policy --- .github/workflows/desktop-prerelease.yml | 33 ++++++++++++++++- .../tests/plugin-packaging-config.test.ts | 37 +++++++++++++++++++ .../plugin-independent-packaging.md | 6 +-- docs/release/github-actions.md | 11 ++++++ scripts/release/verify-desktop-package.mjs | 24 +++++++++++- 5 files changed, 105 insertions(+), 6 deletions(-) diff --git a/.github/workflows/desktop-prerelease.yml b/.github/workflows/desktop-prerelease.yml index 5e9bdc35c..d0ab716f6 100644 --- a/.github/workflows/desktop-prerelease.yml +++ b/.github/workflows/desktop-prerelease.yml @@ -22,6 +22,10 @@ on: type: choice options: [bundled, on-demand] default: bundled + catalog_managed_cua: + description: Include the official Cua Driver cache policy in an on-demand acceptance build + type: boolean + default: false create_draft: description: Create a Draft release after BOTH builds pass (source must be on main) type: boolean @@ -98,6 +102,7 @@ jobs: DESKTOP_RELEASE_TAG: ${{ inputs.release_tag || '' }} DESKTOP_CREATE_DRAFT: ${{ inputs.create_draft && inputs.operation == 'build' }} DESKTOP_PLUGIN_MODE: ${{ inputs.plugin_mode || 'bundled' }} + DESKTOP_CATALOG_MANAGED_CUA: ${{ inputs.catalog_managed_cua && '1' || '0' }} DESKTOP_ALLOW_EXISTING_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }} run: | set -euo pipefail @@ -108,6 +113,9 @@ jobs: node --input-type=module <<'NODE' import { appendFile } from "node:fs/promises"; import { readCandidate } from "./.trusted-main/scripts/release/desktop-release.mjs"; + if (process.env.DESKTOP_CATALOG_MANAGED_CUA === "1" && process.env.DESKTOP_PLUGIN_MODE !== "on-demand") { + throw new Error("Cua Driver catalog acceptance requires plugin_mode=on-demand."); + } if (process.env.DESKTOP_PLUGIN_MODE === "on-demand" && process.env.DESKTOP_CREATE_DRAFT === "true") { throw new Error("On-demand packages are validation candidates until installed acceptance passes."); } @@ -150,6 +158,12 @@ jobs: LING_CUA_DISTRIBUTION_CHANNEL: development LING_CUA_DRIVER_PACKAGE_PROVIDER: "0" LING_PLUGIN_EXTERNAL_ONLY: ${{ inputs.plugin_mode == 'on-demand' && '1' || '0' }} + LING_CUA_DRIVER_CATALOG_MANAGED: ${{ inputs.catalog_managed_cua && '1' || '0' }} + LING_CUA_DARWIN_EXPECTED_TEAM_ID: ${{ inputs.catalog_managed_cua && vars.LING_CUA_DARWIN_EXPECTED_TEAM_ID || '' }} + LING_CUA_PROVIDER_SIGNER_SUBJECT: ${{ inputs.catalog_managed_cua && vars.LING_CUA_PROVIDER_SIGNER_SUBJECT || '' }} + LING_CUA_PROVIDER_SIGNER_SHA256: ${{ inputs.catalog_managed_cua && vars.LING_CUA_PROVIDER_SIGNER_SHA256 || '' }} + LING_CUA_CATALOG_SIGNER_SUBJECT: ${{ inputs.catalog_managed_cua && vars.LING_CUA_CATALOG_SIGNER_SUBJECT || '' }} + LING_CUA_CATALOG_SIGNER_SHA256: ${{ inputs.catalog_managed_cua && vars.LING_CUA_CATALOG_SIGNER_SHA256 || '' }} defaults: run: shell: bash @@ -167,6 +181,23 @@ jobs: with: node-version: 22.22.1 cache: pnpm + - name: Validate Cua Driver catalog signer configuration + if: env.LING_CUA_DRIVER_CATALOG_MANAGED == '1' + run: | + node --input-type=module <<'NODE' + import { + createCuaDriverPackageAuthorityDocuments, + packageAuthorityInputFromEnvironment, + } from "./apps/desktop/scripts/cua-driver-package-runtime-policy.mjs"; + const platform = process.env.DESKTOP_TARGET === "macos-arm64" ? "darwin" : "win32-x64"; + createCuaDriverPackageAuthorityDocuments(packageAuthorityInputFromEnvironment(platform, { + ...process.env, + LING_CUA_SIGNING_TIER: "production_signed", + LING_CUA_DISTRIBUTION_CHANNEL: "production", + LING_CUA_SIGNING_FIXTURE: "0", + LING_CUA_TEST_AUTHORITY_KIND: undefined, + })); + NODE - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 if: runner.os == 'Windows' && env.LING_PLUGIN_EXTERNAL_ONLY != '1' with: @@ -225,7 +256,7 @@ jobs: export LING_BUN_ENTRY_PROBE_BINARY=bun node --test --test-concurrency=1 scripts/ci/desktop-release.test.mjs scripts/ci/desktop-package.test.mjs \ scripts/ci/desktop-bun-entry.test.mjs \ - apps/desktop/tests/distribution*.test.mjs + apps/desktop/tests/distribution*.test.mjs apps/desktop/tests/plugin-packaging-config.test.ts - name: Inspect current distribution inputs without approving redistribution run: | node apps/desktop/scripts/distribution/materials.mjs inspect \ diff --git a/apps/desktop/tests/plugin-packaging-config.test.ts b/apps/desktop/tests/plugin-packaging-config.test.ts index 8f4b58c33..042f82a8b 100644 --- a/apps/desktop/tests/plugin-packaging-config.test.ts +++ b/apps/desktop/tests/plugin-packaging-config.test.ts @@ -1,8 +1,14 @@ import assert from "node:assert/strict"; import { createRequire } from "node:module"; +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { test } from "node:test"; import { withCuaDriverBuilderEnvironment } from "../scripts/cua-driver-builder-environment.mjs"; +import { verifyCandidateCuaDriverAuthority } from "../../../scripts/release/verify-desktop-package.mjs"; +import { CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY, createExternalOnlyCuaDriverPackageAuthority } from "../shared/cua-driver-package-authority-contract.mjs"; +import { writeCuaDriverPackageAuthorityFiles } from "../scripts/cua-driver-package-runtime-policy.mjs"; type Resource = { readonly to?: string }; type BuilderConfig = { @@ -45,3 +51,34 @@ test("the macOS Builder merge excludes compatibility plugin resources in on-dema }); } }); + +test("candidate verification checks the catalog authority and its actual packaged policy bytes", async t => { + const resources = await mkdtemp(join(tmpdir(), "ling-catalog-candidate-")); + t.after(() => rm(resources, { recursive: true, force: true })); + const outputRoot = join(resources, "providers", "cua-driver"); + await mkdir(outputRoot, { recursive: true }); + const signingProfile = { signingTier: "production_signed", distributionChannel: "production" }; + const { hostAuthority, capabilitiesPath } = await writeCuaDriverPackageAuthorityFiles({ + outputRoot, platform: "darwin", providerSource: "official-cache", expectedTeamId: "EXAMPLE001", signingProfile, + }); + const metadata = { [CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY]: hostAuthority }; + const ordinaryMetadata = { [CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY]: createExternalOnlyCuaDriverPackageAuthority() }; + assert.equal(await verifyCandidateCuaDriverAuthority(ordinaryMetadata, resources, "darwin", false), "external-only"); + assert.equal(await verifyCandidateCuaDriverAuthority(metadata, resources, "darwin", true), "official-cache"); + await assert.rejects(verifyCandidateCuaDriverAuthority(metadata, resources, "darwin", false), /requested build/u); + await assert.rejects(verifyCandidateCuaDriverAuthority(metadata, resources, "win32", true), /requested build/u); + await assert.rejects(verifyCandidateCuaDriverAuthority(ordinaryMetadata, resources, "darwin", true), /requested build/u); + await writeFile(capabilitiesPath, "{}"); + await assert.rejects(verifyCandidateCuaDriverAuthority(metadata, resources, "darwin", true), /does not match app.asar/u); + + const winResources = join(resources, "win"); + const winSigner = { subject: "CN=Test Publisher", certificateSha256: "a".repeat(64) }; + const { hostAuthority: winAuthority, runtimeTrustPolicyPath } = await writeCuaDriverPackageAuthorityFiles({ + outputRoot: join(winResources, "providers", "cua-driver"), platform: "win32-x64", + providerSource: "official-cache", signingProfile, providerSigner: winSigner, catalogSigner: winSigner, + }); + const winMetadata = { [CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY]: winAuthority }; + assert.equal(await verifyCandidateCuaDriverAuthority(winMetadata, winResources, "win32", true), "official-cache"); + await writeFile(runtimeTrustPolicyPath, "{}"); + await assert.rejects(verifyCandidateCuaDriverAuthority(winMetadata, winResources, "win32", true), /does not match app.asar/u); +}); diff --git a/docs/design/integrations/plugin-independent-packaging.md b/docs/design/integrations/plugin-independent-packaging.md index 242130c39..4934c938c 100644 --- a/docs/design/integrations/plugin-independent-packaging.md +++ b/docs/design/integrations/plugin-independent-packaging.md @@ -46,12 +46,10 @@ Desktop retains up to two generations of validated GStack runtimes. When the cac `scripts/plugins/package-plugin.mjs` and `generate-catalog.mjs` provide local development tools. Producer repositories release fixed versions. The Official plugin catalog workflow of the main repository uses `LING_PLUGIN_ARTIFACT_PRIVATE_KEY` and `LING_PLUGIN_CATALOG_PRIVATE_KEY`. Select `verify-keys` in `main` to pre-check whether the two private keys match the client's built-in public key. -The default `assemble` operation downloads two platform ZIPs and `.zip.json` manifests of the same name from each fixed Release. The manifest must declare the `stable` channel, and the asset address, size, digest, and Ling version constraints must be consistent with the audit input and package manifest. The workflow reviews the package content, generates a signature and uploads the catalog product. When `publish=true` is passed in, the workflow writes the directory and its signature to the same branch commit. `sources` Input is in the following format. [Directory Workflow](https://github.com/ling-stack-org/ling-stack/actions/workflows/plugin-release.yml) +The default `assemble` operation downloads both platform ZIPs and their `.zip.json` sidecars from the Office Documents, Chrome, and Cua Driver releases pinned in `sources`. Each sidecar must declare the `stable` channel and match the asset URL, size, digest, and Ling version constraints. When `publish=true`, the workflow writes the catalog and its signature in one branch commit. PDF Documents and Office Processing have development archives. Both still need producer integration with this workflow. [Catalog workflow](https://github.com/ling-stack-org/ling-stack/actions/workflows/plugin-release.yml) ```json { - "official:pdf-documents": { "tag": "vX.Y.Z", "sourceSha": "", "sha256": { "darwin-arm64": "", "win32-x64": "" } }, - "official:office-processing": { "tag": "vX.Y.Z", "sourceSha": "", "sha256": { "darwin-arm64": "", "win32-x64": "" } }, "official:office-documents": { "tag": "vX.Y.Z", "sourceSha": "", "sha256": { "darwin-arm64": "", "win32-x64": "" } }, "official:chrome-browser": { "tag": "vX.Y.Z", "sourceSha": "", "sha256": { "darwin-arm64": "", "win32-x64": "" } }, "official:cua-driver": { "tag": "vX.Y.Z", "sourceSha": "", "sha256": { "darwin-arm64": "", "win32-x64": "" } } @@ -164,7 +162,7 @@ The same three-stage process uses the public `v0.6.2-alpha.1` Setup as the third ## Thin package comparison and switching 1. Build thin packages that are compatible with the baseline and `LING_PLUGIN_EXTERNAL_ONLY=1` respectively, on the same independently reviewed source code commits and toolchains. Pre-publishing checks still need to be done through the platform's original Desktop. -2. Cua Driver independent operation verification is set to `LING_CUA_DRIVER_CATALOG_MANAGED=1`. macOS reads `LING_CUA_DARWIN_EXPECTED_TEAM_ID` from the release environment. Windows reads `LING_CUA_PROVIDER_SIGNER_SUBJECT`, `LING_CUA_PROVIDER_SIGNER_SHA256`, `LING_CUA_CATALOG_SIGNER_SUBJECT`, and `LING_CUA_CATALOG_SIGNER_SHA256`. This information belongs to Desktop's production provider trust policy. +2. Build the Cua Driver acceptance package with `catalog_managed_cua=true` and the reviewed platform signer identities. Confirm the package verification report records `cuaDriverProviderSource: official-cache`. [Desktop candidate workflow](../../release/github-actions.md#each-release) 3. Verify offline boot and existing configuration migration on macOS arm64 and Windows x64 installations. Each platform downloads Office, Chrome and Cua Driver from the official signature directory for the first time. After restarting Desktop, perform Excel workbook operation, Chrome Native Messaging operation and Computer Use operation respectively. macOS's `office-local.node` is used by Desktop's file-level Office capabilities and is subject to the same set of independent reviews. 4. Each plugin verifies updates with a second signed version, and after a reboot checks the actual running version. Disconnect the network, roll back and restart, and recheck the actual call and workspace configuration of the previous version. Logs directory commits, platform signatures, version and SHA-256 of actual running files, first download size, DMG and EXE bytes. Desktop package reports provide `pluginMode` and `installedPayloadBytes`. 5. After the platform acceptance is passed, the default packaging will be switched, the duplicate native builds, resources and source codes of the three plug-ins will be cleaned up, and the Desktop release instructions will be updated. diff --git a/docs/release/github-actions.md b/docs/release/github-actions.md index ae240c418..96c0ea406 100644 --- a/docs/release/github-actions.md +++ b/docs/release/github-actions.md @@ -54,6 +54,7 @@ pointed to by every published tag. | `source_sha` | Full source SHA already merged into `main` | | `release_tag` | `v` matching the product version | | `plugin_mode` | `bundled` for the compatibility package; `on-demand` for a thin-package acceptance candidate | + | `catalog_managed_cua` | Enable for testing the signed Cua Driver provider from the official catalog | | `create_draft` | `false` to retain candidate artifacts only; `true` to create a Draft after both platforms succeed | For thin-package acceptance, use `on-demand` with `create_draft=false`, then build a @@ -64,6 +65,16 @@ pointed to by every published tag. manifest collects the native sources and licenses actually bundled for the selected mode, and archive verification checks that mode. + For Cua Driver acceptance, configure repository variables + `LING_CUA_DARWIN_EXPECTED_TEAM_ID`, `LING_CUA_PROVIDER_SIGNER_SUBJECT`, + `LING_CUA_PROVIDER_SIGNER_SHA256`, `LING_CUA_CATALOG_SIGNER_SUBJECT`, and + `LING_CUA_CATALOG_SIGNER_SHA256` with the reviewed provider signing identities. + These values are public certificate metadata. Run with `catalog_managed_cua=true`, + `plugin_mode=on-demand`, and `create_draft=false`. The development installer + embeds the provider trust policy and reports `cuaDriverProviderSource: official-cache`. + Verify installation and operation using the independently signed provider after + launch. + 4. Download and inspect the generated installer, per-platform verification JSON, distribution archive, and `checksums.txt`. Mac produces an arm64 DMG/ZIP; Windows produces an x64 Setup EXE. There are no Intel Mac, Windows ARM64, or automatic-updater artifacts. diff --git a/scripts/release/verify-desktop-package.mjs b/scripts/release/verify-desktop-package.mjs index 8c670ca7b..ed0fed60e 100644 --- a/scripts/release/verify-desktop-package.mjs +++ b/scripts/release/verify-desktop-package.mjs @@ -11,6 +11,8 @@ import { smokeWindowsInstaller } from "./windows-installer-smoke.mjs"; import { createVerifiedDistributionArchive, inventoryDistribution } from "./distribution-archive.mjs"; import { verifyNsisPlugins } from "./verify-nsis-plugins.mjs"; import { prepareNsisExtractor } from "./nsis-extractor.mjs"; +import { CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY, validateCuaDriverPackageAuthority } from "../../apps/desktop/shared/cua-driver-package-authority-contract.mjs"; +import { CUA_DRIVER_PACKAGED_CAPABILITIES_FILENAME, CUA_DRIVER_RUNTIME_TRUST_POLICY_FILENAME } from "../../apps/desktop/scripts/cua-driver-package-runtime-policy.mjs"; const root = fileURLToPath(new URL("../../", import.meta.url)); const desktopRoot = join(root, "apps/desktop"); @@ -44,6 +46,23 @@ function describePayloadDifference(actual, expected, limit = 20) { return { expectedCount: expected.length, actualCount: actual.length, missing, extra, changed }; } +export async function verifyCandidateCuaDriverAuthority(metadata, resources, platform, catalogManaged) { + const authority = validateCuaDriverPackageAuthority(metadata[CUA_DRIVER_PACKAGE_AUTHORITY_METADATA_KEY]); + if (!catalogManaged && !authority.providerExpected) return "external-only"; + if (!catalogManaged || authority.providerSource !== "official-cache" || authority.platform !== platform) { + throw new Error("Packaged Cua Driver authority does not match the requested build"); + } + const policyRoot = join(resources, "providers", "cua-driver"); + const [capabilities, policy] = await Promise.all([ + fileRecord(join(policyRoot, CUA_DRIVER_PACKAGED_CAPABILITIES_FILENAME)), + fileRecord(join(policyRoot, CUA_DRIVER_RUNTIME_TRUST_POLICY_FILENAME)), + ]); + if (capabilities.sha256 !== authority.capabilitiesSha256 || policy.sha256 !== authority.runtimeTrustPolicySha256) { + throw new Error("Packaged Cua Driver catalog policy does not match app.asar"); + } + return authority.providerSource; +} + async function inspectApplication(app, candidate, target, expectedDistribution) { const mac = target === "macos-arm64"; const resources = mac ? join(app, "Contents/Resources") : join(app, "resources"); @@ -58,6 +77,9 @@ async function inspectApplication(app, candidate, target, expectedDistribution) if (pluginMode !== "bundled" && pluginMode !== "on-demand") throw new Error("Unknown Desktop plugin resource mode"); const expectedPluginMode = process.env.LING_PLUGIN_EXTERNAL_ONLY === "1" ? "on-demand" : "bundled"; if (pluginMode !== expectedPluginMode) throw new Error("Packaged plugin resource mode does not match the requested build"); + const cuaDriverProviderSource = await verifyCandidateCuaDriverAuthority( + metadata, resources, mac ? "darwin" : "win32", process.env.LING_CUA_DRIVER_CATALOG_MANAGED === "1", + ); execFileSync(process.execPath, [join(desktopRoot, "scripts/distribution/materials.mjs"), "verify", "--platform", mac ? "darwin-arm64" : "win32-x64", "--plugin-mode", pluginMode, "--resources", resources], { cwd: root, encoding: "utf8", timeout: 120_000, maxBuffer: 4 * 1024 * 1024 }); const pluginResources = pluginMode === "bundled" @@ -100,7 +122,7 @@ async function inspectApplication(app, candidate, target, expectedDistribution) || asar.listPackage(archive).some(name => /(?:^|[/\\])dist[/\\](?:office-driver|daemon[/\\]bundled)(?:[/\\]|$)/u.test(name)))) { throw new Error("Unexpected bundled plugin resource in the on-demand Desktop payload"); } - return { files, payload, pluginMode, installedPayloadBytes: payload.reduce((sum, file) => sum + (file.sizeBytes ?? 0), 0), + return { files, payload, pluginMode, cuaDriverProviderSource, installedPayloadBytes: payload.reduce((sum, file) => sum + (file.sizeBytes ?? 0), 0), distributionFileCount: distribution.length }; } From 5d94d834df7820c5b928ff04ac78cb630f991eeb Mon Sep 17 00:00:00 2001 From: tianxiaochannel-oss88 Date: Mon, 30 Nov 2026 05:36:23 -0500 Subject: [PATCH 2/2] ci: expose catalog Cua input to reusable workflow --- .github/workflows/desktop-prerelease.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/desktop-prerelease.yml b/.github/workflows/desktop-prerelease.yml index d0ab716f6..7e1e5febb 100644 --- a/.github/workflows/desktop-prerelease.yml +++ b/.github/workflows/desktop-prerelease.yml @@ -55,6 +55,11 @@ on: type: string required: false default: bundled + catalog_managed_cua: + description: Include the official Cua Driver cache policy in an on-demand acceptance build + type: boolean + required: false + default: false # Explicit maintainer opt-in permits inspecting a new workflow before landing it. pull_request: types: [labeled]