MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeReadOrderRecorder

Function makeReadOrderRecorder

packages/core/sdk/src/executor.test.ts:924–951  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

922 * FIFO queue is guaranteed to land after those children have launched —
923 * a timer would race them across event-loop phases. */
924const makeReadOrderRecorder = () => {
925 let targets: ReadonlySet<string> = new Set();
926 const events: string[] = [];
927 const record = <A>(key: string, run: () => Promise<A>): Promise<A> => {
928 if (!targets.has(key)) return run();
929 events.push(`start:${key}`);
930 return run()
931 .then(
932 (result) =>
933 new Promise<A>((resolve) => {
934 setImmediate(() => resolve(result));
935 }),
936 )
937 .finally(() => {
938 events.push(`end:${key}`);
939 });
940 };
941 return {
942 arm: (keys: readonly string[]) => {
943 targets = new Set(keys);
944 },
945 record,
946 /** First occurrence — repeat reads of the same key log later entries. */
947 at: (event: string) => events.indexOf(event),
948 /** Snapshot of the full event log, for failure diagnostics. */
949 log: () => events.slice(),
950 };
951};
952
953/** Wrap a test `FumaDb` so every read runs through the recorder as
954 * `<table>.<method>`. `withContext` re-wraps so the executor's

Callers 2

recordToolRowLaunchFunction · 0.85
recordCredentialLaunchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected