Arbitrary.schema: no generation override for a struct's cross-field filter, and lookahead patterns are skipped quietly
メンテナーはふだん 1 日以内に返信
@effect-bot がすでに取り組んでいます。
2026年11月9日 から。
評価
この issue はまだ評価されていません。
説明
Version: effect 4.1.1 (effect/Arbitrary; @effect/vitest 4.1.1 it.prop calls Arbitrary.schema on Schema inputs, so it fails the same way).
Two gaps in Arbitrary.schema. Both end in SampleError after 2001 discards.
1. A cross-field filter on a struct has no generation override
import {Arbitrary, Effect, Schema} from "effect";
const Dead = Schema.Struct({
tries: Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)),
errors: Schema.Array(Schema.String).check(Schema.isMaxLength(32)),
}).check(Schema.makeFilter((v) => v.errors.length === v.tries || "one error per try"));
await Effect.runPromise(Arbitrary.sampleEffect(Arbitrary.schema(Dead), {count: 200, seed: 119120}));
// SampleError {generated: 29, discards: 2001}
arbitraryConstraint cannot say "these two fields agree", and toCodecArbitrary is read only on declarations. In v3, an arbitrary annotation on any schema could replace generation. Could a filter, or any node, take a generation override (an Arbitrary, or a toCodecArbitrary-style link)? Today the workaround is to keep a hand-built Arbitrary next to the schema and pass that to it.prop, so the schema and its generator can drift apart.
2. isPattern with a lookahead is skipped quietly
const TraceId = Schema.String.check(Schema.isPattern(/^(?!0{32})[0-9a-f]{32}$/));
await Effect.runPromise(Arbitrary.sampleEffect(Arbitrary.schema(TraceId), {count: 200, seed: 119120}));
// SampleError {generated: 0, discards: 2001}
The pattern is not compiled for generation, so the generator falls back to random strings and the filter discards all of them. Two asks, either helps: support lookahead (or at least a leading negative lookahead), or throw at derivation with an error that names the pattern it could not compile, instead of the discard error at sample time.
Workaround in use: the same set without a lookahead, isPattern(/^[0-9a-f]{32}$/) plus a filter t !== "0".repeat(32), generates 500 of 500 valid values.
- 主要言語
- TypeScript
- スター
- 16.7k
- フォーク
- 808
- 平均マージ
- 17時間 9分
- マージ済み PR(30日)
- 825
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Effect-TS/effect のほかの issue
-
Tuple.map: accept ordinary callbacks while preserving tuple length対応中かも @effect-bot が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
`Cookies` drops same-name cookies set for a different domain or path対応中かも @effect-bot が 2 日前に担当しました。 オープン
Effect-TS/effect#10469 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Schema: a public way to derive a canonical codec, as `toCodecJson` and `toCodecStringTree` do対応中かも @effect-bot が 3 日前に担当しました。 オープンNeeds Proposal schema
Effect-TS/effect#10457 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
McpServer.layerHttp: optional legacy GET SSE for idle list-change notifications対応中かも @effect-bot が 4 日前に担当しました。 オープン
Effect-TS/effect#10436 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
McpServer.layerStdio: native EOF cancellation policy for active tool handlers対応中かも @effect-bot が 5 日前に担当しました。 オープン
Effect-TS/effect#10412 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
Effect-TS/effect の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
home-assistant/frontend#55841 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
lingdojo/kana-dojo#33905 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
bug(semester-planning): the edit application dialog cannot save with an empty «Annet fra bedriften»オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
blocklist removal
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
MetaMask/eth-phishing-detect#311215 ·
メンテナーはふだん 1 日以内に返信
-
Explore filter: multi-select value list with allowNewOptions stops accepting values and drops earlier ones対応中かも @isaac-jaynes-imperva が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/superset#46146 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信