Skip to content

Add a production partiality audit with justified exceptions #11

Closed

Description

@jonaprieto

Context

The ecosystem prefers total production Lean code, but a blanket ban on partial definitions is not appropriate. Pure public semantics should normally be total; terminal loops, process polling, task coordination, and other externally driven code may legitimately need operational partiality.

The current pre-commit package has no audit for this distinction.

Scope

  • Add a dedicated audit hook, or a clearly named extension to an existing Lean hook, that reports partial definitions in configured production targets.
  • Report source path and line number for every occurrence.
  • Distinguish pure library code, operational IO code, tests, examples, benchmarks, and spike directories through configuration.
  • Require an explicit rationale for retained production partial definitions.
  • Do not fail merely because the keyword partial appears in a benchmark or an approved operational loop.
  • Decide whether partial_fixpoint and equivalent declarations are covered; document the decision.
  • Keep the hook independent of Mathlib.

Acceptance criteria

  • tests/self_check.py covers single-line, private, multiline, and nested partial declarations.
  • Pure production partiality can be made a CI failure where the repository opts into that policy.
  • Approved operational partiality is reported with its rationale rather than silently ignored.
  • Non-production exclusions are target-specific and documented.
  • README and consumer configuration examples are updated.
  • Existing style, module, and axiom hooks remain unchanged and green.

Activity

  1. added
    enhancement
    on Aug 7, 2026
  2. changed the title [-]Add a production no-partial audit hook[/-] [+]Add a production partiality audit with justified exceptions[/+] on Aug 8, 2026
  3. jonaprieto commented on Aug 8, 2026

    @jonaprieto
    OwnerAuthor

    Implemented in local signed commit 22c8fef on fix/partiality-audit: added the lean-partiality hook, explicit --allow-glob exceptions with nearby partiality: rationales, CLI entry point, and self-check coverage. PYTHONPATH=. python3 tests/self_check.py passes. The branch is not pushed yet.

  4. jonaprieto commented on Aug 8, 2026

    @jonaprieto
    OwnerAuthor

    Implementation status: local signed commit 22c8fef on fix/partiality-audit adds the lean-partiality hook, explicit --allow-glob exceptions with nearby partiality: rationales, the CLI entry point, and self-check coverage. PYTHONPATH=. python3 tests/self_check.py passes. Branch not pushed yet.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions