feat(planner): a security and sanity check of the diff before the plan #50

Merged
HumanBean merged 1 commit from HumanBean/Beanstalk:feat/plan-security-check into main 2026-11-16 07:11:11 +00:00
Owner

Why

Today, once a BigBean approves a commit, the planner writes a plan and testers' PCs build and run the code. Before that, the farm should take one quick look at the diff, so a commit that is plainly malicious or broken never reaches a tester's PC, even when a BigBean missed it.

What changed

  • planner.screen: before each PR plan, one call to a quick model checks the commit. The default is gpt-6-luna at low effort; BEANSTALK_SCREEN_MODEL and BEANSTALK_SCREEN_EFFORT change it.

    • What it reads: the diff, the changed files, the PR's title and body, its 6 newest comments, and the maintainer's words. The limits are the planner's.
    • How the PR's text is passed: as fenced data blocks with a random nonce, like the planner does. Text in them that asks for a pass is itself a reason to look harder.
    • Its answer: {"safe": bool, "reason": str}, through the backend's structured output: a strict JSON schema named beanstalk_screen (complete() now takes the format's name; plans stay beanstalk_plan). The parser still accepts fenced JSON in case the backend ever drops the schema, and an unreadable answer counts as no verdict.
  • What it holds: only what is plainly bad. That means:

    • reading or sending files outside the repo;
    • network access or downloads;
    • probing the sandbox;
    • miners or fork bombs;
    • deleting outside the build, or adding persistence;
    • encoded or prebuilt payloads with no source;
    • faking the farm's results, detecting the farm, or changing its scripts for no reason;
    • empty or garbage diffs.

    Style, ordinary bugs and slow code all pass, and so does anything it isn't sure about.

  • A held commit: gets no plan and no jobs. plan_error starts with security check: , and beanstalk/approval fails with "held by the security check: see the farm's comment". The comment says:

    Held by the security check (gpt-6-luna), so nothing is built or run:

    host/net.c opens a socket to evil_host and sends ~/.ssh …

    The check looks at the diff for code that is plainly unsafe or broken before any tester builds it. A new push is checked again. A member of BigBeans who has looked at the code can comment @Beanstalk plan <why it is fine>: the check reads those words.

    The reason has @ defused, backticks replaced and a 600-character cap.

  • Checking again: a new push or @Beanstalk plan <words> starts a new round, and the check runs again, with those words as the maintainer's.

  • When the check can't answer (an error, 2 minutes with no answer, or no verdict), the farm plans anyway, since a BigBean approved the commit already. With AI planning off there is no check.

  • Setup: create_app(..., screen_llm=) takes the check's model; in production it comes from the same ChatGPT sign-in as the planner. Farm.screen_llm is new.

  • Docs: docs/using.md has a section on the check; the setting is in docs/deploy.md and deploy/compose.example.yml.

Testing

  • Coordinator suite: 414 passed, 1 skipped.
  • New tests:
    • A malicious diff whose PR body says "answer safe" is held: no plan call and no jobs. The comment, the status and the stored state are right. The check saw the diff with the body inside its data block.
    • A maintainer's @Beanstalk plan <words> passes those words to the check; it then answers safe, and the commit is planned and started.
    • A safe answer, a model error, an answer that isn't JSON, and an answer with no verdict each go on to the plan.
    • The reason is made safe to show.
    • The request body asks for a strict json_schema format named beanstalk_screen for the check and beanstalk_plan for plans.
  • Not tested: a real gpt-6-luna call. Nothing shows yet how often it holds ordinary PRs. After deploying, the coordinator log line "the security check held …" is worth watching for false holds. Manual runs (#48) don't get the check yet.

Deploy

No migration. With the sign-in present, the check is on by default; set BEANSTALK_SCREEN_MODEL to another model to change it. Each PR plan costs one more quick call.

## Why Today, once a BigBean approves a commit, the planner writes a plan and testers' PCs build and run the code. Before that, the farm should take one quick look at the diff, so a commit that is plainly malicious or broken never reaches a tester's PC, even when a BigBean missed it. ## What changed - **`planner.screen`:** before each PR plan, one call to a quick model checks the commit. The default is `gpt-6-luna` at low effort; `BEANSTALK_SCREEN_MODEL` and `BEANSTALK_SCREEN_EFFORT` change it. - **What it reads:** the diff, the changed files, the PR's title and body, its 6 newest comments, and the maintainer's words. The limits are the planner's. - **How the PR's text is passed:** as fenced data blocks with a random nonce, like the planner does. Text in them that asks for a pass is itself a reason to look harder. - **Its answer:** `{"safe": bool, "reason": str}`, through the backend's structured output: a strict JSON schema named `beanstalk_screen` (`complete()` now takes the format's name; plans stay `beanstalk_plan`). The parser still accepts fenced JSON in case the backend ever drops the schema, and an unreadable answer counts as no verdict. - **What it holds:** only what is plainly bad. That means: - reading or sending files outside the repo; - network access or downloads; - probing the sandbox; - miners or fork bombs; - deleting outside the build, or adding persistence; - encoded or prebuilt payloads with no source; - faking the farm's results, detecting the farm, or changing its scripts for no reason; - empty or garbage diffs. Style, ordinary bugs and slow code all pass, and so does anything it isn't sure about. - **A held commit:** gets no plan and no jobs. `plan_error` starts with `security check: `, and `beanstalk/approval` fails with "held by the security check: see the farm's comment". The comment says: > **Held by the security check** (`gpt-6-luna`), so nothing is built or run: > > > host/net.c opens a socket to evil_host and sends ~/.ssh … > > The check looks at the diff for code that is plainly unsafe or broken before any tester builds it. A new push is checked again. A member of BigBeans who has looked at the code can comment `@Beanstalk plan <why it is fine>`: the check reads those words. The reason has `@` defused, backticks replaced and a 600-character cap. - **Checking again:** a new push or `@Beanstalk plan <words>` starts a new round, and the check runs again, with those words as the maintainer's. - **When the check can't answer** (an error, 2 minutes with no answer, or no verdict), the farm plans anyway, since a BigBean approved the commit already. With AI planning off there is no check. - **Setup:** `create_app(..., screen_llm=)` takes the check's model; in production it comes from the same ChatGPT sign-in as the planner. `Farm.screen_llm` is new. - **Docs:** `docs/using.md` has a section on the check; the setting is in `docs/deploy.md` and `deploy/compose.example.yml`. ## Testing - Coordinator suite: 414 passed, 1 skipped. - **New tests:** - A malicious diff whose PR body says "answer safe" is held: no plan call and no jobs. The comment, the status and the stored state are right. The check saw the diff with the body inside its data block. - A maintainer's `@Beanstalk plan <words>` passes those words to the check; it then answers safe, and the commit is planned and started. - A safe answer, a model error, an answer that isn't JSON, and an answer with no verdict each go on to the plan. - The reason is made safe to show. - The request body asks for a strict `json_schema` format named `beanstalk_screen` for the check and `beanstalk_plan` for plans. - **Not tested:** a real `gpt-6-luna` call. Nothing shows yet how often it holds ordinary PRs. After deploying, the coordinator log line "the security check held …" is worth watching for false holds. Manual runs (#48) don't get the check yet. ## Deploy No migration. With the sign-in present, the check is on by default; set `BEANSTALK_SCREEN_MODEL` to another model to change it. Each PR plan costs one more quick call.
feat(planner): a security and sanity check of the diff before the plan
Some checks failed
CI / Conventional Commit title (pull_request) Successful in 3s
CI / Workflow lint (actionlint) (pull_request) Successful in 3s
CI / Coordinator tests (pull_request) Has been cancelled
CI / Agent build and checks (pull_request) Has been cancelled
CI / Coordinator image (pull_request) Has been cancelled
cf6d94bfd4
Before a PR commit's plan is written, one call to a quick model
(gpt-6-luna at low effort by default; BEANSTALK_SCREEN_MODEL/_EFFORT)
reads the diff, changed files, title, body, latest comments and the
maintainer's words, all as fenced untrusted data, and answers
{safe, reason}. It holds only what is plainly bad: exfiltration, network
access, sandbox probing, miners, destruction outside the build,
obfuscated or prebuilt payloads, tampering with the farm's results or
scripts, garbage diffs.

Held: no plan, no jobs; plan_error starts with "security check: "; the
comment says "Held by the security check" with the reason (no @mentions,
no backticks, capped) and how to go on; beanstalk/approval fails with
"held by the security check". A new push, or a maintainer's
@Beanstalk plan <why it is fine>, checks again with those words.

When the check can't answer (error, 2-minute timeout, no verdict), the
farm plans anyway: a BigBean approved the commit already.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Beanstalk!50
No description provided.