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
hyperpolymath pushed a commit that referenced this pull request Nov 16, 2026
Brings in #172 (T-12, one Agda pin), #173, #174 (scanner fix) and the
CI fixes since. Conflicts in STATE.a2ml and READINESS.adoc are resolved
by keeping main's facts (the Agda pin obligation is closed) with this
branch's grade wording. The receipt lineage now records the actual
outcomes: 42646851111 and 42736066407 were green and are superseded,
as is 43213340167, the last main run before the legs.

Also corrects the test count from 143 to 144 in READINESS, TOPOLOGY and
STATE. #172 and #173 each added a test counted from 141, so main
measures 144, and its STATE vs dashboard reconciliation has failed on
these three lines since 2026-11-10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX
hyperpolymath added a commit that referenced this pull request Nov 16, 2026
…derived (#181)

## Summary

This follows #174 and
metadatastician/standards#1450, which added the proof-receipt profile.
januskey's grades were in prose tables only, and they still said
"receipt pending re-run". This PR adds the machine-readable receipt. The
pinned standards reader derives the grades from it, and mathesis can
read them from it.

## Changes

- **`verification/receipts/januskey_praxis.deed`** (new): a praxis deed
with `:profile proof-receipt` (PROOF-POLICY §8.5.1). It holds:
- `(trusted-base …)`: the four `Agda.Primitive` primitives, each with
its `BUILTIN` binding (§8.4);
  - one `(claim …)` each for G-1, T-1, T-2, T-3 and E-1m;
  - an `(inputs-manifest …)` and `(axioms)` on every current receipt;
- on each current Agda receipt, an `(import …)` of
`hyperpolymath/resource-algebra` at `cf9235c`;
  - superseded receipts with their reasons, as lineage.
- **`scripts/proof-receipt.sh`** (new) writes the receipt.
- **Typed:** two ledgers, the claim list and the CI runs. Each run row
is copied from its job log.
- **Computed from git:** each leg's input set, every file's SHA-256, the
§8.5.1 digest, and the sibling's pin, read from
`scripts/fetch-siblings.sh`. A repin therefore changes the Agda digest.
- A Rocq or Lean leg that nobody has started is left out, not recorded
as `unavailable`. This matches `PROOF-GRADES.adoc`, which records those
legs as "not attempted".
- **`--check`** (`just test-receipt`, and a new `agda-proofs.yml` job
"Proof receipt, derived grades, git checks") does four things:
  1. Regenerates the receipt and refuses any difference.
2. Fetches the standards reader, digest script and checker pinned at
`513cba8` and checks each file's SHA-256. The reader then derives every
grade and refuses one the receipts do not support.
3. Runs `check-proof-receipt.sh`, the §8.5.3 git checks. It needs a full
clone, so the job checks out with `fetch-depth: 0`.
4. Warns with `::warning::` when a leg's inputs have changed since the
source commit. A stale receipt is still true of the commit it names.
- Bun 1.4.4 is installed from the release zip and checked by SHA-256, as
the Lean job already does for Lean. No new `uses:` entry is added, so
`actions.lock` is unchanged.
- **`PROOF-GRADES.adoc` and `PROOF-NEEDS.adoc`:**
  - cite the receipt and run 43213340167 at `b503488`;
- mark runs 42736066407 (the first green run after #174) and 42076969251
as `superseded`;
  - drop "pending re-run";
- list the fourth module, `SingleActiveLog.agda`, and update the cone (7
first-party modules and 8 supplied with the prover).

## Grade change: T-1 goes from PWG-2ii to PWG-1 (derived, not asserted)

Run 43213340167 checked all three of T-1's witnesses at the receipt's
source commit `b503488`: the Agda job and the Rocq and Lean recheck job.
Each has a pinned checker and no axioms. That is the §8.2 condition for
`PWG-1`, and the reader derives it. The other four claims stay `PWG-3`.

**Census (denominator 5):** `PWG-3` 4 · `PWG-2i` 0 · `PWG-2ii` 0 ·
`PWG-1` 1 · `ungraded` 0.

The Rocq checker is `coq=8.18.0+dfsg-1build2` on an ephemeral
`ubuntu-24.04` runner, not inside a digest-pinned container.
secret-types' `PWG-1` receipt makes the same choice. If you read §8.2's
"isolated" more strictly, T-1 would have to stay at `PWG-2ii`, and this
needs your call.

## Testing

| Check | Result |
|---|---|
| `bash scripts/proof-receipt.sh --check` | PASS. Derived: G-1 `PWG-3`,
T-1 `PWG-1`, T-2 `PWG-3`, T-3 `PWG-3`, E-1m `PWG-3`. Every §8.5.3 check
holds, including the import at `cf9235c` |
| Reference digest (`scripts/proof-inputs-sha256.sh` from standards) |
Same Agda digest as the receipt (`6e17ce4a…`) |
| Overstated grade (G-1 recorded as `PWG-2i`) | The reader refuses it |
| Understated grade (T-1 recorded as `PWG-2ii`) | The reader refuses it
|
| A file SHA-256 changed without its digest | The reader refuses it (the
digest does not match the manifest) |
| A forged but self-consistent manifest | The reader accepts it, as
designed; the §8.5.3 git checker fails it ("the manifest does not hold
at b503488…") |
| Stale inputs (a commit that edits `Rollback.lean`) | `::warning::the
lean inputs changed after b503488…` |
| `shellcheck scripts/proof-receipt.sh` | clean |
| `asciidoctor --failure-level WARN` on both docs | clean |

This PR changes no Agda, Rocq or Lean file and does not change
`check-agda.sh` or `check-recheck.sh`, so the receipt still describes
`main`. The new CI job is this PR's own test.

## Not in this PR

- **Negative controls (§8.5.4).** The fixtures under `tests/reject-*`
are already refused by the gates. Recording them as `(control …)` needs
each fixture's own input set, for example `ForwardRollback.v` together
with `Rollback.v`. That is follow-up work.
- **Rocq and Lean legs for G-1, T-2, T-3 and E-1m.** Not attempted.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01GVPPsHYqVJSoPzdNYD9tRg)_

Co-authored-by: Claude <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Nov 16, 2026
## What

This follows #171. T-1 got its Rocq and Lean
recheck legs there. The other four theory rows now get theirs by the
same route: each is re-proved by hand in core Rocq 8.18 and core Lean
4.35.0. Transport is unavailable for this toolchain, for the reasons
recorded in #171. No Agda file changes.

**Legs** (`verification/proofs/{rocq,lean}/`)

| Row | File | Restated |
|---|---|---|
| T-2, T-3 | `SingleActiveLog` | `begin/modify/finish-good`,
`at-most-one-active`, `update-active`, the three refusal lemmas |
| G-1 | `Reversibility` | the six G-1 theorems. The part of
resource-algebra's Loss grade they use is restated, because a leg cannot
import the sibling: the carrier, `+g`, its left unit, and both
annihilation laws |
| E-1m | `Epistemic` | the eight E-1m theorems |

- Every cited theorem and every refusal lemma reports no axioms: 22
reports in Rocq and 22 in Lean.
- The legs use no Mathlib and no `simp`.
- Lean 4.35.0's `Nat.succ_ne_zero`, and `nomatch` on two numerals, both
bring in `propext`. The legs avoid both, and the axiom report caught
each one while the legs were being written.

**Non-vacuity** (`tests/reject-{rocq,lean}/`)

- Rocq and Lean twins of `SettleWithoutSettling`, `HiddenLoss` and
`OldKeyStillUsable`, joining #171's `ForwardRollback` twins.
- Each twin is a closed instance, refused with the value it evaluates
to, for example `Unable to unify "true" with "false"`. That shows the
claim is false, not only that the term does not reduce.
- Each true counterpart checks.

**Gate** (`scripts/check-recheck.sh`)

- The gate used to pass a file if any one of its theorems was clean. It
now counts the reports and fails unless every one is clean. This only
mattered once a file held more than one theorem.
- Mutants it catches, as "6 of 7": `Admitted`/`sorry` on
`modify_good`/`finish_good`, and on the refusal lemma
`modify_refused_when_idle`.
- It counts the commands as the provers parse them (any whitespace
between the words) and fails on any report that lists an axiom. A report
spelled `Print Assumptions` (two spaces) used to escape the count;
CodeRabbit's finding, reproduced and fixed.

**Records**

- `docs/theory/PROOF-GRADES.adoc`:
  - one §8.5 leg record for all five rows;
  - the statement comparison, row by row;
- the residual differences (equality, the `Prop` placement of the
invariants, Lean's `Nat.add` orientation, `propext` in Lean's core
library);
  - pins, and SHA-256 for all 17 inputs.
- `PROOF-NEEDS`, `READINESS` and `STATE` agree with that page. In
`STATE`, existing fields are corrected; nothing is added.

**Receipts.** The Agda receipt is current: run 43213340167 at `b503488`.
This PR touches no Agda input. The recheck receipt is pending: the
recheck job of the first green `agda-proofs.yml` run on `main` after
this merges. A doc-only follow-up records it and promotes the five rows
to `PWG-2ii`.
- Lineage: runs 42736066407 (#174's gate change) and 42646851111 (#171's
merge) were green and are `superseded`, as are 42633520061 and
42076969251.
- Census after this PR: `PWG-3` 5 (G-1, T-1, T-2, T-3, E-1m), each
awaiting promotion to `PWG-2ii` · `PWG-2ii` 0 · `PWG-2i` 0 · `PWG-1` 0 ·
`ungraded` 0. T-1 also waits, because its checker changed here (§8.4).

## Verification (local)

- `scripts/check-recheck.sh` (Rocq 8.18.0, Lean 4.35.0): 4 + 4 legs and
8 fixtures; `[check-recheck] OK`.
- `scripts/check-agda.sh` (Agda 2.6.4.3): cone 7 + 8, 0 postulates, 7
fixtures refused as named; `OK`.
- `dashboard-check`: 144 tests measured, 12 PROVEN claims, no
divergence.
- The 17 recorded digests match the committed bytes.
- `shellcheck scripts/check-recheck.sh`: clean.

## Also fixed here: `main`'s red dashboard check

#172 and #173 each added a test and each counted from 141, so `main`
measures 144 tests while READINESS and TOPOLOGY say 143. `STATE vs
dashboard reconciliation` has failed on `main` on exactly those three
lines since 2026-11-10 (e.g. run 43213340032). This PR corrects the
count to 144 there and in STATE; `dashboard-check` passes locally.

This branch merges `main`, so it includes #172 (T-12, one Agda pin) and
#174 (the scanner fix). Every gate above was re-run on the merged tree.

https://claude.ai/code/session_013CuBToxr5h9catptGiTsFX

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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