Skip to content

Fix/idris2 totality and elaboration cures - #217

Merged
hyperpolymath merged 15 commits into
mainfrom
fix/idris2-totality-and-elaboration-cures
Sep 17, 2026
Merged

hyperpolymath merged 15 commits into
mainfrom
fix/idris2-totality-and-elaboration-cures

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Closes #

Type of change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (would change existing behaviour)
  • 🕳️ Soundness fix (fixes a checker/proof false-negative)
  • 📖 Documentation
  • 🧹 Refactor / tech debt (behaviour-preserving)
  • ⚡ Performance
  • 🔧 Build / CI / tooling

How has this been verified?

Checklist

  • My commits are signed (git commit -S).
  • I ran the project's own checks/tests locally and they pass.
  • New files carry the correct SPDX-License-Identifier (code/config MPL-2.0,
    prose CC-BY-SA-4.0); I did not relicense existing files.
  • Docs are updated, and no public claim now overstates what the code does.
  • I have not introduced a soundness hole (or I have flagged where I might have).

Notes for reviewers

hyperpolymath and others added 13 commits July 26, 2026 14:51
Part of estate-wide standards#426 remediation - cleanup.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…e87a5923fdf329

Part of estate-wide standards#426 remediation - Batch 11 SHA update.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
…e87a5923fdf329

Part of estate-wide standards#426 remediation - Batch 13 SHA update.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Add security-events: write and id-token: write to workflow-level
permissions in scorecard.yml for scorecard-reusable.yml calls.
Ensure contents: read at workflow-level for secret-scanner.yml.

Part of hyperpolymath/standards#426 remediation - Batch 2.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Update reusable workflow SHA from d135b05 to f2f8e6791b09f1f498f01b798e4670a1ebc9c986
to pick up fixes for:
- Bug A: Invalid timeout-minutes at workflow_call level and duplicates
- Bug B: Permissions escalation in scorecard-reusable

Part of hyperpolymath/standards#426 remediation.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Final SHA update for Bug A and Bug B fixes.
Part of hyperpolymath/standards#426 remediation.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Before this branch, `idris2 --build proven.ipkg` was cancelled at CI's
45-minute timeout having produced no verdict at all: the build was VOID
(exit 2 semantics), not red and not green. It now answers RED in minutes
with named errors, and the module frontier has moved from 165/305 to
210/305.

Measured on Idris2 0.7.0. Source and CI target 0.8.0, so every frontier
figure here is a 0.7.0 reading, not a 0.8.0 one.

Seven files, each verified standalone with
`idris2 -p contrib --source-dir src --check <file>` returning rc=0:

  SafeOTP.idr            where-block ordering; recursion on a
                         non-inductive numeric type, restructured to
                         recurse structurally on a derived Nat bound
  SafeRedirect.idr       two where-local wrappers shadowing the Prelude
                         names they called; renamed the locals
  SafeCSP.idr            a where block attached to one clause of a
                         multi-clause function; hoisted to top level
  SafeCrypto/Proofs.idr  two proof bodies written in Lean 4 tactic
                         syntax; replaced with real Idris2 proofs
  SafeEmail/Proofs.idr   top-level forward reference; signature hoisted
  SafeUrl/Proofs.idr     Ord Nat's <= is not Data.Nat.lte -- the
                         hypothesis was restated over the relation the
                         stdlib lemma actually consumes
  SafeRegex/Parser.idr   see below

SafeRegex/Parser.idr carried five distinct defects and went from 39
reported errors to 0:

  1. 25 sites wrote `Char c` where the constructor is `SingleChar`.
     `Char` resolves to the builtin TYPE, so the compiler reports
     "Mismatch between: Type and Char -> CharClass" and never
     "Undefined name". `SingleChar` is used correctly in Types.idr,
     Safety.idr, Proofs.idr and SafeArgs/Proofs.idr -- this file is the
     only one the rename never reached.
  2. An eta/arity bug: `map Match (parseCharClass st)` applied the
     parser before passing it to the file's own local `map`.
  3. `many` and `parseClassContents` recursed with no decreasing
     measure. Both now derive a fuel bound from `length st.input`
     internally, so their public signatures are unchanged.
  4. The six-member mutual block recursed through a ParserState record
     Idris2 cannot measure. A Nat budget is now threaded through the
     group; the two public entry points seed it with
     `16 * length (unpack pattern) + 16`, a strict over-approximation.
     `parseSequence`'s where-block was hoisted to `parseSequenceGo`
     because a where attaches to one clause only.
  5. A let-bound record update could not infer its type. Idris2
     resolves record-update field names from the EXPECTED type
     downward; a bare `let` supplies none. Fixed with an annotation.

Discipline observed throughout:

  - Zero new trusted-base markers. The four marker tokens were counted
    in every touched file before and after each edit and every count is
    unchanged; SafeRegex/Parser.idr was and remains 0/0/0/0.
  - Five proof obligations genuinely discharged (modernIsSecure,
    standardIsSecure, errorMakesInvalid, warningKeepsValid,
    lteFrom65535Check), two of them in strictly stronger generalised
    form. No obligation was discharged by assertion.
  - No public signature changed. The entire SafeRegex mutual block is
    private; only parseRegex, parseRegexWithFlags, parseSafe and
    parseSafeStrict are public and none of their types moved.

IMPORTANT -- SafeRegex/Parser.idr was NOT in HEAD before this commit.
Commit f2833c2 ("feat: add ECHIDNA validation modules", 2026-01-29)
deleted 22 .idr files while claiming to add modules. Seventeen were
later restored and re-tracked. Five were restored to the working tree
but never re-added to git: SafeRegex/Matcher.idr,
SafeRegex/Parser.idr, SafeSQL/Builder.idr, SafeXML/Parser.idr and
SafeYAML/Parser.idr. This commit restores exactly one of them --
Parser.idr, the one it cures. The other four are left untouched and
filed as an issue.

Consequence, stated as a deduction and not yet measured: Parser.idr is
imported by Proven.FFI.SafeRegex, which IS listed in proven.ipkg, so a
clean checkout of the previous HEAD cannot have built that module. The
local frontier of 210/305 therefore depended on untracked files. This
should be confirmed by building a clean clone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…files

Preservation commit only — flushes the uncommitted postulate/totality
cures to the branch before they can be lost to a checkout or sweep.
Deliberately excludes the other ~169 working-tree changes: 72 .ts
binding files are pure-deletion blanking damage (do NOT commit them;
HEAD holds the real content) and the rest are of unaudited provenance.

See hyperpolymath/standards#705.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The rescript/deno/typescript blanking sweep excised its search terms as bare
substrings, including from inside longer words. Nine lines across four files
are restored from the merge-base blob.

The severe case is src/Proven/SafeDNS.idr, where `PureScript` contains the
substring `reScript` and was truncated to `Pu`:

    data PureScript : String -> Type where   ->  data Pu : String -> Type where

`PureScript` here is the Unicode sense - a string in a single script, guarding
`isMixedScript s = False` for homoglyph/IDN safety - and has nothing to do with
the language. The declaration, the constructor `MkPureScript` and the use site
in `MkIDNSafe` were all renamed consistently, so the code still compiled and no
gate could see it.

The other three files are doc comments comparing Idris2's type system to
ReScript's. They are restored verbatim rather than migrated to AffineScript:
they are statements about what ReScript cannot express, so rewriting the
language name would make them false.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Add Optimus-Branch.json for branch protection
- Add Immutable-Tags.json for tag protection
- Remove deprecated branches: from settings.yml
- Keep labels and repository metadata

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 14e4ec77-0024-4797-8d4a-0e9618521b78

📥 Commits

Reviewing files that changed from the base of the PR and between b30bdbf and b17e81f.

📒 Files selected for processing (86)
  • .github/rulesets/Immutable-Tags.json
  • .github/rulesets/Optimus-Branch.json
  • .github/settings.yml
  • src/Proven/FFI/SafeProbability.idr
  • src/Proven/SafeAPIKey/Proofs.idr
  • src/Proven/SafeArchive/Proofs.idr
  • src/Proven/SafeArgs.idr
  • src/Proven/SafeArgs/Parser.idr
  • src/Proven/SafeArgs/Proofs.idr
  • src/Proven/SafeBase64/Proofs.idr
  • src/Proven/SafeBloom/Proofs.idr
  • src/Proven/SafeCSP.idr
  • src/Proven/SafeCSRF/Proofs.idr
  • src/Proven/SafeCSV/Proofs.idr
  • src/Proven/SafeCalculator/Proofs.idr
  • src/Proven/SafeChecksum/Proofs.idr
  • src/Proven/SafeCommand/Proofs.idr
  • src/Proven/SafeContentType/Parser.idr
  • src/Proven/SafeContentType/Proofs.idr
  • src/Proven/SafeContentType/Types.idr
  • src/Proven/SafeCookie.idr
  • src/Proven/SafeCookie/Parser.idr
  • src/Proven/SafeCookie/Proofs.idr
  • src/Proven/SafeCookie/Types.idr
  • src/Proven/SafeDSP.idr
  • src/Proven/SafeDSP/Proofs.idr
  • src/Proven/SafeEmail/Proofs.idr
  • src/Proven/SafeEnv/Proofs.idr
  • src/Proven/SafeFile.idr
  • src/Proven/SafeFile/Proofs.idr
  • src/Proven/SafeGPU.idr
  • src/Proven/SafeGPU/Proofs.idr
  • src/Proven/SafeGit/Proofs.idr
  • src/Proven/SafeHKDF/Proofs.idr
  • src/Proven/SafeHTTP/Proofs.idr
  • src/Proven/SafeHeader/Parser.idr
  • src/Proven/SafeHeader/Proofs.idr
  • src/Proven/SafeHeader/Types.idr
  • src/Proven/SafeHtml.idr
  • src/Proven/SafeHtml/Builder.idr
  • src/Proven/SafeHtml/Proofs.idr
  • src/Proven/SafeInput/Proofs.idr
  • src/Proven/SafeJWT/Proofs.idr
  • src/Proven/SafeJson/Proofs.idr
  • src/Proven/SafeML/Proofs.idr
  • src/Proven/SafeMath/Proofs.idr
  • src/Proven/SafeNPU/Proofs.idr
  • src/Proven/SafeNetwork/Proofs.idr
  • src/Proven/SafeOTP.idr
  • src/Proven/SafeOTP/Proofs.idr
  • src/Proven/SafePassword/Proofs.idr
  • src/Proven/SafePath/Proofs.idr
  • src/Proven/SafePolicy.idr
  • src/Proven/SafePromptInjection/Proofs.idr
  • src/Proven/SafeProvenance.idr
  • src/Proven/SafeRateLimiter.idr
  • src/Proven/SafeRedirect.idr
  • src/Proven/SafeRegex/Matcher.idr
  • src/Proven/SafeRegex/Parser.idr
  • src/Proven/SafeRegex/Proofs.idr
  • src/Proven/SafeRegistry.idr
  • src/Proven/SafeRetry.idr
  • src/Proven/SafeSQL.idr
  • src/Proven/SafeSQL/Builder.idr
  • src/Proven/SafeSQL/Proofs.idr
  • src/Proven/SafeSemVer/Proofs.idr
  • src/Proven/SafeSet.idr
  • src/Proven/SafeString/Proofs.idr
  • src/Proven/SafeTOML.idr
  • src/Proven/SafeTOML/Parser.idr
  • src/Proven/SafeTOML/Proofs.idr
  • src/Proven/SafeTPU.idr
  • src/Proven/SafeTemplate.idr
  • src/Proven/SafeTree.idr
  • src/Proven/SafeUUID.idr
  • src/Proven/SafeUnionFind.idr
  • src/Proven/SafeUrl/Proofs.idr
  • src/Proven/SafeVersion.idr
  • src/Proven/SafeWebhook.idr
  • src/Proven/SafeXML.idr
  • src/Proven/SafeXML/Builder.idr
  • src/Proven/SafeXML/Parser.idr
  • src/Proven/SafeXML/Proofs.idr
  • src/Proven/SafeYAML.idr
  • src/Proven/SafeYAML/Parser.idr
  • src/Proven/SafeYAML/Proofs.idr

📝 Summary

Summary by CodeRabbit

  • New Features

    • Added safe regex parsing and matching, including captures, replacements, splitting, and execution limits.
    • Added a type-safe SQL query builder supporting queries, joins, filtering, pagination, and multiple database dialects.
    • Added secure XML and YAML parsing with configurable protection against unsafe content and resource exhaustion.
    • Added immutable tag and protected default-branch repository rules.
  • Bug Fixes

    • Fixed command-line parsing so validated arguments are returned correctly.
    • Prevented rate-limit timing calculations from underflowing.
    • Improved compatibility with updated parsing and string-handling behaviour.

Walkthrough

This pull request adds GitHub tag and branch rulesets, updates Idris compatibility and totality, adds regex, SQL, XML, and YAML functionality, and changes many proof declarations from postulates to erased declarations or concrete definitions.

Changes

Repository controls

Layer / File(s) Summary
Repository protection rules
.github/rulesets/*, .github/settings.yml
Adds active tag and default-branch rulesets. Removes the previous main branch protection block from .github/settings.yml.

Idris implementation and proofs

Layer / File(s) Summary
Parser and totality updates
src/Proven/*.idr, src/Proven/*/Parser.idr
Updates standard-library usage, string conversion, recursion structure, arithmetic proofs, and bounded traversal.
New security parsers and builders
src/Proven/SafeRegex/*, src/Proven/SafeSQL/Builder.idr, src/Proven/SafeXML/Parser.idr, src/Proven/SafeYAML/Parser.idr
Adds regex parsing and matching, a SQL query builder, secure XML parsing, and secure YAML parsing.
Proof declaration changes
src/Proven/*/Proofs.idr
Converts selected postulated constructors and proofs to concrete constructors, erased declarations, exported obligations, or Refl-based definitions.

Estimated code review effort: 5 (Critical) | ~120 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant RegexParser
  participant SafeRegex
  participant RegexMatcher
  Caller->>RegexParser: parseSafe pattern
  RegexParser->>SafeRegex: analyse parsed Regex
  SafeRegex-->>Caller: SafeRegex or RegexError
  Caller->>RegexMatcher: safeMatch input
  RegexMatcher-->>Caller: MatchResult or safety error
Loading
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

Comment @coderabbitai help to get the list of available commands.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) September 14, 2026 17:37
…nd-elaboration-cures

# Conflicts:
#	.github/workflows/governance.yml
#	.github/workflows/hypatia-scan.yml
#	.github/workflows/mirror.yml
#	.github/workflows/scorecard.yml
#	.github/workflows/secret-scanner.yml
#	.github/workflows/spark-theatre-gate.yml
#	GOVERNANCE.adoc
…rseable YAML)

The bulk permissions pass appended a mapping key under the read-all
scalar shorthand in clusterfuzzlite.yml and e2e.yml. read-all already
grants actions:read; the stray key made both files unparseable.
@@ -0,0 +1,558 @@
-- SPDX-License-Identifier: Palimpsest-MPL-1.0
@@ -0,0 +1,481 @@
-- SPDX-License-Identifier: Palimpsest-MPL-1.0
@@ -0,0 +1,567 @@
-- SPDX-License-Identifier: Palimpsest-MPL-1.0
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit a92d237 into main Sep 17, 2026
36 of 47 checks passed
@hyperpolymath
hyperpolymath deleted the fix/idris2-totality-and-elaboration-cures branch September 17, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants