lib/closure/src/schema/axis.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

  1 pub const SubjectKind = enum(u8) {
  2     source,
  3     build_tool,
  4     binary,
  5     data,
  6     service,
  7     firmware,
  8     hardware,
  9     trust,
 10     model,
 11     specification,
 12     oracle,
 13     unknown,
 14 };
 15 
 16 pub const MaterialRole = enum(u8) {
 17     platform,
 18     native_workload,
 19     linux_compatibility,
 20     model,
 21     user_payload,
 22     validation,
 23     bootstrap_seed,
 24     residual_root,
 25     unknown,
 26 };
 27 
 28 pub const Origin = enum(u8) {
 29     owned_source,
 30     owned_derivation,
 31     external_receipted,
 32     external_unreceipted,
 33     platform_supplied,
 34     unknown,
 35 };
 36 
 37 pub const Phase = enum(u8) {
 38     source,
 39     build,
 40     shipment,
 41     pre_handoff_boot,
 42     post_handoff_runtime,
 43     recovery,
 44     validation,
 45 };
 46 
 47 pub const PhaseSet = u16;
 48 
 49 pub fn phaseBit(phase: Phase) PhaseSet {
 50     return @as(PhaseSet, 1) << @intCast(@backingInt(phase));
 51 }
 52 
 53 pub const ExecutionLocus = enum(u8) {
 54     build_host,
 55     normal_world_cpu,
 56     firmware_management_cpu,
 57     device_cpu,
 58     remote_service,
 59     nonexecuting,
 60     unknown,
 61 };
 62 
 63 pub const AuthorityClass = enum(u8) {
 64     platform_control,
 65     native_workload,
 66     linux_compatibility,
 67     model_behavior,
 68     user_payload,
 69     validation,
 70     none,
 71     unknown,
 72 };
 73 
 74 pub const GrantedAuthority = enum(u8) {
 75     memory,
 76     schedule,
 77     device,
 78     file,
 79     network,
 80     service,
 81     admission,
 82     update,
 83     closure_ledger,
 84     signing,
 85     root,
 86     delegation,
 87     validation,
 88     none,
 89     unknown,
 90 };
 91 
 92 pub const ArtifactKind = enum(u8) {
 93     source,
 94     object,
 95     executable,
 96     image,
 97     data,
 98     manifest,
 99     receipt,
100     service,
101     firmware,
102     hardware,
103     trust,
104     model,
105     specification,
106     unknown,
107 };
108 
109 pub const EdgeKind = enum(u8) {
110     derivation,
111     build_influence,
112     shipment,
113     loading_execution,
114     data_flow,
115     authority_grant,
116     service_call,
117     validation,
118 };
119 
120 pub const EdgeSet = u16;
121 
122 pub fn edgeBit(kind: EdgeKind) EdgeSet {
123     return @as(EdgeSet, 1) << @intCast(@backingInt(kind));
124 }
125 
126 pub const Treatment = enum(u8) {
127     owned,
128     verified,
129     isolated,
130     residual_assumption,
131     optional_user_effect,
132     validation_only,
133     forbidden,
134     unknown,
135 };
136 
137 pub const WitnessKind = enum(u8) {
138     owned,
139     differential,
140     foreign,
141     unknown,
142 };
143 
144 pub const RequirementClass = enum(u8) {
145     required,
146     optional_user_effect,
147     validation_only,
148     unknown,
149 };
150 
151 pub const Verdict = enum(u8) {
152     pass,
153     refuted,
154     inconclusive,
155     not_exercised,
156 };
157 
158 test "phase and edge masks preserve every declared tag" {
159     var phases: PhaseSet = 0;
160     for (std.meta.tags(Phase)) |phase| phases |= phaseBit(phase);
161     try std.testing.expectEqual(
162         (@as(PhaseSet, 1) << std.meta.tags(Phase).len) - 1,
163         phases,
164     );
165     var edges: EdgeSet = 0;
166     for (std.meta.tags(EdgeKind)) |kind| edges |= edgeBit(kind);
167     try std.testing.expectEqual(
168         (@as(EdgeSet, 1) << std.meta.tags(EdgeKind).len) - 1,
169         edges,
170     );
171 }
172 
173 const std = @import("std");