Skip to content

Add recursive arguments support for object-typed arguments - #33

Merged
GromNaN merged 1 commit into
mongodb:mainfrom
GromNaN:recursive-object-arguments
May 4, 2026
Merged

GromNaN merged 1 commit into
mongodb:mainfrom
GromNaN:recursive-object-arguments

Conversation

@GromNaN

@GromNaN GromNaN commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Motivation

Object-typed arguments that have named, fixed sub-properties currently have no way to express their structure beyond a prose description. This forces readers and tooling to parse free-form text to understand what fields are accepted.

Change

Add an optional arguments property to the Argument definition in schemas/operator.json. When an argument's type includes object, it may list its sub-properties as typed Argument entries — recursively, since sub-arguments can themselves be objects with their own arguments.

- name: input
  type:
    - object
  arguments:
    - name: pipelines
      type:
        - pipeline
      variadic: object
      variadicMin: 1

Backward compatibility

The new arguments field is optional. All existing definitions remain valid.

Allow an `arguments` sub-property on any `Argument` whose type includes
`object`. This enables typed descriptions of nested object structures
instead of a prose-only description.

Apply to $rankFusion and $scoreFusion:
- input.pipelines: typed as variadic pipeline map
- input.normalization ($scoreFusion): typed as string
- combination.weights: typed as variadic number map
- combination.method / combination.expression ($scoreFusion): typed
Copilot AI review requested due to automatic review settings April 29, 2026 13:39
@GromNaN
GromNaN requested review from addaleax, alcaeus and lerouxb April 29, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a way to describe nested structure for object-typed operator arguments by allowing Argument definitions to contain recursive sub-arguments, and applies this to the $rankFusion and $scoreFusion stage specs.

Changes:

  • Extend schemas/operator.json Argument definition with an optional recursive arguments field.
  • Update $scoreFusion stage definition to provide typed nested fields under input and combination.
  • Update $rankFusion stage definition to provide typed nested fields under input and combination.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
schemas/operator.json Adds Argument.arguments to enable recursive, typed sub-properties for object arguments.
definitions/stage/scoreFusion.yaml Replaces prose-only object structure docs with typed nested arguments for input/combination.
definitions/stage/rankFusion.yaml Replaces prose-only object structure docs with typed nested arguments for input/combination.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread schemas/operator.json
}
}
},
"required": ["name", "type"],

Copilot AI Apr 29, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema comment says arguments is only valid when type includes object, but the schema currently allows arguments for any Argument type. Consider enforcing this with an if/then (e.g., if: { properties: { type: { contains: { const: "object" } } } } then: { } else: { not: { required: ["arguments"] } }) so invalid uses are rejected during validation.

Suggested change
"required": ["name", "type"],
"required": ["name", "type"],
"if": {
"properties": {
"type": {
"contains": {
"const": "object"
}
}
}
},
"then": {},
"else": {
"not": {
"required": ["arguments"]
}
},

Copilot uses AI. Check for mistakes.
@alcaeus

alcaeus commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Interesting approach, especially as this looks like it would be backward compatible: any consumer that doesn't support the nested argument syntax yet would simply ignore it and continue allowing generic objects. I'm tempted to think this might just work.

@lerouxb lerouxb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. In fact it seems like the obvious solution now that I see it. I can't think of how else you'd express this.

@GromNaN
GromNaN merged commit 671c695 into mongodb:main May 4, 2026
7 checks passed
@GromNaN
GromNaN deleted the recursive-object-arguments branch May 4, 2026 14:38
@GromNaN GromNaN mentioned this pull request May 4, 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.

4 participants