Replies: 5 comments 6 replies
-
We have also analyzed the impact of this proposal on an entry-level language guide, which we are currently writing. We found that the difference between schema-level constraint fields and data/template level regular fields actually simplifies explaining CUE overall. |
Beta Was this translation helpful? Give feedback.
-
i agree with the characterization that policy is related to schema, and that the difference in authorship is significant. But, i would suggest that:
It is of paramount importance that it is possible to distinguish the set of constraints and defaults that derive from the original schema from those applied via any subsequent policies. |
Beta Was this translation helpful? Give feedback.
-
i could not disagree more strongly with this stance. i think that, for at least some schema cases, it is essential that defaults be included in schema declarations. In the class of schemas i am concerned with in thema - roughly, those that describe messages which are ingested through a process boundary by programs (perhaps HTTP object bodies, perhaps configuration files on disk, etc.) - each field in a schema is generally associated with some behavior that is associated with that field. (Some behaviors incorporate multiple fields, of course, but that complicates discussion without adding relevant detail, so let's ignore it for now) As i think of it, there generally exists a bijective correspondence between program behavior and each allowable value in a field's value space. There are probably things this conception of defaults misses, but i have found it useful because, considered in these terms, we can think of each acceptable value in the value space as a name for its corresponding behavior. My sense is that this is how it actually works in peoples' minds, including my own. Thus, the question of whether a field is optional, or whether it has a default, is best understood in terms of its correspondence to some particular, primary program's behavior (think k8s or Grafana) - or some platonic ideal behavior that implementations are supposed to adhere to (think POSIX). If, in the absence of a value for that field, the behavior of the program:
When we think of default values as proxies to underlying behavior, their importance is clear: changing a schema-level default is a machine-analyzable way of indicating that the default behavior of a program has changed. This is powerful, though i don't know to characterize its power beyond a handwavy buzzwordy sentence like "a control-theoretic footnotable exception to Rice's Theorem." But all of this is only possible when we think of there being one primary set of defaults that emanate from the schema author, understood as distinct from any policy-level defaults (per my other comment) that might be added later. To be clear, interpreting schemas in the context of some program, even an idealized one, is an important boundary to this guidance. It does not seem especially applicable to "pure data" contexts - e.g., a schema that describes measurements taken of real-world phenomena. (Though i have a nagging feeling that it may apply even there...). But every other way i've tried to think about it seems untethered from actual reality in a way that reminds me of Haskell without monads. cc @joshhunt |
Beta Was this translation helpful? Give feedback.
-
i have effectively been creating a "schema mode" within Thema via use of CUE's Go SDK, and while i like a lot of what's proposed here, the proposal also does not obviate the need for Thema. Thus, i'd like to see the proposal indicate how these logical modes will be exposed by the SDK, so that i can reasonably easily keep Thema in line with what's being done here. The more i think about this, the more i think having this expressed clearly, and being able to build atop it, is really important for us. I have been trying to avoid taking a position on whether instances of Thema schemas are required to be concrete, or "in data mode" as this proposal seems to describe it. It's led to awkward things like this. We have known cases, however, where we expect to receive a combination of data and schema, and want to be able to schematize all of that. This isn't something i expect any native CUE capabilities for, necessarily - if the Go SDK exposes clearer controls over these modes, then i can make attributes which Thema authors use to indicate whether a subtree of a schema should be treated as data or further schema when being validated. |
Beta Was this translation helpful? Give feedback.
-
This proposal was accepted and required fields landed in CUE as of https://cuelang.org/cl/549206. Closing this issue to recognise the decision to accept the proposal. |
Beta Was this translation helpful? Give feedback.
-
Proposal #822 introduced a required field notation to handle various shortcomings of current CUE. This proposal turned out to be problematic on various fronts and
As this is a design that already has gone through many iterations, we went ahead writing
a new design doc which we will post here shortly.
Abstract
We introduce a new field type, a required field, with the aim to address
various shortcomings of CUE while at the same time allowing for simpler semantics for other features we wish to introduce in CUE.
https://github.com/cue-lang/proposal/blob/main/designs/1951-required-fields-v2.md
Beta Was this translation helpful? Give feedback.
All reactions