mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
* feat(foundry): checkpoint actor and workspace refactor
* docs(foundry): add agent handoff context
* wip(foundry): continue actor refactor
* wip(foundry): capture remaining local changes
* Complete Foundry refactor checklist
* Fix Foundry validation fallout
* wip
* wip: convert all actors from workflow to plain run handlers
Workaround for RivetKit bug where c.queue.iter() never yields messages
for actors created via getOrCreate from another actor's context. The
queue accepts messages (visible in inspector) but the iterator hangs.
Sleep/wake fixes it, but actors with active connections never sleep.
Converted organization, github-data, task, and user actors from
run: workflow(...) to plain run: async (c) => { for await ... }.
Also fixes:
- Missing auth tables in org migration (auth_verification etc)
- default_model NOT NULL constraint on org profile upsert
- Nested workflow step in github-data (HistoryDivergedError)
- Removed --force from frontend Dockerfile pnpm install
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Convert all actors from queues/workflows to direct actions, lazy task creation
Major refactor replacing all queue-based workflow communication with direct
RivetKit action calls across all actors. This works around a RivetKit bug
where c.queue.iter() deadlocks for actors created from another actor's context.
Key changes:
- All actors (organization, task, user, audit-log, github-data) converted
from run: workflow(...) to actions-only (no run handler, no queues)
- PR sync creates virtual task entries in org local DB instead of spawning
task actors — prevents OOM from 200+ actors created simultaneously
- Task actors created lazily on first user interaction via getOrCreate,
self-initialize from org's getTaskIndexEntry data
- Removed requireRepoExists cross-actor call (caused 500s), replaced with
local resolveTaskRepoId from org's taskIndex table
- Fixed getOrganizationContext to thread overrides through all sync phases
- Fixed sandbox repo path (/home/user/repo for E2B compatibility)
- Fixed buildSessionDetail to skip transcript fetch for pending sessions
- Added process crash protection (uncaughtException/unhandledRejection)
- Fixed React infinite render loop in mock-layout useEffect dependencies
- Added sandbox listProcesses error handling for expired E2B sandboxes
- Set E2B sandbox timeout to 1 hour (was 5 min default)
- Updated CLAUDE.md with lazy task creation rules, no-silent-catch policy,
React hook dependency safety rules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix E2B sandbox timeout comment, frontend stability, and create-flow improvements
- Add TEMPORARY comment on E2B timeoutMs with pointer to rivetkit sandbox
resilience proposal for when autoPause lands
- Fix React useEffect dependency stability in mock-layout and
organization-dashboard to prevent infinite re-render loops
- Fix terminal-pane ref handling
- Improve create-flow service and tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
85 lines
3.3 KiB
TypeScript
85 lines
3.3 KiB
TypeScript
// @ts-nocheck
|
|
import { mkdtempSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { execFileSync } from "node:child_process";
|
|
import { setTimeout as delay } from "node:timers/promises";
|
|
import { describe, expect, it } from "vitest";
|
|
import { setupTest } from "rivetkit/test";
|
|
import { organizationKey } from "../src/actors/keys.js";
|
|
import { registry } from "../src/actors/index.js";
|
|
import { organizationWorkflowQueueName } from "../src/actors/organization/queues.js";
|
|
import { repoIdFromRemote } from "../src/services/repo.js";
|
|
import { createTestDriver } from "./helpers/test-driver.js";
|
|
import { createTestRuntimeContext } from "./helpers/test-context.js";
|
|
|
|
const runActorIntegration = process.env.HF_ENABLE_ACTOR_INTEGRATION_TESTS === "1";
|
|
|
|
function createRepo(): { repoPath: string } {
|
|
const repoPath = mkdtempSync(join(tmpdir(), "hf-isolation-repo-"));
|
|
execFileSync("git", ["init"], { cwd: repoPath });
|
|
execFileSync("git", ["config", "user.email", "test@example.com"], { cwd: repoPath });
|
|
execFileSync("git", ["config", "user.name", "Foundry Test"], { cwd: repoPath });
|
|
writeFileSync(join(repoPath, "README.md"), "hello\n", "utf8");
|
|
execFileSync("git", ["add", "README.md"], { cwd: repoPath });
|
|
execFileSync("git", ["commit", "-m", "init"], { cwd: repoPath });
|
|
return { repoPath };
|
|
}
|
|
|
|
async function waitForOrganizationRows(ws: any, organizationId: string, expectedCount: number) {
|
|
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
const rows = await ws.listTasks({ organizationId });
|
|
if (rows.length >= expectedCount) {
|
|
return rows;
|
|
}
|
|
await delay(50);
|
|
}
|
|
return ws.listTasks({ organizationId });
|
|
}
|
|
|
|
describe("organization isolation", () => {
|
|
it.skipIf(!runActorIntegration)("keeps task lists isolated by organization", async (t) => {
|
|
const testDriver = createTestDriver();
|
|
createTestRuntimeContext(testDriver);
|
|
|
|
const { client } = await setupTest(t, registry);
|
|
const wsA = await client.organization.getOrCreate(organizationKey("alpha"), {
|
|
createWithInput: "alpha",
|
|
});
|
|
const wsB = await client.organization.getOrCreate(organizationKey("beta"), {
|
|
createWithInput: "beta",
|
|
});
|
|
|
|
const { repoPath } = createRepo();
|
|
const repoId = repoIdFromRemote(repoPath);
|
|
await wsA.send(organizationWorkflowQueueName("organization.command.github.repository_projection.apply"), { repoId, remoteUrl: repoPath }, { wait: true });
|
|
await wsB.send(organizationWorkflowQueueName("organization.command.github.repository_projection.apply"), { repoId, remoteUrl: repoPath }, { wait: true });
|
|
|
|
await wsA.createTask({
|
|
organizationId: "alpha",
|
|
repoId,
|
|
task: "task A",
|
|
sandboxProviderId: "local",
|
|
explicitBranchName: "feature/a",
|
|
explicitTitle: "A",
|
|
});
|
|
|
|
await wsB.createTask({
|
|
organizationId: "beta",
|
|
repoId,
|
|
task: "task B",
|
|
sandboxProviderId: "local",
|
|
explicitBranchName: "feature/b",
|
|
explicitTitle: "B",
|
|
});
|
|
|
|
const aRows = await waitForOrganizationRows(wsA, "alpha", 1);
|
|
const bRows = await waitForOrganizationRows(wsB, "beta", 1);
|
|
|
|
expect(aRows.length).toBe(1);
|
|
expect(bRows.length).toBe(1);
|
|
expect(aRows[0]?.organizationId).toBe("alpha");
|
|
expect(bRows[0]?.organizationId).toBe("beta");
|
|
expect(aRows[0]?.taskId).not.toBe(bRows[0]?.taskId);
|
|
});
|
|
});
|