Skip to content

feat(roadmap): check new commands register dry-run and mcp #3296

Not planned

Description

@dan-petty

Problem or Motivation

When a change adds a new CLI command under src/devops_cli/commands/, the project requires multiple companion registrations across contracts and tests:

  1. Dry-run classification in command-dry-run-class specification and corresponding command dry-run test callbacks (e.g. PR_COMMAND_CALLBACKS in tests/commands/test_pr_dry_run.py).
  2. MCP exposure entry in CONST_MCP_EXPOSURE_TABLE (src/devops_cli/config/constants.py) or MCP exclusion entry in tests/ai/mcp/test_mcp.py to prevent test_all_cli_commands_are_either_exposed_or_excluded failures.
  3. Generated CLI documentation (docs/CLI_REFERENCE.md and docs/commands/<family>.md).

In PR #3237 (issue #3199), the automated stage plan added devops pr evidence but omitted all companion registrations and dry-run spec updates.
check_proposal has no rule enforcing that a plan adding a CLI command includes tasks for dry-run classification, MCP registry/exclusion, and generated command documentation.

Proposed Solution & Architectural Design

  1. In src/devops_cli/roadmap/stage_change.py or stage_eval_gates.py, detect when a plan's task groups add a new CLI command to src/devops_cli/commands/.
  2. Verify that the plan includes:
    • A spec delta for command-dry-run-class assigning the command's dry-run class.
    • Tasks modifying CONST_MCP_EXPOSURE_TABLE or tests/ai/mcp/test_mcp.py.
    • Tasks running uv run devops docs generate --sync-readme and verifying uv run devops ci docs.
  3. Provide actionable feedback to the stage model during planning if any companion registrations are missing.
  4. Add unit tests in tests/roadmap/ asserting that plans adding CLI commands must include companion dry-run and MCP tasks.

Target Subsystem

src/devops_cli/roadmap/stage_eval_gates.py, src/devops_cli/roadmap/stage_change.py

Existing Tool Considered

check_proposal in stage_eval_gates.py already checks group forms and spec deltas. Extending it with command addition checks prevents missing companion registrations without adding external dependencies. Cost to build: about 6,000 tokens and 45 minutes.

Dependencies

Proposed design

Problem statement

A stage plan can add a new CLI command and leave out the registrations that the project requires for it. The dry-run class, the dry-run test callback, the MCP exposure or exclusion, and the generated documentation each fail a check after the merge. check_proposal in src/devops_cli/roadmap/stage_change.py already returns the plan problems to the stage model, and it holds no rule for these companion registrations. This change adds that rule there, with unit tests in tests/roadmap/.

Acceptance criteria

Requirement: New command detection

The stage proposal check SHALL report a devops command that a task group names and that the command tree at the staged commit does not hold.

Scenario: New subcommand in an existing module

  • WHEN A plan task says Add devops pr evidence to src/devops_cli/commands/pr.py and the staged tree holds no pr evidence command.
  • THEN check_proposal returns a finding that names pr evidence and its task group.

Requirement: No finding for an existing command

The stage proposal check SHALL NOT report a companion registration finding for a task group that names only commands that the staged tree holds.

Scenario: Edit of an existing command

  • WHEN A plan task changes the help text of devops pr list and names no new command.
  • THEN check_proposal returns no companion registration finding.

Requirement: Dry-run class delta

The stage proposal check SHALL refuse a plan that adds a CLI command without a command-dry-run-class spec delta entry for that command.

Scenario: Missing dry-run class

  • WHEN A plan adds devops pr evidence and its spec deltas hold no command-dry-run-class entry for pr evidence.
  • THEN The finding states that the plan must add the dry-run class of pr evidence to command-dry-run-class.

Requirement: Dry-run callback

The stage proposal check SHALL require a task that adds the new command to the dry-run callback table of its family.

Scenario: Missing dry-run callback

  • WHEN A plan adds devops pr evidence and no task modifies PR_COMMAND_CALLBACKS in tests/commands/test_pr_dry_run.py.
  • THEN The finding names tests/commands/test_pr_dry_run.py and the missing callback entry.

Requirement: MCP exposure or exclusion

The stage proposal check SHALL require a task that adds the new command to CONST_MCP_EXPOSURE_TABLE or records its exclusion in tests/ai/mcp/test_mcp.py.

Scenario: Missing MCP registration

  • WHEN A plan adds devops pr evidence and no task modifies CONST_MCP_EXPOSURE_TABLE or tests/ai/mcp/test_mcp.py.
  • THEN The finding states that the plan must expose pr evidence or record its exclusion.

Requirement: Generated documentation

The stage proposal check SHALL require a task for uv run devops docs generate --sync-readme and a task for uv run devops ci docs when a plan adds a CLI command.

Scenario: Missing documentation tasks

  • WHEN A plan adds devops pr evidence and its tasks omit one of the two documentation commands.
  • THEN The finding names each missing documentation command.

Requirement: One actionable report

The stage proposal check SHALL report all missing companion registrations of a new CLI command in one finding list.

Scenario: Several missing registrations

  • WHEN A plan adds devops pr evidence and misses the dry-run class, the MCP entry and both documentation commands.
  • THEN One finding list names the dry-run class, the MCP entry and both documentation commands.

Requirement: Unit test coverage

The roadmap test suite SHALL hold unit tests for a plan that adds a CLI command with and without its companion registrations.

Scenario: Complete companion plan

  • WHEN A test plan adds devops pr evidence with its dry-run class, dry-run callback, MCP entry and both documentation tasks.
  • THEN check_proposal returns no finding for a missing companion registration.

Existing Tool Considered

No open, maintained tool or library covers this need. The rule reads the plan form of this project, CONST_MCP_EXPOSURE_TABLE and the dry-run callback tables of this project, so no external code answers it. The change extends check_proposal in src/devops_cli/roadmap/stage_change.py (line 593) and its gate in src/devops_cli/roadmap/stage_eval_gates.py. Written cost to build, keep and fix that code: about 6,000 tokens and 45 minutes of elapsed time.

Key questions

  • Does the premise of this item hold at the staging commit: does check_proposal lack a rule that requires the companion registrations of a new CLI command?: Yes. check_proposal at src/devops_cli/roadmap/stage_change.py:593 returns only the spec-delta problems, the content problems, the group form, the path problems, the what-changes problems, the move-prefix and move-verify problems, the search problems, the criteria problems and the overlap problems (lines 615-624). It holds no check for a new CLI command and none for the dry-run class, the dry-run callback, the MCP entry or the generated documentation. The premise holds, and the placeholder line of the stage return is no evidence at all. [sources: src/devops_cli/roadmap/stage_change.py:593, src/devops_cli/roadmap/stage_change.py:615]
  • Which inputs does check_proposal receive, and does one of them give the command tree at the staged commit?: It receives the proposal, the known capability names, the StagedTree of the staging commit and the keyword inputs requirements, issue_body, probes, overlaps and search_evidence (src/devops_cli/roadmap/stage_change.py:593). None gives the command tree: StagedTree holds only the tracked file paths of the commit as a frozenset, with the folders, suffixes and file names above them (src/devops_cli/roadmap/stage_paths.py:76), and it holds no file text and no command name. So the check must take the command paths from the command registry that the job already imports, _COMMAND_SPECS of src/devops_cli/main.py:38, and match the devops command that a task group names against it; the tree tells only whether a task touches src/devops_cli/commands/. [sources: src/devops_cli/roadmap/stage_change.py:593, src/devops_cli/roadmap/stage_paths.py:76, src/devops_cli/main.py:38]
  • Which defect type of the roadmap-stage spec does a companion registration finding take?: No new defect type and no new gate: the finding is one more problem of the paths gate, which catches missing_path. _path_gate calls check_proposal and GATES maps GateName.PATHS to DefectType.MISSING_PATH (src/devops_cli/roadmap/stage_eval_gates.py:155, src/devops_cli/roadmap/stage_eval_gates.py:191), and a prior change that added a rule to check_proposal recorded the same choice (openspec/changes/3344-the-stage-probe-checks-client-model/design.md:10). The nine types of the verification pass stay as they are. (best practice) [sources: src/devops_cli/roadmap/stage_eval_gates.py:155, src/devops_cli/roadmap/stage_eval_gates.py:191, openspec/changes/3344-the-stage-probe-checks-client-model/design.md:10]
    • Chosen: Report it through the existing paths gate as missing_path. The rule runs in check_proposal, which the replay judges with the paths gate, and that gate catches missing_path; the finding is a missing companion registration, which is a missing path.
    • Rejected: Add a new defect type and a new gate. It changes the nine-type schema, the verification prompt and the eval cases for a rule that the paths gate already judges.
  • Where should the check for companion registrations live?: Extend check_proposal in src/devops_cli/roadmap/stage_change.py, beside the other proposal rules that src/devops_cli/roadmap/stage_eval_gates.py:161 and src/devops_cli/roadmap/stage.py:948 both call. Its findings reach the stage model. (best practice) [sources: src/devops_cli/roadmap/stage_change.py:593, src/devops_cli/roadmap/stage_eval_gates.py:161, src/devops_cli/roadmap/stage.py:948]
    • Chosen: Extend check_proposal. It already checks group forms and spec deltas, and both the job and the replay reach it.
    • Rejected: Add the rule to stage_change.py outside check_proposal. check_proposal is the one place that both callers reach, and a rule outside it would run in neither the replay nor the job's gate.
    • Rejected: Add a separate validation module. It splits related rules and adds a second call path.
  • How should the check identify a new CLI command?: Take each devops command that a task of a group touching src/devops_cli/commands/ names, and match it against _COMMAND_SPECS of src/devops_cli/main.py:38, which holds the command groups that the app registers. A command that the registry lacks is new. The StagedTree gives no command name, so the registry is the reference. (best practice) [sources: src/devops_cli/main.py:38, src/devops_cli/roadmap/stage_paths.py:76, src/devops_cli/roadmap/stage_change.py:593]
    • Chosen: Compare task-text commands with _COMMAND_SPECS. It catches a new subcommand in an existing module, and _COMMAND_SPECS is the registry that the app and the dry-run ratchet already use.
    • Rejected: Treat every task group that touches commands/ as a new command. It reports edits and refactors as new commands.
    • Rejected: Require a new plan field for new commands. It changes the plan schema and the prompt for a check that can use the existing task text.
  • Should a missing companion registration stop the plan or only warn?: Stop the plan. check_proposal returns a finding, and the stage model must correct the plan before it proceeds. (best practice) [sources: src/devops_cli/roadmap/stage_change.py:593, src/devops_cli/roadmap/stage.py:948]
    • Chosen: Stop the plan. The missing registration breaks tests and generated documentation after the merge.
    • Rejected: Warn only. A warning does not prevent the known failure.
    • Rejected: Stop only after the first plan. It adds a second path for the same rule.
  • Which MCP registration should the check accept?: Accept either an entry in CONST_MCP_EXPOSURE_TABLE or an exclusion in tests/ai/mcp/test_mcp.py. (best practice) [sources: src/devops_cli/config/constants.py, tests/ai/mcp/test_mcp.py]
    • Chosen: Exposure table or exclusion test. The existing test requires every CLI command to be exposed or excluded.
    • Rejected: Exposure table only. Not every command is safe or useful to expose through MCP.
    • Rejected: Exclusion test only. An exposed command needs its table entry with timeout and read-only flags.
  • Which dry-run evidence should the check require?: Require both a command-dry-run-class spec delta and an entry in the dry-run test callback table of the command family. (best practice) [sources: tests/commands/test_pr_dry_run.py, tests/invariants/test_dry_run_class_ratchet.py]
    • Chosen: Spec delta and test callback. The spec assigns the class and the callback test enforces it.
    • Rejected: Spec delta only. It does not prove that the command callback declares the class.
    • Rejected: Test callback only. It leaves the dry-run class undefined in the specification.
  • Which documentation tasks should the check require?: Require uv run devops docs generate --sync-readme and uv run devops ci docs. (best practice) [sources: docs/CLI_REFERENCE.md, src/devops_cli/config/constants.py]
    • Chosen: Generate and CI check. The generate command writes the reference and the CI command verifies the generated documents.
    • Rejected: Generate only. It does not verify that the generated documents pass the docs gate.
    • Rejected: CI check only. It does not regenerate the reference after the command change.
  • Which test enforces MCP exposure or exclusion for every CLI command?: test_all_cli_commands_are_either_exposed_or_excluded in tests/ai/mcp/test_mcp.py. [sources: tests/ai/mcp/test_mcp.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-06: none.
Tool: none found.

Activity

  1. added
    type/feature
    priority/p2-medium
    source/agent
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 2, 2026
  2. added
    status/ready
    and removed
    status/new
    on Nov 3, 2026
  3. devops-cli-service commented on Nov 3, 2026

    @devops-cli-service
    Contributor

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

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

    @devops-cli-service
    Contributor

    The stage job returned the item to New. The premise of the issue does not hold at the staging commit, so the job planned no change and opened no pull request.

    Evidence:

    placeholder

  5. added
    status/new
    status/ready
    and removed
    status/ready
    status/new
    on Nov 3, 2026
  6. 5 remaining items

  7. added a commit that references this issue on Nov 8, 2026
  8. added
    status/planned
    owner/service
    status/in-progress
    and removed
    status/ready
    status/planned
    on Nov 8, 2026
  9. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Stopped at group 1.

    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 stopped 1 8073827/45798 -

    Reason:

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

    Last message of the agent (a claim that no check verified): The callback is satisfied by the verify command. Let me make the tests name the callback as work, and keep the sample verify.

    The job discarded this work. The diff is cut to 20000 characters. Read it before you retry:

    diff --git a/src/devops_cli/lang/en/messages.py b/src/devops_cli/lang/en/messages.py
    index e4f077ee..e9bb28f6 100644
    --- a/src/devops_cli/lang/en/messages.py
    +++ b/src/devops_cli/lang/en/messages.py
    @@ -3603,6 +3603,21 @@ class RoadmapMessages:
             "that builds the plan's own `StageProposal` and asserts that `content_problems` returns "
             "no problem for it, because the rule that the plan adds judges the plan itself."
         )
    +    # A plan that adds a `devops` command registers its companions (#3296): the dry-run class in
    +    # the spec delta of `command-dry-run-class`, the callback in the dry-run test of its family,
    +    # and the two commands that regenerate the CLI documents.
    +    stage_problem_companion_dry_run_class: str = (
    +        "A task names the new command `{command}`, and no spec delta of `command-dry-run-class` "
    +        "names it. Add the dry-run class of `{command}` to that spec delta."
    +    )
    +    stage_problem_companion_callback: str = (
    +        "A task names the new command `{command}`, and no task names its dry-run callback test "
    +        "`{test}`. Add the callback of `{command}` to `{test}`."
    +    )
    +    stage_problem_companion_documents: str = (
    +        "A task names the new command `{command}`, and no task gives both `{generate}` and "
    +        "`{check}`. Add both commands to a task."
    +    )
         # A plan that changes a planner prompt lists and verifies the prompt-rule test (#3347).
         stage_problem_prompt_rule: str = (
             "A group changes `{path}`, and does not list `{test}` in `reads` or `changes` or verify it. "
    diff --git a/src/devops_cli/roadmap/stage/stage_change.py b/src/devops_cli/roadmap/stage/stage_change.py
    index bf910e0d..7cac41ee 100644
    --- a/src/devops_cli/roadmap/stage/stage_change.py
    +++ b/src/devops_cli/roadmap/stage/stage_change.py
    @@ -54,6 +54,7 @@ from devops_cli.roadmap.pull_form import (
         summary_length,
     )
     from devops_cli.roadmap.refine.refine import sanitize_text
    +from devops_cli.roadmap.stage.stage_companions import companion_problems
     from devops_cli.roadmap.stage.stage_constants import constant_problems
     from devops_cli.roadmap.stage.stage_criteria import (
         PENDING_PERSON,
    @@ -212,6 +213,7 @@ STAGE_EVAL_TRIGGER_PATHS: Final[tuple[str, ...]] = (
         "src/devops_cli/roadmap/stage/stage_paths.py",
         "src/devops_cli/roadmap/stage/stage_criteria.py",
         "src/devops_cli/roadmap/stage/stage_eval_gates.py",
    +    "src/devops_cli/roadmap/stage/stage_companions.py",
     )
     # The command that replays the golden set through the gates of the stage job.
     STAGE_EVAL_REPLAY: Final[str] = "uv run devops roadmap eval stage --replay"
    @@ -1150,6 +1152,7 @@ class ProposalGate(StrEnum):
         CREATES = "creates"
         REGISTRY = "registry"
         CONSTANTS = "constants"
    +    COMPANIONS = "companions"
     
     
     def check_gates(
    @@ -1197,6 +1200,7 @@ def check_gates(
                 registry if registry is not None else registry_table(Path.cwd()),
             ),
             ProposalGate.CONSTANTS: constant_problems(plan_texts(proposal), constants or {}),
    +        ProposalGate.COMPANIONS: companion_problems(proposal, read_text),
         }
     
     
    diff --git a/src/devops_cli/roadmap/stage/stage_companions.py b/src/devops_cli/roadmap/stage/stage_companions.py
    new file mode 100644
    index 00000000..a6c34f47
    --- /dev/null
    +++ b/src/devops_cli/roadmap/stage/stage_companions.py
    @@ -0,0 +1,238 @@
    +"""`devops roadmap stage`: a plan that adds a `devops` command registers its companions (#3296).
    +
    +A new command under `src/devops_cli/commands/` needs three registrations that a plan leaves out
    +easily: its dry-run class in the `command-dry-run-class` spec delta, its callback in the dry-run
    +test of its family, and the two commands that regenerate the CLI documents. `companion_problems`
    +reports each missing one. It reads the command module of the staged commit through `read_text`, so
    +it tells a new command from an edit of a command that the commit already holds.
    +"""
    +
    +from __future__ import annotations
    +
    +import re
    +from collections.abc import Callable, Mapping, Sequence
    +from pathlib import PurePosixPath
    +from typing import TYPE_CHECKING, Final
    +
    +from devops_cli.lang import MESSAGES
    +
    +if TYPE_CHECKING:
    +    from devops_cli.roadmap.stage.stage_change import (
    +        StageGroup,
    +        StageProposal,
    +        StageRequirement,
    +        StageSpec,
    +    )
    +
    +# The directory whose module names a command family: `pr.py` is `devops pr`, and a module under
    +# `k8s/` is `devops k8s`.
    +_COMMANDS_DIRECTORY: Final[str] = "src/devops_cli/commands/"
    +_SOURCE_SUFFIX: Final[str] = ".py"
    +# The capability whose spec delta gives a new command its dry-run class.
    +_DRY_RUN_CAPABILITY: Final[str] = "command-dry-run-class"
    +# The check that the generated CLI documents are in step with the code.
    +_DOCUMENTS_CHECK: Final[str] = "uv run devops ci docs"
    +# The texts of a group that a task holds, as `stage_change` renders them.
    +_TASK_FIELDS: Final[tuple[str, ...]] = (
    +    "title",
    +    "test",
    +    "implementation",
    +    "documentation",
    +    "verify",
    +)
    +# The dry-run callback test of each command family whose test file the convention
    +# `tests/commands/test_<family>_dry_run.py` does not name: one file covers several families.
    +_DRY_RUN_TESTS: Final[Mapping[str, tuple[str, ...]]] = {
    +    "ai": (
    +        "tests/commands/test_ai_local_dry_run.py",
    +        "tests/commands/test_ai_model_gateway_dry_run.py",
    +    ),
    +    "ai_ast": ("tests/commands/test_ai_local_dry_run.py",),
    +    "ai_cache": ("tests/commands/test_ai_runs_cost_cache_dry_run.py",),
    +    "ai_chaos": ("tests/commands/test_ai_model_gateway_dry_run.py",),
    +    "ai_controller": ("tests/commands/test_ai_local_dry_run.py",),
    +    "ai_cost": ("tests/commands/test_ai_runs_cost_cache_dry_run.py",),
    +    "ai_gateway": ("tests/commands/test_ai_model_gateway_dry_run.py",),
    +    "ai_harness": ("tests/commands/test_ai_local_dry_run.py",),
    +    "ai_ingest": ("tests/commands/test_ai_rag_ingest_analyze_dry_run.py",),
    +    "ai_research": ("tests/commands/test_ai_rag_ingest_analyze_dry_run.py",),
    +    "ai_runs": ("tests/commands/test_ai_runs_cost_cache_dry_run.py",),
    +    "analyze": ("tests/commands/test_ai_rag_ingest_analyze_dry_run.py",),
    +    "benchmark": ("tests/commands/test_ai_model_gateway_dry_run.py",),
    +    "config": ("tests/commands/test_config_workspace_docs_dry_run.py",),
    +    "dashboard": ("tests/commands/test_telemetry_monitoring_dry_run.py",),
    +    "devcontainer": ("tests/commands/test_devcontainer_install_tools_dry_run.py",),
    +    "docs": ("tests/commands/test_config_workspace_docs_dry_run.py",),
    +    "grafana": ("tests/commands/test_telemetry_monitoring_dry_run.py",),
    +    "install_tools": ("tests/commands/test_devcontainer_install_tools_dry_run.py",),
    +    "k8s": (
    +        "tests/commands/test_k8s_dry_run.py",
    +        "tests/commands/test_k8s_manifest_dry_run.py",
    +    ),
    +    "kustomize": ("tests/commands/test_k8s_manifest_dry_run.py",),
    +    "openspec": ("tests/commands/test_config_workspace_docs_dry_run.py",),
    +    "prometheus": ("tests/commands/test_telemetry_monitoring_dry_run.py",),
    +    "rag": ("tests/commands/test_ai_rag_ingest_analyze_dry_run.py",),
    +    "telemetry": ("tests/commands/test_telemetry_monitoring_dry_run.py",),
    +    "valkey": ("tests/commands/test_valkey_vault_dry_run.py",),
    +    "vault": ("tests/commands/test_valkey_vault_dry_run.py",),
    +    "workspace": ("tests/commands/test_config_workspace_docs_dry_run.py",),
    +}
    +# A command word of a task text: lower-case words and digits joined by single hyphens.
    +_COMMAND_WORD: Final[str] = r"[a-z][a-z0-9]*(?:-[a-z0-9]+)*"
    +
    +
    +def _generate_documents_command() -> str:
    +    """The command that regenerates the CLI documents. `stage_change` imports this module, so this
    +    module reads its constant when it runs, and not when it loads."""
    +    from devops_cli.roadmap.stage.stage_change import REGENERATE_DOCUMENTS
    +
    +    return REGENERATE_DOCUMENTS
    +
    +
    +def _family(path: str) -> str | None:
    +    """The command family that `path` belongs to, or None when it is no module under the command
    +    directory. The first part of the path below that directory names the family, so `pr.py` is
    +    `pr` and `k8s/cluster_jobs.py` is `k8s`."""
    +    if not path.startswith(_COMMANDS_DIRECTORY) or not path.endswith(_SOURCE_SUFFIX):
    +        return None
    +    parts = PurePosixPath(path.removeprefix(_COMMANDS_DIRECTORY)).parts
    +    return parts[0].removesuffix(_SOURCE_SUFFIX) if parts else None
    +
    +
    +def _task_texts(group: StageGroup) -> list[str]:
    +    """The texts of `group` that a task holds: its title and each part of the work."""
    +    return [text for field in _TASK_FIELDS if (text := getattr(group, field)) is not None]
    +
    +
    +def _commands_in(texts: Sequence[str], family: str) -> list[str]:
    +    """Each `devops <family> <command>` that `texts` name, in the order of their first appearance,
    +    once each."""
    +    pattern = re.compile(rf"\bdevops\s+{re.escape(family)}\s+(?P<command>{_COMMAND_WORD})")
    +    commands: list[str] = []
    +    for text in texts:
    +        for match in pattern.finditer(text):
    +            command = match.group("command")
    +            if command not in commands:
    +                commands.append(command)
    +    return commands
    +
    +
    +def _is_new_command(content: str | None, command: str) -> bool:
    +    """Whether the staged command module holds no registration of `command`: no quoted literal
    +    (`"<command>"`, `'<command>'` or `name="<command>"`) and no `def <command_name>(`. A module
    +    that the commit does not hold is new, so every command in it is new."""
    +    if content is None:
    +        return True
    +    name = command.replace("-", "_")
    +    quoted = (f'"{command}"', f"'{command}'", f'name="{command}"')
    +    return not any(literal in content for literal in quoted) and f"def {name}(" not in content
    +
    +
    +def _requirement_texts(requirement: StageRequirement) -> list[str]:
    +    """The texts of `requirement` that can name a command."""
    +    texts = [requirement.name, requirement.text]
    +    for scenario in requirement.scenarios:
    +        texts.extend((scenario.name, scenario.when, scenario.then))
    +    return texts
    +
    +
    +def _spec_texts(spec: StageSpec) -> list[str]:
    +    """The texts of each requirement of `spec` that can name a command."""
    +    texts: list[str] = []
    +    for requirement in (*spec.added, *spec.modified):
    +        texts.extend(_requirement_texts(requirement))
    +    return texts
    +
    +
    +def _dry_run_class_named(proposal: StageProposal, family: str, command: str) -> bool:
    +    """Whether a `command-dry-run-class` spec delta of `proposal` names the command, as
    +    `pr evidence` or `devops pr evidence`."""
    +    pattern = re.compile(rf"(?<![\w-]){re.escape(family)} {re.escape(command)}(?![\w-])")
    +    return any(
    +        pattern.search(text)
    +        for spec in proposal.specs
    +        if spec.capability == _DRY_RUN_CAPABILITY
    +        for text in _spec_texts(spec)
    +    )
    +
    +
    +def _callback_tests(family: str) -> tuple[str, ...]:
    +    """The dry-run callback test files of `family`."""
    +    return _DRY_RUN_TESTS.get(family, (f"tests/commands/test_{family}_dry_run.py",))
    +
    +
    +def _callback_named(texts: Sequence[str], family: str) -> bool:
    +    """Whether a task text names a dry-run callback test file of `family`."""
    +    return any(path in text for text in texts for path in _callback_tests(family))
    +
    +
    +def _documents_named(texts: Sequence[str], generate: str) -> bool:
    +    """Whether the plan gives both documentation commands: the generation, and the check that the
    +    generated pages are in step."""
    +    return any(generate in text for text in texts) and any(
    +        _DOCUMENTS_CHECK in text for text in texts
    +    )
    +
    +
    +def _missing_companions(
    +    proposal: StageProposal,
    +    texts: Sequence[str],
    +    family: str,
    +    command: str,
    +    generate: str,
    +) -> list[str]:
    +    """The problem of each companion registration that `proposal` misses for `command`."""
    +    messages = MESSAGES.roadmap
    +    named = f"devops {family} {command}"
    +    found: list[str] = []
    +    if not _dry_run_class_named(proposal, family, command):
    +        found.append(messages.stage_problem_companion_dry_run_class.format(command=named))
    +    if not _callback_named(texts, family):
    +        found.append(
    +            messages.stage_problem_companion_callback.format(
    +                command=named, test=" or ".join(_callback_tests(family))
    +            )
    +        )
    +    if not _documents_named(texts, generate):
    +        found.append(
    +            messages.stage_problem_companion_documents.format(
    +                command=named, generate=generate, check=_DOCUMENTS_CHECK
    +            )
    +        )
    +    return found
    +
    +
    +def companion_problems(
    +    proposal: StageProposal,
    +    read_text: Callable[[str], str | None] | None,
    +) -> list[str]:
    +    """One problem for each companion registration that a plan which adds a `devops` command
    +    leaves out (#3296): the dry-run class in a `command-dry-run-class` spec delta, the dry-run
    +    callback test of the command family, and the two commands that regenerate the CLI documents.
    +
    +    A command is new when the staged command module holds no registration of it, and a plan that
    +    adds no command adds no problem. A check with no reader judges no command, as the citation
    +    check judges no citation without one."""
    +    if read_text is None:
    +        return []
    +    texts = [text for group in proposal.groups for text in _task_texts(group)]
    +    generate = _generate_documents_command()
    +    problems: list[str] = []
    +    seen: set[tuple[str, str]] = set()
    +    for group in proposal.groups:
    +        for path in group.changes:
    +            family = _family(path)
    +            if family is None:
    +                continue
    +            for command in _commands_in(_task_texts(group), family):
    +                if (family, command) in seen or not _is_new_command(read_text(path), command):
    +                    continue
    +                seen.add((family, command))
    +                problems.extend(
    +                    _missing_companions(proposal, texts, family, command, generate)
    +                )
    +    return problems
    +
    +
    +__all__ = ["companion_problems"]
    diff --git a/tests/roadmap/stage/test_roadmap_stage_companions.py b/tests/roadmap/stage/test_roadmap_stage_companions.py
    new file mode 100644
    index 00000000..4a8c9c72
    --- /dev/null
    +++ b/tests/roadmap/stage/test_roadmap_stage_companions.py
    @@ -0,0 +1,214 @@
    +"""`devops roadmap stage`: a plan that adds a `devops` command registers its companions (#3296).
    +
    +A new command needs its dry-run class in the `command-dry-run-class` spec delta, its callback in
    +the dry-run test of its family, and the two documentation commands. `companion_problems` reports
    +each companion that a plan leaves out, and it reports no command that the staged tree holds. A
    +plan that adds a rule of the plan check gives the test that accepts its own plan (#3404), so
    +`content_problems` finds no problem in the plan of this change.
    +"""
    +
    +from __future__ import annotations
    +
    +from collections.abc import Callable, Mapping
    +
    +from devops_cli.roadmap.stage.stage_change import (
    +    REGENERATE_DOCUMENTS,
    +    StageGroup,
    +    StageProposal,
    +    StageSpec,
    +    content_problems,
    +)
    +from devops_cli.roadmap.stage.stage_companions import companion_problems
    +from tests.support.builders import make_stage_proposal
    +
    +COMMANDS = "src/devops_cli/commands/"
    +PR_MODULE = f"{COMMANDS}pr.py"
    +WORKSPACE_MODULE = f"{COMMANDS}workspace.py"
    +PR_DRY_RUN_TEST = "tests/commands/test_pr_dry_run.py"
    +WORKSPACE_DRY_RUN_TEST = "tests/commands/test_config_workspace_docs_dry_run.py"
    +DOCS_CHECK = "uv run devops ci docs"
    +MESSAGES_FILE = "src/devops_cli/lang/en/messages.py"
    +COMPANIONS_FILE = "src/devops_cli/roadmap/stage/stage_companions.py"
    +CHANGE_FILE = "src/devops_cli/roadmap/stage/stage_change.py"
    +COMPANIONS_TEST = "tests/roadmap/stage/test_roadmap_stage_companions.py"
    +
    +# The shape of a command module, as `src/devops_cli/commands/pr.py` registers its commands: a
    +# quoted literal for `pr list`, and a function definition for `pr view`.
    +PR_MODULE_SAMPLE = '''\
    +@app.command("list")
    +def list_prs(...):
    +    ...
    +
    +@app.command()
    +def view(...):
    +    ...
    +'''
    +# The shape of `src/devops_cli/commands/workspace.py`: it holds no `add` command.
    +WORKSPACE_MODULE_SAMPLE = '''\
    +@app.command()
    +def sync(...):
    +    ...
    +'''
    +NEW_COMMAND = "Write `test_pr_evidence_plans_its_requests` for the new command `devops pr evidence`"
    +
    +
    +def _reader(contents: Mapping[str, str]) -> Callable[[str], str | None]:
    +    """The reader of the staged commit: the text of each path that `contents` holds, and None for
    +    every other path."""
    +    return contents.get
    +
    +
    +def _group(
    +    module: str,
    +    test: str,
    +    *,
    +    changes: list[str] | None = None,
    +    documentation: str | None = None,
    +) -> StageGroup:
    +    """The sample group, which reads and changes `module` and writes `test`."""
    +    sample = make_stage_proposal().groups[0]
    +    return sample.model_copy(
    +        update={
    +            "reads": [module],
    +            "changes": changes if changes is not None else [module],
    +            "creates": [],
    +            "creates_lines": {},
    +            "test": test,
    +            "implementation": f"Add the command to `{module}`",
    +            "documentation": documentation,
    +        }
    +    )
    +
    +
    +def _dry_run_spec(command: str) -> StageSpec:
    +    """The `command-dry-run-class` delta that names `command`."""
    +    return StageSpec.model_validate(
    +        {
    +            "capability": "command-dry-run-class",
    +            "modified": [
    +                {
    +                    "name": "pr-commands-request-plans",
    +                    "text": (
    +                        f"Each external-request command of `devops pr`, such as `{command}`, SHALL "
    +                        "carry the `request-plan` dry-run class."
    +                    ),
    +                    "scenarios": [
    +                        {
    +                            "name": f"Dry run on {command}",
    +                            "when": f"user executes `{command} --dry-run`",
    +                            "then": (
    +                                "no external request is made and the planned requests are printed"
    +                            ),
    +                        }
    +                    ],
    +                }
    +            ],
    +        }
    +    )
    +
    +
    +def test_a_new_command_with_no_companion_registration_is_refused() -> None:
    +    plan = make_stage_proposal(groups=[_group(PR_MODULE, NEW_COMMAND)])
    +
    +    problems = companion_problems(plan, _reader({PR_MODULE: PR_MODULE_SAMPLE}))
    +
    +    assert len(problems) == 3
    +    assert any(
    +        "command-dry-run-class" in problem and "devops pr evidence" in problem
    +        for problem in problems
    +    )
    +    assert any(PR_DRY_RUN_TEST in problem for problem in problems)
    +    assert any(
    +        REGENERATE_DOCUMENTS in problem and DOCS_CHECK in problem for problem in problems
    +    )
    +
    +
    +def test_a_new_command_with_every_companion_registration_passes() -> None:
    +    test = (
    +        "Write `test_pr_evidence_plans_its_requests` in `tests/commands/test_pr_dry_run.py` for "
    +        "the new command `devops pr evidence`"
    +    )
    +    plan = make_stage_proposal(
    +        groups=[
    +            _group(
    +                PR_MODULE,
    +                test,
    +                documentation=f"Run `{REGENERATE_DOCUMENTS}` and `{DOCS_CHECK}`",
    +            )
    +        ],
    +        specs=[_dry_run_spec("devops pr evidence")],
    +    )
    +
    +    assert companion_problems(plan, _reader({PR_MODULE: PR_MODULE_SAMPLE})) == []
    +
    +
    +def test_an_edit_of_an_existing_command_is_no_new_command() -> None:
    +    plan = make_stage_proposal(groups=[_group(PR_MODULE, "Change the help of `devops pr list`")])
    +
    +    assert companion_problems(plan, _reader({PR_MODULE: PR_MODULE_SAMPLE})) == []
    +
    +
    +def test_an_edit_of_a_function_defined_command_is_no_new_command() -> None:
    +    plan = make_stage_proposal(groups=[_group(PR_MODULE, "Chang

    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.
    The push of the commits that passed failed too.
    GitHub did not open the draft pull request of feat/3296-check-new-commands-register-dry-run: GitHub refused POST /repos/dan-petty/devops-cli/pulls (HTTP 422): Validation Failed: 'No commits between main and feat/3296-check-new-commands-register-dry-run'. The job removed the branch from origin.

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

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261108-035237-9613 ended: succeeded.
    Image digest: sha256:df15d6fee1e08fa36b689fb1856024f5229f204279d65d0ca78c5a680e1732cc

    The last lines of its log:

    Tool call: read_file, ok.
    Tool call: shell, started: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_companions.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_gates.py
    Tool call: shell, started: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_eval_gates.py
    Tool call: shell, program uv, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_content.py
    Tool call: shell, started: uv run devops ci test tests/roadmap/stage/test_roadmap_stage_plan.py
    Tool call: shell, program uv, ok.
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops roadmap plan-recheck --source ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops roadmap eval stage ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n <masked> src/devops_cli/roadmap/plan_recheck.py | head ...
    Tool call: shell, program grep, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: grep -n <masked> -A 12 src/devops_cli/roadmap/plan_read.py ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run python -c __import__("pathlib").Path(".data/agent/scratch").mkdir(parents=<masked>
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_plan.py
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_rule.py
    Tool call: shell, program uv, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: uv run python .data/agent/scratch/probe_rule.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run ruff check src/devops_cli/roadmap/stage/stage_companions.py src/devops_cli/roadmap/stage/stage_change.py ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run mypy --strict src/devops_cli/roadmap/stage/stage_companions.py src/devops_cli/roadmap/stage/stage_change.py
    Tool call: shell, program uv, ok.
    Tool call: shell, started: uv run devops ci --help
    Tool call: shell, program uv, ok.
    Failure class limit_reached. Action left: raise_limit.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 12m 37s
    
  12. removed
    owner/service
    on Nov 8, 2026
  13. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.

  14. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    Triage under #6519 (owner instruction of 2026-11-30). This item adds or extends a hand-written gate, refusal, context block or plan-shape rule of the stage or implement job. #6519 found that 263 of about 900 issues in four weeks added gates and none replaced the engine; stage now runs on stock Coder, where the agent reads the repository itself and runs the OpenSpec checks in its loop. The code paths that this item names have also moved (for example src/devops_cli/roadmap/stage/stage_change.py). If the failure class still shows in graded attempts (plan_defect), file a new item from that evidence. Closed as not planned.

  15. removed
    status/blocked
    on Nov 30, 2026
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/lowpriority/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