Repository navigation
fix!: bound retained compile memory and give cross-module facts one owner - #237
Merged
Merged
Conversation
…wner
Breaking: three limits now measure what is retained or compared rather than a proxy, so a schema or document near a limit can be accepted or rejected differently. Some diagnostics change position, text or precedence, as the paragraphs below describe. The exported Go API is unchanged. Only option doc comments change.
`value.Builder` charges the inherited facet entries a derived type retains against its storage budget. Before, it charged only the type's own facets while copying every inherited bound and enumeration into each derived type. A schema of a few hundred KB within every public limit could then retain gigabytes and run out of memory instead of failing. Such a schema now fails with `schema.limit`. Merged facet lists are allocated at their exact length, and a side the derived type does not change shares the base's storage. docs/RESOURCE_LIMITS.md states the per-type retention.
`MaxSchemaPatternRetainedBytes` charges a compiled pattern's tables by capacity instead of length, because the machine retains the whole backing arrays. The retained estimate rises by the arrays' append slack, so a pattern set close to the limit can now exceed it. Each compiled pattern records an explicit runner mode, and the general NFA branch that no pattern could reach is deleted.
`MaxIdentityTupleBytes` caps the canonical text bytes of every identity entry: the sum of each field's canonical length plus one byte between fields. Key, unique and keyref tuples were measured by an internal encoding of the key, and ID and IDREF values by their canonical text. The one public limit meant two things.
A `schemaLocation` or `xml:base` that the project's URI grammar admits but the built-in fallback cannot represent is now an unavailable optional reference, as ARCHITECTURE.md already stated. The fallback re-parsed such references with `net/url` and reported its errors. A value such as `http://h:abc/x.xsd`, valid as `xs:anyURI`, failed compilation, and the outcome depended on whether a resolver was configured.
The include and import reference rules (src-include 2.1, src-import) are decided once, when the compile is planned. They were decided at load time when the referencing document declared `targetNamespace`, and at plan time when it was a chameleon document. The same reference violation then won or lost against a later parse violation depending on that attribute. It now loses to a later parse violation in every case.
One identity operation owns the sequence that records an assessed value, checks its fixed value, captures it into matched fields and commits it. Seven call sites ran these steps by hand in two orders. When a fixed-value violation and an identity violation hit the same node, a declared attribute reported only the identity violation and a wildcard attribute only the fixed-value violation. Both now report the fixed-value violation.
`internal/schema` constructs and renders runtime names. An attribute diagnostic names a known qualified attribute as `"{urn:a}x"`, as it already named an unknown one, where it printed the local name alone. Tests build runtime names through `Schema.ResolveName`, the constructor production uses, and `Schema.NameOf` is deleted.
The XML reader owns the class and position of its errors. `internal/format` reports a document with no root element at the reader's position, as validation does, rather than at 1:1. Misuse of the reader's lifecycle is reported as `internal.invariant` by every consumer. A DOCTYPE declaration is rejected at its `<`. The `KindDirective` token kind, which no consumer could receive, is deleted, so the token switches no longer opt out of the exhaustive lint.
After a simple type is completed, `internal/value` alone holds its structure (base, list item, union members, variety and whitespace), and `internal/schema` reads it through `Builder.TypeView`. Schema's stored declaration no longer carries a copy of that structure, and the duplicate union-facets flag is deleted.
docs/RESOURCE_LIMITS.md owns what each public option means. The option doc comments in compile.go and session.go keep a one-line summary, the zero-value rule and a link, and a test checks that form.
The oracle run cache key covers every file under the directory the providers mount, not only the files a case declares. A changed file that a provider reads now invalidates the cached verdict.
Exported identifiers of internal packages that only tests used are deleted. Their tests go through each module's real surface instead, such as compiling a schema or parsing XML. The deleted identifiers include `schema.Compile`, `value.BuiltinTypeID`, `xmlstream.NewAttr`, `format.XML` and the identity-program read accessors. Production methods that only tests called are deleted too. `tests/test_only_exports_test.go` fails when an exported identifier of an internal package has no production use in the host or js/wasm build. A new `make lint-test-only-code` pass, part of `make lint`, runs `unused` with tests excluded so it reports unexported production code that only tests reach.
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.
Breaking: three limits now measure what is retained or compared rather than a proxy, so a schema or document near a limit can be accepted or rejected differently. Some diagnostics change position, text or precedence, as the paragraphs below describe. The exported Go API is unchanged. Only option doc comments change.
value.Buildercharges the inherited facet entries a derived type retains against its storage budget. Before, it charged only the type's own facets while copying every inherited bound and enumeration into each derived type. A schema of a few hundred KB within every public limit could then retain gigabytes and run out of memory instead of failing. Such a schema now fails withschema.limit. Merged facet lists are allocated at their exact length, and a side the derived type does not change shares the base's storage. docs/RESOURCE_LIMITS.md states the per-type retention.MaxSchemaPatternRetainedBytescharges a compiled pattern's tables by capacity instead of length, because the machine retains the whole backing arrays. The retained estimate rises by the arrays' append slack, so a pattern set close to the limit can now exceed it. Each compiled pattern records an explicit runner mode, and the general NFA branch that no pattern could reach is deleted.MaxIdentityTupleBytescaps the canonical text bytes of every identity entry: the sum of each field's canonical length plus one byte between fields. Key, unique and keyref tuples were measured by an internal encoding of the key, and ID and IDREF values by their canonical text. The one public limit meant two things.A
schemaLocationorxml:basethat the project's URI grammar admits but the built-in fallback cannot represent is now an unavailable optional reference, as ARCHITECTURE.md already stated. The fallback re-parsed such references withnet/urland reported its errors. A value such ashttp://h:abc/x.xsd, valid asxs:anyURI, failed compilation, and the outcome depended on whether a resolver was configured.The include and import reference rules (src-include 2.1, src-import) are decided once, when the compile is planned. They were decided at load time when the referencing document declared
targetNamespace, and at plan time when it was a chameleon document. The same reference violation then won or lost against a later parse violation depending on that attribute. It now loses to a later parse violation in every case.One identity operation owns the sequence that records an assessed value, checks its fixed value, captures it into matched fields and commits it. Seven call sites ran these steps by hand in two orders. When a fixed-value violation and an identity violation hit the same node, a declared attribute reported only the identity violation and a wildcard attribute only the fixed-value violation. Both now report the fixed-value violation.
internal/schemaconstructs and renders runtime names. An attribute diagnostic names a known qualified attribute as"{urn:a}x", as it already named an unknown one, where it printed the local name alone. Tests build runtime names throughSchema.ResolveName, the constructor production uses, andSchema.NameOfis deleted.The XML reader owns the class and position of its errors.
internal/formatreports a document with no root element at the reader's position, as validation does, rather than at 1:1. Misuse of the reader's lifecycle is reported asinternal.invariantby every consumer. A DOCTYPE declaration is rejected at its<. TheKindDirectivetoken kind, which no consumer could receive, is deleted, so the token switches no longer opt out of the exhaustive lint.After a simple type is completed,
internal/valuealone holds its structure (base, list item, union members, variety and whitespace), andinternal/schemareads it throughBuilder.TypeView. Schema's stored declaration no longer carries a copy of that structure, and the duplicate union-facets flag is deleted.docs/RESOURCE_LIMITS.md owns what each public option means. The option doc comments in compile.go and session.go keep a one-line summary, the zero-value rule and a link, and a test checks that form.
The oracle run cache key covers every file under the directory the providers mount, not only the files a case declares. A changed file that a provider reads now invalidates the cached verdict.
Exported identifiers of internal packages that only tests used are deleted. Their tests go through each module's real surface instead, such as compiling a schema or parsing XML. The deleted identifiers include
schema.Compile,value.BuiltinTypeID,xmlstream.NewAttr,format.XMLand the identity-program read accessors. Production methods that only tests called are deleted too.tests/test_only_exports_test.gofails when an exported identifier of an internal package has no production use in the host or js/wasm build. A newmake lint-test-only-codepass, part ofmake lint, runsunusedwith tests excluded so it reports unexported production code that only tests reach.