Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions .agents/skills/release-preparation/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description: Preparing a duroxide-node npm release PR without publishing. Use wh

# Preparing a duroxide-node Release

Prepare the public release changes for review. Publishing is performed separately
by a Microsoft maintainer through the internal release pipeline.
Prepare the public release changes for review. Registry publishing is performed
separately by a Microsoft maintainer through the internal release pipeline.

## 1. Confirm the Release

Expand All @@ -19,6 +19,10 @@ Before editing, identify:
Follow Semantic Versioning and the policy in
[RELEASE_POLICY.md](../../../RELEASE_POLICY.md).

A runtime-floor increase is a breaking change requiring at least the next minor
version on 0.x. Maintenance releases are outside the current release flow and
require a separate approved plan.

## 2. Synchronize npm Versions

Set the target version in:
Expand All @@ -30,6 +34,15 @@ Set the target version in:
All six package versions and all five optional dependency versions must match.
Do not change the `Cargo.toml` package version as part of an npm-only release.

Also synchronize `engines.node` in the root and all five platform manifests,
including the root entry in `package-lock.json`; the manifests define the
supported floor.
After packing, run `node ci/smoke/check-engines.js <tarball-directory>` to check
all six distributable manifests, not just the source files. A future intentional
floor increase must update this check, the loader hint in `lib/duroxide.js`,
its tests in `__tests__/native_loader.test.js`, and the runtime documentation.
This check covers GitHub-built tarballs, not internal-pipeline artifacts.

## 3. Finalize the Changelog

In `CHANGELOG.md`:
Expand All @@ -51,11 +64,44 @@ Create a pull request targeting `main`.

GitHub Actions validates the full SDK test suite, cross-platform builds, and
local-package smoke tests on the pull request.
Confirm the `Build & Smoke` workflow succeeds before merging.

## 5. Maintainer Handoff

After the pull request is merged, release preparation is complete.
After the pull request is merged, the release-preparation PR work is complete.
Every new SDK version tag requires notes-only GitHub release notes.
Adopting this policy does not change existing tags or releases.

Do not run `npm publish`, create a GitHub Release, or add publishing credentials
Do not run `npm publish` or add publishing credentials, publishing workflows,
or internal pipeline configuration. A Microsoft maintainer runs the internal
release pipeline.
release pipeline; npm publishing remains exclusive to that pipeline.

### Tag Authorization

Tag creation is a separate action requiring explicit developer authorization
for the version and exact release commit SHA, not the current tip of `main`.
Confirm the approved commit contains the merged release changes and has a
successful `Build & Smoke` run. Check local and remote tags first. If the tag
already exists, verify its commit matches the approved SHA and do not recreate it.
If absent and authorized, create it with `git tag "$TAG" "$RELEASE_SHA"` and push
only that tag with `git push origin "refs/tags/$TAG"`. Never move or delete tags.

### GitHub Notes

1. The notes step never creates a tag. Fetch the existing remote tag without
force; compare `git rev-parse "$TAG^{commit}"` with the approved release SHA
and confirm `Build & Smoke` passed for that commit. Stop on a missing tag or
mismatched SHA. Inspect existing release state, body, and assets; stop on
inconsistencies; reuse a matching approved draft instead of creating a
duplicate, and do not alter unrelated existing releases.
2. Use the tagged changelog and upgrade notes. Ask for timing if unspecified:
notes may precede or follow npm. An explicit request to publish notes is
approval; tag authorization alone is not. Without publication approval,
prepare only a safe draft.
3. Use `gh release create "$TAG" --verify-tag --notes-file "$NOTES_FILE"`,
adding `--draft` for preparation, `--latest=false` for older/non-highest
stable versions, and `--prerelease` for prereleases. Check these flags when
publishing an approved draft too. Do not upload package assets.
4. If notes precede npm, include "npm publication pending". Update those notes
when publication is confirmed, or state that the version was not published
if abandoned. Never move or delete the tag.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ jobs:
done
- name: Pack main package
run: npm pack --pack-destination "$GITHUB_WORKSPACE/tarballs"
- name: Check packed runtime requirements
run: node ci/smoke/check-engines.js tarballs
- name: List tarballs
run: ls -lh tarballs/
- name: Upload tarballs
Expand Down Expand Up @@ -156,6 +158,7 @@ jobs:
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Download tarballs
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- The next minor release (0.4.0) requires Node.js 22 or newer for `duroxide`
- Starting with 0.4.0, Node.js 22 or newer is required for `duroxide`
and its native platform packages. Upgrade from Node.js 18 or 20 before
installing 0.4.0. The requirement for 0.3.0 is unchanged.

### Fixed

- Explain possible runtime and install-time Node.js version causes when a
published native platform package is missing, while preserving the original
error as the cause and retaining its `code` and `requireStack`.

## [0.3.0] - 2026-11-30

### Changed
Expand Down
34 changes: 30 additions & 4 deletions RELEASE_POLICY.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
# Release Policy

`duroxide` and its platform packages are published to npm by Microsoft's
internal open-source release infrastructure. Publishing credentials and release
execution remain outside this repository.
internal open-source release infrastructure. Registry publishing credentials
and execution remain outside this repository.

## Contributor Workflow

Contributors can prepare a release through a pull request:

1. Keep the root package version, every `npm/npm/*/package.json` version, and
all platform `optionalDependencies` aligned.
all platform `optionalDependencies` aligned. Keep `engines.node` aligned
across all six manifests and the lockfile root, and check the packed tarballs.
2. Update `CHANGELOG.md` and relevant documentation.
3. Open a pull request for review. GitHub Actions runs the build, tests, and
package smoke checks.

After the release change is merged, a Microsoft maintainer runs the internal
release pipeline to build and publish the packages to npm.

## Supported Runtimes

The supported Node.js floor is defined by the package manifests' `engines.node`.
Increasing it is a breaking change requiring at least the next minor SDK
version on 0.x. Maintenance releases are not supported by the current release
flow and require a separate approved plan.

## Publishing Boundary

- Do not run `npm publish` for the Microsoft release.
- Do not create a GitHub Release manually.
- Do not upload package assets or add publishing workflows.
- Do not request or store Microsoft publishing credentials in this repository.

## GitHub Releases

Every new SDK version tag must have a notes-only GitHub Release using that tag's
changelog and upgrade notes. Verify the immutable tag matches the approved
release commit; creating tags requires separate explicit authorization.
The notes step never creates tags or duplicates releases. Adopting this policy
does not change existing tags or releases; never move, recreate, or delete tags.

The developer's request controls whether notes precede or follow npm publication.
Ask if timing is unspecified. An explicit request to publish notes is approval;
tag authorization alone is not. A safe draft may be prepared without publication
approval. If notes precede npm, mark publication pending and update the status
when confirmed or abandoned. Stop on inconsistent release state.

GitHub Releases are independent of npm publication and do not publish packages.
See the [release-preparation skill](.agents/skills/release-preparation/SKILL.md)
for verification and publication steps.

For release questions, open a GitHub issue without including credentials or
internal pipeline configuration.
134 changes: 134 additions & 0 deletions __tests__/native_loader.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

const { describe, it } = require('node:test');
const assert = require('node:assert/strict');
const { spawnSync } = require('node:child_process');
const { copyFileSync, mkdtempSync, mkdirSync, readFileSync, rmSync } = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const vm = require('node:vm');

const root = path.join(__dirname, '..');
const source = readFileSync(path.join(root, 'lib', 'duroxide.js'), 'utf8');
const manifest = require('../package.json');

describe('native loader diagnostics', () => {
it('still exports the SDK when native bindings load successfully', () => {
const context = {
module: { exports: {} },
require(name) {
assert.equal(name, '../index.js');
return {};
},
};
vm.runInNewContext(source, context);
for (const name of ['SqliteProvider', 'PostgresProvider', 'Client', 'Runtime']) {
assert.equal(typeof context.module.exports[name], 'function');
}
});

it('explains a missing optional package through the real generated loader', (t) => {
const directory = mkdtempSync(path.join(os.tmpdir(), 'duroxide-loader-'));
t.after(() => rmSync(directory, { recursive: true, force: true }));
mkdirSync(path.join(directory, 'lib'));
copyFileSync(path.join(root, 'index.js'), path.join(directory, 'index.js'));
copyFileSync(path.join(root, 'package.json'), path.join(directory, 'package.json'));
copyFileSync(path.join(root, 'lib', 'duroxide.js'), path.join(directory, 'lib', 'duroxide.js'));
const script = `
const assert = require('node:assert/strict');
assert.throws(() => require('./lib/duroxide'), (error) => {
assert.match(error.message, /Cannot find module 'duroxide-/);
assert.match(error.message, /running on Node.js older than 22/);
assert.match(error.message, /installing with Node.js older than 22/);
assert.match(error.message, /install-time Node.js version/);
assert.match(error.message, /Other causes include omitted optional dependencies/);
assert.match(error.message, /reinstall with optional dependencies enabled/);
assert.equal(error.cause.code, 'MODULE_NOT_FOUND');
assert.equal(error.code, 'MODULE_NOT_FOUND');
assert.equal(error.requireStack, error.cause.requireStack);
assert.ok(error.message.startsWith(error.cause.message));
assert.match(error.cause.stack, /index.js/);
assert.ok(error.cause.requireStack.some((file) => file.endsWith('index.js')));
return true;
});
`;
const child = spawnSync(process.execPath, ['-e', script], {
cwd: directory, encoding: 'utf8', env: { ...process.env, NODE_PATH: '' }, timeout: 10000,
});
assert.equal(child.status, 0, child.stderr || String(child.error));
});

it('keeps the original error and its existing cause', () => {
const cause = new Error('underlying failure');
const original = new Error("Cannot find module 'duroxide-linux-x64-gnu'", { cause });
original.code = 'MODULE_NOT_FOUND';
original.requireStack = ['index.js', 'lib/duroxide.js'];
assert.throws(() => vm.runInNewContext(source, {
require(name) {
if (name === '../package.json') return manifest;
throw original;
},
}), (error) => {
assert.equal(error.cause, original);
assert.equal(error.cause.cause, cause);
assert.equal(error.code, original.code);
assert.equal(error.requireStack, original.requireStack);
return true;
});
});

for (const packageName of ['duroxide-linux-x64-musl', 'duroxide-win32-arm64', 'duroxide-freebsd-x64']) {
it(`does not give reinstall or Node-version advice for unpublished ${packageName}`, () => {
const original = new Error(`Cannot find module '${packageName}'`);
original.code = 'MODULE_NOT_FOUND';
assert.throws(() => vm.runInNewContext(source, {
require(name) {
if (name === '../package.json') return manifest;
throw original;
},
}), (error) => {
assert.equal(error, original);
assert.doesNotMatch(error.message, /Node.js|reinstall/);
return true;
});
});
}

it('preserves the native error when the package manifest cannot be read', () => {
const original = new Error("Cannot find module 'duroxide-linux-x64-gnu'");
original.code = 'MODULE_NOT_FOUND';
assert.throws(() => vm.runInNewContext(source, {
require(name) {
if (name === '../package.json') throw new SyntaxError('Invalid package manifest');
throw original;
},
}), (error) => error === original);
});

it('preserves the native error when the manifest has no optional dependencies', () => {
const original = new Error("Cannot find module 'duroxide-linux-x64-gnu'");
original.code = 'MODULE_NOT_FOUND';
assert.throws(() => vm.runInNewContext(source, {
require(name) {
if (name === '../package.json') return {};
throw original;
},
}), (error) => error === original);
});

for (const [code, message] of [
['MODULE_NOT_FOUND', "Cannot find module 'unrelated-dependency'"],
['MODULE_NOT_FOUND', "Cannot find module '../index.js'"],
['ERR_DLOPEN_FAILED', 'Native library could not be opened'],
[undefined, 'Unsupported architecture'],
]) {
it(`does not replace unrelated load errors: ${message}`, () => {
const original = new Error(message);
original.code = code;
assert.throws(() => vm.runInNewContext(source, {
require() { throw original; },
}), (error) => error === original);
});
}
});
Loading
Loading