From bde84a51de6f7744fbbb3a90ddc88d2c233a6486 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 15 Nov 2026 14:39:02 +0000 Subject: [PATCH] fix(workflow): run agent tasks on WP Codebox v0.33.4 Pin run-agent-task.yml, its helpers, and the release ref to the v0.33.4 tag commit 126f85b2a8b887ae8e2457d1cb71b15ebdb712cd. Refs Automattic/wp-codebox#2567. AI assistance: Extra Chill Bot (Claude), via a Roadie subagent. --- .github/workflows/README.md | 18 +++++------ .github/workflows/maintain-docs.yml | 6 ++-- .github/workflows/validate.yml | 2 +- README.md | 10 +++--- tests/validate-docs-agent-packages.php | 8 ++--- ...ate-wp-codebox-run-agent-task-contract.php | 32 +++++++++++++++---- tests/wp-codebox-release.fixture.json | 16 ++++++---- 7 files changed, 58 insertions(+), 34 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index bb54870..6884657 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -16,19 +16,19 @@ The reusable workflow declares the expected typed review artifacts for Docs Agen 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. -Docs Agent consumes the reusable WP Codebox workflow and helper implementation at accepted immutable revision `a6fe2d208e990a8d04104aa74aacbb8d1539fbc1` and passes `wp_codebox_release_ref: v0.12.29` only for released packaged runtime assets. The release tag resolves to immutable revision `bc982947ec33c78160125026e16d357b7ece3ea1`, distinct from both the workflow producer revision and the fixed Docs Agent package revision. WP Codebox materializes the declared native runtime closure, executes the selected package, applies bounded workspace changes, runs verification, and publishes approved host changes. The released assets are `01-wp-codebox.zip` and `02-wp-codebox-workspace-0.12.29.tgz`; the private package-recovery manifest is intentionally not a reviewer asset. +Docs Agent consumes the reusable WP Codebox workflow and helper implementation at immutable revision `126f85b2a8b887ae8e2457d1cb71b15ebdb712cd` and passes `wp_codebox_release_ref: v0.33.4` and `wp_codebox_workflow_ref: 126f85b2a8b887ae8e2457d1cb71b15ebdb712cd`. That revision is the commit the annotated `v0.33.4` 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.4 release assets are `wp-codebox-cli-linux-x64.tar.gz`, `wp-codebox-workspace-0.33.4.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 v0.12.24 uploads a reviewer-safe workflow-result projection: public control, verification, 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). The canonical transcript remains the bounded tool-observability surface. 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 and is not a successful v0.12.24 reviewer-safe workflow-result run. +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. -WP Codebox v0.12.25 excludes Git-ignored verification artifacts such as pnpm's symlinked `node_modules` tree from publication integrity snapshots while continuing to reject tracked or otherwise publishable symlinks. This allows dependency installation during verification without weakening the bounded workspace publication contract; see [WP Codebox #1845](https://github.com/Automattic/wp-codebox/pull/1845). +Publication integrity snapshots exclude Git-ignored verification artifacts, such as pnpm's symlinked `node_modules` tree, and mutable `.codebox` runtime control files, while tracked or otherwise publishable symlinks stay rejected. Integrity failures report bounded added, modified, and deleted paths, and non-Git workspaces keep a bounded filesystem snapshot fallback. Canonical GitHub repository identity is compared case-insensitively, while pull-request URL, pull number, target binding, and API resolution checks stay strict. Successful pull-request verification returns `{ valid: true }` without a failure-only `error`. These came from [WP Codebox #1845](https://github.com/Automattic/wp-codebox/pull/1845), [#1848](https://github.com/Automattic/wp-codebox/pull/1848), [#1852](https://github.com/Automattic/wp-codebox/pull/1852), [#1875](https://github.com/Automattic/wp-codebox/pull/1875), and [#1885](https://github.com/Automattic/wp-codebox/pull/1885). -WP Codebox v0.12.26 restores the unconditional exclusion for mutable `.codebox` runtime control files, preventing task request and result state from invalidating an approved workspace snapshot. Publishable workspace files remain governed by Git tracking and ignore semantics; see [WP Codebox #1848](https://github.com/Automattic/wp-codebox/pull/1848). +WP Codebox v0.33.4 makes the runner-workspace apply step observable; see [WP Codebox #2588](https://github.com/Automattic/wp-codebox/pull/2588) and [WP Codebox #2567](https://github.com/Automattic/wp-codebox/issues/2567). Earlier revisions could finish a run with agent writes that never reached the host workspace, and the uploaded transcript could be a stub. In v0.33.4: -WP Codebox v0.12.27 reports bounded added, modified, and deleted paths when post-verification integrity changes and preserves that evidence in normalized publication failures. It also restores bounded filesystem snapshots for non-Git workspaces; see [WP Codebox #1852](https://github.com/Automattic/wp-codebox/pull/1852). - -WP Codebox v0.12.28 validates canonical GitHub repository identity case-insensitively while preserving strict pull-request URL, pull number, target binding, and API resolution checks; see [WP Codebox #1875](https://github.com/Automattic/wp-codebox/pull/1875). - -WP Codebox v0.12.29 returns `{ valid: true }` without a failure-only `error` when canonical pull-request verification succeeds, while repository mismatches retain their exact diagnostic; see [WP Codebox #1885](https://github.com/Automattic/wp-codebox/pull/1885). +- The workflow result and its reviewer-safe projection carry `workspace_apply` (`wp-codebox/runner-workspace-apply-outcome/v1`). It records `status` (`applied`, `no-op`, `writes-not-applied`, `rejected`, `failed`, or `skipped`), `applied_paths`, every rejected path with its reason, `unapplied_paths`, `declared_changes`, and content-free `write_tool_calls` counts and paths taken from the sandbox write ledger. +- If the sandbox accepted `workspace_write`, `workspace_edit`, or `workspace_apply_patch` calls but the canonical patch declared no changes, the run fails at `stage: apply` with `writes-not-applied` and lists the lost paths. Verification, drift checks, and the Docs Agent completion check do not run in that case. A run with no write calls still reaches them. +- The sandbox and the host use the same writable-path glob matcher: `**` spans directories, and `*`, `?`, and `[...]` stay within one path segment. Patterns such as `docs/**/*.md` or `plugins/*/docs/user/**` are no longer accepted in the sandbox and then rejected on the host. +- The uploader decodes the JSON-encoded `wordpress.run-php` output, so the compact reviewer transcript includes tool observability and the write ledger (tool names and workspace paths, never file contents). +- Publication reuses the branch derived from `docs_branch` only while it has an exact open pull request that descends from the current base. If the branch exists without an open pull request, WP Codebox publishes to a fresh `-` branch instead of appending to the stale one. If the open pull request's branch does not descend from the current base, publication fails and asks for a rebase. ## Docs Agent Runner Recipe diff --git a/.github/workflows/maintain-docs.yml b/.github/workflows/maintain-docs.yml index 19ef135..bb89849 100644 --- a/.github/workflows/maintain-docs.yml +++ b/.github/workflows/maintain-docs.yml @@ -348,10 +348,10 @@ jobs: contents: write pull-requests: write issues: write - uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@a6fe2d208e990a8d04104aa74aacbb8d1539fbc1 + uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@126f85b2a8b887ae8e2457d1cb71b15ebdb712cd with: - wp_codebox_release_ref: v0.12.29 - wp_codebox_workflow_ref: a6fe2d208e990a8d04104aa74aacbb8d1539fbc1 + wp_codebox_release_ref: v0.33.4 + wp_codebox_workflow_ref: 126f85b2a8b887ae8e2457d1cb71b15ebdb712cd 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 }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9eb1ced..2c85f5c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v4 with: repository: Automattic/wp-codebox - ref: a6fe2d208e990a8d04104aa74aacbb8d1539fbc1 + ref: 126f85b2a8b887ae8e2457d1cb71b15ebdb712cd path: .wp-codebox - name: Validate Docs Agent env: diff --git a/README.md b/README.md index 693d021..db91e3b 100644 --- a/README.md +++ b/README.md @@ -137,9 +137,11 @@ 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 accepted revision `a6fe2d208e990a8d04104aa74aacbb8d1539fbc1`; `v0.12.29` remains only the `wp_codebox_release_ref` for released packaged runtime assets at `bc982947ec33c78160125026e16d357b7ece3ea1`. +The reusable workflow and helper implementation are pinned to WP Codebox `v0.33.4`: `wp_codebox_release_ref: v0.33.4` and `wp_codebox_workflow_ref` both resolve to the tag commit `126f85b2a8b887ae8e2457d1cb71b15ebdb712cd`. This producer revision is independent of the fixed Docs Agent package revision. -WP Codebox v0.12.29 at `bc982947ec33c78160125026e16d357b7ece3ea1` uploads a reviewer-safe workflow-result projection with public control and publication fields plus canonical transcript provenance. This released workflow revision remains distinct from the fixed Docs Agent package revision. 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. Successful publication verification returns `{ valid: true }` without a failure-only `error`, while repository mismatches retain their exact diagnostic as fixed by [WP Codebox #1885](https://github.com/Automattic/wp-codebox/pull/1885). 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. Before apply-back, it 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. The publication snapshot fixes are tracked in [WP Codebox #1845](https://github.com/Automattic/wp-codebox/pull/1845), [WP Codebox #1848](https://github.com/Automattic/wp-codebox/pull/1848), [WP Codebox #1852](https://github.com/Automattic/wp-codebox/pull/1852), [WP Codebox #1875](https://github.com/Automattic/wp-codebox/pull/1875), and [WP Codebox #1885](https://github.com/Automattic/wp-codebox/pull/1885). The published release assets are `01-wp-codebox.zip` and `02-wp-codebox-workspace-0.12.29.tgz`; its private package-recovery manifest is intentionally not a reviewer asset. +WP Codebox v0.33.4 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.4 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. + +The workflow result records the runner-workspace apply outcome as `workspace_apply` (`wp-codebox/runner-workspace-apply-outcome/v1`): applied, rejected, and unapplied paths plus write-tool call counts. Sandbox and host now share one writable-path glob matcher, so `docs/**` and `docs/**/*.md` behave the same on both sides. If the agent made successful write calls but the canonical patch declared no changes, the run fails at `stage: apply` with `writes-not-applied` instead of passing as a no-op. See [WP Codebox #2588](https://github.com/Automattic/wp-codebox/pull/2588) and [WP Codebox #2567](https://github.com/Automattic/wp-codebox/issues/2567). Docs Agent owns native package selection, lane, artifact, prompt, and workspace mapping. The completion command downloads its validator from the independent immutable `DOCS_AGENT_COMPLETION_CONTRACT_REVISION`; native package descriptors remain pinned by `DOCS_AGENT_PACKAGE_REVISION`. Execution, credentials, AI provider selection, sandboxing, and publication are runner-owned concerns outside this repository. @@ -154,7 +156,7 @@ A live run succeeds only when four independent layers pass: 3. Caller dependency, verification, and drift commands pass. 4. WP Codebox publishes and verifies a pull request when the outcome and caller policy require one. -For `changes`, `changed_paths` exactly equals the Git diff and every path must be writable. A write-tool call that leaves no byte diff produces `no_changes`. +For `changes`, `changed_paths` exactly equals the Git diff and every path must be writable. `no_changes` requires a clean workspace. If a sandbox write call succeeds but the canonical patch declares no changes, WP Codebox fails the run at `stage: apply` (`writes-not-applied`) before the completion check. Only runs without successful write calls reach `no_changes`. For every maintenance outcome, `source_delta` must be non-empty and caller-bounded: each item has a unique ID and non-empty source refs, and those records are copied canonically into the report. Caller-known drift marked `requires_documentation_change: true` requires an actual Markdown or MDX diff. Bootstrap uses `inventory` with its required positive bootstrap contract and deterministic substantive filesystem checks. Model final prose is never parsed or used for completion. @@ -166,7 +168,7 @@ Docs Agent opens or updates one canonical PR for the configured branch. - If the selected maintenance surface is current, the run succeeds only with a non-empty caller-bounded source delta and no workspace diff. - If maintenance is needed, changes are written only under `writable_paths`. -- If the canonical PR is already open, later runs reuse the same `docs_branch` and PR instead of creating duplicates. +- If the canonical PR is already open and its branch descends from the current base, later runs append to the same branch (derived from `docs_branch`) and PR instead of creating duplicates. If that branch has fallen behind the base, publication fails until the PR is rebased. If the branch exists without an open PR, WP Codebox publishes to a fresh `-` branch. - `validation_dependencies` is an optional caller-owned reusable-workflow input. It is passed through the portable recipe and runs before verification commands when a live runner execution needs setup. - `job_status`, `transcript_summary`, `credential_mode`, `success_requires_pr`, `validation_dependencies`, and bounded `projected_outputs_json` are exposed as reusable workflow outputs. A `run_agent: false` call returns `job_status: skipped`; a `dry_run: true` call validates without starting a model run. `OPENAI_API_KEY` is only required for a live OpenAI run and is never included in recipes, workflow outputs, or artifacts. Bootstrap lanes require a published pull request and its projected URL for success. Maintenance lanes allow a bounded no-change result by default; set `require_pr: true` when an acceptance or remediation run must fail without a valid target-repository PR. Runtime typed artifact declarations remain optional, while the completion post-command artifact is mandatory and exposed through WP Codebox declared-artifact staging. Raw engine data is not exposed as a workflow output or uploaded reviewer artifact. diff --git a/tests/validate-docs-agent-packages.php b/tests/validate-docs-agent-packages.php index f1f58c9..193b783 100644 --- a/tests/validate-docs-agent-packages.php +++ b/tests/validate-docs-agent-packages.php @@ -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 = 'a6fe2d208e990a8d04104aa74aacbb8d1539fbc1'; +$wp_codebox_producer_revision = '126f85b2a8b887ae8e2457d1cb71b15ebdb712cd'; $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.12.29' ), 'maintain-docs.yml must pass the matching WP Codebox release tag.' ); +$assert( str_contains( $maintain_docs_workflow, 'wp_codebox_release_ref: v0.33.4' ), '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.' ); @@ -103,7 +103,7 @@ 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.12.29' ), 'Workflow README must record the WP Codebox release tag.' ); +$assert( str_contains( $workflow_readme, 'v0.33.4' ), 'Workflow README must record the WP Codebox release tag.' ); $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.' ); @@ -116,7 +116,7 @@ $assert( str_contains( $workflow_readme, 'pre-sanitization reviewer-evidence descriptor' ), 'Workflow README must document the pre-sanitization reviewer-evidence descriptor.' ); $assert( str_contains( $workflow_readme, 'reviewer-safe workflow-result projection' ), 'Workflow README must document the reviewer-safe workflow-result projection.' ); $assert( str_contains( $workflow_readme, 'pre-redaction trusted apply input' ), 'Workflow README must document the pre-redaction trusted apply input.' ); -$assert( str_contains( $workflow_readme, 'private package-recovery manifest' ), 'Workflow README must document the omitted private package-recovery manifest.' ); +$assert( str_contains( $workflow_readme, 'wp-codebox/runner-workspace-apply-outcome/v1' ) && str_contains( $workflow_readme, 'writes-not-applied' ), 'Workflow README must document the WP Codebox runner-workspace apply outcome.' ); $assert( str_contains( $workflow_readme, 'independent of the reusable-workflow revision' ), 'Workflow README must distinguish package and reusable-workflow revisions.' ); $declared_artifact_names = array_keys( $expected_artifact_schemas ); diff --git a/tests/validate-wp-codebox-run-agent-task-contract.php b/tests/validate-wp-codebox-run-agent-task-contract.php index 9657b53..1a45830 100644 --- a/tests/validate-wp-codebox-run-agent-task-contract.php +++ b/tests/validate-wp-codebox-run-agent-task-contract.php @@ -58,9 +58,10 @@ $published_assets = $release['published_assets'] ?? null; $assert( is_array( $published_assets ), 'WP Codebox release fixture must record published release assets.' ); $assert( array( - '01-wp-codebox.zip' => 'sha256:a239c72ae79c5b24fe7bed9ccfd375c0b70892ca66406d98140a51d219cfaaee', - '02-wp-codebox-workspace-0.12.29.tgz' => 'sha256:d332924b3b91ef8e47b5ebca7063b2964734d3ac081dd62fa18ec9417fefdcd5', -) === $published_assets, 'WP Codebox release fixture must retain the published v0.12.29 asset digests.' ); + 'wp-codebox-cli-linux-x64.tar.gz' => 'sha256:c37f770deb9a9c26e8191b44292da759f150b0641705af45ee6d41640ac695ab', + 'wp-codebox-workspace-0.33.4.tgz' => 'sha256:57e8daf900de6504590edb1f1aa9a992c64b7fad8b5526162a3d377c63f95279', + 'wp-codebox.zip' => 'sha256:46dc08b55eb4fd3d6fbd67d1ea25978816dea1eeade07c0444ad660ee547c975', +) === $published_assets, 'WP Codebox release fixture must retain the published v0.33.4 asset digests.' ); $run = $release['run'] ?? null; $assert( is_string( $run ) && preg_match( '/^\d+$/', $run ) === 1, 'WP Codebox release fixture must retain the regression run reference.' ); $diagnostic_regression_run = $release['diagnostic_regression_run'] ?? null; @@ -96,6 +97,9 @@ $assert( true === ( $release['workspace_integrity_change_evidence'] ?? null ), 'WP Codebox release fixture must preserve bounded workspace integrity change evidence.' ); $assert( true === ( $release['non_git_workspace_snapshot_fallback'] ?? null ), 'WP Codebox release fixture must retain bounded snapshots for non-Git workspaces.' ); $assert( true === ( $release['canonical_repository_casing'] ?? null ), 'WP Codebox release fixture must retain canonical repository casing coverage.' ); +$assert( true === ( $release['runner_workspace_apply_outcome'] ?? null ), 'WP Codebox release fixture must record the explicit runner-workspace apply outcome.' ); +$assert( true === ( $release['writes_not_applied_fails_closed'] ?? null ), 'WP Codebox release fixture must fail closed when sandbox writes do not reach the host workspace.' ); +$assert( true === ( $release['decoded_reviewer_transcript_write_ledger'] ?? null ), 'WP Codebox release fixture must upload decoded tool observability and the write ledger in the reviewer transcript.' ); $native_result_path = $release['native_result_path'] ?? null; $workflow_result_path = $release['workflow_result_path'] ?? null; $assert( '.codebox/native-agent-task-result.json' === $native_result_path, 'WP Codebox release fixture must declare the controlled native result path.' ); @@ -104,6 +108,7 @@ $assert( ( $release['package_version'] ?? null ) === ( $producer_package['version'] ?? null ), 'Checked-out WP Codebox package version must match the release fixture.' ); $producer_revision = trim( (string) shell_exec( 'git -C ' . escapeshellarg( $wp_codebox_dir ) . ' rev-parse HEAD' ) ); $assert( $producer_candidate_revision === $producer_revision, 'Checked-out WP Codebox producer must match the immutable reusable-workflow candidate commit.' ); +$assert( $release_revision === $producer_candidate_revision, 'Docs Agent must run the reusable workflow and helpers from the exact commit the WP Codebox release tag resolves to.' ); $workflow = (string) file_get_contents( $root . '/.github/workflows/maintain-docs.yml' ); $assert( preg_match( '/^\s*uses: Automattic\/wp-codebox\/\.github\/workflows\/run-agent-task\.yml@' . preg_quote( $producer_candidate_revision, '/' ) . '$/m', $workflow ) === 1, 'Docs Agent must call the immutable WP Codebox producer candidate.' ); @@ -187,7 +192,9 @@ }; $assert( $is_coherent_producer_pair( $workflow, $producer_candidate_revision, $release_tag ), 'Docs Agent must pair the immutable producer candidate with the exact packaged runtime release tag.' ); $assert( ! $is_coherent_producer_pair( str_replace( 'wp_codebox_release_ref: ' . $release_tag, 'wp_codebox_release_ref: v0.12.3', $workflow ), $producer_candidate_revision, $release_tag ), 'A mismatched WP Codebox packaged runtime release tag must fail.' ); -$assert( ! $is_coherent_producer_pair( str_replace( $producer_candidate_revision, $release_revision, $workflow ), $producer_candidate_revision, $release_tag ), 'A mismatched WP Codebox reusable-workflow producer revision must fail.' ); +// ded3cbc0… is the v0.33.4 fix merge commit: a plausible but non-release producer revision. +$assert( ! $is_coherent_producer_pair( str_replace( $producer_candidate_revision, 'ded3cbc08a810b34fc7912824e30598b1efa7b5d', $workflow ), $producer_candidate_revision, $release_tag ), 'A mismatched WP Codebox reusable-workflow producer revision must fail.' ); +$assert( ! $is_coherent_producer_pair( preg_replace( '/(wp_codebox_workflow_ref: )[0-9a-f]{40}/', '${1}ded3cbc08a810b34fc7912824e30598b1efa7b5d', $workflow ), $producer_candidate_revision, $release_tag ), 'A helper revision that differs from the reusable-workflow revision must fail.' ); $caller_secrets = array(); preg_match_all( '/^ (?[A-Z0-9_]+): (?[^\n]+)$/m', $caller['secrets'], $matches, PREG_SET_ORDER ); @@ -287,6 +294,13 @@ $assert( str_contains( $producer_execute, 'trustedArtifactApplyRefs(trustedApplyArtifactRoot, refs)' ) && str_contains( $producer_execute, 'applyRunnerWorkspacePatch({ artifactRoot: trustedArtifacts.root, artifactRefs: trustedArtifacts.refs, workspaceRoot: workspace, writablePaths, seedIdentity: runnerWorkspaceSeedSnapshot?.provenance.identity })' ), 'WP Codebox must apply the pre-redaction trusted artifacts while retaining seed identity validation.' ); $assert( str_contains( $producer_execute, 'await rm(trustedApplyArtifactRoot, { recursive: true, force: true })' ) && str_contains( $producer_execute, 'runtimeResult = sanitizeRuntimeSourceValue(runtimeResult, runtimeSourceOutputRoots)' ), 'WP Codebox must remove private trusted apply inputs before durable-result sanitization.' ); $assert( str_contains( $producer_execute, '...(error?.evidence ? { evidence: error.evidence } : {})' ), 'WP Codebox must retain rejected apply evidence in the normalized failure result.' ); +$assert( str_contains( $producer_execute, '...(Array.isArray(error?.rejectedPaths) ? { rejected_paths: error.rejectedPaths } : {})' ), 'WP Codebox apply failures must name every rejected path.' ); +$producer_apply_outcome = (string) file_get_contents( rtrim( $wp_codebox_dir, '/' ) . '/.github/scripts/run-agent-task/runner-workspace-apply-outcome.mjs' ); +$assert( str_contains( $producer_apply_outcome, 'schema: "wp-codebox/runner-workspace-apply-outcome/v1"' ) && str_contains( $producer_apply_outcome, 'status = "writes-not-applied"' ), 'WP Codebox must publish the runner-workspace apply outcome, including writes that never reached the host.' ); +$assert( str_contains( $producer_execute, '...(workspaceApplyOutcome ? { workspace_apply: workspaceApplyOutcome } : {})' ), 'WP Codebox must record the runner-workspace apply outcome in the workflow result.' ); +$assert( str_contains( $producer_execute, 'if (workspaceApplyOutcome?.status === "writes-not-applied") {' ) && str_contains( $producer_execute, 'downstreamFailure ??= { stage: "apply", message: workspaceApplyOutcome.message, unapplied_paths: workspaceApplyOutcome.write_tool_calls.paths }' ), 'WP Codebox must fail at the apply stage when successful sandbox writes produce no host change.' ); +$assert( str_contains( $producer_execute, 'if (execution.code === 0 && request.run_agent && !request.dry_run && !downstreamFailure) {' ), 'WP Codebox must skip verification, drift, and completion checks after an apply-stage failure.' ); +$assert( str_contains( $producer_upload, 'function decodedParsedOutput(parsed)' ) && str_contains( $producer_upload, 'workspace_mutations: workspaceMutations' ), 'WP Codebox reviewer transcripts must decode the runtime output and retain the content-free write ledger.' ); $assert( str_contains( $producer_upload, 'async function stageApplyFailureEvidence(result)' ) && str_contains( $producer_upload, 'apply-failure' ) && str_contains( $producer_upload, 'rejected.patch' ), 'WP Codebox must stage rejected patch and changed-file evidence for upload.' ); $assert( str_contains( $producer_execute, '.filter((ref) => ref.kind === "codebox-patch" || ref.kind === "codebox-changed-files")' ), 'WP Codebox must treat canonical patch and changed-file references as actionable workspace evidence.' ); $assert( str_contains( $producer_execute, 'verifyRunnerWorkspaceIntegrity(workspaceApply.integrity)' ) && str_contains( $producer_execute, 'publishRunnerWorkspace' ), 'WP Codebox must verify host-applied changes before publication.' ); @@ -313,7 +327,7 @@ $projection_end = strpos( $producer_upload, 'function safeTargetPath(value)', $projection_start ); $assert( false !== $projection_start && false !== $projection_end, 'WP Codebox must define the reviewer-safe workflow-result projection.' ); $workflow_result_projection = substr( $producer_upload, $projection_start, $projection_end - $projection_start ); -foreach ( array( 'schema: result.schema', 'run_id: result.run_id', 'status: result.status', 'success: result.success', 'request_path: result.request_path', 'reviewer_evidence:', 'verification,', 'publication: result.publication', 'transcript: result.transcript', 'artifacts: result.artifacts', 'outputs: outputs.projections', 'access: result.access', 'publication_verification: result.publication_verification', 'publication_error: result.publication_error', 'failure: result.failure', 'projection_error: result.projection_error' ) as $public_projection_field ) { +foreach ( array( 'schema: result.schema', 'run_id: result.run_id', 'status: result.status', 'success: result.success', 'request_path: result.request_path', 'reviewer_evidence:', 'verification,', 'workspace_apply: result.workspace_apply', 'publication: result.publication', 'transcript: result.transcript', 'artifacts: result.artifacts', 'outputs: outputs.projections', 'access: result.access', 'publication_verification: result.publication_verification', 'publication_error: result.publication_error', 'failure: result.failure', 'projection_error: result.projection_error' ) as $public_projection_field ) { $assert( str_contains( $workflow_result_projection, $public_projection_field ), "WP Codebox reviewer-safe workflow-result projection must retain {$public_projection_field}." ); } foreach ( array( 'runtime_result', 'engine_data', 'model', 'provider', 'tool_calls', 'tool_results', 'source_package_root' ) as $private_projection_field ) { @@ -327,7 +341,7 @@ $assert( in_array( '.codebox/agent-task-request.json', $producer_upload_regression['observed']['uploaded'] ?? array(), true ), 'WP Codebox upload regression fixture must retain the controlled request upload.' ); $assert( ! array_intersect( array( 'MODEL_PROVIDER_SECRET_1', 'MODEL_PROVIDER_SECRET_2', 'MODEL_PROVIDER_SECRET_3', 'MODEL_PROVIDER_SECRET_4', 'MODEL_PROVIDER_SECRET_5' ), array_keys( $caller_secrets ) ), 'Docs Agent must forward only the OPENAI_API_KEY provider secret name.' ); -$assert( str_contains( $workflow, 'output_projections="$(jq -cn --arg path \'metadata.runner_workspace_publication.pull_request.url\' --argjson required "$success_requires_pr" \'{docs_agent_publication:{path:$path,required:$required}}\')"' ), 'Docs Agent must define the v0.12.29 publication projection descriptor.' ); +$assert( str_contains( $workflow, 'output_projections="$(jq -cn --arg path \'metadata.runner_workspace_publication.pull_request.url\' --argjson required "$success_requires_pr" \'{docs_agent_publication:{path:$path,required:$required}}\')"' ), 'Docs Agent must define the runner workspace publication projection descriptor.' ); $docs_projections = array( 'docs_agent_publication' => array( 'path' => 'metadata.runner_workspace_publication.pull_request.url', @@ -337,9 +351,13 @@ $publication_descriptor = $docs_projections['docs_agent_publication'] ?? null; $assert( is_array( $publication_descriptor ), 'Docs Agent must define the docs_agent_publication projection descriptor.' ); $publication_path = $publication_descriptor['path'] ?? null; -$assert( 'metadata.runner_workspace_publication.pull_request.url' === $publication_path, 'Docs Agent publication projection must use the v0.12.29 runner workspace publication pull request URL path.' ); +$assert( 'metadata.runner_workspace_publication.pull_request.url' === $publication_path, 'Docs Agent publication projection must use the runner workspace publication pull request URL path.' ); $assert( 'string' === ( $contract['inputs']['output_projections']['type'] ?? null ), 'WP Codebox must accept Docs Agent custom output projections.' ); +$assert( str_contains( $producer_execute, 'runtimeRecord.metadata = { ...record(runtimeRecord.metadata), runner_workspace_publication: publication }' ), 'WP Codebox must still record runner workspace publication at metadata.runner_workspace_publication.' ); +$producer_publisher = (string) file_get_contents( rtrim( $wp_codebox_dir, '/' ) . '/.github/scripts/run-agent-task/runner-workspace-publisher.mjs' ); +$assert( str_contains( $producer_publisher, 'pull_request: { number: pull.number, url: pull.html_url,' ), 'WP Codebox runner workspace publication must still expose pull_request.url.' ); +$assert( 'string' === ( $contract['inputs']['callback_data']['type'] ?? null ) && str_contains( $producer_execute, 'callback_data: record(request.callback_data)' ), 'WP Codebox must accept and carry the Docs Agent recipe as callback_data.' ); $runtime_result_fixture = $read_json( $root . '/tests/wp-codebox-runtime-result.fixture.json' ); $publication_url = $result_value( $runtime_result_fixture, $publication_path ); diff --git a/tests/wp-codebox-release.fixture.json b/tests/wp-codebox-release.fixture.json index 682722f..55cf41f 100644 --- a/tests/wp-codebox-release.fixture.json +++ b/tests/wp-codebox-release.fixture.json @@ -1,11 +1,12 @@ { - "tag": "v0.12.29", - "revision": "bc982947ec33c78160125026e16d357b7ece3ea1", - "producer_revision": "a6fe2d208e990a8d04104aa74aacbb8d1539fbc1", - "package_version": "0.12.29", + "tag": "v0.33.4", + "revision": "126f85b2a8b887ae8e2457d1cb71b15ebdb712cd", + "producer_revision": "126f85b2a8b887ae8e2457d1cb71b15ebdb712cd", + "package_version": "0.33.4", "published_assets": { - "01-wp-codebox.zip": "sha256:a239c72ae79c5b24fe7bed9ccfd375c0b70892ca66406d98140a51d219cfaaee", - "02-wp-codebox-workspace-0.12.29.tgz": "sha256:d332924b3b91ef8e47b5ebca7063b2964734d3ac081dd62fa18ec9417fefdcd5" + "wp-codebox-cli-linux-x64.tar.gz": "sha256:c37f770deb9a9c26e8191b44292da759f150b0641705af45ee6d41640ac695ab", + "wp-codebox-workspace-0.33.4.tgz": "sha256:57e8daf900de6504590edb1f1aa9a992c64b7fad8b5526162a3d377c63f95279", + "wp-codebox.zip": "sha256:46dc08b55eb4fd3d6fbd67d1ea25978816dea1eeade07c0444ad660ee547c975" }, "run": "29350690551", "diagnostic_regression_run": "29307978522", @@ -39,6 +40,9 @@ "workspace_integrity_change_evidence": true, "non_git_workspace_snapshot_fallback": true, "canonical_repository_casing": true, + "runner_workspace_apply_outcome": true, + "writes_not_applied_fails_closed": true, + "decoded_reviewer_transcript_write_ledger": true, "native_result_path": ".codebox/native-agent-task-result.json", "workflow_result_path": ".codebox/agent-task-workflow-result.json" }