release: accept organizationId on POST /api/sessions (#620)

Merged
SW
6mo ago
+140-228

Releases #620 to production.

Summary

POST /api/sessions now has the minimal body shape { title?, organizationId? }. The api derives the workspace clone URL itself via ensurePersonalRepo for both personal (auth.accountId) and org (auth.orgId) sessions. Callers no longer construct GitHub URLs.

Smoke tests on preview

  • Brand-new agent (api key) → 200, creates recoupable/<accountId> ✓
  • Privy Bearer + empty body → 200, returns existing recoupable/<accountId> ✓
  • Privy Bearer + {organizationId} for a real org → 200, returns recoupable/<orgId> ✓
  • Two different orgIds → two different cloneUrls ✓
  • Cross-tenant attempt (other agent against Recoup org) → 403 ✓
  • Non-UUID organizationId → 400 ✓
  • Idempotency on both personal + org branches ✓

3,321 / 3,321 tests pass. Full audit trail in the PR comments.

Pairs with recoupable/docs#226 (already merged).

🤖 Generated with Claude Code


Summary by cubic

POST /api/sessions now accepts { title?, organizationId? } and derives the workspace repo URL server-side. Removed cloneUrl, branch, and sandboxType; the API auto‑provisions recoupable/<accountId | organizationId>.

  • Refactors

    • Handler uses ensurePersonalRepo and always sets clone_url; returns 502 on provisioning failure.
    • Validation requires organizationId to be a UUID and forwards it to validateAuthContext to set auth.orgId.
    • buildSessionInsertRow hard-codes branch: null and sandbox_state: { type: "vercel" }; removed resolveSessionCloneUrl and its tests.
  • Migration

    • Stop sending cloneUrl, branch, sandboxType (and any repo fields). Only title and optional organizationId are accepted.
    • Send organizationId to create org-scoped sessions; omit it for personal sessions.
    • Invalid organizationId → 400; no org access → 403. Docs: recoupable/docs#226.