Skip to content

proofs: a token may start after a skipped literal in the postulate scan - #174

Merged
hyperpolymath merged 7 commits into
mainfrom
claude/awesome-wright-va45xo
Nov 10, 2026
Merged

hyperpolymath merged 7 commits into
mainfrom
claude/awesome-wright-va45xo

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

This follows #170 (merged as 05ade78) and answers the Codex finding on it that arrived after the merge: "Recognize line comments after character literals".

The scanner decided whether -- (or ') starts a token from the raw character before it. In c = 'x'-- postulate X : Set the closing quote of the character literal therefore counted as a name character, so the line comment was not recognised, and a postulate Agda never sees failed the gate. That is a false failure, so it fails safe, but it is still wrong lexing. The scanner now uses the last character it emitted as code. A skipped literal, comment or pragma leaves a space, just as it leaves a token boundary in Agda.

Changes

  • scripts/scan-postulates.sh: prev is the last character of code, not substr(line, i-1, 1).
  • scripts/check-agda.sh: the comments-only control gains c = 'x'-- postulate after a character literal, which must exit 0.

The branch merges main into #170's head rather than rewriting it, so its diff against main is exactly these two files (+4/−2).

Testing

Check Result
Scanner cases (32), under mawk and gawk all pass. The scanner at 9ff3043 (merged) fails exactly the reported case; string literals, block comments and primed names (x'--y stays one name) are unchanged
bash scripts/check-agda.sh (local Agda 2.6.3) [check-agda] OK: cone 6 + 8, 0 postulates, Primitive names and bindings checked, controls behave, 6 rejections refused as named
shellcheck on both scripts clean

After merge

The first green agda-proofs.yml run on main at this PR's merge commit becomes the gate's receipt. #170's merge run 42633520061 at 05ade78 was green too, but this PR changes the checker again. A doc-only PR then records that run in PROOF-GRADES.adoc and PROOF-NEEDS.adoc, marks 42076969251 superseded, and drops "pending re-run". A doc-only commit changes neither the modules nor the checker, so it leaves that receipt current.


Generated by Claude Code

…cone

The grade records were written against the mathesis brief on 2026-11-01,
before the owner ruling of 2026-11-04 made PROOF-POLICY §8 normative:

- The five theory rows (G-1, T-1, T-2, T-3, E-1m) are PWG-3, written with
  the prefix. The brief's "2ii needs Isabelle/HOL" is replaced by §8.3's
  +foundation-diverse tag.
- The receipt is the current green agda-proofs run 42076969251 at 23bc8c3,
  covering all three modules under the §2.1 canonical invocation, with
  library pin, flags, import cone and axioms recorded. Runs 41687715055 and
  40867211509 are kept as state: superseded. The page had still cited the
  pre-flag receipt it said it would replace.
- The duplicated row counts, which had drifted (23 against 27 TESTED), are
  removed from PROOF-GRADES; PROOF-NEEDS stays the only count.
- Rust's verifiers read Creusot/Pearlite and Verus (§1.2, 2026-11-07).

§8.4 asks for a comment-aware postulate scan of the import cone beside
--safe. scripts/scan-postulates.sh does that, and check-agda.sh runs it on
the proofs and the pinned resource-algebra sibling with a negative and a
positive control written at run time. Verified locally: cone 10 files, 0
postulates; a mutant scan that reports nothing fails the gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg
…e-run

Review on #170 (Codex, CodeRabbit), each finding checked:

- The cone is now the module set `agda --dependency-graph` reports for the
  three roots, resolved to files on the include path and in Agda's own
  library; an unresolved module fails the gate. The directory scan both
  missed the 8 prover-supplied modules and swept in unimported ones.
- First-party modules (6) must have no postulate. Agda.Primitive's
  universe-level primitives (Level, lzero, lsuc, _⊔_, bound by BUILTIN)
  are reported as the prover's trusted base; a postulate in any other
  prover-supplied module fails.
- The scanner takes explicit files, refuses unreadable ones, and lexes
  `--` comments with no space, and string and character literals.
- Controls must exit exactly 0 and 1, and the planted one must be named.
- Run 42076969251 predates the changed gate, so it is recorded as the
  last receipt for the modules; the first green run of this gate on main
  replaces it.
- The stale "23 TESTED" is gone; Rust guidance names Creusot/Pearlite and
  Verus throughout.

Verified locally: gate OK (6 first-party, 0 postulates; 2 BUILTIN blocks
in Agda.Primitive); a never-reporting scanner, a comment-blind scanner and
a planted postulate in Epistemic.agda each fail the gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg
…y name

The scanner treated only space and tab as keyword boundaries, so a postulate
next to NO-BREAK SPACE, a Unicode space separator, CR, FF or VT went
unreported. Agda reads every isSpace character other than tab and newline as
a space (Agda.Syntax.Parser.Alex, toASCII); the scanner now does the same,
byte-wise in the C locale so mawk and gawk agree. The planted control gains a
NO-BREAK SPACE case, and the comments-only control `--postulate postulate`.

The prover-supplied allowance was the path Agda/Primitive.agda. The gate now
requires those blocks to declare exactly Level, lzero, lsuc and _⊔_, each with
its BUILTIN binding, so a prover pin that adds a postulate fails.

PROOF-NEEDS states the PWG-3 grade as pending its re-run receipt, and
PROOF-GRADES cites the green branch run of the changed gate as evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg
…gda does

A block comment was removed without leaving a token boundary, so
`postulate{- c -}X : Set`, which Agda reads as a postulate, became
`postulateX` and was not reported; in Agda.Primitive it would also have slipped
past the name check. A comment now leaves a space behind.

A pragma was scanned as code, so a FOREIGN payload using `postulate` as a
Haskell name failed the gate, and a payload holding `{- {-` opened a comment
Agda never sees, hiding a postulate after the pragma. Agda does not nest
comments inside a pragma and closes it at a `#-}` token (Lexer.x); the scan
now skips to the first `#-}`, which can end a pragma early but never late.

Controls: the comments-only file gains a FOREIGN payload; the planted file
gains the comment-separated and after-pragma cases, and must name lines 2-5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg
The scanner decided whether `--` or `'` starts a token from the raw
character before it, so in `c = 'x'-- postulate …` the closing quote of
the character literal counted as a name character, the line comment was
not recognised, and a postulate that Agda never sees failed the gate.
It now uses the last character emitted as code: a skipped literal,
comment or pragma leaves a space, as it leaves a token boundary in Agda.
The comments-only control carries the case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg
…-va45xo

# Conflicts:
#	scripts/check-agda.sh
#	scripts/scan-postulates.sh
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved postulate scanning so skipped literals, comments and pragmas are handled correctly when identifying token boundaries. This helps prevent text following these elements from being misread during scanning.
  • Tests
    • Expanded scanner checks to cover a character literal followed by a line comment, alongside the existing foreign pragma case.

The scanner now checks the last character emitted into code when it determines whether a token can begin. The comments-only fixture adds a character literal followed by a line comment.

Changes: Scanner token-boundary handling

Layer / File(s) Summary
Token-boundary check and fixture
scripts/scan-postulates.sh, scripts/check-agda.sh
The scanner checks the last emitted character in code instead of the preceding raw input character. The comments-only fixture adds a character literal followed by a line comment.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related PRs

Merge Risk: Minimal · up to 22432

No actionable merge-blocking risk was identified. Run the normal checks before merging.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly describes the scanner change: recognising a token after a skipped literal.
Description check Passed The description explains the scanner change, its test case and reported test results. It is relevant to the changeset.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 54e116f8-3c60-47af-9782-83d6e4d54a2d
Commits

Reviewing files that changed from the base of the PR and between e0bee35 and 224324f.

Files selected for processing: 1

  • scripts/check-agda.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: STATE vs dashboard reconciliation
Additional comments: 1

scripts/check-agda.sh: 1

95-95: LGTM!

@linear-code
linear-code Bot marked this pull request as ready for review November 9, 2026 15:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T23:17:35.568142Z 224324f New commits
🔒 Security Review ❌ Failed 2026-11-09T23:15:16.246497Z
We couldn’t complete this review. Comment @codex security review to try again.
224324f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 9, 2026 23:15
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit e165438 into main Nov 10, 2026
22 checks passed
@hyperpolymath
hyperpolymath deleted the claude/awesome-wright-va45xo branch November 10, 2026 01:28
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