From c98560e3cc8d2a967b3b19b0d7aaf9ddca3b4719 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 03:00:31 +0000 Subject: [PATCH 1/7] test(ship): failing-first Step 12 keep-current refusal and unattended early bump write (GST-380) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- test/helpers/ship-bin-fixture.ts | 3 ++- test/ship-release.test.ts | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/test/helpers/ship-bin-fixture.ts b/test/helpers/ship-bin-fixture.ts index 2db3045dd5..8ba52af55b 100644 --- a/test/helpers/ship-bin-fixture.ts +++ b/test/helpers/ship-bin-fixture.ts @@ -56,7 +56,8 @@ export function shipFixture(base: Record = {}, feat: Record { }); }); +describe('version (Step 12): keeping VERSION and waiting for the bump answer (GST-380)', () => { + const UNATTENDED = { GSTACK_SESSION_KIND: 'unattended' }; + const untouched = (f: ShipFx) => { + expect(read(f, 'VERSION')).toBe('1.0.0.0\n'); + expect(JSON.parse(read(f, 'package.json')).version).toBe('1.0.0'); + expect(read(f, 'CHANGELOG.md')).toContain('## [Unreleased]'); + expect(f.git('status', '--porcelain').stdout).toBe(''); + }; + + // Value: protects=a repo whose unit PRs never change VERSION can pass Step 12 with --keep-current or --version on a FRESH branch, and nothing is written or claimed; fails_when=FRESH demands a level before it reads those flags (gstack-evals#85: BUMP_LEVEL needed for all three flags); + // why_new=GST-380; seam=gstack-version-bump classify; no_claim=the queue's live host read + test('FRESH under bump ask: --keep-current and --version keep VERSION with no write', () => { + for (const args of [['--keep-current'], ['--version', '1.0.0.0']]) { + const f = fx(); + const r = f.run(RELEASE, ['version', '--base', 'main', ...args]); + expect([r.status, lineOf(r.stdout, 'VERSION')]).toEqual([0, expect.stringMatching(/^VERSION: 1\.0\.0\.0 kept \(FRESH, /)]); + expect(r.stdout).toContain('NEXT: Step 13'); + untouched(f); + } + const g = fx(); + const incomplete = g.run(RELEASE, ['version', '--base', 'main', '--accept-incomplete']); + expect([incomplete.status, incomplete.stdout.includes('--keep-current')]).toEqual([3, true]); + untouched(g); + }); + + // Value: protects=in a session no person answers (unattended, spawned, OpenClaw, headless) a bump under bump ask waits for the owner's words before anything is written; fails_when=the bin writes VERSION on a --bump the agent took as the recommended option (gstack-evals#89 wrote 0.0.2 before anyone was asked); + // why_new=GST-380; seam=gstack-session-kind's classification, gstack-version-bump write; no_claim=that the words came from the owner + test('an unattended --bump under bump ask stops with BUMP_ANSWER_REQUIRED and writes nothing until --answer', () => { + for (const env of [UNATTENDED, { GSTACK_SESSION_KIND: 'spawned' }, { OPENCLAW_SESSION: '1' }, { GSTACK_HEADLESS: '1' }]) { + const f = fx(); + const r = f.run(RELEASE, ['version', '--base', 'main', '--bump', 'micro', '--why', 'small'], env); + expect([r.status, /^STOP: BUMP_ANSWER_REQUIRED/m.test(r.stdout), r.stdout.includes('--keep-current')]).toEqual([3, true, true]); + untouched(f); + } + const f = fx(); + expect(f.run(RELEASE, ['version', '--base', 'main', '--bump', 'micro', '--answer', '--why', 'x'], UNATTENDED).status).toBe(2); + expect(f.run(RELEASE, ['version', '--base', 'main', '--bump', 'micro', '--answer', ' '], UNATTENDED).status).toBe(2); + untouched(f); + const ok = f.run(RELEASE, ['version', '--base', 'main', '--bump', 'micro', '--answer', 'micro is fine'], UNATTENDED); + expect([ok.status, read(f, 'VERSION')]).toEqual([0, '1.0.0.1\n']); + const patch = fx({ '.gstack/ship-policy.json': '{"bump":"patch"}\n' }); + expect([patch.run(RELEASE, ['version', '--base', 'main'], UNATTENDED).status, read(patch, 'VERSION')]).toEqual([0, '1.0.1.0\n']); + }); +}); + describe('finish (Steps 15-16)', () => { // Value: protects=finish commits only release metadata with the trailer, then checks the reviewed-tree route, docs freshness, each lane receipt and the pregate; fails_when=it commits feature files, skips a stage, or pushes; // why_new=moved from Steps 15-16; seam=gstack-wtree, gstack-docs-candidate compare, gstack-evidence, gstack-pregate; no_claim=the stage 5 report From 492615e25fb5d7e14bf7c0b90c62b4866d07a0b4 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 03:13:59 +0000 Subject: [PATCH 2/7] fix(ship): Step 12 keeps VERSION on --keep-current, adds bump never, and waits for the owner's answer before an unattended bump (GST-380) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- docs/ship-policy.md | 4 ++- lib/restamp.ts | 1 + lib/ship-policy.ts | 25 +++++++++++----- lib/ship-release.ts | 27 ++++++++++++++--- ship/DRIVER.md | 4 +-- ship/DRIVER.md.tmpl | 4 +-- ship/SKILL.md | 2 +- ship/SKILL.md.tmpl | 2 +- ship/sections/changelog.md | 4 +++ ship/sections/changelog.md.tmpl | 4 +++ test/gstack-restamp-queue.test.ts | 13 +++++++++ test/gstack-ship-policy.test.ts | 20 +++++++++++-- test/ship-release.test.ts | 29 +++++++++++++++++++ .../ship/gsta-191-ship-keep-current.json | 4 +++ 14 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 test/size-ledger/ship/gsta-191-ship-keep-current.json diff --git a/docs/ship-policy.md b/docs/ship-policy.md index 025ada534a..c7b3f3f830 100644 --- a/docs/ship-policy.md +++ b/docs/ship-policy.md @@ -39,7 +39,7 @@ refuses the file (`POLICY_GSTACK_TOO_OLD`). `validate` ends with | Key | Values | Default | Meaning | |---|---|---|---| -| `bump` | `patch` \| `ask` | `ask` | `patch` skips the MINOR/MAJOR prompt in `/ship` Step 12 and `gstack-restamp --next` bumps PATCH; `ask` keeps the prompt. | +| `bump` | `patch` \| `ask` \| `never` | `ask` | `patch` skips the MINOR/MAJOR prompt in `/ship` Step 12 and `gstack-restamp --next` bumps PATCH; `ask` keeps the prompt, and in a session no person answers `--bump` stops with `BUMP_ANSWER_REQUIRED` until `--answer ""`; `never` is for a repo whose unit PRs never change VERSION: Step 12 keeps it with no question, refuses `--bump`, and `gstack-restamp --next` needs an explicit `--bump` or `--version` (the release process bumps). `never` needs `min_gstack_version` at its introducing release and cannot be combined with `queue_mode: stamp-at-merge`, `train` or `changelog_fragments`, which stamp a version at every merge. | | `queue_mode` | `claim-at-open` \| `stamp-at-merge` | `claim-at-open` | See [stamp-at-merge](#stamp-at-merge). `claim-at-open` is today's queue (`gstack-next-version` claims a slot when the PR opens). | | `release_tool` | command or `null` | `null` | The repo's own release command (`bun run release:restamp`). Runs in an isolated staging worktree under the [release-tool contract](#release-tool-contract). | | `release_outputs` | globs | `[]` | Paths the release tool may write beyond the version files, lockfiles, CHANGELOG and `stamp_paths`. Anything else is `RESTAMP_OUTPUT_OUTSIDE_ALLOWED`. | @@ -866,6 +866,8 @@ which carry the workflow consequences the skill prose would otherwise spell out: | `ship: shared merge queue: …` | in a coordinator-run queue, `gstack-ship-queue ready`, `gate-ahead` and `stamp` replace the restamp calls; see [Run a shared merge queue](#run-a-shared-merge-queue) | | `ship: gate-ahead: …` | with `.gstack/tmp/gate-ahead.json` present, Step 16 reuses only the lanes `gstack-tree-receipt … --json > .gstack/tmp/tree-receipt.json` marks reusable; stamp-sensitive and not-eligible lanes run live; `--force-gate ` is the coordinator's call | | `ship: bump patch: …` | Step 12 never asks for MINOR or MAJOR; PATCH or MICRO by size | +| `ship: bump never: …` | Step 12 prints `VERSION: kept (policy: bump never; no write)`, asks nothing and refuses `--bump`; a branch that moved VERSION stops until it is put back | +| `ship: bump ask: …` | Step 12 asks for MINOR and MAJOR; on FRESH, `--keep-current` (or `--version `) keeps VERSION, and in a session no person answers any `--bump` waits for `--answer` | | `ship: preregistration: …` | `gstack-evidence ancestor --from-policy --base ` must print only `ANCESTOR: ok` before push | | `ship: release_tool: …` | the command runs only inside `gstack-restamp` (staging worktree, outputs confined to `release_outputs`) | | `ship: review_scope …` | Step 9.4 item 0 runs `gstack-review-scope classify` on each pass's findings; see [review_scope](#review-scope) | diff --git a/lib/restamp.ts b/lib/restamp.ts index c9b4c7707c..06b4a8828f 100644 --- a/lib/restamp.ts +++ b/lib/restamp.ts @@ -672,6 +672,7 @@ export function restamp(o: RestampOptions): RestampResult { try { const { loaded, label } = loadPolicy(o); if (loaded.errors.length) throw new Refusal(loaded.errors[0]!.code, `${SHIP_POLICY_PATH} (${label}): ${loaded.errors[0]!.message} at ${loaded.errors[0]!.path}; nothing written`); + if (loaded.policy.bump === 'never' && !o.bump && !o.version) throw new Refusal('RESTAMP_VERSION_SOURCE', `${SHIP_POLICY_PATH} (${label}): bump never names no level; a release stamp passes --bump or --version ; nothing written`); const commands = declaredCommands(loaded.policy); if (commands.length && !o.allowRepoCommands) { throw new Refusal('REPO_COMMANDS_NOT_ALLOWED', `repo commands not executed (pass --allow-repo-commands): ${commands.map(c => `${c.key}: ${c.command}`).join('; ')}; nothing written`, { commands }); diff --git a/lib/ship-policy.ts b/lib/ship-policy.ts index acd3f423c7..e1be67394c 100644 --- a/lib/ship-policy.ts +++ b/lib/ship-policy.ts @@ -21,7 +21,7 @@ import { cmpVersion, parseVersion } from './version-source'; export const SHIP_POLICY_PATH = '.gstack/ship-policy.json'; export const SHIP_POLICY_SCHEMA = 'https://github.com/garrytan/gstack/docs/ship-policy.md#schema-v1'; -export type BumpPolicy = 'patch' | 'ask'; +export type BumpPolicy = 'patch' | 'ask' | 'never'; export type QueueMode = 'claim-at-open' | 'stamp-at-merge'; export type HistoryPolicy = 'merge-only' | 'squash-ok'; /** `frozen`: /ship fixes the diff in pass 1, defers unchanged code to issues and reviews only the range after; `all`: every finding is fixed now. */ @@ -29,7 +29,7 @@ export type ReviewScope = 'frozen' | 'diff-plus-blocking' | 'all'; export interface ShipPolicy { $schema?: string; - /** `patch` skips the MINOR/MAJOR prompts in /ship Step 12; `ask` keeps them. */ + /** `patch` skips the MINOR/MAJOR prompts in /ship Step 12; `ask` keeps them; `never` keeps VERSION on every unit PR. */ bump: BumpPolicy; /** `stamp-at-merge`: no claim at PR open; stamp when the PR is next. `claim-at-open` is today's queue. */ queue_mode: QueueMode; @@ -128,7 +128,7 @@ export const POLICY_KEYS = Object.keys(DEFAULT_POLICY) as PolicyKey[]; /** What each key means, printed by `init --explain` (JSON carries no comments). */ export const POLICY_EXPLANATIONS: Record = { - bump: 'patch | ask. `patch` skips the MINOR/MAJOR prompt in /ship Step 12.', + bump: 'patch | ask | never. `patch` skips the MINOR/MAJOR prompt in /ship Step 12; `ask` keeps it, and a session no person answers needs the owner\'s words (--answer) before a bump is written; `never` keeps VERSION on every unit PR (Step 12 writes nothing and asks nothing; the release process bumps). `never` needs min_gstack_version and rules out stamp-at-merge, train and changelog_fragments.', queue_mode: 'claim-at-open | stamp-at-merge. stamp-at-merge stamps when the PR is next (`gstack-restamp --next`), from the base branch version at that moment.', release_tool: 'The repo’s own release command, run in an isolated staging worktree with an enumerated allowed-output set. Never runs without /ship or --allow-repo-commands.', release_outputs: 'Globs the release tool may write beyond the version files, lockfiles, CHANGELOG and stamp_paths. Any other output refuses the restamp.', @@ -181,6 +181,8 @@ export const TRAIN_KEYS_VERSION = '1.91.146.0'; export const REVIEW_SCOPE_KEY_VERSION = '1.91.256.0'; export const DOCS_CAPS_KEY_VERSION = '1.91.270.0'; export const CHANGELOG_FRAGMENTS_KEY_VERSION = '1.91.336.0'; +/** `bump: never` is a value of an older key, so the per-key floor check misses it; compatErrors checks it by value. */ +export const BUMP_NEVER_KEY_VERSION = '1.92.0.0'; export const POLICY_KEY_INTRODUCED: Record = { bump: '1.91.73.0', queue_mode: '1.91.73.0', release_tool: '1.91.73.0', release_outputs: '1.91.73.0', stamp_paths: '1.91.73.0', changelog: '1.91.73.0', mirror: '1.91.73.0', history: '1.91.73.0', preregistration_shas: '1.91.73.0', stamp_sensitive_gates: '1.91.73.0', @@ -200,14 +202,14 @@ const newer = (a: string, b: string): boolean => cmpVersion(parseVersion(a)!, pa export function runningGstackVersion(): string { let own = '0.0.0.0'; try { own = fs.readFileSync(path.resolve(import.meta.dir, '..', 'VERSION'), 'utf8').trim(); } catch {} - const known = Object.values(POLICY_KEY_INTRODUCED).reduce((a, b) => (newer(b, a) ? b : a)); + const known = [...Object.values(POLICY_KEY_INTRODUCED), BUMP_NEVER_KEY_VERSION].reduce((a, b) => (newer(b, a) ? b : a)); return parseVersion(own) && !newer(known, own) ? own : known; } /** The newest introducing version among the keys a parsed policy sets: the gstack a crew needs to read it. */ export function minimumReader(raw: Record): string { return Object.keys(raw).filter((k): k is PolicyKey => POLICY_KEYS.includes(k as PolicyKey)) - .map(k => POLICY_KEY_INTRODUCED[k]).reduce((a, b) => (newer(b, a) ? b : a), POLICY_KEY_INTRODUCED.bump); + .map(k => (k === 'bump' && raw.bump === 'never' ? BUMP_NEVER_KEY_VERSION : POLICY_KEY_INTRODUCED[k])).reduce((a, b) => (newer(b, a) ? b : a), POLICY_KEY_INTRODUCED.bump); } export interface PolicyError { code: ResultCodeName; path: string; message: string } @@ -339,7 +341,11 @@ export function validatePolicy(raw: unknown, opts: { gstackVersion?: string } = const oneOf = (key: string, values: readonly string[]) => { if (key in obj && !values.includes(obj[key] as string)) errors.push({ code: 'POLICY_INVALID', path: key, message: `must be one of ${values.join(' | ')}, got ${JSON.stringify(obj[key])}` }); }; - oneOf('bump', ['patch', 'ask']); + oneOf('bump', ['patch', 'ask', 'never']); + if (obj.bump === 'never') { + const stamps = [obj.queue_mode === 'stamp-at-merge' && 'queue_mode stamp-at-merge', obj.train != null && 'train', obj.changelog_fragments != null && 'changelog_fragments'].filter(Boolean); + if (stamps.length) errors.push({ code: 'POLICY_INVALID', path: 'bump', message: `never keeps VERSION on every PR, but ${stamps.join(' and ')} stamps a version at every merge; drop one` }); + } oneOf('queue_mode', ['claim-at-open', 'stamp-at-merge']); oneOf('history', ['merge-only', 'squash-ok']); oneOf('review_scope', ['frozen', 'diff-plus-blocking', 'all']); @@ -412,6 +418,9 @@ function compatErrors(obj: Record, running: string, errors: Pol if (typeof min === 'string' && !newer(since, min)) continue; errors.push({ code: 'POLICY_INVALID', path: key, message: `introduced in gstack ${since}; set min_gstack_version to ${since} or later so an older gstack refuses this policy by name` }); } + if (obj.bump === 'never' && !(typeof min === 'string' && !newer(BUMP_NEVER_KEY_VERSION, min))) { + errors.push({ code: 'POLICY_INVALID', path: 'bump', message: `never was introduced in gstack ${BUMP_NEVER_KEY_VERSION}; set min_gstack_version to ${BUMP_NEVER_KEY_VERSION} or later so an older gstack refuses this policy by name` }); + } } /** @@ -575,7 +584,9 @@ export function shipConsequences(policy: ShipPolicy, base: string): string[] { } else out.push('queue_mode claim-at-open: Step 12 runs as written (claims through gstack-next-version)'); const frag = policy.changelog_fragments?.dir.replace(/\/+$/, ''); if (frag) out.push(`changelog_fragments ${frag}: Step 12 writes no version and Step 13 writes the entry as ${frag}/.md (the entry text only, no heading; \`bump: minor\` or \`bump: major\` front matter only when the change warrants more than the policy bump), never an [Unreleased] section; lint it with \`gstack-prose-lint ${frag}/.md --gate\`; \`gstack-ship-queue land\` assigns the version at merge (docs/ship-policy.md#changelog-fragments)`); - out.push(policy.bump === 'patch' ? 'bump patch: Step 12 never asks for MINOR or MAJOR; PATCH or MICRO by size' : 'bump ask: Step 12 asks for MINOR and MAJOR as written'); + out.push(policy.bump === 'patch' ? 'bump patch: Step 12 never asks for MINOR or MAJOR; PATCH or MICRO by size' + : policy.bump === 'never' ? 'bump never: Step 12 keeps VERSION (no write, no question) and refuses --bump; the release process bumps outside /ship' + : 'bump ask: Step 12 asks for MINOR and MAJOR as written; in a session no person answers, a bump waits for the owner\'s words (--answer)'); out.push(policy.review_scope === 'all' ? 'review_scope all: Step 9.4 fixes every finding on every pass (gstack-review-scope classify --policy all)' : policy.review_scope === 'diff-plus-blocking' diff --git a/lib/ship-release.ts b/lib/ship-release.ts index ec9fc81ff6..7780a327f0 100644 --- a/lib/ship-release.ts +++ b/lib/ship-release.ts @@ -18,8 +18,9 @@ import { bin, evidenceExempt, firstLine, flagReader, fragmentPath, gh, git, host export const RELEASE_HELP = `gstack-ship-release — /ship Steps 12 and 15-17 (ship/SKILL.md) - version --base [--bump micro|patch|minor|major] [--version ] [--keep-current] [--accept-incomplete] [--why ] - Step 12: classify, pick the queue-aware version, write it with --regen-digest --changelog, log the decision + version --base [--bump micro|patch|minor|major] [--version ] [--keep-current] [--accept-incomplete] [--why ] [--answer ] + Step 12: classify, pick the queue-aware version, write it with --regen-digest --changelog, log the decision; + --keep-current (or --version ) keeps VERSION; under bump ask a session no person answers needs --answer before a bump is written finish --base --reviewed-tree --docs-post [--lane