Skip to content

What we have learned applying formal methods to control AI agents - #63

Merged
zredlined merged 6 commits into
mainfrom
codex/learning-formal-methods-agent-policy-prover
Sep 14, 2026
Merged

zredlined merged 6 commits into
mainfrom
codex/learning-formal-methods-agent-policy-prover

Conversation

@zredlined

Copy link
Copy Markdown
Collaborator

Summary

  • publish the Dev Note “Learning Formal Methods by Building an Agent Policy Prover”
  • preserve the supplied prose while adding Markdown structure, source links, and publishing metadata
  • add an accessible static rendering of the supplied approval flowchart
  • regenerate the Dev Notes index and navigation

Validation

  • python3 tests/test_render_dev_notes.py
  • scripts/build-docs.sh
  • verified the formatted article retains the supplied prose word-for-word

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Documentation preview

The preview has been removed.

@zredlined zredlined changed the title Learning Formal Methods by Building an Agent Policy Prover What we have learned applying formal methods to control AI agents Sep 14, 2026
@zredlined zredlined self-assigned this Sep 14, 2026
@zredlined zredlined added the documentation Improvements or additions to documentation label Sep 14, 2026

@johnnygreco johnnygreco left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks Alex! I enjoyed this read—appreciate the human prose 💚

Left some mostly nit comments inline. One general comment, which is the biggest of nits that you can feel free to ignore: IMO it would add a touch of polish to have an agent go through and make all the em-dashes actual em-dashes (which BTW is like my favorite punctuation mark, and I don't care if AI loves them too).

Comment thread docs/assets/agent-policy-prover/hero-concept.png
Comment thread docs/dev-notes/posts/2026-09-10-learning-formal-methods-agent-policy-prover.md Outdated

## The demo that changed our minds

In one of our first demos of OpenShell, for Jensen actually, we demonstrated the ability to use OpenShell’s REST inspection endpoint to only allow an OpenClaw agent to write selectively to a GitHub repository, despite having access to a broadly scoped API key. The demo started off as expected- OpenShell’s sandbox saw the attempted write to the forbidden repo and blocked it. Then the next message was “file successfully written to \[forbidden repo\]. What had happened here? The agent realized that it was running in a sandbox, and then used the GitHub credential with another low-level Github binary called git-remote-https, bypassing OpenShell’s layer 7 HTTP/REST/MCP inspection using the available wire protocol and a binary that at the time, we had approved in our policy to clone Git repos, but that we had no idea was capable of writing to them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is such a great illustrative example!

just a thought: what about adding a diagram / graphic of some kind that visually shows what happened here? just to get it to really sink into the reader's mind.

<img src="../../assets/agent-policy-prover/hero-concept.png" alt="Five colorful clusters of connected AI agent nodes sit within a green policy boundary while a red path crosses the boundary and is stopped by a proof marker.">
</figure>

In this post- we’ll dive into how permission review breaks at agent scale, and how to use the Z3 open source library to write a formal proof that a policy change proposed by an agent stays inside what you approved.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe make "Z3 open source library" a link?


Back in the 2016 timeframe, members of our team were working at AWS and faced a similar challenge. Given all of the awesome complexity of AWS IAM policies, AWS S3 storage policies, historical version support- can we definitively say whether an object in S3 is accessible to the public Internet or not?

Today, this sounds kind of funny, and it did in 2016 too, until you think about the complexity and layering interactions possible between the policies that we write to control systems. Byron Cook’s team of Ph.D’s came up with a clever approach, code-named Zelkova, that now runs once per day for every S3 bucket policy- millions of SMT queries per day and definitively answers this question.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a link to Byron Cook and/or his team?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It is no longer a single team :) What he started has morphed into a huge automated reasoning workforce at AWS. He remains the key evangelist.

binary_matches(rule, a) ∧ endpoint_matches(rule, a)
```

This is where you start to see some of the complexity of modeling an entire policy language. For example, OpenShell supports `*` and `**` glob semantics. These are compiled into Z3 regular expressions. As humans that are familiar with glob mechanics, we know that a single `*` cannot cross `/` for paths or `.` for hosts- while `**` can. So, we use our Rust code to encode this logic. Z3's regular-expression theory can then check for us whether the symbolic string belongs to the resulting language. For a deep-dive on our research around containment, check out the OpenShell spike on maximum policies and narrowness budgets here: <https://github.com/NVIDIA/OpenShell/blob/spike/maximal-policy-prover-subset/crates/openshell-prover/MAXIMUM_POLICY_ENVELOPE_SPIKE.md>.

@johnnygreco johnnygreco Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure we can count on branches persisting, especially considering the repo itself could move. If the example is needed, perhaps it should be extracted and persisted somewhere more intentional, or just move the markdown description somewhere.

@vishwa-raman vishwa-raman Sep 14, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While regular expressions form a regular language that is decidable, using things like back references which Python supports makes them more expressive at the cost of decidability. Maybe we can add somewhere that we only process decidable fragments of regexes (as in Formal Regex)? I remember because we had to deal with Python/Java code with regexes at AWS that made it hard to prove equivalence between these legacy controls and the ones we built using a strongly typed fully decidable domain specific language for controls.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I am saying this also because the OpenAI HuggingFace incident relied on poor regex matches. Not the same problem but regexes have been oftentimes involved in breaking security me thinks.

@zredlined
zredlined merged commit fbb6b3c into main Sep 14, 2026
15 checks passed
@zredlined
zredlined deleted the codex/learning-formal-methods-agent-policy-prover branch September 14, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants