Skip to content

harness: the sequence-order oracle reads a fold's report without what its declarations disagree over #2125

In progress

Description

@OmarAlJarrah

Problem

The sequence-order oracle reverses each allOf and compares the two compiles' diagnostics without
their message text, so it reads a report of the member fold by its severity, code, place and the
member it names. What the report is about (a type, a bound by its keyword, a default, docs) is
written in the message alone. That leaves the oracle wrong in two directions.

Two reports told apart by their message cancel. Where the reversal moves one report to a place
another report holds in the other order, the two are one to the oracle, the moved one is left
unpaired, the tie it states is not read, and a valid document is judged order-dependent:

openapi: 3.0.3
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    D0: {type: object, properties: {p: {type: array, maxItems: 5, items: {type: string, maxLength: 3}, deprecated: true}}}
    D1: {type: object, properties: {p: {type: array, maxItems: 5, items: {type: string, maxLength: 3}, default: 3}}}
    D3: {type: object, properties: {p: {type: array, minItems: 1, items: {type: string}, writeOnly: true}}}
    D4: {type: object, properties: {p: {type: array, minItems: 1, items: {type: string}, description: da}}}
    M0: {allOf: [{$ref: '#/components/schemas/D3'}, {$ref: '#/components/schemas/D4'}, {$ref: '#/components/schemas/D1'}, {$ref: '#/components/schemas/D0'}]}

As written, morphic compile --verify --diag-limit 0 exits 0 with, in full:

info openapi/degraded-construct spec.yaml#/components/schemas/M0/allOf/2: declarations of field "p" give types t/anon/components/schemas/D0/properties/p and t/anon/components/schemas/D1/properties/p whose values overlap but that the merge does not narrow to one; kept the type the declaration at /components/schemas/D0/properties/p gives over the one at /components/schemas/D1/properties/p, which stays declared on its model
warning pass/default-outside-type spec.yaml#/components/schemas/D1/properties/p: default is a number, and t/anon/components/schemas/D1/properties/p holds a list

With M0's entries reversed, [D0, D1, D4, D3]:

info openapi/degraded-construct spec.yaml#/components/schemas/M0/allOf/1: the merge cannot show that the type the declarations of field "p" merge to admits the default the declaration at /components/schemas/D1/properties/p gives; not adopted, and that declaration stays declared on its model
info openapi/degraded-construct spec.yaml#/components/schemas/M0/allOf/2: declarations of field "p" give types t/anon/components/schemas/D3/properties/p and t/anon/components/schemas/D4/properties/p whose values overlap but that the merge does not narrow to one; kept the type the declaration at /components/schemas/D3/properties/p gives over the one at /components/schemas/D4/properties/p, which stays declared on its model
warning pass/default-outside-type spec.yaml#/components/schemas/D1/properties/p: default is a number, and t/anon/components/schemas/D1/properties/p holds a list

M0.p takes t/composed/components/schemas/M0/allOf/properties/p in both. Both orders follow the
documented tie (docs/compilers/openapi.md#allof-redeclared-property: "Of those holding as many,
the later wins"; a default the merged type may not admit is reported). Read back into the source as
written, the reversed default report sits at allOf/2, where the as-written overlap report sits,
and the oracle pairs those two, which agree but for their message. The reversed overlap report is
left over, and morphic-harness spec.yaml reports:

spec.yaml sequence-order-dependent diagnostics depend on sequence order (-as-written +reversed):
+"info\x00openapi/degraded-construct\x00/components/schemas/M0/allOf/1\x00false\x00p/composed/components/schemas/M0/allOf/properties/p\x000\x000\x00"
document depends on sequence order (-as-written +reversed):
-225:       "docs": {
-226:         "description": "da"
-227:       },
+225:       "docs": {},

sequence-order-invariance 1 1 0.

A tie over a bound and one over a type are one to the oracle. It reads a tie from a mirrored
pair of openapi/conflicting-redeclaration reports, and finds it contradicted only where the
member takes, in each order, the type its report says lost; a member holding the same type in both
orders while its reports trade places passes. That is right where the tie is over a bound:

openapi: 3.0.3
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    A: {type: object, properties: {p: {type: string, pattern: "^a"}}}
    B: {type: object, properties: {p: {type: string, format: uuid, pattern: "^b"}}}
    M: {allOf: [{$ref: '#/components/schemas/A'}, {$ref: '#/components/schemas/B'}]}

M.p is t/prim/uuid in both orders and draws one warning, as written
declarations of field "p" disagree: conflicting pattern ("^b" and "^a"); kept what the declaration at /components/schemas/B/properties/p says over the one at /components/schemas/A/properties/p, which stays declared on its model,
reversed the same with A and B swapped; the oracle passes it (1 0 0), as the rule documents.
But a compiler defect reporting a type conflict as following the entries while choosing the type by
other means draws the same two reports over the same unmoved type, and passes too: the code is one
for a conflict of types and of bounds, and the related entries name the places and the member,
not what the declarations disagree over. Treating an unmoved type as a contradiction would flag the
valid document above.

Cause

difference in internal/harness/sequenceorder.go takes the two compiles' reports as multisets of
diagnosticKey (internal/harness/order.go), which leaves the message out, before movedReports
reads what is left; the tie reading (tiedBy, keptTypes, internal/harness/ties.go) has the
same key and the related entries, nothing more (morphic @512f3ee46).

Direction

A draft, with the choice open:

  • give the fold's reports a structured member saying what its declarations disagree over (the
    type, a bound by its keyword, a default, a detail by its field), filled where the fold already
    knows it. The key tells the two reports above apart, and the oracle reads a tie over a type as
    contradicted where the type is unmoved and a tie over a bound by that bound. A change of a
    diagnostic's shape moves IRVersion and the JSON findings report's schema version;
  • compare the message with every place it names erased. This splits the first pair but brings back
    a sensitivity to wording the oracle dropped on purpose, and it does not settle the second, whose
    messages also swap the values they quote;
  • state both limits beside difference and tiedBy.

A judge of types in the harness, the other way to read the second case, repeats the compiler's
narrowing rule in a second place that cannot stay in step with it.

Out of scope

Related: #2097, #2099, #2059

Priority: P4, rule 1 (a test oracle's verdict and reach; it changes no lowering, validation, IR or
emitted output until the first direction's shape change is taken up). morphic-harness on the
first spec → sequence-order-invariance 1 1 0, on the second 1 0 0 (morphic @512f3ee46).

Activity

  1. added
    type:bug
    priority:P4
    on Nov 19, 2026
  2. OmarAlJarrah commented on Nov 29, 2026

    @OmarAlJarrah
    MemberAuthor

    #2354 closes this at its merge on the first problem, which bfb46546f fixes. Each member fold report now sits where the declaration it is about is written and names no node of its own. It lists every member it decided (decided) and, where it is about two declarations, the place of the one whose say was kept (kept, the first written of those agreeing with it). So two reports that differ only in their message no longer meet with the same site and related entries. At this issue's D1/properties/p, the overlap reported as written keeps D0's place, and the refusal of D1's default reported reversed keeps none.

    The sequence-order oracle reads a report by its code, site and related entries:

    • a decided member is compared with every index of a reversed sequence erased, since the reversal moves the declaration that names it (decidedErased);
    • a tie is a pair of reports carrying a kept place, one in each order with the two places the other way round (tiedBy). Stated by a report other than a conflict, it decides what the member folds over every declaration; stated by conflicts alone, it leaves the member's deprecation, docs, name and XML hints compared (statedAlone);
    • a report carrying no kept place ties nothing, whether or not the reversal moves it (7bc855725). It is forgiven, itself alone, only where it is about a member a tie decided or a model holding one, or sits at or beneath such a member's pointer (untied);
    • an untied member's kept place is compared as it stands, erased, since of agreeing declarations it names the first written in either order, and by the node the fold minted where the member takes one.

    TestCheck_SequenceOrderOracleHoldsOnTheRealCompiler/a_tie_whose_report_leaves_a_declaration_that_reports_its_default_reversed (940aff2af) shows the cancellation alone. M0 composes D0, D1 and D2, and D1's and D2's lists of p overlap and hold as many declarations, so the later wins. As written, the tie's report sits at D1/properties/p, keeping D2's place. Reversed, it sits at D2/properties/p, keeping D1's, and D1/properties/p also reports giving its default up to D0's, keeping D0's place. The two reports at D1 agree in severity, code, site and decided member and differ in their kept place, so neither cancels the other. The oracle reads the mirrored tie, forgives p, and passes (1 0 0), and p takes the default [a] in either order.

    The second problem remains a stated limit. No message is read, so a tie over a bound and one over a type at the same places look the same, and a tie over one detail decides every detail the member folds. This is written beside difference, tiedBy and tiedByConflictsAlone and in CLAUDE.md; #2340 tracks it.

    The first reproduction is still found, for another reason: morphic-harness gives sequence-order-invariance 1 1 0 at a18eb82e4. Of the overlapping lists, the fold keeps D0's over D1's as written and D3's over D4's reversed, so the composed node holds D4's description in one order only. The refusal of D1's default, a report with no kept place at a member no tie decided, is found with it. That is the order-dependent winner #1931 records, with its spec, not a report the oracle misreads.

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:P4type:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions