diff --git a/.github/workflows/attach-release-vsix.yml b/.github/workflows/attach-release-vsix.yml index 347041e6..c904fc01 100644 --- a/.github/workflows/attach-release-vsix.yml +++ b/.github/workflows/attach-release-vsix.yml @@ -31,9 +31,53 @@ jobs: with: release-tag: ${{ inputs.tag }} - attach: + qualify: needs: build runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - run: node --test scripts/verify-release-packages.test.mjs + - uses: actions/download-artifact@v4 + with: + name: ${{ needs.build.outputs.artifact-name }} + path: output + - name: Verify and unpack the exact candidate VSIX + env: + EXPECTED_SHA: ${{ needs.build.outputs.sha256 }} + run: | + set -euo pipefail + vsix=$(ls output/*.vsix) + test "$(sha256sum "$vsix" | cut -d' ' -f1)" = "$EXPECTED_SHA" + mkdir -p "$RUNNER_TEMP/draft-vsix" + unzip -q "$vsix" -d "$RUNNER_TEMP/draft-vsix" + echo "TX_E2E_EXTENSION_PATH=$RUNNER_TEMP/draft-vsix/extension" >> "$GITHUB_ENV" + echo "VSIX_SHA256=$EXPECTED_SHA" >> "$GITHUB_ENV" + echo "TX_E2E_PACKAGE_OUTPUT=$GITHUB_WORKSPACE/qualified" >> "$GITHUB_ENV" + - name: Qualify the packaged UI and retain its exact installed CLI archive + run: xvfb-run -a npm run test:e2e-extension:packaged + - name: Package the matching diagrams workspace + run: npm pack --ignore-scripts --workspace packages/diagrams --pack-destination qualified --json > qualified/diagrams-pack.json + - name: Hash qualified assets + run: | + cd qualified + sha256sum *.tgz *.json > SHA256SUMS + - name: Verify qualified identities and refusal controls + run: node scripts/verify-release-packages.mjs qualified output/*.vsix + - uses: actions/upload-artifact@v4 + with: + name: qualified-release-packages + path: qualified/* + if-no-files-found: error + retention-days: 7 + + attach: + needs: [build, qualify] + runs-on: ubuntu-latest permissions: contents: write steps: @@ -43,6 +87,14 @@ jobs: name: ${{ needs.build.outputs.artifact-name }} path: output + - uses: actions/download-artifact@v4 + with: + name: qualified-release-packages + path: qualified + + - name: Verify qualified package hashes + run: cd qualified && sha256sum --check SHA256SUMS + - name: Verify downloaded artifact matches the attested hash shell: bash run: | @@ -115,7 +167,7 @@ jobs: # host `gh api` defaults to for a bare path — `gh release upload` targets # the correct host itself. gh release upload "${{ inputs.tag }}" \ - output/*.vsix output/*.sha256 output/sbom.xml \ + output/*.vsix output/*.sha256 output/sbom.xml qualified/* \ -R ${{ github.repository }} - name: Update release notes with attestation verification command diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index ce870593..9b7acbfc 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -22,7 +22,12 @@ name: npm — publish packages on: release: types: [published] - workflow_dispatch: {} + workflow_dispatch: + inputs: + tag: + description: Published release tag whose verified assets will be published + required: true + type: string permissions: contents: read @@ -48,9 +53,12 @@ jobs: - name: Check npm channel selection run: node --test scripts/npm-publish-tag.test.mjs + - name: Test exact package refusal controls + run: node --test scripts/verify-release-packages.test.mjs + - name: Check release package versions env: - RELEASE_TAG: ${{ github.event.release.tag_name }} + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }} run: node scripts/check-release-versions.mjs publish: @@ -76,33 +84,35 @@ jobs: - name: Install OIDC-capable npm run: npm install --global npm@11 - - name: Install root dependencies - run: npm ci - - - name: Build @transitrix/diagrams - run: npm run build --workspace packages/diagrams - - # Each package selects next for a prerelease and latest for a stable version. - # Publish order matters: diagrams first, then cli (runbook convention). - - name: Publish @transitrix/diagrams (skips if version already published) + - name: Download the release-qualified package archives + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }} run: | - LOCAL=$(node -p "require('./packages/diagrams/package.json').version") - DIST_TAG=$(node scripts/npm-publish-tag.mjs "$LOCAL") - PUBLISHED=$(npm view "@transitrix/diagrams@$LOCAL" version 2>/dev/null || echo "") - if [ "$PUBLISHED" = "$LOCAL" ]; then - echo "@transitrix/diagrams@$LOCAL is already on the registry — skipping." - else - npm publish --workspace packages/diagrams --access public --tag "$DIST_TAG" - fi - - - name: Publish @transitrix/cli (skips if version already published) + set -euo pipefail + test -n "$RELEASE_TAG" + gh api "/repos/$GITHUB_REPOSITORY/releases/tags/$RELEASE_TAG" > release.json + node -e "const r=require('./release.json'); if(r.draft || r.target_commitish !== process.env.GITHUB_SHA) process.exit(1)" + mkdir qualified + gh release download "$RELEASE_TAG" -R "$GITHUB_REPOSITORY" --dir qualified \ + --pattern '*.tgz' --pattern '*.vsix' --pattern 'cli-qualification.json' --pattern 'runtime-audit.json' --pattern 'SHA256SUMS' + - name: Verify exact qualified package identities + run: node scripts/verify-release-packages.mjs qualified qualified/*.vsix + + # These are the exact qualified archives. Never rebuild at publication. + - name: Publish verified archives (skip only identical registry bytes) run: | - LOCAL=$(node -p "require('./packages/cli/package.json').version") - DIST_TAG=$(node scripts/npm-publish-tag.mjs "$LOCAL") - PUBLISHED=$(npm view "@transitrix/cli@$LOCAL" version 2>/dev/null || echo "") - if [ "$PUBLISHED" = "$LOCAL" ]; then - echo "@transitrix/cli@$LOCAL is already on the registry — skipping." - else - # prepack (scripts/build-cli-package.mjs) assembles dist/ + schemas/. - npm publish --workspace packages/cli --access public --tag "$DIST_TAG" - fi + set -euo pipefail + for package in diagrams cli; do + version=$(node -p "require('./packages/$package/package.json').version") + archive="qualified/transitrix-$package-$version.tgz" + integrity=$(node -e "const fs=require('fs'),c=require('crypto');console.log('sha512-'+c.createHash('sha512').update(fs.readFileSync(process.argv[1])).digest('base64'))" "$archive") + published=$(npm view "@transitrix/$package@$version" dist.integrity 2>/dev/null || true) + if [ -n "$published" ]; then + test "$published" = "$integrity" || { echo 'Existing package integrity differs'; exit 1; } + echo "Identical @transitrix/$package@$version already published; skipping" + else + channel=$(node scripts/npm-publish-tag.mjs "$version") + npm publish "$archive" --ignore-scripts --access public --tag "$channel" + fi + done diff --git a/CHANGELOG.md b/CHANGELOG.md index 430e5f82..ef9b8b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [3.10.0] — 2026-11-08 + +### Added + +- Per-file relation validation with admission and quoted inclusive lifecycle dates; actor identity validation rejects inline reporting fields. (#742) + +### Changed + +- CLI 2.13.0 and diagrams 1.17.0 move together; requirements reports retain transport 1, projection 0.3 and the explicit 0.2 adapter. +- Updated dependencies since 3.9.0 remain subject to exact-candidate checks. + +Known vocabulary limitation: the same 22 baseline drift entries (declared +methodology 3.1.0 versus vendored 3.3.0, block-grid TYPE registry and unbound +vocabulary registries) are explicitly renewed only until 2026-11-16. This +release does not claim complete Methodology 8.0.0 vocabulary conformance. New, +stale or subsequently expired exceptions still fail closed. + +See [compatibility and candidate qualification](docs/releases/3.10.0-compatibility.md). No publication or installed support is claimed. + ## [3.9.0] — 2026-10-25 ### Added diff --git a/changelog/fragments/person-reporting-validation.md b/changelog/fragments/person-reporting-validation.md deleted file mode 100644 index 0aaa34ca..00000000 --- a/changelog/fragments/person-reporting-validation.md +++ /dev/null @@ -1,6 +0,0 @@ -### Added - -- Per-file relation validation accepts `reports_to` and checks scalar endpoints, - admission metadata and inclusive lifecycle dates. Actor validation rejects - inline reporting fields while preserving free-form extensions. Reporting - graph validation and dated queries remain separate from file validation. diff --git a/docs/internal/release-runbook.md b/docs/internal/release-runbook.md index 08f36af9..4c5fee3e 100644 --- a/docs/internal/release-runbook.md +++ b/docs/internal/release-runbook.md @@ -11,7 +11,7 @@ from CI. | Artifact | Pipeline | Trigger | |---|---|---| | Universal VSIX, attached to the release + SHA-256 recorded | `.github/workflows/attach-release-vsix.yml` | Explicit `workflow_dispatch` for an existing draft tag, run against its exact target commit | -| `@transitrix/diagrams` + `@transitrix/cli` → npm | `.github/workflows/npm-publish.yml` | GitHub Release **published** (or `workflow_dispatch`) | +| `@transitrix/diagrams` + `@transitrix/cli` → npm (verified attached archives) | `.github/workflows/npm-publish.yml` | GitHub Release **published** (or `workflow_dispatch`) | | VS Code extension → VS Code Marketplace | `.github/workflows/vscode-marketplace-publish.yml` | `workflow_dispatch` only — see that workflow's header before changing this | | VS Code extension → Open VSX (Cursor / VSCodium / Windsurf) | `.github/workflows/openvsx-publish.yml` | GitHub Release **published** (or `workflow_dispatch`); downloads the asset `attach-release-vsix.yml` attached rather than rebuilding | | IntelliJ plugin → JetBrains Marketplace | `.github/workflows/jetbrains-publish.yml` | GitHub Release **published** (plugin version derived from the release tag, `v` prefix stripped) | @@ -165,3 +165,7 @@ npm deprecate @transitrix/diagrams@1.0.0 "Broken — use 1.0.1+" [`openvsx-publish-runbook.md`](openvsx-publish-runbook.md) — the marketplace-specific notes the workflows codify. - [`docs/cli.md`](cli.md) — CLI install docs. + +## Qualified package identity + +The draft-attachment workflow gates attachment on packaged UI/CLI tests and a zero-vulnerability runtime audit. It retains the exact tested CLI archive; publication verifies the attached archives against source/version/hash receipts and publishes those bytes with lifecycle scripts disabled. An existing registry version is skipped only when its integrity matches. No rebuild may silently replace the qualified package. Draft creation and attachment do not publish a release. diff --git a/docs/releases/3.10.0-compatibility.md b/docs/releases/3.10.0-compatibility.md new file mode 100644 index 00000000..4269d595 --- /dev/null +++ b/docs/releases/3.10.0-compatibility.md @@ -0,0 +1,64 @@ +# Studio 3.10.0 preparation candidate + +Status: proposed source changes; no release, installation or final artifact qualification. + +| Surface | Proposed version | Classification | +|---|---|---| +| Studio / extension | 3.10.0 | MINOR: newly supported relation-file validation; no command or supported report contract removed | +| CLI | 2.13.0 | MINOR: new file-validation support; bundled diagrams must move with the source | +| diagrams | 1.17.0 | MINOR: correct enforcement of the existing actor identity boundary | +| Methodology | 8.0.0 | Separate MAJOR: closed relation enum expansion and stricter adopter tooling | + +## Compatibility disposition + +Compare Studio v3.9.0 (`4ad085e14e7cc9c1662e55065c183e09a42f95c6`) +with the source baseline `b5651f326f59f82155eed327ecbebd80d954fecd`. +Before #742, `relation` had no file validator and was in the registered-but- +unsupported population. An unvalidated/strict-failing input is not a previously +supported clean result. Admission and quoted lifecycle date checks therefore +add support, rather than remove supported relation-file behavior. They do not +prove catalogue identity, actor subtype, cycles or reporting health. + +Methodology v7.0.0 already describes ACTOR as identity-only, with engagement and +hierarchy in first-class REL records (19-actors §1/§5 and ACTOR-003). +Rejecting inline `manager` / `reports_to` corrects previously permissive tooling; +it does not remove a field admitted by that contract. Preserve authored values +for review; never infer reporting from employment or silently move data. +Free-form `extensions` stay opaque. Existing supported employment/unit_parent +forms and admission/lifecycle positives and negatives are retained by +`tests/relation-validation.test.ts`; actor tests retain the extensions control. + +These MINOR classifications concern these package contracts, independently of +Methodology's closed-enum MAJOR policy. If review produces an old-contract-valid, +previously supported counterexample, revise the affected package to MAJOR with +migration guidance before merging this preparation. + +## Exact caller boundary + +The requirements-analysis skill must pin the final full Studio commit containing +this version change and the 2.13.0 package identity, not just a branch or version +range. `requirements-build.json` embeds the build's source revision. A candidate +receipt must also record the tarball SHA-256/npm integrity, bundled diagrams +1.17.0 and emitted tool version/source revision. No artifact hash exists in this +source-only proposal. A later merge/rebuild requires its own receipt and skill +map update; do not substitute public 2.12.1 or the old 2.12.0 candidate. + +Transport stays `requirements-report/1`; projection stays `requirement-chain/0.3` +with the explicit `requirement-chain/0.2` adapter retained. Keep PRODUCT and +APPLICATION identities, project/release/as-at/source provenance, unknown totals, +exact contributing IDs and the accepted UI oracle. No Phase 2 metrics are added. + +## Qualification remaining for these changed candidates + +Run source version/lock guards, affected relation/actor controls and retained +requirements projection tests in the exact locked environment. Then qualify the +exact packed CLI's identity, four subject fixtures, negative controls, replay +and unchanged model bytes, and correlate the versioned VSIX's UI populations/IDs. +Reuse historical #711/#712/#742 evidence only at its recorded scope and identity; +unchanged leaf blobs alone do not qualify a rebuilt dependency environment. +This preparation does not repeat earlier machine operations or claim those checks. + +JetBrains derives its version from the extension release. Obsidian 0.1.1 keeps +its independent identity. Language advisories remain opt-in/experimental. +Publishing a GitHub Release triggers npm, Open VSX and JetBrains; none is +triggered by this proposal. Microsoft Marketplace remains excluded. diff --git a/extension/CHANGELOG.md b/extension/CHANGELOG.md index d0f4af59..2e3e65fe 100644 --- a/extension/CHANGELOG.md +++ b/extension/CHANGELOG.md @@ -1,5 +1,10 @@ # Transitrix Studio — changelog +## 3.10.0 — 2026-11-08 + +- Adds relation-file conformance validation and enforces the existing actor identity boundary. Reporting graph checks remain separate. +- Requirements report semantics and opt-in language advisories are retained. Exact versioned package/UI qualification is pending; no release is claimed. + ## 3.9.0 — 2026-10-25 ### Added diff --git a/extension/package-lock.json b/extension/package-lock.json index 4973ff1e..c14668e7 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -1,12 +1,12 @@ { "name": "transitrix-studio", - "version": "3.4.2", + "version": "3.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "transitrix-studio", - "version": "3.4.2", + "version": "3.10.0", "license": "MIT", "engines": { "vscode": "^1.85.0" diff --git a/extension/package.json b/extension/package.json index 85e9d061..2f501a2d 100644 --- a/extension/package.json +++ b/extension/package.json @@ -2,7 +2,7 @@ "name": "transitrix-studio", "displayName": "Transitrix Studio", "publisher": "transitrix", - "version": "3.9.0", + "version": "3.10.0", "description": "Diagrams as text: 17 YAML notations plus release-scoped requirement traceability, live in your editor. Diffable in git. AI-friendly. Open source.", "license": "MIT", "icon": "icon.png", diff --git a/extension/test-e2e/runTest.ts b/extension/test-e2e/runTest.ts index ce7a1bfe..0971b257 100644 --- a/extension/test-e2e/runTest.ts +++ b/extension/test-e2e/runTest.ts @@ -39,10 +39,14 @@ async function main(): Promise { }); npm(['run', 'build:diagrams']); npm(['pack', '--workspace', 'packages/cli', '--pack-destination', consumerDir, '--cache', path.join(consumerDir, 'cache'), '--json']); - const tarball = fs.readdirSync(consumerDir).find(name => name.endsWith('.tgz')); + // Lifecycle stdout may precede npm's JSON. Use the manifest-bound filename + // and hash actual archive bytes rather than parsing mixed stdout. + const tarball = `transitrix-cli-${cliVersion}.tgz`; if (!tarball) throw new Error('CLI packaging produced no tarball'); const packagePath = path.join(consumerDir, tarball); - const packageHash = createHash('sha256').update(fs.readFileSync(packagePath)).digest('hex'); + const packageBytes = fs.readFileSync(packagePath); + const packageHash = createHash('sha256').update(packageBytes).digest('hex'); + const packageIntegrity = 'sha512-' + createHash('sha512').update(packageBytes).digest('base64'); npm(['install', '--prefix', consumerDir, '--ignore-scripts', '--no-audit', '--no-fund', '--cache', path.join(consumerDir, 'cache'), packagePath]); const callerPath = path.join(consumerDir, 'node_modules', '@transitrix', 'cli', 'dist', 'cli.js'); const sourceRevision = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: repoRoot, encoding: 'utf8' }).trim(); @@ -90,6 +94,25 @@ async function main(): Promise { if (exitCode !== 0) { throw new Error(`extension-e2e: VS Code test host exited with code ${exitCode}`); } + // Retain the exact installed/tested archive, never a post-test rebuild. + const packageOutput = process.env.TX_E2E_PACKAGE_OUTPUT; + if (packageOutput) { + const audit = JSON.parse(npm(['audit', '--prefix', consumerDir, '--omit=dev', '--json'])); + if (audit.metadata?.vulnerabilities?.total !== 0) throw new Error('Candidate runtime audit must report zero vulnerabilities'); + fs.mkdirSync(packageOutput, { recursive: true }); + const target = path.join(packageOutput, tarball!); + if (fs.existsSync(target) || fs.existsSync(path.join(packageOutput, 'cli-qualification.json'))) throw new Error('Refusing to overwrite retained candidate evidence'); + fs.copyFileSync(packagePath, target); + fs.writeFileSync(path.join(packageOutput, 'runtime-audit.json'), JSON.stringify(audit, null, 2) + '\n'); + fs.writeFileSync(path.join(packageOutput, 'cli-qualification.json'), JSON.stringify({ + schema: 'transitrix-packaged-ui-cli-qualification/1', sourceRevision, + cliVersion, diagramsVersion: JSON.parse(fs.readFileSync(path.join(repoRoot, 'packages/diagrams/package.json'), 'utf8')).version, + artifact: tarball, sha256: packageHash, integrity: packageIntegrity, + vsixSha256: process.env.VSIX_SHA256 ?? null, + reportContract: 'requirement-chain/0.3', transport: 'requirements-report/1', + exactArchiveUsedByPackagedUiTests: true, runtimeAuditVulnerabilities: 0, + }, null, 2) + '\n'); + } console.log(`extension-e2e: all tests passed. PNG captures in ${captureDir}`); } finally { fs.rmSync(consumerDir, { recursive: true, force: true }); diff --git a/package-lock.json b/package-lock.json index 0048b15f..1ab7b6ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "transitrix-studio", - "version": "3.9.0", + "version": "3.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "transitrix-studio", - "version": "3.9.0", + "version": "3.10.0", "license": "MIT", "workspaces": [ "packages/*" @@ -7949,7 +7949,7 @@ }, "packages/cli": { "name": "@transitrix/cli", - "version": "2.12.1", + "version": "2.13.0", "license": "MIT", "dependencies": { "@resvg/resvg-js": "^2.6.2", @@ -7968,7 +7968,7 @@ }, "packages/diagrams": { "name": "@transitrix/diagrams", - "version": "1.16.1", + "version": "1.17.0", "license": "MIT", "devDependencies": { "@testing-library/dom": "^10.4.2", diff --git a/package.json b/package.json index 7b3adfb4..7fcd2881 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "transitrix-studio", - "version": "3.9.0", + "version": "3.10.0", "private": true, "workspaces": [ "packages/*" diff --git a/packages/cli/README.md b/packages/cli/README.md index 81506fe9..353782e5 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -119,9 +119,14 @@ MIT — see [`LICENSE`](./LICENSE). ## Requirements reports -The 2.12.0 source candidate adds `requirements-report`; 2.11.0 does not provide -this command. Publication is separate from building a candidate. Install the -supplied 2.12.0 tarball with `npm install --ignore-scripts /path/to/transitrix-cli-2.12.0.tgz` +The 2.13.0 preparation candidate retains `requirements-report/1` and +`requirement-chain/0.3`, including the explicit 0.2 adapter. CLI 2.11.0 does not +provide this command. The earlier qualified 2.12.0 handoff remains historical +evidence at its original source; it does not qualify these new package bytes. +See [candidate compatibility](../../docs/releases/3.10.0-compatibility.md). +Publication is separate from building a candidate. Only after its exact source +and artifact integrity are supplied and verified, install the supplied tarball +with `npm install --ignore-scripts /path/to/transitrix-cli-2.13.0.tgz` in an empty consumer project, then use its executable on Node 20 or newer: ```sh diff --git a/packages/cli/package.json b/packages/cli/package.json index 7eab98a9..0019d7a7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@transitrix/cli", - "version": "2.12.1", + "version": "2.13.0", "type": "module", "description": "Transitrix CLI: compile, validate, and report on Transitrix diagrams from any shell or CI pipeline.", "license": "MIT", diff --git a/packages/diagrams/package.json b/packages/diagrams/package.json index b012da96..08e39440 100644 --- a/packages/diagrams/package.json +++ b/packages/diagrams/package.json @@ -1,6 +1,6 @@ { "name": "@transitrix/diagrams", - "version": "1.16.1", + "version": "1.17.0", "type": "module", "description": "Shared rendering, validation, and pure mutations for Transitrix custom diagram formats.", "license": "MIT", diff --git a/publish-manifest.yaml b/publish-manifest.yaml index b1e59b1c..44a9d982 100644 --- a/publish-manifest.yaml +++ b/publish-manifest.yaml @@ -36,7 +36,6 @@ published: - RELEASING.md - SECURITY.md - changelog/fragments/README.md - - changelog/fragments/person-reporting-validation.md - docs/README.md - docs/cli.md - docs/document-provenance.md @@ -74,6 +73,7 @@ published: - docs/internal/vsix-audit-v3.2.0/scans.md - docs/notation.md - docs/repo-layout.md + - docs/releases/3.10.0-compatibility.md - docs/requirement-advisories.md - docs/validation.md - extension/.vscodeignore @@ -805,6 +805,8 @@ published: - scripts/vendor-methodology-document-renderer.mjs - scripts/vendor-methodology-vocabulary.mjs - scripts/verify-extension-packaging.mjs + - scripts/verify-release-packages.mjs + - scripts/verify-release-packages.test.mjs - scripts/verify-extension-packaging.test.mjs - src/bpmn-export-profile.ts - src/bpmn-moddle.d.ts diff --git a/scripts/verify-release-packages.mjs b/scripts/verify-release-packages.mjs new file mode 100644 index 00000000..32f8526a --- /dev/null +++ b/scripts/verify-release-packages.mjs @@ -0,0 +1,43 @@ +import { readFileSync } from 'node:fs'; +import { createHash } from 'node:crypto'; +import { execFileSync } from 'node:child_process'; +import { resolve, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +const root = resolve(fileURLToPath(new URL('..', import.meta.url))); +const sha = (file, algorithm = 'sha256') => createHash(algorithm).update(readFileSync(file)).digest(algorithm === 'sha512' ? 'base64' : 'hex'); +export function verifyPackages(dir, source, versions, expectedVsixSha256) { + if (!/^[a-f0-9]{40}$/.test(source ?? '')) throw Error('Exact source commit required'); + const receipt = JSON.parse(readFileSync(join(dir, 'cli-qualification.json'), 'utf8')); + if (receipt.sourceRevision !== source || receipt.cliVersion !== versions.cli || receipt.diagramsVersion !== versions.diagrams + || receipt.exactArchiveUsedByPackagedUiTests !== true || receipt.runtimeAuditVulnerabilities !== 0 + || !/^[a-f0-9]{64}$/.test(expectedVsixSha256 ?? '') || receipt.vsixSha256 !== expectedVsixSha256) throw Error('Qualification identity mismatch'); + const sums = new Map(readFileSync(join(dir, 'SHA256SUMS'), 'utf8').trim().split('\n').map(line => { + const match = /^([a-f0-9]{64}) ([a-zA-Z0-9.-]+)$/.exec(line); + if (!match) throw Error('Malformed checksum manifest'); + return [match[2], match[1]]; + })); + for (const evidence of ['cli-qualification.json', 'runtime-audit.json']) { + if (sha(join(dir, evidence)) !== sums.get(evidence)) throw Error('Evidence checksum mismatch'); + } + if (JSON.parse(readFileSync(join(dir, 'runtime-audit.json'))).metadata?.vulnerabilities?.total !== 0) throw Error('Runtime audit must be clean'); + for (const name of ['diagrams', 'cli']) { + const version = versions[name]; + if (!/^\d+\.\d+\.\d+$/.test(version)) throw Error('Stable version required'); + const filename = `transitrix-${name}-${version}.tgz`, archive = join(dir, filename); + if (sha(archive) !== sums.get(filename)) throw Error('Archive checksum mismatch'); + const content = path => JSON.parse(execFileSync('tar', ['-xOf', archive, `package/${path}`], { encoding: 'utf8' })); + const pkg = content('package.json'); + if (pkg.name !== `@transitrix/${name}` || pkg.version !== version) throw Error('Package version mismatch'); + if (name === 'cli' && (receipt.artifact !== filename || receipt.sha256 !== sha(archive) + || receipt.integrity !== `sha512-${sha(archive, 'sha512')}` + || content('dist/requirements-build.json').sourceRevision !== source + || content('dist/diagrams-version.json').version !== versions.diagrams)) throw Error('CLI archive provenance mismatch'); + } + return receipt; +} +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + const versions = Object.fromEntries(['cli', 'diagrams'].map(name => [name, JSON.parse(readFileSync(join(root, 'packages', name, 'package.json'))).version])); + if (!process.argv[3]) throw Error('Actual VSIX path required'); + verifyPackages(resolve(process.argv[2] ?? 'qualified'), process.env.GITHUB_SHA, versions, sha(resolve(process.argv[3]))); + console.log('PASS: exact release-qualified package bytes and source identities'); +} diff --git a/scripts/verify-release-packages.test.mjs b/scripts/verify-release-packages.test.mjs new file mode 100644 index 00000000..d445ced3 --- /dev/null +++ b/scripts/verify-release-packages.test.mjs @@ -0,0 +1,49 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { execFileSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { verifyPackages } from './verify-release-packages.mjs'; +const digest = (file, alg) => createHash(alg).update(readFileSync(file)).digest(alg === 'sha512' ? 'base64' : 'hex'); +test('release verification accepts bound archives and refuses changed bytes, source, version and unqualified receipts', () => { + const dir = mkdtempSync(join(tmpdir(), 'release-packages-')); + try { + const source = 'a'.repeat(40), versions = { cli: '2.13.0', diagrams: '1.17.0' }; + for (const name of ['cli', 'diagrams']) { + const stage = join(dir, name); mkdirSync(join(stage, 'package', 'dist'), { recursive: true }); + const put = (path, data) => writeFileSync(join(stage, 'package', path), JSON.stringify(data)); + put('package.json', { name: `@transitrix/${name}`, version: versions[name] }); + if (name === 'cli') { put('dist/requirements-build.json', { sourceRevision: source }); put('dist/diagrams-version.json', { version: versions.diagrams }); } + execFileSync('tar', ['-czf', join(dir, `transitrix-${name}-${versions[name]}.tgz`), '-C', stage, 'package']); + } + const artifact = 'transitrix-cli-2.13.0.tgz', archive = join(dir, artifact); + const receipt = { sourceRevision: source, cliVersion: versions.cli, diagramsVersion: versions.diagrams, + artifact, sha256: digest(archive, 'sha256'), integrity: 'sha512-' + digest(archive, 'sha512'), + exactArchiveUsedByPackagedUiTests: true, runtimeAuditVulnerabilities: 0, vsixSha256: 'b'.repeat(64) }; + writeFileSync(join(dir, 'runtime-audit.json'), JSON.stringify({ metadata: { vulnerabilities: { total: 0 } } })); + const save = value => writeFileSync(join(dir, 'cli-qualification.json'), JSON.stringify(value)); save(receipt); + const saveSums = () => writeFileSync(join(dir, 'SHA256SUMS'), [ + ...['cli', 'diagrams'].map(name => `transitrix-${name}-${versions[name]}.tgz`), 'cli-qualification.json', 'runtime-audit.json', + ].map(f => `${digest(join(dir, f), 'sha256')} ${f}`).join('\n') + '\n'); + saveSums(); + const verify = (src = source, vers = versions, vsix = 'b'.repeat(64)) => verifyPackages(dir, src, vers, vsix); + assert.equal(verify().sha256, receipt.sha256); + assert.throws(() => verify('c'.repeat(40)), /identity/); + assert.throws(() => verify(source, { ...versions, cli: '2.14.0' }), /identity/); + for (const change of [{ exactArchiveUsedByPackagedUiTests: false }, { runtimeAuditVulnerabilities: 1 }, { integrity: 'sha512-bad' }]) { + save({ ...receipt, ...change }); assert.throws(() => verify()); + } + save(receipt); saveSums(); + assert.throws(() => verify(source, versions, 'c'.repeat(64)), /identity/); + save({ ...receipt, vsixSha256: 'c'.repeat(64) }); saveSums(); assert.throws(() => verify(), /identity/); + save(receipt); saveSums(); + save({ ...receipt, extra: 'changed' }); assert.throws(() => verify(), /Evidence checksum/); + save(receipt); saveSums(); + writeFileSync(join(dir, 'runtime-audit.json'), '{}'); assert.throws(() => verify(), /Evidence checksum/); + writeFileSync(join(dir, 'runtime-audit.json'), JSON.stringify({ metadata: { vulnerabilities: { total: 1 } } })); saveSums(); assert.throws(() => verify(), /audit/); + writeFileSync(join(dir, 'runtime-audit.json'), JSON.stringify({ metadata: { vulnerabilities: { total: 0 } } })); saveSums(); + writeFileSync(archive, 'tampered'); assert.throws(() => verify(), /checksum/); + } finally { rmSync(dir, { recursive: true, force: true }); } +}); diff --git a/tests/vocabulary-drift/allowlist.ts b/tests/vocabulary-drift/allowlist.ts index 6407784e..da81e7fe 100644 --- a/tests/vocabulary-drift/allowlist.ts +++ b/tests/vocabulary-drift/allowlist.ts @@ -23,7 +23,9 @@ export interface AllowlistEntry { /** Shared review date for the divergences this check found on its first run — * they were measured together and are re-measured together. */ -const FIRST_RUN = '2026-11-08'; +// Release review 2026-11-08 renewal; applies only to the same 22 existing keys. +// New or stale divergences still fail. No runtime vocabulary is changed. +const FIRST_RUN = '2026-11-16'; export const ALLOWLIST: readonly AllowlistEntry[] = [ {