Repository navigation
feat(ir)!: state tuple openness and bounds from prefixItems - #734
Open
fuad-daoud wants to merge 3 commits into
Open
fuad-daoud wants to merge 3 commits into
fuad-daoud wants to merge 3 commits into
Conversation
ir.Tuple gains Constraints, the field List already carried, so a tuple's minItems/maxItems/uniqueItems move off Unmodeled and onto the node. A tail past the positional head is one entry under openapi:items-after-prefix whatever its source: an absent items keeps the literal true at the tuple's own pointer, items: true and a typed tail keep what they wrote at their own /items pointer, and items: false keeps nothing and is reported for nothing. items absent beside unevaluatedItems is left to the §4.7 keeper, whose raw value is the tail. The head is a positional head of fixed length whose positions are not individually required; an instance's length is bounded by Constraints, never restated by Elems. IRVersion moves to 0.7.0: a 0.6.0 consumer that read a tuple's collection bounds out of unmodeled now finds nothing there.
6 tasks done
Resolve the conflicts with main, move the 0.7.0 history entry into ir-design §2.1 where main now keeps it, and bring the doc comments this branch adds under the 100-word cap main now enforces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GCzyGPq9DQ7RLfagZm2JB5
8 tasks done
Main took irVersion 0.7.0 for group IDs and idSpaces, so this change moves to 0.8.0: the constant, its ir-design.md history entry, the neighbour rows of TestCompatibleVersion and every golden.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A JSON Schema tuple written with
prefixItemscurrently reports its openness the wrong way round, and drops the bounds beside it.prefixItems(noitems) is silent. The source's open tail — every position past the fixed head is unconstrained — reaches the IR in no form at all, and the node is byte-identical to a genuinely closed one.items: falseis reported as open. It lowers to the sameTuple, keepsUnmodeled["openapi:items-after-prefix"], and emits "items after prefixItems is an open tuple". The closed form is described as the open one.minItems/maxItems/uniqueItemsbeside a tuple are homeless.ir.Tuplehas noConstraintsfield, so the census keeps them verbatim underUnmodeledand reports the keyword as having no home.This corrects the lowering to the JSON Schema 2020-12 reading, and gives a tuple the bounds field
Listalready has.Change
ir.TuplegainsConstraints *Constraints(the same field and tags asList), and the tail past the positional head is decided by a single helper over three states:Unmodeled["openapi:items-after-prefix"]Constraintsitemsabsenttrue, at the tuple's own pointerinfo degraded-construct, says openitems: true/itemsitems: {schema}/itemsitems: falseAn absent
itemsbehaves as the empty schematruein 2020-12, so its entry states the effective tail; the declaration pointer distinguishes it from a writtenitems: true.items: falseis exactly what the head states, so it keeps nothing and is reported for nothing. Whenitemsis absent butunevaluatedItemsis present, nothing is synthesized — the §4.7 keeper already holds that keyword verbatim, and its raw value is the tail.A tuple's tail is therefore closed exactly when it carries no
openapi:items-after-prefixentry, and open exactly when it carries one (unconstrained when the value istrue, typed when it is a schema). "Closed" says nothing follows the head; it does not mean "exact": with nominItemsthe same source still accepts a shorter array, so the length comes fromConstraints, never from the head alone.ir.Tuple's prose loses "fixed-arity" for the same reason —prefixItemsrequires none of its positions, so a head of two names two element types and never says two elements are required. The TypeSpec and Erlang rows carry the forward note that a genuinely fixed tuple must lower withConstraints.MinItems = len(Elems)and no tail entry, or every position becomes optional in silence.Breaking
IRVersionmoves to 0.7.0. This adds a JSON key (constraints) to every tuple node and movesminItems/maxItems/uniqueItemsoffunmodeledonto it, so a consumer pinned to 0.6.0 that read a tuple's collection bounds out ofunmodelednow finds nothing there. The stamp move is the whole of the break; everyprefixItemstuple's JSON changes.Test plan
make gategreen; coverage is exactly 100% (7598 of 7598 statements).true,false, typed, bounds), each assertingElems,Constraints, the fullUnmodeledmap and whether the info fired.tuples-prefixitems.yamlholds one schema per state (closed first, so a lowering that confused closed with open is visible in the single-order golden), withassertTuplesasserting the tail entry's value, reason and pointer per schema.unhomed-keywordsturnsItemsBoundOnTupleinto a control (items: false,maxItems: 2): it loses theopenapi:maxItemsentry and gainsconstraints.items; dropping thefalsearm; dropping the tuple arm from the census; not calling the bounds reader.irverifycorpus and the unpreservable suite pass unchanged;unwitnessed.golden.txtis untouched, soTuple.Constraintsis witnessed by the corpus.Merge ordering
This branch and the webhook-name branch both set
IRVersionto0.7.0from the same base. Whichever merges second must rebase and take0.8.0, re-anchoringir/document_test.go's three literals and regenerating its goldens.