Skip to content

fix(workflows): validate handoff UTF-8 before decoding - #590

Open
ooiuuii wants to merge 1 commit into
openpi-dev:mainfrom
ooiuuii:fix/worktree-handoff-utf8-validation
Open

ooiuuii wants to merge 1 commit into
openpi-dev:mainfrom
ooiuuii:fix/worktree-handoff-utf8-validation

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #588.

The worktree handoff's UTF-8 check mistakes a literal U+FFFD for evidence of a decode failure. Valid patches and untracked/ignored filenames can therefore prevent handoff capture.

Value

Preserve valid text exactly while retaining the existing fail-closed protection against lossy recovery artifacts.

Approach

Read bounded Git stdout as bytes and decode it with TextDecoder in fatal mode, preserving any BOM. Remove the duplicate character heuristic in nulPaths, whose inputs already pass that decoder. Git arguments, deadlines, size caps, manifest schema and cleanup policy are unchanged.

Validation

  • Real Git repository and child-worktree fixtures drive prepareWorktreeHandoff and read the persisted artifact: literal U+FFFD in a tracked patch and in untracked/ignored names each fail before and pass after.
  • An actual invalid 0xff byte in a Git text patch is still refused; no artifact is published and the checkout remains. Existing binary-patch and cleanup tests remain passing.
  • Before: handoff suite 3 pass / 2 fail. After: handoff plus shared-worktree suites 44 pass / 0 fail / 1 existing platform skip.
  • node --experimental-strip-types --test tests/extensions/workflows/worktree-handoff.test.ts tests/extensions/shared/worktree.test.ts, bun run check, git diff --check — pass.
  • Scoped structured review (autoreview --mode local --engine codex --model gpt-6-astra --thinking xhigh --no-web-search): helper exit0, no actionable findings.
  • Source-checkout synthetic fixtures only. Full local suite is not claimed green due previously reproduced host timeout/Windows process-cleanup limitations; fresh branch CI remains the broader gate.

Impact

  • User/model-visible: successful handoff can include legitimate replacement characters without changing their content.
  • Runtime/lifecycle: invalid UTF-8 remains a capture failure; no changes to cleanup or preservation decisions.
  • Persisted config/data: existing manifest format, no migrations or configuration changes.
  • Compatibility/risk: same encoding requirement and byte limits, now checked on original bytes rather than guessed from decoded characters.

@github-actions github-actions Bot added the area:workflows Workflow engine, capability, skills, or tests label Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:workflows Workflow engine, capability, skills, or tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(workflows): valid replacement characters block worktree handoff

1 participant