Repository navigation
Description
Problem
A refactor that changes where a report is raised or collected can change the order of the diagnostics for one input, and the skills reach that order only through the corpus.
The order is output. docs/cli.md gives a report's findings "in the order reported". docs/micro-compiler-design.md §6.1 names this as the neutrality risk of moving to bottom-up returns: "compile.Diags preserves first-seen order, but "first-seen" differs between central accumulation and bottom-up returns, so some reordering is expected and each instance must be understood".
Three things in the skills see diagnostics, and none of them reaches a reordering on an input the corpus lacks:
morphic-verifying-changes/references/claims.md#prove-safety-arguments-in-every-directionchecks a neutrality claim with "run old and new over the corpus and diff the IR".scripts/sweep.pycompares each spec's diagnostics byte for byte, but only for the specs the corpus holds.- The determinism angle and
differentials.md#two-order-diagnosticscompare diagnostics as a sorted multiset, which is blind to their order by design.
A moved report changes the order only on an input that raises it beside a report it moves past. Where no committed spec does that, every sweep reads identical. During #2354's work, a refactor reordered a nullability finding in this way, and it passed every corpus sweep.
Direction
A draft, as a rule in morphic-reviewing-prs/references/correctness.md beside refactor-differential-fuzz, or in claims.md#prove-safety-arguments-in-every-direction. Where a change moves the point at which a report is raised, collected or deduplicated (a return up a frame, a report moved to another phase, a new dedupe), list each pair of codes whose relative order the move can change. Compile a minimal spec raising both on $main and on the head, and diff the diagnostic list in order. A difference is a behaviour change: the PR body states it, or the change fixes it.
Out of scope
Whether diagnostic order should be part of the contract at all. Sorting at the engine boundary would remove the class, but that is a design decision of its own.
Related: #2354
Priority: P4, rule 1 (housekeeping): a skills change that alters no lowering, validation, IR or emit-contract behaviour. git grep -n -E 'for neutrality|sorted multiset|as a sorted$' -- .claude/skills → the neutrality probe at claims.md:168 runs over the corpus, and the other four hits compare diagnostics as a sorted multiset (morphic @4a7a384c9).
Activity
OmarAlJarrah commentedon Nov 29, 2026
More evidence for the direction, from a review of #2354's branch: an identical corpus does not show that finding order is kept.
A reviewer wrote a generator of shapes, one family per principal kind:
{allOf: [{<principal>, k1, k2}]<outer>}, placed both atitemsand as the component. Each shape was compiled on the branch and on its base, and the diagnostic lists were compared in order. Of 6,370 generated shapes, 1,044 reported their findings in a different order. Over the same two builds, every committed spec stayed byte-equal, both in its IR and in its diagnostics.So the rule should ask for a generator over the shapes the moved report can meet, not only one minimal spec per pair of codes. Such a generator crosses each principal kind with the keywords beside it, at each position. The comparison must be in order, not as a sorted multiset.