Skip to content

feat(tf): refuse agent state changes in tf/github #7061

Backlog

Description

@devops-cli-service

Split from #5320.

The issue title asks to refuse agent state changes in tf/github. No devops tf state command exists. The documented commands are init, plan, apply, destroy, output, validate, fmt, status, graph, drift, lint, notify-plan and cost. commands/tf.py defines no state command. A test cannot run a subcommand that does not exist. This part is deferred so the plan, apply and destroy guard can ship and be tested now. Acceptance criteria: - The tf command MUST add a devops tf state subcommand that runs tofu state for a tf/github stack. - The tf command MUST refuse the devops tf state subcommand for an agent caller on a tf/github stack whose agent_access is plan. - The tf command MUST allow a person caller to run the same devops tf state subcommand. - The tf command MUST apply the same pre-plan core budget floor and reader App credentials to an agent state read when those checks apply.

Proposed design

Problem statement

The tf command has no devops tf state subcommand. The project cannot refuse an agent state operation on a tf/github stack whose agent_access is plan. This item adds the subcommand and applies the existing caller, budget and credential checks.

Acceptance criteria

Requirement: State subcommand runs OpenTofu

The tf command MUST add a devops tf state subcommand that runs tofu state with the remaining arguments for a tf/github stack.

Scenario: Person runs state list

  • WHEN A test invokes devops tf state list as a person caller on a tf/github stack.
  • THEN The command starts tofu state list in the stack directory and returns the exit code of that process.

Requirement: Agent at plan is refused

The tf command MUST refuse the devops tf state subcommand for an agent caller on a tf/github stack whose agent_access is plan.

Scenario: Agent runs state show

  • WHEN A test invokes devops tf state show as an agent caller on a tf/github stack whose agent_access is plan.
  • THEN The command exits with a refusal and starts no tofu state process.

Requirement: Person at plan is allowed

The tf command MUST allow a person caller to run the devops tf state subcommand on a tf/github stack whose agent_access is plan.

Scenario: Person runs state show

  • WHEN A test invokes devops tf state show as a person caller on a tf/github stack whose agent_access is plan.
  • THEN The command starts tofu state show and does not refuse.

Requirement: Pre-plan checks apply to agent state read

The tf command MUST apply the same pre-plan core budget floor and reader App credentials to an agent state read when those checks apply.

Scenario: Agent state read uses pre-plan helpers

  • WHEN A test invokes devops tf state list as an agent caller on a tf/github stack whose agent_access is safe and that enables the core budget floor and reader App credentials.
  • THEN The command calls the same core budget floor and reader App credential helpers as the pre-plan path before it starts tofu state list.

Existing Tool Considered

No alternatives check has run. OpenTofu provides tofu state and its state subcommands. No open tool covers the project's caller and agent_access guard. The change builds a thin wrapper. Cost: about 1,500 tokens and 1 hour to build the command, guard and tests; about 500 tokens per year to keep and fix it.

Key questions

  • Which devops tf subcommands exist before this change?: The documented subcommands are init, plan, apply, destroy, output, validate, fmt, status, graph, drift, lint, notify-plan and cost. No state subcommand exists. [sources: docs/CLI_REFERENCE.md, src/devops_cli/commands/tf.py]
  • How should devops tf state pass its arguments to OpenTofu?: Pass the remaining arguments to tofu state unchanged. OpenTofu owns the set of state subcommands. (best practice) [sources: src/devops_cli/commands/tf.py]
    • Chosen: Pass through the remaining arguments. Keeps the wrapper small and follows the OpenTofu CLI.
    • Rejected: Define a fixed allowlist of state subcommands. Adds code to update for each OpenTofu release.
  • Which guard should refuse an agent on a plan stack?: Reuse the existing tf caller and agent_access guard. Refuse before any tofu state process starts. (best practice) [sources: CONTEXT.md, src/devops_cli/commands/tf.py]
    • Chosen: Reuse the existing tf guard. Keeps one access policy for all tf commands.
    • Rejected: Add a state-specific guard. Duplicates policy and risks drift.
  • Should devops tf state reuse the pre-plan core budget floor and reader App credentials?: Yes. When those checks apply, call the same pre-plan helpers before the state read. (best practice) [sources: src/devops_cli/commands/tf.py, docs/CLI_REFERENCE.md]
    • Chosen: Reuse the pre-plan checks. Keeps agent state reads under the same budget and credential policy.
    • Rejected: Run no pre-plan checks. Lets a state read bypass the guard.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    source/agent
    status/new
    value/medium
    effort/medium
    on Nov 25, 2026
  2. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor
    • Scope: none. The title has the scope tf, and .github/labels.yml declares no scope/tf label. Add the label to the file to give the scope to this item.
    • Related: feat(tf): refuse agent apply, destroy and state changes in tf/github #5320, which asks for a different change. Both target agent_access guards on tf/github stacks; #5320 is the umbrella covering apply, destroy, and state, while this candidate covers only the state subcommand guard.
  3. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

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-mediumsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions