Skip to content

Run Amp threads on instabox sandboxes as Amp orbs - #110

Draft
CarmenDou wants to merge 18 commits into
mainfrom
amp-orbs
Draft

CarmenDou wants to merge 18 commits into
mainfrom
amp-orbs

Conversation

@CarmenDou

@CarmenDou CarmenDou commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Adds Amp orbs: InstaADE makes the user's instabox workspace an orb provider for Amp, so each Amp thread runs on its own instabox sandbox. Setup is one click on a paid plan. It needs no change to the instabox backend or to Amp. See docs/amp-orbs.md.

How it works

  • Provider sandbox. Setup makes amp-orb-provider (smallest size, auto sleep off, metadata instabox-role=amp-orb-provider). It installs amp-orbs and three systemd units, then runs amp orb provider /usr/local/bin/amp-orbs as a service.
  • Dispatch program (src-tauri/assets/amp-orbs/amp-orbs, bash). Amp calls it with ORB_OPERATION:
    • spawn finds or creates the thread's orb sandbox, named by Amp's orb ID amp-<thread UUID>, from the project's snapshot, else the newest base snapshot. When the thread picked an orb type (ORB_TYPE), the orb gets that type's size: small, medium, large, xlarge/xxlarge (Amp's size names, a1. optional) or <vCPUs>x<GB>. instabox snapshots are size-locked, so a mismatched orb is resized with instabox resize --restart before Amp starts. An unknown type fails before any sandbox; a new orb that cannot get its size is deleted. Without types: 4 vCPU / 8 GB, as before. Then it starts amp orb bootstrap there.
    • pause saves a snapshot when Amp asks for one, then suspends the orb.
    • delete deletes the orb.
    • It only touches sandboxes with instabox-role=amp-orb and the matching amp-orb-id.
    • The app finds the provider and orbs only in sandboxes whose orgId is the workspace's; a sandbox without an orgId is in no workspace.
  • Orb image. instabox snapshot import imports Amp's official orb image as amp-orb-base-<time>. A daily timer imports it again. The import's builder sandbox is amp-orb-builder-<provider id>: the program and removal delete only a builder with that exact name and the import's mark, never an import of the user's.
  • instabox key. Setup makes a workspace key with machine and image scopes for 365 days. It goes to the provider through exec env with noHistory, never in the command text. The install saves it in /etc/amp-orbs/key (root only, read by systemd) and runs the installers in a new process without it. Repair rotates it. The app renews it in its last 30 days, in the workspace the read was for, also when the user switched workspaces meanwhile.
    • Setups that run at once (two admins, two apps) cannot leave an extra key or a revoked one installed. The provider installs one key at a time (flock) and keeps the newest key, ranked by expiry then id (orbs::key_rank). Each setup lists the keys after its install and revokes only keys older than its own, and its own key when the provider kept a newer one.
  • Tools on the provider. instabox CLI 0.8.522, installed only when its npm tarball has the hash InstaADE knows (orbs::INSTABOX_CLI). Amp's CLI from npm, unpinned.
  • Sign-in. A terminal opens on the provider. It runs amp login, amp orb provider create instabox and set-default, so the user copies no token.
  • Removal refuses while orbs are left. It stops dispatch on the provider and checks the orbs again, then deletes the orb snapshots and the import builder with the user's sign-in, revokes every Amp orbs key, and deletes the provider. Each step must succeed, and a second removal finishes what a failed one left.
    • The stop takes the install lock and marks the provider as being removed. For 30 minutes, a setup, repair or renewal in another app changes nothing on it, so none starts dispatch again or installs a key. The keys are listed after the stop.
    • It deletes only snapshots named as amp-orbs names them (amp-orb-base-<time>, amp-orb-snap-<project>-<time>[-<tag>]), never a user's snapshot that only starts alike.
  • Provider token. amp-orbs-connect keeps the token that amp orb provider create instabox saved for the Amp server in use, in /var/lib/amp-orbs/provider-token (0600). The provider runs with that token only.

UI

  • An offer above the list in Amp mode, and Settings → Amp orbs.
  • The Amp orbs page: setup steps, costs, the sign-in terminal, status, Rebuild image, Remove.
  • Provider and orb rows show their role. Orbs have no ADE, power or delete; Open thread opens the thread at ampcode.com. The tray leaves both out.
  • Free plan: the page asks for a paid plan.

API client

  • create_org_api_key, org_api_keys and revoke_org_api_key (POST/GET/DELETE /v1/orgs/{id}/keys).
  • delete_snapshot (DELETE /v1/snapshots/{id}).
  • ExecRequest gains envs and noHistory.

End-to-end run (2026-12-04 PST, Team workspace, real Amp account)

  • Setup, install, key isolation (/etc/amp-orbs/key root 0600, not in the env file), sign-in, token saved under orb-provider-token@https://ampcode.com/, service active: OK.
  • Orb image import: amp-orb-base-1796416451 ready.
  • A thread on an orb (amp -ox … --orb-provider instabox): spawn in 15.9 s, 4 vCPU / 8 GB from the base snapshot, amp orb bootstrap running. Archive → pause in 2.8 s; delete → sandbox deleted in 2.2 s.
  • Found by the run and fixed here: Amp's orb ID is amp-<thread UUID>, not amp-T-<UUID>, so Open thread did not show.
  • Not yet run: a project thread (snapshot on pause), orb types against real Amp, Remove.

Verify

  • bun run typecheck, bun run test (255 passed), bun run build.
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test: 1040 passed. ade::orca::tests::slow_servers_share_one_deadline_and_one_not_read_hides_no_work fails under full-suite load locally, also on main, and passes alone.
  • The script tests run the dispatch program against a fake instabox, amp and systemctl.
  • Browser preview: ?orbs=setup|signin|connected|free. docs/amp-orbs.md has screenshots of it and an Orb sizes section.

🤖 Generated with Claude Code

CarmenDou and others added 5 commits December 3, 2026 23:51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amp-orbs is the dispatch program Amp's orb provider runs on an always-on
provider sandbox: it starts, pauses (saving a project snapshot) and
deletes one instabox sandbox per Amp thread with the instabox CLI. It
imports Amp's orb image as the base snapshot every day. orbs.rs mints a
workspace key, creates or repairs the provider and installs the program
with the key sent as exec env.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amp mode offers Amp orbs in the list. The page sets up the provider
sandbox, opens the sign-in terminal on it, shows its status, rebuilds
the orb image and removes it all. Orb and provider rows say what they
are, open their thread or the page, and have no ADE, power or delete
actions. Free plans get a paid-plan notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The key renewed only while the Amp orbs page was open. The app now reads
the provider's status when it lists the provider and twice a day, so the
key renews in its last 30 days while InstaADE runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Amp-orbs implementation is well documented and broadly tested, but teardown and key-rotation failure paths can strand live resources or privileged credentials.

Requirements context

I assessed the PR against its description, docs/amp-orbs.md, README.md, and DEVELOPMENT.md; no linked issue or separate design specification was provided. The documented contract requires removal to refuse while any orb remains, purge managed snapshots, revoke the workspace key, and then delete the provider; repair must rotate and revoke the previous key.

The paid-workspace/Amp-sign-in end-to-end flow and the explicitly unverified Amp CLI behavior remain outside this local review.

Findings

Critical

  1. Removal can delete the provider while a live orb still exists. orbs_remove counts orbs from the app's cached machine list and passes that count into remove; the removal implementation never refreshes the list from the API. More importantly, the provider remains active between this check and purge, so Amp can spawn an orb after even a fresh check. The provider and key can then be deleted while that orb remains, stranding a potentially running, billable sandbox that Amp can no longer manage. Stop dispatch first and verify the authoritative machine list after it can no longer spawn, restoring the service if removal must be refused. Add a regression test for a stale/concurrent orb. (src-tauri/src/app.rs:5446-5474, src-tauri/src/orbs.rs:464-497)

  2. Repair and removal silently lose the key ID when provider status fails or is malformed. Both paths convert status errors or an unparsable response into None. Repair then installs a new key without revoking the prior full machine/image key; removal proceeds to delete the provider without revoking it. This violates the documented rotation/removal contract and leaves 365-day privileged credentials active with no remaining in-app recovery path. Status failure must either block the destructive operation or the key must be recoverable and revoked through an authoritative API-side mechanism. (src-tauri/src/orbs.rs:370-440, src-tauri/src/orbs.rs:482-497)

  3. Snapshot deletion failures do not fail removal. purge logs each failed snapshot rm and still exits successfully. Rust therefore revokes the key and deletes the provider, leaving failed-to-delete base/project snapshots behind and making the cleanup impossible to retry through the Amp-orbs UI. Since removal explicitly promises to purge these snapshots, aggregate deletion failures and return a nonzero result before destroying the provider. (src-tauri/assets/amp-orbs/amp-orbs:347-363, src-tauri/src/orbs.rs:488-497)

Suggestion

(none)

Information

  • Software engineering/architecture: module boundaries follow the existing Rust-command/React-UI design, and the new behavior has substantial unit/UI coverage. The critical failure and race cases above are not covered.
  • Security: beyond the orphaned privileged-key issue above, no additional reportable input-validation, secret-logging, authentication, or authorization defect was detected.
  • Performance: no reportable N+1 access, unbounded hot-path work, UI event-loop blocking, or excessive allocation issue was detected.
  • Readability and documentation are generally strong, and the Rust/TypeScript state representations remain synchronized.

Tests

  • timeout --kill-after=10s 120s bun run typecheck — environment failure: bun was unavailable.
  • timeout --kill-after=10s 120s bun run test -- src/App.test.tsx — environment failure: bun was unavailable.
  • timeout --kill-after=10s 120s cargo test orbs --lib — environment failure: Cargo's default registry cache was read-only.
  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s npx --yes bun@1.3.3 install --frozen-lockfile — dependency setup failed because that Bun release could not read lockfile version 2; no tracked file changed.
  • timeout --kill-after=10s 120s npm install --no-save --no-package-lock --ignore-scripts — completed; used only to create ignored local dependencies because the available Bun could not consume the lockfile.
  • timeout --kill-after=10s 120s env CARGO_HOME="$TMPDIR/cargo-home" cargo test orbs --lib — environment failure before tests: the VM lacks the glib-2.0 development package required by Tauri's Linux dependencies.
  • timeout --kill-after=10s 120s npm run typecheck — passed.
  • timeout --kill-after=10s 120s npm run test -- src/App.test.tsx — passed, 160 tests.
  • timeout --kill-after=10s 120s npm run test — passed, 255 tests across 11 files.
  • timeout --kill-after=10s 120s npm run build — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • git diff --check — passed.
  • cargo clippy --all-targets -- -D warnings — skipped after Cargo compilation established that the required GLib development package is unavailable.
  • Paid-workspace setup, Amp sign-in, real thread spawn/pause/delete, and removal were not exercised because they require external accounts/services explicitly unavailable to this review.
  • Final git status --short and git diff --name-only were clean; testing changed no tracked files.

Verdict

Request changes. The three Critical teardown and credential-lifecycle defects must be addressed before merge.

Removal could delete the provider while Amp started an orb, could lose the
key when the provider's status failed, and went on when purge left a
snapshot. Now each step must succeed before the next one:

- Removal stops dispatch, then reads the sandboxes from the API. With an
  orb left it starts dispatch again and refuses.
- Repair and removal find the keys of Amp orbs by name in the workspace's
  key list (GET /v1/orgs/{id}/keys), not in the provider's status. A key
  that stays valid fails the step, so Repair or Remove can try again.
- purge counts the snapshots and builder it cannot delete, and fails when
  one stays. The provider then stays, so a second removal can try again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The feature is well structured and documented, but two correctness defects block merge because they can strand removal or connect the provider with the wrong token.

Requirements context

Intent was derived from the PR description, docs/amp-orbs.md, README.md, and DEVELOPMENT.md. The review assessed setup/repair, scoped-key rotation, Amp sign-in, metadata-safe dispatch, snapshot handling, loss-safe removal, UI integration, security, and performance.

Findings

Critical

  1. Removal cannot be retried after provider deletion fails. The flow purges snapshots, revokes every workspace key, and only then deletes the provider (src-tauri/src/orbs.rs:543-545). If that final API deletion fails transiently, the documented retry reruns purge, but the provider now has only the revoked key; ib snapshot ls consequently fails and prevents the retry from ever reaching provider deletion (src-tauri/assets/amp-orbs/amp-orbs:360-378). This violates the documented promise that a failed step can be retried and leaves an always-on provider stranded unless the user discovers a separate repair/manual-deletion workaround (docs/amp-orbs.md:73-80). Preserve enough state/credentials to retry, or make the post-revocation retry able to complete safely, and add a regression covering “purge and revoke succeed, provider deletion fails, second removal succeeds.”

  2. Sign-in treats any saved orb-provider token as the instabox token. read_token selects the first secret whose key starts with orb-provider-token@, without tying it to the active Amp endpoint or the provider being configured (src-tauri/assets/amp-orbs/amp-orbs:260-278). Therefore, when secrets.json contains another provider/account endpoint token, connect skips amp orb provider create instabox, and serve exports that unrelated token (src-tauri/assets/amp-orbs/amp-orbs:287-295). A two-entry JSON reproduction returned the unrelated first token. This can make setup report completion without creating a usable instabox provider. Identify the exact token created for this provider/active endpoint and test coexistence with another saved token.

Suggestion

  • Reduce credential exposure during runtime installation. Setup executes instabox@latest and a downloaded Amp installer while the delete-capable workspace key remains inherited in the process environment (src-tauri/src/orbs.rs:203-258). Consider pinning/validating runtime dependencies and writing the protected environment file before unsetting the key for installation subprocesses. This improves reproducibility and limits supply-chain exposure.

Information

  • Software engineering/architecture: the Rust orchestration, dispatch script, API client, and React presentation are separated consistently with existing project conventions.
  • Security beyond the findings: command inputs are generally quoted/validated, orb operations verify role and ID metadata, and the key is sent with noHistory and stored mode 0600.
  • Performance: no reportable hot-path, unbounded-read, N+1, or event-loop-blocking issue was found. Status polling is bounded and stops once setup settles.

Tests

  • timeout --kill-after=10s 120s bun run typecheck — initially failed because bun was absent from PATH.
  • timeout --kill-after=10s 120s bun run test -- --run src/App.test.tsx src/types.test.ts — initially failed because bun was absent from PATH.
  • timeout --kill-after=10s 120s cargo test orbs:: --lib — initially failed because Cargo’s default cache was read-only.
  • timeout --kill-after=10s 120s cargo test api::tests:: --lib — initially failed because Cargo’s default cache was read-only.
  • Bun installation into the writable runtime directory — passed.
  • Initial cargo fetch --locked — failed against the read-only default Cargo cache.
  • bun install --frozen-lockfile — passed, 94 packages installed from the lockfile.
  • CARGO_HOME=<writable-runtime-cache> cargo fetch --locked — passed.
  • bun run typecheck — passed.
  • bun run test -- --run src/App.test.tsx src/types.test.ts — passed, 161 tests across 2 files.
  • cargo test orbs:: --lib — environment failure before project compilation: required glib-2.0/gobject-2.0 development packages are unavailable.
  • cargo test api::tests:: --lib — same environment failure.
  • cargo fmt --check — passed.
  • bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • bun run build — passed.
  • Targeted jq reproduction of multi-token selection — completed and selected the unrelated first token.
  • git diff --check and final git status --short — clean; testing changed no tracked files.

The paid-workspace/Amp-sign-in end-to-end flow was not run because it requires a paid workspace, cloud credentials, and an interactive Amp account. Full Rust tests and Clippy remain unverified because the sandbox lacks the required Tauri system libraries, and VM configuration changes were out of scope.

Verdict

Request changes. Both Critical findings affect explicit setup/removal guarantees and should be fixed before merge.

Removal deleted the orb snapshots on the provider with its key. When
deleting the provider failed after the key was revoked, a second removal
could not list the snapshots and never reached the provider. InstaADE now
deletes the import builder and the orb snapshots of the workspace itself,
with the user's sign-in (DELETE /v1/snapshots/{id}), so every step of a
second removal works. The provider only stops dispatch (amp-orbs stop).

The provider ran with the first orb-provider token in Amp's secrets.json,
which could be another Amp server's or another provider's. amp-orbs-connect
now keeps the token that `amp orb provider create instabox` saved for the
Amp server in use, only when it is new, in /var/lib/amp-orbs/provider-token
(mode 0600). serve and status read that file alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The implementation matches the documented Amp-orbs lifecycle and has no Critical findings; one non-blocking status-display issue remains.

Requirements context

Reviewed against the PR description, docs/amp-orbs.md, README.md, and DEVELOPMENT.md. These define the provider/orb lifecycle, role isolation, workspace-key rotation, token handling, safe removal, paid-plan restriction, and UI behavior. No linked issue or additional design document was identified.

Architecture and project conventions are followed: the React UI uses Rust commands, serialized state is mirrored in TypeScript, and orchestration is isolated in orbs.rs and the provider asset. Security-sensitive inputs are quoted or validated, the workspace key is sent through exec environment fields with history disabled, token/key files use restrictive permissions, and destructive operations check role metadata or workspace ownership. No reportable security or performance issue was detected within the reviewed paths.

Findings

Critical

(none)

Suggestion

  • src/AmpOrbs.tsx:327-366 — The connected-page summary treats every orb that is not currently running as paused. Orbs in creating, starting, stopping, error, or other transitional states will therefore produce an inaccurate “N paused” count. Count only the paused/suspended state, or show an additional “other” category.

Information

(none)

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • timeout --kill-after=10s 120s npx bun run test -- src/App.test.tsx — passed: 160 tests.
  • timeout --kill-after=10s 120s npx bun run typecheck — passed.
  • timeout --kill-after=10s 120s npx bun run build — passed.
  • timeout --kill-after=10s 120s cargo test orbs --lib — environment failure: Cargo’s default registry cache is read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME="$TMPDIR/cargo-home" cargo test orbs --lib — environment failure during compilation: required GLib, GObject, and GIO development packages/pkg-config metadata are absent. No Rust test result was observed.
  • timeout --kill-after=10s 120s npx --yes bun@1.3.3 install --frozen-lockfile — failed because Bun 1.3.3 does not understand this lockfile version.
  • timeout --kill-after=10s 120s npx --yes bun@latest install --frozen-lockfile — passed; dependencies installed from the committed lockfile.
  • Initial bun run test -- src/App.test.tsx and bun run typecheck attempts were skipped by the shell because Bun was not installed; both passed after the locked dependency installation above.
  • Paid-workspace setup, interactive Amp sign-in, live spawn/pause/delete, key renewal, and removal E2E were not run because this sandbox has no paid-workspace credentials or interactive Amp account. These are also identified as unverified in the PR description.
  • git status --short remained clean after testing; tools changed no tracked files.

Verdict

approved — no Critical findings were found within the reviewed scope.

…bs by state

The install ran npm and Amp's install script while the workspace key was
in its environment. It now saves the key in /etc/amp-orbs/key, which only
root reads, and runs the rest in a new process without the key, so no
installer can read it, also not from /proc. The new key replaces the old
one only once the install worked. systemd reads the file as root and hands
the key to the services (EnvironmentFile).

The provider installs instabox 0.8.522, and only when its npm tarball has
the hash InstaADE knows. Amp's CLI now comes from npm, checked against the
registry, not from a script piped to bash. It stays unpinned: Amp's server
and CLI change together.

The Amp orbs page called every orb that does not run paused. It now
counts each state: "1 running · 1 paused · 1 creating · 1 error".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The implementation is comprehensive, but the project-snapshot collision can violate Amp’s save-on-pause contract and risks losing an orb’s state.

Requirements context

I assessed the PR against its description, docs/amp-orbs.md, README.md, and DEVELOPMENT.md; no linked issue was supplied. The reviewed scope includes provider setup and key handling, dispatch lifecycle operations, removal/recovery, API additions, sandbox-role isolation, and the React UI.

Findings

Critical

  • Concurrent pauses can alias one snapshot and discard an orb’s saved state. Snapshot names use only the project-derived prefix plus date +%s. If two orbs with the same ORB_SNAPSHOT_ID pause within one second, both request the same name. The second operation explicitly treats a name conflict as success, then polls the first matching snapshot by name and proceeds to suspend its own sandbox. Consequently, Amp can receive a successful pause even though that orb was never snapshotted; after its sandbox is deleted, its changes are unavailable to the next orb for that project. Generate a collision-resistant name and track the snapshot created by this operation rather than accepting an arbitrary existing same-name snapshot. Add a concurrent-pause regression test. (src-tauri/assets/amp-orbs/amp-orbs:181-208)

Suggestion

  • Provide a recovery path for a stale saved provider token. Once provider-token exists, connect never calls amp orb provider create again. If the provider is removed in Amp or the user changes Amp accounts, opening the sign-in terminal or running Repair continues using the old token, while local status can still report tokenSaved and the UI can appear connected. Consider validating/rotating the token or exposing an explicit reconnect flow. (src-tauri/assets/amp-orbs/amp-orbs:297-319)

Information

  • Security: No additional reportable security issue was detected. The workspace key is sent through exec environment fields with history disabled, installed before old keys are revoked, and kept out of command text. (src-tauri/src/orbs.rs:483-517)
  • Performance: No reportable hot-path issue was detected. UI orb counting uses a fixed eight-state scan, and the heavier API/deletion loops are user-triggered administrative flows. (src/AmpOrbs.tsx:13-21, src-tauri/src/orbs.rs:554-620)
  • Software engineering: The feature follows the Rust-command/React boundary and includes extensive fake-provider, removal, key, script, and UI tests. End-to-end behavior requiring a paid workspace and real Amp sign-in remains unverified, as disclosed by the PR. (src-tauri/src/orbs.rs:623-2125, src/App.test.tsx:2778-2940)

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • timeout --kill-after=10s 120s git diff --check main...HEAD — passed.
  • timeout --kill-after=10s 120s cargo test orbs:: --lib — environment failure: the default Cargo cache is read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME="$XDG_CACHE_HOME/cargo" cargo test orbs:: --lib — environment failure: compilation reached glib-sys but the VM lacks the glib-2.0 development package.
  • timeout --kill-after=10s 120s bun install --frozen-lockfile — environment failure: bun is not installed. Consequently, TypeScript typecheck, Vitest, and the frontend build were skipped.
  • Paid-workspace/Amp sign-in end-to-end testing was skipped because it requires external accounts and credentials unavailable within this review environment.
  • git status --short remained clean after testing; no tracked files were changed.

Verdict

Request changes. The snapshot-name race is a proven correctness and data-loss risk and must be fixed before merge.

Two orbs of a project that paused in the same second asked for the same
snapshot name. The second save took the conflict for success, waited for
the first orb's snapshot and paused its own orb unsaved, so its state was
lost.

A project snapshot's name now ends in a random tag, and a pause follows
the snapshot by the id its save gave. A failed save fails the pause. A
pause deletes only the snapshots of its project that are older than its
own, so a newer one of an orb that paused meanwhile stays. Names keep to
128 characters, also for a long project id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The PR implements the documented Amp-orbs provider lifecycle across the Rust core, provider dispatch script, API client, and React UI, with no merge-blocking defect found in the reviewed paths.

Requirements context

Intent was derived from the PR description, docs/amp-orbs.md, README.md, and DEVELOPMENT.md; no linked issue or separate design specification was present. The reviewed scope covered provider setup/repair, workspace-key handling and renewal, orb spawn/pause/delete dispatch, image refresh, ordered/retryable removal, sandbox-role integration, and the Amp-orbs UI.

Findings

Critical

(none)

Suggestion

  • src-tauri/assets/amp-orbs/amp-orbs:92-100 — Project snapshot namespaces use an eight-hex-digit cksum when an ORB_SNAPSHOT_ID needs normalization or truncation. Two distinct IDs with the same sanitized prefix and 32-bit checksum would share snapshots, allowing one project to resume from another project's state. This is unlikely accidentally, but using a longer collision-resistant digest would preserve project isolation even for adversarial or numerous IDs.

  • src/AmpOrbs.tsx:453-456 — The user-initiated Check again action discards every refresh error, leaving stale status with no feedback when the provider or API cannot be reached. The background polling at lines 312-318 can reasonably remain quiet, but the explicit button should use the existing run wrapper so failures are surfaced.

Information

  • Architecture and maintainability: the feature follows the existing Rust-command/React-client boundary and isolates provider behavior in orbs.rs and assets/amp-orbs/. No reportable architecture or readability issue was detected within scope.
  • Security: secret installation uses exec environment fields with noHistory, root-only key storage, scoped workspace credentials, metadata checks before sandbox mutation, and a pinned integrity value for the instabox CLI. Apart from the snapshot-namespace hardening suggestion above, no reportable security issue was detected.
  • Performance: workspace lists and cleanup loops occur in infrequent setup/removal paths; UI counting is linear over the displayed sandboxes. No reportable hot-path, unbounded-read, or N+1 issue was detected.
  • The PR explicitly identifies paid-workspace and Amp sign-in end-to-end behavior as unverified; this review had neither those credentials nor external services available.

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • timeout --kill-after=10s 120s npx --yes bun@latest install --frozen-lockfile — passed; installed the pinned frontend dependencies without modifying tracked manifests.
  • timeout --kill-after=10s 120s npx --yes bun@latest run test -- --run src/App.test.tsx src/types.test.ts — passed: 161 tests across 2 files.
  • timeout --kill-after=10s 120s npx --yes bun@latest run typecheck — passed.
  • timeout --kill-after=10s 120s npx --yes bun@latest run build — passed.
  • git diff --check main...HEAD — passed.
  • Initial timeout --kill-after=10s 120s cargo test orbs:: --lib — environment failure because Cargo's default registry cache was read-only.
  • Retried with writable CARGO_HOME and CARGO_TARGET_DIR — compilation stopped because the VM lacks the glib-2.0 and gobject-2.0 development packages required by Tauri. Rust tests were therefore not executed.
  • Initial Bun test/typecheck attempts failed because bun and then project dependencies were not installed; both checks passed after the frozen dependency installation above.
  • Paid-workspace/Amp sign-in end-to-end tests were skipped because the required account, workspace, and Amp credentials were unavailable.

Testing created only ignored build/dependency artifacts; git status --short reported no tracked-file changes.

Verdict

approved — no Critical findings were identified. The suggestions are non-blocking.

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - approved.

CarmenDou and others added 4 commits December 4, 2026 15:44
Amp names an orb amp-<thread UUID> (amp-01a242cb-... runs thread
T-01a242cb-...), not amp-T-<UUID> as the code assumed. The end-to-end
test showed it: Open thread did not appear on a real orb. Match the real
form in the thread link, the tests, the preview data and the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Amp passes the thread's orb type to spawn as ORB_TYPE; the provider
decides what each name means. Map Amp's own size names (small, medium,
large, xlarge/xxlarge, with or without "a1.") and vCPUs x GB names such
as 32x64 to instabox sizes.

instabox locks a snapshot to the size it was saved at, so an orb from
the base or a project snapshot starts at that size; spawn then resizes
it with a restart before Amp starts in it. An unknown type fails before
any sandbox is made, with the names in the thread's setup log. A new orb
that cannot get its size (not on the plan) is deleted; an existing one
keeps its files. Without orb types nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/amp-orbs.md now says how to start a thread on an instabox orb from
ampcode.com and from the CLI, and shows the setup page, the connected
page, the list in Amp mode and an orb's details. The screenshots are of
the browser preview (?orbs=setup and ?orbs=connected) at 2x, cropped like
the README's. The preview's paused orb is 8 vCPU / 16 GB, as an orb of
the large type would be.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Amp-orbs implementation is well documented and extensively tested in source, but the workspace-switch and resource-ownership paths contain blocking isolation and data-loss risks.

Requirements context

I assessed the PR against its description, docs/amp-orbs.md, the README/Amp documentation, and the repository conventions in DEVELOPMENT.md. These specify one provider per selected workspace, explicit one-click setup, automatic key renewal, ownership-safe cleanup, and dispatch limited to resources belonging to Amp orbs. No linked issue or separate design document was identified.

Findings

Critical

  1. Automatic renewal can create or repair a provider in the wrong workspace. orbs_refresh captures workspace A before awaiting its provider status, but after the await it updates the current state without checking that A is still selected. More importantly, when A's key is due, it calls orbs_context() again, which reads whichever workspace is selected then. If the user switches to paid workspace B while A's status request is in flight, A's status can therefore trigger orbs_install for B, minting a key and potentially creating a billable always-on provider there without the user choosing setup for B. Keep the captured org and sizes through renewal, or discard the result when the selected org changes; state updates should also be scoped by both account and org. (src-tauri/src/app.rs:5375-5408)

  2. A machine with no orgId is treated as belonging to every workspace. Machine.org_id defaults to an empty string, while find_provider, orbs_of, and builder cleanup accept that empty value for any requested org. Because /v1/machines is account-wide, a legacy or incomplete response for a provider in workspace A can be reused during setup in B and installed with B's workspace key; removal in B can likewise stop or delete that provider or an unscoped builder. An unknown owner must not be attributed to every selected workspace—resolve the actual personal workspace explicitly or refuse workspace-sensitive operations when ownership is unknown. (src-tauri/src/orbs.rs:331-351, src-tauri/src/orbs.rs:554-560)

  3. Image setup/removal can delete an unrelated import builder. The dispatch script deletes any sandbox named amp-orb-builder carrying the generic instabox-import marker, and removal uses the same name/marker test. A user import created with that builder name has exactly those properties, so setup, a daily rebuild, or removal can destroy the user's unrelated sandbox. Mark the builder with Amp-orbs-specific ownership metadata and require it before deletion, or reject the name collision as setup already does for the provider. (src-tauri/assets/amp-orbs/amp-orbs:395-399, src-tauri/src/orbs.rs:554-560)

Suggestion

  1. Surface snapshot-retention failures instead of reporting successful maintenance. Failures deleting old project or base snapshots are only logged, so daily imports and pauses can succeed while billable snapshots accumulate indefinitely, contrary to the documented one-base/one-project retention behavior. Consider failing the operation or recording a visible degraded status that Repair can address. (src-tauri/assets/amp-orbs/amp-orbs:254-264, src-tauri/assets/amp-orbs/amp-orbs:414-423)

Information

  • Architecture and maintainability: the provider orchestration is isolated in orbs.rs, the dispatch implementation is separately embedded, and UI/API types remain synchronized. The large change is cohesive, although its size increases review risk. (src-tauri/src/orbs.rs:1-42, src/types.ts:245-306)
  • Security beyond the findings above: the workspace key is passed through envs with noHistory, written root-only, and removed from the installer environment; I found no additional reportable secret exposure or input-to-shell injection path. (src-tauri/src/orbs.rs:173-323, src-tauri/src/orbs.rs:483-500)
  • Performance: no reportable hot-path or unbounded-work issue was detected. API machine listing is paginated, and dispatch polling has operation deadlines. (src-tauri/src/api/mod.rs:275-298, src-tauri/assets/amp-orbs/amp-orbs:94-104)

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • git diff --check main...HEAD — passed.
  • timeout --kill-after=10s 120s bun run typecheck — could not start because bun is not installed on the VM.
  • timeout --kill-after=10s 120s cargo test orbs:: --lib — could not build because the default Cargo registry cache is read-only.
  • CARGO_HOME=/data/state/codex-review-bot/work/codex-runtime-RPBo9k/cargo-home timeout --kill-after=10s 120s cargo test orbs:: --lib — dependencies downloaded, then the build failed because the VM lacks the required glib-2.0 system development package.
  • Shellcheck was unavailable on the VM.
  • UI tests/build and Rust unit tests therefore remain unverified. Cloud end-to-end behavior was not exercised because it requires real instabox/Amp accounts and services.
  • Testing created only ignored build/cache artifacts; no tracked files changed.

Verdict

Request changes. The workspace-switch renewal race and ambiguous resource ownership can operate on the wrong workspace, while the builder collision can delete unrelated user data. These Critical findings must be addressed before merge.

- A key renewal or setup that ends after the user switched workspaces
  now acts and shows its steps only in the workspace it started in.
- The provider, its orbs and the builder are found only in sandboxes
  whose orgId is the workspace's. A sandbox without one is in none.
- The import builder is amp-orb-builder-<provider id>, passed to the
  provider in its env file. The image build and removal delete only a
  builder with that name and the import's mark, never a user's import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Amp-orbs implementation is comprehensive, but the workspace-switch race in automatic key renewal violates an explicit requirement and can eventually stop the provider from starting orbs.

Requirements context

I reviewed the implementation against the PR description, docs/amp-orbs.md, DEVELOPMENT.md, and the existing sandbox/API/UI conventions. The intended scope includes workspace-isolated provider management, automatic renewal of the provider key during its final 30 days—including when the selected workspace changes during a status read—secure installation, orb lifecycle dispatch, cleanup, and the related UI. No linked issue supplied additional requirements.

Findings

Critical

  • Renewal is abandoned if the user switches workspaces while status is being read. In orbs_refresh, the captured workspace’s due key is renewed only when that workspace is still selected after the asynchronous status request completes. If the user switches during that request, here is false and lines 5432–5447 skip key creation and installation entirely. The recurring UI check for the original provider is also removed after the switch, so renewal may not be retried unless the user later returns to that workspace; the key can consequently expire and prevent Amp from starting orbs. This contradicts the PR description’s guarantee that renewal occurs in the workspace the read was for even if the user switches meanwhile. The regression test currently codifies the broken behavior by asserting that no key is minted despite its name saying the key “renews.” Preserve the captured workspace for renewal while continuing to keep its status and progress out of the newly selected workspace. (src-tauri/src/app.rs:5422-5447, src-tauri/src/app.rs:12745-12772)

Suggestion

(none)

Information

(none)

Beyond the blocking issue above, I found no reportable security defect in the reviewed secret transport, shell-input validation, provider/orb ownership checks, or dependency-install paths. I also found no reportable performance issue: the new list operations are infrequent control-plane work, and the UI’s orb aggregation is bounded by the displayed sandbox list. The new module follows the existing Rust-command/React-client boundary and includes substantial targeted coverage, though the PR is unusually large.

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • timeout --kill-after=10s 120s sh -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • git diff --check main...HEAD — passed.
  • timeout --kill-after=10s 120s bun run typecheck — not run successfully: Bun is not installed in the sandbox.
  • timeout --kill-after=10s 120s bun run test -- --run src/App.test.tsx src/types.test.ts — not run successfully: Bun is not installed in the sandbox.
  • timeout --kill-after=10s 120s cargo test orbs --lib — environment failure: Cargo’s default registry cache is read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME=/data/state/codex-review-bot/work/codex-review-68W1BS/codex-runtime-Zm2XaH/cargo cargo test orbs --lib — environment failure during compilation: the VM lacks the required glib-2.0/gobject-2.0 development libraries. VM configuration was not changed.
  • Full frontend build, Clippy, and broader Rust tests were not run because they require the same unavailable Bun or native GTK/GLib infrastructure. Cloud end-to-end behavior was not exercised because it requires external accounts and services.
  • git status --short remained clean after testing; no tracked files were changed.

Verdict

Request changes. The Critical workspace-switch renewal defect must be fixed before merge.

orbs_refresh skipped the renewal when the user picked another workspace
while the provider answered. The key could then expire before the user
picked that workspace again, and Amp could start no orb.

The refresh now reads the workspace, its plan and its sizes when it
starts, and renews the key there whatever is selected when the status
comes back. Its steps and status still show only while that workspace
is selected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Amp-orbs implementation is comprehensive and well tested, but concurrent setup or repair from two clients can violate the key-rotation guarantee and leave a broad workspace key active.

Requirements context

I reviewed against the PR description, docs/amp-orbs.md, DEVELOPMENT.md, and the implementation’s own lifecycle contracts. Together they require one provider per workspace, workspace-scoped discovery, safe secret handling, repair-driven key rotation, removal of every Amp orbs key, role-restricted sandbox operations, orb sizing, snapshot lifecycle management, and UI restrictions for provider/orb sandboxes. No linked issue or separate design document was present.

Findings

Critical

  • src-tauri/src/orbs.rs:476-481,522-526 — Concurrent setup or repair can leave an additional 365-day workspace key active. Each flow lists existing keys before creating its own key, then only revokes IDs from that earlier snapshot. If two InstaADE clients begin setup/repair before either creates its key, neither flow sees the other flow’s key; both can complete, while the provider ultimately uses only the last installed key and the other machine/image-management key remains valid. This violates the stated rotation behavior and the function’s guarantee to revoke every other Amp-orbs key. The lifecycle needs cross-client serialization or another concurrency-safe reconciliation mechanism; a simple local orbs_flow guard only serializes one app instance.

Suggestion

  • src-tauri/src/orbs.rs:515-518 — If provider creation or installation fails and revoking the newly minted key also fails, the revocation error is discarded. This can leave a valid broad-scope key behind while showing only the original installation error. Preserve/report the cleanup failure and direct the user to Repair so the remaining key is visible and actionable.

  • src-tauri/assets/amp-orbs/amp-orbs:256-265 — Snapshot cleanup compares only createdAt < $t. Concurrent project snapshots receiving equal API timestamps are both retained, despite the documented one-snapshot-per-project policy. Consider adding the snapshot name or ID as the same deterministic tie-breaker used by newest.

Information

  • docs/amp-orbs.md:135 — Two troubleshooting bullets are accidentally joined (provider.- **"Amp saved..."**), which makes the rendered instructions harder to scan.

  • Architecture and maintainability are otherwise sound: the provider lifecycle is isolated in src-tauri/src/orbs.rs, dispatch behavior is separated into the installed asset, and the React/Rust state types remain synchronized. Aside from the key races above, I found no additional reportable security issue, untrusted shell interpolation path, authorization weakening, or secret logged in command text.

  • I found no reportable performance issue. Status polling is bounded, API listings follow the existing pagination behavior, dispatch polling has deadlines, and no new hot-path N+1 work was identified.

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • timeout --kill-after=10s 120s bun run test -- src/App.test.tsx src/types.test.ts — initial attempt skipped/failed because bun was not installed.
  • timeout --kill-after=10s 120s bun run typecheck — initial attempt skipped/failed because bun was not installed.
  • timeout --kill-after=10s 120s cargo test orbs:: --lib — initial attempt failed because Cargo’s default registry cache was read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME="$TMPDIR/cargo-home" CARGO_TARGET_DIR="$TMPDIR/cargo-target" cargo test orbs:: --lib — environment failure while compiling: required glib-2.0 and gobject-2.0 development packages were unavailable. Rust behavioral tests and Clippy therefore remain unverified.
  • timeout --kill-after=10s 120s npm install --global --prefix "$TMPDIR/bun-install" bun@1.3.5 — passed, but that Bun version could not parse lockfile version 2.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install/bin/bun" install --frozen-lockfile — failed due to the unsupported lockfile version.
  • timeout --kill-after=10s 120s npm install --global --prefix "$TMPDIR/bun-install-new" bun@1.4.5 && timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" install --frozen-lockfile — passed; 94 locked packages installed.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" run test -- src/App.test.tsx src/types.test.ts — passed: 161 tests.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" run typecheck — passed.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" run build — passed.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" run test — failed: 254 passed, 1 failed in the unrelated GitHubSignIn.test.tsx Paseo ordering assertion.
  • timeout --kill-after=10s 120s "$TMPDIR/bun-install-new/bin/bun" run test -- src/GitHubSignIn.test.tsx — passed in isolation: 10 tests, indicating suite interference or an existing flake rather than a demonstrated Amp-orbs regression.
  • Real Amp/instabox end-to-end flows were not run because they require external accounts and cloud credentials.
  • git diff --check main...HEAD passed. Testing left no tracked-file changes.

Verdict

Request changes. The concurrent key-rotation race is a blocking security and lifecycle correctness defect; the remaining findings are non-blocking.

Two InstaADE apps that set up, repair or renew at the same time could
leave a second 365-day key valid. In another order, one app revoked the
key the other then installed, and the provider ran with a revoked key.
Both installs also wrote the same key.new file.

- The provider installs one key at a time, under a flock held for the
  whole install.
- Keys rank by expiry, then id (key_rank). The provider keeps the
  newest: an install with an older key than the one it has changes
  nothing.
- Each setup lists the keys after its install and revokes only keys
  older than its own, and its own when the provider kept a newer one.
  No setup revokes a newer key, so none revokes the key in use.
- A failed install whose new key cannot be revoked says so, with
  Repair as the next step.
- Fix two joined troubleshooting bullets in the docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The feature is comprehensively documented and tested, but removal is not currently safe against concurrent setup or unrelated snapshots using the same broad prefixes.

Requirements context

I assessed the change against the PR description, docs/amp-orbs.md, and the repository conventions in DEVELOPMENT.md. No linked issue or separate design specification was provided; the documented requirements include cross-admin key safety, stopping dispatch before destructive removal, revoking every Amp-orbs key, workspace isolation, and deleting only Amp-orb resources.

Findings

Critical

  1. Concurrent repair can undo removal’s safety barrier and leave credentials or resources behind (src-tauri/src/orbs.rs:523-560, src-tauri/src/orbs.rs:355-360, src-tauri/src/orbs.rs:695-717)

    Removal captures the key list before stopping dispatch. A setup/repair in another admin’s app can then mint a new key and run the installer, which unconditionally enables and restarts the provider service. One concrete ordering is:

    1. Removal lists the current keys and stops the provider.
    2. Concurrent repair creates a new key, installs it, and restarts dispatch.
    3. Removal’s second machine read sees no orb yet, revokes only its earlier key list, and deletes the provider.

    The repair’s new workspace key remains valid because removal never listed it, violating the documented “revokes every Amp orbs key” behavior. Dispatch is also live again after the claimed stop barrier, so an Amp request can create an orb after the final orb check and leave it orphaned when the provider is deleted. The existing flock serializes installs only; removal neither participates in that exclusion nor leaves a marker that prevents a later installer from restarting services. Coordinate setup and removal across apps, list keys after that exclusion is established, and add a regression test for this interleaving.

  2. Removal can delete unrelated user snapshots solely because their names share a prefix (src-tauri/src/orbs.rs:657-668)

    purge deletes every workspace snapshot whose name merely starts with amp-orb-base- or amp-orb-snap-. Therefore a user snapshot such as amp-orb-base-my-backup or amp-orb-snap-important is irreversibly deleted even though this feature could never have created that name. The provider’s own image cleanup already checks the exact timestamp suffix shape in src-tauri/assets/amp-orbs/amp-orbs:422-430; removal needs an equivalent ownership check, preferably a durable ID/marker, and coverage proving malformed or foreign prefixed snapshots survive.

Suggestion

(none)

Information

  • Software engineering and architecture otherwise follow the established Rust-command/React-view boundary, with substantial unit coverage for dispatch, key rotation, workspace filtering, UI behavior, and removal sequencing.
  • The security-relevant findings are the leaked-key race and destructive snapshot ownership check above. I found no additional reportable injection, authorization, or secret-logging defect in the reviewed paths.
  • I found no reportable performance issue: provider polling is bounded, lifecycle waits have deadlines, and machine listing follows pagination.

Tests

  • timeout --kill-after=10s 120s npx --yes bun@1.3.3 --version — passed; confirmed Bun 1.3.3, but that version was too old for this repository’s lockfile.
  • timeout --kill-after=10s 120s npx --yes bun@1.3.3 install --frozen-lockfile — failed because Bun 1.3.3 does not recognize lockfile version 2.
  • timeout --kill-after=10s 120s npx --yes bun --version && timeout --kill-after=10s 120s npx --yes bun install --frozen-lockfile — passed with Bun 1.4.5.
  • timeout --kill-after=10s 120s bun run test -- --run src/App.test.tsx — not run; bun was not installed directly on PATH.
  • timeout --kill-after=10s 120s bun run typecheck — not run for the same reason.
  • timeout --kill-after=10s 120s npx --yes bun test src/App.test.tsx — failed because this invoked Bun’s native test runner rather than the repository’s Vitest configuration (localStorage was unavailable); this was an invocation mismatch, not a PR failure.
  • timeout --kill-after=10s 120s npx --yes bun run test -- src/App.test.tsx — passed: 160 tests.
  • timeout --kill-after=10s 120s npx --yes bun run typecheck — passed.
  • timeout --kill-after=10s 120s npx --yes bun run build — passed.
  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s cargo test orbs:: — first attempt failed because Cargo’s default registry cache was read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME="$XDG_CACHE_HOME/cargo" cargo test orbs:: — dependencies downloaded, but compilation failed because the VM lacks the glib-2.0 development package. Per the review constraints, I did not alter the VM configuration.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed.
  • git diff --check main...HEAD — passed.
  • git status --short — clean; testing changed no tracked files.

Unverified: Rust unit behavior and Clippy beyond formatting, due to the missing system GLib development library; real Amp/instabox integration was not exercised because it requires external accounts and services.

Verdict

Request changes. The concurrent-removal race and overbroad snapshot deletion are blocking correctness, security, and data-loss risks.

…apshots

A setup, repair or renewal in another InstaADE could run while a
removal ran: it restarted dispatch after the removal's stop, and put a
new key in place that the removal, which listed the keys before the
stop, never revoked. Removal also deleted every snapshot whose name
only started with amp-orb-base- or amp-orb-snap-.

- amp-orbs stop takes the install lock and marks the provider as being
  removed. For 30 minutes an install changes nothing on a marked
  provider. start clears the mark.
- Removal lists the keys after the stop, so a key made meanwhile is
  revoked too.
- purge deletes only snapshots named exactly as amp-orbs names them:
  amp-orb-base-<time> and amp-orb-snap-<project>-<time>[-<tag>].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The Amp-orbs lifecycle is comprehensively implemented and tested, but the provider sandbox exposes privileged credentials through its user-accessible terminal.

Requirements context

I reviewed against the PR description, docs/amp-orbs.md, and the repository conventions in DEVELOPMENT.md. No linked issue was supplied. The intended behavior includes workspace isolation, role/ID ownership checks, safe concurrent key rotation, reversible removal, and keeping the instabox key and Amp provider token isolated on the provider.

Findings

Critical

  1. The provider terminal exposes both long-lived credentials to the service account. The installer makes /var/lib/amp-orbs owned by the current sandbox user and installs the services using that same user (src-tauri/src/orbs.rs:324-325, src-tauri/src/orbs.rs:388-405). The provider token is consequently a mode-0600 file owned by the terminal user (src-tauri/assets/amp-orbs/amp-orbs:329-352). Although the instabox key file is root-only, systemd injects it into a process running as that user (src-tauri/assets/amp-orbs/amp-orb-provider.service:8-14), so the same user can read it from the service process environment under the sandbox's normal /proc policy. The UI explicitly offers an unrestricted terminal on provider sandboxes (src/AmpOrbs.tsx:202-210, src/SandboxMenu.tsx:248-250).

    Trigger: any workspace user who can obtain the offered provider terminal runs as the service account. They can directly read the Amp provider token and recover INSTABOX_API_KEY from the provider/image process environment. The key carries workspace-wide machine and image read/write/delete scopes (src-tauri/src/orbs.rs:23-31), which can exceed that member's own authority and allows deleting unrelated sandboxes or snapshots; the Amp token also permits impersonating the provider.

    Please isolate dispatch and its state under a dedicated non-login account inaccessible to SSH users, with process/credential isolation that prevents terminal users from inspecting its environment. The interactive Amp sign-in can hand the resulting token to that privileged service through a narrow root-owned mechanism. Alternatively, terminal access to the provider must be restricted to principals already authorized for all capabilities carried by these credentials.

Suggestion

(none)

Information

(none)

Tests

  • timeout --kill-after=10s 120s cargo fmt --check — passed.
  • timeout --kill-after=10s 120s bash -n src-tauri/assets/amp-orbs/amp-orbs — passed as the first part of the combined shell validation command.
  • shellcheck -s bash src-tauri/assets/amp-orbs/amp-orbs — skipped because shellcheck is not installed.
  • timeout --kill-after=10s 120s cargo test orbs:: --lib — environment failure: Cargo's default registry cache is read-only.
  • timeout --kill-after=10s 120s env CARGO_HOME=/data/state/codex-review-bot/work/codex-runtime-3hUnFn/cargo cargo test orbs:: --lib — environment failure while compiling: the sandbox lacks the GLib/GObject development packages required by Linux Tauri.
  • Same-user /proc/<pid>/environ diagnostic under timeout --kill-after=10s 120s — passed, confirming the credential exposure path under this sandbox's process policy.
  • git diff --check main...HEAD — passed.
  • bun run typecheck, bun run test, and bun run build — skipped because Bun and node_modules are unavailable.
  • Full Cargo tests and Clippy — not run after the targeted build failed on the same missing system libraries.

The worktree had no tracked changes after testing. Real Amp/provider integration, real orb-type dispatch, and end-to-end removal were not verified in this environment. Static review found no additional reportable functionality, architecture, performance, or dependency issues within scope.

Verdict

Request changes because the credential exposure is a reachable privilege-escalation and destructive-access risk.

Every member of a team workspace can open a shell on each of its
sandboxes, the provider and the orbs too. So every member can read the
provider's instabox key, the Amp sign-in of the person who connected
it, the provider's Amp token, and the work on each orb. The docs now
say so, and that Repair replaces the instabox key after someone leaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CarmenDou

Copy link
Copy Markdown
Collaborator Author

Re: review 6199197819 (credentials on the provider readable from a terminal)

We checked this and keep the account model in this PR. The docs now state the exposure.

  • A dedicated service account would not close it. The sandbox user on the provider has passwordless sudo (checked on a live provider: (ALL : ALL) NOPASSWD: ALL). Every shell, exec and SSH session on an instabox sandbox runs as that user. A shell on the provider is root, so it can read any file and any process environment, whatever account the service runs as.
  • Who gets a shell is instabox's access model, not InstaADE's. Every member of a workspace, also the member role, can exec, SSH and open terminals on every sandbox in it: instabox docs/orgs.md ("Members share the org's machines"), and machineAccess in internal/server/machines.go checks only membership of the org. The same holds for any credential on any shared sandbox; instabox notes that finer permissions are not built yet. Restricting shells to one sandbox's creator needs an instabox change, outside this PR.
  • Documented in 190b47f, docs/amp-orbs.md → "In a team workspace": every member can read the provider's instabox key, the Amp sign-in of the person who connected the provider and the provider's Amp token, and the work on each orb. Set it up in a team workspace only if you trust its members with that. After someone leaves, Repair makes a new instabox key and revokes the old ones.

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - approved.

@CarmenDou CarmenDou added the preview-build Build a signed Instabox Preview of this pull request label Dec 5, 2026
@github-actions github-actions Bot removed the preview-build Build a signed Instabox Preview of this pull request label Dec 5, 2026

This branch has not been deployed

No deployments
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.

2 participants