Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix: enforce pinned-runtime contract in DSH release pipeline
momoyeyua574f00278de
diff --git a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs b/integrations/deepseek-harness/scripts/distribution-acceptance.mjsindex f933b5b0..c46b4f2b 100644--- a/integrations/deepseek-harness/scripts/distribution-acceptance.mjs+++ b/integrations/deepseek-harness/scripts/distribution-acceptance.mjs@@ -15,7 +15,8 @@ const repoRoot = path.resolve(integrationRoot, '..', '..');const PACKAGE_NAME = manifest.name;const PACKAGE_VERSION = manifest.version;const DSH_RELEASE_REF = release.sourceCommit;-const DSH_SPEC = `@deepseek-ai/dsh@${release.dshVersion}`;+const DSH_PACKAGE_NAME = '@deepseek-ai/dsh';+const DSH_SPEC = `${DSH_PACKAGE_NAME}@${release.dshVersion}`;const PROFILE = 'archify-dsh-acceptance';const DSH_RUNTIME_INSTALL_TIMEOUT = process.platform === 'win32' ? 600_000 : 300_000;const PLUGIN_MUTATION_TIMEOUT = 180_000;@@ -248,9 +249,12 @@ requireStatus('dsh-runtime-install', runtimeInstall, {const dshPackageRoot = path.join(dshRuntime, 'node_modules', '@deepseek-ai', 'dsh');const dshManifest = JSON.parse(fs.readFileSync(path.join(dshPackageRoot, 'package.json'), 'utf8'));const dshBin = path.join(dshPackageRoot, 'lib', 'bin.js');-if (dshManifest.version !== DSH_SPEC.slice(DSH_SPEC.lastIndexOf('@') + 1) || !fs.existsSync(dshBin)) {+if (dshManifest.name !== DSH_PACKAGE_NAME || dshManifest.version !== release.dshVersion+ || !fs.existsSync(dshBin)) {fail('dsh-runtime-install', 'installed DSH runtime identity mismatch', {+ name: dshManifest.name,version: dshManifest.version,+ expectedVersion: release.dshVersion,binExists: fs.existsSync(dshBin),});}diff --git a/integrations/deepseek-harness/scripts/pack.mjs b/integrations/deepseek-harness/scripts/pack.mjsindex ebfa0a1b..18e9b6fb 100644--- a/integrations/deepseek-harness/scripts/pack.mjs+++ b/integrations/deepseek-harness/scripts/pack.mjs@@ -24,7 +24,7 @@ try {stageCleanSkill({ repoRoot: snapshot, destination: path.join(stage, 'skills', 'archify') });fs.copyFileSync(path.join(snapshot, 'LICENSE'), path.join(stage, 'LICENSE'));- const packed = spawnCliSync('npm', ['pack', '--json', '--pack-destination', stage], {+ const packed = spawnCliSync('npm', ['pack', '--json', '--ignore-scripts', '--pack-destination', stage], {cwd: stage,encoding: 'utf8',});diff --git a/integrations/deepseek-harness/scripts/release-source.mjs b/integrations/deepseek-harness/scripts/release-source.mjsindex add431e7..b7e209e4 100644--- a/integrations/deepseek-harness/scripts/release-source.mjs+++ b/integrations/deepseek-harness/scripts/release-source.mjs@@ -62,6 +62,17 @@ if (!/^[a-f0-9]{40}$/.test(release.sourceCommit)) {throw new Error('DSH release sourceCommit must be a full immutable Git commit');}+// Only an exact SemVer may pin the runtime: ranges, tags, registry aliases,+// URLs, and local paths would let the committed release file substitute an+// arbitrary package for @deepseek-ai/dsh.+const EXACT_SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;+if (typeof release.dshVersion !== 'string' || !EXACT_SEMVER.test(release.dshVersion)) {+ throw new Error(`DSH release dshVersion must be an exact SemVer version: ${JSON.stringify(release.dshVersion)}`);+}+if (Object.keys(manifest.scripts || {}).length > 0) {+ throw new Error(`DSH adapter manifest must not declare npm scripts: ${Object.keys(manifest.scripts).join(', ')}`);+}+export function releaseSnapshot(destination) {// A separate checkout gives the canonical stager a real index, preserves Git// modes, and cannot include uncommitted or untracked files from the caller.diff --git a/integrations/deepseek-harness/test/adapter-staging.test.mjs b/integrations/deepseek-harness/test/adapter-staging.test.mjsindex b23cf72f..c5359a8e 100644--- a/integrations/deepseek-harness/test/adapter-staging.test.mjs+++ b/integrations/deepseek-harness/test/adapter-staging.test.mjs@@ -43,6 +43,7 @@ function fixture() {'archify/renderers/shared/portable-path.mjs','archify/renderers/shared/sidecar-path.mjs','integrations/deepseek-harness/scripts/release-source.mjs',+ 'integrations/deepseek-harness/scripts/pack.mjs',];for (const relative of contractFiles) {const target = path.join(checkout, ...relative.split('/'));@@ -336,3 +337,73 @@ test('pack rejects committed adapter paths that collide by normalization and casfs.rmSync(root, { recursive: true, force: true });}});++test('pack accepts committed exact-SemVer dshVersion values including prereleases', () => {+ const { root, checkout } = fixture();+ try {+ const releasePath = adapterPath(checkout, 'release.json');+ for (const dshVersion of ['0.1.2-rc.2', '1.0.0', '2.0.0-alpha.1+build.5']) {+ const release = JSON.parse(fs.readFileSync(releasePath, 'utf8'));+ release.dshVersion = dshVersion;+ fs.writeFileSync(releasePath, `${JSON.stringify(release, null, 2)}\n`);+ commitFixture(checkout, `test: pin exact dshVersion ${dshVersion}`);+ const { out, result } = pack(checkout, root);+ assert.equal(result.status, 0, `${dshVersion}: ${result.stderr || result.stdout}`);+ assert.equal(fs.existsSync(out), true, dshVersion);+ fs.rmSync(out, { force: true });+ }+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});++test('pack rejects a committed non-SemVer dshVersion before any install or pack step', () => {+ const { root, checkout } = fixture();+ try {+ const releasePath = adapterPath(checkout, 'release.json');+ const hostileVersions = [+ 'npm:[email protected]',+ 'jsr:[email protected]',+ '^0.1.2',+ '0.1.2 || 1.0.0',+ 'latest',+ 'file:../payload',+ './payload',+ 'https://example.invalid/payload.tgz',+ 'github:attacker/repo',+ ];+ for (const dshVersion of hostileVersions) {+ const release = JSON.parse(fs.readFileSync(releasePath, 'utf8'));+ release.dshVersion = dshVersion;+ fs.writeFileSync(releasePath, `${JSON.stringify(release, null, 2)}\n`);+ commitFixture(checkout, `test: pin hostile dshVersion ${dshVersion}`);+ const { out, result } = pack(checkout, root);+ assert.notEqual(result.status, 0, dshVersion);+ assert.match(`${result.stderr}\n${result.stdout}`, /dshVersion must be an exact SemVer version/);+ assert.equal(fs.existsSync(out), false, dshVersion);+ }+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});++test('pack rejects a committed adapter manifest declaring scripts and leaves no target tarball', () => {+ const { root, checkout } = fixture();+ try {+ const marker = path.join(root, 'lifecycle-marker');+ const manifestPath = adapterPath(checkout, 'package.json');+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));+ manifest.scripts = { prepack: `touch ${JSON.stringify(marker)}`, postpack: `touch ${JSON.stringify(marker)}.post` };+ fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);+ commitFixture(checkout, 'test: commit adapter lifecycle scripts');++ const { out, result } = pack(checkout, root);+ assert.notEqual(result.status, 0);+ assert.match(`${result.stderr}\n${result.stdout}`, /must not declare npm scripts/);+ assert.equal(fs.existsSync(out), false);+ assert.equal(fs.existsSync(marker), false, 'prepack must not execute');+ assert.equal(fs.existsSync(`${marker}.post`), false, 'postpack must not execute');+ } finally {+ fs.rmSync(root, { recursive: true, force: true });+ }+});diff --git a/integrations/deepseek-harness/test/package-contract.test.mjs b/integrations/deepseek-harness/test/package-contract.test.mjsindex f90b61c9..31c56177 100644--- a/integrations/deepseek-harness/test/package-contract.test.mjs+++ b/integrations/deepseek-harness/test/package-contract.test.mjs@@ -17,7 +17,7 @@ const DEPENDENCY_FIELDS = ['bundledDependencies','bundleDependencies',];-const LIFECYCLE_SCRIPTS = ['prepare', 'install', 'postinstall', 'preinstall'];+test('adapter source lives only under integrations/deepseek-harness with no root workspace', () => {assert.equal(fs.existsSync(path.join(repoRoot, 'package.json')), false);@@ -43,9 +43,7 @@ test('publishable manifest is @tt-a1i/[email protected] with a DSH bundle patchfor (const field of DEPENDENCY_FIELDS) {assert.equal(Object.prototype.hasOwnProperty.call(pkg, field), false, field);}- for (const script of LIFECYCLE_SCRIPTS) {- assert.equal(pkg.scripts?.[script], undefined, script);- }+ assert.equal(Object.keys(pkg.scripts || {}).length, 0, 'adapter manifest must not declare npm scripts');assert.match(pkg.exports?.['./package.json'] || '', /package\.json/);});@@ -84,6 +82,30 @@ test('distribution acceptance reserves stdout for its machine-readable JSON receassert.equal([...source.matchAll(/process\.stdout\.write/g)].length, 2);});+test('pack and acceptance enforce the pinned-runtime contract before executing it', () => {+ const releaseSource = fs.readFileSync(+ path.join(integrationRoot, 'scripts', 'release-source.mjs'),+ 'utf8',+ );+ assert.match(releaseSource, /dshVersion must be an exact SemVer version/);+ assert.match(releaseSource, /manifest\.scripts/);+ const packSource = fs.readFileSync(+ path.join(integrationRoot, 'scripts', 'pack.mjs'),+ 'utf8',+ );+ assert.match(packSource, /--ignore-scripts/);+ const acceptance = fs.readFileSync(+ path.join(integrationRoot, 'scripts', 'distribution-acceptance.mjs'),+ 'utf8',+ );+ assert.match(acceptance, /dshManifest\.name !== DSH_PACKAGE_NAME/);+ assert.match(acceptance, /dshManifest\.version !== release\.dshVersion/);+ const identityCheck = acceptance.indexOf('dshManifest.name !== DSH_PACKAGE_NAME');+ const entryExec = acceptance.indexOf('[dshBin, ...args]');+ assert.ok(identityCheck !== -1 && entryExec !== -1 && identityCheck < entryExec,+ 'installed identity must be verified before the DSH entry runs');+});+test('distribution receipt separates canonical ZIP bytes from cross-platform content checks', () => {const source = fs.readFileSync(path.join(integrationRoot, 'scripts', 'distribution-acceptance.mjs'),