Imported from GitHub samson-media/barn#32 — opened by @daniel-samson on 2026-01-22 10:36:13 UTC
Overview
Allow jobs to declare dependencies on other jobs. A dependent job stays queued until its parent job reaches succeeded state. If the parent fails or is killed, the dependent job transitions to a new skipped state.
Proposed CLI
# Create a pipeline: download → transcode → uploadJOB1=$(barn run --output=json -- curl -o input.mkv $URL| jq -r .id)JOB2=$(barn run --output=json --depends-on=$JOB1 -- ffmpeg -i input.mkv output.mp4 | jq -r .id)JOB3=$(barn run --output=json --depends-on=$JOB2 -- rclone copy output.mp4 remote:)# All three jobs are created immediately, but:# - JOB1 starts right away# - JOB2 waits for JOB1 to succeed# - JOB3 waits for JOB2 to succeed
New skipped State
A new terminal state for jobs that were never executed because their dependency failed.
State
Meaning
skipped
Job was not executed because a dependency failed, was killed, or was skipped
This is distinct from:
failed - job ran and exited with non-zero code
canceled - job was canceled by user before running
<!-- github-import:issue:32 -->
_Imported from GitHub samson-media/barn#32 — opened by **@daniel-samson** on 2026-01-22 10:36:13 UTC_
## Overview
Allow jobs to declare dependencies on other jobs. A dependent job stays `queued` until its parent job reaches `succeeded` state. If the parent fails or is killed, the dependent job transitions to a new `skipped` state.
## Proposed CLI
```bash
# Create a pipeline: download → transcode → upload
JOB1=$(barn run --output=json -- curl -o input.mkv $URL | jq -r .id)
JOB2=$(barn run --output=json --depends-on=$JOB1 -- ffmpeg -i input.mkv output.mp4 | jq -r .id)
JOB3=$(barn run --output=json --depends-on=$JOB2 -- rclone copy output.mp4 remote:)
# All three jobs are created immediately, but:
# - JOB1 starts right away
# - JOB2 waits for JOB1 to succeed
# - JOB3 waits for JOB2 to succeed
```
## New `skipped` State
A new terminal state for jobs that were never executed because their dependency failed.
| State | Meaning |
|-------|---------|
| `skipped` | Job was not executed because a dependency failed, was killed, or was skipped |
This is distinct from:
- `failed` - job ran and exited with non-zero code
- `canceled` - job was canceled by user before running
- `killed` - job was killed by user while running
### State Transitions
```
queued ──dependency succeeds──► queued (ready to run)
queued ──dependency fails────► skipped
queued ──dependency killed───► skipped
queued ──dependency skipped──► skipped (cascades)
```
## Behavior
| Parent State | Dependent Job Action |
|--------------|---------------------|
| `queued` | Stay `queued` (waiting) |
| `running` | Stay `queued` (waiting) |
| `succeeded` | Transition to `queued` (ready to run) |
| `failed` | Transition to `skipped` with error "Dependency failed: {parent-id}" |
| `killed` | Transition to `skipped` with error "Dependency killed: {parent-id}" |
| `skipped` | Transition to `skipped` with error "Dependency skipped: {parent-id}" |
| `canceled` | Transition to `skipped` with error "Dependency canceled: {parent-id}" |
## CLI Options
```bash
barn run --depends-on=<job-id> -- <command>
```
- Job is created with `queued` state but won't be scheduled until dependency succeeds
- Multiple dependencies supported: `--depends-on=job1,job2` (all must succeed)
## Implementation Notes
### JobState Changes
Add new state to `JobState` enum:
```java
public enum JobState {
QUEUED,
RUNNING,
SUCCEEDED,
FAILED,
KILLED,
CANCELED,
SKIPPED // new
}
```
### Manifest Changes
Add optional `dependsOn` field to `JobManifest`:
```java
public record JobManifest(
// ... existing fields
List<String> dependsOn // new: list of job IDs this job depends on
) { }
```
### Scheduler Changes
In `JobScheduler.findNextQueued()`:
1. Filter out jobs whose dependencies haven't succeeded
2. Check each dependency's state
3. If any dependency is in a terminal non-success state, mark the dependent job as `skipped`
### Status Output
Show dependency info in `barn describe`:
```json
{
"id": "job-bbb",
"state": "queued",
"dependsOn": ["job-aaa"],
"dependencyStatus": "waiting"
}
```
When skipped:
```json
{
"id": "job-bbb",
"state": "skipped",
"dependsOn": ["job-aaa"],
"error": "Dependency failed: job-aaa"
}
```
### Status Command
Update `barn status` to show skipped jobs:
```
ID STATE TAG CREATED EXIT
job-aaa failed download 2026-01-22 10:00:00 1
job-bbb skipped transcode 2026-01-22 10:00:01 -
job-ccc skipped upload 2026-01-22 10:00:02 -
Total: 3 jobs (1 failed, 2 skipped)
```
## Example Use Cases
**1. Download → Transcode → Upload Pipeline**
```bash
#!/bin/bash
DL=$(barn run --output=json -- curl -o input.mkv "$URL" | jq -r .id)
TX=$(barn run --output=json --depends-on=$DL -- ffmpeg -i input.mkv out.mp4 | jq -r .id)
UP=$(barn run --output=json --depends-on=$TX -- rclone copy out.mp4 remote:)
echo "Pipeline created: $DL → $TX → $UP"
barn status
```
If download fails:
```
job-aaa failed - download failed
job-bbb skipped - Dependency failed: job-aaa
job-ccc skipped - Dependency skipped: job-bbb
```
**2. Parallel transcodes, then merge**
```bash
T1=$(barn run --output=json -- ffmpeg -i in.mkv -ss 0 -t 300 part1.mp4 | jq -r .id)
T2=$(barn run --output=json -- ffmpeg -i in.mkv -ss 300 -t 300 part2.mp4 | jq -r .id)
MERGE=$(barn run --depends-on=$T1,$T2 -- ffmpeg -f concat -i list.txt output.mp4)
```
If either T1 or T2 fails, MERGE is skipped.
## Related
- #31 (Status event hooks) - `--on-skipped` hook could be added for this state
## Acceptance Criteria
- [ ] New `skipped` state added to JobState enum
- [ ] `--depends-on=<job-id>` creates a dependent job
- [ ] Dependent job stays `queued` until parent succeeds
- [ ] Dependent job becomes `skipped` if parent fails, is killed, canceled, or skipped
- [ ] Skipped state cascades to downstream dependencies
- [ ] Multiple dependencies supported (`--depends-on=id1,id2`)
- [ ] Dependency info shown in `barn describe`
- [ ] Circular dependencies detected and rejected
- [ ] `barn status` shows skipped count in summary
- [ ] Works on Windows, macOS, and Linux
- [ ] Documentation updated
- [ ] `mvn verify` passes
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Imported from GitHub samson-media/barn#32 — opened by @daniel-samson on 2026-01-22 10:36:13 UTC
Overview
Allow jobs to declare dependencies on other jobs. A dependent job stays
queueduntil its parent job reachessucceededstate. If the parent fails or is killed, the dependent job transitions to a newskippedstate.Proposed CLI
New
skippedStateA new terminal state for jobs that were never executed because their dependency failed.
skippedThis is distinct from:
failed- job ran and exited with non-zero codecanceled- job was canceled by user before runningkilled- job was killed by user while runningState Transitions
Behavior
queuedqueued(waiting)runningqueued(waiting)succeededqueued(ready to run)failedskippedwith error "Dependency failed: {parent-id}"killedskippedwith error "Dependency killed: {parent-id}"skippedskippedwith error "Dependency skipped: {parent-id}"canceledskippedwith error "Dependency canceled: {parent-id}"CLI Options
queuedstate but won't be scheduled until dependency succeeds--depends-on=job1,job2(all must succeed)Implementation Notes
JobState Changes
Add new state to
JobStateenum:Manifest Changes
Add optional
dependsOnfield toJobManifest:Scheduler Changes
In
JobScheduler.findNextQueued():skippedStatus Output
Show dependency info in
barn describe:When skipped:
Status Command
Update
barn statusto show skipped jobs:Example Use Cases
1. Download → Transcode → Upload Pipeline
If download fails:
2. Parallel transcodes, then merge
If either T1 or T2 fails, MERGE is skipped.
Related
--on-skippedhook could be added for this stateAcceptance Criteria
skippedstate added to JobState enum--depends-on=<job-id>creates a dependent jobqueueduntil parent succeedsskippedif parent fails, is killed, canceled, or skipped--depends-on=id1,id2)barn describebarn statusshows skipped count in summarymvn verifypasses