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 | ||
| Rust repos service with shipping; pull requests kept in the model | 7 | pub mod events; |
| API and MCP server, Rust identity service, registration, site redesign | 8 | pub mod identity; |
| 9 | mod ids; | |
| 10 | mod names; | |
| 11 | mod outcome; | |
| Rust repos service with shipping; pull requests kept in the model | 12 | pub mod repos; |
| RFC 3339 timestamps in identity and repos | 13 | pub mod time; |
| Work service in Rust, with RFC 3339 timestamps | 14 | pub mod work; |
| API and MCP server, Rust identity service, registration, site redesign | 15 | |
| 16 | pub use ids::new_id; | |
| 17 | pub use names::{is_valid_namespace, is_valid_repo_name}; | |
| 18 | pub use outcome::{Failure, FailureCode, Outcome}; | |
| 19 | ||
| 20 | use serde::{Deserialize, Serialize}; | |
| 21 | ||
| Workspaces own repositories | 22 | /// What a member may do in a workspace. |
| 23 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] | |
| 24 | #[serde(rename_all = "lowercase")] | |
| 25 | pub enum Role { | |
| 26 | /// Everything a member can, plus managing members. | |
| 27 | Owner, | |
| Issues and pull requests replace intents and attempts | 28 | /// Create repositories, push, manage issues and merge pull requests. |
| Workspaces own repositories | 29 | Member, |
| 30 | } | |
| 31 | ||
| 32 | /// One workspace a user belongs to. | |
| API and MCP server, Rust identity service, registration, site redesign | 33 | #[derive(Clone, Debug, Serialize, Deserialize)] |
| Workspaces own repositories | 34 | pub struct Membership { |
| 35 | /// The workspace's name in URLs: `g1t.sh/<slug>`. | |
| 36 | pub slug: String, | |
| 37 | pub role: Role, | |
| 38 | } | |
| 39 | ||
| 40 | #[derive(Clone, Debug, Default, Serialize, Deserialize)] | |
| API and MCP server, Rust identity service, registration, site redesign | 41 | pub struct User { |
| 42 | pub id: String, | |
| 43 | pub username: String, | |
| Email verification, password reset, and Git for AI scale positioning | 44 | /// Whether the account's email address has been confirmed. Unverified |
| 45 | /// accounts can sign in but cannot create or change anything. | |
| 46 | #[serde(default)] | |
| 47 | pub verified: bool, | |
| Workspaces own repositories | 48 | /// The workspaces this user belongs to. Filled in when a user is |
| 49 | /// resolved from credentials, so any service can authorize from it. | |
| 50 | #[serde(default)] | |
| 51 | pub workspaces: Vec<Membership>, | |
| 52 | } | |
| 53 | ||
| 54 | impl User { | |
| 55 | pub fn role_in(&self, slug: &str) -> Option<Role> { | |
| 56 | self.workspaces | |
| 57 | .iter() | |
| 58 | .find(|membership| membership.slug == slug) | |
| 59 | .map(|membership| membership.role) | |
| 60 | } | |
| 61 | ||
| 62 | pub fn is_member(&self, slug: &str) -> bool { | |
| 63 | self.role_in(slug).is_some() | |
| 64 | } | |
| API and MCP server, Rust identity service, registration, site redesign | 65 | } |
| 66 | ||
| 67 | /// Who is asking. Every read and write in every service takes one. | |
| 68 | pub type Viewer = Option<User>; |