# How to Start the ARS Pipeline at a Specific Stage: Integrity Checking and Mid-Stream Execution

> Start the ARS pipeline at a specific stage like integrity checking using the run_codex_audit sh script and the --stage flag. Learn mid-stream execution for your academic research skills.

- Repository: [Edward Cheng-I Wu/academic-research-skills](https://github.com/Imbad0202/academic-research-skills)
- Tags: how-to-guide
- Published: 2026-05-13

---

**To start the ARS pipeline at a specific stage like integrity checking, invoke the [`scripts/run_codex_audit.sh`](https://github.com/Imbad0202/academic-research-skills/blob/main/scripts/run_codex_audit.sh) wrapper with the `--stage` flag set to your destination stage, or use targeted slash-commands such as `ars-revision` or `ars-finalize` that map to specific pipeline modes.**

The **Academic Research Skills (ARS)** system in the `Imbad0202/academic-research-skills` repository is built as a **mode-registry-driven pipeline** that orchestrates ten logical stages, from deep research to final PDF generation. While the `ars-full` command runs all stages sequentially, the architecture provides specific hooks to start the pipeline mid-stream at integrity checkpoints or other stage boundaries.

## Understanding the ARS Pipeline Architecture

### The 10-Stage Orchestration Model

The orchestration logic lives in the **`academic-pipeline`** skill, which sequences agents across ten distinct stages. According to [`academic-pipeline/references/reproducibility_audit.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/references/reproducibility_audit.md), the pipeline includes dedicated **integrity checkpoints** at Stage 2.5 (pre-Review) and Stage 4.5 (pre-Finalize) that gate progress between major phases.

### Integrity Checkpoints as Entry Points

Unlike linear pipelines that require restart from Stage 1, ARS treats these checkpoints as valid entry points. The **integrity gate** validates deliverables before they transition into downstream stages such as Review or Finalize, making them ideal starting positions for resuming work or auditing existing drafts.

## Method 1: Using the Audit Wrapper to Start at a Specific Stage

The most flexible approach to start at integrity checking involves calling the underlying audit wrapper directly. The Bash script [`scripts/run_codex_audit.sh`](https://github.com/Imbad0202/academic-research-skills/blob/main/scripts/run_codex_audit.sh) implements the **audit gate** executed before stage transitions and accepts a mandatory `--stage <1-6>` flag indicating the *destination* stage your deliverable is about to enter.

For **pre-review integrity checking** (the gate between Stage 2 and Stage 3), you target destination Stage 3 by passing `--stage 2`:

```bash
./scripts/run_codex_audit.sh \
  --stage 2 \
  --agent synthesis_agent \
  --deliverable paper/draft.md \
  --round 1 \
  --target-rounds 3

```

This triggers the integrity verification before the **research → write** transition. The wrapper validates inputs, snapshots the artifact, runs the Codex audit, and emits a **verdict** and **proposal entry** that the orchestrator consumes. If the audit passes (no `AUDIT_FAILED` emission), the pipeline can continue to the next stage.

## Method 2: Invoking Mode-Specific Commands

Each slash-command in the `commands/` directory maps to an entry in [`MODE_REGISTRY.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/MODE_REGISTRY.md), providing thin wrappers around specific pipeline modes:

- **`ars-revision`** and **`ars-revision-coach`**: Run the revision part of the pipeline after the integrity checkpoint has passed ([`commands/ars-revision.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/commands/ars-revision.md))
- **`ars-finalize`**: Runs the pipeline from the final integrity gate (Stage 4.5) through PDF generation

These commands abstract the underlying audit calls but assume prerequisite stages have completed. Use them when the integrity checks have already been cleared, or combine them with Method 1 for precise control.

## Step-by-Step Workflow for Integrity Checking

To begin execution specifically at an integrity gate:

1. **Prepare your draft file** (the deliverable to audit) and ensure it meets the format requirements for the target stage.
2. **Run the audit wrapper** with the appropriate destination stage:
   - `--stage 2` for pre-review integrity (entering Stage 3)
   - `--stage 4` for final integrity before PDF generation (entering Stage 5)
3. **Inspect the audit verdict** located in the output directory; if `failure_reason` is present (`scripts/run_codex_audit.sh#L1065-L1070`), address the issues before retrying.
4. **Continue the pipeline** by invoking the next ARS command (e.g., `ars-review` after `--stage 2` succeeds, or `ars-finalize` after `--stage 4`).

## Understanding the Stage Flag Semantics

The `--stage` parameter specifies the **destination stage**—the stage the deliverable will enter after passing the gate—not the stage that just finished. As documented in [`docs/design/2026-04-30-ars-v3.6.7-step-6-orchestrator-hooks-spec.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/docs/design/2026-04-30-ars-v3.6.7-step-6-orchestrator-hooks-spec.md), the `audit_artifact.stage` field records where the deliverable is headed next.

This design makes it safe to resume at any checkpoint by indicating the *next* stage in your workflow. For example, to enter the Review phase (Stage 3), you specify `--stage 2` because you are crossing the gate *into* Stage 3.

```bash

# Final integrity check before PDF generation (entering Stage 5)

./scripts/run_codex_audit.sh \
  --stage 4 \
  --agent synthesis_agent \
  --deliverable paper/post-review.md \
  --round 1

# Continue to final output

ars-finalize --paper paper/post-review.md

```

## Summary

- **ARS uses a mode-registry architecture** with ten stages and integrity checkpoints at 2.5 and 4.5 that serve as valid pipeline entry points.
- **Use `scripts/run_codex_audit.sh --stage <n>`** to start at a specific gate, where `<n>` represents the destination stage you intend to enter (e.g., `--stage 2` for pre-review integrity).
- **Target specific modes** with slash-commands like `ars-revision` and `ars-finalize` when integrity checks are already satisfied.
- **The audit wrapper** handles artifact snapshots, validation, and verdict emission; pipeline continuation depends on the absence of `AUDIT_FAILED` in the output.

## Frequently Asked Questions

### Can I skip multiple stages and start at any arbitrary point in the pipeline?

No, you can only start at defined integrity checkpoints (Stage 2.5 and Stage 4.5) or stage boundaries that correspond to the `--stage` values accepted by [`run_codex_audit.sh`](https://github.com/Imbad0202/academic-research-skills/blob/main/run_codex_audit.sh). The script validates that your deliverable meets the input requirements for the destination stage, preventing jumps into incompatible workflow states.

### What happens if the integrity audit fails?

The pipeline halts immediately and emits a detailed `failure_reason` in the audit verdict (`scripts/run_codex_audit.sh#L1065-L1070`). You must address the cited issues in your draft and re-run the audit with the same `--stage` flag before proceeding to subsequent stages like Review or Finalize.

### How do I continue the pipeline after a successful integrity check?

Once the audit wrapper returns without emitting `AUDIT_FAILED`, invoke the corresponding mode-specific command for your target stage. After passing `--stage 2` (pre-review integrity), call `ars-review` to enter the Review phase; after `--stage 4` (final integrity), use `ars-finalize` to generate the PDF.

### What is the difference between the Stage 2 and Stage 4 integrity checks?

Stage 2 integrity (pre-review) validates the transition from research to writing, ensuring your draft meets structural and sourcing standards before entering the Review phase. Stage 4 integrity (pre-finalize) performs the final reproducibility audit before PDF generation, catching any lingering issues in the post-review manuscript according to the pipeline state machine defined in [`academic-pipeline/references/pipeline_state_machine.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/references/pipeline_state_machine.md).