github cue-lang/cue v0.14.0

latest releases: v0.14.1, v0.15.0-0.dev
one month ago

This release brings significant performance improvements, three language changes, and initial support for Kubernetes CRDs.

Changes which may break some users are marked below with: ⚠️

Evaluator

Performance

A particularly slow part of the new closedness algorithm has been rewritten for speed, resulting in improvements of up to 10x in wall times for some projects.

Significant progress has been made to the new evaluator's memory usage; a few large projects experiencing high memory usage on v0.13 now see reductions of up to 80%.

Various other optimizations and performance bug fixes have been made to the new evaluator, yielding speed-ups of 5-20% on a variety of CUE projects.

error builtin

A new error builtin is added to the language, which allows users to create custom error values with a specified message.

Don't simplify validators into concrete values

A new CUE_EXPERIMENT=keepvalidators experiment is introduced, already on by default, which prevents validators from being simplified into concrete values.

X == Y and == X

Firstly, there were several bug fixes related to ==. Most notably, [int] == [int] incorrectly resolved to true. It now correctly resolves to an error.

All other changes are enabled using the @experiment(structcmp) file-level attribute.
Enabling this experiment allows all CUE values to be compared for equality. This includes comparing structs.

The same experiment also allows a unary == to enforce that a value is a specific concrete value.

Other changes

⚠️ The file embedding experiment can no longer be disabled via CUE_EXPERIMENT=embed=0, having been introduced in CUE v0.10.0.

File embedding is now enabled when using the cue/cuecontext or cue/load APIs; earlier versions could not expose it via the Go API due to an import cycle.

⚠️ The topological field sorting experiment can no longer be disabled via CUE_EXPERIMENT=toposort=0, having been introduced in CUE v0.11.0.

⚠️ CUE_EXPERIMENT=cmdreferencepkg, introduced in v0.13.0 to require referencing tool packages to declare cue cmd tasks, is now on by default.

The new closedness algorithm has been adjusted to fix a number of "field not allowed" bugs, particularly in the form of regressions compared to the old evaluator.

A particularly slow part of the new closedness algorithm has been optimized, resulting in improvements of up to 10x in wall times for some projects.

cmd/cue

⚠️ cue def --strict jsonschema:, deprecated in favor of cue def jsonschema+strict: in v0.11.0, is no longer supported.

Two bugs have been fixed in the new cue trim algorithm where disjunctions could incorrectly select defaults or be treated as ambiguous.

Encodings

cue get crd introduces support for extracting Kubernetes Custom Resource Definitions (CRDs) as CUE definitions; see cue help get crd.

The new encoding/jsonschema.ExtractCRDs Go API exposes the extractor used by cue get crd.

The JSON Schema decoder has gained support for dependencies, bringing the pass rate for the official JSON Schema test suite up from 79% to 81%.

Go API

cue/load now provides module information via the new Instance.ModuleFile field.

⚠️ In order to support the above change, the mod/modfile.File.Format method has been moved to the function mod/modfile.Format: an API-breaking change but necessary to avoid a cyclic package dependency.

cue/parser gains a new Config API, which allows other packages like cue/load to properly apply the right parser options such as the CUE language version.

⚠️ In order to support the above change, the cue/parser.Config.ParseFile and cue/build.ParseFile signatures have now changed (incompatibly) to add a parser.Config argument, enabling the CUE language version to be passed through.

Fix an issue where cue.Value.Decode did not work with *math/big.Float types.

Full list of changes since v0.13.0
  • internal/core/adt: inline combinedFlags helpers by @mpvl in dffc5ce
  • internal/core/adt: refactor combinedFlags from bit-packed uint32 to struct by @mpvl in f44480d
  • ai: specify use of git codereview by @mpvl in f34d9a5
  • ai: allow certain tools unconditionally by @mpvl in 80473ca
  • internal/core/adt: revert the top-level parallelism of EvalV{1,2} tests by @mvdan in 6c32704
  • internal/core/adt: silence tests once again by @mvdan in 4f388b1
  • cue/load: buffer non-regular input files like we do for "-" by @mvdan in fbb4840
  • internal/ci: make the writing of files reusable by @mvdan in 649bb67
  • internal/ci: place input parameters inside an #in struct by @mvdan in 92d4bab
  • cmd/cue: add testscript for issue 4009 by @mvdan in fb631bd
  • ai: adjustments to code by @mpvl in 4bdc446
  • ai: initial Claude.md by @mpvl in 5530af0
  • cue/token: add []byte content to token.File by @cuematthew in 3e50617
  • internal/ci/base: add helpers for OS + Go version matrices by @mvdan in f5ad0d3
  • tools/trim: only consider defaults when we're not ignoring the conjunct by @cuematthew in b95b211
  • internal/encoding/yaml: properly report disjunction errors by @kilpkonn in c7cc1a8
  • pkg/encoding: add test cases for disjunction errors with Validate by @kilpkonn in 5189932
  • lsp/fscache: Force parsing mode to always be ParseComments by @cuematthew in 741955c
  • internal/core/adt: clear close check by @mpvl in d8451da
  • internal/core/adt: exclude more cases for adding defID by @mpvl in b12697e
  • internal/core/adt: add tests for Issue 4000 by @mpvl in b20058e
  • internal/core/adt: fix panic on remnant notifications by @mpvl in faecce4
  • internal/core/adt: add cycle detection by @mpvl in 0740c0a
  • internal/core/adt: remove requirement type by @mpvl in f0f4cee
  • internal/core/adt: update tests by @mpvl in 83f3c87
  • internal/lsp: Move much of our own code to internal/lsp by @cuematthew in 6d10132
  • internal/ci: add base steps for the common Go checks and staticcheck by @mvdan in a79c3d8
  • internal/ci: include more useful string values in base by @mvdan in a78e432
  • internal/ci: split Linux runners into "small" and "large" by @mvdan in 6d3530b
  • internal/ci: allow gerritHubHostname to be overridden by @myitcv in 5cc6d81
  • internal/core/adt: new data structure for reqSets by @mpvl in 3f23e12
  • internal/core/adt: add generation tracking to closedness info by @mpvl in 5077511
  • internal/core/adt: add generation tracking to prevent stale context usage by @mpvl in 19e2c74
  • tools/flow: avoid looking like we're using go run for real by @mvdan in 5f4bd37
  • update dependencies for v0.14.0-rc.1 by @mvdan in 0c84f96
  • cue/stats: remove unused CloseIDElems counter by @mpvl in 930a98b
  • internal/core/adt: fix notification CloseInfo by @mpvl in 0ccf38c
  • cmd/cue/cmd: add tests for 3981 by @mpvl in 840ff27
  • internal/core/adt: add tests for 3981 by @mpvl in 78e1a11
  • internal/core/adt: ToDataAll rewrite by @mpvl in 2804f1d
  • internal/ci: allow additional cache modes by @jpluscplusm in 9afca73
  • encoding/jsonschema: implement dependencies by @rogpeppe in 9620eae
  • internal/cmd/cue-ast: use cue/load with SkipImports=true by @mvdan in 45ab65e
  • gopls/cache: add test for imports of non-ambiguous non-default modules by @cuematthew in e4cdcd3
  • internal/core/adt: remove CloseIDElems counter by @mpvl in 9033834
  • internal/core/adt: add counters before rewrite by @mpvl in c8256cd
  • internal/core/adt: hoist loop by @mpvl in 24cc414
  • internal/core/adt: change signature by @mpvl in 5ee4254
  • internal/core/adt: remove replaceID.add field by @mpvl in d987d88
  • gopls/cache: rework normalizeImportPath by @cuematthew in f309265
  • internal/ci: start publishing the module by @mvdan in 05a3d64
  • internal/ci: carve out into a separate module to be published by @mvdan in 17177e9
  • internal/ci: do a little bit more for trybot jobs in the base package by @mvdan in 1004c32
  • internal/ci: apply the top-level githubactions.#Workflow schema by @mvdan in d9aaac0
  • gopls/cache: ignore imports of stdlib by @cuematthew in eac9728
  • internal/core/adt: revert CL 1208898 for evalv2 by @mvdan in 1789dd4
  • tools/trim: Work harder to discover disjunction branches by @cuematthew in 7f38bb8
  • internal/golangorgx: remove the unused tools/facts package by @mvdan in 60c36a5
  • internal/golangorgx/vendoring: remove by @mvdan in 4d66634
  • cmd/cue/cmd: speed up use of sleeps to test concurrent commands by @mvdan in 13461f1
  • internal/ci: rename "ubuntu" runner to "linux" by @mvdan in 8250c1f
  • internal/golangorgx: delete unused and Go-specific packages by @mvdan in dbed9a3
  • internal/golangorgx: remove unused gopls/util packages by @mvdan in 9ca9609
  • internal/gopls: rewrite gopls/cuelsp by @cuematthew in a23afdf
  • gopls/lsprpc: Adjust gopls to cuelsp and simplify by @cuematthew in ca86fb0
  • internal/gopls: remove unnecessary old command alias by @cuematthew in 4752c04
  • internal/gopls: renaming of gopls to cuelsp by @cuematthew in 8935ee3
  • internal/gopls: delete a lot of code by @cuematthew in 3fb3043
  • all: make some txtar table tests parallel by @mvdan in 2d182a5
  • internal/golangorgx: remove gopls re-vendoring script by @mvdan in 3114a2f
  • update all direct dependencies by @mvdan in 2df1b5a
  • internal/core/adt: filter notifications by @mpvl in 971ee4f
  • internal/core/adt: keep track of notification counts by @mpvl in 18b7df0
  • internal/core/adt: run evaluator tests in parallel by @mvdan in 991e549
  • internal/pkg: fix a race when contexts concurrently load std imports by @mvdan in 79798ca
  • internal/core/adt: clean up orphaned arcs by @mpvl in a397974
  • internal/core/adt: mark inlined nodes for cleanup by @mpvl in e92f16e
  • internal/core/adt: prune parent processing by @mpvl in 1b7a71c
  • internal/core/adt: trigger more diffs in stats by @mpvl in f389502
  • internal/core/adt: clean up use of Vertex.state by @mpvl in fb4f507
  • internal/core/adt: basic memory management for evalv3 by @mpvl in 4ebd05f
  • internal/core/adt: check for nil state in parent disjunction by @mpvl in 4638be0
  • internal/core/adt: delay processing of pattern constraints by @mpvl in ab40e7f
  • internal/core/adt: handle equal disjuncts by @mpvl in 654008d
  • internal/core/adt: do not set error for nil task state by @mpvl in 495f602
  • internal/core/adt: reuse more lets by @mpvl in b96ed2c
  • tools/trim: handle error cases in API by @mpvl in bd237a2
  • internal/core/adt: allow unprocessed by @mpvl in 4d894fa
  • internal/core/adt: remove filter for let sharing by @mpvl in 521d442
  • internal/core/adt: rearrange newNodeContext by @mpvl in f42b369
  • internal/core/adt: mark nodeContext.clone as v2 by @mpvl in b7d9b69
  • internal/core/adt: add benchmark for Issue 3334 by @mpvl in 99494a6
  • internal/core/adt: more eagerly update stats in tests by @mpvl in 2862a10
  • internal/ci: skip "check git tags" when testing CLs by @mvdan in 5100525
  • internal/ci: use shorter Namespace runner profile aliases by @mvdan in 6f50798
  • internal/ci: run tests with GOARCH=386 on protected branches only by @mvdan in 673b49f
  • internal/robustio: add stub js/wasm getFileID implementation by @cuematthew in c13484f
  • internal/core/adt: normalize how the tests configure the runtime by @mvdan in a6abf3b
  • internal/cuetxtar: do not load the root cuelang.org/go CUE module by @mvdan in 7a237eb
  • cue/load: deduplicate handling missing files for ad-hoc packages by @mvdan in 4cb33de
  • cue/load: reject unsupported cue.mod files by inspecting open errors by @mvdan in c80fdaf
  • internal/robustio: Copy from upstream and consolidate use by @cuematthew in 4544972
  • internal/core/adt: remove unused test code by @mvdan in ee299f0
  • internal/modpkgload: Make Package keep its set of files by @cuematthew in 6405ce0
  • internal/core: remove a few unnecessary trailing Fprintln calls in tests by @mvdan in c2f57e3
  • internal/lsp/fscache: Create CUECacheFS and OverlayFS by @cuematthew in 955e7f4
  • encoding/jsonschema: parallelize vendor_external.go a bit by @mvdan in 3b10030
  • internal/ci: drop "evict caches" nightly cron job by @mvdan in 206e824
  • cmd/cue: implement cue get crd by @rogpeppe in a6df86a
  • internal/ci: cache staticcheck via nscloud-cache-action by @mvdan in ff4639c
  • encoding/jsonschema: implement ExtractCRDs by @rogpeppe in e2835d9
  • internal/ci: assume the CI machines are reasonably modern by @mvdan in 7bddda5
  • cmd/cue: skip tests using sleeps in short mode by @mvdan in f7e5f80
  • internal/ci: skip the test cache via GOFLAGS=-count=1 by @mvdan in d3da405
  • internal/ci: switch to Namespace GitHub Actions runners by @mvdan in f615383
  • internal/core/adt: delay stringifying nodes in errors via fmt.Stringer by @mvdan in 7e4dff2
  • internal/core/adt: ensure emptyNode is inert by @mpvl in 2adf5e9
  • mod/modfiledata: rename File.ModulePath() to File.ModuleRootPath() by @cuematthew in b8a14de
  • mod/modpkgload: correct calculation of pkg.fromExternal by @cuematthew in a8ba684
  • mod/modpkgload: capture faulty behaviour of pkg.fromExternal by @cuematthew in c237083
  • cue/ast: Ensure ImportPath.Canonical copes with host-only paths by @cuematthew in 703c22c
  • mod/modpkgload: Make LoadPackages support nil shouldIncludePkgFile by @cuematthew in 19d3abc
  • internal/core/adt: use custom int set implementation for visited by @rogpeppe in 12ec0ec
  • all: simplify three iterator uses with range-over-func by @mvdan in bb2494b
  • internal/core/adt: remove cycle check by @mpvl in d92e916
  • internal/core/adt: add tests for 3978 by @mpvl in 81795ac
  • internal/core/adt: revert 1217228 by @mpvl in 47912fc
  • cmd/cue/cmd: fix versiontest test by @rogpeppe in 2bbc359
  • doc/ref/spec.md: support struct and list for equality by @mpvl in d58d1f5
  • internal/core/compile: add version check for builtins by @mpvl in 985e693
  • internal/core/adt: add builtin for user-defined errors by @mpvl in 3ad8663
  • internal/core/adt: rename CallContext.Expr by @mpvl in 64ffd0d
  • doc/ref/spec.md: document error builtin by @mpvl in be18b05
  • internal/ci: update Go and goreleaser versions by @mvdan in 8d463da
  • update golang.org/x/... dependencies by @mvdan in e88d161
  • internal/core/adt: support unary == and != for all types by @mpvl in 030658e
  • internal/core/adt: comparison of values of different types by @mpvl in 34faddf
  • internal/core/adt: consider required fields for final values in Equal by @mpvl in 64d5789
  • internal/core/adt: support comparsion of structs by @mpvl in 2b7dfbd
  • internal/core/adt: fix error gobbling of internal nodes by @mpvl in 665f697
  • internal/core/adt: add tests for Issue 3977 by @mpvl in 996e8b0
  • cue/load: pass language version down to parser by @rogpeppe in d567750
  • cue/load: use error registry in SkipImports mode by @rogpeppe in 5a04616
  • cue/parser: enable cueexperiment.File throughout by @mpvl in 86f7a64
  • internal/cueexperiment: support for per-file experiments by @mpvl in 52988e0
  • internal/core/adt: simplify recursive getReqSets calls by @mvdan in 2d4263e
  • cmd/cue: remove CUE_SYNTAX_OVERRIDE support by @rogpeppe in 450ba7f
  • internal/core/adt: do not repeat replaceIDs calls by @mvdan in 8241d9c
  • cue/load: actually populate build.Instance.ModuleFile correctly by @rogpeppe in 48ec278
  • internal/core/adt: handle incomplete values in comparators by @mpvl in c925040
  • internal/core/adt: use replaceIDs incrementally in checkTypos by @mvdan in 16c782a
  • internal/core/adt: rewrite replaceIDs to scale better by @mvdan in b4212a3
  • internal/core/adt: Equal should take defaults when appropriate by @mpvl in 361384c
  • internal/core/adt: limit closedness check in Equal by @mpvl in e8e8682
  • internal/core/adt: merge validate package with adt by @mpvl in 26e1596
  • internal/core/adt: add tests for incomplete lists comparison by @mpvl in e67898f
  • cue/parser: add Config type by @rogpeppe in 211309c
  • cue/load: include module file in build.Instance by @rogpeppe in ab9ac54
  • internal/core/adt: use pointers for snapshot and result in nodeContext by @mvdan in 1a2d2e7
  • internal/core/adt: add tests for Issue 3929 by @mpvl in 7777230
  • internal/core/adt: handle yields in Resolve by @mpvl in 81e88ee
  • internal/core/adt: add tests for Issue 3972 by @mpvl in 0ac3913
  • internal/core/adt: make small iota enums consistently uint8 by @mvdan in ce44cfb
  • internal/core/adt: allow lookup across disjunction boundary by @mpvl in 20afefd
  • internal/core/adt: apply vertex rewriting to blocked tasks by @mpvl in d713052
  • internal/core/adt: add tests for 3967 by @mpvl in 5c5f970
  • cuecontext: revert support for CUE_EXPERIMENT by @mpvl in 2a70935
  • internal/pkg: only use %s with stringifiable builtin errors by @mvdan in fc4ca40
  • cue/parser: prohibit definition identifiers for package names by @rogpeppe in 548c23c
  • internal/core/export: avoid panic on non-regular identifiers for packages by @rogpeppe in 8bbf9b4
  • cmd/cue: add test cases for issue 3968 by @rogpeppe in e0010dd
  • cmd/cue: add testscript for exp gengotypes output filenames by @mvdan in b20d1a4
  • all: swap math/rand for math/rand/v2 where it affects behavior by @mvdan in 82ff070
  • all: remove a bit of dead code by @mvdan in ab546cf
  • cmd/cue: properly document the keepvalidators experiment by @mvdan in 398cdac
  • all: swap math/rand for math/rand/v2 where it doesn't affect behavior by @mvdan in db84c62
  • cmd/cue: fix error on cue mod rename with a bad module by @rogpeppe in 9f9ebac
  • cmd/cue: add test case for modrename with a bad module by @rogpeppe in 90d9b04
  • internal/core/adt: also create embed scope for disjunctions by @mpvl in c925902
  • internal/core/adt: add tests for 3964 by @mpvl in 2597e9e
  • internal/core/adt: fix default logic by @mpvl in 8dc494c
  • cueexperiment: export Config type and use it by @mpvl in 33a1792
  • internal/core/adt: add tests for 3958 by @mpvl in 5d162df
  • README: minor updates by @jpluscplusm in eb54082
  • internal/core: start removing pre-toposort field ordering code by @mvdan in 6fd9f7d
  • internal/core/adt: don't check removed scopes by @mpvl in 86ef530
  • internal/core/adt: track scope of closed() by @mpvl in c6abd6e
  • internal/core/adt: do not remove embed groups by @mpvl in 191a0eb
  • internal/core/adt: adjustments to closedness algo by @mpvl in 6746a82
  • internal/core/adt: change ellipsis to fix hidden bug by @mpvl in e9a4d11
  • internal/core/adt: update tests for 3833 and 3839 before fix by @mpvl in f7e46e9
  • internal/core/adt: add tests for Issue 3920 by @mpvl in 75660e3
  • internal/core/adt: also typo check disjuncts by @mpvl in dba18d3
  • internal/core/adt: add tests for Issue 3957 by @mpvl in deed94c
  • internal/core/adt: remove most validator simplifications by @mpvl in 487e526
  • internal/core/adt: copy bounds.txtar by @mpvl in 97927bc
  • cmd/cue: allow "access denied" testscript to pass on Wine by @mvdan in 250524b
  • cmd/cue: tweak two more testscripts to be portable by @mvdan in 9758314
  • cue/ast: improve ImportPath.Canonical by @rogpeppe in 12f3193
  • cue/ast: add more tests for ImportPath.Canonical by @rogpeppe in 3444f26
  • cue: fix decoding into big.Float by @haoqixu in dcc3088
  • cmd/cue: add false, echo, and cat testscript commands by @mvdan in d1210a5
  • cmd/cue: drop debug lines from testscripts by @mvdan in c0c6072
  • cue: add tests for issue 3927 by @haoqixu in 7cfda37
  • cue: use multiple sizes in BenchmarkLargeValueMarshalJSON by @mvdan in 4e0e427
  • update all other dependencies by @mvdan in b226e16
  • update golang.org/x/... by @mvdan in c947a0b
  • all: rely on iterators being available since Go 1.23 by @mvdan in 100a7cc
  • internal/golangorgx: remove files build-tagged for old Go versions by @mvdan in 15536aa
  • internal/golangorgx/tools/analysisinternal: remove by @mvdan in 830ad6f
  • cue/cuecontext: always enable embedding by @rogpeppe in e2e0711
  • internal/golangorgx/tools/typesinternal: remove by @mvdan in 6024ad4
  • internal/golangorgx/gopls/cache/methodsets: remove by @mvdan in 881004d
  • internal/golangorgx/tools/tokeninternal: remove by @mvdan in 518f13e
  • cue/load: make NoFilesError use position arguments for paths by @mvdan in 5b6d50f
  • cmd/cue: remove dev.txtar testscript by @mvdan in d0cb1dd
  • cmd/cue: deprecate --strict flag in favor of the jsonschema filetype tag by @mvdan in 00d3a8f
  • internal/cueexperiment: enable cmdreferencepkg by default by @mvdan in 16444fa
  • cmd/cue: turn all "cmd" testscripts away from legacy id/kind fields by @mvdan in 8b11b9d
  • internal/cueexperiment: toposort is always on now by @mvdan in 06de121
  • internal/cueexperiment: keep record of how experiments advanced by @mvdan in fa77cff
  • internal/cueexperiment: file embedding is always on now by @mvdan in 23f2527
  • all: ensure we init cuedebug and cueexperiment before every use by @mvdan in fc8460b
  • cmd/cue: consistently use the same top-level command context by @mvdan in 60e5703
  • cmd/cue: add more CUE_DEBUG=http tests by @mvdan in 6119be2
  • internal/core/adt: partially revert CL 1214950 by @mpvl in e1fd269
  • internal/core/adt: add tests for 3946 by @mpvl in d2adadc
  • internal/cueversion: avoid dependency on golang.org/x/mod by @rogpeppe in 94630d5
  • internal/core/adt: do not always filter disjuncts by @mpvl in 50e6b31
  • internal/core/adt: add tests for 3947 by @mpvl in a1f0964
  • cmd/cue: remove stale testscript txtar files for CUE_EXPERIMENT=modules=0 by @mvdan in b7b7cc7
  • internal/cueexperiment: tweak the docs for all experiment flags by @mvdan in 1981718
  • cmd/cue: consistently use tab indentation in help texts by @mvdan in 9113b8e
  • cmd/cue: drop evalv3=0 testscripts by @mvdan in a27b03f
  • cmd/cue: implement mirror --dry-run by @rogpeppe in 707f96b
  • internal/cueversion: bump languageVersion for v0.14 by @mvdan in 9eb4c14
  • internal/mod/modfiledata: factor out of mod/modfile by @rogpeppe in da6a638

Don't miss a new cue release

NewReleases is sending notifications on new releases.