BackgroundJobManagerInterface
Owns the lifecycle of {@see BackgroundJob}s a TUI runtime tracks (e.g. long-running commands surfaced in a job monitor panel). Every mutator here returns the job's new state rather than mutating in place, mirroring {@see BackgroundJob}'s own immutability; implementations MAY additionally publish a {@see \Milpa\Live\ValueObjects\Tui\TuiEvent} through a {@see TuiEventBusInterface} for each transition so a job-monitor node renderer can react without polling.
BackgroundJobManagerInterface::start()
abstract public function start(string $label, string $command = ''): Milpa\Live\ValueObjects\Tui\BackgroundJobStarts and registers a new job in `running` status.
Parameters
| Name | Type | Description |
|---|---|---|
| $label | string | |
| $command | string |
BackgroundJobManagerInterface::appendOutput()
abstract public function appendOutput(string $jobId, string $line, string $stream = 'stdout'): Milpa\Live\ValueObjects\Tui\BackgroundJobAppends one line of output to an existing job.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $line | string | |
| $stream | string |
Throws
\RuntimeException If `$jobId` is not a known job.
BackgroundJobManagerInterface::progress()
abstract public function progress(string $jobId, float $progress): Milpa\Live\ValueObjects\Tui\BackgroundJobUpdates an existing job's progress. Implementations MUST clamp `$progress` to the `[0.0, 1.0]` range.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $progress | float |
Throws
\RuntimeException If `$jobId` is not a known job.
BackgroundJobManagerInterface::finish()
abstract public function finish(string $jobId, int $exitCode = 0): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks an existing job `done` with the given exit code.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $exitCode | int |
Throws
\RuntimeException If `$jobId` is not a known job.
BackgroundJobManagerInterface::fail()
abstract public function fail(string $jobId, string $reason, int $exitCode = 1): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks an existing job `failed` with a reason and exit code.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string | |
| $reason | string | |
| $exitCode | int |
Throws
\RuntimeException If `$jobId` is not a known job.
BackgroundJobManagerInterface::cancel()
abstract public function cancel(string $jobId): Milpa\Live\ValueObjects\Tui\BackgroundJobMarks an existing job `canceled`.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string |
Throws
\RuntimeException If `$jobId` is not a known job.
BackgroundJobManagerInterface::get()
abstract public function get(string $jobId): ?Milpa\Live\ValueObjects\Tui\BackgroundJobThe job with this id, or null when it is unknown.
Parameters
| Name | Type | Description |
|---|---|---|
| $jobId | string |
Returns
`null` if `$jobId` is not a known job — unlike the mutators, this lookup does not throw.
BackgroundJobManagerInterface::all()
abstract public function all(): arrayAll tracked jobs, in registration order.