Complete orchestration V2 frontend cutover

- Migrate web and mobile state, commands, and persistence to V2 projections
- Render conversations from authoritative visible turn items
- Harden runtime policy, launch handling, attachments, and cache invalidation
This commit is contained in:
Julius Marminge authored and maria-rcks committed 2026-08-03 11:45:05 -04:00
1 parent 75e126993b
commit 3991a00629
111 files changed
+6306 -9244

No files matched your search

@@ -1,4 +1,5 @@
export * from "./capabilities.ts";
export * from "./persistence.ts";
export * from "./orchestrationCache.ts";
export * from "./source.ts";
export * from "./storageDocument.ts";
@@ -0,0 +1,59 @@
import { describe, expect, it } from "@effect/vitest";
import { EnvironmentId } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import {
ORCHESTRATION_CACHE_SCHEMA_VERSION,
StoredOrchestrationShellSnapshot,
StoredOrchestrationThreadSnapshot,
decodeOrDiscardOrchestrationCache,
} from "./orchestrationCache.ts";
import { v2Projection, v2ShellSnapshot, v2ThreadId } from "../state/orchestrationV2TestFixtures.ts";
const environmentId = EnvironmentId.make("environment-cache-test");
const decodeStoredShellSnapshot = Schema.decodeUnknownEffect(StoredOrchestrationShellSnapshot);
const decodeStoredThreadSnapshot = Schema.decodeUnknownEffect(StoredOrchestrationThreadSnapshot);
describe("orchestration cache envelopes", () => {
it.effect("accepts V2 shell and thread cache envelopes", () =>
Effect.gen(function* () {
const shell = yield* decodeStoredShellSnapshot({
schemaVersion: ORCHESTRATION_CACHE_SCHEMA_VERSION,
environmentId,
snapshot: v2ShellSnapshot,
});
const thread = yield* decodeStoredThreadSnapshot({
schemaVersion: ORCHESTRATION_CACHE_SCHEMA_VERSION,
environmentId,
threadId: v2ThreadId,
thread: v2Projection,
});
expect(shell.snapshot).toEqual(v2ShellSnapshot);
expect(thread.thread).toEqual(v2Projection);
}),
);
it.effect("discards V1-versioned cache envelopes after a decode failure", () =>
Effect.gen(function* () {
let discardCount = 0;
const decoded = decodeStoredShellSnapshot({
schemaVersion: 1,
environmentId,
snapshot: v2ShellSnapshot,
}).pipe(Effect.map(Option.some));
const result = yield* decodeOrDiscardOrchestrationCache(
decoded,
Effect.sync(() => {
discardCount += 1;
}),
);
expect(Option.isNone(result)).toBe(true);
expect(discardCount).toBe(1);
}),
);
});
@@ -0,0 +1,32 @@
import {
EnvironmentId,
OrchestrationV2ShellSnapshot,
OrchestrationV2ThreadProjection,
ThreadId,
} from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
export const ORCHESTRATION_CACHE_SCHEMA_VERSION = 2 as const;
export const StoredOrchestrationShellSnapshot = Schema.Struct({
schemaVersion: Schema.Literal(ORCHESTRATION_CACHE_SCHEMA_VERSION),
environmentId: EnvironmentId,
snapshot: OrchestrationV2ShellSnapshot,
});
export const StoredOrchestrationThreadSnapshot = Schema.Struct({
schemaVersion: Schema.Literal(ORCHESTRATION_CACHE_SCHEMA_VERSION),
environmentId: EnvironmentId,
threadId: ThreadId,
thread: OrchestrationV2ThreadProjection,
});
/** Invalid orchestration caches are disposable and must never block live synchronization. */
export function decodeOrDiscardOrchestrationCache<A, E, R, E2, R2>(
decode: Effect.Effect<Option.Option<A>, E, R>,
discard: Effect.Effect<void, E2, R2>,
) {
return decode.pipe(Effect.catch(() => discard.pipe(Effect.as(Option.none<A>()))));
}
@@ -1,8 +1,7 @@
import {
type EnvironmentId,
type OrchestrationShellSnapshot,
type OrchestrationThreadDetailSnapshot,
type ServerConfig,
type OrchestrationV2ShellSnapshot,
type OrchestrationV2ThreadProjection,
type ThreadId,
type VcsListRefsResult,
} from "@t3tools/contracts";
@@ -60,21 +59,18 @@ export class EnvironmentCacheStore extends Context.Service<
{
readonly loadShell: (
environmentId: EnvironmentId,
) => Effect.Effect<Option.Option<OrchestrationShellSnapshot>, ConnectionPersistenceError>;
) => Effect.Effect<Option.Option<OrchestrationV2ShellSnapshot>, ConnectionPersistenceError>;
readonly saveShell: (
environmentId: EnvironmentId,
snapshot: OrchestrationShellSnapshot,
snapshot: OrchestrationV2ShellSnapshot,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly loadThread: (
environmentId: EnvironmentId,
threadId: ThreadId,
) => Effect.Effect<
Option.Option<OrchestrationThreadDetailSnapshot>,
ConnectionPersistenceError
>;
) => Effect.Effect<Option.Option<OrchestrationV2ThreadProjection>, ConnectionPersistenceError>;
readonly saveThread: (
environmentId: EnvironmentId,
snapshot: OrchestrationThreadDetailSnapshot,
thread: OrchestrationV2ThreadProjection,
) => Effect.Effect<void, ConnectionPersistenceError>;
readonly removeThread: (
environmentId: EnvironmentId,