Skip to content

v1.91.376.0 feat(ubicloud): reattach to a live verify VM and checkpoint tiers (GSTA-158 P3) - #3615

Merged
capy-ai[bot] merged 4 commits into
mainfrom
gsta158-ubi-reattach
Oct 31, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
gsta158-ubi-reattach

Conversation

@garrytan

@garrytan garrytan commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3615,
  "head": "35deaa6cee53ec2ef3b9a253bd32cb82070c48a4",
  "version": "1.91.365.0",
  "base": "main",
  "session_kind": "unattended",
  "queue_mode": "stamp-at-merge",
  "head_tree": "330ba4e7ad01506d99720884ec5c2d3221eb8541",
  "product_patch_id": "103f0ea01a1ca873a910dacca5cfc9ccd41f9a2d",
  "gstack_version": "1.91.366.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 729,
    "rules": "150435b0a543019a",
    "base": "41a67b996d8bbf2167996683953dd2d7cd387d64",
    "registry": "41a67b996d8bbf2167996683953dd2d7cd387d64",
    "gate_scan": {
      "tagged": 0,
      "head": "35deaa6cee53ec2ef3b9a253bd32cb82070c48a4"
    },
    "reasons": [
      "gate-class",
      "runtime=729>50"
    ]
  },
  "pregate": "requires-remote cleared @330ba4e7ad01 (1 checks, current for 35deaa6cee53)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41203178864",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/41203178786",
    "pregate.json/remote_gate: remote-gate tree=330ba4e7ad01 tests=18045"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "ubicloud/SKILL.md.tmpl, docs/TESTING_INTERNALS.md, changelog.d/gsta158-ubi-reattach.md"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 0,
    "fixed": 0,
    "scope": "frozen",
    "fix_checks": 2,
    "dispatches": {
      "specialist": 8,
      "red-team": 1
    }
  }
}

What changed

ubi-runner run and verify now survive a dead local runner. Their setup, command and tier phases run detached on the VM (~/.ubirun-<phase>.{out,err,pid,exit}), and a rerun of the same command reattaches to the live VM instead of paying for a new one.

  • Run key. Computed locally before any VM exists: the checkout's content tree, the command, the setup script's sha256, every --env entry, each --pass name plus a sha256 of its value (raw values are never stored), size, location, image, storage, origin/HEAD, tiers, --key-input strings and the runner's own sha256. The VM recomputes the tree after unpack and refuses a mismatch (UBI_VM_TREE_MISMATCH, exit 3).
  • Reattach. A same-key record whose VM still exists prints ubi-runner: reattached to <vm> created_at=<epoch> key=<k12> and continues from the first phase without an exit file (a finished setup is not rerun). UBI_ATTACH_BUSY when another live runner owns it; exit 125 UBI_ATTACH_LOST when the remote session died without a status.
  • Signals. INT and TERM still tear the VM down (pregate-remote's spend-cap watchdog depends on it). HUP once a phase is live detaches: UBI_DETACHED: vm=… key=… reattach: rerun the same command, exit 129, VM left under its TTL. SIGKILL or a machine stop leaves the record and VM for the next same-key run. Reattach never extends a TTL.
  • attach NAME resumes a recorded run explicitly. run --probe prints UBI_ATTACH_INFO and the tier plan without creating anything. --key-input S adds caller inputs to the key.
  • Tiers. .gstack/ubicloud.json accepts tiers: [{name, command}] (UBI_CONFIG_TIERS_AND_COMMAND, UBI_CONFIG_TIER_NAME). Each tier is its own detached phase with write-once start/pass/fail checkpoints under UBI_CHECKPOINT_DIR/<run key>/, published under flock with a monotonic generation. Reruns print UBI_VERIFY_RESUME: per tier, reuse a pass younger than UBI_CHECKPOINT_MAX_AGE whose log re-hashes, hold a recorded fail until --rerun-failed (then prior_failures), and honour --no-resume. A tier that edits the source gets no pass record (UBI_VERIFY_TREE_MOVED). The final line is UBI_VERIFY: tree= key= tiers= passed= reused= failed= prior_failures= saved_s=.
  • pregate-remote.sh passes its tree and planned-set digest as --key-input, so a rerun of gstack-pregate --stage tests --remote reattaches. spent= bills from the original created_at, and the wall budget subtracts minutes already billed (PREGATE_REMOTE_CAP_SPENT, exit 5; PREGATE_REMOTE_ATTACH_BUSY, exit 4). The PREGATE_REMOTE: receipt grammar is unchanged; lib/pregate is untouched.
  • ssh NAME COMMAND stays attached.

Why

GSTA-158 P3 (autoplan-20261029035729, APPROVED gate rev 2): a Capy machine that sleeps or a runner that gets SIGKILLed lost a whole remote verify and left a paid VM running to its TTL.

Blast radius

scripts/ubicloud/ubi-runner.sh, scripts/ubicloud/pregate-remote.sh, their two test files, ubicloud/SKILL.md(.tmpl) and docs/TESTING_INTERNALS.md. The fake ssh in test/ubicloud-runner.test.ts now executes remote commands in a directory, so detached phases, tail --pid and pkill run for real.

Real smoke on Ubicloud standard-2 (≈$0.01): SIGKILL the runner 30 s into a 90 s command, rerun, reattached and reported exit 5, VM destroyed.

Approvals

GSTA-158 plan approved by Garry (autoplan-20261029035729, gate rev 2); P3 shipping in parallel with P1 approved by GStack Minder.

Review fixes (pre-landing review, pass 1 + one fix-check)

  • Reattach replays what a phase already printed (outside voice): a rerun reads the local copies up to one measured offset, then streams from that offset, so pregate-remote still sees PREGATE_VM_TREE and PREGATE_VM_TREE_BUILT after a kill and no longer reports a false PREGATE_REMOTE_TREE_MOVED.
  • A settled verify destroys a dead runner's VM: when every tier is reused or a recorded fail blocks, a live same-key VM whose lease is free is torn down before verify returns.
  • ubicloud/SKILL.md prose trimmed to fit the eager context ceiling (CI's context-budget ratchet); the ceiling is unchanged.
  • Tests: TTL-less HUP teardown, a stale-writer unit test on the checkpoint publisher, the SIGKILL reattach test asserts the replay, and the ATTACH_LOST test waits for the remote session instead of racing it.

Merge with main and re-plan (rule 19 grant, GStack Minder)

  • origin/main a305302 merged once. The conflicts were with v1.91.341.0 fix(ubicloud): no zombie VMs: owner required, 3h TTL, legacy sweep, leftover line (GST-118) #3652 (v1.91.341.0), and they're resolved on v1.91.341.0 fix(ubicloud): no zombie VMs: owner required, 3h TTL, legacy sweep, leftover line (GST-118) #3652's rules as written: UBI_OWNER is required on creates, every generated VM carries -t<h> (default 3 h), run_teardown prints the UBICLOUD: left= line, and the legacy sweep reaps only the caller's own TTL-less VMs. A detach prints left=1 … detached=1 and --keep prints kept=1. pregate-remote keeps v1.91.341.0 fix(ubicloud): no zombie VMs: owner required, 3h TTL, legacy sweep, leftover line (GST-118) #3652's TTL'd VM names and UBI_LEFT_FILE.
  • P3's TTL-less HUP teardown is removed, since every generated VM now has a TTL.
  • A reattach happens only while the TTL lasts. ttl_short compares the VM's remaining TTL (created_at plus -t<h>, minus now) with the run still to do plus UBI_REATTACH_MARGIN (900 s). The run still to do is the UBI_RUN_TIMEOUT bound of each unfinished phase, and 0 when UBI_RUN_TIMEOUT is unset. When the TTL is too short, the runner prints UBI_REATTACH_TTL_SHORT: vm=… ttl_left=…s needs=…s (…), destroys that VM (its own run record, after the UBI_ATTACH_BUSY check), and starts a fresh VM that reuses the tier checkpoints. --probe reports none … ttl_short, so pregate-remote agrees with the run.
  • Main's leftover tests now use a clean --src and make test under P3's fake ssh, which really executes commands. Every VM test runs against the fake API.
  • The changelog entry is changelog.d/gsta158-ubi-reattach.md.
  • One fix-check on the merge and re-plan hunks found nothing at the floor. Two notes below the floor: ttl_short counts setup even after setup finished, which only biases toward a fresh VM; and a probe-to-run TTL flip makes pregate overstate spend.

Review notes

Below the blocking floor (informational, test gaps); recorded here and not fixed in this PR.

  • ubi-runner.sh run key includes origin/HEAD, so a git fetch that moves it defeats reattach and checkpoint reuse.
  • ubi-runner.sh vm_alive treats a transient show error (timeout, 5xx) as absent, so a rerun starts a fresh VM and leaves the old one under its TTL (pregate's names have none). This matches pre-PR behaviour for any killed runner.
  • pregate-remote.sh:197 the probe and the real run decide reattach independently and repeat the bash ~/.pregate-run.sh literal the key hashes; the teardown hint keys off the probe.
  • ubi-runner.sh the tree snapshot copies the index without preserving mtime (gstack-evidence can report FRESH after a source change (intermittent, load-dependent): evidence.test.ts allow-paths carve-out #2687 racy-git hardening); checkpoint copies use the default umask.
  • ubi-runner.sh detached() duplicates watched()'s watchdog loop; write_record persists RESUME/RERUN_FAILED redundantly.
  • Test gaps: attach NAME, UBI_VM_TREE_MISMATCH, --keep record removal, probe-vs-run key equality, and the settled-verify teardown have no dedicated test; the HUP tests still sleep 500 ms after the phase start.
  • docs/pregate.md reason-code table lacks PREGATE_REMOTE_ATTACH_BUSY and PREGATE_REMOTE_CAP_SPENT; scripts/free-test-durations.json seeds ubicloud-runner.test.ts at 2.5 s (now ~140 s).

Sibling trial merge

#3612 (P1) also edits docs/TESTING_INTERNALS.md. Trial merge of 35deaa6 with #3612 head c86543f in a scratch worktree: git auto-merged with no conflict; flaky-run, context-budget and pregate-remote tests pass on the merge (68/68).

Open in Capy

…TA-158 P3)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…m skill prose (GSTA-158 P3)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan and others added 2 commits October 31, 2026 12:54
…while the VM TTL covers the run (GSTA-158 P3)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot changed the title feat(ubicloud): reattach to a live verify VM and checkpoint tiers (GSTA-158 P3) v1.91.376.0 feat(ubicloud): reattach to a live verify VM and checkpoint tiers (GSTA-158 P3) Oct 31, 2026
@capy-ai
capy-ai Bot merged commit 5ba425a into main Oct 31, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant