Skip to content

harness: no oracle catches a declaration dropped without an Unmodeled entry #2374

Backlog

Description

@OmarAlJarrah

Problem

No oracle catches a lowering that loses a source declaration: no typed home holds its value, no Unmodeled entry keeps it, and no diagnostic says it was dropped. Every oracle of harness.Check judges something else:

  • no-panic, invariants and no-error-diagnostic judge one compile;
  • round-trip, determinism and idempotence compare a document with itself or with a rerun;
  • order and sequence-order compare two orders, and a loss that happens in both orders compares equal.

The presence oracle reads loss, but only on the schema cases, and only where a construct changes nothing or a changed value changes nothing (internal/harness/presence.go, whatChangesNothing, whatDiscarded). A spec on disk never reaches it.

One such loss went through every oracle in the work on #2354. A composition cycle of three models redeclares id as three kinds:

openapi: 3.1.0
info: {title: t, version: "1"}
paths: {}
components:
  schemas:
    A: {allOf: [{$ref: '#/components/schemas/B'}], properties: {id: {type: string}}}
    B: {allOf: [{$ref: '#/components/schemas/C'}], properties: {id: {type: integer}}}
    C: {allOf: [{$ref: '#/components/schemas/A'}], properties: {id: {type: boolean}}}

At fae29c4, a commit of that work which #2354's branch does not hold yet:

$ morphic compile --verify --diagnostics-per-code-limit 0 ring.yaml > ir.json; echo "exit $?"
warning openapi/conflicting-redeclaration ring.yaml#/components/schemas/A/properties/id: declarations of field "id" disagree: incompatible types type/primitive/integer and type/primitive/string; kept what the declaration at /components/schemas/B/properties/id says over the one at /components/schemas/A/properties/id, which is kept verbatim under Unmodeled; the same holds at each of 3 models composing field "id"
warning openapi/conflicting-redeclaration ring.yaml#/components/schemas/B/properties/id: declarations of field "id" disagree: incompatible types type/primitive/bool and type/primitive/integer; kept what the declaration at /components/schemas/C/properties/id says over the one at /components/schemas/B/properties/id, which stays declared on its model; the same holds at each of 3 models composing field "id"
warning pass/composition-cycle ring.yaml#/components/schemas/A: composition never ends: base type/openapi/components/schemas/B leads back into a cycle of bases and mixins
warning pass/composition-cycle ring.yaml#/components/schemas/B: composition never ends: base type/openapi/components/schemas/C leads back into a cycle of bases and mixins
warning pass/composition-cycle ring.yaml#/components/schemas/C: composition never ends: base type/openapi/components/schemas/A leads back into a cycle of bases and mixins
exit 0
$ jq -c '.types | to_entries[] | select(.key|test("schemas/(A|B|C)$")) | {id: (.key|split("/")|last), type: .value.properties[0].type.target, ptr: .value.properties[0].provenance.pointer, kept: [.value.properties[0].unmodeled[] | .value]}' ir.json
{"id":"A","type":"type/primitive/bool","ptr":"/components/schemas/A/properties/id","kept":[{"type":"string"}]}
{"id":"B","type":"type/primitive/bool","ptr":"/components/schemas/B/properties/id","kept":[{"type":"string"}]}
{"id":"C","type":"type/primitive/bool","ptr":"/components/schemas/C/properties/id","kept":[{"type":"string"}]}
$ morphic-harness ring.yaml
ring.yaml ok

oracle                     asked  found declined
no-panic                       1      0        0
invariants                     1      0        0
no-error-diagnostic            1      0        0
round-trip                     1      0        0
determinism                    1      0        0
idempotence                    1      0        0
order-invariance               1      0        0
sequence-order-invariance      0      0        1  nothing to permute 1

B's {type: integer} is nowhere. B's id is bool, the one Unmodeled entry keeps A's {type: string}, and the warning at B says B's declaration "stays declared on its model". On main (4a7a384), the same spec gives A a string, B an integer and C a bool. The order oracle asked and found nothing; the sequence-order oracle declined.

A check by pointer alone would pass this case too: B's property stands at B's pointer, and a warning names that pointer.

Direction

A draft. Add a loss oracle that maps each keyword a schema writes, by its pointer and keyword, to one of:

  • a typed home that holds its value, such as the property at that pointer typed as the keyword says;
  • an Unmodeled entry whose provenance is that pointer and whose value holds the keyword;
  • a diagnostic that names that pointer and says the keyword was dropped or replaced.

It reports every keyword that maps to none. A diagnostic saying a declaration "stays declared" excuses nothing unless the home holds its value. The mapping from keyword to typed home is the hard part. A first version could cover the keywords the conformance matrix already pins for each row, and grow from there.

Out of scope

The cycle fold's loss itself, a defect of the work on #2354 that belongs to that work. The presence oracle's reach.

Related: #2354

Priority: P4, rule 1 (housekeeping): a test-oracle feature that alters no lowering, validation, IR or emit-contract behaviour, and the issue names no higher-tier work it unblocks. It would guard lowering fidelity on every spec, the golden spec included, but rule 1 decides first. The case that went through does not reach the golden spec: morphic compile --diagnostics-per-code-limit 0 openapi.json → 0 pass/composition-cycle among 4,660 findings (spec @904c5434, morphic @4a7a384c9). The harness run above → ring.yaml ok (morphic @fae29c473).

Activity

  1. added
    type:feature
    priority:P4
    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:P4type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions