Skip to content

fix(agent-task): record runner-workspace apply outcome and upload write evidence - #2588

Merged
chubes4 merged 1 commit into
mainfrom
fix/2567-runner-workspace-apply-outcome
Nov 15, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/2567-runner-workspace-apply-outcome

Conversation

@chubes4

@chubes4 chubes4 commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Refs #2567

Summary

Runner-workspace agent writes could disappear with no trace. This PR makes that impossible to miss, and gets write tool calls into the uploaded transcript.

  • Explicit apply outcome: the workflow result now carries workspace_apply (wp-codebox/runner-workspace-apply-outcome/v1). It lists status, applied_paths, rejected_paths with a reason for each, unapplied_paths, declared_changes, and write_tool_calls (attempted, succeeded, failed, paths). It is also kept in the uploaded result.
  • Loud failure instead of a vacuous no_changes: if the sandbox accepted write calls but the canonical patch declared nothing, the run fails at stage: "apply" with status writes-not-applied, and the message lists the lost paths.
  • Sandbox write ledger: WP_Codebox_Sandbox_Workspace_Executor records a content-free entry for each workspace_write/workspace_edit/workspace_apply_patch call (tool, status, error type, workspace-relative paths). The runtime package executor attaches it as metadata.sandbox_workspace_mutations. This is the source of the apply outcome's write counts. It doesn't depend on the pinned agents-api version emitting tool_observability, which the current pin does not do.
  • Every rejected path reported: host apply validation now names every rejected path with a reason, where it used to stop at the first one.
  • One glob semantics on both sides: the sandbox used PHP fnmatch (* works, ** behaves like *). The host used literal prefix matching (* never matches). So patterns like plugins/*/docs/user/** or docs/**/*.md were accepted by the sandbox and then rejected by the host. Both sides now use writablePathMatches / writable_pattern_matches, where ** spans directories and *, ? and [...] stay within one path segment.
  • Transcript upload: the uploader now decodes parsed.output. Tool observability and the write ledger (tool names plus workspace/<path>, never file contents) now reach the uploaded transcript.json.

Root cause

  • Transcript: in the canonical runtime-…/files/transcript.json, the wordpress.run-php execution stores the agent runtime result as a JSON string in parsed.output. projectParsed in .github/scripts/run-agent-task/prepare-agent-task-upload.mjs only read object fields (parsed.agent_runtime, parsed.tool_calls, …), so it produced parsed: {}. That explains the 248-byte projection in the issue.
  • No apply outcome: in .github/scripts/run-agent-task/execute-native-agent-task.mjs, workspaceApply (status and changed files) was only used for gating. It was never projected into the result. A no-op apply with requires_pr: false therefore finished green with nothing recorded.
  • Writable-glob divergence: between writable_path() in class-wp-codebox-sandbox-workspace-executor.php and relativePathMatchesExcludePattern as used by validateChangedFiles in runner-workspace-apply.ts.

I could not pin down which layer dropped the writes in runs 43653766342 and 43717318730, because the evidence this PR adds didn't exist then. I reproduced the exact policy from those runs (plugins/extrachill-shop/docs/user/**, with a new file in new directories) through the real Playground e2e, and it applies correctly on main. So a plain prefix/** glob is not the culprit for those runs. The next run that loses writes will now fail at stage: apply and show which paths were written, rejected or lost. That's why this is Refs, not Fixes.

Tests

  • tests/runner-workspace-apply.test.ts: nested-glob apply (plugins/extrachill-shop/docs/user/**, ./…/, plugins/*/docs/user/**, plugins/**/*.md), the full list of rejected paths with reasons, declaredChanges, and a matcher truth table.
  • scripts/php-sandbox-workspace-executor-smoke.php: ledger contents and reset, the denied-write reason, no contents in the ledger, a nested new-directory write, and the same matcher truth table for parity.
  • tests/runner-workspace-apply-outcome.test.mjs (new): outcome projection for applied / writes-not-applied / rejected / failed-writes / no-op / skipped, plus the tool-observability fallback.
  • tests/runtime-sources-materialization.test.ts: string-encoded parsed.output is decoded; write paths survive; contents, unsafe paths and read tools are dropped; workspace_apply is uploaded.
  • tests/execute-native-agent-task-playground-e2e.test.ts: the real Playground run asserts workspace_apply (applied README.md, ledger source) and the ledger in the uploaded transcript.

Verification

  • npm run check: passed (330 commands).
  • npm run test:integration: 15 of 16 passed. The only failure is tests/mysqli-poll.integration.test.ts, which needs Docker (not available on this host); CI provides it.
  • Reproduced locally with the Playground e2e: a nested workspace_write to plugins/x/docs/user/a.md under plugins/x/docs/user/** is applied, and the ledger records it.

AI assistance: Extra Chill Bot (Claude), via a Roadie subagent.

…te evidence

Runner-workspace agent writes could disappear without any trace: the
workflow result never recorded what apply did, a no-op apply after
successful sandbox writes passed silently, and the uploaded transcript
dropped every tool call because the agent runtime result is a
JSON-encoded string in the canonical execution's parsed.output.

- Sandbox workspace executor keeps a content-free mutation ledger (tool,
  status, error type, target paths) that the runtime package executor
  attaches to the run metadata.
- The workflow result gains workspace_apply
  (wp-codebox/runner-workspace-apply-outcome/v1): applied paths, rejected
  paths with reasons, unapplied paths, and write-call counts. Successful
  writes with a no-op apply now fail at stage "apply" with
  status writes-not-applied instead of a vacuous no_changes.
- Host apply validation reports every rejected path with its reason.
- Host and sandbox writable_paths matching now share one glob semantics
  (`**` spans directories, `*`/`?`/`[...]` stay within a segment), so the
  host never rejects a nested path the sandbox accepted.
- The upload projection decodes parsed.output so tool observability and
  the write ledger (names plus workspace paths, no contents) reach the
  uploaded transcript, and workspace_apply is kept in the uploaded result.

Refs #2567

AI assistance: Extra Chill Bot (Claude), via a Roadie subagent.
@chubes4
chubes4 merged commit ded3cbc into main Nov 15, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant