diff --git a/crates/agentdeckd/src/github_list.rs b/crates/agentdeckd/src/github_list.rs index 1f24a26..0c6b505 100644 --- a/crates/agentdeckd/src/github_list.rs +++ b/crates/agentdeckd/src/github_list.rs @@ -8,6 +8,13 @@ //! 12 requests. Each page is served as it arrives while no list is held; once one is, a //! refresh runs quietly under it and replaces it whole. One load runs at a time. //! +//! A held list keeps each page's `ETag`, and a refresh asks for every page but the first with +//! `If-None-Match`: GitHub's `304` costs nothing against the rate limit and keeps the page +//! held. Page 1 is always read whole, since a `304` carries no `Link` header and the page +//! count may have changed. Each page stands alone: a `304` says that page reads as held, so a +//! repository added or removed, which shifts the pages after it, just has those pages answer +//! whole, and the list stays exact without reading the rest unconditionally. +//! //! The list is kept in memory for the run, for the sign-in it was read with: when the token //! changes, it is dropped and, if a client had asked for it, loaded again. Every change to it //! or its progress sends `changed github_repositories`. `search/repositories` is never called: @@ -21,7 +28,9 @@ use futures_util::{StreamExt as _, TryStreamExt as _}; use crate::events::Events; use crate::github_auth::{GithubAuth, NoToken}; use crate::model::{GithubListStatus, GithubRepositoryList, Repository}; -use crate::prsync::github::{Github, GithubError, REPOS_PAGE_SIZE, RemoteRepository, ReposPage}; +use crate::prsync::github::{ + Github, GithubError, REPOS_PAGE_SIZE, RemoteRepository, ReposPage, ReposRead, +}; /// How many pages after the first are read at once. const PAGES_IN_FLIGHT: usize = 4; @@ -42,6 +51,22 @@ struct Inner { state: Mutex, } +/// One page of a list loaded whole, with the `ETag` GitHub sent it with. +#[derive(Clone)] +struct HeldPage { + etag: Option, + repositories: Vec, +} + +impl From for HeldPage { + fn from(read: ReposPage) -> HeldPage { + HeldPage { + etag: read.etag, + repositories: read.repositories.into_iter().map(repository).collect(), + } + } +} + #[derive(Default)] struct State { /// Bumped when the sign-in changes, so a load from before stores nothing. @@ -50,8 +75,8 @@ struct State { loading: bool, /// Whether a client has asked for the list since the sign-in last changed. asked: bool, - /// The last list loaded whole. - held: Option>, + /// The last list loaded whole, by page from 1. + held: Option>, /// While no list is held, the first load's pages that have arrived, by number from 1. pages: Vec>>, /// The first load's last page number, once page 1 has answered. @@ -66,7 +91,13 @@ impl State { /// The list as `GET /v1/github/repositories` answers it. fn list(&self) -> GithubRepositoryList { let (status, repositories, total) = match &self.held { - Some(held) => (GithubListStatus::Loaded, held.clone(), Some(len(held))), + Some(held) => { + let repositories: Vec = (held.iter()) + .flat_map(|page| page.repositories.iter().cloned()) + .collect(); + let total = Some(len(&repositories)); + (GithubListStatus::Loaded, repositories, total) + } None if self.loading => { let repositories: Vec = self.pages.iter().flatten().flatten().cloned().collect(); @@ -141,7 +172,7 @@ impl GithubList { /// reads signed out; with a token GitHub rejects, failed. pub async fn refresh(&self) { let token = self.inner.auth.current_token().await; - let (generation, quiet) = { + let (generation, quiet, kept) = { let mut state = self.state(); state.asked = true; if state.loading { @@ -175,14 +206,15 @@ impl GithubList { }; } } - (state.generation, quiet) + let kept = (state.held.clone()).filter(|_| quiet).unwrap_or_default(); + (state.generation, quiet, kept) }; if !quiet { self.changed(); } if let Ok(token) = token { let this = self.clone(); - tokio::spawn(async move { this.load(generation, token).await }); + tokio::spawn(async move { this.load(generation, token, kept).await }); } } @@ -205,10 +237,10 @@ impl GithubList { } /// Reads every page with `token` and keeps the list, unless the sign-in changed meanwhile. - /// A list held already is replaced whole, and a failure keeps it, saying why; either sends - /// `changed` only when what clients read differs. - async fn load(&self, generation: u64, token: String) { - let loaded = self.read_pages(generation, token).await; + /// A list held already (`kept`, by page) is replaced whole, and a failure keeps it, saying + /// why; either sends `changed` only when what clients read differs. + async fn load(&self, generation: u64, token: String, kept: Vec) { + let loaded = self.read_pages(generation, token, &kept).await; let changed = { let mut state = self.state(); if state.generation != generation { @@ -235,25 +267,34 @@ impl GithubList { } } - /// Every page, in order: page 1, then the last, then those between. While no list is held, - /// each is kept as it arrives. + /// Every page, in order: page 1, then the last, then those between. Each page after the + /// first that `kept` holds is asked for only if it changed, and kept as it was if not. + /// While no list is held, each is kept as it arrives. async fn read_pages( &self, generation: u64, token: String, - ) -> Result, GithubError> { + kept: &[HeldPage], + ) -> Result, GithubError> { let (first, token) = self.first_page(token).await?; let last = first.last.unwrap_or(1).max(1); - let mut pages: Vec>> = vec![None; last as usize]; - self.arrived(generation, &mut pages, 1, first, Some(last)); + let mut pages: Vec> = vec![None; last as usize]; + self.arrived(generation, &mut pages, 1, first.into(), Some(last)); let order = (last > 1).then_some(last).into_iter().chain(2..last); let github = &self.inner.github; let token = token.as_str(); let mut reads = futures_util::stream::iter(order.map(|page| async move { - github - .user_repos_page(token, page) - .await - .map(|read| (page, read)) + let kept = kept.get(page as usize - 1); + let etag = kept.and_then(|kept| kept.etag.as_deref()); + let read = match github.user_repos_page(token, page, etag).await? { + ReposRead::Page(read) => read.into(), + // Only a page asked for with a kept page's ETag answers 304. + ReposRead::NotModified => kept.cloned().ok_or(GithubError::Status { + status: 304, + message: None, + })?, + }; + Ok((page, read)) })) .buffer_unordered(PAGES_IN_FLIGHT); while let Some((page, read)) = reads.try_next().await.inspect_err(|err| { @@ -263,26 +304,34 @@ impl GithubList { })? { self.arrived(generation, &mut pages, page, read, None); } - Ok(pages.into_iter().flatten().flatten().collect()) + Ok(pages.into_iter().flatten().collect()) } - /// Page 1 and the token that read it: a 401 reads the token's sources again and tries - /// once more, then counts the token as rejected. + /// Page 1, read whole for its `Link` header, and the token that read it: a 401 reads the + /// token's sources again and tries once more, then counts the token as rejected. async fn first_page(&self, token: String) -> Result<(ReposPage, String), GithubError> { let github = &self.inner.github; - match github.user_repos_page(&token, 1).await { + let whole = |read| match read { + ReposRead::Page(page) => Ok(page), + // Never asked with an ETag, so never answered 304. + ReposRead::NotModified => Err(GithubError::Status { + status: 304, + message: None, + }), + }; + match github.user_repos_page(&token, 1, None).await { Err(GithubError::Unauthorized) => { let fresh = (self.inner.auth.reread().await).map_err(|_| GithubError::Unauthorized)?; - match github.user_repos_page(&fresh, 1).await { + match github.user_repos_page(&fresh, 1, None).await { Err(GithubError::Unauthorized) => { self.inner.auth.rejected(); Err(GithubError::Unauthorized) } - read => read.map(|page| (page, fresh)), + read => whole(read?).map(|page| (page, fresh)), } } - read => read.map(|page| (page, token)), + read => whole(read?).map(|page| (page, token)), } } @@ -291,18 +340,17 @@ impl GithubList { fn arrived( &self, generation: u64, - pages: &mut [Option>], + pages: &mut [Option], page: u32, - read: ReposPage, + read: HeldPage, last: Option, ) { - let read: Vec = read.repositories.into_iter().map(repository).collect(); let at = page as usize - 1; { let mut state = self.state(); if state.generation == generation && state.held.is_none() { state.pages.resize(pages.len(), None); - state.pages[at] = Some(read.clone()); + state.pages[at] = Some(read.repositories.clone()); if last.is_some() { state.last = last; } diff --git a/crates/agentdeckd/src/prsync/github.rs b/crates/agentdeckd/src/prsync/github.rs index c17061f..2351263 100644 --- a/crates/agentdeckd/src/prsync/github.rs +++ b/crates/agentdeckd/src/prsync/github.rs @@ -373,19 +373,31 @@ impl Github { /// Page `page` (from 1) of every repository the token's user can reach, read with the /// REST API's `GET /user/repos?sort=full_name&direction=asc&per_page=100`: owned, - /// collaborator and organisation ones, by `owner/name`. Tried again after each of - /// `RETRY_WAITS` while it fails for a reason that may pass. - pub async fn user_repos_page(&self, token: &str, page: u32) -> Result { + /// collaborator and organisation ones, by `owner/name`. With `etag`, the `ETag` the page + /// came with before, it is asked for only if it changed (`If-None-Match`), and GitHub's + /// `304`, which costs nothing against the rate limit, is [`ReposRead::NotModified`]. Tried + /// again after each of `RETRY_WAITS` while it fails for a reason that may pass. + pub async fn user_repos_page( + &self, + token: &str, + page: u32, + etag: Option<&str>, + ) -> Result { retrying(GithubError::may_pass, || { - self.user_repos_page_once(token, page) + self.user_repos_page_once(token, page, etag) }) .await } /// [`Github::user_repos_page`], once. - async fn user_repos_page_once(&self, token: &str, page: u32) -> Result { + async fn user_repos_page_once( + &self, + token: &str, + page: u32, + etag: Option<&str>, + ) -> Result { let url = format!("{}/user/repos", self.rest); - let response = self + let mut request = self .http .get(url) .query(&[ @@ -396,13 +408,18 @@ impl Github { ]) .bearer_auth(token) .header("accept", "application/vnd.github+json") - .header("x-github-api-version", REST_API_VERSION) - .send() - .await?; + .header("x-github-api-version", REST_API_VERSION); + if let Some(etag) = etag { + request = request.header(reqwest::header::IF_NONE_MATCH, etag); + } + let response = request.send().await?; let status = response.status(); if status == reqwest::StatusCode::UNAUTHORIZED { return Err(GithubError::Unauthorized); } + if status == reqwest::StatusCode::NOT_MODIFIED && etag.is_some() { + return Ok(ReposRead::NotModified); + } if !status.is_success() { let body = response.text().await.unwrap_or_default(); return Err(GithubError::Status { @@ -410,14 +427,19 @@ impl Github { message: message(&body), }); } - let last = (response.headers().get(reqwest::header::LINK)) - .and_then(|link| link.to_str().ok()) - .and_then(last_page); + let header = |name| { + (response.headers().get(name)) + .and_then(|value| value.to_str().ok()) + .map(str::to_owned) + }; + let last = header(reqwest::header::LINK).as_deref().and_then(last_page); + let etag = header(reqwest::header::ETAG); let repositories: Vec = response.json().await?; - Ok(ReposPage { + Ok(ReposRead::Page(ReposPage { repositories: repositories.into_iter().map(Into::into).collect(), last, - }) + etag, + })) } /// Who `token` belongs to, and its scopes. A token GitHub rejects is @@ -718,6 +740,17 @@ pub struct ReposPage { /// The last page's number, from the `Link` header's `rel="last"`; `None` when there's /// none, as on the last page itself. pub last: Option, + /// The page's `ETag`, to ask for it again only if it changed. + pub etag: Option, +} + +/// What `GET /user/repos` answered for one page. +#[derive(Debug, PartialEq, Eq)] +pub enum ReposRead { + /// The page, read whole. + Page(ReposPage), + /// `304 Not Modified`: the page is as it was when it came with the `ETag` sent. + NotModified, } /// The `page` of the `rel="last"` URL in a `Link` header; `None` when it has none, or one diff --git a/crates/agentdeckd/tests/integration/github_list.rs b/crates/agentdeckd/tests/integration/github_list.rs index 5370066..c2edf42 100644 --- a/crates/agentdeckd/tests/integration/github_list.rs +++ b/crates/agentdeckd/tests/integration/github_list.rs @@ -287,6 +287,167 @@ mod post_v1_github_repositories_refresh { assert_eq!(first.calls_async().await, 1); } + /// A quiet refresh sends each held page's `ETag` as `If-None-Match` (page 1 excepted, whose + /// `Link` header a `304` wouldn't carry), so a page GitHub answers `304` costs nothing + /// against the rate limit and keeps the page held. + mod conditional { + use super::*; + + use crate::support::github::UserReposPage; + + /// A daemon holding `repos`, loaded once, and their page mocks. + async fn holding<'a>( + github: &'a MockServer, + repos: &[RestRepo], + ) -> (TestDaemon, Vec>) { + let pages = mock_user_repos(github, TOKEN, repos); + let daemon = signed_in(github).await; + refresh(&daemon.client).await; + until_status(&daemon.client, GithubListStatus::Loaded).await; + (daemon, pages) + } + + /// GitHub's list changed to `after`: every page answers for it now. + async fn changed_to<'a>( + github: &'a MockServer, + pages: &mut [UserReposPage<'a>], + after: &[RestRepo], + ) -> Vec> { + for page in pages { + page.delete_async().await; + } + mock_user_repos(github, TOKEN, after) + } + + /// Waits until `page` has answered `304` `count` times. + async fn not_modified(page: &UserReposPage<'_>, count: usize) { + eventually(&format!("{count} 304s"), || async { + (page.not_modified_async().await == count).then_some(()) + }) + .await; + } + + #[tokio::test] + async fn should_send_each_held_pages_etag_and_keep_the_list_on_304s_204() { + let github = MockServer::start_async().await; + let repos = user_repos(250); + let (daemon, pages) = holding(&github, &repos).await; + let before = list(&daemon.client).await; + let mut ws = Ws::connect(&daemon).await; + + refresh(&daemon.client).await; + not_modified(&pages[1], 1).await; + not_modified(&pages[2], 1).await; + + assert!( + ws.quiet_for(Duration::from_millis(500)).await.is_none(), + "no `changed` for a list that stayed the same" + ); + assert_eq!(list(&daemon.client).await, before); + assert_eq!(pages[0].calls_async().await, 2, "page 1 read again"); + assert_eq!( + pages[0].not_modified_async().await, + 0, + "page 1 unconditional" + ); + for page in &pages[1..] { + assert_eq!(page.calls_async().await, 2); + } + } + + #[tokio::test] + async fn should_read_a_changed_page_whole_keeping_the_pages_that_answer_304_204() { + let github = MockServer::start_async().await; + let before = user_repos(250); + let (daemon, mut pages) = holding(&github, &before).await; + let mut after = before.clone(); + after[150].private = !after[150].private; + let pages = changed_to(&github, &mut pages, &after).await; + let mut ws = Ws::connect(&daemon).await; + + refresh(&daemon.client).await; + changed(&mut ws).await; + + let read = list(&daemon.client).await; + assert_eq!(read.status, GithubListStatus::Loaded); + assert_eq!(names(&read), named(&after)); + assert_eq!(read.repositories[150].private, after[150].private); + assert_eq!(pages[1].not_modified_async().await, 0, "page 2 changed"); + assert_eq!(pages[1].calls_async().await, 1); + assert_eq!(pages[2].not_modified_async().await, 1, "page 3 kept"); + } + + mod page_shift { + use super::*; + + #[tokio::test] + async fn should_read_every_shifted_page_and_a_new_last_page_when_a_repo_is_added_204() { + let github = MockServer::start_async().await; + let before = user_repos(300); + let (daemon, mut pages) = holding(&github, &before).await; + let after = [vec![RestRepo::new("acme/aaa")], before.clone()].concat(); + let pages = changed_to(&github, &mut pages, &after).await; + + refresh(&daemon.client).await; + let read = eventually("301 repositories", || async { + let read = list(&daemon.client).await; + (read.loaded == 301).then_some(read) + }) + .await; + + assert_eq!(names(&read), named(&after)); + assert_eq!(read.total, Some(301)); + for page in &pages { + assert_eq!(page.calls_async().await, 1); + assert_eq!(page.not_modified_async().await, 0); + } + } + + #[tokio::test] + async fn should_find_a_page_added_after_a_full_last_page_that_answers_304_204() { + let github = MockServer::start_async().await; + let before = user_repos(200); + let (daemon, mut pages) = holding(&github, &before).await; + let after = [before.clone(), vec![RestRepo::new("acme/zzz")]].concat(); + let pages = changed_to(&github, &mut pages, &after).await; + + refresh(&daemon.client).await; + let read = eventually("201 repositories", || async { + let read = list(&daemon.client).await; + (read.loaded == 201).then_some(read) + }) + .await; + + assert_eq!(names(&read), named(&after)); + assert_eq!(pages[1].not_modified_async().await, 1, "page 2 kept"); + assert_eq!(pages[2].calls_async().await, 1, "page 3 read"); + } + + #[tokio::test] + async fn should_read_every_shifted_page_and_drop_the_last_when_a_repo_is_removed_204() { + let github = MockServer::start_async().await; + let before = user_repos(201); + let (daemon, mut pages) = holding(&github, &before).await; + let after = before[1..].to_vec(); + let pages = changed_to(&github, &mut pages, &after).await; + + refresh(&daemon.client).await; + let read = eventually("200 repositories", || async { + let read = list(&daemon.client).await; + (read.loaded == 200).then_some(read) + }) + .await; + + assert_eq!(names(&read), named(&after)); + assert_eq!(read.total, Some(200)); + assert_eq!(pages.len(), 2); + for page in &pages { + assert_eq!(page.not_modified_async().await, 0); + } + } + } + } + mod failure { use super::*; @@ -468,5 +629,42 @@ mod post_v1_github_repositories_refresh { .await; assert_eq!(names(&read), named(&theirs)); } + + #[tokio::test] + async fn should_drop_the_held_pages_etags_when_the_token_changes_204() { + const OTHER: &str = "gho_other"; + let github = MockServer::start_async().await; + mock_viewer(&github, TOKEN, "octocat", None); + mock_viewer(&github, OTHER, "hubot", None); + let repos = user_repos(150); + mock_user_repos(&github, TOKEN, &repos); + let theirs = mock_user_repos(&github, OTHER, &repos); + let dirs = tempfile::tempdir().expect("a temp dir"); + set_gh_token(dirs.path(), Some(TOKEN)); + set_daemon_env(dirs.path(), &[("AGENTDECK_KEYRING", "memory")]); + let daemon = TestDaemon::start_with_github(dirs, &github.url("/graphql")).await; + refresh(&daemon.client).await; + until_status(&daemon.client, GithubListStatus::Loaded).await; + + let saved = (daemon.client.github_token_put()) + .body(GithubTokenBody { + token: OTHER.into(), + }) + .send() + .await; + saved.expect("save the other token"); + + eventually("hubot's page 2", || async { + (theirs[1].calls_async().await == 1).then_some(()) + }) + .await; + assert_eq!( + theirs[1].not_modified_async().await, + 0, + "no If-None-Match from the sign-in before" + ); + let read = until_status(&daemon.client, GithubListStatus::Loaded).await; + assert_eq!(names(&read), named(&repos)); + } } } diff --git a/crates/agentdeckd/tests/integration/support/github.rs b/crates/agentdeckd/tests/integration/support/github.rs index 9edf4ec..73044cc 100644 --- a/crates/agentdeckd/tests/integration/support/github.rs +++ b/crates/agentdeckd/tests/integration/support/github.rs @@ -161,15 +161,50 @@ fn user_repos_link(server: &MockServer, page: u32, last: u32) -> String { links.join(", ") } +/// One page of `GET /user/repos` as GitHub answers it: [`UserReposPage::full`] with the page, +/// its `ETag` and `Link` header, unless the request's `If-None-Match` is that `ETag`, which +/// [`UserReposPage::not_modified`] answers `304` with no body or `Link`, as GitHub does. +pub struct UserReposPage<'a> { + pub full: Mock<'a>, + pub not_modified: Mock<'a>, +} + +impl UserReposPage<'_> { + /// Requests for the page, answered either way. + pub async fn calls_async(&self) -> usize { + self.full.calls_async().await + self.not_modified.calls_async().await + } + + /// Requests answered `304 Not Modified`. + pub async fn not_modified_async(&self) -> usize { + self.not_modified.calls_async().await + } + + /// Stops answering the page, as when GitHub's content for it changes. + pub async fn delete_async(&mut self) { + self.full.delete_async().await; + self.not_modified.delete_async().await; + } +} + +/// The `ETag` GitHub would send with `body`: weak, and the same for the same content. +fn etag(body: &Value) -> String { + use std::hash::{DefaultHasher, Hash, Hasher}; + let mut hasher = DefaultHasher::new(); + body.to_string().hash(&mut hasher); + format!("W/\"{:016x}\"", hasher.finish()) +} + /// `GET /user/repos?sort=full_name&direction=asc&per_page=100&page=` with `token`, -/// answered after `delay` with `repos`' page `page` (from 1) and its `Link` header. +/// answered after `delay` with `repos`' page `page` (from 1), its `ETag` and `Link` header, +/// or `304` when the request's `If-None-Match` is that `ETag`. pub fn mock_user_repos_page<'a>( server: &'a MockServer, token: &str, repos: &[RestRepo], page: u32, delay: Duration, -) -> Mock<'a> { +) -> UserReposPage<'a> { let last = repos.len().div_ceil(100).max(1) as u32; let start = (page as usize - 1) * 100; let body: Vec = (repos.iter().skip(start).take(100)) @@ -188,8 +223,10 @@ pub fn mock_user_repos_page<'a>( }) }) .collect(); + let body = Value::Array(body); + let etag = etag(&body); let link = user_repos_link(server, page, last); - server.mock(|when, then| { + let request = |when: httpmock::When| { when.method(GET) .path("/user/repos") .query_param("sort", "full_name") @@ -197,12 +234,25 @@ pub fn mock_user_repos_page<'a>( .query_param("per_page", "100") .query_param("page", page.to_string()) .header("authorization", format!("Bearer {token}")) - .header("x-github-api-version", "2022-11-28"); - let then = then.status(200).delay(delay).json_body(Value::Array(body)); + .header("x-github-api-version", "2022-11-28") + }; + let full = server.mock(|when, then| { + let current = etag.clone(); + request(when).is_false(move |request| { + (request.headers().get("if-none-match")).is_some_and(|sent| sent == current.as_str()) + }); + let then = (then.status(200).delay(delay)) + .header("etag", &etag) + .json_body(body); if !link.is_empty() { then.header("link", link); } - }) + }); + let not_modified = server.mock(|when, then| { + request(when).header("if-none-match", &etag); + then.status(304).delay(delay).header("etag", &etag); + }); + UserReposPage { full, not_modified } } /// Every page of `repos` for `token`, answered at once, by page from 1. @@ -210,7 +260,7 @@ pub fn mock_user_repos<'a>( server: &'a MockServer, token: &str, repos: &[RestRepo], -) -> Vec> { +) -> Vec> { let last = repos.len().div_ceil(100).max(1) as u32; (1..=last) .map(|page| mock_user_repos_page(server, token, repos, page, Duration::ZERO)) diff --git a/docs/spec.md b/docs/spec.md index bb41588..710d7e9 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -358,10 +358,11 @@ min_ms = 400 # a new state must hold this long before it is pu - **Cancel:** one sign-in runs at a time, so a new `POST` cancels the one before. `DELETE /v1/github/device` cancels it (204, also with none running) and sends no event. - **Looking up a Repository** (`GET /v1/repositories/resolve`, and linking one agentdeck doesn't know, §4) is agentdeck's REST call to GitHub: `GET /repos/{owner}/{repo}` with the token as a bearer, `Accept: application/vnd.github+json` and `X-GitHub-Api-Version: 2022-11-28`, reading `id`, `full_name`, `html_url`, `private` and `archived`. GitHub redirects an old name to the renamed Repository, so the answer carries its name now. It uses the token as PR sync does (a `gh` token is checked first, a 401 reads the sources again and tries once more, then counts as rejected), the same 30 s timeout, the same retries (after 1 s and 2 s, on a 5xx or a request that failed in transit) and the same wording for a failure. A 404 is a Repository GitHub doesn't show the sign-in (no such repository, or no access): `400 unknown_repository`, "GitHub can't see owner/name. Check the name or your token's access." No token, or one GitHub still rejects, is `409 not_signed_in` ("Sign in to GitHub to look up owner/name.", or "GitHub rejected the token, so agentdeck can't look up owner/name."); any other failure is `502 github_error`. Confirming a Suggestion's name (§3) is the same call, with two differences: it takes the token as last read, never running `gh` or reading the sources while there is none (signed out, it only reads what agentdeck keeps), and its answers, a 404 included, are kept in memory for the run, while a failure is kept by no one and only logged. - **The GitHub repository list** (`GET /v1/github/repositories`, §4) is every repository the sign-in can reach, as the Link picker's All your repositories offers them (§11): REST `GET /user/repos?sort=full_name&direction=asc&per_page=100&page=N`, with the token and headers a lookup uses, reading `id`, `full_name`, `html_url`, `private` and `archived` of each (owned, collaborator and organisation repositories; what a fine-grained token or an SSO organisation hides stays hidden, which the picker's "Not listed?" line covers). `search/repositories` is never called: it allows 30 requests a minute and misses repositories you only collaborate on. - - **Loading:** nothing loads until a client asks (`POST /v1/github/repositories/refresh`), which the GUI does each time a picker opens and on Retry. Page 1 comes first; its `Link` header's `rel="last"` names the last page (none means page 1 is the only one). Then the last page, so the total is exact early, then the pages between, 4 requests at once. About 1,100 repositories take 12 requests, out of 5,000 an hour. Each page uses the token as a lookup does (page 1's 401 reads the sources again and tries once more, then counts as rejected; a later page's 401 counts as rejected), the same 30 s timeout, the same retries (after 1 s and 2 s, on a 5xx or a request that failed in transit) and the same wording for a failure. A 403 or 429 (a rate limit) isn't tried again. + - **Loading:** nothing loads until a client asks (`POST /v1/github/repositories/refresh`), which the GUI does each time a picker opens and on Retry. Page 1 comes first; its `Link` header's `rel="last"` names the last page (none means page 1 is the only one). Then the last page, so the total is exact early, then the pages between, 4 requests at once. About 1,100 repositories take 12 requests, out of 5,000 an hour; a refresh of a held list takes 1 (below). Each page uses the token as a lookup does (page 1's 401 reads the sources again and tries once more, then counts as rejected; a later page's 401 counts as rejected), the same 30 s timeout, the same retries (after 1 s and 2 s, on a 5xx or a request that failed in transit) and the same wording for a failure. A 403 or 429 (a rate limit) isn't tried again. - **Progress:** while no list is held, each page is served as it arrives, the list keeping GitHub's order with gaps for pages still to come, `loaded` counting it and `total` estimating the whole; a `github_repositories` event goes with each. A page that fails fails the whole load: `status: failed`, its `error`, no repositories. - - **Memory:** the list is kept in memory for the run, only the five fields of each repository. A refresh of a held list runs quietly under it: clients go on reading the list before until the new one has loaded whole, then read the new one; a quiet refresh that fails keeps the list before and sets `error`. One load runs at a time; a refresh while one runs changes nothing. - - **Sign-in:** the list belongs to the token it was read with. When the token changes through the auth routes or a sign-in (§8 Re-read), it is dropped and, if a client had asked for it since the last change, loaded again with the new one. With no token, a refresh reads `signed_out` without calling GitHub. + - **Memory:** the list is kept in memory for the run, by page, only the five fields of each repository and the `ETag` GitHub sent with each page. A refresh of a held list runs quietly under it: clients go on reading the list before until the new one has loaded whole, then read the new one, and a `github_repositories` event goes only if it reads differently; a quiet refresh that fails keeps the list before and sets `error`. One load runs at a time; a refresh while one runs changes nothing. + - **Conditional requests:** a quiet refresh reads page 1 whole (a `304` carries no `Link` header, and the page count may have changed), then asks for each later page the held list has with `If-None-Match: `. GitHub's `304 Not Modified` costs nothing against the rate limit and keeps that page as held; a `200` replaces it and brings its new `ETag`; a page the held list didn't have is read whole. Each page stands alone: a `304` says that page reads as it did, so a repository added or removed, which shifts every page after it, just has those pages answer `200`, and a list grown or shrunk by a page follows page 1's `Link` header, with no rule to reload the rest. An unchanged list of about 1,100 repositories costs 1 request a refresh, not 12. + - **Sign-in:** the list belongs to the token it was read with. When the token changes through the auth routes or a sign-in (§8 Re-read), it is dropped with its `ETag`s and, if a client had asked for it since the last change, loaded again with the new one. With no token, a refresh reads `signed_out` without calling GitHub. - **Closing PRs** (`POST /v1/prs/close`) closes them only: no comment, no branch delete. - Each PR is named by its reference, `owner/name#123` (or its GitHub URL, which clients turn into one), and found by its Repository's name and its number, ignoring case as GitHub does; the name follows the Repository's renames, so the name GitHub gives it now finds it. It must be stored `open`, Finished ones included, and not unreachable; any other, and one agentdeck doesn't keep, fails with "Not an open PR" and never reaches GitHub. With no token, every one fails with "Not signed in to GitHub". The results come back one per reference, in the order asked, each naming the reference asked for. - The daemon reads the PRs' node ids by Repository name and number, 25 to a request as fetches by number go. Then it closes each PR on its own, one at a time, with its own GraphQL `closePullRequest` mutation, since GitHub has no batch close. @@ -566,7 +567,7 @@ Built on `brrritscold-core-gpui` (`init`, `Root`, theme preference, toasts). Scr | Tier | Where | What | |---|---|---| | unit | `agentdeck-core`, GUI views (`#[gpui::test]`), daemon pure parts | rules with recorded output (the Copy PR details text among them, one PR's and several joined by a blank line), why a PR is yours (`why_yours`: its author, review requests and assignees against your login, ignoring case), which open PRs an incremental sync fetches again, layout tree, snapshot encode/decode round-trip, env allowlist, `openapi.json` staleness; GUI views over a fake API and a fake notifier, asserting what a user sees (the Pull requests view's groups and their order, collapse and Show finished kept in the GUI state file, Finished rows hidden until Show finished and showing GitHub's state, the row's link and menu, Sync now, the banner, the empty state, Unreachable rows, an Unreachable Repository's header in place of its Workspaces on both views; Select mode: entering and leaving it, picking by row click, group checkbox (folded too) and select-all, which rows can be picked (open and reachable, Finished-but-open included; not merged, closed or Unreachable), the bar's count and order, Copy PR details joined in the list's order, Close PRs asking then closing by reference, a PR that didn't close kept picked and marked with why, a closed PR shown closed at once, "Closing N of M…", and Select disabled on the empty view; the header and the table fitting the narrowest window in Select mode, and that window's minimum fitting the narrowest PR table in Select mode; the sidebar's entries and counts, Finished PRs left out, no Inbox or Tasks entry, each Workspace's count over its linked Repositories, none on an archived row, the no-Workspaces hint and its New workspace, Pull requests the fallback selection; linked groups first, then Not in a workspace, each alphabetical, a group's header naming its linking Workspaces as links that open their Pull requests, Archived Workspaces absent from headers and order; the group `…` menu on every group of both views, in the rows' `…` column: Open on GitHub opening the Repository's page, Link to a workspace offering the Workspaces that aren't archived and don't link it in the sidebar's order then New workspace, New workspace alone when none is eligible, New workspace opening the dialog with the Repository picked, a link applied at once by GitHub's id with "Linked owner/name to " and an Undo that unlinks, Unlink from this workspace only on a Workspace's Pull requests, applied at once with "Unlinked owner/name from " and its open PRs (singular, plural, none, and where they went when no other Workspace links it), its Undo linking again by id once the unlink deleted the Repository, and failures toasted; a Workspace's side switch with its count, `secondary-shift-p`, each Workspace's side remembered across a restart and opened from its sidebar row, a new one on its Panes; a Workspace's Pull requests: only its linked Repositories, "No open PRs", Select, Show finished and Edit workspace with no sync controls, the banner, collapse kept apart from the Pull requests view's, the no-Repositories state whose Link repository opens Edit workspace with its picker focused and open; Edit workspace and New workspace: the linked rows with their Unlink, lock and Unreachable badge, staging until Save (one request with the name, applied to the fake, none before), Save enabled by a staged change alone, Undo, the leaving note and its singular and its absence at 0, Cancel discarding what was staged, a refusal under the picker keeping the dialog open, an archived workspace linked, the picker's From your pull requests (no linked, picked or Unreachable Repository; the lock), local filtering ignoring case and by a pasted URL, picking (the field cleared), Enter picking the first row, the typed row only for an unlisted name, GitHub showing it (staged under GitHub's name, private kept) or not ("GitHub can't see …" under the field, the list closed, cleared by typing), signed out (no typed row, "Sign in to GitHub to find more repositories."), and New workspace linking what was picked on create; the picker's Suggested section first, ignoring dismissals, its rows left out of From your pull requests, filtered as typed, picked by click or Enter; its All your repositories after the other sections (none listed above, linked or Unreachable; the lock), filtered as typed, picked by click or Enter, no typed row for a name it lists, a refresh asked each time it opens, the rows loaded so far with "Loading your repositories… N of about M" under them (and with no count before page 1, and still in view under rows that scroll), read again on `changed github_repositories`, "Couldn't load your repositories." with Retry (GitHub's failure or the daemon unreadable) keeping the other sections and typed names, Retry loading again, "Sign in to GitHub…" in its place signed out (PR status or the list's `signed_out`), and only the rows in view drawn for 1,100; the loading line's count and rounding; the sidebar not reading again for a `github_repositories` event; the Suggestions strip on a Workspace's Pull requests (one row alone, several stacked in one strip under the header and over the table, none on the Pull requests view, an archived Workspace or for what it links by now), Link at once by GitHub's id with "Linked owner/name to ", the row gone and the group shown once read, its Undo unlinking without dismissing and a failure toasted with the row kept, Not now taking the row away for that Workspace only and kept across a restart in the GUI state file, the strip under Link repository on a Workspace with no Repositories, and an unlink from the group menu or Edit workspace's Save recording a dismissal (a failed one none); the GUI state's dismissed pairs, written by id; the GUI state forgetting a Workspace's entries (collapsed groups, last side, dismissals) when the Delete workspace dialog deletes it (none on a failed delete) and on the sidebar's next read that no longer lists it (deleted elsewhere, or before the GUI started; archived ones kept), never before the first read succeeds or on a failed read, and the file written back without them; the picker's offer read from a snapshot (linked ones, Unreachable included; Suggestions but what the Workspace links by now; your PRs' reachable Repositories; open PRs counted as the sidebar does; signed out only while the token is logged out); the archived screen with no switch; a pane notifying while its workspace shows its Pull requests; New workspace's Name field and optional picker; New agent's Folder select (where a new pane starts first, the other panes' folders, then `~`, each once) and a new pane starting in `~` in a workspace with none; the Delete workspace dialog's lines (its Repositories unlinked, its running panes stopped, each left out at 0); the archive toast; the top bar's name, centred, before its side switch; a Pane alert's body, " · ", and the pane header's parts; PR alerts over the fake notifier: each trigger, only PRs you authored (one you review, are assigned, or both, never alerts), one alert per PR replaced on a new change, a click landing on the row with its group opened, a Finished row shown with Show finished left off, scrolled to and highlighted until the highlight fades, "N PRs changed" opening the view, an alert withdrawn once the view shows, and the mute rule with every linking Workspace muted, one unmuted, only Archived muted ones, and none); the PR alert mute rule and the GitHub remote parser (https, ssh and scp-like URLs, for Suggestions) in `agentdeck-core`; the daemon's git config reader for Suggestions (each remote's first URL by name, sections and keys ignoring case, the old dotted header, comments and quotes, `upstream` on GitHub over `origin`, no other remote; a folder deep in a repo, a worktree's `.git` file and `commondir`, a relative `gitdir`, none outside a repo) and which events make Suggestions due | -| integration | `agentdeckd/tests/integration` | temp `$XDG_*` dirs, a real daemon on a random port, a real client; PTYs run `sh`, which moves a pane with `cd` (read through `/proc`) or `printf`s an OSC 7, so a pane's current folder, its `changed` and its restore folder are tested without a shell that reports one; GitHub is httpmock (`AGENTDECK_GITHUB_API`, `AGENTDECK_GITHUB_REST_API` and `AGENTDECK_GITHUB_OAUTH`: GraphQL with `closePullRequest`, REST's `GET /repos/{owner}/{repo}` for Repository lookups, Links and Suggestions, `GET /repositories/{id}` for Repositories read by id and `GET /user/repos` for the GitHub repository list, and the device flow's code and token endpoints); Suggestions run Panes (`sh`, `sleep`) in temp git repos with `upstream`, `origin` and other remotes: upstream on GitHub over origin, origin when upstream is elsewhere, other remotes ignored, none outside a repo, one per name, a Pane that `cd`s in, an exited Pane at its last folder, a name GitHub can't see never suggested, a renamed one under GitHub's name, each name asked about once per run across reads and Workspaces, signed out only kept Repositories, one other Workspaces link still suggested, one the Workspace links left out, an archived Workspace none, `404 not_found`, and `changed suggestions` when a Pane opens in or moves into a repo, a Link takes one away and a deleted Pane takes one away; the client's `repositories::suggestions` against the same daemon, none from an older one; the GitHub repository list (REST `GET /user/repos` on httpmock, pages with a `Link` header): not loaded until a refresh asks, every page in GitHub's order once loaded, one page with no `Link` header, page 1 served while the rest load (`total` estimated from the last page link), the last page read first so `total` is exact early, a `github_repositories` event as the load begins, as each page arrives and as it ends, the list kept across reads with no new request, a refresh quietly showing the list before until the new one has loaded, a refresh while a load runs left alone, a 5xx tried three times then `failed` and loaded on a retry, a 403 rate limit and a 429 failing at once, a later page failing the whole load, a 401 `failed` ("GitHub rejected the token"), a failed quiet refresh keeping the list with its `error`, `signed_out` with no token and no GitHub call, a changed token loading the new sign-in's list, and `search/repositories` never called; the client's `repositories::github_list` and `refresh_github_list` against the same daemon (loaded, signed out, the daemon's `unauthorized`); `gh` is a stub script on `PATH`, and so are `claude` and `codex`, which read input as their TUIs do, and exit on a submitted `/exit` so a shell pane's hosted agent can leave (raw, bracketed paste on, a read that is a lone `\r` submits, any other read is a paste); the keyring is an in-memory fake store (`AGENTDECK_KEYRING=memory`; without it the harness's daemon has no session bus, so no keyring). The `agentdeck_client` helpers the GUI's real API calls (`panes`, `settings`, `prs`, `repositories`, `workspaces`) are tested here through the real client (`*_client`), each new operation of the GUI's fake API with a test of the same call in the same PR, so the fake can't drift from the daemon; `prs::list` also lists none from a daemon older than `GET /v1/prs`, and lists Finished PRs, marked; `repositories::list` lists each Repository with the Workspaces linking it, Archived ones included, and none from a daemon older than `GET /v1/repositories`; `repositories::resolve` answers the Repository GitHub shows for a typed URL and fails with the daemon's "GitHub can't see …"; `repositories::link` links by GitHub's id and links again, signed out, once an unlink deleted the Repository, and `repositories::unlink` keeps one another Workspace links and fails with the daemon's `not_found` for one the Workspace doesn't link; `workspaces::create` makes a Workspace linking what was picked, or nothing, and `workspaces::update` renames, links and unlinks together, or changes nothing, failing with the daemon's words. The Workspace routes' Links are tested here too: create linking a Repository agentdeck keeps (no GitHub call) and one GitHub resolves, nothing made when GitHub can't see one; update renaming, linking and unlinking in one request (an unreferenced Repository gone), nothing changed when a link fails or the name is blank, `invalid_links`, unlinking one it doesn't link changing nothing, an archived Workspace linked, and `changed` for each Repository then the workspace. The link route's link by GitHub's `id` is tested here too: a Repository an unlink deleted stored again from the body signed out (no GitHub, where a link by name is `not_signed_in`), the Repository kept with that id linked under its name now, `changed` for the Repository then the workspace, and `404 not_found` storing nothing for a Workspace that doesn't exist. PR sync's PRs of each kind are tested here too: the ones you authored, those where your review is requested and those assigned to you, and one that is yours several ways at once, each with why it is yours in `GET /v1/prs`, in a full sync (the list and the two open searches) and an incremental one (a search for each), the age cutoff leaving out old ones of each kind in both. Its Finished PRs too: Finished on merge, on close (from GitHub and from agentdeck), past the cutoff and once no longer yours (your review submitted, seen by the incremental sync's fetch by number; you unassigned, seen by a full sync's), an authored PR whose review request goes staying unfinished, no longer Finished once GitHub shows a PR open and yours again, deleted with their unreferenced Repositories after the window (`AGENTDECK_PR_FINISHED_SECS=0`), and Unreachable PRs kept with no window. PRs are kept by Repository and number: a renamed Repository's PR and one of another Repository that took the old name are two PRs. Repositories read by id are tested here too: a linked Repository with no PR renamed (its Link kept), lost (Unreachable, its Link kept, a `changed repository`) and regained (the mark cleared), none read while GitHub shows a PR of it, a PR's Repository GitHub doesn't show marked Unreachable with the PR, and a PR merged after its Repository's rename, the old name since taken by another Repository with a PR of the same number, fetched under the new name and Finished, not Unreachable. Workspaces without folders are tested here too: creating one makes nothing on disk and its JSON has no folder, an older client's `dir` and `force` are ignored, the dirty report route is gone (dropshot's own 404), deleting one unlinks its Repositories (a Repository nothing else names goes) and stops its panes but leaves every folder on disk (its panes' folders and an old scratch folder), the first pane of a workspace with none opens in `~` through `panes::new_shell_tab`, and `0002` drops the folder columns from a database at `0001`, keeping each Workspace and its Links. The fresh start is tested here too: a fresh data dir gets the migrations' schema (no `tasks`, `comments` or `instructions`; `pull_requests` keyed by `(repository_id, number)` with nothing unique on a name), a current database survives a restart, and a database with a `tasks` table, its last writes still in its WAL, is moved aside with its WAL and SHM files (the moved one still reads), logged, never over an earlier one, with scratch folders left alone, and the daemon starts empty | +| integration | `agentdeckd/tests/integration` | temp `$XDG_*` dirs, a real daemon on a random port, a real client; PTYs run `sh`, which moves a pane with `cd` (read through `/proc`) or `printf`s an OSC 7, so a pane's current folder, its `changed` and its restore folder are tested without a shell that reports one; GitHub is httpmock (`AGENTDECK_GITHUB_API`, `AGENTDECK_GITHUB_REST_API` and `AGENTDECK_GITHUB_OAUTH`: GraphQL with `closePullRequest`, REST's `GET /repos/{owner}/{repo}` for Repository lookups, Links and Suggestions, `GET /repositories/{id}` for Repositories read by id and `GET /user/repos` for the GitHub repository list, and the device flow's code and token endpoints); Suggestions run Panes (`sh`, `sleep`) in temp git repos with `upstream`, `origin` and other remotes: upstream on GitHub over origin, origin when upstream is elsewhere, other remotes ignored, none outside a repo, one per name, a Pane that `cd`s in, an exited Pane at its last folder, a name GitHub can't see never suggested, a renamed one under GitHub's name, each name asked about once per run across reads and Workspaces, signed out only kept Repositories, one other Workspaces link still suggested, one the Workspace links left out, an archived Workspace none, `404 not_found`, and `changed suggestions` when a Pane opens in or moves into a repo, a Link takes one away and a deleted Pane takes one away; the client's `repositories::suggestions` against the same daemon, none from an older one; the GitHub repository list (REST `GET /user/repos` on httpmock, pages with a `Link` header): not loaded until a refresh asks, every page in GitHub's order once loaded, one page with no `Link` header, page 1 served while the rest load (`total` estimated from the last page link), the last page read first so `total` is exact early, a `github_repositories` event as the load begins, as each page arrives and as it ends, the list kept across reads with no new request, a refresh quietly showing the list before until the new one has loaded, a refresh while a load runs left alone, a refresh sending each held page's `ETag` as `If-None-Match` but page 1's (httpmock answering `304` to the page's current `ETag`) and keeping the list with no event when every page answers `304`, a changed page read whole while the others answer `304`, a repository added at the front shifting every page and adding a last one, one added after a full last page that answers `304` found through page 1's `Link`, one removed shifting every page and dropping the last, a changed token sending none of the `ETag`s held before, a 5xx tried three times then `failed` and loaded on a retry, a 403 rate limit and a 429 failing at once, a later page failing the whole load, a 401 `failed` ("GitHub rejected the token"), a failed quiet refresh keeping the list with its `error`, `signed_out` with no token and no GitHub call, a changed token loading the new sign-in's list, and `search/repositories` never called; the client's `repositories::github_list` and `refresh_github_list` against the same daemon (loaded, signed out, the daemon's `unauthorized`); `gh` is a stub script on `PATH`, and so are `claude` and `codex`, which read input as their TUIs do, and exit on a submitted `/exit` so a shell pane's hosted agent can leave (raw, bracketed paste on, a read that is a lone `\r` submits, any other read is a paste); the keyring is an in-memory fake store (`AGENTDECK_KEYRING=memory`; without it the harness's daemon has no session bus, so no keyring). The `agentdeck_client` helpers the GUI's real API calls (`panes`, `settings`, `prs`, `repositories`, `workspaces`) are tested here through the real client (`*_client`), each new operation of the GUI's fake API with a test of the same call in the same PR, so the fake can't drift from the daemon; `prs::list` also lists none from a daemon older than `GET /v1/prs`, and lists Finished PRs, marked; `repositories::list` lists each Repository with the Workspaces linking it, Archived ones included, and none from a daemon older than `GET /v1/repositories`; `repositories::resolve` answers the Repository GitHub shows for a typed URL and fails with the daemon's "GitHub can't see …"; `repositories::link` links by GitHub's id and links again, signed out, once an unlink deleted the Repository, and `repositories::unlink` keeps one another Workspace links and fails with the daemon's `not_found` for one the Workspace doesn't link; `workspaces::create` makes a Workspace linking what was picked, or nothing, and `workspaces::update` renames, links and unlinks together, or changes nothing, failing with the daemon's words. The Workspace routes' Links are tested here too: create linking a Repository agentdeck keeps (no GitHub call) and one GitHub resolves, nothing made when GitHub can't see one; update renaming, linking and unlinking in one request (an unreferenced Repository gone), nothing changed when a link fails or the name is blank, `invalid_links`, unlinking one it doesn't link changing nothing, an archived Workspace linked, and `changed` for each Repository then the workspace. The link route's link by GitHub's `id` is tested here too: a Repository an unlink deleted stored again from the body signed out (no GitHub, where a link by name is `not_signed_in`), the Repository kept with that id linked under its name now, `changed` for the Repository then the workspace, and `404 not_found` storing nothing for a Workspace that doesn't exist. PR sync's PRs of each kind are tested here too: the ones you authored, those where your review is requested and those assigned to you, and one that is yours several ways at once, each with why it is yours in `GET /v1/prs`, in a full sync (the list and the two open searches) and an incremental one (a search for each), the age cutoff leaving out old ones of each kind in both. Its Finished PRs too: Finished on merge, on close (from GitHub and from agentdeck), past the cutoff and once no longer yours (your review submitted, seen by the incremental sync's fetch by number; you unassigned, seen by a full sync's), an authored PR whose review request goes staying unfinished, no longer Finished once GitHub shows a PR open and yours again, deleted with their unreferenced Repositories after the window (`AGENTDECK_PR_FINISHED_SECS=0`), and Unreachable PRs kept with no window. PRs are kept by Repository and number: a renamed Repository's PR and one of another Repository that took the old name are two PRs. Repositories read by id are tested here too: a linked Repository with no PR renamed (its Link kept), lost (Unreachable, its Link kept, a `changed repository`) and regained (the mark cleared), none read while GitHub shows a PR of it, a PR's Repository GitHub doesn't show marked Unreachable with the PR, and a PR merged after its Repository's rename, the old name since taken by another Repository with a PR of the same number, fetched under the new name and Finished, not Unreachable. Workspaces without folders are tested here too: creating one makes nothing on disk and its JSON has no folder, an older client's `dir` and `force` are ignored, the dirty report route is gone (dropshot's own 404), deleting one unlinks its Repositories (a Repository nothing else names goes) and stops its panes but leaves every folder on disk (its panes' folders and an old scratch folder), the first pane of a workspace with none opens in `~` through `panes::new_shell_tab`, and `0002` drops the folder columns from a database at `0001`, keeping each Workspace and its Links. The fresh start is tested here too: a fresh data dir gets the migrations' schema (no `tasks`, `comments` or `instructions`; `pull_requests` keyed by `(repository_id, number)` with nothing unique on a name), a current database survives a restart, and a database with a `tasks` table, its last writes still in its WAL, is moved aside with its WAL and SHM files (the moved one still reads), logged, never over an earlier one, with scratch folders left alone, and the daemon starts empty | | integration | `mod integration_tests` in `agentdeckd/src` | a crate-private part over a real dependency, which `tests/integration` can't reach since the daemon is a binary: a `Pane` over a real PTY running `sh` reads as exited only once its exit is recorded. The integration nextest profile runs these modules; the unit one skips them | | integration | `agentdeckd/tests/integration` (keyring) | the keyring store against a real Secret Service: `gnome-keyring-daemon`, unlocked, on a private `dbus-daemon` session bus the test starts, as `agentdeck-notify`'s test does, which CI installs with `script/install-linux-deps.sh`. It saves, finds, replaces and deletes the token and client ID entries, and finds none with no Secret Service. It is the fake store's contract test: the same cases run against the fake, and a fake lands with a test of the real call in the same PR | | integration | `agentdeck/tests/integration` | the real `agentdeck` binary in temp `$XDG_*` dirs, starting the real daemon itself, with GitHub on httpmock, GraphQL and REST, for `pr ls` (by Repository and by workspace, and why each PR is yours in `--json`), `pr close`, `repo ls|link|unlink` (`repo ls` marking a Repository a `pr sync` found Unreachable, in text and `--json`) and `ws new|ls|rename|rm` (no folder made or removed, `ws ls`' REPOSITORIES in text and `--json`, `ws rm` unlinking, no `--dir`, `--repo` or `--force`); a long-lived client (the test binary re-run as a child, connecting through `agentdeck_client::daemon`, as the GUI does) for reaping and restarting the daemon it started; panes run `sh`, never a real agent CLI |