Skip to content

feat(roadmap): the plan check requires a new rule to accept its own plan #3404

Closed

Description

@dan-petty

Problem or Motivation

A plan that adds a plan-check rule can write text that the new rule refuses. The checks of the stage job never run a proposed rule on the plan that proposes it, so the plan can pass every gate and still refuse itself.

The plan of PR #3349 (for #3343) is an example. Its group 1 test task said that a proposal "says a finding has kind: placeholder". The rule under plan refuses a sentence that names a finding and holds a kind value outside DefectType. The plan therefore held the exact text that its own rule refuses. A later staging of the same plan would return a problem for the rule it adds.

#3386 makes the conflict certain. It asks a plan that adds a gate to quote the defect that the gate refuses. A plan that quotes an unknown finding type, as #3386 requires, then holds the text that a prose rule such as #3343 refuses.

content_problems in src/devops_cli/roadmap/stage_change.py judges the text of a plan. It does not build the plan's own StageProposal and run the new rule on it.

Proposed Solution & Architectural Design

  1. In content_problems in src/devops_cli/roadmap/stage_change.py, when a plan changes src/devops_cli/roadmap/stage_change.py and adds a rule that reads the text of a plan, require a task group test that builds the plan's own StageProposal and asserts that the new rule returns no problem for it.
  2. Alternatively, the stage job builds the plan's own StageProposal from the reply and runs the new rule on it. It refuses the plan when the rule would refuse the plan text.
  3. Add a case in tests/roadmap/test_roadmap_stage_plan.py for a plan that adds a text rule without a test that the rule accepts its own proposal, and one for a plan with that test.
  4. Name the rule in src/devops_cli/ai/tasks/roadmap_stage_change.md beside the other checks of a plan.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

No open, maintained tool checks a plan against the rule that the plan adds. The stage check is the only place that reads both the rule and the plan text. The project builds the check itself: about 6,000 tokens to build, about 1,500 tokens to keep and fix, and about 4 hours elapsed.

Proposed design

Problem statement

A plan that adds a rule to check plan text can hold text that the new rule refuses. The stage checks never run the proposed rule on the plan itself. This change adds a stage check that requires such a plan to include a test. The test builds the plan's own StageProposal and asserts that the new rule returns no problem.

Acceptance criteria

Requirement: Missing self-acceptance test

A plan with a behavior group that changes src/devops_cli/roadmap/stage_change.py MUST include a test text that names StageProposal, content_problems and no problem.

Scenario: Plan without the test is refused

  • WHEN check_proposal receives a valid proposal with a behavior group that changes src/devops_cli/roadmap/stage_change.py and no group test text names both symbols and no problem.
  • THEN check_proposal returns one problem that names StageProposal and content_problems.

Requirement: Present self-acceptance test

A plan with a behavior group that changes src/devops_cli/roadmap/stage_change.py MUST pass the self-acceptance rule when one group test text names StageProposal, content_problems and no problem.

Scenario: Plan with the test is accepted

  • WHEN check_proposal receives a valid proposal with a behavior group that changes src/devops_cli/roadmap/stage_change.py and a group test text that names both symbols and no problem.
  • THEN check_proposal returns no self-acceptance problem.

Requirement: No self-acceptance rule for other plans

A plan whose groups change no path in src/devops_cli/roadmap/stage_change.py MUST NOT be refused by the self-acceptance rule.

Scenario: Plan that changes another file is accepted

  • WHEN check_proposal receives a valid proposal whose groups change only src/devops_cli/roadmap/stage.py.
  • THEN check_proposal returns no self-acceptance problem.

Requirement: Staging prompt states the rule

The staging prompt src/devops_cli/ai/tasks/roadmap_stage_change.md MUST state the self-acceptance test rule beside the other checks of a plan.

Scenario: Prompt names the self-acceptance test

  • WHEN A test loads the prompt with load_task_prompt.
  • THEN The prompt text contains StageProposal, content_problems and the self-acceptance test rule.

Existing Tool Considered

No alternatives check has run. No open, maintained tool checks a plan against the rule that the plan adds. The stage check is the only place that reads both the rule and the plan text. The project builds the check itself: about 6,000 tokens to build, about 1,500 tokens to keep and fix, and about 4 hours elapsed.

Key questions

  • Where does the stage check enforce the self-acceptance test rule?: Add the rule to content_problems in src/devops_cli/roadmap/stage_change.py. The stage job and the replay both call this function through check_proposal. One rule set judges both paths. (best practice) [sources: src/devops_cli/roadmap/stage_change.py, src/devops_cli/roadmap/stage_eval_gates.py]
    • Chosen: Add the rule to content_problems. The stage job and the replay call the same function, so the rule needs no second seam.
    • Rejected: Build the plan's own StageProposal in the stage job and run the new rule. The new rule is not implemented at staging time, so the stage job cannot run it.
    • Rejected: State the rule in the prompt only. The prompt gives guidance and no gate, so a plan can still pass and refuse itself.
  • When does the self-acceptance test rule apply?: Apply the rule when a behavior group changes src/devops_cli/roadmap/stage_change.py. A behavior group adds or changes code behavior, so it marks a new or changed plan rule. An other group that only refactors the file does not trigger the rule. (best practice) [sources: src/devops_cli/roadmap/stage_change.py, src/devops_cli/ai/tasks/roadmap_stage_change.md]
    • Chosen: A behavior group that changes stage_change.py. It marks added behavior and avoids a test demand for refactors and documents.
    • Rejected: Any change to stage_change.py. It refuses a refactor or a comment change that adds no rule.
    • Rejected: A text keyword in why or what_changes. The text is free prose and a fragile trigger.
  • Which test text satisfies the self-acceptance test rule?: Require one group test text to name StageProposal, content_problems and the phrase no problem. The check accepts any group, not only the group that changes stage_change.py. (best practice) [sources: src/devops_cli/roadmap/stage_change.py, tests/roadmap/test_roadmap_stage_plan.py, openspec/changes/3343-the-stage-probe-checks-defecttype-membership/design.md:10]
    • Chosen: Required symbols and the phrase no problem. The check is deterministic and matches the test the issue asks for.
    • Rejected: Exact sentence match. A small wording change would fail a valid plan.
    • Rejected: No static check and rely on review. The stage gate would still pass a plan that refuses itself.
  • Does the plan check have enough data to apply the rule?: Yes. StageProposal holds each group with its kind, changes and test text. content_problems receives the whole proposal. [sources: src/devops_cli/roadmap/stage_change.py]
  • Can a test build a StageProposal and call content_problems offline?: Yes. Existing tests build proposals with make_stage_proposal and call check_proposal and content_problems with no network or cluster. [sources: tests/roadmap/test_roadmap_stage_plan.py, tests/roadmap/test_roadmap_stage_content.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    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. A plan can pass every gate and still refuse itself, which is a correctness gap in the validation pipeline.
    • Value: Medium. It closes a class of self-contradictory plans that no current gate catches.
    • Effort: Medium. It changes content_problems, adds two test cases, and names the rule in the task document.
    • Related: feat(roadmap): a plan that adds a gate quotes the defect the gate refuses #3386, which asks for a different change. Both concern a plan that adds a rule or gate, but #3386 requires quoting the refused defect while the candidate requires the new rule to accept the plan's own text.
  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 4e0e243 (see proposed design in issue body).

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

    @devops-cli-service
    Contributor

    Staged: branch feat/3404-the-plan-check-requires-a-new, draft pull request #3409. 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. Refuse a plan whose own rule would refuse it: 22691 tokens
    2. State the self-acceptance rule in the staging prompt: 27104 tokens
    3. Keep the roadmap stage tests green after the new problem: 14822 tokens

    The plan run made 3 model request(s), and used 236067 input tokens and 12120 output tokens. The model made no tool call.

  7. dan-petty commented on Nov 4, 2026

    @dan-petty
    OwnerAuthor

    PR #3408 (the plan for #3405) is another instance.

    The plan adds a rule that refuses a task text that names MESSAGES.roadmap unless a group changes src/devops_cli/lang/en/messages.py. Group 1 of the plan named MESSAGES.roadmap in its tasks and did not list messages.py in changes. The plan passed every check, and the rule it adds would refuse it.

    The omitted file was also a real defect: the plan needed a new RoadmapMessages entry in messages.py for the problem text, and the project holds every output string in that catalog. The fixed plan lists messages.py in group 1.

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

    @devops-cli-service
    Contributor

    Stopped at fix.

    Failed check: Service Image. The end of its log:

    et update && apt-get upgrade -y && apt-get install -y --no-install-recommends     git     ca-certificates     && rm -rf /var/lib/apt/lists/*     && rm -rf /usr/local/lib/python3.14/site-packages/pip* /usr/local/bin/pip*
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.6928586Z #21 CANCELED
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.6928972Z ------
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.6930591Z  > [builder  7/12] ADD --checksum=sha256:77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b     https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_amd64.tar.gz /tmp/gh_amd64.tar.gz:
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.6932275Z ------
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.6937409Z ERROR: failed to build: failed to solve: digest mismatch sha256:bef140a1a96994029153dca8c00b1750b9a5a764fb9db2dc68d7bb40e8a29e8a: sha256:77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.7012248Z ##[group]Reference
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8199102Z builder-48eee801-d45b-495a-88cc-75d3f0427a83/builder-48eee801-d45b-495a-88cc-75d3f0427a830/olipp0i4s8w9i71tfeo46g3jy
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8201115Z ##[endgroup]
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8202183Z ##[group]Check build summary support
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8204450Z Build summary supported!
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8205990Z ##[endgroup]
    Service Image\tBuild and Load Service Image\t2026-11-05T15:39:04.8229766Z ##[error]buildx failed with: failed to build: failed to solve: digest mismatch sha256:bef140a1a96994029153dca8c00b1750b9a5a764fb9db2dc68d7bb40e8a29e8a: sha256:77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b
    

    Failure class: limit_reached.
    Action taken: none.
    Action left: raise_limit: raise the limit that the run went over.

    Step Status Attempts Tokens in/out Last failing command
    group 1 done 1 3253225/15971 pytest on base: tests/roadmap/test_roadmap_stage_content.py
    group 2 done 1 3318133/9585 pytest on base: tests/roadmap/test_roadmap_stage_prompt_rules.py
    fix stopped 1 8116441/62425 Service Image

    Reason:

    LimitReached: The step spent its budget `roadmap.implement.step_token_budget=8000000`.
    Refused commands: git 2, grep 2, uv 1, other 1. Other retries: 0.
    

    Last message of the agent (a claim that no check verified): Now let me check the premise evidence once more and look at the exact Dockerfile region I will change:

    The job discarded this work. Read it before you retry:

    diff --git a/Dockerfile b/Dockerfile
    index eb3d1f5d..60a7e380 100644
    --- a/Dockerfile
    +++ b/Dockerfile
    @@ -9,6 +9,36 @@ ARG TARGETARCH=amd64
     
     COPY --from=uv /uv /uvx /usr/local/bin/
     
    +# curl fetches the gh archives below. It is in this stage for that one step, and the Service stage
    +# builds on the Python base image, so the Service image does not get it.
    +RUN apt-get update && apt-get install -y --no-install-recommends curl \
    +    && rm -rf /var/lib/apt/lists/*
    +
    +# gh, from its release at the pin. Each SHA-256 is the asset `digest` of that release
    +# (`gh api repos/cli/cli/releases/tags/v2.102.1`) and its line in `gh_2.102.1_checksums.txt`. The
    +# fetch checks the digest and fetches again when a response does not match it: the release host
    +# answered a pull request build with a body that hashed to another digest (#3404), and one bad
    +# response must cost a retry and not the build. Bytes that never match still fail the build. This
    +# step reads no source, so a change to `src/` reuses its layer.
    +RUN set -eu; \
    +    fetch() { \
    +      for attempt in 1 2 3; do \
    +        if curl -fsSL --retry 2 --retry-all-errors -o "$3" "$1" \
    +           && echo "$2  $3" | sha256sum -c -; then \
    +          return 0; \
    +        fi; \
    +        echo "gh: $1 did not match sha256 $2 on attempt $attempt" >&2; \
    +      done; \
    +      return 1; \
    +    }; \
    +    fetch "https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_amd64.tar.gz" \
    +      77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b /tmp/gh_amd64.tar.gz; \
    +    fetch "https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_arm64.tar.gz" \
    +      5019b3cc6e8a03bb4d88600f8dbda2add8e6407705c159b0c63151036e77a1af /tmp/gh_arm64.tar.gz
    +RUN tar -xzf "/tmp/gh_${TARGETARCH}.tar.gz" -C /tmp && \
    +    install -m 755 "/tmp/gh_2.102.1_linux_${TARGETARCH}/bin/gh" /usr/local/bin/gh && \
    +    rm -rf /tmp/gh*
    +
     WORKDIR /app
     ENV UV_COMPILE_BYTECODE=1 \
         UV_PYTHON_DOWNLOADS=never
    @@ -20,10 +50,26 @@ ENV TIKTOKEN_CACHE_DIR=/app/.cache/tiktoken
     RUN uv sync --locked --no-dev --no-editable && \
         /app/.venv/bin/python -c "import tiktoken; tiktoken.get_encoding('cl100k_base'); tiktoken.get_encoding('o200k_base')"
     
    -ADD --checksum=sha256:77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b \
    -    https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_amd64.tar.gz /tmp/gh_amd64.tar.gz
    -ADD --checksum=sha256:5019b3cc6e8a03bb4d88600f8dbda2add8e6407705c159b0c63151036e77a1af \
    -    https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_arm64.tar.gz /tmp/gh_arm64.tar.gz
    +# gh, from its release at the pin. Each SHA-256 is the asset `digest` of that release
    +# (`gh api repos/cli/cli/releases/tags/v2.102.1`) and its line in `gh_2.102.1_checksums.txt`. The
    +# fetch checks the digest and fetches again when a response does not match it: the release host
    +# answered a pull request build with a body that hashed to another digest (#3404), and one bad
    +# response must cost a retry and not the build. Bytes that never match still fail the build.
    +RUN set -eu; \
    +    fetch() { \
    +      for attempt in 1 2 3; do \
    +        if curl -fsSL --retry 2 --retry-all-errors -o "$3" "$1" \
    +           && echo "$2  $3" | sha256sum -c -; then \
    +          return 0; \
    +        fi; \
    +        echo "gh: $1 did not match sha256 $2 on attempt $attempt" >&2; \
    +      done; \
    +      return 1; \
    +    }; \
    +    fetch "https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_amd64.tar.gz" \
    +      77b9e297e94c50336823d0f84de7ef1be60cba704601fa0d98f129f47a94987b /tmp/gh_amd64.tar.gz; \
    +    fetch "https://github.com/cli/cli/releases/download/v2.102.1/gh_2.102.1_linux_arm64.tar.gz" \
    +      5019b3cc6e8a03bb4d88600f8dbda2add8e6407705c159b0c63151036e77a1af /tmp/gh_arm64.tar.gz
     RUN tar -xzf "/tmp/gh_${TARGETARCH}.tar.gz" -C /tmp && \
         install -m 755 "/tmp/gh_2.102.1_linux_${TARGETARCH}/bin/gh" /usr/local/bin/gh && \
         rm -rf /tmp/gh*
    @@ -42,8 +88,8 @@ RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
     # The runner: the pod of a cluster Job in which `devops roadmap implement` runs its steps (#2667).
     # It adds to the builder's venv the dev dependencies that the steps' tests and checks run (pytest,
     # ruff, mypy, pre-commit and the rest of the dev group), and git, which a step and the job need. The
    -# builder holds uv, gh, the Node runtime and the pinned OpenSpec already. The stage adds the tools
    -# that the gate and the hooks need (#3072): curl and jq from apt, and promtool at its pin in
    +# builder holds uv, gh, the Node runtime, curl and the pinned OpenSpec already. The stage adds the
    +# tools that the gate and the hooks need (#3072): curl and jq from apt, and promtool at its pin in
     # `tools.lock`. actionlint, shellcheck and Trivy are not here: the image scan fails on the newest
     # release of each (see `NOT_IN_RUNNER`). The list of the tools is `RUNNER_TOOLS` in
     # `src/devops_cli/roadmap/runner_tools.py`, and the last step of the stage checks every one of them. This stage comes before `service`, so that a build with no

    The item is Blocked, and the job will not run it. Fix the cause. Then comment implement: retry. The Service clears the stop on its own when a new runner image rolls out, but only if a retry can fix the class of the stop and the limits of roadmap.implement.digest_clears_per_class and roadmap.implement.digest_clears_per_item allow it.

  11. added
    status/blocked
    and removed
    status/in-progress
    on Nov 5, 2026
  12. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261105-150105-8e54 ended: succeeded.
    Image digest: sha256:8db59b516837519d266dfa65de12581c242b8c7de3e2501820d66fb0fdab5e08

    The last lines of its log:

    Tool call: write_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_fetch_step.py
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_real_fetch.py
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_tar.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/invariants/test_service_image.py ...
    Tool call: shell, program uv, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: uv run devops ci test tests/invariants ...
    Tool call: shell, program uv, ok.
    Tool call: read_file, ok.
    Tool call: grep, ok.
    Tool call: read_file, ok.
    Tool call: edit_file, ok.
    Tool call: edit_file, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: uv run devops ci --check --only ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --only openspec
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops install-tools --tool kubectl
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_fetch_step.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_real_fetch.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/invariants/test_service_image.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: git diff
    Tool call: shell, program git, ok.
    Tool call: edit_file, ok.
    Failure class limit_reached. Action left: raise_limit.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 1h 2m 36s
    
  13. removed
    owner/service
    on Nov 5, 2026
  14. removed
    status/blocked
    on Nov 6, 2026
  15. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor
  16. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 06:16 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/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions