Repository navigation
Description
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 listas a person caller on a tf/github stack. - THEN The command starts
tofu state listin 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 showas an agent caller on a tf/github stack whoseagent_accessisplan. - THEN The command exits with a refusal and starts no
tofu stateprocess.
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 showas a person caller on a tf/github stack whoseagent_accessisplan. - THEN The command starts
tofu state showand 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 listas an agent caller on a tf/github stack whoseagent_accessissafeand 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 tfsubcommands exist before this change?: The documented subcommands are init, plan, apply, destroy, output, validate, fmt, status, graph, drift, lint, notify-plan and cost. Nostatesubcommand exists. [sources: docs/CLI_REFERENCE.md, src/devops_cli/commands/tf.py] - How should
devops tf statepass its arguments to OpenTofu?: Pass the remaining arguments totofu stateunchanged. 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_accessguard. Refuse before anytofu stateprocess 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 statereuse 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
devops-cli-service commentedon Nov 25, 2026
tf, and .github/labels.yml declares no scope/tf label. Add the label to the file to give the scope to this item.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.devops-cli-service commentedon Nov 25, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.