Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1305b29
test(work): reproduce oversized board detail query failures
oxa-agent[bot] Nov 17, 2026
5fc27bf
fix(work): bound and retry board detail batches (#1153)
oxa-agent[bot] Nov 17, 2026
5e9de06
Merge origin/main into agent/1153-batch-board-reads
n0rpan Nov 17, 2026
52863c5
feat(work): consume admitted helper packets with fenced claims (#1017)
Nov 17, 2026
e074629
test(work): cover complete paginated board reads
oxa-agent[bot] Nov 17, 2026
1b47197
fix(work): read and revalidate complete paginated boards (#1153)
oxa-agent[bot] Nov 17, 2026
93a1120
Merge main preserving landed batching and pagination controls
oxa-agent[bot] Nov 17, 2026
78bfb67
refactor(work): share bounded board reader with native consumer
oxa-agent[bot] Nov 17, 2026
1271fbc
test(work): reproduce worker reservation racing refill (#1017)
n0rpan Nov 17, 2026
6e3f801
feat(work): reserve idle helper claims under the shared lock (#1017)
Nov 17, 2026
c1c348e
Merge remote-tracking branch 'origin/agent/1017-idle-worker-claims' i…
n0rpan Nov 17, 2026
c8d62f5
fix(work): reserve an idle helper under the shared claim lock (#1017)
n0rpan Nov 17, 2026
812c089
test(work): reject transient markers as helper bootstrap state (#1017)
Nov 17, 2026
e4ef689
fix(work): require saved bootstrap state for idle helper admission (#…
Nov 17, 2026
15f7f6c
Merge remote-tracking branch 'origin/agent/1017-idle-worker-claims' i…
n0rpan Nov 17, 2026
1d0dd37
Merge remote-tracking branch 'origin/agent/1153-paginated-board-reads…
n0rpan Nov 17, 2026
5be12e8
test(work): extract prepared input and reproduce partial metadata (#1…
n0rpan Nov 17, 2026
d9f630b
fix(work): complete and bound prepared metadata before admission (#1017)
n0rpan Nov 17, 2026
40da279
Merge remote-tracking branch 'origin/main' into agent/1017-refill-con…
n0rpan Nov 17, 2026
eb6e442
style(work): follow the workspace formatter edition (#1017)
n0rpan Nov 17, 2026
b3532db
Merge remote-tracking branch 'origin/agent/1017-refill-consumer' into…
n0rpan Nov 17, 2026
a07d947
style(work): format source input with the workspace edition (#1017)
n0rpan Nov 17, 2026
e9faf01
Merge remote-tracking branch 'origin/main' into agent/1017-refill-source
n0rpan Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions oxa/oxa-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod status;
mod themes;
mod wipe_cmd;
mod work_board;
pub use work_board::refill_input;
mod work_checks;
mod work_cmd;
pub mod work_refill;
Expand Down
1 change: 1 addition & 0 deletions oxa/oxa-cli/src/work_board.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Explicitly opted-in, read-only GitHub sampling. Never invokes a worker or mutation.
pub mod refill_input;
use oxa_work::board::{Board, GitHub, Mergeability, Policy, PullRequest, RequiredCi};
use serde_json::Value;
use std::{
Expand Down
157 changes: 157 additions & 0 deletions oxa/oxa-cli/src/work_board/refill_input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
//! Read-only prepared-input normalization through the existing board Reader.
use super::*;
use crate::work_refill::Source;
use oxa_work::board::{Action, Entry, Issue, Snapshot};
pub(super) fn text<'a>(value: &'a Value, key: &str) -> Result<&'a str, String> {
value[key]
.as_str()
.ok_or_else(|| "missing board input field".into())
}

pub struct Prepared {
pub number: u64,
pub revision: String,
pub action: Action,
pub branch: String,
pub task: String,
}
pub struct Input<'a> {
reader: Reader<'a>,
packets: &'a [Prepared],
intake: bool,
}
impl<'a> Input<'a> {
/// Caller authorizes the source, trusted executable and App token before acquisition.
pub fn new(
gh: &'a Path,
path: &'a std::ffi::OsStr,
repo: &'a str,
token: &'a str,
packets: &'a [Prepared],
intake: bool,
) -> Self {
Self {
reader: Reader::new(gh, path, repo, token),
packets,
intake,
}
}
}
impl GitHub for Input<'_> {
fn snapshot(&mut self) -> Result<Snapshot, String> {
let pull_requests = self.reader.open_pull_requests()?;
let mut issue_fields = String::new();
for packet in self.packets.iter().filter(|p| p.action == Action::BuildIssue) {
issue_fields.push_str(&format!(
" i{}:issue(number:{}){{number state updatedAt}}",
packet.number, packet.number
));
}
let (mut metadata, mut rows, mut cursor, mut cursors) =
(Value::Null, vec![], String::new(), BTreeSet::new());
// Retained normalized facts and all metadata pages share one bounded budget.
let mut bytes = serde_json::to_vec(&pull_requests)
.map_err(|_| "cannot bound board facts")?
.len();
loop {
let fields = format!(
"pullRequests(first:100,states:OPEN{cursor}){{totalCount nodes{{number headRefOid headRefName closingIssuesReferences(first:100){{totalCount nodes{{number}}}}}} pageInfo{{hasNextPage endCursor}}}}{issue_fields}"
);
let (page, read) = self.reader.repository_read(&fields)?;
super::charge(&mut bytes, read)?;
let connection = &page["pullRequests"];
if connection["totalCount"].as_u64() != Some(pull_requests.len() as u64) {
return Err("board membership changed; retry later".into());
}
let batch = connection["nodes"].as_array().ok_or("missing metadata page")?;
if batch.len() > 100 {
return Err("oversized metadata page".into());
}
rows.extend(batch.iter().cloned());
if rows.len() > pull_requests.len() {
return Err("oversized metadata snapshot".into());
}
if metadata.is_null() {
metadata = page.clone();
}
if !connection["pageInfo"]["hasNextPage"]
.as_bool()
.ok_or("missing metadata pagination")?
{
break;
}
let next = connection["pageInfo"]["endCursor"]
.as_str()
.filter(|c| !c.is_empty())
.ok_or("missing metadata cursor")?;
if batch.is_empty() || !cursors.insert(next.to_owned()) {
return Err("invalid metadata pagination progress".into());
}
cursor = format!(",after:{next:?}");
issue_fields.clear();
}
metadata["pullRequests"]["nodes"] = rows.into();
let rows = nodes(&metadata["pullRequests"])?;
let heads: BTreeMap<_, _> = rows
.iter()
.map(|p| (p["number"].as_u64(), p["headRefOid"].as_str()))
.collect();
if heads.len() != rows.len()
|| heads.len() != pull_requests.len()
|| pull_requests
.iter()
.any(|p| heads.get(&Some(p.number)) != Some(&Some(p.head.as_str())))
{
return Err("board membership or head changed; retry later".into());
}
let mut closing = BTreeSet::new();
for pr in rows {
for issue in nodes(&pr["closingIssuesReferences"])? {
closing.insert(issue["number"].as_u64().ok_or("invalid closing issue")?);
}
if let Some(packet) = self
.packets
.iter()
.find(|p| p.number == pr["number"].as_u64().unwrap_or(0))
{
if text(pr, "headRefName")? != packet.branch {
return Err("prepared PR branch changed".into());
}
}
}
let mut issues = vec![];
for packet in self.packets.iter().filter(|p| p.action == Action::BuildIssue) {
let issue = &metadata[format!("i{}", packet.number)];
if issue["number"].as_u64() != Some(packet.number) {
return Err("prepared issue is missing".into());
}
issues.push(Issue {
number: packet.number,
revision: text(issue, "updatedAt")?.into(),
release_pinned: false,
approved: self.intake && pull_requests.len() < 40 && text(issue, "state")? == "OPEN",
has_open_pull_request: closing.contains(&packet.number),
});
}
Ok(Snapshot {
pull_requests,
issues,
})
}
}
impl Source for Input<'_> {
fn revalidate(&mut self, entry: &Entry) -> Result<bool, String> {
let board = Board::read(
self,
&Policy {
enabled: true,
..Policy::default()
},
&BTreeMap::new(),
0,
)?;
Ok(board.entries.iter().any(|fresh| {
fresh.number == entry.number && fresh.head == entry.head && fresh.action == entry.action
}))
}
}
125 changes: 125 additions & 0 deletions oxa/oxa-cli/tests/work_refill_input.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
use oxa_cli::{
refill_input::{Input, Prepared},
work_refill::Source,
};
use oxa_fake::TestEnv;
use oxa_work::board::{Action, Board, GitHub, Policy};
use serde_json::{json, Value};
use std::{collections::BTreeMap, fs, os::unix::fs::PermissionsExt};

fn write(env: &TestEnv, name: &str, value: &Value) {
fs::write(env.tmp().join(name), value.to_string()).unwrap();
}

fn fixture(count: u64, linked: bool) -> (TestEnv, Vec<Prepared>) {
let env = TestEnv::new();
fs::set_permissions(env.tmp(), fs::Permissions::from_mode(0o700)).unwrap();
let gh = env.write(
"tmp/gh",
r#"#!/bin/sh
[ "$GH_TOKEN" = synthetic ] || exit 93
printf 'HTTP/2.0 200 OK\r\n\r\n'
case "$*" in
*headRefName*) case "$*" in *after:*) cat "$0.second";; *) cat "$0.first";; esac ;;
*':pullRequest('*) cat "$0.details" ;;
*) cat "$0.list" ;;
esac
"#,
);
fs::set_permissions(gh, fs::Permissions::from_mode(0o700)).unwrap();
let list: Vec<_> = (100..100 + count)
.map(|n| json!({"number":n,"headRefOid":format!("head-{n}")}))
.collect();
let mut repository = json!({"mergeQueue":null,"pullRequests":{
"totalCount":count,"nodes":list,"pageInfo":{"hasNextPage":false,"endCursor":"last"}}});
write(&env, "gh.list", &json!({"data":{"repository":repository}}));
for n in 100..100 + count {
repository[format!("p{n}")] = json!({"number":n,"headRefOid":format!("head-{n}"),
"baseRefName":"main","state":"OPEN","body":"","isDraft":false,"reviewDecision":null,
"mergeable":"MERGEABLE","mergeStateStatus":"CLEAN",
"baseRef":{"refUpdateRule":null,"rules":{"totalCount":0,"nodes":[]}},
"labels":{"totalCount":0,"nodes":[]},"files":{"totalCount":0,"nodes":[]},
"reviewThreads":{"totalCount":0,"nodes":[]},"latestOpinionatedReviews":{"totalCount":0,"nodes":[]},
"commits":{"nodes":[{"commit":{"statusCheckRollup":null}}]}});
}
write(&env, "gh.details", &json!({"data":{"repository":repository}}));
let metadata: Vec<_> = (100..100 + count)
.map(|n| {
json!({"number":n,
"headRefOid":format!("head-{n}"),"headRefName":format!("agent/{n}"),
"closingIssuesReferences":if linked && n == 99+count {
json!({"totalCount":1,"nodes":[{"number":44}]})
} else { json!({"totalCount":0,"nodes":[]}) }})
})
.collect();
let split = metadata.len() / 2;
for (name, rows, more) in [
("gh.first", &metadata[..split], true),
("gh.second", &metadata[split..], false),
] {
write(
&env,
name,
&json!({"data":{"repository":{
"pullRequests":{"totalCount":count,"nodes":rows,"pageInfo":{"hasNextPage":more,"endCursor":"next"}},
"i44":{"number":44,"state":"OPEN","updatedAt":"revision"}}}}),
);
}
let packets = vec![Prepared {
number: 44,
revision: "revision".into(),
action: Action::BuildIssue,
branch: "agent/44".into(),
task: "i44 local/fake agent/44 main\nSynthetic packet.\n".into(),
}];
(env, packets)
}

#[test]
fn all_metadata_pages_preserve_linked_issue_refusal_and_explicit_intake() {
let (env, packets) = fixture(2, true);
let gh = env.tmp().join("gh");
let path = std::env::var_os("PATH").unwrap();
let mut source = Input::new(&gh, &path, "example/project", "synthetic", &packets, true);
let snapshot = source.snapshot().unwrap();
assert_eq!(snapshot.pull_requests.len(), 2);
assert!(snapshot.issues[0].approved);
assert!(snapshot.issues[0].has_open_pull_request);
let mut off = Input::new(&gh, &path, "example/project", "synthetic", &packets, false);
assert!(!off.snapshot().unwrap().issues[0].approved);
let mut second: Value = serde_json::from_slice(&fs::read(env.tmp().join("gh.second")).unwrap()).unwrap();
second["data"]["repository"]["pullRequests"]["nodes"][0]["headRefOid"] = "changed-head".into();
write(&env, "gh.second", &second);
assert!(source.snapshot().is_err());
}

#[test]
fn fresh_revision_and_global_open_pr_cap_gate_issue_admission() {
let (env, packets) = fixture(2, false);
let gh = env.tmp().join("gh");
let path = std::env::var_os("PATH").unwrap();
let mut source = Input::new(&gh, &path, "example/project", "synthetic", &packets, true);
let board = Board::read(
&mut source,
&Policy {
enabled: true,
..Policy::default()
},
&BTreeMap::new(),
10,
)
.unwrap();
let entry = board.entries.iter().find(|row| row.number == 44).unwrap();
assert_eq!(entry.action, Action::BuildIssue);
assert!(source.revalidate(entry).unwrap());
let mut first: Value = serde_json::from_slice(&fs::read(env.tmp().join("gh.first")).unwrap()).unwrap();
first["data"]["repository"]["i44"]["updatedAt"] = "changed-revision".into();
write(&env, "gh.first", &first);
assert!(!source.revalidate(entry).unwrap());
let (capped, packets) = fixture(40, false);
let gh = capped.tmp().join("gh");
let mut source = Input::new(&gh, &path, "example/project", "synthetic", &packets, true);
let snapshot = source.snapshot().unwrap();
assert_eq!(snapshot.pull_requests.len(), 40);
assert!(!snapshot.issues[0].approved);
}
Loading