Repository navigation
fix(agent-task): record runner-workspace apply outcome and upload write evidence - #2588
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
workspace_apply(wp-codebox/runner-workspace-apply-outcome/v1). It listsstatus,applied_paths,rejected_pathswith a reason for each,unapplied_paths,declared_changes, andwrite_tool_calls(attempted, succeeded, failed, paths). It is also kept in the uploaded result.no_changes: if the sandbox accepted write calls but the canonical patch declared nothing, the run fails atstage: "apply"with statuswrites-not-applied, and the message lists the lost paths.WP_Codebox_Sandbox_Workspace_Executorrecords a content-free entry for eachworkspace_write/workspace_edit/workspace_apply_patchcall (tool, status, error type, workspace-relative paths). The runtime package executor attaches it asmetadata.sandbox_workspace_mutations. This is the source of the apply outcome's write counts. It doesn't depend on the pinned agents-api version emittingtool_observability, which the current pin does not do.fnmatch(*works,**behaves like*). The host used literal prefix matching (*never matches). So patterns likeplugins/*/docs/user/**ordocs/**/*.mdwere accepted by the sandbox and then rejected by the host. Both sides now usewritablePathMatches/writable_pattern_matches, where**spans directories and*,?and[...]stay within one path segment.parsed.output. Tool observability and the write ledger (tool names plusworkspace/<path>, never file contents) now reach the uploadedtranscript.json.Root cause
runtime-…/files/transcript.json, thewordpress.run-phpexecution stores the agent runtime result as a JSON string inparsed.output.projectParsedin.github/scripts/run-agent-task/prepare-agent-task-upload.mjsonly read object fields (parsed.agent_runtime,parsed.tool_calls, …), so it producedparsed: {}. That explains the 248-byte projection in the issue..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. Ano-opapply withrequires_pr: falsetherefore finished green with nothing recorded.writable_path()inclass-wp-codebox-sandbox-workspace-executor.phpandrelativePathMatchesExcludePatternas used byvalidateChangedFilesinrunner-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 onmain. So a plainprefix/**glob is not the culprit for those runs. The next run that loses writes will now fail atstage: applyand show which paths were written, rejected or lost. That's why this isRefs, notFixes.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-encodedparsed.outputis decoded; write paths survive; contents, unsafe paths and read tools are dropped;workspace_applyis uploaded.tests/execute-native-agent-task-playground-e2e.test.ts: the real Playground run assertsworkspace_apply(appliedREADME.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 istests/mysqli-poll.integration.test.ts, which needs Docker (not available on this host); CI provides it.workspace_writetoplugins/x/docs/user/a.mdunderplugins/x/docs/user/**is applied, and the ledger records it.AI assistance: Extra Chill Bot (Claude), via a Roadie subagent.