Skip to content

Commit d3f98bf

Browse files
ubik2Gozalaanotherjessejsantellbfollington
authored
Remove legacy remote storage provider (#1079)
* chore: commit wip with working serverside traverse overhaul * chore: finished updating tests * chore: commit wip while debugging lack of schema * fix: wrong charm title (#1023) * add gemini-flash-lite (#1035) support flash-lite * chore: Do not attempt to serve static directories (#1037) * Only re-render CharmList when connection status actually changes (#1038) * Only re-render CharmList when connection status actually changes * Update types * track loads differently based on their schema import as FactModule instead of Fact to avoid collision expose the schema associated with the facts from QueryView make schemaContext optional in SchemaPathSelector, since I don't want to traverse commit logs Change default storage to cached * Llm feedback (#1036) User Feedback UI - Implemented FeedbackActions and FeedbackDialog components in Jumble to allow users to submit positive or negative feedback on generated content. - Added interactive thumbs-up/down buttons with feedback form submission workflow. Trace Span ID Management - Added functions (setLastTraceSpanID, getLastTraceSpanID) to manage trace IDs in the builder environment. - Updated builder exports to expose new trace ID functions. Integration of Trace ID in LLM Client - Modified LLMClient to capture x-ct-llm-trace-id from response headers and store it via setLastTraceSpanID. Backend Feedback Handling - Extended toolshed API (/api/ai/llm/feedback) to accept user feedback and relay it to Phoenix observability backend. Instrumentation and Span Filtering - Enhanced OpenTelemetry instrumentation to include specific spans relevant to LLM inference requests for better observability. * fix schema query with commit+json * chore: commit wip * chore: env variable to toggle schema sub * changed to have subscribing queries not delete themselves with the task/return changed so the server sends each response to each subscriber, even though there may be duplicates. a schema subscription on the client needs to know its updated list of entities added lots of debugging to try to track down this stall issue * we should be able to inspect both the graph/query and the subscribe for the combo * reverted incomplete change to docIsSyncing that caused me to stall on load * fix blunder with pulling value from fact cleaned up logging and comments * change todo comment for linter * remove incorrect comment in test * fix the other half of the value blunder * Remove unused import * Added start-ci task for running integration tests that makes BroadcastChannel available. * Change cache to only use the BroadcastChannel if it's available. * better import of isObj * just inline the isObj test * Remove the BroadcastChannel, since we're not really using it. * Remove remote provider Needs more work, since we fail tests which try to use indexdb in deno. * correct merge error --------- Co-authored-by: Irakli Gozalishvili <contact@gozala.io> Co-authored-by: Jesse Andrews <anotherjesse@gmail.com> Co-authored-by: Jordan Santell <jsantell@users.noreply.github.com> Co-authored-by: Ben Follington <5009316+bfollington@users.noreply.github.com> Co-authored-by: Jake Dahn <jake@common.tools>
1 parent effffd7 commit d3f98bf

File tree

6 files changed

+38
-770
lines changed

6 files changed

+38
-770
lines changed

cli/memory_demo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { RemoteStorageProvider } from "../runner/src/storage/remote.ts";
21
import { StorageProvider } from "../runner/src/storage/base.ts";
2+
import { Provider as CachedStorageProvider } from "../runner/src/storage/cache.ts";
33
import { EntityId } from "../runner/src/doc-map.ts";
44
import { Identity } from "../identity/src/index.ts";
55

@@ -34,7 +34,7 @@ function entity_id(i: number): EntityId {
3434
async function main() {
3535
const authority = await Identity.fromPassphrase("ellyse5");
3636

37-
const storageProvider: StorageProvider = new RemoteStorageProvider({
37+
const storageProvider: StorageProvider = new CachedStorageProvider({
3838
id: import.meta.url,
3939
address: new URL("/api/storage/memory", BASE_URL),
4040
space: authority.did(),

runner/src/storage.ts

+8-20
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import {
88
} from "./query-result-proxy.ts";
99
import { idle } from "./scheduler.ts";
1010
import { isStatic, markAsStatic } from "@commontools/builder";
11-
import { StorageProvider, StorageValue } from "./storage/base.ts";
12-
import { RemoteStorageProvider } from "./storage/remote.ts";
11+
import {
12+
BaseStorageProvider,
13+
StorageProvider,
14+
StorageValue,
15+
} from "./storage/base.ts";
1316
import {
1417
Provider as CachedStorageProvider,
1518
RemoteStorageProviderSettings,
@@ -22,11 +25,7 @@ import { sleep } from "@commontools/utils/sleep";
2225
import { TransactionResult } from "@commontools/memory";
2326
import { refer } from "@commontools/memory/reference";
2427
import { defer } from "@commontools/utils";
25-
import {
26-
Entity,
27-
SchemaContext,
28-
SchemaNone,
29-
} from "@commontools/memory/interface";
28+
import { SchemaContext, SchemaNone } from "@commontools/memory/interface";
3029

3130
export function log(fn: () => any[]) {
3231
debug(() => {
@@ -319,18 +318,7 @@ class StorageImpl implements Storage {
319318
? "volatile"
320319
: ((import.meta as any).env?.VITE_STORAGE_TYPE ?? "cached");
321320

322-
if (type === "remote") {
323-
if (!this.remoteStorageUrl) {
324-
throw new Error("No remote storage URL set");
325-
}
326-
327-
provider = new RemoteStorageProvider({
328-
id: this.id,
329-
address: new URL("/api/storage/memory", this.remoteStorageUrl!),
330-
space: space as `did:${string}:${string}`,
331-
as: this.signer,
332-
});
333-
} else if (type === "volatile") {
321+
if (type === "volatile") {
334322
provider = new VolatileStorageProvider(space);
335323
} else if (type === "cached") {
336324
if (!this.remoteStorageUrl) {
@@ -774,7 +762,7 @@ class StorageImpl implements Storage {
774762
}
775763

776764
const conflictJobIndex = jobs.findIndex((job) =>
777-
RemoteStorageProvider.toEntity(job.entityId) === conflict.of
765+
BaseStorageProvider.toEntity(job.entityId) === conflict.of
778766
);
779767

780768
if (conflictJobIndex === -1) {

runner/src/storage/base.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Cancel, EntityId } from "@commontools/runner";
2-
import type { Result, Unit } from "@commontools/memory/interface";
2+
import type { Entity, Result, Unit } from "@commontools/memory/interface";
33
import { log } from "../storage.ts";
44
import { SchemaContext } from "@commontools/memory/interface";
55

@@ -144,4 +144,21 @@ export abstract class BaseStorageProvider implements StorageProvider {
144144
abstract destroy(): Promise<void>;
145145

146146
abstract getReplica(): string | undefined;
147+
148+
static toEntity(source: EntityId): Entity {
149+
if (typeof source["/"] === "string") {
150+
return `of:${source["/"]}`;
151+
} else if (source.toJSON) {
152+
return `of:${source.toJSON()["/"]}`;
153+
} else {
154+
throw Object.assign(
155+
new TypeError(
156+
`💣 Got entity ID that is neither merkle reference nor {'/'}`,
157+
),
158+
{
159+
cause: source,
160+
},
161+
);
162+
}
163+
}
147164
}

runner/src/storage/cache.ts

+9-22
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import type {
1818
Unit,
1919
} from "@commontools/memory/interface";
2020
import type { Cancel, EntityId } from "@commontools/runner";
21-
import { type StorageProvider, type StorageValue } from "./base.ts";
21+
import {
22+
BaseStorageProvider,
23+
type StorageProvider,
24+
type StorageValue,
25+
} from "./base.ts";
2226
import type { MemorySpaceSession } from "@commontools/memory/consumer";
2327
import { assert, retract, unclaimed } from "@commontools/memory/fact";
2428
import { fromString, refer } from "merkle-reference";
@@ -789,29 +793,12 @@ export class Provider implements StorageProvider {
789793
}
790794
}
791795

792-
static toEntity(source: EntityId): Entity {
793-
if (typeof source["/"] === "string") {
794-
return `of:${source["/"]}`;
795-
} else if (source.toJSON) {
796-
return `of:${source.toJSON()["/"]}`;
797-
} else {
798-
throw Object.assign(
799-
new TypeError(
800-
`💣 Got entity ID that is neither merkle reference nor {'/'}`,
801-
),
802-
{
803-
cause: source,
804-
},
805-
);
806-
}
807-
}
808-
809796
sink<T = any>(
810797
entityId: EntityId,
811798
callback: (value: StorageValue<T>) => void,
812799
): Cancel {
813800
const { the } = this;
814-
const of = Provider.toEntity(entityId);
801+
const of = BaseStorageProvider.toEntity(entityId);
815802
const { workspace } = this;
816803
const address = { the, of };
817804
const subscriber = (revision?: Revision<State>) => {
@@ -836,14 +823,14 @@ export class Provider implements StorageProvider {
836823
schemaContext?: SchemaContext,
837824
) {
838825
const { the } = this;
839-
const of = Provider.toEntity(entityId);
826+
const of = BaseStorageProvider.toEntity(entityId);
840827
return this.workspace.load([[{ the, of }, schemaContext]]);
841828
}
842829

843830
get<T = any>(entityId: EntityId): StorageValue<T> | undefined {
844831
const entity = this.workspace.get({
845832
the: this.the,
846-
of: Provider.toEntity(entityId),
833+
of: BaseStorageProvider.toEntity(entityId),
847834
});
848835

849836
return entity?.is as StorageValue<T> | undefined;
@@ -865,7 +852,7 @@ export class Provider implements StorageProvider {
865852

866853
const changes = [];
867854
for (const { entityId, value } of batch) {
868-
const of = Provider.toEntity(entityId);
855+
const of = BaseStorageProvider.toEntity(entityId);
869856
const content = JSON.stringify(value);
870857

871858
const current = workspace.get({ the, of });

0 commit comments

Comments
 (0)