feat 185: add array_filter evaluator for compound platform predicates (#185)#425
Merged
feat 185: add array_filter evaluator for compound platform predicates (#185)#425
Conversation
Add PlatformField, CompoundPredicate, and ArrayFilterPredicate types for compound per-element filtering on STAC item platform arrays. Extend FilterExpression with optional arrayFilters field. https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp
Add matchArrayFilter() and evaluateCompound() for per-element compound predicate matching on platforms[]. Supports AND/OR logic, case-insensitive comparison, taxonomy expansion for vessel_class, and negation. Extends engine.matches() to evaluate arrayFilters as AND conditions. 19 new tests covering US1, US3, US4 acceptance scenarios plus edge cases. https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp
Implement serialize/deserialize for array_filter expressions: - compoundPredicateToCql2() and arrayFilterToCql2() for serialization - parseCql2Predicate() and cql2JsonToArrayFilters() for deserialization - NOT-wrapping for negated array_filter expressions - Round-trip fidelity: serialize→deserialize→evaluate produces identical results 13 new tests covering serialization, deserialization, round-trips, and negation. https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp
- Remove unused ArrayFilterPredicate imports from test files - Replace index-signature platform type with PlatformRecord + explicit field accessor for strict type compatibility - Define Cql2Node interface for CQL2 JSON deserialization to reduce unsafe Record<string, unknown> casts https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp
- Evidence: test-summary.md (32/32 pass), usage-example.md, code-example-output.txt - Media: shipped-post.md, linkedin-shipped.md - Mark all tasks complete in tasks.md - Mark backlog item 185 as complete https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp
🚀 Preview DeploymentsCode Server (Full VS Code Extension)Browser-based VS Code with the Debrief extension and sample data pre-installed. Web Shell (Standalone App)Use this for Playwright testing and demos - runs outside Storybook. Storybook (Component Library)Browse all components, stories, and documentation. All Links
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
array_filter()evaluator to the CQL2 filter engine for compound per-element predicates onplatforms[]— eliminates false positives from cross-platform attribute mixing (e.g., "British submarines" no longer matches items where GB and subsurface are on different platforms)array_filterexpressions, enabling round-trip fidelity with the NL-to-CQL2 pipeline (feat: Add nested child selection support with path-based addressing #188)vessel_classmatching and expression-level negation inside compound predicatesChanges
Phase 2: Foundation — Type Definitions
PlatformField,CompoundPredicate(discriminated union),ArrayFilterPredicatetypes totypes.tsFilterExpressionwith optionalarrayFiltersfield (backward-compatible)index.tsPhase 3: US1 — Compound Platform Filtering
evaluateCompound()recursive predicate evaluator inmatchers.tsmatchArrayFilter()per-element matcher inmatchers.tsmatches()inengine.tsto evaluatearrayFiltersas AND conditionsPhase 4: US2 — CQL2 JSON Serialization
compoundPredicateToCql2()andarrayFilterToCql2()serialization incql2-json.tsparseCql2Predicate()andcql2JsonToArrayFilters()deserializationfilterExpressionToCql2Json()to include arrayFilters in outputPhase 5: US3 — Taxonomy Expansion
vessel_classcomparisons inside compound predicates use existingDescendantMapfor hierarchical matchingPhase 6: US4 — Negation
negatedflag onArrayFilterPredicateinverts match (XOR with result)Evidence
Test Results
Key Scenarios Verified
Usage Example
Test Plan
Related
specs/185-cql2-array-filter/spec.mdspecs/185-cql2-array-filter/plan.mdspecs/185-cql2-array-filter/tasks.mdspecs/185-cql2-array-filter/evidence/https://claude.ai/code/session_012oktLgzBZa6Vun213kBdjp