Skip to content

fix(roadmap): the stage gate proves a negative search verify #3410

Closed

Description

@dan-petty

Problem or Motivation

The stage gate checks the form and the paths of a verify command, but it never checks whether the command can pass on the tree that the plan produces. So a plan can give a negative search that proves nothing, or one that fails forever after the change.

The plan of #3372 in pull request #3378 chose ! git grep -n -F devops_cli.roadmap.stage src/ tests/ as the whole-prefix check for a move of the stage* modules. The literal matches from devops_cli.roadmap.stage import on the staged tree. After the move it also matches every new path under devops_cli.roadmap.stage/, such as devops_cli.roadmap.stage.ready. A negative search passes only on exit 1, so this command can never pass on the tree that the plan produces, while the plan's own spec says it must.

The planner has the search_code and references tools, so it can test the literal on the staged commit. The prompt asks it for a ! git grep line but not for the evidence that the line fails before the change and passes after it. The stage gate cannot catch the fault, because form_problems reads the shape of the command and path_problems reads only the paths.

Proposed Solution & Architectural Design

  1. The stage job runs the literal of each negative-search verify on the staged tree with git grep, and gives the hit count to check_proposal as a recorded input, in the same way that probes carries the premise probe. The replay reads the count from the stage eval case, so it runs no git.
  2. check_proposal refuses a negative-search literal with no hit on the staged tree: a search that finds nothing already passes before the change and proves nothing.
  3. check_proposal refuses a negative-search literal whose only hits are on paths that the plan creates: the search can never pass on the produced tree.
  4. The stage prompt asks the planner to run search_code with the literal and to quote the hit count in feasibility.
  5. A stage eval case holds the plan of docs(openspec): plan #3372 Check every module of a moved prefix #3378 and asserts the two refusals and the accepted literal devops_cli.roadmap.stage_.

Target Subsystem

src/devops_cli/roadmap/stage_change.py, src/devops_cli/roadmap/stage.py, src/devops_cli/roadmap/stage_form.py, src/devops_cli/ai/tasks/roadmap_stage_change.md

Existing Tool Considered

git grep and the existing search_code and references stage tools cover the search need. No new scanner is needed. The cost is about 10k tokens and 1 hour to build, and nothing to keep.

Proposed design

Problem statement

The stage gate checks the form and the paths of a verify command. It does not check whether a negative search can pass on the tree that the plan produces. A plan can give a search that proves nothing before the change, or a search that fails forever after the change. This issue makes the stage job record git grep evidence and makes check_proposal refuse both faults.

Acceptance criteria

Requirement: Negative-search evidence is recorded

The stage job SHALL run the literal of each negative-search verify command on the staged tree with git grep and record the matching paths and hit count.

Scenario: A negative search has staged hits

  • WHEN A plan gives a negative-search verify command and its literal matches files on the staged tree.
  • THEN The stage job records each matching path and the hit count and passes the record to check_proposal.

Requirement: A negative search with no staged hit is refused

check_proposal MUST refuse a negative-search literal when the recorded evidence holds no matching path.

Scenario: The literal finds nothing before the change

  • WHEN The recorded evidence for a negative-search literal holds no matching path.
  • THEN check_proposal returns a problem that says the search already passes before the change and proves nothing.

Requirement: A negative search that a created module keeps is refused

check_proposal MUST refuse a negative-search literal when the plan creates a source path whose import path contains the literal.

Scenario: A created module matches the literal

  • WHEN A group creates a source path under src/devops_cli/ whose import path contains the negative-search literal.
  • THEN check_proposal returns a problem that says the search can never pass on the produced tree.

Requirement: A negative search with a surviving hit is accepted

check_proposal MUST accept a negative-search literal when the staged tree has a hit and no created source path has an import path that contains the literal.

Scenario: A staged hit survives the change

  • WHEN The recorded evidence holds a matching path and no created source path has an import path that contains the literal.
  • THEN check_proposal returns no problem for that literal.

Requirement: The stage prompt asks for the search evidence

The stage prompt MUST ask the planner to run search_code with the negative-search literal and quote the hit count in feasibility.

Scenario: The planner reads the prompt

  • WHEN The stage job plans an item whose plan gives a negative-search verify command.
  • THEN The prompt tells the planner to call search_code with the literal and to quote the hit count in feasibility.

Requirement: The replay uses recorded evidence

The stage eval replay MUST read the negative-search evidence from the eval case and MUST run no git command.

Scenario: The replay judges a negative search

  • WHEN The stage eval replay judges a plan with a negative-search verify command.
  • THEN The replay reads the evidence from the case and runs no git grep.

Requirement: The eval case covers the #3378 plan

The stage eval case MUST hold the plan of #3378 and assert the no-hit refusal, the created-module refusal, and the acceptance of devops_cli.roadmap.stage_.

Scenario: The replay runs the #3378 plan

Existing Tool Considered

No alternatives check has run. git grep and the existing search_code and references stage tools cover the search need. They lack a check that the literal has a hit before the change and no hit on a path that the plan creates. The gate code costs about 10k tokens and 1 hour to build, and nothing to keep.

Key questions

  • How does the stage job give negative-search evidence to check_proposal without a git call in the replay?: The stage job runs git grep on the staged tree and records the matching paths and hit count for each negative-search literal. It passes that record to check_proposal as a recorded input, and the eval case stores the same record for the replay. (best practice) [sources: src/devops_cli/roadmap/stage.py, src/devops_cli/roadmap/stage_change.py, docs/ROADMAP_WORKFLOW.md:254]
    • Chosen: Recorded evidence per literal. It follows the probes input and lets the replay run no git.
    • Rejected: Run git grep in check_proposal. The replay calls no git, and the check must judge a recorded plan.
    • Rejected: Record only the total hit count. A total cannot show whether a hit is on a created path.
  • Where does the stage job run the negative-search literal?: In the planner request, on the checkout at the staged commit, before check_proposal judges the reply. The job reuses the premise probe path that already reads the staged commit. (best practice) [sources: src/devops_cli/roadmap/stage.py, src/devops_cli/roadmap/stage_change.py]
    • Chosen: In the planner request with the premise probe. It already has the checkout and the staged commit.
    • Rejected: In check_proposal. It has no checkout and the replay must run no git.
    • Rejected: In stage_form. The form gate has no tree and no hit evidence.
  • How does the gate read the literal and paths of a negative-search command?: It reuses NEGATIVE_SEARCH_WORD and the command grammar of implement_shell_policy to read the literal and the relative paths. A command of another form stays with form_problems. (best practice) [sources: src/devops_cli/roadmap/stage_form.py, src/devops_cli/roadmap/implement_shell_policy.py, src/devops_cli/ai/tasks/roadmap_stage_change.md]
    • Chosen: Reuse the existing negative-search grammar. One grammar already refuses pipes, redirects and unsupported options.
    • Rejected: Add a second git grep parser. It would drift from the shell policy and from stage_form.
    • Rejected: Parse the command in the prompt. The gate needs the literal and paths, not a model answer.
  • How does the gate detect a literal that the produced tree will keep?: It maps each created source path under src/devops_cli/ to its import path. It refuses the literal when that import path contains the literal, because the new module or its imports will match after the change. (best practice) [sources: src/devops_cli/roadmap/stage_change.py, src/devops_cli/roadmap/stage_paths.py, src/devops_cli/roadmap/stage_form.py]
  • What does the stage prompt ask the planner to do with the literal?: It asks the planner to call search_code with the literal and to quote the hit count in feasibility. The quote ties the plan to the staged commit. (best practice) [sources: src/devops_cli/ai/tasks/roadmap_stage_change.md, src/devops_cli/roadmap/stage.py]
    • Chosen: Ask for search_code and a quoted count. The planner has the tool, and the quote gives the evidence that the gate records.
    • Rejected: Ask only for a ! git grep line. The line gives no evidence that the search fails before the change and passes after it.
    • Rejected: Leave the check to the gate only. The planner can correct the plan before the gate refuses it.
  • How does the eval case prove the gate catches the docs(openspec): plan #3372 Check every module of a moved prefix #3378 fault?: The case holds the plan of docs(openspec): plan #3372 Check every module of a moved prefix #3378 and its recorded git grep evidence. The replay asserts a refusal for the no-hit literal, a refusal for the literal that a created module keeps, and an acceptance for devops_cli.roadmap.stage_. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:254, src/devops_cli/roadmap/stage_eval_gates.py, src/devops_cli/roadmap/stage_eval_run.py, openspec/changes/3372-the-stage-plan-of-a-module/tasks.md:18]
    • Chosen: Replay the docs(openspec): plan #3372 Check every module of a moved prefix #3378 plan with recorded evidence. It reproduces the reported fault offline and checks both refusals and the accepted literal.
    • Rejected: Add only a unit test of check_proposal. It does not show that the recorded plan and the replay judge the real fault.
    • Rejected: Run git grep in the replay. The replay calls no git.
  • Which existing tool covers the search need?: git grep and the existing search_code and references stage tools cover the search need. No new scanner is needed. The gate code costs about 10k tokens and 1 hour to build, and nothing to keep. (best practice) [sources: src/devops_cli/roadmap/stage.py, src/devops_cli/roadmap/stage_form.py, src/devops_cli/ai/tasks/roadmap_stage_change.md]
    • Chosen: git grep and the existing stage tools. They already run on the staged commit and give the literal evidence.
    • Rejected: Add a new scanner. It duplicates the search and adds maintenance.
    • Rejected: Ask the model to judge the literal. The gate must give the same answer on each run.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    on Nov 4, 2026
  2. added
    status/new
    value/medium
    effort/medium
    on Nov 4, 2026
  3. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Priority: P2-Medium. Plans can pass the gate with a verify command that can never succeed, but the impact is limited to negative-search verifies that match their own created paths.
    • Value: Medium. Prevents a class of unsatisfiable verify commands from passing the stage gate, reducing wasted implement steps.
    • Effort: Medium. Requires modifying the stage job to run git grep, adding two refusals to check_proposal, updating the prompt, and adding an eval case; the body estimates about 1 hour.
    • Related: fix(roadmap): Check a class claim against the staged source #3407, which asks for a different change. Both add a check to check_proposal that reads the staged source, but #3407 checks design claims about a class while this candidate checks whether a verify literal can pass on the produced tree.
  4. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 4, 2026
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 1643cc7 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3410-the-stage-gate-proves-a-negative, draft pull request #3435. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Read the literal and the paths of a negative search: 8173 tokens
    2. Pass the recorded evidence to the gate: 8156 tokens
    3. Read the evidence from the eval case in the replay: 8098 tokens
    4. Add the case of the plan of the moved modules: 12179 tokens
    5. Ask the planner for the hit count: 8017 tokens

    A model review of the plan found these open findings. The stage keeps this pull request a draft with the label plan/needs-fix until a later round clears them:

    • spec_delta_wrong at specs roadmap-stage-eval, requirement "The golden set holds the case of a kept negative search", and group 4: The spec and group 4 say the case accepts the whole module prefix of the moved modules. The issue says the whole prefix is refused and only devops_cli.roadmap.stage_ is accepted. The scenario contradicts the issue and the created-module requirement. Evidence: "assert the no-hit refusal, the created-module refusal and the acceptance of the whole module prefix of the moved modules."

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • other at group 3 and group 4: The issue asks for a stage eval case that holds the plan of docs(openspec): plan #3372 Check every module of a moved prefix #3378 and its recorded evidence. The plan writes a new pytest file instead. It does not change stage_eval_cases.py, where StageCase and CaseFacts live, so the case has no field for the evidence that the replay must read. Evidence: "Read the search evidence of the case in src/devops_cli/roadmap/stage_eval_gates.py and pass it to check_proposal as the search record."

    The plan run made 2 model request(s), and used 151866 input tokens and 19005 output tokens. The model made no tool call.

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

  7. added 2 commits that reference this issue on Nov 4, 2026
  8. added
    status/planned
    and removed
    status/ready
    on Nov 4, 2026
  9. added
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 4, 2026
  10. removed
    status/in-review
    on Nov 4, 2026
  11. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-04 14:17 UTC

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

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions