Skip to content

Bind the capabilities the operator tags left unmapped - #4590

Open
evanchooly wants to merge 1 commit into
audits-update-readsfrom
audits-capability-bindings
Open

evanchooly wants to merge 1 commit into
audits-update-readsfrom
audits-capability-bindings

Conversation

@evanchooly

@evanchooly evanchooly commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Stacked on #4589 (audits-update-reads). Step 5 of the plan: bindings for the 102 capabilities the operator tags left UNKNOWN_MAPPING.

Problem

The coverage report left 102 capabilities as UNKNOWN_MAPPING, which is neither published nor counted as present. Two different causes produced them:

  • 77 tokens the manual documents in several contexts:

    • $sum as an accumulator and a window function;
    • $push as an accumulator and an update operator;
    • $avg as an expression, an accumulator and a window function.

    The Morphia factories carry @aggregation.expression $sum, a tag that covers all three aggregation contexts, so inference rightly refused to choose. $merge and $out have their tag on the class rather than the factory method, which inference doesn't read.

  • 25 facets: documented variants of an existing operator, each with its own version, such as $convert to array (8.3), $lookup's concise correlated syntax (5.0) and $out's time-series options (6.3). Facets are never inferred.

Change

  • Bindings, 105 entries in coverage-plan.json:

    • Each multi-context token is bound to the factory that claims it, but only where that factory writes the context's form. I checked this in the encoders.
    • $merge and $out are bound to Merge#merge and Out#out.
    • Facets reachable through the existing API are bound. Some are server behavior only, such as $bsonSize 9.0, $text memory limits and explain output. Others are variants the builder already writes, such as $lookup's concise syntax through Lookup#pipeline and $merge with aggregate-level variables through AggregationOptions#let.
  • Reviewed gaps: a new missing list in the plan records a capability the tagged API claims but can't express. It reports MISSING_TYPED_API with its reason, and the published issue's title carries the reason's first sentence so variants of one operator can be told apart. There are 18:

    Gap Why
    $concatArrays, $setUnion as accumulators and window functions The factories always write an array: {$concatArrays: ["$items"]}, never the accumulator form {$concatArrays: "$items"}
    $top, $bottom, $topN, $bottomN as expressions (8.3) The factories write the accumulator's output, not the expression's input
    $convert to array or object (8.3), to binData (9.0), binary subtypes, format (8.3) ConvertType has no array, object or binData target, and ConvertExpression no format
    arrayIndexAs on $filter and $map (8.3) Neither expression has the option
    $currentOp's targetAllNodes (7.1) CurrentOp lacks the option
    $out time-series options (6.3) Out has no time-series support
    $elemMatch as a projection FindOptions has no elemMatch projection; Filters.elemMatch is the query predicate
  • Comparison rule changes:

    • Wider binding claims: an explicitly bound selector may also claim an operator that the manual documents only in other contexts. UpdateOperators#push(String, List) claims both $push and $each, and previously that made both bindings ambiguous. A claim of another operator in the same context, or of one the manual doesn't document, is still ambiguous.
    • Earliest annotation wins: a declaration that serves several capabilities carries the earliest one's annotation. A missing or earlier annotation for a later variant becomes LATER_VARIANT, which isn't published. For example, ObjectExpressions#mergeObjects serves the accumulator and also the window function added in 8.3, and Lookup#pipeline serves base $lookup and the 5.0 concise form. An annotation newer than the capability's own introduction is still a finding.
    • Facet-only methods: a method that only a facet uses carries the facet's version.
    • Gaps beat inference: a reviewed gap turns inference off for its capability.
  • Core: AggregationOptions#let gains @mongodb.server.release 5.0. Its missing annotation was the one real version finding the new bindings surfaced.

Result at docs e4b0c153

Before After
Typed present 231 315
Missing typed API 14 32
Excluded 32 32
Unknown mapping 102 0

The weekly job would file 32 MISSING_API issues: the 14 new server expressions plus the 18 reviewed gaps. It would file no version findings.

Decisions to review

  1. The missing list is a new plan concept. Before this, the plan had no way to record "reviewed: Morphia can't express this", so facets like these stayed unmapped indefinitely. A gap can't also be bound or excluded, and contract validation rejects that.
  2. Behavior-only facets are bound, not excluded, for example "$text memory limits" and "$planCacheStats output". Morphia expresses the operator, and the server applies the behavior. Excluding them would also have been defensible.
  3. The 18 gaps are candidate core features. Once merged, the weekly job files them as issues. If you'd rather add some of them to Morphia first (arrayIndexAs, $convert targets, $out time series and the expression forms of $top/$bottom), they'd become follow-up PRs.
  4. DSL bindings for generation are separate. $merge, $out and pipeline updates still have no dsl-bindings.json entry, so Run the page's own read after a write #4589's paired reads don't generate yet. That would be its own step.

Testing

  • Audits suite: 442 tests, 0 failures, 4 skipped.
  • New tests cover:
    • reviewed gaps, and their rejection when the capability is also bound;
    • a selector claiming another context's operator;
    • later-context and facet annotation states, including a facet-only method and an annotation newer than the introduction;
    • the gap's issue title.
  • Coverage is reproduced at e4b0c153 against a fresh API inventory of this tree.
  • Local review: three Codex rounds.
    • Round 1 found two bindings that overstated coverage (concatArrays and setUnion as accumulators, and top/bottom as expressions) and an annotation suppression that was too broad.
    • Round 2 found that the facet-base exemption hid a facet-only method's finding.
    • All are fixed. Round 3 was clean.

Self-reviewed only.

Every capability the manual documents is now bound, inferred, excluded
or a reviewed gap. Tokens documented in several contexts are bound to
the factories that write each context's form; contexts and facets the
factories can't write go in the coverage plan's new missing list, which
reports MISSING_TYPED_API with its reason and titles the issue with it.

A selector may also claim an operator the manual documents only in
other contexts, as push with a list claims $each. A declaration that
serves several capabilities carries the earliest one's annotation;
a missing or earlier annotation for a later one is LATER_VARIANT.
AggregationOptions#let gains its 5.0 server annotation.

This branch has not been deployed

No deployments
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