You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #639, #727 (job persistence), and #729 (job ingestion). The relay can now recognize NIP-90 job request events and record them as submitted jobs, but nothing actually hands them off to a worker process yet.
This issue covers dispatch: pick up a pending job, spawn/communicate with its configured worker, wait for a result (with a timeout), update job state through its lifecycle, and publish the result back as a NIP-90 event.
Spawn/communicate with the worker process, extending the existing spawn()-based pattern in src/cli/utils/process.ts (timeout/kill/error-classification) rather than inventing a second spawn convention.
Frame messages to/from the worker as newline-delimited JSON over stdin/stdout no existing convention covers this (process.ts buffers all output into one string, which doesn't work for a long-lived worker handling multiple in-flight jobs), so this needs new code.
On timeout: mark the job timed_out via DvmJobRepository.updateStatus() and kill the worker process (soft Node-level guard — timeout + child.kill(), not full OS-level sandboxing; that's a stretch goal, not required for this).
On success: mark the job completed, publish a kind 6000-6999 job result event.
On worker error/crash: mark the job failed with an error message.
Tests for the dispatch flow: successful completion, timeout, worker crash, and the state transitions in each case.
Description
Follow-up to #639, #727 (job persistence), and #729 (job ingestion). The relay can now recognize NIP-90 job request events and record them as
submittedjobs, but nothing actually hands them off to a worker process yet.This issue covers dispatch: pick up a pending job, spawn/communicate with its configured worker, wait for a result (with a timeout), update job state through its lifecycle, and publish the result back as a NIP-90 event.
What needs to be done
submittedjobs (viaDvmJobRepository.findPendingJobs()) and assign them to a worke (DvmJobRepository.assignWorker(), already atomic/race-safe from feat(dvm): add dvm job persistence migration and repository #727).spawn()-based pattern insrc/cli/utils/process.ts(timeout/kill/error-classification) rather than inventing a second spawn convention.timed_outviaDvmJobRepository.updateStatus()and kill the worker process (soft Node-level guard — timeout +child.kill(), not full OS-level sandboxing; that's a stretch goal, not required for this).completed, publish a kind 6000-6999 job result event.failedwith an error message.