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