Skip to content

promote: test → main (org base-snapshot lookup + prebuilt fix)#530

Merged
sweetmantech merged 1 commit intomainfrom
test
May 7, 2026
Merged

promote: test → main (org base-snapshot lookup + prebuilt fix)#530
sweetmantech merged 1 commit intomainfrom
test

Conversation

@sweetmantech
Copy link
Copy Markdown
Contributor

@sweetmantech sweetmantech commented May 7, 2026

Promotes the org base-snapshot lookup port from test to main.

What lands on main

  • feat(sandbox): port org base-snapshot lookup from open-agents (feat(sandbox): port org base-snapshot lookup from open-agents #529, squash-merged into test as 13d074f7)
  • extractOrgRepoName + findOrgSnapshot — recoupable repos warm-boot from per-org base snapshots when one exists
  • source.prebuilt: !!orgSnapshotId flag plumbed correctly so git fetch + reset runs against the snapshot's repo instead of fresh clone (real bug caught during smoke testing — see PR comments)
  • Production observability: [findOrgSnapshot] log line per request

Verification

  • All CI checks green on feat(sandbox): port org base-snapshot lookup from open-agents #529
  • Smoke-tested end-to-end against the real recoupable org URL https://github.com/recoupable/org-rostrum-pacific-cebcc866-...:
    • Pre-built snapshot via SDK → snap_MxxRCI8WAPjZgVVyZOf26lgMWIK4
    • POST hit the snapshot, restored from it, returned 200 in 15.5s vs ~30s+ cold
    • Runtime logs confirmed [findOrgSnapshot] '...' → hit snap_MxxRCI8WAPjZgVVyZOf26lgMWIK4

Out of scope (still missing from cutover)

  • Build-org-snapshot workflow (needs Vercel Workflow infra in api)
  • Lifecycle workflow kicks
  • Failure-state self-healing in /status
  • Transient/unavailable distinction in /reconnect

🤖 Generated with Claude Code


Summary by cubic

Warm-boots recoupable org sandboxes by looking up per-org base snapshots and enabling the prebuilt restore path, cutting cold starts by ~75s. Adds lightweight production logs to verify snapshot hits.

  • New Features

    • Lookup per-org snapshot for recoupable repos via extractOrgRepoName + findOrgSnapshot (uses @vercel/sandbox) and pass baseSnapshotId to the sandbox.
    • Skip lookup for non-recoupable repos; fall through to default provisioning on miss or error.
    • Add [findOrgSnapshot] log per request for observability.
  • Bug Fixes

    • Set source.prebuilt: true when using baseSnapshotId to trigger the fast git fetch + reset path instead of a fresh clone.
    • Tests cover URL parsing, snapshot selection, handler plumbing, and prebuilt flag behavior.

Written for commit 13d074f. Summary will update on new commits.

* feat(sandbox): port org base-snapshot lookup from open-agents

Closes the largest user-visible regression in the cutover gap analysis:
~75s slower cold start per session because api wasn't reading the
per-org base snapshots open-agents builds. After this, api warm-boots
recoupable org sessions from the most recent created snapshot when one
exists, falling through to default provisioning otherwise.

Scope: lookup only.
- `extractOrgRepoName(repoUrl)` matches `https://github.com/recoupable/X`
  and returns X (or null for non-recoupable repos)
- `findOrgSnapshot(name)` calls `Snapshot.list({ name, sortOrder: "desc",
  limit: 5 })` from `@vercel/sandbox` and returns the first `created`
  snapshot's id, null on miss / error
- `createSandboxHandler` runs the lookup only when extractOrgRepoName
  returns non-null (skips for non-recoupable repos so the latency cost
  only applies where it can pay off), then plumbs the resolved id into
  `connectSandbox` options as `baseSnapshotId`

Out of scope (will need its own PR):
- `kickBuildOrgSnapshotWorkflow` — builds new snapshots when none exist
  yet. Open-agents currently does this via Vercel Workflow. Skipped here
  because (a) api doesn't have Vercel Workflow infra yet, and (b)
  open-agents' workflow keeps building snapshots today, so api can
  immediately benefit by reading what open-agents writes. Once open-agents
  is fully cut over to api, the build piece needs to land too — at that
  point new orgs would never get a snapshot.

TDD red -> green:
- 7 unit tests for extractOrgRepoName (recoupable URL, .git suffix,
  trailing slash, non-recoupable orgs, nested paths, non-GitHub,
  org-root-no-repo)
- 5 unit tests for findOrgSnapshot (most-recent-created, list call
  shape, no-created-state, empty list, throw)
- 3 new createSandboxHandler tests (recoupable repo + lookup hit
  plumbs baseSnapshotId, non-recoupable repo skips lookup entirely,
  recoupable repo + lookup miss does not pass baseSnapshotId)
- Suite: 2559 -> 2574 (+15 tests). pnpm lint:check + tsc --noEmit clean
  for new files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore(sandbox): log findOrgSnapshot outcomes for production observability

Adds a single structured log line on the success path:
[findOrgSnapshot] '<name>' → <hit snap_id | miss> (N total returned)

Useful both for the cutover verification (proves the lookup ran for
specific request URLs without needing to redeploy with debug
instrumentation) and for ongoing prod observability — when an org's
snapshot pipeline breaks, this is the line that surfaces it. Error
path log was already present.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(sandbox): set source.prebuilt:true when restoring from org snapshot

Caught during the hit-case smoke test against a real recoupable org
repo: with a snapshot found and `baseSnapshotId` plumbed in, the
sandbox boot still fell through to a fresh `git clone`, which then
failed with exit 128. Reason: I'd dropped the `prebuilt` source flag
from the port, calling it "informational." It is not.

Reading lib/sandbox/vercel/sandbox/VercelSandbox.ts, the flag switches
between two distinct boot paths:

- `source && baseSnapshotId && !source.prebuilt` → fresh clone on top
  of snapshot (often fails for private repos and defeats the warm-boot
  benefit)
- `source?.prebuilt && baseSnapshotId` → `git fetch` + `git reset --hard`
  against the repo that's already inside the snapshot (the fast path)

Setting `prebuilt: !!orgSnapshotId` matches open-agents' behavior and
unlocks the actual ~75s warm-boot win this PR exists to enable.

Tests updated: existing assertions for hit-case extended to also
verify `source.prebuilt === true` when a snapshot is found, and
`source.prebuilt === false` when the lookup misses.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Building Building Preview May 7, 2026 7:58pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Warning

Rate limit exceeded

@sweetmantech has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 21 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af2aaeb2-473d-4deb-be39-ccdceb96726d

📥 Commits

Reviewing files that changed from the base of the PR and between 0e4ac9c and 13d074f.

⛔ Files ignored due to path filters (3)
  • lib/recoupable/__tests__/extractOrgRepoName.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/sandbox/__tests__/createSandboxHandler.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/sandbox/__tests__/findOrgSnapshot.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (3)
  • lib/recoupable/extractOrgRepoName.ts
  • lib/sandbox/createSandboxHandler.ts
  • lib/sandbox/findOrgSnapshot.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sweetmantech sweetmantech merged commit cdc9e5f into main May 7, 2026
6 of 7 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