Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constrain sequence lenses so that an absent declaration is not valid #2

Closed
sdboyer opened this issue Nov 30, 2021 · 1 comment · Fixed by #82
Closed

Constrain sequence lenses so that an absent declaration is not valid #2

sdboyer opened this issue Nov 30, 2021 · 1 comment · Fixed by #82
Labels
bug Something isn't working invariants Involves the definition or enforcement of a key system invariant

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Nov 30, 2021

A key invariant of scuemata is that authors must define lenses for all sequences after the first. While it's impossible to generically verify the completeness of the translations in these lenses, or the lacunae the may emit, the bare minimum here is erroring if the author doesn't define a lens, at all.

Unfortunately, when we take the #Lens definition

thema/lineage.cue

Lines 48 to 67 in b7b4330

#Lens: {
// The last schema in the previous sequence; logical predecessor
ancestor: joinSchema
// The first schema in this sequence; logical successor
descendant: joinSchema
forward: {
to: descendant
from: ancestor
rel: descendant
lacunas: [...#Lacuna]
translated: to & rel
}
reverse: {
to: ancestor
from: descendant
rel: ancestor
lacunas: [...#Lacuna]
translated: to & rel
}
}

and reference it directly in seqs where we want lens instances to appear:

thema/lineage.cue

Lines 72 to 80 in b7b4330

seqs: [
{
schemas: #Sequence
},
...{
schemas: #Sequence
lens: #Lens
}
]

it means that a lineage is still valid even when the author omits the field. The questions are:

  • What's a reasonable thing to force a constraint failure on? Should #Lens itself be refactored so that it's more amenable to doing this?
  • How do we square wanting this to be incomplete with also wanting to provide helpers that reduce some of the boilerplate of writing lenses?

Maybe this is just yet another place where we need a must() check (cue-lang/cue#943), particularly to emit the right error.

Note that this issue is targeting a relatively minimal check - to climb up to our true-goal invariant, in addition to basic lens existence, we have to be certain that a) the Lens connects the end of the prior sequence to the head of its current sequence, and b) that given a concrete input valid wrt the predecessor schema, the rel of both forward and reverse lenses is sufficient to produce a concrete output of the successor schema.

@sdboyer sdboyer added bug Something isn't working invariants Involves the definition or enforcement of a key system invariant labels Nov 30, 2021
@sdboyer
Copy link
Contributor Author

sdboyer commented Mar 12, 2023

#82 will address this problem; we won't address it in current structure, which is pretty broken wrt lenses anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invariants Involves the definition or enforcement of a key system invariant
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant