Skip to content

engine: decide whether a run's findings keep the order reported or are sorted #2380

Backlog

Description

@OmarAlJarrah

Problem

A run's findings come out in the order the stages reported them, and that order is output. docs/cli.md gives a JSON report's findings "in the order reported". The text format writes "the first three of each code and severity, in the order they were reported", so the order also decides which findings a default run shows. Yet the order is only whatever sequence the stages happened to collect their reports in.

A change that moves where a report is raised, collected or deduplicated reorders findings on any input that raises it beside another, and no committed spec has to show it. Across one refactor, 1,044 of 6,370 generated shapes reported their findings in another order while every committed spec stayed byte-equal (#2356). The order oracles compare diagnostics as a sorted multiset, so they cannot see it. docs/micro-compiler-design.md §6.1 met the same risk when accumulation became bottom-up returns, and answered it by explaining each reordering by hand.

On the golden spec, the order is neither sorted nor grouped:

$ morphic validate --diagnostics-per-code-limit 0 openapi.json 2>err; echo "exit $?"
exit 1
$ wc -l < err; awk '{print $2}' err | sort -u | wc -l; awk '{print $2}' err | uniq | wc -l
4660
18
251
$ awk '{print $3}' err | sort -C || echo "not sorted by location"
not sorted by location

4,660 findings of 18 codes arrive in 251 runs of one code, in no order a reader could reproduce from the document.

Direction

A decision, with the options as drafts:

  1. Keep the reported order as the contract. A review holds each change moving a report to a generated, in-order diff (morphic-reviewing-prs/references/correctness.md#moved-report-order, added by chore(skills): resolve the skills issues filed up to #2407 #2379), and a PR states every reordering.
  2. Sort the findings at the engine boundary by a total key, such as source, pointer, position, code and message, and state that key in docs/cli.md and docs/library.md. This removes the class: no refactor can move the order again. It costs one sort per run, and it changes which three findings of a code the text format writes.
  3. Sort the JSON report alone, and keep the text format in the reported order.

Weigh each against what a consumer reads in the order, such as the first finding of a code as the one to fix first, and against docs/prior-art.md.

Out of scope

What a finding says, and which codes a run reports.

Related: #2356, #2379

Priority: P2, rule 6 (indirect impact: the order of the findings the golden spec draws, not its IR). The commands above → 4,660 findings of 18 codes in 251 runs of one code, not sorted by location (spec @23b96e30941ce8affc503744ca9fc5170ef24ed1, morphic @4a7a384c9).

Activity

  1. added
    type:feature
    priority:P2
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:P2type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions