From 24e3813795efddf57b9f60ab1a2d5b0f17e82559 Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Sun, 8 Nov 2026 13:44:31 -0500 Subject: [PATCH 1/2] Keep prepared release files discoverable by the artifact uploader --- .github/workflows/publish.yml | 8 +- README.md | 16 +- docs/PROJECT_PLAN.md | 19 +- docs/RELEASING.md | 66 ++++- package.json | 3 +- packages/rate-limit/README.md | 16 +- packages/rate-limit/package.json | 2 +- pnpm-lock.yaml | 53 ++++ scripts/release-artifact-discovery.test.mjs | 310 ++++++++++++++++++++ 9 files changed, 459 insertions(+), 34 deletions(-) create mode 100644 scripts/release-artifact-discovery.test.mjs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e656606..ddb5235 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -104,19 +104,21 @@ jobs: shell: bash run: | set -euo pipefail + release_dir="${RUNNER_TEMP}/rate-limit-prepared" pnpm run release:pack -- \ --require-clean \ --require-main-ancestor \ --require-release-tag \ - --expected-release-commit "${RELEASE_COMMIT}" - manifest_digest="$(sha256sum .release/package-manifest.json | awk '{print $1}')" + --expected-release-commit "${RELEASE_COMMIT}" \ + --output "${release_dir}" + manifest_digest="$(sha256sum "${release_dir}/package-manifest.json" | awk '{print $1}')" printf 'manifest-digest=%s\n' "${manifest_digest}" >> "${GITHUB_OUTPUT}" - name: Upload the prepared release uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 with: name: rate-limit-release-${{ github.run_id }} - path: .release/ + path: ${{ runner.temp }}/rate-limit-prepared/ if-no-files-found: error include-hidden-files: false overwrite: true diff --git a/README.md b/README.md index 81378f7..8e41d46 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ in-memory tier and a durable storage-backed tier for expensive operations. > [!IMPORTANT] > Rate Limit is in early `0.x` development. Its public API is not stable. -> Current source is the **`0.3.1` candidate, not published**. Registry `latest` +> Current source is the **`0.3.2` candidate, not published**. Registry `latest` > remains `0.2.0`, which > predates the merged [PR #8 hardening](https://github.com/pegma-dev/rate-limit/pull/8) > and the new bounded maintenance helper. The first advertised `0.1.0` @@ -16,14 +16,20 @@ in-memory tier and a durable storage-backed tier for expensive operations. > remains separate under `bootstrap`. pegma.dev composes the durable tier in > its production Identity worker; this candidate is not a new host deployment. -The source behavior below describes the `0.3.1` candidate. Adoption waits for +The source behavior below describes the `0.3.2` candidate. Adoption waits for its reviewed publication and the host's explicit configuration/storage transition. The signed `v0.3.0` tag and GitHub release are retained history: their preparation failed before packing, produced no release artifact, and did not -publish npm bytes. `0.3.1` corrects the packing checkout's SSH trust configuration -without changing the reviewed limiter API. See the -[failed preparation and patch-release record](docs/RELEASING.md#failed-030-preparation-and-031-candidate). +publish npm bytes. `0.3.1` fixed that trust configuration and passed packing, +but upload discovered no files beneath hidden `.release/`; no artifact was +retained and smoke/publication were skipped. Neither version is on npm. +The `0.3.2` candidate uses one nonhidden preparation/digest/upload directory, +with the limiter/helper API unchanged. See the +[failed upload and new candidate record](docs/RELEASING.md#failed-031-upload-and-032-candidate). +Hosts must wait for actual verified `0.3.2` publication before pinning the new +helper, including through an alias. Existing Identity/Support `0.2.0` imports +remain unchanged; no legacy data transition is automatic. ## Two tiers, no pretending diff --git a/docs/PROJECT_PLAN.md b/docs/PROJECT_PLAN.md index 5dca0c0..fe4105a 100644 --- a/docs/PROJECT_PLAN.md +++ b/docs/PROJECT_PLAN.md @@ -5,7 +5,7 @@ **Stage:** Phases 1, 2, and 4 are complete; Phase 3 has its first production consumer. Registry `@pegma/rate-limit@0.2.0` is published, and pegma.dev composes the durable tier for its Identity surface. Registry `latest` remains `0.2.0`. -Current source is the **`0.3.1` +Current source is the **`0.3.2` candidate, not published**, retaining exact Storage Core `0.4.0`. Published `0.2.0` predates the already-merged [PR #8 hardening](https://github.com/pegma-dev/rate-limit/pull/8) for immutable policy descriptors, counter kind/configuration bindings, and @@ -16,10 +16,15 @@ publication or host-adoption receipt. Signed `v0.3.0` and its GitHub release remain immutable history. Their preparation failed before packing because SSH trust was configured only in the temporary verification repository, not the packing checkout. No release -artifact or npm `0.3.0` bytes were published. The `0.3.1` candidate corrects that -release configuration without changing the helper API; its own review, gates, -publication and registry verification remain required. See the -[failed-run receipt](RELEASING.md#failed-030-preparation-and-031-candidate). +artifact or npm `0.3.0` bytes were published. Signed `v0.3.1` corrected that +trust configuration and passed its gates/pack, then upload excluded hidden +`.release/`: zero artifacts were retained, smoke/publication were skipped, and +no npm `0.3.1` release exists. The `0.3.2` candidate uses one nonhidden +preparation/digest/upload directory, with the helper API unchanged. Its own +review, gates, publication and registry verification remain required. See the +[failed-upload receipt](RELEASING.md#failed-031-upload-and-032-candidate). +Hosts must await verified `0.3.2` publication before adopting the new helper, +including an alias; existing Identity/Support `0.2.0` imports stay unchanged. The exact reviewed `0.0.0` package-name bootstrap remains published under `bootstrap`. The first advertised `0.1.0` release was published from the @@ -196,7 +201,7 @@ collection over an injected Store). The memory tier must remain importable without a Store — a host wanting only abuse-dampening should not construct storage. TypeScript, vitest, the ecosystem's standard layout. -## `0.3.1` bounded-maintenance source candidate +## `0.3.2` bounded-maintenance source candidate `sweepDurableWindowsPage` is a root/durable export over the existing `rate-limit-windows` collection. One call makes one physical global scan page, @@ -227,7 +232,7 @@ retrying from the previous cursor can repeat work. The define the interface; current-head gates, review, exact publication, and host adoption remain release work. -Host aliases for this helper must pin `0.3.1` only after its actual verified +Host aliases for this helper must pin `0.3.2` only after its actual verified registry publication. A signed tag or GitHub release alone is not publication. Upgrading existing durable data is deliberate: use versioned policy names or diff --git a/docs/RELEASING.md b/docs/RELEASING.md index fc8f636..bdfbb33 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -5,6 +5,11 @@ the hardened GitHub release workflow, npm trusted publishing, and provenance. The completed one-time manual `0.0.0` ceremony below exists as an audit record: npm could not configure a trusted publisher until `@pegma/rate-limit` existed. +As of 2026-11-08, npm `latest` is `0.2.0` and historical `bootstrap` is `0.0.0`. +Current source is the **unpublished `0.3.2` candidate**. The signed `0.3.0` and +`0.3.1` GitHub releases below did not publish npm versions; neither is a host +dependency or evidence of completed artifact/consumer verification. + ## Release invariants The release tool verifies the exact public workspace inventory, stable package @@ -24,6 +29,8 @@ Normal preparation authenticates the stable signed tag in a temporary bare repository before checkout. The packing checkout must also configure the same approved SSH allowed-signers trust before the release tool independently checks the signed tag; trust scoped to the temporary bare repository is not inherited. +Current preparation writes, hashes and uploads the same nonhidden +`${RUNNER_TEMP}/rate-limit-prepared` directory, with `include-hidden-files: false`. The resulting artifact contains exactly two regular files: the manifest and its named tarball. Consumer installation runs in a separate job without publication authority. The environment-protected @@ -32,10 +39,11 @@ checkout, verifies the preparation manifest digest and both tarball digests, and invokes npm from a fresh directory with empty configuration files and an allowlisted environment. It never executes repository code. -## Failed `0.3.0` preparation and `0.3.1` candidate + + +## Failed `0.3.0` preparation -As of 2026-11-08, npm `latest` remains `0.2.0`; current source is the unpublished -`0.3.1` candidate. Protected signed annotated +Protected signed annotated [`v0.3.0`](https://github.com/pegma-dev/rate-limit/releases/tag/v0.3.0), tag object `9df80b019b8ed6e5b7fc0f5a8c7359ae4cae6486`, points to reviewed source [`93c7a4207d493e10568b797bf7d5a402f446cc70`](https://github.com/pegma-dev/rate-limit/commit/93c7a4207d493e10568b797bf7d5a402f446cc70). @@ -52,16 +60,50 @@ failure, not evidence that the protected signed tag was invalid. Preserve the `v0.3.0` tag object, source commit, GitHub release and failed-run record. Never move or replace that tag, reuse its version for changed source, -or treat the failed preparation as publication. The correction uses a reviewed -`0.3.1` patch and a new protected signed `v0.3.1` release identity after merge. -It adds explicit trust to the packing checkout; the limiter/helper API and -behavior remain unchanged. The full Node 22/24 gates and exact-artifact release -checks still apply to the new source. - -Only after `0.3.1` actually publishes and its original prepared bytes and +or treat the failed preparation as publication. The correction used reviewed +`0.3.1` source and a new protected signed `v0.3.1` identity after merge. It +added explicit trust to the packing checkout without changing limiter/helper +behavior. Its later failure was a separate upload boundary, recorded next. + +## Failed `0.3.1` upload and `0.3.2` candidate + +The signed annotated +[`v0.3.1` release](https://github.com/pegma-dev/rate-limit/releases/tag/v0.3.1), +tag object `0b44be7a99771e92f5defc34ca408917c403f526`, points to reviewed source +[`b2f15e4a2a2937894ad90b623fee8914ba13ca31`](https://github.com/pegma-dev/rate-limit/commit/b2f15e4a2a2937894ad90b623fee8914ba13ca31). +[Run `42510458896`](https://github.com/pegma-dev/rate-limit/actions/runs/42510458896), +attempt 1, failed in +[prepare job `128822182349`](https://github.com/pegma-dev/rate-limit/actions/runs/42510458896/job/128822182349) +on 2026-11-08. Tag authentication, the checkout signing-trust helper, repository +gates, and preparation/sealing all passed. The packer produced its manifest and +tarball under the runner's `.release/` directory. + +Upload then failed at **2026-11-08T18:32:14Z**: its path was `.release/`, while +`include-hidden-files: false` excluded that hidden directory. Discovery found +zero files and upload failed closed. The run's artifacts API reports zero +retained artifacts; smoke and publish were skipped. The successful runner-local +pack is not a downloadable, independently verified release artifact. No npm +`0.3.1` publication occurred. + +Preserve the signed `v0.3.1` tag, source and failed-run record alongside the +earlier `v0.3.0` history. Do not replace a tag, reuse either version for changed +source, or treat a GitHub release as npm availability. + +The new `0.3.2` candidate keeps the limiter/helper API and signing correction +unchanged. Its producer uses explicit `--output` at the nonhidden +`${RUNNER_TEMP}/rate-limit-prepared` directory, computes the manifest digest +there, and uploads that same directory through `${{ runner.temp }}`. Hidden-file +exclusion remains false; recovery does not broaden artifact collection. +Validate the actual YAML producer/digest/upload wiring and file discovery with +the pinned `@actions/glob@0.5.0` regression. Current-head review, full Node 22/24 +gates, the new signed release identity, retained exact artifact, isolated smoke, +publication and registry verification remain required for this candidate. + +Only after `0.3.2` actually publishes and its original prepared bytes and registry release are verified may a host pin it, including through an npm alias. This does not migrate legacy `0.2.0` counters or change existing host -deployment state. No repeated bootstrap, token fallback or signature bypass is +deployment state; existing Identity/Support `0.2.0` imports remain unchanged. +No repeated bootstrap, token fallback or signature bypass is part of this recovery. ## One-time `0.0.0` package-name bootstrap @@ -245,4 +287,4 @@ npm dist-tag ls @pegma/rate-limit For that ceremony the registry check had to report `@pegma/rate-limit@0.1.0: exact`, with `latest` at `0.1.0` and `bootstrap` at `0.0.0`. Current `latest` is `0.2.0`; do not retag an older release or repeat -the bootstrap to prepare the unpublished `0.3.1` candidate. +the bootstrap to prepare the unpublished `0.3.2` candidate. diff --git a/package.json b/package.json index 6f47ef2..398ce68 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,10 @@ "release:pack": "node scripts/release-package.mjs pack", "release:publish": "node scripts/release-package.mjs publish", "release:registry:check": "node scripts/release-package.mjs registry-check", - "test": "pnpm run build && vitest run && node --test scripts/configure-release-signing.test.mjs scripts/release-workflow-signing.test.mjs" + "test": "pnpm run build && vitest run && node --test scripts/configure-release-signing.test.mjs scripts/release-workflow-signing.test.mjs scripts/release-artifact-discovery.test.mjs" }, "devDependencies": { + "@actions/glob": "0.5.0", "@azure/data-tables": "13.3.1", "@pegma/storage-azure-tables": "0.4.0", "@types/node": "26.1.1", diff --git a/packages/rate-limit/README.md b/packages/rate-limit/README.md index 07e481a..186530e 100644 --- a/packages/rate-limit/README.md +++ b/packages/rate-limit/README.md @@ -9,7 +9,7 @@ Two explicitly named application rate-limit tiers: abuse-critical operations. > [!IMPORTANT] -> Current source is the **`0.3.1` candidate, not published**. Registry `latest` +> Current source is the **`0.3.2` candidate, not published**. Registry `latest` > remains `0.2.0`, which > predates the merged descriptor/configuration hardening and the bounded > global sweep described here. `0.1.0` was the first advertised release, published through @@ -22,10 +22,16 @@ published version only after its release verification and an explicit host storage/configuration transition. The signed `v0.3.0` tag and GitHub release exist, but preparation failed before -packing: no release artifact or npm `0.3.0` bytes were published. The `0.3.1` -candidate fixes release-checkout SSH trust, with the reviewed limiter API -unchanged. The immutable failure history and new patch identity are recorded in +packing: no release artifact or npm `0.3.0` bytes were published. Signed +`v0.3.1` fixed checkout trust and passed its gates and pack, but upload excluded +hidden `.release/`, retained zero artifacts, and skipped smoke/publication. +There is no npm `0.3.1` release. The `0.3.2` candidate moves preparation, +digesting and upload to the same nonhidden directory without changing the +limiter/helper API. The immutable failure history and new candidate are recorded in [release operations](https://github.com/pegma-dev/rate-limit/blob/main/docs/RELEASING.md). +No host should pin a new helper alias until actual `0.3.2` publication and +exact-artifact verification. Existing Identity/Support `0.2.0` composition and +legacy counter storage remain separate from that adoption. There is no default tier and no automatic upgrade. This package is application abuse control, not DDoS protection, HTTP middleware, or billing metering. @@ -206,7 +212,7 @@ delete arbitrary malformed rows, or mistake the global sweep for a migration of previously published `0.2.0` data. A host adopting the new helper through an npm alias must wait for actual -`0.3.1` publication and registry verification before pinning that alias. Existing +`0.3.2` publication and registry verification before pinning that alias. Existing `0.2.0` consumers and counters need their own deliberate migration; the new release does not convert them automatically. diff --git a/packages/rate-limit/package.json b/packages/rate-limit/package.json index 1538cac..ca5535b 100644 --- a/packages/rate-limit/package.json +++ b/packages/rate-limit/package.json @@ -1,6 +1,6 @@ { "name": "@pegma/rate-limit", - "version": "0.3.1", + "version": "0.3.2", "description": "Explicit per-instance sliding-window and shared durable fixed-window rate limiters.", "license": "MIT", "type": "module", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca7bad0..d08a3ca 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: devDependencies: + '@actions/glob': + specifier: 0.5.0 + version: 0.5.0 '@azure/data-tables': specifier: 13.3.1 version: 13.3.1 @@ -44,6 +47,21 @@ importers: packages: + '@actions/core@1.11.1': + resolution: {integrity: sha512-hXJCSrkwfA46Vd9Z3q4cpEpHB1rL5NG04+/rbqW9d3+CSvtB1tYe8UTpAlixa1vj0m/ULglfEK2UKxMGxCxv5A==} + + '@actions/exec@1.1.1': + resolution: {integrity: sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==} + + '@actions/glob@0.5.0': + resolution: {integrity: sha512-tST2rjPvJLRZLuT9NMUtyBjvj9Yo0MiJS3ow004slMvm8GFM+Zv9HvMJ7HWzfUyJnGrJvDsYkWBaaG3YKXRtCw==} + + '@actions/http-client@2.2.3': + resolution: {integrity: sha512-mx8hyJi/hjFvbPokCg4uRd4ZX78t+YyRPtnKWwIl+RzNaVuFpQHfmlGVfsKEJN8LwTCvL+DfVgAM04XaHkm6bA==} + + '@actions/io@1.1.3': + resolution: {integrity: sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==} + '@azure-rest/core-client@2.8.0': resolution: {integrity: sha512-F1ybHeN+++QhyFCF/ehLUEvrOB6fehPdFBFtGdj0C3B2lpQ9zkPiO5JDgsqc6IfjuUe6b3dAbXK0a7+VgSGfhw==} engines: {node: '>=22.0.0'} @@ -148,6 +166,10 @@ packages: '@emnapi/wasi-threads@1.2.2': resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==} + '@fastify/busboy@2.1.1': + resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} + engines: {node: '>=14'} + '@jridgewell/sourcemap-codec@1.5.5': resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} @@ -1594,6 +1616,10 @@ packages: undici-types@8.3.0: resolution: {integrity: sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==} + undici@5.29.0: + resolution: {integrity: sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==} + engines: {node: '>=14.0'} + universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} engines: {node: '>= 10.0.0'} @@ -1761,6 +1787,27 @@ packages: snapshots: + '@actions/core@1.11.1': + dependencies: + '@actions/exec': 1.1.1 + '@actions/http-client': 2.2.3 + + '@actions/exec@1.1.1': + dependencies: + '@actions/io': 1.1.3 + + '@actions/glob@0.5.0': + dependencies: + '@actions/core': 1.11.1 + minimatch: 3.1.5 + + '@actions/http-client@2.2.3': + dependencies: + tunnel: 0.0.6 + undici: 5.29.0 + + '@actions/io@1.1.3': {} + '@azure-rest/core-client@2.8.0': dependencies: '@azure/abort-controller': 2.2.0 @@ -1986,6 +2033,8 @@ snapshots: tslib: 2.8.1 optional: true + '@fastify/busboy@2.1.1': {} + '@jridgewell/sourcemap-codec@1.5.5': {} '@js-joda/core@5.7.0': {} @@ -3388,6 +3437,10 @@ snapshots: undici-types@8.3.0: {} + undici@5.29.0: + dependencies: + '@fastify/busboy': 2.1.1 + universalify@2.0.1: {} unpipe@1.0.0: {} diff --git a/scripts/release-artifact-discovery.test.mjs b/scripts/release-artifact-discovery.test.mjs new file mode 100644 index 0000000..a2fb0e1 --- /dev/null +++ b/scripts/release-artifact-discovery.test.mjs @@ -0,0 +1,310 @@ +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { + mkdir, + mkdtemp, + readFile, + realpath, + rm, + stat, + writeFile, +} from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { basename, isAbsolute, join, relative, resolve } from "node:path"; +import { test } from "node:test"; +import { create } from "@actions/glob"; +import { parse } from "yaml"; + +const WORKFLOW = new URL("../.github/workflows/publish.yml", import.meta.url); +const UPLOAD_ACTION = + "actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4"; +const PREFIX = "rate-limit-artifact-discovery-"; + +function contained(root, path) { + const target = resolve(path); + const suffix = relative(root, target); + assert.ok( + suffix !== "" && + suffix !== ".." && + !suffix.startsWith(".." + (process.platform === "win32" ? "\\" : "/")) && + !isAbsolute(suffix), + "Fixture paths must remain inside their owned temporary root", + ); + return target; +} + +async function fixture(t) { + const parent = await realpath(tmpdir()); + const root = await mkdtemp(join(parent, PREFIX)); + t.after(async () => { + const actual = await realpath(root); + assert.equal( + actual, + root, + "Cleanup target must remain the original owned directory", + ); + contained(parent, actual); + assert.ok(basename(actual).startsWith(PREFIX)); + await rm(actual, { recursive: true, force: true }); + }); + const runnerTemp = contained(root, join(root, "runner-temp")); + const workspace = contained(root, join(root, "workspace")); + await mkdir(runnerTemp); + await mkdir(workspace); + return { root, runnerTemp, workspace }; +} + +function oneMatch(text, pattern, name) { + const matches = [...text.matchAll(pattern)]; + assert.equal( + matches.length, + 1, + "Expected one supported " + name + " binding", + ); + return matches[0][1]; +} + +function shellValue(value, environment) { + const expanded = value.replace( + /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/gu, + (_, name) => { + assert.ok(Object.hasOwn(environment, name), "Unknown producer variable"); + return environment[name]; + }, + ); + assert.ok(!expanded.includes("$"), "Unsupported producer shell expression"); + return expanded; +} + +function actionValue(value, context) { + assert.equal(typeof value, "string"); + const expanded = value.replace( + /\$\{\{\s*([A-Za-z0-9_.]+)\s*\}\}/gu, + (_, name) => { + assert.ok( + Object.hasOwn(context, name), + "Unknown artifact path expression", + ); + return context[name]; + }, + ); + assert.ok(!expanded.includes("$"), "Unsupported artifact path expression"); + return expanded; +} + +function steps(document) { + const prepare = document.jobs.prepare; + const pack = prepare.steps.find((step) => step.id === "pack"); + const upload = prepare.steps.find((step) => + step.uses?.startsWith("actions/upload-artifact@"), + ); + assert.ok( + pack && typeof pack.run === "string", + "Expected actual pack producer", + ); + assert.equal( + upload?.uses, + UPLOAD_ACTION, + "Re-review discovery behavior when the action pin changes", + ); + return { pack, upload }; +} + +function includeHidden(value) { + // The pinned action's input defaults to false; YAML may encode it as text. + if (value === undefined || value === false || value === "false") return false; + if (value === true || value === "true") return true; + assert.fail("Unexpected include-hidden-files input"); +} + +/** Public glob API and the reviewed action's options/directory filtering only. */ +async function uploadFiles(pattern, includeHiddenFiles) { + const globber = await create(pattern, { + followSymbolicLinks: true, + implicitDescendants: true, + omitBrokenSymbolicLinks: true, + excludeHiddenFiles: !includeHiddenFiles, + }); + const files = []; + for (const path of await globber.glob()) { + const info = await stat(path); + if (!info.isDirectory()) { + assert.ok( + info.isFile(), + "Selection fixture must contain regular files only", + ); + files.push(resolve(path)); + } + } + return files.sort(); +} + +/** Replay path bindings only: never run workflow shell, npm, packing or upload. */ +async function discovery(t, document) { + const f = await fixture(t); + const { pack, upload } = steps(document); + const environment = { + RUNNER_TEMP: f.runnerTemp, + GITHUB_WORKSPACE: f.workspace, + }; + const assigned = oneMatch( + pack.run, + /^\s*release_dir="([^"\r\n]+)"\s*$/gmu, + "release_dir", + ); + environment.release_dir = shellValue(assigned, environment); + const producerCommands = pack.run + .replace(/\\\r?\n[\t ]*/gu, " ") + .split(/\r?\n/u) + .filter((line) => /^\s*pnpm run release:pack\s+--(?:\s|$)/u.test(line)); + assert.equal( + producerCommands.length, + 1, + "Expected the real release producer command", + ); + const outputArgument = oneMatch( + producerCommands[0], + /--output\s+"([^"\r\n]+)"/gu, + "pack output argument", + ); + const output = contained( + f.root, + resolve(f.workspace, shellValue(outputArgument, environment)), + ); + assert.equal( + output, + resolve(f.workspace, environment.release_dir), + "Pack output must match its assigned release directory", + ); + await mkdir(output, { recursive: true }); + // These are deliberately not npm proof/artifact bytes, only discovery inputs. + const manifestPath = join(output, "package-manifest.json"); + const tarballPath = join(output, "synthetic-selection-only.tgz"); + const manifest = JSON.stringify({ + fixture: "artifact discovery only", + tarball: basename(tarballPath), + }); + await writeFile(manifestPath, manifest); + await writeFile( + tarballPath, + "synthetic selection bytes, not an npm package\n", + ); + await writeFile( + join(output, ".incidental-hidden-file"), + "must never be selected\n", + ); + const sealArgument = oneMatch( + pack.run, + /^\s*manifest_digest="\$\(sha256sum\s+"([^"\r\n]+)"[^\r\n]*\)"\s*$/gmu, + "manifest digest path", + ); + const sealedPath = contained( + f.root, + resolve(f.workspace, shellValue(sealArgument, environment)), + ); + assert.equal( + sealedPath, + manifestPath, + "Seal path must identify the producer's actual manifest", + ); + assert.equal( + createHash("sha256") + .update(await readFile(sealedPath)) + .digest("hex"), + createHash("sha256").update(manifest).digest("hex"), + ); + const rendered = actionValue(upload.with.path, { + "runner.temp": f.runnerTemp, + "github.workspace": f.workspace, + }); + assert.ok( + !["\n", "\r", "*", "?", "[", "]", "!"].some((character) => + rendered.includes(character), + ), + "Replay supports one literal owned upload directory only", + ); + const pattern = contained(f.root, resolve(f.workspace, rendered)); + const files = await uploadFiles( + pattern, + includeHidden(upload.with["include-hidden-files"]), + ); + return { + files, + expected: [manifestPath, tarballPath].map((path) => resolve(path)).sort(), + }; +} + +function requireComplete(result) { + assert.deepEqual( + result.files, + result.expected, + "Upload must discover exactly the producer's two regular files", + ); +} + +async function workflow() { + return parse(await readFile(WORKFLOW, "utf8")); +} + +test("actual workflow discovers both sealed files using the reviewed glob library and hidden-file policy", async (t) => { + const manifest = JSON.parse( + await readFile(new URL("../package.json", import.meta.url), "utf8"), + ); + assert.equal(manifest.devDependencies["@actions/glob"], "0.5.0"); + assert.equal(manifest.devDependencies.yaml, "2.9.1"); + requireComplete(await discovery(t, await workflow())); +}); + +test("the old hidden .release producer/upload path reproduces zero selected files", async (t) => { + const document = await workflow(); + const { pack, upload } = steps(document); + pack.run = pack.run.replace( + /^\s*release_dir="[^"\r\n]+"\s*$/mu, + 'release_dir="${GITHUB_WORKSPACE}/.release"', + ); + upload.with.path = ".release/"; + const result = await discovery(t, document); + assert.deepEqual(result.files, []); + assert.throws(() => requireComplete(result), /two regular files/u); +}); + +test("a different upload target cannot pass discovery despite successful production and sealing", async (t) => { + const document = await workflow(); + steps(document).upload.with.path = "${{ runner.temp }}/unrelated-target/"; + const result = await discovery(t, document); + assert.deepEqual(result.files, []); + assert.throws(() => requireComplete(result), /two regular files/u); +}); + +test("producer directory drift cannot leave upload pointing at an empty old location", async (t) => { + const document = await workflow(); + const { pack } = steps(document); + pack.run = pack.run.replace( + /^\s*release_dir="[^"\r\n]+"\s*$/mu, + 'release_dir="${RUNNER_TEMP}/different-producer"', + ); + const result = await discovery(t, document); + assert.deepEqual(result.files, []); + assert.throws(() => requireComplete(result), /two regular files/u); +}); + +test("a digest path detached from the actual pack output fails the seal binding", async (t) => { + const document = await workflow(); + const { pack } = steps(document); + pack.run = pack.run.replace( + /sha256sum\s+"[^"\r\n]+"/u, + 'sha256sum "${RUNNER_TEMP}/unrelated-manifest/package-manifest.json"', + ); + await assert.rejects(discovery(t, document), /producer's actual manifest/u); +}); + +test("enabling hidden files is observed by real discovery and admits the incidental file", async (t) => { + const document = await workflow(); + steps(document).upload.with["include-hidden-files"] = true; + const result = await discovery(t, document); + assert.equal(result.files.length, 3); + assert.ok( + result.files.some((path) => basename(path) === ".incidental-hidden-file"), + ); + assert.throws(() => requireComplete(result), /two regular files/u); +}); From 5d6cc015629c1c7cdece8e193d8b0e3c55dc8d6f Mon Sep 17 00:00:00 2001 From: Nathan Rover Date: Sun, 8 Nov 2026 13:59:22 -0500 Subject: [PATCH 2/2] Clarify artifact discovery scope with immutable dependency references --- docs/RELEASING.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index bdfbb33..f432fe0 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -76,7 +76,7 @@ attempt 1, failed in [prepare job `128822182349`](https://github.com/pegma-dev/rate-limit/actions/runs/42510458896/job/128822182349) on 2026-11-08. Tag authentication, the checkout signing-trust helper, repository gates, and preparation/sealing all passed. The packer produced its manifest and -tarball under the runner's `.release/` directory. +tarball in the checkout's workspace-relative `.release/` directory. Upload then failed at **2026-11-08T18:32:14Z**: its path was `.release/`, while `include-hidden-files: false` excluded that hidden directory. Discovery found @@ -93,9 +93,18 @@ The new `0.3.2` candidate keeps the limiter/helper API and signing correction unchanged. Its producer uses explicit `--output` at the nonhidden `${RUNNER_TEMP}/rate-limit-prepared` directory, computes the manifest digest there, and uploads that same directory through `${{ runner.temp }}`. Hidden-file -exclusion remains false; recovery does not broaden artifact collection. +exclusion remains enabled (`include-hidden-files: false`); recovery does not +broaden artifact collection. Validate the actual YAML producer/digest/upload wiring and file discovery with -the pinned `@actions/glob@0.5.0` regression. Current-head review, full Node 22/24 +the pinned `@actions/glob@0.5.0` regression. The pinned upload action's +[package lock](https://github.com/actions/upload-artifact/blob/330a01c490aca151604b8cf639adc76d48f6c5d4/package-lock.json) +records that version with the same integrity as the +[registry artifact](https://registry.npmjs.org/@actions%2fglob/0.5.0). +Its [search implementation](https://github.com/actions/upload-artifact/blob/330a01c490aca151604b8cf639adc76d48f6c5d4/src/shared/search.ts) +defines the glob options and directory filtering used by the +[regression](../scripts/release-artifact-discovery.test.mjs). The test exercises +that public glob API and filtering only; it does not execute the vendored action +bundle or upload bytes. Current-head review, full Node 22/24 gates, the new signed release identity, retained exact artifact, isolated smoke, publication and registry verification remain required for this candidate.