| 1 | package setup |
| 2 | |
| 3 | import "time" |
| 4 | |
| 5 | type Runner struct { |
| 6 | RequestedAt time.Time `gorm:"-"` |
| 7 | TrialOwner string `gorm:"-"` |
| 8 | TrialAt time.Time `gorm:"-"` |
| 9 | TrialVersions string `gorm:"-"` |
| 10 | ID string `gorm:"primaryKey"` |
| 11 | Person string `gorm:"index:runner_person"` |
| 12 | MachineKeyHash string |
| 13 | Label string |
| 14 | Revision int64 |
| 15 | RevokedAt *time.Time |
| 16 | // Role is primary (the person's first runner) or worker. |
| 17 | Role string |
| 18 | // Report is what the runner last said of itself: its platform, how |
| 19 | // it confines checks and a Mac's self-probes (nil until it has). |
| 20 | Report *RunnerReport `gorm:"-"` |
| 21 | // TaintedAt: a check ran outside the sandbox on this runner (a Mac |
| 22 | // worker). Never cleared: its checks are labelled that way for good. |
| 23 | TaintedAt *time.Time |
| 24 | // RemovingAt: removal asked for while work it may have started was |
| 25 | // still running; it is revoked once that work's end is proven. |
| 26 | RemovingAt *time.Time |
| 27 | // CredentialHeldAt: since when the instance holds this Mac worker as |
| 28 | // having a model credential (slice F, D1); nil when it holds none. |
| 29 | CredentialHeldAt *time.Time |
| 30 | } |
| 31 | |
| 32 | // RunnerReport is a runner's own report, for the Connections view. |
| 33 | type RunnerReport struct { |
| 34 | Platform, Sandbox string |
| 35 | Probes []RunnerProbe |
| 36 | // Unproven says, in words, why an attempt's end there can never be |
| 37 | // proven ("" for none). |
| 38 | Unproven string |
| 39 | // Engineering says, in words, whether Engineering can run there now |
| 40 | // (a Mac at protocol 37; "" otherwise), EngineeringState its state; |
| 41 | // Guards say what keeps Claude off it and as whom to change it. |
| 42 | Engineering, EngineeringState string |
| 43 | Guards []string |
| 44 | } |
| 45 | |
| 46 | // RunnerProbe is one self-probe: P1 to P7, its verdict and detail. |
| 47 | type RunnerProbe struct{ ID, Verdict, Detail string } |
| 48 | |
| 49 | // Runner roles. |
| 50 | const ( |
| 51 | RolePrimary = "primary" |
| 52 | RoleWorker = "worker" |
| 53 | ) |
| 54 | |
| 55 | type RunnerRecord struct { |
| 56 | Runner `gorm:"embedded"` |
| 57 | InstanceID string |
| 58 | } |
| 59 | |
| 60 | func (RunnerRecord) TableName() string { return "runners" } |
| 61 | |
| 62 | type EnrolmentRecord struct { |
| 63 | CreatedAt time.Time |
| 64 | ID string `gorm:"primaryKey"` |
| 65 | InstanceID string |
| 66 | Audience string |
| 67 | MachinePublicKey string |
| 68 | MachineKeyHash string |
| 69 | Label string |
| 70 | DeviceSecretHash string `gorm:"uniqueIndex:runner_device_secret"` |
| 71 | UserCodeHash string `gorm:"uniqueIndex:runner_user_code"` |
| 72 | Challenge string |
| 73 | ExpiresAt time.Time |
| 74 | NextPollAt time.Time |
| 75 | Person string |
| 76 | RunnerID string |
| 77 | ApprovedAt *time.Time |
| 78 | ConsumedAt *time.Time |
| 79 | RevokedAt *time.Time |
| 80 | // WorkerOnly: the machine said it can only be a worker (a Mac). |
| 81 | WorkerOnly bool |
| 82 | } |
| 83 | |
| 84 | func (EnrolmentRecord) TableName() string { return "runner_enrolments" } |
| 85 | |