@systemfsoftware/effect-spec-runtime 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @systemfsoftware/effect-spec-runtime
2
2
 
3
- # @systemfsoftware/effect-spec-runtime@1.2.0
3
+ # @systemfsoftware/effect-spec-runtime@1.3.1
4
4
 
5
- A live scenario can name the pipeline its second run executes: `scenario(title, { live: reason, rerun: pipeline }, firstPipeline)`. Every passing case runs again on fresh services to find state kept outside its layer, so a live scenario whose first run waits on an act that happens once, such as a person approving a sign-in in a browser, would ask for that act a second time. With `rerun` the second run executes the given pipeline over the same layers instead, and that check still runs. The runtime's `RegisterFn` accepts the rerun scenario through the new `CaseLive` type.
5
+ Requires Effect ^4.1.4.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Context, Effect, Layer, Scope } from "effect";
1
+ import { Context, Effect, Layer, Scope, Tracer } from "effect";
2
2
  import { Expect, Vitest } from "@systemfsoftware/vitest";
3
3
  import { Asserted } from "@systemfsoftware/vitest/integration";
4
4
  import { TestOptions } from "vitest";
@@ -37,6 +37,19 @@ declare const liveCase: {
37
37
  declare const explore: <A, E>(program: Effect.Effect<A, E>) => Promise<void>;
38
38
  /** An explored case's leak-check second run: its first run already took every seeded schedule. */
39
39
  declare const exploreOnce: <A, E>(program: Effect.Effect<A, E>) => Promise<void>;
40
+ declare namespace SpanRecorder_d_exports {
41
+ export { SpanRecorder, make };
42
+ }
43
+ /**
44
+ * A tracer that keeps every span a program opens, in the order they began. It is the tracing harness for a package
45
+ * that sits below `@systemfsoftware/trace-spec` in the dependency graph and whose published behaviour is the spans
46
+ * it emits; every other package asserts spans through a trace suite.
47
+ */
48
+ interface SpanRecorder {
49
+ readonly tracer: Tracer.Tracer;
50
+ readonly spans: ReadonlyArray<Tracer.NativeSpan>;
51
+ }
52
+ declare const make: () => SpanRecorder;
40
53
  //#endregion
41
54
  //#region src/Register.d.ts
42
55
  type RegisterMode = 'run' | 'skip' | 'only';
@@ -110,4 +123,4 @@ declare const provideTaskRef: {
110
123
  <A, E, R, Ctx>(effect: Effect.Effect<A, E, R>, ctx: Ctx): Effect.Effect<A, E, R>;
111
124
  };
112
125
  //#endregion
113
- export { KernelCase_d_exports as KernelCase, Suite_d_exports as Suite, TaskRef_service_d_exports as TaskRef };
126
+ export { KernelCase_d_exports as KernelCase, SpanRecorder_d_exports as SpanRecorder, Suite_d_exports as Suite, TaskRef_service_d_exports as TaskRef };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Kernel } from "@systemfsoftware/effect-sim-kernel";
3
3
  import { createSpanRecorder, providedWorkspaceRoot, replayOfText, testIdentityOf, throwFailureRecord } from "@systemfsoftware/vitest/failure";
4
- import { Cause, Config, Context, Effect, Exit, Layer, Match, Option, Schema, Scope } from "effect";
4
+ import { Cause, Config, Context, Effect, Exit, Layer, Match, Option, Schema, Scope, Tracer } from "effect";
5
5
  import { dual } from "effect/Function";
6
6
  import { VitestTestContext, vitestTestContextKey } from "@systemfsoftware/vitest";
7
7
  import { captureRunBinding } from "@systemfsoftware/vitest/integration";
@@ -101,7 +101,7 @@ const describeSuspended = (fiber) => {
101
101
  if (first === void 0) return `fiber ${fiber.id}`;
102
102
  return `fiber ${fiber.id} at ${first}`;
103
103
  };
104
- const describeKernelFailure = (failure) => Match.value(failure).pipe(Match.when({ _tag: "Escape" }, (escape) => `escaped the controlled schedule through the ${escape.timer} timer at ${escape.site}`), Match.when({ _tag: "Blocked" }, (blocked) => `waited on a resource the kernel cannot observe: ${blocked.resources.join(", ")}`), Match.when({ _tag: "Deadlock" }, (deadlock) => `deadlocked with ${deadlock.suspended.length} suspended fibers: ${deadlock.suspended.map(describeSuspended).join("; ")}`), Match.when({ _tag: "Runaway" }, (runaway) => `ran past ${runaway.steps} steps with ${runaway.pending} fibers pending`), Match.exhaustive);
104
+ const describeKernelFailure = (failure) => Match.value(failure).pipe(Match.when({ _tag: "Escape" }, (escape) => `escaped the controlled schedule through the ${escape.timer} timer at ${escape.site}`), Match.when({ _tag: "Blocked" }, (blocked) => `waited on a resource the kernel cannot observe: ${blocked.resources.join(", ")}`), Match.when({ _tag: "Deadlock" }, (deadlock) => `deadlocked with ${deadlock.suspended.length} suspended fibers: ${deadlock.suspended.map(describeSuspended).join("; ")}`), Match.when({ _tag: "Runaway" }, (runaway) => `ran past ${runaway.steps} steps with ${runaway.pending} fibers pending`), Match.when({ _tag: "ReplayTraceDiverged" }, (diverged) => `the replayed trace diverged at step ${diverged.atStep}: expected ${JSON.stringify(diverged.expected)}, got ${JSON.stringify(diverged.actual)}`), Match.exhaustive);
105
105
  /** One run with its own recorder: the record is rendered from exactly the spans this run opened (KTD2). */
106
106
  const recorded = (program) => {
107
107
  const recorder = createSpanRecorder();
@@ -124,7 +124,7 @@ const throwRecord = (failure, schedule, recorder) => throwFailureRecord({
124
124
  schedule: scheduleNoteOf(schedule),
125
125
  root: providedWorkspaceRoot()
126
126
  });
127
- const throwKernelFailure = (failure, schedule, recorder) => throwRecord(new KernelFailure({ detail: describeKernelFailure(failure) }), schedule, recorder);
127
+ const throwKernelFailure = (failure, schedule, recorder) => throwRecord(KernelFailure.make({ detail: describeKernelFailure(failure) }), schedule, recorder);
128
128
  const throwExitFailure = (exit, schedule, recorder) => throwRecord(Cause.squash(exit.cause), schedule, recorder);
129
129
  const isKernelFailure = (observed) => "failure" in observed;
130
130
  const throwIfExitFailed = (observed, schedule, recorder) => {
@@ -193,6 +193,20 @@ const exploreOnce = (program) => readReplayValue().then((value) => {
193
193
  return replayOrBaseline(program, replayOfText(value));
194
194
  });
195
195
  //#endregion
196
+ //#region src/SpanRecorder.ts
197
+ var SpanRecorder_exports = /* @__PURE__ */ __exportAll({ make: () => make });
198
+ const make = () => {
199
+ const spans = [];
200
+ return {
201
+ tracer: Tracer.make({ span: (options) => {
202
+ const span = new Tracer.NativeSpan(options);
203
+ spans.push(span);
204
+ return span;
205
+ } }),
206
+ spans
207
+ };
208
+ };
209
+ //#endregion
196
210
  //#region src/Register.ts
197
211
  const selectDescribe = (mode) => ({
198
212
  skip: describe.skip,
@@ -353,4 +367,4 @@ const openSharedCaseImpl = (bindings, config, shared, caseLayer, use) => {
353
367
  };
354
368
  const openSharedCase = dual(5, openSharedCaseImpl);
355
369
  //#endregion
356
- export { KernelCase_exports as KernelCase, Suite_exports as Suite, TaskRef_service_exports as TaskRef };
370
+ export { KernelCase_exports as KernelCase, SpanRecorder_exports as SpanRecorder, Suite_exports as Suite, TaskRef_service_exports as TaskRef };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/effect-spec-runtime",
3
3
  "license": "Apache-2.0",
4
- "version": "1.2.0",
4
+ "version": "1.3.1",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,18 +32,18 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@systemfsoftware/effect-sim-kernel": "^2.0.5"
35
+ "@systemfsoftware/effect-sim-kernel": "^2.0.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@microsoft/api-extractor": "^7.59.4",
39
39
  "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
40
- "@systemfsoftware/oxlint-config-recommended": "^7.0.0",
40
+ "@systemfsoftware/oxlint-config-recommended": "^8.0.3",
41
41
  "@systemfsoftware/tsconfig": "^2.1.0",
42
42
  "@systemfsoftware/tsdown-config": "^0.1.2",
43
- "@systemfsoftware/vitest": "^4.1.2",
43
+ "@systemfsoftware/vitest": "^4.1.3",
44
44
  "@systemfsoftware/vitest-config": "^0.1.3",
45
45
  "@types/node": "^26.6.5",
46
- "effect": "^4.1.2",
46
+ "effect": "^4.1.4",
47
47
  "fast-check": "^4.10.2",
48
48
  "oxlint": "~1.93.0",
49
49
  "rimraf": "^6.1.3",
@@ -52,8 +52,8 @@
52
52
  "vitest": "^5.1.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@systemfsoftware/vitest": "^4.1.2",
56
- "effect": "^4.1.2",
55
+ "@systemfsoftware/vitest": "^4.1.3",
56
+ "effect": "^4.1.4",
57
57
  "vitest": "^5.1.0"
58
58
  },
59
59
  "publishConfig": {