Skip to content
201 linesCodeBlameRaw

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 redesign1//! 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 look7pub mod access;
8pub mod accounts;
GitHub Actions on g1t, part two: running workflows9pub mod actions;
Agents and memory, checks and conflicts, profiles, slug renames, custom domains10pub mod agents;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API11pub mod audit;
Merge branch 'worktree-agent-ac5b181a013e54348'12pub mod backups;
Agents as a team: lifecycle, merge queue, billing and a new shell13pub mod billing;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API14pub mod capture;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar15pub mod codeowners;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API16pub mod credentials;
Rust repos service with shipping; pull requests kept in the model17pub mod events;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look18pub mod github;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API19pub mod guardrails;
API and MCP server, Rust identity service, registration, site redesign20pub mod identity;
Inbox: the events service tells people what needs them as events arrive21pub mod inbox;
Integrations: your own model provider, alerts that open issues, tickets agents read22pub mod integrations;
API and MCP server, Rust identity service, registration, site redesign23mod ids;
24mod names;
25mod outcome;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member26pub mod packages;
Projects: what a workspace builds and runs, first on every page27pub mod projects;
Rust repos service with shipping; pull requests kept in the model28pub mod repos;
Rules engine: rulesets for branches and tags, and the facts they judge29pub mod rules;
Fast pages, required checks on the branch, self-hosted runners, honest incidents30pub mod runners;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step31pub mod scopes;
Search across all of g1t, Explore, and a command palette32pub mod search;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API33pub mod security;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar34pub mod teams;
35pub mod security_suite;
RFC 3339 timestamps in identity and repos36pub mod time;
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar37pub mod updates;
Webhooks: every event, to your own addresses, signed and retried38pub mod webhooks;
Work service in Rust, with RFC 3339 timestamps39pub mod work;
API and MCP server, Rust identity service, registration, site redesign40
41pub 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-agent42pub use names::{claimable_namespace, is_reserved_name, is_valid_namespace, is_valid_repo_name};
API and MCP server, Rust identity service, registration, site redesign43pub use outcome::{Failure, FailureCode, Outcome};
44
45use serde::{Deserialize, Serialize};
46
Workspaces own repositories47/// What a member may do in a workspace.
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
49#[serde(rename_all = "lowercase")]
50pub enum Role {
51 /// Everything a member can, plus managing members.
52 Owner,
Issues and pull requests replace intents and attempts53 /// Create repositories, push, manage issues and merge pull requests.
Workspaces own repositories54 Member,
55}
56
57/// One workspace a user belongs to.
API and MCP server, Rust identity service, registration, site redesign58#[derive(Clone, Debug, Serialize, Deserialize)]
Workspaces own repositories59pub struct Membership {
60 /// The workspace's name in URLs: `g1t.sh/<slug>`.
61 pub slug: String,
62 pub role: Role,
Workspace names and icons, and a component kit for every control63 /// The workspace's display name, for showing it to people. Set when a
64 /// user is resolved from credentials; absent on principals made up by
65 /// a service.
66 #[serde(default, skip_serializing_if = "Option::is_none")]
67 pub name: Option<String>,
68 /// The workspace's uploaded icon: the SHA-256 of its bytes, served at
69 /// `/avatars/<avatar>`. Absent means the generated letter avatar.
70 #[serde(default, skip_serializing_if = "Option::is_none")]
71 pub avatar: Option<String>,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look72 /// What a member gets on each of the workspace's repositories: the
73 /// workspace's base permission. Set when a user is resolved from
74 /// credentials; absent means the default, Write. Owners have Admin
75 /// whatever it says. See [`access`].
76 #[serde(default, skip_serializing_if = "Option::is_none")]
77 pub base_permission: Option<access::BasePermission>,
Workspaces own repositories78}
79
Workspace names and icons, and a component kit for every control80impl Membership {
81 /// A plain member of `slug`, as services act inside one workspace.
82 pub fn member(slug: impl Into<String>) -> Self {
83 Membership {
84 slug: slug.into(),
85 role: Role::Member,
86 name: None,
87 avatar: None,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look88 base_permission: None,
Workspace names and icons, and a component kit for every control89 }
90 }
91}
92
Agents as a team: lifecycle, merge queue, billing and a new shell93/// What a set of credentials resolved to.
94#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
95#[serde(rename_all = "lowercase")]
96pub enum PrincipalKind {
97 /// A person's account.
98 #[default]
99 User,
100 /// A workspace, acting through one of its own access tokens. Its `id`
101 /// is the workspace's, its `username` the workspace's slug, and it is a
102 /// member of that workspace and no other.
103 Workspace,
104 /// A g1t agent at work in a sandbox, acting through a token that lives
105 /// 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-agent106 /// one repository. Its `username` is `g1t`.
Agents as a team: lifecycle, merge queue, billing and a new shell107 Agent,
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily108 /// g1t itself: the platform acting on its own, as when it opens a
109 /// pull request to upgrade a vulnerable dependency or merges from the
110 /// queue. Never resolved from credentials: only services make one,
111 /// with [`User::system`]. Its `username` is `g1t`, which nobody can
112 /// register.
113 System,
114}
115
116/// g1t's own identity, as [`PrincipalKind::System`] work is recorded.
117pub mod system {
118 /// Its id wherever an author or actor id is stored.
119 pub const ID: &str = "g1t";
120 /// Its name, shown as the author of what it does.
121 pub const USERNAME: &str = "g1t";
122 /// The address on the commits it makes, which no mailbox receives.
123 pub const EMAIL: &str = "g1t@users.noreply.g1t.sh";
124 /// Ids that earlier versions stored for g1t's own actions, such as a
125 /// merge its settings made. Read as g1t too.
126 pub const LEGACY_IDS: [&str; 3] = ["g1t_policy", "svc_runner", "g1t_runner"];
127
128 /// Whether `id` is g1t's own.
129 pub fn is_system_id(id: &str) -> bool {
130 id == ID || LEGACY_IDS.contains(&id)
131 }
Agents as a team: lifecycle, merge queue, billing and a new shell132}
133
Workspaces own repositories134#[derive(Clone, Debug, Default, Serialize, Deserialize)]
API and MCP server, Rust identity service, registration, site redesign135pub struct User {
136 pub id: String,
137 pub username: String,
Agents as a team: lifecycle, merge queue, billing and a new shell138 #[serde(default)]
139 pub kind: PrincipalKind,
Email verification, password reset, and Git for AI scale positioning140 /// Whether the account's email address has been confirmed. Unverified
141 /// accounts can sign in but cannot create or change anything.
142 #[serde(default)]
143 pub verified: bool,
Workspaces own repositories144 /// The workspaces this user belongs to. Filled in when a user is
145 /// resolved from credentials, so any service can authorize from it.
146 #[serde(default)]
147 pub workspaces: Vec<Membership>,
Workspace names and icons, and a component kit for every control148 /// The person's uploaded avatar: the SHA-256 of its bytes, served at
149 /// `/avatars/<avatar>`. Absent means the generated letter avatar.
150 #[serde(default, skip_serializing_if = "Option::is_none")]
151 pub avatar: Option<String>,
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API152 /// Set on an agent resolved from its token: who it acts for, with which
153 /// credential, and what it may do. See [`credentials`].
154 #[serde(default, skip_serializing_if = "Option::is_none")]
155 pub acting: Option<Box<credentials::Acting>>,
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look156 /// The repositories this user has been given a role on directly,
157 /// whether or not they belong to its workspace. Filled in with
158 /// `workspaces`; see [`access`].
159 #[serde(default, skip_serializing_if = "Vec::is_empty")]
160 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 step161 /// Set on a user resolved from an access token: its scopes and the
162 /// workspaces or repositories it is limited to. Absent on a signed-in
163 /// session and on an agent (whose `acting` scope applies instead).
164 /// See [`scopes`].
165 #[serde(default, skip_serializing_if = "Option::is_none")]
166 pub token: Option<Box<scopes::TokenAccess>>,
Workspaces own repositories167}
168
169impl User {
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily170 /// g1t itself, acting in `workspace`: what the platform's own work,
171 /// such as security updates, is done and recorded as.
172 pub fn system(workspace: &str) -> User {
173 User {
174 id: system::ID.to_owned(),
175 username: system::USERNAME.to_owned(),
176 kind: PrincipalKind::System,
177 verified: true,
178 workspaces: vec![Membership::member(workspace.to_lowercase())],
179 ..User::default()
180 }
181 }
182
183 /// Whether this is g1t itself.
184 pub fn is_system(&self) -> bool {
185 self.kind == PrincipalKind::System
186 }
187
Workspaces own repositories188 pub fn role_in(&self, slug: &str) -> Option<Role> {
189 self.workspaces
190 .iter()
191 .find(|membership| membership.slug == slug)
192 .map(|membership| membership.role)
193 }
194
195 pub fn is_member(&self, slug: &str) -> bool {
196 self.role_in(slug).is_some()
197 }
API and MCP server, Rust identity service, registration, site redesign198}
199
200/// Who is asking. Every read and write in every service takes one.
201pub type Viewer = Option<User>;

This file's history is long; its oldest lines are credited to the oldest commit read.