Files
MultiforaDB/src
A.Shakhmatov 61ce9805c7 commands: $project is a stage, not a note about how to print the answer
It set a variable that the emit applied once. Three consequences, all measured
on a live server before this changed rather than read off the code:

  - only the *last* `$project` in a pipeline had any effect;
  - a `$match` after one still matched on the field it had removed;
  - `{y: {$literal: 5}}` read as falsy, which flipped the whole projection into
    its exclusion branch and returned every document minus `y`, where mongod
    adds a computed `y`.

Now it transforms the stream where it stands, materializing into the same tree
form `$group` already produced. `$match`, `$sort` and `$group` after it read
what it left, which is what "stage" means.

What it cannot do is refused rather than mis-read. A computed field needs the
expression evaluator M2.5 brings, and a nested spec (`{a: {b: 1}}`) needs a
narrowing `query.project` does not do -- both were falsy, and falsy is the
answer that quietly returned the whole document. Codes read off mongod 8.3.7,
and the replies now match it on code, codeName and message text for the empty,
the mixed and the computed forms:

    projection must have at least one field   51272  Location51272
    cannot mix inclusion and exclusion        31254  Location31254
    unknown expression in $project            31325  Location31325

Recorded, not fixed here: `query.project` is shared with `find`'s `projection`,
where a nested inclusion has the same falsy reading and the same wrong answer.
That is a real gap rather than an unimplemented feature -- narrowing is
something this projection should do -- so it is its own fix, not a refusal, and
it belongs with whichever milestone takes `find`'s projection seriously.

Scorecard unchanged again at 194/97/196. The corpus has no `$project` stage
tests either; A6 said so, and this is the second commit to confirm it.

Mutations: drop the refusals and the empty projection answers `ok: 1`; put the
projection back on the emit and the `$match`-after-`$project` case goes red.

190/190 unit tests in ReleaseFast and ReleaseSafe, 83/83 fuzz, e2e 49, e2e2
concurrent, e2e3 16, e2e4 17, e2e6 72, e2e7 86.
2026-08-09 20:43:18 +03:00
..
2026-08-03 12:35:01 +03:00
2026-08-03 23:52:22 +03:00