Repository navigation
0.18 PR6: drop sentinel and onUndefined policy - #33
Conversation
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
left a comment
There was a problem hiding this comment.
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'sseries(..., {onUndefined: 'error'})inside another copy'sserieswithstrategy: collect; the outer copy does not recognize the brand and collects the error. Plan-prescribed, but it contrasts with the cross-copy motivation forSymbol.forondropitself. - LOW —
onUndefineddiagnostics name the engine, not the wrapper:mapSeries(xs, fn, {onUndefined: 'keep'})rejects withseries() onUndefined must be 'drop' or 'error', and the fatal message hardcodesseriesSync() mappereven when raised throughmapSeriesSync(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:169still says "undefinedis the drop sentinel" and omitsdrop;docs/examples.md:126,243still useundefinedas 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
onUndefinedthroughmapSeries/mapSeriesSync, or fatality underfailFast/failLate/skip/rethrow; those were verified by reviewer probe only. - INFO —
filter/filterSyncstill acceptonUndefinedsilently (it has no effect there, since their transform returnsdrop). 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.jsandtests/drop-sync.test.js, consistent with the repo's twin-test layout.
CI: green — the test check (Code Check workflow) succeeded.
Plan:
/home/della/.opencode/plan/pipelean-0.18.md§PR 6 (bridge release, additive only).What
src/sentinel.js:drop = Symbol.for('pipelean.drop')(the only public export, viasrc/index.js),isDrop,normalizeOnUndefined, a branded fatalundefinedPolicyError,assertNotDrop.onUndefinedis read only by the series family (series/mapSeries+ sync twins) throughplanSeries. Default'drop':undefinedstill drops, so 0.18 changes no behaviour.'error'is an opt-in fatalTypeError.runAsyncStrategycatch beforefailOnSource, sync step catch,runSyncStrategycatch) so it can never be collected intoerrors/sourceErrors/failure. Mutation-checked.dropacross consumers: series/mapSeries drop the item (noonProgress);pipe/pipeSyncshort-circuit and return the sentinel unchanged;filter/filterSyncreturndropon exclusion;findSync/wheretreatdropas falsy (a symbol is truthy);assignmaps it to{};enrich/enrichSyncreject adroppatch with a dedicated step error; folds andjoinkeep it as an ordinary value.tryCatchneeds no code:recover: () => dropcomposes with pipe/series (tested).Not in this PR
PR 7 (rejecting unsupported options —
filterstill forwards an inertonUndefined), PR 8 (docs IA), the 0.19 warning phase, the 1.0 default flip,findSync.resultremoval.Tests
New
tests/drop.test.js+tests/drop-sync.test.js(+37 cases). No existing test changed.Gates (local)
yarn lintexit 0yarn vitest run75 files / 1050 tests passedyarn checkexit 0 (jsinspect 0, jscpd 0 clones, knip clean)Note:
enrich.jssits at the 180-line gate, so the drop-patch guard lives insentinel.jsasassertNotDrop(value, message).