HarperFast / HarperFast/harper
Support not(...) group and scope negation in REST query syntax (RQL 2.0 §5.4)
- Dominant language
- JavaScript
- Stars
- 89
- Forks
- 10
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 200
Description
RQL 2.0 (§5.4, [spec](https://github.com/HarperFast/rql/blob/kris/rql-v2/specification/rql-2.0.md)) defines `not(body)` as logical negation of a group, condition, or element scope, valid in any term position:
```
status=open¬(tag=urgent|tag=blocked)
not(scores[=ge=10&=le=20]) ; no element in the range
```
It is pure parse-time sugar — no execution or planner changes required. Desugaring (De Morgan, meaning-preserving because negation is set complement):
- `not(condition)` toggles the condition's negated flag (`not_` prefix equivalent)
- `not(and-group)` → or-group of negated terms; `not(or-group)` → and-group of negated terms (recursive)
- `not(scoped-match)` toggles the element-scope negation (as `not_between` already does internally)
- nested `not` cancels
Harper implementation surface: the query-string parser in resources/search.ts — recognize `not(` in term position (it is not a call function; §5.6's closed call set is unaffected), parse the inner group-body, and apply the toggles onto the existing conditions/chainedConditions representation (negated flags already exist on conditions).
Reference implementation and conformance tests: HarperFast/rql branch kris/rql-v2 (`src/parser.ts`, `test/v2/`).
Contributor guide
Research direction
Start in resources/search.ts and compare its query-string parsing with src/parser.ts on the HarperFast/rql kris/rql-v2 branch. Use the conformance tests in test/v2/ to check group and scope negation, including nested not expressions; done means the parser handles the listed forms without execution or planner changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, search
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100