gunk-dev/the-valley

schema.nix

sourcee5e09626b3e3main's published tip history
4.0 KiB
1# The schemas against the examples they must accept and the ones they must
2# reject. CUE closedness is easy to regress silently — embedding a
3# definition instead of referencing it opens the schema — so every rejection
4# is a checked-in example, and the ones whose field carries the weight are
5# held to naming it.
6{ pkgs, partOf, ... }:
7{
8 # A host declaration: the pilot's own, with a group and an alias, the
9 # compatibility case, the protection block the installer renders a hook
10 # from, and the sixteen declarations the schema must refuse, among them
11 # group names that collide, a project alias that is a group's name, an
12 # undeclared group and aliases without a group. The event payloads live here too —
13 # the publisher hook's vocabulary is a schema like any other — and so
14 # does the worked verification policy under examples/policy/, with the
15 # carry modes and the restacker's cap case by case under
16 # examples/policy/carry/, and the hardware approval requirement case by
17 # case under examples/policy/approval/. The read policies are vetted
18 # too: the worked ones under examples/policy/read/, among them the one a
19 # new project starts from, the ones the schema must refuse, and the-valley's
20 # own under policy/read/. The other host declarations, and the deriver's
21 # and the smoke policies, are other checks' fixtures, and cue-vet is given
22 # none of them.
23 cue-vet = pkgs.runCommand "valley-cue-vet" {
24 nativeBuildInputs = [ pkgs.cue ];
25 schema = ../../schema/valley.cue;
26 example = ../../examples/host.cue;
27 hosts = partOf ../../examples/hosts [
28 ../../examples/hosts/no-backup.cue
29 ../../examples/hosts/protected.cue
30 ../../examples/hosts/rejected
31 ];
32 eventSchema = ../../schema/events.cue;
33 events = ../../examples/events;
34 rejectedCases = ./cue-vet-rejected.txt;
35 verificationSchema = ../../schema/verification.cue;
36 policies = partOf ../../examples/policy [
37 ../../examples/policy/instance
38 ../../examples/policy/project
39 ../../examples/policy/carry
40 ../../examples/policy/approval
41 ];
42 readSchema = ../../schema/read.cue;
43 readPolicies = ../../examples/policy/read;
44 ownRead = ../../policy/read;
45 } (builtins.readFile ./cue-vet.sh);
46
47 # The attestation statement schema (dcr-0de694f). A statement the
48 # helper composes must vet, and the schema must reject what it
49 # claims to reject. Two rejections carry the decision's whole
50 # weight and are pinned by name in the script: a subject with no
51 # content-addressed digest has no identity at all, and a
52 # predicate that crosses the pure/effectful line would let a
53 # notarization pass itself off as re-derivable.
54 attest-schema = pkgs.runCommand "valley-attest-schema" {
55 nativeBuildInputs = [ pkgs.cue ];
56 schema = ../../schema/attestation.cue;
57 statements = ../../examples/attestations;
58 } (builtins.readFile ./attest-schema.sh);
59
60 # The identity registry schema (dcr-b87f6e8). The worked registry vets,
61 # and the registries the schema must refuse are refused. Four of those
62 # are the substrate's floor over every instance registry — mandatory
63 # expiry where a raw key is held, an external principal carrying one, no
64 # external principal governing the registry, a genesis entry that governs
65 # it — and a floor that stopped being enforced would be silent, so each is
66 # held to naming its field. So are the read grants' rules: anyone holds
67 # read grants alone, no key, and no entry under principals, and is never
68 # genesis; a read grant names its projects, by name and identity, and no
69 # other grant names any; an edge read boundary names its destination, and
70 # no other boundary names one.
71 identity-schema = pkgs.runCommand "valley-identity-schema" {
72 nativeBuildInputs = [ pkgs.cue ];
73 schema = ../../schema/identity.cue;
74 registry = ../../examples/identity/registry;
75 rejected = ../../examples/identity/rejected;
76 rejectedCases = ./identity-rejected.txt;
77 } (builtins.readFile ./identity-schema.sh);
78}