Files
zopu-code/packages/backend/convex/signalRouting.test.ts
-Puter a5414d83bd Convex-only Slice 1: clients talk to Convex, Flue is a private worker
Normalize the topology so web/desktop/mobile clients communicate only with
Convex. Convex admits durable commands, dispatches private Flue turns through
FLUE_URL, and stores the product-facing result before clients observe it.

- Normalized relational schema: organizations, projects, conversations/turns/
  messages/attachments, signals/sources/constraints, works/events/attachments.
- Conversation turns queued in Convex; the agent runAction dispatches to Flue
  and persists assistant response, signals, and proposed work back into Convex.
- Browser chat moved off the Flue transport: use-chat-agent now reads reactive
  Convex rows and sends through conversationMessages.send.
- Fixed signed-in blank screen: gate all product queries on useConvexAuth
  (isAuthenticated && !isRefreshing) plus personal-org bootstrap.
- Pinned react/react-dom to 19.2.8 via catalog to fix SSR dual-React crash.
- Removed ~16.6k net lines: daemon, AgentOS/Orb, project issues/runs/artifacts,
  todos, browser Flue transport, mobile execution views, smoke scripts.

Verified end-to-end on cheaptricks: connect repo, send actionable message,
Flue turn completes, Signal + proposed Work created with exact provenance,
persists across refresh.
2026-07-27 21:32:17 +05:30

88 lines
2.8 KiB
TypeScript

import { env } from "@code/env/convex";
import { convexTest } from "convex-test";
import { anyApi } from "convex/server";
import { describe, expect, test } from "vitest";
import schema from "./schema";
declare global {
interface ImportMeta {
readonly glob: (pattern: string) => Record<string, () => Promise<unknown>>;
}
}
const modules = import.meta.glob("./**/*.ts");
const api = anyApi;
describe("signalRouting", () => {
test("creates one normalized Signal from admitted conversation evidence", async () => {
const t = convexTest({ modules, schema });
const organization = await t.run(async (ctx) => {
const organizationId = await ctx.db.insert("organizations", {
createdAt: 1,
createdBy: "user",
kind: "personal",
name: "Personal",
});
const projectId = await ctx.db.insert("projects", {
createdAt: 1,
name: "Zopu",
normalizedSourceUrl: "https://example.com/zopu",
organizationId,
repositoryPath: "puter/zopu",
sourceHost: "example.com",
sourceUrl: "https://example.com/zopu",
updatedAt: 1,
});
const conversationId = await ctx.db.insert("conversations", {
createdAt: 1,
organizationId,
});
const turnId = await ctx.db.insert("conversationTurns", {
clientRequestId: "request-1",
conversationId,
createdAt: 1,
status: "processing",
});
const messageId = await ctx.db.insert("conversationMessages", {
content: "Fix the deploy",
conversationId,
createdAt: 1,
ordinal: 0,
role: "user",
turnId,
});
return { messageId, organizationId, projectId };
});
const result = await t.mutation(api.signalRouting.createSignal, {
messageIds: [String(organization.messageId)],
organizationId: organization.organizationId,
problemStatement: {
constraints: ["Keep production stable"],
desiredOutcome: "Deploy succeeds",
summary: "The deploy is failing",
title: "Fix deploy",
},
processedByAgentInstanceId: String(organization.organizationId),
projectId: organization.projectId,
token: env.FLUE_DB_TOKEN,
});
const stored = await t.run(async (ctx) => ({
constraints: await ctx.db.query("signalConstraints").collect(),
signal: await ctx.db.get(result.signalId),
sources: await ctx.db.query("signalSources").collect(),
}));
expect(stored.signal).toMatchObject({
desiredOutcome: "Deploy succeeds",
summary: "The deploy is failing",
title: "Fix deploy",
});
expect(stored.constraints.map((row) => row.value)).toEqual([
"Keep production stable",
]);
expect(stored.sources[0]?.rawTextSnapshot).toBe("Fix the deploy");
});
});