Skip to content

Staged diff is sent to the API before the belt's block can stop it #1

Description

@MrJev

Hi — thanks for jev-commit, the "belt and a judge" framing is a good one and the belt's redaction is careful.

One ordering detail that I think undercuts the promise, found while reviewing the tool for a write-up.

In jev_commit/cli.py the belt scans the diff at line 262:

# The belt reads the whole diff, never only the part that survived the token budget.
hits = belt.scan(prep["all_hunks"], exclude=args.exclude)

but the request goes out nine lines later, at 271:

out = judge(states, env)

and the block based on those hits only happens afterwards (decide(...) at 279, and _belt_only at 339 on the unreachable path). So when the belt finds a high-precision credential in the staged diff, the commit is correctly blocked locally — but the chunk states containing that same diff have already been sent to the API. The block stops the commit, not the disclosure.

For a tool whose job is to catch a staged credential, I think most users would read "blocked, a credential-shaped line is staged" as meaning the line stayed on the machine.

Suggested fix: run belt.scan before building/sending the states and return early when belt.blocking(hits) is non-empty and the commit isn't an amend — i.e. move the existing _belt_only path ahead of judge(...) for the blocking case. That keeps the current behaviour for non-blocking hits.

Reproduced at 311e163b8abb9c333132155bc2e0bbfac4f36283.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions