Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/aien-sovereign-core-mv/patches/55b4074dd32aad4f
# aien-sovereign-core-mv
AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
## GitHub aien-dev/aien-sovereign-core-mv#801 (code only)
closed derived `55b4074dd32aad4f` #801
Imported from GitHub aien-dev/aien-sovereign-core-mv#801 (code only)
GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).
Base `5c95594a923de32a833e85512d677dba0b213110` · Head `3a7f5be9f04ac3abc7623c670cbf09ac2b3b5fa2`
drakestapleton reviewed (COMMENTED) on 2026-10-30 11:17 UTC
Triage: needs changes.
- This PR conflicts with main and needs a rebase.
- Hosted CI and signed pipeline qualification have not run yet.
- DCO sign-off is still pending.
Hardware evidence: n/a.
Triage only; no approval or merge implied.
drakestapleton reviewed (COMMENTED) on 2026-10-30 22:04 UTC
Merge-head review at `6a4494b26304a0b09d093ff57ed319f5ce171ab9` (J5u).
Verdict: the merge is clean and the pagination fix is unchanged. No code must-fix. It is still blocked by the gates in the PR body: signed pipeline qualification is NOT_RUN and DCO is pending Drake. The body itself says not to mark this ready-to-merge until those clear.
Merge verification
- `6a4494b2` has two parents, `d7357227` (old PR head) and `e9c1b2a6` (main).
- `d7357227`...`6a4494b2`: ahead 39, behind 0, merge_base = `d7357227`. 111 files changed.
- Main span `50e0416d` (old base)...`e9c1b2a6`: 38 commits, 111 files. Every merged file's blob equals main's blob at `e9c1b2a6` except `.crumb`, which is regenerated. No hand conflict resolutions in source files.
- `e9c1b2a6`...`6a4494b2`: ahead 4, behind 0, 2 files (`.crumb`, `tools/aien-test/src/worker.rs`). The same 2 files as `50e0416d`...`d7357227`. The worker.rs blob is `e649a8c5` in both, so the pagination fix is byte-identical.
.crumb: source_tree and digest are recomputed (digest `b25d4aa5`..., source_tree `f56d0fe4`...). generated_at_commit = `d7357227`, the PR-side parent, which is the accepted convention. The merge message names crumb `94fffbcf`, and AIEN Checks passed on this head. Nit: the `crates/aien-heartbeat` child now has `last_commit: ""` (it was `e728371b`). That is harmless to verify, but worth checking on the next crumb compile.
Checks at head: AIEN Checks success, CodeQL success, Analyze (rust, python, actions, javascript-typescript) success, AIEN Alpha skipped (tag-only). Full `cargo test --workspace` runs only on the Forgejo Spark runner, so the 4-pass host test count rests on the author's word.
Commits: all 4 messages are ASCII.
Claims: the PR body makes no performance or GB10 claims.
— Grokbot
cursor[bot] reviewed (APPROVED) on 2026-11-01 21:09 UTC
Risk: medium. Cursor Bugbot and Cursor Security Agent both completed successfully with no findings that need human review, so this update is approved. Pagination and Link-header handling stay within the medium-risk threshold.
Sent by Cursor Approval Agent: Pull Request Router and Approver
### Fetch it
A git bundle of the pull request's head, 11478 bytes.
```
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/55b4074dd32aad4f.bundle -o 55b4074dd32aad4f.bundle
git fetch 55b4074dd32aad4f.bundle refs/pull/801/head
```
Raw bundle · Diff
### Provenance
This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:
```
github-import 1
aien-dev/aien-sovereign-core-mv
801
3a7f5be9f04ac3abc7623c670cbf09ac2b3b5fa2
```
```
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":801,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/801","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:38:04Z","metadata":"unavailable","state_derived":true}
```
### Changes
```
diff --git a/tools/aien-test/src/worker.rs b/tools/aien-test/src/worker.rs
index 84bf3254..af03efb7 100644
--- a/tools/aien-test/src/worker.rs
+++ b/tools/aien-test/src/worker.rs
@@ -1549,23 +1549,72 @@ pub fn triggers(state: &StateDir) -> Vec<(String, String, PathBuf)> {
/// What the last answer to one GitHub list request said, kept with its ETag so the next poll can ask
/// "has it changed?" (a 304 reply costs nothing against the hourly allowance; L337, G3-ci-judge-7).
+/// `next` is the following page path when the 200 that produced this ETag carried `Link: rel="next"`.
+/// A 304 omits that header, so the cached path is what the next poll follows.
#[derive(Default)]
pub struct GithubHeadCache {
- entries: std::collections::HashMap)>,
+ entries: std::collections::HashMap,
}
-/// One list request as a conditional GET. `pick` turns a 200 body into head shas. A 304 returns the shas of
-/// the answer the ETag belongs to; any other status is an error carrying gh's message.
+struct CachedHeads {
+ etag: String,
+ heads: Vec,
+ next: Option,
+}
+
+/// The `rel="next"` target of a GitHub `Link` header, as a path `gh api` accepts.
+/// None when this page is the last. Absolute `api.github.com` URLs are stripped to the path.
+fn link_next(headers: &str) -> Option {
+ for line in headers.lines() {
+ let Some((name, value)) = line.split_once(':') else {
+ continue;
+ };
+ if !name.eq_ignore_ascii_case("link") {
+ continue;
+ }
+ for part in value.split(',') {
+ let Some((url, rest)) = part.split_once('>') else {
+ continue;
+ };
+ let rel = rest.to_ascii_lowercase();
+ if !rel.contains("rel=\"next\"")
+ && !rel.contains("rel='next'")
+ && !rel.contains("rel=next")
+ {
+ continue;
+ }
+ let url = url.trim().trim_start_matches('<').trim();
+ if url.is_empty() {
+ continue;
+ }
+ return Some(github_api_path(url));
+ }
+ }
+ None
+}
+
+fn github_api_path(url: &str) -> String {
+ for prefix in ["https://api.github.com/", "http://api.github.com/"] {
+ if let Some(rest) = url.strip_prefix(prefix) {
+ return rest.to_string();
+ }
+ }
+ url.trim_start_matches('/').to_string()
+}
+
+/// One list request as a conditional GET. `pick` turns a 200 body into head shas. A 304 returns the shas
+/// and the next-page path of the answer the ETag belongs to; any other status is an error carrying gh's
+/// message. The next-page path is `None` when the 200 had no `Link: rel="next"`.
fn conditional_heads(
gh: &str,
path: &str,
pick: fn(&Value) -> Vec,
cache: &mut GithubHeadCache,
-) -> Result, String> {
+) -> Result<(Vec, Option), String> {
let mut cmd = Command::new(gh);
cmd.args(["api", "-i"]);
- if let Some((etag, _)) = cache.entries.get(path) {
- cmd.args(["-H", &format!("If-None-Match: {etag}")]);
+ if let Some(cached) = cache.entries.get(path) {
+ cmd.args(["-H", &format!("If-None-Match: {}", cached.etag)]);
}
cmd.arg(path);
let out = process::output_gated(&mut cmd).map_err(|e| format!("cannot run {gh}: {e}"))?;
@@ -1580,8 +1629,8 @@ fn conditional_heads(
.and_then(|l| l.split_whitespace().nth(1))
.unwrap_or("");
if status == "304" {
- if let Some((_, shas)) = cache.entries.get(path) {
- return Ok(shas.clone());
+ if let Some(cached) = cache.entries.get(path) {
+ return Ok((cached.heads.clone(), cached.next.clone()));
}
}
if status != "200" || !out.status.success() {
@@ -1600,6 +1649,7 @@ fn conditional_heads(
.map(|s| s.trim().to_ascii_lowercase())
.filter(|s| valid_sha(s))
.collect();
+ let next = link_next(head);
let etag = head
.lines()
.find_map(|l| {
@@ -1609,13 +1659,20 @@ fn conditional_heads(
.map(|(_, v)| v.trim().to_string());
match etag {
Some(etag) if !etag.is_empty() => {
- cache.entries.insert(path.to_string(), (etag, shas.clone()));
+ cache.entries.insert(
+ path.to_string(),
+ CachedHeads {
+ etag,
+ heads: shas.clone(),
+ next: next.clone(),
+ },
+ );
}
_ => {
cache.entries.remove(path);
}
}
- Ok(shas)
+ Ok((shas, next))
}
/// `triggers`, limited to the repositories in `repos` (a poller started with
@@ -1725,26 +1782,69 @@ fn main_head(v: &Value) -> Vec {
v["sha"].as_str().map(str::to_string).into_iter().collect()
}
-/// Open PR heads and the main head of `repo` from GitHub (bounded: one conditional call per list). Errors are
-/// returned, never fatal to the loop. Unchanged lists answer 304 and cost no allowance.
+/// GitHub returns at most 100 pull requests per page. Issue #732: a poll that
+/// stops at the first page never sees an open PR past that page, so the local
+/// judge never runs it.
+const OPEN_PULLS_PER_PAGE: usize = 100;
+/// Twenty pages is 2000 open PRs. Past that the list is incomplete; say so
+/// instead of silently dropping the rest.
+const OPEN_PULLS_PAGE_CAP: usize = 20;
+
+/// Whether a next-page path taken from `Link` is another page of a pull list on api.github.com.
+/// GitHub writes it as `repositories//pulls?...` (seen on 2026-10-31) and may write
+/// `repos///pulls?...`. An absolute URL to another host keeps its scheme after
+/// [`github_api_path`] and never matches.
+fn is_pulls_page(next: &str, or: &str) -> bool {
+ let repos = format!("repos/{or}/pulls?");
+ if next
+ .get(..repos.len())
+ .is_some_and(|p| p.eq_ignore_ascii_case(&repos))
+ {
+ return true;
+ }
+ next.strip_prefix("repositories/")
+ .and_then(|rest| rest.split_once("/pulls?"))
+ .is_some_and(|(id, _)| !id.is_empty() && id.bytes().all(|b| b.is_ascii_digit()))
+}
+
+/// Every open PR head, following `Link: rel="next"` until the last page.
+/// A next link that is not another page of a pull list ([`is_pulls_page`]) is an error:
+/// `gh api` follows an absolute URL to any host, so the walk never hands it one.
+fn open_pull_heads(gh: &str, or: &str, cache: &mut GithubHeadCache) -> Result, String> {
+ let mut path = format!("repos/{or}/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}");
+ let mut out = Vec::new();
+ for _page in 1..=OPEN_PULLS_PAGE_CAP {
+ let (shas, next) = conditional_heads(gh, &path, pull_heads, cache)?;
+ out.extend(shas);
+ let Some(next) = next.filter(|n| n != &path) else {
+ return Ok(out);
+ };
+ if !is_pulls_page(&next, or) {
+ return Err(format!(
+ "open pull list for {or}: next page link {next:?} is not a page of a pull list"
+ ));
+ }
+ path = next;
+ }
+ Err(format!(
+ "open pull list for {or} still had a next page after {OPEN_PULLS_PAGE_CAP} pages of {OPEN_PULLS_PER_PAGE}"
+ ))
+}
+
+/// Open PR heads and the main head of `repo` from GitHub. Open pulls are read
+/// page by page (`Link: rel="next"`, at most [`OPEN_PULLS_PAGE_CAP`] pages).
+/// Errors are returned, never fatal to the loop. Unchanged pages answer 304
+/// and cost no allowance; a 304 still follows the next page remembered with
+/// its ETag.
pub fn github_heads_cached(
gh: &str,
repository: &str,
cache: &mut GithubHeadCache,
) -> Result, String> {
let or = owner_repo(repository).ok_or("bad repository name")?;
- let mut shas = conditional_heads(
- gh,
- &format!("repos/{or}/pulls?state=open&per_page=50"),
- pull_heads,
- cache,
- )?;
- shas.extend(conditional_heads(
- gh,
- &format!("repos/{or}/commits/main"),
- main_head,
- cache,
- )?);
+ let mut shas = open_pull_heads(gh, &or, cache)?;
+ let (main, _) = conditional_heads(gh, &format!("repos/{or}/commits/main"), main_head, cache)?;
+ shas.extend(main);
shas.sort();
shas.dedup();
Ok(shas)
@@ -2032,7 +2132,9 @@ key=$(printf '%s' "$path" | tr -c 'A-Za-z0-9' '_')
if [ ! -f "$d/$key.body" ]; then printf 'HTTP/2.0 404 Not Found\r\n\r\n{}'; echo "gh: Not Found (HTTP 404)" >&2; exit 1; fi
etag=$(cat "$d/$key.etag")
if [[ " $* " == *"If-None-Match: $etag "* ]]; then printf 'HTTP/2.0 304 Not Modified\r\nEtag: %s\r\n\r\n' "$etag"; echo "gh: HTTP 304" >&2; exit 1; fi
-printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\nContent-Type: application/json\r\n\r\n' "$etag"; cat "$d/$key.body"
+linkhdr=""
+if [ -f "$d/$key.link" ]; then linkhdr=$(printf 'Link: %s\r\n' "$(cat "$d/$key.link")"); fi
+printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\n%sContent-Type: application/json\r\n\r\n' "$etag" "$linkhdr"; cat "$d/$key.body"
"#,
)
.unwrap();
@@ -2048,6 +2150,15 @@ printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\nContent-Type: application/json\r\n\r\n' "
.collect();
fs::write(dir.join(format!("{key}.etag")), etag).unwrap();
fs::write(dir.join(format!("{key}.body")), body).unwrap();
+ let _ = fs::remove_file(dir.join(format!("{key}.link")));
+ }
+
+ fn fake_link(dir: &Path, path: &str, link: &str) {
+ let key: String = path
+ .chars()
+ .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
+ .collect();
+ fs::write(dir.join(format!("{key}.link")), link).unwrap();
}
#[test]
@@ -2057,11 +2168,11 @@ printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\nContent-Type: application/json\r\n\r\n' "
let gh = fake_gh(&dir);
let gh = gh.to_str().unwrap();
let (p1, p2, m1) = ("1".repeat(40), "2".repeat(40), "3".repeat(40));
- let pulls = "repos/aien-dev/demo/pulls?state=open&per_page=50";
+ let pulls = format!("repos/aien-dev/demo/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}");
let main = "repos/aien-dev/demo/commits/main";
fake_answer(
&dir,
- pulls,
+ &pulls,
"W/\"a\"",
&format!(r#"[{{"head":{{"sha":"{p2}"}}}},{{"head":{{"sha":"{p1}"}}}}]"#),
);
@@ -2087,7 +2198,7 @@ printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\nContent-Type: application/json\r\n\r\n' "
let p3 = "4".repeat(40);
fake_answer(
&dir,
- pulls,
+ &pulls,
"W/\"b\"",
&format!(r#"[{{"head":{{"sha":"{p3}"}}}}]"#),
);
@@ -2103,6 +2214,240 @@ printf 'HTTP/2.0 200 OK\r\nEtag: %s\r\nContent-Type: application/json\r\n\r\n' "
let _ = fs::remove_dir_all(&dir);
}
+ #[test]
+ fn link_next_reads_the_next_rel_and_strips_the_api_host() {
+ let headers = "HTTP/2.0 200 OK\r\nLink: ; rel=\"next\", ; rel=\"last\"\r\n";
+ assert_eq!(
+ link_next(headers).as_deref(),
+ Some("repos/o/r/pulls?state=open&per_page=100&page=2")
+ );
+ assert_eq!(link_next("HTTP/2.0 200 OK\r\nEtag: \"x\"\r\n"), None);
+ }
+
+ /// Issue #732: a first page of 100 is not the whole list. The head on page 2
+ /// must be judged too. A 304 omits Link, so the remembered next page is what
+ /// the second poll follows. Dropping the link stops the walk (negative control).
+ #[test]
+ fn open_pulls_past_the_first_page_are_polled_and_a_304_still_follows_next() {
+ let dir = std::env::temp_dir().join(format!("sc732-heads-{}", std::process::id()));
+ fs::create_dir_all(&dir).unwrap();
+ let gh = fake_gh(&dir);
+ let gh = gh.to_str().unwrap();
+ let (p1, p2, m1) = ("a".repeat(40), "b".repeat(40), "c".repeat(40));
+ let page1 = format!("repos/aien-dev/demo/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}");
+ let page2 = format!("{page1}&page=2");
+ let main = "repos/aien-dev/demo/commits/main";
+ fake_answer(
+ &dir,
+ &page1,
+ "W/\"p1\"",
+ &format!(r#"[{{"head":{{"sha":"{p1}"}}}}]"#),
+ );
+ fake_link(
+ &dir,
+ &page1,
+ &format!("; rel=\"next\""),
+ );
+ fake_answer(
+ &dir,
+ &page2,
+ "W/\"p2\"",
+ &format!(r#"[{{"head":{{"sha":"{p2}"}}}}]"#),
+ );
+ fake_answer(&dir, main, "\"m\"", &format!(r#"{{"sha":"{m1}"}}"#));
+ let mut cache = GithubHeadCache::default();
+ let first = github_heads_cached(gh, "github.com/aien-dev/demo", &mut cache).unwrap();
+ assert_eq!(first, vec![p1.clone(), p2.clone(), m1.clone()]);
+ let second = github_heads_cached(gh, "github.com/aien-dev/demo", &mut cache).unwrap();
+ assert_eq!(
+ second, first,
+ "304 on page 1 still walks the remembered page 2"
+ );
+ let log = fs::read_to_string(dir.join("log")).unwrap();
+ let page2_calls = log.lines().filter(|l| l.contains("page=2")).count();
+ assert_eq!(page2_calls, 2, "both polls ask for page 2: {log}");
+ assert!(
+ log.lines().any(|l| l.contains("If-None-Match: W/\"p2\"")),
+ "page 2 is conditional on the second poll: {log}"
+ );
+ // Negative control: no next link, so the head that lived only on page 2 disappears
+ // and that page is not requested again.
+ fake_answer(
+ &dir,
+ &page1,
+ "W/\"p1b\"",
+ &format!(r#"[{{"head":{{"sha":"{p1}"}}}}]"#),
+ );
+ let third = github_heads_cached(gh, "github.com/aien-dev/demo", &mut cache).unwrap();
+ assert_eq!(third, vec![p1, m1], "no next link stops at page 1");
+ let log = fs::read_to_string(dir.join("log")).unwrap();
+ assert_eq!(
+ log.lines().filter(|l| l.contains("page=2")).count(),
+ 2,
+ "page 2 is not fetched once page 1 no longer links it: {log}"
+ );
+ let _ = fs::remove_dir_all(&dir);
+ }
+
+ /// Issue #732 acceptance: more than 100 open PRs, the last page's head, a
+ /// duplicate across pages, an unchanged 304, a changed later page, and a
+ /// failed later page that is an error rather than a short success.
+ #[test]
+ fn a_list_longer_than_one_page_keeps_the_last_head_and_a_later_error_is_not_success() {
+ let dir = std::env::temp_dir().join(format!("sc732-long-{}", std::process::id()));
+ fs::create_dir_all(&dir).unwrap();
+ let gh = fake_gh(&dir);
+ let gh = gh.to_str().unwrap();
+ let sha = |n: u32| format!("{n:040x}");
+ let page1 = format!("repos/aien-dev/wide/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}");
+ let page2 = format!("{page1}&page=2");
+ let main = "repos/aien-dev/wide/commits/main";
+ let m1 = sha(0xffff);
+ let mut body = String::from("[");
+ for n in 0..100 {
+ if n > 0 {
+ body.push(',');
+ }
+ body.push_str(&format!(r#"{{"head":{{"sha":"{}"}}}}"#, sha(n)));
+ }
+ body.push(']');
+ fake_answer(&dir, &page1, "W/\"wide1\"", &body);
+ fake_link(
+ &dir,
+ &page1,
+ &format!("; rel=\"next\""),
+ );
+ fake_answer(
+ &dir,
+ &page2,
+ "W/\"wide2\"",
+ &format!(
+ r#"[{{"head":{{"sha":"{}"}}}},{{"head":{{"sha":"{}"}}}}]"#,
+ sha(0),
+ sha(100)
+ ),
+ );
+ fake_answer(&dir, main, "\"mw\"", &format!(r#"{{"sha":"{m1}"}}"#));
+ let mut cache = GithubHeadCache::default();
+ let first = github_heads_cached(gh, "github.com/aien-dev/wide", &mut cache).unwrap();
+ let mut expect: Vec = (0..101).map(sha).collect();
+ expect.push(m1);
+ expect.sort();
+ expect.dedup();
+ assert_eq!(
+ first, expect,
+ "100 page-1 heads + last-page head + main, duplicate dropped"
+ );
+ assert!(first.contains(&sha(100)), "last page head is present");
+ assert_eq!(first.len(), 102);
+
+ let second = github_heads_cached(gh, "github.com/aien-dev/wide", &mut cache).unwrap();
+ assert_eq!(second, first, "304 keeps the long list, including page 2");
+
+ fake_answer(
+ &dir,
+ &page2,
+ "W/\"wide2b\"",
+ &format!(r#"[{{"head":{{"sha":"{}"}}}}]"#, sha(101)),
+ );
+ let third = github_heads_cached(gh, "github.com/aien-dev/wide", &mut cache).unwrap();
+ assert!(third.contains(&sha(101)), "a changed later page is read");
+ assert!(
+ !third.contains(&sha(100)),
+ "the replaced later-page head is gone"
+ );
+
+ let key: String = page2
+ .chars()
+ .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
+ .collect();
+ fs::remove_file(dir.join(format!("{key}.body"))).unwrap();
+ let err = github_heads_cached(gh, "github.com/aien-dev/wide", &mut cache).unwrap_err();
+ assert!(
+ err.contains("404"),
+ "a failed later page is an error, not a short list: {err}"
+ );
+ let _ = fs::remove_dir_all(&dir);
+ }
+
+ #[test]
+ fn only_pull_list_pages_count_as_next_pages() {
+ let or = "aien-dev/demo";
+ assert!(is_pulls_page("repositories/42/pulls?page=2", or));
+ assert!(is_pulls_page("repos/aien-dev/demo/pulls?page=2", or));
+ assert!(is_pulls_page("repos/Aien-Dev/Demo/pulls?page=2", or));
+ assert!(!is_pulls_page(
+ "https://evil.invalid/repositories/42/pulls?page=2",
+ or
+ ));
+ assert!(!is_pulls_page("repositories/42/issues?page=2", or));
+ assert!(!is_pulls_page("repositories//pulls?page=2", or));
+ assert!(!is_pulls_page("repositories/4x2/pulls?page=2", or));
+ assert!(!is_pulls_page("repos/aien-dev/other/pulls?page=2", or));
+ assert!(!is_pulls_page("user/repos?page=2", or));
+ }
+
+ /// GitHub's real `Link` names later pages `repositories//pulls?...` (seen on
+ /// aien-sovereign-core-mv, 2026-10-31), not the `repos//` path the walk started
+ /// from; that page is followed. A next link to another host is refused before `gh` is asked
+ /// for it (negative control).
+ #[test]
+ fn next_links_in_the_repositories_id_form_are_followed_and_other_hosts_are_refused() {
+ let dir = std::env::temp_dir().join(format!("sc732-repoid-{}", std::process::id()));
+ fs::create_dir_all(&dir).unwrap();
+ let gh = fake_gh(&dir);
+ let gh = gh.to_str().unwrap();
+ let (p1, p2, m1) = ("d".repeat(40), "e".repeat(40), "f".repeat(40));
+ let page1 = format!("repos/aien-dev/byid/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}");
+ let page2 = format!(
+ "repositories/1375978313/pulls?state=open&per_page={OPEN_PULLS_PER_PAGE}&page=2"
+ );
+ let main = "repos/aien-dev/byid/commits/main";
+ fake_answer(
+ &dir,
+ &page1,
+ "W/\"i1\"",
+ &format!(r#"[{{"head":{{"sha":"{p1}"}}}}]"#),
+ );
+ fake_link(
+ &dir,
+ &page1,
+ &format!(
+ "; rel=\"next\", ; rel=\"last\""
+ ),
+ );
+ fake_answer(
+ &dir,
+ &page2,
+ "W/\"i2\"",
+ &format!(r#"[{{"head":{{"sha":"{p2}"}}}}]"#),
+ );
+ fake_answer(&dir, main, "\"mi\"", &format!(r#"{{"sha":"{m1}"}}"#));
+ let mut cache = GithubHeadCache::default();
+ let heads = github_heads_cached(gh, "github.com/aien-dev/byid", &mut cache).unwrap();
+ assert_eq!(heads, vec![p1.clone(), p2, m1]);
+
+ fake_answer(
+ &dir,
+ &page1,
+ "W/\"i1b\"",
+ &format!(r#"[{{"head":{{"sha":"{p1}"}}}}]"#),
+ );
+ fake_link(
+ &dir,
+ &page1,
+ "; rel=\"next\"",
+ );
+ let err = github_heads_cached(gh, "github.com/aien-dev/byid", &mut cache).unwrap_err();
+ assert!(err.contains("not a page of a pull list"), "{err}");
+ let log = fs::read_to_string(dir.join("log")).unwrap();
+ assert!(
+ !log.contains("evil.invalid"),
+ "the foreign link is never handed to gh: {log}"
+ );
+ let _ = fs::remove_dir_all(&dir);
+ }
+
#[test]
fn pin_list_selects_the_repository_and_refuses_bad_lines() {
let sha = "353b7d4be3f00169545caec1615cffa61f7d311a";
```