@opsydyn/oxlint-effect 1.1.0 → 2.0.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.
Files changed (44) hide show
  1. package/README.md +387 -73
  2. package/dist/index.d.mts +6586 -289
  3. package/dist/index.mjs +1 -1
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +8 -5
  6. package/skills/oxlint-effect/SKILL.md +114 -0
  7. package/skills/oxlint-effect/assets/contracts.ts +39 -0
  8. package/skills/oxlint-effect/assets/domain-context.bad.ts +18 -0
  9. package/skills/oxlint-effect/assets/domain-context.good.ts +32 -0
  10. package/skills/oxlint-effect/assets/domain-decisions.bad.ts +26 -0
  11. package/skills/oxlint-effect/assets/domain-decisions.good.ts +71 -0
  12. package/skills/oxlint-effect/assets/domain-shapes.bad.ts +22 -0
  13. package/skills/oxlint-effect/assets/domain-shapes.good.ts +39 -0
  14. package/skills/oxlint-effect/assets/domain.bad.ts +16 -0
  15. package/skills/oxlint-effect/assets/domain.good.ts +32 -0
  16. package/skills/oxlint-effect/assets/effect4/contracts.ts +39 -0
  17. package/skills/oxlint-effect/assets/effect4/domain-context.bad.ts +18 -0
  18. package/skills/oxlint-effect/assets/effect4/domain-context.good.ts +32 -0
  19. package/skills/oxlint-effect/assets/effect4/domain-decisions.bad.ts +26 -0
  20. package/skills/oxlint-effect/assets/effect4/domain-decisions.good.ts +71 -0
  21. package/skills/oxlint-effect/assets/effect4/domain-shapes.bad.ts +22 -0
  22. package/skills/oxlint-effect/assets/effect4/domain-shapes.good.ts +39 -0
  23. package/skills/oxlint-effect/assets/effect4/domain.bad.ts +16 -0
  24. package/skills/oxlint-effect/assets/effect4/domain.good.ts +32 -0
  25. package/skills/oxlint-effect/assets/effect4/error-preservation.bad.ts +21 -0
  26. package/skills/oxlint-effect/assets/effect4/error-preservation.good.ts +18 -0
  27. package/skills/oxlint-effect/assets/effect4/expected-state.bad.ts +28 -0
  28. package/skills/oxlint-effect/assets/effect4/expected-state.good.ts +19 -0
  29. package/skills/oxlint-effect/assets/effect4/public-errors.bad.ts +20 -0
  30. package/skills/oxlint-effect/assets/effect4/public-errors.good.ts +33 -0
  31. package/skills/oxlint-effect/assets/error-preservation.bad.ts +21 -0
  32. package/skills/oxlint-effect/assets/error-preservation.good.ts +18 -0
  33. package/skills/oxlint-effect/assets/expected-state.bad.ts +28 -0
  34. package/skills/oxlint-effect/assets/expected-state.good.ts +19 -0
  35. package/skills/oxlint-effect/assets/public-errors.bad.ts +20 -0
  36. package/skills/oxlint-effect/assets/public-errors.good.ts +33 -0
  37. package/skills/oxlint-effect/references/configuration.md +117 -0
  38. package/skills/oxlint-effect/references/domain-context.md +84 -0
  39. package/skills/oxlint-effect/references/domain-decisions.md +93 -0
  40. package/skills/oxlint-effect/references/domain-modeling.md +140 -0
  41. package/skills/oxlint-effect/references/error-preservation.md +76 -0
  42. package/skills/oxlint-effect/references/expected-state.md +78 -0
  43. package/skills/oxlint-effect/references/public-errors.md +80 -0
  44. package/skills/oxlint-effect/references/versioned-rules.md +309 -0
@@ -0,0 +1,84 @@
1
+ # Domain Context, Time, And Failure Ownership
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ Read the paired [failures](../assets/domain-context.bad.ts) and
9
+ [repairs](../assets/domain-context.good.ts). The three annotated failures are
10
+ checked against the full DDD preset; the passing control also typechecks.
11
+
12
+ ## Explicit Context
13
+
14
+ `linteffect/no-domain-meaning-by-folder-only` detects contextual function names
15
+ around raw identifiers. It does not inspect access-control correctness. A
16
+ branded ID can satisfy this detector without establishing caller authority.
17
+
18
+ The repair reuses `UserId` and requires a `DeletionPolicy` service. The operation
19
+ consults that policy before returning the target ID. Tests supply an allowing
20
+ policy and a denying policy; the original denial object propagates unchanged.
21
+ The negative type fixture proves that the service requirement cannot be treated
22
+ as an environment-free Effect.
23
+
24
+ This is an authorisation-contract example, not a user-deletion implementation.
25
+ There is no persistence write in either control. The original helper always
26
+ succeeded; adding denial is a deliberate policy change, not behaviour-preserving
27
+ refactoring. In a consumer, reuse its established policy and principal context,
28
+ and retain the actual protected operation after authorisation. Resolve the
29
+ authenticated actor at a trusted boundary; never supply an allowing policy based
30
+ on an untrusted request flag. A caller can still provide an unsafe service.
31
+ Neither a tag nor a clean lint run proves access control or prevents races
32
+ between checking a policy and writing data.
33
+
34
+ ## Time Ownership
35
+
36
+ `linteffect/no-new-date-in-domain-logic` reports Date construction outside its
37
+ configured boundaries in Effect-importing files, including conversion of a
38
+ supplied timestamp. Determine whether the code reads time or converts a value
39
+ before selecting a repair. Do not enable boundary exemptions merely to hide a
40
+ domain clock read.
41
+
42
+ The control accepts a modelled `EpochMillis` input and compares it with a lease's
43
+ expiry. This example chooses inclusive expiry (`now >= expiresAt`); tests cover
44
+ before, at, and after the threshold, negative timestamps and fractional values.
45
+ This slice deliberately requires finite instants: its decoder rejects `NaN` and
46
+ both infinities, and the comparison validates both clock and expiry inputs even
47
+ when an earlier, broader decoder supplied the branded value. The shared time
48
+ shape example remains unconstrained. This finite-value policy is a chosen
49
+ validation change; confirm the consumer's sentinel and malformed-input contracts
50
+ before adopting it. Runtime validation throws synchronously in this pure fixture;
51
+ an application must own that failure path rather than silently treating malformed
52
+ time as an unexpired lease.
53
+ This is a deterministic replacement direction for a hidden clock read, not an
54
+ equivalent implementation of the bad file's timestamp-returning helper.
55
+ Preserve the consumer's comparison, return shape and call sites when repairing.
56
+
57
+ Obtain time once at the owning boundary using the consumer's Effect Clock
58
+ convention, then pass it into pure decisions. Alternatively read Clock within an
59
+ Effect and control it through the project's test-clock setup. Avoid mixing
60
+ seconds, milliseconds and durations. The brand prevents accidental typed
61
+ interchange but cannot detect a caller providing seconds to the number decoder.
62
+ The fixture's synchronous decoder throws on malformed values; application
63
+ boundaries should use their established Effect-returning decoding/error policy.
64
+
65
+ ## Structured Failure Context
66
+
67
+ `linteffect/no-empty-error-tag` is a strict payload rule. The example retains
68
+ `DeletionDenied` while adding the target `userId` and policy `reason`, which a
69
+ caller can use for recovery or diagnosis. Tests assert tag, fields and identity
70
+ through the failure channel, without reducing the error to its message.
71
+
72
+ Choose fields from actual caller needs, not to satisfy a non-empty shape. Update
73
+ error constructors, recovery handlers and public adapters together. Preserve
74
+ existing causes and external representations where required; never expose
75
+ sensitive policy details in public responses just because they exist internally.
76
+ When a tag represents ordinary expected state with no useful failure context,
77
+ assess a result variant or Option instead of adding placeholder fields.
78
+
79
+ ## Evidence Limits
80
+
81
+ These checks establish fixture diagnostics, type contracts and selected runtime
82
+ behaviour. They do not qualify production authorisation, clock integration,
83
+ storage effects, or agent-generated repairs. Preserve intentional `EXPECT`/`QA`
84
+ failures and verify repairs under the consumer's entire configured lint policy.
@@ -0,0 +1,93 @@
1
+ # Domain Variants, Predicates, And State Machines
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ Read the paired [failures](../assets/domain-decisions.bad.ts) and
9
+ [repairs](../assets/domain-decisions.good.ts). Each failure has one intentional
10
+ DDD diagnostic; the complete repair is linted with the full `ddd` preset.
11
+
12
+ ## Domain Vocabulary
13
+
14
+ `linteffect/no-magic-domain-string` flags raw status comparisons. The example
15
+ uses a named `OrderStatus` schema with the same lowercase wire literals. A
16
+ schema-backed `isApproved` predicate answers the existing approval question.
17
+ The operation accepts the decoded domain type, not arbitrary status strings.
18
+
19
+ Supported values retain their original decisions. An unknown status previously
20
+ compared false; the new decoder rejects it. This is a boundary-contract change,
21
+ not automatically a correct consumer migration. Determine whether unknown
22
+ statuses represent malformed input, forward-compatible protocol values, or a
23
+ legitimate domain variant. Preserve supported wire values and case sensitivity;
24
+ reuse existing schemas instead of inventing a vocabulary.
25
+
26
+ ## Business Predicates
27
+
28
+ `linteffect/no-domain-logic-in-conditional` detects three or more comparisons
29
+ combined in a logical expression. Extracting the same expression into a named
30
+ function can still trigger the detector. Give each invariant a name and compose
31
+ the predicates meaningfully, rather than obscuring the expression to dodge lint.
32
+
33
+ The repair names the minimum-total, minimum-item-count, and discount-cap
34
+ predicates and composes them using `Predicate.struct`. The thresholds remain
35
+ `total > 100`, `itemCount >= 2`, and `discountPercentage <= 20`. Tests compare
36
+ the old and new decisions across threshold combinations, NaN, and Infinity.
37
+ The example predicates are pure; no effectful calls are moved or reordered.
38
+
39
+ For a consumer, preserve comparison direction, inclusivity, short-circuit
40
+ behaviour, and evaluation order. Do not split effectful checks into an eager
41
+ collection or run validations in parallel without a separate business reason.
42
+ Name predicates for domain invariants, not individual AST nodes. The consumer
43
+ still owns its currency, rounding, and validation policy.
44
+
45
+ ## Lifecycle States And Transitions
46
+
47
+ `linteffect/no-implicit-state-machine-object` warns when multiple lifecycle
48
+ flags are inspected together. It does not discover valid states or transitions.
49
+ Recover those contracts from the application and its tests before changing the
50
+ model. Multiple flags may be independent facts rather than mutually exclusive
51
+ states; a tagged union is appropriate only when exclusivity is established.
52
+
53
+ The example's chosen lifecycle has these states:
54
+
55
+ | Variant | Legacy flags | Allowed transition |
56
+ | --- | --- | --- |
57
+ | Open | `cancelled: false`, `shipped: false` | Ship or cancel |
58
+ | Shipped | `cancelled: false`, `shipped: true` | Terminal in this example |
59
+ | Cancelled | `cancelled: true`, `shipped: false` | Terminal in this example |
60
+
61
+ `Schema.TaggedStruct` defines the variants. `shipOrder` and `cancelOrder` require
62
+ `Open`, and runtime validation rejects terminal input even if a JavaScript
63
+ caller bypasses the TypeScript contract. Compile-time tests reject forbidden
64
+ transitions and extra flags on a fresh literal. TypeScript's structural typing
65
+ still allows extra fields through an intermediate variable, as another fixture
66
+ demonstrates. Runtime validation rejects extra fields during transition and
67
+ legacy encoding, including contradictory flags attached to an otherwise valid
68
+ tag. The type alone does not guarantee an exact object shape. Runtime tests
69
+ exercise both allowed transitions and both terminal rejections.
70
+
71
+ The legacy decoder accepts exactly the three supported boolean combinations.
72
+ The encoder uses exhaustive tagged matching to preserve those flag payloads.
73
+ `cancelled: true` together with `shipped: true` is rejected rather than silently
74
+ choosing one state. A consumer must explicitly decide how to migrate existing
75
+ contradictory persisted records. Never arbitrarily prioritise one flag.
76
+
77
+ The adapter handles a flags-only envelope and rejects excess properties. Keep
78
+ other order data and supported extension fields through the consumer's actual
79
+ record adapter; do not feed a full record into this example and discard fields.
80
+ The example terminal-state policy is not a rule that all orders must follow.
81
+ Refund, return, or post-shipping cancellation may require additional variants
82
+ and transitions in the consumer.
83
+
84
+ ## Boundary Errors And Evidence
85
+
86
+ Synchronous schema decoders/validators throw parse errors in these fixtures.
87
+ In an Effect application, map boundary or transition validation failures through
88
+ the existing typed error channel, using `Schema.decodeUnknown`/`Schema.validate`
89
+ as appropriate. Do not introduce unchecked throws in Effect workflows.
90
+
91
+ The tests prove the stated example contracts, exact rule IDs/counts, and clean
92
+ DDD controls. They do not prove authorization, business completeness, safe
93
+ database migration, or correct agent repairs in arbitrary repositories.
@@ -0,0 +1,140 @@
1
+ # Domain Modeling And Structured Errors
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ These are syntax-based design-smell detectors. Confirm the installed rule's
9
+ documented trigger and the actual business contract before deciding on a repair.
10
+ `ddd` includes both domain and error modeling; `domainModeling` is narrower.
11
+
12
+ ## Repair Decisions
13
+
14
+ | Rule | Domain question | Preferred direction |
15
+ | --- | --- | --- |
16
+ | `linteffect/no-raw-domain-id-alias` | Can IDs from different concepts be interchanged accidentally? | Reuse a branded schema or type; decode at the boundary and keep the brand through callers. |
17
+ | `linteffect/no-raw-domain-primitive-params` | Which arguments have distinct meaning, units, or invariants? | Model meaningful values or a typed command; preserve argument order and validation semantics. |
18
+ | `linteffect/no-boolean-domain-flag` | What does each boolean value make the operation do? | Name the existing modes explicitly; map both old values at callers. |
19
+ | `linteffect/no-magic-domain-string` | Is this a domain variant or an external protocol value? | Reuse a schema/literal union or tagged variant; parse external strings once. |
20
+ | `linteffect/no-raw-time-domain-field` | Is this an instant, duration, or timestamp in a particular unit? | Reuse the project's time value type and convert at boundaries without changing units or timezone behaviour. |
21
+ | `linteffect/no-overloaded-options-object` | Which combinations are valid? | Introduce a schema or discriminated command with the existing allowed combinations. |
22
+ | `linteffect/no-domain-logic-in-conditional` | What invariant does this expression implement? | Extract a named predicate or validation operation with the same truth table. |
23
+ | `linteffect/no-implicit-state-machine-object` | Which states and transitions are actually reachable? | Model mutually exclusive states as variants; preserve transitions and persistence adapters. |
24
+ | `linteffect/no-adhoc-domain-error` | What information does a caller need to recover? | Use the existing structured error convention and preserve its cause/context. |
25
+ | `linteffect/no-domain-meaning-by-folder-only` | Where is caller authority or bounded-context identity established? | Reuse an explicit capability/context or service contract. A name or brand alone is not authorization. |
26
+ | `linteffect/no-new-date-in-domain-logic` | Does the operation read the clock or convert an existing timestamp? | Inject a clock/time value using the project's Effect conventions; preserve conversions. |
27
+
28
+ ## Paired Examples
29
+
30
+ Read [domain.bad.ts](../assets/domain.bad.ts) and
31
+ [domain.good.ts](../assets/domain.good.ts) together. The failure file has three
32
+ intentional annotated warnings; the repair is checked under the full `ddd`
33
+ preset and both files typecheck against this repository's Effect dependency.
34
+
35
+ 1. `UserId = string` becomes a schema brand with a boundary decoder. The example
36
+ adds a non-empty invariant for illustration. Do not introduce that validation
37
+ in a consumer unless its contract already requires it.
38
+ 2. `shouldNotifyCustomer` becomes `NotificationMode`. `true` maps to `Notify` and
39
+ `false` to `Silent`; the payload still uses the existing boolean representation.
40
+ The named modes improve the operation contract without changing the payload.
41
+ 3. A string transfer failure becomes `TransferRejected` with operation context.
42
+ This changes the error-channel representation: update consumers and adapters
43
+ together and retain any externally required message/cause semantics.
44
+
45
+ Branding prevents accidental type interchange; it does not validate input at
46
+ runtime. A schema decoder validates at the point where untrusted data enters.
47
+ Do not manufacture branded values with type assertions.
48
+
49
+ For paired examples of status variants, composed predicates, and explicit
50
+ lifecycle states, read [domain decisions](domain-decisions.md). That guide
51
+ separates preserved decisions from boundary and transition policy changes.
52
+
53
+ ## Commands, Time, And Options
54
+
55
+ Read [domain-shapes.bad.ts](../assets/domain-shapes.bad.ts) and
56
+ [domain-shapes.good.ts](../assets/domain-shapes.good.ts) together. These add
57
+ three intentional warnings and a full-DDD clean control:
58
+
59
+ 1. `linteffect/no-raw-domain-primitive-params`: positional transfer arguments
60
+ become a schema-backed `TransferCommand` with named fields and branded
61
+ accounts/amount. The decoder and encoder keep the existing field names and
62
+ numeric values. The example does not invent positive-amount or non-empty-ID
63
+ rules. Both accounts share a brand, so this does not prove that the caller
64
+ selected the correct source and destination. Check caller intent as well as
65
+ typechecking. Update existing positional callers to construct the command.
66
+ 2. `linteffect/no-raw-time-domain-field`: `expiresAt` uses an `EpochMillis`
67
+ brand and a schema codec. This example's wire contract is milliseconds since
68
+ the Unix epoch, including fractional values. Encoding preserves the value;
69
+ it does not read the clock or convert to seconds. A brand expresses the unit
70
+ but cannot detect a caller sending seconds as an ordinary number. For elapsed
71
+ time or timeouts use the project's `Duration` model instead. Never substitute
72
+ a duration for an absolute instant. Choose range/precision constraints only
73
+ when they are part of the consumer's existing contract.
74
+ 3. `linteffect/no-overloaded-options-object`: `PaymentIntent` names invoice ID,
75
+ amount, and optional memo. Omitted, explicitly undefined, empty, and populated
76
+ memos are covered by tests. The example decoder rejects extra properties
77
+ explicitly so that accidental fields are not silently discarded. This is a
78
+ chosen example policy, not equivalent to accepting arbitrary `any` values.
79
+ Confirm required fields, nullable versus optional fields, and extension-field
80
+ behaviour before applying a schema to a consumer. Preserve supported
81
+ extensions explicitly when required.
82
+
83
+ The synchronous decoders here make fixture validation observable as thrown
84
+ parse errors. In Effect application boundaries, use `Schema.decodeUnknown` and
85
+ map parse errors through the consumer's existing error contract as appropriate.
86
+ Do not move throwing decoders into Effect domain logic without owning that
87
+ failure path.
88
+
89
+ The tests also compile negative type examples: raw primitives cannot bypass the
90
+ transfer command, an account ID cannot fill the time field, and payment options
91
+ cannot omit the required amount. Runtime roundtrips cover zero, negative and
92
+ fractional numbers; business limits must still be decided by the application.
93
+
94
+ ## Error Modeling Within DDD
95
+
96
+ Read [public errors](public-errors.md) for paired public-channel failures and
97
+ repairs, cause preservation, and selective recovery tests.
98
+
99
+ Read [domain context](domain-context.md) for paired examples of explicit policy
100
+ requirements, modelled clock input, and meaningful tagged failure payloads.
101
+ The guide distinguishes detector acceptance from authorisation and makes the
102
+ example's deliberate policy changes explicit.
103
+
104
+ For `linteffect/no-error-as-public-effect-error`,
105
+ `linteffect/no-unknown-public-error-channel`, and
106
+ `linteffect/no-mixed-effect-error-shapes`, identify the operation's expected
107
+ failure variants. Use the existing tagged error model with meaningful fields.
108
+ Do not replace an unknown failure with an invented domain error or discard its
109
+ cause just to narrow the annotation.
110
+
111
+ For `linteffect/no-empty-error-tag`, supply fields callers actually need; avoid
112
+ placeholder payloads. For `linteffect/no-expected-state-as-error`, distinguish
113
+ ordinary absence/state from a failed operation before choosing `Option`, a
114
+ variant, or an error.
115
+
116
+ Read [expected state](expected-state.md) for absence, broad null-recovery and
117
+ thrown-rejection pairs, including explicit caller and failure-channel changes.
118
+
119
+ For `linteffect/no-effect-fail-error-message`, retain the structured failure
120
+ instead of reducing it to text. For `linteffect/no-catchall-generic-rethrow`,
121
+ `linteffect/no-log-only-error-handling`, `linteffect/no-early-catchall-null`, and
122
+ `linteffect/no-exception-domain-error`, establish who owns recovery and what
123
+ must remain observable. Prefer selective tagged recovery where supported by
124
+ the installed Effect version. Logging alone does not establish recovery.
125
+
126
+ Read [error preservation](error-preservation.md) for paired message-loss,
127
+ generic-rethrow and log-only failures, with identity and executed-logging tests.
128
+ It also documents the heuristic's legitimate `tapError` observation case.
129
+
130
+ ## Verification Boundaries
131
+
132
+ Test decoding failures, identifier interchange, both behaviour modes, every
133
+ supported state transition, and callers that inspect error payloads as relevant
134
+ to the repair. Run the selected DDD rules and the consumer's complete configured
135
+ lint policy: a DDD-clean example may still violate a different selected group.
136
+
137
+ Keep fixtures marked `EXPECT`/`QA` intentionally failing. If the rule misses its
138
+ annotated pattern, report a detector/example discrepancy; do not change business
139
+ code just to provoke a warning. A passing heuristic check is not evidence of
140
+ aggregate invariants, access control, or cross-file type correctness.
@@ -0,0 +1,76 @@
1
+ # Recovery Ownership And Error Preservation
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ Read the paired [failures](../assets/error-preservation.bad.ts) and
9
+ [repairs](../assets/error-preservation.good.ts). These wrap a supplied profile
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.
12
+
13
+ | Rule | Question before repair | Example direction |
14
+ | --- | --- | --- |
15
+ | `linteffect/no-effect-fail-error-message` | Do callers expect a structured error or a string? | Preserve the original tagged error instead of failing with its message. |
16
+ | `linteffect/no-catchall-generic-rethrow` | Does the adapter need a new public error contract? | Remove an erasing handler when the original tagged contract is already appropriate. |
17
+ | `linteffect/no-log-only-error-handling` | Is this observation or owned recovery? | When failure must propagate, execute logging and then re-fail with the original error. |
18
+
19
+ ## Preserve Details, Not Just Text
20
+
21
+ `rejectProfile` fails with the supplied `ProfileUnavailable` rather than its
22
+ message. Tests assert original error identity, tag and cause. Changing from a
23
+ string error channel to a tagged one changes callers' contract: migrate their
24
+ comparisons, recovery and public adapters together. Do not assume the tagged
25
+ wrapper's message is its cause's message or expose internal causes publicly.
26
+
27
+ `rethrowProfile` removes the generic catch-all replacement and returns the
28
+ original Effect. Its success value and typed failure pass through unchanged.
29
+ This does not preserve the bad wrapper's generic Error representation. If a
30
+ consumer deliberately owns a different boundary error, use its established
31
+ mapping while retaining the original cause; see [public errors](public-errors.md).
32
+ Do not introduce redundant catch-and-re-fail code when no observation or mapping
33
+ is needed.
34
+
35
+ ## Observation Is Not Recovery
36
+
37
+ The bad `observeProfile` uses `catchAll` with `Effect.logError`. A successful
38
+ logging Effect recovers the original typed failure to successful void. The good
39
+ example chooses propagation instead: its handler yields logging, then yields
40
+ `Effect.fail(error)`. Tests capture one log entry containing the original error,
41
+ assert the same failure reaches the caller, and verify successes do not log.
42
+ Logging must actually be sequenced: merely constructing an Effect in a handler
43
+ does not execute it.
44
+
45
+ This is a chosen ownership change, not equivalent recovery. If the consumer's
46
+ boundary intentionally owns recovery to void, retain that contract until the
47
+ owner decides otherwise. Choose a fallback or result variant only from its
48
+ business requirements. Never replace successful recovery with failure solely
49
+ to clear a diagnostic.
50
+
51
+ `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.
54
+ Report that detector/policy mismatch when this is legitimate observation. Do not
55
+ put `Effect.fail(error)` inside `tapError` just to satisfy the rule: a failing
56
+ observer can alter the resulting cause. Do not add wrappers, casts or suppression
57
+ to conceal the warning. Investigate the policy separately from changing runtime
58
+ semantics. The full-DDD control uses an explicit catch/log/re-fail handler to
59
+ demonstrate failure ownership, not to prescribe replacing every tap observer.
60
+
61
+ If logging itself fails or defects, the original error is not guaranteed to be
62
+ the resulting failure. These examples use Effect's built-in logging with a
63
+ successful logger; test the consumer's real observer contract separately.
64
+ Avoid logging secrets or duplicating the same event at several ownership layers.
65
+
66
+ ## Verification Boundaries
67
+
68
+ The paired examples and negative types verify structured failures and a
69
+ non-void success channel. They do not establish complete production recovery,
70
+ logging delivery, redaction or transport compatibility. Recovery operators here
71
+ handle typed failures, not defects or interruptions. Preserve that distinction
72
+ and test it when adapting real boundaries.
73
+
74
+ Keep `EXPECT`/`QA` examples intentionally failing. Run both the focused DDD
75
+ policy and the consumer's complete lint configuration on repairs. A clean
76
+ heuristic result is not proof that an observer or recovery handler is correct.
@@ -0,0 +1,78 @@
1
+ # Expected State And Failure Boundaries
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ Read the paired [failures](../assets/expected-state.bad.ts) and
9
+ [repairs](../assets/expected-state.good.ts). Three targeted rules produce four
10
+ diagnostics: the string `NotFound` also triggers `no-adhoc-domain-error`. The
11
+ test checks that overlap explicitly rather than suppressing it. The passing
12
+ control is clean under full DDD.
13
+
14
+ | Rule | Contract question | Fixture direction |
15
+ | --- | --- | --- |
16
+ | `linteffect/no-expected-state-as-error` | Is absence ordinary state or a failed requirement? | Model optional UI selection as Option in the success channel. |
17
+ | `linteffect/no-early-catchall-null` | Is missing data being confused with infrastructure failure? | Preserve profile failures until their recovery owner handles them. |
18
+ | `linteffect/no-exception-domain-error` | Is the thrown condition a documented expected rejection or an unexpected defect? | Put the expected checkout rejection in the typed failure channel. |
19
+
20
+ ## Ordinary Absence
21
+
22
+ The fixture accepts a string or undefined selection. `undefined` becomes None;
23
+ all supplied strings, including the empty string, become Some. No non-empty
24
+ validation or new selection policy is introduced. The repair deliberately
25
+ changes the old string failure into successful Option data and wraps present
26
+ values too. Update consumers from catch-based absence handling to explicit
27
+ Option handling and preserve their UI behaviour at the owning boundary.
28
+
29
+ The rule recognises particular string failure names, not domain semantics. A
30
+ failed mandatory lookup may legitimately be an error, while optional absence is
31
+ data. Establish that distinction before applying this example. Do not merely
32
+ rename `NotFound` or add a meaningless payload to evade the detector. Reuse the
33
+ consumer's existing Option, result variant or error convention.
34
+
35
+ ## Failed Lookup Is Not Missing Data
36
+
37
+ The bad profile adapter recovers every typed failure to null. It cannot
38
+ distinguish absence from unavailable storage. The repair removes that recovery
39
+ and propagates the same tagged failure, preserving successes. This intentionally
40
+ changes the bad adapter's error and success contracts: null is no longer a
41
+ successful fallback. Callers must now own the propagated failure.
42
+
43
+ Do not substitute Option.none for every caught failure; that still conceals
44
+ infrastructure errors. If an upstream contract separately represents actual
45
+ missing data, map that recognised variant selectively and let other failures
46
+ propagate. Do not infer retryability or absence from an opaque cause or error
47
+ message. If null recovery is deliberate at an established boundary, preserve
48
+ that contract until its owner approves a change. The rule has configurable
49
+ boundary paths; configure real boundaries, not exemptions to hide domain logic.
50
+
51
+ ## Expected Rejection Versus Defect
52
+
53
+ Both checkout controls use the same `CheckoutRejectedError` with a reason.
54
+ Throwing it inside `Effect.gen` creates a defect. The repair uses `Effect.fail`
55
+ so typed recovery can recognise the documented expected rejection. Tests verify
56
+ the original defect and the repaired failure separately and retain tag and
57
+ reason. This is a deliberate channel change, not runtime equivalence.
58
+
59
+ Do not convert programmer bugs, invariants unexpectedly violated or arbitrary
60
+ exceptions into domain failures just because an error class ends with Error.
61
+ The detector uses syntax and naming, not knowledge of expected outcomes. Reuse
62
+ existing failure variants and update recovery, supervision and transport
63
+ adapters with the consumer's contract. Converting a defect to a typed failure
64
+ changes which handlers run; agree that classification before repairing.
65
+
66
+ ## Coverage And Limits
67
+
68
+ With this pair, the companion corpus has annotated failures for every exported
69
+ DDD rule. A coverage test compares the unique annotation IDs with `dddRules`,
70
+ and each pair checks exact observed diagnostics, clean repairs, packaging and
71
+ TypeScript contracts. This covers representative patterns, not every detector
72
+ variant or every business interpretation. Negative types reject raw absence,
73
+ swallowed profile failures and an invisible checkout failure channel.
74
+
75
+ These are lint-only fixtures, not a production UI, storage implementation or
76
+ checkout service. Verify real caller migration and boundary behaviour in the
77
+ consumer. Keep intentional `EXPECT`/`QA` failures and do not confuse a clean
78
+ heuristic run with semantic correctness.
@@ -0,0 +1,80 @@
1
+ # Public Error-Channel Contracts
2
+
3
+ API examples in this reference retain the labelled legacy Effect 3 corpus.
4
+ For Effect 4 use [versioned guidance](versioned-rules.md) and the paired
5
+ current assets linked from the skill entrypoint. Preserve the domain contract,
6
+ not legacy API spelling; matching packed consumers verify both corpora.
7
+
8
+ Read the paired [failures](../assets/public-errors.bad.ts) and
9
+ [repairs](../assets/public-errors.good.ts). Each is an adapter around an injected
10
+ Effect, not a working profile, session or inventory service. The failing control
11
+ has exactly three DDD diagnostics; the passing control is clean under full DDD.
12
+
13
+ | Rule | Contract to establish | Repair direction |
14
+ | --- | --- | --- |
15
+ | `linteffect/no-error-as-public-effect-error` | Which operation failed, and what do callers inspect on the existing Error? | Reuse an operation-specific tagged error and preserve the original error as its cause. |
16
+ | `linteffect/no-unknown-public-error-channel` | Is the upstream failure understood or still opaque? | Wrap opaque typed failures with operation context; keep their original value without inventing a business classification. |
17
+ | `linteffect/no-mixed-effect-error-shapes` | What does each upstream shape mean? | Map documented alternatives into a consistent tagged union with their payloads intact. |
18
+
19
+ ## Mapping And Caller Migration
20
+
21
+ `loadProfile` maps an existing typed Error to `ProfileUnavailable`, preserving
22
+ the exact object in `cause`. The tag is a chosen fixture contract, not proof that
23
+ every failure means missing data or permits retry. A caller reading the old
24
+ error's message must now deliberately inspect `cause.message` or use its existing
25
+ public error adapter. The wrapper's own message is not guaranteed to be the old
26
+ message; update serialisation, logging and recovery sites together.
27
+
28
+ `refreshSession` maps an opaque typed failure to `SessionRefreshFailed`. Its
29
+ `cause` remains unknown, including null, undefined, primitives and opaque objects.
30
+ The cause field must be present even when its value is undefined. The caller can
31
+ recover at the operation level by tag, but must narrow the cause before inspecting
32
+ it. Do not cast it to Error, stringify away its payload, or classify it as an
33
+ authentication/business error without an established upstream contract.
34
+
35
+ `readInventory` uses this fixture's explicit adapter convention: strings mean
36
+ validation details, numbers mean upstream codes. They become `InventoryRejected`
37
+ and `InventoryUnavailable`, respectively. This convention is not inferred by
38
+ the linter and must not be copied into a consumer with different semantics.
39
+ Empty strings, zero, negative codes and NaN are preserved by the example; it does
40
+ not add status-range or non-empty validation. Validate codes separately only when
41
+ required by the existing adapter contract.
42
+
43
+ All three repairs change the error-channel representation while preserving
44
+ successes. They are not drop-in, behaviour-preserving replacements for callers
45
+ that rely on primitive errors, instanceof Error, messages or serialized fields.
46
+ Reuse established error classes and operation context rather than introducing
47
+ duplicate error taxonomies. If the upstream already has an appropriate tagged
48
+ union, preserve it instead of wrapping every failure again.
49
+
50
+ ## Selective Recovery And Defects
51
+
52
+ Use `Effect.catchTag` to recover only from the variant owned by the caller. The
53
+ tests recover `InventoryRejected` to a test-only sentinel and prove that an
54
+ `InventoryUnavailable` passes through unchanged. That sentinel is not a suggested
55
+ production inventory fallback: select recovery from the consumer's contract.
56
+ Negative type examples reject raw public failures and unrelated recovery tags.
57
+
58
+ The adapters use `Effect.mapError`: they transform typed failures, not defects,
59
+ interruptions or the success channel. Unexpected throws remain defects. Do not
60
+ convert all causes to expected domain failures with catch-all cause recovery
61
+ merely to satisfy an annotation. When adapting a throwing API, decide at its
62
+ boundary which failures are expected and preserve unexpected-defect behaviour.
63
+
64
+ Causes may contain secrets or implementation details. Keeping a cause for internal
65
+ diagnosis does not authorise exposing it in a public response. Retain the
66
+ consumer's redaction and transport-error policy, and test public representations
67
+ where that is part of the repair.
68
+
69
+ ## Verification Limits
70
+
71
+ The detectors inspect supported syntax in public Effect annotations, not the
72
+ meaning of every runtime failure or cross-file alias. Removing an annotation,
73
+ hiding a union behind an alias, adding a cast or suppressing the diagnostic is
74
+ not a repair. A clean run does not establish exhaustive business recovery.
75
+
76
+ Tests verify successes, original cause identity, both mixed variants, selective
77
+ recovery, unchanged defects and interruptions; fixtures also typecheck under the repository's Effect
78
+ version. In a consumer, verify the installed version and test real callers,
79
+ transport adapters and defect/interruption behaviour as applicable. Preserve
80
+ the intentionally failing `EXPECT`/`QA` corpus.