Repository navigation
Description
Problem
An allOf whose kinds are not an object alone lowers to a use of one of its conjuncts, not to a Model (docs/ir/models.md#an-allof-no-object-satisfies: "A Model says its value is an object"). Where the read of the conjuncts is cut short, docs/compilers/openapi.md#allof-refinement keeps the allOf composing, and the composition is a Model whatever its conjuncts say, so a schema that admits only strings lowers to an object type:
$ python3 -c 'b = "{type: string}"
for _ in range(34): b = "{allOf: [" + b + "]}"
print("openapi: 3.1.0\ninfo: {title: t, version: \"1\"}\npaths: {}\ncomponents:\n schemas:\n S: " + b)' > nest34.yaml
$ morphic compile --diag-limit 0 nest34.yaml >ir.json; echo "exit $?"
info openapi/degraded-construct nest34.yaml#/components/schemas/S/allOf/0/allOf/0/…: inline allOf branch is nested past the flattening depth of 32, so its own allOf was not flattened, and the branch is kept verbatim under Unmodeled
exit 0
$ jq -c '.types | to_entries[] | select(.key | test("schemas/S$")) | {kind: .value.kind, base: .value.base.target, unmodeled: (.value.unmodeled // {} | keys | length)}' ir.json
{"kind":"model","base":null,"unmodeled":1}(the pointer in the report repeats allOf/0 34 times and is shortened here.) The same schema with 33 nested allOfs is a Scalar over string with no diagnostic. The cut can come from the other limits the rule lists too. An allOf of 65 {type: string} entries (64 is a Scalar over string) lowers to a Model with no member and a warning that says what the lowering does: "inline allOf branch declares a type that is not an object, which the composed model asserts it is" (65 reports, one per entry). A const whose value no reading can convert is another, but it also draws an error, so the document is refused there.
The Model is an empty object type for a schema that admits strings. Two tests pin it: TestRefinement_ACappedBranchStaysAComposition (a string under 34 nested allOfs) and TestRefinement_AConstUnreadableStaysAComposition. The behaviour is the one allof-refinement documents for a read cut short, so what is open is whether the documented fallback is the right one. It disagrees with the statement the models document makes of a Model, and with the rule the OpenAPI compiler states for the position (a Model only where the kinds it lowers to are an object alone), which a position whose kinds were not read cannot show.
main (morphic @9562ea46d) and #1996 (at 6630476) lower the specs above alike, apart from the number of entries the 65-entry case keeps (65 on main, 1 with #1996).
Cause
Among the exits that keep an allOf composing, decide (compilers/openapi/internal/schema/refinement.go) returns no refinement when the read does not finish (w.incomplete()) or refinableBranches refuses the conjuncts, and the allOf then lowers as the composition (lowerAllOf, allof.go), a Model whose Base, Mixins and members come from the conjuncts it could read (morphic @9562ea46d).
Direction
A draft; the answer differs by what the read missed.
- Keep the
Model, and say so: the composition is the fallback because it holds every conjunct, and the warning of the over-wide case already says the model asserts an object. It costs a consumer readingKindan object type for a schema whose conjuncts may admit none, and the nested case draws only an info. - The top type keeping the
allOfverbatim where the part of the read that finished names no object (no conjunct writesproperties,requiredor the like, and none names an object kind), and theModelwhere it does. It claims least: the position is "any value" with the wholeallOfunderUnmodeled, as for a schema the compiler cannot read. It costs the composition where the unread conjuncts are the objects that make it one (a 65-entry composition of object$refs is aModelover aBaseand 64Mixins, and the top type loses that), so the rule must say which finished part decides. - Raise the limits so that a schema reaching them is no schema the compiler is expected to lower, and keep option 1 for what remains; the nested case needs 34 levels and the wide case 65 entries, which no document written by hand reaches.
Either answer is stated in docs/compilers/openapi.md#allof-refinement and pinned by the two tests above, which then assert the kind rather than only the Go type.
Out of scope
- An
allOfwhose conjuncts' value sets share no member, which composes an emptyModelwith infos only ({allOf: [{enum: [a, b]}, {enum: [c, d]}]}), a different cause that would take the same answer. - An entry whose
$refnames nothing (openapi: an allOf branch whose $ref fails is kept nowhere in the IR, with every keyword beside the $ref #1568, openapi: a value set on an allOf entry beside a $ref naming nothing composes a model, where beside the $ref it is the value set #2064).
Priority: P4, rule 2 (a limit or an unconvertible value: the cut is reached only by adversarial depth or width, a cycle or a value no JSON holds). jq '[.. | objects | select(has("allOf")) | .allOf | length] | max' openapi.json → 3, and no openapi/budget-exceeded diagnostic in the golden spec compiled by main or #1996 → 0 (cloudflare/api-schemas@8b1a4518; morphic @9562ea46d and #1996 at 6630476).
Activity
OmarAlJarrah commentedon Nov 18, 2026
Two residues after #1996 (at 248aba1), which the issue does not say. Its out-of-scope list leaves value sets sharing no member aside as composing an empty
Model; #1996 changes that, and it leaves kinds sharing none as they were.(a)
KindsandKindRefsare an emptyModel, with the warning that says no instance satisfies them. Conjuncts whose kinds share none admit no value, so what they lower to is the question this issue asks of a read cut short, and here the read finished. Onmain(9562ea4)KindRefsis aModelwithStrandIntas mixins; with #1996 it keeps both$refs verbatim and has no base.(b) The same unsatisfiable schema about a value set lowers three ways. Two entries sharing no member (
EnumEntries) are the top type keeping each entry underUnmodeled. Anenumwritten beside theallOf(EnumBeside) is theEnumof thatenum's members, whichallOf/0contradicts, kept underopenapi:allOf/0; each warning says what its lowering cannot state. AndKindsis an object type. OnmainEnumEntrieswas an emptyModelwith infos only andEnumBesidethe sameEnumwith an info, so #1996 moved the entries' spelling and not the one beside theallOf. Whichever answer this issue settles for anallOfno value satisfies (the top type keeping each conjunct, or aModel), the three spellings should give it.OmarAlJarrah commentedon Nov 18, 2026
One more case the answer here decides: a member of a cycle of
allOfs that writes object keywordsand no
type.With #1996 (at c2bd480),
Nis aModelofxwhoseBaseisN2, with the twocomposition never endsfindings, and its provenance names nokind-inference;Mis aModelwhose
BaseisM2and names it. With--opt kind-inference=false,Nis the sameModelandMaScalarkeepingproperties:Nis aModelby this issue's fallback, not by the policy,so the node carries no mark, as
docs/compilers/openapi.md#shape-applicatormarks only a node thepolicy builds. The compiler's own reading of
N's kinds (lowersTo, which reads a cut read's kindsoff the keywords it writes) does count them as the policy's, which the dead-branch check and the
election read. If the answer here moves a cut read off the
Model, a position likeNshould takethe kinds the policy reads, marked, as
Mdoes; if it keeps theModel, the two readings stayapart and that is worth a sentence in the rule.
main(morphic @38da05c38) marks neither.OmarAlJarrah commentedon Nov 30, 2026
Decided and fixed in #2354 at 7213104, which closes this on merge: an
allOfcomposes aModelonly where the kinds it reads are an object alone (docs/compilers/openapi.md#allof-refinement). With the specs here:{type: string}under 34 nestedallOfs: the top type, keeping theallOfwhole (degraded_lowering) beside the depth report.{type: string}: theScalaroverstring, with no finding.Kinds,KindRefs: a closedModelwith no member, keeping each conjunct.EnumEntries,EnumBeside: the closed emptyEnumofstring, keeping every set. Each draws oneopenapi/unsatisfiable-schemawarning.NcomposesN2, markedkind-inferenceasMis.