Durable coding-agent harnesses (Claude Code, Codex, OpenCode, Pi, fx) on a Workflow SDK World
Enforce patch-only releases in CI and release commands (#29)
Pranay Prakashea8aa4060cf4
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 2c8e6e8..57a600c 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -71,6 +71,20 @@ jobs:PR_BODY: ${{ github.event.pull_request.body }}run: node scripts/check-public.mjs --commits "$BASE_SHA..$HEAD_SHA"+ release-policy:+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@v5+ - uses: pnpm/action-setup@v6+ - uses: actions/setup-node@v5+ with:+ node-version: 24+ cache: pnpm+ - run: pnpm install --frozen-lockfile+ - name: Patch-only release policy and regression tests+ run: pnpm check:changesets+typecheck:runs-on: ubuntu-latesttimeout-minutes: 15@@ -87,10 +101,6 @@ jobs:# tools or NodeExecutionEnv, or mints the machine brand (docs/workspaces.md §6).- name: Host spawn lintrun: node --test scripts/lint-host-spawn.test.mjs && node scripts/lint-host-spawn.mjs- # durable-harness stays on 0.0.x: a changeset may only be a patch, and only- # for durable-harness (docs/releasing.md). The Release workflow runs it too.- - name: Check the release line- run: pnpm check:changesets# The release gate on every change (the Release workflow runs it before a# publish too): durable-harness's build ships the relay bundle, no stub or# stand-in, Claude Code and Codex only on a branded machine, and thediff --git a/AGENTS.md b/AGENTS.mdnew file mode 100644index 0000000..8c10b1d--- /dev/null+++ b/AGENTS.md@@ -0,0 +1,6 @@+# Release policy++- `durable-harness` stays on `0.0.x`. Normal releases may increment only the patch version.+- A request to ship, publish, or release changes does **not** authorize a major or minor bump, changing the release line, or weakening its checks.+- Changing the release line requires an explicit decision from a human maintainer and a separately reviewed policy change, including the guard and its tests. Do not infer that decision from a Changesets release PR.+- Run `pnpm check:changesets` before versioning or publishing. See [docs/releasing.md](docs/releasing.md) for the release workflow.diff --git a/docs/releasing.md b/docs/releasing.mdindex 8bc6da2..cc1e45a 100644--- a/docs/releasing.md+++ b/docs/releasing.md@@ -21,10 +21,18 @@ fails whenchangesets cannot be assembled into a release plan (which would break`changeset version` on main).-CI runs it on every pull request (the `typecheck` job) and the Release-workflow runs it before anything else. Leaving 0.0.x is a deliberate decision:-change `LINE` in that script in the same pull request as the changeset that-moves.+CI runs it on every pull request in the separate `release-policy` job. The+command includes regression tests that reject minor/major changesets and+manually edited versions outside 0.0.x, including prereleases. It also accepts+ordinary patch releases and consumed Version Packages pull requests. The Release+workflow runs the same command before building. Both `pnpm ci:version` and+`pnpm ci:publish` also run it before versioning or publishing.++Leaving 0.0.x requires an **explicit human maintainer decision** and a separately+reviewed policy change to the guard (`LINE`) and its tests. A request to ship or+publish a release, or merging an automatically generated Version Packages pull+request, does not authorize changing this policy. There is no automatic major or+minor override.## Adding a changesetdiff --git a/package.json b/package.jsonindex 0bdca01..e4beda5 100644--- a/package.json+++ b/package.json@@ -6,9 +6,9 @@"scripts": {"build": "pnpm -r build","changeset": "changeset",- "check:changesets": "node scripts/check-changesets.mjs",- "ci:publish": "pnpm --filter durable-harness build && pnpm --filter durable-harness check-dist && changeset publish",- "ci:version": "changeset version",+ "check:changesets": "node --test scripts/check-changesets.test.mjs && node scripts/check-changesets.mjs",+ "ci:publish": "pnpm check:changesets && pnpm --filter durable-harness build && pnpm --filter durable-harness check-dist && changeset publish",+ "ci:version": "pnpm check:changesets && changeset version","cli-check": "pnpm --filter harness-world-cli-check cli-check","test": "pnpm -r test","typecheck": "pnpm -r typecheck"diff --git a/scripts/check-changesets.mjs b/scripts/check-changesets.mjsindex fdba65a..fc1149b 100644--- a/scripts/check-changesets.mjs+++ b/scripts/check-changesets.mjs@@ -19,8 +19,9 @@* on main. A changeset naming a private package (every package but* durable-harness) fails too: it would release nothing.*- * Leaving 0.0.x is a deliberate decision: change LINE below in the same pull- * request as the changeset that moves to the new line.+ * Leaving 0.0.x requires an explicit human maintainer decision and a separately+ * reviewed policy change. A normal release request never authorizes changing+ * LINE below or relaxing this guard (AGENTS.md, docs/releasing.md).** Usage: node scripts/check-changesets.mjs (pnpm check:changesets). Writes a* summary to $GITHUB_STEP_SUMMARY when set.diff --git a/scripts/check-changesets.test.mjs b/scripts/check-changesets.test.mjsnew file mode 100644index 0000000..90ec4c5--- /dev/null+++ b/scripts/check-changesets.test.mjs@@ -0,0 +1,85 @@+import assert from 'node:assert/strict';+import { mkdtempSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join, resolve } from 'node:path';+import { spawnSync } from 'node:child_process';+import { test } from 'node:test';+import { fileURLToPath } from 'node:url';++const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');+const script = readFileSync(join(root, 'scripts/check-changesets.mjs'));+const config = JSON.parse(readFileSync(join(root, '.changeset/config.json'), 'utf8'));++// Run the real lint against disposable workspaces, including Changesets' real+// release planner. No fixture can change the checked-out package's version.+function check(t, { version = '0.0.1', bump, name = 'durable-harness', preState } = {}) {+ const cwd = mkdtempSync(join(tmpdir(), 'durable-harness-release-policy-'));+ t.after(() => rmSync(cwd, { recursive: true, force: true }));+ for (const dir of ['scripts', '.changeset', 'packages/durable-harness', 'packages/private']) {+ mkdirSync(join(cwd, dir), { recursive: true });+ }+ writeFileSync(join(cwd, 'package.json'), JSON.stringify({ name: 'policy-fixture', private: true, packageManager: '[email protected]' }));+ writeFileSync(join(cwd, 'pnpm-workspace.yaml'), 'packages:\n - packages/*\n');+ writeFileSync(join(cwd, 'packages/durable-harness/package.json'), JSON.stringify({ name: 'durable-harness', version }));+ writeFileSync(join(cwd, 'packages/private/package.json'), JSON.stringify({ name: 'private-harness', version: '0.0.1', private: true }));+ writeFileSync(join(cwd, '.changeset/config.json'), JSON.stringify({ ...config, changelog: false }));+ if (bump) writeFileSync(join(cwd, '.changeset/fixture.md'), `---\n"${name}": ${bump}\n---\n\nFixture release.\n`);+ if (preState) writeFileSync(join(cwd, '.changeset/pre.json'), JSON.stringify(preState));+ writeFileSync(join(cwd, 'scripts/check-changesets.mjs'), script);+ symlinkSync(join(root, 'node_modules'), join(cwd, 'node_modules'), 'junction');+ const env = { ...process.env };+ delete env.GITHUB_STEP_SUMMARY;+ const result = spawnSync(process.execPath, [join(cwd, 'scripts/check-changesets.mjs')], { cwd, env, encoding: 'utf8', timeout: 30_000 });+ assert.ifError(result.error);+ return { status: result.status, output: result.stdout + result.stderr };+}++test('a patch changeset releases 0.0.2', (t) => {+ const result = check(t, { bump: 'patch' });+ assert.equal(result.status, 0, result.output);+ assert.match(result.output, /durable-harness@0\.0\.2/);+});++for (const bump of ['minor', 'major']) {+ test(`rejects a ${bump} changeset before versioning`, (t) => {+ const result = check(t, { bump });+ assert.equal(result.status, 1, result.output);+ assert.match(result.output, new RegExp('`' + bump + '` bump'));+ });+}++for (const version of ['0.1.0', '0.1.0-beta.1', '1.0.0', '1.0.0-beta.1']) {+ test(`rejects a manifest edited directly to ${version}, even with no changesets`, (t) => {+ const result = check(t, { version });+ assert.equal(result.status, 1, result.output);+ assert.match(result.output, /version on this commit/);+ assert.match(result.output, /not 0\.0\.x/);+ });+}++test('a consumed version PR can publish the next patch without pending changesets', (t) => {+ const result = check(t, { version: '0.0.2' });+ assert.equal(result.status, 0, result.output);+ assert.match(result.output, /0 changeset\(s\) pending/);+});++test('allows a patch within an explicitly configured beta prerelease', (t) => {+ const result = check(t, {+ version: '0.0.2-beta.0', bump: 'patch',+ preState: { mode: 'pre', tag: 'beta', initialVersions: { 'durable-harness': '0.0.1' }, changesets: [] },+ });+ assert.equal(result.status, 0, result.output);+ assert.match(result.output, /durable-harness@0\.0\.2-beta\.1/);+});++test('rejects changesets for private bundled packages', (t) => {+ const result = check(t, { bump: 'patch', name: 'private-harness' });+ assert.equal(result.status, 1, result.output);+ assert.match(result.output, /private: this releases nothing/);+});++test('rejects a changeset that cannot form a release plan', (t) => {+ const result = check(t, { bump: 'patch', name: 'missing-harness' });+ assert.equal(result.status, 1, result.output);+ assert.match(result.output, /cannot be turned into a release plan/);+});