Skip to content

Commit 6c16c0f

Browse files
authored
chore(runner): removed all direct reads or writes to DocImpl, now everything goes via transactions (#1427)
* refactor(runner): remove remaining direct uses of `doc` - Refactored core runner modules to eliminate direct references to the `doc` object. - Updated builder, builtins, cell, data-updating, doc-map, link-utils, query-result-proxy, recipe-binding, runner, runtime, scheduler, sigil-types, storage, storage/transaction-shim, and uri-utils to use new abstractions or access patterns. - Adjusted related tests to align with the new approach and ensure coverage. * refactor: consolidate sigil link creation and improve schema handling - Move createSigilLink function from cell.ts to link-utils.ts as createSigilLinkFromParsedLink - Add support for base cell/link parameter to enable relative references - Add sanitizeSchemaForLinks function to remove asCell/asStream flags from schemas - Update all callers to use new function signature with options object - Add comprehensive tests for schema sanitization
1 parent 7f3d61d commit 6c16c0f

32 files changed

+834
-618
lines changed

packages/runner/src/builder/factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* Factory function to create builder functions with runtime dependency injection
33
*/
4-
import { getCellLinkOrThrow, type Runtime } from "../index.ts";
54
import type {
65
BuilderFunctionsAndConstants,
76
Cell,
@@ -34,14 +33,15 @@ import {
3433
} from "./built-in.ts";
3534
import { getRecipeEnvironment } from "./env.ts";
3635
import type { RuntimeProgram } from "../harness/types.ts";
36+
import type { IRuntime } from "../runtime.ts";
3737

3838
/**
3939
* Creates a set of builder functions with the given runtime
4040
* @param runtime - The runtime instance to use for cell creation
4141
* @returns An object containing all builder functions
4242
*/
4343
export const createBuilder = (
44-
runtime: Runtime,
44+
runtime: IRuntime,
4545
): {
4646
commontools: BuilderFunctionsAndConstants;
4747
exportsCallback: (exports: Map<any, RuntimeProgram>) => void;

packages/runner/src/builder/json-utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import { getTopFrame } from "./recipe.ts";
2121
import { deepEqual } from "../path-utils.ts";
2222
import { IRuntime } from "../runtime.ts";
23-
import { parseLink } from "../link-utils.ts";
23+
import { parseLink, sanitizeSchemaForLinks } from "../link-utils.ts";
2424

2525
export function toJSONWithLegacyAliases(
2626
value: Opaque<any>,
@@ -55,8 +55,12 @@ export function toJSONWithLegacyAliases(
5555
$alias: {
5656
...(isShadowRef(value) ? { cell: value } : {}),
5757
path: pathToCell as (string | number)[],
58-
...(exported?.schema ? { schema: exported.schema } : {}),
59-
...(exported?.rootSchema ? { rootSchema: exported.rootSchema } : {}),
58+
...(exported?.schema
59+
? { schema: sanitizeSchemaForLinks(exported.schema) }
60+
: {}),
61+
...(exported?.rootSchema
62+
? { rootSchema: sanitizeSchemaForLinks(exported.rootSchema) }
63+
: {}),
6064
},
6165
} satisfies LegacyAlias;
6266
} else throw new Error(`Cell not found in paths`);

packages/runner/src/builtins/stream-data.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ export function streamData(
6565
tx,
6666
);
6767

68-
pending.getDoc().ephemeral = true;
69-
result.getDoc().ephemeral = true;
70-
error.getDoc().ephemeral = true;
71-
7268
pending.setSourceCell(parentCell);
7369
result.setSourceCell(parentCell);
7470
error.setSourceCell(parentCell);

0 commit comments

Comments
 (0)