gunk-dev/the-valley

schema.nix

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