@opsydyn/oxlint-effect 2.2.0 → 2.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opsydyn/oxlint-effect",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Oxlint plugin rules for Effect TypeScript code shape constraints.",
5
5
  "author": "Alan Currie",
6
6
  "license": "MIT",
@@ -34,6 +34,7 @@
34
34
  "test": "bun test ./tests/*.test.ts",
35
35
  "test:effect-versions": "bun run build && bun scripts/verify-effect-version-consumers.ts",
36
36
  "test:type-aware": "bun run build && bun scripts/verify-type-aware-consumer.ts",
37
+ "test:type-aware:tsrs": "bun run build && bun scripts/verify-type-aware-consumer.ts --tsrs",
37
38
  "typecheck": "tsc --noEmit",
38
39
  "version": "changeset version"
39
40
  },
@@ -71,7 +72,7 @@
71
72
  "size-limit": [
72
73
  {
73
74
  "path": "dist/index.mjs",
74
- "limit": "30 KB"
75
+ "limit": "31 KB"
75
76
  }
76
77
  ],
77
78
  "publishConfig": {
@@ -97,6 +97,13 @@ keep defects and interruptions distinct from typed failures.
97
97
  For message-only failures, generic rethrows, or log-only handlers, read
98
98
  [error preservation](references/error-preservation.md). Establish recovery
99
99
  ownership and distinguish `catchAll` from `tapError` before changing semantics.
100
+ When mapping a rich failure into a new boundary error, also read
101
+ [cause narrowing](references/cause-narrowing.md). Its versioned bad/repair pairs
102
+ demonstrate cause identity, observer sequencing, public disclosure and assertions
103
+ that miss erasure. The opt-in `linteffect/no-error-cause-loss` rule, introduced in
104
+ plugin 2.3.0, diagnoses the matched cases. Check installed exports and
105
+ the owner's retention policy first. Other review questions remain gaps; a clean
106
+ lint result does not prove preservation, constructor storage or telemetry delivery.
100
107
  For current Effect use the versioned guide: broad `catch`/`catchEager` differs
101
108
  from failure-preserving observers, and legacy `catch` is discriminator-specific.
102
109
 
@@ -0,0 +1,31 @@
1
+ // Legacy Effect 3 cause-loss anti-patterns. Enable the opt-in errorModeling policy.
2
+ import { Data, Effect } from "effect";
3
+ import { type ProviderFailure } from "./cause-narrowing.good";
4
+
5
+ export class ErasedProfileFailure extends Data.TaggedError("ProfileBoundaryFailure")<{
6
+ readonly operation: "profile.load";
7
+ }> {}
8
+
9
+ // EXPECT: linteffect/no-error-cause-loss
10
+ // QA: same public tag and operation, but the original failure is lost.
11
+ export function mapProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
12
+ return Effect.mapError(operation, () => new ErasedProfileFailure({ operation: "profile.load" }));
13
+ }
14
+
15
+ // EXPECT: linteffect/no-error-cause-loss
16
+ // QA: returning a tagged failure does not by itself retain its cause.
17
+ export function recoverProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
18
+ return Effect.catchAll(operation, () => Effect.fail(new ErasedProfileFailure({ operation: "profile.load" })));
19
+ }
20
+
21
+ // EXPECT: linteffect/no-error-cause-loss
22
+ // QA: constructing a reporting Effect does not execute that Effect.
23
+ export function captureAndMap<A, R>(
24
+ operation: Effect.Effect<A, ProviderFailure, R>,
25
+ capture: (failure: ProviderFailure) => Effect.Effect<void>,
26
+ ) {
27
+ return Effect.mapError(operation, (error) => {
28
+ capture(error);
29
+ return new ErasedProfileFailure({ operation: "profile.load" });
30
+ });
31
+ }
@@ -0,0 +1,43 @@
1
+ // Legacy Effect 3 packaged review/repair runtime contracts.
2
+ import { Cause, Effect, Exit } from "effect";
3
+ import * as bad from "./cause-narrowing.bad";
4
+ import * as good from "./cause-narrowing.good";
5
+
6
+ const check = (valid: boolean, message: string) => { if (!valid) throw new Error(message); };
7
+ const secret = { credential: "fixture-secret" };
8
+ const original = new good.ProviderFailure({ code: 503, cause: secret });
9
+ for (const [erasing, preserving] of [[bad.mapProfile, good.mapProfile], [bad.recoverProfile, good.recoverProfile]] as const) {
10
+ const lost = Effect.runSync(Effect.flip(erasing(Effect.fail(original))));
11
+ const retained = Effect.runSync(Effect.flip(preserving(Effect.fail(original))));
12
+ // Tag-only assertions would accept both outcomes and miss the regression.
13
+ check(lost._tag === retained._tag && lost.operation === retained.operation, "Boundary discriminator changed");
14
+ check(!Object.hasOwn(lost, "cause"), "Erasure counterexample no longer erases");
15
+ check(retained.cause === original && retained.cause.cause === secret, "Original cause identity lost");
16
+ check(Effect.runSync(preserving(Effect.succeed(42))) === 42, "Successful value changed");
17
+ check(JSON.stringify(good.toPublicFailure(retained)) === '{"_tag":"ProfileBoundaryFailure","operation":"profile.load"}', "Internal cause leaked to public projection");
18
+ }
19
+
20
+ const captured: good.ProviderFailure[] = [];
21
+ const capture = (error: good.ProviderFailure) => Effect.sync(() => { captured.push(error); });
22
+ Effect.runSync(Effect.flip(bad.captureAndMap(Effect.fail(original), capture)));
23
+ check(captured.length === 0, "Unsequenced capture unexpectedly executed");
24
+ const observed = Effect.runSync(Effect.flip(good.captureAndMap(Effect.fail(original), capture)));
25
+ check(captured.length === 1 && captured[0] === original && observed.cause === original, "Capture or mapping lost the original");
26
+ check(Effect.runSync(good.captureAndMap(Effect.succeed(42), capture)) === 42 && captured.length === 1, "Success invoked the failure observer");
27
+
28
+ for (const value of [undefined, null, false, 0, -0, NaN, 1n, "failure", Symbol("failure"), () => 1]) {
29
+ const supplied = new good.ProviderFailure({ code: 503, cause: value });
30
+ check(Object.is(Effect.runSync(Effect.flip(good.mapProfile(Effect.fail(supplied)))).cause.cause, value), "Unknown cause was fabricated or discarded");
31
+ }
32
+ const defect = { source: "defect" };
33
+ const died = Effect.runSyncExit(good.mapProfile(Effect.die(defect)));
34
+ if (!Exit.isFailure(died)) throw new Error("Typed mapping swallowed a defect");
35
+ const diedWith = Cause.dieOption(died.cause);
36
+ check(diedWith._tag === "Some" && diedWith.value === defect, "Typed mapping changed a defect");
37
+ const interrupted = Effect.runSyncExit(good.mapProfile(Effect.interrupt));
38
+ check(Exit.isFailure(interrupted) && Cause.isInterruptedOnly(interrupted.cause), "Typed mapping swallowed interruption");
39
+ const reporterDefect = { source: "reporter" };
40
+ const brokenObserver = Effect.runSyncExit(good.captureAndMap(Effect.fail(original), () => Effect.die(reporterDefect)));
41
+ if (!Exit.isFailure(brokenObserver)) throw new Error("Observer failure became success");
42
+ const observerDiedWith = Cause.dieOption(brokenObserver.cause);
43
+ check(observerDiedWith._tag === "Some" && observerDiedWith.value === reporterDefect, "Observer failure was concealed");
@@ -0,0 +1,32 @@
1
+ // Legacy Effect 3 asset; use assets/effect4 for current policy.
2
+ import { Data, Effect } from "effect";
3
+
4
+ export class ProviderFailure extends Data.TaggedError("ProviderFailure")<{
5
+ readonly code: number;
6
+ readonly cause: unknown;
7
+ }> {}
8
+
9
+ export class ProfileBoundaryFailure extends Data.TaggedError("ProfileBoundaryFailure")<{
10
+ readonly operation: "profile.load";
11
+ readonly cause: ProviderFailure;
12
+ }> {}
13
+
14
+ export function mapProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
15
+ return Effect.mapError(operation, (cause) => new ProfileBoundaryFailure({ operation: "profile.load", cause }));
16
+ }
17
+
18
+ export function recoverProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
19
+ return Effect.catchAll(operation, (cause) => Effect.fail(new ProfileBoundaryFailure({ operation: "profile.load", cause })));
20
+ }
21
+
22
+ export function captureAndMap<A, R>(
23
+ operation: Effect.Effect<A, ProviderFailure, R>,
24
+ capture: (failure: ProviderFailure) => Effect.Effect<void>,
25
+ ) {
26
+ return mapProfile(Effect.tapError(operation, capture));
27
+ }
28
+
29
+ // This fixture's owned public projection deliberately omits internal causes.
30
+ export function toPublicFailure(error: ProfileBoundaryFailure) {
31
+ return { _tag: "ProfileBoundaryFailure" as const, operation: error.operation };
32
+ }
@@ -0,0 +1,17 @@
1
+ // Compile-only contract. Do not execute this file.
2
+ import { Effect } from "effect";
3
+ import { mapProfile, ProfileBoundaryFailure, ProviderFailure, toPublicFailure } from "./cause-narrowing.good";
4
+
5
+ declare const operation: Effect.Effect<string, ProviderFailure, "ProfileStore">;
6
+ declare const failure: ProfileBoundaryFailure;
7
+ const mapped = mapProfile(operation);
8
+ const preserved: Effect.Effect<string, ProfileBoundaryFailure, "ProfileStore"> = mapped;
9
+ // @ts-expect-error Mapping failures must not erase the dependency requirement.
10
+ const missingDependency: Effect.Effect<string, ProfileBoundaryFailure> = mapped;
11
+ // @ts-expect-error The new error is structured, not a string error channel.
12
+ const stringFailure: Effect.Effect<string, string, "ProfileStore"> = mapped;
13
+ // @ts-expect-error The public projection deliberately has no raw cause field.
14
+ toPublicFailure(failure).cause;
15
+ void preserved;
16
+ void missingDependency;
17
+ void stringFailure;
@@ -1,4 +1,5 @@
1
1
  // Legacy Effect 3 packaged repair runtime contract.
2
+ import "./cause-narrowing.contracts";
2
3
  import { Effect, Logger } from "effect";
3
4
  import { decodeUserId, decodeInvoiceId, settleInvoice, rejectTransfer, TransferRejected } from "./domain.good";
4
5
  import { decodeTransferCommand, encodeTransferCommand, transferFunds, decodeSessionLease, encodeSessionLease, decodePaymentIntent, encodePaymentIntent, createPaymentIntent } from "./domain-shapes.good";
@@ -0,0 +1,31 @@
1
+ // Effect 4 cause-loss anti-patterns. Enable the opt-in errorModeling policy.
2
+ import { Data, Effect } from "effect";
3
+ import { type ProviderFailure } from "./cause-narrowing.good";
4
+
5
+ export class ErasedProfileFailure extends Data.TaggedError("ProfileBoundaryFailure")<{
6
+ readonly operation: "profile.load";
7
+ }> {}
8
+
9
+ // EXPECT: linteffect/no-error-cause-loss
10
+ // QA: same public tag and operation, but the original failure is lost.
11
+ export function mapProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
12
+ return Effect.mapError(operation, () => new ErasedProfileFailure({ operation: "profile.load" }));
13
+ }
14
+
15
+ // EXPECT: linteffect/no-error-cause-loss
16
+ // QA: returning a tagged failure does not by itself retain its cause.
17
+ export function recoverProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
18
+ return Effect.catch(operation, () => Effect.fail(new ErasedProfileFailure({ operation: "profile.load" })));
19
+ }
20
+
21
+ // EXPECT: linteffect/no-error-cause-loss
22
+ // QA: constructing a reporting Effect does not execute that Effect.
23
+ export function captureAndMap<A, R>(
24
+ operation: Effect.Effect<A, ProviderFailure, R>,
25
+ capture: (failure: ProviderFailure) => Effect.Effect<void>,
26
+ ) {
27
+ return Effect.mapError(operation, (error) => {
28
+ capture(error);
29
+ return new ErasedProfileFailure({ operation: "profile.load" });
30
+ });
31
+ }
@@ -0,0 +1,43 @@
1
+ // Effect 4 packaged review/repair runtime contracts.
2
+ import { Effect, Exit, Result } from "effect";
3
+ import * as bad from "./cause-narrowing.bad";
4
+ import * as good from "./cause-narrowing.good";
5
+
6
+ const check = (valid: boolean, message: string) => { if (!valid) throw new Error(message); };
7
+ const secret = { credential: "fixture-secret" };
8
+ const original = new good.ProviderFailure({ code: 503, cause: secret });
9
+ for (const [erasing, preserving] of [[bad.mapProfile, good.mapProfile], [bad.recoverProfile, good.recoverProfile]] as const) {
10
+ const lost = Effect.runSync(Effect.flip(erasing(Effect.fail(original))));
11
+ const retained = Effect.runSync(Effect.flip(preserving(Effect.fail(original))));
12
+ // Tag-only assertions would accept both outcomes and miss the regression.
13
+ check(lost._tag === retained._tag && lost.operation === retained.operation, "Boundary discriminator changed");
14
+ check(!Object.hasOwn(lost, "cause"), "Erasure counterexample no longer erases");
15
+ check(retained.cause === original && retained.cause.cause === secret, "Original cause identity lost");
16
+ check(Effect.runSync(preserving(Effect.succeed(42))) === 42, "Successful value changed");
17
+ check(JSON.stringify(good.toPublicFailure(retained)) === '{"_tag":"ProfileBoundaryFailure","operation":"profile.load"}', "Internal cause leaked to public projection");
18
+ }
19
+
20
+ const captured: good.ProviderFailure[] = [];
21
+ const capture = (error: good.ProviderFailure) => Effect.sync(() => { captured.push(error); });
22
+ Effect.runSync(Effect.flip(bad.captureAndMap(Effect.fail(original), capture)));
23
+ check(captured.length === 0, "Unsequenced capture unexpectedly executed");
24
+ const observed = Effect.runSync(Effect.flip(good.captureAndMap(Effect.fail(original), capture)));
25
+ check(captured.length === 1 && captured[0] === original && observed.cause === original, "Capture or mapping lost the original");
26
+ check(Effect.runSync(good.captureAndMap(Effect.succeed(42), capture)) === 42 && captured.length === 1, "Success invoked the failure observer");
27
+
28
+ for (const value of [undefined, null, false, 0, -0, NaN, 1n, "failure", Symbol("failure"), () => 1]) {
29
+ const supplied = new good.ProviderFailure({ code: 503, cause: value });
30
+ check(Object.is(Effect.runSync(Effect.flip(good.mapProfile(Effect.fail(supplied)))).cause.cause, value), "Unknown cause was fabricated or discarded");
31
+ }
32
+ const defect = { source: "defect" };
33
+ const died = Effect.runSyncExit(good.mapProfile(Effect.die(defect)));
34
+ if (!Exit.isFailure(died)) throw new Error("Typed mapping swallowed a defect");
35
+ const diedWith = Exit.findDefect(died);
36
+ check(Result.isSuccess(diedWith) && diedWith.success === defect, "Typed mapping changed a defect");
37
+ const interrupted = Effect.runSyncExit(good.mapProfile(Effect.interrupt));
38
+ check(Exit.isFailure(interrupted) && Exit.hasInterrupts(interrupted) && !Exit.hasFails(interrupted) && !Exit.hasDies(interrupted), "Typed mapping swallowed interruption");
39
+ const reporterDefect = { source: "reporter" };
40
+ const brokenObserver = Effect.runSyncExit(good.captureAndMap(Effect.fail(original), () => Effect.die(reporterDefect)));
41
+ if (!Exit.isFailure(brokenObserver)) throw new Error("Observer failure became success");
42
+ const observerDiedWith = Exit.findDefect(brokenObserver);
43
+ check(Result.isSuccess(observerDiedWith) && observerDiedWith.success === reporterDefect, "Observer failure was concealed");
@@ -0,0 +1,32 @@
1
+ // Effect 4 first-class asset; qualify against the pinned current consumer.
2
+ import { Data, Effect } from "effect";
3
+
4
+ export class ProviderFailure extends Data.TaggedError("ProviderFailure")<{
5
+ readonly code: number;
6
+ readonly cause: unknown;
7
+ }> {}
8
+
9
+ export class ProfileBoundaryFailure extends Data.TaggedError("ProfileBoundaryFailure")<{
10
+ readonly operation: "profile.load";
11
+ readonly cause: ProviderFailure;
12
+ }> {}
13
+
14
+ export function mapProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
15
+ return Effect.mapError(operation, (cause) => new ProfileBoundaryFailure({ operation: "profile.load", cause }));
16
+ }
17
+
18
+ export function recoverProfile<A, R>(operation: Effect.Effect<A, ProviderFailure, R>) {
19
+ return Effect.catch(operation, (cause) => Effect.fail(new ProfileBoundaryFailure({ operation: "profile.load", cause })));
20
+ }
21
+
22
+ export function captureAndMap<A, R>(
23
+ operation: Effect.Effect<A, ProviderFailure, R>,
24
+ capture: (failure: ProviderFailure) => Effect.Effect<void>,
25
+ ) {
26
+ return mapProfile(Effect.tapError(operation, capture));
27
+ }
28
+
29
+ // This fixture's owned public projection deliberately omits internal causes.
30
+ export function toPublicFailure(error: ProfileBoundaryFailure) {
31
+ return { _tag: "ProfileBoundaryFailure" as const, operation: error.operation };
32
+ }
@@ -0,0 +1,17 @@
1
+ // Compile-only contract. Do not execute this file.
2
+ import { Effect } from "effect";
3
+ import { mapProfile, ProfileBoundaryFailure, ProviderFailure, toPublicFailure } from "./cause-narrowing.good";
4
+
5
+ declare const operation: Effect.Effect<string, ProviderFailure, "ProfileStore">;
6
+ declare const failure: ProfileBoundaryFailure;
7
+ const mapped = mapProfile(operation);
8
+ const preserved: Effect.Effect<string, ProfileBoundaryFailure, "ProfileStore"> = mapped;
9
+ // @ts-expect-error Mapping failures must not erase the dependency requirement.
10
+ const missingDependency: Effect.Effect<string, ProfileBoundaryFailure> = mapped;
11
+ // @ts-expect-error The new error is structured, not a string error channel.
12
+ const stringFailure: Effect.Effect<string, string, "ProfileStore"> = mapped;
13
+ // @ts-expect-error The public projection deliberately has no raw cause field.
14
+ toPublicFailure(failure).cause;
15
+ void preserved;
16
+ void missingDependency;
17
+ void stringFailure;
@@ -1,4 +1,5 @@
1
1
  // Effect 4 first-class packaged repair runtime contract.
2
+ import "./cause-narrowing.contracts";
2
3
  import { Effect, Logger } from "effect";
3
4
  import { decodeUserId, decodeInvoiceId, settleInvoice, rejectTransfer, TransferRejected } from "./domain.good";
4
5
  import { decodeTransferCommand, encodeTransferCommand, transferFunds, decodeSessionLease, encodeSessionLease, decodePaymentIntent, encodePaymentIntent, createPaymentIntent } from "./domain-shapes.good";
@@ -9,6 +9,7 @@ export function rejectProfile(error: ProfileUnavailable) {
9
9
  }
10
10
 
11
11
  // EXPECT: linteffect/no-catchall-generic-rethrow
12
+ // EXPECT: linteffect/no-error-cause-loss
12
13
  // QA: Replacing every typed failure with a generic error erases the original.
13
14
  export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
15
  return Effect.catch(operation, () => Effect.fail(new Error("profile failed")));
@@ -9,6 +9,7 @@ export function rejectProfile(error: ProfileUnavailable) {
9
9
  }
10
10
 
11
11
  // EXPECT: linteffect/no-catchall-generic-rethrow
12
+ // EXPECT: linteffect/no-error-cause-loss
12
13
  // QA: Replacing every typed failure with a generic error erases the original.
13
14
  export function rethrowProfile(operation: Effect.Effect<string, ProfileUnavailable>) {
14
15
  return Effect.catchAll(operation, () => Effect.fail(new Error("profile failed")));
@@ -0,0 +1,103 @@
1
+ # Cause-Preserving Error Narrowing
2
+
3
+ Use this when a boundary maps rich internal failures into a caller-facing error.
4
+ Since plugin 2.3.0, `linteffect/no-error-cause-loss` diagnoses the matched bad
5
+ examples under explicit `errorModeling`, `ddd` or `allRules` policy. It stays
6
+ out of recommended and type-aware recommended in both majors. Verify the
7
+ installed exports before enabling it.
8
+
9
+ The three bad cases now carry `EXPECT` annotations. Broader review questions
10
+ remain outside deterministic lint coverage. Unknown code is not proof of safety,
11
+ and a clean lint result does not establish telemetry delivery or error semantics.
12
+
13
+ ## Choose The Matching Corpus
14
+
15
+ | Major | Review counterexamples | Repair | Runtime And Types |
16
+ | --- | --- | --- | --- |
17
+ | Effect 4 | [bad](../assets/effect4/cause-narrowing.bad.ts) | [good](../assets/effect4/cause-narrowing.good.ts) | [runtime](../assets/effect4/cause-narrowing.contracts.ts), [types](../assets/effect4/cause-narrowing.types.ts) |
18
+ | Legacy Effect 3 | [bad](../assets/cause-narrowing.bad.ts) | [good](../assets/cause-narrowing.good.ts) | [runtime](../assets/cause-narrowing.contracts.ts), [types](../assets/cause-narrowing.types.ts) |
19
+
20
+ These utilities wrap a supplied Effect. They are not a production profile
21
+ service, telemetry transport or policy requiring every application error to
22
+ contain a cause. Current broad recovery uses `Effect.catch`; legacy uses
23
+ `Effect.catchAll`. Both use `mapError` for typed failure transformations.
24
+
25
+ ## Establish The Owner's Contract
26
+
27
+ Identify which details callers need, which internal failure must remain
28
+ available for diagnosis, and who owns reporting and public serialization.
29
+ Distinguish preserving the original error object from merely preserving its tag,
30
+ message or a reconstructed approximation. An established field other than
31
+ `cause` can retain the same evidence; reuse the consumer's representation.
32
+
33
+ The existing message-only and generic-rethrow rules cover specific erasure
34
+ patterns. A new tagged error can still discard the original without triggering
35
+ either older rule. The opt-in cause-loss rule addresses visible constructor
36
+ inputs, not every possible erasure. Conversely, narrowing a fully understood expected domain state can
37
+ be intentional. Do not add causes, logging or failure channels without an owned
38
+ requirement, and do not rewrite an intentional recovery merely to satisfy style.
39
+
40
+ ## Preserve And Sequence Deliberately
41
+
42
+ In the repair, `mapProfile` and `recoverProfile` retain the exact `ProviderFailure`
43
+ as the new error's cause. Its raw cause remains unchanged, including arbitrary
44
+ unknown values. The success value and environment requirement remain intact;
45
+ the error representation intentionally changes, so update callers where needed.
46
+ Typed mapping does not turn defects or interruptions into domain failures.
47
+
48
+ `captureAndMap` sequences an observer with `tapError` before mapping. Merely
49
+ calling a function that returns a reporting Effect inside `mapError` does not
50
+ execute that Effect. Keep `mapError` pure. Use the consumer's configured
51
+ observability service and decide where a single event is owned, rather than
52
+ adding duplicate reporting at every layer.
53
+
54
+ Logging is not preservation. A nearby `tapError` does not prove delivery,
55
+ durability, redaction or retention of the original. The reference anti-slop rule
56
+ allows some preceding observers as an escape hatch; this guide deliberately
57
+ does not equate that syntax with a preserved cause. When an owned boundary
58
+ intentionally captures and then erases internal details, verify that separate
59
+ contract rather than demanding a cause on its public error.
60
+
61
+ If the observer defects, it can replace the original typed failure. The corpus
62
+ tests this explicitly; choose and test the real reporting failure policy instead
63
+ of assuming `tapError` can never change the outcome. Avoid logging secrets.
64
+
65
+ ## Keep Internal Evidence Out Of Public Payloads
66
+
67
+ Retaining internal evidence does not authorise exposing it. `toPublicFailure`
68
+ projects the fixture's owned tag and operation only. Do not serialize the whole
69
+ error, stack, SDK response or `cause` into HTTP/RPC payloads. Use the consumer's
70
+ existing schema and disclosure contract; this example is not a universal wire
71
+ format. A typed internal cause is not an automatic redaction mechanism.
72
+
73
+ ## Make Verification Able To Reject The Regression
74
+
75
+ Check the mapped value, original error identity and structured context. For
76
+ capture, assert the original is observed exactly once and successes do not invoke
77
+ the observer. Verify dependency requirements and the new error channel at compile
78
+ time, plus defects, interruptions and the chosen public projection at runtime.
79
+
80
+ The bad and good examples have the same public tag and operation: assertions on
81
+ only those fields pass for both. The contracts expose that weakness and reject
82
+ the erasing control. This is a deterministic test-quality example, not a generic
83
+ lint rule proving that arbitrary tests are meaningful. Tests may assert through
84
+ helpers or service state; do not require inline assertions or ban test placement.
85
+
86
+ These packaged contracts are synthetic QA, not proof that an agent follows the
87
+ skill in a new repository or that production telemetry delivers an event.
88
+
89
+ ## Reference And Limits
90
+
91
+ Inspired by [anti-slop's cause-narrowing rule](https://github.com/K-Mistele/anti-slop/blob/b7c1619b4d51b4815e89ba3700a975a6ec54b8c3/src/effect/rules/require-cause-when-narrowing.ts),
92
+ not copied wholesale. Retain the consumer's version, contracts and policy.
93
+ The cause-loss rule examines direct constructors in synchronous inline mapError
94
+ and broad typed/Cause recovery handlers, including current eager map/typed catch
95
+ forms. It checks direct/data-last calls and block/conditional returns with actual
96
+ value-import and handler bindings. Passing the original inside a literal input
97
+ is evidence only that the constructor receives it, not that it stores it.
98
+ It respects later keys; opaque spreads/keys, aliases/helpers, destructured or
99
+ reassigned parameters, async/generator handlers, named handlers, `.make` factories
100
+ and cross-file storage remain outside that inference. These are gaps, not fixes.
101
+
102
+ Ambient service re-provision and general test-quality detection remain separate
103
+ follow-ups. No automatic fix or universal preservation contract is imposed.
@@ -90,10 +90,16 @@ does not silently override the consumer's policy. Preserve file overrides too.
90
90
  ## Type-Aware Opt-In
91
91
 
92
92
  Only enable type-aware linting when requested and supported by the installed
93
- Oxlint. Consult that version's requirements for `oxlint-tsgolint`, TypeScript,
93
+ Oxlint. Consult that version's requirements for the selected backend, TypeScript,
94
94
  project resolution, and editor integration. The consumer owns the engine
95
95
  dependency and must build workspace dependencies whose declarations are needed.
96
96
 
97
+ `oxlint-tsgolint` is the standard path. Do not add the optional `tsrs` preview
98
+ without explicit consumer opt-in: Oxlint 1.92+ can prefer it automatically when
99
+ installed. Keep the same preset and standalone compiler check, and verify lint
100
+ diagnostics on the target platform. See the
101
+ [Oxc backend announcement](https://oxc.rs/blog/2026-11-17-faster-type-aware-linting-with-tsrs).
102
+
97
103
  ```ts
98
104
  import { defineConfig } from "oxlint";
99
105
  import { typeAware } from "@opsydyn/oxlint-effect";
@@ -8,7 +8,8 @@ not legacy API spelling; matching packed consumers verify both corpora.
8
8
  Read the paired [failures](../assets/error-preservation.bad.ts) and
9
9
  [repairs](../assets/error-preservation.good.ts). These wrap a supplied profile
10
10
  Effect; they do not implement persistence or choose a production recovery policy.
11
- The bad file has three intentional diagnostics. The good file is full-DDD clean.
11
+ The bad file has four intentional diagnostics under the 2.3.0 DDD preset
12
+ (three under 2.2.0). The good file is full-DDD clean.
12
13
 
13
14
  | Rule | Question before repair | Example direction |
14
15
  | --- | --- | --- |
@@ -49,8 +50,9 @@ business requirements. Never replace successful recovery with failure solely
49
50
  to clear a diagnostic.
50
51
 
51
52
  `tapError(error => Effect.logError(error))` is different: a successful observer
52
- already preserves the original typed failure. The current heuristic also flags
53
- that log-only callback; the diagnostic does not prove the error was swallowed.
53
+ already preserves the original typed failure. The legacy Effect 3 policy also
54
+ flags that log-only callback; the Effect 4 policy keeps such observers clean.
55
+ The legacy diagnostic does not prove the error was swallowed.
54
56
  Report that detector/policy mismatch when this is legitimate observation. Do not
55
57
  put `Effect.fail(error)` inside `tapError` just to satisfy the rule: a failing
56
58
  observer can alter the resulting cause. Do not add wrappers, casts or suppression
@@ -74,3 +76,9 @@ and test it when adapting real boundaries.
74
76
  Keep `EXPECT`/`QA` examples intentionally failing. Run both the focused DDD
75
77
  policy and the consumer's complete lint configuration on repairs. A clean
76
78
  heuristic result is not proof that an observer or recovery handler is correct.
79
+
80
+ For tagged mappings beyond those three lint patterns, read
81
+ [cause narrowing](cause-narrowing.md). It provides current and legacy
82
+ counterexamples and repairs, and distinguishes internal retention, actually
83
+ sequenced capture and public disclosure. The opt-in cause-loss rule, introduced
84
+ in 2.3.0, addresses the visible constructor-input subset, not every review question.
@@ -12,6 +12,17 @@ A passing control labelled as a gap is not a recommended repair.
12
12
 
13
13
  ## API Selection
14
14
 
15
+ ### Opt-In Cause Loss In 2.3+
16
+
17
+ `linteffect/no-error-cause-loss` was introduced in 2.3.0. Explicit errorModeling,
18
+ ddd and allRules selections enable it; recommended/typeAware remain unchanged.
19
+ It checks actual value imports and inline synchronous map/recovery handlers for
20
+ returned constructors that do not visibly receive the original. Read
21
+ [cause narrowing](cause-narrowing.md) for precise forms and unknown-input limits.
22
+ Legacy uses catchAll/catchAllCause; current uses catch/catchEager/catchCause and
23
+ also mapErrorEager. This retention policy is not a mandate to attach internal
24
+ causes to public payloads or change intentional domain recovery.
25
+
15
26
  ### Concurrency Accuracy In 2.2+
16
27
 
17
28
  Plugin 2.2.0 and later recalibrates no-race-without-cleanup and the