Skip to content

AI Workspace: agent audit trail, chats in personal-data export and erase, Wapuu busy states - #1317

Merged
whyisjake merged 15 commits into
feat/agent-command-palettefrom
feat/agent-audit-privacy
Nov 13, 2026
Merged

whyisjake merged 15 commits into
feat/agent-command-palettefrom
feat/agent-audit-privacy

Conversation

@whyisjake

@whyisjake whyisjake commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

What?

Related: #1287

The AI Workspace gains an audit trail, personal-data export and erase, and Wapuu busy states:

  • One audit trail. Every agent event is one agent row in the AI Request Log and one call of a new wpai_agent_event action. Events are tool calls (including withheld ones), each item an approval writes, and each step in a proposal's life: created, edited, declined, expired, failed, or refused because its chat was deleted. The action fires even when AI Request Logging is off.
  • Chats are personal data. Tools → Export Personal Data includes the person's saved chats, and Tools → Erase Personal Data deletes them. This works with the experiment off.
  • Wapuu. While a turn runs, the transcript shows a working Wapuu instead of a spinner, then a celebrating one for a moment when the turn finishes, or an oops one next to an error.

This is the fourth stacked PR for #1287, on top of #1316, #1315 and #1314.

Why?

#1287 asks that a site owner can see everything the agent did, was asked and was refused, in one place, and that audit plugins can hook it. Before this, workspace rows were mixed in with every other ability row, proposal events weren't logged at all, and nothing fired with logging off. Saved chats are personal data that core's export and erase tools didn't know about. And Jeff posted a Wapuu set on #1287 so a long turn looks busy rather than stuck.

How?

Agent_Audit is the one place agent events are recorded.

  • It fires wpai_agent_event( $operation, $status, $context, $error ), then writes the row through log_ai_request() with the new agent type.
  • The two existing log calls, for tool calls in Turn_Runner and for written items in Proposal_Writes, now go through it. Proposal events are recorded in Proposal_Store and Proposal_Controller:
    • created, when a proposal is stored;
    • edited, when an approval carries edits, naming the edited items;
    • declined;
    • expired, once, when an expired proposal is next read, since it's deleted then;
    • failed, when a write throws or is interrupted for longer than the approval lock;
    • refused, when an approval comes after its chat was deleted.
  • Context names the conversation, the proposal and its item keys, the post and field, or the option. It never carries post content or option values.
  • The hook covers agent turns and approvals only. A direct MCP call to an ability doesn't fire it. Docs say so.
  • The log screen gains the denied status, ported from Feature : Site Agent Experiment #1214, and agent rows are labelled "Agent". Rows logged before this keep the ability type.
  • Feature : Site Agent Experiment #1214's wp_after_execute_ability listener isn't ported: Turn_Runner already logs each call, so it would log them twice.

Conversation_Privacy registers an "AI chats" exporter and eraser.

  • They're hooked from Main, next to the chat ownership filter, so they work while the experiment is off.
  • The export has one item per chat: name, created and updated dates, whether it's archived, and each turn's message and reply. Tool results are left out. It pages at 20 chats.
  • The eraser deletes all the person's chats.
  • Chat IDs are read straight from the posts table, as the user-deletion cleanup already does, so archived chats are found even while their status isn't registered. That reader is now shared, as Conversation_Store::chat_ids().
  • A proposal from an erased chat can't be approved, because an approval is refused once its chat is gone.

Wapuu sprites replace the transcript's spinner.

  • Sprites: working while a turn runs, celebrating for 1.8 seconds after one finishes, and oops next to an error. They come from the set @jeffpaul posted on New Experiment: One AI agent across wp-admin #1287.
  • Accessibility: each sprite is an <img alt="">. The existing "Responding…" text and error text stay as the status.
  • Reduced motion: an SVG inside an <img> doesn't reliably follow the page's setting. So with reduced motion on, the component switches each sprite's animations off in its markup, which gives the same still pose.
  • Scope: only busy, done and error states ship. Per-tool sprites need streaming to know which tool is running.
  • Credit: the sprites are derived from Kazuko Kaneuchi's original Wapuu, GPL-2.0-or-later, and credited in CREDITS.md.

Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: implementing the changes and tests, and code review.

I've reviewed the changes, understand them and can explain them under review. They have all been tested locally.

Testing Instructions

  1. Enable AI Workspace and AI Request Logging, and connect a provider.
  2. Send a message. A Wapuu shows beside "Responding…", then a celebrating Wapuu for a moment when the reply arrives.
  3. Ask for a new tagline. Edit the proposed value and approve it. Ask for a draft and discard it.
  4. Open Tools → AI Request Logs and filter by type agent. The tool calls, proposal_created, proposal_edited and proposal_declined rows are there, none of them with the tagline's text.
  5. Tools → Export Personal Data for your own email: the download has an "AI chats" section with your chats. Erase personal data for a test user who has chats: their chats are gone.
  6. With reduced motion turned on in your OS, the Wapuu is still.

Tests run (all passing):

  • PHPUnit, full suite: 3398 tests, single site and multisite, on WordPress latest.
  • Agent_AuditTest: test_agent_is_a_log_type, test_an_event_writes_one_row_and_fires_the_hook, test_the_hook_fires_with_logging_off, test_a_proposal_event_names_the_proposal_and_its_items_only and test_a_proposal_without_a_kind_is_recorded_as_drafts.
  • Proposal_ControllerTest: test_each_proposal_event_is_recorded_once_in_order, test_events_fire_the_hook_with_logging_off, test_an_expired_proposal_is_recorded_once, test_an_expired_proposal_read_through_the_store_is_recorded_once, test_an_interrupted_write_is_recorded_failed_once, test_a_writer_that_throws_is_recorded_failed and test_an_approval_for_a_deleted_chat_is_recorded_denied.
  • Turn_ControllerTest: test_a_turn_records_a_withheld_call_and_a_proposal_in_order, and test_every_tool_call_writes_exactly_one_log_row updated for the agent type.
  • Post_Field_ProposalTest: test_a_content_update_records_the_field_not_the_content.
  • AI_Request_Log_ControllerTest: test_get_logs_filters_agent_rows_by_type_and_denied_status.
  • Conversation_PrivacyTest: test_the_exporter_and_eraser_are_registered_without_the_experiment, test_export_returns_every_chat_with_its_prompts_and_replies, test_export_with_the_experiment_off_includes_archived_chats, test_export_pages_at_twenty_chats, test_erase_removes_the_persons_chats_only, test_a_proposal_in_an_erased_chat_cannot_be_approved and test_an_unknown_email_exports_and_erases_nothing.
  • e2e (Chromium): all ai-workspace* specs, the palette spec and the request-log spec, 168 passed in one run on a fresh site. That includes the new "AI Workspace Wapuu" tests in ai-workspace.spec.js: a running turn shows the busy Wapuu beside "Responding…"; with reduced motion the busy Wapuu is a still frame; a failed turn shows the error Wapuu with the error; a finished turn shows the done Wapuu briefly. Each Wapuu test also ran three more times, 12 of 12 passing.
  • Test-first: the audit tests failed before Agent_Audit existed. The privacy tests were written before Conversation_Privacy but first run after it, so they have no recorded red run.
  • Other checks: PHPStan finds no errors, phpcs is clean on the changed plugin PHP, and tsc, lint-js and the build are clean. Style lint reports errors in ai-request-logs/index.scss and ai-workspace/index.scss that are already on the base branch.
  • Live check: core's exporter and eraser lists include "AI chats" on a running site, and the screenshots below come from one.
  • Not run yet: a live check against a real provider, and the PHPUnit suite on WordPress trunk.

Code review: seven reviewers ran on this PR's own diff (correctness, security, adversarial, testing, maintainability, frontend races and API contract), plus an independent validator. The verdict was "Ready to merge" with no actionable findings. The one candidate, that the status filter rejects skipped, was rejected because it's already on the base branch. Applied afterwards in eef886a: agent rows were labelled "Text" on the log screen, a docblock still said these rows use the ability type, and the store's expiry path had no test.

One test from #1316 hardened (1060833): its short palette search for "q" matched "AI Request Logs" whenever AI Request Logging was on, which the request-log spec leaves on when both run in one session. It now searches for "~".

Screenshots

A running turn

The working Wapuu beside "Responding…"

A finished turn

The celebrating Wapuu under the reply

A failed turn

The oops Wapuu beside the error

Agent events in the AI Request Log

proposal_created, proposal_expired and proposal_refused rows labelled Agent

AI chats in a personal-data export

The AI chats group in an export, with each chat's name, dates, archived flag, message and reply

Known limits

  • After an erase, a pending proposal from an erased chat can still be read by its owner, though not approved, until it expires (about 90 minutes).
  • "Recorded once" for an expired or interrupted proposal holds for requests that run one after another. Two requests reading the same proposal at the same instant can each record it.
  • A wpai_agent_event listener that throws during an approval write marks the proposal failed, as any WordPress hook would. The hook isn't wrapped.
  • The log screen's status filter doesn't accept skipped, which item rows have used since before this PR.
  • Workspace rows written after this are agent, not ability, so a view filtered to ability no longer shows them.

Changelog Entry

Added - AI Workspace records every agent tool call and proposal event in the AI Request Log under an agent type, with a wpai_agent_event hook that fires even when logging is off; saved chats are included in personal-data export and erase; and a Wapuu shows while a turn runs, finishes or fails.

Post-deploy monitoring: no additional operational monitoring is required. This is an experiment behind the AI Workspace toggle, off by default. The exporter and eraser run only when an administrator processes a personal-data request.


Compound Engineering

🤖 Generated with Claude Code

Open WordPress Playground Preview

whyisjake and others added 6 commits November 7, 2026 06:37
Tool calls, approved items and proposal events (created, edited,
declined, expired, failed, refused for a deleted chat) are each one
`agent` row in the AI Request Log and one `wpai_agent_event` call,
which fires whether or not AI Request Logging is on. The log screen
gains the `denied` status, ported from #1214.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rase

Tools → Export Personal Data gains an "AI chats" group: one item per
chat, archived ones included, with its name, dates, archived flag and
each turn's message and reply, paged at 20. Tools → Erase Personal Data
deletes all of the person's chats. Both are hooked from Main, so they
work while the experiment is off, and read chat IDs straight from the
posts table, as the user-deletion cleanup does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The transcript's spinner becomes Jeff Paul's working Wapuu from #1287,
with a done Wapuu for a moment after a turn finishes and an oops Wapuu
beside an error. Each sprite is decorative, next to the existing status
text, and is a still frame when reduced motion is on. The sprites are
derived from Kazuko Kaneuchi's original Wapuu (GPL-2.0-or-later),
credited in CREDITS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… expiry

Agent rows carry no request kind, so the log screen labelled them Text.
They now read Agent. The tool-call docblock no longer says rows are of
the ability type, and an expired proposal read through the store is
tested to record one expired event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The short-search test searched for "q", which matches "AI Request Logs"
once AI Request Logging is on, as it is after that spec runs in the same
session. It now searches for "~" and "~^".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@whyisjake
whyisjake marked this pull request as ready for review November 7, 2026 15:27
@whyisjake
whyisjake requested review from a team and jeffpaul as code owners November 7, 2026 15:27
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: whyisjake <whyisjake@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.03974% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.81%. Comparing base (3b897cb) to head (7768645).

Files with missing lines Patch % Lines
.../Experiments/AI_Workspace/Conversation_Privacy.php 92.59% 6 Missing ⚠️
includes/Experiments/AI_Workspace/Agent_Audit.php 94.28% 2 Missing ⚠️
...es/Experiments/AI_Workspace/Conversation_Store.php 93.75% 1 Missing ⚠️
Additional details and impacted files
@@                       Coverage Diff                        @@
##             feat/agent-command-palette    #1317      +/-   ##
================================================================
+ Coverage                         86.77%   86.81%   +0.04%     
- Complexity                         6282     6330      +48     
================================================================
  Files                               224      226       +2     
  Lines                             22769    22901     +132     
================================================================
+ Hits                              19758    19882     +124     
- Misses                             3011     3019       +8     
Flag Coverage Δ
unit 86.81% <94.03%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@whyisjake
whyisjake added this pull request to stack #1321 November 8, 2026 04:53
@jeffpaul jeffpaul added this to the 1.6.0 milestone Nov 9, 2026
@jeffpaul

jeffpaul commented Nov 9, 2026

Copy link
Copy Markdown
Member

Something seems off in testing:

Screenshot 2026-11-09 at 2 54 30 PM

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sprites: working while a turn runs, celebrating for 1.8 seconds after one finishes, and oops next to an error. They come from the set @jeffpaul posted on #1287.

Scope: only busy, done and error states ship. Per-tool sprites need streaming to know which tool is running.

Safe to assume that the other sprites are still available, mainly for scenarios where another plugin might provide function where they'd come into use (or perhaps once core/AI client provides streaming or other functions so those additional sprites can be rendered)?

@whyisjake

whyisjake commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

Yes. The full set stays in your post on #1287; this PR only ships busy, done and error. The others can come in when there's something to show them for, such as streaming that names the tool running, or another plugin's abilities.

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: drafting this reply.

I've reviewed the changes, understand them and can explain them under review.

@whyisjake
whyisjake merged commit 1af9b02 into feat/ai-workspace Nov 13, 2026
36 checks passed
@whyisjake
whyisjake deleted the feat/agent-audit-privacy branch November 13, 2026 18:08
whyisjake added a commit that referenced this pull request Nov 13, 2026
## What?

Related: #1287

The docs pass for the #1287 stack. AI Workspace keeps its name and is
documented as the plugin's one agent. The experiment doc, `readme.txt`,
`README.md`, the changelog and the settings card now describe what #1314
to #1317 added. No code paths change.

This is the fifth and last stacked PR for #1287, on top of #1317, #1316,
#1315 and #1314.

## Why?

#1287 folds two planned experiments into AI Workspace: Site Agent
(#1214) and Command Palette AI Search (#1250). A reader of the docs,
readme or changelog should learn that from them. Before this, the
settings card and readme still described a workspace that only creates
drafts and templates. The changelog had nothing for the write, palette,
audit, privacy or Wapuu changes, `README.md` had no AI Workspace entry
at all, and "Site Agent" was still listed under Coming Soon.

## How?

- **`docs/experiments/ai-workspace.md`**
- The summary and key features cover changes to existing content, site
answers and screen links, the chats panel, the Wapuu, the audit log and
personal-data export.
- A new "One agent" section says what Site Agent and Command Palette AI
Search proposed and where each now lives. It also says that the name,
menu, URL and every identifier, including the experiment ID
`ai-workspace`, are unchanged.
- The entry-points list names every ability the experiment registers,
and `Conversation_Privacy`.
- A stale limitation is removed. It said chats have no history screen,
but the chats panel ships.
- **`readme.txt` and `CHANGELOG.md`**
- Added: changes to existing content, the palette's AI search and Ask
AI, the `agent` log rows, chats in export and erase, and the Wapuu.
- Developer: `wpai_agent_event`, the two new proposal filters, the MCP
visibility change, `raw: true`, and the `ability` to `agent` log type
change.
- `CHANGELOG.md` also gains the two ability lines #1315 added only to
`readme.txt`.
- **`README.md`:** adds the missing AI Workspace entry.
- **Both readme files:** "Site Agent" leaves Coming Soon.
- **Settings card:** the AI Workspace description says it answers site
questions, proposes changes to posts and the site title and tagline, and
adds AI to the command palette.

The name stays "AI Workspace". Nothing on #1287 has settled on another
name.

### Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for:
writing the documentation and changelog entries, checking them against
the code, and code review.

I've reviewed the changes, understand them and can explain them under
review. They have all been tested locally.

## Testing Instructions

1. Open Settings → AI. The AI Workspace card reads as in the screenshot
below.
2. Read `docs/experiments/ai-workspace.md` → "One agent", and the
Unreleased changelog in `readme.txt` and `CHANGELOG.md`.

**Tests run** (all passing):
- **PHPUnit, full suite:** 3398 tests, single site and multisite, on
WordPress latest. Only the settings-card string is code, and no test
asserts it.
- **Other checks:** phpcs and `php -l` are clean on `AI_Workspace.php`.
- **Name check:** a grep for "Site Agent" and "Wordspace" across
`includes/`, `src/` and the built assets finds nothing user-visible.
- **Claims checked against the code:**
  - the abilities `AI_Workspace::register()` registers;
  - `meta.mcp.public` false on the propose and ask-user abilities;
- the `wpai_workspace_write_proposals_enabled` and
`wpai_workspace_proposal_kinds` filters;
  - `raw` on `ai/read-content-bodies`;
  - the chats panel's rename, archive and delete actions;
  - the three in-page anchors the doc links to.
- **Not run:** e2e. No script, style or behavior changes.

**Code review:** `ce-code-review` sized this diff to a single-context
review: 51 changed lines, two of them code. It found nothing and gave
"Ready to merge". Its one residual is applied in 0b06540: the doc's
feature bullet now says rows are written while AI Request Logging is on.

## Screenshots

**The settings card**

![The AI Workspace card on Settings →
AI](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/pr-e-settings-card.png)

## Known limits

- The changelog lines for #1314, #1316 and #1317 are added here rather
than in those PRs, so they land only when this one merges after them.

## Changelog Entry

> Changed - AI Workspace is documented as the plugin's one agent: it now
includes what the Site Agent and Command Palette AI Search proposals
planned, under its existing name.

**Post-deploy monitoring:** no additional operational monitoring is
required. Documentation and one settings-card string.

---

[![Compound
Engineering](https://img.shields.io/badge/Built_with-Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- wp-playground-preview:start -->
<a
href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1318-aa0faf515572fcec68b35f0b8a0634d387875fd1.zip%22%7D%7D%5D%7D"
target="_blank" rel="noopener noreferrer">
<img
src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg"
alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants