Skip to content

Commit d054c37

Browse files
authored
Pin Docs Agent native package source revision (#122)
1 parent 5344a4b commit d054c37

12 files changed

Lines changed: 79 additions & 34 deletions

.github/actionlint.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The target repository grants `contents: write`, `pull-requests: write`, and `iss
1616

1717
Docs Agent workflow call sites prepare a portable recipe instead of calling a concrete runner. Docs Agent owns the native package, lane, artifact, prompt, and workspace mapping. Consumers depend on Docs Agent inputs and review artifacts, not runner internals.
1818

19-
The recipe boundary covers standalone native package selection, workspace publication expectations, artifact declarations, verification, drift checks, and output mapping suggestions. Package provenance is the immutable reusable-workflow commit and each descriptor includes a byte digest. Runtime substrate checkout resolution is intentionally outside the Docs Agent-facing recipe, and validation blocks concrete runner workflow calls, runtime ability names, component paths, mount directives, provider defaults, and define directives from consumer examples.
19+
The recipe boundary covers standalone native package selection, workspace publication expectations, artifact declarations, verification, drift checks, and output mapping suggestions. Package provenance is the fixed `DOCS_AGENT_PACKAGE_REVISION`, independent of the reusable-workflow revision, and each descriptor includes a byte digest. Package changes advance that revision and every declared digest atomically. Runtime substrate checkout resolution is intentionally outside the Docs Agent-facing recipe, and validation blocks concrete runner workflow calls, runtime ability names, component paths, mount directives, provider defaults, and define directives from consumer examples.
2020

2121
Native package selection is expressed through recipe `docsAgent.externalPackageSource`. Workspace boundaries are expressed through recipe `runner` fields so agents remain workspace editors while caller-owned execution handles sandboxing and publication handoff.
2222

.github/workflows/maintain-docs.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Maintain Docs
22

3+
env:
4+
# Advance this revision and all package digests together when package bytes change.
5+
DOCS_AGENT_PACKAGE_REVISION: 7b2df969c34de112ec7ad13189ba94226a7f76f3
6+
37
'on':
48
workflow_call:
59
inputs:
@@ -102,7 +106,6 @@ jobs:
102106
RUN_AGENT: ${{ inputs.run_agent }}
103107
DRY_RUN: ${{ inputs.dry_run }}
104108
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
105-
DOCS_AGENT_REVISION: ${{ github.job_workflow_sha }}
106109
INPUT_DOCS_BRANCH: ${{ inputs.docs_branch }}
107110
INPUT_BASE_REF: ${{ inputs.base_ref }}
108111
GITHUB_REPOSITORY_NAME: ${{ github.repository }}
@@ -160,8 +163,8 @@ jobs:
160163
161164
verification_commands="$(printf '%s' "$INPUT_VERIFICATION_COMMANDS" | jq -c 'if type == "array" then . else error("verification_commands must be an array") end')"
162165
drift_checks="$(printf '%s' "$INPUT_DRIFT_CHECKS" | jq -c 'if type == "array" then . else error("drift_checks must be an array") end')"
163-
if ! printf '%s' "$DOCS_AGENT_REVISION" | grep -Eq '^[0-9a-fA-F]{40}$'; then
164-
printf 'github.job_workflow_sha must be a full immutable Docs Agent commit SHA.\n' >&2
166+
if ! printf '%s' "$DOCS_AGENT_PACKAGE_REVISION" | grep -Eq '^[0-9a-fA-F]{40}$'; then
167+
printf 'DOCS_AGENT_PACKAGE_REVISION must be a full immutable Docs Agent commit SHA.\n' >&2
165168
exit 1
166169
fi
167170
@@ -190,7 +193,7 @@ jobs:
190193
--arg targetRepository "$GITHUB_REPOSITORY_NAME" \
191194
--arg prompt "$prompt" \
192195
--arg repository "Automattic/docs-agent" \
193-
--arg revision "$DOCS_AGENT_REVISION" \
196+
--arg revision "$DOCS_AGENT_PACKAGE_REVISION" \
194197
--arg packagePath "$package_path" \
195198
--arg packageDigest "$package_digest" \
196199
--arg agentSlug "$agent_slug" \
@@ -202,7 +205,7 @@ jobs:
202205
--argjson driftChecks "$drift_checks" \
203206
--argjson artifactDeclarations "$artifact_declarations" \
204207
'{schema:"docs-agent/runner-recipe/v1",targetRepository:$targetRepository,prompt:$prompt,docsAgent:{externalPackageSource:{repository:$repository,revision:$revision,path:$packagePath,digest:$packageDigest},agentSlug:$agentSlug},runner:{verificationCommands:$verificationCommands,driftChecks:$driftChecks,writablePaths:$writablePaths,baseRef:$baseRef,docsBranch:$docsBranch,successRequiresPr:$successRequiresPr},artifacts:{expected:($artifactDeclarations|map(.name)),declarations:$artifactDeclarations}}')"
205-
external_package_source="$(jq -cn --arg repository "Automattic/docs-agent" --arg revision "$DOCS_AGENT_REVISION" --arg path "$package_path" --arg digest "$package_digest" '{repository:$repository,revision:$revision,path:$path,digest:$digest}')"
208+
external_package_source="$(jq -cn --arg repository "Automattic/docs-agent" --arg revision "$DOCS_AGENT_PACKAGE_REVISION" --arg path "$package_path" --arg digest "$package_digest" '{repository:$repository,revision:$revision,path:$path,digest:$digest}')"
206209
207210
runner_workspace="$(jq -cn \
208211
--arg repo "$GITHUB_REPOSITORY_NAME" \

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
with:
1818
repository: Automattic/docs-agent
1919
ref: ${{ github.sha }}
20+
fetch-depth: 0
2021
persist-credentials: false
2122

2223
- name: Check out Agents API

.github/workflows/validate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
1416
- name: Checkout WP Codebox producer contract
1517
uses: actions/checkout@v4
1618
with:

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ Docs Agent ships standalone native Agents API packages selected by the reusable
187187
- `bundles/user-docs-agent/native/user-docs-maintenance-agent.agent.json`
188188
- `bundles/skills-agent/native/skills-maintenance-agent.agent.json`
189189

190-
The reusable workflow maps `audience` and `run_kind` to exactly one package and its canonical agent slug. It pins the source to `github.job_workflow_sha`, the immutable commit GitHub used for the called reusable workflow, rejects a missing or non-SHA value, and supplies a byte-level `sha256-bytes-v1` digest.
190+
The reusable workflow maps `audience` and `run_kind` to exactly one package and its canonical agent slug. Every descriptor uses the package-source revision `7b2df969c34de112ec7ad13189ba94226a7f76f3`, independently of the revision that invokes the reusable workflow, and supplies a byte-level `sha256-bytes-v1` digest.
191+
192+
Package updates advance the package-source revision and all five declared digests atomically. The immutable-source validator reads each package blob from that Git revision, recomputes its digest and canonical slug, and rejects a descriptor that does not match those historical bytes.
191193

192194
Each lane also ships native Agents API runtime packages for direct import through `wp_agent_import_runtime_bundles()`: technical docs bootstrap and maintenance, user docs bootstrap and maintenance, and skills maintenance. These packages retain the same source-grounded workspace-only editing boundary and required workspace-write gate as their corresponding bundle lanes.
193195

@@ -216,7 +218,7 @@ php tests/validate-docs-agent-bundle.php
216218
php tests/validate-external-native-package-sources.php
217219
php tests/repair-docs-links-smoke.php
218220
WP_CODEBOX_DIR=/path/to/wp-codebox php tests/validate-wp-codebox-run-agent-task-contract.php
219-
actionlint -config-file .github/actionlint.yaml .github/workflows/*.yml
221+
actionlint .github/workflows/*.yml
220222
git diff --check
221223
```
222224

@@ -228,4 +230,4 @@ AGENTS_API_DIR=/path/to/agents-api php tests/native-agent-import.php
228230

229231
It imports every native package through `wp_agent_import_runtime_bundles()`, verifies registration and preserved write-gate defaults, and invokes the default native chat handler far enough to resolve each registered agent. It intentionally fails when `AGENTS_API_DIR` is unavailable rather than treating an unexecuted importer as a passing test. It does not execute a model turn because the packages intentionally leave provider/model selection to the caller.
230232

231-
The `Docs Agent Tests` GitHub Actions workflow runs on pull requests and pushes. It runs the structural bundle validator, native package descriptor/digest validator, docs-link repair smoke test, and native importer integration test against `Automattic/agents-api` at `5addf598167ec17821954b0f9aa3a9b160b7e36e`.
233+
The `Docs Agent Tests` GitHub Actions workflow runs on pull requests and pushes. It fetches Docs Agent history so it can run the immutable native package source validator, then runs the structural bundle validator, docs-link repair smoke test, and native importer integration test against `Automattic/agents-api` at `5addf598167ec17821954b0f9aa3a9b160b7e36e`.

ci/docs-agent-runner-recipe.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"targetRepository": "OWNER/REPO",
44
"prompt": "Run the technical docs maintenance flow. Update developer-facing living documentation only where source evidence shows stale, missing, fragmented, or misleading coverage.",
55
"docsAgent": {
6-
"repository": "https://github.com/Automattic/docs-agent.git",
7-
"ref": "main",
8-
"bundlePath": "bundles/technical-docs-agent",
9-
"bundlePathInRepo": "bundles/technical-docs-agent",
10-
"agentSlug": "technical-docs-agent",
11-
"pipelineSlug": "technical-docs-pipeline",
12-
"flowSlug": "technical-docs-maintenance-flow"
6+
"externalPackageSource": {
7+
"repository": "Automattic/docs-agent",
8+
"revision": "7b2df969c34de112ec7ad13189ba94226a7f76f3",
9+
"path": "bundles/technical-docs-agent/native/technical-docs-maintenance-agent.agent.json",
10+
"digest": "sha256-bytes-v1:6057aad4eb7c5f0320ccfbce9da93a5fa1d3fc521478b5571ed81c28129325aa"
11+
},
12+
"agentSlug": "technical-docs-maintenance-agent"
1313
},
1414
"runner": {
1515
"verificationCommands": [],

examples/runner-recipe.example.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"targetRepository": "OWNER/REPO",
44
"prompt": "Run the technical docs maintenance flow. Update developer-facing living documentation only where source evidence shows stale, missing, fragmented, or misleading coverage.",
55
"docsAgent": {
6-
"repository": "https://github.com/Automattic/docs-agent.git",
7-
"ref": "v0.1.0",
8-
"bundlePath": "bundles/technical-docs-agent",
9-
"bundlePathInRepo": "bundles/technical-docs-agent",
10-
"agentSlug": "technical-docs-agent",
11-
"pipelineSlug": "technical-docs-pipeline",
12-
"flowSlug": "technical-docs-maintenance-flow"
6+
"externalPackageSource": {
7+
"repository": "Automattic/docs-agent",
8+
"revision": "7b2df969c34de112ec7ad13189ba94226a7f76f3",
9+
"path": "bundles/technical-docs-agent/native/technical-docs-maintenance-agent.agent.json",
10+
"digest": "sha256-bytes-v1:6057aad4eb7c5f0320ccfbce9da93a5fa1d3fc521478b5571ed81c28129325aa"
11+
},
12+
"agentSlug": "technical-docs-maintenance-agent"
1313
},
1414
"runner": {
1515
"verificationCommands": [],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"failed_runs": [29280583288, 29280583450, 29280583504, 29280583286],
3+
"called_workflow_context": {
4+
"job_workflow_sha": ""
5+
},
6+
"expected_package_revision": "7b2df969c34de112ec7ad13189ba94226a7f76f3"
7+
}

tests/validate-docs-agent-bundle.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,16 @@
149149

150150
$assert( 'docs-agent/runner-recipe/v1' === ( $example['schema'] ?? null ), 'Example config must use the portable Docs Agent runner recipe schema.' );
151151
$assert( 'docs-agent/runner-recipe/v1' === ( $recipe['schema'] ?? null ), 'Runner recipe must use the portable Docs Agent runner recipe schema.' );
152-
$assert( 'https://github.com/Automattic/docs-agent.git' === ( $example['docsAgent']['repository'] ?? null ), 'Example config must point docsAgent.repository at Docs Agent.' );
152+
$expected_package_source = array(
153+
'repository' => 'Automattic/docs-agent',
154+
'revision' => '7b2df969c34de112ec7ad13189ba94226a7f76f3',
155+
'path' => 'bundles/technical-docs-agent/native/technical-docs-maintenance-agent.agent.json',
156+
'digest' => 'sha256-bytes-v1:6057aad4eb7c5f0320ccfbce9da93a5fa1d3fc521478b5571ed81c28129325aa',
157+
);
158+
foreach ( array( $recipe, $example ) as $runner_recipe ) {
159+
$assert( $expected_package_source === ( $runner_recipe['docsAgent']['externalPackageSource'] ?? null ), 'Runner recipes must use the immutable Docs Agent package source.' );
160+
$assert( 'technical-docs-maintenance-agent' === ( $runner_recipe['docsAgent']['agentSlug'] ?? null ), 'Runner recipes must use the package agent slug.' );
161+
}
153162

154163
$recipe_text = (string) file_get_contents( $root . '/ci/docs-agent-runner-recipe.json' );
155164
$blocked_runtime_fragments = array( 'wp-codebox', 'Automattic/wp-codebox', 'Extra-Chill/homeboy', 'homeboy-extensions', 'datamachine/', 'datamachine-agent-ci', 'runtime_task_ability', 'runtime_bundle_ability', 'runtime_workflow_ability', 'runtime_components', 'Automattic/agents-api@', 'Extra-Chill/data-machine@', 'Extra-Chill/data-machine-code@', 'workspace_policy', '/wordpress/wp-content/mu-plugins', 'required_abilities', 'disable_datamachine_directives', 'provider: openai', 'OPENAI_API_KEY', 'default_provider', 'default_model' );

0 commit comments

Comments
 (0)