Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| API and MCP server, Rust identity service, registration, site redesign | 1 | //! Types and service interfaces shared by every g1t service. |
| 2 | //! | |
| 3 | //! Each service has a module here holding the data it exchanges and the | |
| 4 | //! arguments of each of its methods. Services and their callers depend on | |
| 5 | //! this crate, never on each other's code. | |
| 6 | ||
| Merge branch 'main' into worktree-agent-a69aeabc4b0deeb97 | 7 | pub mod about; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 8 | pub mod access; |
| 9 | pub mod accounts; | |
| GitHub Actions on g1t, part two: running workflows | 10 | pub mod actions; |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 11 | pub mod agents; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 12 | pub mod audit; |
| Merge branch 'worktree-agent-ac5b181a013e54348' | 13 | pub mod backups; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 14 | pub mod billing; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 15 | pub mod capture; |
| Merge checks: statuses and check runs on every commit | 16 | pub mod checks; |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 17 | pub mod codeowners; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 18 | pub mod credentials; |
| Rust repos service with shipping; pull requests kept in the model | 19 | pub mod events; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 20 | pub mod github; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 21 | pub mod guardrails; |
| API and MCP server, Rust identity service, registration, site redesign | 22 | pub mod identity; |
| Inbox: the events service tells people what needs them as events arrive | 23 | pub mod inbox; |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 24 | pub mod integrations; |
| API and MCP server, Rust identity service, registration, site redesign | 25 | mod ids; |
| 26 | mod names; | |
| 27 | mod outcome; | |
| Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member | 28 | pub mod packages; |
| Projects: what a workspace builds and runs, first on every page | 29 | pub mod projects; |
| Rust repos service with shipping; pull requests kept in the model | 30 | pub mod repos; |
| Merge rulesets: branch and tag rules, agent-first, enforced on push and merge | 31 | pub mod rules; |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 32 | pub mod runners; |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 33 | pub mod scopes; |
| Search across all of g1t, Explore, and a command palette | 34 | pub mod search; |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 35 | pub mod security; |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 36 | pub mod teams; |
| 37 | pub mod security_suite; | |
| RFC 3339 timestamps in identity and repos | 38 | pub mod time; |
| Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar | 39 | pub mod updates; |
| Webhooks: every event, to your own addresses, signed and retried | 40 | pub mod webhooks; |
| Work service in Rust, with RFC 3339 timestamps | 41 | pub mod work; |
| API and MCP server, Rust identity service, registration, site redesign | 42 | |
| 43 | pub use ids::new_id; | |
| Merge branch 'worktree-agent-a8385d293d42c913a' | 44 | pub use names::{ |
| 45 | aliasable_name, claimable_namespace, is_namespace_shaped, is_reserved_name, is_route_name, is_valid_namespace, | |
| 46 | is_valid_repo_name, | |
| 47 | }; | |
| API and MCP server, Rust identity service, registration, site redesign | 48 | pub use outcome::{Failure, FailureCode, Outcome}; |
| 49 | ||
| 50 | use serde::{Deserialize, Serialize}; | |
| 51 | ||
| Workspaces own repositories | 52 | /// What a member may do in a workspace. |
| 53 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] | |
| 54 | #[serde(rename_all = "lowercase")] | |
| 55 | pub enum Role { | |
| 56 | /// Everything a member can, plus managing members. | |
| 57 | Owner, | |
| Issues and pull requests replace intents and attempts | 58 | /// Create repositories, push, manage issues and merge pull requests. |
| Workspaces own repositories | 59 | Member, |
| 60 | } | |
| 61 | ||
| 62 | /// One workspace a user belongs to. | |
| API and MCP server, Rust identity service, registration, site redesign | 63 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| Workspaces own repositories | 64 | pub struct Membership { |
| 65 | /// The workspace's name in URLs: `g1t.sh/<slug>`. | |
| 66 | pub slug: String, | |
| 67 | pub role: Role, | |
| Workspace names and icons, and a component kit for every control | 68 | /// The workspace's display name, for showing it to people. Set when a |
| 69 | /// user is resolved from credentials; absent on principals made up by | |
| 70 | /// a service. | |
| 71 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 72 | pub name: Option<String>, | |
| 73 | /// The workspace's uploaded icon: the SHA-256 of its bytes, served at | |
| 74 | /// `/avatars/<avatar>`. Absent means the generated letter avatar. | |
| 75 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 76 | pub avatar: Option<String>, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 77 | /// What a member gets on each of the workspace's repositories: the |
| 78 | /// workspace's base permission. Set when a user is resolved from | |
| 79 | /// credentials; absent means the default, Write. Owners have Admin | |
| 80 | /// whatever it says. See [`access`]. | |
| 81 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 82 | pub base_permission: Option<access::BasePermission>, | |
| Merge branch 'worktree-agent-ad7c6d88d93adc817' | 83 | /// Who may create the workspace's teams. Set when a user is resolved |
| 84 | /// from credentials; absent means the default, any member. See | |
| 85 | /// [`teams::TeamCreation`]. | |
| 86 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 87 | pub team_creation: Option<teams::TeamCreation>, | |
| Workspaces own repositories | 88 | } |
| 89 | ||
| Workspace names and icons, and a component kit for every control | 90 | impl Membership { |
| 91 | /// A plain member of `slug`, as services act inside one workspace. | |
| 92 | pub fn member(slug: impl Into<String>) -> Self { | |
| 93 | Membership { | |
| 94 | slug: slug.into(), | |
| 95 | role: Role::Member, | |
| 96 | name: None, | |
| 97 | avatar: None, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 98 | base_permission: None, |
| Merge branch 'worktree-agent-ad7c6d88d93adc817' | 99 | team_creation: None, |
| Workspace names and icons, and a component kit for every control | 100 | } |
| 101 | } | |
| 102 | } | |
| 103 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 104 | /// What a set of credentials resolved to. |
| 105 | #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] | |
| 106 | #[serde(rename_all = "lowercase")] | |
| 107 | pub enum PrincipalKind { | |
| 108 | /// A person's account. | |
| 109 | #[default] | |
| 110 | User, | |
| 111 | /// A workspace, acting through one of its own access tokens. Its `id` | |
| 112 | /// is the workspace's, its `username` the workspace's slug, and it is a | |
| 113 | /// member of that workspace and no other. | |
| 114 | Workspace, | |
| 115 | /// A g1t agent at work in a sandbox, acting through a token that lives | |
| 116 | /// as long as its run and can do only what that token's scope lists, in | |
| g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent | 117 | /// one repository. Its `username` is `g1t`. |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 118 | Agent, |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 119 | /// g1t itself: the platform acting on its own, as when it opens a |
| 120 | /// pull request to upgrade a vulnerable dependency or merges from the | |
| 121 | /// queue. Never resolved from credentials: only services make one, | |
| 122 | /// with [`User::system`]. Its `username` is `g1t`, which nobody can | |
| 123 | /// register. | |
| 124 | System, | |
| 125 | } | |
| 126 | ||
| 127 | /// g1t's own identity, as [`PrincipalKind::System`] work is recorded. | |
| 128 | pub mod system { | |
| 129 | /// Its id wherever an author or actor id is stored. | |
| 130 | pub const ID: &str = "g1t"; | |
| 131 | /// Its name, shown as the author of what it does. | |
| 132 | pub const USERNAME: &str = "g1t"; | |
| 133 | /// The address on the commits it makes, which no mailbox receives. | |
| 134 | pub const EMAIL: &str = "g1t@users.noreply.g1t.sh"; | |
| 135 | /// Ids that earlier versions stored for g1t's own actions, such as a | |
| 136 | /// merge its settings made. Read as g1t too. | |
| 137 | pub const LEGACY_IDS: [&str; 3] = ["g1t_policy", "svc_runner", "g1t_runner"]; | |
| 138 | ||
| 139 | /// Whether `id` is g1t's own. | |
| 140 | pub fn is_system_id(id: &str) -> bool { | |
| 141 | id == ID || LEGACY_IDS.contains(&id) | |
| 142 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 143 | } |
| 144 | ||
| Workspaces own repositories | 145 | #[derive(Clone, Debug, Default, Serialize, Deserialize)] |
| API and MCP server, Rust identity service, registration, site redesign | 146 | pub struct User { |
| 147 | pub id: String, | |
| 148 | pub username: String, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 149 | #[serde(default)] |
| 150 | pub kind: PrincipalKind, | |
| Email verification, password reset, and Git for AI scale positioning | 151 | /// Whether the account's email address has been confirmed. Unverified |
| 152 | /// accounts can sign in but cannot create or change anything. | |
| 153 | #[serde(default)] | |
| 154 | pub verified: bool, | |
| Workspaces own repositories | 155 | /// The workspaces this user belongs to. Filled in when a user is |
| 156 | /// resolved from credentials, so any service can authorize from it. | |
| 157 | #[serde(default)] | |
| 158 | pub workspaces: Vec<Membership>, | |
| Workspace names and icons, and a component kit for every control | 159 | /// The person's uploaded avatar: the SHA-256 of its bytes, served at |
| 160 | /// `/avatars/<avatar>`. Absent means the generated letter avatar. | |
| 161 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 162 | pub avatar: Option<String>, | |
| Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API | 163 | /// Set on an agent resolved from its token: who it acts for, with which |
| 164 | /// credential, and what it may do. See [`credentials`]. | |
| 165 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 166 | pub acting: Option<Box<credentials::Acting>>, | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 167 | /// The repositories this user has been given a role on directly, |
| 168 | /// whether or not they belong to its workspace. Filled in with | |
| 169 | /// `workspaces`; see [`access`]. | |
| 170 | #[serde(default, skip_serializing_if = "Vec::is_empty")] | |
| 171 | pub grants: Vec<access::RepoGrant>, | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 172 | /// Set on a user resolved from an access token: its scopes and the |
| 173 | /// workspaces or repositories it is limited to. Absent on a signed-in | |
| 174 | /// session and on an agent (whose `acting` scope applies instead). | |
| 175 | /// See [`scopes`]. | |
| 176 | #[serde(default, skip_serializing_if = "Option::is_none")] | |
| 177 | pub token: Option<Box<scopes::TokenAccess>>, | |
| Workspaces own repositories | 178 | } |
| 179 | ||
| 180 | impl User { | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 181 | /// g1t itself, acting in `workspace`: what the platform's own work, |
| 182 | /// such as security updates, is done and recorded as. | |
| 183 | pub fn system(workspace: &str) -> User { | |
| 184 | User { | |
| 185 | id: system::ID.to_owned(), | |
| 186 | username: system::USERNAME.to_owned(), | |
| 187 | kind: PrincipalKind::System, | |
| 188 | verified: true, | |
| 189 | workspaces: vec![Membership::member(workspace.to_lowercase())], | |
| 190 | ..User::default() | |
| 191 | } | |
| 192 | } | |
| 193 | ||
| 194 | /// Whether this is g1t itself. | |
| 195 | pub fn is_system(&self) -> bool { | |
| 196 | self.kind == PrincipalKind::System | |
| 197 | } | |
| 198 | ||
| Workspaces own repositories | 199 | pub fn role_in(&self, slug: &str) -> Option<Role> { |
| 200 | self.workspaces | |
| 201 | .iter() | |
| 202 | .find(|membership| membership.slug == slug) | |
| 203 | .map(|membership| membership.role) | |
| 204 | } | |
| 205 | ||
| 206 | pub fn is_member(&self, slug: &str) -> bool { | |
| 207 | self.role_in(slug).is_some() | |
| 208 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 209 | } |
| 210 | ||
| 211 | /// Who is asking. Every read and write in every service takes one. | |
| 212 | pub type Viewer = Option<User>; |
This file's history is long; its oldest lines are credited to the oldest commit read.