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

Function makeReadOrderRecorder

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

Source from the content-addressed store, hash-verified

812 * FIFO queue is guaranteed to land after those children have launched —
813 * a timer would race them across event-loop phases. */
814const makeReadOrderRecorder = () => {
815 let targets: ReadonlySet<string> = new Set();
816 const events: string[] = [];
817 const record = <A>(key: string, run: () => Promise<A>): Promise<A> => {
818 if (!targets.has(key)) return run();
819 events.push(`start:${key}`);
820 return run()
821 .then(
822 (result) =>
823 new Promise<A>((resolve) => {
824 setImmediate(() => resolve(result));
825 }),
826 )
827 .finally(() => {
828 events.push(`end:${key}`);
829 });
830 };
831 return {
832 arm: (keys: readonly string[]) => {
833 targets = new Set(keys);
834 },
835 record,
836 /** First occurrence — repeat reads of the same key log later entries. */
837 at: (event: string) => events.indexOf(event),
838 /** Snapshot of the full event log, for failure diagnostics. */
839 log: () => events.slice(),
840 };
841};
842
843/** Wrap a test `FumaDb` so every read runs through the recorder as
844 * `<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