gunk-dev/the-valley

schema.nix

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