Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ Maintenance permits a no-op only for a non-empty caller-bounded `source_delta`.

The reusable workflow declares the expected typed review artifacts for Docs Agent runs: transcript, change summary, verification report, drift report, completion report, and workspace publication links. `maintain-docs.yml` writes those declarations into the portable recipe and exposes the declaration objects through `declared_artifacts_json`. The completion runtime declaration remains optional for producer lifecycle compatibility, but the final completion drift command has a mandatory generic `{name,type,path}` artifact output. The Docs Agent-owned validator generates canonical host-observed bytes under `.codebox/agent-task-artifacts`, and WP Codebox stages only that declared artifact for review.

The target repository grants `contents: write`, `pull-requests: write`, and `issues: write`. Docs Agent forwards the caller-scoped `${{ github.token }}` to WP Codebox for same-repository publication, so consumers do not configure `ACCESS_TOKEN`. Optional `PUBLISH_APP_ID` / `PUBLISH_APP_PRIVATE_KEY` are forwarded as WP Codebox `ACCESS_APP_ID` / `ACCESS_APP_PRIVATE_KEY`; WP Codebox v0.34.0 mints a GitHub App installation token from them so docs pull requests open as the app and trigger `pull_request` workflows ([WP Codebox #2596](https://github.com/Automattic/wp-codebox/pull/2596)). An optional `PUBLISH_TOKEN` is forwarded as `ACCESS_TOKEN` and takes precedence; Docs Agent no longer forwards `github.token` itself, because an explicit token would override the minted app token. `OPENAI_API_KEY` is an optional workflow secret and is required only for a live OpenAI run; skipped and dry-run calls do not require it. `EXTERNAL_PACKAGE_SOURCE_POLICY` remains a separate required v1 JSON secret. Migrate its value to the exact one-line JSON in the root README: it authorizes the selected Docs Agent package, the pinned Agents API component, the pinned PHP AI Client overlay, and the checksum-pinned OpenAI provider artifact. Both secrets are forwarded to WP Codebox without serialization into the task descriptor.
The target repository grants `contents: write`, `pull-requests: write`, and `issues: write`. Docs Agent forwards the caller-scoped `${{ github.token }}` to WP Codebox for same-repository publication, so consumers do not configure `ACCESS_TOKEN`. Optional `PUBLISH_APP_ID` / `PUBLISH_APP_PRIVATE_KEY` are forwarded as WP Codebox `ACCESS_APP_ID` / `ACCESS_APP_PRIVATE_KEY`; WP Codebox mints a GitHub App installation token from them so docs pull requests open as the app and trigger `pull_request` workflows ([WP Codebox #2596](https://github.com/Automattic/wp-codebox/pull/2596)). An optional `PUBLISH_TOKEN` is forwarded as `ACCESS_TOKEN` and takes precedence; Docs Agent no longer forwards `github.token` itself, because an explicit token would override the minted app token. `OPENAI_API_KEY` is an optional workflow secret and is required only for a live OpenAI run; skipped and dry-run calls do not require it. `EXTERNAL_PACKAGE_SOURCE_POLICY` remains a separate required v1 JSON secret. Migrate its value to the exact one-line JSON in the root README: it authorizes the selected Docs Agent package, the pinned Agents API component, the pinned PHP AI Client overlay, and the checksum-pinned OpenAI provider artifact. Both secrets are forwarded to WP Codebox without serialization into the task descriptor.

Docs Agent consumes the reusable WP Codebox workflow and helper implementation at immutable revision `9fce8a758b44109b86da22db68a1b6c801bdd6bb` and passes `wp_codebox_release_ref: v0.34.0` and `wp_codebox_workflow_ref: 9fce8a758b44109b86da22db68a1b6c801bdd6bb`. That revision is the commit the annotated `v0.34.0` tag resolves to, so the reusable workflow, its helper scripts, and the release tag all name the same producer code; the fixed Docs Agent package revision stays separate. WP Codebox checks that the helper checkout matches `wp_codebox_workflow_ref` and that its `package.json` version equals the release tag, then installs its runtime from that checkout. WP Codebox materializes the declared native runtime closure, executes the selected package, applies bounded workspace changes, runs verification, and publishes approved host changes. The v0.34.0 release assets are `wp-codebox-cli-linux-x64.tar.gz`, `wp-codebox-workspace-0.34.0.tgz`, and `wp-codebox.zip`; `tests/wp-codebox-release.fixture.json` records their published SHA-256 digests.
Docs Agent consumes the reusable WP Codebox workflow and helper implementation at immutable revision `470b3743deb3132965f1008cb18f63e8c90d5286` and passes `wp_codebox_release_ref: v0.37.0` and `wp_codebox_workflow_ref: 470b3743deb3132965f1008cb18f63e8c90d5286`. That revision is the commit the annotated `v0.37.0` tag resolves to, so the reusable workflow, its helper scripts, and the release tag all name the same producer code; the fixed Docs Agent package revision stays separate. WP Codebox checks that the helper checkout matches `wp_codebox_workflow_ref` and that its `package.json` version equals the release tag, then installs its runtime from that checkout. WP Codebox materializes the declared native runtime closure, executes the selected package, applies bounded workspace changes, runs verification, and publishes approved host changes. The v0.37.0 release assets are `wp-codebox-cli-linux-x64.tar.gz`, `wp-codebox-workspace-0.37.0.tgz`, and `wp-codebox.zip`; `tests/wp-codebox-release.fixture.json` records their published SHA-256 digests.

The optional `product_site` input (JSON string, default empty) is forwarded unchanged to the WP Codebox `run-agent-task` `product_site` input, added in v0.37.0. When set, WP Codebox boots the read-only product site before the agent turn and gives the agent the `product_page_view` tool so it can check real screens; when empty, behavior is unchanged. v0.37.0 adds no other caller-facing input changes.

Provider artifacts retain only allowlisted review artifacts, controlled workflow envelopes, and canonical runtime-source and seed provenance. WP Codebox uploads a reviewer-safe workflow-result projection: public control, verification, workspace-apply, publication, output-projection, access, failure, artifact-declaration, and canonical transcript-provenance fields remain, while raw `runtime_result`, `outputs.engine_data`, model/provider/tool payloads, source content, private paths, and secrets are excluded. Before persistence or upload, it sanitizes private runtime paths from nested values, object keys, diagnostics, and command arguments. WP Codebox captures one trusted canonical `codebox-transcript` through a pre-sanitization reviewer-evidence descriptor, validates its artifact-root containment, schema, digest, and size, then emits the compact reviewer transcript as a `wp-codebox/reviewer-agent-transcript/v1` projection. Before apply-back, it compares the seed identity with the host workspace identity; rejected patches preserve the expected and actual identities plus patch and changed-file evidence for upload. Its pre-redaction trusted apply input preserves machine-applicable patch bytes in a private channel that is removed before durable artifact sanitization, as fixed in [WP Codebox #1842](https://github.com/Automattic/wp-codebox/pull/1842). Lifecycle and downstream failures retain runtime evidence in their internal normalized failed result even when artifact preparation cannot complete. Diagnostic messages that name runtime classes remain reviewable, while PHP-shaped runtime source remains blocked. See [WP Codebox #1767](https://github.com/Automattic/wp-codebox/issues/1767), [WP Codebox #1814](https://github.com/Automattic/wp-codebox/issues/1814), [WP Codebox #1815](https://github.com/Automattic/wp-codebox/pull/1815), and [WP Codebox #1823](https://github.com/Automattic/wp-codebox/pull/1823). Successful canonical reviewer-evidence reference: [run `29350690551`](https://github.com/Automattic/build-with-wordpress/actions/runs/29350690551). The [hosted failure `29468956857`](https://github.com/Automattic/agents-api/actions/runs/29468956857) executed WP Codebox v0.12.20, published [Agents API #430](https://github.com/Automattic/agents-api/pull/430), then failed during upload preparation; it motivated #1814/#1815.

Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/maintain-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ env:
description: Agent run time budget in milliseconds.
type: number
default: 1800000
product_site:
description: 'Optional JSON read-only product site {blueprint, plugins, start_url, login_role}, forwarded unchanged to WP Codebox. When set, the agent can call product_page_view to check real screens. Empty leaves behavior unchanged.'
type: string
default: ""
secrets:
OPENAI_API_KEY:
description: Optional OpenAI credential used for live Docs Agent runs.
Expand Down Expand Up @@ -395,10 +399,10 @@ jobs:
contents: write
pull-requests: write
issues: write
uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@9fce8a758b44109b86da22db68a1b6c801bdd6bb
uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@470b3743deb3132965f1008cb18f63e8c90d5286
with:
wp_codebox_release_ref: v0.34.0
wp_codebox_workflow_ref: 9fce8a758b44109b86da22db68a1b6c801bdd6bb
wp_codebox_release_ref: v0.37.0
wp_codebox_workflow_ref: 470b3743deb3132965f1008cb18f63e8c90d5286
external_package_source: ${{ needs.prepare.outputs.external_package_source }}
runtime_sources: ${{ needs.prepare.outputs.runtime_sources }}
workload_id: docs-agent-${{ inputs.audience }}-${{ inputs.run_kind }}
Expand All @@ -423,6 +427,7 @@ jobs:
dry_run: ${{ inputs.dry_run }}
max_turns: ${{ inputs.max_turns }}
time_budget_ms: ${{ inputs.time_budget_ms }}
product_site: ${{ inputs.product_site }}
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ACCESS_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: Automattic/wp-codebox
ref: 9fce8a758b44109b86da22db68a1b6c801bdd6bb
ref: 470b3743deb3132965f1008cb18f63e8c90d5286
path: .wp-codebox
- name: Validate Docs Agent
env:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

Docs Agent targets the calling repository and forwards its scoped `${{ github.token }}` to WP Codebox for checkout and publication. The consumer must grant `contents: write`, `pull-requests: write`, and `issues: write`; no `ACCESS_TOKEN` secret is required for this same-repository contract. `OPENAI_API_KEY` is optional in the reusable workflow schema but required for a live `run_agent: true` OpenAI run. `EXTERNAL_PACKAGE_SOURCE_POLICY` is a separate required secret: WP Codebox uses it to authorize the selected Docs Agent package and the complete WordPress-native runtime closure. Replace the prior v1 secret value with the exact value below; its secret name and workflow mapping are unchanged.

To give docs pull requests CI, publish them as a GitHub App. GitHub does not start `pull_request` workflows for pull requests opened with `github.token`. Pass the app's ID and private key as `PUBLISH_APP_ID` and `PUBLISH_APP_PRIVATE_KEY`. WP Codebox (v0.34.0+) mints an installation token for the calling repository inside the agent job, so the pull request opens as that app and triggers the repository's `pull_request` workflows. Install the app on the calling repository with `contents`, `pull-requests`, and `issues` write. Installation tokens last one hour, which covers the default 30-minute time budget. A token minted in an earlier caller job does not work, because GitHub drops job outputs that contain secrets, so pass the credentials instead.
To give docs pull requests CI, publish them as a GitHub App. GitHub does not start `pull_request` workflows for pull requests opened with `github.token`. Pass the app's ID and private key as `PUBLISH_APP_ID` and `PUBLISH_APP_PRIVATE_KEY`. WP Codebox mints an installation token for the calling repository inside the agent job, so the pull request opens as that app and triggers the repository's `pull_request` workflows. Install the app on the calling repository with `contents`, `pull-requests`, and `issues` write. Installation tokens last one hour, which covers the default 30-minute time budget. A token minted in an earlier caller job does not work, because GitHub drops job outputs that contain secrets, so pass the credentials instead.

`PUBLISH_TOKEN` is an optional explicit override, for example a fine-grained personal access token from a machine account limited to the calling repository. It takes precedence over the app credentials. When neither is set, WP Codebox falls back to `${{ github.token }}` as above, and those docs pull requests get no CI.

Expand Down Expand Up @@ -114,6 +114,7 @@ The consumer API is product-level. Consumer repositories configure the documenta
| `dry_run` | `false` | Set `true` to validate the prepared task without starting a live agent run. |
| `max_turns` | `40` | Maximum agent turns. WP Codebox defaults to 12, which a large source tree can use up on reading before any write. |
| `time_budget_ms` | `1800000` | Agent run time budget in milliseconds. |
| `product_site` | empty | Optional JSON read-only product site (`blueprint`, `plugins`, `start_url`, `login_role`; plugin paths relative to the target workspace), forwarded unchanged to WP Codebox. Set it for user-facing docs so the agent can call `product_page_view` to check real screens; empty leaves behavior unchanged. |

`verification_commands` and `drift_checks` are executable caller inputs. Docs Agent appends its own completion-contract check as a separate drift entry after them. The target repository remains the only writable PR boundary.

Expand Down Expand Up @@ -148,7 +149,7 @@ Docs Agent declares the review artifacts it expects the runner to materialize as

`maintain-docs.yml` writes `expected_artifacts` and `artifact_declarations` into a portable Docs Agent recipe and exposes the same declaration objects as `declared_artifacts_json`. The runtime declaration for `docs_agent_completion_report` remains `required: false` because WP Codebox may evaluate runtime-level required artifacts before post-command validation. The final completion drift entry is mandatory and declares `{name,type,path}`; after deterministic host validation, the validator atomically writes canonical JSON to `.codebox/agent-task-artifacts/docs-agent-completion-report.json`, and WP Codebox stages that declared command artifact for reviewers.

The reusable workflow and helper implementation are pinned to WP Codebox `v0.34.0`: `wp_codebox_release_ref: v0.34.0` and `wp_codebox_workflow_ref` both resolve to the tag commit `9fce8a758b44109b86da22db68a1b6c801bdd6bb`. This producer revision is independent of the fixed Docs Agent package revision.
The reusable workflow and helper implementation are pinned to WP Codebox `v0.37.0`: `wp_codebox_release_ref: v0.37.0` and `wp_codebox_workflow_ref` both resolve to the tag commit `470b3743deb3132965f1008cb18f63e8c90d5286`. This producer revision is independent of the fixed Docs Agent package revision.

WP Codebox v0.33.6 uploads a reviewer-safe workflow-result projection with public control, workspace-apply, and publication fields plus canonical transcript provenance. It excludes raw `runtime_result`, `outputs.engine_data`, model/provider/tool payloads, source content, private paths, secrets, Git-ignored verification artifacts such as pnpm's symlinked `node_modules` tree, and mutable `.codebox` runtime control files. Tracked or otherwise publishable symlinks remain rejected. Integrity failures retain bounded added, modified, and deleted path evidence, and non-Git workspaces retain a bounded filesystem snapshot fallback. Canonical GitHub repository identity is compared case-insensitively while pull-request URL syntax, pull number, target binding, and API resolution remain strict. The canonical `codebox-transcript` remains the bounded tool-observability surface: its pre-sanitization reviewer-evidence descriptor records the trusted artifact-relative path, schema, verified source digest, and size, which the uploader revalidates before producing the `wp-codebox/reviewer-agent-transcript/v1` projection. Since v0.33.6 that projection decodes the runtime output, so it includes tool observability and the content-free sandbox write ledger instead of a stub. Before apply-back, WP Codebox validates that the runner seed and host workspace identities match; rejected patches retain identity, patch, and changed-file evidence for review. The pre-redaction trusted apply input fixed by [WP Codebox #1842](https://github.com/Automattic/wp-codebox/pull/1842) retains machine-applicable patch bytes privately, then removes them before durable artifact sanitization.

Expand Down
8 changes: 5 additions & 3 deletions tests/validate-docs-agent-packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@
$assert( str_contains( $maintain_docs_workflow, 'The host generates and stages the completion report from caller inputs, Git, and filesystem checks' ), 'maintain-docs.yml must make host-owned completion generation explicit.' );
$assert( ! str_contains( $maintain_docs_workflow, 'DOCS_AGENT_COMPLETION_REPORT' ), 'maintain-docs.yml must not request model-authored completion reports.' );

$wp_codebox_producer_revision = '9fce8a758b44109b86da22db68a1b6c801bdd6bb';
$wp_codebox_producer_revision = '470b3743deb3132965f1008cb18f63e8c90d5286';
$generic_codebox_agent_task_workflow = 'uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@' . $wp_codebox_producer_revision;
$assert( str_contains( $maintain_docs_workflow, $generic_codebox_agent_task_workflow ), 'maintain-docs.yml must call the immutable generic Codebox agent-task workflow candidate.' );
$assert( str_contains( $maintain_docs_workflow, 'wp_codebox_release_ref: v0.34.0' ), 'maintain-docs.yml must pass the matching WP Codebox release tag.' );
$assert( str_contains( $maintain_docs_workflow, 'wp_codebox_release_ref: v0.37.0' ), 'maintain-docs.yml must pass the matching WP Codebox release tag.' );
$assert( str_contains( $maintain_docs_workflow, 'wp_codebox_workflow_ref: ' . $wp_codebox_producer_revision ), 'maintain-docs.yml must execute helpers from the accepted producer revision.' );

$assert( str_contains( $maintain_docs_workflow, '--arg writablePaths "$INPUT_WRITABLE_PATHS"' ), 'maintain-docs.yml must include writable paths in the portable recipe.' );
Expand Down Expand Up @@ -109,7 +109,9 @@
foreach ( array( 'Docs Agent Runner Recipe', 'portable recipe', 'Docs Agent owns the native package' ) as $migration_note_text ) {
$assert( str_contains( $workflow_readme, $migration_note_text ), "Workflow README missing agent runtime note: {$migration_note_text}" );
}
$assert( str_contains( $workflow_readme, 'v0.34.0' ), 'Workflow README must record the WP Codebox release tag.' );
$assert( str_contains( $workflow_readme, 'v0.37.0' ), 'Workflow README must record the WP Codebox release tag.' );
$assert( str_contains( $maintain_docs_workflow, 'product_site: ${{ inputs.product_site }}' ), 'maintain-docs.yml must forward product_site unchanged to WP Codebox.' );
$assert( str_contains( (string) file_get_contents( $root . '/README.md' ), '| `product_site` | empty |' ), 'README inputs table must document product_site.' );
$assert( str_contains( $workflow_readme, 'Diagnostic messages that name runtime classes remain reviewable' ), 'Workflow README must document diagnostic-versus-source detection.' );
$assert( str_contains( $workflow_readme, 'allowlisted review artifacts' ), 'Workflow README must document the WP Codebox upload allowlist.' );
$assert( str_contains( $workflow_readme, 'normalized failed result' ), 'Workflow README must document normalized WP Codebox failures.' );
Expand Down
Loading
Loading