Skip to content

Add research catalog for the mango query normalizer/optimizer package - #8834

Closed
pubkey wants to merge 7 commits into
masterfrom
claude/mango-query-normalizer-2ynt5l
Closed

Add research catalog for the mango query normalizer/optimizer package#8834
pubkey wants to merge 7 commits into
masterfrom
claude/mango-query-normalizer-2ynt5l

Conversation

@pubkey

@pubkey pubkey commented Jul 21, 2026

Copy link
Copy Markdown
Owner

This PR contains:

  • Research results (a design document under orga/) for the planned npm package that normalizes and optimizes mango queries, as listed in orga/BACKLOG.md ("query normalization and optimization").

Describe the problem you have without this PR

The backlog entry lists six known optimization tricks for the planned package. Before implementing, a deep research pass was done to find more rewrite rules and their correctness conditions. Without this document, the verified findings (MongoDB MatchExpression optimizer rules, MySQL range-extraction interval arithmetic, Calcite RexSimplify null-semantics guards, plan-cache query-shape encoding, and architecture lessons like the SERVER-84013 predicate-order bug) would be lost and the package design would start from the six bullet points alone.

The document catalogs:

  • Schema-free normalization rules (shorthand $eq, $and/$or flattening, deterministic ordering)
  • Schema-free optimizations ($in canonicalization, $or-to-$in fold with collator/regex guards, interval arithmetic, contradiction detection, guarded DNF boolean simplification)
  • Schema-dependent optimizations (enum rewrites, impossible $eq detection, $exists/$type elimination)
  • Index/execution hints (primary-key fast path, prefix-$regex ranges, restrictive operator injection, superset rule for post-filtering)
  • Canonical cache-key generation and correctness caveats (missing-field semantics, array fields, type bracketing, collation)

Todos

  • Implementation of the package in a follow-up PR (this PR is the research step only)

🤖 Generated with Claude Code

https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC


Generated by Claude Code

claude added 7 commits July 21, 2026 14:25
Deep-research results (MongoDB matcher optimizer, MySQL range
optimization, Apache Calcite RexSimplify, CouchDB Mango, RxDB
query-planner) as the design basis for the planned npm package
that normalizes and optimizes mango queries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
Self-contained implementation prompt: API design, full rewrite-rule
catalog with correctness guards, equivalence testing strategy
(mingo, mongodb-memory-server, RxDB memory storage) and performance
test suites measuring optimizer overhead and optimization effect
against MongoDB and RxDB.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
Random data plus random query generation with exact-equal-outcome
checks between optimized and non-optimized queries, across mingo,
MongoDB and RxDB oracles, with seeded reproducibility and shrunk
counterexamples kept as regression fixtures.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
Add a project-setup section that mirrors pubkey/jsonschema-key-compression:
dual tsc build (dist/lib CJS, dist/es ESM), zero runtime dependencies,
mocha + ts-node test scripts, test/unit plus performance test layout,
helper.ts data generators, single GitHub Actions workflow, .npmignore
and .npmrc conventions. Align the test and perf sections with that setup.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
Set the package name in the agent prompt and require mango/mongodb
related npm keywords so the package stays findable for mango query
searches.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
Rename the orga research and agent-prompt docs to the
nosql-query-optimizer name, add a terminology rule to the agent
prompt for all user-facing text, and record the naming preference
in CLAUDE.md: most developers do not know the term 'mango query'.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
The test asserted querySignal.value.length directly after insert(),
but the signal updates asynchronously when the change event has
propagated through the query observable. On slow storages like the
MongoDB storage the emission can happen after the insert() promise
resolves, which made the storage-mongodb CI job fail intermittently.
Wait for the emission like the surrounding assertions already do.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He8qhzAbBoeuG7UE6CbRrC
@pubkey pubkey closed this Jul 22, 2026
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.

2 participants