<!-- llms-explorer concept facts · https://llms-explorer.com/tree/densify-and-fill-gap-filling/ · pack 2026-09-18 · ~33818 tokens -->

# $densify and $fill Gap Filling

> Depth-first rabbithole dossier for $densify and $fill Gap Filling; source-anchored research pack.

6 facets · 256 facts · page: https://llms-explorer.com/tree/densify-and-fill-gap-filling/

## Definitions

- Terminology used consistently below: a **partition** is a group of documents sharing a compound key; a **generated document** is a document `$densify` synthesizes; the **densify field** is the field named in `$densify.field`. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#scope`

## Structure and components

- 3. The documents `$densify` generates contain only the values of `field` and of `partitionByFields`; every other field is absent. Consequence: a downstream `$project`, `$group`, or chart binding that expects a metadata field on every document will see it missing on generated rows unless `$fill` (or `$set`) puts it back. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://oneuptime.com/blog/post/2026-03-31-mongodb-how-to-use-densify-and-fill-with-time-series-in-mongodb/view> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#what-the-stages-do-and-how-they-divide-the-work`
- 12. Documents generated by `$densify` contain only the densified `field` and the fields named in `partitionByFields`. They carry no `_id` and none of the other fields of the surrounding documents. Any metadata not lifted into `partitionByFields` is lost for synthetic rows, and downstream stages that assume `_id` exists will misbehave. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 16. `$fill` with `method: "locf"` leaves `null` and missing values that appear *before* the first non-null value in sort order as `null`. Leading gaps at the start of a partition are never filled. If a partition contains only null or missing values, `locf` sets the field to `null` for the whole partition. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 22. SERVER-127280: `$linearFill` validated only that `sortBy` contained a single element and did not reject expression-based sort parts such as `{x: {$meta: 'randVal'}}`, which are incompatible with linear interpolation. Reported against 8.0.27, created 2026-05-20, resolved 2026-07-24; fix versions include 7.0.39, 8.0.28, 8.2.12, 8.3.7, 9.0.0-rc2. This validation gap existed for roughly four years after the feature shipped. — https://jira.mongodb.org/browse/SERVER-127280 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#confirmed-server-defects`
- **E1.** Generated documents contain only the densify field and the fields listed in `partitionByFields`. They do not carry any other fields from neighbouring documents. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#e-densify-output-contract`
- **E4.** E3 stands in tension with B1: `$densify` *requires* sorted input and prepends a `$sort` to get it, yet makes no promise about its own output order. The practical reading is that the internal sort is an implementation detail serving the generation algorithm and is not part of the stage's contract. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#e-densify-output-contract`
- **H1.** `output` is required and is an object whose keys are the fields to fill. Each value must be an object with exactly one of `value` or `method`. The implementation raises 6050203 ("The output field in '$fill' must contain an object with at least one element"), 6050200 ("Each fill output specification must be an object with exactly one field"), and 6050201 ("Each fill output specification must have exactly one of 'method' or 'value' fields, not both"). Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>, <https://github.com/mongodb/mongo/blob/master/src/mon — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- 14. MongoDB 8.0.20 relaxed a `linear` restriction: from that release `$fill` can interpolate even when different partitions contain identical `sortBy` values. Before it, `linear` errors on repeated `sortBy` values within a single partition, and allows exactly one `sortBy` field. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#version-dependent-semantics`
- **S34.** `$fill`'s `output` is required and each entry must be an object with exactly one of `value` or `method`. Errors 6050203 ("The output field in '$fill' must contain an object with at least one element"), 6050200 ("Each fill output specification must be an object with exactly one field"), 6050201 ("Each fill output specification must have exactly one of 'method' or 'value' fields, not both"). **[converged: M H1, E 9]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S39.** Generated documents contain only the densify field and the fields listed in `partitionByFields`. `[E]` adds the sharpest consequence: they carry no `_id`, so downstream stages that assume `_id` exists will misbehave, and any metadata not lifted into `partitionByFields` is lost for synthetic rows. **[converged: M E1, E 12, P 3]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://oneuptime.com/blog/post/2026-03-31-mongodb-how-to-use-densify-and-fill-with-time-series-in-mongodb/view> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S42.** S41 stands in tension with S12: `$densify` requires sorted input and prepends a `$sort` to obtain it, yet promises nothing about its own output order. The reading `[M]` offers is that the internal sort is an implementation detail serving the generation algorithm and is not part of the stage's contract. **[single-source: M E4]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S64.** **SERVER-127280.** `$linearFill` validated only that `sortBy` contained a single element and did not reject expression-based sort parts such as `{x: {$meta: 'randVal'}}`, which are incompatible with linear interpolation. Reported against 8.0.27, created 2026-05-20, resolved 2026-07-24; fix versions include 7.0.39, 8.0.28, 8.2.12, 8.3.7, 9.0.0-rc2. The validation gap stood for roughly four years after the feature shipped. **[single-source: E 22]** — <https://jira.mongodb.org/browse/SERVER-127280> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **E2.** Original documents pass through with all their fields intact. Documents that do not contain the densify field at all "continue through the pipeline unmodified." Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#e-densify-output-contract`
- **S40.** Original documents pass through with all fields intact. Documents that do not contain the densify field at all "continue through the pipeline unmodified." **[single-source: M E2]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`

## How it works

- This report covers the internal mechanism of MongoDB's two gap-filling aggregation stages, `$densify` and `$fill`: their desugaring into other stages, their execution state machine, their configuration surface, their invariants, and their documented and observed limits. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#scope`
- 5. The working pipeline order is `$match` (narrow the range and the partitions) → `$densify` (create the missing instants) → `$fill` (give them values) → `$sort` (for output). `$densify` must precede `$fill`, because `$fill` only assigns values to documents that already exist. — <https://oneuptime.com/blog/post/2026-03-31-mongodb-how-to-use-densify-and-fill-with-time-series-in-mongodb/view> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#operating-them-together`
- **S3.** MongoDB states the division in its own words: "The $densify stage creates new documents to eliminate the gaps in the time or numeric domain at the required granularity level, and $fill sets values for the fields when a value is null or missing." **[converged: M A3, H 11, P 1]** — <https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **C4.** When no `partitionByFields` is given, the implementation still uses the partition machinery with a single dummy partition keyed as `true`, so partitioned and unpartitioned execution share one code path. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#c-densify-execution-state-machine`
- **E5.** Generated documents exist only within the pipeline. They are produced by the `DocGenerator` at execution time and are not written to the collection; persisting them requires an explicit `$out` or `$merge`. Source (mechanism): <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#e-densify-output-contract`
- **I4.** Trailing nulls behave differently by method: under `linear` they remain null, because interpolation needs a bounding value on both sides; under `locf` they are filled with the last non-null value. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **S50.** Trailing nulls diverge by method: under `linear` they remain null, because interpolation needs a bounding value on both sides; under `locf` they are filled with the last non-null value. **[converged: M I4, E 17, P 8]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **Resolved: 5.1.** The reference documentation and the driver annotation are the authoritative pair; the 5.3-for-both framing is announcement shorthand for "the gap-filling story completed in 5.3." `[H]` records it because secondary write-ups repeat the 5.3 figure. The other three reports all state 5.1 without noticing the contrary source. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d5-which-version-introduced-densify`
- **One adjacent mechanism fact, from `[M]`.** S68 shows the implementation *does* handle variable calendar-unit lengths and has a defined fallback for misalignment. That makes the DST reports more pointed, not less: the code reasons about calendar irregularity but has no zone-offset concept at all. These are adjacent, not identical — S68 is about month and year length, the thread is about offset shifts — so this is a lead, not a diagnosis. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d7-severity-of-the-dst-timezone-gap`
- 2. **The "is `bounds` required?" contradiction is weaker than either report thought.** Mechanism and edge-cases each weighed Microsoft Learn as a peer reference against MongoDB's manual. Practice independently found the Microsoft `$fill` page carries `ai-usage: ai-assisted` and lists `linear` twice in its own method table. Neither of the first two had that fact. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- 3. **Two reports give directly conflicting pipeline-order advice.** Practice says `$densify → $fill → $sort`; edge-cases says the safe shape is `$densify → $sort → $fill` or you get silent wrong fills. Mechanism's desugaring (`$fill` → `$setWindowFields` with its own `sortBy`) favours practice, but no report states `$setWindowFields`'s sorting contract — it was out of scope in all four, which is exactly why the conflict survived. Left unresolved with the cheapest closing move named. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- 24. A user reports that when `range.bounds` is an explicit date array and no document in a partition falls inside those bounds, `$densify` densifies only the first partition in the result set and silently omits the others. Reported 2023-08-28 with a reproduction; no resolution in the thread. — https://www.mongodb.com/community/forums/t/densify-doesnt-produce-results-for-the-given-partition/241601 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unfixed-unacknowledged-behaviour`
- **B2.** The generated sort pattern is the partition fields followed by the densify field, except when `bounds` is `"full"`, in which case the partition fields are omitted and the sort is on the densify field alone. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#b-densify-desugaring`
- **D2.** Values of the densify field must be all numeric or all dates. `range.unit` is required when the field holds dates and must be absent when it holds numbers; the stage errors in either mismatched case. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **F6.** SERVER-63145: `$densify` produced incorrect results when query optimization was enabled and the pipeline used `$count` or a count-like operator such as `$sortByCount`. The optimizer "was disregarding the fact that $densify can add more documents to the output," pushing count logic past the stage. A pipeline that should have returned 12 documents returned 2 with optimization on. Affected 5.2.x and 5.3.0-alpha; fixed in 5.2.1 and 5.3.0. Source: <https://jira.mongodb.org/browse/SERVER-63145> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **G5.** The functional difference between `$fill` and using `$linearFill`/`$locf` directly is the write target: "When you use the `$fill` stage, the field you specify in the output is the same field used as the source data. When you `$linearFill` or `$locf`, you can set values for a different field than the field used as the source data." Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#g-fill-desugaring`
- **H4.** `sortBy` is required when any output field uses `method`, and optional otherwise. Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- 8. `linear` and `locf` both leave edges null. `linear` fills a run of nulls only when it is both preceded and followed by non-null values, so nulls at the start or end of a partition stay null; `locf` likewise leaves null any value that precedes the first non-null observation in sort order. Consequence: densifying to a fixed `bounds` window wider than the observed data produces null-valued rows at the window edges that no fill method will populate — a constant `value` fill is the only remedy. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#operating-them-together`
- **S10.** The one functional difference between `$fill` and the direct operators is the write target: "When you use the `$fill` stage, the field you specify in the output is the same field used as the source data. When you `$linearFill` or `$locf`, you can set values for a different field than the field used as the source data." **[single-source: M G5]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S12.** `$densify`'s `create()` prepends a `DocumentSourceSort` and appends the internal stage, so the user-visible stage expands to `$sort` + `$_internalDensify`. The generated sort pattern is the partition fields followed by the densify field, except under `bounds: "full"`, where the partition fields are omitted and the sort is on the densify field alone. A `combineSorts()` optimization erases a redundant following sort when the preceding sort already matches the generated pattern. **[single-source: M B1–B3]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_so — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S18.** Consistent with S13, `sortBy` is required in `$fill` only when an output field uses `method`; a constant `value` fill needs no sort, because that path desugars to `$addFields` and has no dependence on neighbouring documents. **[converged: M H4 & I7, H 16, P 7]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S66.** **Untracked: partition omission under explicit bounds.** When `range.bounds` is an explicit date array and no document in a partition falls inside those bounds, `$densify` densifies only the first partition in the result set and silently omits the others. Reported 2023-08-28 with a reproduction. `[P]` records the vendor-community answer: three products, data timestamped 2020-01-01, bounds covering August 2023; only the partition with a document inside the pipeline was densified, and `bounds: "full"` was the recommended fix. **[converged: E 24, P 10]** — <https://www.mongodb.com/commun — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **Mechanism evidence favours Position A, but not conclusively.** S13 establishes that a `method`-based `$fill` desugars to `$setWindowFields`, which takes its own `sortBy` and establishes its own ordering — so `$fill` should not depend on the order in which documents reach it. `[P]` claim 6 states this directly: "`$fill`'s own `sortBy` governs fill order." If that holds, Position B's hazard is not real and its extra `$sort` is merely redundant work. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d3-where-does-the-sort-go-before-or-after-fill`
- 1. **A field-reported bug has its explanation sitting in a different report.** The "partitions with no in-bounds document are silently omitted" report (edge-cases 24 / practice 10) is explained by mechanism's `_partitionTable`, which maps only *observed* partition keys — a partition absent from the stream never enters the table. That also explains why `bounds: "full"` was the working fix, since "full" drops partition fields from the generated sort entirely. Testable, and it predicts the omission is by construction, not a defect. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- 4. **Source independence is lower than the per-report quality gates suggest.** Pooled: 9 hosts, but `mongodb.com`, `jira.mongodb.org`, `github.com/mongodb/mongo` and `mongodb.github.io` are all MongoDB-controlled. Genuinely independent: 5, of which 3 are reimplementation docs, 1 a press article, 1 a practitioner blog. Every mechanism and limits claim traces to MongoDB itself. The 5.3 announcement is also cited under two different URLs across the reports — one artifact, not two. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- **N4. Source independence is lower than the per-report quality gates suggest.** Each report certified four to six distinct hosts. Pooled across all four, the corpus spans nine hosts — but `mongodb.com` (docs, blog, forums), `jira.mongodb.org`, `github.com/mongodb/mongo`, and `mongodb.github.io` are all MongoDB-controlled. Genuinely independent hosts number five: `learn.microsoft.com`, `docs.aws.amazon.com`, `documentdb.io`, `techtarget.com`, `oneuptime.com`. Of those, three are reimplementation documentation, one is a single press article, and one is a practitioner blog post. **Every claim abo — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-3-findings-only-the-synthesis-produces`
- **C3. Two claims are inferences this synthesis makes, not any report's finding.** The mechanism argument in D3 (that `$setWindowFields` establishes its own order) and the diagnosis in N1 (that `_partitionTable` explains the partition-omission report) are both labelled in place. Neither is sourced; both are testable. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-5-methodological-caveats-carried-forward`

## Problems, failure modes and limitations

- **Concept:** `$densify` and `$fill` Gap Filling **Parent domain:** mongodb-time-series **Report type:** edge-cases (boundary conditions, failure modes, disagreements) **Compiled:** 2026-09-18 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md`
- 11. **[derived]** Because `$densify` does not preserve input order (claim 10) and both the `locf` and `linear` methods of `$fill` are defined relative to `sortBy` order (claim 7, 8), a `$sort → $densify → $fill` pipeline that omits a second `$sort` between the two stages can produce wrong fill values without raising an error. The safe shape is `$densify → $sort → $fill`. — https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/ , https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- **Gaps not closed by this pass.** No primary source was found quantifying `$densify` or `$fill` memory consumption or spill behaviour, nor confirming how either stage is split across shards in a sharded cluster. General aggregation guidance on the 100 MB per-stage limit and `allowDiskUse` exists (https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits/) but does not name `$densify` or `$fill` among the stages it governs, so no claim is made here about their memory behaviour. Disagreement B could not be resolved without running both engines. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#quality-gate`
- **S59.** No primary source was found in any of the four passes quantifying `$densify` or `$fill` memory consumption or spill behaviour. The general aggregation guidance on the 100 MB per-stage limit and `allowDiskUse` exists but does not name either stage. The only documented ceiling on `$densify` is the generated-document count. **[converged: M U4, E "Gaps not closed"]** — <https://www.mongodb.com/docs/manual/core/aggregation-pipeline-limits/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#g-hard-limits-and-capacity-arithmetic`
- - **Position A (`[P]` claim 5).** The working order is `$match` → `$densify` → `$fill` → `$sort`, with the final sort for output presentation. — <https://oneuptime.com/blog/post/2026-03-31-mongodb-how-to-use-densify-and-fill-with-time-series-in-mongodb/view> - **Position B (`[E]` claim 11, labelled derived).** Because `$densify` does not preserve input order (S41) and both fill methods are defined relative to `sortBy` order, a `$sort → $densify → $fill` pipeline that omits a second `$sort` between the two stages can produce wrong fill values with no error raised. The safe shape is `$densify` → — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d3-where-does-the-sort-go-before-or-after-fill`
- | Area | Evidence of saturation | |------|------------------------| | Division of labour between the stages | All four reports, identical, quoting the same vendor sentence | | Version lineage (`$densify` 5.1, `$fill` 5.3) | All four, plus an independent MongoDB-owned corroborator (S5), plus a resolved contrary source (D5) | | Configuration surface and error conditions | `[M]` and `[E]` converge; `[M]` adds eleven specific error codes with messages | | Documented limits (500k generated docs) | All four, from two doc versions | | Output-order non-guarantee | All four, verbatim quote | | Generate — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#saturated-stop-researching`
- 1. `$densify` aborts the pipeline with an error if it would generate more documents than `internalQueryMaxAllowedDensifyDocs`, whose default value is 500,000 documents. The limit counts generated documents, not input documents, so a narrow `step` over a wide `bounds` range fails even on a tiny source collection. — https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 5. Starting in MongoDB 8.1, `$densify` errors when `field` shares a path prefix with any entry in `partitionByFields` — for example `field: "timestamp"` with `partitionByFields: ["timestamp.hours"]`. Pipelines valid on 8.0 can fail on 8.1. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 8. `$fill` with `method: "linear"` errors if the `sortBy` field contains any repeated value within a single partition. Duplicate timestamps — a normal occurrence in sensor ingest — are a hard failure, not a tolerated case. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- **D3.** `range.step` must be a strictly positive numeric value. The implementation raises error 5733401 with the message "The step parameter in a range statement must be a strictly positive numeric value." Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D4.** When densifying a date range, `step` must be a whole number. The implementation raises error 6586400 with the message "The step parameter in a range statement must be a whole number when densifying a date range." Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D5.** `bounds: "partition"` requires a non-empty `partitionByFields` array. The implementation raises error 5733408: "One cannot specify the bounds as 'partition' without specifying a non-empty array of partitionByFields." Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **F1.** `$densify` errors if it generates more documents than `internalQueryMaxAllowedDensifyDocs` allows. The default limit is 500,000 generated documents. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **F2.** The limit check raises error code 5897900 with the message "Generated \<n\> documents in $densify, which is over the limit of \<max\>." Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **H6.** For `method: "linear"`, `sortBy` must name exactly one field: "You can specify exactly one field in `sortBy`. `$fill` returns an error if you specify multiple fields." Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- **H7.** For `method: "linear"`, `$fill` "returns an error if there are any repeated values in the `sortBy` field in a single partition." Starting in MongoDB 8.0.20, identical `sortBy` values in *different* partitions no longer trigger this error. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- **S30.** For a date range, `step` must be a whole number — error 6586400, "The step parameter in a range statement must be a whole number when densifying a date range." Fractional date steps are not expressible. **[converged: M D4, E 6]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp>, <https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S37.** For `method: "linear"`, `sortBy` must name exactly one field: "You can specify exactly one field in `sortBy`. `$fill` returns an error if you specify multiple fields." Multi-key ordering is unavailable with linear interpolation. **[converged: M H6, E 7, P 14]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S55.** `$densify` errors if it would generate more documents than `internalQueryMaxAllowedDensifyDocs`, default 500,000. The limit counts *generated* documents, not input documents, so a narrow `step` over a wide `bounds` range fails even on a tiny source collection. **[converged: M F1, H 20, E 1, P 9]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#g-hard-limits-and-capacity-arithmetic`
- **S56.** The limit check raises error 5897900: "Generated \<n\> documents in $densify, which is over the limit of \<max\>." **[single-source: M F2]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#g-hard-limits-and-capacity-arithmetic`
- 2. `$densify` errors if any document's `field` value is a date and `range.unit` is not specified, and errors if any value is numeric and `range.unit` *is* specified. A collection with mixed numeric and date values in the same field therefore cannot be densified under any single configuration. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 7. `$fill` with `method: "linear"` accepts exactly one field in `sortBy` and errors on more than one. Multi-key ordering cannot be used with linear interpolation. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- **U4. Memory ceiling for partition state.** `_partitionTable` grows with partition cardinality and the stage declares no disk use. No documented limit on partition count or partition-state memory was found for `$densify`, and the `$setWindowFields` reference consulted did not state a per-partition memory limit either (<https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/>). The only documented ceiling on `$densify` is the generated-document count (F1). Treat high-cardinality partitioning as an unquantified memory risk. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#unresolved-disagreements`
- 10. `$densify` can only densify partitions that are already present in the document stream. When explicit `bounds` exclude a partition's only documents, that partition produces no output at all. A reported case had three products, data timestamped 2020-01-01, and bounds covering August 2023; only the partition with a document inside the pipeline was densified, and `bounds: "full"` was the recommended fix. Consequence: `$densify` cannot invent a device that reported nothing during the window — that requires a separate seed source (for example a `$unionWith` over a partition-key collection). — < — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#limits-restrictions-and-failure-modes`
- **S28.** Values of the densify field must be all numeric or all dates. `range.unit` is required when the field holds dates and must be absent when it holds numbers; the stage errors on either mismatch. A collection holding mixed numeric and date values in the same field therefore cannot be densified under any configuration. **[converged: M D2, E 2]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S35.** `partitionBy` and `partitionByFields` are mutually exclusive in `$fill` — error 6050204, "Maximum one of 'partitionBy' and 'partitionByFields can be specified in '$fill'." **[converged: M H2, E 9]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S71.** **8.1 — new hard error.** `$densify` errors when `field` shares a path prefix with any entry in `partitionByFields` — for example `field: "timestamp"` with `partitionByFields: ["timestamp.hours"]`. Enforced with errors 8993000 and 9554500. A pipeline accepted on 8.0 fails outright on 8.1. **[converged: M D10, H 18, E 5, P 13]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#i-version-dependent-semantics-the-upgrade-hazard-timeline`
- **S29.** `range.step` must be a strictly positive numeric value — error 5733401, "The step parameter in a range statement must be a strictly positive numeric value." **[single-source: M D3]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S31.** `bounds: "partition"` requires a non-empty `partitionByFields` array — error 5733408, "One cannot specify the bounds as 'partition' without specifying a non-empty array of partitionByFields." **[single-source: M D5]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- 13. MongoDB 8.1 added an error when `field` shares a prefix with any entry in `partitionByFields` (for example `field: "timestamp"` with `partitionByFields: ["timestamp.hours"]`). A pipeline accepted on 8.0 can therefore fail outright on 8.1. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#version-dependent-semantics`
- In scope: the two stages, the two window operators they compile to (`$locf`, `$linearFill`), their mechanism, sub-parts, history, edge cases, failure modes, and the disagreements between sources about them. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#scope`
- **S41.** `$densify` "does not guarantee sort order of the documents it outputs. To guarantee sort order, use `$sort` on the field you want to sort by." **[converged: M E3, H 21, E 10, P 6]** — the single most redundantly attested caveat in the corpus. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S60.** *Derived risk.* S26 and S59 together: `_partitionTable` grows with partition cardinality, the stage declares no disk use, and no documented limit on partition count or partition-state memory exists. High-cardinality partitioning is an unquantified memory risk. **[converged: M U4, E]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#g-hard-limits-and-capacity-arithmetic`
- **S67.** *Generalization of S66.* `$densify` can only densify partitions already present in the document stream. It cannot invent a device that reported nothing during the window; that requires a separate seed source, for example a `$unionWith` over a partition-key collection. **[single-source: P 10]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **S70.** **8.0.20 — restriction relaxed.** "Starting in MongoDB 8.0.20, `$fill` can interpolate when different partitions contain identical `sortBy` values." Repeated `sortBy` values *within* a single partition still error under `linear`. **[converged: M H7, H 19, P 14]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#i-version-dependent-semantics-the-upgrade-hazard-timeline`
- **S72.** *Synthesis note.* S69 is the dangerous one: S71 fails loudly at parse time and S70 only widens what is accepted, but S69 changes results with no error. Only `[P]` and `[E]` name the silence explicitly. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#i-version-dependent-semantics-the-upgrade-hazard-timeline`

## Comparisons and alternatives

- 2. **Is database-side gap filling always the right layer?** The practitioner guide surveyed presents `$densify` + `$fill` as producing "dashboard-ready" output and gives no performance, cardinality, or cost caveat (<https://oneuptime.com/blog/post/2026-03-31-mongodb-how-to-use-densify-and-fill-with-time-series-in-mongodb/view>). That is contradicted by the primary documentation's own 500,000-document ceiling (claim 9) and by the absence of any index that `$densify`'s synthesis can use. No dated, independent benchmark of `$densify` at high partition cardinality was found; the trade-off against — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#unresolved-disagreements`
- 1. **Memory and spill behaviour.** All four reports name this as a gap (S59, S60). No source quantifies `_partitionTable` growth, partition-count ceilings, or whether the desugared `$sort` spills under `allowDiskUse`. **Highest-value open question**, because it is the one thing a production adopter needs and the one thing nobody documented. 2. **Sharded-cluster behaviour.** `[E]` explicitly names it as unclosed; the other three do not mention it at all. Zero coverage. Given S62 (the optimizer mis-reasoned about densify cardinality once already), how `$densify` splits across shards is a plausib — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#not-saturated-worth-another-pass`
- **I7.** Filling with `value` is the only method that has no ordering requirement and no dependence on neighbouring documents, because it desugars to `$addFields` with `$ifNull` rather than to `$setWindowFields`. This follows from G1 and G3. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **Both are true; the reports sampled different vendors.** `[E]` claim 26 supplies the reconciliation: support is *split* between MongoDB-compatible platforms rather than uniformly present or absent. The corrected claim is that these stages port to the DocumentDB/Azure lineage on paper and do not port to Amazon DocumentDB at all. `[P]` itself qualifies Position A as documented-support, not verified-behaviour. A reader taking only `[P]` would overestimate portability; a reader taking only `[E]` would underestimate it. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d4-is-gap-filling-portable-across-mongodb-compatible-engines`
- This report covers only the two MongoDB aggregation stages `$densify` (added 5.1) and `$fill` (added 5.3) and their directly coupled expression operators `$linearFill` and `$locf`. It records boundary conditions, documented error cases, confirmed server defects, and evidence that contradicts the stages' marketed behaviour. It does not cover sibling frontier items: time-series collections generally, `$setWindowFields` as a window-function facility, bucketing, or downsampling. Where a claim is an inference drawn from two documented facts rather than a directly stated one, it is labelled **[deriv — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#scope`
- 9. The stated problem is discontinuity in recorded series: gaps appear when a device or sensor stops reporting, and analytics over the series need continuous entries. — <https://www.techtarget.com/searchdatamanagement/news/252515600/MongoDB-53-enhances-times-series-data-capabilities> 10. MongoDB framed the goal as keeping the work in the database: doing this analytics natively instead of building application-layer pipelines or exporting to a specialised time series store or warehouse. — <https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3> 11. Division of lab — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#stated-motivation`
- 12. `$densify` is a user-facing alias, not the executed stage: `src/mongo/db/pipeline/document_source_densify.h` declares `kStageName = "$densify"` for the parser and a separate `DocumentSourceInternalDensify` with `kStageName = "$_internalDensify"` for execution. — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h> 13. The same header models densification over a `DensifyValue` variant covering both numeric and date values, with a `RangeStatement` carrying step, optional time unit, and one of three bounds types: `Full`, `Partition`, `ExplicitBounds`. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#implementation-server-source-as-primary-evidence`
- 17. MongoDB 8.0 changed `$densify` bounds semantics: bounds with an equal lower and upper bound (for example `[10, 10]`) are treated as an empty set and generate no document; earlier versions generated one document at that bound. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> 18. MongoDB 8.1 added a new `$densify` error case: it errors when `field` shares a prefix with any entry in `partitionByFields` (for example `field: "timestamp"` with `partitionByFields: ["timestamp.hours"]`). — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#post-release-evolution-behaviour-changed-after-5-3`
- 1. **Which version introduced `$densify`.** The manual and the Java driver both say 5.1 (claims 2, 3). TechTarget's 2022-04-06 report instead says "MongoDB 5.3 introduces two primary commands", naming `$densify` and `$fill` together (<https://www.techtarget.com/searchdatamanagement/news/252515600/MongoDB-53-enhances-times-series-data-capabilities>). MongoDB's own 5.3 blog is internally ambiguous: it credits densification to 5.1 in one sentence but calls both "the two new aggregation stages" in the next (<https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3>). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#unresolved-disagreements`
- 15. Both stages exist outside MongoDB Inc.'s server. Open-source DocumentDB (an LF Projects entity) documents `$densify` with full syntax and examples, and Azure Cosmos DB for MongoDB (vCore) documents `$fill` with `value`, `linear`, and `locf`. Consequence: adopting these stages is not automatically single-vendor lock-in, though the reimplementations are documented independently and their edge-case behaviour should be tested rather than assumed. — <https://documentdb.io/docs/reference/operators/aggregation/$densify/>, <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#portability`
- 1. **Does `$fill` carry observations *backward*?** MongoDB's 5.3 announcement says filling "can be done with a constant or using linear interpolation, carrying over the last observation or carrying backward the next observation" (<https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3>). The current `$fill` reference lists only `value`, `linear`, and `locf` — no next-observation- carried-backward method (<https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>). Microsoft's page repeats the looser phrasing ("val — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#unresolved-disagreements`
- **A cross-report observation neither could make.** Position B rests entirely on Microsoft Learn. `[P]` independently established that the Microsoft `$fill` page carries `ai-usage: ai-assisted` metadata and contains a demonstrable table error — it lists `linear` twice, once as "numeric fields only" and once as "between surrounding values." That does not prove the `$densify` pages share the defect (they are different pages in a different family), but it removes the presumption of editorial reliability that Position B depends on. The disagreement is now better characterized as *one well-maintaine — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d2-is-range-bounds-required`
- **F3.** Because the limit is a server parameter, the ceiling is tunable but the failure is abrupt: the pipeline errors rather than truncating. This follows from F1 and F2. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **Why this is recorded as unresolved rather than settled.** None of the four reports states that `$setWindowFields` sorts its own input; that step is an inference this synthesis is making from S13 plus `[P]` claim 6, and `[P]` claim 6 is itself an interpretation rather than a quoted statement. Position B's insertion is *safe* under either reading — a redundant sort costs work but cannot produce a wrong answer — so the conservative operational advice is Position B's, while the likely-correct mechanism is Position A's. **Cheapest resolution: read `$setWindowFields`'s own sorting contract, an exp — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d3-where-does-the-sort-go-before-or-after-fill`
- **Saturation: saturated on the documented surface, not on operational behaviour.** Ten-odd facts converged across all four — but partly as an artifact of all four reading the same two reference pages. The marginal value came from reports that went elsewhere: two of three server defects and both untracked issues (DST/timezone, partition omission) came from exactly one report each. Top open items: memory/spill behaviour (all four name it as a gap), sharded-cluster behaviour (zero coverage), and history's own method correction — query `jira.mongodb.org` directly rather than via web search, which — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- The NOCB question is settled by mechanism's source-level evidence (`document_source_fill.cpp` validates `method` against exactly `locf` and linear), which upgrades it from docs-vs-marketing to docs-plus-source-vs-marketing. Combined with "neither method extrapolates backwards," that means leading gaps have no first-party fill strategy at all — the one method that would have filled them never shipped. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md`
- 20. SERVER-63145: query optimization disregarded that `$densify` adds documents, so `$count` and `$sortByCount` after `$densify` counted only the pre-densify documents. The reported reproduction returned `count: 2` with optimization enabled versus the correct `count: 12` with it disabled. Status Closed/Fixed, fix versions 5.2.1 and 5.3.0. — https://jira.mongodb.org/browse/SERVER-63145 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#confirmed-server-defects`
- 23. `$densify` has no `timezone` parameter and operates in UTC, unlike `$dateTrunc`. Users report that densifying across daylight-saving transitions with `day` or `month` units yields misaligned dates and extra documents that do not line up with a `$dateTrunc` bucketing of the same data. The thread runs from 2022-12-30 to 2025-02-15 with multiple independent reporters and no MongoDB staff reply or acknowledged fix. — https://www.mongodb.com/community/forums/t/bug-densify-and-daylight-saving/206378 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unfixed-unacknowledged-behaviour`
- 26. Azure's DocumentDB / Cosmos DB for MongoDB documentation does document `$densify`, including a limitations table covering field restrictions, `partitionByFields` restrictions and bounds semantics. Support is therefore split between MongoDB-compatible platforms rather than uniformly absent. — https://learn.microsoft.com/en-us/documentdb/query/operators/aggregation/$densify — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#portability-boundaries`
- **D. The Microsoft limitations table omits MongoDB's two most operationally significant caveats.** The DocumentDB page's "Limitations" table lists field, partition and bounds restrictions but does not mention the 500,000-document generation limit (claim 1) or the absence of an output sort-order guarantee (claim 10) (https://learn.microsoft.com/en-us/documentdb/query/operators/aggregation/$densify vs https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/). Whether the DocumentDB implementation lacks these limits or the documentation is incomplete is unresolved. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unresolved-disagreements`
- **Met.** Claims rest on 10 documents across 4 independent hosts — `mongodb.com` (reference manual and corporate blog), `mongodb.github.io` (driver API), `github.com` (server source), and `techtarget.com` (contemporaneous independent press). A disconfirming source was actively sought and found on two points: the version attribution in disagreement 1, and the NOCB method in disagreement 2. The gap noted in disagreement 3 (no ticket-level design record) is stated rather than papered over. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#quality-gate`
- **U1. Is `range.bounds` required?** The MongoDB manual lists `range.bounds` as Required (<https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>). Microsoft's DocumentDB / Azure Cosmos DB for MongoDB vCore reference for the same operator lists `range.bounds` and `range.unit` as Optional (<https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$densify>). This most likely reflects a divergence in the reimplementation rather than an error in either document, but it is unverified. Treat `bounds` as required when targeting MongoDB proper. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#unresolved-disagreements`
- **U3. Does `bounds: "full"` require buffering all input?** The execution stage is declared `kStreaming` with `kNoDiskUse` (<https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h>), which implies `"full"` densification works against the running maximum rather than a pre-computed global one. Because `$densify` desugars to a preceding `$sort` on the densify field (<https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp>), the input arrives in order and a streaming implementation is sufficient. This report did not verif — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#unresolved-disagreements`
- 9. `$densify` errors if it would generate more documents than `internalQueryMaxAllowedDensifyDocs`, default 500,000. Consequence: the safe budget is `partitions × intervals`, so a one-minute step over a 30-day window across 12 devices (≈518,400 rows) already exceeds the default and fails rather than degrading. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#limits-restrictions-and-failure-modes`
- 11. `$densify` has had correctness defects, not merely performance ones. SERVER-63145 records `$densify` returning wrong counts when query optimization was enabled: a pipeline returned 2 documents optimized versus 12 unoptimized, because plan translation "is disregarding the fact that `$densify` can add more documents to the output." Fixed in 5.2.1 and 5.3.0. Consequence: treat aggregate counts computed over densified output as a thing to verify, and keep servers above those patch levels. — <https://jira.mongodb.org/browse/SERVER-63145> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#limits-restrictions-and-failure-modes`
- **S38.** For `method: "linear"`, `$fill` errors on repeated `sortBy` values within a single partition. `[E]` notes the operational weight of this: duplicate timestamps are a normal occurrence in sensor ingest, and this is a hard failure rather than a tolerated case. **[converged: M H7, E 8, P 14]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S61.** **SERVER-63145.** Query optimization disregarded that `$densify` adds documents, so `$count` and `$sortByCount` after `$densify` counted only pre-densify documents. The reported reproduction returned `count: 2` optimized versus the correct `count: 12` unoptimized. Affected 5.2.x and 5.3.0-alpha; Closed/Fixed in 5.2.1 and 5.3.0. **[converged: M F6, E 20, P 11]** — <https://jira.mongodb.org/browse/SERVER-63145> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **S65.** **Untracked: DST / timezone.** `$densify` has no `timezone` parameter and operates in UTC, unlike `$dateTrunc`. Users report that densifying across daylight-saving transitions with `day` or `month` units yields misaligned dates and extra documents that do not line up with a `$dateTrunc` bucketing of the same data. The community thread runs 2022-12-30 to 2025-02-15 with multiple independent reporters, no MongoDB staff reply, and no acknowledged fix. **[single-source: E 23]** — <https://www.mongodb.com/community/forums/t/bug-densify-and-daylight-saving/206378> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- - **Position A (vendor announcement).** MongoDB's 2022-04-06 release blog lists four `$fill` approaches: constant value, linear interpolation, last observation carried forward, and *next observation carried backward*. — <https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3> - **Position B (reference documentation).** The `$fill` reference documents exactly three: `value`, `linear`, `locf`. No `nocb` method. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> - **Position C (implementation, decisive).** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d1-backward-fill-nocb-announced-never-shipped`
- - **Position A.** The execution stage declares `kStreaming` and `kNoDiskUse` (S24), which implies `"full"` densification works against a running maximum rather than a pre-computed global one. - **Position B.** The user-visible stage desugars to a prepended blocking `$sort` (S12), so a pipeline containing `$densify` can still block and spill (S25). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d6-does-densify-block-and-does-bounds-full-buffer`
- **N1. A field-reported bug has a mechanism-level explanation sitting in another report.** S66 (`[E]`/`[P]`: partitions with no in-bounds document are silently omitted) is explained by S21 (`[M]`: `_partitionTable` maps *observed* partition keys to last-seen values). A partition with no document in the stream never enters the table, so there is nothing to densify and nothing to report. This also explains why `bounds: "full"` was the working fix — S12 shows `"full"` drops partition fields from the generated sort entirely, taking a different path. **This is an inference across reports, not a veri — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-3-findings-only-the-synthesis-produces`
- - **Done** — read four reports, wrote `synthesis.md` with 75 source-anchored claims, 7 preserved contradictions, 4 cross-report findings, saturation verdict - **Decided** — kept all contradictions side by side rather than resolving D2/D3 on inference alone; labelled the two inferences the synthesis itself introduces - **State** — concept tree untouched, no repo changes, branch `chore/sync-optimizer-skills` still clean - **Next** — the unsaturated items, chiefly memory/spill and sharded-cluster behaviour, plus a direct jira.mongodb.org SERVER query — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md#session-summary`
- 1. `/rabbithole` has no command file at `~/.claude/commands/rabbithole.md`, and Bash, Glob, Grep and the hub MCP tools are all denied in this session, so I could not search elsewhere for it. I executed the contract from your prompt directly. Does the command live somewhere I should register, or was the inline contract the intent? 2. Output path assumed as `reports/synthesis.md` alongside the four inputs. Move it to the run root or rename if the pipeline expects something else. 3. The Stele MCP tools are not connected in this session, so no task was created or knowledge recorded for this work. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md#needs-input`
- Caveat on method: several source-code claims were extracted through a summarizing fetch of raw files rather than by reading the full files line by line. Error codes, messages, enum names, and desugaring structure are quoted as returned; a reader depending on an exact code should confirm it against the version of the source matching their server build, since the cited files are `master`, not a release tag. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#quality-gate`
- **S7.** The stated motivation is that a device or sensor stops reporting, leaving discontinuities that downstream analytics cannot consume, and that MongoDB wanted this work done in the database rather than in an application layer or an exported time series store. **[single-source: H 9–10]** — <https://www.techtarget.com/searchdatamanagement/news/252515600/MongoDB-53-enhances-times-series-data-capabilities>, <https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S17.** S13 explains the release order in S6: `$fill` could only ship once both window operators existed, which is why it lands in 5.3 with `$linearFill` rather than in 5.2 with `$locf`. **[single-source: H 15]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **C1. Source-code claims are provisional.** `[M]` discloses that several source-code claims — error codes, messages, enum names, desugaring structure — were extracted through a summarizing fetch of raw files rather than line-by-line reading, and that the cited files are `master`, not a release tag. Any reader depending on an exact error code should confirm it against the source matching their server build. This caveat covers S11–S16, S19–S24, S29–S31, S34–S35, S46, S56, and S68. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-5-methodological-caveats-carried-forward`

## Facts and statements

- 1. `$densify` (aggregation stage), MongoDB Database Manual — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ 2. `$densify` (aggregation stage), MongoDB Database Manual v8.0 — https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/ 3. `$fill` (aggregation stage), MongoDB Database Manual — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ 4. `$linearFill` (expression operator), MongoDB Database Manual — https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearfill/ 5. Aggregation Pipeline Limits, MongoDB Databas — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#sources`
- 22. Despite the time series framing in every announcement, neither stage is restricted to time series collections. The manual's own `$densify` and `$fill` examples run against ordinary collections (`db.weather`, `db.stock`, `db.dailySales`), and `$densify` accepts any all-numeric field, not only dates. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> 23. `$fill` is not the only route to gap filling. The identical result is reachable by calling `$setWindowFields` with `$locf`/`$linearFill` — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#disconfirming-boundary-correcting-findings`
- **S52.** *Structural consequence — the boundary of the whole facility.* S49 and S50 define where gap filling stops. `$densify` can manufacture a document at any instant inside the requested bounds, but `$fill` assigns it a value only where surrounding data supports one. A densified window wider than the observed data yields null-valued rows at the window edges that no `method` will populate; a constant `value` fill is the only first-party remedy. **[converged: M I6, E 17, P 8]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- - **Position A (`[P]` claim 15).** "Adopting these stages is not automatically single-vendor lock-in" — open-source DocumentDB documents `$densify`, Azure Cosmos DB vCore documents `$fill`. — <https://documentdb.io/docs/reference/operators/aggregation/$densify/>, <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$fill> - **Position B (`[E]` claim 25).** Amazon DocumentDB supports neither stage at any API level, nor `$setWindowFields`, including at the 8.0 API level. — <https://docs.aws.amazon.com/documentdb/latest/devguide/mongo-apis.html> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d4-is-gap-filling-portable-across-mongodb-compatible-engines`
- **Out of scope (separate frontier items, not researched here):** MongoDB time series collections generally, `$setWindowFields` as a windowing feature in its own right, other aggregation stages, and gap filling in non-MongoDB systems (InfluxDB `FILL`, TimescaleDB `time_bucket_gapfill`, etc.). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#scope`
- 1. `$setWindowFields`, the stage the fill operators run inside, is "New in version 5.0." — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/setwindowfields/> 2. `$densify` is "New in version 5.1." — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> 3. The MongoDB Java driver's densify builders are annotated "Since server release 5.1", independently corroborating claim 2 from a separate MongoDB-owned host. — <https://mongodb.github.io/mongo-java-driver/5.6/apidocs/driver-core/com/mongodb/client/model/densify/package-summary.html> 4. `$locf` (last o — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#version-lineage`
- 1. MongoDB Manual — `$densify` (aggregation stage). <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> 2. MongoDB Manual — `$fill` (aggregation stage). <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> 3. MongoDB Manual — `$setWindowFields` (aggregation stage). <https://www.mongodb.com/docs/manual/reference/operator/aggregation/setWindowFields/> 4. MongoDB Blog — "Introducing Gap Filling for Time Series Data in MongoDB 5.3." <https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5- — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#sources`
- **S4.** `$densify` is new in 5.1; `$fill` is new in 5.3. A deployment pinned below 5.3 has half the pair. **[converged: M A4, H 2 & 6, E, P 2]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- Not a disagreement between two stated positions, but between user-reported behaviour and official silence. Reporters in the thread call it "a showstopper"; MongoDB has neither acknowledged it as a defect nor documented UTC-only behaviour as intended in the `$densify` reference, and no SERVER ticket tracking it surfaced in any of the four passes. — <https://www.mongodb.com/community/forums/t/bug-densify-and-daylight-saving/206378> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d7-severity-of-the-dst-timezone-gap`
- 25. Amazon DocumentDB's list of supported aggregation pipeline stage operators — covering the 3.6, 4.0, 5.0 and 8.0 API levels and Elastic clusters — does not list `$densify` or `$fill` at all, and lists `$setWindowFields` as "No" for every version including 8.0. Gap-filling pipelines written for MongoDB do not port to Amazon DocumentDB. — https://docs.aws.amazon.com/documentdb/latest/devguide/mongo-apis.html — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#portability-boundaries`
- **C. Severity of the DST/timezone gap.** The community thread in claim 23 has reporters calling it "a showstopper", while MongoDB has neither acknowledged it as a defect nor documented the UTC-only behaviour as intended in the `$densify` reference. There is no SERVER ticket surfaced in this search that tracks it. The disagreement is therefore between user-reported behaviour and official silence, not between two stated positions. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unresolved-disagreements`
- Disconfirming evidence was actively sought and found: the AWS support table (claim 25) contradicts any assumption that gap filling is portable across MongoDB-compatible engines; the four-methods claim in the vendor launch blog (disagreement A) is contradicted by the shipped reference; the DST thread (claim 23) contradicts the implied correctness of calendar- unit densification. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#quality-gate`
- **In scope:** the origin and version-by-version evolution of MongoDB's gap-filling feature pair — the `$densify` and `$fill` aggregation stages and the two `$setWindowFields` window operators they are built on (`$locf`, `$linearFill`) — plus the primary/official sources that establish that history. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#scope`
- **I6.** I3 and I4 define the boundary of the whole gap-filling facility: `$densify` can manufacture a document at any timestamp inside the requested bounds, but `$fill` will only assign it a value where the surrounding data supports one. A densified range extending before the first real observation yields documents whose fields stay null. This is an inference from E1, I3, and I4. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **Concept:** MongoDB's `$densify` and `$fill` aggregation stages, used together to turn a sparse time (or numeric) series into a continuous one. **Parent context:** mongodb-time-series. **Date of research:** 2026-09-18. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md`
- 1. `$densify` creates new documents to remove gaps in a date or numeric domain at a chosen granularity; `$fill` sets values for fields that are null or missing. The two are separate stages and MongoDB describes them as a pair. — <https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#what-the-stages-do-and-how-they-divide-the-work`
- 2. The stages shipped in different releases: `$densify` in MongoDB 5.1, `$fill` in the 5.3 Rapid Release (April 2022). A deployment pinned below 5.3 therefore has half of the pair, and any pipeline that assumes both requires a 5.3+ server. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#what-the-stages-do-and-how-they-divide-the-work`
- 6. `$densify` does not guarantee the sort order of the documents it outputs. The manual states: "$densify does not guarantee sort order of the documents it outputs. To guarantee sort order, use $sort on the field you want to sort by." Consequence: never rely on densified output being chronological; `$fill`'s own `sortBy` governs fill order, and a final `$sort` governs what the client receives. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#operating-them-together`
- **Concept:** MongoDB's `$densify` and `$fill` aggregation stages **Parent domain:** `mongodb-time-series` **Report type:** synthesis of four independent reports **Compiled:** 2026-09-18 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md`
- Out of scope, consistently across all four inputs: time series collections themselves, the bucketing storage format, `$setWindowFields` as a general window-function facility, `$dateTrunc`, and gap filling in non-MongoDB systems. This report does not edit the concept tree. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#scope`
- **S6.** The full feature arrived across four releases: `$setWindowFields` in 5.0 (Jul 2021), `$densify` in 5.1, `$locf` in 5.2 (Jan 2022), `$linearFill` and `$fill` together in 5.3 (Apr 2022). Release dates are from TechTarget's contemporaneous coverage; the version attributions are from the reference manual. **[single-source: H 1–7]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/setwindowfields/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearfill/>, <https://www.te — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S8.** Despite the time series framing in every announcement, neither stage is restricted to time series collections. The manual's own examples run against ordinary collections (`db.weather`, `db.stock`, `db.dailySales`), and `$densify` accepts any all-numeric field, not only dates. **[single-source: H 22]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S33.** Every `partitionByFields` name must be a string and must not begin with `$`. Both `$densify` and `$fill` enforce this. **[converged: M D9 & H5, E 4]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S73.** Amazon DocumentDB's supported-operator table — covering the 3.6, 4.0, 5.0 and 8.0 API levels and Elastic clusters — does not list `$densify` or `$fill` at all, and lists `$setWindowFields` as "No" for every version including 8.0. Gap-filling pipelines written for MongoDB do not port to Amazon DocumentDB. **[single-source: E 25]** — <https://docs.aws.amazon.com/documentdb/latest/devguide/mongo-apis.html> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#j-portability`
- **S75.** Microsoft documents both stages across two page families: `$densify` with a limitations table covering field restrictions, `partitionByFields` restrictions and bounds semantics, and `$fill` with `value`, `linear`, and `locf`. **[converged: M U1, E 26, P 15]** — <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$densify>, <https://learn.microsoft.com/en-us/documentdb/query/operators/aggregation/$densify>, <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$fill> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#j-portability`
- - **Position A.** The reference manual says 5.1; the Java driver annotation independently says "Since server release 5.1." — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://mongodb.github.io/mongo-java-driver/5.6/apidocs/driver-core/com/mongodb/client/model/densify/package-summary.html> - **Position B.** TechTarget's 2022-04-06 report says "MongoDB 5.3 introduces two primary commands," naming `$densify` and `$fill` together. — <https://www.techtarget.com/searchdatamanagement/news/252515600/MongoDB-53-enhances-times-series-data-capabilities> - **Position — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d5-which-version-introduced-densify`
- **N3. Two of the four reports give directly conflicting pipeline-order advice.** See D3. `[P]` says sort after `$fill`; `[E]` says sort between `$densify` and `$fill`. Anyone reading the reports separately gets one answer and no signal that the other exists. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-3-findings-only-the-synthesis-produces`
- 19. `$densify` — MQL for DocumentDB (Azure Cosmos DB for MongoDB vCore), Microsoft Learn, page updated 2026-01-28 — <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$densify> 20. `$densify` — MQL for DocumentDB (in Azure), Microsoft Learn, dated 2025-12-30 — <https://learn.microsoft.com/en-us/documentdb/query/operators/aggregation/$densify> 21. `$fill` — Azure Cosmos DB for MongoDB (vCore), Microsoft Learn (carries `ai-usage: ai-assisted`; see C2, N2) — <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$fill> 22. `$dens — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#genuinely-independent-hosts`
- 3. `$densify` errors if the densified field name begins with `$`; the documented workaround is to rename the field with `$project` first. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 4. `$densify` errors if any entry in `partitionByFields` evaluates to a non-string value or begins with `$`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- **C1.** Execution is driven by a `DensifyState` enum with the states `kUninitialized`, `kNeedGen`, `kHaveGenerator`, `kFinishingDensifyWithGenerator`, `kFinishingDensifyNoGenerator`, and `kDensifyDone`. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#c-densify-execution-state-machine`
- **C2.** Document synthesis is delegated to a `DocGenerator` with its own `GeneratorState` enum: `kGenerating`, `kReturningFinalDocument`, `kDone`. The generator emits the synthesized documents first and the preserved source document last. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#c-densify-execution-state-machine`
- **C3.** The stage keeps a `_partitionTable` mapping each partition key to a `DensifyValue` holding the last-seen value for that partition. Partitions are densified and then removed from the table during finalization. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#c-densify-execution-state-machine`
- **C5.** Partition state is held in memory in `_partitionTable`. The stage declares no disk use (B4), so partition cardinality is a memory cost with no spill path. This is an inference from B4 and C3. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#c-densify-execution-state-machine`
- **D8.** The densify field name must not begin with `$`. The documentation states: "The field name begins with `$`. You must rename the field if you want to densify it." Renaming is done with `$project`. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **F4.** Date arithmetic accounts for variable month and year lengths. If a decrement lands on a misaligned day (for example, 31 March minus one month is 28 February), subsequent increments may overshoot the range bounds, and the implementation falls back to the explicit start bound. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **F7.** F6 is the clearest evidence that `$densify` breaks an assumption the rest of the aggregation optimizer makes — that a stage's output cardinality is bounded by its input cardinality. Any stage or optimization reasoning about document counts must be made densify-aware. This is an inference from F6. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **G2.** `method: "linear"` maps to the `$linearFill` window operator and `method: "locf"` maps to the `$locf` window operator inside the generated `$setWindowFields`. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#g-fill-desugaring`
- **H3.** If neither `partitionBy` nor `partitionByFields` is given, the whole collection is treated as a single partition. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- **I2.** `method: "locf"` ("last observation carried forward") replaces each null or missing value with the field's last known non-null value in `sortBy` order. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **I5.** If a field is null or missing in every document of a partition, `locf` leaves it null. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- 4. Generated documents exist only inside the pipeline. `$densify` does not write them to the collection. Persisting a densified series requires an explicit `$merge` or `$out`. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#what-the-stages-do-and-how-they-divide-the-work`
- **S1.** `$densify` creates new documents where values in a numeric or date field are missing from a sequence. It assigns no values to other fields in those documents. **[converged: M A1, E, P 1]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S5.** The MongoDB Java driver's densify builders are annotated "Since server release 5.1", corroborating S4 from a second MongoDB-owned host. **[single-source: H 3]** — <https://mongodb.github.io/mongo-java-driver/5.6/apidocs/driver-core/com/mongodb/client/model/densify/package-summary.html> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S19.** `$densify` execution is driven by a `DensifyState` enum with states `kUninitialized`, `kNeedGen`, `kHaveGenerator`, `kFinishingDensifyWithGenerator`, `kFinishingDensifyNoGenerator`, `kDensifyDone`. **[single-source: M C1]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S32.** The densify field name must not begin with `$`; the documented workaround is to rename it with `$project` first. **[converged: M D8, E 3]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S36.** If `$fill` is given neither `partitionBy` nor `partitionByFields`, the whole collection is treated as one partition. **[single-source: M H3]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S48.** `method: "locf"` ("last observation carried forward") replaces each null or missing value with the field's last known non-null value in `sortBy` order. **[converged: M I2, E 16, P 7]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **S51.** If a field is null or missing in every document of a partition, `locf` leaves it null for the whole partition. **[converged: M I5, E 16]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **S53.** The output of `$fill` does not record whether a value was populated by the stage or was already present. Provenance must be captured manually with a `$set` stage placed *before* `$fill`. **[single-source: E 18]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- 6. `range.step`, `range.bounds` are both required in `$densify`, and `range.unit` is required if and only if the field holds dates. If `range.unit` is set, `step` must be an integer; fractional date steps are not expressible. — https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 9. `partitionBy` and `partitionByFields` are mutually exclusive in `$fill`, as are `value` and `method` within a single `output.<field>` specification. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#hard-limits-and-error-conditions`
- 13. `$densify` does not filter out documents whose field value falls outside `range.bounds`. The stage is additive only; out-of-range input passes through and must be removed with a separate `$match` if a bounded output is wanted. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 14. `range.bounds` array semantics are half-open: the lower bound is inclusive and the upper bound is exclusive. The lower bound sets the start value for generated documents irrespective of existing documents. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 15. MongoDB 8.0 changed the meaning of an equal-valued bounds array. Bounds `[10, 10]` are now treated as an empty set and generate no document; before 8.0 the same input generated one document with field value 10. This is a silent behaviour change across a major version. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 17. `$fill` with `method: "linear"` fills only nulls that are both preceded and followed by non-null values in sort order. Unanchored nulls — leading and trailing gaps — remain `null`. Neither shipped method extrapolates. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 19. `$fill` treats a missing field and an explicit `null` as the same condition throughout; there is no mode that distinguishes "absent" from "recorded as null". — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- **A. The launch announcement lists four `$fill` methods; the shipped stage has two.** MongoDB's 2022-04-06 release blog states `$fill` offers four approaches: constant value, linear interpolation, last observation carried forward (LOCF), and *next observation carried backward (NOCB)* (https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3). The current `$fill` reference states that `output.<field>.method` must be either `linear` or `locf` (https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/). No NOCB method e — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unresolved-disagreements`
- 1. `$densify` (aggregation stage), MongoDB Database Manual — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> 2. `$fill` (aggregation stage), MongoDB Database Manual — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> 3. `$locf` (expression operator), MongoDB Database Manual — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/> 4. `$linearFill` (expression operator), MongoDB Database Manual — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearfill/> 5. `$setWindowFields` (aggregation stage), Mon — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#sources`
- 9. Jane Fine, "Introducing Gap Filling for Time Series Data in MongoDB 5.3", MongoDB Blog, 2022-04-06 (updated 2022-11-21) — <https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#sources`
- Out of scope (separate frontier items): time series collections themselves, the bucketing storage format, `$setWindowFields` as a general window-function facility, `$linearFill`/`$locf` as standalone accumulators outside `$fill`, and sibling aggregation stages. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#scope`
- **A2.** `$fill` populates `null` and missing field values in documents that already exist; it does not create documents. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#a-division-of-labour`
- **A3.** The two stages compose as a pipeline: `$densify` eliminates gaps in the time or numeric domain at the required granularity, then `$fill` sets values for the fields that are null or missing in the resulting documents. Source: <https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#a-division-of-labour`
- **A4.** `$densify` was introduced in MongoDB 5.1. `$fill` was introduced in MongoDB 5.3. Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#a-division-of-labour`
- **B1.** `$densify` is not a single execution stage. Its `create()` prepends a `DocumentSourceSort` and then appends the internal densify stage, so the user-visible stage expands to `$sort` + `$_internalDensify`. The source comment states: "If we're creating an internal stage then we must not desugar and produce a sort stage in addition." Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#b-densify-desugaring`
- **B3.** A `combineSorts()` optimization removes a redundant sort: if the sort that precedes densify matches the generated pattern and a following sort is compatible, the following sort is erased. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#b-densify-desugaring`
- **B4.** The internal densify stage declares `StreamType::kStreaming`, `DiskUseRequirement::kNoDiskUse`, and permits use inside `$facet`, `$lookup`, `$unionWith`, and transactions. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#b-densify-desugaring`
- **B5.** Consequence of B1 and B4 together: the streaming, no-disk-use property belongs to the internal stage only. The prepended `$sort` is a blocking stage, so a pipeline containing `$densify` can still block and spill. This is an inference from B1 and B4, not a directly documented statement. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#b-densify-desugaring`
- **D1.** The syntax is `{ $densify: { field: <fieldName>, partitionByFields: [...], range: { step, unit, bounds } } }`, with `field` and `range` required and `partitionByFields` optional. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D6.** With an explicit `[lower, upper]` bounds array, the lower bound is inclusive and the upper bound is exclusive. The bounds control which documents are *generated*; `$densify` does not filter out existing documents whose field values fall outside the bounds. Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$densify> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D7.** `bounds: "full"` densifies across the full range of field values observed across the whole collection; `bounds: "partition"` densifies within each partition's own observed minimum and maximum. In the implementation, `"full"` sets `_isFullDensify = true` and densifies to the global maximum, while `"partition"` leaves `_rangeDensifyStart` and `_rangeDensifyEnd` as `boost::none`. Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D9.** Every name in `partitionByFields` must be a string and must not begin with `$`; `$densify` errors if a name "Evaluates to a non-string value" or "Begins with `$`". Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **D10.** Starting in MongoDB 8.1, the densify field may not share a path prefix with any entry in `partitionByFields` — for example `field: "timestamp"` with `partitionByFields: ["timestamp.hours"]` is rejected. The implementation enforces this with errors 8993000 and 9554500. Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#d-densify-configuration-surface-and-invariants`
- **F5.** In MongoDB 8.0 and later, equal bounds such as `[10, 10]` generate an empty set. Earlier versions generated one document holding that bound value. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#f-densify-hard-limits-and-known-defects`
- **G1.** `$fill` is pure syntactic sugar. `createFromBson` returns zero, one, or both of a `$setWindowFields` stage (for output fields specified with `method`) and an `$addFields` stage (for output fields specified with `value`). Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#g-fill-desugaring`
- **H2.** `partitionBy` and `partitionByFields` are mutually exclusive. The implementation raises 6050204: "Maximum one of 'partitionBy' and 'partitionByFields can be specified in '$fill'." Sources: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>, <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- **H5.** Every name in `partitionByFields` must be a string and must not begin with `$`; `$fill` errors if a name "Evaluates to a non-string value" or "Begins with `$`". Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#h-fill-configuration-surface-and-invariants`
- **I1.** `method: "linear"` computes each missing value by linear interpolation from the nearest surrounding non-null values, proportioned by the number of nulls between them and ordered by `sortBy`. Documented example: values `0, null, null, null, 10` at indexes 0–4 become `0, 2.5, 5, 7.5, 10`. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **I3.** Leading nulls — those occurring before the first non-null value in sort order — remain null under both `linear` and `locf`. Neither method extrapolates backwards. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#i-fill-fill-semantics-and-limits`
- **U2. Does `$fill` support a backward-fill method?** The MongoDB 5.3 release announcement lists four fill behaviours, including "carrying backward the next observation (forward fill)" (<https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3>). The `$fill` reference documents only `value`, `linear`, and `locf` (<https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/>), and the implementation validates `method` against exactly `locf` and linear interpolation (<https://github.com/mongodb/mongo/blob/master/src/mongo — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#unresolved-disagreements`
- Disconfirming sources were sought and found: SERVER-63145 contradicts the implicit correctness claim of the reference documentation (F6); the Microsoft reference contradicts the manual on whether `bounds` is required (U1); and the release announcement contradicts both the reference and the source on the available fill methods (U2). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#quality-gate`
- 7. `$fill` offers three fill strategies in `output`: a literal or computed `value`, `method: "linear"` (numeric interpolation), and `method: "locf"` (last observation carried forward). `sortBy` is required whenever `method` is used. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#operating-them-together`
- 12. Boundary semantics changed in 8.0: "Starting in MongoDB 8.0, $densify treats bounds with an equal lower and upper bound as an empty set and does not generate a document with the bound as the field value." Earlier versions treated an equal-bound range as a closed interval and generated one document. Consequence: a pipeline that emitted a single point on a degenerate range silently emits nothing after an 8.0 upgrade. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#version-dependent-semantics`
- 3. **Documentation reliability of the non-MongoDB pages.** The Microsoft `$fill` page carries `ai-usage: ai-assisted` metadata and its method table lists `linear` twice (once as "numeric fields only", once as "between surrounding values") (<https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators/aggregation/$fill>). Treat claim 15's portability conclusion as documented-support, not verified-behaviour. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#unresolved-disagreements`
- **S2.** `$fill` populates `null` and missing field values in documents that already exist. It creates no documents. **[converged: M A2, E, P 1]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S9.** `$fill` adds ergonomics, not capability. The same result is reachable by calling `$setWindowFields` with `$locf` or `$linearFill` directly — which is exactly what `$fill` compiles to (S13) — and that route has been available since 5.2 and 5.3 respectively. **[single-source: H 23]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#a-division-of-labour-and-lineage`
- **S11.** `$densify` is a parser-facing alias, not the executed stage. The header declares `kStageName = "$densify"` for the parser and a separate `DocumentSourceInternalDensify` with `kStageName = "$_internalDensify"` for execution. **[converged: M B1, H 12]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S13.** `$fill` is pure syntactic sugar. `createFromBson` returns zero, one, or both of a `$setWindowFields` stage (for outputs specified with `method`) and an `$addFields` stage (for outputs specified with `value`). **[converged: M G1, H 14]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S24.** The internal densify stage declares `StreamType::kStreaming`, `DiskUseRequirement::kNoDiskUse`, and permits use inside `$facet`, `$lookup`, `$unionWith`, and transactions. **[single-source: M B4]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S25.** *Inference.* The streaming, no-disk-use property of S24 belongs to the internal stage only. The `$sort` prepended by S12 is a blocking stage, so a pipeline containing `$densify` can still block and spill. `[M]` labels this an inference from B1 and B4, not a documented statement. **[single-source: M B5]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S27.** `$densify` syntax is `{ $densify: { field: <fieldName>, partitionByFields: [...], range: { step, unit, bounds } } }`. `field` and `range` are required; `partitionByFields` is optional. **[converged: M D1, E 6]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d-configuration-surface-invariants-and-error-codes`
- **S44.** With an explicit `[lower, upper]` bounds array, the lower bound is inclusive and the upper bound is exclusive. The lower bound sets the start value for generated documents irrespective of existing documents. **[converged: M D6, E 14]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S45.** `$densify` does not filter out existing documents whose field values fall outside `range.bounds`. The stage is additive only; out-of-range input passes through and must be removed with a separate `$match` if a bounded output is wanted. **[converged: M D6, E 13]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S47.** `method: "linear"` computes each missing value by linear interpolation from the nearest surrounding non-null values, proportioned by the count of nulls between them and ordered by `sortBy`. Documented example: `0, null, null, null, 10` at indexes 0–4 becomes `0, 2.5, 5, 7.5, 10`. **[single-source: M I1]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **S49.** Leading nulls — those before the first non-null value in sort order — remain null under both `linear` and `locf`. Neither method extrapolates backwards. **[converged: M I3, E 16 & 17, P 8]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **S54.** `$fill` treats a missing field and an explicit `null` as the same condition throughout. There is no mode that distinguishes "absent" from "recorded as null." **[single-source: E 19]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#f-fill-semantics-and-the-outer-boundary-of-the-facility`
- **S69.** **8.0 — silent output change.** Bounds with an equal lower and upper bound (for example `[10, 10]`) are treated as an empty set and generate no document. Earlier versions generated one document holding that bound value. A pipeline that emitted a single point on a degenerate range silently emits nothing after an 8.0 upgrade. **[converged: M F5, H 17, E 15, P 12]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#i-version-dependent-semantics-the-upgrade-hazard-timeline`
- **S74.** Open-source DocumentDB (an LF Projects entity) documents `$densify` with full syntax and examples. **[single-source: P 15]** — <https://documentdb.io/docs/reference/operators/aggregation/$densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#j-portability`
- **Resolved on the factual question, unresolved on the historical one.** No NOCB method exists in shipped `$fill`; backward fill must be built manually, by reversing `sortBy` direction around a `locf` pass. What remains unresolved — and `[H]` and `[E]` both say so explicitly — is whether NOCB was cut before GA, renamed, or never meant as a method. No official source documents either a drop or a rename. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d1-backward-fill-nocb-announced-never-shipped`
- - **Position A.** MongoDB's manual, both current and v8.0, lists `range.bounds` as **Required**. — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/>, <https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/> - **Position B.** Two Microsoft pages list `range.bounds` as **Optional** — the Cosmos DB vCore page (updated 2026-01-28, cited by `[M]`) and the DocumentDB page (dated 2025-12-30, cited by `[E]`). `[M]` additionally notes the vCore page lists `range.unit` as optional. — <https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/operators — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d2-is-range-bounds-required`
- **Largely self-resolving from within `[M]`, which did not connect the two.** `[M]` U3 leaves open whether `"full"` requires buffering all input, but S12 already answers the structural half: under `bounds: "full"` the generated sort is on the densify field alone, which is precisely the ordering a streaming global-maximum scan needs. Positions A and B are therefore compatible — the *internal* stage streams; the *desugared pipeline* blocks at the sort. **What remains genuinely unverified**, as `[M]` states, is the precise handling of the final partition's upper edge under `"full"` bounds at the s — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d6-does-densify-block-and-does-bounds-full-buffer`
- 1. `$densify` (aggregation stage) — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> 2. `$densify` (aggregation stage), v8.0 — <https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/> 3. `$fill` (aggregation stage) — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/> 4. `$locf` (expression operator) — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/locf/> 5. `$linearFill` (expression operator) — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/linearfill/> 6. `$setWindowFields` (aggre — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#mongodb-controlled-not-mutually-independent-see-n4`
- 8. Jane Fine, "Introducing Gap Filling for Time Series Data in MongoDB 5.3", 2022-04-06 (updated 2022-11-21) — <https://www.mongodb.com/company/blog/product-release-announcements/introducing-gap-filling-time-series-data-mongodb-5-3> · <https://www.mongodb.com/blog/post/introducing-gap-filling-time-series-data-mongodb-5-3> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#mongodb-controlled-not-mutually-independent-see-n4`
- 17. "BUG: densify and daylight saving", 2022-12-30 to 2025-02-15 — <https://www.mongodb.com/community/forums/t/bug-densify-and-daylight-saving/206378> 18. "'densify' doesn't produce results for the given partition", 2023-08-28 — <https://www.mongodb.com/community/forums/t/densify-doesnt-produce-results-for-the-given-partition/241601> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#mongodb-controlled-not-mutually-independent-see-n4`
- **G4.** `partitionBy` given as a string is passed straight to `$setWindowFields`; given as an object it is validated as an expression. `partitionByFields` is converted into a nested field specification using `$fieldName` references. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#g-fill-desugaring`
- - [x] Read all four input reports — completed - [x] Build convergence map and provenance tags — completed - [x] Reconcile contradictions, preserve side by side — completed - [x] Derive cross-report findings — completed - [x] Write saturation verdict and pooled source list — completed - [x] Write synthesis to reports/ — completed — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/rabbithole-synthesis.md#tasks`
- 10. `$densify` explicitly does not guarantee the sort order of the documents it outputs; the documentation instructs callers to add an explicit `$sort` after the stage to obtain ordering. — https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 18. The output of `$fill` does not record whether a value was populated by the stage or was already present in the document. Provenance must be captured manually with a `$set` stage placed before `$fill`. — https://www.mongodb.com/docs/manual/reference/operator/aggregation/fill/ — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#silent-wrong-answer-boundaries-no-error-raised`
- 21. SERVER-78472: `$densify` generated documents that violated the specified lower bound, observed on MongoDB 6.0.6 on Atlas. Status Closed/Fixed, fix versions 6.0.9, 7.0.0-rc7, 7.1.0-rc0. Deployments pinned below 6.0.9 remain exposed. — https://jira.mongodb.org/browse/SERVER-78472 — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#confirmed-server-defects`
- **B. Is `range.bounds` required?** MongoDB's own v8.0 reference lists `range.bounds` as **Required** (https://www.mongodb.com/docs/v8.0/reference/operator/aggregation/densify/). Microsoft's DocumentDB `$densify` page lists `range.bounds` as **(Optional)** (https://learn.microsoft.com/en-us/documentdb/query/operators/aggregation/$densify). Either the DocumentDB reimplementation genuinely accepts a `range` without `bounds`, or the Microsoft page is inaccurate. Not resolvable from documentation alone; needs execution against both engines. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#unresolved-disagreements`
- **Met.** Sources span six distinct hosts: `mongodb.com` (reference documentation), `jira.mongodb.org` (defect tracker), `mongodb.com/community/forums` (user reports), `mongodb.com/company/blog` (vendor announcement), `learn.microsoft.com` (independent reimplementation), and `docs.aws.amazon.com` (independent vendor, negative evidence). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/edge-cases.md#quality-gate`
- Each claim is atomic and carries its source inline. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/history.md#claims`
- **A1.** `$densify` creates new documents where values in a numeric or date field are missing from a sequence; it does not assign values to other fields in those documents. Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#a-division-of-labour`
- **E3.** `$densify` "does not guarantee sort order of the documents it outputs. To guarantee sort order, use `$sort` on the field you want to sort by." Source: <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#e-densify-output-contract`
- **G3.** A constant-value output field is translated to `{ <field>: { $ifNull: [ "$<field>", <value> ] } }` inside `$addFields`. The `$ifNull` is what makes the fill non-destructive: existing non-null values are preserved. Source: <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#g-fill-desugaring`
- Met. Six independent source hosts/artifacts were used across four distinct hosts: `www.mongodb.com` (reference documentation and a dated release announcement), `jira.mongodb.org` (a dated defect report), `github.com/mongodb/mongo` (primary implementation source: four separate files), and `learn.microsoft.com` (an independent reimplementation's reference). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/mechanism.md#quality-gate`
- **In scope:** what the two stages do, how they are operated together, their documented restrictions and limits, known defects, portability across MongoDB-compatible engines, and the concrete consequences of each for a production pipeline. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#scope`
- **Out of scope (deliberately not researched):** MongoDB time series collections themselves, `$setWindowFields` and its `$locf` / `$linearFill` window operators, `$dateTrunc` bucketing, Atlas Charts, and non-MongoDB gap-filling systems. Those are separate frontier items. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#scope`
- **Quality gate:** met. Eleven claims below rest on eight sources across five distinct hosts (`mongodb.com`, `jira.mongodb.org`, `learn.microsoft.com`, `documentdb.io`, `oneuptime.com`), including a defect tracker and two independent reimplementations. A disconfirming source was sought and found (see Disagreements §2 and §3). — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/practice.md#scope`
- Provenance tags on each claim below name every input report that carries it. A claim carried by three or four reports is marked **[converged]**; one carried by a single report is marked **[single-source]** and is no weaker for it — the four reports divided the ground deliberately, so single-sourcing usually means only one angle looked there. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#inputs`
- **S14.** Inside the generated `$setWindowFields`, `method: "linear"` maps to the `$linearFill` window operator and `method: "locf"` maps to `$locf`. **[single-source: M G2]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S15.** A constant-value output field is translated to `{ <field>: { $ifNull: [ "$<field>", <value> ] } }` inside `$addFields`. The `$ifNull` is what makes the fill non-destructive — existing non-null values survive. **[converged: M G3, H 14]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_fill.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#b-desugaring-both-stages-are-rewrites-not-engines`
- **S20.** Document synthesis is delegated to a `DocGenerator` with its own `GeneratorState` enum (`kGenerating`, `kReturningFinalDocument`, `kDone`). The generator emits the synthesized documents first and the preserved source document last. **[single-source: M C2]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S21.** The stage keeps a `_partitionTable` mapping each partition key to a `DensifyValue` holding that partition's last-seen value. Partitions are densified and then removed from the table during finalization. **[single-source: M C3]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S22.** With no `partitionByFields`, the implementation still uses the partition machinery with a single dummy partition keyed as `true`, so partitioned and unpartitioned execution share one code path. **[single-source: M C4]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S23.** Densification is modelled over a `DensifyValue` variant covering both numeric and date values, with a `RangeStatement` carrying step, optional time unit, and one of three bounds types: `Full`, `Partition`, `ExplicitBounds`. **[single-source: H 13]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/pipeline/document_source_densify.h> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S26.** *Inference.* Partition state lives in memory in `_partitionTable` (S21) and the stage declares no disk use (S24), so partition cardinality is a memory cost with no spill path. **[single-source: M C5]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#c-execution-and-state`
- **S43.** Generated documents exist only inside the pipeline. `$densify` does not write them to the collection; persisting a densified series requires an explicit `$out` or `$merge`. **[converged: M E5, P 4]** — <https://www.mongodb.com/docs/manual/reference/operator/aggregation/densify/> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S46.** `bounds: "full"` densifies across the full range of field values observed in the whole collection; `bounds: "partition"` densifies within each partition's own observed minimum and maximum. In the implementation, `"full"` sets `_isFullDensify = true` and densifies to the global maximum, while `"partition"` leaves `_rangeDensifyStart` and `_rangeDensifyEnd` as `boost::none`. **[single-source: M D7]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#e-output-contract`
- **S58.** *Capacity rule.* The budget is `partitions × intervals`. A one-minute step over a 30-day window across 12 devices is ≈518,400 generated rows and already exceeds the default. **[single-source: P 9]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#g-hard-limits-and-capacity-arithmetic`
- **S62.** *Structural reading of S61.* `$densify` breaks an assumption the rest of the aggregation optimizer makes — that a stage's output cardinality is bounded by its input cardinality. Any stage or optimization reasoning about document counts must be made densify-aware. **[single-source: M F7 (inference)]** — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **S63.** **SERVER-78472.** `$densify` generated documents that violated the specified lower bound, observed on MongoDB 6.0.6 on Atlas. Closed/Fixed in 6.0.9, 7.0.0-rc7, 7.1.0-rc0. Deployments pinned below 6.0.9 remain exposed. **[single-source: E 21]** — <https://jira.mongodb.org/browse/SERVER-78472> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **S68.** Date arithmetic in the implementation accounts for variable month and year lengths. If a decrement lands on a misaligned day — 31 March minus one month is 28 February — subsequent increments may overshoot the range bounds, and the implementation falls back to the explicit start bound. **[single-source: M F4]** — <https://github.com/mongodb/mongo/blob/master/src/mongo/db/exec/agg/densify_stage.cpp> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#h-defects-three-tracked-two-untracked`
- **Compounding consequence.** Combine this with S49: leading gaps have *no* first-party fill strategy at all. The one method that would have populated them is the one that never shipped. `[E]` is the only report that draws this line. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d1-backward-fill-nocb-announced-never-shipped`
- `[M]` reads this as a genuine divergence in the reimplementation and advises treating `bounds` as required for MongoDB proper. `[E]` declines to resolve it and says it needs execution against both engines. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#d2-is-range-bounds-required`
- **N2. The "bounds optional" contradiction rests on a documentation family whose quality another report independently impeached.** See D2. `[M]` and `[E]` each weighed Microsoft Learn as a peer reference; `[P]` found an `ai-usage: ai-assisted` marker and a duplicated table row on a sibling page. Neither of the first two reports had that fact. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-3-findings-only-the-synthesis-produces`
- Three of the four reports converged on the same ten-odd documented facts, which is what saturation looks like. But that convergence is partly an artifact: all four read the same two reference pages. The genuine marginal value came from the reports that went *elsewhere* — `[M]` into the server source, `[E]` into the defect tracker and community forums, `[H]` into the driver docs and contemporaneous press. Two of the three server defects (S63, S64) and both untracked issues (S65, S66) came from exactly one report each. **A next pass should go where no report went, not deeper where three already — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#method-note-on-saturation`
- **C2. Reimplementation documentation is documented-support, not verified behaviour.** `[P]` states this directly for S74 and S75, and D2/N2 give the concrete reason. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-5-methodological-caveats-carried-forward`
- **C4. Inference labels from the input reports are preserved.** S25, S26, S52, S57, S60, and S62 are marked as inferences in `[M]`; S52 also in `[E]` and `[P]`. `[E]` claim 11 (D3, Position B) is labelled `[derived]` in its own report. — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#part-5-methodological-caveats-carried-forward`
- 9. SERVER-63145, "$densify produces incorrect results with optimizations enabled", fixed 5.2.1 / 5.3.0 — <https://jira.mongodb.org/browse/SERVER-63145> 10. SERVER-78472, "$densify creating documents outside of bounds", fixed 6.0.9 / 7.0.0-rc7 / 7.1.0-rc0 — <https://jira.mongodb.org/browse/SERVER-78472> 11. SERVER-127280, "Reject expression-based sortBy in `$linearFill` parser", created 2026-05-20, resolved 2026-07-24 — <https://jira.mongodb.org/browse/SERVER-127280> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#mongodb-controlled-not-mutually-independent-see-n4`
- 16. `com.mongodb.client.model.densify` package summary, Java driver 5.6 — <https://mongodb.github.io/mongo-java-driver/5.6/apidocs/driver-core/com/mongodb/client/model/densify/package-summary.html> — source: `~/.global-ai-hub/research-runs/frontier-current/densify-and-fill-gap-filling/reports/synthesis.md#mongodb-controlled-not-mutually-independent-see-n4`

## Related concepts

- and — is a part of $densify and $fill Gap Filling
- densify — is a part of $densify and $fill Gap Filling
- fill — is a part of $densify and $fill Gap Filling
- Gap — is a part of $densify and $fill Gap Filling
- Filling — is a part of $densify and $fill Gap Filling
