Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
v1.92.53.0 fix(ubicloud): reap destroys only the caller's own VMs (GST-573) (#3756)
Garry Tan693ee7132a9d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bbb8e5a32..e75ec6b6b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,12 @@# Changelog+## [1.92.53.0] - 2026-11-02++**`reap` and `up` now destroy only your own Ubicloud VMs (GST-573).** Before, every `up` destroyed any VM in the project whose TTL had ended, whoever created it, which broke the rule that cloud deletes stay with the owner who made the resource. Now reap destroys only the caller's own expired VMs and its own old TTL-less ones, and only counts other owners' expired VMs in its log (`reap: left N expired VMs of other owners; only their owners reap them`).++### Changed+- **Owner-scoped reap.** Another owner's VM, even an expired one, and an untagged one are never reaped. A lane's leftover VM is destroyed by that owner's own next `up` or `reap`, so a lane that never runs again leaves its VM until someone with that owner runs `reap` or `down`.+## [1.92.52.0] - 2026-11-02**/ship on Capy runs Exploratory QA again.** Since v1.91.345.0 (#3648) the driver sent Step 9.2.1 out as a QA reader subagent, but the section says only the parent runs report-only discovery, so the reader refused on every pass ("parent-only") and the parent ran the probes afterward anyway, an extra reader call each pass (the C4-36 and C5-36 replays).diff --git a/VERSION b/VERSIONindex f38f1222d..222a2a9f5 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-1.92.52.0+1.92.53.0diff --git a/agents-digest/gstack-AGENTS.md b/agents-digest/gstack-AGENTS.mdindex 513868411..716c0c598 100644--- a/agents-digest/gstack-AGENTS.md+++ b/agents-digest/gstack-AGENTS.md@@ -1,4 +1,4 @@-# gstack digest v1.92.52.0 — regenerate/re-copy after upgrading gstack+# gstack digest v1.92.53.0 — regenerate/re-copy after upgrading gstackBehavioral rules from gstack (https://github.com/garrytan/gstack), compressedfor agent hosts without a full skill install. The full skills add workflows,diff --git a/docs/TESTING_INTERNALS.md b/docs/TESTING_INTERNALS.mdindex ea9a9f4ca..8c913e020 100644--- a/docs/TESTING_INTERNALS.md+++ b/docs/TESTING_INTERNALS.md@@ -1002,7 +1002,7 @@ with `UBICLOUD: left=<0|1|unknown> owner=<o> vm=<name> others=<n>`, checkedagainst the project's VM list after teardown; anything but `left=0` turns apassing command into exit 1. pregate-remote.sh reads that line from the filenamed by `UBI_LEFT_FILE`, never from the command's output. No owner-age sweep runs by default (the TTL reaper-below covers every owner); set+below covers this owner's expired VMs); set`UBI_GC_HOURS` to a positive number (or run `gc HOURS`; `gc 0` is a no-op) tosweep only this owner's VMs older than that. For other commands, use the runnerdirectly: `scripts/ubicloud/ubi-runner.sh run --setup <script> -- '<command>'`,@@ -1011,12 +1011,12 @@ or its `up` / `ssh` / `sync` / `pull` / `down` steps (`--help` lists them).The runner is also the `/ubicloud` skill's engine (`bin/gstack-ubi` execs it).A generated name ends in `-t<hours>` (`UBI_TTL_HOURS`, 1-999, default 3; pregate-remote.shuses its stop deadline plus 15 minutes, rounded up: `-t1` today), the creator's own statement of how long the VM may live: `reap`-destroys every VM in the project whose TTL ended more than ten minutes ago,-whichever owner made it, and the caller's own `ubirun-<UBI_OWNER>-*` names-without a TTL (older runner copies) once they are `UBI_LEGACY_HOURS` old-(default 4). Another owner's TTL-less VM and an untagged one are never reaped,-because only a TTL lets reap judge another lane's VM. Every `up` runs it-first (`UBI_REAP=0` skips it). Names outside the `ubirun-` prefix are never reaped. The+destroys only the caller's own VMs: its `ubirun-<UBI_OWNER>-*` names whose TTL+ended more than ten minutes ago, and those without a TTL (older runner copies)+once they are `UBI_LEGACY_HOURS` old (default 4). Another owner's VM and an+untagged one are never reaped, even after their TTL ends; reap only counts them+in its log, because cloud deletes stay with the owner that created the VM+(GST-573). Every `up` runs it first (`UBI_REAP=0` skips it). Names outside the `ubirun-` prefix are never reaped. Thequota preflight adds the size's vCPUs to the project's running VMs and refusesbefore the create request when that exceeds the known ceiling(`UBI_QUOTA_VCPUS`, or the maximum the last refusal printed, remembered in the@@ -1070,7 +1070,7 @@ machine swap, in this order:one side local and the other remote.4. Profiling very large imports (a whole-repo ingest, the full free suite undera profiler) is warned about before it starts: it holds the VM for hours, and- any other lane's `up` reaps it once its TTL (`UBI_TTL_HOURS`, default 3)+ the same owner's next `up` or `reap` destroys it once its TTL (`UBI_TTL_HOURS`, default 3)plus ten minutes has passed, so set `UBI_TTL_HOURS` above the expectedduration and name that duration in the thread before launching.diff --git a/docs/skills.md b/docs/skills.mdindex 5ce9fe9dd..c121fc89d 100644--- a/docs/skills.md+++ b/docs/skills.md@@ -1006,8 +1006,8 @@ VM. `/ubicloud` runs it there through one entry point, `bin/gstack-ubi`(`scripts/ubicloud/ubi-runner.sh`), with the discipline a shared quota needs:every VM is named `ubirun-<owner>-<epoch>-<suffix>-t<hours>`, so its owner(`UBI_OWNER`, required to create one) and TTL (`UBI_TTL_HOURS`, default 3) are-visible to everyone; every `up` first reaps VMs whose TTL ended, whichever owner-made them, and its own owner's VMs with no TTL once they are 4 hours old; every run+visible to everyone; every `up` first reaps its own owner's VMs whose TTL ended,+and those with no TTL once they are 4 hours old, never another owner's; every runends with `UBICLOUD: left=0` or fails; thequota preflight refuses before the create request when the project's runningVMs plus the new size exceed the known ceiling (`UBI_QUOTA_VCPUS`, or the@@ -1030,7 +1030,7 @@ Claude: UBICLOUD_API_KEY: set; UBI_OWNER=lane7gstack-ubi verify (.gstack/ubicloud.json: bootstrap.sh, "bash scripts/verify.sh", standard-16)ubi-runner: reap: no expired VMsubi-runner: creating eu-central-h1/ubirun-lane7-1761500000-9f3a2c10-t3 (standard-16)- ubi-runner: ubirun-lane7-1761500000-9f3a2c10-t3 carries a 3h TTL (any later run of this script reaps it); if this process dies first: gstack-ubi down ubirun-lane7-1761500000-9f3a2c10-t3+ ubi-runner: ubirun-lane7-1761500000-9f3a2c10-t3 carries a 3h TTL (this owner's next up or reap destroys it once it expires); if this process dies first: gstack-ubi down ubirun-lane7-1761500000-9f3a2c10-t3ubi-runner: heartbeat: command 300s elapsed, last output 2s agoubi-runner: command exited 0 after 1140subi-runner: destroyed eu-central-h1/ubirun-lane7-1761500000-9f3a2c10-t3diff --git a/package.json b/package.jsonindex 48e84b84b..5ef1cf28b 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "gstack",- "version": "1.92.52",+ "version": "1.92.53","description": "Garry's Stack — Claude Code skills + fast headless browser. One repo, one install, entire AI engineering workflow.","license": "MIT","type": "module",diff --git a/scripts/ubicloud/ubi-runner.sh b/scripts/ubicloud/ubi-runner.shindex bef063f33..03a698e4b 100755--- a/scripts/ubicloud/ubi-runner.sh+++ b/scripts/ubicloud/ubi-runner.sh@@ -44,12 +44,13 @@## TTL and reaper: a name this script generates ends in -t<hours> (UBI_TTL_HOURS,# 1-999, default 3), the creator's own declaration of how long the VM may live.-# `reap` destroys every VM in the project whose TTL expired more than ten-# minutes ago, whichever owner made it, and this owner's own ubirun-<owner>-*-# names with no TTL once they are UBI_LEGACY_HOURS old (default 4; another-# owner's or an untagged TTL-less VM is never reaped); every `up` runs it first (UBI_REAP=0 skips it), so a runner-# killed by a sleeping machine leaves nothing behind for longer than its TTL.-# Names outside the ubirun- prefix are never reaped.+# `reap` destroys only this owner's VMs: its ubirun-<owner>-* names whose TTL+# expired more than ten minutes ago, and those with no TTL once they are+# UBI_LEGACY_HOURS old (default 4). Another owner's VM, an untagged one and+# names outside the ubirun- prefix are never reaped, expired or not; reap only+# counts other owners' expired VMs in its log (cloud deletes stay owner-scoped,+# GST-573). Every `up` runs it first (UBI_REAP=0 skips it), so a lane killed by+# a sleeping machine has its leftovers destroyed by its own next `up`.## Leftover line: `run` and `verify` end with# UBICLOUD: left=<0|1|unknown> owner=<owner> vm=<name> others=<n>@@ -754,23 +755,26 @@ vm_rows() {done}-# reap: destroy every VM whose name carries a TTL that ended more than-# REAP_GRACE seconds ago, whichever owner created it (the TTL is that owner's-# own declaration), and the caller's own TTL-less ubirun-<UBI_OWNER>-* names at-# least LEGACY_HOURS old. Another owner's TTL-less VM, an untagged one, and names-# outside the prefix are never touched: only a TTL lets reap judge another lane's VM.+# reap: destroy the caller's own VMs whose TTL ended more than REAP_GRACE+# seconds ago, and its TTL-less ubirun-<UBI_OWNER>-* names at least LEGACY_HOURS+# old. Every other VM is never touched, whatever its TTL says: a delete stays+# with the owner that created the VM. Other owners' expired VMs are only counted.cmd_reap() {- local now rows loc name owner expires created n=0 failed=0+ local now rows loc name owner expires created n=0 failed=0 others=0[[ "$LEGACY_HOURS" =~ ^[1-9][0-9]{0,3}$ ]] || die "UBI_LEGACY_HOURS must be a whole number of hours from 1 to 9999 with no leading zero (how old a TTL-less ubirun-* VM must be before reap destroys it)"now=$(date +%s)rows=$(vm_rows) || { log "reap: could not list the project's VMs; nothing destroyed"; return 1; }while read -r loc name owner expires created; do[ -n "$name" ] || continue+ if [ "$owner" != "$OWNER" ]; then+ [ "$expires" = - ] || [ "$now" -lt $(( expires + REAP_GRACE )) ] || others=$(( others + 1 ))+ continue+ fiif [ "$expires" != - ]; then[ "$now" -ge $(( expires + REAP_GRACE )) ] || continuelog "reaping expired $loc/$name (owner $owner; its TTL ended $(( (now - expires) / 60 )) min ago)"else- [ -n "${UBI_OWNER:-}" ] && [ "$owner" = "$OWNER" ] && [ "$created" != - ] || continue+ [ -n "${UBI_OWNER:-}" ] && [ "$created" != - ] || continue[ $(( now - 10#$created )) -ge $(( LEGACY_HOURS * 3600 )) ] || continuelog "reaping TTL-less $loc/$name (owner $owner; $(( (now - 10#$created) / 3600 ))h old, legacy sweep at ${LEGACY_HOURS}h)"fi@@ -778,6 +782,7 @@ cmd_reap() {cmd_down "$name" -l "$loc" || { failed=$(( failed + 1 )); log "failed to reap $loc/$name"; }done <<<"$rows"[ "$n" -gt 0 ] || log "reap: no expired VMs"+ [ "$others" -eq 0 ] || log "reap: left $others expired VMs of other owners; only their owners reap them"[ "$failed" -eq 0 ] || { log "reap: $failed of $n expired VMs could not be destroyed"; return 1; }}@@ -1363,7 +1368,7 @@ cmd_run() {trap 'exit 130' INT TERM QUITtrap on_hup HUPif [[ "$name" =~ -t([0-9]+)$ ]]; then- log "$name carries a ${BASH_REMATCH[1]}h TTL (any later run of this script reaps it); if this process dies first: $0 down $name"+ log "$name carries a ${BASH_REMATCH[1]}h TTL (this owner's next up or reap destroys it once it expires); if this process dies first: $0 down $name"elif [[ "$name" =~ ^$PREFIX-$OWNER-[0-9]{10}- ]]; thenlog "$name has no TTL (reap destroys it once it is ${LEGACY_HOURS}h old); if this process dies before its teardown line, destroy it with: $0 down $name"else@@ -1579,8 +1584,8 @@ usage: ubi-runner.sh <command> [args]owner print this caller's owner tag ($OWNER)records VMs this machine created and has not confirmed gone ($VM_RECORD)gc HOURS destroy this owner's VMs older than HOURS (never other owners')- reap destroy every VM whose -t<hours> TTL has ended (any owner) and this- owner's TTL-less ubirun-* VMs older than UBI_LEGACY_HOURS+ reap destroy this owner's VMs whose -t<hours> TTL has ended and its+ TTL-less ubirun-* VMs older than UBI_LEGACY_HOURS (never other owners')cli ARGS... raw Ubicloud CLI passthrough (e.g. cli vm list)signals: INT and TERM tear the VM down. HUP, once a remote phase is live, detachesdiff --git a/test/ubicloud-runner-run.test.ts b/test/ubicloud-runner-run.test.tsindex 81890df77..2e4cabfad 100644--- a/test/ubicloud-runner-run.test.ts+++ b/test/ubicloud-runner-run.test.ts@@ -50,6 +50,7 @@ describe('ubi-runner run, verify and quota against a fake API and a fake ssh', (const err = r.stderr.toString();expect(r.exitCode, err).toBe(0);expect(err).toMatch(/UBICLOUD: left=0 owner=thrd1 vm=ubirun-thrd1-\d{10}-[0-9a-f]{8}-t3 others=1\n/);+ expect(err).toMatch(/carries a 3h TTL \(this owner's next up or reap destroys it once it expires\); if this process dies first: /);expect(f.listed()).toBe('eu-central-h1 ubirun-thrd1-9999999999-sib1-t3\n');// Value: protects=UBI_LEFT_FILE carries the same leftover line pregate-remote.sh parses, apart from the command's output; fails_when=the file is not written or its format drifts from pregate-remote.sh's parser; why_new=the pregate stub hand-copies the format; seam=none; no_claim=real VM teardown (fake API and ssh)expect(readFileSync(leftFile, 'utf8')).toMatch(/^UBICLOUD: left=0 owner=thrd1 vm=ubirun-thrd1-\d{10}-[0-9a-f]{8}-t3 others=1\n$/);diff --git a/test/ubicloud-runner-verify-quota.test.ts b/test/ubicloud-runner-verify-quota.test.tsindex e099b9638..a7cbeea6b 100644--- a/test/ubicloud-runner-verify-quota.test.ts+++ b/test/ubicloud-runner-verify-quota.test.ts@@ -210,12 +210,12 @@ describe('ubi-runner run, verify and quota against a fake API and a fake ssh', (}, 90_000);test('reap reports a failed list and a failed destroy as failures; UBI_TTL_HOURS rejects leading zeros and more than three digits', () => {- const f = fakeVm({ listed: 'eu-central-h1 ubirun-other-1000000000-bbbb-t1\n' });+ const f = fakeVm({ listed: 'eu-central-h1 ubirun-thrd1-1000000000-bbbb-t1\n' });try {- writeFileSync(join(f.root, 'bin/curl'), '#!/usr/bin/env bash\nout=""; while [ $# -gt 0 ]; do [ "$1" = -o ] && out=$2; shift; done\nbody=$(cat)\ncase "$body" in\n *\'"list"\'*) echo "eu-central-h1 ubirun-other-1000000000-bbbb-t1" > "$out"; printf 200 ;;\n *\'"show"\'*) printf \'state: running\\nsize: standard-16\\nip4: 192.0.2.1\\n\' > "$out"; printf 200 ;;\n *) echo "boom" > "$out"; printf 500 ;;\nesac\n');+ writeFileSync(join(f.root, 'bin/curl'), '#!/usr/bin/env bash\nout=""; while [ $# -gt 0 ]; do [ "$1" = -o ] && out=$2; shift; done\nbody=$(cat)\ncase "$body" in\n *\'"list"\'*) echo "eu-central-h1 ubirun-thrd1-1000000000-bbbb-t1" > "$out"; printf 200 ;;\n *\'"show"\'*) printf \'state: running\\nsize: standard-16\\nip4: 192.0.2.1\\n\' > "$out"; printf 200 ;;\n *) echo "boom" > "$out"; printf 500 ;;\nesac\n');const destroyFails = run(f, ['reap']);expect(destroyFails.exitCode).toBe(1);- expect(destroyFails.stderr.toString()).toContain('failed to reap eu-central-h1/ubirun-other-1000000000-bbbb-t1');+ expect(destroyFails.stderr.toString()).toContain('failed to reap eu-central-h1/ubirun-thrd1-1000000000-bbbb-t1');expect(destroyFails.stderr.toString()).toContain('reap: 1 of 1 expired VMs could not be destroyed');writeFileSync(join(f.root, 'bin/curl'), '#!/usr/bin/env bash\nout=""; while [ $# -gt 0 ]; do [ "$1" = -o ] && out=$2; shift; done\ncat >/dev/null; echo "down" > "$out"; printf 503\n');const listFails = run(f, ['reap']);diff --git a/test/ubicloud-runner.test.ts b/test/ubicloud-runner.test.tsindex 71d1de15e..66f6605bf 100644--- a/test/ubicloud-runner.test.ts+++ b/test/ubicloud-runner.test.ts@@ -204,25 +204,25 @@ esac} finally { rmSync(f.root, { recursive: true, force: true }); }});- test('up reaps expired TTL VMs of any owner first, names its own VM with -t<hours>, and the quota preflight refuses before any create request', () => {- const listed = 'eu-central-h1 ubirun-other-1000000000-bbbb-t1\neu-central-h1 ubirun-peer-9999999999-cccc\n';+ test('up reaps this owner\'s expired TTL VMs first and leaves another owner\'s, names its own VM with -t<hours>, and the quota preflight refuses before any create request', () => {+ const listed = 'eu-central-h1 ubirun-thrd1-1000000000-hhhh-t1\neu-central-h1 ubirun-peer-9999999999-cccc\n';const f = fakeApi({ destroy: 200, listed });try {const r = Bun.spawnSync(['bash', join(DIR, 'ubi-runner.sh'), 'up'], { env: { ...process.env, PATH: `${join(f.root, 'bin')}:${process.env.PATH}`, UBICLOUD_API_KEY: 'offline', UBI_RUNNER_STATE: join(f.root, 'state'), UBI_POLL_SECONDS: '1', UBI_VM_RECORD: f.record, UBI_OWNER: 'thrd1', UBI_QUOTA_VCPUS: '31' }, timeout: 90_000 });expect(r.exitCode).toBe(1);const err = r.stderr.toString();- expect(err).toMatch(/reaping expired eu-central-h1\/ubirun-other-1000000000-bbbb-t1 \(owner other; its TTL ended \d+ min ago\)/);+ expect(err).toMatch(/reaping expired eu-central-h1\/ubirun-thrd1-1000000000-hhhh-t1 \(owner thrd1; its TTL ended \d+ min ago\)/);expect(err).toMatch(/quota preflight refused eu-central-h1\/ubirun-thrd1-\d{10}-[0-9a-f]{8}-t3 \(standard-16\): it needs 16 vCPUs and the project's VMs already use 16 of 31/);expect(err).toContain('create refused before any request: vCPU quota exhausted');const destroyed = f.calls().split('\n').filter(l => l.includes('destroy'));expect(destroyed).toHaveLength(1);- expect(destroyed[0]).toContain('ubirun-other-1000000000-bbbb-t1');+ expect(destroyed[0]).toContain('ubirun-thrd1-1000000000-hhhh-t1');expect(f.calls()).not.toContain('"create"');expect(existsSync(f.record)).toBe(false);} finally { rmSync(f.root, { recursive: true, force: true }); }});- test('UBI_REAP=0 skips the reap and UBI_TTL_HOURS sets the name\'s TTL; reap destroys expired TTLs and this owner\'s old TTL-less names, never unexpired, recent, another owner\'s TTL-less, untagged or foreign ones', () => {+ test('UBI_REAP=0 skips the reap and UBI_TTL_HOURS sets the name\'s TTL; reap destroys this owner\'s expired TTLs and old TTL-less names, never unexpired, recent, another owner\'s expired or TTL-less, untagged or foreign ones', () => {const now = Math.floor(Date.now() / 1000);const listed = `eu-central-h1 ubirun-other-1000000000-bbbb-t1\neu-central-h1 ubirun-thrd1-9999999999-dddd-t1\neu-central-h1 ubirun-thrd1-1000000000-aaaa\neu-central-h1 ubirun-1000000000-cccc\neu-central-h1 ubirun-thrd1-${now - 3 * 3600}-eeee\neu-central-h1 ubirun-gbra240-1000000000-gggg\neu-central-h1 team-db-1000000000-ffff\n`;const f = fakeApi({ destroy: 200, listed });@@ -235,7 +235,8 @@ esacexpect(reap.exitCode).toBe(0);expect(reap.stderr.toString()).toMatch(/reaping TTL-less eu-central-h1\/ubirun-thrd1-1000000000-aaaa \(owner thrd1; \d+h old, legacy sweep at 4h\)/);const destroyed = f.calls().split('\n').filter(l => l.includes('destroy')).map(l => l.match(/ubirun-[a-z0-9-]+|team-db-[a-z0-9-]+/)?.[0]).sort();- expect(destroyed).toEqual(['ubirun-other-1000000000-bbbb-t1', 'ubirun-thrd1-1000000000-aaaa']);+ expect(destroyed).toEqual(['ubirun-thrd1-1000000000-aaaa']);+ expect(reap.stderr.toString()).toContain('reap: left 1 expired VMs of other owners; only their owners reap them');expect(f.run('reap').stderr.toString()).toContain('reap: no expired VMs');// Value: protects=UBI_LEGACY_HOURS sets reap's bound for TTL-less ubirun names (a 3h-old name is spared at 4h, reaped at 2h); fails_when=reap ignores UBI_LEGACY_HOURS and keeps a fixed bound; why_new=only the default bound and the validation are tested; seam=none; no_claim=real Ubicloud list and destroy (fake curl)const lowered = Bun.spawnSync(['bash', join(DIR, 'ubi-runner.sh'), 'reap'], { env: { ...process.env, PATH: `${join(f.root, 'bin')}:${process.env.PATH}`, UBICLOUD_API_KEY: 'offline', UBI_RUNNER_STATE: join(f.root, 'state'), UBI_POLL_SECONDS: '1', UBI_VM_RECORD: f.record, UBI_OWNER: 'thrd1', UBI_LEGACY_HOURS: '2' }, timeout: 90_000 });@@ -243,13 +244,34 @@ esacexpect(lowered.stderr.toString()).toMatch(/reaping TTL-less eu-central-h1\/ubirun-thrd1-\d{10}-eeee \(owner thrd1; 3h old, legacy sweep at 2h\)/);expect(f.calls()).toMatch(/ubirun-thrd1-\d{10}-eeee[^\n]*destroy/);// Value: protects=the legacy sweep never destroys another lane's or an untagged TTL-less VM (GST-324: 22 gbra240 eval VMs lost); fails_when=the sweep matches any owner again; why_new=the cross-owner sweep destroyed a paid eval; seam=none; no_claim=real Ubicloud list and destroy (fake curl)- expect(f.calls()).not.toMatch(/(team-db|dddd|gggg|cccc)[^\n]*destroy/);+ expect(f.calls()).not.toMatch(/(team-db|dddd|gggg|cccc|bbbb)[^\n]*destroy/);const ownerless = Bun.spawnSync(['bash', join(DIR, 'ubi-runner.sh'), 'reap'], { env: { ...process.env, PATH: `${join(f.root, 'bin')}:${process.env.PATH}`, UBICLOUD_API_KEY: 'offline', UBI_RUNNER_STATE: join(f.root, 'state'), UBI_POLL_SECONDS: '1', UBI_VM_RECORD: f.record, UBI_OWNER: '', UBI_LEGACY_HOURS: '1' }, timeout: 90_000 });expect(ownerless.exitCode).toBe(0);expect(ownerless.stderr.toString()).not.toContain('reaping TTL-less');} finally { rmSync(f.root, { recursive: true, force: true }); }}, 30_000);+ // Value: protects=reap and every up destroy only the caller's own VMs, never another owner's, even one whose TTL ran out (the 2026-10-30 owner-scoped-deletes rule; GST-324 lost 22 of gbrain's eval VMs to a cross-owner sweep); fails_when=reap judges another owner's VM by its TTL again; why_new=the old cases asserted the cross-owner TTL reap this rule forbids; seam=none; no_claim=real Ubicloud list and destroy (fake curl)+ test('reap and up destroy only the caller\'s own expired VMs: another owner\'s and an untagged expired VM survive (GST-573)', () => {+ const listed = 'eu-central-h1 ubirun-other-1000000000-bbbb-t1\neu-central-h1 ubirun-1000000000-cccc-t1\neu-central-h1 ubirun-thrd1-1000000000-hhhh-t1\n';+ const f = fakeApi({ destroy: 200, listed });+ try {+ const reap = f.run('reap');+ expect(reap.exitCode).toBe(0);+ expect(reap.stderr.toString()).toMatch(/reaping expired eu-central-h1\/ubirun-thrd1-1000000000-hhhh-t1 \(owner thrd1; its TTL ended \d+ min ago\)/);+ expect(reap.stderr.toString()).toContain('reap: left 2 expired VMs of other owners; only their owners reap them');+ const destroyed = f.calls().split('\n').filter(l => l.includes('destroy'));+ expect(destroyed).toHaveLength(1);+ expect(destroyed[0]).toContain('ubirun-thrd1-1000000000-hhhh-t1');+ const up = Bun.spawnSync(['bash', join(DIR, 'ubi-runner.sh'), 'up'], { env: { ...process.env, PATH: `${join(f.root, 'bin')}:${process.env.PATH}`, UBICLOUD_API_KEY: 'offline', UBI_RUNNER_STATE: join(f.root, 'state'), UBI_POLL_SECONDS: '1', UBI_VM_RECORD: f.record, UBI_OWNER: 'thrd1', UBI_QUOTA_VCPUS: '1' }, timeout: 90_000 });+ expect(up.stderr.toString()).toContain('create refused before any request');+ expect(up.stderr.toString()).toContain('reap: left 2 expired VMs of other owners; only their owners reap them');+ expect(up.stderr.toString()).not.toMatch(/reaping[^\n]*(ubirun-other|ubirun-1000000000-cccc)/);+ expect(f.calls().split('\n').filter(l => l.includes('destroy'))).toHaveLength(1);+ for (const name of ['ubirun-other-1000000000-bbbb-t1', 'ubirun-1000000000-cccc-t1']) expect(readFileSync(join(f.root, 'listed'), 'utf8')).toContain(name);+ } finally { rmSync(f.root, { recursive: true, force: true }); }+ }, 90_000);+// Value: protects=a project with no VMs (Ubicloud answers vm list with a bare newline) reads as empty everywhere vm_rows feeds; fails_when=a blank list row becomes a VM named "-" again and reap dies on it or usage asks to show it; why_new=every fake list in this file had at least one VM, so #3678 shipped green; seam=none; no_claim=the real API's empty-body shape (taken from #3678's reading of ubi_cli.rb)test('an empty project (vm list answers a bare or blank line) has no VMs: reap destroys nothing and exits 0, usage prints total 0 0, list --mine prints nothing (#3678)', () => {for (const listed of ['\n', ' \n']) {diff --git a/ubicloud/SKILL.md b/ubicloud/SKILL.mdindex 4aaa63463..3b90355ae 100644--- a/ubicloud/SKILL.md+++ b/ubicloud/SKILL.md@@ -102,7 +102,7 @@ telemetry — it never blocks the workflow.A full suite or verify that takes an hour on a 4-core sandbox takes minutes on a`standard-16` VM, and a VM that outlives its run costs the whole project itsshared vCPU quota. This skill is one runner with the discipline built in: every-VM carries its owner and a TTL in its name, any later run reaps expired VMs, the+VM carries its owner and a TTL in its name, its owner's next run reaps it once expired, thecreate is refused before the quota fills, a silent remote command is killed withits last output instead of hanging, and a repository's verify is one committeddefinition rather than a wrapper per lane.@@ -143,12 +143,12 @@ $U usage # VMs and vCPUs per owner: who holds the shared quota```A VM in `records` but absent from `list` is already gone: `$U down <name>`-forgets it. A VM in the project under another owner is theirs; leave it (its-TTL will reap it). Every `up` runs `$U reap` first, destroying any VM whose-`-t<hours>` TTL ended more than ten minutes ago, whichever owner made it, and-this owner's own `ubirun-<UBI_OWNER>-*` names with no TTL once they are-`UBI_LEGACY_HOURS` old (default 4). Another owner's TTL-less VM, an untagged-one and names outside the `ubirun-` prefix are never reaped.+forgets it. A VM in the project under another owner is theirs; leave it.+Every `up` runs `$U reap` first, destroying only this owner's+`ubirun-<UBI_OWNER>-*` VMs whose `-t<hours>` TTL ended more than ten minutes+ago, and those with no TTL once they are `UBI_LEGACY_HOURS` old (default 4).+Another owner's VM, expired or not, an untagged one and names outside the+`ubirun-` prefix are never reaped.Quota: with `UBI_QUOTA_VCPUS=<project ceiling>` exported (or after one refusal,whose maximum the runner remembers), `up` adds the size's vCPUs to the project's@@ -171,7 +171,7 @@ background operation leaves its VM until the reaper. So:`### gstack-detach EXIT=<code> ###` sentinel.- Set `UBI_TTL_HOURS` above the longest plausible run (default 3; 1-999) andname the expected duration in the thread before launching anything over an- hour. A run that outlives its TTL is reaped by the next `up` anywhere.+ hour. A run that outlives its TTL is reaped by its owner's next `up` or `reap`.The runner prints `<name> carries a <n>h TTL ...; if this process dies first:<self> down <name>` right after the VM is ready; quote that line in your reportdiff --git a/ubicloud/SKILL.md.tmpl b/ubicloud/SKILL.md.tmplindex 970627d94..1c339af9f 100644--- a/ubicloud/SKILL.md.tmpl+++ b/ubicloud/SKILL.md.tmpl@@ -28,7 +28,7 @@ sensitive: falseA full suite or verify that takes an hour on a 4-core sandbox takes minutes on a`standard-16` VM, and a VM that outlives its run costs the whole project itsshared vCPU quota. This skill is one runner with the discipline built in: every-VM carries its owner and a TTL in its name, any later run reaps expired VMs, the+VM carries its owner and a TTL in its name, its owner's next run reaps it once expired, thecreate is refused before the quota fills, a silent remote command is killed withits last output instead of hanging, and a repository's verify is one committeddefinition rather than a wrapper per lane.@@ -69,12 +69,12 @@ $U usage # VMs and vCPUs per owner: who holds the shared quota```A VM in `records` but absent from `list` is already gone: `$U down <name>`-forgets it. A VM in the project under another owner is theirs; leave it (its-TTL will reap it). Every `up` runs `$U reap` first, destroying any VM whose-`-t<hours>` TTL ended more than ten minutes ago, whichever owner made it, and-this owner's own `ubirun-<UBI_OWNER>-*` names with no TTL once they are-`UBI_LEGACY_HOURS` old (default 4). Another owner's TTL-less VM, an untagged-one and names outside the `ubirun-` prefix are never reaped.+forgets it. A VM in the project under another owner is theirs; leave it.+Every `up` runs `$U reap` first, destroying only this owner's+`ubirun-<UBI_OWNER>-*` VMs whose `-t<hours>` TTL ended more than ten minutes+ago, and those with no TTL once they are `UBI_LEGACY_HOURS` old (default 4).+Another owner's VM, expired or not, an untagged one and names outside the+`ubirun-` prefix are never reaped.Quota: with `UBI_QUOTA_VCPUS=<project ceiling>` exported (or after one refusal,whose maximum the runner remembers), `up` adds the size's vCPUs to the project's@@ -97,7 +97,7 @@ background operation leaves its VM until the reaper. So:`### gstack-detach EXIT=<code> ###` sentinel.- Set `UBI_TTL_HOURS` above the longest plausible run (default 3; 1-999) andname the expected duration in the thread before launching anything over an- hour. A run that outlives its TTL is reaped by the next `up` anywhere.+ hour. A run that outlives its TTL is reaped by its owner's next `up` or `reap`.The runner prints `<name> carries a <n>h TTL ...; if this process dies first:<self> down <name>` right after the VM is ready; quote that line in your report