Skip to content

feat: job_start/job_poll tools for long-running work - #64

Merged
ajianaz merged 2 commits into
developfrom
feat/long-running-jobs
Sep 12, 2026
Merged

ajianaz merged 2 commits into
developfrom
feat/long-running-jobs

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

Two tools formalizing the improvised nohup-background + poll pattern (issue #59):

  • job_start (Write): argv-split exactly like run_command (no shell; bash -c is the explicit shell escape), detached into its own process group (survives CLI exit), stdin null, stdout+stderr appended to tole-jobs/<id>/log INSIDE the file-tools workspace. Returns job id + pid immediately, under the normal approval gate.
  • job_poll (ReadOnly): liveness via ps -p <pid> -o stat= (zombie state Z* counts as finished) + bounded 8KiB-window tail of the log (stat → seek → read, lossy UTF-8 at the boundary). Full log reachable via read_file through the same jail.

Builds on #57 (merged): logs live under the file-tools root, so read_file reaches them without workarounds.

Why (the problem you're solving)

CPU-bound jobs (30-60s video renders) exceed the 30s run_command ceiling; both vetio missions hand-rolled nohup + result-file polling unprompted. Formalizing the pattern removes improvisation cost. This also resolves issue #56 option (b) for the shell-job dimension.

Testing (how you verified this works)

  • 6 unit tests: spawn→poll→log-capture cycle (asserts running:false + stdout captured), unspawnable program, unknown job, path-trick job ids rejected (../, /, empty), empty command, risk tiers. Suite 85/85 lib, both feature profiles green (mobile --no-default-features unaffected: module is shell-tools-gated).
  • CodeCora caught 2 majors pre-push, both real, both fixed: (1) zombie children made poll report running=true forever → stat= Z* check; (2) unbounded log read per poll → 8KiB seek window.
  • Live E2E with the fresh release binary (headless --allow 'job_*'): job_start spawned sh -c, job_poll transitioned to running:false exactly when the process exited (the zombie fix proven live), job dir + pid file created under the workspace, agent completed the mission reporting JOB-OK. A second run confirmed the agent-side redirect pattern (job writes its own output file in the workspace, read_file picks it up).
  • fmt + clippy -D warnings clean; full workspace tests green.

Closes #59, closes #56

Formalize the nohup-background + poll pattern agents improvise for
CPU-bound jobs exceeding the 30s run_command ceiling (issue #59):

- job_start (Write): argv-split like run_command (no shell; bash -c is
  the explicit shell escape), detached into its own process group,
  stdin null, stdout+stderr -> tole-jobs/<id>/log inside the file-tools
  workspace. Returns job id + pid immediately.
- job_poll (ReadOnly): liveness via 'ps -p <pid> -o stat=' treating
  zombie state (Z*) as finished, plus a bounded 8KiB-window tail of the
  log (stat -> seek -> read; lossy UTF-8 at the boundary). The full log
  stays reachable via read_file through the same jail.

Depends on the --workspace jail (#57, merged): logs live under the
file_root so read_file can reach them without workarounds.

Closes #59, closes #56 (option b: native shell job control)
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 4d4096f into develop Sep 12, 2026
13 checks passed
@ajianaz
ajianaz deleted the feat/long-running-jobs branch September 12, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant