Repository navigation
feat(ephemeral-vm): give ephemeral hosts a lifetime contract and an extend hook - #81
Merged
Merged
Conversation
…xtend hook A per-workspace environment recipe could create a provider-billed host but had no way to say when the provider would take it away, and Orca had no way to ask for more time. Add the missing half of the contract. A recipe publishes a deadline in its result `userData` (`releaseAt`, plus optional `lifetimeSeconds`, `provider`, `resourceId`). Orca validates it, counts it down on the workspace card and in the runtime settings pane, and — past the deadline — stops retrying the host's relay and reports the lease as the reason instead of exhausting its reconnect attempts. A recipe may also declare `extend` plus the lifetimes it is willing to sell (`extendDurations`). Orca then offers an Extend lifetime action restricted to exactly those, so it can never ask a provider for a lease it will not sell. When the deadline plus a grace has passed and the host is provably not coming back, the host's registrations are released, its `destroy` runs best-effort, and the renderer removes the workspace from Orca's list. A failed destroy is recorded rather than blocking, and the runtime record is kept as a tombstone. Only a declared `releaseAt` opts a recipe in, so recipes that predate this behave unchanged. The new snapshot fields round-trip through the compatibility sidecar so the runtime store stays readable by an older build. Refs #79
nplez1
added a commit
that referenced
this pull request
Oct 24, 2026
…ne runs (#178) * test(unit-gate): run the unit lane's file set and the fork-local tests Two gaps made a gate verdict narrower than it read. The suite ran `defaultExclude` rather than upstream's `UNIT_EXCLUDE`, so it collected 80 files the unit lane quarantines — electron, node-pty, live-shell and the whole cross-version-wire directory — and charged this fork for their reds. And `local/**/*.test.mjs` match nothing in `UNIT_INCLUDE`, so the sync-tooling tests were in no lane at all (fork issue #151 § 3 and § 5). The exclusion switch is `ORCA_BALANCE_UNIT_SHARDS=1`, the one `config/vitest.config.ts` already reads; a `--exclude` flag cannot reach the projects because each sets `extends: false`. Since parity is now a switch, the gate asserts the report collected none of the quarantined files and fails closed if one appears, and it treats an allowlist entry for a quarantined file as a problem rather than letting an entry that can never match sit there. Fork-local tests run first, so a broken sync tool cannot produce a verdict about anything else, and the summary line reports both facts. * test(unit-gate): name every allowlisted failure and drop the quarantined files The manifest was 15 entries, 14 of them file-level wildcards. A wildcard also covers a NEW failure in the same file, which is how one hid for two syncs. Every entry now names its test title, taken from a reconciliation run over the allowlisted files whose arithmetic closes: 32 allowlisted + 5 upstream-quarantined + 1 fixed = 38 records. Three files leave the manifest because the gate no longer runs them: upstream's own unit lane excludes repro-13767, relay-region-correction and the whole cross-version-wire directory, so their reds are upstream's to carry. Ownership is corrected where it was unattributed — both remaining `unattributed` files are upstream files this fork never touched. * test(runtime): assert the documented undefined read for an unbound pane `terminal-pane-screen-prompt.ts` returns `undefined` for a pane it cannot bind to a terminal, and says why in the method's own doc comment: a restored pane reconnects after the hook store starts, so "cannot see it" must not read as "no dialog". The case asserted `toBeNull()` for that path in the same commit that added both (`3526000b5c`), so it never passed — and a file-level allowlist entry kept it hidden inside a 1,476-case file. Found by tightening `local/unit-known-red.json` to test titles (fork issue #151 § 1). Renamed to match what it asserts. * docs(fork): record issue #151's allowlist rework and correct the extend-test diagnosis LOCAL-PATCHES.md gains the section for this work, and the extend-test entry is corrected where fork issue #151 § 4 says it no longer matches the import graph: `ephemeral-vm-runtime-extend.ts:22` imports only `getSshConnectionManager`, so the mock was complete for the module under test and the missing export was only visible to what that module reaches. The 28 `TypeError: {} is not iterable` rejections were a second cause — the renderer's reclaim bridge iterating a non-list `listRuntimes` answer, fixed in `2368ed38da` — which the recorded sentence welded to the mock because both appeared in one run. BRANCHES.md gets the branch's entry and its place under nplez1/main. * test(tools): put the unit gate's tests where the unit suite collects them `tests/tools/**` is in `UNIT_INCLUDE` and is where `local/gate-lint.mjs` keeps its tests, so the gate's judging rules run in the suite rather than only in the gate's own fork-local lane. The lane stays, because `local/sync/lib/*.test.mjs` are still outside `UNIT_INCLUDE` and are what fork issue #151 § 5 is about. Written as vitest to match `tests/tools/lint-gate.test.mjs`; same assertions. * fix(unit-gate): judge an isolated re-run per test, and stop a dead entry hiding Two gaps that naming the entries opened, both from the Opus review round. The isolation re-run asked whether the *file* passed alone. With named entries that question is unanswerable: the file's own allowlisted reds still fail when it runs alone, so a load flake in a file that also has recorded reds always looked like a real break — process-host-dev-rebuild and orca-runtime are both that shape. The re-run now writes its own JSON report and a failure counts as reproduced only when that same test failed there; a missing report still counts as reproduced, so it fails closed. `unseen` meant "the file did not fail", which cannot happen to a dead entry in a file that still reds elsewhere — so a renamed case left its entry matching nothing forever. It now means "nothing in the run matched this entry and it is not stale", which covers the renamed case and the vanished file alike. Also here: the fork-local lane gets its own five-minute deadline instead of the suite's hour, `closeSync` is imported (every `closeSyncSafe` had been throwing into its own catch, leaking the log descriptor), the duplicate JSDoc on `judgeUnhandled` is gone, and `repoPath` normalises the checkout prefix so the new quarantine check can fire on Windows too. The two new checks are extracted and tested rather than inlined in `evaluate()`. * fix(cli): link the launcher this fork actually ships in the privileged repair case The case symlinked `/Applications/Old Orca.app/.../bin/orca` and expected the installer to adopt it. This fork ships `orca-np` (`cli-install-constants.ts:6`), and `isManagedSymlinkTarget` rejects a target whose basename differs from the launcher's own name (`cli-command-inspection.ts:117`), so the installer read its own launcher as a foreign command and refused it: `Refusing to replace non-Orca command at /var/folders/...`. The two sibling cases in this file already link `old/orca-np` — this one arrived later from upstream, after the fork's identity patch. One hunk, and the red is gone rather than recorded, so its allowlist entry goes with it. `local/unit-known-red.json` therefore drops to 31 named entries and its `observedRun` arithmetic closes at 38 records: 31 allowlisted, 5 upstream-quarantined, 2 repaired. The note also stops contradicting itself about keeping an entry that has stopped reproducing: prune wins, and LOCAL-PATCHES.md stays the history of why a class was red. * test(ephemeral-vm): mock the module the extend unit actually imports `vi.mock('./ipc/runtime-environments')` named a path the 2026-10-19 module reorganisation deleted; the code imports `./ipc/runtime-environments/runtime-environments` (`ephemeral-vm-runtime-extend.ts:16`) and the directory has no `index.ts`, so the mock was inert and the real module loaded with everything it reaches. That is the mechanism behind the failure `LOCAL-PATCHES.md` recorded by guess: a gap in the mocked SSH registry surfaced thirty frames away, because the graph the dead mock failed to cut still read `getSshTargetRegistryStore`. Naming the real module is the fix; the registry mock stays as it is. * docs(fork): re-diagnose the extend-test red and record the review round's corrections The review round found the recorded cause wrong twice over, so LOCAL-PATCHES.md now says what is checkable: - the extend test's mock named `./ipc/runtime-environments`, a path the 2026-10-19 reorganisation deleted, so it was inert and the real module loaded — which is why a registry-mock gap surfaced thirty frames away; - the `TypeError: {} is not iterable` rejections had their own cause, the renderer reclaim bridge iterating a non-list answer, fixed in `2368ed38da`; - both files are fork-owned (`902955072a` is fork PR #81, absent from `upstream/main`), so the issue's "send it upstream" premise does not hold. The `local(test)` section also records the two reds the tightening repaired, the per-test isolation rule, the new `unseen` meaning, and the resolved keep-vs-prune contradiction. BRANCHES.md follows: 31 entries, and what § 4 actually turned out to be. * fix(unit-gate): do not call every entry unseen when a selector filters the run A forwarded selector describes a different suite, so every entry outside it matches nothing. Reporting those as unseen made a one-file smoke run print all 31 entries as prune candidates, which is the false signal the new rule was supposed to avoid. Unseen is now only judged when the gate runs the whole suite, and a filtered run says so instead. The quarantine list also stops at twelve names without saying so; it now counts the rest. * fix(unit-gate): waive a failure only when the re-run saw that test pass The per-test rule asked whether the re-run *failed* the test, which is not the same as proof it passed. Three shapes slipped through as waivable flakes: a collect error in the re-run replaces every case with one `(suite)` entry, a failing `beforeAll` reports its cases as skipped, and a report with no files at all has an empty failure set. In each, the original test is absent — and absent is not evidence, which is the rule a missing report already followed. `reproducedFailures()` now waives only a test the re-run reported as passing; a `(suite)` failure is waived only when the file itself passed. A corrupt isolation report is parsed locally instead of through `readJsonFile`, which would exit mid-verdict. `prunableEntries()` replaces the bare `fullRun` filter for the same reason: an entry may be called unseen only on a complete, unfiltered run, and not when its file reported nothing but a collect failure. `repoPath` now checks the path separator, so a sibling checkout named `issue-151-x` no longer reads as inside this one. The judgement moved to `local/unit-gate-judgement.mjs`: it is pure over data the gate already holds, it is what the tests now import, and the gate had grown past this fork's 600-line budget carrying both roles. * docs(fork): point the old privileged-CLI entry at its re-diagnosis `local(test)` § "five more environment-bound reds" filed that case under the `/private/var` symlink cause, which the re-diagnosis two sections down now contradicts — the recorded error path is `/var/…` and the cause is the fork's `orca-np` rename. The bullet says so and points at the entry, rather than leaving two causes for one red. Also names the reorganisation that deleted the extend test's mock path (`1938bd055a`, stablyai#30362) and records where the gate's judgement now lives. * fix(unit-gate): name the preparation steps so the failure line type-checks The changed-code gate's type-aware pass rejects `${label}` in the preparation failure line: destructuring a heterogeneous tuple array widens `label` to `string | string[]`. Objects give it one type, and the fork-local lane still runs before both. * fix(unit-gate): refuse a waiver the re-run contradicts, and read one file's report Round-3 delta findings, both one hunk. A waiver now needs the pass to be the whole story: a name the same report also failed (a `test.each` duplicate) or a `(suite)` entry beside it (a hook broken under) keeps the failure, which is also what puts `rerun.failures` back to work instead of leaving it built and unread. The re-run is also read per file — `reportForFile()` filters by path, because a positional selector is a substring match and `thing.test.ts` collects `thing.test.tsx` too. That function is tested directly, which the `filePassed` branch was not. Prune advice stays silent on a report with no tests at all, not merely on one that did not complete. * test(ipc): accept the gh-account argument the branch-prefix login now takes `a8ca9685a3` (#170) made the branch-prefix login follow the repo's pinned gh account: `resolveLocalGitUsername(repoPath, ghAccount)`. This upstream case still asserted the one-argument call, so `nplez1/main` has been red on it since that merge — it surfaced as the only unallowlisted failure of the first full gate run on this branch, which is exactly what the tightened allowlist exists to show. The case's repo has no binding, so the second argument is `undefined`. * docs(fork): record the gate verdict for issue #151 Verdict on the revision that ships, and the honest note that its first full run found a red the base had carried since #170 rather than a red this branch made — an upstream case still asserting the one-argument branch-prefix login. No entry was stale and none was unseen, which is the check that the tightening was faithful rather than merely equivalent to the wildcard it replaced. BRANCHES.md carries the same verdict plus the three review rounds. * fix(unit-gate): order the fs imports NIT from the merge-resolution review: `closeSync` sorts before `openSync`. EOF2 * docs(fork): reframe the gate verdict the #177 merge superseded PR #177 landed `local/gate-verdict-cache.mjs` and made `local/open-pr.mjs` read it, so a verdict now belongs to one exact revision and the shipped one is quoted in the PR body. This records the earlier full run as what it was — the first run after the tightening, before #177 — instead of calling it the shipped revision's verdict, and notes the merge-resolution review round. Raised as the only MINOR by the review of the merge resolution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Orca can create a throwaway remote machine for a workspace — a cloud sandbox, a VM, a container — and the provider that rents it out puts an expiry date on it. Until now Orca treated that machine like any other remote host: it had no idea when it would be taken away, no way to ask the provider for more time, and no way to tell an expired host from a healthy one that happened to be offline. This adds the missing half of that contract. A recipe says "this host dies at 3pm"; Orca shows a countdown next to the workspace, offers an "Extend lifetime" action when the recipe knows how to ask for more, and — once the deadline has passed and the machine is demonstrably not answering — tidies the dead host out of Orca's list, without ever touching the machine itself.
What Changed
Before. A per-workspace environment recipe (
orca.yaml→environmentRecipes) could create an ephemeral host, suspend it, resume it and destroy it. Its "result" was a connection plus an opaqueuserDatablob that Orca persisted and never interpreted. There was no notion of a lease anywhere in the codebase — a search forreleaseAtreturned nothing. A host whose provider deadline had passed looked exactly like a host that was merely offline. The only way to get more time was to use the provider's own CLI by hand.After.
userData.releaseAt, plus optionallifetimeSeconds,provider,resourceId). Orca reads it and starts counting down.Exp 3h/Exp 11mright-aligned on the title row, in red under an hour, with the absolute release time in a tooltip. An expired host readsExpiredrather than showing a bogus countdown.extendhook and the lifetimes it is willing to sell (extendDurations: [1h, 4h, 24h]). Orca then offers an Extend lifetime submenu on the workspace's right-click menu and in the runtime settings row, restricted to exactly those lifetimes. Provider failures surface as actionable, retryable errors; there is no silent success path.reclaimedAt, and the renderer removes the attached workspace from Orca's list. The recipe'sdestroyis never run by this sweep.Why
The recipe stays the provider boundary. Everything provider-specific — which API extends a lease, what a resource id looks like — stays inside the recipe's own scripts. Orca consumes a deadline and calls a hook. That is what lets one contract cover aquactl, a cloud VM API, Vercel, a container, or a scheduler without Orca knowing which one it is.
Reclaim is Orca's own bookkeeping, and it destroys nothing. An earlier revision ran the recipe's
destroyfrom the reclaim sweep. Review showed the evidence for that was partly circular: suppressing the reconnect ladder past the deadline manufactured thereconnection-failedverdict the reclaim then read as proof the machine was gone. A VM extended outside Orca — or one whose provider enforces its TTL lazily, the very thing the grace assumes — could have been deleted with unpushed work on it. So the sweep now only releases registrations and forgets workspace rows. The reconnect suppression was deleted outright (the ladder is already bounded at nine attempts, ~103s, so nothing was gained by shortening it), the reclaim clears the connection it released, and the renderer's workspace-removal path explicitly skips reclaimed runtimes — without that last part, forgetting the row re-entered cleanup and randestroyanyway.destroystays an explicit user action and still runs on workspace deletion; the provider's own TTL remains the hard safety net.Loss of contact is not evidence of death, and the docs say where that stops being true. For SSH the evidence is the bounded ladder genuinely reaching
reconnection-failed. For orca-server hosts, whose shared-control reconnect scheduler caps nothing by design, it is a probe that actually failed (verification === 'unavailable') or the host's own verdict that the pairing is over. A probe that never settled is not a failure. Neither transport checks whether this machine had a network, so a laptop offline past the deadline plus the grace is the one case where a live host loses its rows — stated plainly in the reference doc rather than left implicit, together with what it costs: nothing on the machine, but recovering means re-creating the workspace.Backward compatibility was designed rather than hoped for. Only a declared
releaseAtopts a recipe in;provideris a common key for a recipe to set for its own reasons, so the reader requiresreleaseAtspecifically.extend/extendDurationsare snapshotted as top-level runtime-record fields, not inside the recipe snapshot: that snapshot is a strict schema and the runtime store must stay readable by an older build, so a field placed there would make the whole store unreadable to it, while the record's own object is not strict and an older build simply ignores them.A metadata typo must never strand a paid machine. A malformed
releaseAtis reported as a warning (recipe.result.lifetime.unreadable) rather than failing the recipe result, because by thencreatehas already run and rejecting the result would throw away the only record of a machine the provider is billing for. The host provisions without a countdown and is never reclaimed automatically — an unreadable deadline reads as no deadline to every reader. Where the record survives and the action is retryable, the opposite holds: anextendorresumethat would lose an existing deadline is refused outright.Alternatives considered and rejected
destroyfrom the sweep. Rejected on review: the evidence available to a background sweep is not strong enough to justify deleting a machine that may still be alive.expiredruntime status. Expiry is a pure function ofreleaseAtand the current time, so persisting it duplicates derivable state and widens a status enum read by the compatibility projection.Linked Issue
Fixes #79
Visual Proof
N/A— no screenshot is attached, and I would rather say so than imply otherwise. The UI surfaces (theExp 3hchip on the workspace card, the Extend lifetime submenu, the runtime settings row's deadline and countdown, and the host-picker marker) are covered by component tests, but this change was not exercised in a running Electron app in this session. If you want before/after captures I can produce them with the$electronskill over CDP — it needs a workspace actually provisioned from a recipe that publishes areleaseAt, which is why it was not done here.Testing
pnpm tc— clean.pnpm lint— clean, including the design-system, max-lines and localization gates.pnpm run check:code-quality:changed— 0 findings across 73 changed files.pnpm test— 58 failures across 18 files, and none of them ours. Every failing file is in a class this fork has already classified: 10 upstream-redagent-session-*/agent-launch-*/structured-agent-session-*files (34 tests), 3 bun-project PTY/shell files (23 tests),packaged-cli-assets.test.ts(macOS/var→/private/varrealpath), two renderer files whoseruntime-rpc-clientmocks are stale — proved pre-existing by stashing the entire change and observing identical failures at the base commit — andrelay-region-correctionpluscross-version-host-descriptor(this checkout has nocloud/install and nov1.4.224tag). No test file belonging to this feature failed, and the feature's own tests are green: 459 passing across 46 files.Every guard added in the last three rounds was ablation-checked — the production code was temporarily reverted, exactly the intended test was confirmed to fail, and the file was restored byte-identical. That covers the recipe-snapshot conversion (both writers), the reclaimed-runtime cleanup guard, the reclaimed-host header predicate, the extend serialisation lock, and the lost-deadline guards in extend, resume and the CLI.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Developed with an AI coding agent (Pi) under human direction, which ran the implementation and the test suites. A second model performed the ship-blocking reviews; five passes were run, and every finding they raised was fixed and re-reviewed. The design decisions, the scope, and the decision to reject the earlier destructive reclaim are the author's.
Review
Reviewed by Opus 5.5 at high reasoning (
claude/opus), clean on9376604ee1. Seven passes were run; every finding was fixed and the corrected diff re-reviewed rather than only the changed lines.destroy; a renderer that forgot whichever row shared a workspace id; a compatibility sidecar unsafe to downgrade from.extendcould not be provisioned — the machine was billed and left untracked; the suppression still fabricated the reclaim's evidence, 15 minutes later.destroy: nonefailed starts) and stale docs describing the deleted suppression.destroyon a reclaimed host, and a malformed deadline at create time stranding a billed machine.extend/resume, letting them silently lose a deadline; plus two docs still claiming the old behaviour.ship-ready, with three minor items (a duplicated predicate in the host header, an undocumentedcleanup_failedon a reclaimed host, one stale doc sentence). All three were fixed.VERDICT: ship-ready— no blocking defects, the three fixes confirmed correct, and all 20 doc line references verified.Full review prompts and verdicts are in the session log rather than the diff.
Agent skill upstream boundary
Notes
orca vm recipe extendinherits the existing recipe runner's.cmd/WSL handling. Noe.metaKeywas added.unref'd interval and does nothing when no runtime has a passed deadline.