v0.5.0
This release focuses on changes to the implementation of comprehensions, the algorithm for detecting cycles in CUE, and the reimplementation of let comprehensions as fields.
Also included are a number of bug fixes and changes to help the KubeVela project upgrade off CUE v0.2.2 to the latest release. v0.5.0 is the first release since v0.4.3 back in April 2022. It has been a long time in the making, and is comprised of 277 commits.
It is worth noting that we do not plan nor wish for such long gaps between releases. For more details on upcoming releases and steps we are taking to increase release cadence as well as our confidence in each release, please see this discussion.
As a reminder: users can register their projects with unity, our regression and performance testing setup. unity is used to ensure that a project’s CUE evaluations do not unexpectedly stop working, or regress in terms of performance. unity continues to catch multiple issues with each release. Adding your project to unity not only guarantees that we will not break your tests (if we do, we will work with you to fix your CUE code), but it also helps to improve the quality of each CUE release. We are currently in the process of releasing Unity as a GitHub App on the public Marketplace. Sign up to receive updates; we will be in touch as soon as the GitHub App is ready.
Thank you to @djosephsen, @joaopapereira, @mpvl, @mvdan, @myitcv, @qequ, @rogpeppe, @rytswd, @satotake, @spachava753, and @tmm1 for contributing to this release!
Project-level changes
Various CI-related changes have been made to simplify and streamline the GerritHub-based CI setup across the various CUE repositories. A common base package is vendored into each repository and used as a template for GitHub workflows and other configuration. For those interested in studying the setup, please see the files beneath internal/ci.
This release drops support for go1.16.x , go1.17.x and go1.18.x, is tested against go1.19.x and go1.20.x, and is built using go1.20.2.
Our dependency on github.com/rogpeppe/go-internal is upgraded to v1.9.0 and various testscript-related improvements have been made to CUE’s tests.
GoReleaser has been upgrade to v1.16.2 as part of the release workflow. In a related change, CL 546920 moves us to a CUE-based source configuration for GoReleaser. This allows us to define the concept of ’latest’, state which indicates whether we should perform the homebrew release and the Docker manifest latest steps. This fixes a long-standing bug whereby homebrew taps and Docker images were created for the latest release, regardless of whether that was a pre-release, or indeed a patch version of a non-current minor version.
As of CL 547507, CUE build artefacts published on GitHub are entirely reproducible, thanks to Go’s support for reproducible, verifiable and verified builds.
Encoders
When cue import-ing YAML, the -R recursive flag now only recursively interprets text as YAML if it contains a newline CL 536902.
API
Various APIs have been transitioned to drop use of the deprecated cue.Runtime type, as well as migrating away from cue.Instance via cue.InstanceOrValue. Some use of these deprecated types remains: #1035, #1735, #1806. These will be tidied up in later releases as the API surface matures towards v1.0.0.
The cue package now supports InlineImports for Value.Syntax CL 541561. This leverages new support within the internal exporter to creating self-contained CUE. This change also deprecates Value.ResolveReferences().
Package cue adds Selector.Type to make it easier to pull out selector-specific information from a selector (for example, it makes it possible and cheap to retrieve the unquoted string label from a regular field selector) CL 542738.
Package cue adds Value.BuildInstance(). If a cue.Value exactly represents a package, BuildInstance() returns the build instance corresponding to the value CL 542769.
cue/stats is introduced as a new package for getting CUE operation statistics. The functionality is hoisted from internal/core/adt, but the package should for all practical purposes be seen as a new implementation. The stats have been aggregated as experimental functionality to the tools/flow package.
CL 546763 disallowed deprecated language features in the Go API. These features had long been deprecated in cmd/cue. This means that API operations will now fail on deprecated features whereas before they were handled in compatibility mode. The parser.FromVersion feature can be used to reenable these deprecated features.
Language
This release does not introduce any language changes. CL 537264 made some minor adjustments to the language specification to improve readability.
CL 541457 removes support for re-writing of old-style let declarations. This had already been deprecated for a long time and this change was made to enable support for aliases of embeddings.
Core evaluator
Per-field comprehensions
One of the major changes introduced in this release is how comprehensions are handled. CL 529524 move the evaluator to a model of per-field comprehensions.
Comprehensions are expanded for, if, and let clauses that yield zero or more structs to be embedded in the enclosing list or struct.
CUE does not allow cyclic dependencies between comprehensions if they result in an ambiguous set of fields. It does allow cascading insertions as in:
a?: int
b?: int
if a != _|_ {
b: 2
}
if b != _|_ {
c: 3
d: 4
}The way this works is that for fields with a fixed prefix path in a comprehension value, the comprehension is assigned to these respective fields.
More concretely, the above example is rewritten to:
a?: int
b: if a != _|_ { 2 }
c: if b != _|_ { 3 }
d: if b != _|_ { 4 }where the fields with if clause are only inserted if their condition resolves to true. Note that this is not valid CUE; it may be in the future.
With this rewrite, dependencies in comprehension expressions are handled analogously to other expressions.
Note that a single comprehension may be distributed across multiple fields. The evaluator will ensure, however, that a comprehension is only evaluated once.
Analogous to reference cycles, as of CL 544129 we allow comprehensions to use the struct in which they are defined as source, as long as they do not introduce new fields, which would alter the source on which they iterate.
Reimplementation of cycle detection
The new algorithm is inspired by the cycle detection used by Tomabechi’s 1 and Van Lohuizen’s 2 graph unification algorithms.
Unlike with traditional graph unification, however, CUE uses references, which, unlike node equivalence, are unidirectional. This means that the technique to track equivalence through dereference, as common in graph unification algorithms like Tomabechi’s, does not work unaltered.
The unidirectional nature of references imply that each reference equates an exact copy of the value it points to. This renders the original approach of node-pointer equivalence useless.
The new algorithm, a variant of Tomabechi’s and Van Lohuizen’s algorithm, looks at references equality on conjuncts, instead of node equality. This simplifies the accounting and allows for far simpler and precise accounting when using references instead of the traditional node equivalence.
More background info on cycles
We have to define when a cycle is detected. CUE implementations MUST report an error upon a structural cycle, and SHOULD report cycles at the shortest possible paths at which they occur, but MAY report these at deeper paths. For instance, the following CUE has a structural cycle:
f: g: fThe shortest path at which the cycle can be reported is f.g, but as all failed configurations are logically equal, it is fine for implementations to report them at f.g.g, for instance.
It is not, however, correct to assume that a reference to a parent is always a cycle. Consider this case:
a: [string]: b: aEven though reference a refers to a parent node, the cycle needs to be fed by a concrete field in struct a to persist, meaning it cannot result in a cycle as defined in the spec as it is defined here. Note however, that a specialization of this configuration can result in a cycle. Consider
a: [string]: b: a
a: c: _Here reference a is guaranteed to result in a structural cycle, as field c will match the pattern constraint unconditionally.
In other words, it is not possible to exclude tracking references across pattern constraints from cycle checking.
It is tempting to try to find a complete set of these edge cases with the aim to statically determine cases in which this occurs. But as Carpenter 3 demonstrates, it is possible for cycles to be created as a result of unifying two graphs that are themselves acyclic. The following example is a translation of Carpenters example to CUE:
y: {
f: h: g
g: _
}
x: {
f: _
g: f
}Even though the above contains no cycles, the result of x & y is cyclic:
f: h: g
g: fThis means that, in practice, cycle detection has at least partially a dynamic component to it.
The language specification contains a higher-level and more complete overview of structural cycles.
Reimplementation of let comprehensions
CL 543362 made a change to internal/core to reimplement let comprehensions as fields. This makes it easier to track context as let comprehensions then follow the same paradigm as fields. It also allows debug information to be shown as to where lets are added in the tree. This change was accompanied by number of others that refined the approach.
Self-contained export
internal/core/export now implements an algorithm for generating self-contained CUE on export, an option that can further be refined by asking the exporter to inline imports. These internal changes manifest in changes to cue def and cuelang.org/go/cue that are described elsewhere.
Other changes
CL 545897 started tracking stats within the core CUE tests. This book keeping helps to spot likely regressions in performance early by collocating the stats with the CUE that is being evaluated.
Builtins
In the strconv package, strconv.FormatInt and strconv.FormatUint now support arbitary-precision format; see CL 538512.
CL 545898 improved the error messages for pkg builtins, by including the path in error in many cases, and passing a wrapped message for encoding/yaml.
CL 546237 allows incomplete list.MinItems constraints. Before it either returned false or true, ignoring that making a configuration more specific might still satisfy MinItems later on. CL 546238 made a similar change for struct.MinFields.
Tooling layer
Standard input is now parsed correctly in cue cmd-declared command tasks; see CL 541898.
cmd/cue
Version control system (VCS) information is included in cue version as of CL 540297. The Go version used to build cmd/cue is included as of CL 549302.
cue def now supports an --inline-imports flag which resolves imports to print a self-contained version of the command input. For example, given the txtar input:
-- cue.mod/module.cue --
module: "example.com/a"
-- in.cue --
package a
import "example.com/a/pkg"
import "list"
v: pkg.v
-- pkg/pkg.cue --
package pkg
v: { x: 3, y: x }The running cue def --inline-imports in.cue will give:
package a
import "list"
v: {
x: 3
y: x
}CL 546243 fixed a long-standing bug whereby the --ignore errors flag was not observed by cue eval.
All changes
278 changesby area
all19
allremove mistakenly added fileallapply and follow Go 1.19's gofmtallstart using testscript.Params.RequireExplicitExecalluse txtar filename extensions consistentlyallapply Go 1.19's gofmtalluse the .test TLD for module paths in testsallfix migration to x/tools/txtarallfix common pattern of calling cuextxtar.Loadallswap rogpeppe/go-internal/txtar for x/tools/txtaralluse go-cmp.Diff more consistentlyallreplace filepath.Walk with WalkDirallavoid using too many packages.Need bitsallfix a few more staticcheck nitsallmake use of t.TempDir and t.Setenvalldrop support for Go 1.16.xallmake vet happyallcheck the filepath.Walk error parameterallfix a few minor typos spotted by gospelallremove redundant interface type assertions
cmd17
cmd/cueinclude Go in the version commandcmd/cueadd evaluator stats supportcmd/cueadd tests for issue 345cmd/cuedon't panic in vet if a schema has incomplete errorscmd/cuefix --ignore errors flagcmd/cue/cmdtestscript moved its gopath locationcmd/cueremove all stdin bufferingcmd/cue/cmdadd --inline-imports flagcmd/cue/cmdremove bits of unused codecmd/cuesupport buildinfo in version sub-commandcmd/cueusecuein test scripts rather thanexec cuecmd/cue/cmdremove usage of cue.Runtimecmd/cueinitialize toTop and toString without go/packagescmd/cueremove the need for embedpkgcmd/cueremove duplicate files from get_go_types.txtcmd/cueimport -R: don't treat text with no newlines as YAMLcmd/cuebetter test for import --recursive
cue19
cue/testdata/benchmarksadd benchmark for let keycue/export/extractfix comments with comprehensionscue/parserdisallow deprecated language features in APIcueupdate Value.Source doc commentcue/astfix StructLit.Endcue/testdata/benchmarksadd statscue/statsnew package for getting operation statisticscuetweaks to selector APIcueadd Value.BuildInstance methodcueadd Selector.Type APIcue/loaddeterministically sort CUE files when loadingcuesupport InlineImports for Syntaxcue/formatfixStructLittrailing comma bugcue/loadactually apply the latest doc wording per the reviewscue/loadremove old reference to a "query tool"cue/pkg/strconvsupport arbitary-precision formatcue/formatescape tabs when printing comments, literals, and attributescue/literalallow escaped newlines in multiline stringscue/scannerallow leading double-quote in #-quoted string
doc8
docsimple whitespace change to track down GerritHub replication issuedoc/ref/spec.mdbinary literals support_separators as welldoc/tutorial/kubernetesmark both tests as longdoc/tutorial/kubernetesonly run as a long testdoc/tutorial/basicsmake test scripts run againdoc/specminor adjustments after a careful readdoc/contribute.mdsimplify code backticksdoc/refmention that newlines can be escaped in multiline strings
encoding5
encoding/gocodeencode hex consistently like Go 1.19+encoding/gocodebe resilient to Go string literal changesencoding/openapiupdate APIencoding/yamlbe clearer about the role of the src argumentencoding/protobufupdate dependencies
internal176
internal/cifix cache evictioninternal/ciaddress review feedback from CL 551352internal/ciallow trybot workflows to be workflow_dispatch-edinternal/cirefactor CI workflowsinternal/ciremove hard-codings in base packageinternal/cimove evict_caches to baseinternal/ciremove mention of matrix and runner from baseinternal/ciremove trybot from push branchesinternal/cirefactor base caching patterninternal/cidrop pullThroughProxy stepinternal/cibump pinned version of Go for releasesinternal/core/adtrevert fix for 2209internal/core/adtfix possible infinte loop for API usageinternal/core/adtfix regression in comparing to bottominternal/core/adtremove unnecessary checkinternal/core/adtdetect closed lists as fatal errorsinternal/core/adtsharpen condition for scalar settinginternal/cifix goreleaser in non-snapshot mode againinternal/core/adtfix 2235internal/core/adtadd tests for 2235internal/cifix and test the release workflow on branchesinternal/core/adtfilter more disjunctionsinternal/core/adtadd tests for 2209internal/core/adtimprove mechanism for conjunct insertioninternal/core/adtadd tests for conjunct insertioninternal/core/adtonly set scalar if not already definedinternal/cimake github CLI shell invocations saferinternal/coreclone let upon use of for var referencesinternal/core/debugchange notation for "multi" letsinternal/core/adtdon't add errors to "void" arcsinternal/core/adtevaluate expressions directlyinternal/core/evalnode should not finalize itself mid flightinternal/cideploy [tip.cuelang.org](http://tip.cuelang.org/) via repository_dispatchinternal/cienable push_to_tip_trybotinternal/ciapply various CI-related changes from [cuelang.org](http://cuelang.org/) repointernal/ci/goreleaseractually make builds reproducibleinternal/ci/goreleasermake builds reproducibleinternal/core/adtdon't evaluate inlined structs prematurelyinternal/core/adtadd tests for issue #2163internal/cireview follow-up changes to goreleaser_tool.cueinternal/ciswitch to CUE based definition for goreleaserinternal/ciimport for current goreleaser configurationinternal/ciupgrade to later GitHub workflow schemainternal/ciupgrade to latest GoReleaser versioninternal/ciuse newer versions of the docker github actionsinternal/core/adtbase error mode on requested stateinternal/core/adtonly set validation result when safeinternal/core/adtpass desired state to more functionsinternal/core/adtpass more state aroundinternal/core/adtpass state to validationinternal/core/adtpass state to evaluateinternal/core/adtavoid duplicate insertion of conjunctsinternal/core/adttighten uniqueness of conjunctsinternal/core/adtremove nested comprehension special casinginternal/core/adtdisambiguate let cacheinternal/core/adtupdate stats to fix build breakageinternal/core/adtmerge Conjunct and Partial processinginternal/core/adtremove assertioninternal/core/adtadd test cases for issue 2119internal/core/adtadd tests related to Issue #2113internal/core/adtevaluate let fields earlier in comprehensionsinternal/core/adtdetect cycles in patternsinternal/core/adtfix comprehension cycle regressioninternal/core/adtadd tests to address regressionsinternal/core/adtsplit some tests into filesinternal/core/adtfix panic using builtin validatorsinternal/core/adtdon't bump stateinternal/core/adtprevent early error assignmentinternal/core/adtrelax cycle trackinginternal/core/adtadd tests for #2052internal/core/adtfix redundant errors in callsinternal/core/adtimproved reporting disjunction errorsinternal/core/adtavoid uninformative cyclic errorinternal/core/adtremove over-aggressive deduplicationinternal/core/adtfix error checking buginternal/core/adtadd cycle detection for alt evaluation pathinternal/core/adterrors in let expressions are okayinternal/core/adtadd statsinternal/core/dephandle recursive letsinternal/core/adtfix comprehension buginternal/core/adtremove redundant state changeinternal/third_party/yamlfix float parsinginternal/third_party/yamlslim down APIinternal/core/adtrecursively pre-expand comprehensionsinternal/core/adtrepresent comprehension clauses as listinternal/core/depremove useless codeinternal/core/adtfix cycle detection bug for letsinternal/core/adtallow self-referential comprehensionsinternal/core/adtupdate state constants and docsinternal/core/adtadd conjuncts to dynamic list as wellinternal/core/adtreport cycle error in comprehension sourceinternal/core/adtrename testinternal/core/adtadd IsDefined to filter out void arcsinternal/core/adtfix closedness regressioninternal/core/depfix comprehension environment bindinginternal/core/adtfix broken let lookup in embedded scalarsinternal/core/adtoptimize cycle detection for disjunctionsinternal/citest and release on Go 1.19.xinternal/core/adtremove problematic Ref deletioninternal/core/adtadd test for issue 1837internal/core/adtmake some errors semi-permanentinternal/core/adtreduce size of ErrorCodeinternal/core/exportfix crash in dynamic fieldsinternal/coreimplement let as fieldsinternal/core/adteliminate disjuncts for incomplete errorsinternal/core/adtfix testinternal/core/adtadd tests for letinternal/core/compileprepare for let changeinternal/core/...fix various attributes printing issuesinternal/core/adtremove StructInfo for unused structsinternal/core/compileadd missing import in testinternal/cuetxtaradd method for getting a single instanceinternal/filetypesnot a file extension if the file starts with a dotinternal/core/adtdefensive use of CloseInfointernal/filetypesfix TestParseFile testsinternal/cuetxtarimprove docsinternal/core/pathpackage for Selector to Feature conversioninternal/core/adtfix cycles in evaluationinternal/core/adttighten structural cycle detectioninternal/core/adttighten structural cycle detectioninternal/core/adtfix spurious cycle for inline recursioninternal/core/adtfix issue with references cyclesinternal/core/adtsome fixes to structural cycle detectioninternal/core/compilefix aliases to dynamic fieldsinternal/core/adtcount conjunctsinternal/core/adtfinalize arcs that are almost doneinternal/core/adtremove redundant lineinternal/core/adtclean up some span logic and add a commentinternal/core/adtmove Label for better bin packinginternal/core/adtclean up some closedness codeinternal/core/adtfix spurious child errorinternal/core/adtpick defaults for label evaluationinternal/core/adtSpawnRef loop optimizationinternal/core/adtfix spurious cycleinternal/core/adtreimplementation of cycle algorithminternal/core/adthoist cycle logicinternal/core/adtpass Conjunct instead of Environment to Resolveinternal/core/adtdon't spawn duplicate locationsinternal/core/adtfix env linking for comprehensionsinternal/core/exportdon't inline for errorsinternal/core/exportenhancements for import inlininginternal/core/exportimplement self-contained algo for exportinternal/ciuse consistent name for CUELANGORGTIPREBUILDHOOKinternal/difftwo different errors are equalinternal/core/exportcleanup of initialization and finalizeinternal/core/exportsimplify dynamic labelsinternal/core/exportrefactor uniqueFeatureinternal/core/exportfix bug exporting dynamic referencesinternal/core/adtclarify examples for referencesinternal/core/exporthoist FieldReference logicinternal/core/exportpass Environmentinternal/core/exportmove tests to subdirinternal/core/exporthoist reference logicinternal/ci/githubskip non-race tests when running race testsinternal/cirefactor CI workflowsinternal/cisplit github workflows into separate filesinternal/ciwrite netrc file for triggering trybotsinternal/cimove to using gerritstatusupdaterinternal/cirename test and repository_dispatch workflowsinternal/cimove workflow declarations to their own packageinternal/cistop using txtar tests for GitHub actions workflowsinternal/core/adtremove stutter in errorinternal/core/adtkeep arc on comprehension errorinternal/core/adtuse per-field comprehensionsinternal/core/adtmove closedness checkinternal/core/adtprepare for comprehension changeinternal/core/adtremove redundant indirectioninternal/core/adtadd convenience logging methodinternal/encodingalways validate when exportinginternal/ciavoid merge commits when testing GitHub PRsinternal/encoding/yamlupdate dependenciesinternal/corecomment improvementsinternal/ciremove gorelease check stepinternal/cienforce Signed-off-by temporarilyinternal/cibump GitHub Actions OS versionsinternal/cuetestdrive long tests via an env var
pkg12
pkg/listmake error of MaxItems consistent with MinItemspkg/structfix MinFields analogously to MinItemspkg/internalallow incomplete list.MinItemspkgimprove error messagespkgreuse pkg/gen to generate package godocspkg/tool/clirework Stdin and make Ask read an entire linepkg/genremove unreachable codepkg/gengenerate (almost) all pkg.go files in one callpkg/internalmake it clearer that const is exclusive to funcpkg/strconvRevert "pkg/strconv: allow string argument for format"pkg/strconvallow string argument for formatpkg/list/sortfix syntax in docs
tools3
tools/flowadd debug support via CUE_DEBUG_TOOLS_FLOWtools/fixremove rewriting support for old-style lettools/flowget rid of deprecated cue.Runtime
Other19
- [release-branch.v0.5] internal/ci: use go1.19.8 for the release of v0.5.0
- [release-branch.v0.5] internal/ci: bring inline with be0601bf
githubbring the bug report template up to dategoreleaserformatting changes in Yaml fileREADMEfix the stale GitHub Actions badgeinfraupgrade goreleaser- drop support for Go 1.17.x ahead of the v0.5 release
depsbump [golang.org/x/text](http://golang.org/x/text) dependency.gitignoreadd .DS_Storeerrorsmake Errors and Print respect wrapped errorsmoddrop x/xerrors from the module graphmoddrop apd v1 from the module graphCIonly pull master commits through a proxy on LinuxCItry "pull through proxy" go get up to five timesinteral/diffskip hidden fields by default.gitignoreignore some binariescuegofix example in docs- Revert "all: avoid using too many packages.Need bits"
- bump x/tools and x/net dependencies
Downloads
Every file this release published on GitHub, with its SHA-256. Most people install CUE as Installing CUE describes, which also shows how to check a download.
Archives
| Platform | File and SHA-256 |
|---|---|
| macOS, Intel | cue_e2cede1965afa66dc52de7c1cd461227f4ff924f7a2adc9791cf1a699485409f |
| macOS, Apple silicon | cue_00fc991977232240893ae36dc852366af859214d6e1b2b9e03e93b8f9f0991a7 |
| Linux, x86-64 | cue_38c9a2f484076aeafd9f522efdee40538c31337539bd8c80a29f5c4077314e53 |
| Linux, Arm64 | cue_735fa1b9bb02ef0ee79dd40c418760687776b44747f43f2e26c3bca4e1fd96f6 |
| Windows, x86-64 | cue_0aec9ea6b4095250406f8072d959bbea4c29bdcf9f85579f2c6dc915ce75082e |
| Windows, Arm64 | cue_262f381041d6ebdf6a8b87fe482077efd9212e7d195a81fe437a2c24afe4d871 |
SHA-256 checksums for all of these: checksums.txt
https://aclanthology.org/C92-2068 Hideto Tomabechi. 1992. Quasi-Destructive Graph Unification with Structure-Sharing. In COLING 1992 Volume 2: The 14th International Conference on Computational Linguistics. ↩︎
https://aclanthology.org/P00-1045/ Marcel P. van Lohuizen. 2000. “Memory-Efficient and Thread-Safe Quasi-Destructive Graph Unification”. In Proceedings of the 38th Annual Meeting of the Association for Computational Linguistics, pages 352–359, Hong Kong. Association for Computational Linguistics. ↩︎
Bob Carpenter, “The logic of typed feature structures.” Cambridge University Press, ISBN:0-521-41932-8 ↩︎