Skip to content

Conversation

@gt-oai
Copy link
Contributor

@gt-oai gt-oai commented Jan 30, 2026

requirements.toml should be able to specify rules which always run.

My intention here was that these rules could only ever be restrictive, which means the decision can be "prompt" or "forbidden" but never "allow". A requirement of "you must always allow this command" didn't make sense to me, but happy to be gaveled otherwise.

Rules already applies the most restrictive decision, so we can safely merge these with rules found in other config folders.

@gt-oai gt-oai marked this pull request as ready for review January 30, 2026 00:42
Copy link
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fill out the PR body.

cmd.iter().map(std::string::ToString::to_string).collect()
}

fn allow_all(_: &[String]) -> Decision {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the arg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inlined this

#[test]
fn deserialize_exec_policy_requirements() -> Result<()> {
let toml_str = r#"
[exec_policy]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not use exec_policy in any API since we have moved to "rules" as the public-facing name?

Though honestly, it may soon become permissions...

Comment on lines 678 to 682
let requirements_toml_file = if cfg!(windows) {
"C:\\etc\\codex\\requirements.toml"
} else {
"/etc/codex/requirements.toml"
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in a helper function or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't material to the test

#[error("exec policy prefix_rule at index {rule_index} has an empty justification")]
EmptyJustification { rule_index: usize },

#[error("exec policy prefix_rule at index {rule_index} is missing a decision")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"rules"

"#;

let parsed: RequirementsExecPolicyToml = from_str(toml_str)?;
let err = parsed.to_policy().expect_err("allow decision not allowed");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't the provider of requirements.toml allowed to declare a rule with decision = "allow"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified the error message as to why this is the case

#[test]
fn empty_prefix_rules_is_rejected() -> anyhow::Result<()> {
let toml_str = r#"
prefix_rules = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this mean that an end-user is not allowed to define any rules?

return Ok(policy);
};

let mut combined_rules = policy.rules().clone();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should combine rules in this case, should we? Shouldn't requirements_policy be the only rules you can set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO users (and repo config) should be allowed to set rules that are more restrictive than the ones in requirements_policy. Rules already apply the most restrictive matching decision, so additional rules feels harmless to me.

I cannot think of a genuine use for "admins can require that command X is always allowed, regardless of what the user wants". Perhaps it would be good to e.g. always allow bazel build or something, but that feels more in the camp of sensible default that should be included in the repo, rather than a strict requirement that prevents a user's other rules from loading.

@jif-oai
Copy link
Collaborator

jif-oai commented Jan 30, 2026

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gt-oai gt-oai force-pushed the gt/reqs-to-rules branch 3 times, most recently from c175b27 to 50bef97 Compare January 30, 2026 13:10
@gt-oai gt-oai merged commit 5662eb8 into main Jan 30, 2026
32 checks passed
@gt-oai gt-oai deleted the gt/reqs-to-rules branch January 30, 2026 18:04
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants