Skip to content

strict_shape_contract hashes comments: comment-only edits demand reviewed repins (3 today) #1962

Closed

Description

@InauguralPhysicist

tools/strict_shape_contract.py pins each exempt builtin by the SHA-256 of its raw body and of every helper in its closure. Comments are part of that text, so an edit that changes only a comment fails the gate ("exempt source/helper changed; review the contract") exactly as a code change does. Because tools/strict_differential.sh aborts its preflight on the same hashes, one such edit fails about seven full-lane jobs at once.

What it cost on 2026-10-24:

Each review was a closure diff whose answer was "comments only", and a gate whose reds are mostly false invites rubber-stamp repins.

Proposal: hash a normalized body, with comments stripped by a real tokenizer (string, character-literal and comment state; mechanical-gates §57) and whitespace collapsed. The gate still reds on any token change in the function or its helpers.

Done when

  • The body and helper hashes are taken over the comment-stripped, whitespace-normalized token stream. The stripper honours string and char literals, and its selftest covers /* inside a string and // inside a char literal.
  • A comment-only edit to an exempt builtin passes. A one-token code change in the builtin, or in a helper of its closure, fails, naming the function. Both are planted in the selftest.
  • All existing contracts are repinned once, in the same PR, with a closure diff showing that only the hash function changed.
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

    area:gatesSubsystem: gateskind:gate-defectA gate, check or claim that measures less than it says

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions