# What Happens in the FINALIZE Stage (Stage 5) of the ARS Pipeline?

> Discover the FINALIZE stage of the ARS pipeline. Learn how this critical step converts manuscripts to publication-ready formats, ensuring accuracy and preparing your work for diverse outputs like Markdown, DOCX, LaTeX, or PDF.

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

---

**The FINALIZE stage (Stage 5) converts the peer-reviewed manuscript into publication-ready formats through a strict quality gate that enforces citation provenance, validates required sections, and dispatches the `formatter_agent` to produce Markdown, DOCX, LaTeX, or PDF outputs.**

The FINALIZE stage represents the last decision-heavy checkpoint in the Academic Research Skills (ARS) pipeline maintained in the `Imbad0202/academic-research-skills` repository. At this stage, the completed manuscript undergoes format conversion, journal-specific adaptation, and a mandatory provenance audit before any files are emitted to the user.

## How the FINALIZE Stage Works in the ARS Pipeline

According to the pipeline definition in [`academic-pipeline/SKILL.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/SKILL.md), Stage 5 (labelled **S**) orchestrates the transition from a finalized draft to distributable artifacts. The stage is architected as a human-gate (🧑) in the system design, requiring explicit user confirmation before proceeding.

### User-Driven Format Selection

The orchestrator initiates Stage 5 by querying the user for the desired output format. Available options include:

- **Markdown** (default)
- **DOCX** (via Pandoc)
- **LaTeX** (APA 7.0 or journal-specific)
- **PDF** (compiled with tectonic)
- **Combination** of multiple formats

This selection determines the conversion path invoked by the `formatter_agent` in the subsequent steps.

### Dispatch to the formatter_agent

Once the user selects a format, the pipeline calls the `formatter_agent` (skill `academic-paper` operating in *format-convert* mode) as defined at lines 79-81 of [`academic-pipeline/SKILL.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/SKILL.md). This agent encapsulates all conversion logic, validation rules, and journal adaptation protocols required to produce publication-ready files.

## The formatter_agent Conversion Workflow

The `formatter_agent` executes a complete formatting workflow defined in [`academic-paper/agents/formatter_agent.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-paper/agents/formatter_agent.md). This workflow ensures that technical requirements, content integrity, and ethical standards are met before any output is generated.

### Confirming Output Requirements

The agent first confirms the specific output requirements and validates that all mandatory sections are present. Required elements include:

- **Abstract**
- **AI-disclosure statement**
- **Limitations section**
- **Complete bibliography**

If any required section is missing, the agent surfaces the deficiency to the user and refuses to proceed until the manuscript is repaired.

### Journal-Specific Adaptation

When a target journal is specified, the agent consults the journal submission guide and applies specific formatting rules:

1. Adjusts heading hierarchy and numbering
2. Converts reference style to match journal requirements (e.g., APA, Vancouver)
3. Adds required front-matter including cover letters, CRediT author contributions, funding statements, and conflict-of-interest (COI) declarations
4. Applies journal-specific LaTeX classes or DOCX templates

### The Cite-Time Provenance Hard Gate

Before emitting any final artifact, the `formatter_agent` executes the **Cite-Time Provenance Hard Gate** (versions 3.7.1 and 3.7.3). This critical safety mechanism scans the entire document for unresolved provenance markers:

- `[UNVERIFIED CITATION — NO ORIGINAL]`
- `<!--anchor:none:-->`

If any such markers are detected, the agent **refuses** to produce output and returns a hard error message indicating the specific locations requiring remediation. The user must acquire the original sources and set `source_acquired: true` before the FINALIZE stage can complete successfully.

### Final Quality Checklist Validation

The agent runs a comprehensive final quality checklist covering content integrity, format compliance, and required elements. All items must **PASS**; otherwise, the agent loops back to the user for repairs. Checklist items include verification of bibliography completeness, AI disclosure presence, and limitations statement inclusion.

## Output Package Creation and Stage Transition

Upon successful completion of all validations, the `formatter_agent` bundles the generated files into an **Output Package**. According to the specification in [`formatter_agent.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/formatter_agent.md) (lines 88-108), this package typically contains:

- [`paper.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/paper.md) (Markdown source)
- `paper.tex` (LaTeX source, if applicable)
- `paper.pdf` (compiled PDF)
- `paper.docx` (Word document, if requested)
- [`cover_letter.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/cover_letter.md) (journal-specific cover letter)
- Provenance summary and citation audit trail

After the orchestrator records the Stage 5 checkpoint and updates the state tracker, the system prompts the user to proceed to **Stage 6 (Process Summary)**. This transition is formally defined in the state machine at [`academic-pipeline/references/pipeline_state_machine.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/references/pipeline_state_machine.md).

## Code Examples: Running the FINALIZE Stage

### Example 1: Interactive Format Selection

```markdown
**Orchestrator:** You have completed Stage 4 (RE-REVISE).
Would you like to proceed to Stage 5 – FINALIZE? (yes/no)

**User:** yes

**Orchestrator:** Please choose an output format:
1. Markdown (default)
2. DOCX (via Pandoc)
3. LaTeX (APA 7.0)
4. PDF (compiled with tectonic)
5. All of the above

**User:** 4

**Orchestrator:** Generating PDF via LaTeX...
(Formatter agent runs its workflow, checks the final quality checklist, and compiles `paper.tex` with `tectonic`.)

**Formatter Agent:** ✅ All checks passed.
📦 Output Package:
- `paper.md` (Markdown)
- `paper.tex` (LaTeX source)
- `paper.pdf` (PDF)
- `cover_letter.md` (journal cover letter)
- `provenance_summary.json`

**Orchestrator:** FINALIZE completed. Ready for Stage 6 – PROCESS SUMMARY? (yes/no)

```

### Example 2: CLI Invocation with Journal Target

```bash

# Trigger format conversion with strict provenance checking

ars format-convert \
  --input draft.md \
  --output-format pdf \
  --target-journal "Nature" \
  --include-cover-letter \
  --strict-provenance

```

This command triggers the complete FINALIZE workflow:

1. Validates required sections and provenance markers
2. Converts Markdown → LaTeX → PDF using tectonic
3. Applies Nature journal template (heading style, reference formatting, COI block)
4. Returns the complete output package only if all gates pass

### Example 3: Handling Provenance Failure

```bash
ars format-convert --input draft.md --output-format docx

```

If [`draft.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/draft.md) contains `[UNVERIFIED CITATION — NO ORIGINAL]`, the formatter responds:

```text
❌ REFUSING OUTPUT
Unresolved provenance marker found in Section 3.2:
  [UNVERIFIED CITATION — NO ORIGINAL]
Remediation: acquire the original source and set `source_acquired: true`.

```

The pipeline returns control to the user at the FINALIZE checkpoint, preventing publication of unverified citations.

## Summary

- The **FINALIZE stage (Stage 5)** is the last quality checkpoint before publication, converting peer-reviewed drafts into distributable formats.
- The **`formatter_agent`** handles all format conversions (Markdown, DOCX, LaTeX, PDF) through a structured workflow defined in [`academic-paper/agents/formatter_agent.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-paper/agents/formatter_agent.md).
- A **Cite-Time Provenance Hard Gate** blocks output emission if unverified citation markers remain in the document.
- **Journal-specific adaptation** automatically adjusts reference styles, headings, and required front-matter when a target journal is specified.
- All items on the **Final Quality Checklist** must pass before the Output Package is created and the pipeline transitions to Stage 6 (Process Summary).

## Frequently Asked Questions

### What triggers the refusal to output files in the FINALIZE stage?

The `formatter_agent` refuses to generate output files if it detects unresolved provenance markers such as `[UNVERIFIED CITATION — NO ORIGINAL]` or `<!--anchor:none:-->` during the Cite-Time Provenance Hard Gate check. This enforcement ensures that all citations are properly sourced before publication, requiring the user to acquire original sources and update the manuscript metadata before retrying the FINALIZE stage.

### Which file defines the FINALIZE stage requirements and workflow?

The FINALIZE stage is defined in [`academic-pipeline/SKILL.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-pipeline/SKILL.md), which specifies the user format selection prompt, the hand-off to `formatter_agent`, and the transition logic to Stage 6. The detailed implementation of the formatting workflow, including the provenance gate and quality checklist, resides in [`academic-paper/agents/formatter_agent.md`](https://github.com/Imbad0202/academic-research-skills/blob/main/academic-paper/agents/formatter_agent.md).

### Can the FINALIZE stage produce multiple output formats simultaneously?

Yes. When the user selects option 5 ("All of the above") or specifies multiple formats in the configuration, the `formatter_agent` generates a complete Output Package containing Markdown source, LaTeX source, compiled PDF, DOCX (via Pandoc), and associated metadata files including the provenance summary and cover letter.

### What happens immediately after the FINALIZE stage completes successfully?

Upon successful completion, the orchestrator records the Stage 5 checkpoint in the state tracker and prompts the user to proceed to **Stage 6 (Process Summary)**. This optional final stage generates a retrospective analysis of the entire research workflow, including timing metrics, revision history, and lessons learned from the ARS pipeline execution.