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
4 changes: 2 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ 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`. `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 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.

Docs Agent consumes the reusable WP Codebox workflow and helper implementation at immutable revision `9764022156a61ba7d2b4d8a2196b01ccb33b82b5` and passes `wp_codebox_release_ref: v0.33.7` and `wp_codebox_workflow_ref: 9764022156a61ba7d2b4d8a2196b01ccb33b82b5`. That revision is the commit the annotated `v0.33.7` 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.33.7 release assets are `wp-codebox-cli-linux-x64.tar.gz`, `wp-codebox-workspace-0.33.7.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 `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.

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
18 changes: 13 additions & 5 deletions .github/workflows/maintain-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ env:
description: Version 1 JSON policy authorizing Docs Agent standalone native packages.
required: true
PUBLISH_TOKEN:
description: Optional token for checkout and publication. Defaults to the caller-scoped github.token. Pass a GitHub App installation token so the docs pull request opens as that app and triggers the repository's pull_request workflows, which GitHub suppresses for github.token.
description: Optional explicit token for checkout and publication. Takes precedence over PUBLISH_APP_ID/PUBLISH_APP_PRIVATE_KEY; when neither is set, WP Codebox uses the caller-scoped github.token, whose pull requests do not trigger pull_request workflows.
required: false
PUBLISH_APP_ID:
description: Optional GitHub App ID. With PUBLISH_APP_PRIVATE_KEY, WP Codebox mints an installation token for the target repository so the docs pull request opens as that app and triggers pull_request workflows.
required: false
PUBLISH_APP_PRIVATE_KEY:
description: Optional GitHub App private key; requires PUBLISH_APP_ID.
required: false
outputs:
job_status:
Expand Down Expand Up @@ -389,10 +395,10 @@ jobs:
contents: write
pull-requests: write
issues: write
uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@9764022156a61ba7d2b4d8a2196b01ccb33b82b5
uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@9fce8a758b44109b86da22db68a1b6c801bdd6bb
with:
wp_codebox_release_ref: v0.33.7
wp_codebox_workflow_ref: 9764022156a61ba7d2b4d8a2196b01ccb33b82b5
wp_codebox_release_ref: v0.34.0
wp_codebox_workflow_ref: 9fce8a758b44109b86da22db68a1b6c801bdd6bb
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 @@ -419,5 +425,7 @@ jobs:
time_budget_ms: ${{ inputs.time_budget_ms }}
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ACCESS_TOKEN: ${{ secrets.PUBLISH_TOKEN || github.token }}
ACCESS_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
ACCESS_APP_ID: ${{ secrets.PUBLISH_APP_ID }}
ACCESS_APP_PRIVATE_KEY: ${{ secrets.PUBLISH_APP_PRIVATE_KEY }}
EXTERNAL_PACKAGE_SOURCE_POLICY: ${{ secrets.EXTERNAL_PACKAGE_SOURCE_POLICY }}
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: 9764022156a61ba7d2b4d8a2196b01ccb33b82b5
ref: 9fce8a758b44109b86da22db68a1b6c801bdd6bb
path: .wp-codebox
- name: Validate Docs Agent
env:
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ 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.

`PUBLISH_TOKEN` is optional. When it is empty, Docs Agent uses `${{ github.token }}` as above. GitHub does not start `pull_request` workflows for pull requests opened with `github.token`, so docs pull requests opened that way get no CI. To get CI on them, store a fine-grained personal access token as a repository secret and pass it as `PUBLISH_TOKEN`. Limit the token to the calling repository, with `contents`, `pull-requests`, and `issues` write. The pull request then opens as that token's account. Prefer a dedicated machine account, because the token reaches the agent run's checkout and publication. A GitHub App installation token minted in an earlier caller job does not work: GitHub drops job outputs that contain secrets, so the token cannot reach a reusable workflow call.
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.

`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.

```yaml
secrets:
PUBLISH_APP_ID: ${{ secrets.MY_APP_ID }}
PUBLISH_APP_PRIVATE_KEY: ${{ secrets.MY_APP_PRIVATE_KEY }}
```

Configure `DOCS_AGENT_EXTERNAL_PACKAGE_SOURCE_POLICY` with this exact v1 JSON value:

Expand Down Expand Up @@ -140,7 +148,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.33.7`: `wp_codebox_release_ref: v0.33.7` and `wp_codebox_workflow_ref` both resolve to the tag commit `9764022156a61ba7d2b4d8a2196b01ccb33b82b5`. This producer revision is independent of the fixed Docs Agent package revision.
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.

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
Loading
Loading