Source-linked AI summary

Certified Panic Mode: Repair-Invariant Error Recovery for Maximal-Munch Lexing

Nicklas Nidhögg

arXiv:2609.10600v2cs.PL

TL;DR

Classical panic-mode recovery promises progress but no repair-universal token-boundary guarantee for its resume position. This paper uses static certificates to define recovery points that remain token boundaries across evidence-reaching prefix repairs. In the reported results, the two repair readings coincide for 40,450 of 43,736 answers (92.5%).

  • Problem

    Classical panic-mode recovery promises progress and, when a synchronizer is found, membership in its designated set, but not a repair-universal boundary guarantee.

    Source: §1 · p. 1
  • Method

    The paper defines a sound recovery point as one where every prefix repair whose scan commits through certificate evidence places a token boundary there.

    Source: §1 · p. 2, §8 · p. 23
  • Results

    40,450 of 43,736 answers (92.5%) had equal repair readings; on the generated JSON row, newline-past’s mean absolute overshoot was about seven times certified recovery’s.

    Source: §8 · p. 24
  • Takeaways & Limitations

    The procedure ships with its contract documented, and the conclusion bounds its claims by where the searched certificates end.

    Source: §8 · pp. 23–24

    The guarantee is relative to the active mode’s automaton and does not cover modal repairs.

    Source: §3 · p. 5

Abstract

from arXiv · show

Classical panic-mode recovery skips a failed scan forward by convention: it promises progress, and membership in a designated set where one is found, but no repair-universal boundary guarantee for the position it lands on. This paper chooses the resume position by theorem: a position is a sound recovery point when every prefix repair whose scan commits through the certificate's returned evidence places a token boundary there, complete repairs the special case, by a committed-prefix lemma over certificates posted for a different purpose (arXiv:2608.03473, arXiv:2608.09761). The quantifier is strictly the stronger one, and a dichotomy locates the difference exactly: the inclusion is strict precisely when no repair completes while some scan still commits through the evidence, a two-token witness realizing the case. The evidence-returning form pairs each answer with the interval it rests on, which is what makes the guarantee deployable: a caller who knows what the scanner cannot check decides whether the certified boundary transfers to the clean input it intended. The search is one forward walk in evidence order and provably terminates; the guarantee is per-automaton, relative to the active mode. The procedure ships in the munch lexing library, and a deterministic corruption study measures its recovery quality beside the classical skip-one and delimiter conventions. Every certified answer whose evidence survives the damage passes its executable landing check on every recovery move, 40,885 of 40,885; among first answers, the 5,595 resting on evidence the damage reached land 1,589 times, reported and never asserted. On 13,522 of the 16,808 trials the shipped repair routine labels beyond repair, the resumed suffix tokenizes whole and the two quantifiers provably coincide, so both are empty there if those negative labels are exact; 3,286 stay undetermined.

1 Introduction

Classical panic-mode recovery chooses a resume position by convention, without guaranteeing that it is a token boundary across repairs. This paper defines repair-invariant recovery points using certificates and evaluates their recovery quality beside conventional approaches.

1 Introduction

  • Certified recovery replaces convention-based skipping with positions where every prefix repair committing through the certificate’s evidence has a token boundary.Complete repairs are the special case; classical panic mode promises progress and, when found, membership in a designated set, but not a repair-universal boundary guarantee.Source: §1 · pp. 1–2
  • Repair invariance addresses three failed alternatives: standalone suffix tokenizability, suffix-only window reasoning, and guarantees about tokens committed before failure.The definition quantifies over repaired inputs, anchors certificate evidence in the unmodified region, and concerns continuation past the failure.Source: §1 · p. 2
  • The recovery contract reuses posted certificates rather than constructing new ones, with byte and window guarantees subject to their respective anchor conditions.A progress lemma ensures termination; mode-driven guarantees are relative to the active automaton.Source: §1 · p. 2
  • The deterministic corruption study checks theorem-predicted boundaries whenever damage spares their evidence and compares recovery quality with skip-one and delimiter conventions.Its pristine corpus supplies the repair for the landing check; a complete-repair decider is included as a different-property comparator.Source: §1 · p. 2
  • The paper separates repair completion, boundary guarantees across evidence-reaching repairs, and evidence survival under measured damage.Its logical chain includes a collapse proposition and dichotomy, an overhang lemma, and measurements of availability, coverage, and displacement.Source: §1 · pp. 2–3

2 Preliminaries

The paper restates the companions’ maximal-munch automaton model and defines the byte and window certificates used in its recovery results. These are static, automaton-relative certificates, with window results limited to flat token sets with non-nullable patterns.

2 Preliminaries

  • Maximal-munch scanning emits the last accepting token and restarts there; con(x) is the final committed offset, and complete tokenizability means con(x) = |x|.A failed scan’s failure offset is its final committed offset, not necessarily the read head where transitions stop.Source: §2 · p. 3
  • A certified byte begins a token at every occurrence in every completely tokenizable input, while a certified window’s origin marks the token covering its final byte.Window certificates apply to non-nullable flat token sets; the shipped recovery walk searches window lengths two to four.Source: §2 · p. 3
  • Both certificate kinds are static and relative to one automaton; byte results have no flat-token-set restriction, unlike window results.The useful certified bytes reported by the library require a live initial-state transition.Source: §2 · p. 3

3 Repair-invariant resynchronization

The section defines recovery-point soundness over every prefix repair whose scan commits through the certificate’s evidence, then derives the guarantee from existing byte and window certificates. It distinguishes this stronger quantifier from complete repairs and states the conditions and scope of the resulting guarantees.

3 Repair-invariant resynchronization

  • The byte and window theorems bind repairs that commit through their evidence, a condition weaker than requiring the entire repaired input to tokenize.This avoids making the guarantee vacuous merely because an unsalvageable tail follows ordinary committed text.Source: §3 · p. 4
  • The committed-prefix lemma lets certificates for completely tokenizable inputs apply to a failed scan: its committed prefix is completely tokenizable with the same segmentation.An evidence-reaching repair need only commit through the evidence; it may fail later.Source: §3 · p. 4
  • Certified bytes and windows place a committed token boundary at their certified position or origin in every repair whose scan commits through the evidence.The window result is scoped to flat token sets with non-nullable patterns.Source: §3 · pp. 4–5
  • A recovery driver terminates after at most |x| advancing iterations because each search starts one position beyond the failure offset.Starting one past the failure offset avoids returning the same certified byte indefinitely.Source: §3 · p. 5
  • The guarantee is relative to the active mode’s automaton and does not extend to repairs or resumed text scanned under another mode.The paper does not establish a guarantee over modal repairs.Source: §3 · p. 5
  • If a complete repair exists, the resumed suffix tokenizes completely and the evidence-reaching and complete-repair quantifiers coincide.Conversely, a surviving answer whose resumed suffix tokenizes completely also forces the quantifiers to coincide.Source: §3 · p. 6
  • Complete repairs are a special case; the stronger guarantee differs exactly when no repair completes but at least one repair commits through the evidence.The text gives a witness over {ab, ;} where the identity repair reaches the certified semicolon although no repair can tokenize the trailing #.Source: §3 · pp. 5–6

3.1 Non-claims

  • The results cover prefix repairs only; for windows, the anchor must be at or before the occurrence, and guarantees may be vacuous when no repair reaches the evidence.The driver promises termination, not recovery, when the resumed suffix cannot be saved to the end of input.Source: §3.1 · p. 7

4 The search

The search walks forward through byte and window certificates and returns the first one in evidence order, resuming at its certified position. Its soundness follows from the certificate theorems, and the search’s starting offset ensures progress.

4 The search

  • The walk returns the first certificate in evidence order, resuming at a byte’s position or at a window’s occurrence plus origin.At one position it checks the byte first, then windows by increasing length.Source: §4 · p. 7, Figure 1 · p. 8
  • Any returned answer is repair-invariant for repairs whose scans commit through its reported evidence, with an anchor no later than the search offset.The reported evidence lies wholly at or after the search offset.Source: §4 · p. 7
  • In the library fixture, the window "def " at offset 6 with origin 3 yields answer 9, the whitespace byte that begins a token.Returning the occurrence instead of occurrence plus origin would resume at an uncertified position.Source: §4 · p. 8

5 Implementation

The implementation separates certificate search from driver recovery: the lexer reports certified positions and evidence, while the tokenizer chooses how to respond to failure. Tests pin the layers and check certified landings against the pristine repair.

5 Implementation

  • The lexer exposes position-only and evidence-returning searches, while the tokenizer’s recover() asks the active mode’s lexer for the first certified start one byte past failure.When no certificate is found, the position does not move and refusal is explicit.Source: §5 · pp. 8–9
  • Fail-closed fixtures test both certificate kinds, nullable-mode behavior, refusal, skip counts, window origins, and active-mode isolation.A mutant that resumed at a window occurrence rather than its certified origin is caught by a named fixture.Source: §5 · p. 9
  • Every trial whose answer’s evidence survives in the preserved suffix passes the executable landing assertion against the repair supplied by the pristine corpus.The check is applied to every such answer in the campaign.Source: §5 · p. 9

6 Evaluation

The evaluation examines certified recovery alongside classical conventions and an anchored decider through deterministic corruption experiments, assessing boundary behavior, answer minimality, and factors shaping measured quality and guarantee scope. Results span six rows over five grammars using synthetic damage and one real-world document, with bounded checks and substantial limits on external validity.

  • The deterministic campaign draws 81,000 damages across six rows and eleven arms; 43,736 scans fail, and the procedure continues each incident until completion, refusal, or 100 attempts.The campaign uses three damage operations at k ∈ {1, 4, 16}, with three fixed seeds and 500 trials per cell.Source: §6 · pp. 9–10
  • All 40,885 evidence-covered recovery moves land on mapped pristine boundaries; 5,595 first answers with evidence before the corruption end land 1,589 times, reported but never asserted.The covered moves include 38,141 first-answer checks; Proposition 2 supports transfer only when the evidence begins at or after the corruption end.Source: §6 · pp. 11, 14, Table 2 · p. 13
  • Fresh-restart token-filtered newline lands 97.1% pooled versus certified recovery’s 90.8%, but lacks a repair-universal guarantee and has median convergence 26 bytes versus 10.The token-filtered method’s 97.1% pooled landing rate exceeds certified recovery’s 90.8%; its median convergence distance is more than twice as large.Source: §6 · p. 14
  • In the bare C-like row, 2,213 of 2,408 byte-evidence answers are uncovered and none land, while all 4,387 covered answers pass the asserted check.This is an observed within-row association, not a randomized comparison; the overhang law states that evidence is covered exactly when evidence travel is at least overhang minus one.Source: §6 · p. 14
  • On twitter.json, newline-past lands 0.01% versus newline-at’s 96.9%, while token-newline lands 97.0%; generated-row placement changes can reverse the raw delimiter result.The token-filtered form lands 93.7–98.0% on every generated row, but its semicolon variant returns nothing on the real document.Source: Figure 3 · p. 15, §6 · p. 16
  • At 40,450 of 43,736 blind anchors the two quantifiers coincide; under negative-label exactness, both are empty at 13,522 anchors, leaving 3,286 undetermined.Equality also holds on all 26,928 routine-labeled-repairable trials without that assumption; the remaining 3,286 are the only cases left undetermined in content under it.Source: Table 1 · p. 12, §6 · pp. 16–17
  • The anchored decider lands 89.8% pooled versus the walk’s 90.8%, winning the bare row 89.1% to 60.5% but losing the conventional row 54.3% to 96.7%.With the oracle floor, both methods land on every trial; the decider’s documented predicate is complete-repair invariance, unlike the walk’s evidence-reaching guarantee.Source: §6 · pp. 15–18

6 Evaluation

  • Skip-one converged at a 2-byte median and lost 0.90 boundaries per error, while certified recovery converged at a 10-byte pooled median and lost 6.85 boundaries per error.Certified medians were 2 bytes on the bare row and 6 on generated JSON; newline conventions lost 8.01 past and 7.42 retained boundaries per error at 24–26 bytes, while semicolon forms lost 24.4 past, 23.4 retained, and 24.5 token-filtered at about 60 bytes. Skip-one required 10.9 attempts per incident and had 0.9 spurious starts per error; the token-filtered semicolon form refused every real-document incident because its candidate delimiter was inside a string token. Convergence compares resumed boundary streams, including dropped tokens.Source: §6 · p. 18, Table 4 · p. 20
  • 90 of 43,736 certified first answers were nonminimal, with a total excess of 90 bytes, one byte per answer.The evidence-order walk returns the first certificate in evidence order rather than the smallest answerable position; the measured cost was described as negligible on these rows.Source: §6 · pp. 18–19
  • The independent reference model matched the shipped scan on 7.6 million strings with zero disagreements, and bounded sweeps found no violations across the reported soundness, collapse, anchored-decider, and pristine-transfer checks.The checks included 46,035,590 walk (answer, repair) pairs, 836,387 collapse-proposition answers, 4,712,940 (answer, completing repair) pairs, and 1,068,953 covered pristine-transfer answers; 95,836 negative labels were not refuted by repairs up to length four. These are bounded evidence, not proof, and the tested literal-token universe excludes regex structure and priority ties.Source: §6 · p. 19
  • Quality figures cover six rows over five grammars and do not generalize beyond them; the damage model is synthetic, and real edit traces and throughput were not studied.The anchored procedure’s per-move cost was not compared with the walk’s single forward scan; its worst-case advancing procedure is cubic, with jump-table construction reaching quadratic in the tail. Campaign automata were non-nullable, and repairability labels and decider refusals rely on assumed anchored-routine contracts; shared scenario machinery makes agreement consistency rather than independent confirmation. The convergence metric credits agreement rather than non-triviality, and the searched certificates do not claim to discover every sound position.Source: §6 · p. 19

7 Related work

Prior recovery methods select or validate repairs, delimiters, or decoder states, but do not guarantee that a fixed resume position is a boundary across every evidence-reaching repair. This paper frames repair invariance as that scoped guarantee and contrasts it with those approaches.

Classical and interactive recovery

  • Classical panic mode guarantees termination and, where a synchronizer is found, membership in its designated set, but not a repair-universal boundary at the landed position [3, pp. 88, 164–165].The certificates add a theorem about the position landed on, ranging over repairs.Source: §7 · p. 21
  • Boullier and Jourdan’s two-level scheme validates local corrections through analyser acceptance, then falls back to a key terminal or offending-character deletion, without a repair-universal resume-boundary guarantee.Its acceptance conditions apply per correction rather than across all evidence-reaching repairs.Source: §7 · p. 21

Repair selection and minimum distance

  • Repair-based recovery validates selected fixes by parse-ahead, while minimum-distance methods select minimum-error repairs; neither asks whether every evidence-reaching repair agrees on a resume boundary,,.CPCT+ reports complete minimum-cost repair sequences and repairs 98.4% of 200,000 real invalid Java programs within a half-second timeout each, but its quantification remains over repairs to select.Source: §7 · pp. 21–22

Incremental lexing and coding theory

  • Incremental lexers seek batch or sequential agreement for incorporated text, whereas repair invariance concerns a boundary shared by repairs of an unrepaired prefix,.Synchronizing words instead realign decoders at intact occurrences; maximal-munch tokens can prefix one another and require lookahead and rollback, so the models do not transfer directly, [15].Source: §7 · p. 22

Classical and interactive recovery

  • Tree-sitter targets useful parsing amid syntax errors using error and missing nodes, while asserting no soundness property for the re-anchoring position.The paper presents repair invariance as a more precise target for that position.Source: §7 · p. 22

Repair invariance and comparison axes

  • Repair invariance guarantees that every prefix repair whose scan commits through the returned evidence places a token boundary at the fixed resume position.The guarantee is narrower than a correct-continuation claim and applies to repairs reaching the stated evidence.Source: §7 · p. 23

Comparison across approaches

  • Synchronizing words concern decoder states, while the certificates quantify over repairs of a broken prefix; Table 5 compares their search targets, guarantee scope, and behavior when nothing is found.The certificate row is the only one whose guarantee ranges over repairs and whose forward search may refuse rather than consume to the end.Source: §7 · p. 22, Table 5 · p. 23

8 Conclusion

The conclusion presents certified recovery as a theorem-backed alternative to delimiter conventions, with executable landing checks passed by every evidence-covered answer. The measured repair readings coincide on most answers, while sparse certificates still lead to refusal rather than a guess.

Conclusion

  • 40,885 of 40,885 evidence-covered answers passed their executable landing check on every recovery move; 90.8% of first answers landed.The anchored complete-repair decider won the bare row and lost the conventional row, while both oracle-floored arms held their contractual 100 percent.Source: §8 · p. 23
  • 40,450 of 43,736 answers had provably equal repair readings (92.5%); 26,928 were supported by an exhibited completing repair and 13,522 by a whole resumed suffix.Assumption 1 is needed to read the latter group’s coincident sets as empty; 3,286 answers remain candidates for strict inclusion.Source: §8 · p. 24
  • On generated JSON, newline-past’s mean absolute overshoot was about seven times certified recovery’s; where certificates are sparse, the procedure refuses rather than guesses.The conclusion states that claims end where the certificates end.Source: §8 · p. 24
Loading 2609.10600v2…