Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
3936b70
Register oxa-work crate for issue #333
n0rpan Nov 15, 2026
fb25b36
Add opt-in work task runner with external acceptance checks (#333)
n0rpan Nov 15, 2026
cfd23d3
Merge remote-tracking branch 'origin/main' into agent/333-work-task-r…
n0rpan Nov 15, 2026
779e689
Merge remote-tracking branch 'origin/main' into agent/333-work-continue
n0rpan Nov 15, 2026
cdfab27
Fix sandbox commits and offline issue lookup in work runner
n0rpan Nov 15, 2026
667f3f6
Merge remote-tracking branch 'origin/main' into agent/333-work-task-r…
n0rpan Nov 15, 2026
e6e30c3
Merge branch 'agent/333-work-task-runner' into agent/333-work-continue
n0rpan Nov 15, 2026
c86fa8b
Continue work branches with ordinary base merges (#333)
n0rpan Nov 15, 2026
d053910
Include the current base when resuming an older merge
n0rpan Nov 15, 2026
1e39172
Preserve offline policy and continue work batches after task failures
n0rpan Nov 15, 2026
6915352
Merge remote-tracking branch 'origin/main' into agent/333-work-task-r…
n0rpan Nov 15, 2026
6c24b5f
Merge branch 'agent/333-work-task-runner' into agent/333-work-continue
n0rpan Nov 15, 2026
77100aa
Checkpoint work tasks and save unfinished work as commits (#333)
n0rpan Nov 15, 2026
f6321b0
Keep task ownership throughout saving and detect interrupted status
n0rpan Nov 15, 2026
232eb0e
Publish accepted work and file scrubbed duplicate-checked problem not…
n0rpan Nov 15, 2026
8bf1f38
Preserve execution privacy and finish failed reporting checkpoints
n0rpan Nov 15, 2026
5c227ed
Run oldest queued tasks with bounded workers, disk checks and monitor…
n0rpan Nov 15, 2026
d7ab5cf
Keep prompt parsing stable and retain agent failure causes (#333)
n0rpan Nov 15, 2026
e8952cb
Merge remote-tracking branch 'origin/main' into agent/333-work-task-r…
n0rpan Nov 15, 2026
b7cfc06
Merge branch 'agent/333-work-task-runner' into agent/333-work-continue
n0rpan Nov 15, 2026
8f1e2c0
Merge branch 'agent/333-work-continue' into agent/333-work-state
n0rpan Nov 15, 2026
7bec3a9
Merge main into agent/333-work-state
n0rpan Nov 15, 2026
94fb542
Merge remote-tracking branch 'origin/agent/333-work-state' into agent…
n0rpan Nov 15, 2026
91fc859
Merge branch 'agent/333-work-state' into agent/333-work-publish
n0rpan Nov 15, 2026
2841b35
Require terminal approval for public work actions and retain interrup…
n0rpan Nov 15, 2026
0c1b7e8
Merge branch 'agent/333-work-publish' into agent/333-work-queue
n0rpan Nov 15, 2026
ad1db00
Drain queue workers on errors and reconcile changed inputs (#333)
n0rpan Nov 15, 2026
e9feda5
Merge remote-tracking branch 'origin/main' into agent/333-work-publish
n0rpan Nov 15, 2026
a80596a
Merge remote-tracking branch 'origin/main' into agent/333-work-queue
n0rpan Nov 15, 2026
06585e8
Keep the leading subcommand dispatch in parse_args instead of rewriti…
n0rpan Nov 17, 2026
8d71af0
merge: compose retained work publication with trusted runner
n0rpan Nov 17, 2026
a8e2efe
fix(work): preserve action and save retries on current checkpoints
n0rpan Nov 17, 2026
f1b5ec3
test(work): reject dispatch of an archived pending input
n0rpan Nov 17, 2026
e9305a2
merge: retain queue admission on the current trusted runner
n0rpan Nov 17, 2026
494cfff
fix(work): clear completed save outcome before later execution
n0rpan Nov 17, 2026
153804a
test(work): retain queue drain control with trusted runner inputs
n0rpan Nov 17, 2026
0222d8a
merge: carry publication retry correction into queue candidate
n0rpan Nov 17, 2026
02d6889
fix(work): authorize only confirmed publication transports
n0rpan Nov 17, 2026
8e65469
fix(work): withdraw archived inputs before queue admission
n0rpan Nov 17, 2026
c0be38b
merge: share confirmed publication transport controls with queue
n0rpan Nov 17, 2026
1b9e38a
test(work): expose note privacy and publication metadata regressions
n0rpan Nov 17, 2026
a7db5ec
fix(work): sanitize notes and retain publication host and owner body
n0rpan Nov 17, 2026
ed83dc3
test(work): expose global queue admission boundary failures
n0rpan Nov 17, 2026
27b661e
fix(work): preserve publication boundaries and queue admission controls
n0rpan Nov 17, 2026
ff82d24
test(work): reporting must retain a pending accepted save
n0rpan Nov 17, 2026
2b6a47b
fix(work): preserve pending save through report checkpoints
n0rpan Nov 17, 2026
7a8f847
Merge commit '2b6a47b3' into agent/333-work-queue
n0rpan Nov 17, 2026
9650ba9
Merge main preserving publication and native shadow interfaces
n0rpan Nov 17, 2026
a901c8a
Merge publication conflict repair retaining execution queue and shadow
n0rpan Nov 17, 2026
6936ee2
test(work): reject publication recovery acceptance bypasses
n0rpan Nov 17, 2026
95c55cb
fix(work): revalidate terminal action checkpoints on explicit rerun
n0rpan Nov 17, 2026
a7cc395
Merge commit '95c55cba' into agent/333-work-queue
n0rpan Nov 17, 2026
cb7ae1f
Merge main preserving publication alongside native helper queue
n0rpan Nov 17, 2026
4a6c1f6
Merge commit 'cb7ae1fd' into agent/333-work-queue
n0rpan Nov 17, 2026
6e3f801
feat(work): reserve idle helper claims under the shared lock (#1017)
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
dcd4f46
Merge main while retaining work publication and verification
n0rpan Nov 17, 2026
96b609f
Merge main while retaining the approved work queue
n0rpan Nov 17, 2026
08c2c9b
test(work): expose stale save and publication verification failures
n0rpan Nov 17, 2026
e58b910
Test queue input limits and inherited reporting lease
n0rpan Nov 17, 2026
8ac1cc9
Verify committed publication and recovered saves
n0rpan Nov 17, 2026
46f497b
Bound queue inputs and preserve the reporting lease
n0rpan Nov 17, 2026
e89fb4e
Merge committed publication verification into the native queue
n0rpan Nov 17, 2026
c3b0b29
Merge main and use its shared report command runner
n0rpan Nov 17, 2026
48abc45
Merge refreshed publication and shared command runner
n0rpan Nov 17, 2026
10a1392
Retain queue admission receipts in the original claim row
n0rpan Nov 17, 2026
63122e7
Revert "Retain queue admission receipts in the original claim row"
n0rpan Nov 17, 2026
4227fe3
Merge commit '23eaa743ba5626534ac223ffcd2e717ee13c0526' into agent/33…
n0rpan Nov 17, 2026
23eaa74
Merge main and preserve native refill and report routes
n0rpan Nov 17, 2026
1bf6389
Merge commit 'adde48e3f774a96014b451592978a7c7fbb9eeb5' into agent/33…
n0rpan Nov 17, 2026
adde48e
Merge main and protect publication checkpoint reads
n0rpan Nov 17, 2026
9f4fb84
Retain native attempt bindings in board claim rows (#1017)
Nov 17, 2026
158b1ea
Preserve merged idle-claims history for native binding follow-up
Nov 17, 2026
7bd662d
Keep task ownership through publication and reporting
n0rpan Nov 17, 2026
bb47e72
Exercise exhausted binding writes without refunding the lease (#1017)
Nov 17, 2026
e7866a5
Use an invalid Git branch in the malformed binding fixture (#1017)
Nov 17, 2026
2431bc0
Merge Work1 native claim binding contract
n0rpan Nov 17, 2026
ed67227
Merge commit 'e7866a56cc47cc55375d7460db5e434499b32f67' into agent/33…
n0rpan Nov 17, 2026
08b4094
Fence native queue completion with the original task binding
n0rpan Nov 17, 2026
2c1b106
Merge main and carry the canonical report deadline
n0rpan Nov 17, 2026
7d7598c
Merge refreshed publication while retaining reporting ownership
n0rpan Nov 17, 2026
de1e27f
Carry the refreshed queue baseline into native completion
n0rpan Nov 17, 2026
72025f3
test(work): cover publication subprocess and destination guards
n0rpan Nov 17, 2026
d449d02
test(work): cover whole queue input limits
n0rpan Nov 17, 2026
72a5d6e
test(work): assert the confirmed report host is used
n0rpan Nov 17, 2026
4ab6488
Bound queue admission scans and retained task identities
n0rpan Nov 17, 2026
373b8bd
Bound publication commands and bind confirmed destinations
n0rpan Nov 17, 2026
41603b4
Carry publication guard repairs into the native queue
n0rpan Nov 17, 2026
b67cc48
Use the queue report gate in the host regression
n0rpan Nov 17, 2026
7275f10
Run an admitted native board packet through the held task lock
n0rpan Nov 17, 2026
80cea9a
Preserve the native queue command and apply isolation internally
n0rpan Nov 17, 2026
41c4b89
Merge main and preserve #1090 PR packets with publication
n0rpan Nov 17, 2026
79d306c
Merge refreshed publication and retain native task ownership
n0rpan Nov 17, 2026
0872759
Fence started spool packets to the original lease generation
n0rpan Nov 17, 2026
49ed0fc
Use #1090 guidance to materialize native board tasks
n0rpan Nov 17, 2026
cb8174d
Merge #1043 and #1099 with publication and action recovery
n0rpan Nov 17, 2026
a0a6ada
Carry #1043 and #1099 through the held-lock queue
n0rpan Nov 17, 2026
0731c39
Resolve #407 queue conflict after #397 landed
n0rpan Nov 18, 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
47 changes: 47 additions & 0 deletions oxa/docs/work.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,50 @@ A later explicit `--report-problems` retries local reports without replaying the
agent. A draft-write failure records a failed report and finishes the task checkpoint;
`--report-problems` can retry it. Reports contain only scrubbed structured symptom
summaries, without raw assistant output or acceptance logs.


Queue mode watches a directory of regular, non-hidden `*.json` task files.
Each file may contain up to 128 tasks and occupy up to 1 MiB. A queue accepts
up to 256 task files and 16 MiB of input per scan. The controller retains at
most 4,096 task identities and 16 MiB of task text across scans. Archive
completed inputs and restart the controller if it reaches the retention limit.
After adding task files, run
`oxa work --queue ./tasks --max 2 --min-free-mib 1024`.

Files are admitted oldest modification time first (filename breaks ties), with
array order preserved inside a file. At most `--max` tasks run; surviving workers
from an interrupted controller still occupy slots until their locks release.
Task IDs must be unique across the queue. Completed task state prevents agent
replay on restart. Files remain available for inspection and manual archiving.
Write new files with an atomic rename so the runner reads a complete task file.

The default free-space floor is 512 MiB. The runner checks the repository, common
git directory, worktree storage and queue filesystems before each admission. A low
or unreadable free-space value pauses new work while active jobs finish. Invalid
JSON files report an error and do not skip other work. `--once` drains available
work and exits; when disk space blocks pending tasks it exits 1 with their files
retained. Without `--once`, the directory stays under watch for new files.
Appending tasks to an existing file queues only new IDs. Discovered task definitions
are immutable; changing one requires a new ID. Correcting or archiving an invalid
input clears its current queue errors. Archiving inputs does not interrupt admitted
work. A controller or monitor error stops admission and drains active workers
before returning an error.

Queue mode supports `--publish`, `--report-problems` and `--rerun` with the same
explicit policy as single-file mode. Its worker threads preserve the parent's
offline policy. Standard output emits JSON lines tagged `state`, `task` or `error`.
The latest state line is also replaced atomically at
`<queue>/.oxa-queue-status.json` for a monitor. It contains a heartbeat timestamp,
active task IDs, pending/finished/failed counts, free bytes and disk-pause details.
A controller lock prevents two queue controllers from exceeding the worker cap.

The native board adapter runs one previously admitted packet from that board's
existing spool. Use `oxa work --native-queue --config PATH` from the source
repository with the same private config used by refill and `nativeExecution`
explicitly enabled. This execution path uses the offline policy. It moves the
matching packet into `started` and resumes from the task checkpoint after
interruption. The original claim releases after the whole task finishes and
its worker process exits.

Problem-report workflows hold a per-user kernel lease across drafting, duplicate
search, match reads and writing, so concurrent workers share one reporting lane.
280 changes: 198 additions & 82 deletions oxa/oxa-cli/src/work_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use sha2::{Digest, Sha256};
use std::io::Write;
use std::path::{Path, PathBuf};

#[path = "work_cmd/native_queue.rs"]
mod native_queue;

pub(crate) fn trusted(cwd: &Path, env: &Env, dirs: &Dirs) -> Result<bool, String> {
crate::dispatch::project_trusted(
&crate::Args::default(),
Expand Down Expand Up @@ -227,6 +230,63 @@ pub(crate) fn run(
}
let task_args = &args[..end];
let is_trusted = trusted(&root, env, dirs)?;
let context = Context {
cwd: root.clone(),
binary: binary.clone(),
policy: policy.clone(),
dirs: dirs.clone(),
env: env.clone(),
rerun,
publish,
reports,
};
if task_args.first().is_some_and(|word| word == "--native-queue") {
if !is_trusted {
return Err("source project is not trusted; approve it before unattended work".into());
}
let [_, flag, config] = task_args else {
return Err("usage: oxa work --native-queue --config PATH".into());
};
if flag != "--config" || rerun || publish {
return Err("invalid native queue options".into());
}
return native_queue::run(context, &common, &cwd.join(config), out);
}
if task_args.first().is_some_and(|word| word == "--queue") {
if !is_trusted {
return Err("source project is not trusted; approve it before unattended work".into());
}
let (directory, options) = queue_options(task_args, cwd)?;
let df = crate::netguard::trusted_executable_for(
"df",
Some(policy.host_path.as_os_str()),
Some(&root),
Some(&dirs.home),
)
.ok_or("no trusted disk-space executable outside the source project")?;
let worker = std::sync::Arc::new(move |task: &oxa_work::Task| {
let plan = if context.publish || context.reports {
oxa_work::plan_task_for_actions(
&context.cwd,
task.clone(),
&context.policy,
context.rerun,
)
} else {
oxa_work::plan_task_for_run(&context.cwd, task.clone(), &context.policy, context.rerun)
};
match plan {
Ok(plan) => context.planned(&plan),
Err(error) => Ok(oxa_work::blocked_record(task, error)),
}
});
let summary =
oxa_work::run_queue(&root, &directory, &options, &policy, &df, worker, &mut |event| {
serde_json::to_writer(&mut *out, &event).map_err(|e| e.to_string())?;
writeln!(out).and_then(|_| out.flush()).map_err(|e| e.to_string())
})?;
return Ok(i32::from(summary.failed > 0 || summary.pending > 0));
}
let tasks = match task_args {
[file] if !file.starts_with('-') => oxa_work::read_tasks(&cwd.join(file))?,
[flag, number, model_flag, model] if flag == "--issue" && model_flag == "--model" => {
Expand Down Expand Up @@ -298,88 +358,7 @@ pub(crate) fn run(
let mut code = 0;
for task in planned {
let record = match task {
Ok(plan) => {
let cached = if (publish || reports) && !rerun {
oxa_work::action_record(&policy, plan.task())?
} else {
None
};
let mut record = if let Some(record) = cached {
record
} else {
let ctx = crate::report_cmd::ScrubCtx::from_env(env, dirs);
match oxa_work::run_task_with_notes(
&root,
&binary,
&plan,
&policy,
rerun,
&|_: &oxa_work::Record| Ok(()),
&|note| crate::work_reports::scrub_note(note, &ctx),
) {
Ok(record) => record,
Err(oxa_work::RunError::Blocked(detail)) => {
let mut record = oxa_work::blocked_record(plan.task(), detail);
record.base_sha = Some(plan.base_sha().to_owned());
record
}
Err(oxa_work::RunError::Checkpoint(error)) => return Err(error),
}
};
if publish && !record.worktree.as_os_str().is_empty() {
let gh = crate::netguard::trusted_executable_for(
"gh",
Some(policy.host_path.as_os_str()),
Some(&root),
Some(&dirs.home),
)
.unwrap_or_else(|| PathBuf::from("/unavailable/gh"));
record = oxa_work::publish(
&root,
&binary,
plan.task(),
&policy,
&gh,
&|_: &oxa_work::Record| Ok(()),
&mut crate::report_cmd::tty_confirm(env),
)?;
}
if reports && !record.worktree.as_os_str().is_empty() {
let settings = oxa_config::Settings::load(dirs, &root, false);
let ctx = crate::report_cmd::ScrubCtx::from_env(env, dirs);
record = oxa_work::report_notes(
plan.task(),
&policy,
&|_: &oxa_work::Record| Ok(()),
&mut |note, lock, offline| {
let mut runner = |program: &str, args: &[String]| {
let executable = crate::netguard::trusted_executable_for(
program,
Some(policy.host_path.as_os_str()),
Some(&root),
Some(&dirs.home),
)?;
crate::work_reports::process(
&executable.to_string_lossy(),
args,
&root,
lock,
)
};
crate::work_reports::report(
note,
dirs,
&settings,
&ctx,
offline,
&mut crate::report_cmd::tty_confirm(env),
&mut runner,
)
},
)?;
}
record
}
Ok(plan) => context.planned(&plan)?,
Err(record) => *record,
};
if matches!(
Expand All @@ -402,3 +381,140 @@ pub(crate) fn run(
}
}
}

struct Context {
cwd: PathBuf,
binary: PathBuf,
policy: oxa_work::RunPolicy,
dirs: Dirs,
env: Env,
rerun: bool,
publish: bool,
reports: bool,
}
impl Context {
fn planned(&self, plan: &oxa_work::PlannedTask) -> Result<oxa_work::Record, String> {
let mut locked = match oxa_work::LockedTask::acquire(plan.task(), &self.policy) {
Ok(locked) => locked,
Err(error) => return Ok(blocked_plan(plan, error)),
};
self.planned_locked(plan, &mut locked)
}

fn planned_locked(
&self,
plan: &oxa_work::PlannedTask,
locked: &mut oxa_work::LockedTask<'_>,
) -> Result<oxa_work::Record, String> {
let root = &self.cwd;
let binary = &self.binary;
let policy = &self.policy;
let dirs = &self.dirs;
let env = &self.env;
let (rerun, publish, reports) = (self.rerun, self.publish, self.reports);
let cached = if (publish || reports) && !rerun {
oxa_work::action_record(policy, plan.task())?
} else {
None
};
let mut record = if let Some(record) = cached {
record
} else {
let ctx = crate::report_cmd::ScrubCtx::from_env(env, dirs);
match locked.run_with_notes(
root,
binary,
plan,
rerun,
&|_: &oxa_work::Record| Ok(()),
&|note| crate::work_reports::scrub_note(note, &ctx),
) {
Ok(record) => record,
Err(oxa_work::RunError::Blocked(detail)) => blocked_plan(plan, detail),
Err(oxa_work::RunError::Checkpoint(error)) => return Err(error),
}
};
if publish && !record.worktree.as_os_str().is_empty() {
let gh = crate::netguard::trusted_executable_for(
"gh",
Some(policy.host_path.as_os_str()),
Some(root),
Some(&dirs.home),
)
.unwrap_or_else(|| PathBuf::from("/unavailable/gh"));
record = locked.publish(
root,
binary,
&gh,
&|_: &oxa_work::Record| Ok(()),
&mut crate::report_cmd::tty_confirm(env),
)?;
}
if reports && !record.worktree.as_os_str().is_empty() {
let settings = oxa_config::Settings::load(dirs, root, false);
let ctx = crate::report_cmd::ScrubCtx::from_env(env, dirs);
record = locked.report_notes(&|_: &oxa_work::Record| Ok(()), &mut |note, lock, offline| {
let runner = |program: &str, args: &[String], gate: &std::fs::File| {
let executable = crate::netguard::trusted_executable_for(
program,
Some(policy.host_path.as_os_str()),
Some(root),
Some(&dirs.home),
)?;
crate::work_reports::process(&executable.to_string_lossy(), args, root, lock, gate)
};
crate::work_reports::report(
note,
dirs,
&settings,
&ctx,
offline,
&mut crate::report_cmd::tty_confirm(env),
runner,
)
})?;
}
Ok(record)
}
}
fn blocked_plan(plan: &oxa_work::PlannedTask, detail: String) -> oxa_work::Record {
let mut record = oxa_work::blocked_record(plan.task(), detail);
record.base_sha = Some(plan.base_sha().to_owned());
record
}

fn queue_options(args: &[String], cwd: &Path) -> Result<(PathBuf, oxa_work::QueueOptions), String> {
let directory = cwd.join(args.get(1).ok_or("--queue needs a directory")?);
let mut options = oxa_work::QueueOptions::default();
let mut i = 2;
while i < args.len() {
match args[i].as_str() {
"--max" => {
i += 1;
options.max = args
.get(i)
.ok_or("--max needs a value")?
.parse()
.map_err(|_| "invalid --max")?;
}
"--min-free-mib" => {
i += 1;
let mib: u64 = args
.get(i)
.ok_or("--min-free-mib needs a value")?
.parse()
.map_err(|_| "invalid free-space minimum")?;
options.min_free_bytes = mib
.checked_mul(1024 * 1024)
.ok_or("free-space minimum is too large")?;
}
"--once" => options.once = true,
word => return Err(format!("unknown queue option: {word}")),
}
i += 1;
}
if options.max == 0 {
return Err("--max must be positive".into());
}
Ok((directory, options))
}
Loading
Loading