Skip to content

🤖 tests: add a TLA+ check of the CoderAIGatewayKey key lifecycle and a KIND verify skill - #391

Merged
ThomasK33 merged 5 commits into
mainfrom
verification-skills
Oct 29, 2026
Merged

ThomasK33 merged 5 commits into
mainfrom
verification-skills

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Adds two project skills that let an agent prove changes to coder-k8s. verify-coder-k8s launches the real operator on a disposable KIND cluster with a real Coder and drives the CRDs and the aggregated API through kubectl. verify-aigatewaykey-model model-checks the CoderAIGatewayKey key lifecycle with TLA+, against guard statements and timing constants that check.sh reads from the Go source. The PR changes no product code.

Background

A CoderAIGatewayKey keeps a full-trust Coder AI Gateway key in a Secret. Its safety depends on step order across reconciles that can stop at any step, a lagging informer cache, and requests that land after the operator gave up on them. Unit tests rarely reach those interleavings. The repo also had no single scripted way to launch the operator plus Coder and capture proof of a user-facing change.

Implementation

  • hack/formal/aigatewaykey/AIGatewayKey.tla: a model of one object and one controller. It covers the issue step (cleanup record, marker, create, Secret write loop), adopt and recover, the orphan sweep, the retire step, and the delete path. It also covers late Coder commits, late Secret writes, resourceVersion conflicts, crashes, and actions by a person.
  • hack/formal/aigatewaykey/check.sh: reads 10 guard facts and 6 constants from the Go source and fingerprints the 30 covered functions. It then runs TLC 1.7.4 (pinned by SHA-256). Exit codes: 0 pass, 1 violation, 2 cannot run, 3 STALE (covered code changed since the last review).
  • hack/formal/aigatewaykey/view.mjs: a /statechart view that labels states and steps in operator words.
  • .mux/skills/verify-aigatewaykey-model/SKILL.md: when to run the check, the coverage table, how to read a result, and how to update the model.
  • .mux/skills/verify-coder-k8s/: scripts/verify.sh (launch, doctor, kubectl, node, coder-api, capture, collect, cleanup), a throwaway Postgres manifest, and a feature map of 5 user journeys.

Rules checked:

  • SecretKeyAlive: while the object exists, the Secret never holds a key that Coder no longer has, unless a person deleted it.
  • NoLeakAfterRelease: when the finalizer goes, Coder has no key of the object and no create can still commit.

Validation

  • Both rules hold at the quick bound (18,595,034 states, about 1 minute) and at the deep bound (209,344,657 states, about 9 minutes).
  • I broke every fact once in a copy of the sources. Ten breaks fail with a rule violation, including a settle window of 2 minutes and a write age of 5 minutes. The two "skip the held key" filters report only STALE, because the live Secret read before each delete backs them up.
  • A scratch edit in the real tree removed the held-key check in deleteOwnKey. check.sh exited 1, and /statechart gave a 27-step path to the deleted key. With the line restored, the check passed with exit 0.
  • verify-coder-k8s: a full run from launch to cleanup passed in about 2.7 minutes. It covered launch, doctor, the CoderControlPlane journey, and the CoderTemplate/CoderWorkspace journey checked through the Coder API. Cleanup left no cluster, container, or image tag behind.

Known finding (not fixed here)

check.sh --config stall fails NoLeakAfterRelease. Nothing bounds the time between the create marker (attemptStart in issueKey) and CreateAIGatewayKey, the way aiGatewayKeyMaxWriteAge bounds Secret writes. A leader that freezes for about 5 minutes and then sends the create can commit a key after the delete path has already released the object. The docs do not list this assumption. I did not reproduce it live.

Risks

Low. The PR adds files under .mux/skills/ and hack/formal/ only. No build, CI job, or product code path reads them.


Generated with mux • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $10.77

Change-Id: I4b4fb8a81e4b365932719c88bb8fdd69a0d13c73
Signed-off-by: Thomas Kosiewski <tk@coder.com>
Add hack/formal/aigatewaykey: a TLA+ model of the key issue, Secret write,
retire, orphan sweep and delete steps, and check.sh, which reads the guard
statements and timing constants from the Go source, fingerprints the covered
functions, and runs TLC 1.7.4 (pinned by SHA-256). The project skill
verify-aigatewaykey-model says when and how to run it and how to read a result.

Rules: SecretKeyAlive and NoLeakAfterRelease. Both hold at the quick bound
(18.6M states) and the deep bound (209M states). --config stall shows a leak
when the process pauses between the create marker and the create request.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

Change-Id: I83211a19f5c633d93096d28bddd1b5cccb0b640d
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T19:09:07.598714Z d8e05b2 Manual request
🔒 Security Review ✅ Completed 2026-10-29T19:07:46.883890Z d8e05b2 Manual request

Security findings

Advisory findings (3)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 717db990d3

ℹ️ 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".

Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh Outdated
Comment thread hack/formal/aigatewaykey/check.sh Outdated
Comment thread .mux/skills/verify-coder-k8s/features/coderprovisioner.md Outdated
Comment thread hack/formal/aigatewaykey/check.sh Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 717db990d3

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh Outdated
- verify.sh: never default VERIFY_BASE to /tmp; refuse base, bin and run dirs
  that another user can write before PATH use or sourcing run.env.
- verify.sh doctor: require all 7 aggregated resources in discovery.
- coderprovisioner journey: set organizationName coder.
- check.sh: exit 2 when the TLC download fails; report functions that left
  the covered list as STALE.

Change-Id: Ia29f4e67ca9c9d4a1a9aeb38a337f7bb8679855f
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b647f2dc5

ℹ️ 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".

Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh Outdated
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 3b647f2dc5

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh
- Refuse run and base dirs with an ancestor that another user owns, or can
  write without the sticky bit; default the run dir away from /tmp.
- Bind cleanup and the ownership check to the node container ID.
- Count untracked files in SOURCE_DIRTY.
- Refuse attached -s server overrides.

Change-Id: Ib2e1c3a0d97cb227342aa6b21d00195cb1519bd1
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛡️ Codex Security Review

Here are some automated security review suggestions for this pull request.

Reviewed commit: 23cf66db56

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

Comment thread hack/formal/aigatewaykey/check.sh Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23cf66db56

ℹ️ 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".

Comment thread hack/formal/aigatewaykey/check.sh Outdated
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh Outdated
- check.sh: run TLC from a private, re-verified copy of tla2tools.jar; exit 2
  when the output folder cannot be used.
- verify.sh: require absolute dirs; launch only into a new or empty run dir.

Change-Id: If5900ab04c484b459e07ac2d6cb9b57e74d45daf
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: d8e05b26a6

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d8e05b26a6

ℹ️ 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".

Comment thread hack/formal/aigatewaykey/check.sh
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh
Comment thread .mux/skills/verify-coder-k8s/scripts/verify.sh
@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 29, 2026
@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 29, 2026
@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 2019817 Oct 29, 2026
9 of 10 checks passed
@ThomasK33
ThomasK33 deleted the verification-skills branch October 29, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant