fix(skill): address shared runtime review findings

This commit is contained in:
fz committed 2026-09-18 11:52:04 +08:00
1 parent 3ebd70020c
commit 4d34cd87dd
33 files changed
+122 -78

No files matched your search

+15 -15
View File
@@ -2,13 +2,13 @@ import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSyn
import { join, resolve } from 'node:path'
import { tmpdir } from 'node:os'
import { describe, expect, it } from 'vitest'
import desktopRuntimeLock from './primary-runtime/lock.json' with { type: 'json' }
import primaryRuntimeLock from './primary-runtime/lock.json' with { type: 'json' }
import {
CLAUDE_AGENT_SDK_PACKAGE,
assertRuntimeLicenses,
claudeDistributionFromManifest,
collectPythonDependencies,
collectDesktopPythonDependencies,
collectBundledPythonDependencies,
isOwnerAuthorizedRuntime,
isPermissive,
type Manifest,
@@ -33,7 +33,7 @@ describe('THIRD_PARTY_NOTICES.md', () => {
}, async () => {
const generated = await render()
expect(generated).toContain('It depends on the third-party software listed below.')
expect(generated).toContain(`| [\`numpy\`](https://github.com/numpy/numpy) | ${desktopRuntimeLock.pythonPackages.numpy} | BSD-3-Clause |`)
expect(generated).toContain(`| [\`numpy\`](https://github.com/numpy/numpy) | ${primaryRuntimeLock.pythonPackages.numpy} | BSD-3-Clause |`)
expect(generated).toContain('## LibreOffice conversion kit')
expect(generated).toContain('Recipients must have access to those corresponding sources and notices.')
expect(readFileSync(resolve(root, 'THIRD_PARTY_NOTICES.md'), 'utf8'), 'stale notices — run `pnpm run gen-third-party-notices`').toBe(generated)
@@ -323,22 +323,22 @@ describe('collectPythonDependencies', () => {
})
})
describe('collectDesktopPythonDependencies', () => {
it('discloses the committed Desktop closure with its exact locked versions', () => {
const dependencies = collectDesktopPythonDependencies(desktopRuntimeLock.pythonPackages)
expect(dependencies).toHaveLength(Object.keys(desktopRuntimeLock.pythonPackages).length)
describe('collectBundledPythonDependencies', () => {
it('discloses the committed bundled Python closure with its exact locked versions', () => {
const dependencies = collectBundledPythonDependencies(primaryRuntimeLock.pythonPackages)
expect(dependencies).toHaveLength(Object.keys(primaryRuntimeLock.pythonPackages).length)
expect(dependencies).toContainEqual({
name: 'pillow', version: desktopRuntimeLock.pythonPackages.Pillow,
name: 'pillow', version: primaryRuntimeLock.pythonPackages.Pillow,
license: 'MIT-CMU', repo: 'https://github.com/python-pillow/Pillow',
})
expect(dependencies).toContainEqual({
name: 'typing-extensions', version: desktopRuntimeLock.pythonPackages.typing_extensions,
name: 'typing-extensions', version: primaryRuntimeLock.pythonPackages.typing_extensions,
license: 'PSF-2.0', repo: 'https://github.com/python/typing_extensions',
})
})
it('normalizes names while preserving pinned version strings', () => {
expect(collectDesktopPythonDependencies({ 'typing_extensions': '4.16.0', 'Pillow': '12.3.0' }))
expect(collectBundledPythonDependencies({ 'typing_extensions': '4.16.0', 'Pillow': '12.3.0' }))
.toEqual([
{ name: 'pillow', version: '12.3.0', license: 'MIT-CMU', repo: 'https://github.com/python-pillow/Pillow' },
{ name: 'typing-extensions', version: '4.16.0', license: 'PSF-2.0', repo: 'https://github.com/python/typing_extensions' },
@@ -346,18 +346,18 @@ describe('collectDesktopPythonDependencies', () => {
})
it('rejects duplicate normalized distribution names with the same locked version', () => {
expect(() => collectDesktopPythonDependencies({ typing_extensions: '4.16.0', 'typing.extensions': '4.16.0' }))
expect(() => collectBundledPythonDependencies({ typing_extensions: '4.16.0', 'typing.extensions': '4.16.0' }))
.toThrow('duplicate normalized names')
})
it('rejects missing distribution metadata and conflicting normalized versions', () => {
expect(() => collectDesktopPythonDependencies({ missing: '1.0' })).toThrow('missing from PYTHON_METADATA')
expect(() => collectDesktopPythonDependencies({ Pillow: '12.3.0', pillow: '12.4.0' })).toThrow('conflicting locked versions')
expect(() => collectBundledPythonDependencies({ missing: '1.0' })).toThrow('missing from PYTHON_METADATA')
expect(() => collectBundledPythonDependencies({ Pillow: '12.3.0', pillow: '12.4.0' })).toThrow('conflicting locked versions')
})
it('applies the runtime license check to bundled Python distributions', () => {
expect(() => { assertRuntimeLicenses(collectDesktopPythonDependencies(desktopRuntimeLock.pythonPackages)) }).not.toThrow()
const dependencies = collectDesktopPythonDependencies({ 'copyleft-wheel': '1.0' }, {
expect(() => { assertRuntimeLicenses(collectBundledPythonDependencies(primaryRuntimeLock.pythonPackages)) }).not.toThrow()
const dependencies = collectBundledPythonDependencies({ 'copyleft-wheel': '1.0' }, {
'copyleft-wheel': { license: 'GPL-3.0-only', repo: 'https://example.com/project' },
})
expect(() => { assertRuntimeLicenses(dependencies) }).toThrow('copyleft-wheel (GPL-3.0-only)')
+15 -15
View File
@@ -1,7 +1,7 @@
/**
* Generate `THIRD_PARTY_NOTICES.md` from the workspace manifests: every
* external dependency named by a workspace `package.json`, the vendored-package
* manifest in `vendor/README.md`, the Python `pyproject.toml` files, the Desktop
* manifest in `vendor/README.md`, the Python `pyproject.toml` files, the shared
* Python distribution lock, and the pnpm patch list. npm metadata comes from the installed
* store, so the tree must be installed. `--check` verifies the committed
* artifact. Tier policy and ownership live in
@@ -13,7 +13,7 @@ import { dirname, resolve } from 'node:path'
import * as yaml from 'js-yaml'
import { parse as parseToml, type TomlTableWithoutBigInt, type TomlValueWithoutBigInt } from 'smol-toml'
import parseSpdx from 'spdx-expression-parse'
import desktopRuntimeLock from './primary-runtime/lock.json' with { type: 'json' }
import primaryRuntimeLock from './primary-runtime/lock.json' with { type: 'json' }
import { browserBundledExternals } from './browser-bundled-externals.ts'
const root = resolve(import.meta.dirname, '..')
@@ -93,7 +93,7 @@ const OVERRIDES: Record<string, { license?: string; repo?: string }> = {
/**
* Python metadata is recorded from the distributions' license and project
* fields; generation does not require installing their wheels. Both Python
* manifests and the Desktop lock reject names absent from this map.
* manifests and the shared runtime lock reject names absent from this map.
*/
const PYTHON_METADATA: Record<string, { license: string; repo: string; role?: string }> = {
pydantic: { license: 'MIT', repo: 'https://github.com/pydantic/pydantic', role: 'runtime dependency of `deepseek-harness-sdk`' },
@@ -616,12 +616,12 @@ function collectPython(): { name: string; license: string; repo: string; role: s
}
/**
* Disclose every Desktop wheel distribution using its locked version, rejecting duplicate normalized names.
* @param packages - Distribution names and exact versions from the Desktop runtime lock.
* Disclose every bundled wheel distribution using its locked version, rejecting duplicate normalized names.
* @param packages - Distribution names and exact versions from the shared runtime lock.
* @param metadata - License and source metadata for every locked distribution.
* @returns Normalized, sorted distribution identities with versions and licenses.
*/
export function collectDesktopPythonDependencies(
export function collectBundledPythonDependencies(
packages: Readonly<Record<string, string>>,
metadata: PythonMetadata = PYTHON_METADATA,
): { name: string; version: string; license: string; repo: string }[] {
@@ -630,14 +630,14 @@ export function collectDesktopPythonDependencies(
const name = normalizePythonDistributionName(distribution)
const previous = normalized.get(name)
if (previous !== undefined && previous !== version) {
throw new Error(`gen-third-party-notices: Desktop python distribution ${name} has conflicting locked versions.`)
throw new Error(`gen-third-party-notices: bundled Python distribution ${name} has conflicting locked versions.`)
}
if (previous !== undefined) throw new Error(`gen-third-party-notices: Desktop python distribution ${name} has duplicate normalized names.`)
if (previous !== undefined) throw new Error(`gen-third-party-notices: bundled Python distribution ${name} has duplicate normalized names.`)
normalized.set(name, version)
}
return [...normalized].sort(([a], [b]) => a.localeCompare(b)).map(([name, version]) => {
const entry = metadata[name]
if (entry === undefined) throw new Error(`gen-third-party-notices: Desktop python distribution ${name} is missing from PYTHON_METADATA.`)
if (entry === undefined) throw new Error(`gen-third-party-notices: bundled Python distribution ${name} is missing from PYTHON_METADATA.`)
return { name, version, license: entry.license, repo: entry.repo }
})
}
@@ -753,7 +753,7 @@ export async function render(): Promise<string> {
const kitRuntime = runtimeDeps.some(dep => dep.name === LIBREOFFICE_KIT_PACKAGE)
const vendored = collectVendored()
const python = collectPython()
const desktopPython = collectDesktopPythonDependencies(desktopRuntimeLock.pythonPackages)
const bundledPython = collectBundledPythonDependencies(primaryRuntimeLock.pythonPackages)
const patched = collectPatched()
const claudeDistribution = runtimeDeps.some(
dep => dep.name === CLAUDE_AGENT_SDK_PACKAGE,
@@ -762,7 +762,7 @@ export async function render(): Promise<string> {
: undefined
const nonPermissiveDev = devDeps.filter(dep => !isPermissive(dep.license))
assertRuntimeLicenses(runtimeDeps)
assertRuntimeLicenses(desktopPython)
assertRuntimeLicenses(bundledPython)
const patchedLines = patched.map(({ spec, patch }) => `- \`${spec}\` — [\`${patch}\`](${patch})`)
return `<!-- Generated by scripts/gen-third-party-notices.ts — do not edit by hand.
@@ -772,7 +772,7 @@ export async function render(): Promise<string> {
DeepSeek Harness is licensed under [MIT](LICENSE). It depends on the third-party software listed below. Each project remains under its own license; nothing in this file changes those terms.
This file lists **direct** dependencies declared by the workspace, the explicitly disclosed official Claude Code platform payload closure, and the Desktop bundled Python distributions. It is generated by \`scripts/gen-third-party-notices.ts\`: a pre-commit hook regenerates it whenever a staged file changes one of its inputs, and \`scripts/gen-third-party-notices.spec.ts\` asserts in the test lane that the committed bytes match. Deleting a manifest runs no hook, so that case is caught by the assertion instead. Run \`pnpm run verify-third-party-notices\` for the standalone check.
This file lists **direct** dependencies declared by the workspace, the explicitly disclosed official Claude Code platform payload closure, and the Bundled Python distributions. It is generated by \`scripts/gen-third-party-notices.ts\`: a pre-commit hook regenerates it whenever a staged file changes one of its inputs, and \`scripts/gen-third-party-notices.spec.ts\` asserts in the test lane that the committed bytes match. Deleting a manifest runs no hook, so that case is caught by the assertion instead. Run \`pnpm run verify-third-party-notices\` for the standalone check.
The complete npm transitive closure, including the Landlock launcher workspace, is recorded with exact pinned versions in [\`pnpm-lock.yaml\`](pnpm-lock.yaml) — inspect it with \`pnpm licenses list\`. The Python SDK closure is recorded separately in [\`python/sdk/uv.lock\`](python/sdk/uv.lock).
@@ -817,13 +817,13 @@ Direct dependencies of the \`pyproject.toml\` manifests, plus \`uv\` as the deve
${python.map(dep => `| [\`${dep.name}\`](${dep.repo}) | ${dep.license} | ${dep.role} |`).join('\n')}
| [\`uv\`](https://github.com/astral-sh/uv) | MIT / Apache-2.0 | development workflow tool |
## Desktop bundled Python distributions
## Bundled Python distributions
The [Desktop runtime lock](scripts/primary-runtime/lock.json) records each distribution version and the wheel download hashes. The table includes every entry in \`pythonPackages\`, including transitive dependencies. Wheel extraction preserves distribution metadata and the license and notice files supplied by each archive. Project licenses below do not enumerate the separate licenses of native libraries bundled inside wheels.
The [shared runtime lock](scripts/primary-runtime/lock.json) records each distribution version and the wheel download hashes. The table includes every entry in \`pythonPackages\`, including transitive dependencies. Wheel extraction preserves distribution metadata and the license and notice files supplied by each archive. Project licenses below do not enumerate the separate licenses of native libraries bundled inside wheels.
| Distribution | Locked version | Project license |
| --- | --- | --- |
${desktopPython.map(dep => `| [\`${dep.name}\`](${dep.repo}) | ${dep.version} | ${dep.license} |`).join('\n')}
${bundledPython.map(dep => `| [\`${dep.name}\`](${dep.repo}) | ${dep.version} | ${dep.license} |`).join('\n')}
## First-party native packages
+13
View File
@@ -1,3 +1,4 @@
import { readFileSync } from 'node:fs'
import { createHash } from 'node:crypto'
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
@@ -133,3 +134,15 @@ it('copies complete Office resources outside the application archive and removes
it('gives Python-only payloads a distinct identity', () => {
expect(primaryRuntimePayloadDigest('linux-x64', lock, undefined)).not.toBe(primaryRuntimePayloadDigest('linux-x64', lock, '11.7.0'))
})
it('keeps carrier pnpm versions aligned with the shared payload build', () => {
const root = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')) as {
packageManager: string
devDependencies: { pnpm: string }
}
const desktop = JSON.parse(readFileSync(new URL('../../apps/desktop/package.json', import.meta.url), 'utf8')) as {
devDependencies: { pnpm: string }
}
expect(desktop.devDependencies.pnpm).toBe(root.devDependencies.pnpm)
expect(root.packageManager).toBe(`pnpm@${root.devDependencies.pnpm}`)
})