Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 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
049fc60
Merge main into the retained refill CLI branch (#1017)
n0rpan Nov 17, 2026
1271fbc
test(work): reproduce worker reservation racing refill (#1017)
n0rpan Nov 17, 2026
6c0d418
wip(work): preserve queue-only refill CLI carry (#1017)
n0rpan Nov 17, 2026
6e3f801
feat(work): reserve idle helper claims under the shared lock (#1017)
Nov 17, 2026
ff804ad
Merge remote-tracking branch 'origin/agent/1153-paginated-board-reads…
n0rpan Nov 17, 2026
bb76c0d
test(work): drive refill startup and control-file authority (#1017)
n0rpan 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
39a50ed
fix(work): bind refill authority to protected owner controls (#1017)
n0rpan Nov 17, 2026
9ed94f9
Merge remote-tracking branch 'origin/agent/1017-refill-consumer' into…
n0rpan 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
2ce5232
test(work): drive token failure and exact-ref queue publication (#1017)
n0rpan Nov 17, 2026
ad55c29
test(work): isolate stdin token failure from packet validation (#1017)
n0rpan Nov 17, 2026
2d0c836
Merge remote-tracking branch 'origin/agent/1017-refill-source' into a…
n0rpan Nov 17, 2026
767c73a
refactor(work): reuse the extracted prepared-input adapter (#1017)
n0rpan Nov 17, 2026
d9f630b
fix(work): complete and bound prepared metadata before admission (#1017)
n0rpan Nov 17, 2026
7871f47
Merge remote-tracking branch 'origin/agent/1017-refill-source' into a…
n0rpan Nov 17, 2026
b9705e6
fix(work): bind prepared task identity before claim publication (#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
3078d7a
Merge branch 'agent/1017-refill-source' into agent/1017-refill-cli
n0rpan Nov 17, 2026
de8cc14
Merge remote-tracking branch 'origin/main' into agent/1017-refill-cli
n0rpan Nov 17, 2026
f30daa9
test(work): refuse board state in sibling task trees
n0rpan Nov 17, 2026
7745887
fix(work): protect refill state with the runner storage guard
n0rpan Nov 17, 2026
f75653c
Merge main for #1192 runner dispatch conflict (includes #1201)
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
2 changes: 1 addition & 1 deletion oxa/oxa-cli/src/lead_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Result<T> = std::result::Result<T, &'static str>;

/// The caller supplies the owner's uid from its user configuration, never project metadata.
/// Sources must have private parent directories; producers may atomically replace files.
fn open(path: &Path, uid: u32) -> Result<File> {
pub(crate) fn open(path: &Path, uid: u32) -> Result<File> {
let parent = path.parent().ok_or("missing input directory")?;
let directory = fs::symlink_metadata(parent).map_err(|_| "input directory unavailable")?;
if !directory.is_dir() || directory.uid() != uid || directory.mode() & 0o077 != 0 {
Expand Down
5 changes: 5 additions & 0 deletions oxa/oxa-cli/src/work_board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub mod refill_input;
use oxa_work::board::{Board, GitHub, Mergeability, Policy, PullRequest, RequiredCi};
use serde_json::Value;
mod refill;
use std::{
collections::{BTreeMap, BTreeSet},
io::{BufRead, IsTerminal, Read},
Expand Down Expand Up @@ -415,10 +416,14 @@ impl GitHub for Reader<'_> {
pub(crate) fn run(
args: &[String],
root: &Path,
common: &Path,
env: &oxa_config::Env,
dirs: &oxa_config::Dirs,
policy: &oxa_work::RunPolicy,
) -> Result<i32, String> {
if args.first().is_some_and(|arg| arg == "--refill") {
return refill::run(args, root, common, env, dirs, policy);
}
// Existing parser declaration; migrate command/flag metadata together in #1062.
let (repo, options) = match args {
[shadow, flag, repo, options @ ..] if shadow == "--shadow" && flag == "--repo" => (repo, options),
Expand Down
193 changes: 193 additions & 0 deletions oxa/oxa-cli/src/work_board/refill.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
//! Owner-selected queue frontend. Existing Reader, Claims, publisher and private-file IO only.
use super::refill_input::{text, Input, Prepared};
use super::*;
use crate::work_refill::{Consumer, Packet, Partition};
use oxa_work::board::{assignment::Worker, Action};
use std::{fs, os::unix::fs::MetadataExt, path::PathBuf};

fn private(path: &Path, uid: u32) -> Result<Value, String> {
let mut bytes = Vec::new();
crate::lead_input::open(path, uid)?
.take(65_537)
.read_to_end(&mut bytes)
.map_err(|_| "cannot read private board input")?;
if bytes.len() > 65_536 {
return Err("board input exceeds capacity".into());
}
serde_json::from_slice(&bytes).map_err(|_| "invalid private board input".into())
}

pub(super) fn run(
args: &[String],
root: &Path,
common: &Path,
env: &oxa_config::Env,
dirs: &oxa_config::Dirs,
policy: &oxa_work::RunPolicy,
) -> Result<i32, String> {
// #1062 owns command declarations; WorkBoard's existing Tail seam retains handler validation.
let [mode, repo_flag, repo, once, token_flag, config_flag, config] = args else {
return Err(
"usage: oxa work board --refill --repo OWNER/REPO --once --token-stdin --config PATH".into(),
);
};
if mode != "--refill"
|| repo_flag != "--repo"
|| once != "--once"
|| token_flag != "--token-stdin"
|| config_flag != "--config"
{
return Err("invalid board refill options".into());
}
if repo.split('/').count() != 2
|| repo.split('/').any(|part| {
part.is_empty()
|| matches!(part, "." | "..")
|| !part
.bytes()
.all(|b| b.is_ascii_alphanumeric() || b"-_.".contains(&b))
})
{
return Err("expected OWNER/REPO".into());
}
if policy.offline {
return Err("GitHub board is unavailable in offline mode".into());
}
if !crate::work_cmd::trusted(root, env, dirs)? {
return Err("source project is not trusted".into());
}
let config = Path::new(config)
.canonicalize()
.map_err(|_| "board config unavailable")?;
let authority = dirs
.agent_dir
.canonicalize()
.map_err(|_| "owner controls unavailable")?;
if config.starts_with(root) || !config.starts_with(&authority) {
return Err("board config must be in protected owner controls outside the source project".into());
}
let uid = fs::metadata(&dirs.home)
.map_err(|_| "owner home unavailable")?
.uid();
let value = private(&config, uid)?;
if value["enabled"] != true {
return Ok(0);
}
let owner_path = |key| -> Result<PathBuf, String> {
let path = PathBuf::from(text(&value, key)?);
crate::work_cmd::protected_storage(&path, root, common)?;
Ok(path)
};
let queue = owner_path("queue")?;
let pause = owner_path("pause")?;
match fs::symlink_metadata(&pause) {
Ok(_) => return Ok(0),
Err(e) if e.kind() == std::io::ErrorKind::NotFound => (),
Err(_) => return Err("cannot establish board pause state".into()),
}
let claims = oxa_work::board::Claims::open(&owner_path("claims")?)?;
let worker: Worker =
serde_json::from_value(value["worker"].clone()).map_err(|_| "invalid authenticated worker export")?;
let partition = Partition {
modulus: value["partition"]["modulus"]
.as_u64()
.ok_or("missing partition modulus")?,
residues: serde_json::from_value(value["partition"]["residues"].clone())
.map_err(|_| "invalid partition residues")?,
};
let rows = value["packets"]
.as_array()
.filter(|rows| rows.len() <= 20)
.ok_or("expected bounded prepared packets")?;
let mut packets = vec![];
let mut seen = BTreeSet::new();
for row in rows {
let number = row["number"]
.as_u64()
.filter(|n| *n > 0 && seen.insert(*n))
.ok_or("invalid or duplicate prepared ref")?;
let action: Action =
serde_json::from_value(row["action"].clone()).map_err(|_| "invalid prepared action")?;
let path = Path::new(text(row, "taskfile")?)
.canonicalize()
.map_err(|_| "taskfile unavailable")?;
if path.starts_with(root) || !path.starts_with(&authority) {
return Err("taskfile must be in protected owner controls outside source project".into());
}
let mut task = String::new();
crate::lead_input::open(&path, uid)?
.take(65_537)
.read_to_string(&mut task)
.map_err(|_| "cannot read prepared taskfile")?;
let header: Vec<_> = task
.lines()
.next()
.unwrap_or("")
.split_ascii_whitespace()
.collect();
let branch = text(row, "branch")?;
let task_id = format!("{}{number}", if action == Action::BuildIssue { "i" } else { "c" });
if task.len() > 65_536
|| !matches!(header.len(), 3 | 4)
|| header[0] != task_id
|| header[2] != branch
|| header.get(3).copied().unwrap_or("main")
!= if action == Action::BuildIssue {
"main"
} else {
branch
}
{
return Err("prepared taskfile ref/branch/base mismatch".into());
}
packets.push(Prepared {
number,
revision: text(row, "revision")?.into(),
action,
branch: branch.into(),
task,
});
}
let stdin = std::io::stdin();
if stdin.is_terminal() {
return Err("App token input requires a private pipe, not a terminal".into());
}
let token = token_line(&mut stdin.lock())?;
let gh =
crate::netguard::trusted_executable_for("gh", Some(&policy.host_path), Some(root), Some(&dirs.home))
.ok_or("no trusted gh executable")?;
let intake = value["intake"] == true;
let mut source = Input::new(&gh, &policy.host_path, repo, &token, &packets, intake);
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map_err(|_| "invalid system clock")?
.as_secs();
let policy = Policy {
enabled: true,
..Policy::default()
};
let consumer = Consumer {
repository: repo,
queue: &queue,
pause: &pause,
claims: &claims,
worker: &worker,
partition: &partition,
policy: &policy,
ttl: 1800,
};
let inputs: Vec<_> = packets
.iter()
.map(|p| Packet {
number: p.number,
revision: &p.revision,
action: p.action,
task: &p.task,
})
.collect();
let mut log = oxa_work::shadow::open_log(&owner_path("log")?)?;
consumer.once(&mut source, &inputs, now, |board| {
oxa_work::shadow::run(&mut log, true, || Ok(board.board.clone()), |_| {})
})?;
Ok(0)
}
4 changes: 2 additions & 2 deletions oxa/oxa-cli/src/work_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn trusted(cwd: &Path, env: &Env, dirs: &Dirs) -> Result<bool, String
}

// Keep owner state outside every worker Git bind.
fn protected_storage(storage: &Path, repo: &Path, common: &Path) -> Result<(), String> {
pub(crate) fn protected_storage(storage: &Path, repo: &Path, common: &Path) -> Result<(), String> {
if !storage.is_absolute()
|| storage
.components()
Expand Down Expand Up @@ -151,7 +151,7 @@ pub(crate) fn run(
};
protected_storage(&policy.storage, &root, &common)?;
if args.first().is_some_and(|arg| arg == "board") {
return crate::work_board::run(&args[1..], &root, env, dirs, &policy);
return crate::work_board::run(&args[1..], &root, &common, env, dirs, &policy);
}
if matches!(args.first().map(String::as_str), Some("status" | "--status")) {
let json = match args {
Expand Down
Loading
Loading