Skip to content

feat(coderd): audit agent definition and plugin pack enablement changes - #381

Merged
ibetitsmike merged 9 commits into
mainfrom
mike/issue-355-audit-defs
Nov 17, 2026
Merged

ibetitsmike merged 9 commits into
mainfrom
mike/issue-355-audit-defs

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Closes #355.

What changed

The fork mutations from #218's follow-up list now write one audit entry on success, using the same coderd/fork_audit.go helper as the #218 call sites (initForkAudit, target, diff). Each entry is a write of the owning organization with fork_resource, operation and changes in the additional fields:

  • Project agent definitions create, update and delete in coderd/fork_project_agent_definitions.go audit as project_agent_definition.
  • Personal (user-tier) agent definitions create, update and delete in coderd/fork_agent_definitions.go audit as user_agent_definition.
  • Plugin pack enablement and exclusion changes in coderd/fork_plugin_pack_enablement.go audit as project_plugin_pack, chat_plugin_pack or chat_excluded_plugin_pack.

Nothing is written for a request denied before authorization: initForkAudit starts the entry before the handler authorizes, and the commit only runs when the organization target has been named, which happens on success, like the upstream handlers and the #218 call sites. A request that fails after authorization also writes no entry because target is only called on success.

Redaction

The #218 helper keeps full field values in changes and only the pack sources handler treats its URL host specially. I followed that: agent definition content and descriptions are recorded in full (they are the point of the audit trail and the operator can already read them through the API), and there are no secrets in these resources. The plugin pack source URL is not part of these entries; enablement entries record only the pack ID, name and the changed enablement state.

Test plan

  • New audit.NewMock() tests: TestForkProjectAgentDefinitionsAudit, TestForkUserAgentDefinitionsAudit, TestForkPluginPackEnablementAudit, following the existing TestForkOrganizationAgentDefinitionsAudit pattern. They assert one entry per mutation, the resource type, operation, resource ID and name, the changed fields, and that denied and failed requests write nothing.
  • Negative control: removing the audit call from the enablement helper made TestForkPluginPackEnablementAudit fail with 0 entries instead of 2, then the call was restored and the test passed.
  • go build ./..., make lint (no new findings versus base on the touched files) and the coderd test package were run locally; make gen is not needed because no queries or migrations changed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T14:08:20.382326Z 82b9b7b Manual request
ℹ️ 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.

@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: a6384d9dcd

ℹ️ 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 coderd/fork_plugin_pack_enablement.go Resolved
Comment thread coderd/fork_agent_definitions.go Resolved
Comment thread coderd/fork_agent_definitions.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex 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: a6384d9dcd

ℹ️ 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 coderd/fork_plugin_pack_enablement.go Resolved
Comment thread coderd/fork_plugin_pack_enablement.go Resolved
- record the real enablement transition: delete handlers pass the
  desired state instead of a hard-coded false to true
- omit the content of a personal agent definition from its audit
  entry, because auditors can read the audit log without access to
  the personal skill
- keep the 403 for a cross-user update: a denied read of the current
  row falls through to the update, which authorizes the change
- name the audit target only after the update succeeds, so a request
  rejected for an invalid body writes no entry
- name the project or chat an enablement changed in the entry
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the first Codex review in 323dd04:

  • P1 enablement transitions: the helper now takes the desired state, so the delete handlers record true to false.
  • P1 personal content: the audit view of a personal definition omits the content, because auditors can read the audit log without access to the personal skill.
  • P2 cross-user PATCH: a denied read no longer ends the request, the update still authorizes and keeps the 403. The test expectation is restored.
  • P2 target after validation: both PATCH handlers name the audit target only after the update succeeds, so an invalid body writes no entry.
  • P2 concurrent read: accepted, it matches the pre-existing organization-tier pattern, and a stale snapshot only misattributes a field between two actors who could both write.
  • P2 target ID: each enablement entry now records the project or chat ID.
  • P2 idempotent no-ops: accepted, the entry records the request outcome like the coderd: fork admin and configuration mutations write no audit logs #218 enablement entries, and a repeated request still identifies who touched the target.

All seven threads are resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex 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: 323dd0407f

ℹ️ 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 coderd/fork_agent_definitions.go Resolved
- the audit view of a project agent definition omits the content,
  because auditors can read the audit log without access to a chat
  project
- the audit view of a personal agent definition names its owner, so
  a deleted personal definition stays traceable
- an update that a read-denied but write-allowed token performs
  still records the fields it requested
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the second Codex review in 3ef660c:

  • P1 project content: the audit view of a project definition omits the content now, since organization auditors can read the audit log but not chat projects.
  • P2 update-only scoped token: when the read is denied but the update is allowed, the entry records the fields the request changed.
  • P2 affected user: the personal definition audit view records the owner ID.

All three threads are resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex 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: 3ef660c694

ℹ️ 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 coderd/fork_plugin_pack_enablement.go Resolved
Comment thread coderd/fork_agent_definitions.go Resolved
Comment thread coderd/fork_agent_definitions_test.go Resolved
- a project definition audit entry names its project, so a deleted
  definition stays traceable to it
- an enablement entry records its transition only after the write
  succeeded, so a failed write claims no state change
- an update-only scoped token that changes the prompt records a
  secret content change instead of a description change
- the personal definition audit test re-reads the entries after the
  failed requests, so a failed request that wrote an entry fails
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the third Codex review in 0d15432:

  • P2 project ID: the project definition audit view records the project ID.
  • P2 failed enablement write: the transition and target ID are recorded only after the write succeeded.
  • P2 update-only token content: the entry records a secret content change instead of a description change.
  • P2 test negative control: the test re-reads the entries after the failed requests.

All four threads are resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex 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: 0d15432c44

ℹ️ 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 coderd/fork_agent_definitions.go Resolved
- a project or personal definition update that changes the prompt
  body records a secret content change, so the entry is not empty
- a project definition update by a token that may write but not read
  no longer fails on the audit read, and records the fields it
  requested like the personal tier does
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the fourth Codex review in 20e42da:

  • P2 update-only project PATCH: a denied audit read falls through to the update, which records the fields the request changed, like the personal tier.
  • P2 personal prompt change: an update that changes the prompt body records a secret content change.
  • P2 project prompt change: the same for the project tier.

All three threads are resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 20e42dac01

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

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (da6d496, #379) into the branch. No conflicts. The audit tests pass on the merge commit.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 452411df56

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

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged origin/main (25df403, #380) into the branch. No conflicts. The audit tests pass on the merge commit.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex 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: fe05ce6249

ℹ️ 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 coderd/fork_plugin_pack_enablement.go Resolved
The target and the transition are recorded only after the write
succeeded, so a failed write leaves no audit entry at all.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the Codex finding on the merge commit in 2c338f0: the enablement audit target and transition are recorded only after the write succeeded, so a failed write leaves no entry at all. Thread resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex 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: 2c338f0a7b

ℹ️ 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 coderd/fork_agent_definitions.go Resolved
An update-only scoped token that sends new front matter records the
description it wrote in the audit entry, in both the personal and
the project tier.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Addressed the Codex finding in 82b9b7b: an update-only scoped token that sends new front matter records the description it wrote, in both the personal and the project tier. Thread resolved. Re-review requested below.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 82b9b7b3a4

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

@ibetitsmike
ibetitsmike merged commit 99056e8 into main Nov 17, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-355-audit-defs branch November 17, 2026 14:23
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged at head 82b9b7b3a45a2dad7250e6b04842e4838ba56fa0 as 99056e8, on main 25df403d5dab47d0b65cf699fc196df4a78faecc, with the server running that main.

Gates on this exact head:

  1. The head matched the SHA I verified (--match-head-commit).
  2. Every check run passed. fork-ci run 44099208490 passed on this head.
  3. Codex receipt for this head: feat(coderd): audit agent definition and plugin pack enablement changes #381 (comment) ("Didn't find any major issues").
  4. No unresolved review thread.
  5. 0 commits behind main.
  6. I ran the tests below on this exact head.

Tests I ran on 82b9b7b3a4 (detached worktree, under flock ~/.fork-go.lock):

  • go test -count=1 -v -run 'TestForkUserAgentDefinitions|TestForkOrganizationAgentDefinitions|TestForkProjectAgentDefinitions|TestForkPluginPackEnablement|TestForkAudit' ./coderd/: 23 PASS, 0 FAIL.
  • go test -count=1 -race -run 'AgentDefinitionsAudit|PluginPackEnablementAudit' ./coderd/: ok.
  • go vet ./coderd/: clean.
  • Negative control: with the audit target line removed from writeForkPluginPackEnablement, TestForkPluginPackEnablementAudit fails ("should have 2 item(s), but has 0"). The source was restored after the control.

Review notes:

  • Personal, project and organization agent definition writes and plugin pack enablement writes now get audit entries through the existing fork audit helper. The endpoints stay behind their existing fork experiments.
  • Prompt content is recorded as changed without its values.
  • An update-only scoped token that cannot read the old row still gets an entry with the new values it wrote.
  • A failed write leaves no entry, because the target is named only after the write succeeds.

Not exercised:

  • the audit log UI for these resource types;
  • audit export or a non-Postgres auditor backend.

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.

coderd: audit project and personal agent definitions and plugin pack enablement

1 participant