# Redo work through the line

When a station produced something wrong and you've fixed it, send the workpieces it finished back through it. For why, and the full procedure (baseline, unwind, compare), see [Fix the line, not the output](/docs/method/fix-the-line). This guide is the Assembly Line part.

## 1. Stop the factory session

A watched station picks up anything that lands in its `input/` within seconds, and other stations keep running on their schedules. Stop the session for that location while you work:

```bash
al-control procs stop -f .   # a session under pm2; in a terminal, stop npm start
```

Scheduled runs that come due meanwhile wait as `pending` and time out after 30 minutes. The schedules carry on when the session starts again.

## 2. Find the workpieces

```bash
al-control stations status IN2 -f .        # IN2's bins and the workpieces in each
al-control workpieces show inv-1001 -f .   # one workpiece: where it is, its journey
```

## 3. Put them back in the station's input

`done/` holds an untouched copy of what the station was given. Move that copy back to `input/`:

```bash
al-control workpieces requeue inv-1001 -f .         # a dry run: shows what would move
al-control workpieces requeue inv-1001 -f . --yes
```

`requeue` takes one workpiece by id from a `done` or `failed` bin. It adds a `requeued` event to the workpiece's `log.jsonl`.

A workpiece that went through several stations is in each station's `done/`, and `requeue` refuses an id it finds in more than one bin. Move that copy yourself:

```bash
mv temp/stations/IN2/done/inv-1001 temp/stations/IN2/input/
```

You don't need to remove the old copy in `IN2/output/`: the station replaces it when it finishes the workpiece again.

## 4. Run the fix dry

If the station has a dry-run setting in its config, turn it on for one run and run the station on your machine first:

```bash
npx factory stations run IN2 --set dry_run=true
```

Compare what it would send with the records you saved before unwinding anything.

## 5. Let the line run

Start the session again, and run the fixed station:

```bash
al-control procs start -f .   # or npm start
al-orc stations run IN2
```

Stations after it pick the work up on their own triggers. Follow a workpiece with `al-control workpieces watch inv-1001 -f .`.

## Keep the done bins you may need

`al-control workpieces clear` deletes workpieces from `done` bins, and a redo starts from `done`. List the bins you want to keep in the factory's entry in `~/.al/al-control/config.yml`, and `clear` skips them:

```yaml
hosts:
  local:
    factories:
      factory-acme:
        path: ~/factories/factory-acme
        keep: [IN2/done]
```

The commands are in the [al-control README](https://github.com/assemblyline-sh/al-control#commands).
