Skip to content

bend PROOF.bend exits 0 with @unsafe in the import graph, and checks only the laws it happens to import #776

Closed

Description

@jasisz

What you did

bend PROOF.bend

What happened

1 term annotated as unsafe.
The code is well-typed, but may contain logical paradoxes.

Exit code 0.
  1. An @unsafe def anywhere in the import graph proves any law, and bend still exits 0. The note above goes to stdout, but "run bend PROOF.bend before committing" is what the README tells agents to do. A hook, a CI job or an agent looking at the exit status sees success. The unsafe def does not even have to be in PROOF.bend: putting it in main.bend, which the AI writes anyway, is enough. The guide describes @unsafe as a normal option, so an agent under pressure will find it.

  2. bend PROOF.bend checks the laws of whatever PROOF.bend imports. A PROOF.bend that simply omits import ./LAWS.bend checks clean. Nothing records which laws must be filled, so the guarantee depends on the AI not deleting one line in a file it owns.
    Both seem to want the same fix: a non-zero exit when the book contains an @unsafe def (or a flag to opt into the current behaviour), and some way to say "these laws must be filled" outside the files the AI edits, for example bend PROOF.bend --laws LAWS.bend, or the gate refusing when a LAWS.bend next to it is not imported.

The file

import Base

def absurd(e: Empty) -> {0n == 1n : Nat}:
  match e:

law falso:
  {0n == 1n : Nat}

@unsafe def loop() -> Empty:
  loop()

def falso():
  absurd(loop())

For the multi-file version put the @unsafe def in main.bend, state a law about it in LAWS.bend, and prove it in PROOF.bend with absurd({...}, G.loop()). Same output, same exit code. For (2), take the app_win_is_bug_2d demo and remove import ./LAWS.bend as Laws from PROOF.bend.

bend --version

bend 2.0.4

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.0.123.102)

Activity

  1. added
    bug
    on Sep 17, 2026
  2. Hitesh-XS commented on Sep 18, 2026

    @Hitesh-XS

    is this bug still open , if you like i would like to fix it

  3. nood-co1 commented on Sep 18, 2026

    @nood-co1
    Contributor

    Reproduced on 2.0.5 at commit 0b7e2b1. Two things, both from the same session.

    1. The gate checks the laws the invoked file imports. On
    demos/app_win_is_bug_2d, whose LAWS.bend states two unproven laws
    (you_cant_win, never_on_flag):

    $ bend PROOF.bend        # a PROOF.bend that does NOT import LAWS.bend
    All terms check.
    exit 0
    
    $ bend check_laws.bend   # the same, with `import ./LAWS.bend as Laws` added
    Error: 2 TODOs found.
    The code is incomplete, and not a valid proof yet.
    exit 1
    

    The README tells agents to run bend PROOF.bend before committing, and
    PROOF.bend is a file the agent writes. Whether that is a defect or the intended
    contract is your call -- I am reporting the behaviour, not judging the design.

    2. The @unsafe disclosure is on the no-main path only. cli_report is called
    only from book_run's no-main branch, and cli_emit never reports at all, so:

    bend PROOF.bend      -> "6 terms annotated as unsafe." + the paradox warning
    bend main.bend       -> the program's output, nothing else
    bend main.bend -o x  -> no output at all
    

    I ran every demo proof: 4 of the 15 that ship one use @unsafe, including
    pure_hvm5_mini with 6 unsafe terms. Each printed the banner only because it happens
    to have no main. Under bend main.bend or any -o, the disclosure vanishes while
    the unsafe def stays in the import graph.

    Suggested, and both cheap: a non-zero exit while any @unsafe def is in the import
    graph, and a way to require laws outside the agent-editable files -- either
    bend PROOF.bend --laws LAWS.bend, or a refusal when a LAWS.bend beside it is not
    imported.


    Found by an agent working for @blockbrain_labs

  4. VictorTaelin commented on Sep 18, 2026

    @VictorTaelin
    Contributor

    Shipped in 2.0.8: bend refuses a PROOF.bend that sits beside a LAWS.bend without importing it (bend: PROOF.bend must import ./LAWS.bend). The guide's convention paragraph says so.

    Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions