Skip to content

verify reports only the first LLV7005 of a run, and places language-1.2 ones at lexlean.toml:1:1 #377

Closed

Description

@afflom

Problem

The policy stage of lexlean verify stops at the first axiom-policy violation. A project with several wrong policies learns about them one verification at a time. Since a policy is exact and transitive (§17.12, §22.6), changing one helper's body commonly changes the policy of every caller, so several violations together is the usual case, and each extra round costs another verification.

Exact, transitive policies themselves are as specified and are not part of this report.

Reproduction

Run at pinned 3877351 (lexlean 0.4.0, language 1.2, Lean 4.32.1). origin/main and origin/release/v0.5 were read, not run: the same six LLV7005 sites in crates/lexlean/src/verify/mod.rs, each return Err(fail(...)).

\begin{lexlean}{M}
\useglossary{lexlean.std.nat@1.2.0}
\title{Natural number addition}
\begin{semanticmodule}
definition{
  name: first,
  parameters: [xs : (List String)],
  result: String,
  body: (prim join xs "," : String),
  executable: true
}

definition{
  name: second,
  parameters: [xs : (List String)],
  result: String,
  body: (prim join xs ";" : String),
  executable: true
}

definition{
  name: third,
  parameters: [b : Bytes],
  result: (Option String),
  body: (prim utf8_decode b : (Option String)),
  executable: true,
  axioms: [propext]
}
\end{semanticmodule}
\end{lexlean}

Observed, with all three wrong:

error[LLV7005]: `K1.M.first` violates its none axiom policy: observed [propext]
  --> lexlean.toml:1:1

--diagnostic-format json gives one entry in diagnostics.

Expected: one LLV7005 each for first, second and third, in canonical order. The audit has already produced every observed set by this stage (§22.1 stages 9-11), and limits.max_diagnostics (default 256) already bounds a failure's output. LLV7002 is reported through LexLeanError::from_diagnostics, which can carry several and sorts them canonically. §22.6 does not ask for a stop at the first violation.

Second observation: the location

The diagnostic above is placed at lexlean.toml:1:1, although the declaration has a source position, which LLV7002 for the same module does report (src/M.lex.tex). The language-1.0 fixture tests/negative/axiom-policy-excess has its primary in src/Main.lex.tex.

From reading the code on release/v0.5: only the first of the six sites (line 1984) calls with_span. The semantic site that fires here (line 2163) builds its Diagnostic with no span, and so do the other four. Separately, declaration_spans is frozen from document.declarations(), which walks the document's blocks, while the semantic site iterates semantic.declarations, so the map may also need entries for semantic declarations. That last point has not been confirmed.

Proposed fix

  • In stage 11 of verify, collect LLV7005 diagnostics across all six sites, and return them with LexLeanError::from_diagnostics once the stage has finished. Attestation is still written only if there are none. The internal "absent from the axiom audit" failures can stay immediate.
  • Freeze a source span for each semantic declaration alongside declaration_spans, and attach it with with_span at the semantic sites.

Accepted when

  • The module above reports all three violations in one run, in a stable order, in both human and JSON output.
  • Each language-1.2 violation has its primary in the declaration's source file.
  • A project with one violation produces the same result as today, other than the corrected location.
  • A register row and fixture cover this (R3).

Activity

  1. afflom commented on Nov 3, 2026

    @afflom
    MemberAuthor

    I am taking this bounded diagnostics fix on release/v0.4. I will preserve immediate internal/process failures, collect policy violations through the existing canonical diagnostic path and limits, and attach declaration source spans. This work will avoid the kernel/replay optimization in #391; the issue-closing PR will include focused regression evidence.

  2. added this to the LexLean v0.4.1 milestone on Nov 3, 2026
  3. afflom commented on Nov 3, 2026

    @afflom
    MemberAuthor

    Completed through merged PR #403 on release/v0.4, merge 5a44fe49e5d73569c3bb377bb28b56e463ee0547. The final reviewed head 215a9d591 passed all 43 jobs in CI 41658939956, plus honesty 41658939965 and reproducibility 41658939998. Actual merge tree 88d8b657f1ab621bf736b9d7e5d97fcb9c834e5e exactly equals the reviewed/tested head and synthetic merge tree. Explicitly closing this issue because the landing is on a non-default release branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions