Skip to content

0.18 PR6: drop sentinel and onUndefined policy - #33

Merged
ildella merged 4 commits into
masterfrom
feat-drop-sentinel
Nov 24, 2026
Merged

ildella merged 4 commits into
masterfrom
feat-drop-sentinel

Conversation

@ildella

@ildella ildella commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Plan: /home/della/.opencode/plan/pipelean-0.18.md §PR 6 (bridge release, additive only).

What

  • New internal src/sentinel.js: drop = Symbol.for('pipelean.drop') (the only public export, via src/index.js), isDrop, normalizeOnUndefined, a branded fatal undefinedPolicyError, assertNotDrop.
  • onUndefined is read only by the series family (series/mapSeries + sync twins) through planSeries. Default 'drop': undefined still drops, so 0.18 changes no behaviour. 'error' is an opt-in fatal TypeError.
  • The policy error is branded with a module-private symbol and rethrown at four seams (async item catch, runAsyncStrategy catch before failOnSource, sync step catch, runSyncStrategy catch) so it can never be collected into errors/sourceErrors/failure. Mutation-checked.
  • drop across consumers: series/mapSeries drop the item (no onProgress); pipe/pipeSync short-circuit and return the sentinel unchanged; filter/filterSync return drop on exclusion; findSync/where treat drop as falsy (a symbol is truthy); assign maps it to {}; enrich/enrichSync reject a drop patch with a dedicated step error; folds and join keep it as an ordinary value.
  • tryCatch needs no code: recover: () => drop composes with pipe/series (tested).

Not in this PR

PR 7 (rejecting unsupported options — filter still forwards an inert onUndefined), PR 8 (docs IA), the 0.19 warning phase, the 1.0 default flip, findSync.result removal.

Tests

New tests/drop.test.js + tests/drop-sync.test.js (+37 cases). No existing test changed.

Gates (local)

  • yarn lint exit 0
  • yarn vitest run 75 files / 1050 tests passed
  • yarn check exit 0 (jsinspect 0, jscpd 0 clones, knip clean)

Note: enrich.js sits at the 180-line gate, so the drop-patch guard lives in sentinel.js as assertNotDrop(value, message).

Introduce the registered drop symbol (Symbol.for('pipelean.drop')) as the
explicit drop signal and wire it through every consumer while keeping
undefined dropping by default for 0.18.

- series/mapSeries (+ sync twins) drop on drop, still drop on undefined,
  and accept onUndefined: 'drop' | 'error'. The 'error' policy raises a
  branded fatal TypeError that escapes the strategy and is never collected
  in errors/sourceErrors/failure.
- pipe/pipeSync short-circuit on drop and return the sentinel unchanged.
- filter/filterSync treat drop as falsy; findSync treats it as no match;
  where never matches drop; assign treats a drop parse as a no-op.
- enrich/enrichSync reject a drop patch with a dedicated step error.
- folds and join keep drop as an ordinary value.

Default behaviour is unchanged; onUndefined is only read by the series
family.
Add async and sync suites for the sentinel export, series/mapSeries drops
without onProgress, the fatal onUndefined policy (not collected), eager
validation, pipe/pipeSync short-circuiting, filter/findSync/where/assign
truthiness, enrich step errors, folds/join value preservation, and
tryCatch recover returning drop.
Turn the undefined-sentinel section into the drop sentinel (keeping the
old anchor), add the per-consumer table, and mark onUndefined as a
series-only option. Update the guide, README limitations, architecture
drop signal, FP pipe analogy, skill guidance, and migration with the
0.18 additive notes plus the 1.0 undefined -> drop codemod.
@ildella
ildella marked this pull request as ready for review November 24, 2026 14:55

@ildella ildella left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVED

REVIEW: Both review passes found no medium-or-higher issues. drop is exported as Symbol.for('pipelean.drop') and behaves consistently across series/mapSeries, pipe/tryCatch recover, filter/findSync, where/assign and enrich, while folds and join preserve it as an ordinary value. The default is unchanged (undefined still drops), and onUndefined: 'error' is a fatal branded TypeError that never reaches errors, sourceErrors, failure or the callbacks under any strategy in both async and sync paths. Docs across README, guide, reference, migration, architecture, fp-mapping and skill were updated.

FINDINGS: No medium-or-higher findings. Low/info follow-ups:

  • LOW — the fatal-policy brand uses a module-private Symbol('undefinedPolicy'), not a registered symbol. Trigger: nesting one pipelean copy's series(..., {onUndefined: 'error'}) inside another copy's series with strategy: collect; the outer copy does not recognize the brand and collects the error. Plan-prescribed, but it contrasts with the cross-copy motivation for Symbol.for on drop itself.
  • LOW — onUndefined diagnostics name the engine, not the wrapper: mapSeries(xs, fn, {onUndefined: 'keep'}) rejects with series() onUndefined must be 'drop' or 'error', and the fatal message hardcodes seriesSync() mapper even when raised through mapSeriesSync (the new test asserts that wording). Trigger: any invalid option or fatal undefined on those wrappers; behavior is correct.
  • LOW — stale docs outside the plan's file list: docs/patterns.md:169 still says "undefined is the drop sentinel" and omits drop; docs/examples.md:126,243 still use undefined as the selection/recover signal. Trigger: a reader following them keeps legacy selection and is broken by the 1.0 flip.
  • LOW — no committed test asserts invalid onUndefined through mapSeries/mapSeriesSync, or fatality under failFast/failLate/skip/rethrow; those were verified by reviewer probe only.
  • INFO — filter/filterSync still accept onUndefined silently (it has no effect there, since their transform returns drop). Trigger: passing the option to a filter; PR 7 defers explicit rejection.
  • INFO — user errors can only be misflagged as fatal by deliberately extracting the private symbol from a caught policy error; no accidental path exists.
  • INFO — fixtures are mirrored almost line-for-line between tests/drop.test.js and tests/drop-sync.test.js, consistent with the repo's twin-test layout.

CI: green — the test check (Code Check workflow) succeeded.

@ildella
ildella merged commit 67bf910 into master Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant