arXiv:2608.23001cs.AIAug 2026

Manuscript Offprint

arXiv:2608.23001

PatchWrite: One Line, Not One Section -- Compile-Gated, Validity-Preserving Editing for AI-Drafted Manuscripts

Weiwei Yang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Automated manuscript pipelines often regenerate a whole section to fix a local defect, and the PDF still builds even though unrelated metrics and citations have quietly moved. PatchWrite instead applies one line-interval EDIT N M (span ≤ 40), committing only when pdflatex is clean and every \cite key and numeric token is attested in a registry or experimental log, and rolling back to the last compiling HEAD otherwise. On a 24-manuscript × 8-fault oracle stress test (768 jobs, split evenly between compile-breaking and content-only faults), whole-slot rewrite mutates an unrelated “12-layer” line in every single case (0/192 preserved, numeric Jaccard 0.6667), while PatchWrite preserves it 192/192 times. Disabling the compile gate drives the accept rate to 0; disabling the evidence gate lets a hallucinated citation through. The pattern holds uniformly across all eight faults. Because oracle repairs test the mechanism rather than generation quality, we reran the same 192 jobs with the writer model itself proposing the EDIT. It is accepted 75% of the time before a one-line prompt fix, and the shortfall traces almost entirely to one reproducible failure mode: the model tries to delete a line using an empty replacement, which the grammar rejects. Telling the model explicitly to comment out rather than empty the line raises acceptance to 100% and eliminates the fallback, though only 84.9% (down from 93.75%) of the now-accepted patches pass our strict fault-fixed check, since one fault class is resolved by commenting out the defect marker rather than removing it. Every accepted patch still clears both gates: no hallucinated citation and no unattested number gets through. The author and a second rater, both blind to condition, preferred PatchWrite on all sixteen PDF pairs sampled from the oracle corpus when the criterion is keeping lab-grounded facts intact (C1 Likert 5.0 vs. 2.0), and scored the prose nearly identically. Logs from 193 in-product drafting tasks show the same failure modes occurring in the wild.

Keywords automated scientific writing · LaTeX revision · compile gates · evidence locks · multi-agent systems

1 Introduction

Large language models can draft conference-shaped LATEX [Song et al., 2026, Schmidgall et al., 2025, Yamada et al., 2025]. A remaining failure is non-monotonic revision: a reviewer asks to fix one undefined citation; the agent rewrites Results; the PDF still builds; a lab-grounded number has moved. Dashboards that only plot compile rate will celebrate the new PDF. The unit of mutation was the section, not the line.

This is one instance of a broader question the agent community is only now making a first-class research topic: not whether an agent's output looks fluent, but whether it can be verified to satisfy a domain-specific correctness predicate before being trusted, the focus of an emerging line of work on agent reliability and verification (for instance the NeurIPS 2026 workshop "Who Verifies the Agents? Toward Reliable Agent Development," https://verify-agents-workshop.github.io/, non-archival at the time of writing). This paper grounds

A PREPRINT

that question in one narrow, high-stakes domain, LaTeX manuscript revision, where the correctness predicate is a compile gate plus an evidence lock rather than a hand-wavable quality score.

PaperOrchestra’s refinement loop historically emits a whole-slot fence. A slot is a named placeholder region of the venue template, for instance an entire Method or Results section, that the writer model regenerates in full each round rather than editing in place: compile failure is a continue, success replaces the whole slot [Song et al., 2026]. Agent Laboratory’s PaperSolver already uses EDIT N M with immediate pdflatex [Schmidgall et al., 2025], but on English ICLR-shaped shells (the outer document-class/template scaffold a paper is typeset into, as distinct from its content) and with LLM self-scores as quality. EasyPaper generates structured LATEX from metadata [EasyPaper, 2026] (software, not a peer-reviewed writing operator). We combine bounded interval editing, a compile gate that does not trust a nonstopmode PDF, cite/number locks, and PaperOrchestra’s venue shells into one invariant: the file on disk is always the last compiling, evidence-clean manuscript.

PatchWrite sits in the refinement loop (Figure 1). The proposer sees numbered source and emits one EDIT N M. The runtime commits a compiling, evidence-clean T′T' or returns T. Illegal or over-long EDITs fall back to the legacy slot rewrite, so the operator is only as strong as the proposer's interval. PatchWrite is deployed as the revision operator inside Solus (https://solus.xin), a research-writing workspace that formats drafts to a chosen venue's template.

We ask five questions:

  1. Does surgical EDIT keep unrelated tokens that slot rewrite mutates?

  2. Does the compile gate reject a bad patch rather than a nonstopmode PDF?

  3. Does the evidence gate catch a compiling patch that invents a cite key?

  4. When the writer model itself proposes the EDIT instead of an oracle, how often is it legal, does it pass the gates, and does the accepted patch actually fix the fault?

  5. When two readers compare the resulting PDFs, do they prefer the surgical draft if lab-grounded facts must not move?

Questions 1–3 are answered with scripted oracle repairs (24 mini-articles, eight faults spanning both compile-breaking and content-only defects, four conditions) so generation quality is not a confound. Question 4 is answered by rerunning the same 24×824 \times 8 corpus with the writer model (qwen3.7-plus) proposing the patch itself, single call per job, no oracle (Section 4.2); this is exactly the measurement Questions 1–3 deliberately deferred by isolating the mechanism. Question 5 is answered with a dual-pass rater annotation of sixteen held-out PDF pairs from the oracle corpus (Section 4.3). Product logs from 193 drafting tasks motivate the gates but are not a substitute for either pass.

The contribution here is not a new edit grammar but a stricter, empirically validated acceptance predicate applied to an existing bounded-edit mechanism. Contributions: (i) a compile gate that scans the pdflatex log for fatalities rather than trusting a nonstopmode PDF, applied to PaperSolver's EDIT N M and rollback-on-failure mechanism (tex_patch.py, ContentRefinementAgent); (ii) cite and numeric locks reused from PaperOrchestra, combined with (i) for the first time as a single acceptance criterion; (iii) an oracle stress protocol at 24×824 \times 8 scale plus two ablations isolating each gate's contribution, with table cells copied from evals/results/summary.json; (iv) a live-model companion at the same 24×824 \times 8 scale across two independent writer models (qwen3.7-plus, Kimi K2.6) measuring parse, compile, gate, and fault-fixed rates for each model's own EDIT proposals, including a one-line prompt fix that closes one model's fallback gap while surfacing a new fault-fixed trade-off, cells copied from evals/results/llm_edit_summary.json and evals/results_kimi/llm_edit_summary.json; (v) a sixteen-pair rater inspection with cells copied from raw_materials/human_eval.json.